@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.
Files changed (55) hide show
  1. package/CONTRIBUTING.md +13 -0
  2. package/README.md +18 -16
  3. package/dist/ast-mcp.js +183 -137
  4. package/dist/ast-mcp.js.map +58 -42
  5. package/package.json +17 -11
  6. package/src/ast-bro/capability.ts +20 -10
  7. package/src/ast-bro/tools.json +22 -2
  8. package/src/cli.ts +10 -7
  9. package/src/config-cli.ts +166 -19
  10. package/src/config-migrate.ts +223 -0
  11. package/src/config-registry.ts +321 -0
  12. package/src/config-schema-common.ts +81 -0
  13. package/src/config-v2-schema.ts +97 -0
  14. package/src/config.ts +346 -148
  15. package/src/helpers/ast-bro.ts +1 -7
  16. package/src/helpers/config.ts +7 -0
  17. package/src/helpers/installer.ts +8 -0
  18. package/src/helpers/mcp-schema.ts +98 -4
  19. package/src/host-smoke.ts +182 -0
  20. package/src/http.ts +8 -3
  21. package/src/installer-transport.ts +6 -4
  22. package/src/installer.ts +192 -51
  23. package/src/patch/engine.ts +555 -279
  24. package/src/patch/languages.ts +9 -0
  25. package/src/patch/strategy/aiderBlock.ts +110 -0
  26. package/src/patch/strategy/ast.ts +170 -0
  27. package/src/patch/strategy.ts +61 -0
  28. package/src/runtime/approval.ts +438 -0
  29. package/src/runtime/dependencies.ts +1 -1
  30. package/src/runtime/document-inspection.ts +78 -0
  31. package/src/runtime/file-capabilities.ts +250 -0
  32. package/src/runtime/file-delete.ts +110 -37
  33. package/src/runtime/file-read.ts +142 -14
  34. package/src/runtime/file-rename.ts +5 -2
  35. package/src/runtime/format.ts +65 -27
  36. package/src/runtime/path-policy.ts +557 -0
  37. package/src/runtime/path-utils.ts +40 -0
  38. package/src/runtime/paths.ts +142 -44
  39. package/src/server.ts +2 -1
  40. package/src/tools/ast-bro.ts +196 -75
  41. package/src/tools/configuration.ts +450 -0
  42. package/src/tools/configured.ts +49 -21
  43. package/src/tools/files.ts +168 -61
  44. package/src/tools/index.ts +2 -0
  45. package/src/tools/lifecycle.ts +82 -38
  46. package/templates/AGENTS.md +13 -15
  47. package/templates/skills/ast-mcp/SKILL.md +28 -20
  48. package/templates/skills/ast-mcp/evals/evals.json +221 -9
  49. package/templates/skills/ast-mcp/evals/score.ts +80 -0
  50. package/templates/skills/ast-mcp/evals/semantic.ts +3 -1
  51. package/templates/skills/ast-mcp/references/installation.md +12 -12
  52. package/templates/skills/ast-mcp/references/patch-state-machine.md +15 -14
  53. package/templates/skills/ast-mcp/references/tool-catalog.md +13 -7
  54. package/templates/skills/ast-mcp/scripts/check-install.ts +8 -17
  55. package/src/ast-bro/rewrite-capability.ts +0 -9
package/CONTRIBUTING.md CHANGED
@@ -5,6 +5,7 @@ Thanks for helping improve ast-mcp. Changes should preserve its core promise: re
5
5
  ## Prerequisites
6
6
 
7
7
  - Bun 1.3 or newer
8
+ - Node.js 22.19 or newer when running MCP Inspector commands
8
9
  - the pinned `ast-bro` and `dprint` binaries installed by `bun install`
9
10
  - a checkout with no unrelated changes in files you plan to edit
10
11
 
@@ -47,6 +48,18 @@ bun pm pack --dry-run
47
48
 
48
49
  The formatter command intentionally applies Biome's safe and unsafe fixes and treats every remaining warning as a failure.
49
50
 
