context-mode 1.0.161 → 1.0.163

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 (153) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  5. package/.openclaw-plugin/package.json +1 -1
  6. package/README.md +142 -28
  7. package/bin/statusline.mjs +24 -4
  8. package/build/adapters/antigravity/index.d.ts +1 -1
  9. package/build/adapters/antigravity-cli/index.d.ts +51 -0
  10. package/build/adapters/antigravity-cli/index.js +341 -0
  11. package/build/adapters/claude-code/hooks.d.ts +1 -0
  12. package/build/adapters/claude-code/hooks.js +3 -0
  13. package/build/adapters/claude-code/index.js +24 -5
  14. package/build/adapters/client-map.js +5 -0
  15. package/build/adapters/codex/hooks.d.ts +5 -1
  16. package/build/adapters/codex/hooks.js +5 -1
  17. package/build/adapters/codex/index.d.ts +9 -1
  18. package/build/adapters/codex/index.js +87 -5
  19. package/build/adapters/copilot-cli/hooks.d.ts +33 -0
  20. package/build/adapters/copilot-cli/hooks.js +64 -0
  21. package/build/adapters/copilot-cli/index.d.ts +48 -0
  22. package/build/adapters/copilot-cli/index.js +341 -0
  23. package/build/adapters/detect.d.ts +1 -1
  24. package/build/adapters/detect.js +71 -3
  25. package/build/adapters/openclaw/mcp-tools.js +1 -1
  26. package/build/adapters/opencode/index.js +31 -17
  27. package/build/adapters/opencode/zod3tov4.js +27 -6
  28. package/build/adapters/pi/extension.d.ts +2 -12
  29. package/build/adapters/pi/extension.js +114 -96
  30. package/build/adapters/types.d.ts +5 -4
  31. package/build/adapters/types.js +4 -3
  32. package/build/cache-heal.d.ts +48 -0
  33. package/build/cache-heal.js +150 -0
  34. package/build/cli.js +37 -97
  35. package/build/executor.d.ts +25 -0
  36. package/build/executor.js +143 -22
  37. package/build/opencode-plugin.js +5 -2
  38. package/build/routing-block.d.ts +8 -0
  39. package/build/routing-block.js +86 -0
  40. package/build/runtime.d.ts +0 -36
  41. package/build/runtime.js +107 -27
  42. package/build/search/flood-guard.d.ts +57 -0
  43. package/build/search/flood-guard.js +80 -0
  44. package/build/security.d.ts +8 -3
  45. package/build/security.js +155 -29
  46. package/build/server.d.ts +14 -0
  47. package/build/server.js +368 -350
  48. package/build/session/analytics.d.ts +8 -8
  49. package/build/session/analytics.js +18 -13
  50. package/build/session/db.d.ts +1 -0
  51. package/build/session/db.js +37 -4
  52. package/build/session/extract.d.ts +46 -0
  53. package/build/session/extract.js +764 -13
  54. package/build/session/project-attribution.js +14 -0
  55. package/build/store.d.ts +1 -1
  56. package/build/store.js +139 -25
  57. package/build/tool-naming.d.ts +4 -0
  58. package/build/tool-naming.js +24 -0
  59. package/build/util/jsonc.d.ts +14 -0
  60. package/build/util/jsonc.js +104 -0
  61. package/cli.bundle.mjs +260 -254
  62. package/configs/antigravity/GEMINI.md +2 -2
  63. package/configs/antigravity-cli/hooks/hooks.json +37 -0
  64. package/configs/antigravity-cli/hooks.json +37 -0
  65. package/configs/antigravity-cli/mcp_config.json +10 -0
  66. package/configs/antigravity-cli/plugin.json +14 -0
  67. package/configs/antigravity-cli/rules/context-mode.md +77 -0
  68. package/configs/antigravity-cli/skills/context-mode/SKILL.md +77 -0
  69. package/configs/claude-code/CLAUDE.md +2 -2
  70. package/configs/codex/AGENTS.md +2 -2
  71. package/configs/copilot-cli/.github/plugin/plugin.json +23 -0
  72. package/configs/copilot-cli/.mcp.json +12 -0
  73. package/configs/copilot-cli/README.md +47 -0
  74. package/configs/copilot-cli/hooks.json +41 -0
  75. package/configs/copilot-cli/skills/context-mode/SKILL.md +38 -0
  76. package/configs/gemini-cli/GEMINI.md +2 -2
  77. package/configs/jetbrains-copilot/copilot-instructions.md +2 -2
  78. package/configs/kilo/AGENTS.md +2 -2
  79. package/configs/kiro/KIRO.md +2 -2
  80. package/configs/omp/SYSTEM.md +2 -2
  81. package/configs/openclaw/AGENTS.md +2 -2
  82. package/configs/opencode/AGENTS.md +2 -2
  83. package/configs/qwen-code/QWEN.md +2 -2
  84. package/configs/vscode-copilot/copilot-instructions.md +2 -2
  85. package/configs/zed/AGENTS.md +2 -2
  86. package/hooks/antigravity-cli/payload.mjs +98 -0
  87. package/hooks/antigravity-cli/posttooluse.mjs +138 -0
  88. package/hooks/antigravity-cli/pretooluse.mjs +78 -0
  89. package/hooks/antigravity-cli/stop.mjs +58 -0
  90. package/hooks/codex/pretooluse.mjs +14 -4
  91. package/hooks/codex/stop.mjs +12 -4
  92. package/hooks/copilot-cli/posttooluse.mjs +79 -0
  93. package/hooks/copilot-cli/precompact.mjs +66 -0
  94. package/hooks/copilot-cli/pretooluse.mjs +41 -0
  95. package/hooks/copilot-cli/sessionstart.mjs +121 -0
  96. package/hooks/copilot-cli/stop.mjs +59 -0
  97. package/hooks/copilot-cli/userpromptsubmit.mjs +77 -0
  98. package/hooks/core/codex-caps.mjs +112 -0
  99. package/hooks/core/formatters.mjs +158 -7
  100. package/hooks/core/mcp-ready.mjs +37 -8
  101. package/hooks/core/routing.mjs +94 -8
  102. package/hooks/core/tool-naming.mjs +3 -0
  103. package/hooks/hooks.json +12 -1
  104. package/hooks/pretooluse.mjs +6 -2
  105. package/hooks/routing-block.mjs +2 -2
  106. package/hooks/security.bundle.mjs +2 -1
  107. package/hooks/session-db.bundle.mjs +11 -7
  108. package/hooks/session-directive.mjs +88 -20
  109. package/hooks/session-extract.bundle.mjs +2 -2
  110. package/hooks/session-helpers.mjs +21 -0
  111. package/hooks/session-loaders.mjs +8 -5
  112. package/hooks/sessionstart.mjs +53 -7
  113. package/hooks/stop.mjs +49 -0
  114. package/hooks/userpromptsubmit.mjs +9 -2
  115. package/openclaw.plugin.json +1 -1
  116. package/package.json +4 -10
  117. package/scripts/install-antigravity-cli-plugin.mjs +141 -0
  118. package/server.bundle.mjs +214 -205
  119. package/skills/ctx-insight/SKILL.md +12 -17
  120. package/build/util/db-lock.d.ts +0 -65
  121. package/build/util/db-lock.js +0 -166
  122. package/insight/index.html +0 -13
  123. package/insight/package.json +0 -55
  124. package/insight/server.mjs +0 -1265
  125. package/insight/src/components/analytics.tsx +0 -112
  126. package/insight/src/components/ui/badge.tsx +0 -52
  127. package/insight/src/components/ui/button.tsx +0 -58
  128. package/insight/src/components/ui/card.tsx +0 -103
  129. package/insight/src/components/ui/chart.tsx +0 -371
  130. package/insight/src/components/ui/collapsible.tsx +0 -19
  131. package/insight/src/components/ui/input.tsx +0 -20
  132. package/insight/src/components/ui/progress.tsx +0 -83
  133. package/insight/src/components/ui/scroll-area.tsx +0 -55
  134. package/insight/src/components/ui/separator.tsx +0 -23
  135. package/insight/src/components/ui/table.tsx +0 -114
  136. package/insight/src/components/ui/tabs.tsx +0 -82
  137. package/insight/src/components/ui/tooltip.tsx +0 -64
  138. package/insight/src/lib/api.ts +0 -144
  139. package/insight/src/lib/utils.ts +0 -6
  140. package/insight/src/main.tsx +0 -22
  141. package/insight/src/routeTree.gen.ts +0 -189
  142. package/insight/src/router.tsx +0 -19
  143. package/insight/src/routes/__root.tsx +0 -55
  144. package/insight/src/routes/enterprise.tsx +0 -316
  145. package/insight/src/routes/index.tsx +0 -1482
  146. package/insight/src/routes/knowledge.tsx +0 -221
  147. package/insight/src/routes/knowledge_.$dbHash.$sourceId.tsx +0 -137
  148. package/insight/src/routes/search.tsx +0 -97
  149. package/insight/src/routes/sessions.tsx +0 -179
  150. package/insight/src/routes/sessions_.$dbHash.$sessionId.tsx +0 -181
  151. package/insight/src/styles.css +0 -104
  152. package/insight/tsconfig.json +0 -29
  153. package/insight/vite.config.ts +0 -19
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Cross-platform installer: register the context-mode plugin into Antigravity CLI (agy).
4
+ *
5
+ * Replaces the former bash-only scripts/install-antigravity-cli-plugin.sh so
6
+ * `npm run install:agy` runs natively on Windows (PowerShell/cmd) as well as
7
+ * macOS/Linux. agy itself runs on Windows, so its installer must too — unlike
8
+ * the openclaw installer, which is genuinely POSIX-only (signals, pgrep, /tmp).
9
+ *
10
+ * The bundle (configs/antigravity-cli/) registers the context-mode MCP server,
11
+ * routing rule, routing skill, and bounded PreToolUse/PostToolUse/Stop hooks in
12
+ * one step.
13
+ *
14
+ * Usage: npm run install:agy (or: node scripts/install-antigravity-cli-plugin.mjs)
15
+ */
16
+ import { spawnSync } from "node:child_process";
17
+ import { existsSync, rmSync } from "node:fs";
18
+ import { homedir } from "node:os";
19
+ import { dirname, join, resolve } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+
22
+ const isWin = process.platform === "win32";
23
+ const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
24
+ const bundle = resolve(repoRoot, "configs", "antigravity-cli");
25
+
26
+ // Double-quote a path so a clone dir with spaces survives the shell on both
27
+ // cmd.exe and /bin/sh (paths never contain literal quotes).
28
+ const q = (s) => `"${s}"`;
29
+
30
+ // Cross-platform "is <cmd> on PATH?" — `where` on Windows, `command -v` on POSIX.
31
+ // shell:true is required: `command -v` is a shell builtin and `where`/`agy` may
32
+ // resolve to a .cmd shim on Windows that only the shell can launch.
33
+ function onPath(cmd) {
34
+ const probe = isWin ? `where ${cmd}` : `command -v ${cmd}`;
35
+ return spawnSync(probe, { stdio: "ignore", shell: true }).status === 0;
36
+ }
37
+
38
+ // — preflight —
39
+ if (!onPath("agy")) {
40
+ console.error("✗ 'agy' (Antigravity CLI) not found in PATH. Install agy first, then re-run.");
41
+ process.exit(1);
42
+ }
43
+ if (!existsSync(bundle)) {
44
+ console.error(`✗ plugin bundle not found at ${bundle}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ console.log("→ context-mode agy plugin installer");
49
+ console.log(` bundle : ${bundle}`);
50
+
51
+ // The plugin's MCP server runs the global `context-mode` binary (it needs the
52
+ // native better-sqlite3 dependency, which a bare clone does not have). Warn — do
53
+ // not silently global-install on the user's behalf.
54
+ const hasContextMode = onPath("context-mode");
55
+ if (!hasContextMode) {
56
+ console.error("⚠ 'context-mode' is not on PATH — the plugin's MCP server requires it.");
57
+ console.error(" Install it with: npm install -g context-mode");
58
+ }
59
+
60
+ // Run `agy plugin install <bundle>`. String command + shell:true so cmd.exe can
61
+ // resolve agy's .cmd shim on Windows; the quoted bundle path handles spaces.
62
+ const install = spawnSync(`agy plugin install ${q(bundle)}`, { stdio: "inherit", shell: true });
63
+ if (install.status !== 0) {
64
+ console.error(`✗ 'agy plugin install' failed (exit ${install.status ?? "unknown"}).`);
65
+ process.exit(install.status ?? 1);
66
+ }
67
+
68
+ // MCP is registered by `agy plugin install` above, straight from the bundle's
69
+ // native `mcp_config.json` (env-pinned CONTEXT_MODE_PLATFORM=antigravity-cli).
70
+ // Verified on agy 1.0.6: it logs "mcpServers : 1 processed" and writes the
71
+ // server into agy's plugin profile
72
+ // (~/.gemini/config/plugins/context-mode/mcp_config.json, env preserved).
73
+ // agy native validation/install does not read `.mcp.json`; keep the bundle on
74
+ // the single native `mcp_config.json` path to avoid manifest drift.
75
+
76
+ // agy CACHES each MCP server's tool schemas under
77
+ // ~/.gemini/antigravity-cli/mcp/<server>/ and does NOT refresh them on reconnect
78
+ // (verified on agy 1.0.6). A cache captured by an older context-mode holds the
79
+ // Gemini-incompatible schemas (`const` / `additionalProperties`) that make
80
+ // Antigravity CLI silently DROP the ctx_* tools from the model's function list —
81
+ // so even after upgrading, agy keeps hiding the tools and the agent works around
82
+ // them via shell scripts. Clear the cache so agy re-fetches the current
83
+ // (Gemini-safe) tools/list on its next launch.
84
+ const agyToolCache = join(homedir(), ".gemini", "antigravity-cli", "mcp", "context-mode");
85
+ let cacheCleared = false;
86
+ if (existsSync(agyToolCache)) {
87
+ try {
88
+ rmSync(agyToolCache, { recursive: true, force: true });
89
+ cacheCleared = true;
90
+ } catch (err) {
91
+ console.error(`⚠ Could not clear agy's stale tool-schema cache at ${agyToolCache}: ${err.message}`);
92
+ console.error(" If ctx_* tools don't appear in agy, delete that folder manually and restart agy.");
93
+ }
94
+ }
95
+
96
+ // Probe whether the global `context-mode` understands the antigravity-cli hooks.
97
+ // The shipped hook commands resolve the GLOBAL binary at runtime. A context-mode
98
+ // older than the release that added Antigravity CLI support may have no
99
+ // `antigravity-cli` HOOK_MAP entry, and the dispatcher suppresses stderr, so the
100
+ // hooks would be a SILENT no-op. Detect that here and tell the user instead.
101
+ let hooksOk = false;
102
+ if (hasContextMode) {
103
+ hooksOk = ["pretooluse", "posttooluse", "stop"].every((event) => {
104
+ const probe = spawnSync(`context-mode hook antigravity-cli ${event}`, {
105
+ input: "{}",
106
+ stdio: ["pipe", "ignore", "ignore"],
107
+ shell: true,
108
+ });
109
+ return probe.status === 0;
110
+ });
111
+ }
112
+
113
+ console.log("");
114
+ // Confirm `agy plugin install` actually registered the MCP from the bundle's
115
+ // MCP config (it writes it into agy's plugin profile). If a future agy build
116
+ // skips it, fall back to a one-line manual instruction rather than silently
117
+ // leaving MCP unconfigured — never re-introduce a blind global-profile write.
118
+ const pluginMcp = join(homedir(), ".gemini", "config", "plugins", "context-mode", "mcp_config.json");
119
+ if (existsSync(pluginMcp)) {
120
+ console.log("✓ Installed the context-mode agy plugin: MCP server + routing rule + routing skill + hooks.");
121
+ console.log(` MCP registered from the bundle's mcp_config.json → ${pluginMcp}`);
122
+ } else {
123
+ console.log("✓ Installed the context-mode agy plugin: routing rule + routing skill + hooks.");
124
+ console.error("⚠ MCP server not found in agy's plugin profile. If ctx_* tools don't appear, add");
125
+ console.error(' { "mcpServers": { "context-mode": { "command": "context-mode" } } }');
126
+ console.error(" to ~/.gemini/config/mcp_config.json and restart agy.");
127
+ }
128
+ if (cacheCleared) {
129
+ console.log("✓ Cleared agy's stale tool-schema cache — agy re-fetches Gemini-safe schemas on next launch.");
130
+ }
131
+ if (hooksOk) {
132
+ console.log("✓ Antigravity CLI hooks are ACTIVE (this context-mode supports antigravity-cli).");
133
+ } else {
134
+ console.error("⚠ Antigravity CLI hooks may be INACTIVE: your global 'context-mode' is missing or too old");
135
+ console.error(" to handle 'context-mode hook antigravity-cli'. MCP tools + the routing rule + routing skill still work.");
136
+ console.error(" Enable hook enforcement/capture with: npm install -g context-mode@latest");
137
+ }
138
+ console.log("");
139
+ console.log(" Restart agy, then verify:");
140
+ console.log(' agy -p "Use the context-mode ctx_execute MCP tool to compute 7 + 5. Answer only the number." --dangerously-skip-permissions');
141
+ console.log(" Expected output: 12");