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
@@ -24,13 +24,13 @@ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mo
24
24
 
25
25
  ### Shell (>20 lines output)
26
26
  `run_command` ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
27
- Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "shell", code: "...")`
27
+ Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
28
28
 
29
29
  ### File reading (for analysis)
30
30
  Reading to **edit** → `view_file`/`replace_file_content` correct. Reading to **analyze/explore/summarize** → `mcp__context-mode__ctx_execute_file(path, language, code)`.
31
31
 
32
32
  ### Search (large results)
33
- Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
33
+ Use `mcp__context-mode__ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
34
34
 
35
35
  ## Tool selection
36
36
 
@@ -0,0 +1,37 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "run_command|view_file|grep_search|web_fetch|read_url_content",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "context-mode hook antigravity-cli pretooluse"
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "PostToolUse": [
15
+ {
16
+ "matcher": "",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "context-mode hook antigravity-cli posttooluse"
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "Stop": [
26
+ {
27
+ "matcher": "",
28
+ "hooks": [
29
+ {
30
+ "type": "command",
31
+ "command": "context-mode hook antigravity-cli stop"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "run_command|view_file|grep_search|web_fetch|read_url_content",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "context-mode hook antigravity-cli pretooluse"
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "PostToolUse": [
15
+ {
16
+ "matcher": "",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "context-mode hook antigravity-cli posttooluse"
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "Stop": [
26
+ {
27
+ "matcher": "",
28
+ "hooks": [
29
+ {
30
+ "type": "command",
31
+ "command": "context-mode hook antigravity-cli stop"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
37
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "mcpServers": {
3
+ "context-mode": {
4
+ "command": "context-mode",
5
+ "env": {
6
+ "CONTEXT_MODE_PLATFORM": "antigravity-cli"
7
+ }
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "context-mode",
3
+ "version": "1.0.163",
4
+ "description": "context-mode for Antigravity CLI (agy): sandboxed code execution, FTS5 knowledge base, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
5
+ "author": {
6
+ "name": "Mert Koseoğlu",
7
+ "url": "https://github.com/mksglu"
8
+ },
9
+ "homepage": "https://github.com/mksglu/context-mode#readme",
10
+ "license": "Elastic-2.0",
11
+ "skills": [
12
+ "./skills/context-mode"
13
+ ]
14
+ }
@@ -0,0 +1,77 @@
1
+ # context-mode routing for Antigravity CLI
2
+
3
+ context-mode MCP tools are installed for this agy session. Use them when the
4
+ task analyzes, counts, filters, compares, searches, parses, transforms, fetches,
5
+ or otherwise processes data. Raw bytes should stay in the sandbox; only the
6
+ derived answer should enter the conversation.
7
+
8
+ ## Do not dump — derive (most common mistake)
9
+
10
+ Do NOT use `context-mode/ctx_execute_file` or `ctx_execute` to print a whole file
11
+ or a full method/config (e.g. `print(FILE_CONTENT)`, `cat config.yaml`, dumping a
12
+ 281-line file). That defeats the purpose: on agy the tool's stdout is saved to a
13
+ step file that you then read back, so a full dump costs your context window TWICE
14
+ (once in the result, once on the follow-up read). Print only the specific value,
15
+ matches, count, or known line-range you need:
16
+
17
+ - WRONG: `ctx_execute_file(path:"config.yaml", language:"python", code:"print(FILE_CONTENT)")`
18
+ - RIGHT (value): `code:"import yaml; d=yaml.safe_load(FILE_CONTENT); print(d['active_strategy'])"`
19
+ - RIGHT (matches): `code:"import re;[print(i+1,l) for i,l in enumerate(FILE_CONTENT.splitlines()) if 'active_strategies' in l]"`
20
+ - RIGHT (known slice): `code:"print(chr(10).join(FILE_CONTENT.splitlines()[190:230]))"`
21
+
22
+ If you truly need to read a small, exact byte range to edit it, native `Read` /
23
+ `view_file` on that range is fine — but never dump an entire file through a hook.
24
+
25
+ ## Tool call surface
26
+
27
+ Antigravity CLI exposes context-mode tools as `context-mode/<tool>` calls. If
28
+ the host uses the generic MCP wrapper, call `call_mcp_tool` with:
29
+
30
+ - `ServerName`: `"context-mode"`
31
+ - `ToolName`: `"ctx_execute"`, `"ctx_execute_file"`, `"ctx_batch_execute"`,
32
+ `"ctx_fetch_and_index"`, `"ctx_search"`, or `"ctx_index"`
33
+ - `Arguments`: a JSON object for that tool
34
+
35
+ Do not read `~/.gemini/antigravity-cli/mcp/context-mode/*.json` to discover
36
+ schemas. Those files are agy's cached tool schemas and reading them spends
37
+ context. Use these argument shapes instead:
38
+
39
+ - `context-mode/ctx_execute`: `{"language":"python","code":"..."}`
40
+ - `context-mode/ctx_execute_file`:
41
+ `{"path":"path/to/file","language":"python","code":"..."}`
42
+ - `context-mode/ctx_batch_execute`:
43
+ `{"commands":[{"label":"...","command":"..."}],"queries":["..."]}`
44
+ - `context-mode/ctx_fetch_and_index`: `{"url":"https://...","source":"..."}`
45
+ - `context-mode/ctx_search`: `{"queries":["q1","q2"]}`
46
+ - `context-mode/ctx_index`: `{"path":"path/to/file-or-dir","source":"..."}`
47
+ or `{"content":"...","source":"..."}`
48
+
49
+ ## Mandatory routing
50
+
51
+ - Think in code. For analyze/count/filter/compare/search/parse/transform tasks,
52
+ write code with `context-mode/ctx_execute` and print only the final answer.
53
+ Program the analysis; do not read raw data and compute mentally.
54
+ - File read for analysis: there is no separate `ctx_read` tool.
55
+ `context-mode/ctx_execute_file` is the context-mode file-read surface. It
56
+ loads the file into `FILE_CONTENT` inside the sandbox. Print only selected
57
+ lines, counts, matches, summaries, or structured results. Never print
58
+ `FILE_CONTENT` wholesale unless the user explicitly asks for a full file dump.
59
+ - Native `Read` / `view_file` is correct when editing requires exact bytes, or
60
+ when a small known range is needed. For analysis, exploration, summarization,
61
+ counting, filtering, or searching inside a file, use
62
+ `context-mode/ctx_execute_file`.
63
+ - Use one `context-mode/ctx_batch_execute` call for multi-command repository
64
+ reconnaissance. One batch should replace many shell/list/search calls.
65
+ - Use `context-mode/ctx_execute` for shell commands whose output may exceed a
66
+ short fixed answer. Native Bash is only for git, mkdir, rm, mv, navigation,
67
+ installs, or short observable output.
68
+ - Use `context-mode/ctx_fetch_and_index` for web content, then
69
+ `context-mode/ctx_search` to query it. Do not dump raw HTML into the
70
+ conversation.
71
+ - Use `context-mode/ctx_index` only when content should be stored and searched
72
+ later. For a one-off file question, prefer `context-mode/ctx_execute_file`;
73
+ for follow-up retrieval, index with a descriptive `source` and query with
74
+ `context-mode/ctx_search`.
75
+ - Return only derived answers, concise summaries, selected snippets, or file
76
+ paths to written artifacts. Do not paste raw command dumps, full files, large
77
+ search results, cached schemas, or raw HTML into the conversation.
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: context-mode
3
+ description: Mandatory routing rules for Antigravity CLI. Invoke when exploring a codebase, reading files for analysis, listing context-mode tools, searching, parsing, counting, comparing, summarizing, fetching web content, or running data-heavy commands.
4
+ ---
5
+
6
+ # context-mode for Antigravity CLI
7
+
8
+ context-mode MCP tools are available in agy as `context-mode/<tool>`.
9
+ Use these tools directly. Do not inspect cached schema files under
10
+ `~/.gemini/antigravity-cli/mcp/context-mode/*.json`, and do not run
11
+ `ctx_execute` just to discover tool names or schemas.
12
+
13
+ If agy uses the generic MCP wrapper, call `call_mcp_tool` with:
14
+
15
+ - `ServerName`: `"context-mode"`
16
+ - `ToolName`: one of the tool names below
17
+ - `Arguments`: the JSON arguments for that tool
18
+
19
+ ## Tool List
20
+
21
+ - `context-mode/ctx_execute`: run JavaScript, TypeScript, Python, shell, or
22
+ other code in a sandbox. Print only the final answer.
23
+ - `context-mode/ctx_execute_file`: read one file into `FILE_CONTENT` inside the
24
+ sandbox and run code over it. This is the context-mode file-read surface.
25
+ - `context-mode/ctx_batch_execute`: run multiple repository commands in one
26
+ batch, index large output, and answer follow-up queries.
27
+ - `context-mode/ctx_index`: store a file, directory, or content in the local
28
+ FTS5 knowledge base for later search.
29
+ - `context-mode/ctx_search`: search indexed content and captured session
30
+ memory. Batch related questions in `queries`.
31
+ - `context-mode/ctx_fetch_and_index`: fetch web content, store it, then query
32
+ with `ctx_search`.
33
+ - `context-mode/ctx_stats`: show context savings and current-session stats.
34
+ - `context-mode/ctx_doctor`: diagnose context-mode runtime and hook health.
35
+ - `context-mode/ctx_upgrade`: provide upgrade or repair guidance.
36
+ - `context-mode/ctx_purge`: purge stored context-mode knowledge after
37
+ confirmation.
38
+ - `context-mode/ctx_insight`: launch or report the Insight analytics app.
39
+
40
+ When the user asks "what context-mode tools are available", answer from this
41
+ list. Do not list `~/.gemini/antigravity-cli/mcp/context-mode` and do not read
42
+ the JSON schema files.
43
+
44
+ ## File Reading
45
+
46
+ There is no separate `ctx_read` tool. Use `context-mode/ctx_execute_file` for
47
+ file reads that analyze, summarize, extract, count, filter, or compare.
48
+
49
+ Native `Read` / `view_file` is only right when editing needs exact bytes in the
50
+ conversation, or when the user explicitly asks to view a small known range.
51
+
52
+ Use JavaScript by default for lightweight file analysis:
53
+
54
+ ```json
55
+ {
56
+ "path": "README.md",
57
+ "language": "javascript",
58
+ "code": "const lines = FILE_CONTENT.split(/\\r?\\n/); console.log(lines.slice(0, 20).join('\\n'));"
59
+ }
60
+ ```
61
+
62
+ Never print `FILE_CONTENT` wholesale unless the user explicitly asks for a full
63
+ file dump. Print selected lines, counts, matches, summaries, or structured
64
+ results.
65
+
66
+ ## Codebase Exploration
67
+
68
+ For repository exploration, prefer one `context-mode/ctx_batch_execute` call
69
+ instead of many native `ListDir`, `Read`, `Grep`, or shell calls.
70
+
71
+ For one-off computed answers, use `context-mode/ctx_execute`.
72
+ For one-file analysis, use `context-mode/ctx_execute_file`.
73
+ For durable recall across follow-up questions, use `context-mode/ctx_index`
74
+ with a descriptive `source`, then `context-mode/ctx_search`.
75
+
76
+ Return concise derived answers. Do not paste raw command dumps, full files,
77
+ large search results, cached schemas, or raw HTML into the conversation.
@@ -23,13 +23,13 @@ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
23
23
 
24
24
  ### Bash (>20 lines output)
25
25
  Bash ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### Read (for analysis)
29
29
  Reading to **Edit** → Read correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### Grep — may flood context
32
- Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -24,13 +24,13 @@ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
24
24
 
25
25
  ### Shell (>20 lines output)
26
26
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
27
- Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "shell", code: "...")`
27
+ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
28
28
 
29
29
  ### File reading (for analysis)
30
30
  Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
31
31
 
32
32
  ### grep / search (large results)
33
- Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
33
+ Use `ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
34
34
 
35
35
  ## Tool selection
36
36
 
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "context-mode",
3
+ "description": "context-mode for GitHub Copilot CLI: sandboxed code execution in 11 languages, an FTS5 knowledge base with BM25 ranking, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
4
+ "version": "1.0.163",
5
+ "keywords": [
6
+ "mcp",
7
+ "context-window",
8
+ "sandbox",
9
+ "code-execution",
10
+ "fts5",
11
+ "bm25"
12
+ ],
13
+ "author": {
14
+ "name": "Mert Koseoğlu",
15
+ "url": "https://github.com/mksglu"
16
+ },
17
+ "homepage": "https://github.com/mksglu/context-mode#readme",
18
+ "repository": "https://github.com/mksglu/context-mode",
19
+ "license": "Elastic-2.0",
20
+ "skills": [
21
+ "./skills/context-mode"
22
+ ]
23
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "mcpServers": {
3
+ "context-mode": {
4
+ "command": "context-mode",
5
+ "args": [],
6
+ "env": {
7
+ "CONTEXT_MODE_PLATFORM": "copilot-cli",
8
+ "CONTEXT_MODE_COPILOT_PLUGIN": "1"
9
+ }
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,47 @@
1
+ # context-mode — GitHub Copilot CLI plugin
2
+
3
+ One-command install of the context-mode MCP server (and routing skill) into
4
+ GitHub Copilot CLI, with **no `context-mode upgrade` / agent call required**:
5
+
6
+ ```sh
7
+ copilot plugin install mksglu/context-mode:configs/copilot-cli
8
+ ```
9
+
10
+ This registers:
11
+
12
+ - **MCP server** (`.mcp.json`) — exposes the `ctx_*` tools (`ctx_execute`,
13
+ `ctx_batch_execute`, `ctx_search`, `ctx_fetch_and_index`, …). The server is
14
+ launched with `CONTEXT_MODE_PLATFORM=copilot-cli`, so it self-identifies as
15
+ Copilot regardless of any other CLI installed on the machine — `ctx_upgrade`
16
+ and platform detection resolve `copilot-cli`, never a co-installed Claude Code.
17
+ - **Routing skill** (`skills/context-mode/`) — the MANDATORY "Think in Code"
18
+ rules that keep raw bytes out of the context window.
19
+ - **Capture hooks** (`hooks.json`) — `preToolUse`, `postToolUse`,
20
+ `sessionStart`, `userPromptSubmitted`, `agentStop`, `preCompact` (Copilot
21
+ CLI's camelCase event names — verified against the `@github/copilot` 1.0.60
22
+ binary; PascalCase keys are silently ignored and never fire), each dispatching
23
+ `context-mode hook copilot-cli <event>`. Byte-equivalent to what
24
+ `context-mode upgrade` writes to `~/.copilot/hooks/`, so the plugin registers
25
+ them with no `upgrade` / agent call.
26
+
27
+ ## Prerequisite
28
+
29
+ The MCP server runs the global `context-mode` binary (it needs the native
30
+ `better-sqlite3` dependency):
31
+
32
+ ```sh
33
+ npm install -g context-mode
34
+ ```
35
+
36
+ ## Alternative (no plugin)
37
+
38
+ ```sh
39
+ copilot mcp add context-mode --env CONTEXT_MODE_PLATFORM=copilot-cli -- context-mode
40
+ ```
41
+
42
+ Then, to also install the capture hooks, run the upgrade **from inside Copilot**
43
+ (so it detects `copilot-cli` via the live MCP client) rather than standalone:
44
+
45
+ ```sh
46
+ copilot -p "Use the context-mode ctx_upgrade tool to install context-mode's hooks." --allow-all
47
+ ```
@@ -0,0 +1,41 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "preToolUse": [
5
+ {
6
+ "type": "command",
7
+ "command": "context-mode hook copilot-cli pretooluse"
8
+ }
9
+ ],
10
+ "postToolUse": [
11
+ {
12
+ "type": "command",
13
+ "command": "context-mode hook copilot-cli posttooluse"
14
+ }
15
+ ],
16
+ "sessionStart": [
17
+ {
18
+ "type": "command",
19
+ "command": "context-mode hook copilot-cli sessionstart"
20
+ }
21
+ ],
22
+ "userPromptSubmitted": [
23
+ {
24
+ "type": "command",
25
+ "command": "context-mode hook copilot-cli userpromptsubmit"
26
+ }
27
+ ],
28
+ "agentStop": [
29
+ {
30
+ "type": "command",
31
+ "command": "context-mode hook copilot-cli stop"
32
+ }
33
+ ],
34
+ "preCompact": [
35
+ {
36
+ "type": "command",
37
+ "command": "context-mode hook copilot-cli precompact"
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: context-mode
3
+ description: MANDATORY routing rules for context-mode. Invoke whenever you analyze, count, filter, compare, search, parse, or transform data; fetch a URL; or run a data-heavy command — so raw bytes stay out of the context window.
4
+ ---
5
+
6
+ # context-mode — MANDATORY routing rules
7
+
8
+ context-mode MCP tools are available in GitHub Copilot CLI. These rules protect
9
+ the context window from flooding — one unrouted command can dump tens of KB into
10
+ the conversation. Follow them strictly.
11
+
12
+ ## Think in Code — MANDATORY
13
+
14
+ Analyze / count / filter / compare / search / parse / transform data: **write
15
+ code** via `ctx_execute(language, code)` and `console.log()` only the answer. Do
16
+ NOT read raw data into context. PROGRAM the analysis, do not COMPUTE it by
17
+ reading. One script replaces ten tool calls.
18
+
19
+ ## BLOCKED — do NOT use
20
+
21
+ - **curl / wget** — dumps raw HTTP into context. Use
22
+ `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`.
23
+ - **Inline HTTP** (`node -e "fetch(...)"`, `python -c "requests.get(...)"`) — use
24
+ `ctx_execute(language, code)`; only stdout enters context.
25
+ - **Reading large files to analyze** — use
26
+ `ctx_execute_file(path, language, code)`.
27
+
28
+ ## Tool selection
29
+
30
+ 1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands,
31
+ auto-indexes, returns search. One call replaces dozens.
32
+ 2. **PROCESS**: `ctx_execute` / `ctx_execute_file` — sandbox; only stdout enters
33
+ context.
34
+ 3. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — raw
35
+ HTML never enters context.
36
+ 4. **SEARCH**: `ctx_search(queries: [...])` — all questions in one call.
37
+
38
+ Write artifacts to FILES; return a path + one-line description, not inline dumps.
@@ -23,13 +23,13 @@ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mo
23
23
 
24
24
  ### Shell (>20 lines output)
25
25
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### read_file (for analysis)
29
29
  Reading to **edit** → read_file correct. Reading to **analyze/explore/summarize** → `mcp__context-mode__ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `mcp__context-mode__ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
23
23
 
24
24
  ### Terminal / run_in_terminal (>20 lines output)
25
25
  Terminal ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### read_file (for analysis)
29
29
  Reading to **edit** → read_file correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_sear
23
23
 
24
24
  ### Shell (>20 lines output)
25
25
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### File reading (for analysis)
29
29
  Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode_ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `context-mode_ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `context-mode_ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `@context-mode/ctx_fetch_and_index(url, source)` then `@context-mode/ctx_se
23
23
 
24
24
  ### Shell (>20 lines output)
25
25
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `@context-mode/ctx_batch_execute(commands, queries)` or `@context-mode/ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `@context-mode/ctx_batch_execute(commands, queries)` or `@context-mode/ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### fs_read / read (for analysis)
29
29
  Reading to **edit** → fs_read correct. Reading to **analyze/explore/summarize** → `@context-mode/ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `@context-mode/ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `@context-mode/ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -24,13 +24,13 @@ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
24
24
 
25
25
  ### shell (>20 lines output)
26
26
  `shell` ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
27
- Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "shell", code: "...")`
27
+ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
28
28
 
29
29
  ### read (for analysis)
30
30
  Reading to **edit** → `read` correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
31
31
 
32
32
  ### grep / find (large results)
33
- Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
33
+ Use `ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
34
34
 
35
35
  ## Tool selection
36
36
 
@@ -23,13 +23,13 @@ Use: `context-mode__ctx_fetch_and_index(url, source)` then `context-mode__ctx_se
23
23
 
24
24
  ### Shell (>20 lines output)
25
25
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `context-mode__ctx_batch_execute(commands, queries)` or `context-mode__ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `context-mode__ctx_batch_execute(commands, queries)` or `context-mode__ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### File reading (for analysis)
29
29
  Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode__ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `context-mode__ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_sear
23
23
 
24
24
  ### Shell (>20 lines output)
25
25
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### File reading (for analysis)
29
29
  Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode_ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `context-mode_ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `context-mode_ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mo
23
23
 
24
24
  ### Bash (>20 lines output)
25
25
  Bash ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__context-mode__ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### Read (for analysis)
29
29
  Reading to **Edit** → Read correct. Reading to **analyze/explore/summarize** → `mcp__context-mode__ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### Grep — may flood context
32
- Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `mcp__context-mode__ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -23,13 +23,13 @@ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
23
23
 
24
24
  ### Terminal / run_in_terminal (>20 lines output)
25
25
  Terminal ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
26
- Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "shell", code: "...")`
26
+ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
27
27
 
28
28
  ### read_file (for analysis)
29
29
  Reading to **edit** → read_file correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
30
30
 
31
31
  ### grep / search (large results)
32
- Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
32
+ Use `ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
33
33
 
34
34
  ## Tool selection
35
35
 
@@ -24,13 +24,13 @@ Use: `mcp:context-mode:ctx_fetch_and_index(url, source)` then `mcp:context-mode:
24
24
 
25
25
  ### Shell (>20 lines output)
26
26
  Shell ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`.
27
- Otherwise: `mcp:context-mode:ctx_batch_execute(commands, queries)` or `mcp:context-mode:ctx_execute(language: "shell", code: "...")`
27
+ Otherwise: `mcp:context-mode:ctx_batch_execute(commands, queries)` or `mcp:context-mode:ctx_execute(language: "javascript", code: "...")`. Use `language: "shell"` only when code matches the host shell.
28
28
 
29
29
  ### File reading (for analysis)
30
30
  Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `mcp:context-mode:ctx_execute_file(path, language, code)`.
31
31
 
32
32
  ### grep / search (large results)
33
- Use `mcp:context-mode:ctx_execute(language: "shell", code: "grep ...")` in sandbox.
33
+ Use `mcp:context-mode:ctx_execute(language: "javascript", code: "...")` in sandbox for portable filtering/counting.
34
34
 
35
35
  ## Tool selection
36
36