axion-code 1.0.0__py3-none-any.whl

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.
Files changed (82) hide show
  1. axion/__init__.py +3 -0
  2. axion/api/__init__.py +0 -0
  3. axion/api/anthropic.py +460 -0
  4. axion/api/client.py +259 -0
  5. axion/api/error.py +161 -0
  6. axion/api/ollama.py +597 -0
  7. axion/api/openai_compat.py +805 -0
  8. axion/api/openai_responses.py +627 -0
  9. axion/api/prompt_cache.py +31 -0
  10. axion/api/sse.py +98 -0
  11. axion/api/types.py +451 -0
  12. axion/cli/__init__.py +0 -0
  13. axion/cli/init_cmd.py +50 -0
  14. axion/cli/input.py +290 -0
  15. axion/cli/main.py +2953 -0
  16. axion/cli/render.py +489 -0
  17. axion/cli/tui.py +766 -0
  18. axion/commands/__init__.py +0 -0
  19. axion/commands/handlers/__init__.py +0 -0
  20. axion/commands/handlers/agents.py +51 -0
  21. axion/commands/handlers/builtin_commands.py +367 -0
  22. axion/commands/handlers/mcp.py +59 -0
  23. axion/commands/handlers/models.py +75 -0
  24. axion/commands/handlers/plugins.py +55 -0
  25. axion/commands/handlers/skills.py +61 -0
  26. axion/commands/parsing.py +317 -0
  27. axion/commands/registry.py +166 -0
  28. axion/compat_harness/__init__.py +0 -0
  29. axion/compat_harness/extractor.py +145 -0
  30. axion/plugins/__init__.py +0 -0
  31. axion/plugins/hooks.py +22 -0
  32. axion/plugins/manager.py +391 -0
  33. axion/plugins/manifest.py +270 -0
  34. axion/runtime/__init__.py +0 -0
  35. axion/runtime/bash.py +388 -0
  36. axion/runtime/bootstrap.py +39 -0
  37. axion/runtime/claude_subscription.py +300 -0
  38. axion/runtime/compact.py +233 -0
  39. axion/runtime/config.py +397 -0
  40. axion/runtime/conversation.py +1073 -0
  41. axion/runtime/file_ops.py +613 -0
  42. axion/runtime/git.py +213 -0
  43. axion/runtime/hooks.py +235 -0
  44. axion/runtime/image.py +212 -0
  45. axion/runtime/lanes.py +282 -0
  46. axion/runtime/lsp.py +425 -0
  47. axion/runtime/mcp/__init__.py +0 -0
  48. axion/runtime/mcp/client.py +76 -0
  49. axion/runtime/mcp/lifecycle.py +96 -0
  50. axion/runtime/mcp/stdio.py +318 -0
  51. axion/runtime/mcp/tool_bridge.py +79 -0
  52. axion/runtime/memory.py +196 -0
  53. axion/runtime/oauth.py +329 -0
  54. axion/runtime/openai_subscription.py +346 -0
  55. axion/runtime/permissions.py +247 -0
  56. axion/runtime/plan_mode.py +96 -0
  57. axion/runtime/policy_engine.py +259 -0
  58. axion/runtime/prompt.py +586 -0
  59. axion/runtime/recovery.py +261 -0
  60. axion/runtime/remote.py +28 -0
  61. axion/runtime/sandbox.py +68 -0
  62. axion/runtime/scheduler.py +231 -0
  63. axion/runtime/session.py +365 -0
  64. axion/runtime/sharing.py +159 -0
  65. axion/runtime/skills.py +124 -0
  66. axion/runtime/tasks.py +258 -0
  67. axion/runtime/usage.py +241 -0
  68. axion/runtime/workers.py +186 -0
  69. axion/telemetry/__init__.py +0 -0
  70. axion/telemetry/events.py +67 -0
  71. axion/telemetry/profile.py +49 -0
  72. axion/telemetry/sink.py +60 -0
  73. axion/telemetry/tracer.py +95 -0
  74. axion/tools/__init__.py +0 -0
  75. axion/tools/lane_completion.py +33 -0
  76. axion/tools/registry.py +853 -0
  77. axion/tools/tool_search.py +226 -0
  78. axion_code-1.0.0.dist-info/METADATA +709 -0
  79. axion_code-1.0.0.dist-info/RECORD +82 -0
  80. axion_code-1.0.0.dist-info/WHEEL +4 -0
  81. axion_code-1.0.0.dist-info/entry_points.txt +2 -0
  82. axion_code-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,709 @@
