context-mode 1.0.110 → 1.0.112
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/index.ts +3 -2
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/README.md +152 -34
- package/bin/statusline.mjs +144 -127
- package/build/adapters/base.d.ts +8 -5
- package/build/adapters/base.js +8 -18
- package/build/adapters/claude-code/index.d.ts +24 -3
- package/build/adapters/claude-code/index.js +44 -11
- package/build/adapters/codex/hooks.d.ts +10 -5
- package/build/adapters/codex/hooks.js +10 -5
- package/build/adapters/codex/index.d.ts +17 -5
- package/build/adapters/codex/index.js +337 -37
- package/build/adapters/codex/paths.d.ts +1 -0
- package/build/adapters/codex/paths.js +12 -0
- package/build/adapters/cursor/index.d.ts +6 -0
- package/build/adapters/cursor/index.js +83 -2
- package/build/adapters/detect.d.ts +1 -1
- package/build/adapters/detect.js +29 -6
- package/build/adapters/omp/index.d.ts +65 -0
- package/build/adapters/omp/index.js +182 -0
- package/build/adapters/omp/plugin.d.ts +75 -0
- package/build/adapters/omp/plugin.js +220 -0
- package/build/adapters/openclaw/mcp-tools.d.ts +54 -0
- package/build/adapters/openclaw/mcp-tools.js +198 -0
- package/build/adapters/openclaw/plugin.d.ts +130 -0
- package/build/adapters/openclaw/plugin.js +629 -0
- package/build/adapters/openclaw/workspace-router.d.ts +29 -0
- package/build/adapters/openclaw/workspace-router.js +64 -0
- package/build/adapters/opencode/plugin.d.ts +145 -0
- package/build/adapters/opencode/plugin.js +457 -0
- package/build/adapters/pi/extension.d.ts +26 -0
- package/build/adapters/pi/extension.js +552 -0
- package/build/adapters/pi/index.d.ts +57 -0
- package/build/adapters/pi/index.js +173 -0
- package/build/adapters/pi/mcp-bridge.d.ts +113 -0
- package/build/adapters/pi/mcp-bridge.js +251 -0
- package/build/adapters/types.d.ts +11 -6
- package/build/cli.js +186 -170
- package/build/db-base.d.ts +15 -2
- package/build/db-base.js +50 -5
- package/build/executor.d.ts +2 -0
- package/build/executor.js +15 -2
- package/build/opencode-plugin.js +1 -1
- package/build/runPool.d.ts +36 -0
- package/build/runPool.js +51 -0
- package/build/runtime.js +64 -5
- package/build/search/auto-memory.js +6 -4
- package/build/security.js +30 -10
- package/build/server.d.ts +23 -1
- package/build/server.js +652 -174
- package/build/session/analytics.d.ts +404 -1
- package/build/session/analytics.js +1347 -42
- package/build/session/db.d.ts +114 -5
- package/build/session/db.js +275 -27
- package/build/session/event-emit.d.ts +48 -0
- package/build/session/event-emit.js +101 -0
- package/build/session/extract.d.ts +1 -0
- package/build/session/extract.js +79 -12
- package/build/session/purge.d.ts +111 -0
- package/build/session/purge.js +138 -0
- package/build/store.d.ts +7 -0
- package/build/store.js +69 -6
- package/build/util/claude-config.d.ts +26 -0
- package/build/util/claude-config.js +91 -0
- package/build/util/hook-config.d.ts +4 -0
- package/build/util/hook-config.js +39 -0
- package/cli.bundle.mjs +411 -208
- package/configs/antigravity/GEMINI.md +0 -3
- package/configs/claude-code/CLAUDE.md +1 -4
- package/configs/codex/AGENTS.md +1 -4
- package/configs/codex/config.toml +3 -0
- package/configs/codex/hooks.json +8 -0
- package/configs/cursor/context-mode.mdc +0 -3
- package/configs/gemini-cli/GEMINI.md +0 -3
- package/configs/jetbrains-copilot/copilot-instructions.md +0 -3
- package/configs/kilo/AGENTS.md +0 -3
- package/configs/kiro/KIRO.md +0 -3
- package/configs/omp/SYSTEM.md +85 -0
- package/configs/omp/mcp.json +7 -0
- package/configs/openclaw/AGENTS.md +0 -3
- package/configs/opencode/AGENTS.md +0 -3
- package/configs/pi/AGENTS.md +0 -3
- package/configs/qwen-code/QWEN.md +1 -4
- package/configs/vscode-copilot/copilot-instructions.md +0 -3
- package/configs/zed/AGENTS.md +0 -3
- package/hooks/codex/posttooluse.mjs +9 -2
- package/hooks/codex/precompact.mjs +69 -0
- package/hooks/codex/sessionstart.mjs +13 -9
- package/hooks/codex/stop.mjs +1 -2
- package/hooks/codex/userpromptsubmit.mjs +1 -2
- package/hooks/core/routing.mjs +237 -18
- package/hooks/cursor/afteragentresponse.mjs +1 -1
- package/hooks/cursor/hooks.json +31 -0
- package/hooks/cursor/posttooluse.mjs +1 -1
- package/hooks/cursor/sessionstart.mjs +5 -5
- package/hooks/cursor/stop.mjs +1 -1
- package/hooks/ensure-deps.mjs +12 -13
- package/hooks/gemini-cli/aftertool.mjs +1 -1
- package/hooks/gemini-cli/beforeagent.mjs +1 -1
- package/hooks/gemini-cli/precompress.mjs +3 -2
- package/hooks/gemini-cli/sessionstart.mjs +9 -9
- package/hooks/jetbrains-copilot/posttooluse.mjs +1 -1
- package/hooks/jetbrains-copilot/precompact.mjs +3 -2
- package/hooks/jetbrains-copilot/sessionstart.mjs +9 -9
- package/hooks/kiro/agentspawn.mjs +5 -5
- package/hooks/kiro/posttooluse.mjs +2 -2
- package/hooks/kiro/userpromptsubmit.mjs +1 -1
- package/hooks/posttooluse.mjs +45 -0
- package/hooks/precompact.mjs +17 -0
- package/hooks/pretooluse.mjs +23 -0
- package/hooks/routing-block.mjs +0 -12
- package/hooks/run-hook.mjs +16 -3
- package/hooks/session-db.bundle.mjs +27 -18
- package/hooks/session-extract.bundle.mjs +2 -2
- package/hooks/session-helpers.mjs +101 -64
- package/hooks/sessionstart.mjs +51 -2
- package/hooks/vscode-copilot/posttooluse.mjs +1 -1
- package/hooks/vscode-copilot/precompact.mjs +3 -2
- package/hooks/vscode-copilot/sessionstart.mjs +9 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +14 -8
- package/server.bundle.mjs +349 -147
- package/skills/UPSTREAM-CREDITS.md +0 -51
- package/skills/context-mode-ops/SKILL.md +0 -299
- package/skills/context-mode-ops/agent-teams.md +0 -198
- package/skills/context-mode-ops/communication.md +0 -224
- package/skills/context-mode-ops/marketing.md +0 -124
- package/skills/context-mode-ops/release.md +0 -214
- package/skills/context-mode-ops/review-pr.md +0 -269
- package/skills/context-mode-ops/tdd.md +0 -329
- package/skills/context-mode-ops/triage-issue.md +0 -266
- package/skills/context-mode-ops/validation.md +0 -307
- package/skills/diagnose/SKILL.md +0 -122
- package/skills/diagnose/scripts/hitl-loop.template.sh +0 -41
- package/skills/grill-me/SKILL.md +0 -15
- package/skills/grill-with-docs/ADR-FORMAT.md +0 -47
- package/skills/grill-with-docs/CONTEXT-FORMAT.md +0 -77
- package/skills/grill-with-docs/SKILL.md +0 -93
- package/skills/improve-codebase-architecture/DEEPENING.md +0 -37
- package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +0 -44
- package/skills/improve-codebase-architecture/LANGUAGE.md +0 -53
- package/skills/improve-codebase-architecture/SKILL.md +0 -76
- package/skills/tdd/SKILL.md +0 -114
- package/skills/tdd/deep-modules.md +0 -33
- package/skills/tdd/interface-design.md +0 -31
- package/skills/tdd/mocking.md +0 -59
- package/skills/tdd/refactoring.md +0 -10
- package/skills/tdd/tests.md +0 -61
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `search(source: "label")`.
|
|
61
58
|
|
|
@@ -28,7 +28,7 @@ Otherwise: `ctx_batch_execute(commands, queries)` or `ctx_execute(language: "she
|
|
|
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
|
-
### Grep
|
|
31
|
+
### Grep — may flood context
|
|
32
32
|
Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
33
33
|
|
|
34
34
|
## Tool selection
|
|
@@ -57,9 +57,6 @@ Routing block auto-injected into subagent prompts. Bash-type subagents upgraded
|
|
|
57
57
|
|
|
58
58
|
## Output
|
|
59
59
|
|
|
60
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
61
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
62
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
63
60
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
64
61
|
Descriptive source labels for `ctx_search(source: "label")`.
|
|
65
62
|
|
package/configs/codex/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# context-mode — MANDATORY routing rules
|
|
2
2
|
|
|
3
|
-
context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context. Codex CLI
|
|
3
|
+
context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context. Codex CLI hooks provide runtime enforcement when `[features].hooks = true`; these instructions remain mandatory model-side enforcement. Follow strictly.
|
|
4
4
|
|
|
5
5
|
## Think in Code — MANDATORY
|
|
6
6
|
|
|
@@ -54,9 +54,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
54
54
|
|
|
55
55
|
## Output
|
|
56
56
|
|
|
57
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
58
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
59
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
60
57
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
61
58
|
Descriptive source labels for `ctx_search(source: "label")`.
|
|
62
59
|
|
package/configs/codex/hooks.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"hooks": {
|
|
3
3
|
"PreToolUse": [
|
|
4
4
|
{
|
|
5
|
+
"matcher": "local_shell|shell|shell_command|exec_command|container.exec|functions\\.exec_command|Bash|Shell|apply_patch|functions\\.apply_patch|Edit|Write|grep_files|ctx_execute|ctx_execute_file|ctx_batch_execute|ctx_fetch_and_index|ctx_search|ctx_index|mcp__.*__ctx_execute|mcp__.*__ctx_execute_file|mcp__.*__ctx_batch_execute|mcp__.*__ctx_fetch_and_index|mcp__.*__ctx_search|mcp__.*__ctx_index",
|
|
5
6
|
"hooks": [
|
|
6
7
|
{ "type": "command", "command": "context-mode hook codex pretooluse" }
|
|
7
8
|
]
|
|
@@ -21,6 +22,13 @@
|
|
|
21
22
|
]
|
|
22
23
|
}
|
|
23
24
|
],
|
|
25
|
+
"PreCompact": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{ "type": "command", "command": "context-mode hook codex precompact" }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
24
32
|
"UserPromptSubmit": [
|
|
25
33
|
{
|
|
26
34
|
"hooks": [
|
|
@@ -46,9 +46,6 @@ ALWAYS use native file editing tools to create/modify files. NEVER use `ctx_exec
|
|
|
46
46
|
|
|
47
47
|
## Output
|
|
48
48
|
|
|
49
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
50
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
51
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
52
49
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
53
50
|
|
|
54
51
|
## Session Continuity
|
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `search(source: "label")`.
|
|
61
58
|
|
|
@@ -45,9 +45,6 @@ Pass `concurrency: 4-8` to `ctx_batch_execute` and `ctx_fetch_and_index` for net
|
|
|
45
45
|
|
|
46
46
|
## Output
|
|
47
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
48
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
52
49
|
Descriptive source labels for `ctx_search(source: "label")`.
|
|
53
50
|
|
package/configs/kilo/AGENTS.md
CHANGED
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `context-mode_ctx_search(source: "label")`.
|
|
61
58
|
|
package/configs/kiro/KIRO.md
CHANGED
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `search(source: "label")`.
|
|
61
58
|
|
|
@@ -0,0 +1,85 @@
|
|
|
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. context-mode delivers via MCP for OMP; native OMP `pre`/`post` tool-call hooks are not yet wired by this adapter, so these rules are the only enforcement path. Treat them as MUST.
|
|
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 use
|
|
10
|
+
|
|
11
|
+
### curl / wget — FORBIDDEN
|
|
12
|
+
Dumps raw HTTP into context. No hook fallback for OMP today; rule-only enforcement.
|
|
13
|
+
Use: `ctx_fetch_and_index(url, source)` or `ctx_execute(language: "javascript", code: "const r = await fetch(...)")`
|
|
14
|
+
|
|
15
|
+
### Inline HTTP — FORBIDDEN
|
|
16
|
+
No `node -e "fetch(..."`, `python -c "requests.get(..."`. Bypasses sandbox.
|
|
17
|
+
Use: `ctx_execute(language, code)` — only stdout enters context
|
|
18
|
+
|
|
19
|
+
### Direct web fetching — FORBIDDEN
|
|
20
|
+
Raw HTML can exceed 100 KB.
|
|
21
|
+
Use: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)`
|
|
22
|
+
|
|
23
|
+
## REDIRECTED — use sandbox
|
|
24
|
+
|
|
25
|
+
### shell (>20 lines output)
|
|
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: "...")`
|
|
28
|
+
|
|
29
|
+
### read (for analysis)
|
|
30
|
+
Reading to **edit** → `read` correct. Reading to **analyze/explore/summarize** → `ctx_execute_file(path, language, code)`.
|
|
31
|
+
|
|
32
|
+
### grep / find (large results)
|
|
33
|
+
Use `ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
34
|
+
|
|
35
|
+
## Tool selection
|
|
36
|
+
|
|
37
|
+
0. **MEMORY**: `ctx_search(sort: "timeline")` — after resume, check prior context before asking user.
|
|
38
|
+
1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, returns search. ONE call replaces 30+. Each command: `{label: "header", command: "..."}`.
|
|
39
|
+
2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all questions as array, ONE call (default relevance mode).
|
|
40
|
+
3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
41
|
+
4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — raw HTML never enters context.
|
|
42
|
+
5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
|
|
43
|
+
|
|
44
|
+
## Parallel I/O batches
|
|
45
|
+
|
|
46
|
+
For multi-URL fetches or multi-API calls, **always** include `concurrency: N` (1-8):
|
|
47
|
+
|
|
48
|
+
- `ctx_batch_execute(commands: [3+ network commands], concurrency: 5)` — gh, curl, dig, docker inspect, multi-region cloud queries
|
|
49
|
+
- `ctx_fetch_and_index(requests: [{url, source}, ...], concurrency: 5)` — multi-URL batch fetch
|
|
50
|
+
|
|
51
|
+
**Use concurrency 4-8** for I/O-bound work (network calls, API queries). **Keep concurrency 1** for CPU-bound (npm test, build, lint) or commands sharing state (ports, lock files, same-repo writes).
|
|
52
|
+
|
|
53
|
+
GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
54
|
+
|
|
55
|
+
## Output
|
|
56
|
+
|
|
57
|
+
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
58
|
+
Descriptive source labels for `search(source: "label")`.
|
|
59
|
+
|
|
60
|
+
## Session Continuity
|
|
61
|
+
|
|
62
|
+
Skills, roles, and decisions persist for the entire session. Do not abandon them as the conversation grows.
|
|
63
|
+
|
|
64
|
+
## Memory
|
|
65
|
+
|
|
66
|
+
Session history is persistent and searchable. On resume, search BEFORE asking the user:
|
|
67
|
+
|
|
68
|
+
| Need | Command |
|
|
69
|
+
|------|---------|
|
|
70
|
+
| What did we decide? | `ctx_search(queries: ["decision"], source: "decision", sort: "timeline")` |
|
|
71
|
+
| What constraints exist? | `ctx_search(queries: ["constraint"], source: "constraint")` |
|
|
72
|
+
|
|
73
|
+
DO NOT ask "what were we working on?" — SEARCH FIRST.
|
|
74
|
+
If search returns 0 results, proceed as a fresh session.
|
|
75
|
+
|
|
76
|
+
## ctx commands
|
|
77
|
+
|
|
78
|
+
| Command | Action |
|
|
79
|
+
|---------|--------|
|
|
80
|
+
| `ctx stats` | Call `stats` MCP tool, display full output verbatim |
|
|
81
|
+
| `ctx doctor` | Call `doctor` MCP tool, run returned shell command, display as checklist |
|
|
82
|
+
| `ctx upgrade` | Call `upgrade` MCP tool, run returned shell command, display as checklist |
|
|
83
|
+
| `ctx purge` | Call `purge` MCP tool with confirm: true. Warns before wiping knowledge base. |
|
|
84
|
+
|
|
85
|
+
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `context-mode__ctx_search(source: "label")`.
|
|
61
58
|
|
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `search(source: "label")`.
|
|
61
58
|
|
package/configs/pi/AGENTS.md
CHANGED
|
@@ -54,9 +54,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
54
54
|
|
|
55
55
|
## Output
|
|
56
56
|
|
|
57
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
58
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
59
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
60
57
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
61
58
|
Descriptive source labels for `search(source: "label")`.
|
|
62
59
|
|
|
@@ -28,7 +28,7 @@ Otherwise: `mcp__context-mode__ctx_batch_execute(commands, queries)` or `mcp__co
|
|
|
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
|
-
### Grep
|
|
31
|
+
### Grep — may flood context
|
|
32
32
|
Use `mcp__context-mode__ctx_execute(language: "shell", code: "grep ...")` in sandbox.
|
|
33
33
|
|
|
34
34
|
## Tool selection
|
|
@@ -57,9 +57,6 @@ Routing block auto-injected into subagent prompts. Bash-type subagents upgraded
|
|
|
57
57
|
|
|
58
58
|
## Output
|
|
59
59
|
|
|
60
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
61
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
62
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
63
60
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
64
61
|
Descriptive source labels for `mcp__context-mode__ctx_search(source: "label")`.
|
|
65
62
|
|
|
@@ -45,9 +45,6 @@ Pass `concurrency: 4-8` to `ctx_batch_execute` and `ctx_fetch_and_index` for net
|
|
|
45
45
|
|
|
46
46
|
## Output
|
|
47
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
48
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
52
49
|
Descriptive source labels for `ctx_search(source: "label")`.
|
|
53
50
|
|
package/configs/zed/AGENTS.md
CHANGED
|
@@ -53,9 +53,6 @@ GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
53
53
|
|
|
54
54
|
## Output
|
|
55
55
|
|
|
56
|
-
Terse like caveman. Technical substance exact. Only fluff die.
|
|
57
|
-
Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged.
|
|
58
|
-
Pattern: [thing] [action] [reason]. [next step]. Auto-expand for: security warnings, irreversible actions, user confusion.
|
|
59
56
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
60
57
|
Descriptive source labels for `search(source: "label")`.
|
|
61
58
|
|
|
@@ -15,7 +15,8 @@ const { loadSessionDB, loadExtract, loadProjectAttribution } = createSessionLoad
|
|
|
15
15
|
const OPTS = CODEX_OPTS;
|
|
16
16
|
|
|
17
17
|
function normalizeToolName(toolName) {
|
|
18
|
-
// Codex
|
|
18
|
+
// Keep Codex-native tool names like apply_patch intact; only normalize
|
|
19
|
+
// legacy shell aliases that should route through the Bash extractors.
|
|
19
20
|
if (toolName === "Shell") return "Bash";
|
|
20
21
|
return toolName;
|
|
21
22
|
}
|
|
@@ -29,7 +30,7 @@ try {
|
|
|
29
30
|
const { resolveProjectAttributions } = await loadProjectAttribution();
|
|
30
31
|
const { SessionDB } = await loadSessionDB();
|
|
31
32
|
|
|
32
|
-
const dbPath = getSessionDBPath(OPTS);
|
|
33
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
33
34
|
const db = new SessionDB({ dbPath });
|
|
34
35
|
const sessionId = getSessionId(input, OPTS);
|
|
35
36
|
|
|
@@ -41,6 +42,12 @@ try {
|
|
|
41
42
|
tool_response: typeof input.tool_response === "string"
|
|
42
43
|
? input.tool_response
|
|
43
44
|
: JSON.stringify(input.tool_response ?? ""),
|
|
45
|
+
tool_output: input.tool_output
|
|
46
|
+
? {
|
|
47
|
+
...input.tool_output,
|
|
48
|
+
isError: input.tool_output.isError === true || input.tool_output.is_error === true,
|
|
49
|
+
}
|
|
50
|
+
: undefined,
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
const events = extractEvents(normalizedInput);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "../suppress-stderr.mjs";
|
|
3
|
+
import "../ensure-deps.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Codex CLI PreCompact hook - snapshot generation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
readStdin,
|
|
10
|
+
parseStdin,
|
|
11
|
+
getSessionId,
|
|
12
|
+
getSessionDBPath,
|
|
13
|
+
getInputProjectDir,
|
|
14
|
+
resolveConfigDir,
|
|
15
|
+
CODEX_OPTS,
|
|
16
|
+
} from "../session-helpers.mjs";
|
|
17
|
+
import { createSessionLoaders } from "../session-loaders.mjs";
|
|
18
|
+
import { appendFileSync } from "node:fs";
|
|
19
|
+
import { join, dirname } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
|
|
22
|
+
const HOOK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const { loadSessionDB, loadSnapshot } = createSessionLoaders(HOOK_DIR);
|
|
24
|
+
const OPTS = CODEX_OPTS;
|
|
25
|
+
const DEBUG_LOG = join(resolveConfigDir(OPTS), "context-mode", "precompact-debug.log");
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const raw = await readStdin();
|
|
29
|
+
const input = parseStdin(raw);
|
|
30
|
+
const projectDir = getInputProjectDir(input, OPTS);
|
|
31
|
+
|
|
32
|
+
const { buildResumeSnapshot } = await loadSnapshot();
|
|
33
|
+
const { SessionDB } = await loadSessionDB();
|
|
34
|
+
|
|
35
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
36
|
+
const db = new SessionDB({ dbPath });
|
|
37
|
+
const sessionId = getSessionId(input, OPTS);
|
|
38
|
+
|
|
39
|
+
const events = db.getEvents(sessionId);
|
|
40
|
+
|
|
41
|
+
if (events.length > 0) {
|
|
42
|
+
const stats = db.getSessionStats(sessionId);
|
|
43
|
+
const snapshot = buildResumeSnapshot(events, {
|
|
44
|
+
compactCount: (stats?.compact_count ?? 0) + 1,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
db.upsertResume(sessionId, snapshot, events.length);
|
|
48
|
+
db.incrementCompactCount(sessionId);
|
|
49
|
+
|
|
50
|
+
const fileEvents = events.filter((event) => event.category === "file");
|
|
51
|
+
db.insertEvent(sessionId, {
|
|
52
|
+
type: "compaction_summary",
|
|
53
|
+
category: "compaction",
|
|
54
|
+
data: `Session compacted. ${events.length} events, ${fileEvents.length} files touched.`,
|
|
55
|
+
priority: 1,
|
|
56
|
+
}, "PreCompact");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
db.close();
|
|
60
|
+
} catch (err) {
|
|
61
|
+
try {
|
|
62
|
+
appendFileSync(DEBUG_LOG, `[${new Date().toISOString()}] ${err?.message || err}\n`);
|
|
63
|
+
} catch {
|
|
64
|
+
// Hook errors must not break Codex compaction.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Codex PreCompact accepts universal hook fields only; no hookSpecificOutput.
|
|
69
|
+
process.stdout.write(JSON.stringify({}) + "\n");
|
|
@@ -43,17 +43,18 @@ try {
|
|
|
43
43
|
|
|
44
44
|
if (source === "compact" || source === "resume") {
|
|
45
45
|
const { SessionDB } = await loadSessionDB();
|
|
46
|
-
const dbPath = getSessionDBPath(OPTS);
|
|
46
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
47
47
|
const db = new SessionDB({ dbPath });
|
|
48
|
+
const sessionId = getSessionId(input, OPTS);
|
|
49
|
+
let resumeSnapshot = null;
|
|
48
50
|
|
|
49
51
|
if (source === "compact") {
|
|
50
|
-
const
|
|
51
|
-
const resume = db.getResume(sessionId);
|
|
52
|
+
const resume = sessionId ? db.getResume(sessionId) : null;
|
|
52
53
|
if (resume && !resume.consumed) {
|
|
53
|
-
|
|
54
|
+
resumeSnapshot = resume.snapshot;
|
|
54
55
|
}
|
|
55
56
|
} else {
|
|
56
|
-
try { unlinkSync(getCleanupFlagPath(OPTS)); } catch { /* no flag */ }
|
|
57
|
+
try { unlinkSync(getCleanupFlagPath(OPTS, projectDir)); } catch { /* no flag */ }
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
// Filter events to the session being resumed/compacted. Falling back to
|
|
@@ -61,19 +62,22 @@ try {
|
|
|
61
62
|
// session whose session_meta.started_at is more recent — observed
|
|
62
63
|
// cross-session bleed when a different session started after this one
|
|
63
64
|
// and before the resume.
|
|
64
|
-
const sessionId = getSessionId(input, OPTS);
|
|
65
65
|
const events = sessionId ? getSessionEvents(db, sessionId) : [];
|
|
66
66
|
if (events.length > 0) {
|
|
67
|
-
const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS));
|
|
67
|
+
const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS, projectDir));
|
|
68
68
|
additionalContext += buildSessionDirective(source, eventMeta, toolNamer);
|
|
69
69
|
}
|
|
70
|
+
if (resumeSnapshot) {
|
|
71
|
+
additionalContext += `\n\n${resumeSnapshot}`;
|
|
72
|
+
db.markResumeConsumed(sessionId);
|
|
73
|
+
}
|
|
70
74
|
|
|
71
75
|
db.close();
|
|
72
76
|
} else if (source === "startup") {
|
|
73
77
|
const { SessionDB } = await loadSessionDB();
|
|
74
|
-
const dbPath = getSessionDBPath(OPTS);
|
|
78
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
75
79
|
const db = new SessionDB({ dbPath });
|
|
76
|
-
try { unlinkSync(getSessionEventsPath(OPTS)); } catch { /* no stale file */ }
|
|
80
|
+
try { unlinkSync(getSessionEventsPath(OPTS, projectDir)); } catch { /* no stale file */ }
|
|
77
81
|
|
|
78
82
|
db.cleanupOldSessions(7);
|
|
79
83
|
db.db.exec(`DELETE FROM session_events WHERE session_id NOT IN (SELECT session_id FROM session_meta)`);
|
package/hooks/codex/stop.mjs
CHANGED
|
@@ -20,7 +20,7 @@ try {
|
|
|
20
20
|
const projectDir = getInputProjectDir(input, OPTS);
|
|
21
21
|
|
|
22
22
|
const { SessionDB } = await loadSessionDB();
|
|
23
|
-
const dbPath = getSessionDBPath(OPTS);
|
|
23
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
24
24
|
const db = new SessionDB({ dbPath });
|
|
25
25
|
const sessionId = getSessionId(input, OPTS);
|
|
26
26
|
|
|
@@ -40,4 +40,3 @@ try {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
process.stdout.write("{}\n");
|
|
43
|
-
|
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
const { SessionDB } = await loadSessionDB();
|
|
32
32
|
const { extractUserEvents } = await loadExtract();
|
|
33
33
|
const { resolveProjectAttributions } = await loadProjectAttribution();
|
|
34
|
-
const dbPath = getSessionDBPath(OPTS);
|
|
34
|
+
const dbPath = getSessionDBPath(OPTS, projectDir);
|
|
35
35
|
const db = new SessionDB({ dbPath });
|
|
36
36
|
const sessionId = getSessionId(input, OPTS);
|
|
37
37
|
|
|
@@ -72,4 +72,3 @@ try {
|
|
|
72
72
|
process.stdout.write(JSON.stringify({
|
|
73
73
|
hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: "" },
|
|
74
74
|
}) + "\n");
|
|
75
|
-
|