@mwillbanks/ast-mcp 0.2.2 → 0.3.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/CONTRIBUTING.md +13 -0
- package/README.md +18 -16
- package/dist/ast-mcp.js +183 -137
- package/dist/ast-mcp.js.map +58 -42
- package/package.json +17 -11
- package/src/ast-bro/capability.ts +20 -10
- package/src/ast-bro/tools.json +22 -2
- package/src/cli.ts +10 -7
- package/src/config-cli.ts +166 -19
- package/src/config-migrate.ts +223 -0
- package/src/config-registry.ts +321 -0
- package/src/config-schema-common.ts +81 -0
- package/src/config-v2-schema.ts +97 -0
- package/src/config.ts +346 -148
- package/src/helpers/ast-bro.ts +1 -7
- package/src/helpers/config.ts +7 -0
- package/src/helpers/installer.ts +8 -0
- package/src/helpers/mcp-schema.ts +98 -4
- package/src/host-smoke.ts +182 -0
- package/src/http.ts +8 -3
- package/src/installer-transport.ts +6 -4
- package/src/installer.ts +192 -51
- package/src/patch/engine.ts +555 -279
- package/src/patch/languages.ts +9 -0
- package/src/patch/strategy/aiderBlock.ts +110 -0
- package/src/patch/strategy/ast.ts +170 -0
- package/src/patch/strategy.ts +61 -0
- package/src/runtime/approval.ts +438 -0
- package/src/runtime/dependencies.ts +1 -1
- package/src/runtime/document-inspection.ts +78 -0
- package/src/runtime/file-capabilities.ts +250 -0
- package/src/runtime/file-delete.ts +110 -37
- package/src/runtime/file-read.ts +142 -14
- package/src/runtime/file-rename.ts +5 -2
- package/src/runtime/format.ts +65 -27
- package/src/runtime/path-policy.ts +557 -0
- package/src/runtime/path-utils.ts +40 -0
- package/src/runtime/paths.ts +142 -44
- package/src/server.ts +2 -1
- package/src/tools/ast-bro.ts +196 -75
- package/src/tools/configuration.ts +450 -0
- package/src/tools/configured.ts +49 -21
- package/src/tools/files.ts +168 -61
- package/src/tools/index.ts +2 -0
- package/src/tools/lifecycle.ts +82 -38
- package/templates/AGENTS.md +13 -15
- package/templates/skills/ast-mcp/SKILL.md +28 -20
- package/templates/skills/ast-mcp/evals/evals.json +221 -9
- package/templates/skills/ast-mcp/evals/score.ts +80 -0
- package/templates/skills/ast-mcp/evals/semantic.ts +3 -1
- package/templates/skills/ast-mcp/references/installation.md +12 -12
- package/templates/skills/ast-mcp/references/patch-state-machine.md +15 -14
- package/templates/skills/ast-mcp/references/tool-catalog.md +13 -7
- package/templates/skills/ast-mcp/scripts/check-install.ts +8 -17
- package/src/ast-bro/rewrite-capability.ts +0 -9
|
@@ -15,33 +15,41 @@ Treat ast-mcp as the only code-intelligence and filesystem boundary. Do not call
|
|
|
15
15
|
|
|
16
16
|
## Explore before editing
|
|
17
17
|
|
|
18
|
-
-
|
|
18
|
+
- Start unfamiliar work with `digest`, use `map` for one file's shape, and use `show` for exact symbols. When a file workflow is uncertain, call `file_capabilities` once for all relevant paths; `file_read`, `run`, and `file_patch` enforce that same result.
|
|
19
19
|
- Use `search` when names are unknown and `find_related` for code similar to a known location.
|
|
20
20
|
- Use `context` for a symbol plus nearby calls; use `impact` before changing a public or shared symbol.
|
|
21
21
|
- Use `deps`, `reverse_deps`, `graph`, or `cycles` for module relationships.
|
|
22
22
|
- Use `callers`, `callees`, or `trace` for execution flow; use `implements` for type hierarchies.
|
|
23
23
|
- Use `surface` for exported API shape, `index` for search-index maintenance, and `squeeze` only for repetitive logs or text.
|
|
24
|
-
-
|
|
24
|
+
- `file_read` accepts an agent-selected `mode`: `ast` returns a source map/requested symbols or RFC 6901-selected structured-document values, `text` returns a bounded zero-based end-exclusive slice, and `auto` prefers AST when supported. Use `symbols` for source and `selectors` for JSON, JSONC, TOML, or YAML. Text mode remains available for AST-capable files when exact source text is necessary. Batch multiple files in one call.
|
|
25
25
|
- Use ast-mcp intelligence as the primary repository search route. Never invoke `ast-grep` directly and never use `sed` for repository reads or edits. `rg` is permitted only as a discouraged fallback for exact literals, identifiers, non-AST formats, or discovery unavailable through ast-mcp; external transcript analysis, Git metadata, validation, and live-runtime reproduction are exceptions.
|
|
26
26
|
|
|
27
27
|
Read [tool-catalog.md](references/tool-catalog.md) for exact arguments and combinations.
|
|
28
28
|
|
|
29
|
+
## Batch and parallelize safely
|
|
30
|
+
|
|
31
|
+
- Batch paths, symbols, selectors, and keyed files into one call whenever the tool schema supports them. Prefer one bounded multi-target call over repeated single-target calls.
|
|
32
|
+
- Issue independent read-only calls in the same model turn or host executor, and return all parallel results together when the host protocol requires it.
|
|
33
|
+
- Keep each AST intelligence request within one project root. Split cross-root work into root-specific calls; independent read-only calls may run in parallel.
|
|
34
|
+
- Keep dependent and overlapping work sequential: inspect, preview, hash, then mutate. Never parallelize writes that can touch the same path, configuration generation, or dependency chain.
|
|
35
|
+
- Call `config_status` before the first mutation when formatter selection, path policy, configuration health, or generation is uncertain. Use `policy_check` to preflight read, write, and delete decisions without side effects.
|
|
36
|
+
- Use `document_query` for bounded JSON, JSONC, TOML, and YAML inspection instead of attempting whole-file reads of structured manifests.
|
|
37
|
+
|
|
29
38
|
## Mutate through declared file batches
|
|
30
39
|
|
|
31
|
-
1. Inspect
|
|
32
|
-
2.
|
|
33
|
-
3.
|
|
34
|
-
4.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
The OS temporary directory is an allowed file-operation root by default. Set `safety.allow_temp_directory = false` to disable it. `safety.allow_any_path = true` is an explicit unrestricted mode for file tools; do not enable it merely to avoid configuring a workspace root.
|
|
40
|
+
1. Inspect with `map`, `show`, `context`, a bounded `run`, or `file_read`. Call `file_capabilities` before choosing a read or patch method when intrinsic support or effective configuration is uncertain.
|
|
41
|
+
2. Select `file_read.mode` explicitly when intent matters. Use `ast` with `symbols` for source structure or with RFC 6901 `selectors` for structured documents; use `text` for a bounded exact slice. `auto` is suitable when AST-first behavior is desired.
|
|
42
|
+
3. Select `file_patch.patchStrategy` per file. Prefer `ast` for semantic, repeated, or structurally anchored changes; prefer `aider_block` for a small exact text replacement with unique context. Both remain selectable for parseable source whenever `file_capabilities` reports them, and configuration may narrow the effective choices.
|
|
43
|
+
4. Preview every AST rule with `run({ pattern, paths: [filePath], lang?, json: true })`; inspect all matches and reject capped output before mutation. For a contract-level dry run of either strategy, send the same `file_patch` file entry with `preview: true`.
|
|
44
|
+
5. Call one batched `file_hash({ filePaths: [...] })` immediately before guarded edits. Keep one returned hash per file. The runtime can make hashes optional through `safety.require_hash = false`, but the normal agent workflow should still supply them whenever current-state protection matters.
|
|
45
|
+
6. Mutation tools accept a declared `files` property whose value is a path-keyed object. Use one `file_patch({ files: { ... } })` call for one or more files with exactly one explicit strategy and its matching ordered operations. Each path runs under one lock; preview never commits and normal mode commits atomically.
|
|
46
|
+
7. Use one `file_write({ files: { ... } })` batch for new files or permitted SHA-guarded whole-file replacement. Supply the shared `chattr` object when chmod/chown metadata is required. The complete batch policy preflight finishes first; in-place formatter staging may transiently create, revalidate, and remove missing parents before the guarded commit recreates them, without writing the live target.
|
|
47
|
+
8. Use one `file_rename({ files: { ... } })` batch for hash-guarded moves; validate every source and destination, reject existing destinations, and use no-replace moves. Ordinary failures roll back completed entries when possible; the operation is not crash-atomic.
|
|
48
|
+
9. Use `file_chattr({ files: { ... } })` for metadata-only changes. Use hash-guarded `file_delete({ files: { ... } })` for deletion; it preflights all targets and AST import references before any deletion, requires an explicit `forceReferences` override for referenced source, and removes empty ancestor directories after lock release.
|
|
49
|
+
10. Use direct `run` with `rewrite` and `write: true` only for an intentionally bounded lower-level rewrite; it is not the normal agent patch route and still rewrites only the first match per file.
|
|
50
|
+
11. Verify results with `show`, `map`, `run`, or bounded `file_read` slices, then run repository validation.
|
|
51
|
+
|
|
52
|
+
Version 2 grants no implicit OS-temporary access. Express every exception through the narrowest top-level `[[paths]]` rule; `request` access must be approved through the host and model arguments can never bypass policy. Legacy v1 booleans remain readable only for compatibility and should be migrated with `ast-mcp config migrate`.
|
|
45
53
|
|
|
46
54
|
Example batched AST patch:
|
|
47
55
|
|
|
@@ -91,15 +99,15 @@ Read [patch-state-machine.md](references/patch-state-machine.md) for routing and
|
|
|
91
99
|
|
|
92
100
|
## Recover safely
|
|
93
101
|
|
|
94
|
-
- Stale SHA: refresh `file_hash`, re-inspect
|
|
102
|
+
- Stale SHA: refresh `file_hash`, re-inspect with the selected AST or text mode, and rebuild the patch.
|
|
95
103
|
- Zero or excess matches: narrow each AST rule; every astRules item must match exactly one node because ast-bro rewrites the first match per file, while ordered arrays let one declared `file_patch.files` entry apply multiple reviewed operations.
|
|
96
104
|
- Capped direct preview: narrow paths, glob, or pattern before writing.
|
|
97
|
-
- Aider ambiguity
|
|
98
|
-
- Formatter preflight failure: inspect the
|
|
105
|
+
- Unavailable method: call `file_capabilities` and select a reported read or patch method. Aider ambiguity or a disabled matcher is a safe stop; request a larger `mode: "text"` slice and expand the search block with unique surrounding context.
|
|
106
|
+
- Formatter preflight failure: call `config_status`, inspect the selected formatter and fallback, and do not write until stdout or staged in-place formatting succeeds. A v2 `preserve` fallback deliberately keeps unmatched content unchanged.
|
|
99
107
|
- MCP loss mid-task: stop writing, restore the server, then re-inspect touched and pending files through their correct AST or non-AST routes.
|
|
100
108
|
|
|
101
109
|
## Completion check
|
|
102
110
|
|
|
103
111
|
Confirm the old structure is absent through AST search, callers are correct, touched files were verified through their proper route, configured formatter-backed writes succeeded (or formatting is explicitly disabled), repository validation passes, and no direct-write or whole-file-read bypass was used.
|
|
104
112
|
|
|
105
|
-
Use `evals:check` for fixture-matrix integrity. `evals:measure` inventories direct MCP transcript records and statically visible `tools.mcp__ast_mcp__*` calls inside top-level Codex `exec` source. Put exactly one `ast-mcp-eval:<id>` marker in the user evaluation prompt, or in a direct record input supplied by an evaluation harness, to associate the following direct MCP records with that case. An outer `exec` result cannot prove each nested call, so marked nested calls and multi-marker evidence fail closed. Scoring validates schema-relevant inputs, transcript workspace roots, required order, expected output evidence, assertions, and successful per-call outputs. When the measured run used non-default file safety, pass the validated scorer options `--allow-any-path` and/or `--no-temp-directory`; the scorer does not infer layered project configuration from a transcript. Use `evals:score --strict` only for a complete marked matrix; transcript scoring is matched task-execution evidence, not a blanket agent-quality claim.
|
|
113
|
+
Use `evals:check` for fixture-matrix integrity. `evals:measure` inventories batch density, parallel read-only execution, validation-error codes, calls per recorded model-tool turn, direct MCP transcript records and statically visible `tools.mcp__ast_mcp__*` calls inside top-level Codex `exec` source. Put exactly one `ast-mcp-eval:<id>` marker in the user evaluation prompt, or in a direct record input supplied by an evaluation harness, to associate the following direct MCP records with that case. An outer `exec` result cannot prove each nested call, so marked nested calls and multi-marker evidence fail closed. Scoring validates schema-relevant inputs, transcript workspace roots, required order, expected output evidence, assertions, and successful per-call outputs. When the measured run used non-default file safety, pass the validated scorer options `--allow-any-path` and/or `--no-temp-directory`; the scorer does not infer layered project configuration from a transcript. Use `evals:score --strict` only for a complete marked matrix; transcript scoring is matched task-execution evidence, not a blanket agent-quality claim.
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"assertions": [
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
37
|
+
"Uses file_read with mode ast for AST-capable source.",
|
|
38
|
+
"Requests the named symbol instead of retrieving whole-file text.",
|
|
39
|
+
"Reports resolved mode, capabilities, and whole-file hash."
|
|
40
40
|
],
|
|
41
|
-
"category": "
|
|
42
|
-
"expected_output": "Uses AST
|
|
41
|
+
"category": "variant",
|
|
42
|
+
"expected_output": "Uses file_read AST mode with the createServer symbol.",
|
|
43
43
|
"files": [],
|
|
44
|
-
"forbidden_tools": [
|
|
44
|
+
"forbidden_tools": [],
|
|
45
45
|
"id": 3,
|
|
46
|
-
"prompt": "Inspect the declarations and implementation of createServer in src/server.ts.",
|
|
47
|
-
"required_tools": ["
|
|
46
|
+
"prompt": "Inspect the declarations and implementation of createServer in src/server.ts through file_read AST mode.",
|
|
47
|
+
"required_tools": ["file_read"],
|
|
48
48
|
"surface": "file_read",
|
|
49
|
-
"variant": "ast-
|
|
49
|
+
"variant": "ast-mode"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"assertions": [
|
|
@@ -1175,9 +1175,221 @@
|
|
|
1175
1175
|
"required_tools": [],
|
|
1176
1176
|
"surface": "skill",
|
|
1177
1177
|
"variant": "trigger-negative"
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
"assertions": [
|
|
1181
|
+
"Uses one file_capabilities call for the target.",
|
|
1182
|
+
"Reports intrinsic and configuration-filtered read, patch, and search methods.",
|
|
1183
|
+
"Performs no mutation."
|
|
1184
|
+
],
|
|
1185
|
+
"category": "positive",
|
|
1186
|
+
"expected_output": "Batches capability inspection and reports intrinsic and effective methods.",
|
|
1187
|
+
"files": [],
|
|
1188
|
+
"forbidden_tools": [],
|
|
1189
|
+
"id": 180,
|
|
1190
|
+
"prompt": "Report whether package.json supports AST or text reads and AST or Aider patches before editing it.",
|
|
1191
|
+
"required_tools": ["file_capabilities"],
|
|
1192
|
+
"surface": "file_capabilities",
|
|
1193
|
+
"variant": "primary"
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
"assertions": [
|
|
1197
|
+
"Batches all three paths in one call.",
|
|
1198
|
+
"Distinguishes intrinsic support from effective configuration.",
|
|
1199
|
+
"Uses the result to recommend a valid agent-selected strategy."
|
|
1200
|
+
],
|
|
1201
|
+
"category": "variant",
|
|
1202
|
+
"expected_output": "Uses one batched capability call and explains method differences.",
|
|
1203
|
+
"files": [],
|
|
1204
|
+
"forbidden_tools": [],
|
|
1205
|
+
"id": 181,
|
|
1206
|
+
"prompt": "Compare supported read and patch methods for a TypeScript file, Markdown file, and TOML file.",
|
|
1207
|
+
"required_tools": ["file_capabilities"],
|
|
1208
|
+
"surface": "file_capabilities",
|
|
1209
|
+
"variant": "batch"
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
"assertions": [
|
|
1213
|
+
"Uses file_hash rather than file_capabilities.",
|
|
1214
|
+
"Does not retrieve content.",
|
|
1215
|
+
"Performs no mutation."
|
|
1216
|
+
],
|
|
1217
|
+
"category": "negative",
|
|
1218
|
+
"expected_output": "Uses file_hash directly.",
|
|
1219
|
+
"files": [],
|
|
1220
|
+
"forbidden_tools": ["file_capabilities"],
|
|
1221
|
+
"id": 182,
|
|
1222
|
+
"prompt": "Return the SHA-256 for README.md without inspecting its contents.",
|
|
1223
|
+
"required_tools": ["file_hash"],
|
|
1224
|
+
"surface": "file_capabilities",
|
|
1225
|
+
"variant": "near-miss"
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
"assertions": [
|
|
1229
|
+
"Uses config_status before mutation when policy or formatting is uncertain.",
|
|
1230
|
+
"Reports the effective generation, health, and configuration provenance.",
|
|
1231
|
+
"Does not mutate files or manually reread configuration sources."
|
|
1232
|
+
],
|
|
1233
|
+
"category": "positive",
|
|
1234
|
+
"expected_output": "Inspects the effective configuration generation and provenance.",
|
|
1235
|
+
"files": [],
|
|
1236
|
+
"forbidden_tools": [],
|
|
1237
|
+
"id": 171,
|
|
1238
|
+
"prompt": "Check the effective AST MCP configuration before editing.",
|
|
1239
|
+
"required_tools": ["config_status"],
|
|
1240
|
+
"surface": "config_status",
|
|
1241
|
+
"variant": "primary"
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
"assertions": [
|
|
1245
|
+
"Uses one read-only status call and reports formatter selection order.",
|
|
1246
|
+
"Reports the global formatting enabled value and explicit fallback.",
|
|
1247
|
+
"Preserves first-match ordering and per-formatter enabled overrides."
|
|
1248
|
+
],
|
|
1249
|
+
"category": "variant",
|
|
1250
|
+
"expected_output": "Reports formatting fallback and formatter selection.",
|
|
1251
|
+
"files": [],
|
|
1252
|
+
"forbidden_tools": [],
|
|
1253
|
+
"id": 172,
|
|
1254
|
+
"prompt": "Which formatter would AST MCP use for this project?",
|
|
1255
|
+
"required_tools": ["config_status"],
|
|
1256
|
+
"surface": "config_status",
|
|
1257
|
+
"variant": "formatting"
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
"assertions": [
|
|
1261
|
+
"Does not inspect repository configuration for an unrelated prose request.",
|
|
1262
|
+
"Makes no MCP or filesystem tool call.",
|
|
1263
|
+
"Answers only from the supplied prose."
|
|
1264
|
+
],
|
|
1265
|
+
"category": "negative",
|
|
1266
|
+
"expected_output": "Answers without tool use.",
|
|
1267
|
+
"files": [],
|
|
1268
|
+
"forbidden_tools": ["config_status"],
|
|
1269
|
+
"id": 173,
|
|
1270
|
+
"prompt": "Rewrite this sentence more concisely.",
|
|
1271
|
+
"required_tools": [],
|
|
1272
|
+
"surface": "config_status",
|
|
1273
|
+
"variant": "unrelated"
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
"assertions": [
|
|
1277
|
+
"Batches multiple path decisions in one policy_check call.",
|
|
1278
|
+
"Includes canonical path, operation, tool, and matched rule evidence.",
|
|
1279
|
+
"Performs no mutation while explaining each decision."
|
|
1280
|
+
],
|
|
1281
|
+
"category": "positive",
|
|
1282
|
+
"expected_output": "Explains read, write, and delete decisions without mutation.",
|
|
1283
|
+
"files": [],
|
|
1284
|
+
"forbidden_tools": [],
|
|
1285
|
+
"id": 174,
|
|
1286
|
+
"prompt": "Preflight read, write, and delete policy for three paths.",
|
|
1287
|
+
"required_tools": ["policy_check"],
|
|
1288
|
+
"surface": "policy_check",
|
|
1289
|
+
"variant": "primary"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"assertions": [
|
|
1293
|
+
"Checks all independent paths in one batch.",
|
|
1294
|
+
"Reports matched rule source and specificity for every destination.",
|
|
1295
|
+
"Distinguishes allow, request, and deny without granting approval."
|
|
1296
|
+
],
|
|
1297
|
+
"category": "variant",
|
|
1298
|
+
"expected_output": "Returns matched rules and provenance for each path.",
|
|
1299
|
+
"files": [],
|
|
1300
|
+
"forbidden_tools": [],
|
|
1301
|
+
"id": 175,
|
|
1302
|
+
"prompt": "Explain which safety rules match two external destinations.",
|
|
1303
|
+
"required_tools": ["policy_check"],
|
|
1304
|
+
"surface": "policy_check",
|
|
1305
|
+
"variant": "external"
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
"assertions": [
|
|
1309
|
+
"Uses file_hash rather than policy_check when only a digest is requested.",
|
|
1310
|
+
"Uses one bounded hash call for the requested path.",
|
|
1311
|
+
"Does not retrieve file contents or invoke policy_check."
|
|
1312
|
+
],
|
|
1313
|
+
"category": "negative",
|
|
1314
|
+
"expected_output": "Hashes the file directly.",
|
|
1315
|
+
"files": [],
|
|
1316
|
+
"forbidden_tools": ["policy_check"],
|
|
1317
|
+
"id": 176,
|
|
1318
|
+
"prompt": "Return the SHA-256 for README.md.",
|
|
1319
|
+
"required_tools": ["file_hash"],
|
|
1320
|
+
"surface": "policy_check",
|
|
1321
|
+
"variant": "hash-near-miss"
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
"assertions": [
|
|
1325
|
+
"Uses RFC 6901 selectors and returns a whole-file hash.",
|
|
1326
|
+
"Batches both selectors in one document_query call.",
|
|
1327
|
+
"Returns bounded values and source locations without whole-file content."
|
|
1328
|
+
],
|
|
1329
|
+
"category": "positive",
|
|
1330
|
+
"expected_output": "Queries bounded values from a TOML manifest.",
|
|
1331
|
+
"files": [],
|
|
1332
|
+
"forbidden_tools": [],
|
|
1333
|
+
"id": 177,
|
|
1334
|
+
"prompt": "Read /version and /formatting/fallback from ast-mcp.toml.",
|
|
1335
|
+
"required_tools": ["document_query"],
|
|
1336
|
+
"surface": "document_query",
|
|
1337
|
+
"variant": "primary"
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
"assertions": [
|
|
1341
|
+
"Batches multiple selectors in one document_query call.",
|
|
1342
|
+
"Uses RFC 6901 escaping and selector semantics.",
|
|
1343
|
+
"Reports selected values, source locations, and the whole-file hash."
|
|
1344
|
+
],
|
|
1345
|
+
"category": "variant",
|
|
1346
|
+
"expected_output": "Returns selected JSONC values and locations.",
|
|
1347
|
+
"files": [],
|
|
1348
|
+
"forbidden_tools": [],
|
|
1349
|
+
"id": 178,
|
|
1350
|
+
"prompt": "Inspect three keys from a JSONC manifest without reading the entire file.",
|
|
1351
|
+
"required_tools": ["document_query"],
|
|
1352
|
+
"surface": "document_query",
|
|
1353
|
+
"variant": "jsonc-batch"
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
"assertions": [
|
|
1357
|
+
"Uses AST intelligence rather than document_query for TypeScript source.",
|
|
1358
|
+
"Uses show for the requested createServer implementation.",
|
|
1359
|
+
"Does not read the whole source file or invoke document_query."
|
|
1360
|
+
],
|
|
1361
|
+
"category": "negative",
|
|
1362
|
+
"expected_output": "Routes source inspection to show.",
|
|
1363
|
+
"files": [],
|
|
1364
|
+
"forbidden_tools": ["document_query"],
|
|
1365
|
+
"id": 179,
|
|
1366
|
+
"prompt": "Show the createServer implementation in src/server.ts.",
|
|
1367
|
+
"required_tools": ["show"],
|
|
1368
|
+
"surface": "document_query",
|
|
1369
|
+
"variant": "ast-near-miss"
|
|
1370
|
+
},
|
|
1371
|
+
{
|
|
1372
|
+
"assertions": [
|
|
1373
|
+
"Uses file_hash when only a whole-file digest is requested.",
|
|
1374
|
+
"Does not retrieve source, document values, or bounded text.",
|
|
1375
|
+
"Performs no mutation."
|
|
1376
|
+
],
|
|
1377
|
+
"category": "negative",
|
|
1378
|
+
"expected_output": "Routes hash-only inspection directly to file_hash.",
|
|
1379
|
+
"files": [],
|
|
1380
|
+
"forbidden_tools": ["file_read"],
|
|
1381
|
+
"id": 183,
|
|
1382
|
+
"prompt": "Return the SHA-256 for src/server.ts without reading its contents.",
|
|
1383
|
+
"required_tools": ["file_hash"],
|
|
1384
|
+
"surface": "file_read",
|
|
1385
|
+
"variant": "hash-only-near-miss"
|
|
1178
1386
|
}
|
|
1179
1387
|
],
|
|
1180
1388
|
"mcp_tools": [
|
|
1389
|
+
"config_status",
|
|
1390
|
+
"document_query",
|
|
1391
|
+
"file_capabilities",
|
|
1392
|
+
"policy_check",
|
|
1181
1393
|
"file_chattr",
|
|
1182
1394
|
"file_delete",
|
|
1183
1395
|
"file_rename",
|
|
@@ -40,14 +40,18 @@ type TranscriptCall = {
|
|
|
40
40
|
|
|
41
41
|
export type TranscriptScore = {
|
|
42
42
|
astMcpOutputChars: number;
|
|
43
|
+
batchDensity: number;
|
|
44
|
+
callsPerModelTurn: number;
|
|
43
45
|
errors: string[];
|
|
44
46
|
evaluatedCases: number;
|
|
45
47
|
execBatches: number;
|
|
46
48
|
mutationCalls: number;
|
|
49
|
+
parallelReadOnlyCalls: number;
|
|
47
50
|
passed: boolean;
|
|
48
51
|
session: string;
|
|
49
52
|
toolCalls: Record<string, number>;
|
|
50
53
|
unscoredBatches: number;
|
|
54
|
+
validationErrorCodes: Record<string, number>;
|
|
51
55
|
verifiedAssertions: number;
|
|
52
56
|
};
|
|
53
57
|
|
|
@@ -416,6 +420,50 @@ function validateStrictMatrix(
|
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
422
|
|
|
423
|
+
function targetCount(value: unknown, key = ""): number {
|
|
424
|
+
if (Array.isArray(value))
|
|
425
|
+
return [
|
|
426
|
+
"filePaths",
|
|
427
|
+
"paths",
|
|
428
|
+
"symbols",
|
|
429
|
+
"files",
|
|
430
|
+
"checks",
|
|
431
|
+
"selectors",
|
|
432
|
+
].includes(key)
|
|
433
|
+
? value.length
|
|
434
|
+
: Math.max(0, ...value.map((item) => targetCount(item)));
|
|
435
|
+
if (!value || typeof value !== "object") return 0;
|
|
436
|
+
const record = value as Record<string, unknown>;
|
|
437
|
+
const own = key === "files" ? Object.keys(record).length : 0;
|
|
438
|
+
return Math.max(
|
|
439
|
+
own,
|
|
440
|
+
...Object.entries(record).map(([childKey, child]) =>
|
|
441
|
+
targetCount(child, childKey),
|
|
442
|
+
),
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function invocationTargetCount(invocation: Invocation): number {
|
|
447
|
+
try {
|
|
448
|
+
return targetCount(JSON.parse(invocation.input));
|
|
449
|
+
} catch {
|
|
450
|
+
const match = invocation.input.match(
|
|
451
|
+
/(?:filePaths|paths|symbols)\s*:\s*\[([^\]]*)\]/s,
|
|
452
|
+
);
|
|
453
|
+
return match?.[1]?.trim() ? match[1].split(",").filter(Boolean).length : 0;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function validationErrorCodes(calls: Map<string, TranscriptCall>) {
|
|
458
|
+
const codes: Record<string, number> = {};
|
|
459
|
+
for (const call of calls.values()) {
|
|
460
|
+
const text = outputText(call.output?.output);
|
|
461
|
+
for (const match of text.matchAll(/["']code["']\s*:\s*["']([^"']+)["']/g))
|
|
462
|
+
codes[match[1]] = (codes[match[1]] ?? 0) + 1;
|
|
463
|
+
}
|
|
464
|
+
return codes;
|
|
465
|
+
}
|
|
466
|
+
|
|
419
467
|
export async function scoreTranscript(
|
|
420
468
|
sessionPath: string,
|
|
421
469
|
strict = false,
|
|
@@ -446,16 +494,48 @@ export async function scoreTranscript(
|
|
|
446
494
|
(toolCalls.file_patch ?? 0) +
|
|
447
495
|
(toolCalls.file_write ?? 0) +
|
|
448
496
|
(toolCalls.file_rename ?? 0);
|
|
497
|
+
const invocations = [...collector.calls.values()].flatMap(
|
|
498
|
+
(call) => call.invocations,
|
|
499
|
+
);
|
|
500
|
+
const batched = invocations.filter(
|
|
501
|
+
(invocation) => invocationTargetCount(invocation) > 1,
|
|
502
|
+
).length;
|
|
503
|
+
const statefulTools = new Set([
|
|
504
|
+
"file_chattr",
|
|
505
|
+
"file_delete",
|
|
506
|
+
"file_patch",
|
|
507
|
+
"file_rename",
|
|
508
|
+
"file_write",
|
|
509
|
+
"find_related",
|
|
510
|
+
"index",
|
|
511
|
+
"search",
|
|
512
|
+
]);
|
|
513
|
+
const parallelReadOnlyCalls = invocations.filter(
|
|
514
|
+
(invocation) =>
|
|
515
|
+
invocation.concurrent &&
|
|
516
|
+
!statefulTools.has(invocation.tool) &&
|
|
517
|
+
!(
|
|
518
|
+
invocation.tool === "run" &&
|
|
519
|
+
/(?:["']write["']|\bwrite)\s*:\s*true/.test(invocation.input)
|
|
520
|
+
),
|
|
521
|
+
).length;
|
|
449
522
|
return {
|
|
450
523
|
astMcpOutputChars: outputChars,
|
|
524
|
+
batchDensity: invocations.length === 0 ? 0 : batched / invocations.length,
|
|
525
|
+
callsPerModelTurn:
|
|
526
|
+
collector.calls.size === 0
|
|
527
|
+
? 0
|
|
528
|
+
: invocations.length / collector.calls.size,
|
|
451
529
|
errors: collector.errors,
|
|
452
530
|
evaluatedCases: result.evaluatedCases,
|
|
453
531
|
execBatches: collector.calls.size,
|
|
454
532
|
mutationCalls,
|
|
533
|
+
parallelReadOnlyCalls,
|
|
455
534
|
passed: collector.errors.length === 0,
|
|
456
535
|
session: sessionPath,
|
|
457
536
|
toolCalls,
|
|
458
537
|
unscoredBatches: grouped.unscoredBatches,
|
|
538
|
+
validationErrorCodes: validationErrorCodes(collector.calls),
|
|
459
539
|
verifiedAssertions: result.verifiedAssertions,
|
|
460
540
|
};
|
|
461
541
|
}
|
|
@@ -25,12 +25,14 @@ const toolKeys: Record<string, string[]> = {
|
|
|
25
25
|
context: ["target"],
|
|
26
26
|
deps: ["file"],
|
|
27
27
|
digest: ["paths"],
|
|
28
|
+
document_query: ["filePath", "selectors"],
|
|
28
29
|
file_hash: ["filePaths"],
|
|
29
30
|
file_read: ["files"],
|
|
30
31
|
find_related: ["path", "line"],
|
|
31
32
|
impact: ["target"],
|
|
32
33
|
implements: ["paths", "target"],
|
|
33
34
|
map: ["paths"],
|
|
35
|
+
policy_check: ["checks"],
|
|
34
36
|
reverse_deps: ["file"],
|
|
35
37
|
run: ["pattern"],
|
|
36
38
|
search: ["query"],
|
|
@@ -146,7 +148,7 @@ const inputValidators: Record<string, InputValidator> = {
|
|
|
146
148
|
|
|
147
149
|
function meaningfulInput(invocation: Invocation) {
|
|
148
150
|
const input = withoutComments(invocation.input).trim();
|
|
149
|
-
if (!input || input === "{}") return
|
|
151
|
+
if (!input || input === "{}") return invocation.tool === "config_status";
|
|
150
152
|
const validator = inputValidators[invocation.tool];
|
|
151
153
|
if (validator) return validator(input);
|
|
152
154
|
return (toolKeys[invocation.tool] ?? []).every((key) => hasKey(input, key));
|
|
@@ -6,9 +6,9 @@ Use this only when the ast-mcp tools are absent, incomplete, or disconnected. Do
|
|
|
6
6
|
|
|
7
7
|
From the installed skill directory, run the read-only checker:
|
|
8
8
|
|
|
9
|
-
`bun run scripts/check-install.ts --scope local --target codex
|
|
9
|
+
`bun run scripts/check-install.ts --scope local --target codex`
|
|
10
10
|
|
|
11
|
-
Replace `codex` with `claude` or `copilot`.
|
|
11
|
+
Replace `codex` with `claude` or `copilot`. Pass `--scope global` for a global installation. Pass the HTTP address and port for HTTP installations. The checker validates guidance, MCP definitions, hooks, skills, and managed assets. It also prints the required install or update command.
|
|
12
12
|
|
|
13
13
|
## Install from this package checkout
|
|
14
14
|
|
|
@@ -16,13 +16,13 @@ When the `@mwillbanks/ast-mcp` source checkout is already available, install its
|
|
|
16
16
|
|
|
17
17
|
`bun install && bun run build`
|
|
18
18
|
|
|
19
|
-
`bun run bin/ast-mcp.ts install --scope local --target all
|
|
19
|
+
`bun run bin/ast-mcp.ts install --scope local --target all`
|
|
20
20
|
|
|
21
21
|
For one host globally:
|
|
22
22
|
|
|
23
23
|
`bun run bin/ast-mcp.ts install --scope global --target codex`
|
|
24
24
|
|
|
25
|
-
Targets are `codex`, `claude`, `copilot`, or `all`. Stdio is the default transport. Use
|
|
25
|
+
Targets are `codex`, `claude`, `copilot`, or `all`. Stdio is the default transport. Use the HTTP options for HTTP host entries. Add `--service` to manage a macOS LaunchAgent or Linux systemd user unit.
|
|
26
26
|
|
|
27
27
|
## Install from the published package
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ When installing with Bun, allow the pinned native installers:
|
|
|
36
36
|
|
|
37
37
|
`bun pm trust @ast-bro/cli dprint`
|
|
38
38
|
|
|
39
|
-
`./node_modules/.bin/ast-mcp install --scope local --target all
|
|
39
|
+
`./node_modules/.bin/ast-mcp install --scope local --target all`
|
|
40
40
|
|
|
41
41
|
For a global host surface, use the package manager's persistent global install:
|
|
42
42
|
|
|
@@ -44,18 +44,18 @@ For a global host surface, use the package manager's persistent global install:
|
|
|
44
44
|
npm install --global @mwillbanks/ast-mcp
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Then run `ast-mcp install --scope global --target codex`.
|
|
47
|
+
Then run `ast-mcp install --scope global --target codex`. Use a project-local installation with Yarn 2+. Yarn 2+ does not provide the Yarn Classic global workflow. Bun blocks transitive lifecycle scripts by default. Trust `@ast-bro/cli` and `dprint` to run their pinned native installers. Approve those packages when another manager blocks dependency build scripts.
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Invoke the executable that must remain available. The installer records that path in MCP, hook, service, and manual-start output. The runtime checks package binaries, package metadata, global bins, and `PATH`. The installer uses the stable CLI and its `mcp` and `hook` subcommands. Run the local binary for local updates and removal. Run `ast-mcp update` or `ast-mcp uninstall` for global installations.
|
|
50
50
|
|
|
51
|
-
The pinned
|
|
51
|
+
The pinned package provides a precompiled binary for macOS Apple Silicon. Install ast-bro with Cargo on Linux or macOS Intel. Set `AST_BRO_BINARY` to the installed path and persist the export. Use the Cargo executable path on Windows. Ensure GUI-launched hosts inherit the variable. The installer verifies the binary before changing host configuration. It returns setup commands when required.
|
|
52
52
|
|
|
53
53
|
## Activate and verify
|
|
54
54
|
|
|
55
|
-
1. Run `ast-mcp config validate
|
|
56
|
-
2. Restart or reconnect MCP servers in the host
|
|
55
|
+
1. Run `ast-mcp config validate` before reconnecting. Use `ast-mcp config show` when the effective source is unclear. `--root` remains deprecated for one release.
|
|
56
|
+
2. Restart or reconnect MCP servers in the host. A skill file cannot make MCP tools callable. Send `SIGHUP` to request graceful cleanup and restart.
|
|
57
57
|
3. Confirm `file_hash`, `file_read`, `file_write`, and `file_patch` are present.
|
|
58
58
|
4. Confirm direct intelligence tools such as `digest`, `map`, `show`, `context`, and `impact` are present; there is no proxy tool.
|
|
59
|
-
5. Verify that
|
|
59
|
+
5. Verify that read and mutation tools accept their current batch fields. Reject dictionary-only mutation schemas and the legacy whole-file read schema.
|
|
60
60
|
6. Rerun `check-install.ts` if the tool list remains incomplete.
|
|
61
|
-
7.
|
|
61
|
+
7. Run `bun run tools:check` from the package checkout when startup fails. Report the missing dependency or startup error. Preserve the write boundary.
|