You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Always run `bun typecheck` from package directories (e.g., `packages/opencode`), never `tsc` directly.
129
+
130
+
# context-mode — MANDATORY routing rules
131
+
132
+
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.
133
+
134
+
## BLOCKED commands — do NOT attempt these
135
+
136
+
### curl / wget — BLOCKED
137
+
Any shell command containing `curl` or `wget` will be intercepted and blocked by the context-mode plugin. Do NOT retry.
138
+
Instead use:
139
+
-`context-mode_ctx_fetch_and_index(url, source)` to fetch and index web pages
140
+
-`context-mode_ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
141
+
142
+
### Inline HTTP — BLOCKED
143
+
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.
144
+
Instead use:
145
+
-`context-mode_ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
146
+
147
+
### Direct web fetching — BLOCKED
148
+
Do NOT use any direct URL fetching tool. Use the sandbox equivalent.
149
+
Instead use:
150
+
-`context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` to query the indexed content
151
+
152
+
## REDIRECTED tools — use sandbox equivalents
153
+
154
+
### Shell (>20 lines output)
155
+
Shell is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
156
+
For everything else, use:
157
+
-`context-mode_ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
158
+
-`context-mode_ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
159
+
160
+
### File reading (for analysis)
161
+
If you are reading a file to **edit** it → reading is correct (edit needs content in context).
162
+
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.
163
+
164
+
### grep / search (large results)
165
+
Search results can flood context. Use `context-mode_ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
166
+
167
+
## Tool selection hierarchy
168
+
169
+
1.**GATHER**: `context-mode_ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls.
170
+
2.**FOLLOW-UP**: `context-mode_ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
4.**WEB**: `context-mode_ctx_fetch_and_index(url, source)` then `context-mode_ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
173
+
5.**INDEX**: `context-mode_ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
174
+
175
+
## Output constraints
176
+
177
+
- Keep responses under 500 words.
178
+
- Write artifacts (code, configs, PRDs) to FILES — never return them as inline text. Return only: file path + 1-line description.
179
+
- When indexing content, use descriptive source labels so others can `search(source: "label")` later.
180
+
181
+
## ctx commands
182
+
183
+
| Command | Action |
184
+
|---------|--------|
185
+
|`ctx stats`| Call the `stats` MCP tool and display the full output verbatim |
186
+
|`ctx doctor`| Call the `doctor` MCP tool, run the returned shell command, display as checklist |
187
+
|`ctx upgrade`| Call the `upgrade` MCP tool, run the returned shell command, display as checklist |
0 commit comments