@mwillbanks/ast-mcp 0.2.0 → 0.2.2
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 +3 -1
- package/dist/ast-mcp.js +76 -76
- package/dist/ast-mcp.js.map +13 -13
- package/package.json +1 -1
- package/src/config.ts +32 -4
- package/src/helpers/config.ts +5 -3
- package/src/helpers/mcp-schema.ts +7 -0
- package/src/installer.ts +37 -17
- package/src/runtime/file-delete.ts +33 -4
- package/src/runtime/file-rename.ts +2 -4
- package/src/runtime/paths.ts +85 -22
- package/src/service.ts +2 -4
- package/src/tools/ast-bro.ts +3 -3
- package/src/tools/files.ts +15 -18
- package/src/tools/lifecycle.ts +13 -13
- package/templates/AGENTS.md +5 -5
- package/templates/skills/ast-mcp/SKILL.md +31 -23
- package/templates/skills/ast-mcp/evals/batch.evals.json +9 -9
- package/templates/skills/ast-mcp/evals/measure.ts +27 -4
- package/templates/skills/ast-mcp/evals/score.test.ts +46 -3
- package/templates/skills/ast-mcp/evals/score.ts +7 -0
- package/templates/skills/ast-mcp/evals/semantic.test.ts +209 -28
- package/templates/skills/ast-mcp/evals/semantic.ts +148 -36
- package/templates/skills/ast-mcp/references/installation.md +1 -1
- package/templates/skills/ast-mcp/references/patch-state-machine.md +4 -4
- package/templates/skills/ast-mcp/references/tool-catalog.md +6 -6
- package/templates/skills/ast-mcp/scripts/check-install.ts +15 -25
|
@@ -96,23 +96,13 @@ const instructionsBegin = "<!-- ast-mcp:begin -->";
|
|
|
96
96
|
const instructionsEnd = "<!-- ast-mcp:end -->";
|
|
97
97
|
|
|
98
98
|
async function astMcpEntry(entry: unknown): Promise<boolean> {
|
|
99
|
-
if (
|
|
99
|
+
if (entry === "./node_modules/.bin/ast-mcp") return true;
|
|
100
|
+
if (typeof entry !== "string" || path.basename(entry) !== "ast-mcp")
|
|
100
101
|
return false;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
await readFile(path.join(folder, "package.json"), "utf8"),
|
|
106
|
-
);
|
|
107
|
-
return (
|
|
108
|
-
manifest.name === "@mwillbanks/ast-mcp" &&
|
|
109
|
-
path.resolve(entry) === path.join(folder, "dist/ast-mcp.js")
|
|
110
|
-
);
|
|
111
|
-
} catch {}
|
|
112
|
-
const parent = path.dirname(folder);
|
|
113
|
-
if (parent === folder) return false;
|
|
114
|
-
folder = parent;
|
|
115
|
-
}
|
|
102
|
+
const bin = path.dirname(entry);
|
|
103
|
+
return (
|
|
104
|
+
path.basename(bin) === "bin" && path.basename(path.dirname(bin)) === ".bun"
|
|
105
|
+
);
|
|
116
106
|
}
|
|
117
107
|
|
|
118
108
|
async function expectedReference(
|
|
@@ -173,7 +163,7 @@ async function hookCurrent(
|
|
|
173
163
|
);
|
|
174
164
|
for (const command of commands) {
|
|
175
165
|
if (typeof command !== "string") continue;
|
|
176
|
-
const match = command.match(/^
|
|
166
|
+
const match = command.match(/^(.+) hook$/);
|
|
177
167
|
if (!match) continue;
|
|
178
168
|
try {
|
|
179
169
|
if (await astMcpEntry(JSON.parse(match[1]))) return true;
|
|
@@ -203,10 +193,10 @@ function httpJsonMcpCurrent(
|
|
|
203
193
|
}
|
|
204
194
|
async function stdioCommandCurrent(entry: McpEntry | undefined) {
|
|
205
195
|
return (
|
|
206
|
-
entry?.command
|
|
207
|
-
Array.isArray(entry
|
|
208
|
-
entry.args
|
|
209
|
-
|
|
196
|
+
(await astMcpEntry(entry?.command)) &&
|
|
197
|
+
Array.isArray(entry?.args) &&
|
|
198
|
+
entry.args.length === 1 &&
|
|
199
|
+
entry.args[0] === "mcp"
|
|
210
200
|
);
|
|
211
201
|
}
|
|
212
202
|
|
|
@@ -266,12 +256,12 @@ function codexHttpMcpCurrent(block: string, url: string | undefined) {
|
|
|
266
256
|
);
|
|
267
257
|
}
|
|
268
258
|
async function codexStdioMcpCurrent(block: string, root: string | undefined) {
|
|
269
|
-
const
|
|
259
|
+
const command = block.match(/command = (".*")/);
|
|
270
260
|
if (
|
|
271
261
|
!block.includes("[mcp_servers.ast-mcp]") ||
|
|
272
|
-
!block.includes('
|
|
273
|
-
!
|
|
274
|
-
!(await astMcpEntry(JSON.parse(
|
|
262
|
+
!block.includes('args = ["mcp"]') ||
|
|
263
|
+
!command ||
|
|
264
|
+
!(await astMcpEntry(JSON.parse(command[1])))
|
|
275
265
|
)
|
|
276
266
|
return false;
|
|
277
267
|
return root
|