@axplusb/kepler 2.2.0 → 2.3.0

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/KEPLER-README.md CHANGED
@@ -1,222 +1,237 @@
1
1
  # @axplusb/kepler
2
2
 
3
- AI coding agent that plans, builds, tests, and ships. 30.7% on SWE-bench Lite.
3
+ Kepler is an AI coding agent for terminal-first software work. It can inspect a
4
+ repo, plan changes, run tools, ask for human approval, resume prior sessions, and
5
+ keep local project context in `.kepler/`.
4
6
 
5
7
  ## Install
6
8
 
7
9
  ```bash
8
- npm install -g @axplusb/kepler
10
+ npm install -g @axplusb/kepler@latest
9
11
  ```
10
12
 
11
- ## Quick Start
13
+ Run without global install:
12
14
 
13
15
  ```bash
14
- kepler login # Sign in via browser (GitHub/Google)
15
- kepler # Start interactive REPL
16
- kepler "fix the auth bug" # Run a single instruction
16
+ npx @axplusb/kepler@latest
17
17
  ```
18
18
 
19
- ## Commands
19
+ Update an existing global install:
20
20
 
21
- ```
22
- kepler Start interactive REPL
23
- kepler "instruction" Run a single instruction and exit
24
- kepler login Sign in via browser
25
- kepler dashboard Open Kepler Pulse analytics dashboard
26
- kepler sessions List recent local sessions
27
- kepler stats Aggregate session stats (tokens, cost, tools)
28
- kepler history Recent prompt history
29
- kepler skills list List discovered project and global skills
30
- kepler skills view NAME View a skill procedure or bundled resource
31
- kepler skills install SRC Install skills from a directory or Git repository
32
- kepler skills update NAME Update a locked installed skill
33
- kepler skills remove NAME Remove an installed skill
34
- kepler version Show version
21
+ ```bash
22
+ npm update -g @axplusb/kepler
23
+ kepler version
35
24
  ```
36
25
 
37
- ## Agent Skills
26
+ Requires Node.js 18 or newer.
38
27
 
39
- Kepler supports portable `SKILL.md` bundles and Claude-compatible skill
40
- directories. Skill metadata is included in the cached agent context; full
41
- instructions and references are loaded only when the agent calls
42
- `skill_view`.
43
-
44
- Discovery precedence:
28
+ ## Quick Start
45
29
 
46
- 1. `<project>/.kepler/skills`
47
- 2. `<project>/.claude/skills`
48
- 3. `~/.kepler/skills`
49
- 4. `~/.claude/skills`
30
+ ```bash
31
+ kepler login
32
+ kepler
33
+ kepler "fix the failing auth test"
34
+ ```
50
35
 
51
- Install a local bundle or a repository containing one or more skills:
36
+ Common startup commands:
52
37
 
53
38
  ```bash
54
- kepler skills install ./my-skill
55
- kepler skills install github:owner/skills-repository
56
- kepler skills install https://github.com/owner/skills.git
57
- kepler skills install ./team-skills --project
39
+ kepler Start interactive REPL
40
+ kepler "instruction" Run a single instruction and exit
41
+ kepler login Sign in through the browser
42
+ kepler dashboard Open Kepler Pulse analytics dashboard
43
+ kepler sessions List recent local sessions
44
+ kepler stats Aggregate local session stats
45
+ kepler history Show recent prompt history
46
+ kepler version Show installed version
58
47
  ```
59
48
 
60
- Global installations are recorded in `~/.kepler/skills.lock.json`. Project
61
- installations use `<project>/.kepler/skills.lock.json`. Kepler copies skill
62
- files as data, rejects symlinks, and does not execute bundled scripts during
63
- installation.
49
+ ## What's New In 2.2.0
50
+
51
+ - Resume sessions with summary-only, summary plus last 10 turns, or summary plus
52
+ last 20 turns.
53
+ - Resume summaries are checkpointed in the selected session transcript, so future
54
+ resumes summarize only new uncovered history.
55
+ - Approval prompts now use one consistent layout across shell, sensitive reads,
56
+ destructive actions, and backend/framework HITL approvals.
57
+ - Reject/stop is a single action. Use re-plan with note when you want to steer
58
+ the agent.
59
+ - Approval logs redact secrets before writing to `.kepler/approvals.log`.
60
+ - Long shell commands wrap instead of being truncated.
61
+ - Long-running shell commands return an observed output tail instead of hanging
62
+ silently.
64
63
 
65
64
  ## REPL Commands
66
65
 
67
- ```
68
- /help Show available commands
69
- /stats Session metrics (tokens, cost, tools)
70
- /cost Detailed cost breakdown by model
66
+ ```text
67
+ /help Show commands and command groups
68
+ /status Session status and loaded project context
69
+ /plan Show project plan and task files
70
+ /tasks List or add project tasks
71
+ /stats Session metrics
71
72
  /history Conversation history
72
- /clear Clear conversation history
73
+ /history approvals Recent approval decisions
74
+ /resume Resume a previous local session
75
+ /clear Clear in-memory conversation history
73
76
  /explore <query> Spawn read-only codebase explorer
74
77
  /review <query> Spawn code review agent
75
78
  /architect <query> Spawn architecture planning agent
76
79
  /safety Show safety guardrail status
77
80
  /revoke Revoke auto-approvals
81
+ /settings Show effective settings and policy sources
78
82
  /exit Exit the REPL
79
83
  ```
