@lorekit/cli 1.59.0 → 1.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/adapters/cursor.mjs +1 -1
- package/src/commands/hook.mjs +17 -0
- package/src/shared/mcp.mjs +13 -1
package/package.json
CHANGED
package/src/adapters/cursor.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export const cursor = {
|
|
|
28
28
|
cwd:
|
|
29
29
|
input.cwd ||
|
|
30
30
|
(Array.isArray(input.workspace_roots) ? input.workspace_roots[0] : null),
|
|
31
|
-
sessionId: input.
|
|
31
|
+
sessionId: input.conversation_id || input.generation_id || null,
|
|
32
32
|
toolName: 'command',
|
|
33
33
|
toolResponse: null,
|
|
34
34
|
event: input.hook_event_name || null,
|
package/src/commands/hook.mjs
CHANGED
|
@@ -109,6 +109,23 @@ async function run(args, meter) {
|
|
|
109
109
|
const parsed = adapter.parse(input);
|
|
110
110
|
const event = args.event || parsed.event;
|
|
111
111
|
|
|
112
|
+
// Every adapter already normalises the host's own session id off the stdin
|
|
113
|
+
// payload (Claude's `session_id`, Codex's `thread_id`, Cursor's
|
|
114
|
+
// `conversation_id`). Publishing it as `LOREKIT_SESSION_ID` — the first name
|
|
115
|
+
// `deriveSessionContext` looks for — is what lets a hook-driven remote read
|
|
116
|
+
// carry a `correlation_id`, so the dashboard's Runs view can group a session's
|
|
117
|
+
// reads and writes. It is the AUTHORITATIVE id: the payload says which session
|
|
118
|
+
// this fire belongs to, whereas an inherited env var only says which process
|
|
119
|
+
// tree we happen to be in, and Cursor/Codex export nothing at all.
|
|
120
|
+
//
|
|
121
|
+
// `||=`, never an overwrite: an explicit LOREKIT_SESSION_ID (or the
|
|
122
|
+
// LOREKIT_CORRELATION_ID that outranks all of this) is a deliberate override
|
|
123
|
+
// and must keep winning. Process-local and short-lived — this CLI invocation
|
|
124
|
+
// handles exactly one hook fire and exits.
|
|
125
|
+
if (parsed.sessionId && !process.env.LOREKIT_SESSION_ID) {
|
|
126
|
+
process.env.LOREKIT_SESSION_ID = parsed.sessionId;
|
|
127
|
+
}
|
|
128
|
+
|
|
112
129
|
// Harvest the real payload when recording is enabled (opt-in via env).
|
|
113
130
|
recordFixture(args.adapter, event, raw);
|
|
114
131
|
|
package/src/shared/mcp.mjs
CHANGED
|
@@ -231,7 +231,19 @@ export function deriveSessionContext(env = process.env) {
|
|
|
231
231
|
// Well-known agent-host session id env vars. Best-effort: hosts differ and
|
|
232
232
|
// this is not an exhaustive registry, so an unrecognised host still falls
|
|
233
233
|
// through to `unknown` rather than fabricating an id.
|
|
234
|
-
|
|
234
|
+
//
|
|
235
|
+
// `CLAUDE_CODE_SESSION_ID` is the name Claude Code actually exports (verified
|
|
236
|
+
// against a live session's env); `CLAUDE_SESSION_ID` was a guess and is not
|
|
237
|
+
// set by any Claude Code version, so before it was joined here EVERY local
|
|
238
|
+
// Claude session fell through to `unknown` with no correlation id — which is
|
|
239
|
+
// why `GET /memories/usage/runs` returned an empty list on an account with
|
|
240
|
+
// ~44K usage events. Kept alongside rather than replaced: it costs nothing,
|
|
241
|
+
// and dropping a name is how the same blind spot comes back.
|
|
242
|
+
const sessionId = firstNonEmptyEnv(env, [
|
|
243
|
+
'LOREKIT_SESSION_ID',
|
|
244
|
+
'CLAUDE_CODE_SESSION_ID',
|
|
245
|
+
'CLAUDE_SESSION_ID',
|
|
246
|
+
]);
|
|
235
247
|
if (sessionId) {
|
|
236
248
|
// A local session IS known even when the specific id fails the
|
|
237
249
|
// correlation-id charset/length check — report the kind either way, and
|