Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Read a routing ladder from its JSON file: the one this setup ships, or a project's own, kept in its config's folder. docs/decisions.md → `routing: one ladder of (model, effort) rungs`."""
|
||||
import json
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
@@ -17,9 +18,9 @@ MODEL = re.compile(r"[^\s-]+(-[^\s-]+)+")
|
||||
SHAPE = f'a JSON list of rungs, least competent first, each as {{"model": "claude-opus-5-5", "effort": "medium"}}: a model\'s full name, one model for each family such as opus, and an effort of {", ".join(EFFORTS[:-1])} or {EFFORTS[-1]}'
|
||||
|
||||
|
||||
def project_ladder_file(directory: str | None, home: pathlib.Path, shipped: pathlib.Path = SHIPPED) -> pathlib.Path | Failure:
|
||||
def project_ladder_file(directory: str | None, home: pathlib.Path, env: Mapping[str, str], shipped: pathlib.Path = SHIPPED) -> pathlib.Path | Failure:
|
||||
"""The file that holds the ladder of the project whose checkout holds directory, else the current directory: the file NAME in its config's folder under home, or shipped where that folder holds none. Also shipped where no config names a checkout there, or git fails there. A Failure where the project's config is faulty or cannot be read, since its folder may hold the ladder."""
|
||||
config = located(directory, home)
|
||||
config = located(directory, home, env)
|
||||
if isinstance(config, Unnamed):
|
||||
return shipped
|
||||
if isinstance(config, Failure):
|
||||
@@ -28,9 +29,9 @@ def project_ladder_file(directory: str | None, home: pathlib.Path, shipped: path
|
||||
return own if own.exists() else shipped
|
||||
|
||||
|
||||
def project_ladder(directory: str | None, home: pathlib.Path, shipped: pathlib.Path = SHIPPED) -> Ladder | Failure:
|
||||
def project_ladder(directory: str | None, home: pathlib.Path, env: Mapping[str, str], shipped: pathlib.Path = SHIPPED) -> Ladder | Failure:
|
||||
"""The ladder project_ladder_file's file holds. A Failure where that file holds a fault too: the shipped ladder never stands in for a project's own, since work routed on it could run on a model the project cannot reach."""
|
||||
file = project_ladder_file(directory, home, shipped)
|
||||
file = project_ladder_file(directory, home, env, shipped)
|
||||
return file if isinstance(file, Failure) else read_ladder(file)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user