Skip to content

Use working directory as project root instead of marker-based detection#46

Merged
gregology merged 1 commit intomainfrom
fix-project-root-use-cwd
Mar 10, 2026
Merged

Use working directory as project root instead of marker-based detection#46
gregology merged 1 commit intomainfrom
fix-project-root-use-cwd

Conversation

@gregology
Copy link
Copy Markdown
Owner

Summary

Fixes #44. findProjectRoot was walking up from the target file looking for markers like .git, pyproject.toml, Makefile, etc. In monorepos where a subdirectory has its own pyproject.toml, it'd stop there and never reach the actual root. So the root AGENTS.yaml just vanished.

The fix: stop guessing. Use the working directory instead of marker detection.

  • Hook mode (sctx hook): uses the cwd field from Claude Code's JSON input, which is the directory where claude was launched
  • CLI mode (sctx context, sctx decisions): uses os.Getwd(), so wherever you run sctx from is the root

findProjectRoot is deleted entirely. No fallback to markers. The root is always explicit and predictable.

Changes:

  • Added Root field to ResolveRequest
  • Resolve() uses req.Root when set, falls back to os.Getwd()
  • Claude adapter passes hookInput.CWD as Root
  • Removed findProjectRoot() and all .git marker files from tests
  • Updated protocol.md, README, and cli-reference docs

@gregology gregology merged commit df1665e into main Mar 10, 2026
2 checks passed
@gregology gregology deleted the fix-project-root-use-cwd branch March 10, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

findProjectRoot stops at subdirectory markers like pyproject.toml, never reaching the actual repo root

1 participant