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.
Files changed (53) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  4. package/.openclaw-plugin/package.json +1 -1
  5. package/README.md +4 -4
  6. package/build/adapters/claude-code/hooks.d.ts +16 -1
  7. package/build/adapters/claude-code/hooks.js +16 -0
  8. package/build/adapters/claude-code/index.js +2 -11
  9. package/build/adapters/codex/hooks.d.ts +19 -0
  10. package/build/adapters/codex/hooks.js +22 -0
  11. package/build/adapters/codex/index.js +8 -1
  12. package/build/adapters/copilot-base.d.ts +17 -1
  13. package/build/adapters/copilot-base.js +18 -2
  14. package/build/adapters/cursor/hooks.d.ts +14 -1
  15. package/build/adapters/cursor/hooks.js +14 -0
  16. package/build/adapters/detect.d.ts +12 -2
  17. package/build/adapters/detect.js +70 -3
  18. package/build/adapters/gemini-cli/hooks.d.ts +16 -0
  19. package/build/adapters/gemini-cli/hooks.js +19 -0
  20. package/build/adapters/gemini-cli/index.js +4 -2
  21. package/build/adapters/kiro/hooks.d.ts +16 -1
  22. package/build/adapters/kiro/hooks.js +19 -0
  23. package/build/adapters/pi/extension.d.ts +9 -0
  24. package/build/adapters/pi/extension.js +47 -0
  25. package/build/adapters/qwen-code/hooks.d.ts +26 -0
  26. package/build/adapters/qwen-code/hooks.js +29 -0
  27. package/build/adapters/qwen-code/index.js +6 -0
  28. package/build/cli.js +26 -1
  29. package/build/executor.js +18 -3
  30. package/build/lifecycle.d.ts +15 -0
  31. package/build/lifecycle.js +24 -1
  32. package/build/runtime.js +34 -13
  33. package/build/session/extract.js +150 -48
  34. package/build/session/snapshot.js +46 -0
  35. package/cli.bundle.mjs +137 -136
  36. package/configs/codex/hooks.json +1 -1
  37. package/configs/cursor/hooks.json +1 -1
  38. package/configs/kiro/agent.json +1 -1
  39. package/hooks/core/routing.mjs +56 -1
  40. package/hooks/cursor/hooks.json +1 -1
  41. package/hooks/ensure-deps.mjs +22 -3
  42. package/hooks/hooks.json +9 -0
  43. package/hooks/routing-block.mjs +5 -0
  44. package/hooks/session-extract.bundle.mjs +2 -2
  45. package/hooks/session-snapshot.bundle.mjs +21 -20
  46. package/openclaw.plugin.json +1 -1
  47. package/package.json +3 -3
  48. package/scripts/heal-better-sqlite3.mjs +188 -10
  49. package/scripts/heal-installed-plugins.mjs +111 -0
  50. package/scripts/postinstall.mjs +18 -2
  51. package/server.bundle.mjs +111 -111
  52. package/start.mjs +14 -1
  53. 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>`;