context-mode 1.0.121 → 1.0.122
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/README.md +4 -4
- package/build/adapters/claude-code/hooks.d.ts +16 -1
- package/build/adapters/claude-code/hooks.js +16 -0
- package/build/adapters/claude-code/index.js +2 -11
- package/build/adapters/codex/hooks.d.ts +19 -0
- package/build/adapters/codex/hooks.js +22 -0
- package/build/adapters/codex/index.js +8 -1
- package/build/adapters/copilot-base.d.ts +17 -1
- package/build/adapters/copilot-base.js +18 -2
- package/build/adapters/cursor/hooks.d.ts +14 -1
- package/build/adapters/cursor/hooks.js +14 -0
- package/build/adapters/detect.d.ts +12 -2
- package/build/adapters/detect.js +70 -3
- package/build/adapters/gemini-cli/hooks.d.ts +16 -0
- package/build/adapters/gemini-cli/hooks.js +19 -0
- package/build/adapters/gemini-cli/index.js +4 -2
- package/build/adapters/kiro/hooks.d.ts +16 -1
- package/build/adapters/kiro/hooks.js +19 -0
- package/build/adapters/pi/extension.d.ts +9 -0
- package/build/adapters/pi/extension.js +47 -0
- package/build/adapters/qwen-code/hooks.d.ts +26 -0
- package/build/adapters/qwen-code/hooks.js +29 -0
- package/build/adapters/qwen-code/index.js +6 -0
- package/build/cli.js +26 -1
- package/build/executor.js +18 -3
- package/build/lifecycle.d.ts +15 -0
- package/build/lifecycle.js +24 -1
- package/build/runtime.js +34 -13
- package/build/session/extract.js +150 -48
- package/build/session/snapshot.js +46 -0
- package/cli.bundle.mjs +137 -136
- package/configs/codex/hooks.json +1 -1
- package/configs/cursor/hooks.json +1 -1
- package/configs/kiro/agent.json +1 -1
- package/hooks/core/routing.mjs +56 -1
- package/hooks/cursor/hooks.json +1 -1
- package/hooks/ensure-deps.mjs +22 -3
- package/hooks/hooks.json +9 -0
- package/hooks/routing-block.mjs +5 -0
- package/hooks/session-extract.bundle.mjs +2 -2
- package/hooks/session-snapshot.bundle.mjs +21 -20
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/scripts/heal-better-sqlite3.mjs +188 -10
- package/scripts/heal-installed-plugins.mjs +111 -0
- package/scripts/postinstall.mjs +18 -2
- package/server.bundle.mjs +111 -111
- package/start.mjs +14 -1
- package/.mcp.json +0 -8
|
@@ -342,6 +342,43 @@ function buildIntentSection(intentEvents) {
|
|
|
342
342
|
const lastIntent = intentEvents[intentEvents.length - 1];
|
|
343
343
|
return ` <intent mode="${escapeXML(lastIntent.data)}"/>`;
|
|
344
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Raw-prompt safety net (issue #535):
|
|
347
|
+
* Always surface the most recent user prompts verbatim so the next LLM
|
|
348
|
+
* sees them even if every universal-rule detector misses. Bound per-prompt
|
|
349
|
+
* payload to RECENT_MESSAGE_MAX_CHARS Unicode codepoints; bound the total
|
|
350
|
+
* count to RECENT_MESSAGES_LIMIT to keep the resume block compact.
|
|
351
|
+
*/
|
|
352
|
+
const RECENT_MESSAGES_LIMIT = 3;
|
|
353
|
+
const RECENT_MESSAGE_MAX_CHARS = 400;
|
|
354
|
+
function truncateForSnapshot(value, max) {
|
|
355
|
+
const codepoints = [...value];
|
|
356
|
+
if (codepoints.length <= max)
|
|
357
|
+
return value;
|
|
358
|
+
return codepoints.slice(0, max).join("");
|
|
359
|
+
}
|
|
360
|
+
function buildRecentMessagesSection(userPromptEvents) {
|
|
361
|
+
if (userPromptEvents.length === 0)
|
|
362
|
+
return "";
|
|
363
|
+
// Last N in chronological order — newest at the bottom mirrors the
|
|
364
|
+
// way the user reads their own scrollback.
|
|
365
|
+
const recent = userPromptEvents.slice(-RECENT_MESSAGES_LIMIT);
|
|
366
|
+
const items = recent
|
|
367
|
+
.map(ev => {
|
|
368
|
+
const body = truncateForSnapshot(ev.data ?? "", RECENT_MESSAGE_MAX_CHARS);
|
|
369
|
+
if (!body)
|
|
370
|
+
return "";
|
|
371
|
+
return ` <message>${escapeXML(body)}</message>`;
|
|
372
|
+
})
|
|
373
|
+
.filter(Boolean);
|
|
374
|
+
if (items.length === 0)
|
|
375
|
+
return "";
|
|
376
|
+
return [
|
|
377
|
+
` <recent_user_messages count="${items.length}">`,
|
|
378
|
+
...items,
|
|
379
|
+
` </recent_user_messages>`,
|
|
380
|
+
].join("\n");
|
|
381
|
+
}
|
|
345
382
|
// ── Main builder ─────────────────────────────────────────────────────────────
|
|
346
383
|
/**
|
|
347
384
|
* Build a reference-based resume snapshot XML string from stored session events.
|
|
@@ -369,6 +406,7 @@ export function buildResumeSnapshot(events, opts) {
|
|
|
369
406
|
const intentEvents = [];
|
|
370
407
|
const skillEvents = [];
|
|
371
408
|
const roleEvents = [];
|
|
409
|
+
const userPromptEvents = [];
|
|
372
410
|
for (const ev of events) {
|
|
373
411
|
switch (ev.category) {
|
|
374
412
|
case "file":
|
|
@@ -407,6 +445,9 @@ export function buildResumeSnapshot(events, opts) {
|
|
|
407
445
|
case "role":
|
|
408
446
|
roleEvents.push(ev);
|
|
409
447
|
break;
|
|
448
|
+
case "user-prompt":
|
|
449
|
+
userPromptEvents.push(ev);
|
|
450
|
+
break;
|
|
410
451
|
}
|
|
411
452
|
}
|
|
412
453
|
// ── Build all sections ──
|
|
@@ -451,6 +492,11 @@ export function buildResumeSnapshot(events, opts) {
|
|
|
451
492
|
const intent = buildIntentSection(intentEvents);
|
|
452
493
|
if (intent)
|
|
453
494
|
sections.push(intent);
|
|
495
|
+
// Raw-prompt safety net — always last so it stays adjacent to the next
|
|
496
|
+
// LLM turn and is read after the structured sections.
|
|
497
|
+
const recentMessages = buildRecentMessagesSection(userPromptEvents);
|
|
498
|
+
if (recentMessages)
|
|
499
|
+
sections.push(recentMessages);
|
|
454
500
|
// ── Assemble ──
|
|
455
501
|
const header = `<session_resume events="${events.length}" compact_count="${compactCount}" generated_at="${now}">`;
|
|
456
502
|
const footer = `</session_resume>`;
|