@mwillbanks/ast-mcp 0.1.3 → 0.2.1
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/README.md +59 -20
- package/dist/ast-mcp.js +232 -130
- package/dist/ast-mcp.js.map +107 -27
- package/package.json +2 -1
- package/src/ast-bro/capability.ts +3 -8
- package/src/ast-bro/client.ts +18 -2
- package/src/ast-bro/result.ts +5 -12
- package/src/cli.ts +70 -95
- package/src/config-cli.ts +54 -0
- package/src/config.ts +886 -0
- package/src/helpers/aider.ts +252 -0
- package/src/helpers/ast-bro.ts +64 -0
- package/src/helpers/config.ts +149 -0
- package/src/helpers/hook.ts +60 -0
- package/src/helpers/installer.ts +249 -0
- package/src/helpers/json.ts +19 -0
- package/src/helpers/mcp-schema.ts +31 -0
- package/src/helpers/process.ts +31 -0
- package/src/helpers/string.ts +97 -0
- package/src/hook.ts +135 -40
- package/src/http-entry.ts +1 -1
- package/src/http.ts +118 -103
- package/src/installer-transport.ts +190 -0
- package/src/installer.ts +604 -247
- package/src/mcp-cli.ts +104 -0
- package/src/patch/aider.ts +6 -199
- package/src/patch/engine.ts +271 -197
- package/src/runtime/dependencies.ts +48 -29
- package/src/runtime/file-delete.ts +13 -9
- package/src/runtime/file-read.ts +91 -57
- package/src/runtime/file-rename.ts +158 -0
- package/src/runtime/format.ts +57 -34
- package/src/runtime/paths.ts +30 -16
- package/src/runtime/policy.ts +21 -0
- package/src/runtime/process-input.ts +14 -4
- package/src/service.ts +217 -0
- package/src/shell-policy.ts +331 -0
- package/src/stdio.ts +47 -35
- package/src/tools/ast-bro.ts +12 -6
- package/src/tools/configured.ts +28 -0
- package/src/tools/files.ts +24 -27
- package/src/tools/index.ts +5 -3
- package/src/tools/lifecycle.ts +69 -55
- package/templates/skills/ast-mcp/SKILL.md +7 -6
- package/templates/skills/ast-mcp/evals/batch.evals.json +48 -0
- package/templates/skills/ast-mcp/evals/evals.json +1 -0
- package/templates/skills/ast-mcp/evals/score.test.ts +175 -0
- package/templates/skills/ast-mcp/evals/score.ts +304 -267
- package/templates/skills/ast-mcp/evals/semantic.test.ts +322 -0
- package/templates/skills/ast-mcp/evals/semantic.ts +390 -135
- package/templates/skills/ast-mcp/evals/shell-policy.ts +252 -0
- package/templates/skills/ast-mcp/evals/source.test.ts +46 -0
- package/templates/skills/ast-mcp/evals/source.ts +164 -0
- package/templates/skills/ast-mcp/evals/trigger-queries.json +1 -1
- package/templates/skills/ast-mcp/references/installation.md +9 -8
- package/templates/skills/ast-mcp/references/patch-state-machine.md +5 -5
- package/templates/skills/ast-mcp/references/tool-catalog.md +4 -2
- package/templates/skills/ast-mcp/scripts/check-install.ts +323 -131
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<a href="LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
-
`@mwillbanks/ast-mcp` combines native AST intelligence, deterministic file operations, state-machine-enforced edits,
|
|
18
|
+
`@mwillbanks/ast-mcp` combines native AST intelligence, deterministic file operations, state-machine-enforced edits, best-effort routing hooks, and agent guidance. It gives Codex, Claude Code, GitHub Copilot, and VS Code Copilot a capable repository workflow without granting them an unbounded editor.
|
|
19
19
|
|
|
20
20
|
**[Read the documentation](https://mwillbanks.github.io/ast-mcp/)**
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ Coding agents need more than a text editor. They need a way to understand code r
|
|
|
29
29
|
| Guarded file operations | Batched hashing, bounded text reads, deterministic creation, exact patches, attributes, and reference-aware deletion |
|
|
30
30
|
| Root isolation | One shared path policy for every file and ast-bro operation, with symlink rejection and explicit external-root opt-in |
|
|
31
31
|
| Safe commits | Fresh SHA-256 checks, deterministic cross-process locks, candidate formatting, hash rechecks, and atomic replacement |
|
|
32
|
-
|
|
|
32
|
+
| Agent routing | Best-effort hooks, a unified skill, and idempotent installers for Codex, Claude, Copilot, and VS Code |
|
|
33
33
|
|
|
34
34
|
AST-capable files stay on the intelligence path instead of being retrieved as whole-file text. Unsupported formats use bounded reads and exact Aider search/replace blocks.
|
|
35
35
|
|
|
@@ -52,7 +52,9 @@ Runtime dependencies are pinned where binary compatibility matters. `@ast-bro/cl
|
|
|
52
52
|
|
|
53
53
|
## Install
|
|
54
54
|
|
|
55
|
-
Install the MCP server,
|
|
55
|
+
Install the MCP server, best-effort routing hooks, unified skill, and managed instructions into the current repository:
|
|
56
|
+
|
|
57
|
+
The hooks nudge common direct editor and manual mutation attempts toward ast-mcp. They are not a security boundary and deliberately leave Git operations, output redirection, repository scripts, and arbitrary execution to the host framework and sandbox.
|
|
56
58
|
|
|
57
59
|
```npm
|
|
58
60
|
npm install --save-dev @mwillbanks/ast-mcp
|
|
@@ -71,6 +73,20 @@ bun pm trust @ast-bro/cli dprint
|
|
|
71
73
|
--root "$PWD"
|
|
72
74
|
```
|
|
73
75
|
|
|
76
|
+
Stdio remains the default. To generate Streamable HTTP entries instead, select HTTP and an endpoint:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
./node_modules/.bin/ast-mcp install \
|
|
80
|
+
--scope local \
|
|
81
|
+
--target all \
|
|
82
|
+
--root "$PWD" \
|
|
83
|
+
--transport http \
|
|
84
|
+
--host 127.0.0.1 \
|
|
85
|
+
--port 3768
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Add `--service` to create and start a macOS LaunchAgent or Linux systemd user unit. Local services require an explicit port. Without `--service`, the installer prints the manual `ast-mcp mcp --transport http` startup command. Windows supports manual HTTP startup but not managed services.
|
|
89
|
+
|
|
74
90
|
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`.
|
|
75
91
|
|
|
76
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.
|
|
@@ -103,26 +119,49 @@ bun run build
|
|
|
103
119
|
bun run bin/ast-mcp.ts install --scope local --target all --root "$PWD"
|
|
104
120
|
```
|
|
105
121
|
|
|
106
|
-
##
|
|
122
|
+
## Configuration
|
|
123
|
+
|
|
124
|
+
Create `ast-mcp.toml` in the project root to configure a local or globally installed server without rewriting host MCP definitions:
|
|
125
|
+
|
|
126
|
+
```toml
|
|
127
|
+
version = 1
|
|
107
128
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
[workspace]
|
|
130
|
+
roots = ["."]
|
|
131
|
+
|
|
132
|
+
[safety]
|
|
133
|
+
allow_external_roots = false
|
|
134
|
+
follow_symlinks = false
|
|
135
|
+
require_hash = true
|
|
136
|
+
|
|
137
|
+
[safety.hook]
|
|
138
|
+
enabled = true
|
|
139
|
+
|
|
140
|
+
[formatting]
|
|
141
|
+
enabled = true
|
|
142
|
+
dprint_config = "./dprint.json"
|
|
143
|
+
|
|
144
|
+
[[formatting.formatters]]
|
|
145
|
+
extensions = [".rs"]
|
|
146
|
+
command = "rustfmt"
|
|
147
|
+
args = ["--emit", "stdout"]
|
|
148
|
+
|
|
149
|
+
[http]
|
|
150
|
+
host = "127.0.0.1"
|
|
151
|
+
port = 3768
|
|
123
152
|
```
|
|
124
153
|
|
|
125
|
-
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
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. Safety remains strict by default; explicit settings can allow final symlinks inside configured roots, make mutation hashes optional, or tune the host hook allow/block policy.
|
|
157
|
+
|
|
158
|
+
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.
|
|
159
|
+
|
|
160
|
+
## MCP configuration
|
|
161
|
+
|
|
162
|
+
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.
|
|
163
|
+
|
|
164
|
+
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`.
|
|
126
165
|
|
|
127
166
|
`SIGTERM`, `SIGINT`, and `SIGHUP` all initiate graceful shutdown. The stdio process closes its MCP server; the HTTP process stops accepting requests, closes every active MCP session, then closes remaining connections. Successful cleanup exits 0, cleanup failure exits 1, and a second signal forces exit 1 while cleanup is pending. `SIGHUP` intentionally exits after cleanup so the host supervisor can restart ast-mcp from refreshed code and configuration.
|
|
128
167
|
|