forked from affaan-m/ECC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcursor-session-env.js
More file actions
50 lines (45 loc) · 1.66 KB
/
Copy pathcursor-session-env.js
File metadata and controls
50 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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 };