context-mode 2.0.0-next.25 → 2.0.0-next.27

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.
@@ -9,7 +9,7 @@
9
9
  "name": "context-mode",
10
10
  "skills": "./claude-code/skills",
11
11
  "source": "./",
12
- "version": "2.0.0-next.25"
12
+ "version": "2.0.0-next.27"
13
13
  }
14
14
  ]
15
15
  }
@@ -13,5 +13,5 @@
13
13
  },
14
14
  "name": "context-mode",
15
15
  "skills": "./claude-code/skills",
16
- "version": "2.0.0-next.25"
16
+ "version": "2.0.0-next.27"
17
17
  }
@@ -8,5 +8,5 @@
8
8
  "mcpServers": "./.codex-plugin/mcp.json",
9
9
  "name": "context-mode",
10
10
  "skills": "./codex/skills/",
11
- "version": "2.0.0-next.25"
11
+ "version": "2.0.0-next.27"
12
12
  }
package/README.md CHANGED
@@ -1,370 +1,397 @@
1
1
  # Context Mode
2
2
 
3
- **Keeping tool output out of a coding agent's context window: a local plugin for 10 agents, and the Gateway that works on the whole request.**
3
+ **A free, local plugin that keeps tool output out of your coding agent's context window. 10 agents, zero telemetry, free forever.**
4
4
 