51
+ ### Optional live host smoke checks
52
+
53
+ Live model-host checks are disabled by default. `bun run smoke:hosts` does not spawn Codex, Claude, Copilot, or any other host unless an environment variable named `AST_MCP_HOST_SMOKE_<NAME>` is present. These checks are deliberately separate from `bun run check`, CI, and release workflows.
54
+
55
+ The variable value is a JSON object with a shell-free `command` argument array, optional `expect` marker or marker array, and optional `timeoutMs`. The suffix is arbitrary, so every host uses the same opt-in contract without ast-mcp assuming a particular CLI is installed or authenticated. Independent enabled checks run concurrently.
56
+
57
+ ```bash
58
+ AST_MCP_HOST_SMOKE_MY_HOST='{"command":["my-host","--non-interactive","run an ast-mcp config_status smoke check"],"expect":["config_status","generation"]}' bun run smoke:hosts
59
+ ```
60
+
61
+ The default timeout is 60 seconds. Set `AST_MCP_HOST_SMOKE_TIMEOUT_MS` to change it for every enabled check, or use `timeoutMs` in one host definition. A configured host failure fails this optional command, while an unconfigured host is always skipped.
62
+
50
63
  ## Pull requests
51
64
 
52
65
  - Keep changes focused and explain the user-visible or boundary-level behavior.
package/README.md CHANGED
@@ -69,8 +69,7 @@ bun pm trust @ast-bro/cli dprint
69
69
  ```bash
70
70
  ./node_modules/.bin/ast-mcp install \
71
71
  --scope local \
72
- --target all \
73
- --root "$PWD"
72
+ --target all
74
73
  ```
75
74
 
76
75
  Stdio remains the default. To generate Streamable HTTP entries instead, select HTTP and an endpoint:
@@ -79,7 +78,6 @@ Stdio remains the default. To generate Streamable HTTP entries instead, select H
79
78
  ./node_modules/.bin/ast-mcp install \
80
79
  --scope local \
81
80
  --target all \
82
- --root "$PWD" \
83
81
  --transport http \
84
82
  --host 127.0.0.1 \
85
83
  --port 3768
@@ -89,14 +87,14 @@ Add `--service` to create and start a macOS LaunchAgent or Linux systemd user un
89
87
 
90
88
  Bun blocks transitive lifecycle scripts by default, so the explicit trust step runs the pinned ast-bro and dprint installers before the MCP starts. If another package manager blocks dependency build scripts, approve `@ast-bro/cli` and `dprint` through that manager before configuring a host. npm, pnpm, Yarn Classic, and Yarn 2+ project installations are supported. The runtime resolves binaries from ancestor package bins, package metadata, package-manager global bins, and then `PATH`.
91
89
 
92
- Targets are `codex`, `claude`, `copilot`, or `all`. Use `./node_modules/.bin/ast-mcp update` to reconcile every managed surface and `./node_modules/.bin/ast-mcp uninstall` to remove only marked blocks, managed entries, and the owned `ast-mcp` skill directory.
90
+ Targets are `codex`, `claude`, `copilot`, or `all`. The installer records the invoked executable, creates version 2 configuration, and omits MCP environment fields. Uninstall preserves configuration.
93
91
 
94
92
  ### ast-bro platform support
95
93
 
96
- `@ast-bro/cli@3.0.0` currently publishes a precompiled binary only for macOS Apple Silicon. The ast-mcp installer verifies that the pinned binary can execute before writing host configuration. On Linux, Windows, or macOS Intel, install it through Cargo and set `AST_BRO_BINARY` to the resulting executable before rerunning the installer:
94
+ `@ast-bro/cli@4.0.0` currently publishes a precompiled binary only for macOS Apple Silicon. The ast-mcp installer verifies that the pinned binary can execute before writing host configuration. On Linux, Windows, or macOS Intel, install it through Cargo and set `AST_BRO_BINARY` to the resulting executable before rerunning the installer:
97
95
 
98
96
  ```bash
99
- cargo install ast-bro --version 3.0.0 --locked
97
+ cargo install ast-bro --version 4.0.0 --locked
100
98
  export AST_BRO_BINARY="$HOME/.cargo/bin/ast-bro"
101
99
  printf '%s\n' 'export AST_BRO_BINARY="$HOME/.cargo/bin/ast-bro"' >> "$HOME/.profile"
102
100
  ```
@@ -104,7 +102,7 @@ printf '%s\n' 'export AST_BRO_BINARY="$HOME/.cargo/bin/ast-bro"' >> "$HOME/.prof
104
102
  For Windows PowerShell:
105
103
 
