axor-cli 0.1.0__tar.gz

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.
@@ -0,0 +1,107 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*.*.*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ test:
12
+ name: Test (Python ${{ matrix.python-version }})
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Checkout axor-core
22
+ uses: actions/checkout@v4
23
+ with:
24
+ repository: ${{ github.repository_owner }}/axor-core
25
+ path: axor-core
26
+
27
+ - name: Checkout axor-claude
28
+ uses: actions/checkout@v4
29
+ with:
30
+ repository: ${{ github.repository_owner }}/axor-claude
31
+ path: axor-claude
32
+
33
+ - uses: actions/setup-python@v5
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+ cache: pip
37
+
38
+ - name: Install
39
+ run: |
40
+ pip install -e axor-core/
41
+ pip install -e axor-claude/
42
+ pip install -e ".[dev]"
43
+
44
+ - name: Check entrypoint
45
+ run: |
46
+ python - << 'EOF'
47
+ import tomllib
48
+ with open("pyproject.toml", "rb") as f:
49
+ cfg = tomllib.load(f)
50
+ scripts = cfg["project"]["scripts"]
51
+ assert "axor" in scripts, "axor entrypoint missing"
52
+ assert scripts["axor"] == "axor_cli.main:main"
53
+ print("✓ axor entrypoint registered")
54
+ EOF
55
+
56
+ - name: Run unit tests
57
+ run: pytest tests/unit/ -v --tb=short
58
+
59
+ publish:
60
+ name: Publish to PyPI
61
+ needs: test
62
+ runs-on: ubuntu-latest
63
+ if: startsWith(github.ref, 'refs/tags/v')
64
+ environment: pypi
65
+
66
+ permissions:
67
+ id-token: write
68
+
69
+ steps:
70
+ - uses: actions/checkout@v4
71
+
72
+ - uses: actions/setup-python@v5
73
+ with:
74
+ python-version: "3.12"
75
+
76
+ - name: Verify tag matches package version
77
+ run: |
78
+ python - << 'EOF'
79
+ import pathlib
80
+ import re
81
+ import sys
82
+ import tomllib
83
+
84
+ ref = "${{ github.ref_name }}"
85
+ m = re.fullmatch(r"v(\d+\.\d+\.\d+)", ref)
86
+ if not m:
87
+ print(f"Tag {ref!r} must match vX.Y.Z")
88
+ sys.exit(1)
89
+
90
+ tag_version = m.group(1)
91
+ data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
92
+ pkg_version = data["project"]["version"]
93
+
94
+ if tag_version != pkg_version:
95
+ print(f"Version mismatch: tag={tag_version}, pyproject={pkg_version}")
96
+ sys.exit(1)
97
+
98
+ print(f"Version check passed: {pkg_version}")
99
+ EOF
100
+
101
+ - name: Build
102
+ run: |
103
+ pip install hatchling build
104
+ python -m build
105
+
106
+ - name: Publish to PyPI
107
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .env
8
+ .pytest_cache/
9
+ .coverage
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2025-04-12
4
+
5
+ Initial release.
6
+
7
+ ### Added
8
+ - Core governance kernel (axor-core)
9
+ - Claude Code adapter (axor-claude)
10
+ - CLI with interactive REPL (axor-cli)
11
+ - Dynamic policy selection (7-policy matrix)
12
+ - ContextManager with 11 waste categories
13
+ - ToolResultBus for async tool loop
14
+ - Federation via spawn_child with child_executor
15
+ - CancelToken cooperative cancellation
16
+ - BudgetPolicyEngine (60/80/90/95% thresholds)
17
+ - TraceCollector with lineage (17 event kinds)
@@ -0,0 +1,40 @@
1
+ # Contributing to axor-cli
2
+
3
+ ## Setup
4
+
5
+ ```bash
6
+ git clone https://github.com/your-org/axor-cli
7
+ cd axor-cli
8
+ python -m venv .venv && source .venv/bin/activate
9
+ pip install -e ".[claude,dev]"
10
+ ```
11
+
12
+ ## Running tests
13
+
14
+ ```bash
15
+ pytest tests/unit/ # no API key needed
16
+ ```
17
+
18
+ ## Architecture
19
+
20
+ axor-cli is a thin shell around axor-core + adapters:
21
+
22
+ - `auth.py` — key management only, no business logic
23
+ - `adapters.py` — lazy imports, delegates to adapter's make_session()
24
+ - `display.py` — terminal output only, no execution logic
25
+ - `streaming.py` — connects GovernedSession to terminal display
26
+ - `main.py` — REPL + argument parsing
27
+
28
+ **No governance logic in CLI.** Policy, context, capabilities — all in axor-core.
29
+
30
+ ## Adding an adapter
31
+
32
+ 1. Add entry to `_REGISTRY` in `adapters.py`
33
+ 2. Add env var to `_ENV_VARS` in `auth.py`
34
+ 3. Adapter package must expose `make_session(**kwargs) -> GovernedSession`
35
+
36
+ ## Pull request checklist
37
+
38
+ - [ ] `pytest tests/unit/` passes
39
+ - [ ] No governance logic added to CLI
40
+ - [ ] New adapter registered in both `adapters.py` and `auth.py`
axor_cli-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Axor Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: axor-cli
3
+ Version: 0.1.0
4
+ Summary: CLI for axor-core governance kernel — governed agent sessions in your terminal
5
+ Project-URL: Bug Tracker, https://github.com/Bucha11/axor-cli/issues
6
+ Project-URL: Changelog, https://github.com/Bucha11/axor-cli/releases
7
+ Project-URL: Repository, https://github.com/Bucha11/axor-cli
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,axor,claude,cli,governance,llm
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Classifier: Topic :: Terminals
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: axor-core>=0.1.0
21
+ Provides-Extra: all
22
+ Requires-Dist: axor-claude>=0.1.0; extra == 'all'
23
+ Requires-Dist: axor-openai>=0.1.0; extra == 'all'
24
+ Provides-Extra: claude
25
+ Requires-Dist: axor-claude>=0.1.0; extra == 'claude'
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Provides-Extra: openai
30
+ Requires-Dist: axor-openai>=0.1.0; extra == 'openai'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # axor-cli
34
+
35
+ [![CI](https://github.com/Bucha11/axor-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Bucha11/axor-cli/actions/workflows/ci.yml)
36
+ [![PyPI](https://img.shields.io/pypi/v/axor-cli)](https://pypi.org/project/axor-cli/)
37
+ [![Python](https://img.shields.io/pypi/pyversions/axor-cli)](https://pypi.org/project/axor-cli/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
39
+
40
+
41
+ **Governed agent sessions in your terminal.**
42
+
43
+ Run Claude (or other LLMs) under axor-core governance — controlled context, explicit tool permissions, token optimization, and full audit trail.
44
+
45
+ ---
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ # CLI + Claude adapter
51
+ pip install axor-cli[claude]
52
+
53
+ # or step by step
54
+ pip install axor-cli
55
+ pip install axor-claude
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Quick Start
61
+
62
+ ```bash
63
+ # Interactive REPL
64
+ axor claude
65
+
66
+ # Single task and exit
67
+ axor claude "refactor the auth module"
68
+
69
+ # With options
70
+ axor claude --policy readonly "review this PR for security issues"
71
+ axor claude --limit 100000 "migrate the entire codebase to Go"
72
+ axor claude --model claude-opus-4-5 "design the new architecture"
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Authentication
78
+
79
+ On first run, axor asks for your API key and saves it to `~/.axor/config.toml` (permissions: 600):
80
+
81
+ ```
82
+ $ axor claude
83
+
84
+ No API key found for 'claude'.
85
+ (checked: --api-key flag, ANTHROPIC_API_KEY env var, ~/.axor/config.toml)
86
+
87
+ Anthropic API key (hidden): ****
88
+ Save to ~/.axor/config.toml for future sessions? [Y/n]: y
89
+ ✓ Key saved to ~/.axor/config.toml (permissions: 600)
90
+ ```
91
+
92
+ Key priority (highest to lowest):
93
+
94
+ | Source | When used |
95
+ |--------|-----------|
96
+ | `--api-key` flag | One-off override, never saved |
97
+ | `ANTHROPIC_API_KEY` env var | CI/CD, containers |
98
+ | `~/.axor/config.toml` | Persistent, set via `/auth` |
99
+
100
+ Manage saved keys with `/auth` in the REPL:
101
+
102
+ ```
103
+ > /auth # set or update key (prompts, then saves)
104
+ > /auth --show # show where key is loaded from (never shows the key)
105
+ > /auth --clear # remove saved key
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Interactive REPL
111
+
112
+ ```
113
+ $ axor claude
114
+ axor v0.1.0 │ adapter: claude │ model: claude-sonnet-4-5
115
+ Type a task, a /command, or 'exit' to quit.
116
+
117
+ > refactor the auth module to add rate limiting
118
+ ↳ read(path='auth.py') → def authenticate(token):…
119
+ ↳ write(path='auth.py') → …
120
+ ✓ done │ policy: moderate_mutative │ tokens: 1,247 (in: 800 out: 447)
121
+
122
+ > /cost
123
+ → Tokens spent this session: 1,247
124
+
125
+ > /compact
126
+ → Context compaction requested — will apply on next execution.
127
+
128
+ > exit
129
+ → Bye.
130
+ ```
131
+
132
+ ### REPL commands
133
+
134
+ | Command | Class | Description |
135
+ |---------|-------|-------------|
136
+ | `/auth` | built-in | Set or update API key |
137
+ | `/auth --clear` | built-in | Remove saved key |
138
+ | `/auth --show` | built-in | Show key source (never the key itself) |
139
+ | `/model` | built-in | List available models |
140
+ | `/help` | built-in | All commands |
141
+ | `/cost` | governed | Token usage for this session |
142
+ | `/policy` | governed | Last execution policy |
143
+ | `/compact` | governed | Compress context |
144
+ | `/status` | governed | Session overview |
145
+ | `/tools` | governed | Tools available to current policy |
146
+ | `exit` / `quit` / `^D` | — | Exit |
147
+
148
+ Governed commands (`/cost`, `/policy`, etc.) are handled by axor-core — they never reach the executor.
149
+
150
+ ---
151
+
152
+ ## CLI options
153
+
154
+ ```
155
+ axor <adapter> [task] [options]
156
+
157
+ Arguments:
158
+ adapter Adapter: claude, openai
159
+ task Single task — runs and exits (skips REPL)
160
+
161
+ Options:
162
+ -p, --policy Preset: readonly, sandboxed, standard, federated
163
+ -l, --limit Soft token limit (budget optimization signals)
164
+ -m, --model Model override (e.g. claude-opus-4-5)
165
+ --api-key API key for this session (never saved)
166
+ --tools Tools to enable (default: read write bash search glob)
167
+ --no-skills Skip CLAUDE.md and .claude/skills/
168
+ --no-plugins Skip .claude/plugins/
169
+ --list-adapters Show installed adapters and exit
170
+ --version Show version
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Examples
176
+
177
+ ```bash
178
+ # Analysis only — no writes, no bash
179
+ axor claude --policy readonly "find all security issues in auth.py"
180
+
181
+ # Specific tools only
182
+ axor claude --tools read search "find all TODO comments"
183
+
184
+ # Large migration with budget
185
+ axor claude --limit 200000 "rewrite the API layer to use async/await"
186
+
187
+ # Specific model
188
+ axor claude --model claude-opus-4-5 "design the new microservices architecture"
189
+
190
+ # No extension loading (faster startup)
191
+ axor claude --no-skills --no-plugins "quick question"
192
+
193
+ # CI — reads key from env, single task, exits
194
+ ANTHROPIC_API_KEY=sk-ant-... axor claude "run code review"
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Adapters
200
+
201
+ ```bash
202
+ axor --list-adapters
203
+
204
+ Available adapters:
205
+ claude installed
206
+ openai not installed → pip install axor-openai
207
+ ```
208
+
209
+ Each adapter package must expose `make_session(**kwargs) -> GovernedSession`.
210
+
211
+ ---
212
+
213
+ ## Streaming output
214
+
215
+ When an adapter supports streaming (e.g. `axor-claude`), text is printed to the terminal as it arrives — no waiting for the full response. A spinner shows while Claude is thinking.
216
+
217
+ Non-streaming adapters print the full output when execution completes.
218
+
219
+ ---
220
+
221
+ ## Config file
222
+
223
+ `~/.axor/config.toml` — auto-created with `chmod 600`:
224
+
225
+ ```toml
226
+ [claude]
227
+ api_key = "sk-ant-..."
228
+
229
+ [openai]
230
+ api_key = "sk-..."
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Repository structure
236
+
237
+ ```
238
+ axor-cli/
239
+ ├── axor_cli/
240
+ │ ├── main.py CLI entrypoint, REPL loop, argument parsing
241
+ │ ├── auth.py Key management — ~/.axor/config.toml, priority chain
242
+ │ ├── adapters.py Adapter registry, lazy imports, build_session()
243
+ │ ├── display.py Terminal formatting — color, spinner, streaming output
244
+ │ ├── streaming.py Connects GovernedSession to terminal display
245
+ │ └── _version.py
246
+ └── tests/
247
+ ├── conftest.py tmp_home fixture, anthropic mock
248
+ └── unit/
249
+ ├── test_auth.py 11 tests — config file, permissions, priority
250
+ ├── test_adapters.py 8 tests — registry, availability, session build
251
+ ├── test_display.py display formatting
252
+ └── test_streaming.py 11 tests — output, callback, error, policy override
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Running tests
258
+
259
+ ```bash
260
+ pytest tests/unit/ # no API key needed, anthropic SDK mocked
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Requirements
266
+
267
+ - Python 3.11+
268
+ - `axor-core >= 0.1.0`
269
+ - At least one adapter: `axor-claude` or `axor-openai`
270
+
271
+ ---
272
+
273
+ ## License
274
+
275
+ MIT