Skip to content

feat(cli): default search repo to git root - #154

Merged
joshuaboys merged 3 commits into
mainfrom
feat/cli-repo-autodetect
Oct 20, 2026
Merged

joshuaboys merged 3 commits into
mainfrom
feat/cli-repo-autodetect

Conversation

@joshuaboys

Copy link
Copy Markdown
Contributor

Summary

Implements C3 (workspace auto-detect for the CLI search default repo).

  • New crates/kindling/src/git.rs: repo_root_from(dir) / repo_root_from_cwd() via git rev-parse --show-toplevel, failing open (non-git dir, missing dir or no git gives None). The hook's project-root probe now reuses it, with identical behaviour.
  • New commands::resolve_repo(explicit, all_repos) with deterministic precedence: explicit --repo > --all-repos (no filter) > detected git root > no filter. Kept separate from search so C7 (search filters) can build on it.
  • kindling search: defaults scopeIds.repoId to the git root when --repo is omitted; new --all-repos flag searches everything (conflicts with --repo). Text output prints the applied repo scope; --json already records it in provenance.scopeIds.
  • kindling log and kindling capsule open default their recorded repo scope to the same root, so log then search in a git repo still round-trips (otherwise CLI-logged observations, stored with no repoId, would vanish from default searches).
  • kindling demo's suggested search now passes --all-repos, since demo memory uses its own sample repo ID.
  • Docs: quickstart, both READMEs and the CHANGELOG [Unreleased] section.

Claude Code hook stdin/stdout interface is unchanged. Retrieval stays deterministic (a single exact repo_id = filter, no fallback).

Known limitation

Hook-captured observations store the raw hook cwd as repoId (Node parity). When Claude Code runs from the repo root this matches the detected root; sessions started in a subdirectory would need --repo <that dir> or --all-repos.

Testing

  • Unit tests: git detection at root, nested dir, non-git dir, missing dir, linked worktree (reports its own root); resolver precedence.
  • CLI tests (tests/cli.rs): default scoping from root and nested dir, explicit --repo override, --all-repos, --repo + --all-repos rejected, text output names the scope, log defaults repo and is found by search, non-git dir applies no filter. Confirmed the default-scoping tests fail against the old search.rs.
  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test all pass locally.

🤖 Generated with Claude Code

Without --repo, kindling search now scopes to the enclosing git
working-tree root (git rev-parse --show-toplevel), from any
subdirectory, and applies no repo filter outside git. A new
--all-repos flag searches every repository; an explicit --repo always
wins and conflicts with --all-repos.

log and capsule open default their recorded repo scope to the same
root so CLI round trips keep working. Detection lives in a reusable
git module (shared with the hook's project-root probe) and a
resolve_repo helper that later search filters can build on.

The demo's suggested search passes --all-repos because demo memory
has its own sample repo ID.
git prints forward slashes on Windows while the hook records Claude
Code's raw cwd (backslashes) as an observation's repoId, so the
auto-detected default would never match hook-captured data. Convert
the CLI default to native separators. The hook's project-root routing
keeps git's raw output so per-project DB paths are unchanged.
@joshuaboys
joshuaboys force-pushed the feat/cli-repo-autodetect branch from 8052068 to 05865f2 Compare October 20, 2026 16:34
joshuaboys added a commit that referenced this pull request Oct 20, 2026
Mark C1, C2 and C4 merged (PRs #152, #155, #153), C3 in review
(#154), and PUBDIR-001/002 in review as draft PR #151. Log ISS-004
for daemons leaked by the thin-client and adapter test suites.
@joshuaboys
joshuaboys merged commit 521ba84 into main Oct 20, 2026
27 checks passed
@joshuaboys
joshuaboys deleted the feat/cli-repo-autodetect branch October 20, 2026 16:39
joshuaboys added a commit that referenced this pull request Oct 20, 2026
PR #154 merged: search defaults to the git root, with Windows
separator parity against hook-captured repo ids.
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.

1 participant