80
84
 
81
- ## Keyboard
85
+ Keyboard:
82
86
 
83
- ```
84
- Esc Cancel current execution
87
+ ```text
88
+ Esc Stop current execution or close a prompt
85
89
  Space Pause / resume execution
86
90
  Ctrl+C Exit
87
91
  ```
88
92
 
89
- ## Configuration
93
+ ## Resume Behavior
90
94
 
91
- Settings are managed via the web dashboard at [codekepler.ai/dashboard/settings](https://codekepler.ai/dashboard/settings) and synced to the CLI automatically.
95
+ `/resume` reads local JSONL transcripts from `~/.kepler/projects/**`. The
96
+ selected session is the source of truth.
92
97
 
93
- - **API Key**: Add your OpenRouter/Anthropic/OpenAI key in Settings
94
- - **Model**: Choose your preferred model (40+ supported)
95
- - **Gateway**: Select provider (OpenRouter, Anthropic, OpenAI, Bedrock, Google AI, etc.)
96
- - **Config directory**: `~/.kepler/`
98
+ For large sessions, Kepler shows mode choices:
97
99
 
98
- ## Models
100
+ ```text
101
+ full transcript
102
+ summary only
103
+ summary + last 10 turns
104
+ summary + last 20 turns
105
+ ```
99
106
 
100
- Works with 13 providers and 40+ models:
107
+ The session picker still shows the raw full transcript estimate, for example
108
+ `593k ctx`. If a summary checkpoint exists, it also shows a status such as
109
+ `summarized 82%`. That means earlier reconstructed messages are already covered
110
+ by a stored `resume_summary` marker. Summary and tail modes reuse that marker and
111
+ only summarize uncovered messages when needed.
101
112
 
102
- | Provider | Models |
103
- |----------|--------|
104
- | DeepSeek | V4 Flash, V4 Pro, R1 |
105
- | Anthropic | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 |
106
- | Google | Gemini 2.5 Pro, Flash |
107
- | OpenAI | GPT-4.1, O3, Codex |
108
- | Meta | Llama 4 Maverick, Scout |
109
- | Mistral | Devstral, Codestral |
110
- | xAI | Grok 3 |
111
- | Qwen | Qwen3 Coder |
112
- | + | AWS Bedrock, Azure OpenAI, Databricks, Moonshot, Custom |
113
+ The agent receives:
113
114
 
114
- Platform default included free. Bring your own API key for unlimited.
115
+ 1. resume metadata
116
+ 2. the original user request
117
+ 3. the checkpointed or freshly generated summary
118
+ 4. the retained recent tail for summary-plus-tail modes
115
119
 
116
- ## SWE-bench
120
+ ## Approvals And HITL
117
121
 
118
- | Model | Score | Cost |
119
- |-------|-------|------|
120
- | DeepSeek V4 Flash + stagnation | 47.3% (142/300) | $0.046/instance |
121
- | DeepSeek V4 Flash | 39.7% (119/300) | $0.046/instance |
122
- | DeepSeek V4 Flash (baseline) | 30.7% (92/300) | $0.03/instance |
123
- | DeepSeek V4 Pro | 50% (14/28 sample) | $0.48/instance |
122
+ Kepler auto-approves low-risk reads and safe shell inspection commands. It asks
123
+ for confirmation for sensitive reads, mutating shell commands, destructive
124
+ actions, network actions, and framework-level HITL requests.
124
125
 
125
- ### Running SWE-bench
126
+ Prompt actions:
126
127
 
127
- Benchmarks run on an Azure VM (`swebench-eval-vm`, D8s_v3) with a local backend + CLI.
128
+ ```text
129
+ Enter / y approve once
130
+ t always allow this tool type, when available
131
+ s trust this pattern for the session, when policy allows it
132
+ a trust this pattern for the project, when policy allows it
133
+ r re-plan with a note for the agent
134
+ n / Esc stop without running
135
+ ? show why approval is required
136
+ ```
128
137
 
129
- **Setup (one-time):**
138
+ Sensitive reads include files such as `.env`, `*.pem`, and `secrets/**`.
130
139
 
131
- ```bash
132
- # Deploy backend + CLI + harness to VM
133
- ./benchmark/vm-setup.sh
134
- ```
140
+ Approval decisions are logged locally in `.kepler/approvals.log`. Secret-like
141
+ values in commands, nested args, query strings, authorization headers, and
142
+ rejection notes are redacted before the log is written.
135
143
 
136
- **Run benchmark:**
144
+ ## Project Context
137
145
 
138
- ```bash
139
- # SSH into VM
140
- ssh azureuser@20.9.77.9
141
-
142
- # Start backend
143
- source ~/.tarang-benchmark.env
144
- cd ~/tarang-backend
145
- source ~/backend-env/bin/activate
146
- uvicorn app.main:app --port 8000 &
147
-
148
- # Run all 300 instances (3 parallel workers, skip already-done)
149
- source ~/swebench-env/bin/activate
150
- cd ~/tarang-npm
151
- python3 benchmark/swe-bench/harness.py \
152
- --dataset lite \
153
- --model deepseek/deepseek-v4-flash \
154
- --parallel 3 \
155
- --skip-done \
156
- --timeout 600
146
+ Kepler uses a project-local `.kepler/` folder for hand-editable context:
147
+
148
+ ```text
149
+ .kepler/
150
+ KEPLER.md Project operating brief
151
+ settings.json Project settings and policy
152
+ hooks.json Tool/user hook configuration
153
+ hitl.md Approval guidance
154
+ tasks/
155
+ backlog.md
156
+ active.md
157
+ blocked.md
158
+ done.md
157
159
  ```
158
160
 
159
- **Flags:**
161
+ Use `/plan` and `/tasks` in the REPL to inspect and update task files.
162
+
163
+ ## Skills
160
164
 
161
- | Flag | Description |
162
- |------|-------------|
163
- | `--dataset lite\|verified\|full` | SWE-bench split (default: lite, 300 instances) |
164
- | `--model <id>` | OpenRouter model ID |
165
- | `--parallel <n>` | Number of parallel workers (default: 1) |
166
- | `--skip-done` | Skip instances already in the output file |
167
- | `--timeout <s>` | Per-instance timeout in seconds (default: 600) |
168
- | `--limit <n>` | Only run first N instances |
169
- | `--instance <id>` | Run a single instance by ID |
170
- | `--gen-only` | Generate patches only (skip test evaluation) |
171
- | `--output <path>` | Custom output file path |
165
+ Kepler supports portable `SKILL.md` bundles and Claude-compatible skill
166
+ directories. Skill metadata is included in cached context; full instructions and
167
+ references are loaded only when needed.
168
+
169
+ Discovery precedence:
172
170
 
173
- **Results** are saved incrementally to `benchmark/results/<model>_<dataset>.json` — no data loss on kill.
171
+ 1. `<project>/.kepler/skills`
172
+ 2. `<project>/.claude/skills`
173
+ 3. `~/.kepler/skills`
174
+ 4. `~/.claude/skills`
174
175
 
175
- **Convenience scripts on VM:**
176
+ Install skills:
176
177
 
177
178
  ```bash
178
- # Watchdog (auto-restarts on crash)
179
- tmux new-session -d -s bench "bash /tmp/start-parallel.sh"
179
+ kepler skills install ./my-skill
180
+ kepler skills install github:owner/skills-repository
181
+ kepler skills install https://github.com/owner/skills.git
182
+ kepler skills install ./team-skills --project
183
+ ```
184
+
185
+ ## Configuration
180
186
 
181
- # Check progress
182
- tmux capture-pane -t bench -p | tail -20
187
+ Settings are managed in the web dashboard and synced to the CLI:
183
188
 
184
- # Or use the pre-built start script
185
- ./start-benchmark.sh deepseek/deepseek-v4-flash
189
+ https://codekepler.ai/dashboard/settings
190
+
191
+ Common local paths:
192
+
193
+ ```text
194
+ ~/.kepler/ Global CLI state
195
+ ~/.kepler/projects/** Local JSONL transcripts
196
+ ~/.kepler/history.jsonl Prompt history
197
+ <project>/.kepler/ Project context and policy
198
+ <project>/.kepler/approvals.log Project approval audit log
186
199
  ```
187
200
 
188
- ## Terminal-Bench
201
+ Provider API keys can be configured in the dashboard or through environment
202
+ variables such as `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, and
203
+ `OPENROUTER_API_KEY`.
189
204
 
190
- Use the benchmark-only adapter under `benchmark/terminal-bench/` when you want to
191
- evaluate Kepler in Terminal-Bench without touching the production CLI.
205
+ ## Troubleshooting
192
206
 
193
- It runs with:
207
+ Check installed package:
194
208
 
195
- - a separate backend venv
196
- - a separate backend port (`8001` by default)
197
- - a custom `--agent-import-path kepler_agent:KeplerAgent`
198
- - per-trial workspace isolation so memory does not leak across tasks
209
+ ```bash
210
+ npm list -g @axplusb/kepler --depth=0
211
+ kepler version
212
+ ```
199
213
 
200
- Reusable entrypoints:
214
+ Use a clean one-off run:
201
215
 
202
216
  ```bash
203
- benchmark/terminal-bench/setup-kepler-backend.sh
204
- benchmark/terminal-bench/run-kepler-backend.sh
205
- benchmark/terminal-bench/run-kepler-benchmark.sh --task-id hello-world
217
+ npx @axplusb/kepler@latest --version
206
218
  ```
207
219
 
208
- Environment variables that can be overridden in another machine or CI setup:
220
+ If npm cache permissions are broken, use a temporary cache:
209
221
 
210
- `BACKEND_DIR`, `FRAMEWORK_DIR`, `VENV_DIR`, `TB_VENV`, `TARANG_NPM_DIR`,
211
- `ENV_FILE`, `BACKEND_URL`, `PORT`, `MODEL`, `DATASET`, `CONCURRENCY`.
222
+ ```bash
223
+ env NPM_CONFIG_CACHE=/private/tmp/kepler-npm-cache npm pack --dry-run
224
+ ```
212
225
 
213
- Create a local `.tarang-tbench.env` with the benchmark credentials and backend
214
- auth token, then point `ENV_FILE` at it if needed.
226
+ If a resume session shows a large context number, check whether the row also
227
+ shows `summarized`. The large number is the full transcript estimate; summary and
228
+ tail modes usually send much less.
215
229
 
216
230
  ## Links
217
231
 
218
- - Website: [codekepler.ai](https://codekepler.ai)
219
- - Company: [axplusb.tech](https://axplusb.tech)
232
+ - Website: https://codekepler.ai
233
+ - Company: https://axplusb.tech
234
+ - Repository: https://github.com/raviakasapu/codekepler-npm
220
235
 
221
236
  ## License
222
237
 
package/README.md CHANGED
@@ -1,96 +1,68 @@
1
1
  # @axplusb/kepler
2
2
 
3
- AI coding agent that plans, builds, tests, and ships. 30.7% on SWE-bench Lite.
3
+ Kepler is an AI coding agent for terminal-first software work. It can inspect a
4
+ repo, plan changes, run tools, ask for human approval, resume prior sessions, and
5
+ keep local project context in `.kepler/`.
6
+
7
+ The npm package uses [KEPLER-README.md](./KEPLER-README.md) as the published
8
+ README. Keep that file as the canonical npm-facing documentation.
4
9
 
5
10
  ## Install
6
11
 
7
12
  ```bash
8
- npm install -g @axplusb/kepler
13
+ npm install -g @axplusb/kepler@latest
9
14
  ```
10
15
 
11
- ## Quick Start
16
+ Run without global install:
12
17
 
13
18
  ```bash
14
- kepler login # Sign in via browser (GitHub/Google)
15
- kepler # Start interactive REPL
16
- kepler "fix the auth bug" # Run a single instruction
19
+ npx @axplusb/kepler@latest
17
20
  ```
18
21
 
19
- ## Commands
22
+ ## Quick Start
20
23
 
24
+ ```bash
25
+ kepler login
26
+ kepler
27
+ kepler "fix the failing auth test"
21
28
  ```
29
+
30
+ ## Common Commands
31
+
32
+ ```text
22
33
  kepler Start interactive REPL
23
34
  kepler "instruction" Run a single instruction and exit
24
- kepler login Sign in via browser
35
+ kepler login Sign in through the browser
25
36
  kepler dashboard Open Kepler Pulse analytics dashboard
26
37
  kepler sessions List recent local sessions
27
- kepler stats Aggregate session stats (tokens, cost, tools)
28
- kepler history Recent prompt history
29
- kepler version Show version
38
+ kepler stats Aggregate local session stats
39
+ kepler history Show recent prompt history
40
+ kepler version Show installed version
30
41
  ```
31
42
 
32
- ## REPL Commands
43
+ ## 2.2.0 Highlights
33
44
 
34
- ```
35
- /help Show available commands
36
- /stats Session metrics (tokens, cost, tools)
37
- /cost Detailed cost breakdown by model
38
- /history Conversation history
39
- /clear Clear conversation history
40
- /explore <query> Spawn read-only codebase explorer
41
- /review <query> Spawn code review agent
42
- /architect <query> Spawn architecture planning agent
43
- /safety Show safety guardrail status
44
- /revoke Revoke auto-approvals
45
- /exit Exit the REPL
46
- ```
45
+ - Checkpointed `/resume` summaries with summary-only and summary-plus-tail modes.
46
+ - One approval prompt model for shell, sensitive reads, destructive actions, and
47
+ backend/framework HITL.
48
+ - Redacted local approval logs.
49
+ - Wrapped full shell command display.
50
+ - Long-running shell command tail capture.
47
51
 
48
- ## Keyboard
52
+ ## Development
49
53
 
54
+ ```bash
55
+ npm test
56
+ env NPM_CONFIG_CACHE=/private/tmp/kepler-npm-cache npm pack --dry-run
50
57
  ```
51
- Esc Cancel current execution
52
- Space Pause / resume execution
53
- Ctrl+C Exit
54
- ```
55
-
56
- ## Configuration
57
-
58
- Settings are managed via the web dashboard at [codekepler.ai/dashboard/settings](https://codekepler.ai/dashboard/settings) and synced to the CLI automatically.
59
-
60
- - **API Key**: Add your OpenRouter/Anthropic/OpenAI key in Settings
61
- - **Model**: Choose your preferred model (40+ supported)
62
- - **Gateway**: Select provider (OpenRouter, Anthropic, OpenAI, Bedrock, Google AI, etc.)
63
- - **Config directory**: `~/.kepler/`
64
-
65
- ## Models
66
-
67
- Works with 13 providers and 40+ models:
68
-
69
- | Provider | Models |
70
- |----------|--------|
71
- | DeepSeek | V4 Flash, V4 Pro, R1 |
72
- | Anthropic | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 |
73
- | Google | Gemini 2.5 Pro, Flash |
74
- | OpenAI | GPT-4.1, O3, Codex |
75
- | Meta | Llama 4 Maverick, Scout |
76
- | Mistral | Devstral, Codestral |
77
- | xAI | Grok 3 |
78
- | Qwen | Qwen3 Coder |
79
- | + | AWS Bedrock, Azure OpenAI, Databricks, Moonshot, Custom |
80
-
81
- Platform default included free. Bring your own API key for unlimited.
82
-
83
- ## SWE-bench
84
58
 
85
- | Model | Score | Cost |
86
- |-------|-------|------|
87
- | DeepSeek V4 Flash | 30.7% (92/300) | $0.03/fix |
88
- | DeepSeek V4 Pro | 50% (14/28 sample) | $0.48/fix |
59
+ See [RELEASE.md](./RELEASE.md) for the merge, PR, and npm publish checklist.
89
60
 
90
61
  ## Links
91
62
 
92
- - Website: [codekepler.ai](https://codekepler.ai)
93
- - Company: [axplusb.tech](https://axplusb.tech)
63
+ - Website: https://codekepler.ai
64
+ - Company: https://axplusb.tech
65
+ - Repository: https://github.com/raviakasapu/codekepler-npm
94
66
 
95
67
  ## License
96
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axplusb/kepler",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Kepler — AI coding agent with operating brief, preflight planning, and sub-agents. SWE-bench Lite evaluated.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,7 +14,7 @@
14
14
  "readme": "KEPLER-README.md",
15
15
  "scripts": {
16
16
  "start": "node src/terminal/main.mjs",
17
- "test": "KEPLER_HOME=/tmp/kepler-test-home node test/test-sse-client.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-tool-executor.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-project-artifacts.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-skills.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-callback.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-rate-limit-display.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-preflight.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-formatter.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-terminal-rendering.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-slash-commands.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-approval.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-approval-log.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-kepler-contract.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-session-manager.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-safety.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-jsonl-writer.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-analytics.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-stagnation.mjs"
17
+ "test": "KEPLER_HOME=/tmp/kepler-test-home node test/test-sse-client.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-tool-executor.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-project-artifacts.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-work-scope.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-skills.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-callback.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-rate-limit-display.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-preflight.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-formatter.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-terminal-rendering.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-slash-commands.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-approval.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-approval-log.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-kepler-contract.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-session-manager.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-safety.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-jsonl-writer.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-analytics.mjs && KEPLER_HOME=/tmp/kepler-test-home node test/test-stagnation.mjs"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=18.0.0"
@@ -103,6 +103,19 @@ export function parseArgs(args) {
103
103
  result.freeswim = true; // headless implies skip permissions
104
104
  break;
105
105
 
106
+ case '--cache-report':
107
+ // PRD-071 §1.5 — write a machine-readable cache summary to
108
+ // <path> at end of run. Consumed by benchmark/cache-check.sh.
109
+ result.cacheReport = args[++i];
110
+ break;
111
+
112
+ case '--local':
113
+ // Force LocalAgent path (bypass backend). Meant for benchmarks
114
+ // that need to exercise the CLI's own LLM code — cache_control
115
+ // wiring, prompt-cache stats, etc.
116
+ result.local = true;
117
+ break;
118
+
106
119
  case '--freeswim-open-waters':
107
120
  case '--freeswim':
108
121
  case '--yes':
@@ -161,6 +174,7 @@ Options:
161
174
  --resume, -r [sessionId] Resume last session (or specific session)
162
175
  --continue Alias for --resume
163
176
  --headless Non-interactive mode: auto-approve, JSONL output
177
+ --cache-report <file> Write prompt-cache summary JSON to <file> (headless only)
164
178
  --freeswim-open-waters Skip all approval prompts (no boundaries)
165
179
  --freeswim Alias for --freeswim-open-waters
166
180
  --yes Alias for --freeswim-open-waters
@@ -6,6 +6,7 @@ import { streamResponse, accumulateStream } from './streaming.mjs';
6
6
  import { ContextManager } from './context-manager.mjs';
7
7
  import { buildSystemPrompt } from './system-prompt.mjs';
8
8
  import { createStagnationTracker, stagnationMessage } from './stagnation.mjs';
9
+ import { PromptCache } from './cache.mjs';
9
10
  import fs from 'fs';
10
11
  import path from 'path';
11
12
  export function createAgentLoop({ model, tools, permissions, settings, hooks }) {
@@ -23,10 +24,11 @@ export function createAgentLoop({ model, tools, permissions, settings, hooks })
23
24
  messages: [],
24
25
  systemPrompt: promptResult.full,
25
26
  turnCount: 0,
26
- tokenUsage: { input: 0, output: 0 },
27
+ tokenUsage: { input: 0, output: 0, cache_read: 0, cache_creation: 0 },
27
28
  model,
28
29
  tools,
29
30
  _contextManager: contextManager,
31
+ _promptCache: new PromptCache(),
30
32
  };
31
33
  const stagnation = createStagnationTracker({
32
34
  enabled: settings.stagnationDetection === true,
@@ -99,10 +101,14 @@ export function createAgentLoop({ model, tools, permissions, settings, hooks })
99
101
  return;
100
102
  }
101
103
 
102
- // Track token usage
104
+ // Track token usage (PRD-071 §1.1: also record cache hits/writes so
105
+ // /extra-usage and /status stop reporting zeros)
103
106
  if (response.usage) {
104
107
  state.tokenUsage.input += response.usage.input_tokens || 0;
105
108
  state.tokenUsage.output += response.usage.output_tokens || 0;
109
+ state.tokenUsage.cache_read += response.usage.cache_read_input_tokens || 0;
110
+ state.tokenUsage.cache_creation += response.usage.cache_creation_input_tokens || 0;
111
+ state._promptCache.updateStats(response.usage);
106
112
  }
107
113
 
108
114
  // Build assistant message for history