@codai/axiom-mcp 1.0.24 โ 2.0.0
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/LICENSE +22 -0
- package/README.md +124 -423
- package/dist/axm-lazy-WdJHPy6W.js +2 -0
- package/dist/axm-lazy.js +12776 -0
- package/dist/cli-main.js +26407 -0
- package/dist/cli.js +19 -0
- package/dist/gate-lazy.js +8979 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.js +904 -0
- package/package.json +72 -36
- package/spec/biome.json +6 -0
- package/spec/codai-tools.json +283 -0
- package/spec/tools.json +1966 -0
- package/dist/mcp-stdio.js +0 -368
- package/dist/postinstall.js +0 -31
- package/dist/server.js +0 -115
- package/dist/tools/fs-probe-write.js +0 -81
- package/scripts/prepublish.js +0 -52
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2025
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,423 +1,124 @@
|
|
|
1
|
-
# @codai/axiom-mcp
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Features**:
|
|
128
|
-
- โ
**POSIX paths**: All artifact paths use `/` (cross-platform)
|
|
129
|
-
- โ
**Deterministic**: Same IR + profile โ same manifest SHA256
|
|
130
|
-
- โ
**Profile-based**: Different cold start thresholds per profile
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
### 4. `axiom_check`
|
|
135
|
-
|
|
136
|
-
Run policy checks on generated manifest.
|
|
137
|
-
|
|
138
|
-
**Input**:
|
|
139
|
-
```typescript
|
|
140
|
-
{
|
|
141
|
-
manifest: Manifest,
|
|
142
|
-
ir?: IR // Optional for enhanced checking
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
**Output**:
|
|
147
|
-
```typescript
|
|
148
|
-
{
|
|
149
|
-
passed: boolean, // AND over all checks
|
|
150
|
-
report: {
|
|
151
|
-
checkName: string,
|
|
152
|
-
kind: "sla" | "policy",
|
|
153
|
-
passed: boolean,
|
|
154
|
-
details: {
|
|
155
|
-
expression: string,
|
|
156
|
-
evaluated: true, // Always true (real evaluation)
|
|
157
|
-
message: string,
|
|
158
|
-
measurements: {
|
|
159
|
-
cold_start_ms: number,
|
|
160
|
-
frontend_bundle_kb: number,
|
|
161
|
-
max_dependencies: number,
|
|
162
|
-
no_pii_in_artifacts: boolean,
|
|
163
|
-
// ... more metrics
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}[]
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**Features**:
|
|
171
|
-
- โ
**Real evaluation**: Deterministic metrics calculation
|
|
172
|
-
- โ
**Profile-aware**: Edge (50ms), Default (100ms), Budget (120ms)
|
|
173
|
-
- โ
**Transparent**: `evaluated:true` confirms real computation
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
### 5. `axiom_apply`
|
|
178
|
-
|
|
179
|
-
Apply manifest to filesystem or create Pull Request.
|
|
180
|
-
|
|
181
|
-
**Input**:
|
|
182
|
-
```typescript
|
|
183
|
-
{
|
|
184
|
-
manifest: Manifest,
|
|
185
|
-
mode: "fs" | "pr", // "fs" = filesystem, "pr" = pull request
|
|
186
|
-
repoPath?: string, // Default: process.cwd()
|
|
187
|
-
|
|
188
|
-
// PR mode only:
|
|
189
|
-
branchName?: string,
|
|
190
|
-
commitMessage?: string
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Manifest artifact structure (enhanced v1.0.17):
|
|
194
|
-
interface Artifact {
|
|
195
|
-
path: string; // POSIX relative path
|
|
196
|
-
kind: "file" | "report";
|
|
197
|
-
sha256: string; // Content hash for validation
|
|
198
|
-
bytes: number;
|
|
199
|
-
|
|
200
|
-
// โจ NEW in 1.0.17: Optional embedded content (store-less operation)
|
|
201
|
-
contentUtf8?: string; // UTF-8 text content (for README, configs)
|
|
202
|
-
contentBase64?: string; // Base64 binary content (for images, compiled assets)
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
**Output**:
|
|
207
|
-
```typescript
|
|
208
|
-
{
|
|
209
|
-
filesWritten: string[], // POSIX relative paths: "out/webapp/index.html"
|
|
210
|
-
summary: string
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**Features**:
|
|
215
|
-
- โ
**Versioned Artifact Cache**: `.axiom/cache/v1/<sha256>` (future-proof structure)
|
|
216
|
-
- โ
**3-Tier Content Fallback** (NEW in 1.0.17):
|
|
217
|
-
1. `artifact.contentUtf8` โ Buffer.from(utf-8) - **Fastest, no store lookup**
|
|
218
|
-
2. `artifact.contentBase64` โ Buffer.from(base64) - **Embedded binary content**
|
|
219
|
-
3. `artifactStore.get(sha256)` โ Cached content - **Fallback for large files**
|
|
220
|
-
4. Throws `ERR_ARTIFACT_CONTENT_MISSING` if all sources unavailable
|
|
221
|
-
- โ
**Real Filesystem Writes**: Physical `fs/promises.writeFile()` to `out/` directory
|
|
222
|
-
- โ
**SHA256 Validation**: Verifies file integrity after write (throws `ERR_SHA256_MISMATCH`)
|
|
223
|
-
- โ
**Auto-creates `./out/`**: No manual directory setup required
|
|
224
|
-
- โ
**POSIX Paths**: `filesWritten[]` use `/` on all platforms (guaranteed no backslash)
|
|
225
|
-
- โ
**Security**: Comprehensive protection:
|
|
226
|
-
- Blocks absolute paths (`/etc/passwd`)
|
|
227
|
-
- Blocks path traversal (`../../../sensitive`)
|
|
228
|
-
- Blocks mid-path traversal (`safe/../evil/hack.txt`)
|
|
229
|
-
- Validates all paths stay within `out/` directory
|
|
230
|
-
- โ
**Error Handling**: Clear errors with diagnostic context
|
|
231
|
-
|
|
232
|
-
**Workflow Integration**:
|
|
233
|
-
1. **Generate**: Creates manifest + optionally embeds small content OR caches by SHA256 in `.axiom/cache/v1/`
|
|
234
|
-
2. **Apply**:
|
|
235
|
-
- Tries embedded content first (fast path for README, configs)
|
|
236
|
-
- Falls back to cache lookup for large artifacts
|
|
237
|
-
- Writes real files to `out/` with SHA256 validation
|
|
238
|
-
3. **Deterministic**: Identical IR โ identical SHA256 โ identical files (verified post-write)
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|
|
242
|
-
## ๐ฏ Complete Workflow Example
|
|
243
|
-
|
|
244
|
-
```json
|
|
245
|
-
// 1. Parse .axm source
|
|
246
|
-
{
|
|
247
|
-
"tool": "axiom_parse",
|
|
248
|
-
"input": {
|
|
249
|
-
"source": "agent \"notes-app\" {\n capability net(\"firebase\")\n check sla \"fast\" { expect \"cold_start_ms <= 50\" }\n emit service \"web\"\n}"
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// 2. Validate IR
|
|
254
|
-
{
|
|
255
|
-
"tool": "axiom_validate",
|
|
256
|
-
"input": {
|
|
257
|
-
"ir": "<IR from step 1>"
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// 3. Generate artifacts (edge profile for performance)
|
|
262
|
-
{
|
|
263
|
-
"tool": "axiom_generate",
|
|
264
|
-
"input": {
|
|
265
|
-
"ir": "<IR from step 1>",
|
|
266
|
-
"profile": "edge"
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// 4. Check policies
|
|
271
|
-
{
|
|
272
|
-
"tool": "axiom_check",
|
|
273
|
-
"input": {
|
|
274
|
-
"manifest": "<manifest from step 3>",
|
|
275
|
-
"ir": "<IR from step 1>"
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// 5. Apply to filesystem
|
|
280
|
-
{
|
|
281
|
-
"tool": "axiom_apply",
|
|
282
|
-
"input": {
|
|
283
|
-
"manifest": "<manifest from step 3>",
|
|
284
|
-
"mode": "fs",
|
|
285
|
-
"repoPath": "."
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## ๐งช Validation & Testing
|
|
293
|
-
|
|
294
|
-
### Test Suite Status
|
|
295
|
-
|
|
296
|
-
```bash
|
|
297
|
-
cd packages/axiom-tests
|
|
298
|
-
npx vitest run
|
|
299
|
-
|
|
300
|
-
# Results:
|
|
301
|
-
# โ
31/31 tests passing
|
|
302
|
-
# โ
Duration: ~800ms
|
|
303
|
-
# โ
Coverage: 100% of critical paths
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### Key Test Validations
|
|
307
|
-
|
|
308
|
-
| Bug Fix | Test File | Status |
|
|
309
|
-
|---------|-----------|--------|
|
|
310
|
-
| POSIX paths | `path-normalization.test.ts` | โ
2/2 |
|
|
311
|
-
| Real check evaluator | `check-evaluator.test.ts` | โ
3/3 |
|
|
312
|
-
| Apply to FS | `apply-reporoot.test.ts` | โ
3/3 |
|
|
313
|
-
| Security guards | `apply-sandbox.test.ts` | โ
3/3 |
|
|
314
|
-
| Determinism | `determinism-edge.test.ts` | โ
3/3 |
|
|
315
|
-
| Parser completeness | `parser-roundtrip.test.ts` | โ
3/3 |
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
## ๐ Performance & Quality
|
|
320
|
-
|
|
321
|
-
| Metric | Value | Status |
|
|
322
|
-
|--------|-------|--------|
|
|
323
|
-
| Package Size | 4.1KB | โ
Optimized |
|
|
324
|
-
| Install Time | ~5s (97 packages) | โ
Good |
|
|
325
|
-
| Test Duration | 816ms | โ
Fast |
|
|
326
|
-
| Test Coverage | 31/31 (100%) | โ
Excellent |
|
|
327
|
-
| Determinism | Identical SHA256 | โ
Maintained |
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
## ๐ Security Features
|
|
332
|
-
|
|
333
|
-
1. **Path Traversal Protection**: Blocks `..` and absolute paths in `axiom_apply`
|
|
334
|
-
2. **SHA256 Validation**: Verifies file integrity after write
|
|
335
|
-
3. **POSIX Normalization**: Prevents OS-specific path exploits
|
|
336
|
-
4. **Input Validation**: Strict schema validation on all tool inputs
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## ๐ Documentation
|
|
341
|
-
|
|
342
|
-
- **API Reference**: See [docs/mcp_api.md](../../docs/mcp_api.md)
|
|
343
|
-
- **Syntax Spec**: See [docs/syntax_spec.md](../../docs/syntax_spec.md)
|
|
344
|
-
- **IR Spec**: See [docs/ir_spec.md](../../docs/ir_spec.md)
|
|
345
|
-
- **GO-NOGO Report**: See [GO-NOGO-AXIOM-1.0.9.md](../../GO-NOGO-AXIOM-1.0.9.md)
|
|
346
|
-
|
|
347
|
-
---
|
|
348
|
-
|
|
349
|
-
## ๐ Troubleshooting
|
|
350
|
-
|
|
351
|
-
### Issue: "EUNSUPPORTEDPROTOCOL" error
|
|
352
|
-
|
|
353
|
-
**Problem**: Older version (1.0.7) used `workspace:*` dependencies
|
|
354
|
-
**Solution**: Update to latest version
|
|
355
|
-
```bash
|
|
356
|
-
npm install @codai/axiom-mcp@latest
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Issue: MCP server not starting in VS Code
|
|
360
|
-
|
|
361
|
-
**Check**:
|
|
362
|
-
1. Verify `.vscode/mcp.json` configuration
|
|
363
|
-
2. Restart VS Code MCP extension
|
|
364
|
-
3. Check VS Code Output panel (MCP logs)
|
|
365
|
-
|
|
366
|
-
**Debug**:
|
|
367
|
-
```bash
|
|
368
|
-
npx @codai/axiom-mcp@latest
|
|
369
|
-
# Should output: "AXIOM MCP Server running on stdio"
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### Issue: Files not written to `./out/`
|
|
373
|
-
|
|
374
|
-
**Check**:
|
|
375
|
-
1. Verify `repoPath` is correct (default: `process.cwd()`)
|
|
376
|
-
2. Ensure write permissions for directory
|
|
377
|
-
3. Check `filesWritten[]` in response for actual paths
|
|
378
|
-
|
|
379
|
-
---
|
|
380
|
-
|
|
381
|
-
## ๐ Version History
|
|
382
|
-
|
|
383
|
-
### v1.0.9 (2025-10-21) - **CURRENT**
|
|
384
|
-
- โ
Complete MCP fix validation
|
|
385
|
-
- โ
GO-NOGO report with comprehensive evidence
|
|
386
|
-
- โ
All 3 critical bugs confirmed fixed
|
|
387
|
-
|
|
388
|
-
### v1.0.8 (2025-10-21)
|
|
389
|
-
- โ
Fixed `workspace:*` npm compatibility
|
|
390
|
-
- โ
Published internal packages with `internal` tag
|
|
391
|
-
|
|
392
|
-
### v1.0.1 (2025-10-20)
|
|
393
|
-
- โ
POSIX path normalization
|
|
394
|
-
- โ
Real check evaluator
|
|
395
|
-
- โ
Complete .axm parser
|
|
396
|
-
- โ
Apply defaults to `process.cwd()`
|
|
397
|
-
- โ
Determinism enhancements
|
|
398
|
-
|
|
399
|
-
---
|
|
400
|
-
|
|
401
|
-
## ๐ฆ Package Information
|
|
402
|
-
|
|
403
|
-
- **Name**: `@codai/axiom-mcp`
|
|
404
|
-
- **Version**: `1.0.9`
|
|
405
|
-
- **License**: MIT
|
|
406
|
-
- **Repository**: https://github.com/dragoscv/axiom
|
|
407
|
-
- **npm**: https://www.npmjs.com/package/@codai/axiom-mcp
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
## ๐ค Contributing
|
|
412
|
-
|
|
413
|
-
See main repository: https://github.com/dragoscv/axiom
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## ๐ License
|
|
418
|
-
|
|
419
|
-
MIT License - see [LICENSE](../../LICENSE) for details
|
|
420
|
-
|
|
421
|
-
---
|
|
422
|
-
|
|
423
|
-
**Built with ๐ by the AXIOM team**
|
|
1
|
+
# @codai/axiom-mcp
|
|
2
|
+
|
|
3
|
+
MCP server (stdio) and CLI for AXIOM v2 โ the transactional write gate for coding agents:
|
|
4
|
+
`Plan` โ canonical `ManifestBundle` โ set-level checks โ hash-gated two-phase `apply` โ journal.
|
|
5
|
+
`dist/cli.js` (thin entry) + `dist/cli-main.js` (lazy-loaded engines, SDK and zod bundled in); no runtime dependencies.
|
|
6
|
+
|
|
7
|
+
## Install & run
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @codai/axiom-mcp mcp --root /abs/path/to/repo # stdio MCP server
|
|
11
|
+
npx @codai/axiom-mcp --help # CLI verbs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`--root` may repeat. Every tool `root` argument must equal or lie inside one of them; with exactly one
|
|
15
|
+
root it is the default. There is **no** env-var or `cwd` fallback (`ERR_ROOT_REQUIRED` / `ERR_ROOT_NOT_ALLOWED`).
|
|
16
|
+
|
|
17
|
+
### VS Code โ `.vscode/mcp.json`
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"servers": {
|
|
22
|
+
"axiom": {
|
|
23
|
+
"type": "stdio",
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["-y", "@codai/axiom-mcp", "mcp", "--root", "${workspaceFolder}"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Claude Desktop โ `claude_desktop_config.json`
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"axiom": { "command": "npx", "args": ["-y", "@codai/axiom-mcp", "mcp", "--root", "/abs/path/to/repo"] }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
| tool | risk | input | output |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| `axiom_plan_validate` | READ | `{ plan }` | `{ ok, planDigest?, errors[] }` |
|
|
46
|
+
| `axiom_plan_compile` | ACT | `{ plan, store?: inline\|cas, root? }` | `ManifestBundle` (writes only under `<root>/.axiom/` โ CAS blobs and the stored manifest โ when a root is given) |
|
|
47
|
+
| `axiom_manifest_verify` | READ | `{ bundle }` | `{ ok, manifestDigest, canonical, signed, missing[], errors[] }` |
|
|
48
|
+
| `axiom_check` | READ | `{ bundle, profile?, root? }` | `CheckReport` (`verdict: pass\|fail\|error`) |
|
|
49
|
+
| `axiom_apply_dry_run` | READ | `{ bundle, root, profile? }` | `ApplyResult{mode:"dry-run", diff}` |
|
|
50
|
+
| `axiom_apply` | SENSITIVE | `{ bundle, root, profile?, confirmDigest }` | `ApplyResult` |
|
|
51
|
+
| `axiom_rollback` | SENSITIVE | `{ root, manifestDigest }` | `{ status:"rolled-back", phase, steps }` |
|
|
52
|
+
| `axiom_manifest_diff` | READ | `{ a: bundle\|"sha256:โฆ", b }` | `{ added[], removed[], changed[] }` |
|
|
53
|
+
| `axiom_axm_parse` | READ | `{ source }` (`.axm` text) | `{ plan?, diagnostics: [{ severity, code, message, range: { start: {line, column}, end } }] }` |
|
|
54
|
+
| `axiom_roots_list` | READ | `{}` | `{ roots: [{ path, writable, hasGit }] }` |
|
|
55
|
+
|
|
56
|
+
Every tool carries MCP `annotations` (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`)
|
|
57
|
+
and an `outputSchema`; `structuredContent` is the full result, `content[0].text` a small summary (digest,
|
|
58
|
+
verdict, counts, first 20 findings). Errors come back as `isError: true` with `{ code, message, path? }`
|
|
59
|
+
from the closed `ERROR_CODES` enum โ a handler never throws. `spec/tools.json` is generated from the same
|
|
60
|
+
registry (`pnpm build:spec`) and guarded by a parity test. `spec/codai-tools.json` is the same registry in
|
|
61
|
+
codai's `packages/agent-core/spec/tools-v2.json` entry shape (`{ name, risk, description, parameters }`) โ
|
|
62
|
+
see `docs/integration/codai.md`.
|
|
63
|
+
|
|
64
|
+
Resources: `axiom://manifest/{sha}`, `axiom://report/{sha}`, `axiom://applied/{sha}`,
|
|
65
|
+
`axiom://profile/{name}`, `axiom://schema/{Plan|Manifest|ManifestBundle|CheckReport|ApplyResult|Profile|Journal}`.
|
|
66
|
+
|
|
67
|
+
## Trust model
|
|
68
|
+
|
|
69
|
+
- Roots are realpath'd at startup, must be directories, and the set is frozen. Requested roots are
|
|
70
|
+
realpath'd too (case-insensitive containment on Windows); anything outside is a hard error.
|
|
71
|
+
- `axiom_apply` requires `confirmDigest === bundle.manifestDigest` โ echo the digest you saw in dry-run.
|
|
72
|
+
Pre-apply checks run against the profile (default `default`, or `<root>/.axiom/profiles/<name>.json`);
|
|
73
|
+
a non-`pass` verdict aborts with `ERR_CHECKS_FAILED` before any write.
|
|
74
|
+
- Payloads over 4 MiB are rejected up front (`ERR_BUNDLE_TOO_LARGE`).
|
|
75
|
+
- `.axiom/lock` makes apply single-writer per root; the journal makes it crash-safe and reversible.
|
|
76
|
+
- stdout carries only JSON-RPC. Logs are JSON lines on stderr (`--log-level error|warn|info|debug`, default `warn`).
|
|
77
|
+
- External guards (`guard.external`) are **off** unless the process is started with `--allow-guards`
|
|
78
|
+
*and* the profile sets `facts.allowGuards: true`. Relative commands must live under `<root>/scripts/`;
|
|
79
|
+
absolute ones must be listed exactly via `--guard-allowlist <abs>` (repeatable). Guards are spawned
|
|
80
|
+
with an args array (never a shell), a scrubbed environment, a wall-clock timeout, and must print
|
|
81
|
+
`GuardOutput` JSON โ see `docs/checks.md`.
|
|
82
|
+
|
|
83
|
+
## CLI
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
axiom mcp [--root <abs>]... [--allow-guards] [--guard-allowlist <abs>]... [--log-level warn]
|
|
87
|
+
axiom compile <plan.json> [-o out.json] [--store cas --root .]
|
|
88
|
+
axiom verify <bundle.json>
|
|
89
|
+
axiom check <bundle.json> --root . [--profile p] [--json] [--allow-guards] [--guard-allowlist <abs>]...
|
|
90
|
+
axiom apply <bundle.json> --root . [--dry-run] [--profile p] [--confirm <digest>] [--allow-guards] [--guard-allowlist <abs>]...
|
|
91
|
+
axiom rollback <digest> --root .
|
|
92
|
+
axiom diff <a.json> <b.json>
|
|
93
|
+
axiom schema <Plan|Manifest|ManifestBundle|CheckReport|ApplyResult|Profile|Journal>
|
|
94
|
+
axiom gate --stdin [--root <dir>] [--profile <file>] [--strict] [--log-level warn]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Exit codes: `0` ok ยท `1` verdict fail / apply failed ยท `2` usage or error. Non-`mcp` verbs print JSON to stdout.
|
|
98
|
+
|
|
99
|
+
## Hook mode โ `axiom gate --stdin`
|
|
100
|
+
|
|
101
|
+
A PreToolUse hook for Claude Code, Copilot CLI and VS Code agent hooks. It reads **one** harness
|
|
102
|
+
payload from stdin (both `{tool_name, tool_input, cwd}` and `{toolName, toolArgs, cwd}` casings;
|
|
103
|
+
`toolArgs` may be a JSON string), extracts the write target(s) of `Write|Edit|MultiEdit|NotebookEdit`,
|
|
104
|
+
`create_file|replace_string_in_file|insert_edit_into_file|apply_patch|multi_replace_string_in_file|edit_notebook_file`
|
|
105
|
+
and generic `write|edit`, and runs **only** the fast predicates: containment + `RelPath` rules
|
|
106
|
+
(`..`, `CON`, NTFS ADS โ `ERR_CONTAINMENT` / `ERR_PATH_*`), `path.deny`, `path.allow`,
|
|
107
|
+
`content.noSecrets` and `content.maxBytes` on the new content when the payload carries it.
|
|
108
|
+
|
|
109
|
+
| outcome | exit | stdout | stderr |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| allow / unknown tool | `0` | โ | โ |
|
|
112
|
+
| deny | `2` | `{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"โฆ"}}` | `AXIOM GATE DENY <code>: <reason> (<relpath>)` |
|
|
113
|
+
| malformed payload, stdin timeout (2 s), internal error | `0` (**fail open**) | โ | `AXIOM GATE WARN: โฆ` |
|
|
114
|
+
| same, with `--strict` | `2` | deny JSON | `AXIOM GATE DENY ERR_INTERNAL: โฆ` |
|
|
115
|
+
|
|
116
|
+
Root = payload `cwd`, else `--root`, else the process cwd (the hook is the one place where cwd is
|
|
117
|
+
acceptable: the harness spawns the hook in the project directory and owns that value).
|
|
118
|
+
Profile = `--profile <file>` โ `<root>/.axiom/gate-profile.json` โ `~/.axiom/gate-profile.json` โ
|
|
119
|
+
built-in `{ deny: [".git/**", ".axiom/**", "**/*.lock", "pnpm-lock.yaml", ".env", ".env.*", "**/node_modules/**"], noSecrets: true }`.
|
|
120
|
+
Schema: `{ deny: string[], allow?: string[], noSecrets: boolean, maxBytes?: number }` (strict).
|
|
121
|
+
|
|
122
|
+
`gate` is a separate lazy chunk (`dist/gate-lazy.js`, no MCP SDK): in-process p95 โ 5 ms per payload,
|
|
123
|
+
end-to-end โ 150โ200 ms including node startup; `check-gate-latency` guards p95 โค 250 ms.
|
|
124
|
+
Wiring for each harness is in [`docs/hooks.md`](../../docs/hooks.md).
|