mythos-router 1.1.0 → 1.1.3

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/README.md CHANGED
@@ -1,317 +1,398 @@
1
- <div align="center">
2
-
3
- ```
4
- ███╗ ███╗██╗ ██╗████████╗██╗ ██╗ ██████╗ ███████╗
5
- ████╗ ████║╚██╗ ██╔╝╚══██╔══╝██║ ██║██╔═══██╗██╔════╝
6
- ██╔████╔██║ ╚████╔╝ ██║ ███████║██║ ██║███████╗
7
- ██║╚██╔╝██║ ╚██╔╝ ██║ ██╔══██║██║ ██║╚════██║
8
- ██║ ╚═╝ ██║ ██║ ██║ ██║ ██║╚██████╔╝███████║
9
- ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
10
- ```
11
-
12
- ### Capybara Tier · Claude Opus 4.6 · Strict Write Discipline
13
-
14
- **The leaked Anthropic reasoning protocol. Running locally.**
15
-
16
- [![npm](https://img.shields.io/npm/v/mythos-router?style=flat-square&color=cc785c)](https://www.npmjs.com/package/mythos-router)
17
- [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
18
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://typescriptlang.org)
19
- [![Claude](https://img.shields.io/badge/Claude-Opus_4.6-cc785c?style=flat-square)](https://anthropic.com)
20
- [![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)](./LICENSE)
21
- [![GitHub stars](https://img.shields.io/github/stars/thewaltero/mythos-router?style=social)](https://github.com/thewaltero/mythos-router)
22
-
23
- <p align="center">
24
- <img src="assets/demo.png" alt="mythos-router terminal demo" width="700" />
25
- </p>
26
-
27
- ```bash
28
- # Try it now
29
- npx mythos-router chat
30
- ```
31
-
32
- </div>
33
-
34
- ---
35
-
36
- ## What is this?
37
-
38
- **mythos-router** is a local CLI power tool that implements the *leaked Anthropic "Capybara" reasoning protocol* — the specialized tier designed for PhD-level reasoning and cybersecurity analysis.
39
-
40
- Unlike standard Claude wrappers, mythos-router enforces **Strict Write Discipline (SWD)**: every file operation the AI claims to perform is *verified against the actual filesystem*. If the model hallucinates a write, it gets a Correction Turn. If it fails twice, it yields to the human.
41
-
42
- Zero slop. Zero hallucinated state. Full adaptive thinking.
43
-
44
- ---
45
-
46
- ## Features
47
-
48
- | Feature | Description |
49
- |---------|-------------|
50
- | 🧠 **Adaptive Thinking** | Opus 4.6 with configurable effort levels (high/medium/low) |
51
- | 🔒 **Strict Write Discipline** | Pre/post filesystem snapshots verify every model claim |
52
- | 💤 **Self-Healing Memory** | `MEMORY.md` logs every action; auto-compresses via "Dream" |
53
- | ⟲ **Correction Turns** | Model gets 2 retries to match filesystem reality, then yields |
54
- | 📋 **Drift Detection** | `verify` command syncs codebase state with memory |
55
- | 💰 **Token Limiter** | Budget cap with graceful save — progress saved to MEMORY.md, never lose work |
56
- | 🔍 **Dry-Run Mode** | Preview every file operation before it executes — full transparency |
57
- | 📊 **Verbose Tracing** | See exactly what the AI is parsing, thinking, and verifying |
58
- | 🚀 **Zero Build** | Runs directly via `tsx` — no compile step in dev |
59
-
60
- ---
61
-
62
- ## Installation
63
-
64
- ### Quick Start (npm)
65
-
66
- ```bash
67
- # Install globally
68
- npm install -g mythos-router
69
-
70
- # Set your API key
71
- export ANTHROPIC_API_KEY="sk-ant-..."
72
- # Windows: $env:ANTHROPIC_API_KEY = "sk-ant-..."
73
-
74
- # Go
75
- mythos chat
76
- ```
77
-
78
- ### Or try without installing
79
-
80
- ```bash
81
- npx mythos-router chat
82
- ```
83
-
84
- ### From Source
85
-
86
- ```bash
87
- git clone https://github.com/thewaltero/mythos-router.git
88
- cd mythos-router
89
- npm install
90
- npm run chat
91
- ```
92
-
93
- ---
94
-
95
- ## Usage
96
-
97
- ### `mythos chat` — Interactive Capybara Session
98
-
99
- ```bash
100
- mythos chat # Full power (high effort)
101
- mythos chat --effort low # Budget mode
102
- mythos chat --effort medium # Balanced
103
- mythos chat --dry-run # Preview all file changes before executing
104
- mythos chat --verbose # See full SWD traces and thinking
105
- mythos chat --dry-run --verbose # Maximum transparency
106
- ```
107
-
108
- #### 💰 Financial Safety — Never Burn Money Again
109
-
110
- ```bash
111
- mythos chat # Default: 500K tokens, 25 turns
112
- mythos chat --max-tokens 100000 # Cap at 100K tokens
113
- mythos chat --max-turns 10 # Cap at 10 turns
114
- mythos chat --max-tokens 50000 --max-turns 5 # Tight budget
115
- mythos chat --no-budget # Expert mode (no limits)
116
- ```
117
-
118
- The budget limiter tracks every token, turn, and estimated cost in real-time:
119
-
120
- ```
121
- budget: [████████░░░░░░░░░░░░] 78,342/500,000 tokens · [██████░░░░] 12/25 turns · ~$1.2340 · 4m 32s
122
- ```
123
-
124
- At 80%, you get a yellow warning. At 100%, the session performs a **graceful save** — current progress is written to `MEMORY.md` so you can resume context in your next session. No work lost. Use `--no-budget` to disable (at your own risk).
125
-
126
- #### 🔍 Dry-Run Mode The Trust Builder
127
-
128
- ```bash
129
- mythos chat --dry-run
130
- ```
131
-
132
- In dry-run mode, every file operation is previewed before execution:
133
-
134
- ```
135
- DRY-RUN ── File Action Preview ──
136
- 2 file action(s) detected. Review each:
137
-
138
- 1/2 MODIFY src/index.ts
139
- Description: Change 'axios' to 'fetch'
140
- Current state: 1,832 bytes, hash: 7a3f2c1e...
141
- DRY-RUN Accept MODIFY on src/index.ts? [Y/n] y
142
- ✔ Accepted: MODIFY src/index.ts
143
-
144
- 2/2 CREATE src/utils.ts
145
- Description: Add helper utilities
146
- Current state: does not exist
147
- DRY-RUN Accept CREATE on src/utils.ts? [Y/n] n
148
- ⚠ Rejected: CREATE src/utils.ts
149
- ```
150
-
151
- In-session commands:
152
- - `/exit` — End session (shows final budget summary)
153
- - `/memory` — Show memory status
154
- - `/budget` Show current budget consumption
155
- - `/clear` Clear conversation (memory persists)
156
-
157
- ### `mythos verify` — Zero-Drift Codebase Scan
158
-
159
- ```bash
160
- mythos verify # Scan and log results to MEMORY.md
161
- mythos verify --dry-run # Scan without writing to MEMORY.md
162
- ```
163
-
164
- Scans every file in your project and cross-references against `MEMORY.md`:
165
- - ✅ **Verified** — File state matches memory
166
- - ⚠️ **Drift** — File changed but memory doesn't reflect it
167
- - **Missing** Memory references a file that doesn't exist
168
-
169
- ### `mythos dream` Memory Compression
170
-
171
- ```bash
172
- mythos dream # Auto-compress when needed
173
- mythos dream --force # Force compression
174
- mythos dream --dry-run # Preview without writing
175
- ```
176
-
177
- When `MEMORY.md` exceeds 100 entries, older logs are compressed into a summary block using Claude (low effort, minimal token burn). Recent entries are preserved intact.
178
-
179
- ---
180
-
181
- ## Architecture
182
-
183
- ```
184
- mythos-router/
185
- ├── src/
186
- │ ├── cli.ts # Commander.js entry point
187
- │ ├── config.ts # Capybara system prompt + constants + budget defaults
188
- │ ├── client.ts # Anthropic SDK (adaptive thinking)
189
- │ ├── budget.ts # Session budget limiter (token cap, turn cap)
190
- │ ├── swd.ts # Strict Write Discipline + dry-run preview
191
- │ ├── memory.ts # MEMORY.md self-healing manager (dry-run aware)
192
- │ ├── utils.ts # Terminal formatting, badges, prompts (zero-dep)
193
- │ └── commands/
194
- │ ├── chat.ts # Interactive REPL (budget + dry-run + verbose)
195
- │ ├── verify.ts # Codebase ↔ Memory scanner (dry-run aware)
196
- │ └── dream.ts # Memory compression (dry-run aware)
197
- ├── .mythosignore # SWD scan exclusions
198
- ├── MEMORY.md # Auto-generated agentic memory
199
- └── AGENTS.md # Project conventions
200
- ```
201
-
202
- ### The SWD Protocol
203
-
204
- ```
205
- User Input
206
-
207
-
208
- [Pre-Snapshot] ── filesystem state captured
209
-
210
-
211
- [Claude Opus 4.6] ── adaptive thinking (high effort)
212
-
213
-
214
- [Parse FILE_ACTION blocks] ── extract claimed operations
215
-
216
-
217
- [Post-Snapshot] ── filesystem state re-captured
218
-
219
-
220
- [Verify] ── before vs. after vs. model claims
221
-
222
- ├── ✅ All verified → Log to MEMORY.md
223
-
224
- └── Mismatch Correction Turn (max 2 retries)
225
-
226
- └── Still failing Yield to human
227
- ```
228
-
229
- ---
230
-
231
- ## MEMORY.md — Should You Commit It?
232
-
233
- **Yes.** `MEMORY.md` is designed to be committed to your repository. It becomes a "collaborative brain" where:
234
- - Multiple developers can see what the AI did in previous sessions
235
- - Different AI agents can reference past context
236
- - You get a full audit trail of every AI-assisted file operation
237
-
238
- If you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.
239
-
240
- ---
241
-
242
- ## The Capybara System Prompt
243
-
244
- The system prompt implements the leaked Anthropic protocol:
245
-
246
- > **Tier: Capybara** (Specialized in Cybersecurity & PhD Reasoning)
247
- >
248
- > Follow 'Strict Write Discipline' and never hallucinate filesystem state.
249
- > Every file operation must be wrapped in `[FILE_ACTION]` blocks for verification.
250
-
251
- The model is instructed to emit machine-readable delimiters around every file operation, making SWD verification 100% reliable.
252
-
253
- ---
254
-
255
- ## Configuration
256
-
257
- | Env Variable | Required | Description |
258
- |-------------|----------|-------------|
259
- | `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key |
260
-
261
- | File | Purpose |
262
- |------|---------|
263
- | `.mythosignore` | Patterns to exclude from SWD scanning |
264
- | `MEMORY.md` | Auto-generated agentic memory log |
265
-
266
- ---
267
-
268
- ## Token Usage & Budget
269
-
270
- ### Opus 4.6 Pricing (as of 2026-04)
271
-
272
- | Rate | USD |
273
- |------|-----|
274
- | Input tokens | $15.00 / 1M tokens |
275
- | Output tokens | $75.00 / 1M tokens |
276
-
277
- > Pricing constants live in `src/config.ts`. When Anthropic updates rates, change two lines — no budget math to refactor.
278
-
279
- | Mode | Typical Cost Per Turn |
280
- |------|----------------------|
281
- | `--effort high` | Full Opus 4.6 pricing (deep reasoning) |
282
- | `--effort medium` | Balanced good for most tasks |
283
- | `--effort low` | Minimal thinking — quick answers |
284
- | `dream` | Low effort summarization (~500 tokens) |
285
-
286
- | Budget Setting | Default |
287
- |---------------|--------|
288
- | `--max-tokens` | 500,000 per session |
289
- | `--max-turns` | 25 per session |
290
- | Warning threshold | 80% consumption |
291
- | `--no-budget` | Disables all limits |
292
-
293
- ### Graceful Save
294
-
295
- When the budget is reached, mythos doesn't just kill your session — it performs a **graceful save**:
296
-
297
- ```
298
- ⏸ BUDGET REACHED — Graceful Save
299
- 498,231 tokens consumed across 25 turns (~$7.4200).
300
- Progress saved to MEMORY.md. Resume with mythos chat to continue.
301
- Increase limits: mythos chat --max-tokens 1000000 --max-turns 50
302
- Disable limits: mythos chat --no-budget
303
- ```
304
-
305
- Token counts, estimated cost, and budget status are displayed after every chat response.
306
-
307
- ---
308
-
309
- ## License
310
-
311
- MIT
312
-
313
- ---
314
-
315
- <div align="center">
316
- <sub>Built with the leaked Capybara protocol. No affiliation with Anthropic. Use responsibly.</sub>
317
- </div>
1
+ <div align="center">
2
+
3
+ <pre align="center">
4
+ ███╗ ███╗██╗ ██╗████████╗██╗ ██╗ ██████╗ ███████╗
5
+ ████╗ ████║╚██╗ ██╔╝╚══██╔══╝██║ ██║██╔═══██╗██╔════╝
6
+ ██╔████╔██║ ╚████╔╝ ██║ ███████║██║ ██║███████╗
7
+ ██║╚██╔╝██║ ╚██╔╝ ██║ ██╔══██║██║ ██║╚════██║
8
+ ██║ ╚═╝ ██║ ██║ ██║ ██║ ██║╚██████╔╝███████║
9
+ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
10
+ </pre>
11
+
12
+ ### Capybara Tier · Claude Opus 4.7 · Strict Write Discipline
13
+
14
+ **The leaked Anthropic reasoning protocol. Running locally.**
15
+
16
+ [![npm](https://img.shields.io/npm/v/mythos-router?style=flat-square&color=cc785c)](https://www.npmjs.com/package/mythos-router)
17
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
18
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://typescriptlang.org)
19
+ [![Claude](https://img.shields.io/badge/Claude-Opus_4.7-cc785c?style=flat-square)](https://anthropic.com)
20
+ [![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)](./LICENSE)
21
+ [![GitHub stars](https://img.shields.io/github/stars/thewaltero/mythos-router?style=social)](https://github.com/thewaltero/mythos-router)
22
+
23
+ <p align="center">
24
+ <img src="assets/demo.png" alt="mythos-router terminal demo" width="700" />
25
+ </p>
26
+
27
+ ```bash
28
+ # Try it now
29
+ npx mythos-router chat
30
+ ```
31
+
32
+ </div>
33
+
34
+ ---
35
+
36
+ ## What is this?
37
+
38
+ **mythos-router** is a local CLI power tool that implements the *leaked Anthropic "Capybara" reasoning protocol* — the specialized tier designed for PhD-level reasoning and cybersecurity analysis.
39
+
40
+ Unlike standard Claude wrappers, mythos-router enforces **Strict Write Discipline (SWD)**: every file operation the AI claims to perform is *verified against the actual filesystem*. If the model hallucinates a write, it gets a Correction Turn. If it fails twice, it yields to the human.
41
+
42
+ Zero slop. Zero hallucinated state. Full adaptive thinking.
43
+
44
+ ---
45
+
46
+ ## Features
47
+
48
+ | Feature | Description |
49
+ |---------|-------------|
50
+ | 🧠 **Adaptive Thinking** | Opus 4.7 with configurable effort levels (high/medium/low) |
51
+ | 🔒 **Strict Write Discipline** | Pre/post filesystem snapshots verify every model claim |
52
+ | 💤 **Self-Healing Memory** | `MEMORY.md` logs every action; auto-compresses via "Dream" |
53
+ | ⟲ **Correction Turns** | Model gets 2 retries to match filesystem reality, then yields |
54
+ | 📋 **Drift Detection** | `verify` command syncs codebase state with memory |
55
+ | 💰 **Token Limiter** | Budget cap with graceful save — progress saved to MEMORY.md, never lose work |
56
+ | 🔍 **Dry-Run Mode** | Preview every file operation before it executes — full transparency |
57
+ | 📊 **Verbose Tracing** | See exactly what the AI is parsing, thinking, and verifying |
58
+ | 🚀 **Zero Build** | Runs directly via `tsx` — no compile step in dev |
59
+
60
+ ---
61
+
62
+ ## Core Architectural Pillars
63
+
64
+ ### 1. Multi-Model Orchestration
65
+ Most AI tools slam one expensive model with every request, draining API budgets instantly. Mythos Router acts as a true orchestrator, dynamically routing sub-tasks to specialized models based on effort level:
66
+ - 🧠 **The Thinker (`Opus 4.7`)**: Handles high-effort architecture, reasoning, and system planning.
67
+ - ✍️ **The Writer (`Sonnet 3.5`)**: Receives localized plans to execute rapid, flawless code generation.
68
+ - 🔍 **The Validator (`Haiku 3`)**: Executes rapid background verify and drift detection tasks.
69
+ *Result: PhD-level reasoning at 1/5th the API cost.*
70
+
71
+ ### 2. Automated "Dream" Summarization & The Original Sin
72
+ Even with massive 200k+ context windows, models suffer from degradation ("lost in the middle") when packed with massive raw chat history.
73
+ The router tracks this using `MEMORY.md`. As memory approaches capacity, the router delegates a compression phase (the "Dream") to a low-cost model (`Haiku 3`). It condenses transaction logs into tight summaries while forever preserving the **"Original Sin"** of the project—the core architectural decisions and constraints. This prevents AI drift and saves massive API costs on every subsequent turn.
74
+
75
+ ---
76
+
77
+ ## Installation
78
+
79
+ ### Quick Start (npm)
80
+
81
+ ```bash
82
+ # Install globally
83
+ npm install -g mythos-router
84
+
85
+ # Set your API key
86
+ export ANTHROPIC_API_KEY="sk-ant-..."
87
+ # Windows: $env:ANTHROPIC_API_KEY = "sk-ant-..."
88
+
89
+ # Go
90
+ mythos chat
91
+ ```
92
+
93
+ ### Or try without installing
94
+
95
+ ```bash
96
+ npx mythos-router chat
97
+ ```
98
+
99
+ ### From Source
100
+
101
+ ```bash
102
+ git clone https://github.com/thewaltero/mythos-router.git
103
+ cd mythos-router
104
+ npm install
105
+ npm run chat
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Usage
111
+
112
+ ### `mythos chat` Interactive Capybara Session
113
+
114
+ ```bash
115
+ mythos chat # Full power (high effort)
116
+ mythos chat --effort low # Budget mode
117
+ mythos chat --effort medium # Balanced
118
+ mythos chat --dry-run # Preview all file changes before executing
119
+ mythos chat --verbose # See full SWD traces and thinking
120
+ mythos chat --dry-run --verbose # Maximum transparency
121
+ ```
122
+
123
+ #### 💰 Financial Safety — Never Burn Money Again
124
+
125
+ ```bash
126
+ mythos chat # Default: 500K tokens, 25 turns
127
+ mythos chat --max-tokens 100000 # Cap at 100K tokens
128
+ mythos chat --max-turns 10 # Cap at 10 turns
129
+ mythos chat --max-tokens 50000 --max-turns 5 # Tight budget
130
+ mythos chat --no-budget # Expert mode (no limits)
131
+ ```
132
+
133
+ The budget limiter tracks every token, turn, and estimated cost in real-time:
134
+
135
+ ```
136
+ budget: [████████░░░░░░░░░░░░] 78,342/500,000 tokens · [██████░░░░] 12/25 turns · ~$1.2340 · 4m 32s
137
+ ```
138
+
139
+ At 80%, you get a yellow warning. At 100%, the session performs a **graceful save** — current progress is written to `MEMORY.md` so you can resume context in your next session. No work lost. Use `--no-budget` to disable (at your own risk).
140
+
141
+ #### 🔍 Dry-Run Mode The Trust Builder
142
+
143
+ ```bash
144
+ mythos chat --dry-run
145
+ ```
146
+
147
+ In dry-run mode, every file operation is previewed before execution:
148
+
149
+ ```
150
+ DRY-RUN ── File Action Preview ──
151
+ 2 file action(s) detected. Review each:
152
+
153
+ 1/2 MODIFY src/index.ts
154
+ Description: Change 'axios' to 'fetch'
155
+ Current state: 1,832 bytes, hash: 7a3f2c1e...
156
+ DRY-RUN Accept MODIFY on src/index.ts? [Y/n] y
157
+ Accepted: MODIFY src/index.ts
158
+
159
+ 2/2 CREATE src/utils.ts
160
+ Description: Add helper utilities
161
+ Current state: does not exist
162
+ DRY-RUN Accept CREATE on src/utils.ts? [Y/n] n
163
+ ⚠ Rejected: CREATE src/utils.ts
164
+ ```
165
+
166
+ In-session commands:
167
+ - `/exit`End session (shows final budget summary)
168
+ - `/memory` — Show memory status
169
+ - `/budget` — Show current budget consumption
170
+ - `/clear` — Clear conversation (memory persists)
171
+
172
+ ### `mythos verify` — Zero-Drift Codebase Scan
173
+
174
+ ```bash
175
+ mythos verify # Scan and log results to MEMORY.md
176
+ mythos verify --dry-run # Scan without writing to MEMORY.md
177
+ ```
178
+
179
+ Scans every file in your project and cross-references against `MEMORY.md`:
180
+ - ✅ **Verified** — File state matches memory
181
+ - ⚠️ **Drift** — File changed but memory doesn't reflect it
182
+ - ❌ **Missing** — Memory references a file that doesn't exist
183
+
184
+ ### `mythos dream` — Memory Compression
185
+
186
+ ```bash
187
+ mythos dream # Auto-compress when needed
188
+ mythos dream --force # Force compression
189
+ mythos dream --dry-run # Preview without writing
190
+ ```
191
+
192
+ When `MEMORY.md` exceeds 100 entries, older logs are compressed into a summary block using Claude (low effort, minimal token burn). Recent entries are preserved intact.
193
+
194
+ ### 🔌 SDK Usage (For Agentic Systems)
195
+
196
+ `mythos-router` is not just a CLI—it is a programmable execution layer natively exposing its Strict Write Discipline and Multi-Model Router to other AI developers.
197
+
198
+ ```typescript
199
+ import { runSWD, snapshotFiles } from 'mythos-router';
200
+
201
+ // 1. Snapshot the target directory before your agent executes
202
+ const beforeState = snapshotFiles(['./src/components']);
203
+
204
+ // 2. Let your agent generate code (must output [FILE_ACTION] blocks)
205
+ const agentOutput = await myAgent.generateCode();
206
+
207
+ // 3. Route through the Strict Write Discipline engine
208
+ const result = runSWD(agentOutput, beforeState);
209
+
210
+ if (result.verified) {
211
+ console.log('✅ Agent execution verified securely');
212
+ } else {
213
+ console.log('❌ Agent hallucinated a write. Stopping execution.');
214
+ }
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Architecture
220
+
221
+ ```
222
+ mythos-router/
223
+ ├── src/
224
+ │ ├── cli.ts # Commander.js entry point
225
+ ├── config.ts # Capybara system prompt + constants + budget defaults
226
+ │ ├── client.ts # Anthropic SDK (adaptive thinking)
227
+ │ ├── budget.ts # Session budget limiter (token cap, turn cap)
228
+ │ ├── swd.ts # Strict Write Discipline + dry-run preview
229
+ │ ├── memory.ts # MEMORY.md self-healing manager (dry-run aware)
230
+ │ ├── utils.ts # Terminal formatting, badges, prompts (zero-dep)
231
+ │ └── commands/
232
+ │ ├── chat.ts # Interactive REPL (budget + dry-run + verbose)
233
+ │ ├── verify.ts # Codebase Memory scanner (dry-run aware)
234
+ │ └── dream.ts # Memory compression (dry-run aware)
235
+ ├── .mythosignore # SWD scan exclusions
236
+ ├── MEMORY.md # Auto-generated agentic memory
237
+ └── AGENTS.md # Project conventions
238
+ ```
239
+
240
+ ### The SWD Protocol
241
+
242
+ ```
243
+ User Input
244
+
245
+
246
+ [Pre-Snapshot] ── filesystem state captured
247
+
248
+
249
+ [Claude Opus 4.7] ── adaptive thinking (high effort)
250
+
251
+
252
+ [Parse FILE_ACTION blocks] ── extract claimed operations
253
+
254
+
255
+ [Post-Snapshot] ── filesystem state re-captured
256
+
257
+
258
+ [Verify] ── before vs. after vs. model claims
259
+
260
+ ├── ✅ All verified → Log to MEMORY.md
261
+
262
+ └── ❌ Mismatch → Correction Turn (max 2 retries)
263
+
264
+ └── Still failing Yield to human
265
+ ```
266
+
267
+ ---
268
+
269
+ ## MEMORY.md — Should You Commit It?
270
+
271
+ **Yes.** `MEMORY.md` is designed to be committed to your repository. It becomes a "collaborative brain" where:
272
+ - Multiple developers can see what the AI did in previous sessions
273
+ - Different AI agents can reference past context
274
+ - You get a full audit trail of every AI-assisted file operation
275
+
276
+ If you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.
277
+
278
+ ---
279
+
280
+ ## The Capybara System Prompt
281
+
282
+ The system prompt implements the leaked Anthropic protocol:
283
+
284
+ > **Tier: Capybara** (Specialized in Cybersecurity & PhD Reasoning)
285
+ >
286
+ > Follow 'Strict Write Discipline' and never hallucinate filesystem state.
287
+ > Every file operation must be wrapped in `[FILE_ACTION]` blocks for verification.
288
+
289
+ The model is instructed to emit machine-readable delimiters around every file operation, making SWD verification 100% reliable.
290
+
291
+ ---
292
+
293
+ ## Configuration
294
+
295
+ | Env Variable | Required | Description |
296
+ |-------------|----------|-------------|
297
+ | `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key |
298
+
299
+ | File | Purpose |
300
+ |------|---------|
301
+ | `.mythosignore` | Patterns to exclude from SWD scanning |
302
+ | `MEMORY.md` | Auto-generated agentic memory log |
303
+
304
+ ---
305
+
306
+ ## Token Usage & Budget
307
+
308
+ ### Opus 4.7 Pricing (as of 2026-04)
309
+
310
+ | Rate | USD |
311
+ |------|-----|
312
+ | Input tokens | $15.00 / 1M tokens |
313
+ | Output tokens | $75.00 / 1M tokens |
314
+
315
+ > **⚠️ Tokenizer Cost Inflation Alert**
316
+ > While the per-token price remains identical to Opus 4.6, **Opus 4.7 uses a new tokenizer that is significantly less efficient for Latin scripts**.
317
+ > - English prompts require **~59% more tokens** (85 → 135 tokens per paragraph).
318
+ > - French requires **~34% more tokens**.
319
+ > - Mixed multilingual codebases effectively cost **~22% more**.
320
+ > - CJK languages (Chinese/Japanese/Korean) and code (Python) see smaller regressions (+4-21%).
321
+ >
322
+ > *Bottom line: Expect your English-heavy mythos-router sessions to cost up to 59% more with Opus 4.7 than they did with 4.6, simply due to tokenizer changes.*
323
+
324
+ > Pricing constants live in `src/config.ts`. When Anthropic updates rates, change two lines — no budget math to refactor.
325
+
326
+ | Mode | Typical Cost Per Turn |
327
+ |------|----------------------|
328
+ | `--effort high` | Full Opus 4.7 pricing (deep reasoning) |
329
+ | `--effort medium` | Balanced — good for most tasks |
330
+ | `--effort low` | Minimal thinking — quick answers |
331
+ | `dream` | Low effort summarization (~500 tokens) |
332
+
333
+ | Budget Setting | Default |
334
+ |---------------|--------|
335
+ | `--max-tokens` | 500,000 per session |
336
+ | `--max-turns` | 25 per session |
337
+ | Warning threshold | 80% consumption |
338
+ | `--no-budget` | Disables all limits |
339
+
340
+ ### Graceful Save
341
+
342
+ When the budget is reached, mythos doesn't just kill your session — it performs a **graceful save**:
343
+
344
+ ```
345
+ ⏸ BUDGET REACHED — Graceful Save
346
+ 498,231 tokens consumed across 25 turns (~$7.4200).
347
+ Progress saved to MEMORY.md. Resume with mythos chat to continue.
348
+ Increase limits: mythos chat --max-tokens 1000000 --max-turns 50
349
+ Disable limits: mythos chat --no-budget
350
+ ```
351
+
352
+ Token counts, estimated cost, and budget status are displayed after every chat response.
353
+
354
+ ---
355
+
356
+ ## Execution Model
357
+
358
+ 1. User input is received in CLI
359
+ 2. LLM generates response with structured file operations
360
+ 3. File system snapshot is captured
361
+ 4. Proposed changes are validated against actual filesystem state
362
+ 5. Verified actions are applied and logged to `MEMORY.md`
363
+ 6. Drift or mismatches trigger correction handling
364
+
365
+ ---
366
+
367
+ ## MEMORY.md
368
+
369
+ `MEMORY.md` acts as a persistent execution log of the agent system.
370
+
371
+ It records:
372
+ - executed file operations
373
+ - session summaries
374
+ - verification results
375
+
376
+ It can optionally be committed to version control for collaborative AI-assisted development.
377
+
378
+ ---
379
+
380
+ ## Environment Variables
381
+
382
+ | Variable | Required | Description |
383
+ |----------|----------|-------------|
384
+ | `ANTHROPIC_API_KEY` | Yes | API key for Anthropic models |
385
+
386
+ ---
387
+
388
+ ## License
389
+
390
+ MIT
391
+
392
+ ---
393
+
394
+ ## Disclaimer
395
+
396
+ This project is an independent open-source tool built on top of the Anthropic API. It is not affiliated with or endorsed by Anthropic.
397
+
398
+ <div align="center"><sub>Built for structured AI agent workflows with verifiable execution.</sub></div>