{"id":47809026,"url":"https://github.com/thewaltero/mythos-router","last_synced_at":"2026-04-27T17:00:56.118Z","repository":{"id":348351826,"uuid":"1197608241","full_name":"thewaltero/mythos-router","owner":"thewaltero","description":"The leaked Anthropic reasoning protocol. Running locally. Zero-drift coding with Strict Write Discipline and adaptive Claude Opus 4.7 thinking. Mythos CA: 0xb942b75a602fa318ac091370d93d9143ba345ba3","archived":false,"fork":false,"pushed_at":"2026-04-23T01:09:36.000Z","size":1795,"stargazers_count":79,"open_issues_count":0,"forks_count":29,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-04-23T01:30:16.391Z","etag":null,"topics":["anthropic","capybara","claude","claude-code","claude-mythos","claude-opus","claudemythos","claw-code","cli","llm","mythos","opus-4-6","opus-4-7"],"latest_commit_sha":null,"homepage":"https://mythosrouter.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thewaltero.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-31T18:11:22.000Z","updated_at":"2026-04-23T01:09:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"8cdbcc7e-e4a3-4190-a0f6-801344884751","html_url":"https://github.com/thewaltero/mythos-router","commit_stats":null,"previous_names":["thewaltero/mythos-router"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/thewaltero/mythos-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaltero%2Fmythos-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaltero%2Fmythos-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaltero%2Fmythos-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaltero%2Fmythos-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thewaltero","download_url":"https://codeload.github.com/thewaltero/mythos-router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaltero%2Fmythos-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32345816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic","capybara","claude","claude-code","claude-mythos","claude-opus","claudemythos","claw-code","cli","llm","mythos","opus-4-6","opus-4-7"],"created_at":"2026-04-03T18:01:28.509Z","updated_at":"2026-04-27T17:00:56.111Z","avatar_url":"https://github.com/thewaltero.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"assets/banner.png\" alt=\"Mythos Router Banner\" width=\"864\" /\u003e\n\n[![CodeQL](https://github.com/thewaltero/mythos-router/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/thewaltero/mythos-router/actions/workflows/github-code-scanning/codeql)\n[![npm](https://img.shields.io/npm/v/mythos-router?style=flat-square\u0026color=cc785c)](https://www.npmjs.com/package/mythos-router)\n[![Node.js](https://img.shields.io/badge/Node.js-20+-339933?style=flat-square\u0026logo=node.js\u0026logoColor=white)](https://nodejs.org)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square\u0026logo=typescript\u0026logoColor=white)](https://typescriptlang.org)\n[![Claude](https://img.shields.io/badge/Claude-Opus_4.7-cc785c?style=flat-square)](https://anthropic.com)\n[![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)](./LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/thewaltero/mythos-router?style=social)](https://github.com/thewaltero/mythos-router)\n\n\n## Claude Opus 4.7 · Strict Write Discipline · Zero Slop\n**A local CLI power tool for verifiable AI-assisted coding.**\n\n\u003cbr /\u003e\n\n[What is this?](#what-is-this) • [Features](#features) • [Installation](#installation) • [Usage](#usage) • [Architecture](#architecture) • [Token Budget](#token-usage--budget) • [SDK](#-sdk-usage-for-agentic-systems)\n\n\n---\n\n### Support the project\n**CA: `0xb942b75a602fa318ac091370d93d9143ba345ba3` ([$MYTHOS Token](https://app.uniswap.org/swap?outputCurrency=0xb942b75a602fa318ac091370d93d9143ba345ba3\u0026chain=base))**\n\n---\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/demo.png\" alt=\"mythos-router terminal demo\" width=\"700\" /\u003e\n\u003c/p\u003e\n\n```bash\n# Try it now\nnpx mythos-router chat\n```\n\n\u003c/div\u003e\n\n---\n\n## What is this?\n\n**mythos-router** is a local CLI power tool that wraps Claude Opus 4.7 with a custom verification protocol called **Strict Write Discipline (SWD)**.\n\nUnlike standard Claude wrappers, mythos-router enforces filesystem verification: every file operation the AI claims to perform is *checked against the actual filesystem using SHA-256 snapshots*. If the model's claim doesn't match reality, it gets a Correction Turn. If it fails twice, it yields to the human.\n\nZero slop. Zero hallucinated state. Full adaptive thinking.\n\n---\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n|  **Multi-Provider Fallback** | Auto-routes between Anthropic, DeepSeek, and OpenAI with circuit breakers |\n|  **Skills Protocol** | Inject modular expert plugins via YAML frontmatter (`-s mcp`, `-s react`) |\n|  **Deterministic Caching** | SQLite-backed caching for zero-cost, zero-latency repetitive reasoning *(Node 22+)* |\n|  **Adaptive Thinking** | Opus 4.7 with configurable effort levels (high/medium/low) |\n|  **Strict Write Discipline** | Pre/post filesystem snapshots verify every model claim |\n|  **Self-Healing Memory** | Authority-based logging with a rebuildable SQLite FTS5 search index *(Node 22+)* |\n|  **Auto-Healing TDD** | Pass `--test-cmd` for bounded, error-driven autonomous repair loops |\n|  **Correction Turns** | Model gets 2 retries to match filesystem reality, then yields |\n|  **Integrity Gate** | `verify` command and startup hashing ensure zero drift |\n|  **Token Limiter** | Budget cap with graceful save — progress saved to MEMORY.md, never lose work |\n|  **Dry-Run Mode** | Preview every file operation before it executes — full transparency |\n|  **Verbose Tracing** | See exactly what the AI is parsing, thinking, and verifying |\n|  **Budget Analytics** | Persistent tracking of cost across sessions and projects via `stats` |\n|  **Session Branching** | Isolate AI actions in a namespaced git branch (`mythos/`) |\n|  **Zero Build** | Runs directly via `tsx` — no compile step in dev |\n\n---\n\n## Core Architectural Pillars\n\n### 1. Configurable Model Selection\nChoose the right model for the job via the `--effort` flag:\n\n| Effort | Model | Best For |\n|--------|-------|----------|\n|  `high` (default) | Claude Opus 4.7 | Architecture, deep reasoning, complex refactors |\n|  `medium` | Claude Sonnet 3.5 | Balanced code generation, everyday tasks |\n|  `low` | Claude Haiku 3 | Quick answers, memory compression, verification |\n\nThe `dream` command automatically uses `low` effort (Haiku) for cost-efficient memory compression, and `verify` uses lightweight scanning — so you only burn Opus tokens when you need deep reasoning.\n\n### 2. Authority-Based \"Self-Healing\" Memory\nMost agentic systems stored state in opaque databases or messy JSON files. Mythos Router treats `MEMORY.md` as the **Sole Authority**. \n\nEvery action is logged in Markdown first. On startup, the system verifies the integrity of the log via SHA-256 manifest hashing and reconstructs a high-performance **Derivative SQLite Index** (FTS5). If the index drifts or the database is deleted, the system self-heals by rebuilding from the authoritative Markdown source.\n\nAs memory approaches capacity, the `dream` command delegates a compression phase to a low-cost model (Haiku 3), ensuring your \"Sacred Log\" is always lean and relevant.\n\n---\n\n## Installation\n\n\u003e **Node.js Version Requirement:** The core CLI runs perfectly on **Node 20+**. However, the advanced SQLite-backed features (Telemetry Dashboard, Deterministic Caching, and High-Performance Memory Index) require **Node.js 22.12.0+**. If you run the tool on an older version, these features will safely and silently degrade to a no-op without crashing the router.\n\n### Quick Start (npm)\n\n```bash\n# Install globally\nnpm install -g mythos-router\n\n# Set your API keys (Anthropic is primary, others are fallbacks)\nexport ANTHROPIC_API_KEY=\"sk-ant-...\"\nexport OPENAI_API_KEY=\"sk-proj-...\"\nexport DEEPSEEK_API_KEY=\"sk-...\"\n\n# Go\nmythos chat\n```\n\n### Or try without installing\n\n```bash\nnpx mythos-router chat\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/thewaltero/mythos-router.git\ncd mythos-router\nnpm install\nnpm run chat\n```\n\n---\n\n## Usage\n\n### `mythos chat` — Interactive Session\n\n```bash\nmythos chat                  # Full power (high effort, Opus 4.7)\nmythos chat -s react         # Load the 'react' expert skill\nmythos chat --test-cmd \"npm test\" # Enable autonomous test-driven self-healing\nmythos chat --effort low     # Budget mode (Haiku 3)\nmythos chat --effort medium  # Balanced (Sonnet 3.5)\nmythos chat --dry-run        # Preview all file changes before executing\nmythos chat --verbose        # See full SWD traces and thinking\nmythos chat --branch refactor # Isolate session in a fresh git branch\nmythos chat --dry-run --verbose  # Maximum transparency\n```\n\n####  Financial Safety — Never Burn Money Again\n\n```bash\nmythos chat                           # Default: 500K tokens, 25 turns\nmythos chat --max-tokens 100000       # Cap at 100K tokens\nmythos chat --max-turns 10            # Cap at 10 turns\nmythos chat --max-tokens 50000 --max-turns 5  # Tight budget\nmythos chat --no-budget               # Expert mode (no limits)\n```\n\nThe budget limiter tracks every token, turn, and estimated cost in real-time:\n\n```\nbudget: [████████░░░░░░░░░░░░] 78,342/500,000 tokens · [██████░░░░] 12/25 turns · ~$1.2340 · 4m 32s\n```\n\nAt 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).\n\n####  Dry-Run Mode — The Trust Builder\n\n```bash\nmythos chat --dry-run\n```\n\nIn dry-run mode, every file operation is previewed before execution:\n\n```\n DRY-RUN  ── File Action Preview ──\n  2 file action(s) detected. Review each:\n\n  1/2 MODIFY src/index.ts\n  Description: Change 'axios' to 'fetch'\n  Current state: 1,832 bytes, hash: 7a3f2c1e..\n   DRY-RUN  Accept MODIFY on src/index.ts? [Y/n] y\n  ✔ Accepted: MODIFY src/index.ts\n\n  2/2 CREATE src/utils.ts\n  Description: Add helper utilities\n  Current state: does not exist\n   DRY-RUN  Accept CREATE on src/utils.ts? [Y/n] n\n  ⚠ Rejected: CREATE src/utils.ts\n```\n\nIn-session commands:\n- `/exit` — End session (shows final budget summary)\n- `/memory` — Show memory status\n- `/budget` — Show current budget consumption\n- `/clear` — Clear conversation (memory persists)\n\n### `mythos verify` — Zero-Drift Codebase Scan\n\n```bash\nmythos verify              # Scan and log results to MEMORY.md\nmythos verify --dry-run    # Scan without writing to MEMORY.md\n```\n\nScans every file in your project and cross-references against `MEMORY.md`:\n- ✅ **Verified** — File state matches memory\n- ⚠️ **Drift** — File changed but memory doesn't reflect it\n- ❌ **Missing** — Memory references a file that doesn't exist\n\n### `mythos dream` — Memory Compression\n\n```bash\nmythos dream              # Auto-compress when needed\nmythos dream --force      # Force compression\nmythos dream --dry-run    # Preview without writing\n```\n\nWhen `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.\n\n### `mythos stats` — Budget Analytics \u0026 Cost Profiling\n\n```bash\nmythos stats              # Show all-time token usage and costs\nmythos stats --days 7      # Filter for the last week\n```\n\nTracks every penny spent across all your projects. Costs are aggregated by:\n- **Command** (e.g., `chat` vs `dream`)\n- **Project** (directory name)\n- **Time Period**\n\nData is stored locally in `~/.mythos-router/metrics.json`.\n\n### 🔌 SDK Usage (For Agentic Systems)\n\n`mythos-router` exposes its Strict Write Discipline engine for programmatic use:\n\n```typescript\nimport { SWDEngine, parseActions } from 'mythos-router';\n\n// 1. Create an engine instance with your preferred options\nconst engine = new SWDEngine({\n  strict: true,\n  enableRollback: true,\n  onAction: (action) =\u003e console.log(`Executing: ${action.operation} ${action.path}`),\n  onVerify: (result) =\u003e console.log(`${result.status}: ${result.detail}`),\n});\n\n// 2. Let your agent generate code (must output [FILE_ACTION] blocks)\nconst agentOutput = await myAgent.generateCode();\n\n// 3. Parse the agent's output and route through the SWD engine\nconst actions = parseActions(agentOutput);\nconst result = await engine.run(actions);\n\nif (result.success) {\n  console.log('✅ Agent execution verified securely');\n} else {\n  console.log('❌ Agent hallucinated a write. Rolled back:', result.rolledBack);\n  console.log('Errors:', result.errors);\n}\n```\n\n\n---\n\n## Architecture\n\n```\nmythos-router/\n├── src/\n│   ├── cli.ts           # Commander.js entry point\n│   ├── config.ts        # System prompt + constants + budget defaults + validation\n│   ├── client.ts        # Anthropic SDK (adaptive thinking, streaming)\n│   ├── budget.ts        # Session budget limiter (token cap, turn cap, progress bar)\n│   ├── swd.ts           # SWD execution kernel (engine, types, parsing, snapshots)\n│   ├── swd-cli.ts       # SWD terminal presentation (verification output, dry-run)\n│   ├── memory.ts        # MEMORY.md self-healing manager (SQLite FTS5 index)\n│   ├── metrics.ts       # Global metrics store (persistent budget tracking)\n│   ├── diff.ts          # Myers' diff algorithm (zero-dependency)\n│   ├── git.ts           # Git operations (branching, committing)\n│   ├── utils.ts         # Terminal formatting, badges, prompts (zero-dep ANSI)\n│   ├── index.ts         # Public SDK exports\n│   └── commands/\n│       ├── chat.ts      # Interactive REPL (ChatSession + ChatUI abstraction)\n│       ├── verify.ts    # Codebase ↔ Memory scanner (dry-run aware)\n│       ├── dream.ts     # Memory compression (dry-run aware)\n│       └── stats.ts     # Budget analytics reporter\n├── src/providers/       # Multi-Provider Orchestration Engine\n│   ├── orchestrator.ts  # Adaptive routing, circuit breakers, scoring\n│   ├── pricing.ts       # Centralized token cost registry\n│   ├── types.ts         # Unified BaseProvider contracts\n│   ├── anthropic.ts     # Claude provider\n│   └── openai.ts        # Fetch-based OpenAI \u0026 DeepSeek provider\n├── test/                # Automated test suite (node:test)\n├── .mythosignore        # SWD scan exclusions\n├── MEMORY.md            # Auto-generated agentic memory\n└── AGENTS.md            # Project conventions\n```\n\n### The SWD Protocol\n\n```\nUser Input\n    │\n    ▼\n[Claude Opus 4.7] ── adaptive thinking\n    │\n    ▼\n[Parse FILE_ACTION blocks] ── extract claimed operations\n    │\n    ▼\n[Snapshot referenced files] ── targeted filesystem state capture\n    │\n    ▼\n[Verify] ── model claims vs. actual filesystem\n    │\n    ├── ✅ All verified → Log to MEMORY.md\n    │\n    └── ❌ Mismatch → Correction Turn (max 2 retries)\n                │\n                └── Still failing → Yield to human\n```\n\n---\n\n## MEMORY.md — Should You Commit It?\n\n**Yes.** `MEMORY.md` is designed to be committed to your repository. It becomes a \"collaborative brain\" where:\n- Multiple developers can see what the AI did in previous sessions\n- Different AI agents can reference past context\n- You get a full audit trail of every AI-assisted file operation\n\nIf you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.\n\n---\n\n## Configuration\n\n| Env Variable | Required | Description |\n|-------------|----------|-------------|\n| `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key (Primary Provider) |\n| `OPENAI_API_KEY` | ❌ | OpenAI API Key (Fallback Provider) |\n| `DEEPSEEK_API_KEY` | ❌ | DeepSeek API Key (Fallback Provider, reasoning capable) |\n\n| File | Purpose |\n|------|---------| \n| `.mythosignore` | Patterns to exclude from SWD scanning |\n| `MEMORY.md` | Auto-generated agentic memory log |\n\n---\n\n## Token Usage \u0026 Budget\n\n### Opus 4.7 Pricing (as of 2026-04)\n\n| Rate | USD |\n|------|-----|\n| Input tokens | $15.00 / 1M tokens |\n| Output tokens | $75.00 / 1M tokens |\n\n\u003e ** Tokenizer Cost Inflation Alert**\n\u003e 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**. \n\u003e - English prompts require **~59% more tokens** (85 → 135 tokens per paragraph).\n\u003e - French requires **~34% more tokens**.\n\u003e - Mixed multilingual codebases effectively cost **~22% more**.\n\u003e - CJK languages (Chinese/Japanese/Korean) and code (Python) see smaller regressions (+4-21%).\n\u003e \n\u003e *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.*\n\n\u003e Pricing constants live in `src/config.ts`. When Anthropic updates rates, change two lines — no budget math to refactor.\n\n| Mode | Typical Cost Per Turn |\n|------|----------------------|\n| `--effort high` | Full Opus 4.7 pricing (deep reasoning) |\n| `--effort medium` | Balanced — good for most tasks |\n| `--effort low` | Minimal thinking — quick answers |\n| `dream` | Low effort summarization (~500 tokens) |\n\n| Budget Setting | Default |\n|---------------|---------|\n| `--max-tokens` | 500,000 per session |\n| `--max-turns` | 25 per session |\n| Warning threshold | 80% consumption |\n| `--no-budget` | Disables all limits |\n\n### Graceful Save\n\nWhen the budget is reached, mythos doesn't just kill your session — it performs a **graceful save**:\n\n```\n⏸ BUDGET REACHED — Graceful Save\n  498,231 tokens consumed across 25 turns (~$7.4200).\n  Progress saved to MEMORY.md. Resume with mythos chat to continue.\n  Increase limits: mythos chat --max-tokens 1000000 --max-turns 50\n  Disable limits:  mythos chat --no-budget\n```\n\nToken counts, estimated cost, and budget status are displayed after every chat response.\n\n---\n\n## Testing\n\n```bash\nnpm test                 # Run full test suite\nnpx tsc --noEmit         # Type check only\nnpm run build            # Production build\n```\n\n---\n\n## License\n\nMIT\n\n---\n\n## Disclaimer\n\nThis project is an independent open-source tool built on top of the Anthropic API. It is not affiliated with or endorsed by Anthropic.\n\n\u003cdiv align=\"center\"\u003e\u003csub\u003eBuilt for structured AI agent workflows with verifiable execution.\u003c/sub\u003e\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewaltero%2Fmythos-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewaltero%2Fmythos-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewaltero%2Fmythos-router/lists"}