context-mode 1.0.150 → 1.0.152

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 (107) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/mcp.json +5 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.openclaw-plugin/openclaw.plugin.json +16 -1
  6. package/.openclaw-plugin/package.json +1 -1
  7. package/README.md +89 -3
  8. package/build/adapters/claude-code/hooks.js +2 -2
  9. package/build/adapters/claude-code/index.js +14 -13
  10. package/build/adapters/client-map.js +3 -0
  11. package/build/adapters/detect.js +13 -1
  12. package/build/adapters/gemini-cli/hooks.d.ts +10 -0
  13. package/build/adapters/gemini-cli/hooks.js +12 -2
  14. package/build/adapters/gemini-cli/index.d.ts +21 -1
  15. package/build/adapters/gemini-cli/index.js +37 -1
  16. package/build/adapters/kimi/config.d.ts +8 -0
  17. package/build/adapters/kimi/config.js +8 -0
  18. package/build/adapters/kimi/hooks.d.ts +28 -0
  19. package/build/adapters/kimi/hooks.js +34 -0
  20. package/build/adapters/kimi/index.d.ts +66 -0
  21. package/build/adapters/kimi/index.js +537 -0
  22. package/build/adapters/kimi/paths.d.ts +1 -0
  23. package/build/adapters/kimi/paths.js +12 -0
  24. package/build/adapters/kiro/hooks.js +2 -2
  25. package/build/adapters/openclaw/plugin.d.ts +14 -13
  26. package/build/adapters/openclaw/plugin.js +140 -40
  27. package/build/adapters/opencode/plugin.js +4 -3
  28. package/build/adapters/opencode/zod3tov4.js +8 -8
  29. package/build/adapters/pi/extension.js +9 -24
  30. package/build/adapters/pi/mcp-bridge.js +37 -0
  31. package/build/adapters/qwen-code/index.js +7 -7
  32. package/build/adapters/types.d.ts +39 -2
  33. package/build/adapters/types.js +55 -2
  34. package/build/adapters/vscode-copilot/index.js +13 -1
  35. package/build/cli.js +433 -25
  36. package/build/executor.js +6 -3
  37. package/build/runtime.d.ts +81 -1
  38. package/build/runtime.js +195 -9
  39. package/build/search/ctx-search-schema.d.ts +90 -0
  40. package/build/search/ctx-search-schema.js +135 -0
  41. package/build/search/unified.d.ts +12 -0
  42. package/build/search/unified.js +17 -2
  43. package/build/server.d.ts +2 -1
  44. package/build/server.js +378 -97
  45. package/build/session/analytics.d.ts +36 -13
  46. package/build/session/analytics.js +123 -26
  47. package/build/session/db.d.ts +24 -0
  48. package/build/session/db.js +41 -0
  49. package/build/session/extract.js +30 -0
  50. package/build/session/snapshot.js +24 -0
  51. package/build/store.d.ts +12 -1
  52. package/build/store.js +72 -20
  53. package/build/types.d.ts +7 -0
  54. package/build/util/project-dir.d.ts +19 -16
  55. package/build/util/project-dir.js +80 -45
  56. package/cli.bundle.mjs +371 -320
  57. package/configs/kimi/hooks.json +54 -0
  58. package/configs/pi/AGENTS.md +3 -85
  59. package/hooks/cache-heal-utils.mjs +148 -0
  60. package/hooks/core/formatters.mjs +26 -0
  61. package/hooks/core/routing.mjs +9 -1
  62. package/hooks/core/stdin.mjs +74 -3
  63. package/hooks/core/tool-naming.mjs +1 -0
  64. package/hooks/heal-partial-install.mjs +712 -0
  65. package/hooks/kimi/platform.mjs +1 -0
  66. package/hooks/kimi/posttooluse.mjs +72 -0
  67. package/hooks/kimi/precompact.mjs +80 -0
  68. package/hooks/kimi/pretooluse.mjs +42 -0
  69. package/hooks/kimi/sessionend.mjs +61 -0
  70. package/hooks/kimi/sessionstart.mjs +113 -0
  71. package/hooks/kimi/stop.mjs +61 -0
  72. package/hooks/kimi/userpromptsubmit.mjs +90 -0
  73. package/hooks/normalize-hooks.mjs +66 -12
  74. package/hooks/routing-block.mjs +8 -2
  75. package/hooks/security.bundle.mjs +1 -1
  76. package/hooks/session-db.bundle.mjs +6 -4
  77. package/hooks/session-extract.bundle.mjs +2 -2
  78. package/hooks/session-helpers.mjs +93 -3
  79. package/hooks/session-snapshot.bundle.mjs +20 -19
  80. package/hooks/sessionstart.mjs +64 -0
  81. package/insight/server.mjs +15 -3
  82. package/openclaw.plugin.json +16 -1
  83. package/package.json +1 -1
  84. package/scripts/heal-installed-plugins.mjs +31 -10
  85. package/scripts/postinstall.mjs +10 -0
  86. package/server.bundle.mjs +206 -157
  87. package/skills/ctx-index/SKILL.md +46 -0
  88. package/skills/ctx-search/SKILL.md +35 -0
  89. package/start.mjs +84 -11
  90. package/build/cache-heal.d.ts +0 -48
  91. package/build/cache-heal.js +0 -150
  92. package/build/concurrency/runPool.d.ts +0 -36
  93. package/build/concurrency/runPool.js +0 -51
  94. package/build/openclaw/mcp-tools.d.ts +0 -54
  95. package/build/openclaw/mcp-tools.js +0 -198
  96. package/build/openclaw/workspace-router.d.ts +0 -29
  97. package/build/openclaw/workspace-router.js +0 -64
  98. package/build/openclaw-plugin.d.ts +0 -130
  99. package/build/openclaw-plugin.js +0 -626
  100. package/build/opencode-plugin.d.ts +0 -122
  101. package/build/opencode-plugin.js +0 -375
  102. package/build/pi-extension.d.ts +0 -14
  103. package/build/pi-extension.js +0 -451
  104. package/build/routing-block.d.ts +0 -8
  105. package/build/routing-block.js +0 -86
  106. package/build/tool-naming.d.ts +0 -4
  107. package/build/tool-naming.js +0 -24
