Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When running in a git worktree, repoRoot() returns the worktree directory instead of the main repo root. This causes the QMD collection name to differ per worktree, ghost status to report the collection as missing, and .ai-sessions/ to be created inside the worktree (lost on cleanup). Add mainRepoRoot() which uses git rev-parse --git-common-dir to resolve the main repo root. Use it for session storage, QMD collection naming, and all session/knowledge CLI commands. Keep repoRoot() for worktree-local config files (.claude/settings.json, .mcp.json, CLAUDE.md) placed by ghost enable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that mainRepoRoot() returns the main repo from worktrees, sessions created from worktrees are stored in the main repo, collection names are stable across worktrees, and ghost enable from a worktree places config locally but sessions in the main repo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Git Worktrees section to README explaining storage behavior and the two approaches for getting hooks into worktrees (commit config files vs run ghost enable per worktree). Note the implication for Claude Code's automatic worktrees. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainRepoRoot()to resolve the main repo root viagit rev-parse --git-common-dir, even when running inside a worktree.ai-sessions/), QMD collection naming, git hooks, and knowledge files now always target the main repo rootghost enablefrom a worktree places config files (.claude/settings.json,.mcp.json) locally but stores everything else in the main repoghost enableper worktreeFixes #4
Test plan
src/git.test.ts—mainRepoRoot()returns main repo from worktrees, matchesrepoRoot()in normal repossrc/hooks.test.ts— sessions created/ended/written from worktree stored in main reposrc/setup.test.ts—enablefrom worktree, stable collection names, hooks/gitignore in main repo🤖 Generated with Claude Code