context-mode 1.0.89 → 1.0.90
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/README.md +184 -60
- package/build/adapters/antigravity/index.d.ts +3 -5
- package/build/adapters/antigravity/index.js +7 -35
- package/build/adapters/base.d.ts +27 -0
- package/build/adapters/base.js +59 -0
- package/build/adapters/claude-code/index.d.ts +9 -25
- package/build/adapters/claude-code/index.js +12 -140
- package/build/adapters/claude-code-base.d.ts +49 -0
- package/build/adapters/claude-code-base.js +113 -0
- package/build/adapters/client-map.js +5 -0
- package/build/adapters/codex/hooks.d.ts +21 -14
- package/build/adapters/codex/hooks.js +22 -15
- package/build/adapters/codex/index.d.ts +6 -10
- package/build/adapters/codex/index.js +13 -43
- package/build/adapters/copilot-base.d.ts +78 -0
- package/build/adapters/copilot-base.js +281 -0
- package/build/adapters/cursor/index.d.ts +3 -5
- package/build/adapters/cursor/index.js +6 -34
- package/build/adapters/detect.d.ts +7 -0
- package/build/adapters/detect.js +57 -56
- package/build/adapters/gemini-cli/index.d.ts +3 -5
- package/build/adapters/gemini-cli/index.js +7 -35
- package/build/adapters/jetbrains-copilot/config.d.ts +8 -0
- package/build/adapters/jetbrains-copilot/config.js +8 -0
- package/build/adapters/jetbrains-copilot/hooks.d.ts +51 -0
- package/build/adapters/jetbrains-copilot/hooks.js +82 -0
- package/build/adapters/jetbrains-copilot/index.d.ts +24 -0
- package/build/adapters/jetbrains-copilot/index.js +119 -0
- package/build/adapters/kiro/hooks.d.ts +14 -0
- package/build/adapters/kiro/hooks.js +23 -0
- package/build/adapters/kiro/index.d.ts +3 -5
- package/build/adapters/kiro/index.js +10 -38
- package/build/adapters/openclaw/index.d.ts +3 -4
- package/build/adapters/openclaw/index.js +6 -22
- package/build/adapters/opencode/index.d.ts +2 -3
- package/build/adapters/opencode/index.js +5 -16
- package/build/adapters/qwen-code/index.d.ts +39 -0
- package/build/adapters/qwen-code/index.js +199 -0
- package/build/adapters/types.d.ts +1 -1
- package/build/adapters/vscode-copilot/index.d.ts +16 -46
- package/build/adapters/vscode-copilot/index.js +29 -320
- package/build/adapters/zed/index.d.ts +3 -5
- package/build/adapters/zed/index.js +7 -35
- package/build/cli.js +13 -0
- package/build/lifecycle.d.ts +23 -0
- package/build/lifecycle.js +54 -13
- package/build/opencode-plugin.d.ts +19 -7
- package/build/opencode-plugin.js +19 -7
- package/build/runtime.js +24 -9
- package/build/security.d.ts +17 -1
- package/build/security.js +40 -6
- package/build/server.js +41 -9
- package/build/session/analytics.d.ts +8 -7
- package/build/session/analytics.js +95 -75
- package/build/session/db.d.ts +10 -1
- package/build/session/db.js +67 -8
- package/build/session/extract.js +10 -2
- package/build/session/project-attribution.d.ts +73 -0
- package/build/session/project-attribution.js +231 -0
- package/build/store.d.ts +4 -0
- package/build/store.js +58 -9
- package/build/types.d.ts +8 -0
- package/cli.bundle.mjs +135 -121
- package/configs/antigravity/GEMINI.md +31 -36
- package/configs/claude-code/CLAUDE.md +31 -37
- package/configs/codex/AGENTS.md +35 -49
- package/configs/cursor/context-mode.mdc +24 -25
- package/configs/gemini-cli/GEMINI.md +30 -36
- package/configs/jetbrains-copilot/copilot-instructions.md +59 -0
- package/configs/jetbrains-copilot/hooks.json +16 -0
- package/configs/jetbrains-copilot/mcp.json +8 -0
- package/configs/kilo/AGENTS.md +30 -36
- package/configs/kiro/KIRO.md +30 -36
- package/configs/kiro/agent.json +1 -1
- package/configs/openclaw/AGENTS.md +30 -36
- package/configs/opencode/AGENTS.md +30 -36
- package/configs/pi/AGENTS.md +31 -36
- package/configs/qwen-code/QWEN.md +63 -0
- package/configs/vscode-copilot/copilot-instructions.md +30 -36
- package/configs/zed/AGENTS.md +31 -36
- package/hooks/codex/posttooluse.mjs +7 -7
- package/hooks/codex/pretooluse.mjs +3 -3
- package/hooks/codex/sessionstart.mjs +2 -1
- package/hooks/core/formatters.mjs +24 -0
- package/hooks/core/routing.mjs +40 -15
- package/hooks/core/tool-naming.mjs +2 -0
- package/hooks/cursor/posttooluse.mjs +7 -7
- package/hooks/cursor/pretooluse.mjs +3 -3
- package/hooks/cursor/sessionstart.mjs +2 -1
- package/hooks/cursor/stop.mjs +2 -2
- package/hooks/ensure-deps.mjs +22 -10
- package/hooks/gemini-cli/aftertool.mjs +8 -8
- package/hooks/gemini-cli/beforetool.mjs +3 -2
- package/hooks/gemini-cli/precompress.mjs +2 -2
- package/hooks/gemini-cli/sessionstart.mjs +12 -4
- package/hooks/jetbrains-copilot/posttooluse.mjs +61 -0
- package/hooks/jetbrains-copilot/precompact.mjs +54 -0
- package/hooks/jetbrains-copilot/pretooluse.mjs +27 -0
- package/hooks/jetbrains-copilot/sessionstart.mjs +119 -0
- package/hooks/kiro/posttooluse.mjs +6 -7
- package/hooks/kiro/pretooluse.mjs +3 -2
- package/hooks/posttooluse.mjs +8 -8
- package/hooks/precompact.mjs +3 -4
- package/hooks/pretooluse.mjs +5 -4
- package/hooks/routing-block.mjs +35 -33
- package/hooks/session-attribution.bundle.mjs +1 -0
- package/hooks/session-db.bundle.mjs +27 -8
- package/hooks/session-extract.bundle.mjs +2 -1
- package/hooks/session-helpers.mjs +44 -3
- package/hooks/session-loaders.mjs +37 -0
- package/hooks/sessionstart.mjs +5 -5
- package/hooks/userpromptsubmit.mjs +26 -9
- package/hooks/vscode-copilot/posttooluse.mjs +8 -8
- package/hooks/vscode-copilot/precompact.mjs +2 -2
- package/hooks/vscode-copilot/pretooluse.mjs +3 -2
- package/hooks/vscode-copilot/sessionstart.mjs +2 -2
- package/insight/server.mjs +237 -25
- package/insight/src/lib/api.ts +2 -1
- package/insight/src/routes/index.tsx +16 -3
- package/insight/src/routes/search.tsx +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +11 -2
- package/server.bundle.mjs +94 -80
- package/skills/ctx-insight/SKILL.md +1 -1
package/configs/kilo/AGENTS.md
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
1
|
# context-mode — MANDATORY routing rules
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
Analyze/count/filter/compare/search/parse/transform data: **write code** via `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
|
|
9
|
+
## BLOCKED — do NOT attempt
|
|
10
10
|
|
|
11
11
|
### curl / wget — BLOCKED
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `context-mode_ctx_fetch_and_index(url, source)` to fetch and index web pages
|
|
15
|
-
- `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: `context-mode_ctx_fetch_and_index(url, source)` or `context-mode_ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
|
|
16
14
|
|
|
17
15
|
### Inline HTTP — BLOCKED
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- `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: `context-mode_ctx_execute(language, code)` — only stdout enters context
|
|
21
18
|
|
|
22
19
|
### Direct web fetching — BLOCKED
|
|
23
|
-
|
|
24
|
-
Instead use:
|
|
25
|
-
- `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` to query the indexed content
|
|
20
|
+
Use: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)`
|
|
26
21
|
|
|
27
|
-
## REDIRECTED
|
|
22
|
+
## REDIRECTED — use sandbox
|
|
28
23
|
|
|
29
24
|
### Shell (>20 lines output)
|
|
30
|
-
Shell
|
|
31
|
-
|
|
32
|
-
- `context-mode_ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
|
|
33
|
-
- `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: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "shell", code: "...")`
|
|
34
27
|
|
|
35
28
|
### File reading (for analysis)
|
|
36
|
-
|
|
37
|
-
If you are reading to **analyze, explore, or summarize** → use `context-mode_ctx_execute_file(path, language, code)` instead. Only your printed summary enters context.
|
|
29
|
+
Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode_ctx_execute_file(path, language, code)`.
|
|
38
30
|
|
|
39
31
|
### grep / search (large results)
|
|
40
|
-
|
|
32
|
+
Use `context-mode_ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
41
33
|
|
|
42
|
-
## Tool selection
|
|
34
|
+
## Tool selection
|
|
43
35
|
|
|
44
|
-
1. **GATHER**: `context-mode_ctx_batch_execute(commands, queries)` —
|
|
45
|
-
2. **FOLLOW-UP**: `context-mode_ctx_search(queries: ["q1", "q2", ...])` —
|
|
46
|
-
3. **PROCESSING**: `context-mode_ctx_execute(language, code)` | `context-mode_ctx_execute_file(path, language, code)` —
|
|
47
|
-
4. **WEB**: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` —
|
|
48
|
-
5. **INDEX**: `context-mode_ctx_index(content, source)` —
|
|
36
|
+
1. **GATHER**: `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**: `context-mode_ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
|
|
38
|
+
3. **PROCESSING**: `context-mode_ctx_execute(language, code)` | `context-mode_ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
39
|
+
4. **WEB**: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` — raw HTML never enters context.
|
|
40
|
+
5. **INDEX**: `context-mode_ctx_index(content, source)` — store in FTS5 for later search.
|
|
49
41
|
|
|
50
|
-
## Output
|
|
42
|
+
## Output
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
61
|
-
| `ctx doctor` | Call
|
|
62
|
-
| `ctx upgrade` | Call
|
|
63
|
-
| `ctx purge` | Call
|
|
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
|
|
59
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|
package/configs/kiro/KIRO.md
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
1
|
# context-mode — MANDATORY routing rules
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
Analyze/count/filter/compare/search/parse/transform data: **write code** via `@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
|
|
9
|
+
## BLOCKED — do NOT attempt
|
|
10
10
|
|
|
11
11
|
### curl / wget — BLOCKED
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `@context-mode/ctx_fetch_and_index(url, source)` to fetch and index web pages
|
|
15
|
-
- `@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: `@context-mode/ctx_fetch_and_index(url, source)` or `@context-mode/ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
|
|
16
14
|
|
|
17
15
|
### Inline HTTP — BLOCKED
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- `@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: `@context-mode/ctx_execute(language, code)` — only stdout enters context
|
|
21
18
|
|
|
22
19
|
### Direct web fetching — BLOCKED
|
|
23
|
-
|
|
24
|
-
Instead use:
|
|
25
|
-
- `@context-mode/ctx_fetch_and_index(url, source)` then `@context-mode/ctx_search(queries)` to query the indexed content
|
|
20
|
+
Use: `@context-mode/ctx_fetch_and_index(url, source)` then `@context-mode/ctx_search(queries)`
|
|
26
21
|
|
|
27
|
-
## REDIRECTED
|
|
22
|
+
## REDIRECTED — use sandbox
|
|
28
23
|
|
|
29
24
|
### Shell (>20 lines output)
|
|
30
|
-
Shell
|
|
31
|
-
|
|
32
|
-
- `@context-mode/ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
|
|
33
|
-
- `@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: `@context-mode/ctx_batch_execute(commands, queries)` or `@context-mode/ctx_execute(language: "shell", code: "...")`
|
|
34
27
|
|
|
35
28
|
### fs_read / read (for analysis)
|
|
36
|
-
|
|
37
|
-
If you are reading to **analyze, explore, or summarize** → use `@context-mode/ctx_execute_file(path, language, code)` instead. Only your printed summary enters context.
|
|
29
|
+
Reading to **edit** → fs_read correct. Reading to **analyze/explore/summarize** → `@context-mode/ctx_execute_file(path, language, code)`.
|
|
38
30
|
|
|
39
31
|
### grep / search (large results)
|
|
40
|
-
|
|
32
|
+
Use `@context-mode/ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
41
33
|
|
|
42
|
-
## Tool selection
|
|
34
|
+
## Tool selection
|
|
43
35
|
|
|
44
|
-
1. **GATHER**: `@context-mode/ctx_batch_execute(commands, queries)` —
|
|
45
|
-
2. **FOLLOW-UP**: `@context-mode/ctx_search(queries: ["q1", "q2", ...])` —
|
|
46
|
-
3. **PROCESSING**: `@context-mode/ctx_execute(language, code)` | `@context-mode/ctx_execute_file(path, language, code)` —
|
|
47
|
-
4. **WEB**: `@context-mode/ctx_fetch_and_index(url, source)` then `@context-mode/ctx_search(queries)` —
|
|
48
|
-
5. **INDEX**: `@context-mode/ctx_index(content, source)` —
|
|
36
|
+
1. **GATHER**: `@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**: `@context-mode/ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
|
|
38
|
+
3. **PROCESSING**: `@context-mode/ctx_execute(language, code)` | `@context-mode/ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
39
|
+
4. **WEB**: `@context-mode/ctx_fetch_and_index(url, source)` then `@context-mode/ctx_search(queries)` — raw HTML never enters context.
|
|
40
|
+
5. **INDEX**: `@context-mode/ctx_index(content, source)` — store in FTS5 for later search.
|
|
49
41
|
|
|
50
|
-
## Output
|
|
42
|
+
## Output
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
61
|
-
| `ctx doctor` | Call
|
|
62
|
-
| `ctx upgrade` | Call
|
|
63
|
-
| `ctx purge` | Call
|
|
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
|
|
59
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|
package/configs/kiro/agent.json
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
1
|
# context-mode — MANDATORY routing rules
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
Analyze/count/filter/compare/search/parse/transform data: **write code** via `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
|
|
9
|
+
## BLOCKED — do NOT attempt
|
|
10
10
|
|
|
11
11
|
### curl / wget — BLOCKED
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
Shell `curl`/`wget` intercepted and blocked. Do NOT retry.
|
|
13
|
+
Use: `context-mode__ctx_fetch_and_index(url, source)` or `context-mode__ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
|
|
16
14
|
|
|
17
15
|
### Inline HTTP — BLOCKED
|
|
18
|
-
|
|
19
|
-
|
|
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: `context-mode__ctx_execute(language, code)` — only stdout enters context
|
|
21
18
|
|
|
22
19
|
### Direct web fetching — BLOCKED
|
|
23
|
-
|
|
24
|
-
Instead use:
|
|
25
|
-
- `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` to query the indexed content
|
|
20
|
+
Use: `context-mode__ctx_fetch_and_index(url, source)` then `context-mode__ctx_search(queries)`
|
|
26
21
|
|
|
27
|
-
## REDIRECTED
|
|
22
|
+
## REDIRECTED — use sandbox
|
|
28
23
|
|
|
29
24
|
### Shell (>20 lines output)
|
|
30
|
-
Shell
|
|
31
|
-
|
|
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
|
+
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: "...")`
|
|
34
27
|
|
|
35
28
|
### File reading (for analysis)
|
|
36
|
-
|
|
37
|
-
If you are reading to **analyze, explore, or summarize** → use `ctx_execute_file(path, language, code)` instead. Only your printed summary enters context.
|
|
29
|
+
Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode__ctx_execute_file(path, language, code)`.
|
|
38
30
|
|
|
39
31
|
### grep / search (large results)
|
|
40
|
-
|
|
32
|
+
Use `context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
41
33
|
|
|
42
|
-
## Tool selection
|
|
34
|
+
## Tool selection
|
|
43
35
|
|
|
44
|
-
1. **GATHER**: `
|
|
45
|
-
2. **FOLLOW-UP**: `
|
|
46
|
-
3. **PROCESSING**: `
|
|
47
|
-
4. **WEB**: `
|
|
48
|
-
5. **INDEX**: `
|
|
36
|
+
1. **GATHER**: `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**: `context-mode__ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
|
|
38
|
+
3. **PROCESSING**: `context-mode__ctx_execute(language, code)` | `context-mode__ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
39
|
+
4. **WEB**: `context-mode__ctx_fetch_and_index(url, source)` then `context-mode__ctx_search(queries)` — raw HTML never enters context.
|
|
40
|
+
5. **INDEX**: `context-mode__ctx_index(content, source)` — store in FTS5 for later search.
|
|
49
41
|
|
|
50
|
-
## Output
|
|
42
|
+
## Output
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
61
|
-
| `ctx doctor` | Call
|
|
62
|
-
| `ctx upgrade` | Call
|
|
63
|
-
| `ctx purge` | Call
|
|
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
|
|
59
|
+
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
|
-
|
|
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
|
-
|
|
7
|
+
Analyze/count/filter/compare/search/parse/transform data: **write code** via `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
|
|
9
|
+
## BLOCKED — do NOT attempt
|
|
10
10
|
|
|
11
11
|
### curl / wget — BLOCKED
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `context-mode_ctx_fetch_and_index(url, source)` to fetch and index web pages
|
|
15
|
-
- `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: `context-mode_ctx_fetch_and_index(url, source)` or `context-mode_ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
|
|
16
14
|
|
|
17
15
|
### Inline HTTP — BLOCKED
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- `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: `context-mode_ctx_execute(language, code)` — only stdout enters context
|
|
21
18
|
|
|
22
19
|
### Direct web fetching — BLOCKED
|
|
23
|
-
|
|
24
|
-
Instead use:
|
|
25
|
-
- `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` to query the indexed content
|
|
20
|
+
Use: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)`
|
|
26
21
|
|
|
27
|
-
## REDIRECTED
|
|
22
|
+
## REDIRECTED — use sandbox
|
|
28
23
|
|
|
29
24
|
### Shell (>20 lines output)
|
|
30
|
-
Shell
|
|
31
|
-
|
|
32
|
-
- `context-mode_ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
|
|
33
|
-
- `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: `context-mode_ctx_batch_execute(commands, queries)` or `context-mode_ctx_execute(language: "shell", code: "...")`
|
|
34
27
|
|
|
35
28
|
### File reading (for analysis)
|
|
36
|
-
|
|
37
|
-
If you are reading to **analyze, explore, or summarize** → use `context-mode_ctx_execute_file(path, language, code)` instead. Only your printed summary enters context.
|
|
29
|
+
Reading to **edit** → reading correct. Reading to **analyze/explore/summarize** → `context-mode_ctx_execute_file(path, language, code)`.
|
|
38
30
|
|
|
39
31
|
### grep / search (large results)
|
|
40
|
-
|
|
32
|
+
Use `context-mode_ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
41
33
|
|
|
42
|
-
## Tool selection
|
|
34
|
+
## Tool selection
|
|
43
35
|
|
|
44
|
-
1. **GATHER**: `context-mode_ctx_batch_execute(commands, queries)` —
|
|
45
|
-
2. **FOLLOW-UP**: `context-mode_ctx_search(queries: ["q1", "q2", ...])` —
|
|
46
|
-
3. **PROCESSING**: `context-mode_ctx_execute(language, code)` | `context-mode_ctx_execute_file(path, language, code)` —
|
|
47
|
-
4. **WEB**: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` —
|
|
48
|
-
5. **INDEX**: `context-mode_ctx_index(content, source)` —
|
|
36
|
+
1. **GATHER**: `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**: `context-mode_ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call.
|
|
38
|
+
3. **PROCESSING**: `context-mode_ctx_execute(language, code)` | `context-mode_ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
39
|
+
4. **WEB**: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` — raw HTML never enters context.
|
|
40
|
+
5. **INDEX**: `context-mode_ctx_index(content, source)` — store in FTS5 for later search.
|
|
49
41
|
|
|
50
|
-
## Output
|
|
42
|
+
## Output
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
61
|
-
| `ctx doctor` | Call
|
|
62
|
-
| `ctx upgrade` | Call
|
|
63
|
-
| `ctx purge` | Call
|
|
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
|
|
59
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|
package/configs/pi/AGENTS.md
CHANGED
|
@@ -1,65 +1,60 @@
|
|
|
1
1
|
# context-mode — MANDATORY routing rules
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context. Pi enforces routing via hooks (`tool_call` blocks `curl`/`wget`) AND these instructions. Hooks = hard enforcement; rules = completeness for redirections hooks cannot catch.
|
|
4
4
|
|
|
5
5
|
## Think in Code — MANDATORY
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
9
|
+
## BLOCKED — do NOT use
|
|
10
10
|
|
|
11
11
|
### curl / wget — FORBIDDEN (hook-enforced)
|
|
12
|
-
Do NOT use `curl
|
|
13
|
-
|
|
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 `bash`. Pi hooks block these. 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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
|
23
|
+
## REDIRECTED — use sandbox
|
|
28
24
|
|
|
29
25
|
### bash (>20 lines output)
|
|
30
|
-
`bash`
|
|
31
|
-
|
|
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
|
+
`bash` 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
|
### read (for analysis)
|
|
36
|
-
|
|
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** → `read` correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
|
|
38
31
|
|
|
39
32
|
### grep / find (large results)
|
|
40
|
-
|
|
33
|
+
Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
41
34
|
|
|
42
|
-
## Tool selection
|
|
35
|
+
## Tool selection
|
|
43
36
|
|
|
44
|
-
1. **GATHER**: `ctx_batch_execute(commands, queries)` —
|
|
45
|
-
2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` —
|
|
46
|
-
3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` —
|
|
47
|
-
4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` —
|
|
48
|
-
5. **INDEX**: `ctx_index(content, source)` —
|
|
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
|
|
43
|
+
## Output
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
61
|
-
| `ctx doctor` | Call
|
|
62
|
-
| `ctx upgrade` | Call
|
|
63
|
-
| `ctx purge` | Call
|
|
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
|
|
60
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
Bash `curl`/`wget` 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(...)")`
|
|
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 — BLOCKED
|
|
20
|
+
Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
|
|
21
|
+
|
|
22
|
+
## REDIRECTED — use sandbox
|
|
23
|
+
|
|
24
|
+
### Bash (>20 lines output)
|
|
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: "...")`
|
|
27
|
+
|
|
28
|
+
### Read (for analysis)
|
|
29
|
+
Reading to **Edit** → Read correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
|
|
30
|
+
|
|
31
|
+
### Grep (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
|
+
## Subagent routing
|
|
43
|
+
|
|
44
|
+
Routing block auto-injected into subagent prompts. Bash-type subagents upgraded to general-purpose. No manual instruction needed.
|
|
45
|
+
|
|
46
|
+
## Output
|
|
47
|
+
|
|
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")`.
|
|
53
|
+
|
|
54
|
+
## ctx commands
|
|
55
|
+
|
|
56
|
+
| Command | Action |
|
|
57
|
+
|---------|--------|
|
|
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. |
|
|
62
|
+
|
|
63
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|