mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-11 02:33:10 +08:00
* feat: auto-isolate ECC memory data for Cursor via ECC_AGENT_DATA_HOME Add ECC_AGENT_DATA_HOME (defaults to ~/.claude) with Cursor-aware resolution, sessionStart env injection, install scaffolds, and hook bootstrap so memory hooks do not collide with Claude Code when both harnesses are used. Closes #2065 Co-authored-by: Cursor <cursoragent@cursor.com> * fix: log agent-data config errors and ship cursor sessionStart deps Address CodeRabbit review: log invalid .cursor/ecc-agent-data.json parse failures, and copy cursor-session-env.js plus lib deps on legacy Cursor install so sessionStart hook path exists without hooks-runtime alone. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: resolve relative agentDataHome paths from project root Project config values like ".ecc-data" now resolve against the repository root (parent of .cursor/), not process.cwd(), so Cursor hooks persist memory in the intended directory regardless of hook cwd. Addresses cubic review on PR #2066. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: explain getHomeDir duplicate and docstring policy Document why agent-data-home keeps a local home-dir helper (circular require with utils.js) and list consolidation options for maintainers. Note that CodeRabbit JSDoc coverage warnings are informational relative to ECC's usual script documentation style. Addresses cubic P2 context on PR #2066. Co-authored-by: Cursor <cursoragent@cursor.com> * test: isolate agent-data-home tests from dogfooded .cursor config Use isolated temp cwd for default-resolution cases and assert resolveAgentDataHome({ projectDir }) reads ecc-agent-data.json. Document cwd/project caveats in the test file header. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Cursor sessionStart hook — inject ECC_AGENT_DATA_HOME for the composer session.
|
|
*
|
|
* Cursor passes session-scoped env from sessionStart output to all later hooks.
|
|
* @see https://cursor.com/docs/hooks
|
|
*/
|
|
|
|
const {
|
|
getCursorSessionEnvPayload,
|
|
resolveAgentDataHome,
|
|
AGENT_DATA_HOME_ENV,
|
|
} = require('../lib/agent-data-home');
|
|
const { readStdinJson, log } = require('../lib/utils');
|
|
|
|
function main() {
|
|
readStdinJson()
|
|
.then(() => {
|
|
const envPayload = getCursorSessionEnvPayload({ preferCursorDefault: true });
|
|
const agentDataHome = envPayload[AGENT_DATA_HOME_ENV];
|
|
const payload = {
|
|
env: envPayload,
|
|
additional_context: [
|
|
'ECC memory persistence uses a dedicated agent data root for this Cursor session.',
|
|
`${AGENT_DATA_HOME_ENV}=${agentDataHome}`,
|
|
'Session summaries, learned skills, aliases, and metrics live under that directory.',
|
|
'Override via shell env, project .cursor/ecc-agent-data.json, or ECC docs (issue #2065).',
|
|
].join('\n'),
|
|
};
|
|
|
|
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
log(`[cursor-session-env] Set ${AGENT_DATA_HOME_ENV}=${agentDataHome}`);
|
|
process.exit(0);
|
|
})
|
|
.catch(error => {
|
|
const fallbackHome = resolveAgentDataHome({ preferCursorDefault: true });
|
|
const payload = {
|
|
env: { [AGENT_DATA_HOME_ENV]: fallbackHome },
|
|
};
|
|
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
log(`[cursor-session-env] Fallback ${AGENT_DATA_HOME_ENV}=${fallbackHome} (${error.message})`);
|
|
process.exit(0);
|
|
});
|
|
}
|
|
|
|
if (require.main === module) {
|
|
main();
|
|
}
|
|
|
|
module.exports = { main };
|