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 +398 -317
- package/dist/cli.js +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +64 -36
- package/dist/client.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +30 -20
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +0 -11
- package/dist/commands/verify.js.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -7
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/memory.d.ts +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +7 -3
- package/dist/memory.js.map +1 -1
- package/dist/swd.d.ts +0 -1
- package/dist/swd.d.ts.map +1 -1
- package/dist/swd.js +0 -13
- package/dist/swd.js.map +1 -1
- package/dist/utils.js +1 -1
- package/package.json +7 -3
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.
|
|
13
|
-
|
|
14
|
-
**The leaked Anthropic reasoning protocol. Running locally.**
|
|
15
|
-
|
|
16
|
-
[](https://www.npmjs.com/package/mythos-router)
|
|
17
|
-
[](https://nodejs.org)
|
|
18
|
-
[](https://typescriptlang.org)
|
|
19
|
-
[](./LICENSE)
|
|
21
|
-
[](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.
|
|
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
|
-
##
|
|
63
|
-
|
|
64
|
-
###
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
mythos
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
mythos chat
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
mythos chat
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
mythos chat --
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
mythos
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
mythos
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
+
[](https://www.npmjs.com/package/mythos-router)
|
|
17
|
+
[](https://nodejs.org)
|
|
18
|
+
[](https://typescriptlang.org)
|
|
19
|
+
[](https://anthropic.com)
|
|
20
|
+
[](./LICENSE)
|
|
21
|
+
[](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>
|