context-mode 1.0.89 → 1.0.91

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 (128) 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 +184 -60
  6. package/build/adapters/antigravity/index.d.ts +3 -5
  7. package/build/adapters/antigravity/index.js +7 -35
  8. package/build/adapters/base.d.ts +27 -0
  9. package/build/adapters/base.js +59 -0
  10. package/build/adapters/claude-code/index.d.ts +9 -25
  11. package/build/adapters/claude-code/index.js +12 -140
  12. package/build/adapters/claude-code-base.d.ts +49 -0
  13. package/build/adapters/claude-code-base.js +113 -0
  14. package/build/adapters/client-map.js +5 -0
  15. package/build/adapters/codex/hooks.d.ts +21 -14
  16. package/build/adapters/codex/hooks.js +22 -15
  17. package/build/adapters/codex/index.d.ts +6 -10
  18. package/build/adapters/codex/index.js +13 -43
  19. package/build/adapters/copilot-base.d.ts +78 -0
  20. package/build/adapters/copilot-base.js +281 -0
  21. package/build/adapters/cursor/index.d.ts +3 -5
  22. package/build/adapters/cursor/index.js +6 -34
  23. package/build/adapters/detect.d.ts +7 -0
  24. package/build/adapters/detect.js +57 -56
  25. package/build/adapters/gemini-cli/index.d.ts +3 -5
  26. package/build/adapters/gemini-cli/index.js +7 -35
  27. package/build/adapters/jetbrains-copilot/config.d.ts +8 -0
  28. package/build/adapters/jetbrains-copilot/config.js +8 -0
  29. package/build/adapters/jetbrains-copilot/hooks.d.ts +51 -0
  30. package/build/adapters/jetbrains-copilot/hooks.js +82 -0
  31. package/build/adapters/jetbrains-copilot/index.d.ts +24 -0
  32. package/build/adapters/jetbrains-copilot/index.js +119 -0
  33. package/build/adapters/kiro/hooks.d.ts +14 -0
  34. package/build/adapters/kiro/hooks.js +23 -0
  35. package/build/adapters/kiro/index.d.ts +3 -5
  36. package/build/adapters/kiro/index.js +10 -38
  37. package/build/adapters/openclaw/index.d.ts +3 -4
  38. package/build/adapters/openclaw/index.js +6 -22
  39. package/build/adapters/opencode/index.d.ts +2 -3
  40. package/build/adapters/opencode/index.js +5 -16
  41. package/build/adapters/qwen-code/index.d.ts +39 -0
  42. package/build/adapters/qwen-code/index.js +199 -0
  43. package/build/adapters/types.d.ts +1 -1
  44. package/build/adapters/vscode-copilot/index.d.ts +16 -46
  45. package/build/adapters/vscode-copilot/index.js +29 -320
  46. package/build/adapters/zed/index.d.ts +3 -5
  47. package/build/adapters/zed/index.js +7 -35
  48. package/build/cli.js +13 -0
  49. package/build/lifecycle.d.ts +23 -0
  50. package/build/lifecycle.js +54 -13
  51. package/build/opencode-plugin.d.ts +19 -7
  52. package/build/opencode-plugin.js +19 -7
  53. package/build/runtime.js +24 -9
  54. package/build/security.d.ts +17 -1
  55. package/build/security.js +40 -6
  56. package/build/server.js +53 -10
  57. package/build/session/analytics.d.ts +8 -7
  58. package/build/session/analytics.js +107 -76
  59. package/build/session/db.d.ts +10 -1
  60. package/build/session/db.js +67 -8
  61. package/build/session/extract.js +10 -2
  62. package/build/session/project-attribution.d.ts +73 -0
  63. package/build/session/project-attribution.js +231 -0
  64. package/build/store.d.ts +4 -0
  65. package/build/store.js +58 -9
  66. package/build/types.d.ts +8 -0
  67. package/cli.bundle.mjs +135 -121
  68. package/configs/antigravity/GEMINI.md +31 -36
  69. package/configs/claude-code/CLAUDE.md +31 -37
  70. package/configs/codex/AGENTS.md +35 -49
  71. package/configs/cursor/context-mode.mdc +24 -25
  72. package/configs/gemini-cli/GEMINI.md +30 -36
  73. package/configs/jetbrains-copilot/copilot-instructions.md +59 -0
  74. package/configs/jetbrains-copilot/hooks.json +16 -0
  75. package/configs/jetbrains-copilot/mcp.json +8 -0
  76. package/configs/kilo/AGENTS.md +30 -36
  77. package/configs/kiro/KIRO.md +30 -36
  78. package/configs/kiro/agent.json +1 -1
  79. package/configs/openclaw/AGENTS.md +30 -36
  80. package/configs/opencode/AGENTS.md +30 -36
  81. package/configs/pi/AGENTS.md +31 -36
  82. package/configs/qwen-code/QWEN.md +63 -0
  83. package/configs/vscode-copilot/copilot-instructions.md +30 -36
  84. package/configs/zed/AGENTS.md +31 -36
  85. package/hooks/codex/posttooluse.mjs +7 -7
  86. package/hooks/codex/pretooluse.mjs +3 -3
  87. package/hooks/codex/sessionstart.mjs +2 -1
  88. package/hooks/core/formatters.mjs +24 -0
  89. package/hooks/core/routing.mjs +40 -15
  90. package/hooks/core/tool-naming.mjs +2 -0
  91. package/hooks/cursor/posttooluse.mjs +7 -7
  92. package/hooks/cursor/pretooluse.mjs +3 -3
  93. package/hooks/cursor/sessionstart.mjs +2 -1
  94. package/hooks/cursor/stop.mjs +2 -2
  95. package/hooks/ensure-deps.mjs +22 -10
  96. package/hooks/gemini-cli/aftertool.mjs +8 -8
  97. package/hooks/gemini-cli/beforetool.mjs +3 -2
  98. package/hooks/gemini-cli/precompress.mjs +2 -2
  99. package/hooks/gemini-cli/sessionstart.mjs +12 -4
  100. package/hooks/jetbrains-copilot/posttooluse.mjs +61 -0
  101. package/hooks/jetbrains-copilot/precompact.mjs +54 -0
  102. package/hooks/jetbrains-copilot/pretooluse.mjs +27 -0
  103. package/hooks/jetbrains-copilot/sessionstart.mjs +119 -0
  104. package/hooks/kiro/posttooluse.mjs +6 -7
  105. package/hooks/kiro/pretooluse.mjs +3 -2
  106. package/hooks/posttooluse.mjs +8 -8
  107. package/hooks/precompact.mjs +3 -4
  108. package/hooks/pretooluse.mjs +5 -4
  109. package/hooks/routing-block.mjs +35 -33
  110. package/hooks/session-attribution.bundle.mjs +1 -0
  111. package/hooks/session-db.bundle.mjs +27 -8
  112. package/hooks/session-extract.bundle.mjs +2 -1
  113. package/hooks/session-helpers.mjs +44 -3
  114. package/hooks/session-loaders.mjs +37 -0
  115. package/hooks/sessionstart.mjs +5 -5
  116. package/hooks/userpromptsubmit.mjs +26 -9
  117. package/hooks/vscode-copilot/posttooluse.mjs +8 -8
  118. package/hooks/vscode-copilot/precompact.mjs +2 -2
  119. package/hooks/vscode-copilot/pretooluse.mjs +3 -2
  120. package/hooks/vscode-copilot/sessionstart.mjs +2 -2
  121. package/insight/server.mjs +237 -25
  122. package/insight/src/lib/api.ts +2 -1
  123. package/insight/src/routes/index.tsx +16 -3
  124. package/insight/src/routes/search.tsx +1 -1
  125. package/openclaw.plugin.json +1 -1
  126. package/package.json +11 -2
  127. package/server.bundle.mjs +94 -80
  128. package/skills/ctx-insight/SKILL.md +1 -1
