Skip to content

Commit ed2fba3

Browse files
committed
fix(cli): pin resolveWorktrees=true for claude-code installs
The hindsight-memory plugin gained a `resolveWorktrees` flag in hindsight#1520 — when true, the `project` field used in dynamic bank derivation is the main repo basename instead of the cwd basename, so all git worktrees of a repo share a single SDA bank instead of fragmenting memory across one bank per worktree. The plugin already defaults the flag to `true`, but pin it explicitly in the SDA-written config so a future plugin default flip can't silently re-fragment an SDA user's memory. Matches the pattern of how SDA already pins `dynamicBankId`, `dynamicBankGranularity`, and `enableKnowledgeTools`. Test mirror updated + a regression test covering both fresh and explicit-false-overridden cases.
1 parent df0f73b commit ed2fba3

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,11 @@ async function main() {
10931093
ccConfig.dynamicBankId = true;
10941094
ccConfig.dynamicBankGranularity = expectedGranularity;
10951095
ccConfig.enableKnowledgeTools = true;
1096+
// Coalesce all worktrees of a repo into one bank by resolving the
1097+
// `project` field to the main repo basename instead of the cwd basename.
1098+
// Plugin default is already true, but pin it explicitly so future plugin
1099+
// version flips don't fragment a user's memory across worktrees.
1100+
ccConfig.resolveWorktrees = true;
10961101
mkdirSync(ccConfigDir, { recursive: true });
10971102
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
10981103
p.log.success(`Plugin config: ${color.dim(ccConfigPath)}`);

src/tests/cli.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,9 @@ describe("claude-code Hindsight config persistence", () => {
833833
hindsightApiUrl: prompted.apiUrl,
834834
hindsightApiToken: prompted.apiToken,
835835
enableKnowledgeTools: true,
836+
// Pin worktree resolution so all worktrees of a repo land in the same
837+
// bank, matching what cli.ts writes during the claude-code install flow.
838+
resolveWorktrees: true,
836839
};
837840
}
838841

@@ -873,4 +876,16 @@ describe("claude-code Hindsight config persistence", () => {
873876
);
874877
expect(result.enableKnowledgeTools).toBe(true);
875878
});
879+
880+
it("always pins resolveWorktrees=true so worktrees share one bank", () => {
881+
// Plugin already defaults to true, but SDA pins it explicitly so a future
882+
// plugin default flip can't fragment a user's memory across worktrees.
883+
const fresh = applyClaudeConfig({}, { apiUrl: "https://x.com", apiToken: "t" });
884+
expect(fresh.resolveWorktrees).toBe(true);
885+
const overridden = applyClaudeConfig(
886+
{ resolveWorktrees: false },
887+
{ apiUrl: "https://x.com", apiToken: "t" }
888+
);
889+
expect(overridden.resolveWorktrees).toBe(true);
890+
});
876891
});

0 commit comments

Comments
 (0)