inject-subagent-context hook finds the nearest .git instead of the Trellis root
Author: wl336Created Sep 24, 2026Updated Sep 24, 2026
Summary
shared-hooks/inject-subagent-context.py locates the project with find_repo_root, which walks up to the nearest .git. Everything else in Trellis (common/paths.py get_repo_root) walks up to the nearest .trellis. In a polyrepo layout (a .trellis root that is not itself a git repository, with child packages that are), the hook either finds no root, so implement/check/research dispatches get no injected context, or finds a child package's repo, where .trellis/tasks does not exist.
Reproduction (main @ e77ae89)
mkdir -p /tmp/poly/.trellis/tasks/09-23-demo /tmp/poly/packages/app
git -C /tmp/poly/packages/app init# from packages/cli/src/templates
hook.find_repo_root("/tmp/poly") # -> None
hook.find_repo_root("/tmp/poly/packages/app") # -> /tmp/poly/packages/app
paths.get_repo_root(Path("/tmp/poly")) # -> /tmp/poly
paths.get_repo_root(Path("/tmp/poly/packages/app")) # -> /tmp/polyProposed fix
Mirror get_repo_root: search upward for the directory containing .trellis:
def find_repo_root(start_path: str) -> str | None:
"""Find the nearest ancestor containing a .trellis directory."""
current = Path(start_path).resolve()
while current != current.parent:
if (current / ".trellis").is_dir():
return str(current)
current = current.parent
return NoneSource: mindfold-ai/Trellis