You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0d2f840
Browse filesBrowse the repository at this point in the historyBrowse files
feat(config): add ignore_worktrees to skip linked git worktrees
Agents that use `git worktree add` to run parallel branches end up with one
indexed project per worktree. Each is a near-duplicate of the main checkout,
so the cache fills with redundant graphs and project pickers get noisy.
Add an opt-in `ignore_worktrees` config key. When enabled, a linked worktree
is left alone:
- auto-index on connect skips it (logged as autoindex.skip)
- the daemon's background auto-index skips it
- explicit index_repository refuses with an actionable message naming both
ways forward (index_worktree=true, or turn the key off)
- the hook-augment "not indexed" guidance stops telling the agent to run
index_repository in a directory where it would only be refused
Detection is git plumbing, no subprocess: <path>/.git must be a regular file
holding a "gitdir:" pointer AND that gitdir must contain a `commondir` file.
The commondir check is what separates a linked worktree from a submodule,
whose .git is also a gitlink file but whose gitdir has no commondir. The main
checkout of a repo that has worktrees is never affected.
Defaults to false, so behaviour is unchanged unless the key is set.
Signed-off-by: Nohj <vitalnohj@gmail.com>
Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,8 @@ Watcher registration is controlled separately by `auto_watch` (default `true`).
155
155
156
156
To turn the watcher off entirely, set `config set watcher_enabled false` (default `true`): the background poll thread never starts and no project is registered, while `auto_index` and manual `index_repository` keep working. Unlike `auto_watch` — which is consulted per session — `watcher_enabled` is read once when the background daemon starts, so run `codebase-memory-mcp daemon stop` after changing it; reconnecting your MCP client alone will not restart the daemon. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#2-cli-managed-runtime-settings).
157
157
158
+
Linked git worktrees are indexed as their own projects by default. Set `config set ignore_worktrees true` to skip them on the automatic paths — useful when short-lived `git worktree add` checkouts would otherwise each leave behind a permanent index of the same repository. An explicit `index_repository` call on a worktree is then refused unless you pass `index_worktree=true`. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#ignore_worktrees).
159
+
158
160
### Keeping Up to Date
159
161
160
162
**Updates run from the install script on every platform, not from inside the running binary.**`codebase-memory-mcp update` validates your flags and then prints the exact command to run:
@@ -735,6 +737,7 @@ codebase-memory-mcp config list # show all settings
735
737
codebase-memory-mcp config set auto_index true# auto-index on session start
736
738
codebase-memory-mcp config set auto_index_limit 50000 # max files for auto-index
|`auto_watch`|`true`| Register the session's project with the background git watcher on connect. Set `false` to keep a session from registering its project (the watcher still runs for other projects). |
91
92
|`watcher_enabled`|`true`| Master switch for the background watcher subsystem. Set `false` to stop the watcher from starting at all — no poll thread and no project registration. Reindex manually with `index_repository` when disabled. |
92
93
|`index_max_files`|`off`| Optional maximum number of accepted source files in one discovery run. |
@@ -126,6 +127,35 @@ and preserves any previously serving database. See
126
127
[Index resource limits](INDEX_RESOURCE_LIMITS.md) for counting, validation, and
127
128
error-response details.
128
129
130
+
### `ignore_worktrees`
131
+
132
+
Every indexed project is registered under its own absolute root path, so each
133
+
linked worktree becomes a separate permanent index. On machines that create many
134
+
short-lived worktrees, the automatic paths (`auto_index`, and the session hook's
135
+
"index this project first" guidance) turn every throwaway checkout into another
136
+
stored index of what is largely the same repository.
137
+
138
+
Enable the key to keep those checkouts out of the index:
139
+
140
+
```bash
141
+
codebase-memory-mcp config set ignore_worktrees true
142
+
```
143
+
144
+
With it enabled:
145
+
146
+
- automatic indexing skips a session whose root is a linked worktree;
147
+
- the `hook-augment` context says the worktree is unindexed on purpose instead
148
+
of telling the agent to run `index_repository`;
149
+
- an explicit `index_repository` call on a linked worktree is refused, and names
150
+
both ways forward — pass `index_worktree=true` for that one call, or turn the
151
+
key back off.
152
+
153
+
The main checkout of the same repository is unaffected, as are ordinary clones
154
+
and submodules. Detection is git plumbing only: a linked worktree's `.git` is a
155
+
file pointing at a gitdir that contains a `commondir` entry.
156
+
157
+
The default is `false`, so indexing behavior is unchanged unless you opt in.
158
+
129
159
## 3. UI Settings
130
160
131
161
The optional built-in graph UI stores its settings in:
0 commit comments