context-mode 1.0.65 → 1.0.66
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 +3 -1
- package/build/server.js +205 -205
- package/build/session/analytics.d.ts +381 -0
- package/build/session/analytics.js +708 -0
- package/cli.bundle.mjs +203 -143
- package/configs/antigravity/GEMINI.md +3 -0
- package/configs/claude-code/CLAUDE.md +3 -0
- package/configs/codex/AGENTS.md +3 -0
- package/configs/gemini-cli/GEMINI.md +3 -0
- package/configs/kilo/AGENTS.md +3 -0
- package/configs/kiro/KIRO.md +3 -0
- package/configs/openclaw/AGENTS.md +3 -0
- package/configs/opencode/AGENTS.md +3 -0
- package/configs/pi/AGENTS.md +3 -0
- package/configs/vscode-copilot/copilot-instructions.md +3 -0
- package/configs/zed/AGENTS.md +3 -0
- package/hooks/routing-block.mjs +4 -1
- package/hooks/session-helpers.mjs +0 -12
- package/hooks/sessionstart.mjs +2 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +134 -74
- package/skills/context-mode/SKILL.md +2 -0
- package/skills/ctx-purge/SKILL.md +35 -0
- package/skills/ctx-stats/SKILL.md +6 -0
- package/start.mjs +7 -0
|
@@ -100,6 +100,7 @@ About to run a command / read a file / call an API?
|
|
|
100
100
|
| Playwright console/network | `browser_*(filename)` → `ctx_execute_file(path)` | Save to file, analyze in sandbox |
|
|
101
101
|
| MCP output (already in context) | Use directly | Don't re-index — it's already loaded |
|
|
102
102
|
| MCP output (need multi-query) | `ctx_execute` to save → `ctx_index(path)` → `ctx_search` | Save to file first, index server-side |
|
|
103
|
+
| Wipe indexed KB content | `ctx_purge(confirm: true)` | Permanently deletes all indexed content |
|
|
103
104
|
|
|
104
105
|
## Automatic Triggers
|
|
105
106
|
|
|
@@ -288,6 +289,7 @@ Subagents automatically receive context-mode tool routing via a PreToolUse hook.
|
|
|
288
289
|
- Passing ANY large data to `ctx_index(content: ...)` → data enters context as a parameter. **Always** use `ctx_index(path: ...)` to read server-side. The `content` parameter should only be used for small inline text you're composing yourself.
|
|
289
290
|
- Calling an MCP tool (Context7 `query-docs`, GitHub API, etc.) then passing the response to `ctx_index(content: response)` → **doubles** context usage. The response is already in context — use it directly or save to file first.
|
|
290
291
|
- Ignoring `browser_navigate` auto-snapshot → navigation response includes a full page snapshot. Don't rely on it for inspection — call `browser_snapshot(filename)` separately.
|
|
292
|
+
- Expecting `ctx_stats` to reset or wipe anything → `ctx_stats` is read-only (shows stats only). Use `ctx_purge(confirm: true)` to permanently delete all indexed content.
|
|
291
293
|
|
|
292
294
|
## Reference Files
|
|
293
295
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx-purge
|
|
3
|
+
description: |
|
|
4
|
+
Purge the context-mode knowledge base. Permanently deletes all indexed content
|
|
5
|
+
and resets session stats. This is destructive and cannot be undone.
|
|
6
|
+
Trigger: /context-mode:ctx-purge
|
|
7
|
+
user-invocable: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Context Mode Purge
|
|
11
|
+
|
|
12
|
+
Permanently deletes ALL session data for this project: knowledge base, session events, analytics, and stats.
|
|
13
|
+
|
|
14
|
+
## Instructions
|
|
15
|
+
|
|
16
|
+
1. **Warn the user**: This is irreversible. Everything will be deleted:
|
|
17
|
+
- FTS5 knowledge base (all indexed content from `ctx_index`, `ctx_fetch_and_index`, `ctx_batch_execute`)
|
|
18
|
+
- Session events DB (analytics, metadata, resume snapshots)
|
|
19
|
+
- Session events markdown file
|
|
20
|
+
- In-memory session stats
|
|
21
|
+
2. Call the `mcp__context-mode__ctx_purge` MCP tool with `confirm: true`.
|
|
22
|
+
3. Report the result to the user — the response lists exactly what was deleted.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
- When the KB contains stale or incorrect content polluting search results.
|
|
27
|
+
- When switching between unrelated projects in the same session.
|
|
28
|
+
- When you want a completely fresh start for this project.
|
|
29
|
+
|
|
30
|
+
## Important
|
|
31
|
+
|
|
32
|
+
- `ctx_purge` is the **only** way to delete session data. No other mechanism exists.
|
|
33
|
+
- `ctx_stats` is read-only — shows statistics only.
|
|
34
|
+
- `/clear` and `/compact` do NOT affect any context-mode data.
|
|
35
|
+
- There is no undo. Re-index content if you need it again.
|
|
@@ -3,6 +3,8 @@ name: ctx-stats
|
|
|
3
3
|
description: |
|
|
4
4
|
Show how much context window context-mode saved this session.
|
|
5
5
|
Displays token consumption, context savings ratio, and per-tool breakdown.
|
|
6
|
+
Read-only — shows stats only, no reset capability.
|
|
7
|
+
To wipe the knowledge base entirely, use ctx_purge instead.
|
|
6
8
|
Trigger: /context-mode:ctx-stats
|
|
7
9
|
user-invocable: true
|
|
8
10
|
---
|
|
@@ -18,3 +20,7 @@ Show context savings for the current session.
|
|
|
18
20
|
3. After the full output, add ONE sentence highlighting the key savings metric, e.g.:
|
|
19
21
|
- "context-mode saved **12.4x** — 92% of data stayed in sandbox."
|
|
20
22
|
- If no data yet: "No context-mode calls yet this session."
|
|
23
|
+
|
|
24
|
+
## Purge
|
|
25
|
+
|
|
26
|
+
- **`ctx_purge(confirm: true)`** — Permanently deletes all indexed content from the knowledge base. Use `/context-mode:ctx-purge` for this.
|
package/start.mjs
CHANGED
|
@@ -13,6 +13,13 @@ if (!process.env.CLAUDE_PROJECT_DIR) {
|
|
|
13
13
|
process.env.CLAUDE_PROJECT_DIR = originalCwd;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Platform-agnostic project dir — guaranteed to be set for ALL platforms.
|
|
17
|
+
// Adapters may set their own env var (GEMINI_PROJECT_DIR, etc.) but this
|
|
18
|
+
// is the universal fallback so server.ts getProjectDir() never relies on cwd().
|
|
19
|
+
if (!process.env.CONTEXT_MODE_PROJECT_DIR) {
|
|
20
|
+
process.env.CONTEXT_MODE_PROJECT_DIR = originalCwd;
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
// Routing instructions file auto-write DISABLED for all platforms (#158, #164).
|
|
17
24
|
// Env vars like CLAUDE_SESSION_ID may not be set at MCP startup time, making
|
|
18
25
|
// the hook-capability guard unreliable. Writing to project dirs dirties git trees
|