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

This commit is contained in:
2026-12-03 18:56:28 +01:00
parent 20c83f861f
commit 1ca2c8efe0
142 changed files with 1095 additions and 933 deletions
+12 -9
View File
@@ -3,10 +3,11 @@
usage: project-config [<setting>]
Run inside a checkout, or a worktree of one. It finds the config that names the checkout,
~/.claude-projects/<key>/config.toml, and prints each setting and its absolute path, as in
~/.config/build-release/<key>/config.toml, and prints each setting and its absolute path, as in
`plan: /home/me/code/acme/todo.md`. Given a setting, it prints only that setting's path.
Where XDG_CONFIG_HOME is set, the configs are in $XDG_CONFIG_HOME/build-release/ instead.
`~/.claude-projects/do-epic/` holds do-epic's machine-wide settings, not a project's. It needs no `checkout`,
`~/.config/build-release/do-epic/` holds do-epic's machine-wide settings, not a project's. It needs no `checkout`,
and project-config doesn't read anything from it, so no project may use `do-epic` as its key.
The config is TOML. `checkout` names the project's main checkout, and every setting in the example below is a path:
@@ -74,7 +75,7 @@ rule-hook ranks a plan kept as a file before tool calls, and a read from Conflue
`env-file` is an optional setting: the file of KEY=value credentials the project's tools read,
a path that starts with / or ~/ and lies outside the checkout and the config's folder, such as
"~/.claude-projects/acme-billing.env". Where it is left out, the project has no credentials file, and
"~/.config/build-release/acme-billing.env". Where it is left out, the project has no credentials file, and
a tool that needs one fails naming the setting. It is printed with the others only where it is set.
`touch-predictions` is an optional setting, a path spelt as the others are, never a page: the record
@@ -179,6 +180,8 @@ one of those two without a `plan` in Jira, sets the formula to one that doesn't
but a number, sets `readability-floor` to anything but a number
from 1 to 10, sets `parallel-chunks` to anything but a whole number of 1 or more, or sets `jira-finding-type` to anything but a name or without a `plan` in Jira, and where `bench-tasks`, `coding-conventions`, `env-file`, `epic-branch`, `jira-finish-transition`, `jira-finish-status`, `notifier`, `review-request-comment` or `touch-predictions` is asked for and not set. No path setting has a default.
"""
from collections.abc import Mapping
import os
import pathlib
import sys
@@ -195,7 +198,7 @@ def main(argv: list[str]) -> int:
if len(argv) > 1 or (argv and argv[0] not in (*SETTINGS, *OPTIONAL)):
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join((*SETTINGS, *OPTIONAL))}", file=sys.stderr)
return 1
config = located(None, pathlib.Path.home())
config = located(None, pathlib.Path.home(), os.environ)
if isinstance(config, Failure):
print(config.reason, file=sys.stderr)
return 1
@@ -216,7 +219,7 @@ def main(argv: list[str]) -> int:
return 0
def located(directory: str | None, home: pathlib.Path, run: Git = git) -> ProjectConfig | Failure:
def located(directory: str | None, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> ProjectConfig | Failure:
"""The config under home of the checkout that holds directory, else the current directory."""
found = run("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir", cwd=directory)
if isinstance(found, Failure):
@@ -224,12 +227,12 @@ def located(directory: str | None, home: pathlib.Path, run: Git = git) -> Projec
if len(lines := found.splitlines()) != 2:
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
# The common dir is the main checkout's .git, whichever worktree runs this.
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, home)
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, home, env)
def title_templates(directory: str | None, home: pathlib.Path, run: Git = git) -> templates.Titles | Failure:
def title_templates(directory: str | None, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> templates.Titles | Failure:
"""The title templates of the project whose checkout holds directory, else the current directory. Bare summaries where no config names a checkout there, as in a third party's clone, so every title is read as it stands. A Failure where a config is faulty or cannot be read: read bare, a templated project's round titles would count for nothing."""
config = located(directory, home, run)
config = located(directory, home, env, run)
if isinstance(config, Unnamed):
return templates.BARE
return config if isinstance(config, Failure) else config.titles
@@ -237,5 +240,5 @@ def title_templates(directory: str | None, home: pathlib.Path, run: Git = git) -
def project() -> ProjectConfig | Failure:
"""The config of the project whose checkout holds the current directory, under the user's home."""
return located(None, pathlib.Path.home())
return located(None, pathlib.Path.home(), os.environ)