fix(cc-config): .claude.json sits BESIDE ~/.claude by default, not inside it
The previous commit routed the read through getClaudeHome(), which appends /.claude when CLAUDE_HOME is unset — pointing the dashboard at ~/.claude/.claude.json, a file the CLI never writes by default. Verified against the real binary: with CLAUDE_CONFIG_DIR unset the CLI writes $HOME/.claude.json; with it set, .claude.json sits flat inside that dir. Branch on CLAUDE_HOME accordingly. The test now drives a fake claude that writes where the real one does and asserts getClaudeJsonPath() names that exact file, under both branches — the previous test only restated the implementation.
This commit is contained in:
@@ -29,13 +29,21 @@ function getProjectClaudeDir(cwd) {
|
||||
}
|
||||
|
||||
function getClaudeJsonPath() {
|
||||
// One root for everything: this file used to resolve from $HOME while the
|
||||
// other 19 read paths derived from getClaudeHome(), and cc-plugin-cli.js's
|
||||
// runClaude() pinned CLAUDE_CONFIG_DIR to getClaudeHome() — which is where
|
||||
// the CLI puts .claude.json. The dashboard read one file and made the CLI
|
||||
// write another, so MCP add/remove was inert. Keep this and runClaude's
|
||||
// env in step; they are the same decision seen from two sides.
|
||||
return path.join(getClaudeHome(), ".claude.json");
|
||||
// NOT path.join(getClaudeHome(), ".claude.json") — verified against the
|
||||
// real `claude` binary, the two CLAUDE_HOME branches behave differently:
|
||||
// - CLAUDE_HOME set: the CLI's CLAUDE_CONFIG_DIR (pinned to it by
|
||||
// cc-plugin-cli.js's runClaude()) becomes a $HOME-substitute for both
|
||||
// `.claude.json` AND the rest of the tree (projects/, settings.json,
|
||||
// plugins/) — flat inside it, no nested ".claude". Same value
|
||||
// getClaudeHome() returns in this branch, so the two formulas agree.
|
||||
// - CLAUDE_HOME unset: runClaude() deliberately leaves CLAUDE_CONFIG_DIR
|
||||
// unset too, and the CLI's OWN default writes `.claude.json` BESIDE
|
||||
// `~/.claude`, not inside it — while getClaudeHome()'s unset branch
|
||||
// appends "/.claude". Delegating to getClaudeHome() here would read
|
||||
// `~/.claude/.claude.json`, a file the CLI never writes by default.
|
||||
return process.env.CLAUDE_HOME
|
||||
? path.join(process.env.CLAUDE_HOME, ".claude.json")
|
||||
: path.join(os.homedir(), ".claude.json");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user