@@ -1,65 +1,60 @@
1
1
  # context-mode — MANDATORY routing rules
2
2
 
3
- You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Antigravity does NOT have hooks, so these instructions are your ONLY enforcement mechanism. Follow them strictly.
3
+ context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context. Antigravity has NO hooks these instructions are ONLY enforcement. Follow strictly.
4
4
 
5
5
  ## Think in Code — MANDATORY
6
6
 
7
- When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `mcp__context-mode__ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
7
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `mcp__context-mode__ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
8
8
 
9
- ## BLOCKED commands — do NOT use these
9
+ ## BLOCKED — do NOT use
10
10
 
11
11
  ### curl / wget — FORBIDDEN
12
- Do NOT use `curl` or `wget` via `run_command`. They dump raw HTTP responses directly into your context window.
13
- Instead use:
14
- - `mcp__context-mode__ctx_fetch_and_index(url, source)` to fetch and index web pages
15
- - `mcp__context-mode__ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
12
+ Do NOT use `curl`/`wget` via `run_command`. Dumps raw HTTP into context.
13
+ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` or `mcp__context-mode__ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
16
14
 
17
15
  ### Inline HTTP — FORBIDDEN
18
- Do NOT run inline HTTP calls via `run_command` with `node -e "fetch(..."`, `python -c "requests.get(..."`, or similar patterns. They bypass the sandbox and flood context.
19
- Instead use:
20
- - `mcp__context-mode__ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
16
+ No `node -e "fetch(..."`, `python -c "requests.get(..."` via `run_command`. Bypasses sandbox.
17
+ Use: `mcp__context-mode__ctx_execute(language, code)` — only stdout enters context
21
18
 