5
- [![npm downloads](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.npmjs.org%2Fdownloads%2Fpoint%2Flast-year%2Fcontext-mode&query=%24.downloads&label=npm%20downloads%2C%20last%20365%20days&color=blue)](https://www.npmjs.com/package/context-mode) [![GitHub stars](https://img.shields.io/github/stars/mksglu/context-mode?style=flat&color=yellow)](https://github.com/mksglu/context-mode) [![Hacker News 570+ points](https://img.shields.io/badge/Hacker%20News-570%2B%20points-ff6600?logo=ycombinator&logoColor=white)](https://news.ycombinator.com/item?id=47193064) [![GitHub Trending](https://img.shields.io/badge/GitHub-Trending-black?logo=github)](https://github.com/uibm/trending-watcher/issues?q=%22mksglu%2Fcontext-mode%22) [![Discord](https://img.shields.io/discord/1478479412700909750?label=Discord&logo=discord&color=5865f2)](https://discord.gg/DCN9jUgN5v) [![License: ELv2](https://img.shields.io/badge/License-ELv2-blue.svg)](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/LICENSE)
5
+ [![npm downloads](https://img.shields.io/npm/dy/context-mode?label=npm%20downloads)](https://www.npmjs.com/package/context-mode) [![GitHub stars](https://img.shields.io/github/stars/mksglu/context-mode?style=flat&color=yellow)](https://github.com/mksglu/context-mode) [![Hacker News 570+ points](https://img.shields.io/badge/Hacker%20News-570%2B%20points-ff6600?logo=ycombinator&logoColor=white)](https://news.ycombinator.com/item?id=47193064) [![GitHub Trending](https://img.shields.io/badge/GitHub-Trending-black?logo=github)](https://github.com/uibm/trending-watcher/issues?q=%22mksglu%2Fcontext-mode%22) [![Discord](https://img.shields.io/discord/1478479412700909750?label=Discord&logo=discord&color=5865f2)](https://discord.gg/DCN9jUgN5v) [![License: ELv2](https://img.shields.io/badge/License-ELv2-blue.svg)](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/LICENSE)
6
6
 
7
- > **Context Mode Gateway** takes the same idea from tool output to the whole conversation. It is an optional hosted service that works next to this plugin: Recall keeps long sessions searchable, and Memory shares what your agents learn across sessions and tools. The plugin stays free, local and open source. [See how the Gateway works](https://contextmode.ai/docs/how-saving-works)
7
+ > **Context Mode Gateway** takes the same idea from tool output to the whole conversation. It is an optional hosted service that works next to this plugin: Gateway Recall keeps long sessions searchable, and Gateway Memory shares what your agents learn across sessions and tools. The plugin stays free and local, with its source open on GitHub. [See how the Gateway works](https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=quote)
8
8
 
9
9
  <picture>
10
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/hero-dark.png">
11
- <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/hero-light.png" alt="Context Mode: tool output stays out of context. 10 coding agents, 9 MCP tools, 98.8% of output bytes saved (median of 25 rows with 10 KB or more of raw output).">
10
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/hero-dark.png">
11
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/hero-light.png" alt="Context Mode plugin: free and local, for 10 coding agents, zero telemetry, the plugin keeps your data on your machine. 99.4% of output bytes saved (median of 36 rows with 10 KB or more of raw output).">
12
12
  </picture>
13
13
 
14
- **Figure 1.** Context Mode at a glance. The 98.8% is the median over the 25 bench rows with 10 KB or more of raw output, 5 runs each.
15
-
16
- <p align="center">
17
- <sub>Starred by engineers at</sub>
18
- <br><br>
19
- <a href="#"><img src="https://img.shields.io/badge/Microsoft-141414?style=flat" alt="Microsoft" /></a>
20
- <a href="#"><img src="https://img.shields.io/badge/Google-141414?style=flat&logo=google&logoColor=white" alt="Google" /></a>
21
- <a href="#"><img src="https://img.shields.io/badge/Meta-141414?style=flat&logo=meta&logoColor=white" alt="Meta" /></a>
22
- <a href="#"><img src="https://img.shields.io/badge/Amazon-141414?style=flat" alt="Amazon" /></a>
23
- <a href="#"><img src="https://img.shields.io/badge/IBM-141414?style=flat" alt="IBM" /></a>
24
- <a href="#"><img src="https://img.shields.io/badge/NVIDIA-141414?style=flat&logo=nvidia&logoColor=white" alt="NVIDIA" /></a>
25
- <a href="#"><img src="https://img.shields.io/badge/ByteDance-141414?style=flat&logo=bytedance&logoColor=white" alt="ByteDance" /></a>
26
- <a href="#"><img src="https://img.shields.io/badge/Stripe-141414?style=flat&logo=stripe&logoColor=white" alt="Stripe" /></a>
27
- <a href="#"><img src="https://img.shields.io/badge/Datadog-141414?style=flat&logo=datadog&logoColor=white" alt="Datadog" /></a>
28
- <a href="#"><img src="https://img.shields.io/badge/Salesforce-141414?style=flat" alt="Salesforce" /></a>
29
- <a href="#"><img src="https://img.shields.io/badge/GitHub-141414?style=flat&logo=github&logoColor=white" alt="GitHub" /></a>
30
- <a href="#"><img src="https://img.shields.io/badge/Red%20Hat-141414?style=flat&logo=redhat&logoColor=white" alt="Red Hat" /></a>
31
- <a href="#"><img src="https://img.shields.io/badge/Supabase-141414?style=flat&logo=supabase&logoColor=white" alt="Supabase" /></a>
32
- <a href="#"><img src="https://img.shields.io/badge/Canva-141414?style=flat" alt="Canva" /></a>
33
- <a href="#"><img src="https://img.shields.io/badge/Notion-141414?style=flat&logo=notion&logoColor=white" alt="Notion" /></a>
34
- <a href="#"><img src="https://img.shields.io/badge/Hasura-141414?style=flat&logo=hasura&logoColor=white" alt="Hasura" /></a>
35
- <a href="#"><img src="https://img.shields.io/badge/Framer-141414?style=flat&logo=framer&logoColor=white" alt="Framer" /></a>
36
- <a href="#"><img src="https://img.shields.io/badge/Cursor-141414?style=flat&logo=cursor&logoColor=white" alt="Cursor" /></a>
37
- </p>
38
-
39
- ## Abstract
14
+ **Contents:** [Why](#why) · [Install](#install) · [Try it](#try-it) · [Use cases](#use-cases) · [Benchmarks](#benchmarks) · [How it works](#how-it-works) · [Tools](#tools) · [Security and privacy](#security-and-privacy) · [Context Mode Gateway](#context-mode-gateway) · [Adoption](#adoption-stars-and-npm-downloads) · [License](#license) · [Community](#community)
40
15
 
41
- A coding agent reads files, runs commands and fetches pages, and every result goes into its context window.
42
- One Playwright snapshot is 57.5 KB; one access log is 46.2 KB. The window fills, the agent compacts, and it forgets what it was doing.
43
- Context Mode runs the tool work in a local sandbox, keeps the full output in a per-project SQLite index, and returns what the agent asks for.
44
- On the 25 bench rows with 10 KB or more of raw output, it cut the bytes that reach the context by a median of 98.8%, measured with `ctx_bytes` against `raw_bytes`, 5 runs each.
45
- Context Mode Gateway, an optional hosted service, takes the same idea to the whole conversation and all your agents. On a pre-registered long session with a 200K window it cut cost from $4.86 to $3.04 (2026-10-04) (-37.6%).
46
- You can use both layers together. This paper gives the method, the numbers with their raw files, and the test setup behind each one.
47
-
48
- ## 1. The problem
16
+ ## Why
49
17
 
50
- Each tool result goes into the context window whole. Table 1 lists real outputs from the bench, and what Context Mode returns for each.
18
+ A coding agent reads files, runs commands and fetches pages, and every result goes into its context window.
19
+ Context Mode runs that work in a local sandbox, keeps the full output in a SQLite index on your machine, and gives the agent the part it asks for.
51
20
 
52
- **Table 1.** Raw output against the reply the agent sees (median of 5 runs, bench of 2026-10-31).
21
+ - **Free forever.** Use it at home and at work, free of charge, under a source-available license.
22
+ - **Runs on your machine.** The hooks, the sandbox and search run as local processes next to your agent.
23
+ - **The plugin keeps your data on your machine.** Every index lives in `~/.context-mode`: one `context.db` per project.
24
+ - **Zero telemetry.** The plugin keeps all usage data on your machine. A CI test keeps its short list of network calls fixed: see [Security and privacy](#security-and-privacy).
25
+ - **Works offline after install.** Sandbox runs, file indexing and search use local SQLite and your own runtimes.
26
+ - **Small replies.** On the 36 bench rows with 10 KB or more of raw output, the plugin's median reply is 99.4% smaller than the raw output.
53
27
 
54
- | Tool output | Raw | Reply | Cut |
55
- |---|---:|---:|---:|
56
- | Playwright page snapshot | 57,521 B | 315 B | 99.5% |
57
- | 20 GitHub issues | 60,310 B | 1,156 B | 98.1% |
58
- | Access log, 500 requests | 46,216 B | 171 B | 99.6% |
59
- | `npm install` log | 37,761 B | 451 B | 98.8% |
60
- | Big source file | 61,576 B | 489 B | 99.2% |
61
- | Large git log | 191,120 B | 153 B | 99.9% |
62
- | Docs page through WebFetch | 215,354 B | 435 B | 99.8% |
28
+ ## Install
63
29
 
64
- Rule for every headline number in this paper: rows with 10 KB or more of raw output, median per category.
65
- The full results file has [every row, including small outputs, where the cut is smaller](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/results/2026-10-31-darwin-arm64.md).
30
+ The plugin needs Node 24.15.0 or later (the `engines` field in [package.json](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/package.json)). On Windows you also need Git for Windows: the shell tools run in Git Bash, and `context-mode doctor` checks that Git Bash is there.
66
31
 
67
- ## 2. Results
32
+ Open your agent and copy its own install command. Each block also has the update, check and remove steps.
33
+ Every command installs 2.0. The npm commands use `@next`, the current 2.0 release tag; a plain `npm i -g context-mode` installs 1.x. Claude Code, Codex, Gemini CLI and Qwen Code install from GitHub, and each of their commands names the `release` branch.
34
+ The `context-mode` command (doctor, setup, remove) comes with the npm package: run `npm i -g context-mode@next` once, or use `/ctx-doctor` in the agent for the check.
68
35
 
69
- <picture>
70
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-saving-dark.png">
71
- <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-saving-light.png" alt="Bar chart: median output bytes saved per category for rows of 10 KB or more. Sandbox 99.3%, Batch 93.1%, Externalize 92.3%, Hook redirect 99.8%, Session total 98.8%.">
72
- </picture>
36
+ <details open id="install-claude-code"><summary><b>Claude Code</b></summary>
73
37
 
74
- **Figure 2.** Median bytes saved per category, rows of 10 KB or more.
75
-
76
- **Table 2.** Bytes kept out of context, by category (rule: raw output of 10 KB or more, median per category).
77
-
78
- | Category | What runs | Rows | Median cut |
79
- |---|---|---:|---:|
80
- | a. Sandbox | `ctx_execute` on a file or command | 10 | 99.3% |
81
- | c. Batch | `ctx_batch`: many commands, then search | 2 | 93.1% |
82
- | d. Externalize | Host tool output over the cap, indexed whole | 4 | 92.3% |
83
- | f. Hook redirect | A big Read, curl or WebFetch sent to the sandbox | 5 | 99.8% |
84
- | g. Session total | One full scripted session | 1 | 98.8% |
85
-
86
- Search replies (category b) return text on purpose; they are in the full file. Bench on 2.0.0-next.8, macOS arm64, 2026-10-31.
87
- Reproduce: `cd bench && node run.mjs`. Method and every data file: [bench/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/README.md), [bench/evidence/](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/evidence/README.md).
88
- The plugin numbers are bytes; the dollar numbers come from the Gateway runs in section 8.
38
+ ```sh
39
+ claude plugin marketplace add mksglu/context-mode#release
40
+ claude plugin install context-mode@context-mode
41
+ ```
42
+ Update: `claude plugin update context-mode@context-mode`. Check: `context-mode doctor --agents claude-code`. Remove: `context-mode setup --remove --agents claude-code`.
43
+ Hooks: yes (package) · MCP: yes · Skills: yes · Guide: [docs/install/claude-code.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/claude-code.md#install)
44
+ </details>
45
+ <details open id="install-codex"><summary><b>Codex</b></summary>
89
46
 
90
- ### 2.1 Case studies
47
+ ```sh
48
+ codex plugin marketplace add mksglu/context-mode@release
49
+ codex plugin add context-mode@context-mode
50
+ ```
51
+ Then run `context-mode setup --agents codex` once: it marks the plugin hooks as trusted in the Codex `config.toml`, so Codex runs them.
52
+ Update: `codex plugin marketplace upgrade context-mode`. Check: `context-mode doctor --agents codex`. Remove: `context-mode setup --remove --agents codex`.
53
+ Hooks: yes (hook file) · MCP: yes · Skills: yes · Guide: [docs/install/codex.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/codex.md#install)
54
+ </details>
55
+ <details open id="install-gemini"><summary><b>Gemini CLI</b></summary>
91
56
 
92
- **Case 1. A browser snapshot.** Problem: one Playwright snapshot is 57,521 B, and an agent takes many per task.
93
- Action: the agent runs the snapshot through `ctx_execute` and prints the fields it needs.
94
- Result: 315 B reach the context, a 99.5% cut, measured over 5 runs.
57
+ ```sh
58
+ gemini extensions install https://github.com/mksglu/context-mode --ref release
59
+ ```
60
+ Update: `gemini extensions update context-mode`. Check: `context-mode doctor --agents gemini`. Remove: `context-mode setup --remove --agents gemini`, then `gemini extensions uninstall context-mode`.
61
+ Hooks: yes (package) · MCP: yes · Skills: yes · Guide: [docs/install/gemini.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/gemini.md#install)
62
+ </details>
63
+ <details open id="install-qwen"><summary><b>Qwen Code</b></summary>
95
64
 
96
- **Case 2. A docs page.** Problem: a WebFetch of the SQLite FTS5 page returns 215,354 B.
97
- Action: the `PreToolUse` hook denies the fetch and routes it to `ctx_index`, which keeps the page, and `ctx_search`, which returns the part asked for.
98
- Result: a 435 B reply instead of 215,354 B, a 99.8% cut. The hook took 54 ms.
65
+ ```sh
66
+ qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release
67
+ ```
68
+ Update: `qwen extensions update context-mode`. Check: `context-mode doctor --agents qwen`. Remove: `context-mode setup --remove --agents qwen`, then `qwen extensions uninstall context-mode`.
69
+ Hooks: yes (package) · MCP: yes · Skills: yes · Guide: [docs/install/qwen.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/qwen.md#install)
70
+ </details>
71
+ <details open id="install-pi"><summary><b>Pi</b></summary>
99
72
 
100
- **Case 3. A long session (Gateway).** Task: a long Claude Code session on a 200K window.
101
- Action: the same task through Context Mode Gateway with Recall, 3 pairs, with a rule fixed before the run.
102
- Result: cost fell from $4.86 to $3.04 (2026-10-04) (-37.6%). 3 of 3 pairs passed.
73
+ ```sh
74
+ pi install npm:context-mode@next
75
+ ```
76
+ Update: `pi update --extensions`. Check: `context-mode doctor --agents pi`. Remove: `context-mode setup --remove --agents pi`.
77
+ Hooks: yes (the plugin's own event handlers) · MCP: ctx tools built into the plugin · Skills: yes · Guide: [docs/install/pi.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/pi.md#install)
78
+ </details>
79
+ <details open id="install-opencode"><summary><b>OpenCode</b></summary>
103
80
 
104
- ### 2.2 Longer sessions
81
+ ```sh
82
+ opencode plugin add context-mode@next
83
+ ```
84
+ Update: `opencode plugin update`. Check: `context-mode doctor --agents opencode`. Remove: `opencode plugin remove context-mode@next`, then `context-mode setup --remove --agents opencode`.
85
+ Hooks: yes (the plugin's own event handlers) · MCP: yes · Skills: yes · Guide: [docs/install/opencode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/opencode.md#install)
86
+ </details>
87
+ <details open id="install-copilot-cli"><summary><b>Copilot CLI</b></summary>
105
88
 
106
- <picture>
107
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-oss-dark.png">
108
- <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-oss-light.png" alt="A session grows, the context stays small. The PreToolUse hook sends a tool call to ctx_execute or ctx_index; the full output goes into context.db and a small reply returns. At compaction a snapshot keeps the state, and ctx_resume and ctx_search read it back.">
109
- </picture>
89
+ ```sh
90
+ npm i -g context-mode@next
91
+ context-mode setup --agents copilot-cli
92
+ ```
93
+ Update: `context-mode upgrade`. Check: `context-mode doctor --agents copilot-cli`. Remove: `context-mode setup --remove --agents copilot-cli`.
94
+ Hooks: yes (hook file) · MCP: yes · Skills: yes · Guide: [docs/install/copilot-cli.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/copilot-cli.md#install)
95
+ </details>
96
+ <details open id="install-kiro"><summary><b>Kiro</b></summary>
110
97
 
111
- **Figure 3.** Each tool call: the hook sends large output to the sandbox or the index, the full copy goes into `context.db`, and the agent gets a small reply. At compaction: a snapshot of at most 2,048 B keeps the state, and `ctx_resume` and `ctx_search` read it back.
98
+ ```sh
99
+ npm i -g context-mode@next
100
+ context-mode setup --agents kiro
101
+ ```
102
+ Update: `context-mode upgrade`. Check: `context-mode doctor --agents kiro`. Remove: `context-mode setup --remove --agents kiro`.
103
+ Hooks: yes (hook file) · MCP: yes · Skills: yes · Guide: [docs/install/kiro.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/kiro.md#install)
104
+ </details>
105
+ <details open id="install-vscode"><summary><b>VS Code (Copilot)</b></summary>
112
106
 
113
- The context grows with each reply, and the replies stay small. Bench of 2026-10-31, median of 5 runs, [bench/results/2026-10-31-darwin-arm64.json](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/results/2026-10-31-darwin-arm64.json):
107
+ ```sh
108
+ npm i -g context-mode@next
109
+ context-mode setup --agents vscode
110
+ ```
111
+ Update: `context-mode upgrade`. Check: `context-mode doctor --agents vscode`. Remove: `context-mode setup --remove --agents vscode`.
112
+ Hooks: yes (hook file) · MCP: yes · Skills: yes · Guide: [docs/install/vscode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/vscode.md#install)
113
+ </details>
114
+ <details open id="install-zcode"><summary><b>ZCode</b></summary>
114
115
 
115
- - Debugging session, 8 real outputs and 3 searches: 274.7 KB raw, 3.4 KB entered the context. Row [g-session-total](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/g-overhead/README.md#g-session-total).
116
- - Long session, 40 outputs, then compaction: a 432.5 KB transcript, a 2.0 KB `ctx_resume` block. Row [e-long-session](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/e-continuity/README.md#e-long-session).
117
- - One large log: 651.2 KB of output, a 15.3 KB reply; `ctx_search` finds its first, middle and last line (3 of 3). Row [d-synth-1m](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/d-externalize/README.md#d-synth-1m).
116
+ ```sh
117
+ npm i -g context-mode@next
118
+ context-mode setup --agents zcode
119
+ ```
120
+ Update: `context-mode upgrade`. Check: `context-mode doctor --agents zcode`. Remove: `context-mode setup --remove --agents zcode`.
121
+ Hooks: yes (hook file) · MCP: yes · Skills: yes · Guide: [docs/install/zcode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/zcode.md#install)
122
+ </details>
118
123
 
119
- ## Install
124
+ Already installed from GitHub on `main`? Each agent page has the steps to switch to the `release` ref: see "Already installed from GitHub?" in [Claude Code](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/claude-code.md#already-installed-from-github), [Codex](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/codex.md#already-installed-from-github), [Gemini CLI](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/gemini.md#already-installed-from-github) and [Qwen Code](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/qwen.md#already-installed-from-github).
120
125
 
121
- Use your agent's own install command. You need Node 24.15.0 or later (v2 uses the built-in `node:sqlite`). On Windows you also need Git for Windows: the shell tools run in Git Bash, and `context-mode doctor` check D11 (shell) checks for it.
126
+ The npm route works for every agent:
122
127
 
123
- | Agent | Install | Update |
124
- |---|---|---|
125
- | Claude Code | `claude plugin marketplace add mksglu/context-mode#release`, then `claude plugin install context-mode@context-mode` | `claude plugin update context-mode@context-mode` |
126
- | Codex | `codex plugin marketplace add mksglu/context-mode@release`, then `codex plugin add context-mode@context-mode` | `codex plugin marketplace upgrade context-mode` |
127
- | Gemini CLI | `gemini extensions install https://github.com/mksglu/context-mode --ref release` | `gemini extensions update context-mode` |
128
- | Qwen Code | `qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release` | `qwen extensions update context-mode` |
129
- | Pi | `pi install npm:context-mode@next` | `pi update --extensions` |
130
- | OpenCode | `opencode plugin add context-mode@next` (1.19: `opencode plugin context-mode@next --global`) | `opencode plugin update` (1.19: `opencode plugin context-mode@next --global --force`) |
128
+ ```sh
129
+ npm i -g context-mode@next
130
+ context-mode setup
131
+ ```
131
132
 
132
- Until v2 is on `main`, `main` holds the old build (1.0.169), so the four GitHub-source rows name the `release` branch with each agent's own syntax.
133
+ `context-mode setup` is also the repair. It shows a plan, saves your earlier config, then applies the plan; when a step ends early, it restores the saved config.
134
+ Uninstall: `context-mode setup --remove && npm rm -g context-mode`. Details: [docs/install/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/README.md).
133
135
 
134
- After v2 is on main: `claude plugin marketplace add mksglu/context-mode`, `codex plugin marketplace add mksglu/context-mode`, `gemini extensions install https://github.com/mksglu/context-mode`, `qwen extensions install https://github.com/mksglu/context-mode:context-mode`
136
+ Restart the agent, then run `context-mode doctor` (or `/ctx-doctor` in the agent). Each check prints PASS or a fix command.
135
137
 
136
- Already installed from GitHub on `main`? Each agent page has the steps to switch to the `release` ref: see "Already installed from GitHub?" in [Claude Code](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/claude-code.md#already-installed-from-github), [Codex](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/codex.md#already-installed-from-github), [Gemini CLI](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/gemini.md#already-installed-from-github) and [Qwen Code](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/qwen.md#already-installed-from-github).
138
+ Every agent gets hooks, the MCP server and the plugin skills (files in `skills/`); the last line of each block above says how.
139
+ Hooks reach each agent in one of three ways: in the plugin package (Claude Code, Gemini CLI, Qwen Code), in a hook file (Codex, Copilot CLI, Kiro, VS Code, ZCode), or in a plugin inside the agent (OpenCode, Pi).
140
+ We ran the real binary of each agent with the plugin hook: Claude Code, Codex, Gemini CLI, Qwen Code, Pi, OpenCode, Copilot CLI and ZCode. Each run used a clean temp home and a local test model, on 2.0.0-next.15.
141
+ For VS Code and Kiro, the check covers the hook setup: VS Code runs the hook command with the documented payload, and kiro-cli 2.35.2 loads all 6 hook entries.
142
+ CI runs setup, doctor, a hook and an MCP handshake for all 10 agents from the packed package on Linux, macOS and Windows. Record: [docs/architecture/release/HOOKS-FIRE.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/architecture/release/HOOKS-FIRE.md).
137
143
 
138
- Copilot CLI, Kiro, VS Code and ZCode install through npm, which works for every agent:
144
+ ## Try it
139
145
 
140
- ```sh
141
- npm i -g context-mode@next
142
- context-mode setup
146
+ Paste one of these prompts into your agent after the install. Each one ran once, live, in Claude Code 2.1.312, and its answer matched the source data ([evidence and rerun steps](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/evidence/try-it-2026-11-02/README.md)). The headline numbers in [Benchmarks](#benchmarks) use the median of 5 runs. Other agents do the same job with the same tools: `ctx_execute`, `ctx_index` and `ctx_search`.
147
+ Then run `/ctx-stats` in your agent to see how much output stayed out of the context. Every agent gets this command with the plugin skills ([skills/ctx-stats](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/skills/ctx-stats/SKILL.md)).
148
+ ```text
149
+ On https://react.dev/reference/react/useEffect, show me the example that connects to a chat server and cleans up, and list the rules for the dependency array.
143
150
  ```
144
-
145
- `next` is the v2 prerelease tag on npm. `latest` points to the old release, so add `@next` to get v2.
146
- Restart the agent, then check: `context-mode doctor` (or `/ctx-doctor` in the agent). Each check prints PASS, or FAIL with the command that fixes it.
147
- `context-mode setup` is the fallback and the repair. It shows a plan, applies it, and rolls back an agent that fails.
148
- Uninstall: `context-mode setup --remove && npm rm -g context-mode`. Details: [docs/install/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/README.md).
149
-
150
- Every agent gets hooks, the MCP server and the skills. The Install column is the agent's own install command, or the npm route for the other four agents.
151
-
152
- <!-- agents:install:start (node build/readme-agents.mjs --write) -->
153
- | Agent | Hooks | MCP | Skills | Install | Guide |
154
- |---|---|---|---|---|---|
155
- | Claude Code | yes, package | yes | yes | `claude plugin install context-mode@context-mode` | [docs/install/claude-code.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/claude-code.md#install) |
156
- | Codex | yes, hook file | yes | yes | `codex plugin add context-mode@context-mode` | [docs/install/codex.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/codex.md#install) |
157
- | Copilot CLI | yes, hook file | yes | yes | npm + `context-mode setup` | [docs/install/copilot-cli.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/copilot-cli.md#install) |
158
- | Gemini CLI | yes, package | yes | yes | `gemini extensions install https://github.com/mksglu/context-mode --ref release` | [docs/install/gemini.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/gemini.md#install) |
159
- | Kiro | yes, hook file | yes | yes | npm + `context-mode setup` | [docs/install/kiro.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/kiro.md#install) |
160
- | OpenCode | yes, in-process | yes | yes | `opencode plugin add context-mode@next` | [docs/install/opencode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/opencode.md#install) |
161
- | Pi | yes, in-process | in-process | yes | `pi install npm:context-mode@next` | [docs/install/pi.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/pi.md#install) |
162
- | Qwen Code | yes, package | yes | yes | `qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release` | [docs/install/qwen.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/qwen.md#install) |
163
- | VS Code (Copilot) | yes, hook file | yes | yes | npm + `context-mode setup` | [docs/install/vscode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/vscode.md#install) |
164
- | ZCode | yes, hook file | yes | yes | npm + `context-mode setup` | [docs/install/zcode.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/zcode.md#install) |
165
- <!-- agents:install:end -->
166
-
167
- ## 3. How it works
151
+ The hook sends WebFetch to the sandbox, and the agent searches the page for the example and the rules. 601,984 B raw, 20,860 B reached the context, 96.5% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5).
152
+ ```text
153
+ Fetch https://jsonplaceholder.typicode.com/photos. Which photo has the longest title (give its id and title), and how many photos have a title that contains the word "est"?
154
+ ```
155
+ The agent runs code over 5,000 JSON records in the sandbox and gets back two answers. 1,039,898 B raw, 393 B reached the context, 99.96% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5). The answer is two short facts, so this is the best case of the four.
156
+ ```text
157
+ Here is a Linux syslog sample: https://raw.githubusercontent.com/logpai/loghub/master/Linux/Linux_2k.log. How many authentication failures does it contain, and which 3 remote hosts caused the most?
158
+ ```
159
+ The agent counts failures in a 1,999-line syslog in the sandbox. 216,485 B raw, 566 B reached the context, 99.7% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5).
160
+ ```text
161
+ What are the top 10 stories on the Hacker News front page right now? Give title, points and domain for each.
162
+ ```
163
+ The hook sends WebFetch to the sandbox, and the agent reads ten stories from the page. 35,087 B raw, 1,501 B reached the context, 95.7% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5). The front page changes, so the raw size changes with each run.
164
+
165
+ ## Use cases
166
+
167
+ Real tool output from public projects, run through Context Mode. Bench of 2026-11-01 on 2.0.0-next.23 (commit 16a4bcc5), median of 5 runs ([bench/results/2026-11-01-darwin-arm64.json](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/results/2026-11-01-darwin-arm64.json)); each source is in [bench/fixtures/data/SOURCE.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/fixtures/data/SOURCE.md).
168
+
169
+ | What you do | Tool | Raw | Reaches the context | Saved |
170
+ |---|---|---:|---:|---:|
171
+ | [Read a browser page](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-devtools-mcp-snapshot) | Chrome DevTools MCP `take_snapshot` | 136,514 B | 463 B | 99.7% |
172
+ | [List 40 issues](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-gh-issue-list-vite) | GitHub CLI `gh issue list --json` | 182,943 B | 850 B | 99.5% |
173
+ | [List 25 pull requests with checks](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-gh-pr-list-vite) | GitHub CLI `gh pr list --json` | 195,471 B | 776 B | 99.6% |
174
+ | [Look up library docs](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-context7-query-docs-vite) | Context7 `query-docs` | 6,917 B | 473 B | 93.2% |
175
+ | [Run 1,106 tests](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-vitest-run-vite) | Vitest `vitest run --reporter=verbose` | 62,909 B | 429 B | 99.3% |
176
+ | [Lint a source folder](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-biome-lint-vite) | Biome `biome lint --reporter=json` | 288,523 B | 577 B | 99.8% |
177
+ | [Install a workspace](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-pnpm-install-vite) | pnpm `pnpm install --frozen-lockfile` | 14,988 B | 199 B | 98.7% |
178
+ | [Install packages](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-npm-install-log) | npm `npm install --loglevel http` | 37,761 B | 435 B | 98.8% |
179
+ | [Read container logs](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-docker-logs-mongo) | Docker `docker logs` | 60,374 B | 587 B | 99.0% |
180
+ | [Plan 72 resources](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-terraform-plan) | Terraform `terraform plan` | 34,081 B | 166 B | 99.5% |
181
+ | [Read 300 commits with file stats](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/a-sandbox/README.md#a-git-log-stat-vite) | git `git log --stat` | 164,385 B | 268 B | 99.8% |
182
+ | [Read an 89 KB source file](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-read-vite-config) | Read, sent to `ctx_execute` by the hook | 91,362 B | 375 B | 99.6% |
183
+ | [Fetch a 265 KB docs page](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-webfetch-vite-docs) | WebFetch, sent to `ctx_index` and `ctx_search` | 271,731 B | 439 B | 99.8% |
184
+ | [Fetch a 214 KB API reply](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-bash-curl-post) | curl in Bash, replaced after it runs | 219,175 B | 291 B | 99.9% |
185
+ | [Print a 187 KB git log in Bash](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-bash-dump-post) | Bash, output replaced after it runs | 191,120 B | 204 B | 99.9% |
186
+ | [Print the same git log through a host tool](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/d-externalize/README.md#d-real-git-log) | Host tool output over the cap, indexed whole | 191,120 B | 2,842 B | 98.5% |
187
+ | [Print a 214 KB GitHub API reply through a host tool](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/d-externalize/README.md#d-real-github-json) | Host tool output over the cap, indexed whole | 219,175 B | 4,060 B | 98.1% |
188
+ | [Read a 45 KB log file](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-read-large-file) | Read, sent to `ctx_execute` by the hook | 46,216 B | 371 B | 99.2% |
189
+ | [Read a 60 KB source file](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/f-hook-redirect/README.md#f-read-big-source) | Read, sent to `ctx_execute` by the hook | 61,576 B | 374 B | 99.4% |
190
+ | [Debug for a full session: 8 outputs, 3 searches](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/g-overhead/README.md#g-session-total) | All hooks and tools | 281,261 B | 3,266 B | 98.8% |
191
+
192
+ The agent gets the part it asks for. The full output stays in the local index, and `ctx_search` reads it back.
193
+ The Context7 row has 6,917 B of raw output, under the 10 KB line of the headline rule, so the headline leaves it out.
194
+
195
+ ## Benchmarks
168
196
 
169
197
  <picture>
170
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-flow-dark.png">
171
- <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/fig-flow-light.png" alt="One tool call, step by step: the agent runs a tool, the PreToolUse hook denies a big Read and names the ctx_execute call, the MCP server runs it in the sandbox, SQLite FTS5 keeps the output, and after compaction a state block of at most 2,048 B comes back.">
198
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-saving-dark.png">
199
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-saving-light.png" alt="Bar chart: median output bytes saved per category for rows of 10 KB or more. Sandbox 99.5%, Batch 93.1%, Externalize 98.3%, Hook redirect 99.8%, Session total 98.8%. The table below adds Retrieval, 77.2%.">
172
200
  </picture>
173
201
 
174
- **Figure 4.** One tool call, step by step. Output stays in the sandbox and the index; the agent gets the answer.
202
+ Rule for every headline number in this README: rows with 10 KB or more of raw output, median of 5 runs per row, measured with `ctx_bytes` against `raw_bytes`; a category is the median of its rows; 1 KB = 1,024 B.
203
+ All 36 such rows, the six categories below: the plugin keeps a median of 99.4% of output bytes out of the context. Bench on 2.0.0-next.23 (commit 16a4bcc5 and the local edits that the file records), macOS arm64, 2026-11-01.
175
204
 
176
- Context Mode has three parts: hooks, an MCP server with nine tools, and one SQLite database per project.
205
+ | Category | What runs | Rows | Median saved |
206
+ |---|---|---:|---:|
207
+ | a. Sandbox | `ctx_execute` on a file or command | 19 | 99.5% |
208
+ | b. Retrieval | `ctx_search` over the local index | 3 | 77.2% |
209
+ | c. Batch | `ctx_batch`: many commands, then search | 2 | 93.1% |
210
+ | d. Externalize | Host tool output over the cap, indexed whole | 4 | 98.3% |
211
+ | f. Hook redirect | A big Read, curl or WebFetch sent to the sandbox | 7 | 99.8% |
212
+ | g. Session total | One full scripted session | 1 | 98.8% |
177
213
 
178
- ### 3.1 Hooks
214
+ Search replies (category b) carry the matching text, so they save 77.2%. Category e (long sessions) is in [Longer sessions](#longer-sessions). The full file lists every row, small ones too: [bench/results/2026-11-01-darwin-arm64.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/results/2026-11-01-darwin-arm64.md).
215
+ Reproduce: `cd bench && node run.mjs`. Method and every data file: [bench/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/README.md), [bench/evidence/](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/evidence/README.md).
179
216
 
180
- The hooks listen to four events: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`. Gemini CLI, VS Code and OpenCode also send a compaction event; each host keeps its own event names.
181
- `PreToolUse` checks rules in a fixed order: the user's deny list, WebFetch, curl and HTTP or build commands, then Read and shell dumps.
182
- Context Mode denies a full-file `Read` of a file over 16,384 B, and the deny message names the exact `ctx_execute` call to use. A `Read` with a range still runs.
183
- A hook always exits 0: on any error it gives the host's "allow" reply and writes one log line, so your agent keeps working. Spawned hooks time out after 5,000 ms.
217
+ ### Longer sessions
184
218
 
185
- ### 3.2 Sandbox execution
219
+ <picture>
220
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-oss-dark.png">
221
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-oss-light.png" alt="A session grows, the context stays small. The PreToolUse hook sends a tool call to ctx_execute or ctx_index; the full output goes into context.db and a small reply returns. At compaction a snapshot keeps the state, and ctx_resume and ctx_search read it back.">
222
+ </picture>
223
+
224
+ Say you debug a slow test all afternoon. The agent reads files, runs the suite and fetches docs, and each result goes into the context window. When the window is full, the host compacts it, and from then on the agent sees a short summary plus your next message.
186
225
 
187
- `ctx_execute` writes the script to a temp folder and runs it as a subprocess: shell, PowerShell, JavaScript, TypeScript, Python, or any runtime found on `PATH`.
188
- It spawns the runtime directly from an argument list, in the project folder. The default and maximum timeout is 600,000 ms; on timeout it kills the whole process group (`taskkill /F /T` on Windows).
189
- The child gets the parent environment minus the preload variables (`NODE_OPTIONS`, `BUN_OPTIONS`, `DENO_OPTIONS` and similar). The agent gets what the script prints, cut on a whole character.
226
+ Context Mode keeps the full output of each large tool call in `context.db` on your machine and gives the agent a small reply. At compaction, a snapshot of at most 2,048 B keeps the session state. After the compaction, the agent calls `ctx_resume` to read that snapshot back and `ctx_search` to find any earlier output by keyword.
190
227
 
191
- ### 3.3 Index and search
228
+ In the bench, a scripted session of 40 tool outputs and one compaction made a 442,893 B transcript, and the `ctx_resume` block that brought the agent back was 2,019 B (row [e-long-session](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/e-continuity/README.md#e-long-session) in [the bench file](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/results/2026-11-01-darwin-arm64.json)).
229
+ In the same bench, one large log of 666,796 B put 3,380 B into the context, and the full log stayed in the index for `ctx_search` (row [d-synth-1m](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/d-externalize/README.md#d-synth-1m)).
192
230
 
193
- Each output goes into SQLite FTS5 twice: a Porter-stemmed table for words, and a trigram table for paths, names and parts of words.
194
- `ctx_search` ranks each table with BM25 and joins the two lists with Reciprocal Rank Fusion: a hit scores 1/(60 + rank) in each list.
195
- On zero matches, it tries a spelling fix from the indexed words. Search covers one of three scopes: this session, this worktree (the default) or the whole project.
196
- Chunks are at most 4,096 B. A Markdown chunk stays inside one heading section and carries its heading path as its title. A code block that fits in a chunk stays whole; a bigger one splits on blank lines, and each piece repeats the fence.
197
- A reply snippet is at most 800 B, or a whole code block up to 2,048 B.
231
+ ### Speed
198
232
 
199
- ### 3.4 Large output, run and replace
233
+ Median of 5 runs, bench of 2026-11-01. Rows per agent and per query: [bench/results/2026-11-01-darwin-arm64.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/results/2026-11-01-darwin-arm64.md).
200
234
 
201
- When a host tool returns more than the cap, `PostToolUse` indexes the whole output and replaces it.
202
- The agent gets the best-matching whole chunks and one `ctx_search` line for the rest. Context Mode keeps the full text in the index.
235
+ | Measure | Result |
236
+ |---|---|
237
+ | Hook time over a bare `node` start, per agent | 7.5 ms to 12.3 ms ([g-hook-kiro](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/g-overhead/README.md#g-hook-kiro) to [g-hook-claude-code](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/g-overhead/README.md#g-hook-claude-code)) |
238
+ | `ctx_search`, 20 queries over 8 indexed files | 1.62 ms median, 6.70 ms max ([g-search-latency](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/g-overhead/README.md#g-search-latency)) |
239
+ | `ctx_index`, 3 real files, 625,649 B | 150 ms per MB ([g-index-per-mb](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/g-overhead/README.md#g-index-per-mb)) |
203
240
 
204
- ### 3.5 Session continuity
241
+ ## How it works
205
242
 
206
- The hooks log each prompt, edit, command, tool error, index, cost and decision.
207
- After a compaction the agent gets a state block of at most 2,048 B built from that log. Every line stays whole: a long line becomes a `ctx_resume(seq)` pointer that reads the full row.
208
- On the next prompt, a recall block of at most 2,048 B brings back the log rows that match it by BM25, always as whole rows. The same rows always give the same bytes.
243
+ <picture>
244
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-flow-dark.png">
245
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/fig-flow-light.png" alt="One tool call, step by step: the agent runs a tool, the PreToolUse hook denies a big Read and names the ctx_execute call, the MCP server runs it in the sandbox, SQLite FTS5 keeps the output, and after compaction a state block of at most 2,048 B comes back.">
246
+ </picture>
209
247
 
210
- ### 3.6 Storage
248
+ 1. Your agent calls a tool: it reads a file, runs a command or fetches a page.
249
+ 2. A hook sees the call first. It sends a big read or fetch to the sandbox and gives the agent the exact call to use.
250
+ 3. The sandbox runs the work on your machine and keeps the full output in a local SQLite index.
251
+ 4. The agent gets the part it asked for, and calls `ctx_search` when it wants more.
252
+ 5. After a compaction, the agent gets a short state block; each line points to the full record.
211
253
 
212
- Context Mode uses Node's built-in `node:sqlite`, so the install compiles zero native modules. Each project gets one `context.db` under `~/.context-mode`.
213
- The database runs in WAL mode. On close it always runs a PASSIVE checkpoint. Context Mode builds a new database under a temp name, then moves it into place in one step, so the file on disk is always complete, even after a crash. Busy timeout: 5,000 ms.
254
+ Timeouts, chunk sizes, ranking and storage: [Engineering details](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/how-it-works.md#engineering-details).
214
255
 
215
- ## 4. Tools
256
+ ## Tools
216
257
 
217
258
  | Tool | What it does |
218
259
  |---|---|
219
260
  | `ctx_execute` | Runs code or a shell command in a sandbox; returns what it prints |
220
261
  | `ctx_batch` | Runs many commands, indexes the output, and searches it in one call |
221
262
  | `ctx_index` | Indexes a file, a text or a URL into the project database |
222
- | `ctx_search` | Searches the index; returns the matching parts |
223
- | `ctx_resume` | Returns the state block, or one full row by `seq` |
263
+ | `ctx_search` | Searches the local index; returns the matching parts |
264
+ | `ctx_resume` | Returns the plugin's local state block (at most 2,048 B), or one full row by `seq` |
224
265
  | `ctx_stats` | Shows how much output stayed out of context |
225
- | `ctx_doctor` | Checks the install; each FAIL line names its fix |
266
+ | `ctx_doctor` | Checks the install; each check prints PASS or a fix command |
226
267
  | `ctx_upgrade` | Installs, upgrades or uninstalls; replaces old context-mode entries |
227
268
  | `ctx_purge` | Deletes indexed data by session, source or project |
228
269
 
229
- Full reference: [docs/tools.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/tools.md).
230
-
231
- ## Commands
232
-
233
- | Command | What it does |
234
- |---|---|
235
- | `/ctx-stats` | Calls `ctx_stats` and shows the result |
236
- | `/ctx-doctor` | Calls `ctx_doctor`; use its report when you report a defect |
237
- | `/ctx-upgrade` | Calls `ctx_upgrade`, then `ctx_doctor` |
270
+ Full reference: [docs/tools.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/tools.md).
238
271
 
239
- ## 5. Harness: ten agents
272
+ Commands in the agent: `/ctx-stats` shows the `ctx_stats` result, `/ctx-doctor` runs `ctx_doctor` (send its report with a defect report), and `/ctx-upgrade` runs `ctx_upgrade`, then `ctx_doctor`.
240
273
 
241
- Every agent in the Install table gets hooks, the MCP server and the skills, through that agent's own install command.
242
- Hooks reach each agent in one of three ways: in the plugin package (Claude Code, Gemini CLI, Qwen Code), in a hook file (Codex, Copilot CLI, Kiro, VS Code, ZCode), or in-process (OpenCode, Pi).
274
+ ## Security and privacy
243
275
 
244
- Live proof, written for 2.0.0-next.15: we watched the real agent binary run our hook in a clean temp home, logged out and with zero API keys, for 8 of 10 agents.
245
- VS Code and Kiro are at an earlier step: the VS Code hook command works with the documented payload (VS Code 1.144.0 sent 0 requests in the live run), and kiro-cli 2.35.2 loads all 6 hook entries (the live run recorded 0 hook fires).
246
- CI runs setup, doctor, a hook and an MCP handshake for all 10 agents from the packed package on Linux, macOS and Windows. Record: [docs/architecture/release/HOOKS-FIRE.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/architecture/release/HOOKS-FIRE.md).
247
-
248
- ## 6. Performance
249
-
250
- **Table 3.** Time cost, median of 5 runs, bench of 2026-10-31.
251
-
252
- | Measure | Result |
253
- |---|---|
254
- | Hook time over a bare `node` start, per agent | 7.3 ms to 14.6 ms |
255
- | `ctx_search`, 20 queries over 8 indexed files | 1.73 ms median, 6.54 ms max |
256
- | `ctx_index`, 3 real files, 0.6 MB | 155 ms per MB |
257
-
258
- Rows per agent and per query: [docs/performance.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/performance.md).
259
-
260
- ## 7. Security model
261
-
262
- - All data stays on your machine, in `~/.context-mode`: one `context.db` per project.
263
- - Runs fully local: SQLite FTS5 and your own runtimes.
264
- - Network use: npm or git (to the release repository) when you install or upgrade, `git ls-remote` in doctor (to check for a new version), and your agent's own install steps.
265
- - `ctx_index` fetches a URL when the agent asks for it. It blocks private and link-local addresses. It checks each address the host name points to, connects to the address it checked, and checks again at each redirect.
276
+ - The plugin keeps all its data on your machine, in `~/.context-mode`: one `context.db` per project. `ctx_purge` deletes it by session, source or project.
277
+ - The plugin has zero telemetry: usage data, events and crash reports stay on your machine. It uses the network at these call sites, each one started by you or your agent:
278
+ - `ctx_index` of a URL the agent asks for: `src/core/sandbox/fetch.ts`. It blocks private and link-local addresses, checks each address the host name points to, connects to the address it checked, and checks again at each redirect.
279
+ - `context-mode doctor`: `git ls-remote` to the release repository, to check for a new version (`src/core/ops/doctor-env.ts`).
280
+ - `ctx_upgrade`: `git clone --depth 1` of the release branch (`src/core/ops/release-fetch.ts`). `context-mode upgrade`: `npm i -g context-mode@next` (`src/cli/commands.ts`).
281
+ - The debug report: `gh issue create`, after you press a key (`src/cli/commands.ts`).
282
+ - Install and update: your agent's own install command, npm or git.
283
+ - The guard test D-PRIVACY-NET-1 in `tests/0008-enforcement.test.mjs` scans `src` for HTTP clients, sockets, DNS lookups, git network calls and `gh` or `npm` spawns. It fails when a new call site appears outside this list, so this section stays true.
266
284
  - Doctor and the debug report remove secrets by their structure before they print.
267
285
 
268
- Here "sandbox" means the output stays in the sandbox, out of the context.
269
- Code from `ctx_execute` runs on your host as your user, with your environment (minus the preload variables), your files and your network; keep your agent's own permission prompts on.
286
+ Here "sandbox" means the output stays in the sandbox, out of the context. Code from `ctx_execute` runs on your host as your user, with your environment (minus the preload variables), your files and your network; keep your agent's own permission prompts on.
270
287
 
271
- ## 8. Context Mode Gateway
288
+ ## Context Mode Gateway
272
289
 
273
- The plugin works on tool output, on your machine. Context Mode Gateway is a hosted service that works on every request, across all your agents: Recall, Memory, Skills, Search and Protect.
290
+ The plugin works on tool output, on your machine, and it is complete on its own. Context Mode Gateway is an optional hosted service that works on every request, across all your agents. Its 11 features, the full list: Context Saving, Recall, Memory, Skills, Search, Session resume, Active Context, Instructions, Protect, Prompt caching, Live and Analytics.
274
291
  Teams add it for long sessions, shared memory and cost reports. The two work together.
292
+ Gateway Recall, Search and Session resume run on the Gateway server, across sessions and agents. The plugin's `ctx_search` and `ctx_resume` read the local `context.db` of one project.
293
+ With the Gateway on, your requests pass through its server; the plugin keeps its own data on your machine.
275
294
 
276
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/overview.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/overview-1200.webp" alt="Gateway Overview: money saved, AI spend, prompt-cache discount and cost per request over 30 days" width="100%"></a>
295
+ <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/live.mp4"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/live.webp" width="100%" alt="Gateway Live screen during a session: money saved, bytes kept out per request, history kept and sent, and a feed of each request with its cost and saving"></a>
277
296
 
278
- **Overview.** What you paid and what the Gateway saved, per day, in one view.
297
+ **Live.** One session as it runs: money saved this session, bytes kept out per request, history kept and sent, and a feed of each request with its cost and saving. [Full video](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/live.mp4)
298
+
299
+ Docs: [How saving works](https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=live), [Recall](https://contextmode.ai/docs/recall?utm_source=github&utm_medium=readme&utm_content=live), [Session resume](https://contextmode.ai/docs/session-resume?utm_source=github&utm_medium=readme&utm_content=live)
279
300
 
280
301
  <table>
281
- <tr>
282
- <td width="50%" valign="top">
283
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/analytics.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/analytics-1200.webp" alt="Gateway Analytics: saved money over time, split by source" width="100%"></a><br>
284
- <b>Analytics.</b> Where each saving comes from: hidden tools, archived old results, large outputs kept in the archive and trimmed context.
285
- </td>
286
- <td width="50%" valign="top">
287
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/spend.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/spend-1200.webp" alt="Gateway Spend: spend per day by model, cost per request and cache hit rate" width="100%"></a><br>
288
- <b>Spend.</b> Spend per day and per model, cost per request and the cache hit rate, to help you plan a budget.
289
- </td>
290
- </tr>
291
- <tr>
292
- <td width="50%" valign="top">
293
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/memory.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/memory-top-1200.webp" alt="Gateway Memory: money saved by Recall and searches per day" width="100%"></a><br>
294
- <b>Memory.</b> Facts and decisions carry across sessions and agents. The screen shows what Recall saved and how many searches found an answer.
295
- </td>
296
- <td width="50%" valign="top">
297
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/skills.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/skills-1200.webp" alt="Gateway Skills: import from GitHub and the list of installed skills" width="100%"></a><br>
298
- <b>Skills.</b> Add a skill once and all your clients use it when it helps. Import skills from GitHub and see the installed ones.
299
- </td>
300
- </tr>
301
- <tr>
302
- <td colspan="2" align="center">
303
- <a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/assets/readme/gateway/protect.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/gateway/protect-1200.webp" alt="Gateway Protect: a new command rule that blocks terraform destroy" width="50%"></a><br>
304
- <b>Protect.</b> Rules that check each shell command before it runs. Here, a rule that stops <code>terraform destroy</code>.
305
- </td>
306
- </tr>
302
+ <tr><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/overview.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/overview-1200.webp" alt="Gateway Overview: money saved, AI spend, prompt-cache discount and cost per request over 30 days"></a><br><b>Overview.</b> What you paid and what the Gateway saved, per day, in one view.<br>Docs: <a href="https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=overview">How saving works</a></td><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/analytics.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/analytics-1200.webp" alt="Gateway Analytics: saved money over time, split by source"></a><br><b>Analytics.</b> Where each saving comes from: hidden tools, archived old results, large outputs kept in the archive and trimmed context.<br>Docs: <a href="https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=analytics">How saving works</a>, <a href="https://contextmode.ai/docs/active-context?utm_source=github&utm_medium=readme&utm_content=analytics">Active Context</a></td></tr>
303
+ <tr><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/spend.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/spend-1200.webp" alt="Gateway Spend: spend per day by model, cost per request and cache hit rate"></a><br><b>Spend.</b> Spend per day and per model, cost per request and the cache hit rate, to help you plan a budget.<br>Docs: <a href="https://contextmode.ai/docs/prompt-caching?utm_source=github&utm_medium=readme&utm_content=spend">Prompt caching</a></td><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/memory.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/memory-top-1200.webp" alt="Gateway Memory: money saved by Recall and searches per day"></a><br><b>Memory.</b> Facts and decisions carry across sessions and agents. The screen shows what Recall saved and how many searches found an answer.<br>Docs: <a href="https://contextmode.ai/docs/memory?utm_source=github&utm_medium=readme&utm_content=memory">Memory</a>, <a href="https://contextmode.ai/docs/recall?utm_source=github&utm_medium=readme&utm_content=memory">Recall</a></td></tr>
304
+ <tr><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/skills.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/skills-1200.webp" alt="Gateway Skills: import from GitHub and the list of installed skills"></a><br><b>Skills.</b> Add a skill once and all your clients use it when it helps. Import skills from GitHub and see the installed ones.<br>Docs: <a href="https://contextmode.ai/docs/skills?utm_source=github&utm_medium=readme&utm_content=skills">Skills</a></td><td width="50%"><a href="https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/gateway/protect.webp"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/gateway/protect-1200.webp" alt="Gateway Protect: a new command rule that blocks terraform destroy"></a><br><b>Protect.</b> Rules that check each shell command before it runs. Here, a rule that stops <code>terraform destroy</code>.<br>Docs: <a href="https://contextmode.ai/docs/protect?utm_source=github&utm_medium=readme&utm_content=protect">Protect</a></td></tr>
307
305
  </table>
308
306
 
309
- Numbers in these screenshots come from the author's own account over 30 days (Oct 3 - Nov 1, 2026), so read them as one account's usage. Click an image for the full size.
307
+ Numbers in these screens come from the author's own account over 30 days (Oct 3 - Nov 1, 2026), so read them as one account's usage. Click an image for the full size.
308
+
309
+ Three prompts to try with the Gateway on. The line under each one names the feature it shows.
310
+ ```text
311
+ Move this project from Jest to Vitest. Convert every test file, fix the config, run the suite after each batch, and tell me what is left.
312
+ ```
313
+ Memory keeps the plan and the file list across a long job.
314
+ ```text
315
+ Pick up where we stopped yesterday on the Jest to Vitest move. What is done, what is left, and which test was failing?
316
+ ```
317
+ Recall brings back yesterday's work in a fresh session.
318
+ ```text
319
+ Which date library did we choose on Tuesday, and why did we reject the other two?
320
+ ```
321
+ Search finds the answer in past sessions.
310
322
 
311
- **Table 4.** Context Mode Gateway features, from [contextmode.ai/docs](https://contextmode.ai/docs/how-saving-works).
323
+ <details>
324
+ <summary>Gateway features, from contextmode.ai/docs</summary>
325
+
326
+ Source: [contextmode.ai/docs](https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=features):
312
327
 
313
328
  | Feature | What it does | What you get | Details |
314
329
  |---|---|---|---|
315
- | Context Saving | Folds old tool output, runs data work as code (Thinking in Code), trims tool schemas, places cache marks | Tool schemas 102,784 B to 33,611 B per request (-67.3%); a tool output over 2,048 B becomes a pointer of about 285 B, with the full copy archived | Saves the most on sessions with many tool calls; A/B measured in Claude Code |
316
- | Recall | The model sees recent work and an index of older work; the agent searches the archive for the rest | 200K window, 2026-10-04: mean cost per session $4.86 to $3.04 (-37.6%) | Cost measured in Claude Code on Claude Opus 5.5 |
330
+ | Context Saving | Folds old tool output, runs data work as code (Thinking in Code), trims tool schemas, places cache marks | A tool output over 2,048 B becomes a short pointer, with the full copy archived | Saves the most on sessions with many tool calls ([How saving works](https://contextmode.ai/docs/how-saving-works?utm_source=github&utm_medium=readme&utm_content=table)) |
331
+ | Recall | The model sees recent work and an index of older work; the agent searches the archive for the rest | Gateway, Claude Code, Opus 5.5, 200K window, 2026-10-04: mean cost per session $4.8627 to $3.0353 (-37.6% in dollars, [ab.json](https://contextmode.ai/benchmarks/recall/200k-r2/ab.json?utm_source=github&utm_medium=readme&utm_content=table)) | Cost measured in Claude Code on Claude Opus 5.5 |
317
332
  | Memory | Each fact keeps two times: when it was true and when the Gateway learned it | Claude Code and Codex on one account share one store, tested end to end | The memory block goes into the first request of a new session |
318
333
  | Skills | A skill catalog on the Gateway for your account; it loads the skill that matches your message | The matching skill loads on the message that needs it | Import skills from GitHub; a loaded skill joins the prompt in full |
319
- | Search | Searches the prompts, commands and tool output that passed through, in the console and as an agent tool | Find any past prompt, command or tool output, from the console or your agent | The console searches the first 4,000 characters of each tool result |
320
- | Session resume | One command rebuilds a conversation as a native Claude Code or Codex session | Continue a conversation in Claude Code or Codex | Restores the text, tool names and a summary; the command is valid for 15 minutes |
321
- | Active Context | Sets how much a thread carries before its oldest parts move to the archive: 200K, 500K or 1M tokens | Pick the window size per thread | An image older than the kept part becomes a short text note |
322
- | Instructions | One text of at most 4,096 characters that tells every agent how to answer you | Read from the provider cache after the first request | Sets how the agent writes to you |
334
+ | Search | Searches the prompts, commands and tool output that passed through, in the console and as an agent tool | Find any past prompt, command or tool output, from the console or your agent | The console searches the first 4,000 characters of each tool result ([Search](https://contextmode.ai/docs/search?utm_source=github&utm_medium=readme&utm_content=table)) |
335
+ | Session resume | One command rebuilds a conversation as a native Claude Code or Codex session | Continue a conversation in Claude Code or Codex | Restores the text, tool names and a summary; the command is valid for 15 minutes ([Session resume](https://contextmode.ai/docs/session-resume?utm_source=github&utm_medium=readme&utm_content=table)) |
336
+ | Active Context | Sets how much a thread carries before its oldest parts move to the archive: 200K, 500K or 1M tokens | Pick the window size per thread | An image older than the kept part becomes a short text note ([Active Context](https://contextmode.ai/docs/active-context?utm_source=github&utm_medium=readme&utm_content=table)) |
337
+ | Instructions | One text of at most 4,096 characters that tells every agent how to answer you | Read from the provider cache after the first request | Sets how the agent writes to you ([Instructions](https://contextmode.ai/docs/instructions?utm_source=github&utm_medium=readme&utm_content=table)) |
323
338
  | Protect | A tool-call firewall: checks shell commands, file reads and writes, web fetches and tool-server calls by what they do | Each call checked before it runs | Reads the call itself, so keep your agent's sandbox on for script files and paths built at run time; opt-in |
324
- | Prompt caching | Keeps requests cache-friendly: cache marks on the fixed part of the prompt and a cache for fetched pages | Inside the measured costs above | Uses up to 4 cache marks, the provider's maximum |
339
+ | Prompt caching | Keeps requests cache-friendly: cache marks on the fixed part of the prompt and a cache for fetched pages | Inside the measured costs above | Uses up to 4 cache marks, the provider's maximum ([Prompt caching](https://contextmode.ai/docs/prompt-caching?utm_source=github&utm_medium=readme&utm_content=table)) |
325
340
  | Live and Analytics | Shows each request and what the Gateway saved, as it happens and over time | See each request and its saving, live and over time | Covers every request that passes through the Gateway |
326
341
 
342
+ </details>
343
+
327
344
  Gateway cost against Claude Code alone, Claude Opus 5.5, mean dollars per session at list price:
328
345
 
329
- - Six short tasks (2026-09-29): 24.5% cheaper pooled over 176 sessions (21% to 29% per task). [v3-opus55-short.json](https://contextmode.ai/benchmarks/data/v3-opus55-short.json)
330
- - Long Claude Code session, 200K window (2026-10-03/04): mean cost per session $4.86 to $3.04 (-37.6%). [ab.json](https://contextmode.ai/benchmarks/recall/200k-r2/ab.json)
331
- - We fixed the rules before each run: [contextmode.ai/docs/benchmarks](https://contextmode.ai/docs/benchmarks).
346
+ - Six short tasks (2026-09-29): 24.5% fewer dollars pooled over 176 sessions (21% to 29% per task). [v3-opus55-short.json](https://contextmode.ai/benchmarks/data/v3-opus55-short.json?utm_source=github&utm_medium=readme&utm_content=bench)
347
+ - Long Claude Code session, 200K window (2026-10-03/04): mean cost per session $4.8627 to $3.0353 (-37.6% in dollars, mean of 3 pairs). [ab.json](https://contextmode.ai/benchmarks/recall/200k-r2/ab.json?utm_source=github&utm_medium=readme&utm_content=bench)
348
+ - We fixed the rules before each run: [contextmode.ai/docs/benchmarks](https://contextmode.ai/docs/benchmarks?utm_source=github&utm_medium=readme&utm_content=bench).
332
349
 
333
350
  Apps: Claude Code, Claude Desktop, Codex, Codex Desktop, T3 Code, OpenCode and Pi.
334
- Setup is one command, `npx @context-mode/cli`. It signs you in and writes one config change per agent (it needs Node 20.12 or later).
335
- Your own Claude or OpenAI account pays the model directly, at the provider's price.
351
+ Setup is one command, `npx @context-mode/cli`. It signs you in and writes one config change per agent (the Gateway CLI needs Node 20.12 or later, from its npm `engines` field; the plugin needs Node 24.15.0).
352
+ The Gateway routes to Anthropic and OpenAI. The Gateway sends your requests to its server on the way to the model. It keeps a searchable record of your sessions for Recall and Search, and masks secrets and e-mail addresses when it reads archived output back. Its privacy page is at [contextmode.ai/privacy](https://contextmode.ai/privacy?utm_source=github&utm_medium=readme&utm_content=privacy).
353
+ Keep your agent's own sandbox on next to Protect. More at [contextmode.ai](https://contextmode.ai/?utm_source=github&utm_medium=readme&utm_content=more).
336
354
 
337
- The Gateway routes to Anthropic and OpenAI. Requests pass through the Gateway server on their way to the model.
338
- Keep your agent's own sandbox on next to Protect.
339
- More at [contextmode.ai](https://contextmode.ai).
355
+ ## Adoption: stars and npm downloads
340
356
 
341
- ## 9. Adoption
357
+ <picture>
358
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/star-history-dark.png">
359
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/star-history-light.png" alt="Line chart of cumulative GitHub stars for mksglu/context-mode since 2026-02-23. A daily job redraws it.">
360
+ </picture>
342
361
 
343
362
  <picture>
344
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/star-history-dark.png">
345
- <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.25/docs/assets/readme/star-history-light.png" alt="Line chart of cumulative GitHub stars for mksglu/context-mode since 2026-02-23. A daily job redraws it.">
363
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/stargazers-dark.png">
364
+ <img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/stargazers-light.png" alt="Companies that stargazers of mksglu/context-mode name in their GitHub profile, Microsoft, Tencent, Alibaba, ByteDance, Google and more.">
346
365
  </picture>
347
366
 
348
- **Figure 5.** GitHub stars over time, from the stargazers API (GraphQL, `starredAt`). A daily job redraws the chart; the date it was read is in the chart caption.
367
+ Starred by engineers at these companies: each name is the company field of 2 or more stargazer profiles, read with the GitHub GraphQL API on 2026-11-01 ([data](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/assets/readme/data/stargazer-companies.json)).
368
+
369
+ GitHub stars over time, from the stargazers API (GraphQL, `starredAt`). A daily job redraws the chart; the date it was read is in the chart caption.
370
+
371
+ npm downloads of the package by day, week, month and year, read from the npm API (`api.npmjs.org/downloads/range`) since the first publish on 2026-02-23. The total up to 2026-10-29 is 683K npm downloads ([stats.json](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/stats.json) keeps a daily copy). Pick a view; the same daily job redraws all four.
372
+
373
+ <details open name="npm"><summary><b>Daily</b></summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-daily-dark.png"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-daily-light.png" alt="Line chart of npm downloads per day for context-mode over the last 90 days. A daily job redraws it."></picture></details>
374
+ <details name="npm"><summary><b>Weekly</b></summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-weekly-dark.png"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-weekly-light.png" alt="Line chart of npm downloads per ISO week for context-mode since the first publish on 2026-02-23. A daily job redraws it."></picture></details>
375
+ <details name="npm"><summary><b>Monthly</b></summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-monthly-dark.png"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-monthly-light.png" alt="Bar chart of npm downloads per month for context-mode since the first publish on 2026-02-23. A daily job redraws it."></picture></details>
376
+ <details name="npm"><summary><b>Yearly</b></summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-yearly-dark.png"><img src="https://raw.githubusercontent.com/mksglu/context-mode/v2.0.0-next.27/docs/assets/readme/npm-yearly-light.png" alt="Chart of total npm downloads per year for context-mode, with the running total since 2026-02-23. A daily job redraws it."></picture></details>
349
377
 
350
- - **npm downloads.** The badge at the top shows all-time downloads of the npm package, read daily from the npm API ([stats.json](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/stats.json)). We have no count for plugin marketplace installs.
351
378
  - **Hacker News.** "MCP server that reduces Claude Code context consumption by 98%" reached the front page with 570+ points and 107 comments on 2026-02-28 ([thread](https://news.ycombinator.com/item?id=47193064)).
352
379
  - **GitHub Trending.** A bot that watches GitHub Trending logged the repo there on 14 days from 2026-04-24 to 2026-10-17 ([uibm/trending-watcher](https://github.com/uibm/trending-watcher/issues?q=%22mksglu%2Fcontext-mode%22)).
353
- - **Companies.** Engineers at the companies under Figure 1 starred the repo.
354
380
 
355
381
  ## License
356
382
 
357
- [Elastic License 2.0](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/LICENSE) (ELv2), source-available. You may use, copy, change and share the code, and use it at work.
358
- The license keeps two uses for the licensor:
383
+ [Elastic License 2.0](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/LICENSE) (ELv2), a source-available license. You may use, copy, change and share the code, and use it at work, free of charge.
384
+ The license keeps three uses for the licensor:
359
385
 
360
- 1. Offering it to others as a hosted or managed service.
361
- 2. Removing, hiding or getting around its license notices or license key functions.
386
+ 1. Offering the software to others as a hosted or managed service that gives them a large part of its features.
387
+ 2. Moving, changing, turning off or getting around the license key functions, or removing or hiding what the license key protects.
388
+ 3. Changing, removing or hiding the licensor's license, copyright or other notices.
362
389
 
363
390
  We chose ELv2 so the source stays open to all and the hosted service stays with the project.
364
391
 
365
- ## Support
392
+ ## Community
366
393
 
367
394
  Report a defect on [Discord](https://discord.gg/DCN9jUgN5v) with the full `/ctx-doctor` report.
368
- Fixes go into v2. The maintainer writes every change; send ideas and defect reports on Discord.
395
+ The maintainer writes every change; send ideas and defect reports on Discord.
369
396
 
370
- Docs: [docs/install/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/install/README.md) (install, options, uninstall), [docs/how-it-works.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/how-it-works.md), [docs/algorithms.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/algorithms.md) (search, ranking, size limits, deny rules), [docs/tools.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/docs/tools.md), [bench/evidence/](https://github.com/mksglu/context-mode/blob/v2.0.0-next.25/bench/evidence/README.md).
397
+ Docs: [docs/install/README.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/install/README.md) (install, options, uninstall), [docs/how-it-works.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/how-it-works.md), [docs/algorithms.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/algorithms.md) (search, ranking, size limits, deny rules), [docs/tools.md](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/docs/tools.md), [bench/evidence/](https://github.com/mksglu/context-mode/blob/v2.0.0-next.27/bench/evidence/README.md).
package/SHA256SUMS CHANGED
@@ -1,10 +1,10 @@
1
- 19634af32c38fe3240faa244ff5528ab5b48b7eb216996fac7ddf613ef94c7a5 .claude-plugin/marketplace.json
2
- 301a8b854b699e4a230523f262747d3868a3f23d073bdcbca885c7cdc0ee7c1d .claude-plugin/plugin.json
1
+ 5290047c2b946f1f39fc691a8773971334220cb6085440edd7f2d4b8d48e9d3e .claude-plugin/marketplace.json
2
+ 3eb50b61097150f5c8737bed1faa638a410d9bd799d2552891d943263b0c89b3 .claude-plugin/plugin.json
3
3
  187503e1455560d4ab5a72e3b8cd2f274abd4ccc5faa60dd66c37e44bb5f10c2 .codex-plugin/hooks.json
4
4
  4edea851775bc3f0418f8d9cf6ead74f2767c3a9e3b8c05749eacb78ebb3b896 .codex-plugin/mcp.json
5
- f249a7fefe76290647958ebae6dba98789d33f5025f4d239ef246f521a0fc915 .codex-plugin/plugin.json
5
+ 3e6f171a3688c5dd372ef21025d2db7d6fb993c3b20753386156babc74894f23 .codex-plugin/plugin.json
6
6
  92f11a867c41c9e575ccb978ff205ae2011c244a14aa3c576e914e537105caa0 LICENSE
7
- 19b375be1dd98dd6325c7d0c24de2c68fd8d71b8d9e3872b2f9ddd3676fc891d README.md
7
+ 5ead708d3e38e34b549787110722b53e4f3a3d870540c0581de6c053865d7766 README.md
8
8
  1773e40a89384dd1af9023ba533da1908f3e2435dbaaa7cc941edf0514148313 claude-code/skills/ctx-doctor/SKILL.md
9
9
  34fffb9c76d69c551f07036230bec0fbaca7a69177a5a47f89ddb9a9990a1fa2 claude-code/skills/ctx-stats/SKILL.md
10
10
  d8f835d2f2b3eb70c5902f8707e7c5857977cec9e20ace76c499378a04e178e0 claude-code/skills/ctx-upgrade/SKILL.md
@@ -12,9 +12,9 @@ d8f835d2f2b3eb70c5902f8707e7c5857977cec9e20ace76c499378a04e178e0 claude-code/sk
12
12
  83c297020ed0c592fc68c9c482546a6999d41df5d06d8a329498f10edb1bd38e codex/skills/ctx-doctor/SKILL.md
13
13
  adc2c374f699d3698110920bb48411965de09fc6e7232ce59c913f6d58c0d738 codex/skills/ctx-stats/SKILL.md
14
14
  5c12cdd19a5e3ed7d9ba3a47b24d03864a28d36cf7006876284ee07cd4221ec4 codex/skills/ctx-upgrade/SKILL.md
15
- 71f32768a75a71e12b67710be3f40dff63e6011a48c1e3bd614cd0c4b79c5344 copilot/plugin.json
15
+ 46969af88615d4752631c60f35365070f666c104ec427d24111ac09fa9858987 copilot/plugin.json
16
16
  e3bc6cae0bd51b806d81631879711bbc48c679fc929b2642ed4634438364167d fixtures/hook-roundtrip.json
17
- 79f687614cbddfdbe16ead7634adb3b7ba2e83f15d835e061d5eff3791e0d3d4 gemini-extension.json
17
+ 34c718627acc7b3ef6bb3fd31920e16dce8bb9d1104179d3e0c2706857149754 gemini-extension.json
18
18
  7a9b99aaea8d220cc20bead47ea161008bedade54bd0f809f0e9206d485e7646 hook.mjs
19
19
  1f8d8650d2b38737522cab6b875878e8baf84a74acf98cd924c7af22852d873f hooks/claude-code.json
20
20
  2524a0eb52683b65c65943c5097db513e9845ba14e84324b39e9a8ea2bb43193 hooks/codex.json
@@ -24,16 +24,16 @@ f336d1db67de49e641687bbd41ba1a9424e31dfe2377b2284bf44358288ebd8b hooks/kiro.jso
24
24
  017c9cc3997dd53231b8548b1a1609fddc51177af53501565a4f334602039860 hooks/qwen.json
25
25
  33f69267645338d0dc392ce551dcd7c69a0b508113469d6ea637d3f34239ef1d hooks/vscode.json
26
26
  085630bccf2073ac9a62be24ef91dfc47d106092dc82c822db70890b7d3ae1c0 hooks/zcode.json
27
- b75cf3cc1426da4e7ad29dfc8a6037f432c07771b7942bd0e3188c265698614f opencode/plugin.js
28
- 41f5b88ea44b60839d258e04f8b7b10a0f878a58711e3bd1307ab205eadab7e5 package.json
29
- 4fec69ec47e96057a836304cee18ee043e9832c5d9a64f491c4248c0777eb5ee pi/index.js
27
+ 0f558743d4ac30853360a0dda4f44b6f902bb9ac0855ca44a05d1cd060eaf224 opencode/plugin.js
28
+ fc50b8bf8172fef0d03ca403c06eb4cded80957b4a0c84b32ab4d1c45bacb30f package.json
29
+ 456128c05f006b945ef2cfad9980803b6360eb7230b90509d4a62a6a23247116 pi/index.js
30
30
  8712881622c9905aa4836af50d903042d34a91506264e459bc7839331f6f0192 pi/skills/ctx-doctor/SKILL.md
31
31
  8d6e8e2a82eb079bddc60727f52d9f9a6e0bf9e15391357fed82ee76ab5fe76c pi/skills/ctx-stats/SKILL.md
32
32
  db6f9c006bc864a7271f1eeffb1e316ebb537a3414f1c22f8b9de0a896e8e3c5 pi/skills/ctx-upgrade/SKILL.md
33
- d899d085d9e1b122cf004f5ae3f44e29644f34d7df2d218bfb2c15730bc92d25 qwen-extension.json
33
+ 4d91a5290839ffbae3dea75124ec094e3f88b82869dab8d48cdf4a69dfd67189 qwen-extension.json
34
34
  cd2c35d662911b5147d1540c9549172393c8ced94239bb1fdc959424f2160b6b run.mjs
35
35
  cd2c35d662911b5147d1540c9549172393c8ced94239bb1fdc959424f2160b6b search.mjs
36
- 2946a555ee90f13ef3496eaa92af01b0c118e047e3ef753833253a40744276eb server.mjs
36
+ d47b70885fff53d29bd5c433a223e2b8c2205d26791183d3d6ce9e36bb587657 server.mjs
37
37
  e5503a22a6238901484d123efc11d2d933aa9a54c6ac2018812cfa65ec4e53e3 skills/ctx-doctor/SKILL.md
38
38
  1044587a1906c69f2467c089a25e19819a290ea5728389bd1f086c6dfc0d0c51 skills/ctx-stats/SKILL.md
39
39
  c1cac75b7506ee0d06089ce611ac6dc9314cf12435da318ce88ad50e2c5debbf skills/ctx-upgrade/SKILL.md
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.0.0-next.25"
14
+ "version": "2.0.0-next.27"
15
15
  }
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.0.0-next.25"
14
+ "version": "2.0.0-next.27"
15
15
  }
@@ -370,7 +370,7 @@ var DECISION_OPTION_KEY = "option";
370
370
  var DECISION_LABEL_JOIN = " | ";
371
371
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
372
372
  var RELEASE_BRANCH = "release";
373
- var BUNDLE_SHA = true ? "58d6b744f8c640e9f43f03516d8bc50dc1292ae0" : void 0;
373
+ var BUNDLE_SHA = true ? "d873866d92ec9a1db0c48ecda123a27f5b0debac" : void 0;
374
374
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
375
375
  var DOCTOR_LABEL = Object.freeze({
376
376
  D1: "version",
package/package.json CHANGED
@@ -69,5 +69,5 @@
69
69
  "url": "git+https://github.com/mksglu/context-mode.git"
70
70
  },
71
71
  "type": "module",
72
- "version": "2.0.0-next.25"
72
+ "version": "2.0.0-next.27"
73
73
  }
package/pi/index.js CHANGED
@@ -11516,7 +11516,7 @@ var DECISION_OPTION_KEY = "option";
11516
11516
  var DECISION_LABEL_JOIN = " | ";
11517
11517
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11518
11518
  var RELEASE_BRANCH = "release";
11519
- var BUNDLE_SHA = true ? "58d6b744f8c640e9f43f03516d8bc50dc1292ae0" : void 0;
11519
+ var BUNDLE_SHA = true ? "d873866d92ec9a1db0c48ecda123a27f5b0debac" : void 0;
11520
11520
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11521
11521
  var DOCTOR_LABEL = Object.freeze({
11522
11522
  D1: "version",
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "context-mode",
15
- "version": "2.0.0-next.25"
15
+ "version": "2.0.0-next.27"
16
16
  }
package/server.mjs CHANGED
@@ -28351,7 +28351,7 @@ var DECISION_SOURCE = "decision";
28351
28351
  var DECISION_USER_LABEL = "decision (user)";
28352
28352
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
28353
28353
  var RELEASE_BRANCH = "release";
28354
- var BUNDLE_SHA = true ? "58d6b744f8c640e9f43f03516d8bc50dc1292ae0" : void 0;
28354
+ var BUNDLE_SHA = true ? "d873866d92ec9a1db0c48ecda123a27f5b0debac" : void 0;
28355
28355
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
28356
28356
  var DOCTOR_LABEL = Object.freeze({
28357
28357
  D1: "version",