1
+ Metadata-Version: 2.4
2
+ Name: axion-code
3
+ Version: 1.0.0
4
+ Summary: Axion Code - Python AI coding assistant CLI
5
+ Project-URL: Homepage, https://github.com/cypher125/Axion-Code
6
+ Project-URL: Repository, https://github.com/cypher125/Axion-Code
7
+ Project-URL: Issues, https://github.com/cypher125/Axion-Code/issues
8
+ Author-email: Cyrus <osawayecyrus@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,anthropic,claude,cli,codex,coding-assistant,llm,openai,terminal
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development
22
+ Classifier: Topic :: Software Development :: Code Generators
23
+ Classifier: Topic :: Terminals
24
+ Classifier: Topic :: Utilities
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: click>=8.1
28
+ Requires-Dist: httpx-sse>=0.4
29
+ Requires-Dist: httpx>=0.27
30
+ Requires-Dist: prompt-toolkit>=3.0
31
+ Requires-Dist: pydantic>=2.5
32
+ Requires-Dist: rapidfuzz>=3.0
33
+ Requires-Dist: rich>=13.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: aiohttp>=3.9; extra == 'dev'
36
+ Requires-Dist: coverage>=7.0; extra == 'dev'
37
+ Requires-Dist: mypy>=1.10; extra == 'dev'
38
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
39
+ Requires-Dist: pytest>=8.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.4; extra == 'dev'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # Axion-Code
44
+
45
+ [![CI](https://github.com/cypher125/Axion-Code/actions/workflows/ci.yml/badge.svg)](https://github.com/cypher125/Axion-Code/actions/workflows/ci.yml)
46
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
48
+
49
+ An autonomous AI coding assistant that runs in your terminal. Axion connects to Claude, GPT, Grok, OpenAI Codex, or any local model via Ollama and can read your codebase, write code, run commands, manage files, search the web, and handle complex multi-step engineering tasks — all from a single prompt.
50
+
51
+ **Use your existing subscription.** Bring your **Claude Pro/Max** plan or **ChatGPT Plus/Pro/Business** plan instead of paying per-token. Axion authenticates via OAuth with the same flows the official Claude Code and OpenAI Codex CLIs use, so requests are billed against your existing plan. API keys still work too — pick whichever fits your usage.
52
+
53
+ ---
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install axion-code
59
+
60
+ # Or install from source
61
+ git clone https://github.com/cypher125/Axion-Code.git
62
+ cd Axion-Code
63
+ pip install -e ".[dev]"
64
+ ```
65
+
66
+ ## Quick Start
67
+
68
+ ```bash
69
+ # 1. Install
70
+ pip install axion-code
71
+
72
+ # 2. Log in (one time — saves your key permanently)
73
+ axion login
74
+
75
+ # 3. Start coding
76
+ axion
77
+ ```
78
+
79
+ That's it. No environment variables, no `.env` files. Your API key is saved to `~/.axion/credentials/` and works across all terminal sessions.
80
+
81
+ ```bash
82
+ # One-shot prompt
83
+ axion -p "Find and fix the bug in auth.py"
84
+
85
+ # Use a specific model
86
+ axion -m opus
87
+
88
+ # Set a cost budget
89
+ axion --budget 1.00
90
+
91
+ # Permission mode (asks before dangerous ops)
92
+ axion --permission-mode prompt
93
+
94
+ # Resume last session
95
+ axion --resume latest
96
+
97
+ # Health check
98
+ axion doctor
99
+
100
+ # Log out (removes saved key)
101
+ axion logout
102
+ ```
103
+
104
+ ## Supported Providers
105
+
106
+ | Provider | Models | API Key Login | Subscription Login |
107
+ |---|---|---|---|
108
+ | **Anthropic** | Claude Opus 4.7, Sonnet 4.6, Haiku 4.5 | `axion login` | `axion login --subscription` (Claude Pro/Max) |
109
+ | **OpenAI** | GPT-5, GPT-4o, o1, o3, o4-mini | `axion login --provider openai` | — |
110
+ | **OpenAI Codex** | gpt-5-codex, gpt-5-codex-mini (Responses API) | `axion login --provider openai` | `axion login --subscription --provider openai` (ChatGPT Plus/Pro/Business) |
111
+ | **xAI** | Grok-2, Grok-3 | `axion login --provider xai` | — |
112
+ | **Ollama** | Llama, Mistral, DeepSeek, Phi, Gemma, Qwen, CodeLlama | No login needed (free, local) | — |
113
+
114
+ ```bash
115
+ # Anthropic — pick API key or Claude Pro/Max subscription
116
+ axion login # interactive: pick 1=subscription, 2=API key
117
+ axion login --subscription # opens browser → claude.ai → paste code
118
+ axion -p "Explain this codebase"
119
+
120
+ # OpenAI Codex — agent-tuned coding model via the Responses API
121
+ axion login --provider openai # pay-per-token
122
+ axion login --subscription --provider openai # ChatGPT Plus/Pro/Business
123
+ axion -m codex -p "Refactor this function"
124
+
125
+ # OpenAI Chat Completions
126
+ axion -m gpt-5 -p "Write tests for this module"
127
+
128
+ # xAI
129
+ axion login --provider xai
130
+ axion -m grok-2 -p "Review this code"
131
+
132
+ # Local models via Ollama (free, no login, no internet)
133
+ ollama pull llama3.1
134
+ axion -m llama3.1 -p "Refactor this"
135
+
136
+ # List available models across all configured providers
137
+ axion models # or: /models inside the REPL
138
+ ```
139
+
140
+ ### Subscription vs API Key
141
+
142
+ | | Subscription (Pro/Max, ChatGPT Plus+) | API Key |
143
+ |---|---|---|
144
+ | **Cost** | Flat monthly fee | Pay per token |
145
+ | **Rate limits** | Plan-based 5-hour rolling window | Per-org TPM/RPM |
146
+ | **Auth** | OAuth (browser) | API key string |
147
+ | **Storage** | `~/.axion/credentials/anthropic-oauth.json` (or `openai-oauth.json`) | `~/.axion/credentials/anthropic.key` (etc.) |
148
+ | **Best for** | Heavy daily use | Occasional / programmatic use |
149
+ | **Required model** | Any Claude model / Codex models | Any |
150
+
151
+ Switch between modes mid-session with `/auth-mode subscription` or `/auth-mode api`. The provider client rebuilds in place — no restart needed.
152
+
153
+ The welcome screen and bottom toolbar always show which mode is active:
154
+
155
+ ```
156
+ claude-sonnet-4-6 · Pro/Max ← Anthropic subscription
157
+ gpt-5-codex · ChatGPT ← OpenAI subscription
158
+ gpt-5 · API ← API key (pay-per-token)
159
+ qwen2:7b · local ← Ollama (free, on-device)
160
+ ```
161
+
162
+ When the subscription is rate-limited, the error includes the exact retry time parsed from the `anthropic-ratelimit-*-reset` headers:
163
+
164
+ ```
165
+ Rate limit hit — retry at 14:32 (in 18 min)
166
+ Your Claude Pro/Max plan limits messages per 5-hour window:
167
+ • Pro: ~45 messages / 5h
168
+ • Max: ~225-900 messages / 5h (depending on tier)
169
+
170
+ Options while you wait:
171
+ • Switch to API key billing: /auth-mode api
172
+ • Use a different provider: /model gpt-5 or /model grok-2
173
+ ```
174
+
175
+ ## What Can It Do?
176
+
177
+ ### Tools (13 built-in)
178
+
179
+ | Tool | What it does |
180
+ |---|---|
181
+ | **Bash** | Execute shell commands with timeout, background mode, sandboxing |
182
+ | **Read** | Read files with line ranges, binary detection, image/PDF support |
183
+ | **Write** | Create or update files with automatic patch generation |
184
+ | **Edit** | Find-and-replace in files with uniqueness validation |
185
+ | **Glob** | Search for files by pattern, sorted by modification time |
186
+ | **Grep** | Regex search across files with context lines, file type filtering |
187
+ | **WebSearch** | Search the web via DuckDuckGo (no API key needed) |
188
+ | **WebFetch** | Fetch any URL and return its content |
189
+ | **Agent** | Spawn sub-agents for parallel task execution |
190
+ | **TodoWrite** | Manage structured task lists for complex workflows |
191
+ | **NotebookEdit** | Edit Jupyter notebook cells (insert, replace, delete) |
192
+ | **Skill** | Load and execute skill templates from `.md` files |
193
+ | **ToolSearch** | Deferred tool schema loading — search and activate tools on demand |
194
+
195
+ All tools are automatically sent to the model with every request, so the AI can read files, write code, run commands, and search the web without any manual setup.
196
+
197
+ ### Slash Commands (45)
198
+
199
+ ```
200
+ /help Show all commands
201
+ /model opus Switch model mid-conversation
202
+ /models List models across all configured providers (Anthropic, OpenAI, xAI, Ollama)
203
+ /cost Show token usage and costs
204
+ /compact Compress conversation history (heuristic or model-based)
205
+ /status Session info, git branch, token count
206
+ /config Show loaded configuration sources
207
+ /mcp list List connected MCP servers
208
+ /plugins list List installed plugins
209
+ /skills list List available skills
210
+ /agents list List available agents
211
+ /doctor Run health checks
212
+ /export Export transcript to markdown
213
+ /session list List saved sessions
214
+ /resume latest Resume last session (replays full conversation)
215
+ /login Authenticate via OAuth
216
+ /logout Clear stored credentials (API key + subscription)
217
+ /auth-mode Show or switch auth (subscription / api / status)
218
+ /memory View persistent memory entries
219
+ /diff Show git changes with syntax highlighting
220
+ /image Paste image from clipboard or file path (also works inline mid-prompt)
221
+ /plan <task> Enter plan mode (read-only exploration + design)
222
+ /plan execute Approve plan and start implementing
223
+ /plan exit Cancel plan mode
224
+ ```
225
+
226
+ ### Real-Time Tool Display
227
+
228
+ When the AI uses tools (reading files, running commands, editing), you see it happening live in a compact, Claude Code-style inline format:
229
+
230
+ ```
231
+ > fix the bug in auth.py
232
+
233
+ I'll look at the auth module and find the issue.
234
+
235
+ ● Read(/app/auth.py)
236
+ └ Read 86 lines
237
+ ● Edit(/app/auth.py)
238
+ 12 - if user == "admin":
239
+ 12 + if user == "admin" and verify_password(pwd):
240
+ └ Replaced 1 occurrence(s) in /app/auth.py
241
+ ● Bash(pytest tests/test_auth.py -v)
242
+ └ 2 passed in 0.3s
243
+
244
+ Fixed — the login function now properly verifies the password.
245
+ ```
246
+
247
+ `Edit` shows a real diff with line numbers (red background for removals, green for additions). `Write` shows the new content with line numbers and a `+N lines (ctrl+o to expand)` truncation marker for files over 14 lines. `Bash` shows a one-line status that updates live as stderr/stdout streams in (`⠋ Building project...` → `⠹ Generating static pages (3/6)...` → result).
248
+
249
+ ### Image Input
250
+
251
+ Paste screenshots or attach image files directly to your prompts — works with any vision-capable model (Claude Opus/Sonnet/Haiku, GPT-4o, GPT-5, Codex):
252
+
253
+ ```
254
+ # 1. Take a screenshot, then:
255
+ > /image what's wrong with this UI?
256
+
257
+ # 2. Or attach a file:
258
+ > /image ./error.png explain this stack trace
259
+
260
+ # 3. Inline anywhere in a message:
261
+ > this UI looks generic /image — make it look more like Stripe's checkout
262
+
263
+ # 4. Auto-detected from file paths in input:
264
+ > fix the bug shown in error.png
265
+ ```
266
+
267
+ Supports `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp` up to 5MB. Images are base64-encoded and sent natively to both Anthropic (`source.type=base64`) and OpenAI (`image_url` data URL) — same wire format their APIs expect.
268
+
269
+ ### Interactive Permission Prompting
270
+
271
+ When using `--permission-mode prompt`, dangerous operations require your approval:
272
+
273
+ ```
274
+ Permission required
275
+ Tool: Bash
276
+ Mode: prompt → needs workspace-write
277
+ Input: {"command": "rm -rf /tmp/old"}
278
+
279
+ Allow? [y/N/a(lways)]: a
280
+ Allowed (always for this tool).
281
+ ```
282
+
283
+ Three choices: `y` (allow once), `a` (allow always — remembered for this tool), `N` (deny). Permission decisions are cached so you won't be asked again for the same tool.
284
+
285
+ ### Session Persistence & Resume
286
+
287
+ Every conversation is automatically saved. When you resume, Axion **replays the entire conversation** in the original Claude Code-style inline format — your past messages, the AI's responses (rendered as markdown), every tool call with its diff and output. It looks identical to scrolling up in the original session, so you can continue where you left off without context loss.
288
+
289
+ ```bash
290
+ # Resume the last session (full replay)
291
+ axion --resume latest
292
+
293
+ # Resume by session ID (or partial ID)
294
+ axion --resume abc123
295
+
296
+ # Inside the REPL:
297
+ /session list # List all saved sessions
298
+ /session switch abc123 # Switch to a different session
299
+ /session new # Start a fresh session (saves current)
300
+ /session fork feature # Fork current session with a name
301
+ /session delete abc123 # Remove an old session
302
+ /session show # Show current session info
303
+ ```
304
+
305
+ Sessions are stored as JSONL files in `.axion/sessions/` with automatic rotation at 256KB.
306
+
307
+ ### Streaming Markdown Rendering
308
+
309
+ Responses are rendered as markdown in real-time — headings get colored, code blocks get syntax highlighted, and links are formatted. The renderer buffers text until safe boundaries (outside code fences) before rendering, so code blocks are never split mid-render.
310
+
311
+ ### Error Recovery
312
+
313
+ Axion handles errors gracefully without crashing the REPL:
314
+ - **Context window exceeded**: Shows token usage percentage, suggests `/compact` or `/clear`
315
+ - **Authentication errors**: Suggests checking API key or running `/login`
316
+ - **Connection errors**: Suggests checking internet connection
317
+ - **Interrupted turns** (Ctrl+C): Resets cleanly, ready for next prompt
318
+
319
+ ### Compact System Prompt
320
+
321
+ The system prompt is intentionally kept small (~1,200 tokens) — about the same size as Claude Code's. We do not embed the full `git diff` or `settings.json` into every request the way some agents do; the model can run those itself with its tools when needed. On Anthropic, the prompt is wrapped with `cache_control: ephemeral` so even those tokens are billed at cache-read rates after the first turn.
322
+
323
+ Net effect: a "hello" turn to Claude Sonnet costs roughly ~2,000 input tokens including tool definitions, instead of the ~32,000 you'd get if everything were inlined. Subscription users get ~26x more sustained throughput out of the same Pro/Max bucket.
324
+
325
+ ### Token Preflight Check
326
+
327
+ Before every API call, Axion estimates the token count and checks it against the model's context window (200K for Claude). If the request would exceed the limit, it raises a clear error before wasting an API call.
328
+
329
+ ### Extended Thinking Display
330
+
331
+ When using Claude Opus with extended thinking, Axion shows a collapsed thinking indicator instead of dumping raw thinking text:
332
+
333
+ ```
334
+ 💭 Thinking...
335
+ ```
336
+
337
+ The thinking content is captured internally but kept out of the output to keep responses clean.
338
+
339
+ ### Image & PDF Reading
340
+
341
+ The Read tool automatically detects file types:
342
+ - **Images** (`.png`, `.jpg`, `.gif`, `.webp`, `.svg`): Returns base64-encoded content with metadata for the model to interpret
343
+ - **PDFs**: Tries `pdftotext` for text extraction, falls back to metadata if unavailable
344
+
345
+ ### Syntax-Highlighted Diffs
346
+
347
+ The `/diff` command renders git changes with full syntax highlighting using the monokai theme, showing staged and unstaged changes separately:
348
+
349
+ ```bash
350
+ /diff # Shows colorized diff in the terminal
351
+ ```
352
+
353
+ ### Cost Budget Limits
354
+
355
+ Set a maximum spend per session to avoid surprise bills:
356
+
357
+ ```bash
358
+ # Limit session to $1.00
359
+ axion --budget 1.00
360
+
361
+ # The AI will stop when the budget is reached
362
+ # Cost budget exceeded: $1.0234 >= $1.0000 budget.
363
+ # Use /cost to see breakdown or increase the budget.
364
+ ```
365
+
366
+ Budgets are checked after every API call. Use `/cost` anytime to see your running total.
367
+
368
+ ### Plan Mode
369
+
370
+ Design before coding. Plan mode blocks all write tools and lets the AI explore first:
371
+
372
+ ```
373
+ axion> /plan Add JWT authentication to the API
374
+
375
+ 📋 Plan mode ACTIVE
376
+ Only read-only tools allowed (Read, Glob, Grep, WebSearch).
377
+ Write/Edit/Bash are blocked until you approve.
378
+
379
+ Task: Add JWT authentication to the API
380
+
381
+ axion[plan]> go ahead, explore the codebase and design a plan
382
+
383
+ [AI reads files, searches code, explores architecture...]
384
+
385
+ ## Plan: Add JWT Authentication
386
+ 1. Create auth/ module with token generation
387
+ 2. Add middleware to validate tokens on protected routes
388
+ 3. Create login endpoint
389
+ 4. Add tests
390
+
391
+ ### Files to modify:
392
+ - src/main.py
393
+ - src/models.py
394
+
395
+ Ready to implement. Type /plan execute to proceed.
396
+
397
+ axion[plan]> /plan execute
398
+
399
+ Plan approved! Exiting plan mode.
400
+ Write tools are now available. Send your next message to start implementing.
401
+
402
+ axion> implement the plan
403
+ ```
404
+
405
+ The prompt changes to `axion[plan]>` so you always know when plan mode is active.
406
+
407
+ ### Conversation Export
408
+
409
+ Export any session to a clean, readable markdown file:
410
+
411
+ ```bash
412
+ /export # Saves to transcript-<session_id>.md
413
+ /export my-project.md # Custom filename
414
+ ```
415
+
416
+ The export includes numbered turns, collapsible tool use/result blocks (`<details>`), pretty-printed JSON, per-message token costs, and session metadata.
417
+
418
+ ### Cron Scheduling
419
+
420
+ Schedule recurring tasks with standard cron expressions:
421
+
422
+ ```python
423
+ # From the task/cron registries:
424
+ cron_registry.create("*/5 * * * *", TaskPacket(objective="Run health check", scope="all"))
425
+ cron_registry.create("0 9 * * 1-5", TaskPacket(objective="Daily standup summary", scope="src/"))
426
+ ```
427
+
428
+ The `CronScheduler` runs as an async background loop, checking enabled entries every minute and triggering tasks via the `TaskRegistry`. Supports `*`, `*/N`, ranges (`1-5`), and comma lists (`0,15,30,45`).
429
+
430
+ ## Architecture
431
+
432
+ ```
433
+ axion/
434
+ api/ 4 providers, 5 transport clients
435
+ anthropic Claude API: SSE streaming, retry, prompt caching, OAuth bearer support
436
+ openai_compat OpenAI/xAI Chat Completions client with streaming state machine
437
+ openai_responses OpenAI Responses API client for Codex (gpt-5-codex, gpt-5-codex-mini)
438
+ ollama Local model client (auto-detect llama/mistral/deepseek/phi/gemma/qwen)
439
+ types Shared types: MessageRequest, StreamEvent, ImageInputBlock, Usage
440
+ sse Server-Sent Events parser
441
+ error Error hierarchy with retry classification
442
+ client ProviderClient factory with model-aware routing
443
+ cli/ Terminal interface
444
+ main REPL loop, 45 slash commands, session management, image detection
445
+ render Streaming markdown renderer with safe-boundary buffering
446
+ input Tab completion, key bindings, bottom toolbar with auth badge
447
+ tui Welcome screen, inline tool display, line-numbered diff renderer
448
+ runtime/ Core engine
449
+ conversation Agentic loop: stream → tools (parallel Agent calls) → hooks → compact
450
+ session JSONL persistence with rotation, full conversation replay on resume
451
+ permissions Interactive [y/N/a] prompting, decision caching, persistence
452
+ config 3-layer merge with 6 MCP transport types
453
+ hooks Pre/post/failure hooks via subprocess
454
+ mcp/ Model Context Protocol (stdio, SSE, HTTP, WebSocket, SDK)
455
+ oauth PKCE flow with browser launch, callback server, token refresh
456
+ claude_subscription Claude Pro/Max OAuth (paste-style, claude.ai endpoints)
457
+ openai_subscription ChatGPT subscription OAuth (local-callback, auth.openai.com)
458
+ image Clipboard image grab (Win32/macOS/Linux), file loading, base64 encoding
459
+ prompt Compact system prompt builder (~1.2K tokens) with AXION.md walking
460
+ bash Live status spinner, stderr streaming, Ctrl+C cancellation
461
+ memory Persistent user/feedback/project/reference entries
462
+ git Status, log, diff, commit, branch, stash
463
+ skills Load .md skill files with YAML frontmatter
464
+ compact Heuristic + model-based intelligent compaction
465
+ lsp LSP JSON-RPC client (hover, definition, completion, symbols)
466
+ tasks Task registry with team assignment and cron scheduling
467
+ workers Worker state machine with trust gate and prompt delivery
468
+ policy_engine Condition combinators (And/Or/GreenAt), chained actions
469
+ recovery Failure recipes with async retry and escalation
470
+ tools/ 13 built-in tools + deferred schema loading (ToolSearch)
471
+ commands/ 45 slash commands with argument parsing and fuzzy suggestions
472
+ plugins/ Plugin manifest validation, lifecycle execution, persistence
473
+ telemetry/ Session tracing, JSONL/memory sinks, analytics events
474
+ compat_harness/ Upstream manifest extraction
475
+ ```
476
+
477
+ ## Configuration
478
+
479
+ ### Authentication
480
+
481
+ Two ways to authenticate, mix and match per provider:
482
+
483
+ ```bash
484
+ # API key (pay-per-token)
485
+ axion login # Anthropic — interactive picker
486
+ axion login --provider openai # OpenAI
487
+ axion login --provider xai # xAI
488
+
489
+ # Subscription OAuth (use existing plan)
490
+ axion login --subscription # Claude Pro/Max
491
+ axion login --subscription --provider openai # ChatGPT Plus/Pro/Business
492
+
493
+ # Logout
494
+ axion logout # clears Anthropic creds (key + OAuth)
495
+ axion logout --provider openai # clears OpenAI creds
496
+ ```
497
+
498
+ **Claude subscription** uses a paste-style flow (the same one Claude Code uses): `claude.ai` displays an authentication code on a success page, you paste it back into the terminal. No local server needed.
499
+
500
+ **ChatGPT subscription** uses a local-callback flow on port `1455` (the same one OpenAI's codex CLI uses): browser → `auth.openai.com` → automatic redirect back. Note that ChatGPT subscriptions only authorize the **Codex** models (Responses API). Free ChatGPT plans don't include Codex API access — Plus/Pro/Business do.
501
+
502
+ When you log in interactively without flags, Axion asks which path you want:
503
+
504
+ ```
505
+ $ axion login
506
+
507
+ Axion Code Login
508
+
509
+ How do you want to use Claude?
510
+
511
+ 1. Subscription (Claude Pro/Max) — uses your $20-200/mo plan
512
+ Best if you have a Claude subscription, no per-token billing
513
+ 2. API key (pay-per-token)
514
+ Best for occasional use or if you don't have a subscription
515
+
516
+ Choose [1/2]: 1
517
+ ```
518
+
519
+ Credentials are saved to `~/.axion/credentials/` (chmod 600). API keys are stored as plain `.key` files; OAuth tokens go in `*-oauth.json` with auto-refresh.
520
+
521
+ You can force API mode at runtime even when a subscription is saved:
522
+
523
+ ```bash
524
+ AXION_AUTH_MODE=api axion # one-off
525
+ # or inside the REPL:
526
+ /auth-mode api # rebuilds the provider client immediately
527
+ /auth-mode subscription # switches back
528
+ /auth-mode status # shows what's currently active for both providers
529
+ ```
530
+
531
+ ### Config File Hierarchy
532
+
533
+ Axion merges configuration from multiple sources (later overrides earlier):
534
+
535
+ 1. **User**: `~/.axion/settings.json`
536
+ 2. **Project**: `.axion.json` in repo root
537
+ 3. **Local**: `.axion/settings.json` (gitignored)
538
+ 4. **Local override**: `.axion/settings.local.json`
539
+ 5. **Environment**: `ANTHROPIC_API_KEY`, `AXION_MODEL`, `OLLAMA_BASE_URL`, etc.
540
+
541
+ ### AXION.md
542
+
543
+ Drop an `AXION.md` in your project root to give Axion context about your codebase:
544
+
545
+ ```markdown
546
+ # AXION.md
547
+
548
+ ## Project overview
549
+ This is a Django REST API for managing user accounts.
550
+
551
+ ## Build & test
552
+ - `python manage.py test`
553
+ - `ruff check .`
554
+
555
+ ## Code conventions
556
+ - Use type hints everywhere
557
+ - Prefer dataclasses over dicts
558
+ ```
559
+
560
+ Axion walks up the directory tree and includes all `AXION.md` files it finds — monorepos with nested instruction files at different levels work automatically. Files are deduplicated by content hash and truncated to a 12,000 character budget.
561
+
562
+ ## Plugin System
563
+
564
+ ```bash
565
+ # List plugins
566
+ axion plugins list
567
+
568
+ # Install from directory
569
+ axion plugins install ./my-plugin
570
+
571
+ # Enable/disable
572
+ axion plugins enable my-plugin
573
+ axion plugins disable my-plugin
574
+ ```
575
+
576
+ Plugins can provide tools, commands, and hooks. Manifests are validated for hook path existence, tool schema correctness, and lifecycle command availability.
577
+
578
+ ```json
579
+ {
580
+ "name": "my-plugin",
581
+ "version": "1.0.0",
582
+ "hooks": {
583
+ "preToolUse": ["./hooks/check.sh"],
584
+ "postToolUse": ["./hooks/log.sh"]
585
+ },
586
+ "tools": [
587
+ {
588
+ "name": "MyCustomTool",
589
+ "description": "Does something cool",
590
+ "inputSchema": { "type": "object", "properties": {} }
591
+ }
592
+ ]
593
+ }
594
+ ```
595
+
596
+ ## MCP Servers
597
+
598
+ Axion supports the [Model Context Protocol](https://modelcontextprotocol.io/) for connecting to external tool servers:
599
+
600
+ ```json
601
+ {
602
+ "mcpServers": {
603
+ "my-server": {
604
+ "type": "stdio",
605
+ "command": "node",
606
+ "args": ["./mcp-server/index.js"]
607
+ }
608
+ }
609
+ }
610
+ ```
611
+
612
+ Supports 6 transport types: stdio, SSE, HTTP, WebSocket, SDK, and managed proxy.
613
+
614
+ ## Terminal Theme
615
+
616
+ Axion looks best with a dark navy terminal. For the optimal look:
617
+
618
+ **Windows Terminal** — Add to your settings.json profiles:
619
+ ```json
620
+ {
621
+ "colorScheme": "One Half Dark",
622
+ "background": "#0a192f",
623
+ "font": { "face": "Cascadia Code", "size": 13 }
624
+ }
625
+ ```
626
+
627
+ **VS Code Terminal** — Add to settings.json:
628
+ ```json
629
+ {
630
+ "terminal.integrated.fontFamily": "Cascadia Code",
631
+ "workbench.colorCustomizations": {
632
+ "terminal.background": "#0a192f"
633
+ }
634
+ }
635
+ ```
636
+
637
+ Axion uses a **cyan/teal accent** (#00d4aa) with **mint green** (#64ffda) for success and **coral red** (#ff6b6b) for errors.
638
+
639
+ ## Memory System
640
+
641
+ Axion has a persistent memory system that stores context across conversations:
642
+
643
+ ```bash
644
+ # View memory entries
645
+ axion memory
646
+ ```
647
+
648
+ Memory types: `user` (preferences), `feedback` (corrections), `project` (decisions), `reference` (external links). Entries are stored as `.md` files with YAML frontmatter in `~/.axion/memory/`.
649
+
650
+ ## Development
651
+
652
+ ```bash
653
+ # Install dev dependencies
654
+ pip install -e ".[dev]"
655
+
656
+ # Run tests
657
+ pytest tests/ -v
658
+
659
+ # Lint
660
+ ruff check axion/ tests/
661
+
662
+ # Type check
663
+ mypy axion/
664
+ ```
665
+
666
+ ### CI/CD
667
+
668
+ GitHub Actions runs on every push and PR:
669
+ - Tests on **Python 3.11, 3.12, 3.13** across **Linux, Windows, macOS** (9 matrix jobs)
670
+ - Ruff linting
671
+ - CLI smoke tests (`axion --version`, `axion doctor`)
672
+
673
+ ## Stats
674
+
675
+ | Metric | Value |
676
+ |---|---|
677
+ | Python files | 111 |
678
+ | Lines of code | 23,216 |
679
+ | Unit tests | 166 |
680
+ | Integration tests | 7 (mock server) |
681
+ | Providers | 4 (Anthropic, OpenAI, xAI, Ollama) |
682
+ | API transports | 5 (Anthropic, OpenAI Chat Completions, OpenAI Responses, xAI, Ollama) |
683
+ | Auth modes | 4 (API key, Claude Pro/Max, ChatGPT Plus/Pro/Business, local) |
684
+ | Built-in tools | 13 |
685
+ | Slash commands | 47 |
686
+ | System prompt size | ~1,200 tokens (≈26x smaller than naive approach) |
687
+ | CI matrix | 9 jobs (3 OS x 3 Python) |
688
+ | Min Python | 3.11 |
689
+
690
+ ## Author
691
+
692
+ **Cyrus** — [osawayecyrus@gmail.com](mailto:osawayecyrus@gmail.com) — [@cypher125](https://github.com/cypher125)
693
+
694
+ ## Sponsoring
695
+
696
+ Axion is **free and open source** (MIT). It will always stay that way for individual developers — no per-seat licenses, no paid tiers gating features, no usage caps.
697
+
698
+ If Axion saves you time and you'd like to keep it healthy:
699
+
700
+ - **Star the repo** — visibility is the cheapest way to help
701
+ - **Sponsor** via [GitHub Sponsors](https://github.com/sponsors/cypher125) — covers maintenance time
702
+ - **Contribute** — issues, PRs, and custom slash commands all welcome
703
+ - **Tell people** — a tweet, a blog post, or a recommendation to a teammate goes a long way
704
+
705
+ For companies adopting Axion at scale, a hosted/team product is on the roadmap (shared sessions, audit logs, SSO). [Email me](mailto:osawayecyrus@gmail.com) if that's interesting and we can chat early-access.
706
+
707
+ ## License
708
+
709
+ [MIT](LICENSE) — do whatever you want, no warranty, attribution appreciated.