mirror of
https://github.com/mksglu/context-mode.git
synced 2026-09-19 03:27:16 +08:00
d05a37584e
Issue #482 (makoMakoGo) reported that context-mode's caveman/terse injection pressures the model toward brevity on its FINAL ANSWER, not just on tool-output reporting. Cited evidence: Moonshot AI on kimi-k2.5 (anomalyco/opencode#20258, PR #20259) — aggressive brevity prompts measurably degrade coding/reasoning benchmarks because the model drops assumptions, caveats, verification evidence, failure modes, and security warnings the user actually needs. Considered: A — config switch ("injectCommunicationStyle: false"). Rejected: switches default-on become dead code. B — close FR with rationale. Rejected: ignores valid evidence. C — refine wording ("compress when reporting raw tool output, be complete for technical answers"). Rejected: still text injection, model-dependent, half-measure. D — full strip everywhere. Adopted. The decision after grilling: context-mode's value is data routing (sandbox, FTS5, session continuity), not prose styling. The brevity injection conflated three goals — keeping raw data out of context (real, hard-enforced), summarizing tool output compactly (LLMs auto- calibrate), and final-answer prose style (the wrong target). Strip all 22 sites where prose-style language landed. Sites stripped (A-Z): hooks/routing-block.mjs - <communication_style> block (Terse like caveman, fragments OK, auto-expand for security warnings) - <response_format> block (Concise summary, 2-3 bullets) src/server.ts (5 MCP tool descriptions + 2 cosmetic comments) - ctx_execute "When reporting results — terse..." - ctx_execute_file same - ctx_search same - ctx_fetch_and_index same (URL + commands shapes, both) - cosmetic comment "Caveman style — terse status line" - rewrote concurrency note: "Indexing is serial regardless of concurrency" → "Fetches parallelize up to your concurrency setting; FTS5 indexing serializes the writes after (SQLite single-writer rule)." — same fact, less jargon. configs/ (15 adapter MD files — every shipped system prompt) antigravity/GEMINI.md, claude-code/CLAUDE.md, codex/AGENTS.md, cursor/context-mode.mdc, gemini-cli/GEMINI.md, jetbrains-copilot/ copilot-instructions.md, kilo/AGENTS.md, kiro/KIRO.md, omp/SYSTEM.md, openclaw/AGENTS.md, opencode/AGENTS.md, pi/AGENTS.md, qwen-code/ QWEN.md, vscode-copilot/copilot-instructions.md, zed/AGENTS.md All had identical "## Output" block: 3 caveman lines stripped, workflow lines ("Write artifacts to FILES", "Descriptive source labels") kept. CLAUDE.md (repo root — internal dev instructions) Same caveman block stripped. We don't ship this file but we do eat our own dog food. README.md Pillar 4 ("Output Compression — Terse like caveman...") rewritten to "No prose-style enforcement" — explicitly cites the kimi-k2.5 benchmark evidence as the rationale. web/index.html Removed Ch 4b entirely (the "Output compression" chapter with before/after example pushing terse style on the model). Tests: - tests/session/continuity.test.ts: SessionStart routing-block assertion flipped from "must include 'Terse like caveman'" to "must NOT include caveman/terse-style directive". - tests/core/server.test.ts: Task hook injection assertion same flip. Two cosmetic comment renames ("Caveman style — terse status line" → "Status line: counts + sections + size"), test name rename ("caveman style" → "compact format"). Added new "prose-style policy (#482)" describe block at end of file with 3 negative-pin tests covering server.ts MCP descriptions, routing-block, and README. Full suite: 82/82 files passed, 2645 passed, 20 skipped, 0 failed. Net +3 new tests (the policy describe block). CONTRIBUTING.md New "Prose-style policy (#482)" section documents the decision so future contributors don't re-add the injection. Cites the Moonshot benchmark evidence + the regression test that pins the deletion. This addresses #482 in full. Closing the issue with a comment that walks the requester through the decision and links the policy section.
77 lines
3.6 KiB
Plaintext
77 lines
3.6 KiB
Plaintext
---
|
|
description: context-mode routing rules for context window protection
|
|
alwaysApply: true
|
|
---
|
|
|
|
# context-mode
|
|
|
|
Raw tool output floods context window. Use context-mode MCP tools to keep raw data in sandbox.
|
|
|
|
## Think in Code — MANDATORY
|
|
|
|
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.
|
|
|
|
## Tool Selection
|
|
|
|
0. **MEMORY**: `ctx_search(sort: "timeline")` — after resume, check prior context before asking user.
|
|
1. **GATHER**: `ctx_batch_execute(commands, queries)` — runs all commands, auto-indexes, searches. ONE call replaces many steps.
|
|
2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — all follow-up questions, ONE call (default relevance mode).
|
|
3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — sandbox, only stdout enters context.
|
|
4. **WEB**: `ctx_fetch_and_index(url)` then `ctx_search(queries)` — never dump raw HTML.
|
|
5. **INDEX**: `ctx_index(content, source)` — store in FTS5 for later search.
|
|
|
|
## Parallel I/O batches
|
|
|
|
For multi-URL fetches or multi-API calls, **always** include `concurrency: N` (1-8):
|
|
|
|
- `ctx_batch_execute(commands: [3+ network commands], concurrency: 5)` — gh, curl, dig, docker inspect, multi-region cloud queries
|
|
- `ctx_fetch_and_index(requests: [{url, source}, ...], concurrency: 5)` — multi-URL batch fetch
|
|
|
|
**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).
|
|
|
|
GitHub API rate-limit: cap at 4 for `gh` calls.
|
|
|
|
## Forbidden Actions
|
|
|
|
- DO NOT use Bash for >20 lines output — use `ctx_execute` or `ctx_batch_execute`.
|
|
- DO NOT use Read for analysis — use `ctx_execute_file`. Read IS correct for Edit.
|
|
- DO NOT use WebFetch — use `ctx_fetch_and_index`.
|
|
- DO NOT use curl/wget in terminal — use `ctx_fetch_and_index`.
|
|
- Bash ONLY for git, mkdir, rm, mv, navigation, short commands.
|
|
- DO NOT use `ctx_execute`/`ctx_execute_file` to create/modify files. ctx_execute is for analysis and computation only.
|
|
|
|
## File Writing Policy
|
|
|
|
ALWAYS use native file editing tools to create/modify files. NEVER use `ctx_execute`, `ctx_execute_file`, or Bash to write file content.
|
|
|
|
## Output
|
|
|
|
Write artifacts to FILES — never inline. Return: file path + 1-line description.
|
|
|
|
## Session Continuity
|
|
|
|
Skills, roles, and decisions persist for the entire session. Do not abandon them as the conversation grows.
|
|
|
|
## Memory
|
|
|
|
Session history is persistent and searchable. On resume, search BEFORE asking the user:
|
|
|
|
| Need | Command |
|
|
|------|---------|
|
|
| What did we decide? | `ctx_search(queries: ["decision"], source: "decision", sort: "timeline")` |
|
|
| What constraints exist? | `ctx_search(queries: ["constraint"], source: "constraint")` |
|
|
|
|
DO NOT ask "what were we working on?" — SEARCH FIRST.
|
|
If search returns 0 results, proceed as a fresh session.
|
|
|
|
## ctx Commands
|
|
|
|
| Command | Action |
|
|
|---------|--------|
|
|
| `ctx stats` | Call ctx_stats MCP tool, display full output verbatim. |
|
|
| `ctx doctor` | Call ctx_doctor MCP tool, run returned shell command, display as checklist. |
|
|
| `ctx upgrade` | Call ctx_upgrade MCP tool, run returned shell command, display as checklist. |
|
|
| `ctx purge` | Call ctx_purge MCP tool with confirm: true. Warn user this is irreversible. |
|
|
|
|
After /clear or /compact: knowledge base and session stats preserved. Use `ctx purge` to start fresh.
|