fix(cc-config): read .claude.json from the same root the CLI writes it to

getClaudeJsonPath() was the only one of cc-discovery's 20 read paths not
derived from getClaudeHome(), so a CLAUDE_HOME install read one file while
the CLI wrote another. The default case was fixed by dropping the
CLAUDE_CONFIG_DIR pin; this closes the mirrored half.

Also replaces the Remove button's display-string comparison with a
removable flag from the reader: rewording the source label silently
resurrected a button that always fails.
This commit is contained in:
2026-09-09 09:54:27 +07:00
parent 0ad4b8c920
commit 17e4321761
4 changed files with 48 additions and 14 deletions
+23
View File
@@ -224,6 +224,29 @@ describe("cc-plugin-cli CLAUDE_CONFIG_DIR pinning", () => {
else process.env.CLAUDE_HOME = originalHome;
}
});
// The two env tests above pin one half each. This pins the pair: the file
// the dashboard READS must be the file the CLI WRITES, under both settings.
// `.claude.json` was the only read path in cc-discovery not derived from
// getClaudeHome(), which is exactly how the two halves drifted apart.
it("reads the same .claude.json the CLI writes, with CLAUDE_HOME set or unset", () => {
const cc = require("../lib/cc-discovery");
const originalHome = process.env.CLAUDE_HOME;
// CLI's write target = <CLAUDE_CONFIG_DIR>/.claude.json, and
// CLAUDE_CONFIG_DIR is either CLAUDE_HOME or the CLI's own default,
// which is the same directory getClaudeHome() returns.
try {
delete process.env.CLAUDE_HOME;
assert.equal(cc.getClaudeJsonPath(), path.join(os.homedir(), ".claude", ".claude.json"));
process.env.CLAUDE_HOME = "/tmp/some-other-claude-home";
assert.equal(cc.getClaudeJsonPath(), "/tmp/some-other-claude-home/.claude.json");
} finally {
if (originalHome === undefined) delete process.env.CLAUDE_HOME;
else process.env.CLAUDE_HOME = originalHome;
}
});
});
describe("cc-plugin-cli run outcomes", () => {