@akal/supaforge 0.0.0-stage → 0.0.31
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 +350 -2
- package/bin/dev.js +10 -0
- package/bin/run.js +18 -0
- package/dist/base-command.d.ts +134 -0
- package/dist/base-command.js +9 -0
- package/dist/base-command.js.map +1 -0
- package/dist/branch-C4ndfoj5.d.ts +58 -0
- package/dist/chunk-4OU7KO5Y.js +13 -0
- package/dist/chunk-4OU7KO5Y.js.map +1 -0
- package/dist/chunk-5QQBTLWO.js +642 -0
- package/dist/chunk-5QQBTLWO.js.map +1 -0
- package/dist/chunk-5Z3SAIQS.js +2807 -0
- package/dist/chunk-5Z3SAIQS.js.map +1 -0
- package/dist/chunk-6WAMNZLO.js +336 -0
- package/dist/chunk-6WAMNZLO.js.map +1 -0
- package/dist/chunk-BHYLBKYD.js +156 -0
- package/dist/chunk-BHYLBKYD.js.map +1 -0
- package/dist/chunk-BLKJWDTL.js +153 -0
- package/dist/chunk-BLKJWDTL.js.map +1 -0
- package/dist/chunk-DQQ5E563.js +64 -0
- package/dist/chunk-DQQ5E563.js.map +1 -0
- package/dist/chunk-G2DIPIYU.js +94 -0
- package/dist/chunk-G2DIPIYU.js.map +1 -0
- package/dist/chunk-H5MJ5DFX.js +16 -0
- package/dist/chunk-H5MJ5DFX.js.map +1 -0
- package/dist/chunk-KIFJGON5.js +248 -0
- package/dist/chunk-KIFJGON5.js.map +1 -0
- package/dist/chunk-LQXF65MC.js +240 -0
- package/dist/chunk-LQXF65MC.js.map +1 -0
- package/dist/chunk-NXRSAVRU.js +478 -0
- package/dist/chunk-NXRSAVRU.js.map +1 -0
- package/dist/chunk-PARSNTBD.js +837 -0
- package/dist/chunk-PARSNTBD.js.map +1 -0
- package/dist/chunk-RRMI5CZD.js +376 -0
- package/dist/chunk-RRMI5CZD.js.map +1 -0
- package/dist/chunk-SF3YA42C.js +506 -0
- package/dist/chunk-SF3YA42C.js.map +1 -0
- package/dist/chunk-TQJSQLWA.js +574 -0
- package/dist/chunk-TQJSQLWA.js.map +1 -0
- package/dist/chunk-VMTBLHN2.js +122 -0
- package/dist/chunk-VMTBLHN2.js.map +1 -0
- package/dist/chunk-VOXZWQ3N.js +948 -0
- package/dist/chunk-VOXZWQ3N.js.map +1 -0
- package/dist/chunk-X6V2GGDZ.js +333 -0
- package/dist/chunk-X6V2GGDZ.js.map +1 -0
- package/dist/chunk-XMYMIURR.js +552 -0
- package/dist/chunk-XMYMIURR.js.map +1 -0
- package/dist/chunk-YVDSR4GM.js +1264 -0
- package/dist/chunk-YVDSR4GM.js.map +1 -0
- package/dist/commands/clone.d.ts +66 -0
- package/dist/commands/clone.js +416 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/diff.d.ts +65 -0
- package/dist/commands/diff.js +24 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/help.d.ts +32 -0
- package/dist/commands/help.js +36 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/hukam.d.ts +13 -0
- package/dist/commands/hukam.js +29 -0
- package/dist/commands/hukam.js.map +1 -0
- package/dist/commands/init.d.ts +47 -0
- package/dist/commands/init.js +388 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +44 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate/baseline.d.ts +24 -0
- package/dist/commands/migrate/baseline.js +69 -0
- package/dist/commands/migrate/baseline.js.map +1 -0
- package/dist/commands/migrate/create.d.ts +36 -0
- package/dist/commands/migrate/create.js +128 -0
- package/dist/commands/migrate/create.js.map +1 -0
- package/dist/commands/migrate/list.d.ts +23 -0
- package/dist/commands/migrate/list.js +110 -0
- package/dist/commands/migrate/list.js.map +1 -0
- package/dist/commands/migrate/run.d.ts +61 -0
- package/dist/commands/migrate/run.js +19 -0
- package/dist/commands/migrate/run.js.map +1 -0
- package/dist/commands/report.d.ts +27 -0
- package/dist/commands/report.js +210 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/restore.d.ts +26 -0
- package/dist/commands/restore.js +268 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/snapshot.d.ts +33 -0
- package/dist/commands/snapshot.js +251 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/sync.d.ts +16 -0
- package/dist/commands/sync.js +39 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config-CTbeRlJk.d.ts +134 -0
- package/dist/help.d.ts +28 -0
- package/dist/help.js +64 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +493 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import {
|
|
2
|
+
backup
|
|
3
|
+
} from "./chunk-KIFJGON5.js";
|
|
4
|
+
import {
|
|
5
|
+
CHECK_NAMES,
|
|
6
|
+
createDefaultRegistry,
|
|
7
|
+
promote,
|
|
8
|
+
scan
|
|
9
|
+
} from "./chunk-5Z3SAIQS.js";
|
|
10
|
+
import {
|
|
11
|
+
captureSnapshot
|
|
12
|
+
} from "./chunk-YVDSR4GM.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveConfig,
|
|
15
|
+
validateConfig
|
|
16
|
+
} from "./chunk-6WAMNZLO.js";
|
|
17
|
+
|
|
18
|
+
// src/mcp/state.ts
|
|
19
|
+
var lastScanResult = null;
|
|
20
|
+
function setLastScanResult(result) {
|
|
21
|
+
lastScanResult = result;
|
|
22
|
+
}
|
|
23
|
+
function getLastScanResult() {
|
|
24
|
+
return lastScanResult;
|
|
25
|
+
}
|
|
26
|
+
function clearLastScanResult() {
|
|
27
|
+
lastScanResult = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/mcp/server.ts
|
|
31
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
32
|
+
import { z } from "zod";
|
|
33
|
+
import { readFile, readdir } from "fs/promises";
|
|
34
|
+
import { existsSync, readFileSync } from "fs";
|
|
35
|
+
import { resolve, join, dirname } from "path";
|
|
36
|
+
import { fileURLToPath } from "url";
|
|
37
|
+
var SERVER_NAME = "supaforge";
|
|
38
|
+
var SERVER_VERSION = resolveVersion();
|
|
39
|
+
function resolveVersion() {
|
|
40
|
+
try {
|
|
41
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
42
|
+
for (const relative of ["../package.json", "../../package.json", "../../../package.json"]) {
|
|
43
|
+
const candidate = resolve(here, relative);
|
|
44
|
+
if (!existsSync(candidate)) continue;
|
|
45
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
46
|
+
if (typeof pkg.version === "string" && pkg.name?.includes("supaforge")) {
|
|
47
|
+
return pkg.version;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
return "0.0.0-unknown";
|
|
53
|
+
}
|
|
54
|
+
function maskConfig(config) {
|
|
55
|
+
if (typeof config !== "object" || config === null) return config;
|
|
56
|
+
const result = {};
|
|
57
|
+
for (const [key, value] of Object.entries(config)) {
|
|
58
|
+
if (key === "dbUrl" || key === "accessToken") {
|
|
59
|
+
result[key] = typeof value === "string" && value.length > 0 ? "***" : value;
|
|
60
|
+
} else if (typeof value === "object" && value !== null) {
|
|
61
|
+
result[key] = maskConfig(value);
|
|
62
|
+
} else {
|
|
63
|
+
result[key] = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
function createServer(cwd = process.cwd(), options = {}) {
|
|
69
|
+
const allowConfigPath = options.allowConfigPath ?? false;
|
|
70
|
+
const resolveCwd = (configPath) => {
|
|
71
|
+
if (!configPath) return cwd;
|
|
72
|
+
if (!allowConfigPath) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`configPath is not accepted by this server. It was started without --allow-config-path, so it reads only the config in its own working directory (${cwd}). Restart it with --allow-config-path to permit other projects.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return resolve(configPath, "..");
|
|
78
|
+
};
|
|
79
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
|
|
80
|
+
server.registerTool(
|
|
81
|
+
"scan_drift",
|
|
82
|
+
{
|
|
83
|
+
// Reads both databases and writes nothing. Without annotations a client
|
|
84
|
+
// could not tell this from apply_fixes, so it could not ask for
|
|
85
|
+
// confirmation on the one that writes (issue #96).
|
|
86
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
87
|
+
description: "Scan for drift between Supabase environments and return a structured report. Results include per-check status, issues with SQL fixes, and a health score.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
configPath: z.string().optional().describe(
|
|
90
|
+
"Absolute path to supaforge.config.json. Rejected unless the server was started with --allow-config-path; otherwise the config in the server's own working directory is used."
|
|
91
|
+
),
|
|
92
|
+
source: z.string().optional().describe("Source environment name (overrides config default)."),
|
|
93
|
+
target: z.string().optional().describe("Target environment name (overrides config default)."),
|
|
94
|
+
checks: z.array(z.enum(CHECK_NAMES)).optional().describe('Limit scan to specific checks (e.g. ["rls", "rls-coverage"]).'),
|
|
95
|
+
skip: z.array(z.enum(CHECK_NAMES)).optional().describe(
|
|
96
|
+
"Skip specific checks, the equivalent of the CLI --skip flag. Unioned with checks.exclude from the config file. Use this to avoid a slow or failing layer without editing the project config."
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
async ({ configPath, source, target, checks, skip }) => {
|
|
101
|
+
try {
|
|
102
|
+
const effectiveCwd = resolveCwd(configPath);
|
|
103
|
+
const raw = JSON.parse(await readFile(resolve(effectiveCwd, "supaforge.config.json"), "utf-8"));
|
|
104
|
+
const config = resolveConfig({
|
|
105
|
+
...raw,
|
|
106
|
+
...source ? { source } : {},
|
|
107
|
+
...target ? { target } : {}
|
|
108
|
+
});
|
|
109
|
+
const errors = validateConfig(config);
|
|
110
|
+
if (errors.length > 0) {
|
|
111
|
+
return { content: [{ type: "text", text: `Config errors:
|
|
112
|
+
${errors.join("\n")}` }], isError: true };
|
|
113
|
+
}
|
|
114
|
+
const registry = createDefaultRegistry();
|
|
115
|
+
const result = await scan(registry, {
|
|
116
|
+
config,
|
|
117
|
+
checks,
|
|
118
|
+
skip
|
|
119
|
+
});
|
|
120
|
+
setLastScanResult(result);
|
|
121
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
122
|
+
} catch (err) {
|
|
123
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
124
|
+
return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
server.registerTool(
|
|
129
|
+
"apply_fixes",
|
|
130
|
+
{
|
|
131
|
+
// Writes to the target database, and destructively when
|
|
132
|
+
// allowDestructive is set. This is the one a client should confirm.
|
|
133
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
134
|
+
description: "Apply SQL fixes to resolve drift detected by scan_drift. Previews by default \u2014 pass dryRun=false to actually write to the target database.",
|
|
135
|
+
inputSchema: {
|
|
136
|
+
configPath: z.string().optional().describe(
|
|
137
|
+
"Absolute path to supaforge.config.json. Rejected unless the server was started with --allow-config-path; otherwise the config in the server's own working directory is used."
|
|
138
|
+
),
|
|
139
|
+
source: z.string().optional().describe("Source environment name."),
|
|
140
|
+
target: z.string().optional().describe("Target environment name."),
|
|
141
|
+
checks: z.array(z.enum(CHECK_NAMES)).optional().describe("Apply fixes only for specific checks."),
|
|
142
|
+
dryRun: z.boolean().optional().default(true).describe(
|
|
143
|
+
"Preview SQL without executing it. Defaults to true: writing is opt-in here as it is everywhere else in supaforge, where it needs --apply. Pass dryRun=false to actually apply the fixes."
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
async ({ configPath, source, target, checks, dryRun }) => {
|
|
148
|
+
try {
|
|
149
|
+
const effectiveCwd = resolveCwd(configPath);
|
|
150
|
+
const raw = JSON.parse(await readFile(resolve(effectiveCwd, "supaforge.config.json"), "utf-8"));
|
|
151
|
+
const config = resolveConfig({
|
|
152
|
+
...raw,
|
|
153
|
+
...source ? { source } : {},
|
|
154
|
+
...target ? { target } : {}
|
|
155
|
+
});
|
|
156
|
+
const errors = validateConfig(config);
|
|
157
|
+
if (errors.length > 0) {
|
|
158
|
+
return { content: [{ type: "text", text: `Config errors:
|
|
159
|
+
${errors.join("\n")}` }], isError: true };
|
|
160
|
+
}
|
|
161
|
+
const registry = createDefaultRegistry();
|
|
162
|
+
const scanResult = await scan(registry, {
|
|
163
|
+
config,
|
|
164
|
+
checks
|
|
165
|
+
});
|
|
166
|
+
setLastScanResult(scanResult);
|
|
167
|
+
const targetEnv = config.environments[config.target];
|
|
168
|
+
const promoteResult = await promote({
|
|
169
|
+
dbUrl: targetEnv.dbUrl,
|
|
170
|
+
scanResult,
|
|
171
|
+
checks,
|
|
172
|
+
dryRun
|
|
173
|
+
});
|
|
174
|
+
return { content: [{ type: "text", text: JSON.stringify(promoteResult, null, 2) }] };
|
|
175
|
+
} catch (err) {
|
|
176
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
177
|
+
return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
server.registerTool(
|
|
182
|
+
"take_snapshot",
|
|
183
|
+
{
|
|
184
|
+
// Reads the database and writes local files only — nothing in any
|
|
185
|
+
// database changes.
|
|
186
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
|
|
187
|
+
description: "Capture a point-in-time snapshot of a Supabase environment. Snapshots are stored under .supaforge/snapshots/ and can be used to restore state.",
|
|
188
|
+
inputSchema: {
|
|
189
|
+
configPath: z.string().optional().describe(
|
|
190
|
+
"Absolute path to supaforge.config.json. Rejected unless the server was started with --allow-config-path; otherwise the config in the server's own working directory is used."
|
|
191
|
+
),
|
|
192
|
+
environment: z.string().optional().describe("Environment to snapshot (defaults to config source).")
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
async ({ configPath, environment }) => {
|
|
196
|
+
try {
|
|
197
|
+
const effectiveCwd = resolveCwd(configPath);
|
|
198
|
+
const raw = JSON.parse(await readFile(resolve(effectiveCwd, "supaforge.config.json"), "utf-8"));
|
|
199
|
+
const config = resolveConfig(raw);
|
|
200
|
+
const envName = environment ?? config.source ?? Object.keys(config.environments)[0];
|
|
201
|
+
const env = config.environments[envName];
|
|
202
|
+
if (!env) {
|
|
203
|
+
return {
|
|
204
|
+
content: [{ type: "text", text: `Environment "${envName}" not found in config.` }],
|
|
205
|
+
isError: true
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const result = await captureSnapshot({ envName, env, config, cwd: effectiveCwd });
|
|
209
|
+
return {
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: "text",
|
|
213
|
+
text: JSON.stringify({ timestamp: result.timestamp, dir: result.dir, manifest: result.manifest }, null, 2)
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
};
|
|
217
|
+
} catch (err) {
|
|
218
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
219
|
+
return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
server.registerTool(
|
|
224
|
+
"create_migration",
|
|
225
|
+
{
|
|
226
|
+
// Local files only, as with take_snapshot.
|
|
227
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
|
|
228
|
+
description: "Capture a snapshot and generate a migration file containing the diff against the previous snapshot. Migration files are stored under .supaforge/migrations/.",
|
|
229
|
+
inputSchema: {
|
|
230
|
+
configPath: z.string().optional().describe(
|
|
231
|
+
"Absolute path to supaforge.config.json. Rejected unless the server was started with --allow-config-path; otherwise the config in the server's own working directory is used."
|
|
232
|
+
),
|
|
233
|
+
environment: z.string().optional().describe("Environment to snapshot (defaults to config source)."),
|
|
234
|
+
description: z.string().optional().describe('Human-readable description for the migration (e.g. "add-rls-to-orders").')
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
async ({ configPath, environment, description }) => {
|
|
238
|
+
try {
|
|
239
|
+
const effectiveCwd = resolveCwd(configPath);
|
|
240
|
+
const raw = JSON.parse(await readFile(resolve(effectiveCwd, "supaforge.config.json"), "utf-8"));
|
|
241
|
+
const config = resolveConfig(raw);
|
|
242
|
+
const envName = environment ?? config.source ?? Object.keys(config.environments)[0];
|
|
243
|
+
const env = config.environments[envName];
|
|
244
|
+
if (!env) {
|
|
245
|
+
return {
|
|
246
|
+
content: [{ type: "text", text: `Environment "${envName}" not found in config.` }],
|
|
247
|
+
isError: true
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
const result = await backup({
|
|
251
|
+
envName,
|
|
252
|
+
env,
|
|
253
|
+
config,
|
|
254
|
+
cwd: effectiveCwd,
|
|
255
|
+
description
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: "text",
|
|
261
|
+
text: JSON.stringify(
|
|
262
|
+
{
|
|
263
|
+
isBaseline: result.isBaseline,
|
|
264
|
+
migrationFile: result.migrationFile,
|
|
265
|
+
snapshotDir: result.snapshot.dir,
|
|
266
|
+
timestamp: result.snapshot.timestamp
|
|
267
|
+
},
|
|
268
|
+
null,
|
|
269
|
+
2
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
};
|
|
274
|
+
} catch (err) {
|
|
275
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
276
|
+
return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
server.registerTool(
|
|
281
|
+
"get_check_result",
|
|
282
|
+
{
|
|
283
|
+
// Reads the last scan held in memory.
|
|
284
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
285
|
+
description: "Retrieve the result for a specific check from the most recent scan_drift call. Returns issues, status, and duration for the named check.",
|
|
286
|
+
inputSchema: {
|
|
287
|
+
check: z.enum(CHECK_NAMES).describe('The check name to retrieve (e.g. "rls-coverage").')
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
async ({ check }) => {
|
|
291
|
+
const result = getLastScanResult();
|
|
292
|
+
if (!result) {
|
|
293
|
+
return {
|
|
294
|
+
content: [{ type: "text", text: "No scan result available. Run scan_drift first." }],
|
|
295
|
+
isError: true
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const checkResult = result.checks.find((c) => c.check === check);
|
|
299
|
+
if (!checkResult) {
|
|
300
|
+
return {
|
|
301
|
+
content: [
|
|
302
|
+
{ type: "text", text: `Check "${check}" not found in last scan. Was it included in the scan?` }
|
|
303
|
+
],
|
|
304
|
+
isError: true
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return { content: [{ type: "text", text: JSON.stringify(checkResult, null, 2) }] };
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
server.registerResource(
|
|
311
|
+
"config",
|
|
312
|
+
"supaforge://config",
|
|
313
|
+
{
|
|
314
|
+
title: "SupaForge Config",
|
|
315
|
+
description: "Current supaforge.config.json (sensitive fields masked)",
|
|
316
|
+
mimeType: "application/json"
|
|
317
|
+
},
|
|
318
|
+
async (uri) => {
|
|
319
|
+
try {
|
|
320
|
+
const raw = JSON.parse(await readFile(resolve(cwd, "supaforge.config.json"), "utf-8"));
|
|
321
|
+
const masked = maskConfig(raw);
|
|
322
|
+
return {
|
|
323
|
+
contents: [{ uri: uri.href, text: JSON.stringify(masked, null, 2), mimeType: "application/json" }]
|
|
324
|
+
};
|
|
325
|
+
} catch (err) {
|
|
326
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
327
|
+
return { contents: [{ uri: uri.href, text: `Error loading config: ${msg}`, mimeType: "text/plain" }] };
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
server.registerResource(
|
|
332
|
+
"last-scan",
|
|
333
|
+
"supaforge://last-scan",
|
|
334
|
+
{
|
|
335
|
+
title: "Last Scan Result",
|
|
336
|
+
description: "The most recent drift scan result",
|
|
337
|
+
mimeType: "application/json"
|
|
338
|
+
},
|
|
339
|
+
async (uri) => {
|
|
340
|
+
const result = getLastScanResult();
|
|
341
|
+
if (!result) {
|
|
342
|
+
return {
|
|
343
|
+
contents: [
|
|
344
|
+
{
|
|
345
|
+
uri: uri.href,
|
|
346
|
+
text: JSON.stringify({ message: "No scan result yet. Run scan_drift first." }),
|
|
347
|
+
mimeType: "application/json"
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return { contents: [{ uri: uri.href, text: JSON.stringify(result, null, 2), mimeType: "application/json" }] };
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
server.registerResource(
|
|
356
|
+
"migrations",
|
|
357
|
+
"supaforge://migrations",
|
|
358
|
+
{
|
|
359
|
+
title: "Migration Files",
|
|
360
|
+
description: "Migration files under .supaforge/migrations/",
|
|
361
|
+
mimeType: "application/json"
|
|
362
|
+
},
|
|
363
|
+
async (uri) => {
|
|
364
|
+
try {
|
|
365
|
+
const migrationsDir = join(cwd, ".supaforge", "migrations");
|
|
366
|
+
const files = await readdir(migrationsDir).catch(() => []);
|
|
367
|
+
const jsonFiles = files.filter((f) => f.endsWith(".json")).sort();
|
|
368
|
+
return {
|
|
369
|
+
contents: [
|
|
370
|
+
{
|
|
371
|
+
uri: uri.href,
|
|
372
|
+
text: JSON.stringify({ directory: migrationsDir, files: jsonFiles }, null, 2),
|
|
373
|
+
mimeType: "application/json"
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
};
|
|
377
|
+
} catch (err) {
|
|
378
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
379
|
+
return { contents: [{ uri: uri.href, text: `Error: ${msg}`, mimeType: "text/plain" }] };
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
server.registerPrompt(
|
|
384
|
+
"review_drift_before_deploy",
|
|
385
|
+
{
|
|
386
|
+
description: "Generate a drift review context to share with an AI agent before deploying.",
|
|
387
|
+
argsSchema: {
|
|
388
|
+
environment: z.string().optional().describe('Target environment name (e.g. "production")')
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
({ environment }) => {
|
|
392
|
+
const envNote = environment ? ` to **${environment}**` : "";
|
|
393
|
+
const lastScan = getLastScanResult();
|
|
394
|
+
const scanContext = lastScan ? `
|
|
395
|
+
|
|
396
|
+
Last scan result (${lastScan.timestamp}):
|
|
397
|
+
- Score: ${lastScan.score}
|
|
398
|
+
- Total issues: ${lastScan.summary.total} (${lastScan.summary.critical} critical, ${lastScan.summary.warning} warnings)
|
|
399
|
+
- Checks: ${lastScan.checks.filter((c) => c.status === "drifted").map((c) => c.check).join(", ") || "none drifted"}` : "\n\nNo recent scan found \u2014 run scan_drift first for a current drift report.";
|
|
400
|
+
return {
|
|
401
|
+
messages: [
|
|
402
|
+
{
|
|
403
|
+
role: "user",
|
|
404
|
+
content: {
|
|
405
|
+
type: "text",
|
|
406
|
+
text: [
|
|
407
|
+
`Before deploying${envNote}, please review the current SupaForge drift report.`,
|
|
408
|
+
scanContext,
|
|
409
|
+
"",
|
|
410
|
+
"Steps:",
|
|
411
|
+
"1. Call scan_drift to get the latest drift report.",
|
|
412
|
+
"2. Review critical issues (especially rls-coverage and rls checks).",
|
|
413
|
+
"3. Confirm all SQL fixes look correct before applying.",
|
|
414
|
+
"4. If safe, run apply_fixes with dryRun=true first, then dryRun=false."
|
|
415
|
+
].join("\n")
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
server.registerPrompt(
|
|
423
|
+
"fix_critical_issues",
|
|
424
|
+
{
|
|
425
|
+
description: "Generate a step-by-step plan to fix all critical drift issues.",
|
|
426
|
+
argsSchema: {}
|
|
427
|
+
},
|
|
428
|
+
() => {
|
|
429
|
+
const lastScan = getLastScanResult();
|
|
430
|
+
let criticalSummary = "No recent scan \u2014 run scan_drift first.";
|
|
431
|
+
if (lastScan) {
|
|
432
|
+
const criticalIssues = lastScan.checks.flatMap((c) => c.issues).filter((i) => i.severity === "critical");
|
|
433
|
+
if (criticalIssues.length === 0) {
|
|
434
|
+
criticalSummary = "No critical issues found in the last scan. The target environment looks healthy.";
|
|
435
|
+
} else {
|
|
436
|
+
criticalSummary = [
|
|
437
|
+
`Found ${criticalIssues.length} critical issue(s) in last scan (${lastScan.timestamp}):`,
|
|
438
|
+
...criticalIssues.map((i) => `- [${i.check}] ${i.title}`)
|
|
439
|
+
].join("\n");
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
messages: [
|
|
444
|
+
{
|
|
445
|
+
role: "user",
|
|
446
|
+
content: {
|
|
447
|
+
type: "text",
|
|
448
|
+
text: [
|
|
449
|
+
"Fix all critical drift issues in the target Supabase environment.",
|
|
450
|
+
"",
|
|
451
|
+
criticalSummary,
|
|
452
|
+
"",
|
|
453
|
+
"Recommended steps:",
|
|
454
|
+
"1. Run scan_drift to confirm the current state.",
|
|
455
|
+
"2. Review each critical issue and its sql.up fix.",
|
|
456
|
+
"3. Run apply_fixes with dryRun=true to preview the SQL.",
|
|
457
|
+
"4. Confirm the SQL is safe, then run apply_fixes with dryRun=false.",
|
|
458
|
+
"5. Run scan_drift again to confirm all critical issues are resolved.",
|
|
459
|
+
"",
|
|
460
|
+
"Pay special attention to rls-coverage issues \u2014 tables without RLS enabled",
|
|
461
|
+
"are the CVE-2025-48757 vulnerability pattern."
|
|
462
|
+
].join("\n")
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
return server;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export {
|
|
473
|
+
setLastScanResult,
|
|
474
|
+
getLastScanResult,
|
|
475
|
+
clearLastScanResult,
|
|
476
|
+
createServer
|
|
477
|
+
};
|
|
478
|
+
//# sourceMappingURL=chunk-NXRSAVRU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/state.ts","../src/mcp/server.ts"],"sourcesContent":["import type { ScanResult } from '../types/drift.js'\n\n/** In-memory store for the most recent scan result (per-process). */\nlet lastScanResult: ScanResult | null = null\n\nexport function setLastScanResult(result: ScanResult): void {\n lastScanResult = result\n}\n\nexport function getLastScanResult(): ScanResult | null {\n return lastScanResult\n}\n\nexport function clearLastScanResult(): void {\n lastScanResult = null\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\nimport { readFile, readdir } from 'node:fs/promises'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { resolve, join, dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { resolveConfig, validateConfig } from '../config.js'\nimport { createDefaultRegistry } from '../checks/index.js'\nimport { scan } from '../scanner.js'\nimport { promote } from '../promote.js'\nimport { captureSnapshot } from '../snapshot.js'\nimport { backup } from '../migration.js'\nimport { CHECK_NAMES } from '../types/drift.js'\nimport type { ScanResult, CheckName } from '../types/drift.js'\nimport { setLastScanResult, getLastScanResult } from './state.js'\n\nconst SERVER_NAME = 'supaforge'\n\n/**\n * The package's own version.\n *\n * Was a hardcoded '0.0.4' and had drifted fifteen releases behind (issue #82).\n * An MCP client has no other way to know which SupaForge it is talking to, so\n * an agent deciding whether a tool or argument exists was working from a\n * version that had not been true for months. Read from package.json, with a\n * fallback that says so rather than asserting a number.\n */\nconst SERVER_VERSION = resolveVersion()\n\nfunction resolveVersion(): string {\n try {\n const here = dirname(fileURLToPath(import.meta.url))\n // dist/ at runtime, src/mcp/ from source: walk up until package.json.\n for (const relative of ['../package.json', '../../package.json', '../../../package.json']) {\n const candidate = resolve(here, relative)\n if (!existsSync(candidate)) continue\n const pkg = JSON.parse(readFileSync(candidate, 'utf-8'))\n if (typeof pkg.version === 'string' && pkg.name?.includes('supaforge')) {\n return pkg.version\n }\n }\n } catch {\n // Fall through.\n }\n return '0.0.0-unknown'\n}\n\n/** Masks sensitive fields (dbUrl, accessToken) in config output. */\nfunction maskConfig(config: unknown): unknown {\n if (typeof config !== 'object' || config === null) return config\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(config as Record<string, unknown>)) {\n if (key === 'dbUrl' || key === 'accessToken') {\n result[key] = typeof value === 'string' && value.length > 0 ? '***' : value\n } else if (typeof value === 'object' && value !== null) {\n result[key] = maskConfig(value)\n } else {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Create and configure the SupaForge MCP server.\n *\n * @param cwd - Working directory to resolve config files from (defaults to process.cwd())\n */\nexport interface ServerOptions {\n /**\n * Honour a `configPath` argument from the client.\n *\n * Off by default. Every tool accepted an arbitrary path and resolved its\n * working directory from it, so a tool call — or a prompt injected into one —\n * could point the server at any `supaforge.config.json` on disk, including\n * one holding production credentials, bypassing the config the server was\n * started with (issue #96). Enabled with `supaforge mcp --allow-config-path`\n * for the case where an agent legitimately manages several projects.\n */\n allowConfigPath?: boolean\n}\n\nexport function createServer(cwd = process.cwd(), options: ServerOptions = {}): McpServer {\n const allowConfigPath = options.allowConfigPath ?? false\n\n /**\n * The directory to load the config from.\n *\n * Refuses a `configPath` unless the server was started with\n * --allow-config-path, rather than ignoring it silently: a client that asked\n * for a different project should be told it did not get one.\n */\n const resolveCwd = (configPath?: string): string => {\n if (!configPath) return cwd\n if (!allowConfigPath) {\n throw new Error(\n 'configPath is not accepted by this server. It was started without '\n + '--allow-config-path, so it reads only the config in its own working '\n + `directory (${cwd}). Restart it with --allow-config-path to permit `\n + 'other projects.',\n )\n }\n return resolve(configPath, '..')\n }\n\n const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION })\n\n // ── Tools ──────────────────────────────────────────────────────────────────\n\n /**\n * scan_drift: Scan for environment drift and return a structured report.\n */\n server.registerTool(\n 'scan_drift',\n {\n // Reads both databases and writes nothing. Without annotations a client\n // could not tell this from apply_fixes, so it could not ask for\n // confirmation on the one that writes (issue #96).\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n\n description:\n 'Scan for drift between Supabase environments and return a structured report. ' +\n 'Results include per-check status, issues with SQL fixes, and a health score.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n source: z\n .string()\n .optional()\n .describe('Source environment name (overrides config default).'),\n target: z\n .string()\n .optional()\n .describe('Target environment name (overrides config default).'),\n checks: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe('Limit scan to specific checks (e.g. [\"rls\", \"rls-coverage\"]).'),\n skip: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe(\n 'Skip specific checks, the equivalent of the CLI --skip flag. ' +\n 'Unioned with checks.exclude from the config file. Use this to avoid ' +\n 'a slow or failing layer without editing the project config.',\n ),\n },\n },\n async ({ configPath, source, target, checks, skip }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig({\n ...raw,\n ...(source ? { source } : {}),\n ...(target ? { target } : {}),\n })\n\n const errors = validateConfig(config)\n if (errors.length > 0) {\n return { content: [{ type: 'text' as const, text: `Config errors:\\n${errors.join('\\n')}` }], isError: true }\n }\n\n const registry = createDefaultRegistry()\n const result: ScanResult = await scan(registry, {\n config,\n checks: checks as CheckName[] | undefined,\n skip: skip as CheckName[] | undefined,\n })\n setLastScanResult(result)\n\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * apply_fixes: Apply SQL fixes to resolve drift in the target environment.\n */\n server.registerTool(\n 'apply_fixes',\n {\n // Writes to the target database, and destructively when\n // allowDestructive is set. This is the one a client should confirm.\n annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },\n\n description:\n 'Apply SQL fixes to resolve drift detected by scan_drift. ' +\n 'Previews by default — pass dryRun=false to actually write to the target database.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n source: z.string().optional().describe('Source environment name.'),\n target: z.string().optional().describe('Target environment name.'),\n checks: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe('Apply fixes only for specific checks.'),\n dryRun: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Preview SQL without executing it. Defaults to true: writing is opt-in '\n + 'here as it is everywhere else in supaforge, where it needs --apply. '\n + 'Pass dryRun=false to actually apply the fixes.',\n ),\n },\n },\n async ({ configPath, source, target, checks, dryRun }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig({\n ...raw,\n ...(source ? { source } : {}),\n ...(target ? { target } : {}),\n })\n\n const errors = validateConfig(config)\n if (errors.length > 0) {\n return { content: [{ type: 'text' as const, text: `Config errors:\\n${errors.join('\\n')}` }], isError: true }\n }\n\n const registry = createDefaultRegistry()\n const scanResult: ScanResult = await scan(registry, {\n config,\n checks: checks as CheckName[] | undefined,\n })\n setLastScanResult(scanResult)\n\n const targetEnv = config.environments[config.target!]\n const promoteResult = await promote({\n dbUrl: targetEnv.dbUrl,\n scanResult,\n checks: checks as string[] | undefined,\n dryRun,\n })\n\n return { content: [{ type: 'text' as const, text: JSON.stringify(promoteResult, null, 2) }] }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * take_snapshot: Capture a point-in-time snapshot of a Supabase environment.\n */\n server.registerTool(\n 'take_snapshot',\n {\n // Reads the database and writes local files only — nothing in any\n // database changes.\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },\n\n description:\n 'Capture a point-in-time snapshot of a Supabase environment. ' +\n 'Snapshots are stored under .supaforge/snapshots/ and can be used to restore state.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n environment: z\n .string()\n .optional()\n .describe('Environment to snapshot (defaults to config source).'),\n },\n },\n async ({ configPath, environment }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig(raw)\n\n const envName = environment ?? config.source ?? Object.keys(config.environments)[0]\n const env = config.environments[envName]\n if (!env) {\n return {\n content: [{ type: 'text' as const, text: `Environment \"${envName}\" not found in config.` }],\n isError: true,\n }\n }\n\n const result = await captureSnapshot({ envName, env, config, cwd: effectiveCwd })\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ timestamp: result.timestamp, dir: result.dir, manifest: result.manifest }, null, 2),\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * create_migration: Create a migration file from snapshot diff.\n */\n server.registerTool(\n 'create_migration',\n {\n // Local files only, as with take_snapshot.\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },\n\n description:\n 'Capture a snapshot and generate a migration file containing the diff against the previous snapshot. ' +\n 'Migration files are stored under .supaforge/migrations/.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n environment: z\n .string()\n .optional()\n .describe('Environment to snapshot (defaults to config source).'),\n description: z\n .string()\n .optional()\n .describe('Human-readable description for the migration (e.g. \"add-rls-to-orders\").'),\n },\n },\n async ({ configPath, environment, description }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig(raw)\n\n const envName = environment ?? config.source ?? Object.keys(config.environments)[0]\n const env = config.environments[envName]\n if (!env) {\n return {\n content: [{ type: 'text' as const, text: `Environment \"${envName}\" not found in config.` }],\n isError: true,\n }\n }\n\n const result = await backup({\n envName,\n env,\n config,\n cwd: effectiveCwd,\n description,\n })\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(\n {\n isBaseline: result.isBaseline,\n migrationFile: result.migrationFile,\n snapshotDir: result.snapshot.dir,\n timestamp: result.snapshot.timestamp,\n },\n null,\n 2,\n ),\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * get_check_result: Retrieve the result for a specific check from the last scan.\n */\n server.registerTool(\n 'get_check_result',\n {\n // Reads the last scan held in memory.\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n\n description:\n 'Retrieve the result for a specific check from the most recent scan_drift call. ' +\n 'Returns issues, status, and duration for the named check.',\n inputSchema: {\n check: z.enum(CHECK_NAMES).describe('The check name to retrieve (e.g. \"rls-coverage\").'),\n },\n },\n async ({ check }) => {\n const result = getLastScanResult()\n if (!result) {\n return {\n content: [{ type: 'text' as const, text: 'No scan result available. Run scan_drift first.' }],\n isError: true,\n }\n }\n const checkResult = result.checks.find(c => c.check === check)\n if (!checkResult) {\n return {\n content: [\n { type: 'text' as const, text: `Check \"${check}\" not found in last scan. Was it included in the scan?` },\n ],\n isError: true,\n }\n }\n return { content: [{ type: 'text' as const, text: JSON.stringify(checkResult, null, 2) }] }\n },\n )\n\n // ── Resources ──────────────────────────────────────────────────────────────\n\n /** Current SupaForge config (sensitive fields masked). */\n server.registerResource(\n 'config',\n 'supaforge://config',\n {\n title: 'SupaForge Config',\n description: 'Current supaforge.config.json (sensitive fields masked)',\n mimeType: 'application/json',\n },\n async (uri) => {\n try {\n const raw = JSON.parse(await readFile(resolve(cwd, 'supaforge.config.json'), 'utf-8'))\n const masked = maskConfig(raw)\n return {\n contents: [{ uri: uri.href, text: JSON.stringify(masked, null, 2), mimeType: 'application/json' }],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { contents: [{ uri: uri.href, text: `Error loading config: ${msg}`, mimeType: 'text/plain' }] }\n }\n },\n )\n\n /** Last scan result (updated after each scan_drift or apply_fixes call). */\n server.registerResource(\n 'last-scan',\n 'supaforge://last-scan',\n {\n title: 'Last Scan Result',\n description: 'The most recent drift scan result',\n mimeType: 'application/json',\n },\n async (uri) => {\n const result = getLastScanResult()\n if (!result) {\n return {\n contents: [\n {\n uri: uri.href,\n text: JSON.stringify({ message: 'No scan result yet. Run scan_drift first.' }),\n mimeType: 'application/json',\n },\n ],\n }\n }\n return { contents: [{ uri: uri.href, text: JSON.stringify(result, null, 2), mimeType: 'application/json' }] }\n },\n )\n\n /** List of migration files under .supaforge/migrations/. */\n server.registerResource(\n 'migrations',\n 'supaforge://migrations',\n {\n title: 'Migration Files',\n description: 'Migration files under .supaforge/migrations/',\n mimeType: 'application/json',\n },\n async (uri) => {\n try {\n const migrationsDir = join(cwd, '.supaforge', 'migrations')\n const files = await readdir(migrationsDir).catch(() => [] as string[])\n const jsonFiles = files.filter(f => f.endsWith('.json')).sort()\n return {\n contents: [\n {\n uri: uri.href,\n text: JSON.stringify({ directory: migrationsDir, files: jsonFiles }, null, 2),\n mimeType: 'application/json',\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { contents: [{ uri: uri.href, text: `Error: ${msg}`, mimeType: 'text/plain' }] }\n }\n },\n )\n\n // ── Prompts ────────────────────────────────────────────────────────────────\n\n /** Prompt: review drift before deploying. */\n server.registerPrompt(\n 'review_drift_before_deploy',\n {\n description: 'Generate a drift review context to share with an AI agent before deploying.',\n argsSchema: {\n environment: z\n .string()\n .optional()\n .describe('Target environment name (e.g. \"production\")'),\n },\n },\n ({ environment }) => {\n const envNote = environment ? ` to **${environment}**` : ''\n const lastScan = getLastScanResult()\n const scanContext = lastScan\n ? `\\n\\nLast scan result (${lastScan.timestamp}):\\n- Score: ${lastScan.score}\\n- Total issues: ${lastScan.summary.total} (${lastScan.summary.critical} critical, ${lastScan.summary.warning} warnings)\\n- Checks: ${lastScan.checks.filter(c => c.status === 'drifted').map(c => c.check).join(', ') || 'none drifted'}`\n : '\\n\\nNo recent scan found — run scan_drift first for a current drift report.'\n\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Before deploying${envNote}, please review the current SupaForge drift report.`,\n scanContext,\n '',\n 'Steps:',\n '1. Call scan_drift to get the latest drift report.',\n '2. Review critical issues (especially rls-coverage and rls checks).',\n '3. Confirm all SQL fixes look correct before applying.',\n '4. If safe, run apply_fixes with dryRun=true first, then dryRun=false.',\n ].join('\\n'),\n },\n },\n ],\n }\n },\n )\n\n /** Prompt: fix all critical issues. */\n server.registerPrompt(\n 'fix_critical_issues',\n {\n description: 'Generate a step-by-step plan to fix all critical drift issues.',\n argsSchema: {},\n },\n () => {\n const lastScan = getLastScanResult()\n let criticalSummary = 'No recent scan — run scan_drift first.'\n if (lastScan) {\n const criticalIssues = lastScan.checks\n .flatMap(c => c.issues)\n .filter(i => i.severity === 'critical')\n if (criticalIssues.length === 0) {\n criticalSummary = 'No critical issues found in the last scan. The target environment looks healthy.'\n } else {\n criticalSummary = [\n `Found ${criticalIssues.length} critical issue(s) in last scan (${lastScan.timestamp}):`,\n ...criticalIssues.map(i => `- [${i.check}] ${i.title}`),\n ].join('\\n')\n }\n }\n\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Fix all critical drift issues in the target Supabase environment.',\n '',\n criticalSummary,\n '',\n 'Recommended steps:',\n '1. Run scan_drift to confirm the current state.',\n '2. Review each critical issue and its sql.up fix.',\n '3. Run apply_fixes with dryRun=true to preview the SQL.',\n '4. Confirm the SQL is safe, then run apply_fixes with dryRun=false.',\n '5. Run scan_drift again to confirm all critical issues are resolved.',\n '',\n 'Pay special attention to rls-coverage issues — tables without RLS enabled',\n 'are the CVE-2025-48757 vulnerability pattern.',\n ].join('\\n'),\n },\n },\n ],\n }\n },\n )\n\n return server\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,IAAI,iBAAoC;AAEjC,SAAS,kBAAkB,QAA0B;AAC1D,mBAAiB;AACnB;AAEO,SAAS,oBAAuC;AACrD,SAAO;AACT;AAEO,SAAS,sBAA4B;AAC1C,mBAAiB;AACnB;;;ACfA,SAAS,iBAAiB;AAC1B,SAAS,SAAS;AAClB,SAAS,UAAU,eAAe;AAClC,SAAS,YAAY,oBAAoB;AACzC,SAAS,SAAS,MAAM,eAAe;AACvC,SAAS,qBAAqB;AAW9B,IAAM,cAAc;AAWpB,IAAM,iBAAiB,eAAe;AAEtC,SAAS,iBAAyB;AAChC,MAAI;AACF,UAAM,OAAO,QAAQ,cAAc,YAAY,GAAG,CAAC;AAEnD,eAAW,YAAY,CAAC,mBAAmB,sBAAsB,uBAAuB,GAAG;AACzF,YAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,UAAI,CAAC,WAAW,SAAS,EAAG;AAC5B,YAAM,MAAM,KAAK,MAAM,aAAa,WAAW,OAAO,CAAC;AACvD,UAAI,OAAO,IAAI,YAAY,YAAY,IAAI,MAAM,SAAS,WAAW,GAAG;AACtE,eAAO,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