Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(hooks): keep ~/.claude eligible as project sharing root with CLAUDE_CONFIG_DIR

drakeo338334b7847bd4e
diff --git a/scripts/lib/agent-data-home.js b/scripts/lib/agent-data-home.js
index 6859b4947..98cd0a84b 100644
--- a/scripts/lib/agent-data-home.js
+++ b/scripts/lib/agent-data-home.js
@@ -116,6 +116,8 @@ function resolveAllowedProjectConfigHome(candidate) {
const allowedRoots = [
getDefaultCursorAgentDataHome(),
getDefaultClaudeAgentDataHome(),
+ // Keep ~/.claude eligible when CLAUDE_CONFIG_DIR points elsewhere.
+ path.join(getHomeDirFromEnv(), DEFAULT_CLAUDE_DIR_NAME),
];
for (const allowedRoot of allowedRoots) {
diff --git a/tests/lib/agent-data-home.test.js b/tests/lib/agent-data-home.test.js
index b97b7bc6d..61b866096 100644
--- a/tests/lib/agent-data-home.test.js
+++ b/tests/lib/agent-data-home.test.js
@@ -91,6 +91,7 @@ function runTests() {
withIsolatedCwd(() => {
withEnv({
ECC_AGENT_DATA_HOME: undefined,
+ CLAUDE_CONFIG_DIR: undefined,
CURSOR_VERSION: undefined,
CURSOR_PROJECT_DIR: undefined,
}, () => {
@@ -534,6 +535,29 @@ function runTests() {
});
})) passed++; else failed++;
+ if (test('project config may select ~/.claude/shared when CLAUDE_CONFIG_DIR points elsewhere', () => {
+ const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-agent-data-home-claude-root-'));
+ const projectDir = path.join(homeDir, 'project');
+ const configPath = path.join(projectDir, '.cursor', 'ecc-agent-data.json');
+ const sharedHome = path.join(homeDir, '.claude', 'shared');
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
+ fs.writeFileSync(configPath, JSON.stringify({ agentDataHome: sharedHome }), 'utf8');
+
+ try {
+ withEnv({
+ ECC_AGENT_DATA_HOME: undefined,
+ CLAUDE_CONFIG_DIR: path.join(homeDir, 'custom-claude-profile'),
+ HOME: homeDir,
+ USERPROFILE: undefined,
+ }, () => {
+ const agentDataHome = require('../../scripts/lib/agent-data-home');
+ assert.strictEqual(agentDataHome.readProjectConfigAt(configPath), sharedHome);
+ });
+ } finally {
+ fs.rmSync(homeDir, { recursive: true, force: true });
+ }
+ })) passed++; else failed++;
+
if (test('ensureAgentDataHomeEnv sets process.env when unset', () => {
withEnv({
ECC_AGENT_DATA_HOME: undefined,