@@ -205,8 +205,6 @@ export function healSettingsEnabledPlugins({ settingsPath, pluginKey }) {
205
205
  // - `src/cli.ts` upgrade() (post-bump)
206
206
  // ─────────────────────────────────────────────────────────────────────────
207
207
 
208
- /** Matches `<sep>context-mode-upgrade-<digits><sep>`. OS-agnostic. */
209
- const TMPDIR_UPGRADE_RE = /[/\\]context-mode-upgrade-\d+[/\\]/;
210
208
  const PLACEHOLDER_ARG = "${CLAUDE_PLUGIN_ROOT}/start.mjs";
211
209
 
212
210
  /**
@@ -262,10 +260,13 @@ export function healPluginJsonMcpServers({ pluginRoot, pluginCacheRoot, pluginKe
262
260
  const before = ours.args;
263
261
  const after = before.map((a) => {
264
262
  if (typeof a !== "string") return a;
265
- // Detect tmpdir-prefixed `context-mode-upgrade-<digits>` paths and
266
- // rewrite to the literal placeholder that survives upgrades. Only
267
- // rewrites when the trailing component is `start.mjs` (our entrypoint).
268
- if (TMPDIR_UPGRADE_RE.test(a) && /[/\\]start\.mjs$/.test(a)) {
263
+ // Already the placeholder nothing to heal.
264
+ if (a === PLACEHOLDER_ARG) return a;
265
+ // Issue #711: any absolute path ending in start.mjs should be the
266
+ // placeholder. Catches tmpdir paths (context-mode-upgrade-<digits>)
267
+ // AND stale versioned cache-dir paths (.../1.0.103/start.mjs) that
268
+ // normalizeHooksOnStartup baked in during a prior upgrade.
269
+ if (/[/\\]start\.mjs$/.test(a)) {
269
270
  return PLACEHOLDER_ARG;
270
271
  }
271
272
  return a;
@@ -369,14 +370,16 @@ export function healMcpJsonArgs({ pluginRoot, pluginCacheRoot, pluginKey }) {
369
370
  const before = ours.args;
370
371
  const after = before.map((a) => {
371
372
  if (typeof a !== "string") return a;
373
+ // Already the placeholder — nothing to heal.
374
+ if (a === PLACEHOLDER_ARG) return a;
372
375
  // Drift shape #1 (issue #531 / commit aea633c): bare relative `./start.mjs`.
373
- // Resolved against session CWD (not pluginRoot) → MODULE_NOT_FOUND.
374
376
  if (a === "./start.mjs" || a === "start.mjs") {
375
377
  return PLACEHOLDER_ARG;
376
378
  }
377
- // Drift shape #2 (mirror of healPluginJsonMcpServers / #523):
378
- // tmpdir-prefixed `<...>/context-mode-upgrade-<digits>/start.mjs`.
379
- if (TMPDIR_UPGRADE_RE.test(a) && /[/\\]start\.mjs$/.test(a)) {
379
+ // Issue #711: any absolute path ending in start.mjs should be the
380
+ // placeholder. Catches tmpdir paths AND stale versioned cache-dir
381
+ // paths (.../1.0.103/start.mjs) from prior upgrades.
382
+ if (/[/\\]start\.mjs$/.test(a)) {
380
383
  return PLACEHOLDER_ARG;
381
384
  }
382
385
  return a;
@@ -430,6 +433,18 @@ export function healClaudeJsonMcpArgs({ dotClaudeJsonPath, pluginCacheParent, ne
430
433
  }
431
434
 
432
435
  const cacheParentFwd = pluginCacheParent.replace(/\\/g, "/");
436
+ // Post-resolve containment on newArg. ~/.claude.json is locally user-
437
+ // writable (same trust boundary as installed_plugins.json), and the
438
+ // `suffix` slice is derived from arg strings inside the existing config.
439
+ // A crafted arg like
440
+ // .../cache/<owner>/<plugin>/1.0.0/../../../evil/start.mjs
441
+ // slices to suffix="../../../evil/start.mjs", and resolve(newPluginRoot,
442
+ // suffix) normalizes to an attacker-chosen .mjs path outside the plugin
443
+ // cache. Writing that path back into ~/.claude.json mutates the mcpServers
444
+ // args so the next MCP boot spawns from the attacker path. Reject any
445
+ // suffix that escapes newPluginRoot.
446
+ const newPluginRootResolved = resolve(newPluginRoot);
447
+ const newPluginRootWithSep = newPluginRootResolved + sep;
433
448
 
434
449
  let mutated = false;
435
450
  for (const srv of Object.values(servers)) {
@@ -444,6 +459,12 @@ export function healClaudeJsonMcpArgs({ dotClaudeJsonPath, pluginCacheParent, ne
444
459
  if (slashIdx < 0) continue;
445
460
  const suffix = rel.slice(slashIdx + 1);
446
461
  const newArg = resolve(newPluginRoot, suffix);
462
+ if (
463
+ newArg !== newPluginRootResolved &&
464
+ !(newArg + sep).startsWith(newPluginRootWithSep)
465
+ ) {
466
+ continue;
467
+ }
447
468
  if (newArg !== arg) {
448
469
  srv.args[i] = newArg;
449
470
  mutated = true;
@@ -364,10 +364,20 @@ try { healBetterSqlite3Binding(pkgRoot); } catch { /* best effort — don't bloc
364
364
  const TMPDIR_UPGRADE_RE = /[/\\]context-mode-upgrade-\d+[/\\]?$/;
365
365
  if (isGlobalInstall() && !TMPDIR_UPGRADE_RE.test(pkgRoot)) {
366
366
  try {
367
+ // #738: probe for Bun ≥1.0 so the post-install hooks.json rewrite picks
368
+ // the faster runtime where available. Probe failures (e.g. build not
369
+ // present yet during `npm install` itself) fall through to nodePath.
370
+ let jsRuntimePath;
371
+ try {
372
+ const { resolveHookRuntime } = await import("../build/runtime.js");
373
+ const r = resolveHookRuntime();
374
+ if (r.isBun) jsRuntimePath = r.path;
375
+ } catch { /* best effort — fall through */ }
367
376
  const { normalizeHooksOnStartup } = await import("../hooks/normalize-hooks.mjs");
368
377
  normalizeHooksOnStartup({
369
378
  pluginRoot: pkgRoot,
370
379
  nodePath: process.execPath,
380
+ jsRuntimePath,
371
381
  platform: process.platform,
372
382
  });
373
383
  } catch { /* best effort — never block install */ }