mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-29 23:37:41 +00:00
* fix(setup): honour CLAUDE_CONFIG_DIR for Claude Code config paths With CLAUDE_CONFIG_DIR set, Claude Code reads its user-scope MCP servers from $CLAUDE_CONFIG_DIR/.claude.json and its settings, skills and hooks from $CLAUDE_CONFIG_DIR. setup and uninstall hardcoded ~/.claude.json and ~/.claude/, so on a relocated install the MCP entry, skills and hooks landed where Claude Code never looks, or setup reported Claude Code as "not installed" when ~/.claude did not exist. Add claudeConfigPaths() to editor-targets and route every Claude path the factory builds through it; setup's two presence gates use the same root. uninstall only goes through the factory, so it follows automatically. Empty means unset; a relative value resolves against the cwd. vitest pins CLAUDE_CONFIG_DIR to '' so a developer's own value cannot point the HOME-sandboxed setup tests at their real Claude config. * docs(changelog): drop the Unreleased entry for CLAUDE_CONFIG_DIR CHANGELOG.md is owned by the release process (DoD.md 4.5); the README note and the PR title carry the change into the release notes. * test(setup): pin that getEditorTargets reads CODEX_HOME from the injected env Resolving the conflict with #3460 moved the CODEX_HOME lookup from process.env to the env parameter. Nothing asserted that: the existing "other editors stay on HOME" case compares two calls that would both read the process value. Reverting the lookup to process.env fails this case. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Gergő Magyar <gergomagyar@icloud.com> Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
73 lines
3 KiB
TypeScript
73 lines
3 KiB
TypeScript
import path from 'path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
claudeConfigPaths,
|
|
getEditorTargets,
|
|
hookTarget,
|
|
mcpTarget,
|
|
skillTarget,
|
|
} from '../../src/cli/editor-targets.js';
|
|
|
|
const HOME = path.resolve('/home/user');
|
|
|
|
describe('claudeConfigPaths', () => {
|
|
it('defaults to ~/.claude with the MCP file beside it in HOME', () => {
|
|
expect(claudeConfigPaths(HOME, {})).toEqual({
|
|
dir: path.join(HOME, '.claude'),
|
|
mcpFile: path.join(HOME, '.claude.json'),
|
|
});
|
|
});
|
|
|
|
it('moves both the config dir and .claude.json under CLAUDE_CONFIG_DIR', () => {
|
|
const relocated = path.resolve('/cfg/claude');
|
|
expect(claudeConfigPaths(HOME, { CLAUDE_CONFIG_DIR: relocated })).toEqual({
|
|
dir: relocated,
|
|
mcpFile: path.join(relocated, '.claude.json'),
|
|
});
|
|
});
|
|
|
|
it('treats an empty CLAUDE_CONFIG_DIR as unset', () => {
|
|
expect(claudeConfigPaths(HOME, { CLAUDE_CONFIG_DIR: '' })).toEqual(claudeConfigPaths(HOME, {}));
|
|
});
|
|
|
|
it('resolves a relative CLAUDE_CONFIG_DIR against the working directory', () => {
|
|
const { dir, mcpFile } = claudeConfigPaths(HOME, { CLAUDE_CONFIG_DIR: 'rel/claude' });
|
|
expect(dir).toBe(path.resolve('rel/claude'));
|
|
expect(mcpFile).toBe(path.join(path.resolve('rel/claude'), '.claude.json'));
|
|
});
|
|
});
|
|
|
|
describe('getEditorTargets — Claude Code under CLAUDE_CONFIG_DIR', () => {
|
|
const relocated = path.resolve('/cfg/claude');
|
|
const env = { CLAUDE_CONFIG_DIR: relocated };
|
|
|
|
it('routes the MCP file, skills, settings and hook scripts to the relocated root', () => {
|
|
expect(mcpTarget('claude', HOME, env).file).toBe(path.join(relocated, '.claude.json'));
|
|
expect(skillTarget('claude', HOME, env).dir).toBe(path.join(relocated, 'skills'));
|
|
const hooks = hookTarget('claude', HOME, env);
|
|
expect(hooks.settingsFile).toBe(path.join(relocated, 'settings.json'));
|
|
expect(hooks.scriptDir).toBe(path.join(relocated, 'hooks', 'gitnexus'));
|
|
});
|
|
|
|
it('leaves every other editor rooted at HOME', () => {
|
|
const relocatedTargets = getEditorTargets(HOME, env);
|
|
const defaultTargets = getEditorTargets(HOME, {});
|
|
const others = <T extends { id: string }>(list: T[]) => list.filter((t) => t.id !== 'claude');
|
|
expect(others(relocatedTargets.mcpJsonc)).toEqual(others(defaultTargets.mcpJsonc));
|
|
expect(others(relocatedTargets.skills)).toEqual(others(defaultTargets.skills));
|
|
expect(others(relocatedTargets.hooks)).toEqual(others(defaultTargets.hooks));
|
|
expect(relocatedTargets.codex).toEqual(defaultTargets.codex);
|
|
});
|
|
});
|
|
|
|
describe('getEditorTargets — Codex under CODEX_HOME', () => {
|
|
it('takes CODEX_HOME from the injected environment, like CLAUDE_CONFIG_DIR', () => {
|
|
const codexHome = path.resolve('/cfg/codex');
|
|
expect(getEditorTargets(HOME, { CODEX_HOME: codexHome }).codex.configFile).toBe(
|
|
path.join(codexHome, 'config.toml'),
|
|
);
|
|
expect(getEditorTargets(HOME, {}).codex.configFile).toBe(
|
|
path.join(HOME, '.codex', 'config.toml'),
|
|
);
|
|
});
|
|
});
|