Put the release's tools on PATH of every claude the loop starts, and name them bare in the prose
CI / tests (pull_request) Successful in 4m36s
CI / tests (pull_request) Successful in 4m36s
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import dataclasses
|
||||
from collections.abc import Mapping
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
# The release root: the folder the running code ships in, with bin/, skills/ and agents/.
|
||||
@@ -17,6 +18,15 @@ CONFIG_FOLDER = ".claude-projects"
|
||||
STATE_FOLDER = ".local/state"
|
||||
|
||||
|
||||
def with_release_tools(env: Mapping[str, str]) -> dict[str, str]:
|
||||
"""env with the release's tools first on `PATH`: what every claude the loop starts runs in, so its Bash tool and its hooks find each tool by its bare name."""
|
||||
tools = str(RELEASE_ROOT / "bin")
|
||||
rest = env.get("PATH", "")
|
||||
if rest.split(os.pathsep)[0] == tools:
|
||||
return dict(env)
|
||||
return {**env, "PATH": f"{tools}{os.pathsep}{rest}" if rest else tools}
|
||||
|
||||
|
||||
def state_folder(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
|
||||
"""The state folder of a tool that honours `XDG_STATE_HOME`."""
|
||||
return pathlib.Path(env.get("XDG_STATE_HOME") or home / STATE_FOLDER)
|
||||
|
||||
Reference in New Issue
Block a user