22
19
  ### Direct web fetching — FORBIDDEN
23
- Do NOT use `read_url_content` for large pages. Raw HTML can exceed 100 KB.
24
- Instead use:
25
- - `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` to query the indexed content
20
+ No `read_url_content` for large pages. Raw HTML can exceed 100 KB.
21
+ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)`
26
22
 
27
- ## REDIRECTED tools — use sandbox equivalents
23
+ ## REDIRECTED — use sandbox
28
24
 
29
25
  ### Shell (>20 lines output)
30
- `run_command` is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
31
- For everything else, use:
32
- - `mcp__context-mode__ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
33
- - `mcp__context-mode__ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
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: "...")`
34
28
 
35
29
  ### File reading (for analysis)
36
- If you are reading a file to **edit** it → `view_file` / `replace_file_content` is correct (edit needs content in context).
37
- If you are reading to **analyze, explore, or summarize** → use `mcp__context-mode__ctx_execute_file(path, language, code)` instead. Only your printed summary enters context. The raw file stays in the sandbox.
30
+ Reading to **edit** → `view_file`/`replace_file_content` correct. Reading to **analyze/explore/summarize** → `mcp__context-mode__ctx_execute_file(path, language, code)`.
38
31
 
39
32
  ### Search (large results)
40
- Search results can flood context. Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
33
+ Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
41
34
 
42
- ## Tool selection hierarchy
35
+ ## Tool selection
43
36
 
44
- 1. **GATHER**: `mcp__context-mode__ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls. Each command: `{label: "descriptive header", command: "..."}`. Label becomes FTS5 chunk title — descriptive labels improve search.
45
- 2. **FOLLOW-UP**: `mcp__context-mode__ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
46
- 3. **PROCESSING**: `mcp__context-mode__ctx_execute(language, code)` | `mcp__context-mode__ctx_execute_file(path, language, code)` — Sandbox execution. Only stdout enters context.
47
- 4. **WEB**: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
48
- 5. **INDEX**: `mcp__context-mode__ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
37
+ 1. **GATHER**: `mcp__context-mode__ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
38
+ 2. **FOLLOW-UP**: `mcp__context-mode__ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
39
+ 3. **PROCESSING**: `mcp__context-mode__ctx_execute(language, code)` | `mcp__context-mode__ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
40
+ 4. **WEB**: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` — raw HTML never enters context.
41
+ 5. **INDEX**: `mcp__context-mode__ctx_index(content, source)` — store in FTS5 for later search.
49
42
 
50
- ## Output constraints
43
+ ## Output
51
44
 
52
- - Keep responses under 500 words.
53
- - Write artifacts (code, configs, PRDs) to FILES never return them as inline text. Return only: file path + 1-line description.
54
- - When indexing content, use descriptive source labels so others can `search(source: "label")` later.
45
+ Terse like caveman. Technical substance exact. Only fluff die.
46
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
47
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
48
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
49
+ Descriptive source labels for `search(source: "label")`.
55
50
 
56
51
  ## ctx commands
57
52
 
58
53
  | Command | Action |
59
54
  |---------|--------|
60
- | `ctx stats` | Call the `stats` MCP tool and display the full output verbatim |
61
- | `ctx doctor` | Call the `doctor` MCP tool, run the returned shell command, display as checklist |
62
- | `ctx upgrade` | Call the `upgrade` MCP tool, run the returned shell command, display as checklist |
63
- | `ctx purge` | Call the `purge` MCP tool with confirm: true. Warns before wiping the knowledge base. |
55
+ | `ctx stats` | Call `stats` MCP tool, display full output verbatim |
56
+ | `ctx doctor` | Call `doctor` MCP tool, run returned shell command, display as checklist |
57
+ | `ctx upgrade` | Call `upgrade` MCP tool, run returned shell command, display as checklist |
58
+ | `ctx purge` | Call `purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
64
59
 
65
- After /clear or /compact: knowledge base and session stats are preserved. Use `ctx purge` if you want to start fresh.
60
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
@@ -1,69 +1,63 @@
1
1
  # context-mode — MANDATORY routing rules
2
2
 
3
- You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
3
+ context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context.
4
4
 
5
5
  ## Think in Code — MANDATORY
6
6
 
7
- When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
7
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
8
8
 
9
- ## BLOCKED commands — do NOT attempt these
9
+ ## BLOCKED — do NOT attempt
10
10
 
11
11
  ### curl / wget — BLOCKED
12
- Any Bash command containing `curl` or `wget` is intercepted and replaced with an error message. Do NOT retry.
13
- Instead use:
14
- - `ctx_fetch_and_index(url, source)` to fetch and index web pages
15
- - `ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
12
+ Intercepted and replaced with error. Do NOT retry.
13
+ Use: `ctx_fetch_and_index(url, source)` or `ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
16
14
 