106
104
  ```powershell
107
- cargo install ast-bro --version 3.0.0 --locked
105
+ cargo install ast-bro --version 4.0.0 --locked
108
106
  $env:AST_BRO_BINARY = "$HOME\.cargo\bin\ast-bro.exe"
109
107
  [Environment]::SetEnvironmentVariable("AST_BRO_BINARY", "$HOME\.cargo\bin\ast-bro.exe", "User")
110
108
  ```
@@ -116,26 +114,30 @@ From a source checkout:
116
114
  ```bash
117
115
  bun install
118
116
  bun run build
119
- bun run bin/ast-mcp.ts install --scope local --target all --root "$PWD"
117
+ bun run bin/ast-mcp.ts install --scope local --target all
120
118
  ```
121
119
 
122
120
  ## Configuration
123
121
 
124
- Create `ast-mcp.toml` in the project root to configure a local or globally installed server without rewriting host MCP definitions:
122
+ Install or update ast-mcp to create `ast-mcp.toml`. The installer migrates version 1 files and preserves version 2 files.
125
123
 
126
124
  ```toml
127
- version = 1
125
+ version = 2
128
126
 
129
127
  [workspace]
130
128
  roots = ["."]
131
129
 
132
130
  [safety]
133
- allow_any_path = false
134
- allow_external_roots = false
135
- allow_temp_directory = true
136
- follow_symlinks = false
137
131
  require_hash = true
138
132
 
133
+ [[paths]]
134
+ id = "workspace"
135
+ path = "."
136
+ policies = { read = "allow", write = "allow", delete = "deny" }
137
+ follow_symlinks = false
138
+ includes = ["**/*"]
139
+ excludes = [".git/**"]
140
+
139
141
  [safety.hook]
140
142
  enabled = true
141
143
 
@@ -155,13 +157,13 @@ port = 3768
155
157
 
156
158
  Resolution is deterministic: environment overrides, project `ast-mcp.toml`, the platform global `ast-mcp/ast-mcp.toml`, then built-in defaults. The server uses MCP client workspace roots when available, so one global installation automatically selects the connected project. Existing environment variables remain supported as explicit overrides.
157
159
 
158
- Formatting uses dprint by default, can be disabled, or can route the first matching extension/glob to a shell-free external formatter with dprint fallback. Mutation tools expose a host-compatible declared `files` batch. File operations allow the OS temporary directory by default; this can be disabled, while `allow_any_path = true` provides an explicit unrestricted mode. Other safety settings can allow final symlinks inside permitted roots, make mutation hashes optional, or tune the host hook allow/block policy.
160
+ Formatting uses dprint by default and supports shell-free external formatters. Mutation tools expose a declared `files` batch. Version 2 requires explicit `[[paths]]` rules outside the host baseline, including temporary paths. Path rules control symlinks, hashes, and hook policy.
159
161
 
160
162
  Inspect the result with `ast-mcp config validate` and `ast-mcp config show`. See the [configuration reference](https://mwillbanks.github.io/ast-mcp/docs/reference/configuration/) for the full schema, discovery rules, cache behavior, formatter contract, safety semantics, and migration guidance.
161
163
 
162
164
  ## MCP configuration
163
165
 
164
- A minimal global stdio definition needs only the stable executable and `mcp` subcommand. Local installer definitions additionally carry `AST_MCP_PROJECT_ROOT` as a discovery selector; it does not override configuration values. Select `--transport http` during install to generate native URL entries for Codex, Claude Code, Copilot CLI, and VS Code.
166
+ A stdio definition contains the invoked executable and `mcp` subcommand. Generated definitions omit environment fields. Project configuration supplies local roots. Select `--transport http` during install to generate native URL entries for Codex, Claude Code, Copilot CLI, and VS Code.
165
167
 
166
168
  Start HTTP manually with `ast-mcp mcp --transport http [--host <address>] [--port <number>]`, or install a user service with `--service`. CLI flags override environment variables, project TOML, global TOML, and built-in defaults. The endpoint is `/mcp`; wildcard bind addresses generate loopback client URLs, while explicit non-loopback addresses deliberately expose the server. MCP session IDs correlate requests and are not authentication; stdio remains the trusted default transport. HTTP uses SSE by default and emits one event per request; JSON-array responses require `enableJsonResponse`.
167
169