@mwillbanks/ast-mcp 0.1.0 → 0.1.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/CONTRIBUTING.md +1 -1
- package/README.md +11 -9
- package/dist/ast-mcp.js +65 -46
- package/dist/ast-mcp.js.map +12 -7
- package/package.json +7 -8
- package/src/ast-bro/capability.ts +19 -9
- package/src/ast-bro/client.ts +3 -4
- package/src/cli.ts +26 -0
- package/src/installer.ts +13 -15
- package/src/runtime/dependencies.ts +20 -0
- package/src/runtime/format.ts +3 -2
- package/templates/skills/ast-mcp/references/installation.md +12 -6
- package/templates/skills/ast-mcp/scripts/check-install.ts +42 -24
- package/dist/ast-mcp-hook.js +0 -7
- package/dist/ast-mcp-hook.js.map +0 -11
- package/dist/ast-mcp-install.js +0 -22
- package/dist/ast-mcp-install.js.map +0 -12
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Mike Willbanks",
|
|
3
3
|
"bin": {
|
|
4
|
-
"ast-mcp": "dist/ast-mcp.js"
|
|
5
|
-
"ast-mcp-hook": "dist/ast-mcp-hook.js",
|
|
6
|
-
"ast-mcp-install": "dist/ast-mcp-install.js"
|
|
4
|
+
"ast-mcp": "dist/ast-mcp.js"
|
|
7
5
|
},
|
|
8
6
|
"bugs": {
|
|
9
7
|
"url": "https://github.com/mwillbanks/ast-mcp/issues"
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
"url": "git+https://github.com/mwillbanks/ast-mcp.git"
|
|
59
57
|
},
|
|
60
58
|
"scripts": {
|
|
61
|
-
"build": "bun
|
|
59
|
+
"build": "bun run scripts/build.ts",
|
|
62
60
|
"check": "bun run tools:check && bun run format:check && bun run typecheck && bun run test",
|
|
63
61
|
"dev": "bun run --watch src/index.ts",
|
|
64
62
|
"dev:http": "bun run --watch src/http-entry.ts",
|
|
@@ -76,14 +74,15 @@
|
|
|
76
74
|
"skill:check": "bunx skills-ref validate templates/skills/ast-mcp",
|
|
77
75
|
"start": "bun run src/index.ts",
|
|
78
76
|
"start:http": "bun run src/http-entry.ts",
|
|
79
|
-
"test": "bun test --bail --max-concurrency=1",
|
|
80
|
-
"tools:check": "
|
|
77
|
+
"test": "bun test --bail --max-concurrency=1 --timeout=30000",
|
|
78
|
+
"tools:check": "bun run scripts/verify-tools.ts",
|
|
81
79
|
"typecheck": "bunx tsc --noEmit"
|
|
82
80
|
},
|
|
83
81
|
"sideEffects": false,
|
|
84
82
|
"trustedDependencies": [
|
|
85
|
-
"@ast-bro/cli"
|
|
83
|
+
"@ast-bro/cli",
|
|
84
|
+
"dprint"
|
|
86
85
|
],
|
|
87
86
|
"type": "module",
|
|
88
|
-
"version": "0.1.
|
|
87
|
+
"version": "0.1.1"
|
|
89
88
|
}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { AST_BRO_BINARY } from "./client";
|
|
4
|
+
|
|
5
|
+
type AstBroMapPayload = {
|
|
6
|
+
files?: Array<{ error_count?: number; path?: unknown }>;
|
|
7
|
+
};
|
|
5
8
|
|
|
6
9
|
export async function astCapable(
|
|
7
10
|
filePath: string,
|
|
8
11
|
language?: string,
|
|
9
12
|
): Promise<boolean> {
|
|
10
13
|
if (!language) return false;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
16
|
-
const
|
|
14
|
+
const processHandle = Bun.spawn([AST_BRO_BINARY, "map", "--json", filePath], {
|
|
15
|
+
cwd: path.dirname(filePath),
|
|
16
|
+
stderr: "pipe",
|
|
17
|
+
stdout: "pipe",
|
|
18
|
+
});
|
|
19
|
+
const [exitCode, stdout, stderr] = await Promise.all([
|
|
20
|
+
processHandle.exited,
|
|
21
|
+
new Response(processHandle.stdout).text(),
|
|
22
|
+
new Response(processHandle.stderr).text(),
|
|
23
|
+
]);
|
|
24
|
+
const failure = stderr.trim() || `ast-bro map exited ${exitCode}`;
|
|
25
|
+
if (exitCode !== 0) throw new Error(failure);
|
|
26
|
+
const payload = JSON.parse(stdout) as AstBroMapPayload;
|
|
17
27
|
const file = (payload.files ?? []).find(
|
|
18
|
-
(candidate
|
|
28
|
+
(candidate) => candidate.path === filePath,
|
|
19
29
|
);
|
|
20
30
|
return file?.error_count === 0;
|
|
21
31
|
}
|
package/src/ast-bro/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
1
|
import { Client } from "@modelcontextprotocol/client";
|
|
3
2
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
3
|
+
import { AST_BRO_BINARY } from "../runtime/dependencies";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export { AST_BRO_BINARY } from "../runtime/dependencies";
|
|
6
6
|
export const AST_BRO_TOOLS = [
|
|
7
7
|
"map",
|
|
8
8
|
"digest",
|
|
@@ -32,9 +32,8 @@ export async function callAstBro(
|
|
|
32
32
|
const client = new Client({ name: "ast-mcp", version: "1.0.0" });
|
|
33
33
|
const transport = new StdioClientTransport({
|
|
34
34
|
args: ["mcp"],
|
|
35
|
-
command:
|
|
35
|
+
command: AST_BRO_BINARY,
|
|
36
36
|
cwd: root,
|
|
37
|
-
stderr: "pipe",
|
|
38
37
|
});
|
|
39
38
|
try {
|
|
40
39
|
await client.connect(transport);
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface CliHandlers {
|
|
2
|
+
hook(): Promise<number>;
|
|
3
|
+
installer(args: string[]): Promise<void>;
|
|
4
|
+
mcp(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function runCli(
|
|
8
|
+
args: string[],
|
|
9
|
+
handlers: CliHandlers,
|
|
10
|
+
): Promise<number | undefined> {
|
|
11
|
+
const [command, ...rest] = args;
|
|
12
|
+
if (command === "mcp") {
|
|
13
|
+
await handlers.mcp();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (command === "hook") {
|
|
17
|
+
return handlers.hook();
|
|
18
|
+
}
|
|
19
|
+
if (["install", "update", "uninstall"].includes(command ?? "")) {
|
|
20
|
+
await handlers.installer([command as string, ...rest]);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
throw new Error(
|
|
24
|
+
"Usage: ast-mcp <install|update|uninstall|hook|mcp> [options]",
|
|
25
|
+
);
|
|
26
|
+
}
|
package/src/installer.ts
CHANGED
|
@@ -12,7 +12,7 @@ import path from "node:path";
|
|
|
12
12
|
import { isManagedHook } from "./managed-hook";
|
|
13
13
|
|
|
14
14
|
const packageRoot = path.resolve(import.meta.dir, "..");
|
|
15
|
-
const
|
|
15
|
+
const cliEntry = path.join(packageRoot, "dist/ast-mcp.js");
|
|
16
16
|
const hookEntry = path.join(packageRoot, "src/hook.ts");
|
|
17
17
|
const targets = ["codex", "claude", "copilot"] as const;
|
|
18
18
|
type Target = (typeof targets)[number];
|
|
@@ -32,14 +32,9 @@ async function save(file: string, value: unknown) {
|
|
|
32
32
|
}
|
|
33
33
|
function definition(root?: string) {
|
|
34
34
|
return {
|
|
35
|
-
args: ["
|
|
35
|
+
args: [cliEntry, "mcp"],
|
|
36
36
|
command: "bun",
|
|
37
|
-
env: root
|
|
38
|
-
? {
|
|
39
|
-
AST_MCP_ALLOW_EXTERNAL_ROOTS: "1",
|
|
40
|
-
AST_MCP_ROOTS: root,
|
|
41
|
-
}
|
|
42
|
-
: {},
|
|
37
|
+
env: root ? { AST_MCP_ALLOW_EXTERNAL_ROOTS: "1", AST_MCP_ROOTS: root } : {},
|
|
43
38
|
};
|
|
44
39
|
}
|
|
45
40
|
async function codexMcp(file: string, root?: string) {
|
|
@@ -50,7 +45,7 @@ async function codexMcp(file: string, root?: string) {
|
|
|
50
45
|
const environment = root
|
|
51
46
|
? `env = { AST_MCP_ALLOW_EXTERNAL_ROOTS = "1", AST_MCP_ROOTS = ${JSON.stringify(root)} }\n`
|
|
52
47
|
: "";
|
|
53
|
-
const block = `# ast-mcp:begin\n[mcp_servers.ast-mcp]\ncommand = "bun"\nargs = [
|
|
48
|
+
const block = `# ast-mcp:begin\n[mcp_servers.ast-mcp]\ncommand = "bun"\nargs = [${JSON.stringify(cliEntry)}, "mcp"]\n${environment}# ast-mcp:end`;
|
|
54
49
|
await mkdir(path.dirname(file), { recursive: true });
|
|
55
50
|
await writeFile(file, `${clean ? `${clean}\n\n` : ""}${block}\n`);
|
|
56
51
|
}
|
|
@@ -77,15 +72,14 @@ async function hook(
|
|
|
77
72
|
file: string,
|
|
78
73
|
event: "PreToolUse" | "preToolUse",
|
|
79
74
|
scriptFile: string,
|
|
80
|
-
|
|
75
|
+
_commandPath?: string,
|
|
81
76
|
) {
|
|
82
|
-
await
|
|
83
|
-
await cp(hookEntry, scriptFile, { force: true });
|
|
77
|
+
await rm(scriptFile, { force: true });
|
|
84
78
|
const value = await json(file);
|
|
85
79
|
if (event === "preToolUse") value.version ??= 1;
|
|
86
80
|
value.hooks ??= {};
|
|
87
81
|
const prior = Array.isArray(value.hooks[event]) ? value.hooks[event] : [];
|
|
88
|
-
const command = `bun ${JSON.stringify(
|
|
82
|
+
const command = `bun ${JSON.stringify(cliEntry)} hook`;
|
|
89
83
|
const kept = prior.filter(
|
|
90
84
|
(item: unknown) => !isManagedHook(item, event, command),
|
|
91
85
|
);
|
|
@@ -201,9 +195,13 @@ async function removeHook(
|
|
|
201
195
|
const value = await json(file);
|
|
202
196
|
const hooks = value.hooks;
|
|
203
197
|
if (!hooks || !Array.isArray(hooks[event])) return;
|
|
204
|
-
const
|
|
198
|
+
const commands = [
|
|
199
|
+
`bun ${JSON.stringify(commandPath)}`,
|
|
200
|
+
`bun ${JSON.stringify(cliEntry)} hook`,
|
|
201
|
+
];
|
|
205
202
|
hooks[event] = hooks[event].filter(
|
|
206
|
-
(item: unknown) =>
|
|
203
|
+
(item: unknown) =>
|
|
204
|
+
!commands.some((command) => isManagedHook(item, event, command)),
|
|
207
205
|
);
|
|
208
206
|
if (hooks[event].length === 0) delete hooks[event];
|
|
209
207
|
if (Object.keys(hooks).length === 0) delete value.hooks;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export const PACKAGE_ROOT = path.resolve(
|
|
6
|
+
import.meta.dir,
|
|
7
|
+
path.basename(import.meta.dir) === "dist" ? ".." : "../..",
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const astBroWrapper = path.join(PACKAGE_ROOT, "node_modules/.bin/ast-bro");
|
|
11
|
+
const astBroInstaller = createRequire(import.meta.url)(
|
|
12
|
+
path.join(path.dirname(realpathSync(astBroWrapper)), "install.js"),
|
|
13
|
+
) as { getBinaryPath: () => string };
|
|
14
|
+
|
|
15
|
+
export const AST_BRO_BINARY =
|
|
16
|
+
process.env.AST_BRO_BINARY ?? astBroInstaller.getBinaryPath();
|
|
17
|
+
|
|
18
|
+
export const DPRINT_BINARY =
|
|
19
|
+
process.env.DPRINT_BINARY ??
|
|
20
|
+
path.join(PACKAGE_ROOT, "node_modules/.bin/dprint");
|
package/src/runtime/format.ts
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { runCommandInput } from "./process-input";
|
|
12
12
|
|
|
13
|
-
const packageRoot =
|
|
14
|
-
|
|
13
|
+
const { DPRINT_BINARY: dprint, PACKAGE_ROOT: packageRoot } = await import(
|
|
14
|
+
"./dependencies"
|
|
15
|
+
);
|
|
15
16
|
const dprintConfig =
|
|
16
17
|
process.env.AST_MCP_DPRINT_CONFIG ?? path.join(packageRoot, "dprint.json");
|
|
17
18
|
|
|
@@ -12,23 +12,29 @@ Replace `codex` with `claude` or `copilot`. For a global installation, pass `--s
|
|
|
12
12
|
|
|
13
13
|
## Install from this package checkout
|
|
14
14
|
|
|
15
|
-
When the `@mwillbanks/ast-mcp` source checkout is already available:
|
|
15
|
+
When the `@mwillbanks/ast-mcp` source checkout is already available, install its dependencies and build the stable CLI before configuring a host:
|
|
16
16
|
|
|
17
|
-
`bun
|
|
17
|
+
`bun install && bun run build`
|
|
18
|
+
|
|
19
|
+
`bun run bin/ast-mcp.ts install --scope local --target all --root "$PWD"`
|
|
18
20
|
|
|
19
21
|
For one host globally:
|
|
20
22
|
|
|
21
|
-
`bun run bin/ast-mcp
|
|
23
|
+
`bun run bin/ast-mcp.ts install --scope global --target codex`
|
|
22
24
|
|
|
23
25
|
Targets are `codex`, `claude`, `copilot`, or `all`.
|
|
24
26
|
|
|
25
27
|
## Install from the published package
|
|
26
28
|
|
|
27
|
-
If the package is not already installed, obtain user authorization before allowing Bun to download or install it.
|
|
29
|
+
If the package is not already installed, obtain user authorization before allowing Bun to download or install it. Install it into the repository so `@ast-bro/cli` and `dprint` remain available, then run the installed CLI:
|
|
30
|
+
|
|
31
|
+
`bun add --dev @mwillbanks/ast-mcp`
|
|
32
|
+
|
|
33
|
+
`bun pm trust @ast-bro/cli dprint`
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
`./node_modules/.bin/ast-mcp install --scope local --target all --root "$PWD"`
|
|
30
36
|
|
|
31
|
-
For a global host surface,
|
|
37
|
+
For a global host surface, use `bun add --global --trust @ast-bro/cli dprint @mwillbanks/ast-mcp` followed by `ast-mcp install --scope global --target codex`. Bun blocks transitive lifecycle scripts by default; explicitly trusting `@ast-bro/cli` and `dprint` runs their pinned native installers instead of leaving stale or missing cache paths. Do not use an ephemeral package executor for host installation because its temporary package path can disappear after configuration is written. The installer records the stable installed CLI and uses its `mcp` and `hook` subcommands. For a local installation, run `./node_modules/.bin/ast-mcp update` to refresh managed surfaces and `./node_modules/.bin/ast-mcp uninstall` to remove them; global installations use `ast-mcp update` and `ast-mcp uninstall`.
|
|
32
38
|
|
|
33
39
|
## Activate and verify
|
|
34
40
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { isManagedHook } from "./managed-hook";
|
|
6
5
|
|
|
7
6
|
type Scope = "local" | "global";
|
|
8
7
|
type Target = "codex" | "claude" | "copilot";
|
|
@@ -29,7 +28,7 @@ const instructionsBegin = "<!-- ast-mcp:begin -->";
|
|
|
29
28
|
const instructionsEnd = "<!-- ast-mcp:end -->";
|
|
30
29
|
|
|
31
30
|
async function astMcpEntry(entry: unknown): Promise<boolean> {
|
|
32
|
-
if (typeof entry !== "string" || path.basename(entry) !== "
|
|
31
|
+
if (typeof entry !== "string" || path.basename(entry) !== "ast-mcp.js")
|
|
33
32
|
return false;
|
|
34
33
|
let folder = path.dirname(path.resolve(entry));
|
|
35
34
|
while (true) {
|
|
@@ -39,7 +38,7 @@ async function astMcpEntry(entry: unknown): Promise<boolean> {
|
|
|
39
38
|
);
|
|
40
39
|
return (
|
|
41
40
|
manifest.name === "@mwillbanks/ast-mcp" &&
|
|
42
|
-
path.resolve(entry) === path.join(folder, "
|
|
41
|
+
path.resolve(entry) === path.join(folder, "dist/ast-mcp.js")
|
|
43
42
|
);
|
|
44
43
|
} catch {}
|
|
45
44
|
const parent = path.dirname(folder);
|
|
@@ -89,21 +88,30 @@ async function skillCurrent(file: string) {
|
|
|
89
88
|
async function hookCurrent(
|
|
90
89
|
configFile: string,
|
|
91
90
|
event: "PreToolUse" | "preToolUse",
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
_scriptFile: string,
|
|
92
|
+
_commandPath?: string,
|
|
94
93
|
) {
|
|
95
94
|
const config = JSON.parse(
|
|
96
95
|
await readFile(configFile, "utf8").catch(() => "{}"),
|
|
97
96
|
);
|
|
98
|
-
const script = await readFile(scriptFile, "utf8").catch(() => "");
|
|
99
|
-
const command = `bun ${JSON.stringify(commandPath)}`;
|
|
100
97
|
const entries = Array.isArray(config.hooks?.[event])
|
|
101
98
|
? config.hooks[event]
|
|
102
99
|
: [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const commands =
|
|
101
|
+
event === "preToolUse"
|
|
102
|
+
? entries.map((item: { command?: unknown }) => item.command)
|
|
103
|
+
: entries.flatMap((item: { hooks?: Array<{ command?: unknown }> }) =>
|
|
104
|
+
(item.hooks ?? []).map((child) => child.command),
|
|
105
|
+
);
|
|
106
|
+
for (const command of commands) {
|
|
107
|
+
if (typeof command !== "string") continue;
|
|
108
|
+
const match = command.match(/^bun (.+) hook$/);
|
|
109
|
+
if (!match) continue;
|
|
110
|
+
try {
|
|
111
|
+
if (await astMcpEntry(JSON.parse(match[1]))) return true;
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
async function jsonMcpCurrent(
|
|
@@ -117,8 +125,8 @@ async function jsonMcpCurrent(
|
|
|
117
125
|
if (
|
|
118
126
|
entry?.command !== "bun" ||
|
|
119
127
|
!Array.isArray(entry.args) ||
|
|
120
|
-
entry.args[0]
|
|
121
|
-
|
|
128
|
+
!(await astMcpEntry(entry.args[0])) ||
|
|
129
|
+
entry.args[1] !== "mcp"
|
|
122
130
|
)
|
|
123
131
|
return false;
|
|
124
132
|
if (type && entry.type !== type) return false;
|
|
@@ -137,16 +145,18 @@ async function codexMcpCurrent(file: string, root?: string) {
|
|
|
137
145
|
const content = await readFile(file, "utf8").catch(() => "");
|
|
138
146
|
const block =
|
|
139
147
|
content.match(/# ast-mcp:begin\n([\s\S]*?)# ast-mcp:end/)?.[1] ?? "";
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
block.includes(
|
|
143
|
-
block.includes('
|
|
144
|
-
|
|
145
|
-
(
|
|
146
|
-
|
|
148
|
+
const args = block.match(/args = \[(".*"), "mcp"\]/);
|
|
149
|
+
if (
|
|
150
|
+
!block.includes("[mcp_servers.ast-mcp]") ||
|
|
151
|
+
!block.includes('command = "bun"') ||
|
|
152
|
+
!args ||
|
|
153
|
+
!(await astMcpEntry(JSON.parse(args[1])))
|
|
154
|
+
)
|
|
155
|
+
return false;
|
|
156
|
+
return root
|
|
157
|
+
? block.includes(`AST_MCP_ROOTS = ${JSON.stringify(root)}`) &&
|
|
147
158
|
block.includes('AST_MCP_ALLOW_EXTERNAL_ROOTS = "1"')
|
|
148
|
-
|
|
149
|
-
);
|
|
159
|
+
: !block.includes("AST_MCP_ROOTS");
|
|
150
160
|
}
|
|
151
161
|
export async function checkInstall(
|
|
152
162
|
args = process.argv.slice(2),
|
|
@@ -245,8 +255,15 @@ export async function checkInstall(
|
|
|
245
255
|
? "update"
|
|
246
256
|
: "install";
|
|
247
257
|
const suffix = `--scope ${options.scope} --target ${options.target}${global ? "" : ` --root ${JSON.stringify(options.root)}`}`;
|
|
248
|
-
const installCommand =
|
|
249
|
-
|
|
258
|
+
const installCommand = global
|
|
259
|
+
? `bun add --global --trust @ast-bro/cli dprint @mwillbanks/ast-mcp && ast-mcp install ${suffix}`
|
|
260
|
+
: `bun add --dev @mwillbanks/ast-mcp && bun pm trust @ast-bro/cli dprint && ./node_modules/.bin/ast-mcp install ${suffix}`;
|
|
261
|
+
const updateCommand = global
|
|
262
|
+
? `ast-mcp update ${suffix}`
|
|
263
|
+
: `./node_modules/.bin/ast-mcp update ${suffix}`;
|
|
264
|
+
const uninstallCommand = global
|
|
265
|
+
? `ast-mcp uninstall ${suffix}`
|
|
266
|
+
: `./node_modules/.bin/ast-mcp uninstall ${suffix}`;
|
|
250
267
|
return {
|
|
251
268
|
checks,
|
|
252
269
|
installCommand,
|
|
@@ -259,6 +276,7 @@ export async function checkInstall(
|
|
|
259
276
|
: operation === "install"
|
|
260
277
|
? installCommand
|
|
261
278
|
: undefined,
|
|
279
|
+
uninstallCommand,
|
|
262
280
|
updateCommand,
|
|
263
281
|
...options,
|
|
264
282
|
};
|
package/dist/ast-mcp-hook.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
// @bun
|
|
3
|
-
var m=Object.create;var{getPrototypeOf:h,defineProperty:c,getOwnPropertyNames:w}=Object;var f=Object.prototype.hasOwnProperty;function k(e){return this[e]}var b,y,I=(e,t,s)=>{var o=e!=null&&typeof e==="object";if(o){var i=t?b??=new WeakMap:y??=new WeakMap,d=i.get(e);if(d)return d}s=e!=null?m(h(e)):{};let n=t||!e||!e.__esModule?c(s,"default",{value:e,enumerable:!0}):s;for(let r of w(e))if(!f.call(n,r))c(n,r,{get:k.bind(e,r),enumerable:!0});if(o)i.set(e,n);return n};var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var g=(e)=>e;function _(e,t){this[e]=g.bind(null,t)}var x=(e,t)=>{for(var s in t)c(e,s,{get:t[s],enumerable:!0,configurable:!0,set:_.bind(t,s)})};var D=(e,t)=>()=>(e&&(t=e(e=0)),t);var z=import.meta.require;var l={};x(l,{runHook:()=>A,evaluateHook:()=>p,decisionPayload:()=>a});function p(e){let t=String(e.tool_name??e.toolName??e.name??"");if(E.test(t))return{denied:!0,reason:"Direct file editing is blocked. Use ast-mcp."};if(!N.test(t))return{denied:!1};let s=e.tool_input??e.toolInput??e.toolArgs??e.input??e.args,o=s&&typeof s==="object"?s:{},i=typeof s==="string"?s:String(o.cmd??o.command??o.script??o.source??o.code??"");return i&&(F.test(i)||S.test(i)||$.test(i))?{denied:!0,reason:"Direct file mutation is blocked. Use ast-mcp."}:{denied:!1}}function a(e){if(!e.denied)return{};return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e.reason},permissionDecision:"deny",permissionDecisionReason:e.reason}}async function A(e=Bun.stdin.json()){try{return process.stdout.write(`${JSON.stringify(a(p(await e)))}
|
|
4
|
-
`),0}catch(t){return process.stdout.write(`${JSON.stringify(a({denied:!0,reason:`Invalid hook input: ${String(t)}`}))}
|
|
5
|
-
`),2}}var E,F,N,S,$;var u=D(async()=>{E=/^(?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)$/,F=/tools(?:\.(?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)|\s*\[\s*["'](?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)["']\s*\])\s*\(/,N=/^(?:bash|shell|terminal|exec|functions\.exec|mcp__functions__exec|codex\.exec|exec_command|functions\.exec_command|Bash|powershell|PowerShell)$/,S=/(?:^|[;&|]\s*|["'`]\s*|:\s*["'`]\s*)(?:(?:env(?:\s+(?:--?[^\s"'`]+|[A-Za-z_][A-Za-z0-9_]*=[^\s"'`]+))*|command|sudo(?:\s+--?[^\s"'`]+)*|nice(?:\s+--?[^\s"'`]+)*|nohup|busybox)\s+)*(?:(?:\/[^\s/"'`]+)*\/)?(?:apply_patch|patch|tee|truncate|touch|rm|mv|cp|install|dd|ed|awk|mkdir|rmdir|chmod|chown|python\d*|node|ruby|perl|php|sed|ast-grep)(?=\s|["'`]|$)|(?:^|[;&|]\s*|["'`]\s*|:\s*["'`]\s*)(?:find\b[^\n]*\s-delete\b|xargs\s+(?:[^\n]*\s)?rm\b|git(?:\s+(?:-[A-Za-z]\s+[^\s"'`]+|--?[^\s"'`]+))*\s+(?:apply|checkout|restore|reset|clean)|dprint\s+fmt|bun\s+(?:-e|--eval)|(?:Set|Add)-Content|Out-File|Remove-Item|Move-Item|Copy-Item|New-Item)(?=\s|["'`]|$)|(?:^|[^<\d>])>{1,2}(?!=)|<<[-~]?\s*\w/i,$=/(?:bash|sh|zsh|dash|ksh|fish|pwsh|powershell|node|python\d*|ruby|perl|php)(?:["']|\s)+(?:--?[A-Za-z][A-Za-z0-9-]*(?:=[^\s"']+)?(?:["']|\s)+)*(?:-c|--command|-Command|-e|--eval)(?=\s|["']|$)/i});var{runHook:H}=await u().then(() => l);process.exit(await H());
|
|
6
|
-
|
|
7
|
-
//# debugId=A50CC32E164588DC64756E2164756E21
|
package/dist/ast-mcp-hook.js.map
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/hook.ts", "../bin/ast-mcp-hook.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"const direct =\n /^(?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)$/;\nconst nestedDirect =\n /tools(?:\\.(?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)|\\s*\\[\\s*[\"'](?:apply_patch|edit|editFiles|create|createFile|write|writeFile|replace|str_replace|MultiEdit|Edit|Write|NotebookEdit)[\"']\\s*\\])\\s*\\(/;\nconst shell =\n /^(?:bash|shell|terminal|exec|functions\\.exec|mcp__functions__exec|codex\\.exec|exec_command|functions\\.exec_command|Bash|powershell|PowerShell)$/;\nconst mutation =\n /(?:^|[;&|]\\s*|[\"'`]\\s*|:\\s*[\"'`]\\s*)(?:(?:env(?:\\s+(?:--?[^\\s\"'`]+|[A-Za-z_][A-Za-z0-9_]*=[^\\s\"'`]+))*|command|sudo(?:\\s+--?[^\\s\"'`]+)*|nice(?:\\s+--?[^\\s\"'`]+)*|nohup|busybox)\\s+)*(?:(?:\\/[^\\s/\"'`]+)*\\/)?(?:apply_patch|patch|tee|truncate|touch|rm|mv|cp|install|dd|ed|awk|mkdir|rmdir|chmod|chown|python\\d*|node|ruby|perl|php|sed|ast-grep)(?=\\s|[\"'`]|$)|(?:^|[;&|]\\s*|[\"'`]\\s*|:\\s*[\"'`]\\s*)(?:find\\b[^\\n]*\\s-delete\\b|xargs\\s+(?:[^\\n]*\\s)?rm\\b|git(?:\\s+(?:-[A-Za-z]\\s+[^\\s\"'`]+|--?[^\\s\"'`]+))*\\s+(?:apply|checkout|restore|reset|clean)|dprint\\s+fmt|bun\\s+(?:-e|--eval)|(?:Set|Add)-Content|Out-File|Remove-Item|Move-Item|Copy-Item|New-Item)(?=\\s|[\"'`]|$)|(?:^|[^<\\d>])>{1,2}(?!=)|<<[-~]?\\s*\\w/i;\n\nconst nestedInterpreter =\n /(?:bash|sh|zsh|dash|ksh|fish|pwsh|powershell|node|python\\d*|ruby|perl|php)(?:[\"']|\\s)+(?:--?[A-Za-z][A-Za-z0-9-]*(?:=[^\\s\"']+)?(?:[\"']|\\s)+)*(?:-c|--command|-Command|-e|--eval)(?=\\s|[\"']|$)/i;\nexport interface HookDecision {\n denied: boolean;\n reason?: string;\n}\nexport function evaluateHook(event: Record<string, unknown>): HookDecision {\n const name = String(event.tool_name ?? event.toolName ?? event.name ?? \"\");\n if (direct.test(name))\n return {\n denied: true,\n reason: \"Direct file editing is blocked. Use ast-mcp.\",\n };\n if (!shell.test(name)) return { denied: false };\n const raw =\n event.tool_input ??\n event.toolInput ??\n event.toolArgs ??\n event.input ??\n event.args;\n const input =\n raw && typeof raw === \"object\" ? (raw as Record<string, unknown>) : {};\n const command =\n typeof raw === \"string\"\n ? raw\n : String(\n input.cmd ??\n input.command ??\n input.script ??\n input.source ??\n input.code ??\n \"\",\n );\n return command &&\n (nestedDirect.test(command) ||\n mutation.test(command) ||\n nestedInterpreter.test(command))\n ? { denied: true, reason: \"Direct file mutation is blocked. Use ast-mcp.\" }\n : { denied: false };\n}\nexport function decisionPayload(\n decision: HookDecision,\n): Record<string, unknown> {\n if (!decision.denied) return {};\n return {\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: decision.reason,\n },\n permissionDecision: \"deny\",\n permissionDecisionReason: decision.reason,\n };\n}\nexport async function runHook(\n input: Promise<Record<string, unknown>> = Bun.stdin.json(),\n): Promise<number> {\n try {\n process.stdout.write(\n `${JSON.stringify(decisionPayload(evaluateHook(await input)))}\\n`,\n );\n return 0;\n } catch (error) {\n process.stdout.write(\n `${JSON.stringify(decisionPayload({ denied: true, reason: `Invalid hook input: ${String(error)}` }))}\\n`,\n );\n return 2;\n }\n}\nif (import.meta.main) process.exit(await runHook());\n",
|
|
6
|
-
"#!/usr/bin/env bun\nconst { runHook } = await import(\"../src/hook\");\nprocess.exit(await runHook());\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": ";;yyBAeO,SAAS,CAAY,CAAC,EAA8C,CACzE,IAAM,EAAO,OAAO,EAAM,WAAa,EAAM,UAAY,EAAM,MAAQ,EAAE,EACzE,GAAI,EAAO,KAAK,CAAI,EAClB,MAAO,CACL,OAAQ,GACR,OAAQ,8CACV,EACF,GAAI,CAAC,EAAM,KAAK,CAAI,EAAG,MAAO,CAAE,OAAQ,EAAM,EAC9C,IAAM,EACJ,EAAM,YACN,EAAM,WACN,EAAM,UACN,EAAM,OACN,EAAM,KACF,EACJ,GAAO,OAAO,IAAQ,SAAY,EAAkC,CAAC,EACjE,EACJ,OAAO,IAAQ,SACX,EACA,OACE,EAAM,KACJ,EAAM,SACN,EAAM,QACN,EAAM,QACN,EAAM,MACN,EACJ,EACN,OAAO,IACJ,EAAa,KAAK,CAAO,GACxB,EAAS,KAAK,CAAO,GACrB,EAAkB,KAAK,CAAO,GAC9B,CAAE,OAAQ,GAAM,OAAQ,+CAAgD,EACxE,CAAE,OAAQ,EAAM,EAEf,SAAS,CAAe,CAC7B,EACyB,CACzB,GAAI,CAAC,EAAS,OAAQ,MAAO,CAAC,EAC9B,MAAO,CACL,mBAAoB,CAClB,cAAe,aACf,mBAAoB,OACpB,yBAA0B,EAAS,MACrC,EACA,mBAAoB,OACpB,yBAA0B,EAAS,MACrC,EAEF,eAAsB,CAAO,CAC3B,EAA0C,IAAI,MAAM,KAAK,EACxC,CACjB,GAAI,CAIF,OAHA,QAAQ,OAAO,MACb,GAAG,KAAK,UAAU,EAAgB,EAAa,MAAM,CAAK,CAAC,CAAC;AAAA,CAC9D,EACO,EACP,MAAO,EAAO,CAId,OAHA,QAAQ,OAAO,MACb,GAAG,KAAK,UAAU,EAAgB,CAAE,OAAQ,GAAM,OAAQ,uBAAuB,OAAO,CAAK,GAAI,CAAC,CAAC;AAAA,CACrG,EACO,OA3EL,EAEA,EAEA,EAEA,EAGA,oBATA,EACJ,2HACI,EACJ,qRACI,EACJ,kJACI,EACJ,mrBAEI,EACJ,mMCTF,IAAQ,WAAY,wBACpB,QAAQ,KAAK,MAAM,EAAQ,CAAC",
|
|
9
|
-
"debugId": "A50CC32E164588DC64756E2164756E21",
|
|
10
|
-
"names": []
|
|
11
|
-
}
|
package/dist/ast-mcp-install.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
// @bun
|
|
3
|
-
var i=Object.create;var{getPrototypeOf:l,defineProperty:S,getOwnPropertyNames:a}=Object;var t=Object.prototype.hasOwnProperty;function o(q){return this[q]}var e,UU,_U=(q,U,C)=>{var w=q!=null&&typeof q==="object";if(w){var G=U?e??=new WeakMap:UU??=new WeakMap,K=G.get(q);if(K)return K}C=q!=null?i(l(q)):{};let Q=U||!q||!q.__esModule?S(C,"default",{value:q,enumerable:!0}):C;for(let D of a(q))if(!t.call(Q,D))S(Q,D,{get:o.bind(q,D),enumerable:!0});if(w)G.set(q,Q);return Q};var $U=(q,U)=>()=>(U||q((U={exports:{}}).exports,U),U.exports);var AU=(q)=>q;function qU(q,U){this[q]=AU.bind(null,U)}var wU=(q,U)=>{for(var C in U)S(q,C,{get:U[C],enumerable:!0,configurable:!0,set:qU.bind(U,C)})};var F=(q,U)=>()=>(q&&(U=q(q=0)),U);var yU=import.meta.require;function $(q,U,C){if(!q||typeof q!=="object")return!1;let w=q;if(U==="preToolUse")return w.command===C&&w.type==="command";return Array.isArray(w.hooks)&&w.hooks.some((G)=>G&&typeof G==="object"&&G.command===C&&G.type==="command")}var u=()=>{};var p={};wU(p,{update:()=>n,uninstall:()=>r,runInstallerCli:()=>YU,install:()=>h});import{cp as Y,lstat as DU,mkdir as _,readdir as GU,readFile as W,rm as V,writeFile as R}from"fs/promises";import k from"os";import A from"path";async function X(q){try{return JSON.parse(await W(q,"utf8"))}catch(U){if(U.code==="ENOENT")return{};throw U}}async function N(q,U){await _(A.dirname(q),{recursive:!0}),await R(q,`${JSON.stringify(U,null,2)}
|
|
4
|
-
`)}function P(q){return{args:["--hot",d],command:"bun",env:q?{AST_MCP_ALLOW_EXTERNAL_ROOTS:"1",AST_MCP_ROOTS:q}:{}}}async function KU(q,U){let w=(await W(q,"utf8").catch(()=>"")).replace(/# ast-mcp:begin[\s\S]*?# ast-mcp:end\n?/g,"").trimEnd(),G=U?`env = { AST_MCP_ALLOW_EXTERNAL_ROOTS = "1", AST_MCP_ROOTS = ${JSON.stringify(U)} }
|
|
5
|
-
`:"",K=`# ast-mcp:begin
|
|
6
|
-
[mcp_servers.ast-mcp]
|
|
7
|
-
command = "bun"
|
|
8
|
-
args = ["--hot", ${JSON.stringify(d)}]
|
|
9
|
-
${G}# ast-mcp:end`;await _(A.dirname(q),{recursive:!0}),await R(q,`${w?`${w}
|
|
10
|
-
|
|
11
|
-
`:""}${K}
|
|
12
|
-
`)}async function H(q,U,C=!1){let w=await X(q);w.mcpServers={...w.mcpServers??{},"ast-mcp":C?{type:"local",...P(U),tools:["*"]}:P(U)},await N(q,w)}async function QU(q,U){let C=await X(q);C.servers={...C.servers??{},"ast-mcp":{type:"stdio",...P(U)}},await N(q,C)}async function E(q,U,C,w=C){await _(A.dirname(C),{recursive:!0}),await Y(g,C,{force:!0});let G=await X(q);if(U==="preToolUse")G.version??=1;G.hooks??={};let K=Array.isArray(G.hooks[U])?G.hooks[U]:[],Q=`bun ${JSON.stringify(w)}`,D=K.filter((T)=>!$(T,U,Q)),M=U==="preToolUse"?{command:Q,matcher:"bash|powershell|edit|create",timeoutSec:10,type:"command"}:{hooks:[{command:Q,statusMessage:"Enforcing ast-mcp writes",timeout:10,type:"command"}],matcher:".*"};G.hooks[U]=[...D,M],await N(q,G)}async function I(q){let U=A.join(q,"ast-mcp");await V(U,{force:!0,recursive:!0}),await _(q,{recursive:!0}),await Y(A.join(Z,"templates/skills","ast-mcp"),U,{filter:(C)=>A.basename(C)!==".ast-bro",force:!0,recursive:!0}),await Y(A.join(Z,"templates/AGENTS.md"),A.join(U,"references/agents-guidance.md"),{force:!0}),await Y(g,A.join(U,"references/hook.ts"),{force:!0}),await Y(A.join(U,"SKILL.md"),A.join(U,"references/skill-template.md"),{force:!0})}async function j(q,U){let C=U.trimEnd();if(!C){await V(q,{force:!0});return}await _(A.dirname(q),{recursive:!0}),await R(q,`${C}
|
|
13
|
-
`)}async function O(q){let U=(await W(A.join(Z,"templates/AGENTS.md"),"utf8")).trim(),w=(await W(q,"utf8").catch(()=>"")).replace(v,"").trimEnd();await j(q,`${w?`${w}
|
|
14
|
-
|
|
15
|
-
`:""}${TU}
|
|
16
|
-
|
|
17
|
-
${U}
|
|
18
|
-
|
|
19
|
-
${VU}`)}async function y(q){let U=await W(q,"utf8").catch(()=>"");await j(q,U.replace(v,""))}async function c(q,U){if(Object.keys(U).length===0){await V(q,{force:!0});return}await N(q,U)}async function B(q,U="mcpServers"){let C=await X(q),w=C[U];if(!w||typeof w!=="object"||!("ast-mcp"in w))return;if(delete w["ast-mcp"],Object.keys(w).length===0)delete C[U];await c(q,C)}async function WU(q){let U=await W(q,"utf8").catch(()=>"");await j(q,U.replace(/# ast-mcp:begin[\s\S]*?# ast-mcp:end\n?/g,""))}async function J(q,U,C){let w=await X(q),G=w.hooks;if(!G||!Array.isArray(G[U]))return;let K=`bun ${JSON.stringify(C)}`;if(G[U]=G[U].filter((Q)=>!$(Q,U,K)),G[U].length===0)delete G[U];if(Object.keys(G).length===0)delete w.hooks;await c(q,w)}async function XU(q){let U=await W(A.join(q,".codex/config.toml"),"utf8").catch(()=>""),C=await X(A.join(q,".mcp.json")),w=await X(A.join(q,".github/mcp.json"));return Boolean(U.includes("# ast-mcp:begin")||C.mcpServers?.["ast-mcp"]||w.mcpServers?.["ast-mcp"])}function m(q,U,C,w){if(q==="codex"){let K=U?A.join(w,".codex"):A.join(C,".codex");return[A.join(K,"config.toml"),A.join(K,"hooks.json"),A.join(K,"hooks/ast-mcp.ts"),A.join(K,"skills/ast-mcp"),U?A.join(K,"AGENTS.md"):A.join(C,"AGENTS.md")]}if(q==="claude"){let K=U?A.join(w,".claude"):A.join(C,".claude");return[U?A.join(w,".claude.json"):A.join(C,".mcp.json"),A.join(K,"settings.json"),A.join(K,"hooks/ast-mcp.ts"),A.join(K,"skills/ast-mcp"),U?A.join(K,"CLAUDE.md"):A.join(C,"AGENTS.md")]}let G=U?A.join(w,".copilot"):A.join(C,".github");return[U?A.join(G,"mcp-config.json"):A.join(C,".github/mcp.json"),...U?[]:[A.join(C,".vscode/mcp.json")],A.join(G,"hooks/ast-mcp.json"),A.join(G,"hooks/ast-mcp.ts"),A.join(G,"skills/ast-mcp"),U?A.join(G,"copilot-instructions.md"):A.join(C,"AGENTS.md")]}async function L(q){let U=new Map,C=async(w)=>{if(A.basename(w)===".ast-bro")return;let G=await DU(w).catch(()=>{return});if(!G)return;if(G.isDirectory()){for(let K of await GU(w))await C(A.join(w,K));return}if(G.isFile())U.set(w,(await W(w)).toString("base64"))};return await Promise.all(q.map(C)),U}function f(q,U){return[...new Set([...q.keys(),...U.keys()])].filter((C)=>q.get(C)!==U.get(C)).sort()}async function b(q){let U=A.resolve(q.root),C=q.home??k.homedir(),w=q.scope==="global",G=q.targets.flatMap((Q)=>m(Q,w,U,C)),K=await L(G);for(let Q of q.targets)if(Q==="codex"){let D=w?A.join(C,".codex"):A.join(U,".codex");await KU(A.join(D,"config.toml"),w?void 0:U),await E(A.join(D,"hooks.json"),"PreToolUse",A.join(D,"hooks/ast-mcp.ts"),w?A.join(D,"hooks/ast-mcp.ts"):".codex/hooks/ast-mcp.ts"),await I(A.join(D,"skills")),await O(w?A.join(D,"AGENTS.md"):A.join(U,"AGENTS.md"))}else if(Q==="claude"){let D=w?A.join(C,".claude"):A.join(U,".claude");await H(w?A.join(C,".claude.json"):A.join(U,".mcp.json"),w?void 0:U),await E(A.join(D,"settings.json"),"PreToolUse",A.join(D,"hooks/ast-mcp.ts"),w?A.join(D,"hooks/ast-mcp.ts"):"${CLAUDE_PROJECT_DIR}/.claude/hooks/ast-mcp.ts"),await I(A.join(D,"skills")),await O(w?A.join(D,"CLAUDE.md"):A.join(U,"AGENTS.md"))}else{let D=w?A.join(C,".copilot"):A.join(U,".github");if(w)await H(A.join(D,"mcp-config.json"),void 0,!0);else await H(A.join(U,".github/mcp.json"),U,!0),await QU(A.join(U,".vscode/mcp.json"),U);await E(A.join(D,"hooks/ast-mcp.json"),"preToolUse",A.join(D,"hooks/ast-mcp.ts"),w?A.join(D,"hooks/ast-mcp.ts"):".github/hooks/ast-mcp.ts"),await I(A.join(D,"skills")),await O(w?A.join(D,"copilot-instructions.md"):A.join(U,"AGENTS.md"))}return f(K,await L(G))}async function h(q){return b(q)}async function n(q){return b(q)}async function r(q){let U=A.resolve(q.root),C=q.home??k.homedir(),w=q.scope==="global",G=q.targets.flatMap((Q)=>m(Q,w,U,C)),K=await L(G);for(let Q of q.targets)if(Q==="codex"){let D=w?A.join(C,".codex"):A.join(U,".codex");if(await WU(A.join(D,"config.toml")),await J(A.join(D,"hooks.json"),"PreToolUse",w?A.join(D,"hooks/ast-mcp.ts"):".codex/hooks/ast-mcp.ts"),await V(A.join(D,"hooks/ast-mcp.ts"),{force:!0}),await V(A.join(D,"skills/ast-mcp"),{force:!0,recursive:!0}),w)await y(A.join(D,"AGENTS.md"))}else if(Q==="claude"){let D=w?A.join(C,".claude"):A.join(U,".claude");if(await B(w?A.join(C,".claude.json"):A.join(U,".mcp.json")),await J(A.join(D,"settings.json"),"PreToolUse",w?A.join(D,"hooks/ast-mcp.ts"):"${CLAUDE_PROJECT_DIR}/.claude/hooks/ast-mcp.ts"),await V(A.join(D,"hooks/ast-mcp.ts"),{force:!0}),await V(A.join(D,"skills/ast-mcp"),{force:!0,recursive:!0}),w)await y(A.join(D,"CLAUDE.md"))}else{let D=w?A.join(C,".copilot"):A.join(U,".github");if(w)await B(A.join(D,"mcp-config.json"));else await B(A.join(U,".github/mcp.json")),await B(A.join(U,".vscode/mcp.json"),"servers");if(await J(A.join(D,"hooks/ast-mcp.json"),"preToolUse",w?A.join(D,"hooks/ast-mcp.ts"):".github/hooks/ast-mcp.ts"),await V(A.join(D,"hooks/ast-mcp.ts"),{force:!0}),await V(A.join(D,"skills/ast-mcp"),{force:!0,recursive:!0}),w)await y(A.join(D,"copilot-instructions.md"))}if(q.scope==="local"&&!await XU(U))await y(A.join(U,"AGENTS.md"));return f(K,await L(G))}async function YU(q=process.argv.slice(2)){let U=[...q],C="install";if(["install","update","uninstall"].includes(U[0]??""))C=U.shift();let w="local",G=process.cwd(),K=[...z];for(let T=0;T<U.length;T+=1)if(U[T]==="--scope")w=U[++T];else if(U[T]==="--root")G=U[++T];else if(U[T]==="--target"){let x=U[++T];K=x==="all"?[...z]:[x]}else throw Error(`Unknown argument: ${U[T]}`);if(!["local","global"].includes(w)||K.some((T)=>!z.includes(T)))throw Error("Invalid install scope or target");let Q={root:G,scope:w,targets:K},D=C==="install"?await h(Q):C==="update"?await n(Q):await r(Q),M=C==="install"?"Installed":C==="update"?"Updated":"Uninstalled";process.stdout.write(`${JSON.stringify({changed:D,operation:C})}
|
|
20
|
-
`)}var Z,d,g,z,TU="<!-- ast-mcp:begin -->",VU="<!-- ast-mcp:end -->",v;var s=F(async()=>{u();Z=A.resolve(import.meta.dir,".."),d=A.join(Z,"src/index.ts"),g=A.join(Z,"src/hook.ts"),z=["codex","claude","copilot"];v=/<!-- ast-mcp:begin -->[\s\S]*?<!-- ast-mcp:end -->\n?/g});var{runInstallerCli:ZU}=await s().then(() => p);await ZU();
|
|
21
|
-
|
|
22
|
-
//# debugId=B9AD053CC6275C6964756E2164756E21
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../templates/skills/ast-mcp/scripts/managed-hook.ts", "../src/installer.ts", "../bin/ast-mcp-install.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export type HookEvent = \"PreToolUse\" | \"preToolUse\";\n\nexport function isManagedHook(\n item: unknown,\n event: HookEvent,\n command: string,\n): boolean {\n if (!item || typeof item !== \"object\") return false;\n const value = item as Record<string, unknown>;\n if (event === \"preToolUse\")\n return value.command === command && value.type === \"command\";\n return (\n Array.isArray(value.hooks) &&\n value.hooks.some(\n (child) =>\n child &&\n typeof child === \"object\" &&\n (child as Record<string, unknown>).command === command &&\n (child as Record<string, unknown>).type === \"command\",\n )\n );\n}\n",
|
|
6
|
-
"import {\n cp,\n lstat,\n mkdir,\n readdir,\n readFile,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { isManagedHook } from \"./managed-hook\";\n\nconst packageRoot = path.resolve(import.meta.dir, \"..\");\nconst serverEntry = path.join(packageRoot, \"src/index.ts\");\nconst hookEntry = path.join(packageRoot, \"src/hook.ts\");\nconst targets = [\"codex\", \"claude\", \"copilot\"] as const;\ntype Target = (typeof targets)[number];\n\n// biome-ignore lint/suspicious/noExplicitAny: Host configuration JSON is intentionally dynamic.\nasync function json(file: string): Promise<Record<string, any>> {\n try {\n return JSON.parse(await readFile(file, \"utf8\"));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return {};\n throw error;\n }\n}\nasync function save(file: string, value: unknown) {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${JSON.stringify(value, null, 2)}\\n`);\n}\nfunction definition(root?: string) {\n return {\n args: [\"--hot\", serverEntry],\n command: \"bun\",\n env: root\n ? {\n AST_MCP_ALLOW_EXTERNAL_ROOTS: \"1\",\n AST_MCP_ROOTS: root,\n }\n : {},\n };\n}\nasync function codexMcp(file: string, root?: string) {\n const old = await readFile(file, \"utf8\").catch(() => \"\");\n const clean = old\n .replace(/# ast-mcp:begin[\\s\\S]*?# ast-mcp:end\\n?/g, \"\")\n .trimEnd();\n const environment = root\n ? `env = { AST_MCP_ALLOW_EXTERNAL_ROOTS = \"1\", AST_MCP_ROOTS = ${JSON.stringify(root)} }\\n`\n : \"\";\n const block = `# ast-mcp:begin\\n[mcp_servers.ast-mcp]\\ncommand = \"bun\"\\nargs = [\"--hot\", ${JSON.stringify(serverEntry)}]\\n${environment}# ast-mcp:end`;\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${clean ? `${clean}\\n\\n` : \"\"}${block}\\n`);\n}\nasync function jsonMcp(file: string, root?: string, copilot = false) {\n const value = await json(file);\n value.mcpServers = {\n ...(value.mcpServers ?? {}),\n \"ast-mcp\": copilot\n ? { type: \"local\", ...definition(root), tools: [\"*\"] }\n : definition(root),\n };\n await save(file, value);\n}\nasync function vscodeMcp(file: string, root: string) {\n const value = await json(file);\n value.servers = {\n ...(value.servers ?? {}),\n \"ast-mcp\": { type: \"stdio\", ...definition(root) },\n };\n await save(file, value);\n}\n\nasync function hook(\n file: string,\n event: \"PreToolUse\" | \"preToolUse\",\n scriptFile: string,\n commandPath = scriptFile,\n) {\n await mkdir(path.dirname(scriptFile), { recursive: true });\n await cp(hookEntry, scriptFile, { force: true });\n const value = await json(file);\n if (event === \"preToolUse\") value.version ??= 1;\n value.hooks ??= {};\n const prior = Array.isArray(value.hooks[event]) ? value.hooks[event] : [];\n const command = `bun ${JSON.stringify(commandPath)}`;\n const kept = prior.filter(\n (item: unknown) => !isManagedHook(item, event, command),\n );\n const item =\n event === \"preToolUse\"\n ? {\n command,\n matcher: \"bash|powershell|edit|create\",\n timeoutSec: 10,\n type: \"command\",\n }\n : {\n hooks: [\n {\n command,\n statusMessage: \"Enforcing ast-mcp writes\",\n timeout: 10,\n type: \"command\",\n },\n ],\n matcher: \".*\",\n };\n value.hooks[event] = [...kept, item];\n await save(file, value);\n}\nasync function skills(folder: string) {\n const destination = path.join(folder, \"ast-mcp\");\n await rm(destination, { force: true, recursive: true });\n await mkdir(folder, { recursive: true });\n await cp(path.join(packageRoot, \"templates/skills\", \"ast-mcp\"), destination, {\n filter: (source) => path.basename(source) !== \".ast-bro\",\n force: true,\n recursive: true,\n });\n await cp(\n path.join(packageRoot, \"templates/AGENTS.md\"),\n path.join(destination, \"references/agents-guidance.md\"),\n { force: true },\n );\n await cp(hookEntry, path.join(destination, \"references/hook.ts\"), {\n force: true,\n });\n await cp(\n path.join(destination, \"SKILL.md\"),\n path.join(destination, \"references/skill-template.md\"),\n { force: true },\n );\n}\nconst instructionsBegin = \"<!-- ast-mcp:begin -->\";\nconst instructionsEnd = \"<!-- ast-mcp:end -->\";\nconst instructionsPattern =\n /<!-- ast-mcp:begin -->[\\s\\S]*?<!-- ast-mcp:end -->\\n?/g;\n\nasync function writeTextOrRemove(file: string, content: string) {\n const normalized = content.trimEnd();\n if (!normalized) {\n await rm(file, { force: true });\n return;\n }\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${normalized}\\n`);\n}\n\nasync function instructions(file: string) {\n const block = (\n await readFile(path.join(packageRoot, \"templates/AGENTS.md\"), \"utf8\")\n ).trim();\n const old = await readFile(file, \"utf8\").catch(() => \"\");\n const clean = old.replace(instructionsPattern, \"\").trimEnd();\n await writeTextOrRemove(\n file,\n `${clean ? `${clean}\\n\\n` : \"\"}${instructionsBegin}\\n\\n${block}\\n\\n${instructionsEnd}`,\n );\n}\n\nasync function removeInstructions(file: string) {\n const old = await readFile(file, \"utf8\").catch(() => \"\");\n await writeTextOrRemove(file, old.replace(instructionsPattern, \"\"));\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Host configuration JSON is intentionally dynamic.\nasync function saveJsonOrRemove(file: string, value: Record<string, any>) {\n if (Object.keys(value).length === 0) {\n await rm(file, { force: true });\n return;\n }\n await save(file, value);\n}\n\nasync function removeJsonMcp(file: string, section = \"mcpServers\") {\n const value = await json(file);\n const entries = value[section];\n if (!entries || typeof entries !== \"object\" || !(\"ast-mcp\" in entries))\n return;\n delete entries[\"ast-mcp\"];\n if (Object.keys(entries).length === 0) delete value[section];\n await saveJsonOrRemove(file, value);\n}\n\nasync function removeCodexMcp(file: string) {\n const old = await readFile(file, \"utf8\").catch(() => \"\");\n await writeTextOrRemove(\n file,\n old.replace(/# ast-mcp:begin[\\s\\S]*?# ast-mcp:end\\n?/g, \"\"),\n );\n}\n\nasync function removeHook(\n file: string,\n event: \"PreToolUse\" | \"preToolUse\",\n commandPath: string,\n) {\n const value = await json(file);\n const hooks = value.hooks;\n if (!hooks || !Array.isArray(hooks[event])) return;\n const command = `bun ${JSON.stringify(commandPath)}`;\n hooks[event] = hooks[event].filter(\n (item: unknown) => !isManagedHook(item, event, command),\n );\n if (hooks[event].length === 0) delete hooks[event];\n if (Object.keys(hooks).length === 0) delete value.hooks;\n await saveJsonOrRemove(file, value);\n}\n\nasync function hasLocalInstallation(root: string) {\n const codex = await readFile(\n path.join(root, \".codex/config.toml\"),\n \"utf8\",\n ).catch(() => \"\");\n const claude = await json(path.join(root, \".mcp.json\"));\n const copilot = await json(path.join(root, \".github/mcp.json\"));\n return Boolean(\n codex.includes(\"# ast-mcp:begin\") ||\n claude.mcpServers?.[\"ast-mcp\"] ||\n copilot.mcpServers?.[\"ast-mcp\"],\n );\n}\n\nexport interface InstallOptions {\n home?: string;\n root: string;\n scope: \"local\" | \"global\";\n targets: Target[];\n}\n\nfunction targetPaths(\n target: Target,\n global: boolean,\n root: string,\n home: string,\n) {\n if (target === \"codex\") {\n const base = global ? path.join(home, \".codex\") : path.join(root, \".codex\");\n return [\n path.join(base, \"config.toml\"),\n path.join(base, \"hooks.json\"),\n path.join(base, \"hooks/ast-mcp.ts\"),\n path.join(base, \"skills/ast-mcp\"),\n global ? path.join(base, \"AGENTS.md\") : path.join(root, \"AGENTS.md\"),\n ];\n }\n if (target === \"claude\") {\n const base = global\n ? path.join(home, \".claude\")\n : path.join(root, \".claude\");\n return [\n global ? path.join(home, \".claude.json\") : path.join(root, \".mcp.json\"),\n path.join(base, \"settings.json\"),\n path.join(base, \"hooks/ast-mcp.ts\"),\n path.join(base, \"skills/ast-mcp\"),\n global ? path.join(base, \"CLAUDE.md\") : path.join(root, \"AGENTS.md\"),\n ];\n }\n const base = global\n ? path.join(home, \".copilot\")\n : path.join(root, \".github\");\n return [\n global\n ? path.join(base, \"mcp-config.json\")\n : path.join(root, \".github/mcp.json\"),\n ...(global ? [] : [path.join(root, \".vscode/mcp.json\")]),\n path.join(base, \"hooks/ast-mcp.json\"),\n path.join(base, \"hooks/ast-mcp.ts\"),\n path.join(base, \"skills/ast-mcp\"),\n global\n ? path.join(base, \"copilot-instructions.md\")\n : path.join(root, \"AGENTS.md\"),\n ];\n}\n\nasync function snapshot(paths: string[]) {\n const files = new Map<string, string>();\n const visit = async (file: string): Promise<void> => {\n if (path.basename(file) === \".ast-bro\") return;\n const metadata = await lstat(file).catch(() => undefined);\n if (!metadata) return;\n if (metadata.isDirectory()) {\n for (const entry of await readdir(file))\n await visit(path.join(file, entry));\n return;\n }\n if (metadata.isFile())\n files.set(file, (await readFile(file)).toString(\"base64\"));\n };\n await Promise.all(paths.map(visit));\n return files;\n}\n\nfunction changedFiles(before: Map<string, string>, after: Map<string, string>) {\n return [...new Set([...before.keys(), ...after.keys()])]\n .filter((file) => before.get(file) !== after.get(file))\n .sort();\n}\n\nasync function reconcile(options: InstallOptions) {\n const root = path.resolve(options.root);\n const home = options.home ?? os.homedir();\n const global = options.scope === \"global\";\n const paths = options.targets.flatMap((target) =>\n targetPaths(target, global, root, home),\n );\n const before = await snapshot(paths);\n for (const target of options.targets) {\n if (target === \"codex\") {\n const base = global\n ? path.join(home, \".codex\")\n : path.join(root, \".codex\");\n await codexMcp(path.join(base, \"config.toml\"), global ? undefined : root);\n await hook(\n path.join(base, \"hooks.json\"),\n \"PreToolUse\",\n path.join(base, \"hooks/ast-mcp.ts\"),\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : \".codex/hooks/ast-mcp.ts\",\n );\n await skills(path.join(base, \"skills\"));\n await instructions(\n global ? path.join(base, \"AGENTS.md\") : path.join(root, \"AGENTS.md\"),\n );\n } else if (target === \"claude\") {\n const base = global\n ? path.join(home, \".claude\")\n : path.join(root, \".claude\");\n await jsonMcp(\n global ? path.join(home, \".claude.json\") : path.join(root, \".mcp.json\"),\n global ? undefined : root,\n );\n await hook(\n path.join(base, \"settings.json\"),\n \"PreToolUse\",\n path.join(base, \"hooks/ast-mcp.ts\"),\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : `\\${CLAUDE_PROJECT_DIR}/.claude/hooks/ast-mcp.ts`,\n );\n await skills(path.join(base, \"skills\"));\n await instructions(\n global ? path.join(base, \"CLAUDE.md\") : path.join(root, \"AGENTS.md\"),\n );\n } else {\n const base = global\n ? path.join(home, \".copilot\")\n : path.join(root, \".github\");\n if (global)\n await jsonMcp(path.join(base, \"mcp-config.json\"), undefined, true);\n else {\n await jsonMcp(path.join(root, \".github/mcp.json\"), root, true);\n await vscodeMcp(path.join(root, \".vscode/mcp.json\"), root);\n }\n await hook(\n path.join(base, \"hooks/ast-mcp.json\"),\n \"preToolUse\",\n path.join(base, \"hooks/ast-mcp.ts\"),\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : \".github/hooks/ast-mcp.ts\",\n );\n await skills(path.join(base, \"skills\"));\n await instructions(\n global\n ? path.join(base, \"copilot-instructions.md\")\n : path.join(root, \"AGENTS.md\"),\n );\n }\n }\n return changedFiles(before, await snapshot(paths));\n}\n\nexport async function install(options: InstallOptions) {\n return reconcile(options);\n}\n\nexport async function update(options: InstallOptions) {\n return reconcile(options);\n}\n\nexport async function uninstall(options: InstallOptions) {\n const root = path.resolve(options.root);\n const home = options.home ?? os.homedir();\n const global = options.scope === \"global\";\n const paths = options.targets.flatMap((target) =>\n targetPaths(target, global, root, home),\n );\n const before = await snapshot(paths);\n for (const target of options.targets) {\n if (target === \"codex\") {\n const base = global\n ? path.join(home, \".codex\")\n : path.join(root, \".codex\");\n await removeCodexMcp(path.join(base, \"config.toml\"));\n await removeHook(\n path.join(base, \"hooks.json\"),\n \"PreToolUse\",\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : \".codex/hooks/ast-mcp.ts\",\n );\n await rm(path.join(base, \"hooks/ast-mcp.ts\"), { force: true });\n await rm(path.join(base, \"skills/ast-mcp\"), {\n force: true,\n recursive: true,\n });\n if (global) await removeInstructions(path.join(base, \"AGENTS.md\"));\n } else if (target === \"claude\") {\n const base = global\n ? path.join(home, \".claude\")\n : path.join(root, \".claude\");\n await removeJsonMcp(\n global ? path.join(home, \".claude.json\") : path.join(root, \".mcp.json\"),\n );\n await removeHook(\n path.join(base, \"settings.json\"),\n \"PreToolUse\",\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : `\\${CLAUDE_PROJECT_DIR}/.claude/hooks/ast-mcp.ts`,\n );\n await rm(path.join(base, \"hooks/ast-mcp.ts\"), { force: true });\n await rm(path.join(base, \"skills/ast-mcp\"), {\n force: true,\n recursive: true,\n });\n if (global) await removeInstructions(path.join(base, \"CLAUDE.md\"));\n } else {\n const base = global\n ? path.join(home, \".copilot\")\n : path.join(root, \".github\");\n if (global) await removeJsonMcp(path.join(base, \"mcp-config.json\"));\n else {\n await removeJsonMcp(path.join(root, \".github/mcp.json\"));\n await removeJsonMcp(path.join(root, \".vscode/mcp.json\"), \"servers\");\n }\n await removeHook(\n path.join(base, \"hooks/ast-mcp.json\"),\n \"preToolUse\",\n global\n ? path.join(base, \"hooks/ast-mcp.ts\")\n : \".github/hooks/ast-mcp.ts\",\n );\n await rm(path.join(base, \"hooks/ast-mcp.ts\"), { force: true });\n await rm(path.join(base, \"skills/ast-mcp\"), {\n force: true,\n recursive: true,\n });\n if (global)\n await removeInstructions(path.join(base, \"copilot-instructions.md\"));\n }\n }\n if (options.scope === \"local\" && !(await hasLocalInstallation(root)))\n await removeInstructions(path.join(root, \"AGENTS.md\"));\n return changedFiles(before, await snapshot(paths));\n}\n\nexport async function runInstallerCli(\n args = process.argv.slice(2),\n): Promise<void> {\n const tokens = [...args];\n let operation: \"install\" | \"update\" | \"uninstall\" = \"install\";\n if ([\"install\", \"update\", \"uninstall\"].includes(tokens[0] ?? \"\"))\n operation = tokens.shift() as typeof operation;\n let scope: \"local\" | \"global\" = \"local\";\n let root = process.cwd();\n let selected: Target[] = [...targets];\n for (let index = 0; index < tokens.length; index += 1) {\n if (tokens[index] === \"--scope\") scope = tokens[++index] as typeof scope;\n else if (tokens[index] === \"--root\") root = tokens[++index];\n else if (tokens[index] === \"--target\") {\n const value = tokens[++index];\n selected = value === \"all\" ? [...targets] : [value as Target];\n } else throw new Error(`Unknown argument: ${tokens[index]}`);\n }\n if (\n ![\"local\", \"global\"].includes(scope) ||\n selected.some((item) => !targets.includes(item))\n )\n throw new Error(\"Invalid install scope or target\");\n const options = { root, scope, targets: selected };\n const changed =\n operation === \"install\"\n ? await install(options)\n : operation === \"update\"\n ? await update(options)\n : await uninstall(options);\n const _label =\n operation === \"install\"\n ? \"Installed\"\n : operation === \"update\"\n ? \"Updated\"\n : \"Uninstalled\";\n process.stdout.write(`${JSON.stringify({ changed, operation })}\\n`);\n}\nif (import.meta.main) await runInstallerCli();\n",
|
|
7
|
-
"#!/usr/bin/env bun\nconst { runInstallerCli } = await import(\"../src/installer\");\nawait runInstallerCli();\n"
|
|
8
|
-
],
|
|
9
|
-
"mappings": ";;4uBAEO,SAAS,CAAa,CAC3B,EACA,EACA,EACS,CACT,GAAI,CAAC,GAAQ,OAAO,IAAS,SAAU,MAAO,GAC9C,IAAM,EAAQ,EACd,GAAI,IAAU,aACZ,OAAO,EAAM,UAAY,GAAW,EAAM,OAAS,UACrD,OACE,MAAM,QAAQ,EAAM,KAAK,GACzB,EAAM,MAAM,KACV,CAAC,IACC,GACA,OAAO,IAAU,UAChB,EAAkC,UAAY,GAC9C,EAAkC,OAAS,SAChD,kGCnBJ,aACE,WACA,YACA,aACA,eACA,QACA,eACA,oBAEF,kBACA,oBAUA,eAAe,CAAI,CAAC,EAA4C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