17
15
  ### Inline HTTP — BLOCKED
18
- Any Bash command containing `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, or `http.request(` is intercepted and replaced with an error message. Do NOT retry with Bash.
19
- Instead use:
20
- - `ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
16
+ `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, `http.request(` intercepted. Do NOT retry.
17
+ Use: `ctx_execute(language, code)` — only stdout enters context
21
18
 
22
19
  ### WebFetch — BLOCKED
23
- WebFetch calls are denied entirely. The URL is extracted and you are told to use `ctx_fetch_and_index` instead.
24
- Instead use:
25
- - `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` to query the indexed content
20
+ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
26
21
 
27
- ## REDIRECTED tools — use sandbox equivalents
22
+ ## REDIRECTED — use sandbox
28
23
 
29
24
  ### Bash (>20 lines output)
30
- Bash is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
31
- For everything else, use:
32
- - `ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
33
- - `ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
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: "...")`
34
27
 
35
28
  ### Read (for analysis)
36
- If you are reading a file to **Edit** it → Read is correct (Edit needs content in context).
37
- If you are reading to **analyze, explore, or summarize** → use `ctx_execute_file(path, language, code)` instead. Only your printed summary enters context. The raw file content stays in the sandbox.
29
+ Reading to **Edit** → Read correct. Reading to **analyze/explore/summarize** `ctx_execute_file(path, language, code)`.
38
30
 
39
31
  ### Grep (large results)
40
- Grep results can flood context. Use `ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
32
+ Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
41
33
 
42
- ## Tool selection hierarchy
34
+ ## Tool selection
43
35
 
44
- 1. **GATHER**: `ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls. Each command: `{label: "descriptive header", command: "..."}`. Label becomes FTS5 chunk title — descriptive labels improve search.
45
- 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
46
- 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — Sandbox execution. Only stdout enters context.
47
- 4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
48
- 5. **INDEX**: `ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
36
+ 1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
37
+ 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
38
+ 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
39
+ 4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — raw HTML never enters context.
40
+ 5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
49
41
 
50
42
  ## Subagent routing
51
43
 
52
- When spawning subagents (Agent/Task tool), the routing block is automatically injected into their prompt. Bash-type subagents are upgraded to general-purpose so they have access to MCP tools. You do NOT need to manually instruct subagents about context-mode.
44
+ Routing block auto-injected into subagent prompts. Bash-type subagents upgraded to general-purpose. No manual instruction needed.
53
45
 
54
- ## Output constraints
46
+ ## Output
55
47
 
56
- - Keep responses under 500 words.
57
- - Write artifacts (code, configs, PRDs) to FILES never return them as inline text. Return only: file path + 1-line description.
58
- - When indexing content, use descriptive source labels so others can `ctx_search(source: "label")` later.
48
+ Terse like caveman. Technical substance exact. Only fluff die.
49
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
50
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
51
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
52
+ Descriptive source labels for `ctx_search(source: "label")`.
59
53
 
60
54
  ## ctx commands
61
55
 
62
56
  | Command | Action |
63
57
  |---------|--------|
64
- | `ctx stats` | Call the `ctx_stats` MCP tool and display the full output verbatim |
65
- | `ctx doctor` | Call the `ctx_doctor` MCP tool, run the returned shell command, display as checklist |
66
- | `ctx upgrade` | Call the `ctx_upgrade` MCP tool, run the returned shell command, display as checklist |
67
- | `ctx purge` | Call the `ctx_purge` MCP tool with confirm: true. Warns before wiping the knowledge base. |
58
+ | `ctx stats` | Call `ctx_stats` MCP tool, display full output verbatim |
59
+ | `ctx doctor` | Call `ctx_doctor` MCP tool, run returned shell command, display as checklist |
60
+ | `ctx upgrade` | Call `ctx_upgrade` MCP tool, run returned shell command, display as checklist |
61
+ | `ctx purge` | Call `ctx_purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
68
62
 
69
- After /clear or /compact: knowledge base and session stats are preserved. Use `ctx purge` if you want to start fresh.
63
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
@@ -1,84 +1,70 @@
1
1
  # context-mode — MANDATORY routing rules
2
2
 
3
- You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Codex CLI does NOT have hooks, so these instructions are your ONLY enforcement mechanism. Follow them strictly.
3
+ context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context. Codex CLI has NO hooks these instructions are ONLY enforcement. Follow strictly.
4
4
 
5
5
  ## Think in Code — MANDATORY
6
6
 
7
- When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
7
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
8
8
 
9
- ## BLOCKED commands — do NOT use these
9
+ ## BLOCKED — do NOT use
10
10
 
11
11
  ### curl / wget — FORBIDDEN
12
- Do NOT use `curl` or `wget` in any shell command. They dump raw HTTP responses directly into your context window.
13
- Instead use:
14
- - `ctx_fetch_and_index(url, source)` to fetch and index web pages
15
- - `ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
12
+ Do NOT use `curl`/`wget` in shell. Dumps raw HTTP into context.
13
+ Use: `ctx_fetch_and_index(url, source)` or `ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
16
14
 
17
15
  ### Inline HTTP — FORBIDDEN
18
- Do NOT run inline HTTP calls via `node -e "fetch(..."`, `python -c "requests.get(..."`, or similar patterns. They bypass the sandbox and flood context.
19
- Instead use:
20
- - `ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
16
+ No `node -e "fetch(..."`, `python -c "requests.get(..."`. Bypasses sandbox.
17
+ Use: `ctx_execute(language, code)` — only stdout enters context
21
18
 
22
19
  ### Direct web fetching — FORBIDDEN
23
- Do NOT use any direct URL fetching tool. Raw HTML can exceed 100 KB.
24
- Instead use:
25
- - `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` to query the indexed content
20
+ Raw HTML can exceed 100 KB.
21
+ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
26
22
 
27
- ## REDIRECTED tools — use sandbox equivalents
23
+ ## REDIRECTED — use sandbox
28
24
 
29
25
  ### Shell (>20 lines output)
30
- Shell is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
31
- For everything else, use:
32
- - `ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
33
- - `ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
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: "...")`
34
28
 
35
29
  ### File reading (for analysis)
36
- If you are reading a file to **edit** it reading is correct (edit needs content in context).
37
- If you are reading to **analyze, explore, or summarize** → use `ctx_execute_file(path, language, code)` instead. Only your printed summary enters context. The raw file stays in the sandbox.
30
+ Reading to **edit** reading correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
38
31
 
39
32
  ### grep / search (large results)
40
- Search results can flood context. Use `ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
33
+ Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
41
34
 
42
- ## Tool selection hierarchy
35
+ ## Tool selection
43
36
 
44
- 1. **GATHER**: `ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls. Each command: `{label: "descriptive header", command: "..."}`. Label becomes FTS5 chunk title — descriptive labels improve search.
45
- 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
46
- 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — Sandbox execution. Only stdout enters context.
47
- 4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
48
- 5. **INDEX**: `ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
37
+ 1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
38
+ 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
39
+ 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
40
+ 4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — raw HTML never enters context.
41
+ 5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
49
42
 
50
- ## Output constraints
43
+ ## Output
51
44
 
52
- - Keep responses under 500 words.
53
- - Write artifacts (code, configs, PRDs) to FILES never return them as inline text. Return only: file path + 1-line description.
54
- - When indexing content, use descriptive source labels so others can `search(source: "label")` later.
45
+ Terse like caveman. Technical substance exact. Only fluff die.
46
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
47
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
48
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
49
+ Descriptive source labels for `search(source: "label")`.
55
50
 
56
51
  ## ctx commands
57
52
 
58
53
  | Command | Action |
59
54
  |---------|--------|
60
- | `ctx stats` | Call the `stats` MCP tool and display the full output verbatim |
61
- | `ctx doctor` | Call the `doctor` MCP tool, run the returned shell command, display as checklist |
62
- | `ctx upgrade` | Call the `upgrade` MCP tool, run the returned shell command, display as checklist |
63
- | `ctx purge` | Call the `purge` MCP tool with confirm: true. Warns before wiping the knowledge base. |
55
+ | `ctx stats` | Call `stats` MCP tool, display full output verbatim |
56
+ | `ctx doctor` | Call `doctor` MCP tool, run returned shell command, display as checklist |
57
+ | `ctx upgrade` | Call `upgrade` MCP tool, run returned shell command, display as checklist |
58
+ | `ctx purge` | Call `purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
64
59
 
65
- After /clear or /compact: knowledge base and session stats are preserved. Use `ctx purge` if you want to start fresh.
60
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
66
61
 
67
62
  ## Windows notes
68
63
 
69
- **PowerShell cmdlets in shell scripts** The sandbox executes scripts via bash. PowerShell
70
- cmdlets (`Format-List`, `Format-Table`, `Get-Culture`, etc.) do not exist in bash and will fail
71
- with `command not found`. Wrap them with `pwsh -NoProfile -Command "..."` instead.
64
+ **PowerShell cmdlets** Sandbox uses bash. PowerShell cmdlets (`Format-List`, `Get-Culture`, etc.) fail with `command not found`. Wrap with `pwsh -NoProfile -Command "..."`.
72
65
 
73
- **Relative paths** — The sandbox CWD is a temp directory, not your project root. Always convert
74
- any user-supplied path to an absolute path before passing it to `rg`, `grep`, or `find`.
75
- Ask the user to confirm the absolute path if it is not already known.
66
+ **Relative paths** — Sandbox CWD is temp dir, not project root. Convert to absolute paths. Ask user to confirm if unknown.
76
67
 
77
- **Windows drive letter paths** — The sandbox runs Git Bash / MSYS2, not WSL. Drive letters must
78
- use the MSYS2 convention, NOT the WSL convention:
79
- `X:\path` → `/x/path` (lowercase letter, no `/mnt/` prefix).
80
- Never emit `/mnt/<letter>/` prefixes regardless of which drive the project is on.
68
+ **Windows drive letters** — Sandbox runs Git Bash / MSYS2. `X:\path` → `/x/path` (lowercase, no `/mnt/`). Never emit `/mnt/<letter>/`.
81
69
 
82
- **Always quote paths** — If a path contains spaces, bash splits it into separate arguments.
83
- Always wrap every path in double quotes: `rg "symbol" "$REPO_ROOT/some dir/Source"`.
84
- This applies to all tools: `rg`, `grep`, `find`, `ls`, etc.
70
+ **Quote paths** — Spaces in paths cause splits. Always double-quote: `rg "symbol" "$REPO_ROOT/some dir/Source"`.
@@ -5,48 +5,47 @@ alwaysApply: true
5
5
 
6
6
  # context-mode
7
7
 
8
- Raw tool output floods your context window. Use context-mode MCP tools to keep raw data in the sandbox.
8
+ Raw tool output floods context window. Use context-mode MCP tools to keep raw data in sandbox.
9
9
 
10
10
  ## Think in Code — MANDATORY
11
11
 
12
- When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
12
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
13
13
 
14
- ## Tool Selection Hierarchy
14
+ ## Tool Selection
15
15
 
16
- 1. **GATHER**: `ctx_batch_execute(commands, queries)` — Primary tool for research. Runs all commands, auto-indexes, and searches. ONE call replaces many individual steps.
17
- 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — Use for all follow-up questions. ONE call, many queries.
18
- 3. **PROCESSING**: `ctx_execute(language, code)` or `ctx_execute_file(path, language, code)` — Use for API calls, log analysis, and data processing.
19
- 4. **WEB**: `ctx_fetch_and_index(url)` then `ctx_search(queries)` — Fetch, index, then query. Never dump raw HTML.
20
- 5. **INDEX**: `ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
16
+ 1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, searches. ONE call replaces many steps.
17
+ 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all follow-up questions, ONE call.
18
+ 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
19
+ 4. **WEB**: `ctx_fetch_and_index(url)` then `ctx_search(queries)` — never dump raw HTML.
20
+ 5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
21
21
 
22
22
  ## Forbidden Actions
23
23
 
24
- - DO NOT use Bash for commands producing >20 lines of output — use `ctx_execute` or `ctx_batch_execute`.
25
- - DO NOT use Read for analysis — use `ctx_execute_file`. Read IS correct for files you intend to Edit.
26
- - DO NOT use WebFetch — use `ctx_fetch_and_index` instead.
24
+ - DO NOT use Bash for >20 lines output — use `ctx_execute` or `ctx_batch_execute`.
25
+ - DO NOT use Read for analysis — use `ctx_execute_file`. Read IS correct for Edit.
26
+ - DO NOT use WebFetch — use `ctx_fetch_and_index`.
27
27
  - DO NOT use curl/wget in terminal — use `ctx_fetch_and_index`.
28
- - Bash is ONLY for git, mkdir, rm, mv, navigation, and short commands.
29
- - DO NOT use `ctx_execute` or `ctx_execute_file` to create, modify, or overwrite files. ctx_execute is for data analysis, log processing, and computation only.
28
+ - Bash ONLY for git, mkdir, rm, mv, navigation, short commands.
29
+ - DO NOT use `ctx_execute`/`ctx_execute_file` to create/modify files. ctx_execute is for analysis and computation only.
30
30
 
31
31
  ## File Writing Policy
32
32
 
33
- ALWAYS use the native file editing tools to create and modify files. NEVER use `ctx_execute`, `ctx_execute_file`, or Bash to write file content. This applies to all file types: code, configs, plans, specs, YAML, JSON, markdown.
33
+ ALWAYS use native file editing tools to create/modify files. NEVER use `ctx_execute`, `ctx_execute_file`, or Bash to write file content.
34
34
 
35
- ## Output Constraints
35
+ ## Output
36
36
 
37
- - Keep responses under 500 words.
38
- - Write artifacts (code, configs) to FILES never return them as inline text.
39
- - Return only: file path + 1-line description.
37
+ Terse like caveman. Technical substance exact. Only fluff die.
38
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
39
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
40
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
40
41
 
41
42
  ## ctx Commands
42
43
 
43
44
  | Command | Action |
44
45
  |---------|--------|
45
- | `ctx stats` | Call the ctx_stats MCP tool and display the full output verbatim. |
46
- | `ctx doctor` | Call the ctx_doctor MCP tool, run the returned shell command, display results as a checklist. |
47
- | `ctx upgrade` | Call the ctx_upgrade MCP tool, run the returned shell command, display results as a checklist. |
48
- | `ctx purge` | Call the ctx_purge MCP tool with confirm: true. Warn the user this is irreversible. |
46
+ | `ctx stats` | Call ctx_stats MCP tool, display full output verbatim. |
47
+ | `ctx doctor` | Call ctx_doctor MCP tool, run returned shell command, display as checklist. |
48
+ | `ctx upgrade` | Call ctx_upgrade MCP tool, run returned shell command, display as checklist. |
49
+ | `ctx purge` | Call ctx_purge MCP tool with confirm: true. Warn user this is irreversible. |
49
50
 
50
- ## /clear and /compact Preservation
51
-
52
- After /clear or /compact: knowledge base and session stats are preserved. Inform the user: "context-mode knowledge base preserved. Use `ctx purge` if you want to start fresh."
51
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
@@ -1,65 +1,59 @@
1
1
  # context-mode — MANDATORY routing rules
2
2
 
3
- You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
3
+ context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context.
4
4
 
5
5
  ## Think in Code — MANDATORY
6
6
 
7
- When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `mcp__context-mode__ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
7
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `mcp__context-mode__ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
8
8
 
9
- ## BLOCKED commands — do NOT attempt these
9
+ ## BLOCKED — do NOT attempt
10
10
 
11
11
  ### curl / wget — BLOCKED
12
- Any shell command containing `curl` or `wget` will be intercepted and blocked. Do NOT retry.
13
- Instead use:
14
- - `mcp__context-mode__ctx_fetch_and_index(url, source)` to fetch and index web pages
15
- - `mcp__context-mode__ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
12
+ Shell `curl`/`wget` intercepted and blocked. Do NOT retry.
13
+ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` or `mcp__context-mode__ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
16
14
 
17
15
  ### Inline HTTP — BLOCKED
18
- Any shell command containing `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, or `http.request(` will be intercepted and blocked. Do NOT retry with shell.
19
- Instead use:
20
- - `mcp__context-mode__ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
16
+ `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, `http.request(` intercepted. Do NOT retry.
17
+ Use: `mcp__context-mode__ctx_execute(language, code)` — only stdout enters context
21
18
 
22
19
  ### WebFetch / web browsing — BLOCKED
23
- Direct web fetching is blocked. Use the sandbox equivalent.
24
- Instead use:
25
- - `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` to query the indexed content
20
+ Use: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)`
26
21
 
27
- ## REDIRECTED tools — use sandbox equivalents
22
+ ## REDIRECTED — use sandbox
28
23
 
29
24
  ### Shell (>20 lines output)
30
- Shell is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
31
- For everything else, use:
32
- - `mcp__context-mode__ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
33
- - `mcp__context-mode__ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
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: "...")`
34
27
 
35
28
  ### read_file (for analysis)
36
- If you are reading a file to **edit** it → read_file is correct (edit needs content in context).
37
- If you are reading to **analyze, explore, or summarize** → use `mcp__context-mode__ctx_execute_file(path, language, code)` instead. Only your printed summary enters context.
29
+ Reading to **edit** → read_file correct. Reading to **analyze/explore/summarize** `mcp__context-mode__ctx_execute_file(path, language, code)`.
38
30
 
39
31
  ### grep / search (large results)
40
- Search results can flood context. Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
32
+ Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
41
33
 
42
- ## Tool selection hierarchy
34
+ ## Tool selection
43
35
 
44
- 1. **GATHER**: `mcp__context-mode__ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls. Each command: `{label: "descriptive header", command: "..."}`. Label becomes FTS5 chunk title — descriptive labels improve search.
45
- 2. **FOLLOW-UP**: `mcp__context-mode__ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
46
- 3. **PROCESSING**: `mcp__context-mode__ctx_execute(language, code)` | `mcp__context-mode__ctx_execute_file(path, language, code)` — Sandbox execution. Only stdout enters context.
47
- 4. **WEB**: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
48
- 5. **INDEX**: `mcp__context-mode__ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
36
+ 1. **GATHER**: `mcp__context-mode__ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
37
+ 2. **FOLLOW-UP**: `mcp__context-mode__ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
38
+ 3. **PROCESSING**: `mcp__context-mode__ctx_execute(language, code)` | `mcp__context-mode__ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
39
+ 4. **WEB**: `mcp__context-mode__ctx_fetch_and_index(url, source)` then `mcp__context-mode__ctx_search(queries)` — raw HTML never enters context.
40
+ 5. **INDEX**: `mcp__context-mode__ctx_index(content, source)` — store in FTS5 for later search.
49
41
 
50
- ## Output constraints
42
+ ## Output
51
43
 
52
- - Keep responses under 500 words.
53
- - Write artifacts (code, configs, PRDs) to FILES never return them as inline text. Return only: file path + 1-line description.
54
- - When indexing content, use descriptive source labels so others can `search(source: "label")` later.
44
+ Terse like caveman. Technical substance exact. Only fluff die.
45
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
46
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
47
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
48
+ Descriptive source labels for `search(source: "label")`.
55
49
 
56
50
  ## ctx commands
57
51
 
58
52
  | Command | Action |
59
53
  |---------|--------|
60
- | `ctx stats` | Call the `stats` MCP tool and display the full output verbatim |
61
- | `ctx doctor` | Call the `doctor` MCP tool, run the returned shell command, display as checklist |
62
- | `ctx upgrade` | Call the `upgrade` MCP tool, run the returned shell command, display as checklist |
63
- | `ctx purge` | Call the `purge` MCP tool with confirm: true. Warns before wiping the knowledge base. |
54
+ | `ctx stats` | Call `stats` MCP tool, display full output verbatim |
55
+ | `ctx doctor` | Call `doctor` MCP tool, run returned shell command, display as checklist |
56
+ | `ctx upgrade` | Call `upgrade` MCP tool, run returned shell command, display as checklist |
57
+ | `ctx purge` | Call `purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
64
58
 
65
- After /clear or /compact: knowledge base and session stats are preserved. Use `ctx purge` if you want to start fresh.
59
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
@@ -0,0 +1,59 @@
1
+ # context-mode — MANDATORY routing rules
2
+
3
+ context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context.
4
+
5
+ ## Think in Code — MANDATORY
6
+
7
+ Analyze/count/filter/compare/search/parse/transform data: **write code** via `ctx_execute(language, code)`, `console.log()` only the answer. Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it. Pure JavaScript — Node.js built-ins only (`fs`, `path`, `child_process`). `try/catch`, handle `null`/`undefined`. One script replaces ten tool calls.
8
+
9
+ ## BLOCKED — do NOT attempt
10
+
11
+ ### curl / wget — BLOCKED
12
+ Terminal `curl`/`wget` intercepted and blocked. Do NOT retry.
13
+ Use: `ctx_fetch_and_index(url, source)` or `ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
14
+
15
+ ### Inline HTTP — BLOCKED
16
+ `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, `http.request(` — intercepted. Do NOT retry.
17
+ Use: `ctx_execute(language, code)` — only stdout enters context
18
+
19
+ ### WebFetch / fetch — BLOCKED
20
+ Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
21
+
22
+ ## REDIRECTED — use sandbox
23
+
24
+ ### Terminal / run_in_terminal (>20 lines output)
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: "...")`
27
+
28
+ ### read_file (for analysis)
29
+ Reading to **edit** → read_file correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
30
+
31
+ ### grep / search (large results)
32
+ Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
33
+
34
+ ## Tool selection
35
+
36
+ 1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
37
+ 2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
38
+ 3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
39
+ 4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — raw HTML never enters context.
40
+ 5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
41
+
42
+ ## Output
43
+
44
+ Terse like caveman. Technical substance exact. Only fluff die.
45
+ Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
46
+ Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
47
+ Write artifacts to FILES — never inline. Return: file path + 1-line description.
48
+ Descriptive source labels for `ctx_search(source: "label")`.
49
+
50
+ ## ctx commands
51
+
52
+ | Command | Action |
53
+ |---------|--------|
54
+ | `ctx stats` | Call `ctx_stats` MCP tool, display full output verbatim |
55
+ | `ctx doctor` | Call `ctx_doctor` MCP tool, run returned shell command, display as checklist |
56
+ | `ctx upgrade` | Call `ctx_upgrade` MCP tool, run returned shell command, display as checklist |
57
+ | `ctx purge` | Call `ctx_purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
58
+
59
+ After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
@@ -0,0 +1,16 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ { "type": "command", "command": "context-mode hook jetbrains-copilot pretooluse" }
5
+ ],
6
+ "PostToolUse": [
7
+ { "type": "command", "command": "context-mode hook jetbrains-copilot posttooluse" }
8
+ ],
9
+ "PreCompact": [
10
+ { "type": "command", "command": "context-mode hook jetbrains-copilot precompact" }
11
+ ],
12
+ "SessionStart": [
13
+ { "type": "command", "command": "context-mode hook jetbrains-copilot sessionstart" }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "servers": {
3
+ "context-mode": {
4
+ "command": "npx",
5
+ "args": ["-y", "context-mode"]
6
+ }
7
+ }
8
+ }