@supacloud/cli 0.123.2 → 0.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9422,7 +9422,7 @@ var ACTION_POLICY = {
9422
9422
  edge_functions: {
9423
9423
  read: ["list", "get_config", "source"],
9424
9424
  local: ["check", "scaffold"],
9425
- write: ["deploy", "deploy_bundle", "config", "activate", "delete"]
9425
+ write: ["deploy", "deploy_bundle", "deploy_manifest", "config", "activate", "delete"]
9426
9426
  },
9427
9427
  scheduled_functions: { read: ["list", "get"], write: ["create", "update", "delete"] },
9428
9428
  mutations: { read: ["status"] },
@@ -15598,20 +15598,20 @@ import { createHash as createHash6, timingSafeEqual } from "node:crypto";
15598
15598
  import {
15599
15599
  closeSync,
15600
15600
  constants as fsConstants,
15601
- existsSync as existsSync5,
15601
+ existsSync as existsSync6,
15602
15602
  fstatSync,
15603
15603
  lstatSync,
15604
15604
  mkdirSync,
15605
- mkdtempSync,
15605
+ mkdtempSync as mkdtempSync2,
15606
15606
  openSync,
15607
- readFileSync as readFileSync6,
15607
+ readFileSync as readFileSync7,
15608
15608
  readdirSync as readdirSync3,
15609
- rmSync,
15609
+ rmSync as rmSync2,
15610
15610
  statSync as statSync4,
15611
15611
  writeFileSync
15612
15612
  } from "node:fs";
15613
- import { tmpdir } from "node:os";
15614
- import { basename as basename5, join as join5, relative as relative2, resolve as resolve7, sep as sep2 } from "node:path";
15613
+ import { tmpdir as tmpdir2 } from "node:os";
15614
+ import { basename as basename6, join as join6, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
15615
15615
 
15616
15616
  // src/shared/tools/function-aot.ts
15617
15617
  import { execFile } from "node:child_process";
@@ -15930,6 +15930,358 @@ function confirmedFunctionDeletion(payload, expectation) {
15930
15930
  };
15931
15931
  }
15932
15932
 
15933
+ // src/shared/tools/project-function-release.ts
15934
+ import { existsSync as existsSync5, mkdtempSync, readFileSync as readFileSync6, rmSync } from "node:fs";
15935
+ import { tmpdir } from "node:os";
15936
+ import { basename as basename5, join as join5, relative as relative2, resolve as resolve7, sep as sep2 } from "node:path";
15937
+ var SAFE_SLUG_PATTERN2 = /^[A-Za-z0-9_-]{1,128}$/;
15938
+ var RELEASE_ID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/;
15939
+ var POSITIVE_VERSION_PATTERN = /^[1-9][0-9]*$/;
15940
+ var ARTIFACT_SHA256_PATTERN = /^[a-f0-9]{64}$/;
15941
+ var FRAMEWORKS = ["fetch", "elysia", "hono", "sveltekit-function"];
15942
+ var MAX_MANIFEST_BYTES = 1024 * 1024;
15943
+ var MAX_FUNCTIONS = 128;
15944
+ var RELEASE_OPERATION = "edge_functions.deploy_manifest";
15945
+ function record5(candidate) {
15946
+ return candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
15947
+ }
15948
+ function requiredString(candidate, field) {
15949
+ if (typeof candidate !== "string" || !candidate.trim())
15950
+ throw new Error(`Manifest field '${field}' is required`);
15951
+ return candidate.trim();
15952
+ }
15953
+ function optionalString(candidate, field) {
15954
+ if (candidate === undefined)
15955
+ return;
15956
+ return requiredString(candidate, field);
15957
+ }
15958
+ function validStringArray(candidate, field) {
15959
+ if (candidate === undefined)
15960
+ return;
15961
+ if (!Array.isArray(candidate) || candidate.some((value) => typeof value !== "string" || !value.trim())) {
15962
+ throw new Error(`Manifest field '${field}' must be an array of strings`);
15963
+ }
15964
+ return candidate.map((value) => value.trim());
15965
+ }
15966
+ function validObject(candidate, field) {
15967
+ if (candidate === undefined)
15968
+ return;
15969
+ const value = record5(candidate);
15970
+ if (!value)
15971
+ throw new Error(`Manifest field '${field}' must be an object`);
15972
+ return value;
15973
+ }
15974
+ function functionCapabilities(candidate) {
15975
+ const value = validObject(candidate, "capabilities");
15976
+ if (!value)
15977
+ return;
15978
+ const result = {};
15979
+ for (const field of ["secrets", "outbound_hosts", "bindings"]) {
15980
+ const entries = value[field];
15981
+ if (entries === undefined)
15982
+ continue;
15983
+ if (!Array.isArray(entries) || entries.some((entry) => typeof entry !== "string" || !entry.trim())) {
15984
+ throw new Error(`Manifest field 'capabilities.${field}' must be an array of strings`);
15985
+ }
15986
+ result[field] = entries.map((entry) => entry.trim());
15987
+ }
15988
+ if (value.background !== undefined) {
15989
+ if (typeof value.background !== "boolean")
15990
+ throw new Error("Manifest field 'capabilities.background' must be boolean");
15991
+ result.background = value.background;
15992
+ }
15993
+ return result;
15994
+ }
15995
+ function functionLimits(candidate) {
15996
+ const value = validObject(candidate, "limits");
15997
+ if (!value)
15998
+ return;
15999
+ const result = {};
16000
+ for (const field of ["timeout_ms", "max_request_body_bytes", "max_response_body_bytes", "wait_until_timeout_ms", "max_heap_bytes"]) {
16001
+ const entry = value[field];
16002
+ if (entry === undefined)
16003
+ continue;
16004
+ if (typeof entry !== "number" || !Number.isSafeInteger(entry) || entry < 1) {
16005
+ throw new Error(`Manifest field 'limits.${field}' must be a positive safe integer`);
16006
+ }
16007
+ result[field] = entry;
16008
+ }
16009
+ return result;
16010
+ }
16011
+ function parseManifest(path) {
16012
+ const source = readFileSync6(resolve7(path), "utf8");
16013
+ if (Buffer.byteLength(source) > MAX_MANIFEST_BYTES)
16014
+ throw new Error("Function release manifest exceeds 1 MiB");
16015
+ let parsed;
16016
+ try {
16017
+ parsed = JSON.parse(source);
16018
+ } catch {
16019
+ throw new Error("Function release manifest must be valid JSON");
16020
+ }
16021
+ const root = record5(parsed);
16022
+ const entries = root?.functions;
16023
+ if (!Array.isArray(entries) || entries.length < 1 || entries.length > MAX_FUNCTIONS) {
16024
+ throw new Error("Function release manifest must contain 1-128 functions");
16025
+ }
16026
+ const slugs = new Set;
16027
+ return entries.map((candidate) => {
16028
+ const value = record5(candidate);
16029
+ if (!value)
16030
+ throw new Error("Function release manifest contains an invalid function");
16031
+ const slug = requiredString(value.slug, "slug");
16032
+ if (!SAFE_SLUG_PATTERN2.test(slug) || slug === "_project-release" || slugs.has(slug)) {
16033
+ throw new Error(`Function release manifest contains an invalid or duplicate slug '${slug}'`);
16034
+ }
16035
+ slugs.add(slug);
16036
+ const entrypoint = requiredString(value.entrypoint, "entrypoint");
16037
+ if (entrypoint.startsWith("/") || entrypoint.split(/[\\/]/u).includes("..")) {
16038
+ throw new Error(`Manifest entrypoint must stay within the project: ${entrypoint}`);
16039
+ }
16040
+ const framework = optionalString(value.framework, "framework");
16041
+ if (framework !== undefined && !FRAMEWORKS.includes(framework)) {
16042
+ throw new Error(`Manifest field 'framework' is invalid for '${slug}'`);
16043
+ }
16044
+ const bytecode = optionalString(value.bytecode, "bytecode");
16045
+ if (bytecode !== undefined && !["off", "auto", "required"].includes(bytecode)) {
16046
+ throw new Error(`Manifest field 'bytecode' is invalid for '${slug}'`);
16047
+ }
16048
+ if (value.verify_jwt !== undefined && typeof value.verify_jwt !== "boolean") {
16049
+ throw new Error(`Manifest field 'verify_jwt' must be boolean for '${slug}'`);
16050
+ }
16051
+ const verifyJwt = value.verify_jwt;
16052
+ const backgroundRoutes = validStringArray(value.backgroundRoutes ?? value.background_routes, "background_routes");
16053
+ const capabilities = functionCapabilities(value.capabilities);
16054
+ const limits = functionLimits(value.limits);
16055
+ return {
16056
+ slug,
16057
+ entrypoint,
16058
+ ...verifyJwt === undefined ? {} : { verify_jwt: verifyJwt },
16059
+ ...bytecode === undefined ? {} : { bytecode },
16060
+ ...backgroundRoutes === undefined ? {} : { background_routes: backgroundRoutes },
16061
+ ...framework === undefined ? {} : { framework },
16062
+ ...capabilities === undefined ? {} : { capabilities },
16063
+ ...limits === undefined ? {} : { limits }
16064
+ };
16065
+ });
16066
+ }
16067
+ function projectPath(ref, suffix) {
16068
+ return `/v1/projects/${projectRefPathSegment(ref, "Function release")}${suffix}`;
16069
+ }
16070
+ function validUuid(candidate) {
16071
+ return typeof candidate === "string" && RELEASE_ID_PATTERN.test(candidate);
16072
+ }
16073
+ function positiveVersion(candidate) {
16074
+ return typeof candidate === "string" && POSITIVE_VERSION_PATTERN.test(candidate) && Number.isSafeInteger(Number(candidate));
16075
+ }
16076
+ function parseReleaseStatus(payload, projectRef) {
16077
+ const value = record5(payload);
16078
+ if (!value || value.project_ref !== projectRef || value.active_release_id !== null && !validUuid(value.active_release_id) || !Array.isArray(value.functions))
16079
+ return null;
16080
+ const slugs = new Set;
16081
+ const functions = [];
16082
+ for (const candidate of value.functions) {
16083
+ const entry = record5(candidate);
16084
+ if (!entry || typeof entry.slug !== "string" || !SAFE_SLUG_PATTERN2.test(entry.slug) || slugs.has(entry.slug) || !positiveVersion(entry.version) || !validObservedFunctionActivationId(entry.activation_id))
16085
+ return null;
16086
+ slugs.add(entry.slug);
16087
+ functions.push({
16088
+ slug: entry.slug,
16089
+ version: entry.version,
16090
+ activation_id: entry.activation_id
16091
+ });
16092
+ }
16093
+ return {
16094
+ project_ref: projectRef,
16095
+ active_release_id: value.active_release_id,
16096
+ functions
16097
+ };
16098
+ }
16099
+ function stageCodePath(entrypoint, bundlesDir, slug) {
16100
+ if (bundlesDir) {
16101
+ const bundleRoot = resolve7(bundlesDir);
16102
+ const candidate = join5(bundleRoot, `${slug}.js`);
16103
+ if (!existsSync5(candidate))
16104
+ throw new Error(`Prebuilt Function bundle is missing: ${candidate}`);
16105
+ return candidate;
16106
+ }
16107
+ const projectRoot = process.cwd();
16108
+ const candidate = resolve7(projectRoot, entrypoint);
16109
+ const relativePath = relative2(projectRoot, candidate);
16110
+ if (!relativePath || relativePath.startsWith(`..${sep2}`) || relativePath === "..") {
16111
+ throw new Error(`Manifest entrypoint must stay within the project: ${entrypoint}`);
16112
+ }
16113
+ if (!existsSync5(candidate))
16114
+ throw new Error(`Function entrypoint does not exist: ${candidate}`);
16115
+ return candidate;
16116
+ }
16117
+ async function bundleSource(entrypoint, bundlesDir, slug) {
16118
+ const sourcePath = stageCodePath(entrypoint, bundlesDir, slug);
16119
+ if (bundlesDir)
16120
+ return readFileSync6(sourcePath, "utf8");
16121
+ const directory = mkdtempSync(join5(tmpdir(), "supacloud-function-release-"));
16122
+ const output = join5(directory, `${basename5(sourcePath).replace(/\.[^.]+$/u, "") || "index"}.js`);
16123
+ try {
16124
+ const process2 = Bun.spawn(["bun", "build", sourcePath, "--target", "bun", "--outfile", output], {
16125
+ stdout: "pipe",
16126
+ stderr: "pipe"
16127
+ });
16128
+ const [stdout, stderr, exitCode] = await Promise.all([
16129
+ new Response(process2.stdout).text(),
16130
+ new Response(process2.stderr).text(),
16131
+ process2.exited
16132
+ ]);
16133
+ if (exitCode !== 0)
16134
+ throw new Error(`Failed to bundle '${slug}': ${stderr || stdout}`);
16135
+ return readFileSync6(output, "utf8");
16136
+ } finally {
16137
+ rmSync(directory, { recursive: true, force: true });
16138
+ }
16139
+ }
16140
+ function stageConfig(entry) {
16141
+ return {
16142
+ ...entry.verify_jwt === undefined ? {} : { verify_jwt: entry.verify_jwt },
16143
+ ...entry.bytecode === undefined ? {} : { bytecode: entry.bytecode },
16144
+ ...entry.background_routes === undefined ? {} : { background_routes: entry.background_routes },
16145
+ ...entry.framework === undefined ? {} : { framework: entry.framework },
16146
+ ...entry.capabilities === undefined ? {} : { capabilities: entry.capabilities },
16147
+ ...entry.limits === undefined ? {} : { limits: entry.limits }
16148
+ };
16149
+ }
16150
+ function stagedVersion(payload) {
16151
+ const value = record5(payload);
16152
+ if (!value || !positiveVersion(value.version) || typeof value.artifact_sha256 !== "string" || !ARTIFACT_SHA256_PATTERN.test(value.artifact_sha256))
16153
+ return null;
16154
+ return value.version;
16155
+ }
16156
+ function releaseReceipt(payload, projectRef, mutationId, expectedMembers) {
16157
+ const value = record5(payload);
16158
+ if (!value || value.project_ref !== projectRef || value.active_release_id !== mutationId || typeof value.generation !== "number" || !Number.isSafeInteger(value.generation) || value.generation < 1 || !Array.isArray(value.functions) || value.functions.length !== expectedMembers.length)
16159
+ return null;
16160
+ const observed = new Map;
16161
+ for (const candidate of value.functions) {
16162
+ const entry = record5(candidate);
16163
+ if (!entry || typeof entry.slug !== "string" || !SAFE_SLUG_PATTERN2.test(entry.slug) || observed.has(entry.slug) || !positiveVersion(entry.version) || !validObservedFunctionActivationId(entry.activation_id))
16164
+ return null;
16165
+ observed.set(entry.slug, {
16166
+ slug: entry.slug,
16167
+ version: entry.version,
16168
+ activation_id: entry.activation_id
16169
+ });
16170
+ }
16171
+ for (const expected of expectedMembers) {
16172
+ const actual = observed.get(expected.slug);
16173
+ if (!actual || actual.version !== expected.version)
16174
+ return null;
16175
+ }
16176
+ const mutation = record5(value.mutation);
16177
+ if (!mutation || mutation.mutation_id !== mutationId || mutation.status !== "succeeded")
16178
+ return null;
16179
+ return {
16180
+ project_ref: projectRef,
16181
+ mutation_id: mutationId,
16182
+ active_release_id: mutationId,
16183
+ generation: value.generation,
16184
+ functions: [...observed.values()],
16185
+ mutation: { mutation_id: mutationId, status: "succeeded" }
16186
+ };
16187
+ }
16188
+ function requiredArg(args, name) {
16189
+ const value = args[name];
16190
+ if (typeof value !== "string" || !value.trim())
16191
+ throw new Error(`'--${name}' is required`);
16192
+ return value.trim();
16193
+ }
16194
+ async function deployFunctionManifest(http, args, options = {}) {
16195
+ if (options.readOnly) {
16196
+ return { isError: true, content: [{ type: "text", text: "⚠️ Edge Function release publication blocked in read-only mode." }] };
16197
+ }
16198
+ if (args.atomic !== true)
16199
+ throw new Error("'--atomic' is required for 'deploy_manifest'");
16200
+ const projectRef = requiredArg(args, "ref");
16201
+ const manifestPath = requiredArg(args, "manifest");
16202
+ const bundlesDir = typeof args["bundles-dir"] === "string" ? args["bundles-dir"].trim() : undefined;
16203
+ const mutationId = typeof args["mutation-id"] === "string" && args["mutation-id"].trim() ? args["mutation-id"].trim() : crypto.randomUUID();
16204
+ if (!validUuid(mutationId))
16205
+ throw new Error("'--mutation-id' must be a UUIDv4");
16206
+ const entries = parseManifest(manifestPath);
16207
+ const statusResponse = await http.get(projectPath(projectRef, "/function-releases"), { maxJsonBytes: 256 * 1024 });
16208
+ const status = parseReleaseStatus(statusResponse.data, projectRef);
16209
+ if (!statusResponse.ok || !status) {
16210
+ return releaseControlFailure(RELEASE_OPERATION, "INVALID_RESPONSE", statusResponse.status, { project_ref: projectRef, mutation_id: mutationId });
16211
+ }
16212
+ const requested = new Map(entries.map((entry) => [entry.slug, entry]));
16213
+ const memberVersions = new Map(status.functions.map((entry) => [entry.slug, entry]));
16214
+ const staged = [];
16215
+ for (const entry of entries) {
16216
+ const identityResponse = await http.get(projectPath(projectRef, `/functions/${encodeURIComponent(entry.slug)}/config`), {
16217
+ maxJsonBytes: 128 * 1024
16218
+ });
16219
+ const identity = projectedFunctionIdentity(identityResponse.data, projectRef, entry.slug);
16220
+ if (!identityResponse.ok || !identity) {
16221
+ return releaseControlFailure(RELEASE_OPERATION, "INVALID_RESPONSE", identityResponse.status, {
16222
+ project_ref: projectRef,
16223
+ mutation_id: mutationId,
16224
+ slug: entry.slug
16225
+ });
16226
+ }
16227
+ const code = await bundleSource(entry.entrypoint, bundlesDir, entry.slug);
16228
+ const stageResponse = await http.postReleaseMutation(projectPath(projectRef, `/functions/${encodeURIComponent(entry.slug)}/stage`), { code, config: stageConfig(entry) }, { timeoutMs: 5 * 60000 });
16229
+ const version = stagedVersion(stageResponse.data);
16230
+ if (!stageResponse.ok) {
16231
+ return releaseControlMutationFailure(RELEASE_OPERATION, stageResponse, {
16232
+ project_ref: projectRef,
16233
+ mutation_id: mutationId,
16234
+ slug: entry.slug
16235
+ });
16236
+ }
16237
+ if (!version) {
16238
+ return releaseControlFailure(RELEASE_OPERATION, "OUTCOME_UNKNOWN", stageResponse.status, {
16239
+ project_ref: projectRef,
16240
+ mutation_id: mutationId,
16241
+ slug: entry.slug
16242
+ });
16243
+ }
16244
+ staged.push({ slug: entry.slug, version, expected_activation_id: identity.activation_id });
16245
+ }
16246
+ const members = new Map([...memberVersions.values()].map((member) => [
16247
+ member.slug,
16248
+ { slug: member.slug, version: member.version, expected_activation_id: member.activation_id }
16249
+ ]));
16250
+ for (const member of staged)
16251
+ members.set(member.slug, member);
16252
+ const missing = [...memberVersions.keys()].filter((slug) => !requested.has(slug));
16253
+ const releaseResponse = await http.postReleaseMutation(projectPath(projectRef, "/function-releases"), {
16254
+ mutation_id: mutationId,
16255
+ expected_release_id: status.active_release_id,
16256
+ functions: [...members.values()].sort((left, right) => left.slug.localeCompare(right.slug))
16257
+ }, { timeoutMs: 5 * 60000 });
16258
+ if (!releaseResponse.ok) {
16259
+ return releaseControlMutationFailure(RELEASE_OPERATION, releaseResponse, {
16260
+ project_ref: projectRef,
16261
+ mutation_id: mutationId,
16262
+ expected_release_id: status.active_release_id,
16263
+ staged_functions: staged.map(({ slug, version }) => ({ slug, version })),
16264
+ retained_functions: missing
16265
+ });
16266
+ }
16267
+ const receipt = releaseReceipt(releaseResponse.data, projectRef, mutationId, [...members.values()]);
16268
+ if (!receipt) {
16269
+ return releaseControlFailure(RELEASE_OPERATION, "OUTCOME_UNKNOWN", releaseResponse.status, {
16270
+ project_ref: projectRef,
16271
+ mutation_id: mutationId,
16272
+ expected_release_id: status.active_release_id,
16273
+ staged_functions: staged.map(({ slug, version }) => ({ slug, version })),
16274
+ retained_functions: missing
16275
+ });
16276
+ }
16277
+ return releaseControlSuccess(RELEASE_OPERATION, {
16278
+ ...receipt,
16279
+ expected_release_id: status.active_release_id,
16280
+ staged_functions: staged.map(({ slug, version }) => ({ slug, version })),
16281
+ retained_functions: missing
16282
+ });
16283
+ }
16284
+
15933
16285
  // src/shared/tools/advanced-tools.ts
15934
16286
  var SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/;
15935
16287
  var FORBIDDEN_BUNDLE_SEGMENTS = new Set(["node_modules", ".git"]);
@@ -16007,13 +16359,13 @@ function scaffoldFunction(pathArg, slug, framework) {
16007
16359
  if (typeof framework !== "string" || !FUNCTION_FRAMEWORKS2.includes(framework)) {
16008
16360
  throw new Error("'framework' required for 'scaffold'");
16009
16361
  }
16010
- const target = resolve7(typeof pathArg === "string" ? pathArg : join5("supabase", "functions", slug));
16011
- if (existsSync5(target))
16362
+ const target = resolve8(typeof pathArg === "string" ? pathArg : join6("supabase", "functions", slug));
16363
+ if (existsSync6(target))
16012
16364
  throw new Error(`Scaffold target already exists: ${target}`);
16013
16365
  const files = scaffoldFiles(framework, slug);
16014
16366
  for (const [relativePath, contents] of Object.entries(files)) {
16015
- const destination = join5(target, relativePath);
16016
- mkdirSync(resolve7(destination, ".."), { recursive: true });
16367
+ const destination = join6(target, relativePath);
16368
+ mkdirSync(resolve8(destination, ".."), { recursive: true });
16017
16369
  writeFileSync(destination, contents, { flag: "wx" });
16018
16370
  }
16019
16371
  return JSON.stringify({ success: true, framework, path: target, files: Object.keys(files) }, null, 2);
@@ -16058,10 +16410,10 @@ function assertExpectedSha256(bytes, expectedSha256) {
16058
16410
  }
16059
16411
  }
16060
16412
  function readVerifiedPrebundledCode(pathArg, expectedSha256) {
16061
- const descriptor = openSync(resolve7(pathArg), fsConstants.O_RDONLY | fsConstants.O_NONBLOCK);
16413
+ const descriptor = openSync(resolve8(pathArg), fsConstants.O_RDONLY | fsConstants.O_NONBLOCK);
16062
16414
  try {
16063
16415
  const identityBeforeRead = openFileIdentity(descriptor);
16064
- const bytes = readFileSync6(descriptor);
16416
+ const bytes = readFileSync7(descriptor);
16065
16417
  const identityAfterRead = openFileIdentity(descriptor);
16066
16418
  if (BigInt(bytes.byteLength) !== identityBeforeRead.size || !sameOpenFile(identityBeforeRead, identityAfterRead)) {
16067
16419
  throw new Error("Prebundled file changed while it was being read");
@@ -16073,7 +16425,7 @@ function readVerifiedPrebundledCode(pathArg, expectedSha256) {
16073
16425
  }
16074
16426
  }
16075
16427
  function canonicalBundlePath(root, filePath) {
16076
- const bundlePath = relative2(root, filePath).split(sep2).join("/");
16428
+ const bundlePath = relative3(root, filePath).split(sep3).join("/");
16077
16429
  const segments = bundlePath.split("/");
16078
16430
  if (!bundlePath || bundlePath.startsWith("/") || segments.some((segment) => !segment || segment === "." || segment === ".." || segment.startsWith("._") || FORBIDDEN_BUNDLE_SEGMENTS.has(segment))) {
16079
16431
  throw new Error(`Bundle directory contains a forbidden path: ${bundlePath || filePath}`);
@@ -16084,7 +16436,7 @@ function readBundleDirectory(root, directory = root) {
16084
16436
  const files = {};
16085
16437
  const entries = readdirSync3(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
16086
16438
  for (const entry of entries) {
16087
- const entryPath = join5(directory, entry.name);
16439
+ const entryPath = join6(directory, entry.name);
16088
16440
  const bundlePath = canonicalBundlePath(root, entryPath);
16089
16441
  const entryState = lstatSync(entryPath);
16090
16442
  if (entryState.isSymbolicLink())
@@ -16095,7 +16447,7 @@ function readBundleDirectory(root, directory = root) {
16095
16447
  }
16096
16448
  if (!entryState.isFile())
16097
16449
  throw new Error(`Bundle directory must contain only regular files: ${bundlePath}`);
16098
- files[bundlePath] = verifiedUtf8Code(readFileSync6(entryPath));
16450
+ files[bundlePath] = verifiedUtf8Code(readFileSync7(entryPath));
16099
16451
  }
16100
16452
  return files;
16101
16453
  }
@@ -16107,7 +16459,7 @@ function preparedBundleFiles(args) {
16107
16459
  }
16108
16460
  if (typeof bundleDirectory !== "string")
16109
16461
  return files;
16110
- const resolvedDirectory = resolve7(bundleDirectory);
16462
+ const resolvedDirectory = resolve8(bundleDirectory);
16111
16463
  const rootState = lstatSync(resolvedDirectory);
16112
16464
  if (rootState.isSymbolicLink() || !rootState.isDirectory()) {
16113
16465
  throw new Error("'--bundle-dir' must be a regular directory and must not be a symlink");
@@ -16145,8 +16497,8 @@ async function runBunBuild(args) {
16145
16497
  }
16146
16498
  async function bundleEdgeFunctionPath(pathArg) {
16147
16499
  const entrypoint = resolveEntrypoint(pathArg);
16148
- const tmpDir = mkdtempSync(join5(tmpdir(), "supacloud-edge-"));
16149
- const outfile = join5(tmpDir, `${basename5(entrypoint).replace(/\.[^.]+$/, "") || "index"}.js`);
16500
+ const tmpDir = mkdtempSync2(join6(tmpdir2(), "supacloud-edge-"));
16501
+ const outfile = join6(tmpDir, `${basename6(entrypoint).replace(/\.[^.]+$/, "") || "index"}.js`);
16150
16502
  try {
16151
16503
  const { stderr } = await runBunBuild([entrypoint, "--target", "bun", "--outfile", outfile]);
16152
16504
  const outFileHandle = Bun.file(outfile);
@@ -16154,7 +16506,7 @@ async function bundleEdgeFunctionPath(pathArg) {
16154
16506
  throw new Error(`Bundle failed: ${stderr}`);
16155
16507
  return await outFileHandle.text();
16156
16508
  } finally {
16157
- rmSync(tmpDir, { recursive: true, force: true });
16509
+ rmSync2(tmpDir, { recursive: true, force: true });
16158
16510
  }
16159
16511
  }
16160
16512
  function prebundledDeployCode(pathArg, expectedSha256, minify) {
@@ -16189,14 +16541,14 @@ async function preparedDeployCode(args) {
16189
16541
  if (typeof pathArg !== "string")
16190
16542
  throw new Error("Function deploy source is invalid");
16191
16543
  if (args.aot === true) {
16192
- const directory = mkdtempSync(join5(tmpdir(), "supacloud-function-aot-"));
16544
+ const directory = mkdtempSync2(join6(tmpdir2(), "supacloud-function-aot-"));
16193
16545
  try {
16194
- return await buildFunctionAot(resolveEntrypoint(pathArg), join5(directory, "index.js"), {
16546
+ return await buildFunctionAot(resolveEntrypoint(pathArg), join6(directory, "index.js"), {
16195
16547
  ...typeof args["aot-entry"] === "string" ? { appEntry: args["aot-entry"] } : {},
16196
16548
  minify: args.minify === true
16197
16549
  });
16198
16550
  } finally {
16199
- rmSync(directory, { recursive: true, force: true });
16551
+ rmSync2(directory, { recursive: true, force: true });
16200
16552
  }
16201
16553
  }
16202
16554
  return bundledDeployCode(pathArg);
@@ -16220,12 +16572,12 @@ function rejectActionSpecificFlags(action, args) {
16220
16572
  }
16221
16573
  }
16222
16574
  function resolveEntrypoint(pathArg) {
16223
- const resolved = resolve7(pathArg);
16575
+ const resolved = resolve8(pathArg);
16224
16576
  const stat = statSync4(resolved);
16225
16577
  if (!stat.isDirectory())
16226
16578
  return resolved;
16227
- const entrypoint = join5(resolved, "index.ts");
16228
- if (!existsSync5(entrypoint)) {
16579
+ const entrypoint = join6(resolved, "index.ts");
16580
+ if (!existsSync6(entrypoint)) {
16229
16581
  throw new Error(`Directory provided but no index.ts found at ${entrypoint}`);
16230
16582
  }
16231
16583
  return entrypoint;
@@ -16533,7 +16885,7 @@ function functionSourceOutput(slug, sourceCode, output) {
16533
16885
  if (!output) {
16534
16886
  return { content: [{ type: "text", text: JSON.stringify({ code: sourceCode }, null, 2) }] };
16535
16887
  }
16536
- const outputPath = resolve7(output);
16888
+ const outputPath = resolve8(output);
16537
16889
  writeFileSync(outputPath, sourceCode, { flag: "wx" });
16538
16890
  return {
16539
16891
  content: [{
@@ -16705,8 +17057,8 @@ async function activateFunctionVersion(http, args, readOnly = false) {
16705
17057
  }
16706
17058
  function registerAdvancedTools(server, http, environment = process.env, options = {}) {
16707
17059
  registerTool(server, "edge_functions", `Edge Function management (Deno/Bun serverless). Source deploys are bundled; verified prebuilt artifacts stay byte-exact.
16708
- Actions: list, get_config, deploy, deploy_bundle, config, source, activate, delete, check, scaffold`, {
16709
- action: withDescription(stringEnum2(["list", "get_config", "deploy", "deploy_bundle", "config", "source", "activate", "delete", "check", "scaffold"]), "Action"),
17060
+ Actions: list, get_config, deploy, deploy_bundle, deploy_manifest, config, source, activate, delete, check, scaffold`, {
17061
+ action: withDescription(stringEnum2(["list", "get_config", "deploy", "deploy_bundle", "deploy_manifest", "config", "source", "activate", "delete", "check", "scaffold"]), "Action"),
16710
17062
  ref: optional(String2(), "Project ref (not used by scaffold)"),
16711
17063
  slug: optional(String2(), "[get_config/deploy/deploy_bundle/config/source/activate/delete/check] Function name"),
16712
17064
  version: withDescription(functionVersionSchema, "[source/activate] Existing immutable Function version; source requires a positive version"),
@@ -16730,7 +17082,11 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
16730
17082
  max_request_body_bytes: optional(Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }), "[deploy/deploy_bundle/config] Max inbound request body size in bytes"),
16731
17083
  max_body_size_mb: optional(Integer({ minimum: 1, maximum: 10240 }), "[deploy/deploy_bundle/config] Max inbound request body size in MiB (convenience shorthand)"),
16732
17084
  "expected-active-version": withDescription(expectedActiveVersionSchema, "[deploy/deploy_bundle/activate] Required current active version, or 'absent' when none exists"),
16733
- "expected-activation-id": withDescription(expectedActivationIdSchema, "[deploy/deploy_bundle/config/activate/delete] Required activation ID from list, or 'legacy' for a new or legacy function")
17085
+ "expected-activation-id": withDescription(expectedActivationIdSchema, "[deploy/deploy_bundle/config/activate/delete] Required activation ID from list, or 'legacy' for a new or legacy function"),
17086
+ manifest: optional(String2(), "[deploy_manifest] JSON release manifest path"),
17087
+ "bundles-dir": optional(String2(), "[deploy_manifest] Directory containing prebuilt <slug>.js files"),
17088
+ atomic: optional(Boolean2(), "[deploy_manifest] Required atomic project release publication"),
17089
+ "mutation-id": optional(String2(), "[deploy_manifest] Release mutation correlation UUIDv4")
16734
17090
  }, async (args) => {
16735
17091
  if (args.aot === true && options.readOnly) {
16736
17092
  return {
@@ -16741,6 +17097,8 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
16741
17097
  validateFunctionAot(args);
16742
17098
  if (args.action === "activate")
16743
17099
  return activateFunctionVersion(http, args, options.readOnly);
17100
+ if (args.action === "deploy_manifest")
17101
+ return deployFunctionManifest(http, args, options);
16744
17102
  if (args.action === "scaffold") {
16745
17103
  return { content: [{ type: "text", text: scaffoldFunction(args.path, args.slug, args.framework) }] };
16746
17104
  }
@@ -16785,8 +17143,8 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
16785
17143
  });
16786
17144
  const hasFunctionConfig = () => Object.keys(functionConfig()).length > 0;
16787
17145
  const checkSyntax = async (sourceCode) => {
16788
- const tmpDir = mkdtempSync(join5(tmpdir(), "supacloud-edge-check-"));
16789
- const tmpFile = join5(tmpDir, "index.ts");
17146
+ const tmpDir = mkdtempSync2(join6(tmpdir2(), "supacloud-edge-check-"));
17147
+ const tmpFile = join6(tmpDir, "index.ts");
16790
17148
  writeFileSync(tmpFile, sourceCode);
16791
17149
  try {
16792
17150
  if (/@ts-(?:ignore|nocheck|expect-error)\b/.test(sourceCode)) {
@@ -16808,7 +17166,7 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
16808
17166
  return { ok: false, err: `${stdout}
16809
17167
  ${stderr || message}` };
16810
17168
  } finally {
16811
- rmSync(tmpDir, { recursive: true, force: true });
17169
+ rmSync2(tmpDir, { recursive: true, force: true });
16812
17170
  }
16813
17171
  };
16814
17172
  if (action === "check" && pathArg && !code) {
@@ -17099,7 +17457,7 @@ ${JSON.stringify(r.data, null, 2)}` : `❌ Failed (${r.status}): ${JSON.stringif
17099
17457
  import { createHash as createHash8 } from "node:crypto";
17100
17458
  import { constants as fsConstants2 } from "node:fs";
17101
17459
  import { open as open2 } from "node:fs/promises";
17102
- import { resolve as resolve8 } from "node:path";
17460
+ import { resolve as resolve9 } from "node:path";
17103
17461
 
17104
17462
  // src/shared/mutation-protocol.ts
17105
17463
  import { createHash as createHash7 } from "node:crypto";
@@ -17341,7 +17699,7 @@ async function fetchMutationStatus(http, ref, mutationId) {
17341
17699
  // src/shared/tools/frontend-release-control.ts
17342
17700
  var PROJECT_REF_PATTERN3 = /^[A-Za-z0-9_-]{1,20}$/u;
17343
17701
  var DEPLOYMENT_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/u;
17344
- var RELEASE_ID_PATTERN = /^[0-9a-f]{64}$/u;
17702
+ var RELEASE_ID_PATTERN2 = /^[0-9a-f]{64}$/u;
17345
17703
  var MUTATION_ID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
17346
17704
  var TIMESTAMP_PATTERN2 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;
17347
17705
  var ARCHIVE_MAX_BYTES = 100 * 1024 * 1024;
@@ -17386,7 +17744,7 @@ function releaseRecord(candidate) {
17386
17744
  "kind",
17387
17745
  "archive_format"
17388
17746
  ];
17389
- if (!exactKeys2(record, keys) || record.schema !== FRONTEND_ARCHIVE_RELEASE_SCHEMA || record.archive_format !== FRONTEND_ARCHIVE_FORMAT || typeof record.project_ref !== "string" || !PROJECT_REF_PATTERN3.test(record.project_ref) || typeof record.deployment_id !== "string" || !DEPLOYMENT_ID_PATTERN.test(record.deployment_id) || typeof record.release_id !== "string" || !RELEASE_ID_PATTERN.test(record.release_id) || record.sha256 !== record.release_id || typeof record.tree_sha256 !== "string" || !RELEASE_ID_PATTERN.test(record.tree_sha256) || !Number.isSafeInteger(record.size_bytes) || Number(record.size_bytes) < 1 || !Number.isSafeInteger(record.file_count) || Number(record.file_count) < 1 || !canonicalTimestamp2(record.created_at) || record.kind !== "prebuilt_static")
17747
+ if (!exactKeys2(record, keys) || record.schema !== FRONTEND_ARCHIVE_RELEASE_SCHEMA || record.archive_format !== FRONTEND_ARCHIVE_FORMAT || typeof record.project_ref !== "string" || !PROJECT_REF_PATTERN3.test(record.project_ref) || typeof record.deployment_id !== "string" || !DEPLOYMENT_ID_PATTERN.test(record.deployment_id) || typeof record.release_id !== "string" || !RELEASE_ID_PATTERN2.test(record.release_id) || record.sha256 !== record.release_id || typeof record.tree_sha256 !== "string" || !RELEASE_ID_PATTERN2.test(record.tree_sha256) || !Number.isSafeInteger(record.size_bytes) || Number(record.size_bytes) < 1 || !Number.isSafeInteger(record.file_count) || Number(record.file_count) < 1 || !canonicalTimestamp2(record.created_at) || record.kind !== "prebuilt_static")
17390
17748
  return null;
17391
17749
  return {
17392
17750
  project_ref: record.project_ref,
@@ -17435,9 +17793,9 @@ function releaseInventory(candidate, expected) {
17435
17793
  ];
17436
17794
  if (!exactKeys2(record, keys) || typeof record.project_ref !== "string" || !PROJECT_REF_PATTERN3.test(record.project_ref) || typeof record.deployment_id !== "string" || !DEPLOYMENT_ID_PATTERN.test(record.deployment_id) || !Array.isArray(record.releases))
17437
17795
  return null;
17438
- const activeReleaseId = nullableIdentity(record.active_release_id, RELEASE_ID_PATTERN);
17796
+ const activeReleaseId = nullableIdentity(record.active_release_id, RELEASE_ID_PATTERN2);
17439
17797
  const activeActivationId = nullableIdentity(record.active_activation_id, MUTATION_ID_PATTERN2);
17440
- const nextCursor = nullableIdentity(record.next_cursor, RELEASE_ID_PATTERN);
17798
+ const nextCursor = nullableIdentity(record.next_cursor, RELEASE_ID_PATTERN2);
17441
17799
  const releases = record.releases.map(releaseRecord);
17442
17800
  if (activeReleaseId === undefined || activeActivationId === undefined || nextCursor === undefined || activeReleaseId === null !== (activeActivationId === null) || releases.some((release) => release === null))
17443
17801
  return null;
@@ -17464,7 +17822,7 @@ function releaseEndpoint(projectRef, deploymentId) {
17464
17822
  return `${deploymentEndpoint(projectRef, deploymentId)}/releases`;
17465
17823
  }
17466
17824
  function releasePath(projectRef, deploymentId, releaseId) {
17467
- if (!RELEASE_ID_PATTERN.test(releaseId))
17825
+ if (!RELEASE_ID_PATTERN2.test(releaseId))
17468
17826
  throw new Error("'release_id' must be a SHA-256 digest");
17469
17827
  return `${releaseEndpoint(projectRef, deploymentId)}/${releaseId}`;
17470
17828
  }
@@ -17485,7 +17843,7 @@ async function archiveSha256(handle, sizeBytes) {
17485
17843
  return hash.digest("hex");
17486
17844
  }
17487
17845
  async function verifiedArchive(path) {
17488
- const archivePath = resolve8(path);
17846
+ const archivePath = resolve9(path);
17489
17847
  const handle = await open2(archivePath, fsConstants2.O_RDONLY | fsConstants2.O_NOFOLLOW);
17490
17848
  try {
17491
17849
  const before = await handle.stat({ bigint: true });
@@ -17529,7 +17887,7 @@ async function listFrontendReleases(http, projectRef, deploymentId, cursor, limi
17529
17887
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > RELEASE_LIST_LIMIT_MAX) {
17530
17888
  throw new Error("'limit' must be 1-100");
17531
17889
  }
17532
- if (cursor !== undefined && !RELEASE_ID_PATTERN.test(cursor))
17890
+ if (cursor !== undefined && !RELEASE_ID_PATTERN2.test(cursor))
17533
17891
  throw new Error("'cursor' is invalid");
17534
17892
  const query = new URLSearchParams({ limit: String(limit) });
17535
17893
  if (cursor)
@@ -17860,7 +18218,7 @@ async function publishFrontendRelease(http, projectRef, deploymentId, archiveSou
17860
18218
  const envelope = value && typeof value === "object" && !Array.isArray(value) ? value : null;
17861
18219
  const candidate = envelope?.release;
17862
18220
  const release = candidate && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
17863
- if (!release || release.tree_sha256 !== expectedTreeSha256 || typeof release.release_id !== "string" || !RELEASE_ID_PATTERN.test(release.release_id)) {
18221
+ if (!release || release.tree_sha256 !== expectedTreeSha256 || typeof release.release_id !== "string" || !RELEASE_ID_PATTERN2.test(release.release_id)) {
17864
18222
  return releaseFailure("frontend.deploy", "INVALID_RESPONSE", 200);
17865
18223
  }
17866
18224
  const mutationId = crypto.randomUUID();
@@ -17925,7 +18283,7 @@ async function rollbackBoundFrontendRelease(http, input) {
17925
18283
  return boundRollbackResponse(await activateFrontendRelease(http, input), input);
17926
18284
  }
17927
18285
  async function rollbackFrontendRelease(http, projectRef, deploymentId, releaseId, options = {}) {
17928
- if (releaseId !== undefined && !RELEASE_ID_PATTERN.test(releaseId)) {
18286
+ if (releaseId !== undefined && !RELEASE_ID_PATTERN2.test(releaseId)) {
17929
18287
  throw new Error("'release_id' must be a SHA-256 digest");
17930
18288
  }
17931
18289
  const bound = options.expectedActiveReleaseId !== undefined || options.expectedActivationId !== undefined || options.mutationId !== undefined;
@@ -17934,7 +18292,7 @@ async function rollbackFrontendRelease(http, projectRef, deploymentId, releaseId
17934
18292
  if (releaseId === undefined || expectedActiveReleaseId === undefined || expectedActivationId === undefined || mutationId === undefined) {
17935
18293
  throw new Error("'release_id', 'expected_active_release_id', 'expected_activation_id', and 'mutation_id' are required together for a bound rollback");
17936
18294
  }
17937
- if (!RELEASE_ID_PATTERN.test(expectedActiveReleaseId)) {
18295
+ if (!RELEASE_ID_PATTERN2.test(expectedActiveReleaseId)) {
17938
18296
  throw new Error("'expected_active_release_id' must be a SHA-256 digest");
17939
18297
  }
17940
18298
  if (!MUTATION_ID_PATTERN2.test(expectedActivationId)) {
@@ -18022,7 +18380,7 @@ async function readPreviousFrontendRelease(http, projectRef, deploymentId) {
18022
18380
  }
18023
18381
  const data = response.data;
18024
18382
  const value = data && typeof data === "object" && !Array.isArray(data) ? data : null;
18025
- const activeReleaseId = value ? nullableIdentity(value.active_release_id, RELEASE_ID_PATTERN) : undefined;
18383
+ const activeReleaseId = value ? nullableIdentity(value.active_release_id, RELEASE_ID_PATTERN2) : undefined;
18026
18384
  const activeActivationId = value ? nullableIdentity(value.active_activation_id, MUTATION_ID_PATTERN2) : undefined;
18027
18385
  const previousActivationId = value ? nullableIdentity(value.previous_activation_id, MUTATION_ID_PATTERN2) : undefined;
18028
18386
  const previous = value?.previous_release === null ? null : releaseRecord(value?.previous_release);
@@ -18056,7 +18414,7 @@ async function activateFrontendReleaseWithReadback(http, input, readActive) {
18056
18414
  const mutationId = input.mutationId;
18057
18415
  if (!MUTATION_ID_PATTERN2.test(mutationId))
18058
18416
  throw new Error("'mutation_id' must be a UUIDv4");
18059
- if (input.expectedActiveReleaseId !== "absent" && !RELEASE_ID_PATTERN.test(input.expectedActiveReleaseId)) {
18417
+ if (input.expectedActiveReleaseId !== "absent" && !RELEASE_ID_PATTERN2.test(input.expectedActiveReleaseId)) {
18060
18418
  throw new Error("'expected_active_release_id' is invalid");
18061
18419
  }
18062
18420
  if (input.expectedActivationId !== "absent" && !MUTATION_ID_PATTERN2.test(input.expectedActivationId)) {
@@ -21106,11 +21464,11 @@ function responseError(result) {
21106
21464
  }
21107
21465
  return `Request failed with HTTP ${result.status}`;
21108
21466
  }
21109
- function projectPath(ref) {
21467
+ function projectPath2(ref) {
21110
21468
  return `/v1/projects/${encodeURIComponent(ref)}/branches`;
21111
21469
  }
21112
21470
  function branchPath(ref, branchRef) {
21113
- return `${projectPath(ref)}/${encodeURIComponent(branchRef)}`;
21471
+ return `${projectPath2(ref)}/${encodeURIComponent(branchRef)}`;
21114
21472
  }
21115
21473
  function formatPromotionPlan(plan) {
21116
21474
  const lines = [
@@ -21185,10 +21543,10 @@ function registerBranchTools(server, http, options = {}) {
21185
21543
  }
21186
21544
  let result;
21187
21545
  if (action === "list") {
21188
- result = await http.get(projectPath(ref));
21546
+ result = await http.get(projectPath2(ref));
21189
21547
  } else if (action === "create") {
21190
21548
  const name = requireString(args.name, "name");
21191
- result = await http.post(projectPath(ref), {
21549
+ result = await http.post(projectPath2(ref), {
21192
21550
  name,
21193
21551
  data_mode: args.data_mode === "full_clone" ? "full_clone" : "schema_only"
21194
21552
  });
@@ -21288,8 +21646,8 @@ function registerBranchTools(server, http, options = {}) {
21288
21646
  }
21289
21647
 
21290
21648
  // src/shared/tools/supabase-cli-tools.ts
21291
- import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
21292
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve9 } from "node:path";
21649
+ import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
21650
+ import { dirname as dirname4, isAbsolute as isAbsolute2, join as join7, resolve as resolve10 } from "node:path";
21293
21651
  var SENSITIVE_ENV_KEY = /(?:^|_)(?:PASSWORD|PASS|SECRET|TOKEN|KEY|CREDENTIALS?|AUTHORIZATION|AUTH|SESSION|COOKIE|BEARER|DB_URI|DB_URL|DSN|DATABASE_URL|DATABASE_URI|CONNECTION_STRING|CONNECTION_URI)(?:_|$)/i;
21294
21652
  var VALID_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
21295
21653
  var VALID_MIGRATION_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,100}$/;
@@ -21349,12 +21707,12 @@ function schemaArguments(schema) {
21349
21707
  function workdirArguments(workdir) {
21350
21708
  if (!workdir)
21351
21709
  throw new Error("A workdir is required");
21352
- return ["--workdir", resolve9(workdir)];
21710
+ return ["--workdir", resolve10(workdir)];
21353
21711
  }
21354
21712
  function resolveOutputPath(workdir, file, label) {
21355
21713
  if (!file || /[\r\n\0]/.test(file))
21356
21714
  throw new Error(`${label} file is required`);
21357
- return isAbsolute2(file) ? resolve9(file) : resolve9(workdir, file);
21715
+ return isAbsolute2(file) ? resolve10(file) : resolve10(workdir, file);
21358
21716
  }
21359
21717
  function databaseTargetArguments(databaseUrl) {
21360
21718
  return databaseUrl ? ["--db-url", requirePostgresUrl(databaseUrl)] : ["--local"];
@@ -21529,7 +21887,7 @@ function actionArguments(request, workdir) {
21529
21887
  function buildOfficialSupabaseArgs(request) {
21530
21888
  if (request.action === "version")
21531
21889
  return ["--version"];
21532
- const workdir = request.workdir ? resolve9(request.workdir) : undefined;
21890
+ const workdir = request.workdir ? resolve10(request.workdir) : undefined;
21533
21891
  if (!workdir)
21534
21892
  throw new Error("A workdir is required");
21535
21893
  return [...actionArguments(request, workdir), ...workdirArguments(workdir)];
@@ -21606,14 +21964,14 @@ function resolveOfficialSupabaseCommand(workdir, environment = process.env) {
21606
21964
  }
21607
21965
  return ["npx", "--yes", `supabase@${version}`];
21608
21966
  }
21609
- const localPackageEntry = join6(resolve9(workdir), "node_modules", "supabase", "dist", "supabase.js");
21610
- if (existsSync6(localPackageEntry))
21967
+ const localPackageEntry = join7(resolve10(workdir), "node_modules", "supabase", "dist", "supabase.js");
21968
+ if (existsSync7(localPackageEntry))
21611
21969
  return [process.execPath, localPackageEntry];
21612
21970
  return ["supabase"];
21613
21971
  }
21614
21972
  function resolveExistingWorkdir(workdirInput, fallback) {
21615
- const workdir = resolve9(workdirInput || fallback);
21616
- if (!existsSync6(workdir) || !statSync5(workdir).isDirectory()) {
21973
+ const workdir = resolve10(workdirInput || fallback);
21974
+ if (!existsSync7(workdir) || !statSync5(workdir).isDirectory()) {
21617
21975
  throw new Error(`Supabase workdir not found: ${workdir}`);
21618
21976
  }
21619
21977
  return workdir;
@@ -21713,7 +22071,7 @@ async function executeMigrationPush(request, runtime) {
21713
22071
  if (!projectRef)
21714
22072
  return missingProjectRefResult();
21715
22073
  const workdir = resolveExistingWorkdir(request.workdir, runtime.fallbackWorkdir);
21716
- const migrationDirectory = resolve9(workdir, request.dir || "supabase/migrations");
22074
+ const migrationDirectory = resolve10(workdir, request.dir || "supabase/migrations");
21717
22075
  const migrationResponse = await pushMigrations({
21718
22076
  action: "push_migrations",
21719
22077
  ref: projectRef,
@@ -21756,7 +22114,7 @@ async function executeOfficialAction(request, runtime) {
21756
22114
  if (execution.exitCode === 0 && request.action === "gen_types" && outputPath) {
21757
22115
  return generatedTypesResult(outputPath, execution, secrets);
21758
22116
  }
21759
- if (execution.exitCode === 0 && request.action === "db_dump" && outputPath && existsSync6(outputPath)) {
22117
+ if (execution.exitCode === 0 && request.action === "db_dump" && outputPath && existsSync7(outputPath)) {
21760
22118
  chmodSync(outputPath, 384);
21761
22119
  }
21762
22120
  return {
@@ -21825,12 +22183,12 @@ function registerSupabaseCliTools(server, options = {}) {
21825
22183
  }
21826
22184
 
21827
22185
  // src/shared/tools/lite-cli-tools.ts
21828
- import { existsSync as existsSync8, statSync as statSync7 } from "node:fs";
21829
- import { resolve as resolve11 } from "node:path";
22186
+ import { existsSync as existsSync9, statSync as statSync7 } from "node:fs";
22187
+ import { resolve as resolve12 } from "node:path";
21830
22188
 
21831
22189
  // src/shared/tools/lite-cli-command.ts
21832
- import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "node:fs";
21833
- import { isAbsolute as isAbsolute3, join as join7, relative as relative3, resolve as resolve10 } from "node:path";
22190
+ import { existsSync as existsSync8, readFileSync as readFileSync8, statSync as statSync6 } from "node:fs";
22191
+ import { isAbsolute as isAbsolute3, join as join8, relative as relative4, resolve as resolve11 } from "node:path";
21834
22192
  function isRecord5(value) {
21835
22193
  return value !== null && typeof value === "object" && !Array.isArray(value);
21836
22194
  }
@@ -21841,11 +22199,11 @@ function resolveLiteCommand(workdir, environment = process.env) {
21841
22199
  throw new Error("Invalid SUPACLOUD_LITE_CLI_BIN");
21842
22200
  return [explicitBinary];
21843
22201
  }
21844
- const packageRoot = join7(resolve10(workdir), "node_modules", "@supacloud", "lite");
21845
- const manifestPath = join7(packageRoot, "package.json");
21846
- if (!existsSync7(manifestPath))
22202
+ const packageRoot = join8(resolve11(workdir), "node_modules", "@supacloud", "lite");
22203
+ const manifestPath = join8(packageRoot, "package.json");
22204
+ if (!existsSync8(manifestPath))
21847
22205
  return ["supacloud-lite"];
21848
- const manifest = JSON.parse(readFileSync7(manifestPath, "utf8"));
22206
+ const manifest = JSON.parse(readFileSync8(manifestPath, "utf8"));
21849
22207
  if (!isRecord5(manifest) || manifest.name !== "@supacloud/lite" || !isRecord5(manifest.bin)) {
21850
22208
  throw new Error("Invalid installed @supacloud/lite package manifest");
21851
22209
  }
@@ -21853,20 +22211,20 @@ function resolveLiteCommand(workdir, environment = process.env) {
21853
22211
  if (typeof entry !== "string" || !entry.trim() || entry.includes("\x00") || isAbsolute3(entry)) {
21854
22212
  throw new Error("Invalid installed @supacloud/lite bin");
21855
22213
  }
21856
- const executable = resolve10(packageRoot, entry);
21857
- const packageRelative = relative3(packageRoot, executable);
22214
+ const executable = resolve11(packageRoot, entry);
22215
+ const packageRelative = relative4(packageRoot, executable);
21858
22216
  if (!packageRelative || packageRelative === ".." || packageRelative.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute3(packageRelative)) {
21859
22217
  throw new Error("Installed @supacloud/lite bin must stay inside its package");
21860
22218
  }
21861
- if (!existsSync7(executable) || !statSync6(executable).isFile()) {
22219
+ if (!existsSync8(executable) || !statSync6(executable).isFile()) {
21862
22220
  throw new Error("Installed @supacloud/lite bin is missing; reinstall the package");
21863
22221
  }
21864
22222
  return [process.execPath, executable];
21865
22223
  }
21866
22224
  // src/shared/tools/lite-cli-tools.ts
21867
22225
  function requireWorkdir(workdir, fallback) {
21868
- const resolved = resolve11(workdir || fallback);
21869
- if (!existsSync8(resolved) || !statSync7(resolved).isDirectory()) {
22226
+ const resolved = resolve12(workdir || fallback);
22227
+ if (!existsSync9(resolved) || !statSync7(resolved).isDirectory()) {
21870
22228
  throw new Error(`Lite workdir not found: ${resolved}`);
21871
22229
  }
21872
22230
  return resolved;
@@ -22100,40 +22458,40 @@ function registerLiteCliTools(server, options = {}) {
22100
22458
  // src/shared/tools/ai-tools.ts
22101
22459
  import {
22102
22460
  cpSync,
22103
- existsSync as existsSync9,
22461
+ existsSync as existsSync10,
22104
22462
  lstatSync as lstatSync2,
22105
22463
  mkdirSync as mkdirSync3,
22106
- mkdtempSync as mkdtempSync2,
22464
+ mkdtempSync as mkdtempSync3,
22107
22465
  readdirSync as readdirSync4,
22108
- readFileSync as readFileSync8,
22466
+ readFileSync as readFileSync9,
22109
22467
  renameSync,
22110
- rmSync as rmSync2
22468
+ rmSync as rmSync3
22111
22469
  } from "node:fs";
22112
22470
  import { homedir as homedir2 } from "node:os";
22113
- import { dirname as dirname5, join as join8, relative as relative4, resolve as resolve12, sep as sep3 } from "node:path";
22471
+ import { dirname as dirname5, join as join9, relative as relative5, resolve as resolve13, sep as sep4 } from "node:path";
22114
22472
  import { fileURLToPath } from "node:url";
22115
22473
  var SKILL_NAME = "supacloud";
22116
22474
  function regularFiles(rootDirectory, currentDirectory = rootDirectory) {
22117
22475
  const files = [];
22118
22476
  for (const directoryEntry of readdirSync4(currentDirectory, { withFileTypes: true })) {
22119
- const entryPath = join8(currentDirectory, directoryEntry.name);
22477
+ const entryPath = join9(currentDirectory, directoryEntry.name);
22120
22478
  if (directoryEntry.isSymbolicLink())
22121
22479
  throw new Error(`Skill directories cannot contain symlinks: ${entryPath}`);
22122
22480
  if (directoryEntry.isDirectory())
22123
22481
  files.push(...regularFiles(rootDirectory, entryPath));
22124
22482
  if (directoryEntry.isFile())
22125
- files.push(relative4(rootDirectory, entryPath).split(sep3).join("/"));
22483
+ files.push(relative5(rootDirectory, entryPath).split(sep4).join("/"));
22126
22484
  }
22127
22485
  return files.sort();
22128
22486
  }
22129
22487
  function directoriesMatch(sourceDirectory, destinationDirectory) {
22130
- if (!existsSync9(destinationDirectory) || !lstatSync2(destinationDirectory).isDirectory())
22488
+ if (!existsSync10(destinationDirectory) || !lstatSync2(destinationDirectory).isDirectory())
22131
22489
  return false;
22132
22490
  const sourceFiles = regularFiles(sourceDirectory);
22133
22491
  const destinationFiles = regularFiles(destinationDirectory);
22134
22492
  if (sourceFiles.join("\x00") !== destinationFiles.join("\x00"))
22135
22493
  return false;
22136
- return sourceFiles.every((file) => readFileSync8(join8(sourceDirectory, file)).equals(readFileSync8(join8(destinationDirectory, file))));
22494
+ return sourceFiles.every((file) => readFileSync9(join9(sourceDirectory, file)).equals(readFileSync9(join9(destinationDirectory, file))));
22137
22495
  }
22138
22496
  function backupTimestamp(now) {
22139
22497
  return now.toISOString().replace(/[-:.]/g, "");
@@ -22142,7 +22500,7 @@ function availableBackupDirectory(destinationDirectory, now) {
22142
22500
  const baseDirectory = `${destinationDirectory}.backup-${backupTimestamp(now)}`;
22143
22501
  let candidate = baseDirectory;
22144
22502
  let suffix = 2;
22145
- while (existsSync9(candidate)) {
22503
+ while (existsSync10(candidate)) {
22146
22504
  candidate = `${baseDirectory}-${suffix}`;
22147
22505
  suffix += 1;
22148
22506
  }
@@ -22150,12 +22508,12 @@ function availableBackupDirectory(destinationDirectory, now) {
22150
22508
  }
22151
22509
  function stagedSkill(sourceDirectory, targetRoot) {
22152
22510
  mkdirSync3(targetRoot, { recursive: true });
22153
- const stagingRoot = mkdtempSync2(join8(targetRoot, ".supacloud-install-"));
22154
- const stagingSkill = join8(stagingRoot, SKILL_NAME);
22511
+ const stagingRoot = mkdtempSync3(join9(targetRoot, ".supacloud-install-"));
22512
+ const stagingSkill = join9(stagingRoot, SKILL_NAME);
22155
22513
  try {
22156
22514
  cpSync(sourceDirectory, stagingSkill, { recursive: true, errorOnExist: true });
22157
22515
  } catch (error) {
22158
- rmSync2(stagingRoot, { recursive: true, force: true });
22516
+ rmSync3(stagingRoot, { recursive: true, force: true });
22159
22517
  throw error;
22160
22518
  }
22161
22519
  return { root: stagingRoot, skill: stagingSkill };
@@ -22165,7 +22523,7 @@ function createSkill(sourceDirectory, targetRoot, destinationDirectory) {
22165
22523
  try {
22166
22524
  renameSync(staging.skill, destinationDirectory);
22167
22525
  } finally {
22168
- rmSync2(staging.root, { recursive: true, force: true });
22526
+ rmSync3(staging.root, { recursive: true, force: true });
22169
22527
  }
22170
22528
  }
22171
22529
  function replaceSkill(sourceDirectory, targetRoot, destinationDirectory, backupDirectory) {
@@ -22179,17 +22537,17 @@ function replaceSkill(sourceDirectory, targetRoot, destinationDirectory, backupD
22179
22537
  throw error;
22180
22538
  }
22181
22539
  } finally {
22182
- rmSync2(staging.root, { recursive: true, force: true });
22540
+ rmSync3(staging.root, { recursive: true, force: true });
22183
22541
  }
22184
22542
  }
22185
22543
  function skillSummary(request, action, files, backupDirectory) {
22186
- const sourceDirectory = resolve12(request.sourceDirectory);
22187
- const targetRoot = resolve12(request.targetRoot);
22544
+ const sourceDirectory = resolve13(request.sourceDirectory);
22545
+ const targetRoot = resolve13(request.targetRoot);
22188
22546
  return {
22189
22547
  name: SKILL_NAME,
22190
22548
  sourceDirectory,
22191
22549
  targetRoot,
22192
- destinationDirectory: join8(targetRoot, SKILL_NAME),
22550
+ destinationDirectory: join9(targetRoot, SKILL_NAME),
22193
22551
  action,
22194
22552
  mode: request.mode,
22195
22553
  changed: action !== "none",
@@ -22198,14 +22556,14 @@ function skillSummary(request, action, files, backupDirectory) {
22198
22556
  };
22199
22557
  }
22200
22558
  function installSkill(request) {
22201
- const sourceDirectory = resolve12(request.sourceDirectory);
22202
- const targetRoot = resolve12(request.targetRoot);
22203
- const destinationDirectory = join8(targetRoot, SKILL_NAME);
22204
- if (!existsSync9(join8(sourceDirectory, "SKILL.md"))) {
22559
+ const sourceDirectory = resolve13(request.sourceDirectory);
22560
+ const targetRoot = resolve13(request.targetRoot);
22561
+ const destinationDirectory = join9(targetRoot, SKILL_NAME);
22562
+ if (!existsSync10(join9(sourceDirectory, "SKILL.md"))) {
22205
22563
  throw new Error(`Bundled SupaCloud CLI skill not found: ${sourceDirectory}`);
22206
22564
  }
22207
22565
  const files = regularFiles(sourceDirectory);
22208
- if (!existsSync9(destinationDirectory))
22566
+ if (!existsSync10(destinationDirectory))
22209
22567
  return installNewSkill(request, files);
22210
22568
  if (directoriesMatch(sourceDirectory, destinationDirectory)) {
22211
22569
  return skillSummary(request, "none", files, null);
@@ -22216,17 +22574,17 @@ function installSkill(request) {
22216
22574
  return installReplacementSkill(request, files);
22217
22575
  }
22218
22576
  function installNewSkill(request, files) {
22219
- const sourceDirectory = resolve12(request.sourceDirectory);
22220
- const targetRoot = resolve12(request.targetRoot);
22577
+ const sourceDirectory = resolve13(request.sourceDirectory);
22578
+ const targetRoot = resolve13(request.targetRoot);
22221
22579
  if (request.mode === "write") {
22222
- createSkill(sourceDirectory, targetRoot, join8(targetRoot, SKILL_NAME));
22580
+ createSkill(sourceDirectory, targetRoot, join9(targetRoot, SKILL_NAME));
22223
22581
  }
22224
22582
  return skillSummary(request, "create", files, null);
22225
22583
  }
22226
22584
  function installReplacementSkill(request, files) {
22227
- const sourceDirectory = resolve12(request.sourceDirectory);
22228
- const targetRoot = resolve12(request.targetRoot);
22229
- const destinationDirectory = join8(targetRoot, SKILL_NAME);
22585
+ const sourceDirectory = resolve13(request.sourceDirectory);
22586
+ const targetRoot = resolve13(request.targetRoot);
22587
+ const destinationDirectory = join9(targetRoot, SKILL_NAME);
22230
22588
  const backupDirectory = availableBackupDirectory(destinationDirectory, request.now);
22231
22589
  if (request.mode === "write") {
22232
22590
  replaceSkill(sourceDirectory, targetRoot, destinationDirectory, backupDirectory);
@@ -22235,7 +22593,7 @@ function installReplacementSkill(request, files) {
22235
22593
  }
22236
22594
  function resolveDefaultCodexSkillRoot(environment = process.env, homeDirectory = homedir2()) {
22237
22595
  const codexHome = environment.CODEX_HOME?.trim();
22238
- return join8(resolve12(codexHome || join8(homeDirectory, ".codex")), "skills");
22596
+ return join9(resolve13(codexHome || join9(homeDirectory, ".codex")), "skills");
22239
22597
  }
22240
22598
  var SKILL_TARGET_ALIASES = ["codex", "claude", "agents", "project"];
22241
22599
  function resolveSkillTargetRoot(target, options = {}) {
@@ -22247,23 +22605,23 @@ function resolveSkillTargetRoot(target, options = {}) {
22247
22605
  return resolveDefaultCodexSkillRoot(environment, homeDirectory);
22248
22606
  if (normalized === "claude") {
22249
22607
  const config = environment.CLAUDE_CONFIG_DIR?.trim();
22250
- return join8(resolve12(config || join8(homeDirectory, ".claude")), "skills");
22608
+ return join9(resolve13(config || join9(homeDirectory, ".claude")), "skills");
22251
22609
  }
22252
22610
  if (normalized === "agents") {
22253
22611
  const config = environment.AGENTS_HOME?.trim();
22254
- return join8(resolve12(config || join8(homeDirectory, ".agents")), "skills");
22612
+ return join9(resolve13(config || join9(homeDirectory, ".agents")), "skills");
22255
22613
  }
22256
22614
  if (normalized === "project")
22257
- return join8(resolve12(workingDirectory), ".agents", "skills");
22258
- return resolve12(target);
22615
+ return join9(resolve13(workingDirectory), ".agents", "skills");
22616
+ return resolve13(target);
22259
22617
  }
22260
22618
  function resolveBundledSkillDirectory(moduleUrl = import.meta.url) {
22261
22619
  const moduleDirectory = dirname5(fileURLToPath(moduleUrl));
22262
22620
  const candidates = [
22263
- resolve12(moduleDirectory, "../../../skills", SKILL_NAME),
22264
- resolve12(moduleDirectory, "../skills", SKILL_NAME)
22621
+ resolve13(moduleDirectory, "../../../skills", SKILL_NAME),
22622
+ resolve13(moduleDirectory, "../skills", SKILL_NAME)
22265
22623
  ];
22266
- const skillDirectory = candidates.find((candidate) => existsSync9(join8(candidate, "SKILL.md")));
22624
+ const skillDirectory = candidates.find((candidate) => existsSync10(join9(candidate, "SKILL.md")));
22267
22625
  if (!skillDirectory)
22268
22626
  throw new Error("Bundled SupaCloud CLI skill is missing from this installation");
22269
22627
  return skillDirectory;
@@ -22285,7 +22643,7 @@ function registerAiTools(server) {
22285
22643
  name: SKILL_NAME,
22286
22644
  sourceDirectory,
22287
22645
  defaultTargetRoot,
22288
- defaultDestination: join8(defaultTargetRoot, SKILL_NAME),
22646
+ defaultDestination: join9(defaultTargetRoot, SKILL_NAME),
22289
22647
  targetAliases: Object.fromEntries(SKILL_TARGET_ALIASES.map((alias) => [
22290
22648
  alias,
22291
22649
  resolveSkillTargetRoot(alias)
@@ -22351,9 +22709,9 @@ function registerMcpTools(server, context) {
22351
22709
  }
22352
22710
 
22353
22711
  // src/shared/tools/app-tools.ts
22354
- import { existsSync as existsSync12, readFileSync as readFileSync9 } from "node:fs";
22712
+ import { existsSync as existsSync13, readFileSync as readFileSync10 } from "node:fs";
22355
22713
  import { mkdir as mkdir6, readFile as readFile5, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
22356
- import { basename as basename7, dirname as dirname9, join as join14, relative as relative7, resolve as resolve19 } from "node:path";
22714
+ import { basename as basename8, dirname as dirname9, join as join15, relative as relative8, resolve as resolve20 } from "node:path";
22357
22715
  import {
22358
22716
  applyDiagnosticFix,
22359
22717
  buildDeliveryProject,
@@ -22650,7 +23008,7 @@ test("cancelled stream consumers release their subscription", async () => {
22650
23008
 
22651
23009
  // src/shared/tools/app-starter.ts
22652
23010
  import { lstat as lstat2, mkdir as mkdir3, readdir as readdir3, writeFile as writeFile3 } from "node:fs/promises";
22653
- import { basename as basename6, dirname as dirname6, join as join9, resolve as resolve13 } from "node:path";
23011
+ import { basename as basename7, dirname as dirname6, join as join10, resolve as resolve14 } from "node:path";
22654
23012
 
22655
23013
  // src/shared/tools/app-starter-environment.ts
22656
23014
  var STARTER_ENVIRONMENT = String.raw`import { existsSync, readFileSync } from "node:fs";
@@ -27491,8 +27849,8 @@ and governance; TypeScript checks both application and generated source.
27491
27849
  };
27492
27850
  }
27493
27851
  async function initializeAppProject(options) {
27494
- const root = resolve13(options.root ?? process.cwd());
27495
- const name = options.name ?? basename6(root);
27852
+ const root = resolve14(options.root ?? process.cwd());
27853
+ const name = options.name ?? basename7(root);
27496
27854
  if (!/^[a-z][a-z0-9-]*$/.test(name) || name.length > 100) {
27497
27855
  throw new Error("Project name must be lowercase kebab-case (1-100 characters)");
27498
27856
  }
@@ -27524,7 +27882,7 @@ async function initializeAppProject(options) {
27524
27882
  }
27525
27883
  })();
27526
27884
  for (const [relativePath, content] of Object.entries(files)) {
27527
- const path = join9(root, relativePath);
27885
+ const path = join10(root, relativePath);
27528
27886
  await mkdir3(dirname6(path), { recursive: true });
27529
27887
  await writeFile3(path, content, { encoding: "utf8", flag: "wx" });
27530
27888
  }
@@ -27532,8 +27890,8 @@ async function initializeAppProject(options) {
27532
27890
  }
27533
27891
 
27534
27892
  // src/shared/tools/app-database-check.ts
27535
- import { existsSync as existsSync10 } from "node:fs";
27536
- import { join as join10, resolve as resolve14 } from "node:path";
27893
+ import { existsSync as existsSync11 } from "node:fs";
27894
+ import { join as join11, resolve as resolve15 } from "node:path";
27537
27895
  var CHECK_ENTRY = `
27538
27896
  import { createRequire } from "node:module";
27539
27897
  import { join } from "node:path";
@@ -27544,8 +27902,8 @@ process.argv = [process.execPath, cli, "check", "--root", root];
27544
27902
  await import(pathToFileURL(cli).href);
27545
27903
  `;
27546
27904
  function checkAppDatabaseSources(projectRoot) {
27547
- const root = resolve14(projectRoot);
27548
- if (!existsSync10(join10(root, "database.sources.json")))
27905
+ const root = resolve15(projectRoot);
27906
+ if (!existsSync11(join11(root, "database.sources.json")))
27549
27907
  return;
27550
27908
  const name = "database-source-contracts";
27551
27909
  try {
@@ -28738,7 +29096,7 @@ Scenario: Delivery
28738
29096
  // src/shared/tools/app-local-dev.ts
28739
29097
  import { spawn } from "node:child_process";
28740
29098
  import { readFile as readFile2 } from "node:fs/promises";
28741
- import { join as join11, resolve as resolve15 } from "node:path";
29099
+ import { join as join12, resolve as resolve16 } from "node:path";
28742
29100
  function localDatabaseUrl(value) {
28743
29101
  try {
28744
29102
  if (!value || /[\x00-\x20\x7f]/.test(value))
@@ -28785,7 +29143,7 @@ async function probeDatabase(url, signal) {
28785
29143
  }
28786
29144
  }
28787
29145
  async function runLocalDevelopment(options) {
28788
- const root = resolve15(options.root);
29146
+ const root = resolve16(options.root);
28789
29147
  const profile = options.profile ?? "fast";
28790
29148
  if (profile !== "fast" && profile !== "integration")
28791
29149
  throw new Error("Unknown development profile");
@@ -28797,7 +29155,7 @@ async function runLocalDevelopment(options) {
28797
29155
  throw new Error("Inherited remote context must be complete and explicitly tagged with SUPACLOUD_ENV=test");
28798
29156
  }
28799
29157
  const script = profile === "integration" ? "dev:integration" : "dev";
28800
- const manifest = JSON.parse(await readFile2(join11(root, "package.json"), "utf8"));
29158
+ const manifest = JSON.parse(await readFile2(join12(root, "package.json"), "utf8"));
28801
29159
  const scripts = manifest && typeof manifest === "object" && "scripts" in manifest ? manifest.scripts : undefined;
28802
29160
  const command = scripts && typeof scripts === "object" ? Reflect.get(scripts, script) : undefined;
28803
29161
  if (typeof command !== "string" || !command.trim()) {
@@ -28886,9 +29244,9 @@ async function runLocalDevelopment(options) {
28886
29244
 
28887
29245
  // src/shared/tools/app-verification-plan.ts
28888
29246
  import { readdir as readdir4, realpath as realpath3, stat } from "node:fs/promises";
28889
- import { dirname as dirname7, isAbsolute as isAbsolute4, relative as relative5, resolve as resolve16 } from "node:path";
29247
+ import { dirname as dirname7, isAbsolute as isAbsolute4, relative as relative6, resolve as resolve17 } from "node:path";
28890
29248
  function inside2(root, file) {
28891
- const path = relative5(root, file).replaceAll("\\", "/");
29249
+ const path = relative6(root, file).replaceAll("\\", "/");
28892
29250
  return path !== ".." && !path.startsWith("../") && !isAbsolute4(path);
28893
29251
  }
28894
29252
  async function createVerificationPlan(root, graph, target, sourceRoot = root) {
@@ -28898,7 +29256,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28898
29256
  throw new Error("Select one unambiguous module or owned symbol for verification");
28899
29257
  const owner = owners[0];
28900
29258
  const project = await realpath3(root);
28901
- const requestedRoot = resolve16(root);
29259
+ const requestedRoot = resolve17(root);
28902
29260
  const sources = [
28903
29261
  owner.file,
28904
29262
  owner.featureSpec?.file,
@@ -28913,7 +29271,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28913
29271
  const manual = [];
28914
29272
  const validatedSources = [];
28915
29273
  for (const source of new Set(sources)) {
28916
- const requested = resolve16(sourceRoot, source);
29274
+ const requested = resolve17(sourceRoot, source);
28917
29275
  if (!inside2(requestedRoot, requested)) {
28918
29276
  manual.push("A source file is outside the project; select its owning project explicitly");
28919
29277
  continue;
@@ -28924,7 +29282,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28924
29282
  throw error;
28925
29283
  });
28926
29284
  if (actual === null) {
28927
- manual.push(`Source file is missing: ${relative5(requestedRoot, requested).replaceAll("\\", "/")}`);
29285
+ manual.push(`Source file is missing: ${relative6(requestedRoot, requested).replaceAll("\\", "/")}`);
28928
29286
  continue;
28929
29287
  }
28930
29288
  if (!inside2(project, actual)) {
@@ -28932,7 +29290,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28932
29290
  continue;
28933
29291
  }
28934
29292
  if (!(await stat(actual)).isFile()) {
28935
- manual.push(`Source is not a regular file: ${relative5(requestedRoot, requested).replaceAll("\\", "/")}`);
29293
+ manual.push(`Source is not a regular file: ${relative6(requestedRoot, requested).replaceAll("\\", "/")}`);
28936
29294
  continue;
28937
29295
  }
28938
29296
  validatedSources.push(actual);
@@ -28948,12 +29306,12 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28948
29306
  const local = [];
28949
29307
  for (const entry of await readdir4(directory, { withFileTypes: true })) {
28950
29308
  if (entry.isFile() && /\.(test|spec)\.[cm]?[jt]sx?$/.test(entry.name)) {
28951
- const file = relative5(project, resolve16(directory, entry.name)).replaceAll("\\", "/");
29309
+ const file = relative6(project, resolve17(directory, entry.name)).replaceAll("\\", "/");
28952
29310
  tests.add(file);
28953
29311
  local.push(file);
28954
29312
  }
28955
29313
  }
28956
- const path = relative5(project, directory).replaceAll("\\", "/") || ".";
29314
+ const path = relative6(project, directory).replaceAll("\\", "/") || ".";
28957
29315
  coverage.push({ directory: path, tests: local.sort(), basis: "colocated-not-proven" });
28958
29316
  if (!local.length)
28959
29317
  manual.push(`No colocated tests for source directory: ${path}`);
@@ -28968,7 +29326,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28968
29326
  source: "declaration",
28969
29327
  target: owner.name,
28970
29328
  ready: manual.length === 0,
28971
- files: [...new Set(validatedSources.map((file) => relative5(project, file).replaceAll("\\", "/")))].sort(),
29329
+ files: [...new Set(validatedSources.map((file) => relative6(project, file).replaceAll("\\", "/")))].sort(),
28972
29330
  tests: selected.slice(0, 32),
28973
29331
  commands: selected.length <= 32 ? [
28974
29332
  ...selected.map((file) => ["bun", "test", `./${file}`]),
@@ -28989,7 +29347,7 @@ async function createVerificationPlan(root, graph, target, sourceRoot = root) {
28989
29347
  // src/shared/tools/app-scaffold-writes.ts
28990
29348
  import { randomUUID as randomUUID2 } from "node:crypto";
28991
29349
  import { link, lstat as lstat3, mkdir as mkdir4, open as open3, readFile as readFile3, realpath as realpath4, rename as rename2, rmdir, unlink } from "node:fs/promises";
28992
- import { dirname as dirname8, isAbsolute as isAbsolute5, join as join12, relative as relative6, resolve as resolve17, sep as sep4, win32 } from "node:path";
29350
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join13, relative as relative7, resolve as resolve18, sep as sep5, win32 } from "node:path";
28993
29351
 
28994
29352
  class ScaffoldError extends Error {
28995
29353
  code;
@@ -29010,19 +29368,19 @@ function scaffoldPath(root, path) {
29010
29368
  if (parts.some((part) => /[<>:"|?*\u0000-\u001f]/.test(part) || /[ .]$/.test(part) && part !== "." && part !== ".." || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part) || part.toLowerCase() === ".git" || part.toLowerCase() === ".supacloud-generate.lock")) {
29011
29369
  throw new ScaffoldError("SCAFFOLD_PATH_INVALID", "Scaffold path is reserved or not portable");
29012
29370
  }
29013
- const target = resolve17(root, path);
29014
- const local = relative6(root, target);
29015
- if (!local || local === ".." || local.startsWith(`..${sep4}`) || isAbsolute5(local)) {
29371
+ const target = resolve18(root, path);
29372
+ const local = relative7(root, target);
29373
+ if (!local || local === ".." || local.startsWith(`..${sep5}`) || isAbsolute5(local)) {
29016
29374
  throw new ScaffoldError("SCAFFOLD_PATH_INVALID", "Scaffold path is outside the project root");
29017
29375
  }
29018
29376
  return target;
29019
29377
  }
29020
29378
  async function snapshot(root, path) {
29021
29379
  const target = scaffoldPath(root, path);
29022
- const parts = relative6(root, target).split(sep4);
29380
+ const parts = relative7(root, target).split(sep5);
29023
29381
  let current = root;
29024
29382
  for (const [index, part] of parts.entries()) {
29025
- current = join12(current, part);
29383
+ current = join13(current, part);
29026
29384
  let stat;
29027
29385
  try {
29028
29386
  stat = await lstat3(current);
@@ -29049,13 +29407,13 @@ function sameFile(a, b) {
29049
29407
  return a === null ? b === null : b !== null && a.content === b.content && a.dev === b.dev && a.ino === b.ino && a.mode === b.mode;
29050
29408
  }
29051
29409
  async function planScaffoldWrites(root, writes) {
29052
- const canonical = await realpath4(resolve17(root));
29410
+ const canonical = await realpath4(resolve18(root));
29053
29411
  const targets = new Set;
29054
29412
  const planned = [];
29055
29413
  for (const write of writes) {
29056
29414
  const target = scaffoldPath(canonical, write.path);
29057
29415
  const key = target.toLowerCase();
29058
- if (targets.has(key) || [...targets].some((other) => key.startsWith(`${other}${sep4}`) || other.startsWith(`${key}${sep4}`))) {
29416
+ if (targets.has(key) || [...targets].some((other) => key.startsWith(`${other}${sep5}`) || other.startsWith(`${key}${sep5}`))) {
29059
29417
  throw new ScaffoldError("SCAFFOLD_PATH_CONFLICT", `Conflicting scaffold target: ${write.path}`);
29060
29418
  }
29061
29419
  targets.add(key);
@@ -29072,7 +29430,7 @@ async function planScaffoldWrites(root, writes) {
29072
29430
  return Object.freeze({ root: canonical, writes: Object.freeze(planned) });
29073
29431
  }
29074
29432
  async function applyScaffoldWrites(plan) {
29075
- const lockPath = join12(plan.root, ".supacloud-generate.lock");
29433
+ const lockPath = join13(plan.root, ".supacloud-generate.lock");
29076
29434
  const lock = await open3(lockPath, "wx").catch((error) => {
29077
29435
  if (fsCode(error) === "EEXIST")
29078
29436
  throw new ScaffoldError("SCAFFOLD_BUSY", "Another generator owns .supacloud-generate.lock; no files written");
@@ -29092,8 +29450,8 @@ async function applyScaffoldWrites(plan) {
29092
29450
  for (const write of plan.writes) {
29093
29451
  const target = scaffoldPath(plan.root, write.path);
29094
29452
  let current = plan.root;
29095
- for (const part of relative6(plan.root, dirname8(target)).split(sep4).filter(Boolean)) {
29096
- current = join12(current, part);
29453
+ for (const part of relative7(plan.root, dirname8(target)).split(sep5).filter(Boolean)) {
29454
+ current = join13(current, part);
29097
29455
  try {
29098
29456
  await mkdir4(current);
29099
29457
  directories.push(current);
@@ -29172,9 +29530,9 @@ async function applyScaffoldWrites(plan) {
29172
29530
  }
29173
29531
 
29174
29532
  // src/shared/tools/configuration-tools.ts
29175
- import { existsSync as existsSync11 } from "node:fs";
29533
+ import { existsSync as existsSync12 } from "node:fs";
29176
29534
  import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
29177
- import { join as join13, resolve as resolve18 } from "node:path";
29535
+ import { join as join14, resolve as resolve19 } from "node:path";
29178
29536
  var onboardToolSchema = {
29179
29537
  root: optional(String2(), "Repository or configuration root (default: current directory)"),
29180
29538
  profile: optional(stringEnum2(["solo", "podman", "pigsty", "cluster"]), "Deployment profile (default: solo)"),
@@ -29205,7 +29563,7 @@ function textResult(text, isError = false) {
29205
29563
  function jsonResult(value, isError = false) {
29206
29564
  return textResult(JSON.stringify(value, null, 2), isError);
29207
29565
  }
29208
- function record5(value) {
29566
+ function record6(value) {
29209
29567
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
29210
29568
  }
29211
29569
  function unquote(value) {
@@ -29228,10 +29586,10 @@ function parseEnvironment(content) {
29228
29586
  return values;
29229
29587
  }
29230
29588
  async function readJsonObject(path) {
29231
- if (!existsSync11(path))
29589
+ if (!existsSync12(path))
29232
29590
  return {};
29233
29591
  const parsed = JSON.parse(await readFile4(path, "utf8"));
29234
- const value = record5(parsed);
29592
+ const value = record6(parsed);
29235
29593
  if (!value)
29236
29594
  throw new Error(`${path} must contain a JSON object`);
29237
29595
  return value;
@@ -29241,28 +29599,28 @@ async function writeJsonObject(path, value) {
29241
29599
  `, { encoding: "utf8", mode: 420 });
29242
29600
  }
29243
29601
  function contextFromConfig(config) {
29244
- const context = record5(config.context);
29602
+ const context = record6(config.context);
29245
29603
  return context ?? {};
29246
29604
  }
29247
29605
  function environmentContext(config, environment) {
29248
29606
  const context = contextFromConfig(config);
29249
- const environments = record5(context.environments);
29250
- const selected = environments ? record5(environments[environment]) : null;
29607
+ const environments = record6(context.environments);
29608
+ const selected = environments ? record6(environments[environment]) : null;
29251
29609
  return selected ?? {};
29252
29610
  }
29253
29611
  async function syncEnvironmentProfile(args, options) {
29254
- const root = resolve18(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
29612
+ const root = resolve19(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
29255
29613
  const environment = typeof args.environment === "string" && args.environment.trim() ? args.environment.trim() : options.activeContext?.environment;
29256
29614
  if (!environment)
29257
29615
  throw new Error("env sync requires --env <name> or SUPACLOUD_ENV");
29258
- const profilePath = join13(root, `.env.supacloud.${environment}`);
29259
- if (!existsSync11(profilePath))
29616
+ const profilePath = join14(root, `.env.supacloud.${environment}`);
29617
+ if (!existsSync12(profilePath))
29260
29618
  throw new Error(`Environment profile not found: ${profilePath}`);
29261
29619
  const values = parseEnvironment(await readFile4(profilePath, "utf8"));
29262
- const configPath = join13(root, "supacloud.json");
29620
+ const configPath = join14(root, "supacloud.json");
29263
29621
  const config = await readJsonObject(configPath);
29264
29622
  const context = contextFromConfig(config);
29265
- const environments = record5(context.environments) ?? {};
29623
+ const environments = record6(context.environments) ?? {};
29266
29624
  const publicValues = Object.fromEntries(Object.entries(values).filter(([name]) => !SECRET_KEY.test(name) && !PLATFORM_KEY.test(name)));
29267
29625
  const secretNames = Object.keys(values).filter((name) => SECRET_KEY.test(name));
29268
29626
  const nextEnvironment = {
@@ -29293,11 +29651,11 @@ async function syncEnvironmentProfile(args, options) {
29293
29651
  async function readSecretGap(root, environment) {
29294
29652
  if (!environment)
29295
29653
  return { environment, required: [], present: [], missing: [] };
29296
- const config = await readJsonObject(join13(root, "supacloud.json"));
29654
+ const config = await readJsonObject(join14(root, "supacloud.json"));
29297
29655
  const metadata = environmentContext(config, environment);
29298
29656
  const required = Array.isArray(metadata.secret_names) ? metadata.secret_names.filter((value) => typeof value === "string" && /^[A-Z_][A-Z0-9_]*$/.test(value)).sort() : [];
29299
- const profilePath = join13(root, `.env.supacloud.${environment}`);
29300
- const values = existsSync11(profilePath) ? parseEnvironment(await readFile4(profilePath, "utf8")) : {};
29657
+ const profilePath = join14(root, `.env.supacloud.${environment}`);
29658
+ const values = existsSync12(profilePath) ? parseEnvironment(await readFile4(profilePath, "utf8")) : {};
29301
29659
  const present = required.filter((name) => values[name] !== undefined && values[name] !== "" && !/^<[^>]+>$/.test(values[name]));
29302
29660
  return { environment, required, present, missing: required.filter((name) => !present.includes(name)) };
29303
29661
  }
@@ -29516,7 +29874,7 @@ async function generateScaffold(args) {
29516
29874
  throw new ScaffoldError("SCAFFOLD_OPTION_INVALID", `--${flag.replaceAll("_", "-")} must be boolean`);
29517
29875
  }
29518
29876
  }
29519
- const root = resolve19(args.root || process.cwd());
29877
+ const root = resolve20(args.root || process.cwd());
29520
29878
  const dir = args.dir ?? "src/features";
29521
29879
  if (dir !== ".")
29522
29880
  scaffoldPath(root, dir);
@@ -29545,7 +29903,7 @@ async function generateScaffold(args) {
29545
29903
  let contractName;
29546
29904
  if (kind === "module" || kind === "resource" || kind === "feature") {
29547
29905
  const name = requireIdentifier(args.name, "name");
29548
- modulePath = join14(dir, name, kind === "feature" ? `${name}.feature.ts` : `${name}.module.ts`).replaceAll("\\", "/");
29906
+ modulePath = join15(dir, name, kind === "feature" ? `${name}.feature.ts` : `${name}.module.ts`).replaceAll("\\", "/");
29549
29907
  moduleSymbol = kind === "feature" ? `${pascalName(name)}Feature` : `${pascalName(name)}Module`;
29550
29908
  if (kind === "module")
29551
29909
  writes.push({ path: modulePath, content: moduleScaffold(name), overwrite: args.force === true });
@@ -29553,18 +29911,18 @@ async function generateScaffold(args) {
29553
29911
  for (const [file, content] of Object.entries(kind === "feature" ? featureScaffold(name, pascalName(name), {
29554
29912
  ...featureGovernance,
29555
29913
  databaseImportPath: (() => {
29556
- const source = relative7(join14(root, dir, name), join14(root, featureGovernance.database.source)).replaceAll("\\", "/").replace(/\.(?:[cm]?tsx?|mts|cts)$/, "");
29914
+ const source = relative8(join15(root, dir, name), join15(root, featureGovernance.database.source)).replaceAll("\\", "/").replace(/\.(?:[cm]?tsx?|mts|cts)$/, "");
29557
29915
  return source.startsWith(".") ? source : `./${source}`;
29558
29916
  })()
29559
29917
  }) : resourceScaffold(name, pascalName(name)))) {
29560
- writes.push({ path: join14(dir, name, file).replaceAll("\\", "/"), content });
29918
+ writes.push({ path: join15(dir, name, file).replaceAll("\\", "/"), content });
29561
29919
  }
29562
29920
  } else {
29563
29921
  const moduleName = requireIdentifier(args.module, "module");
29564
29922
  const name = kind === "controller" ? moduleName : requireIdentifier(args.name, "name");
29565
29923
  const subdir = kind === "command" ? "commands" : kind === "query" ? "queries" : kind === "job" ? "jobs" : kind === "contract" ? "contracts" : "";
29566
- const path = join14(dir, moduleName, subdir, `${name}.${kind}.ts`).replaceAll("\\", "/");
29567
- if (kind === "controller" && existsSync12(scaffoldPath(root, path))) {
29924
+ const path = join15(dir, moduleName, subdir, `${name}.${kind}.ts`).replaceAll("\\", "/");
29925
+ if (kind === "controller" && existsSync13(scaffoldPath(root, path))) {
29568
29926
  throw new ScaffoldError("SCAFFOLD_EXISTS", `Controller already exists: ${path}(请手工合并路由到现有 controller)`);
29569
29927
  }
29570
29928
  const content = kind === "command" ? commandScaffold(moduleName, name) : kind === "query" ? queryScaffold(moduleName, name) : kind === "job" ? jobScaffold(moduleName, name) : kind === "contract" ? contractScaffold(moduleName, name) : controllerScaffold(moduleName);
@@ -29582,7 +29940,7 @@ async function generateScaffold(args) {
29582
29940
  if (new RegExp(`\\b${moduleSymbol}\\b`).test(original)) {
29583
29941
  throw new ScaffoldError("SCAFFOLD_REGISTRATION_CONFLICT", `Registration target already references ${moduleSymbol}; review the import manually`);
29584
29942
  }
29585
- let importPath = relative7(dirname9(target), resolve19(root, modulePath)).replaceAll("\\", "/").replace(/\.ts$/, "");
29943
+ let importPath = relative8(dirname9(target), resolve20(root, modulePath)).replaceAll("\\", "/").replace(/\.ts$/, "");
29586
29944
  if (!importPath.startsWith("."))
29587
29945
  importPath = `./${importPath}`;
29588
29946
  const edit = await applyDiagnosticFix({
@@ -29613,7 +29971,7 @@ async function generateScaffold(args) {
29613
29971
  written: !args.dry_run,
29614
29972
  changes
29615
29973
  }, null, 2));
29616
- const lines = changes.map((change) => `${args.dry_run ? "PREVIEW" : "✅"} ${change.action}: ${join14(plan.root, change.path)}`);
29974
+ const lines = changes.map((change) => `${args.dry_run ? "PREVIEW" : "✅"} ${change.action}: ${join15(plan.root, change.path)}`);
29617
29975
  if (args.dry_run)
29618
29976
  lines.push("No files written. Omit --dry-run to apply this generation.");
29619
29977
  if (kind === "resource")
@@ -29651,17 +30009,17 @@ function parseInclude(include) {
29651
30009
  return patterns && patterns.length > 0 ? patterns : undefined;
29652
30010
  }
29653
30011
  function sourceRoot(args, root, configured) {
29654
- const hasConfig = ["ts", "mts", "js", "mjs"].some((extension) => existsSync12(join14(root, `supacloud.config.${extension}`)));
30012
+ const hasConfig = ["ts", "mts", "js", "mjs"].some((extension) => existsSync13(join15(root, `supacloud.config.${extension}`)));
29655
30013
  return args.root && !hasConfig ? "." : configured;
29656
30014
  }
29657
30015
  async function projectCompileConfig(args) {
29658
- const root = resolve19(args.root || process.cwd());
29659
- const configFile = ["ts", "mts", "js", "mjs"].map((extension) => join14(root, `supacloud.config.${extension}`)).find((candidate) => existsSync12(candidate)) ?? null;
30016
+ const root = resolve20(args.root || process.cwd());
30017
+ const configFile = ["ts", "mts", "js", "mjs"].map((extension) => join15(root, `supacloud.config.${extension}`)).find((candidate) => existsSync13(candidate)) ?? null;
29660
30018
  const loadedConfig = await loadSupacloudConfig(root);
29661
30019
  const defaults = resolveSupacloudConfig(loadedConfig, root);
29662
30020
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
29663
30021
  const include = parseInclude(args.include) ?? loadedConfig.include;
29664
- const outDir = args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir;
30022
+ const outDir = args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir;
29665
30023
  const compileOptions = compileOptionsFromConfig({
29666
30024
  ...loadedConfig,
29667
30025
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
@@ -29673,8 +30031,8 @@ async function projectCompileConfig(args) {
29673
30031
  return { root, sourceDir: compileOptions.rootDir, configFile, outDir, result };
29674
30032
  }
29675
30033
  async function readAllowedDependencies(root) {
29676
- const path = join14(root, "package.json");
29677
- if (!existsSync12(path)) {
30034
+ const path = join15(root, "package.json");
30035
+ if (!existsSync13(path)) {
29678
30036
  return { dependencies: [], devDependencies: [], optionalDependencies: [], peerDependencies: [] };
29679
30037
  }
29680
30038
  try {
@@ -29712,7 +30070,7 @@ async function runContext(args) {
29712
30070
  const subject = args.target?.trim();
29713
30071
  if (subject) {
29714
30072
  const pack = createContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject);
29715
- const execution = args.events === undefined ? undefined : createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject, await readExecutionMetadata(resolve19(root, args.events)), args.request_id);
30073
+ const execution = args.events === undefined ? undefined : createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject, await readExecutionMetadata(resolve20(root, args.events)), args.request_id);
29716
30074
  const verification = await createVerificationPlan(root, result.graph, pack.subject, sourceDir);
29717
30075
  const repairs = createDiagnosticRepairPlan(pack.diagnostics);
29718
30076
  const workflow = {
@@ -29854,7 +30212,7 @@ async function findUnwiredContracts(rootDir) {
29854
30212
  for (const entry of entries) {
29855
30213
  if (skip.has(entry.name))
29856
30214
  continue;
29857
- const path = join14(directory, entry.name);
30215
+ const path = join15(directory, entry.name);
29858
30216
  if (entry.isDirectory())
29859
30217
  await walk(path);
29860
30218
  else if (entry.isFile() && entry.name.endsWith(".ts"))
@@ -29872,10 +30230,10 @@ async function findUnwiredContracts(rootDir) {
29872
30230
  const symbols = [...source.matchAll(/export\s+const\s+([A-Za-z_$][A-Za-z0-9_$]*)/g)].map((match) => match[1]);
29873
30231
  if (symbols.length === 0)
29874
30232
  continue;
29875
- const moduleName = basename7(contract).replace(/\.ts$/, "");
30233
+ const moduleName = basename8(contract).replace(/\.ts$/, "");
29876
30234
  const wired = otherSources.some((text) => text.includes(moduleName) || symbols.some((symbol) => new RegExp(`\\b${symbol}\\b`).test(text)));
29877
30235
  if (!wired)
29878
- unwired.push({ file: relative7(rootDir, contract), symbols });
30236
+ unwired.push({ file: relative8(rootDir, contract), symbols });
29879
30237
  }
29880
30238
  return unwired;
29881
30239
  }
@@ -29957,7 +30315,7 @@ async function runDoctor(args) {
29957
30315
  `), doctor.errors > 0);
29958
30316
  }
29959
30317
  async function runFix(args) {
29960
- const root = resolve19(args.root || process.cwd());
30318
+ const root = resolve20(args.root || process.cwd());
29961
30319
  const fixPath = args.fix?.trim();
29962
30320
  const doctorPath = args.from_doctor?.trim();
29963
30321
  if (fixPath && doctorPath)
@@ -29972,7 +30330,7 @@ async function runFix(args) {
29972
30330
  if (!Number.isSafeInteger(rawIndex) || rawIndex === undefined || rawIndex < 0) {
29973
30331
  throw new Error("app fix --from-doctor requires a non-negative --fix-index <n>");
29974
30332
  }
29975
- const doctor = JSON.parse(await readFile5(resolve19(root, doctorPath), "utf8"));
30333
+ const doctor = JSON.parse(await readFile5(resolve20(root, doctorPath), "utf8"));
29976
30334
  if (!doctor || typeof doctor !== "object" || !Array.isArray(doctor.fixPlan)) {
29977
30335
  throw new Error("Invalid doctor output: expected a fixPlan array");
29978
30336
  }
@@ -29991,7 +30349,7 @@ async function runFix(args) {
29991
30349
  parsed = repairEntry.fix;
29992
30350
  source = "doctor";
29993
30351
  } else {
29994
- parsed = JSON.parse(await readFile5(resolve19(root, fixPath), "utf8"));
30352
+ parsed = JSON.parse(await readFile5(resolve20(root, fixPath), "utf8"));
29995
30353
  }
29996
30354
  const write = args.write === true;
29997
30355
  const applied = await applyDiagnosticFix(parsed, { rootDir: root, dryRun: !write });
@@ -30040,7 +30398,7 @@ function devDatabase(profile, explicit) {
30040
30398
  }
30041
30399
  function readManifestModules(outDir) {
30042
30400
  try {
30043
- const parsed = JSON.parse(readFileSync9(join14(outDir, "app.manifest.json"), "utf8"));
30401
+ const parsed = JSON.parse(readFileSync10(join15(outDir, "app.manifest.json"), "utf8"));
30044
30402
  return Array.isArray(parsed.modules) ? parsed.modules.map((module) => module.name) : [];
30045
30403
  } catch {
30046
30404
  return [];
@@ -30083,12 +30441,12 @@ async function runAppDev(args, options) {
30083
30441
  throw new ScaffoldError("SCAFFOLD_OPTION_INVALID", "app dev --profile must be fast or integration");
30084
30442
  }
30085
30443
  const database = devDatabase(profile, args.database_url);
30086
- const root = resolve19(args.root || process.cwd());
30444
+ const root = resolve20(args.root || process.cwd());
30087
30445
  const loadedConfig = await loadSupacloudConfig(root);
30088
30446
  const defaults = resolveSupacloudConfig(loadedConfig, root);
30089
30447
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
30090
30448
  const include = parseInclude(args.include) ?? loadedConfig.include;
30091
- const outDir = args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir;
30449
+ const outDir = args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir;
30092
30450
  const watch = args.once !== true && args.watch !== false;
30093
30451
  const compileOptions = compileOptionsFromConfig({
30094
30452
  ...loadedConfig,
@@ -30174,7 +30532,7 @@ async function runAppDev(args, options) {
30174
30532
  return report(lastEvent, "stopped");
30175
30533
  }
30176
30534
  async function runCompile(args) {
30177
- const root = resolve19(args.root || process.cwd());
30535
+ const root = resolve20(args.root || process.cwd());
30178
30536
  const loadedConfig = await loadSupacloudConfig(root);
30179
30537
  const defaults = resolveSupacloudConfig(loadedConfig, root);
30180
30538
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
@@ -30183,7 +30541,7 @@ async function runCompile(args) {
30183
30541
  ...compileOptionsFromConfig({
30184
30542
  ...loadedConfig,
30185
30543
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
30186
- outDir: args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir,
30544
+ outDir: args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir,
30187
30545
  ...include === undefined ? {} : { include },
30188
30546
  strict: args.strict ?? loadedConfig.strict ?? false
30189
30547
  }, root),
@@ -30207,7 +30565,7 @@ async function runCompile(args) {
30207
30565
  return textResult2(text, hasError);
30208
30566
  }
30209
30567
  async function runCheck(args) {
30210
- const root = resolve19(args.root || process.cwd());
30568
+ const root = resolve20(args.root || process.cwd());
30211
30569
  const database = checkAppDatabaseSources(root);
30212
30570
  const loadedConfig = await loadSupacloudConfig(root);
30213
30571
  const defaults = resolveSupacloudConfig(loadedConfig, root);
@@ -30216,7 +30574,7 @@ async function runCheck(args) {
30216
30574
  const config = compileOptionsFromConfig({
30217
30575
  ...loadedConfig,
30218
30576
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
30219
- outDir: args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir,
30577
+ outDir: args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir,
30220
30578
  ...include === undefined ? {} : { include },
30221
30579
  strict: args.strict ?? loadedConfig.strict ?? false
30222
30580
  }, root);
@@ -30249,9 +30607,9 @@ async function runCheck(args) {
30249
30607
  }
30250
30608
  async function readManifest(root, args) {
30251
30609
  const config = await loadSupacloudConfig(root);
30252
- const outDir = args.out_dir ? resolve19(root, args.out_dir) : resolveSupacloudConfig(config, root).outDir;
30253
- const manifestPath = join14(outDir, "app.manifest.json");
30254
- if (!existsSync12(manifestPath)) {
30610
+ const outDir = args.out_dir ? resolve20(root, args.out_dir) : resolveSupacloudConfig(config, root).outDir;
30611
+ const manifestPath = join15(outDir, "app.manifest.json");
30612
+ if (!existsSync13(manifestPath)) {
30255
30613
  throw new Error(`Manifest not found: ${manifestPath}(先运行 app compile 生成)`);
30256
30614
  }
30257
30615
  const parsed = JSON.parse(await readFile5(manifestPath, "utf8"));
@@ -30294,7 +30652,7 @@ function formatGraphText(manifest) {
30294
30652
  `);
30295
30653
  }
30296
30654
  async function runGraph(args) {
30297
- const root = resolve19(args.root || process.cwd());
30655
+ const root = resolve20(args.root || process.cwd());
30298
30656
  const manifest = await readManifest(root, args);
30299
30657
  if (args.format === "json")
30300
30658
  return textResult2(JSON.stringify(manifest, null, 2));
@@ -30362,7 +30720,7 @@ async function runExplain(args) {
30362
30720
  const target = args.target?.trim();
30363
30721
  if (!target)
30364
30722
  throw new Error("app explain requires --target(provider 类名 / token 名 / command 名 / job 名)");
30365
- const root = resolve19(args.root || process.cwd());
30723
+ const root = resolve20(args.root || process.cwd());
30366
30724
  const manifest = await readManifest(root, args);
30367
30725
  for (const module of manifest.modules) {
30368
30726
  const job = module.jobs?.find((entry) => entry.name === target || entry.className === target);
@@ -30437,16 +30795,16 @@ async function runExplain(args) {
30437
30795
  return textResult2(`未找到对象: ${target}`, true);
30438
30796
  }
30439
30797
  async function runExportTools(args) {
30440
- const root = resolve19(args.root || process.cwd());
30798
+ const root = resolve20(args.root || process.cwd());
30441
30799
  const manifest = await readManifest(root, { ...args, out_dir: undefined });
30442
30800
  const definitions = buildToolDefinitions(manifest);
30443
- const outDir = resolve19(args.out_dir || join14(root, "generated"));
30801
+ const outDir = resolve20(args.out_dir || join15(root, "generated"));
30444
30802
  if (args.format === "json") {
30445
30803
  return textResult2(JSON.stringify(definitions, null, 2));
30446
30804
  }
30447
30805
  await mkdir6(outDir, { recursive: true });
30448
- const openaiPath = join14(outDir, "tool-definitions.openai.json");
30449
- const mcpPath = join14(outDir, "tool-definitions.mcp.json");
30806
+ const openaiPath = join15(outDir, "tool-definitions.openai.json");
30807
+ const mcpPath = join15(outDir, "tool-definitions.mcp.json");
30450
30808
  await writeFile5(openaiPath, JSON.stringify(definitions.openai, null, 2), "utf8");
30451
30809
  await writeFile5(mcpPath, JSON.stringify(definitions.mcp, null, 2), "utf8");
30452
30810
  const summary = [
@@ -30461,7 +30819,7 @@ async function runExportTools(args) {
30461
30819
  return textResult2(summary);
30462
30820
  }
30463
30821
  async function runDelivery(args) {
30464
- const root = resolve19(args.root || process.cwd());
30822
+ const root = resolve20(args.root || process.cwd());
30465
30823
  if (args.action === "build") {
30466
30824
  const database = checkAppDatabaseSources(root);
30467
30825
  if (database && !database.ok) {
@@ -30471,7 +30829,7 @@ async function runDelivery(args) {
30471
30829
  const loaded = await loadSupacloudConfig(root);
30472
30830
  const options = compileOptionsFromConfig({
30473
30831
  ...loaded,
30474
- ...args.out_dir === undefined ? {} : { outDir: resolve19(root, args.out_dir) },
30832
+ ...args.out_dir === undefined ? {} : { outDir: resolve20(root, args.out_dir) },
30475
30833
  ...args.include === undefined ? {} : { include: parseInclude(args.include) },
30476
30834
  ...args.strict === undefined ? {} : { strict: args.strict }
30477
30835
  }, root);
@@ -30548,7 +30906,7 @@ async function runAppRelease(request, options, delegate) {
30548
30906
  if (request.activation_id !== undefined || request.expected_activation_id !== undefined) {
30549
30907
  throw new Error("app release generates one activation identity; use app deploy for an exact retry");
30550
30908
  }
30551
- const root = resolve19(request.root || process.cwd());
30909
+ const root = resolve20(request.root || process.cwd());
30552
30910
  const completed = {};
30553
30911
  let manifestPath;
30554
30912
  let buildReceipt;
@@ -30556,7 +30914,7 @@ async function runAppRelease(request, options, delegate) {
30556
30914
  if (request.manifest_path === undefined) {
30557
30915
  throw new Error("app release --skip_build requires --manifest_path");
30558
30916
  }
30559
- manifestPath = resolve19(root, request.manifest_path);
30917
+ manifestPath = resolve20(root, request.manifest_path);
30560
30918
  completed.build = { skipped: true, manifest_path: manifestPath };
30561
30919
  } else {
30562
30920
  const built = await runDelivery({ ...request, action: "build", root, format: "json" });
@@ -30566,7 +30924,7 @@ async function runAppRelease(request, options, delegate) {
30566
30924
  }
30567
30925
  const loaded = await loadSupacloudConfig(root);
30568
30926
  const resolved = resolveSupacloudConfig(loaded, root);
30569
- manifestPath = join14(resolved.outDir, "delivery", "delivery.manifest.json");
30927
+ manifestPath = join15(resolved.outDir, "delivery", "delivery.manifest.json");
30570
30928
  completed.build = {
30571
30929
  ok: true,
30572
30930
  manifest_path: manifestPath,
@@ -30593,7 +30951,7 @@ async function runAppRelease(request, options, delegate) {
30593
30951
  let configurationWrite;
30594
30952
  const activationId = crypto.randomUUID();
30595
30953
  if (request.configuration_path !== undefined) {
30596
- const configurationPath = resolve19(root, request.configuration_path);
30954
+ const configurationPath = resolve20(root, request.configuration_path);
30597
30955
  try {
30598
30956
  configurationWrite = parseApplicationConfigurationWrite(await Bun.file(configurationPath).json());
30599
30957
  configurationId = configurationWrite.configuration_id;
@@ -31129,8 +31487,8 @@ function registerAppTools(server, options = {}) {
31129
31487
  }
31130
31488
 
31131
31489
  // src/shared/tools/db-governance-tools.ts
31132
- import { existsSync as existsSync14 } from "node:fs";
31133
- import { join as join17, resolve as resolve22 } from "node:path";
31490
+ import { existsSync as existsSync15 } from "node:fs";
31491
+ import { join as join18, resolve as resolve23 } from "node:path";
31134
31492
  import {
31135
31493
  buildDatabaseManifest,
31136
31494
  explainObject,
@@ -31143,8 +31501,8 @@ import { databaseSources } from "@supacloud/db/source-contracts";
31143
31501
  // src/shared/tools/db-workflow.ts
31144
31502
  import { createHash as createHash9 } from "node:crypto";
31145
31503
  import { lstat as lstat4, mkdir as mkdir7, mkdtemp, readFile as readFile6, readdir as readdir6, rename as rename3, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
31146
- import { tmpdir as tmpdir2 } from "node:os";
31147
- import { dirname as dirname11, isAbsolute as isAbsolute7, join as join16, relative as relative8, resolve as resolve21 } from "node:path";
31504
+ import { tmpdir as tmpdir3 } from "node:os";
31505
+ import { dirname as dirname11, isAbsolute as isAbsolute7, join as join17, relative as relative9, resolve as resolve22 } from "node:path";
31148
31506
  import {
31149
31507
  assertApplicationRoleRestricted,
31150
31508
  readDatabaseRole,
@@ -31155,8 +31513,8 @@ import {
31155
31513
  import { parseDatabaseSourcesConfig } from "@supacloud/db/source-contracts";
31156
31514
 
31157
31515
  // src/shared/tools/supabase-cli-tools.ts
31158
- import { chmodSync as chmodSync2, existsSync as existsSync13, mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync3 } from "node:fs";
31159
- import { dirname as dirname10, isAbsolute as isAbsolute6, join as join15, resolve as resolve20 } from "node:path";
31516
+ import { chmodSync as chmodSync2, existsSync as existsSync14, mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync3 } from "node:fs";
31517
+ import { dirname as dirname10, isAbsolute as isAbsolute6, join as join16, resolve as resolve21 } from "node:path";
31160
31518
  var SENSITIVE_ENV_KEY2 = /(?:^|_)(?:PASSWORD|PASS|SECRET|TOKEN|KEY|CREDENTIALS?|AUTHORIZATION|AUTH|SESSION|COOKIE|BEARER|DB_URI|DB_URL|DSN|DATABASE_URL|DATABASE_URI|CONNECTION_STRING|CONNECTION_URI)(?:_|$)/i;
31161
31519
  var VALID_VERSION2 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
31162
31520
  var VALID_MIGRATION_NAME2 = /^[A-Za-z0-9][A-Za-z0-9_-]{0,100}$/;
@@ -31216,12 +31574,12 @@ function schemaArguments2(schema) {
31216
31574
  function workdirArguments2(workdir) {
31217
31575
  if (!workdir)
31218
31576
  throw new Error("A workdir is required");
31219
- return ["--workdir", resolve20(workdir)];
31577
+ return ["--workdir", resolve21(workdir)];
31220
31578
  }
31221
31579
  function resolveOutputPath2(workdir, file, label) {
31222
31580
  if (!file || /[\r\n\0]/.test(file))
31223
31581
  throw new Error(`${label} file is required`);
31224
- return isAbsolute6(file) ? resolve20(file) : resolve20(workdir, file);
31582
+ return isAbsolute6(file) ? resolve21(file) : resolve21(workdir, file);
31225
31583
  }
31226
31584
  function databaseTargetArguments2(databaseUrl) {
31227
31585
  return databaseUrl ? ["--db-url", requirePostgresUrl2(databaseUrl)] : ["--local"];
@@ -31396,7 +31754,7 @@ function actionArguments2(request, workdir) {
31396
31754
  function buildOfficialSupabaseArgs2(request) {
31397
31755
  if (request.action === "version")
31398
31756
  return ["--version"];
31399
- const workdir = request.workdir ? resolve20(request.workdir) : undefined;
31757
+ const workdir = request.workdir ? resolve21(request.workdir) : undefined;
31400
31758
  if (!workdir)
31401
31759
  throw new Error("A workdir is required");
31402
31760
  return [...actionArguments2(request, workdir), ...workdirArguments2(workdir)];
@@ -31438,8 +31796,8 @@ function resolveOfficialSupabaseCommand2(workdir, environment = process.env) {
31438
31796
  }
31439
31797
  return ["npx", "--yes", `supabase@${version}`];
31440
31798
  }
31441
- const localPackageEntry = join15(resolve20(workdir), "node_modules", "supabase", "dist", "supabase.js");
31442
- if (existsSync13(localPackageEntry))
31799
+ const localPackageEntry = join16(resolve21(workdir), "node_modules", "supabase", "dist", "supabase.js");
31800
+ if (existsSync14(localPackageEntry))
31443
31801
  return [process.execPath, localPackageEntry];
31444
31802
  return ["supabase"];
31445
31803
  }
@@ -31451,13 +31809,13 @@ var result = (value, isError = false) => ({
31451
31809
  content: [{ type: "text", text: JSON.stringify(value, null, 2) }]
31452
31810
  });
31453
31811
  var schemas = (value) => value?.split(",").map((entry) => entry.trim()).filter(Boolean) ?? ["public"];
31454
- async function projectPath2(root, path) {
31812
+ async function projectPath3(root, path) {
31455
31813
  if (!path || isAbsolute7(path) || path.includes("\\") || path.split("/").some((part) => !part || part === "." || part === "..")) {
31456
31814
  throw new Error("Use a normalized project-relative path");
31457
31815
  }
31458
31816
  let current = root;
31459
31817
  for (const part of path.split("/")) {
31460
- current = join16(current, part);
31818
+ current = join17(current, part);
31461
31819
  try {
31462
31820
  if ((await lstat4(current)).isSymbolicLink())
31463
31821
  throw new Error("Symlink workflow paths are forbidden");
@@ -31479,8 +31837,8 @@ async function exists2(path) {
31479
31837
  }
31480
31838
  }
31481
31839
  async function boundary(root) {
31482
- const config = join16(root, "database.sources.json");
31483
- return await exists2(config) ? parseDatabaseSourcesConfig(JSON.parse(await readFile6(await projectPath2(root, "database.sources.json"), "utf8"))) : undefined;
31840
+ const config = join17(root, "database.sources.json");
31841
+ return await exists2(config) ? parseDatabaseSourcesConfig(JSON.parse(await readFile6(await projectPath3(root, "database.sources.json"), "utf8"))) : undefined;
31484
31842
  }
31485
31843
  var overlaps = (a, b) => a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
31486
31844
  async function candidatePath(root, path) {
@@ -31496,7 +31854,7 @@ async function candidatePath(root, path) {
31496
31854
  ];
31497
31855
  if (protectedPaths.some((source) => overlaps(source, path)))
31498
31856
  throw new Error("Candidate output overlaps maintained sources or migrations");
31499
- return projectPath2(root, path);
31857
+ return projectPath3(root, path);
31500
31858
  }
31501
31859
  function connect(url) {
31502
31860
  const client = new Bun.SQL(url);
@@ -31573,9 +31931,9 @@ async function runOfficial(root, workdir, args, environment, options) {
31573
31931
  async function initializeCandidate(stage, majorVersion = 18) {
31574
31932
  if (![15, 16, 17, 18].includes(majorVersion))
31575
31933
  throw new Error("Select a supported PostgreSQL major version (15-18)");
31576
- await mkdir7(join16(stage, "supabase/migrations"), { recursive: true });
31577
- await mkdir7(join16(stage, "supabase/schemas"), { recursive: true });
31578
- await writeFile6(join16(stage, "supabase/config.toml"), [
31934
+ await mkdir7(join17(stage, "supabase/migrations"), { recursive: true });
31935
+ await mkdir7(join17(stage, "supabase/schemas"), { recursive: true });
31936
+ await writeFile6(join17(stage, "supabase/config.toml"), [
31579
31937
  `project_id = "supacloud-candidate-${hash4(stage).slice(0, 12)}"`,
31580
31938
  "[db]",
31581
31939
  `major_version = ${majorVersion}`,
@@ -31586,16 +31944,16 @@ async function initializeCandidate(stage, majorVersion = 18) {
31586
31944
  `));
31587
31945
  }
31588
31946
  async function copySqlSources(root, source, destination) {
31589
- const path = await projectPath2(root, source);
31947
+ const path = await projectPath3(root, source);
31590
31948
  let count = 0;
31591
31949
  await mkdir7(destination, { recursive: true });
31592
31950
  for (const name of (await readdir6(path)).sort()) {
31593
- const file = await projectPath2(root, `${source}/${name}`);
31951
+ const file = await projectPath3(root, `${source}/${name}`);
31594
31952
  const state = await lstat4(file);
31595
31953
  if (state.isDirectory())
31596
- count += await copySqlSources(root, `${source}/${name}`, join16(destination, name));
31954
+ count += await copySqlSources(root, `${source}/${name}`, join17(destination, name));
31597
31955
  else if (state.isFile() && name.endsWith(".sql")) {
31598
- await writeFile6(join16(destination, name), await readFile6(file));
31956
+ await writeFile6(join17(destination, name), await readFile6(file));
31599
31957
  count++;
31600
31958
  }
31601
31959
  }
@@ -31610,7 +31968,7 @@ async function reverse(args, root, options) {
31610
31968
  throw new Error("Select valid PostgreSQL schemas");
31611
31969
  }
31612
31970
  await mkdir7(dirname11(out), { recursive: true });
31613
- const stage = await mkdtemp(join16(dirname11(out), ".reverse-"));
31971
+ const stage = await mkdtemp(join17(dirname11(out), ".reverse-"));
31614
31972
  try {
31615
31973
  const snapshot = await withDatabase(args, options, async (executor, url) => {
31616
31974
  const snapshot = await reverseDatabase(executor, selectedSchemas);
@@ -31626,15 +31984,15 @@ async function reverse(args, root, options) {
31626
31984
  }, options.environment ?? process.env, options);
31627
31985
  return snapshot;
31628
31986
  });
31629
- const generated = await readdir6(join16(stage, "supabase/schemas"), { recursive: true });
31987
+ const generated = await readdir6(join17(stage, "supabase/schemas"), { recursive: true });
31630
31988
  if (!generated.some((file) => file.endsWith(".sql")))
31631
31989
  throw new Error("Official reverse did not produce declarative SQL");
31632
- await writeFile6(join16(stage, "catalog.json"), renderReverseSnapshot(snapshot));
31990
+ await writeFile6(join17(stage, "catalog.json"), renderReverseSnapshot(snapshot));
31633
31991
  await rename3(stage, out);
31634
31992
  return result({
31635
31993
  ok: true,
31636
31994
  scope: "database-reverse-candidate",
31637
- out: relative8(root, out),
31995
+ out: relative9(root, out),
31638
31996
  databaseWritten: false,
31639
31997
  sourceOverwritten: false,
31640
31998
  review: [...snapshot.review, "Declarative generate and catalog use separate snapshots. Freeze DDL and verify parity before adopting both."]
@@ -31645,7 +32003,7 @@ async function reverse(args, root, options) {
31645
32003
  }
31646
32004
  async function diff2(args, root, options) {
31647
32005
  const sourcePath = args.schema_dir ?? "supabase/schemas";
31648
- const source = await projectPath2(root, sourcePath);
32006
+ const source = await projectPath3(root, sourcePath);
31649
32007
  const out = await candidatePath(root, args.out ?? "output/database-audit/diff");
31650
32008
  if (overlaps(source, out))
31651
32009
  throw new Error("Candidate output overlaps the schema");
@@ -31655,13 +32013,13 @@ async function diff2(args, root, options) {
31655
32013
  if (overlaps(input.dir, out))
31656
32014
  throw new Error("Candidate output overlaps reviewed migration history");
31657
32015
  await mkdir7(dirname11(out), { recursive: true });
31658
- const stage = await mkdtemp(join16(dirname11(out), ".diff-"));
32016
+ const stage = await mkdtemp(join17(dirname11(out), ".diff-"));
31659
32017
  try {
31660
32018
  await initializeCandidate(stage, args.db_major_version);
31661
- if (!await copySqlSources(root, sourcePath, join16(stage, "supabase/schemas")))
32019
+ if (!await copySqlSources(root, sourcePath, join17(stage, "supabase/schemas")))
31662
32020
  throw new Error("No declarative SQL sources");
31663
32021
  for (const { file, text } of input.files)
31664
- await writeFile6(join16(stage, "supabase/migrations", file), text);
32022
+ await writeFile6(join17(stage, "supabase/migrations", file), text);
31665
32023
  await runOfficial(root, stage, {
31666
32024
  action: "db_schema_declarative_sync",
31667
32025
  apply: false,
@@ -31671,15 +32029,15 @@ async function diff2(args, root, options) {
31671
32029
  }, options.environment ?? process.env, options);
31672
32030
  const history = new Map(input.files.map((file) => [file.file, file.text]));
31673
32031
  for (const [file, text] of history) {
31674
- if (await readFile6(join16(stage, "supabase/migrations", file), "utf8") !== text) {
32032
+ if (await readFile6(join17(stage, "supabase/migrations", file), "utf8") !== text) {
31675
32033
  throw new Error("Official diff changed reviewed migration history");
31676
32034
  }
31677
32035
  }
31678
- const names = (await readdir6(join16(stage, "supabase/migrations"))).filter((file) => file.endsWith(".sql") && !history.has(file));
31679
- const candidates = join16(stage, "candidates");
32036
+ const names = (await readdir6(join17(stage, "supabase/migrations"))).filter((file) => file.endsWith(".sql") && !history.has(file));
32037
+ const candidates = join17(stage, "candidates");
31680
32038
  await mkdir7(candidates);
31681
32039
  for (const file of names)
31682
- await writeFile6(join16(candidates, file), await readFile6(join16(stage, "supabase/migrations", file)));
32040
+ await writeFile6(join17(candidates, file), await readFile6(join17(stage, "supabase/migrations", file)));
31683
32041
  await rename3(candidates, out);
31684
32042
  } finally {
31685
32043
  await rm2(stage, { force: true, recursive: true });
@@ -31687,7 +32045,7 @@ async function diff2(args, root, options) {
31687
32045
  return result({
31688
32046
  ok: true,
31689
32047
  scope: "database-migration-candidate",
31690
- out: relative8(root, out),
32048
+ out: relative9(root, out),
31691
32049
  databaseWritten: false,
31692
32050
  review: [
31693
32051
  "Declarative sync compares maintained SQL with replayed migration history, not the live database.",
@@ -31697,13 +32055,13 @@ async function diff2(args, root, options) {
31697
32055
  });
31698
32056
  }
31699
32057
  async function migrations(root, path) {
31700
- const dir = await projectPath2(root, path);
32058
+ const dir = await projectPath3(root, path);
31701
32059
  const names = (await readdir6(dir)).filter((name) => name.endsWith(".sql")).sort();
31702
32060
  if (!names.length)
31703
32061
  throw new Error("No forward migration files");
31704
32062
  const files = [];
31705
32063
  for (const file of names) {
31706
- const text = await readFile6(await projectPath2(root, `${path}/${file}`), "utf8");
32064
+ const text = await readFile6(await projectPath3(root, `${path}/${file}`), "utf8");
31707
32065
  files.push({ file, text, sha256: hash4(text) });
31708
32066
  }
31709
32067
  return { dir, files };
@@ -31717,10 +32075,10 @@ async function migrationAction(args, root, options) {
31717
32075
  throw new Error("Select a Management API and project ref");
31718
32076
  const path = args.dir ?? (await boundary(root))?.migrations ?? "supabase/migrations";
31719
32077
  const input = await migrations(root, path);
31720
- const stage = await mkdtemp(join16(tmpdir2(), "supacloud-reviewed-migrations-"));
32078
+ const stage = await mkdtemp(join17(tmpdir3(), "supacloud-reviewed-migrations-"));
31721
32079
  try {
31722
32080
  for (const { file, text } of input.files)
31723
- await writeFile6(join16(stage, file), text);
32081
+ await writeFile6(join17(stage, file), text);
31724
32082
  const preview = await run({ action: "push_migrations", ref, dir: stage, dry_run: true, strict: true });
31725
32083
  const dryRun = {
31726
32084
  isError: preview.isError === true,
@@ -31747,7 +32105,7 @@ async function migrationAction(args, root, options) {
31747
32105
  }
31748
32106
  }
31749
32107
  async function runDbWorkflow(args, projectRoot, options = {}) {
31750
- const root = resolve21(projectRoot);
32108
+ const root = resolve22(projectRoot);
31751
32109
  if ((await lstat4(root)).isSymbolicLink())
31752
32110
  throw new Error("Workflow root must not be a symlink");
31753
32111
  switch (args.action) {
@@ -31808,8 +32166,8 @@ function normalizeModule(candidate, sourcePath) {
31808
32166
  };
31809
32167
  }
31810
32168
  async function loadDatabaseModules(root, moduleFile) {
31811
- const filePath = moduleFile ? resolve22(root, moduleFile) : join17(root, "db", "modules.ts");
31812
- if (!existsSync14(filePath)) {
32169
+ const filePath = moduleFile ? resolve23(root, moduleFile) : join18(root, "db", "modules.ts");
32170
+ if (!existsSync15(filePath)) {
31813
32171
  throw new Error(moduleFile ? `Module file not found: ${filePath}` : `Module file not found: ${filePath}(用 --module_file 指定一个导出 defineDatabaseModule(...) 的文件)`);
31814
32172
  }
31815
32173
  let imported;
@@ -31898,7 +32256,7 @@ function buildDatabaseAiContext(modules, root, moduleName, target) {
31898
32256
  const objects = target ? allObjects.filter((object) => objectMatchesTarget(object, target)) : allObjects;
31899
32257
  if (target && objects.length === 0)
31900
32258
  throw new Error(`未找到数据库对象: ${target}`);
31901
- const sqlFirst = !existsSync14(join17(root, "zenstack/schema.zmodel")) && existsSync14(join17(root, "supabase/schemas"));
32259
+ const sqlFirst = !existsSync15(join18(root, "zenstack/schema.zmodel")) && existsSync15(join18(root, "supabase/schemas"));
31902
32260
  return {
31903
32261
  version: 1,
31904
32262
  scope: "database-ai-context",
@@ -31945,7 +32303,7 @@ async function collectLintIssues(args, root) {
31945
32303
  const issues = [];
31946
32304
  for (const module of selected) {
31947
32305
  const readSqlFile = async (path) => {
31948
- const absolute = resolve22(root, path);
32306
+ const absolute = resolve23(root, path);
31949
32307
  try {
31950
32308
  return await Bun.file(absolute).text();
31951
32309
  } catch (error) {
@@ -31969,7 +32327,7 @@ ${body}`, hasError);
31969
32327
  async function runCheck2(args, root, environment, spawn, liteBinary, options) {
31970
32328
  const checks = [];
31971
32329
  let ok = true;
31972
- if (existsSync14(join17(root, "database.sources.json"))) {
32330
+ if (existsSync15(join18(root, "database.sources.json"))) {
31973
32331
  try {
31974
32332
  const source = await databaseSources(root, "check");
31975
32333
  checks.push({ name: "source-contract", ok: source.ok, findings: source.findings });
@@ -31982,8 +32340,8 @@ async function runCheck2(args, root, environment, spawn, liteBinary, options) {
31982
32340
  } else {
31983
32341
  checks.push({ name: "source-contract", skipped: true, reason: "database.sources.json not found" });
31984
32342
  }
31985
- const modulePath = args.module_file ? resolve22(root, args.module_file) : join17(root, "db/modules.ts");
31986
- if (existsSync14(modulePath)) {
32343
+ const modulePath = args.module_file ? resolve23(root, args.module_file) : join18(root, "db/modules.ts");
32344
+ if (existsSync15(modulePath)) {
31987
32345
  try {
31988
32346
  const { selected, issues } = await collectLintIssues(args, root);
31989
32347
  const lintOk = !issues.some((issue) => issue.severity === "error");
@@ -32052,14 +32410,14 @@ var defaultLiteSpawn = async (command, cwd) => {
32052
32410
  return { exitCode, stdout, stderr };
32053
32411
  };
32054
32412
  async function runModuleCheckLite(args, root, spawn, liteBinary) {
32055
- const projectDir = resolve22(args.project_dir?.trim() || root);
32413
+ const projectDir = resolve23(args.project_dir?.trim() || root);
32056
32414
  const binary = liteBinary === undefined ? Bun.which("supacloud-lite") : liteBinary;
32057
32415
  if (!binary) {
32058
32416
  throw new Error("db module_check --lite 需要本机可用的 supacloud-lite(npm i -g @supacloud/lite,或加入 PATH)");
32059
32417
  }
32060
32418
  const command = [binary, "db", "check", "--project-dir", projectDir];
32061
32419
  if (args.module_file?.trim())
32062
- command.push("--module-file", resolve22(root, args.module_file.trim()));
32420
+ command.push("--module-file", resolve23(root, args.module_file.trim()));
32063
32421
  const result = await spawn(command, projectDir);
32064
32422
  const output = [result.stdout.trim(), result.stderr.trim()].filter(Boolean).join(`
32065
32423
  `);
@@ -32179,7 +32537,7 @@ function registerDbGovernanceTools(server, options = {}) {
32179
32537
  migration_role: optional(String2(), "[role_sql] Privileged migration role"),
32180
32538
  database: optional(String2(), "[role_sql] PostgreSQL database name")
32181
32539
  }, async (request) => {
32182
- const root = resolve22(request.root || fallbackRoot);
32540
+ const root = resolve23(request.root || fallbackRoot);
32183
32541
  switch (request.action) {
32184
32542
  case "context":
32185
32543
  return runContext2(request, root);
@@ -32219,8 +32577,8 @@ function registerDbGovernanceTools(server, options = {}) {
32219
32577
 
32220
32578
  // src/shared/tools/scheduled-function-tools.ts
32221
32579
  import { randomUUID as randomUUID3 } from "node:crypto";
32222
- import { readFileSync as readFileSync10, statSync as statSync9 } from "node:fs";
32223
- import { resolve as resolve23 } from "node:path";
32580
+ import { readFileSync as readFileSync11, statSync as statSync9 } from "node:fs";
32581
+ import { resolve as resolve24 } from "node:path";
32224
32582
  import { isDeepStrictEqual } from "node:util";
32225
32583
  var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;
32226
32584
  var ENVIRONMENT_NAME_PATTERN3 = /^[A-Za-z_][A-Za-z0-9_]{0,255}$/;
@@ -32243,7 +32601,7 @@ var FORBIDDEN_HEADER_NAMES = new Set([
32243
32601
  "x-project-ref"
32244
32602
  ]);
32245
32603
  var SCHEDULE_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
32246
- var SAFE_SLUG_PATTERN2 = /^[A-Za-z0-9_-]{1,128}$/;
32604
+ var SAFE_SLUG_PATTERN3 = /^[A-Za-z0-9_-]{1,128}$/;
32247
32605
  var CRON_PART_PATTERN = /^(\*|([0-9]+)(?:-([0-9]+))?)(?:\/([0-9]+))?$/;
32248
32606
  var CRON_FIELD_BOUNDS = [[0, 59], [0, 23], [1, 31], [1, 12], [0, 7]];
32249
32607
  var MAX_CRON_EXPRESSION_LENGTH = 256;
@@ -32304,14 +32662,14 @@ function validScheduledFunctionCron(expression) {
32304
32662
  function readScheduleBodyFile(bodyPathInput) {
32305
32663
  if (!bodyPathInput.trim())
32306
32664
  throw new Error("'body_file' must be a path");
32307
- const bodyPath = resolve23(bodyPathInput);
32665
+ const bodyPath = resolve24(bodyPathInput);
32308
32666
  const bodyStat = statSync9(bodyPath);
32309
32667
  if (!bodyStat.isFile() || bodyStat.size > MAX_BODY_FILE_BYTES) {
32310
32668
  throw new Error("Scheduled Function body file must be a regular file no larger than 1 MiB");
32311
32669
  }
32312
32670
  let payload;
32313
32671
  try {
32314
- payload = JSON.parse(readFileSync10(bodyPath, "utf8"));
32672
+ payload = JSON.parse(readFileSync11(bodyPath, "utf8"));
32315
32673
  } catch (error) {
32316
32674
  if (!(error instanceof SyntaxError))
32317
32675
  throw error;
@@ -32372,7 +32730,7 @@ function validSafeSchedule(schedule) {
32372
32730
  return validScheduleIdentity(schedule) && validScheduleDefinition(schedule) && validScheduleMetadata(schedule);
32373
32731
  }
32374
32732
  function validScheduleIdentity(schedule) {
32375
- return typeof schedule.id === "string" && SCHEDULE_ID_PATTERN.test(schedule.id) && typeof schedule.name === "string" && schedule.name.trim().length > 0 && schedule.name.length <= MAX_SCHEDULE_NAME_LENGTH && typeof schedule.slug === "string" && SAFE_SLUG_PATTERN2.test(schedule.slug);
32733
+ return typeof schedule.id === "string" && SCHEDULE_ID_PATTERN.test(schedule.id) && typeof schedule.name === "string" && schedule.name.trim().length > 0 && schedule.name.length <= MAX_SCHEDULE_NAME_LENGTH && typeof schedule.slug === "string" && SAFE_SLUG_PATTERN3.test(schedule.slug);
32376
32734
  }
32377
32735
  function validScheduleDefinition(schedule) {
32378
32736
  return typeof schedule.cron === "string" && validScheduledFunctionCron(schedule.cron) && (schedule.method === "GET" || schedule.method === "POST") && typeof schedule.enabled === "boolean";
@@ -32555,7 +32913,7 @@ function requiredName(args, action) {
32555
32913
  }
32556
32914
  function requiredSlug(args, action) {
32557
32915
  const slug = requiredText2(args, "slug", action);
32558
- if (!SAFE_SLUG_PATTERN2.test(slug))
32916
+ if (!SAFE_SLUG_PATTERN3.test(slug))
32559
32917
  throw new Error(`'slug' is invalid for '${action}'`);
32560
32918
  return slug;
32561
32919
  }
@@ -32688,8 +33046,8 @@ var MUTATION_TOOL_SCHEMA = {
32688
33046
 
32689
33047
  // src/shared/tools/release-tools.ts
32690
33048
  import { createHash as createHash10 } from "node:crypto";
32691
- import { existsSync as existsSync15, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "node:fs";
32692
- import { dirname as dirname12, join as join18, relative as relative9, resolve as resolve24 } from "node:path";
33049
+ import { existsSync as existsSync16, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync12, writeFileSync as writeFileSync4 } from "node:fs";
33050
+ import { dirname as dirname12, join as join19, relative as relative10, resolve as resolve25 } from "node:path";
32693
33051
  var SAFE_PROJECT_REF = /^[A-Za-z0-9_-]{1,64}$/;
32694
33052
  var SAFE_ENVIRONMENT_ID = /^[A-Za-z0-9_-]{1,64}$/;
32695
33053
  var BACKUP_ID = /^logical-full_[A-Za-z0-9_-]{1,64}_[a-f0-9]{32}$/;
@@ -33011,15 +33369,15 @@ function collectScopeFiles(cwd, file, files, dir, task) {
33011
33369
  const results = [];
33012
33370
  const resolvePathWithFallbacks = (filePath) => {
33013
33371
  const trimmed = filePath.trim();
33014
- const resolved = resolve24(cwd, trimmed);
33015
- if (existsSync15(resolved))
33372
+ const resolved = resolve25(cwd, trimmed);
33373
+ if (existsSync16(resolved))
33016
33374
  return resolved;
33017
33375
  const candidates = [
33018
- resolve24(cwd, "supacloud/fa/release-scopes", trimmed),
33019
- resolve24(cwd, "release-scopes", trimmed),
33020
- resolve24(cwd, "scopes", trimmed)
33376
+ resolve25(cwd, "supacloud/fa/release-scopes", trimmed),
33377
+ resolve25(cwd, "release-scopes", trimmed),
33378
+ resolve25(cwd, "scopes", trimmed)
33021
33379
  ];
33022
- const found = candidates.find(existsSync15);
33380
+ const found = candidates.find(existsSync16);
33023
33381
  if (found)
33024
33382
  return found;
33025
33383
  throw new Error(`Scope file not found: ${filePath}`);
@@ -33040,25 +33398,25 @@ function collectScopeFiles(cwd, file, files, dir, task) {
33040
33398
  if (!taskFilter && (!dir || typeof dir !== "string" || !dir.trim())) {
33041
33399
  throw new Error("At least one of --file, --files, or --task is required for scope_rebind");
33042
33400
  }
33043
- const candidates = typeof dir === "string" && dir.trim() ? [resolve24(cwd, dir.trim())] : [
33044
- resolve24(cwd, "supacloud/fa/release-scopes"),
33045
- resolve24(cwd, "release-scopes"),
33046
- resolve24(cwd, "scopes")
33401
+ const candidates = typeof dir === "string" && dir.trim() ? [resolve25(cwd, dir.trim())] : [
33402
+ resolve25(cwd, "supacloud/fa/release-scopes"),
33403
+ resolve25(cwd, "release-scopes"),
33404
+ resolve25(cwd, "scopes")
33047
33405
  ];
33048
33406
  for (const directory of candidates) {
33049
- if (existsSync15(directory)) {
33407
+ if (existsSync16(directory)) {
33050
33408
  try {
33051
33409
  const entries = readdirSync5(directory, { withFileTypes: true });
33052
33410
  for (const entry of entries) {
33053
33411
  if (entry.isFile() && entry.name.endsWith(".json")) {
33054
- const fullPath = join18(directory, entry.name);
33412
+ const fullPath = join19(directory, entry.name);
33055
33413
  if (!taskFilter) {
33056
33414
  results.push(fullPath);
33057
33415
  } else if (entry.name.toLowerCase().includes(taskFilter)) {
33058
33416
  results.push(fullPath);
33059
33417
  } else {
33060
33418
  try {
33061
- const parsed = JSON.parse(readFileSync11(fullPath, "utf8"));
33419
+ const parsed = JSON.parse(readFileSync12(fullPath, "utf8"));
33062
33420
  if (typeof parsed?.taskId === "string" && parsed.taskId.toLowerCase() === taskFilter) {
33063
33421
  results.push(fullPath);
33064
33422
  }
@@ -33077,7 +33435,7 @@ function collectScopeFiles(cwd, file, files, dir, task) {
33077
33435
  return [...new Set(results)];
33078
33436
  }
33079
33437
  function handleScopeRebind(args) {
33080
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
33438
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve25(args.cwd.trim()) : process.cwd();
33081
33439
  const targetBaseCommit = resolveGitBaseCommit(cwd, args.base_commit);
33082
33440
  const requestedEnvironmentId = requestedScopeEnvironment(args, "scope_rebind");
33083
33441
  const scopeFiles = collectScopeFiles(cwd, args.file, args.files, args.dir, args.task);
@@ -33085,7 +33443,7 @@ function handleScopeRebind(args) {
33085
33443
  const parsedScopes = scopeFiles.map((filePath) => {
33086
33444
  let content;
33087
33445
  try {
33088
- content = readFileSync11(filePath, "utf8");
33446
+ content = readFileSync12(filePath, "utf8");
33089
33447
  } catch (cause) {
33090
33448
  throw new Error(`Failed to read scope file '${filePath}': ${cause instanceof Error ? cause.message : String(cause)}`);
33091
33449
  }
@@ -33116,7 +33474,7 @@ function handleScopeRebind(args) {
33116
33474
  writeFileSync4(filePath, formatted, "utf8");
33117
33475
  }
33118
33476
  scopes.push({
33119
- file: relative9(cwd, filePath),
33477
+ file: relative10(cwd, filePath),
33120
33478
  task_id: typeof parsed.taskId === "string" ? parsed.taskId : "",
33121
33479
  target_project_ref: typeof parsed.targetProjectRef === "string" ? parsed.targetProjectRef : "",
33122
33480
  previous_base_commit: previousBaseCommit,
@@ -33135,20 +33493,20 @@ function handleScopeRebind(args) {
33135
33493
  });
33136
33494
  }
33137
33495
  function handleScopeInspect(args) {
33138
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
33496
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve25(args.cwd.trim()) : process.cwd();
33139
33497
  const requestedEnvironmentId = requestedScopeEnvironment(args, "scope_inspect");
33140
33498
  if (typeof args.file !== "string" || !args.file.trim()) {
33141
33499
  throw new Error("'file' is required for scope_inspect");
33142
33500
  }
33143
33501
  const trimmed = args.file.trim();
33144
- let filePath = resolve24(cwd, trimmed);
33145
- if (!existsSync15(filePath)) {
33502
+ let filePath = resolve25(cwd, trimmed);
33503
+ if (!existsSync16(filePath)) {
33146
33504
  const candidates = [
33147
- resolve24(cwd, "supacloud/fa/release-scopes", trimmed),
33148
- resolve24(cwd, "release-scopes", trimmed),
33149
- resolve24(cwd, "scopes", trimmed)
33505
+ resolve25(cwd, "supacloud/fa/release-scopes", trimmed),
33506
+ resolve25(cwd, "release-scopes", trimmed),
33507
+ resolve25(cwd, "scopes", trimmed)
33150
33508
  ];
33151
- const found = candidates.find(existsSync15);
33509
+ const found = candidates.find(existsSync16);
33152
33510
  if (found)
33153
33511
  filePath = found;
33154
33512
  else
@@ -33156,7 +33514,7 @@ function handleScopeInspect(args) {
33156
33514
  }
33157
33515
  let content;
33158
33516
  try {
33159
- content = readFileSync11(filePath, "utf8");
33517
+ content = readFileSync12(filePath, "utf8");
33160
33518
  } catch (cause) {
33161
33519
  throw new Error(`Failed to read scope file '${args.file}': ${cause instanceof Error ? cause.message : String(cause)}`);
33162
33520
  }
@@ -33176,7 +33534,7 @@ function handleScopeInspect(args) {
33176
33534
  const scopeSha256 = genericScopedReleaseScopeSha256(parsed);
33177
33535
  const git = gitCommitInfo(cwd);
33178
33536
  return releaseControlSuccess("release.scope_inspect", {
33179
- file: relative9(cwd, filePath),
33537
+ file: relative10(cwd, filePath),
33180
33538
  scope: {
33181
33539
  task_id: parsed.taskId,
33182
33540
  target_project_ref: parsed.targetProjectRef,
@@ -33208,20 +33566,20 @@ function releaseComponentView(component) {
33208
33566
  return { kind: component.kind, artifact_sha256: component.artifactSha256 };
33209
33567
  }
33210
33568
  function handleContractPlan(args, fallbackRef) {
33211
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
33569
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve25(args.cwd.trim()) : process.cwd();
33212
33570
  const requestedRef = typeof args.ref === "string" && args.ref.trim() || fallbackRef;
33213
33571
  if (!requestedRef || !validProjectRef(requestedRef)) {
33214
33572
  throw new Error("'ref' is required for contract_plan and must identify one project");
33215
33573
  }
33216
33574
  const requestedEnvironmentId = requestedScopeEnvironment(args, "contract_plan");
33217
33575
  const file = typeof args.file === "string" && args.file.trim() ? args.file.trim() : "supacloud.release.json";
33218
- const filePath = resolve24(cwd, file);
33219
- if (!existsSync15(filePath)) {
33576
+ const filePath = resolve25(cwd, file);
33577
+ if (!existsSync16(filePath)) {
33220
33578
  throw new Error(`Release contract not found: ${file}`);
33221
33579
  }
33222
33580
  let parsedValue;
33223
33581
  try {
33224
- parsedValue = JSON.parse(readFileSync11(filePath, "utf8"));
33582
+ parsedValue = JSON.parse(readFileSync12(filePath, "utf8"));
33225
33583
  } catch {
33226
33584
  throw new Error(`Release contract '${file}' is not valid JSON`);
33227
33585
  }
@@ -33244,7 +33602,7 @@ function handleContractPlan(args, fallbackRef) {
33244
33602
  }, { migration: 0, function: 0, web: 0 });
33245
33603
  return releaseControlSuccess("release.contract_plan", {
33246
33604
  plan_schema: "supacloud.release-plan.v1",
33247
- file: relative9(cwd, filePath),
33605
+ file: relative10(cwd, filePath),
33248
33606
  release_id: scope.releaseId,
33249
33607
  scope_sha256: releaseScopeSha256(scope),
33250
33608
  source_commit: scope.sourceCommit,
@@ -33278,7 +33636,7 @@ function parseCommaList(value) {
33278
33636
  return [];
33279
33637
  }
33280
33638
  function handleScopeCreate(args, fallbackRef) {
33281
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
33639
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve25(args.cwd.trim()) : process.cwd();
33282
33640
  if (typeof args.file !== "string" || !args.file.trim()) {
33283
33641
  throw new Error("'file' is required for scope_create");
33284
33642
  }
@@ -33294,7 +33652,7 @@ function handleScopeCreate(args, fallbackRef) {
33294
33652
  throw new Error("'ref' is invalid for release controls");
33295
33653
  }
33296
33654
  const targetBaseCommit = resolveGitBaseCommit(cwd, args.base_commit);
33297
- const filePath = resolve24(cwd, args.file.trim());
33655
+ const filePath = resolve25(cwd, args.file.trim());
33298
33656
  mkdirSync5(dirname12(filePath), { recursive: true });
33299
33657
  const scope = {
33300
33658
  baseCommit: targetBaseCommit,
@@ -33311,7 +33669,7 @@ function handleScopeCreate(args, fallbackRef) {
33311
33669
  `;
33312
33670
  writeFileSync4(filePath, formatted, "utf8");
33313
33671
  return releaseControlSuccess("release.scope_create", {
33314
- file: relative9(cwd, filePath),
33672
+ file: relative10(cwd, filePath),
33315
33673
  task_id: scope.taskId,
33316
33674
  target_project_ref: projectRef,
33317
33675
  target_environment_id: targetEnvironmentId,
@@ -33545,8 +33903,8 @@ function registerReleaseTools(server, http, options = {}) {
33545
33903
  import { access, lstat as lstat5, mkdtemp as mkdtemp2, opendir, readFile as readFile8, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
33546
33904
  import { spawn as spawn2 } from "node:child_process";
33547
33905
  import { createHash as createHash11 } from "node:crypto";
33548
- import { tmpdir as tmpdir3 } from "node:os";
33549
- import { basename as basename8, dirname as dirname14, join as join20, relative as relative10, resolve as resolve27, sep as sep5 } from "node:path";
33906
+ import { tmpdir as tmpdir4 } from "node:os";
33907
+ import { basename as basename9, dirname as dirname14, join as join21, relative as relative11, resolve as resolve28, sep as sep6 } from "node:path";
33550
33908
 
33551
33909
  // src/shared/tools/project-deployment.ts
33552
33910
  async function requireProjectDeploymentProtocol(http, projectRef, environmentId) {
@@ -33622,14 +33980,14 @@ async function readProjectDeploymentStatus(http, projectRef, environmentId, depl
33622
33980
  }
33623
33981
 
33624
33982
  // src/shared/tools/developer-experience-tools.ts
33625
- import { existsSync as existsSync17 } from "node:fs";
33983
+ import { existsSync as existsSync18 } from "node:fs";
33626
33984
  import { mkdir as mkdir8, readdir as readdir7, readFile as readFile7, writeFile as writeFile7 } from "node:fs/promises";
33627
- import { dirname as dirname13, join as join19, resolve as resolve26 } from "node:path";
33985
+ import { dirname as dirname13, join as join20, resolve as resolve27 } from "node:path";
33628
33986
 
33629
33987
  // src/shared/context.ts
33630
- import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
33988
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
33631
33989
  import { homedir as homedir3 } from "node:os";
33632
- import { resolve as resolve25 } from "node:path";
33990
+ import { resolve as resolve26 } from "node:path";
33633
33991
  var CORE_CONTEXT_KEYS2 = [
33634
33992
  "SUPABASE_URL",
33635
33993
  "SUPABASE_SERVICE_ROLE_KEY",
@@ -33662,11 +34020,11 @@ function parseEnvFile2(contents) {
33662
34020
  return values;
33663
34021
  }
33664
34022
  function projectConfigValues2(cwd, environment) {
33665
- const path = resolve25(cwd, "supacloud.json");
33666
- if (!existsSync16(path))
34023
+ const path = resolve26(cwd, "supacloud.json");
34024
+ if (!existsSync17(path))
33667
34025
  return {};
33668
34026
  try {
33669
- const parsed = JSON.parse(readFileSync12(path, "utf8"));
34027
+ const parsed = JSON.parse(readFileSync13(path, "utf8"));
33670
34028
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
33671
34029
  return {};
33672
34030
  const root = parsed;
@@ -33698,13 +34056,13 @@ function projectConfigValues2(cwd, environment) {
33698
34056
  }
33699
34057
  }
33700
34058
  function readEnvFile2(path, required) {
33701
- if (!existsSync16(path)) {
34059
+ if (!existsSync17(path)) {
33702
34060
  if (required)
33703
34061
  throw new Error(`SupaCloud environment file not found: ${path}`);
33704
34062
  return {};
33705
34063
  }
33706
34064
  try {
33707
- return parseEnvFile2(readFileSync12(path, "utf8"));
34065
+ return parseEnvFile2(readFileSync13(path, "utf8"));
33708
34066
  } catch (error) {
33709
34067
  const message = error instanceof Error ? error.message : String(error);
33710
34068
  throw new Error(`Failed to read SupaCloud environment file ${path}: ${message}`);
@@ -33795,7 +34153,7 @@ function parseInsecureTls2(values) {
33795
34153
  }
33796
34154
  function namedEnvironmentSource2(cwd, selector) {
33797
34155
  const environment = normalizeEnvironmentName(selector);
33798
- const path = resolve25(cwd, `.env.supacloud.${selector}`);
34156
+ const path = resolve26(cwd, `.env.supacloud.${selector}`);
33799
34157
  const values = readEnvFile2(path, true);
33800
34158
  if (values.SUPACLOUD_ENV && normalizeEnvironmentName(values.SUPACLOUD_ENV) !== environment) {
33801
34159
  throw new Error(`SUPACLOUD_ENV in ${path} does not match selector ${selector}`);
@@ -33803,7 +34161,7 @@ function namedEnvironmentSource2(cwd, selector) {
33803
34161
  return { values, kind: "named_env_file", path, environment };
33804
34162
  }
33805
34163
  function explicitEnvironmentSource2(cwd, envFile) {
33806
- const path = resolve25(cwd, envFile);
34164
+ const path = resolve26(cwd, envFile);
33807
34165
  const values = readEnvFile2(path, true);
33808
34166
  if (!values.SUPACLOUD_ENV)
33809
34167
  throw new Error(`SUPACLOUD_ENV is required in ${path}`);
@@ -33846,18 +34204,18 @@ function contextSource2(env, cwd, selection) {
33846
34204
  if (hasProcessContext2(env)) {
33847
34205
  return { values: processValues2(env), kind: "process_env", path: null, environment: "" };
33848
34206
  }
33849
- const path = resolve25(cwd, ".env");
34207
+ const path = resolve26(cwd, ".env");
33850
34208
  const values = readEnvFile2(path, false);
33851
34209
  const environment = values.SUPACLOUD_ENV ? normalizeEnvironmentName(values.SUPACLOUD_ENV) : "";
33852
34210
  if (environment) {
33853
34211
  return {
33854
34212
  values: { ...projectConfigValues2(cwd, environment), ...values },
33855
34213
  kind: "legacy_dotenv",
33856
- path: existsSync16(path) ? path : null,
34214
+ path: existsSync17(path) ? path : null,
33857
34215
  environment
33858
34216
  };
33859
34217
  }
33860
- return { values, kind: Object.keys(values).length ? "legacy_dotenv" : "none", path: existsSync16(path) ? path : null, environment };
34218
+ return { values, kind: Object.keys(values).length ? "legacy_dotenv" : "none", path: existsSync17(path) ? path : null, environment };
33861
34219
  }
33862
34220
  function resolveSupaCloudContext2(env = process.env, cwd = process.cwd(), selection = {}) {
33863
34221
  const source = contextSource2(env, cwd, selection);
@@ -33869,7 +34227,7 @@ function resolveSupaCloudContext2(env = process.env, cwd = process.cwd(), select
33869
34227
  host,
33870
34228
  sshUser: env.SUPACLOUD_SSH_USER ?? "root",
33871
34229
  sshPort: parseInt(env.SUPACLOUD_SSH_PORT ?? "22", 10),
33872
- sshKey: env.SUPACLOUD_SSH_KEY ?? resolve25(homedir3(), ".ssh", "id_rsa"),
34230
+ sshKey: env.SUPACLOUD_SSH_KEY ?? resolve26(homedir3(), ".ssh", "id_rsa"),
33873
34231
  sshPass: env.SUPACLOUD_SSH_PASS ?? "",
33874
34232
  apiUrl: core.apiUrl,
33875
34233
  apiToken: core.apiToken,
@@ -33926,7 +34284,7 @@ function textResult4(text, isError = false) {
33926
34284
  function jsonResult2(value, isError = false) {
33927
34285
  return textResult4(JSON.stringify(value, null, 2), isError);
33928
34286
  }
33929
- function record6(value) {
34287
+ function record7(value) {
33930
34288
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
33931
34289
  }
33932
34290
  function packageDependencies(manifest) {
@@ -33944,17 +34302,17 @@ function outputDirectoryFor(manifest) {
33944
34302
  return "dist";
33945
34303
  }
33946
34304
  async function readPackageManifest(root) {
33947
- const path = join19(root, "package.json");
33948
- if (!existsSync17(path))
34305
+ const path = join20(root, "package.json");
34306
+ if (!existsSync18(path))
33949
34307
  return {};
33950
34308
  try {
33951
34309
  const parsed = JSON.parse(await readFile7(path, "utf8"));
33952
- const value = record6(parsed);
34310
+ const value = record7(parsed);
33953
34311
  if (!value)
33954
34312
  throw new Error("package.json must contain an object");
33955
- const scripts = record6(value.scripts);
33956
- const dependencies = record6(value.dependencies);
33957
- const devDependencies = record6(value.devDependencies);
34313
+ const scripts = record7(value.scripts);
34314
+ const dependencies = record7(value.dependencies);
34315
+ const devDependencies = record7(value.devDependencies);
33958
34316
  return {
33959
34317
  scripts: scripts ?? undefined,
33960
34318
  dependencies: dependencies ?? undefined,
@@ -33975,8 +34333,8 @@ async function writeNewFile(path, content) {
33975
34333
  }
33976
34334
  }
33977
34335
  async function ensureGitignore(root) {
33978
- const path = join19(root, ".gitignore");
33979
- const existing = existsSync17(path) ? await readFile7(path, "utf8") : "";
34336
+ const path = join20(root, ".gitignore");
34337
+ const existing = existsSync18(path) ? await readFile7(path, "utf8") : "";
33980
34338
  const required = [".env.supacloud.*", "!.env.supacloud.*.example"];
33981
34339
  const missing = required.filter((entry) => !existing.split(/\r?\n/).includes(entry));
33982
34340
  if (missing.length === 0)
@@ -33990,10 +34348,10 @@ async function ensureGitignore(root) {
33990
34348
  return true;
33991
34349
  }
33992
34350
  async function initializeProject(request, options = {}) {
33993
- const root = resolve26(request.root || options.cwd || process.cwd());
34351
+ const root = resolve27(request.root || options.cwd || process.cwd());
33994
34352
  await mkdir8(root, { recursive: true });
33995
- const configPath = join19(root, "supacloud.json");
33996
- if (existsSync17(configPath)) {
34353
+ const configPath = join20(root, "supacloud.json");
34354
+ if (existsSync18(configPath)) {
33997
34355
  throw new Error(`supacloud.json already exists in ${root}; init never overwrites project configuration`);
33998
34356
  }
33999
34357
  const manifest = await readPackageManifest(root);
@@ -34020,10 +34378,10 @@ async function initializeProject(request, options = {}) {
34020
34378
  throw error;
34021
34379
  }
34022
34380
  created.push("supacloud.json");
34023
- if (await writeNewFile(join19(root, ".env.supacloud.test.example"), TEST_PROFILE)) {
34381
+ if (await writeNewFile(join20(root, ".env.supacloud.test.example"), TEST_PROFILE)) {
34024
34382
  created.push(".env.supacloud.test.example");
34025
34383
  }
34026
- if (await writeNewFile(join19(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE)) {
34384
+ if (await writeNewFile(join20(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE)) {
34027
34385
  created.push(".env.supacloud.production.example");
34028
34386
  }
34029
34387
  if (await ensureGitignore(root))
@@ -34034,7 +34392,7 @@ async function initializeProject(request, options = {}) {
34034
34392
  root,
34035
34393
  created,
34036
34394
  detected: {
34037
- package_json: existsSync17(join19(root, "package.json")),
34395
+ package_json: existsSync18(join20(root, "package.json")),
34038
34396
  build_script: hasBuildScript,
34039
34397
  output_directory: outputDirectory
34040
34398
  },
@@ -34079,22 +34437,22 @@ var deployToolSchema = {
34079
34437
  status: optional(String2({ format: "uuid" }), "Read a backend deployment status without publishing"),
34080
34438
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
34081
34439
  };
34082
- function record7(candidate) {
34440
+ function record8(candidate) {
34083
34441
  return candidate && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
34084
34442
  }
34085
- function requiredString(candidate, field) {
34443
+ function requiredString2(candidate, field) {
34086
34444
  if (typeof candidate !== "string" || !candidate.trim()) {
34087
34445
  throw new Error(`Invalid frontend deployment response: missing ${field}`);
34088
34446
  }
34089
34447
  return candidate.trim();
34090
34448
  }
34091
34449
  function frontendDeployment(candidate) {
34092
- const value = record7(candidate);
34450
+ const value = record8(candidate);
34093
34451
  if (!value)
34094
34452
  throw new Error("Invalid frontend deployment response");
34095
34453
  return {
34096
- id: requiredString(value.id, "id"),
34097
- name: typeof value.name === "string" && value.name.trim() ? value.name.trim() : requiredString(value.id, "id"),
34454
+ id: requiredString2(value.id, "id"),
34455
+ name: typeof value.name === "string" && value.name.trim() ? value.name.trim() : requiredString2(value.id, "id"),
34098
34456
  framework: typeof value.framework === "string" ? value.framework.trim() : "static",
34099
34457
  buildCommand: typeof value.build_command === "string" ? value.build_command.trim() : "",
34100
34458
  outputDirectory: typeof value.output_dir === "string" ? value.output_dir.trim() : "",
@@ -34111,15 +34469,15 @@ async function readJson(path) {
34111
34469
  }
34112
34470
  }
34113
34471
  async function findDeployConfigRoot(startDirectory, environmentName) {
34114
- let directory = resolve27(startDirectory);
34472
+ let directory = resolve28(startDirectory);
34115
34473
  while (true) {
34116
34474
  const environmentFile = environmentName ? `.env.supacloud.${environmentName}` : null;
34117
- if (await pathExists(join20(directory, "supacloud.json")) || await pathExists(join20(directory, "supacloud.config.ts")) || environmentFile !== null && await pathExists(join20(directory, environmentFile))) {
34475
+ if (await pathExists(join21(directory, "supacloud.json")) || await pathExists(join21(directory, "supacloud.config.ts")) || environmentFile !== null && await pathExists(join21(directory, environmentFile))) {
34118
34476
  return directory;
34119
34477
  }
34120
34478
  const parent = dirname14(directory);
34121
34479
  if (parent === directory)
34122
- return resolve27(startDirectory);
34480
+ return resolve28(startDirectory);
34123
34481
  directory = parent;
34124
34482
  }
34125
34483
  }
@@ -34159,7 +34517,7 @@ function optionalStringArray(value, field) {
34159
34517
  });
34160
34518
  }
34161
34519
  function deployTargetConfig(candidate, name) {
34162
- const value = record7(candidate);
34520
+ const value = record8(candidate);
34163
34521
  if (!value || value.type !== "frontend" && value.type !== "edge_function") {
34164
34522
  throw new Error(`supacloud.json targets.${name}.type must be 'frontend' or 'edge_function'`);
34165
34523
  }
@@ -34184,14 +34542,14 @@ function deployTargetConfig(candidate, name) {
34184
34542
  };
34185
34543
  }
34186
34544
  async function readDeployConfig(configRoot) {
34187
- const configPath = join20(configRoot, "supacloud.json");
34545
+ const configPath = join21(configRoot, "supacloud.json");
34188
34546
  const candidate = await readJson(configPath);
34189
34547
  if (candidate === null)
34190
34548
  return {};
34191
- const config = record7(candidate);
34192
- const frontend = record7(config?.frontend);
34193
- const application = record7(config?.application);
34194
- const targetValues = record7(config?.targets);
34549
+ const config = record8(candidate);
34550
+ const frontend = record8(config?.frontend);
34551
+ const application = record8(config?.application);
34552
+ const targetValues = record8(config?.targets);
34195
34553
  if (!config || config.frontend !== undefined && !frontend || config.application !== undefined && !application || config.targets !== undefined && !targetValues) {
34196
34554
  throw new Error("supacloud.json must contain object-valued 'application', 'frontend' or 'targets' configuration");
34197
34555
  }
@@ -34231,16 +34589,16 @@ async function readDeployConfig(configRoot) {
34231
34589
  };
34232
34590
  }
34233
34591
  async function packageName(projectDirectory) {
34234
- const candidate = record7(await readJson(join20(projectDirectory, "package.json")));
34592
+ const candidate = record8(await readJson(join21(projectDirectory, "package.json")));
34235
34593
  return typeof candidate?.name === "string" && candidate.name.trim() ? candidate.name.trim() : null;
34236
34594
  }
34237
34595
  async function pathExists(path) {
34238
34596
  return access(path).then(() => true, () => false);
34239
34597
  }
34240
34598
  async function hasProjectReleaseManifest(root) {
34241
- if (await pathExists(join20(root, "deploy-manifest.json")))
34599
+ if (await pathExists(join21(root, "deploy-manifest.json")))
34242
34600
  return true;
34243
- const directory = await opendir(join20(root, "supacloud")).catch((error) => {
34601
+ const directory = await opendir(join21(root, "supacloud")).catch((error) => {
34244
34602
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
34245
34603
  return null;
34246
34604
  throw error;
@@ -34251,36 +34609,36 @@ async function hasProjectReleaseManifest(root) {
34251
34609
  for await (const entry of directory) {
34252
34610
  if (++entries > 128)
34253
34611
  throw new Error("Too many SupaCloud project roots to resolve a deployment");
34254
- if ((entry.isDirectory() || entry.isSymbolicLink()) && await pathExists(join20(root, "supacloud", entry.name, "deploy-manifest.json")))
34612
+ if ((entry.isDirectory() || entry.isSymbolicLink()) && await pathExists(join21(root, "supacloud", entry.name, "deploy-manifest.json")))
34255
34613
  return true;
34256
34614
  }
34257
34615
  return false;
34258
34616
  }
34259
34617
  async function defaultBuildCommand(projectDirectory, configRoot) {
34260
- const packageJson = record7(await readJson(join20(projectDirectory, "package.json")));
34261
- const scripts = record7(packageJson?.scripts);
34618
+ const packageJson = record8(await readJson(join21(projectDirectory, "package.json")));
34619
+ const scripts = record8(packageJson?.scripts);
34262
34620
  if (typeof scripts?.build !== "string" || !scripts.build.trim()) {
34263
34621
  throw new Error("No build command was configured and package.json has no build script");
34264
34622
  }
34265
34623
  let directory = projectDirectory;
34266
34624
  while (true) {
34267
- if (await pathExists(join20(directory, "bun.lock")) || await pathExists(join20(directory, "bun.lockb")))
34625
+ if (await pathExists(join21(directory, "bun.lock")) || await pathExists(join21(directory, "bun.lockb")))
34268
34626
  return "bun run build";
34269
- if (await pathExists(join20(directory, "pnpm-lock.yaml")))
34627
+ if (await pathExists(join21(directory, "pnpm-lock.yaml")))
34270
34628
  return "pnpm run build";
34271
- if (await pathExists(join20(directory, "yarn.lock")))
34629
+ if (await pathExists(join21(directory, "yarn.lock")))
34272
34630
  return "yarn build";
34273
34631
  if (directory === configRoot)
34274
34632
  break;
34275
34633
  const parent = dirname14(directory);
34276
- if (parent === directory || !directory.startsWith(`${configRoot}${sep5}`))
34634
+ if (parent === directory || !directory.startsWith(`${configRoot}${sep6}`))
34277
34635
  break;
34278
34636
  directory = parent;
34279
34637
  }
34280
34638
  return "npm run build";
34281
34639
  }
34282
34640
  function deploymentList(candidate) {
34283
- const values = Array.isArray(candidate) ? candidate : Array.isArray(record7(candidate)?.deployments) ? record7(candidate)?.deployments : null;
34641
+ const values = Array.isArray(candidate) ? candidate : Array.isArray(record8(candidate)?.deployments) ? record8(candidate)?.deployments : null;
34284
34642
  if (!values)
34285
34643
  throw new Error("Invalid frontend deployment list response");
34286
34644
  return values.map(frontendDeployment);
@@ -34340,9 +34698,9 @@ function selectFrontendTarget(configRoot, config) {
34340
34698
  throw new Error(`Multiple frontend deploy targets found (${targets.map(([name]) => name).sort().join(", ")}). Set defaultTarget to the Web target`);
34341
34699
  }
34342
34700
  function targetRoot(configRoot, target, name) {
34343
- const root = resolve27(configRoot, target.root || (name === "frontend" ? "." : name));
34344
- const prefix = `${resolve27(configRoot)}${sep5}`;
34345
- if (root !== resolve27(configRoot) && !root.startsWith(prefix)) {
34701
+ const root = resolve28(configRoot, target.root || (name === "frontend" ? "." : name));
34702
+ const prefix = `${resolve28(configRoot)}${sep6}`;
34703
+ if (root !== resolve28(configRoot) && !root.startsWith(prefix)) {
34346
34704
  throw new Error(`Deploy target '${name}' root must stay inside the repository root`);
34347
34705
  }
34348
34706
  return root;
@@ -34360,9 +34718,9 @@ function defaultOutputDirectory(framework) {
34360
34718
  }
34361
34719
  }
34362
34720
  function resolveInsideProject(projectDirectory, candidate, allowRoot = false) {
34363
- const resolved = resolve27(projectDirectory, candidate);
34364
- const projectRoot = resolve27(projectDirectory);
34365
- const projectPrefix = `${projectRoot}${sep5}`;
34721
+ const resolved = resolve28(projectDirectory, candidate);
34722
+ const projectRoot = resolve28(projectDirectory);
34723
+ const projectPrefix = `${projectRoot}${sep6}`;
34366
34724
  if (!allowRoot && resolved === projectRoot || resolved !== projectRoot && !resolved.startsWith(projectPrefix)) {
34367
34725
  throw new Error("Frontend output directory must stay inside the project directory");
34368
34726
  }
@@ -34415,7 +34773,7 @@ async function collectArchiveFiles(root) {
34415
34773
  entries.push(entry);
34416
34774
  entries.sort((left, right) => left.name.localeCompare(right.name, "en"));
34417
34775
  for (const entry of entries) {
34418
- const path = join20(directory, entry.name);
34776
+ const path = join21(directory, entry.name);
34419
34777
  const stats = await lstat5(path);
34420
34778
  if (stats.isSymbolicLink())
34421
34779
  throw new Error(`Frontend output cannot contain symbolic links: ${path}`);
@@ -34438,7 +34796,7 @@ async function collectArchiveFiles(root) {
34438
34796
  bytes += data.byteLength;
34439
34797
  if (bytes > MAX_SOURCE_BYTES)
34440
34798
  throw new Error(`Frontend output exceeds ${MAX_SOURCE_BYTES} bytes`);
34441
- const archivePath = relative10(root, path).split(sep5).join("/");
34799
+ const archivePath = relative11(root, path).split(sep6).join("/");
34442
34800
  files.set(archivePath, data);
34443
34801
  digests.push({ path: archivePath, size: data.byteLength, sha256: createHash11("sha256").update(data).digest("hex") });
34444
34802
  }
@@ -34453,8 +34811,8 @@ async function collectArchiveFiles(root) {
34453
34811
  return { files, bytes, count: paths.length, treeSha256: tree.digest("hex") };
34454
34812
  }
34455
34813
  async function createCollectedFrontendArchive(outputDirectory, collected) {
34456
- const temporaryDirectory = await mkdtemp2(join20(tmpdir3(), "supacloud-deploy-"));
34457
- const archivePath = join20(temporaryDirectory, `${basename8(outputDirectory)}.tar.zst`);
34814
+ const temporaryDirectory = await mkdtemp2(join21(tmpdir4(), "supacloud-deploy-"));
34815
+ const archivePath = join21(temporaryDirectory, `${basename9(outputDirectory)}.tar.zst`);
34458
34816
  try {
34459
34817
  const archiveBytes = await createFrontendTarZstd(collected.files);
34460
34818
  await writeFile8(archivePath, archiveBytes);
@@ -34502,7 +34860,7 @@ async function publishConfiguredFrontend(http, projectRef, configRoot, skipBuild
34502
34860
  }
34503
34861
  function registerDeployTools(server, http, options = {}) {
34504
34862
  registerTool(server, "deploy", "Build and publish the linked project with one command", deployToolSchema, async (args) => {
34505
- const invocationDirectory = resolve27(String(args.cwd || options.cwd || process.cwd()));
34863
+ const invocationDirectory = resolve28(String(args.cwd || options.cwd || process.cwd()));
34506
34864
  if (args.action === "init") {
34507
34865
  return initializeProject({
34508
34866
  ...typeof args.root === "string" ? { root: args.root } : {},
@@ -34583,11 +34941,11 @@ function registerDeployTools(server, http, options = {}) {
34583
34941
  }
34584
34942
 
34585
34943
  // src/shared/tools/remote-dev-tools.ts
34586
- import { existsSync as existsSync18 } from "node:fs";
34944
+ import { existsSync as existsSync19 } from "node:fs";
34587
34945
  import { readFile as readFile9 } from "node:fs/promises";
34588
34946
  import { readdir as readdir8 } from "node:fs/promises";
34589
34947
  import { createHash as createHash12 } from "node:crypto";
34590
- import { join as join21, resolve as resolve28 } from "node:path";
34948
+ import { join as join22, resolve as resolve29 } from "node:path";
34591
34949
  import { compileProject as compileProject2 } from "@supacloud/compiler";
34592
34950
  var SAFE_TOKEN = /^[A-Za-z0-9._:@/+,-]+$/;
34593
34951
  var SAFE_REMOTE_ROOT = /^\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\/?$/;
@@ -34615,8 +34973,8 @@ async function runProcess(executable, args, cwd) {
34615
34973
  return { exitCode: exitCode ?? 1, stdout, stderr };
34616
34974
  }
34617
34975
  async function readProjectConfig(root) {
34618
- const file = join21(root, "supacloud.json");
34619
- if (!existsSync18(file))
34976
+ const file = join22(root, "supacloud.json");
34977
+ if (!existsSync19(file))
34620
34978
  return {};
34621
34979
  try {
34622
34980
  const parsed = JSON.parse(await readFile9(file, "utf8"));
@@ -34637,7 +34995,7 @@ async function sourceFingerprint(root) {
34637
34995
  const visit = async (directory) => {
34638
34996
  const entries = await readdir8(directory, { withFileTypes: true });
34639
34997
  for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
34640
- const path = join21(directory, entry.name);
34998
+ const path = join22(directory, entry.name);
34641
34999
  if (entry.isDirectory() && ![".git", "node_modules", "dist", "generated", ".supacloud"].includes(entry.name))
34642
35000
  await visit(path);
34643
35001
  else if (entry.isFile())
@@ -34665,19 +35023,19 @@ function remoteRoot(value) {
34665
35023
  }
34666
35024
  function targetDirectory(root, target, functionSlug, config = {}) {
34667
35025
  if (target === "db")
34668
- return join21(root, "supabase", "migrations");
35026
+ return join22(root, "supabase", "migrations");
34669
35027
  if (target === "functions") {
34670
35028
  const targets = config["targets"];
34671
35029
  const entries = targets && typeof targets === "object" ? Object.values(targets) : [];
34672
35030
  const match = entries.find((entry) => entry !== null && typeof entry === "object" && ("type" in entry) && entry.type === "edge_function" && (!("root" in entry) || typeof entry.root === "string") && (!("slug" in entry) || typeof entry.slug === "string") && (!functionSlug || ("slug" in entry) && entry.slug === functionSlug));
34673
- const base = match?.root ? resolve28(root, match.root) : join21(root, "supabase", "functions");
34674
- return match?.root ? base : functionSlug ? join21(base, safeToken(functionSlug, "function")) : base;
35031
+ const base = match?.root ? resolve29(root, match.root) : join22(root, "supabase", "functions");
35032
+ return match?.root ? base : functionSlug ? join22(base, safeToken(functionSlug, "function")) : base;
34675
35033
  }
34676
35034
  if (target === "frontend") {
34677
35035
  const targets = config["targets"];
34678
35036
  const entries = targets && typeof targets === "object" ? Object.values(targets) : [];
34679
35037
  const match = entries.find((entry) => entry !== null && typeof entry === "object" && ("type" in entry) && entry.type === "frontend" && (!("root" in entry) || typeof entry.root === "string"));
34680
- return match?.root ? resolve28(root, match.root) : join21(root, "apps", "web");
35038
+ return match?.root ? resolve29(root, match.root) : join22(root, "apps", "web");
34681
35039
  }
34682
35040
  return root;
34683
35041
  }
@@ -34716,10 +35074,10 @@ function reloadCommand(config, target, projectRef, functionSlug) {
34716
35074
  return [...command.split(" "), "--project-ref", safeToken(projectRef || "test", "project_ref"), "--target", targetConfigPath(target), ...functionSlug ? ["--function", safeToken(functionSlug, "function")] : []];
34717
35075
  }
34718
35076
  function sshArgs(connection, remoteCommand) {
34719
- return ["-p", String(connection.port), "-i", resolve28(connection.key), "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=yes", `${connection.user}@${connection.host}`, ...remoteCommand];
35077
+ return ["-p", String(connection.port), "-i", resolve29(connection.key), "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=yes", `${connection.user}@${connection.host}`, ...remoteCommand];
34720
35078
  }
34721
35079
  function rsyncArgs(connection, source, destination, excludes, deleteRemote) {
34722
- const args = ["-az", "--checksum", "--partial", "--protect-args", "-e", `ssh -p ${connection.port} -i ${resolve28(connection.key)} -o BatchMode=yes -o StrictHostKeyChecking=yes`];
35080
+ const args = ["-az", "--checksum", "--partial", "--protect-args", "-e", `ssh -p ${connection.port} -i ${resolve29(connection.key)} -o BatchMode=yes -o StrictHostKeyChecking=yes`];
34723
35081
  if (deleteRemote)
34724
35082
  args.push("--delete-delay");
34725
35083
  for (const exclude of excludes) {
@@ -34731,17 +35089,17 @@ function rsyncArgs(connection, source, destination, excludes, deleteRemote) {
34731
35089
  return args;
34732
35090
  }
34733
35091
  async function syncOnce(args, options) {
34734
- const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
35092
+ const root = resolve29(String(args.project_dir || options.cwd || process.cwd()));
34735
35093
  const projectConfig = await readProjectConfig(root);
34736
35094
  const config = projectConfig.dev || {};
34737
35095
  const target = String(args.target || "project");
34738
35096
  const source = targetDirectory(root, target, typeof args.function === "string" ? args.function : undefined, projectConfig);
34739
- if (!existsSync18(source))
35097
+ if (!existsSync19(source))
34740
35098
  throw new Error(`Dev source directory not found: ${source}`);
34741
35099
  let compiled = false;
34742
35100
  if (config.compile === true && target !== "db") {
34743
- const compileRoot = resolve28(root, config.compileRoot || ".");
34744
- const compileOutDir = resolve28(root, config.compileOutDir || "generated");
35101
+ const compileRoot = resolve29(root, config.compileRoot || ".");
35102
+ const compileOutDir = resolve29(root, config.compileOutDir || "generated");
34745
35103
  const compilation = await compileProject2({
34746
35104
  rootDir: compileRoot,
34747
35105
  outDir: compileOutDir,
@@ -34779,7 +35137,7 @@ function registerRemoteDevTools(server, options = {}) {
34779
35137
  if (["production", "prod"].includes((options.environment || "").toLowerCase()))
34780
35138
  throw new Error("Remote dev mode is forbidden for production environments");
34781
35139
  if (args.action === "status") {
34782
- const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
35140
+ const root = resolve29(String(args.project_dir || options.cwd || process.cwd()));
34783
35141
  const config = await readDevConfig(root);
34784
35142
  const connection = connectionArgs(options, config, args);
34785
35143
  const execute = options.execute || ((command, commandArgs, cwd) => runProcess(command, commandArgs, cwd));
@@ -34790,7 +35148,7 @@ function registerRemoteDevTools(server, options = {}) {
34790
35148
  return { content: [{ type: "text", text: JSON.stringify(await syncOnce(args, options), null, 2) }] };
34791
35149
  }
34792
35150
  if (args.action === "watch") {
34793
- const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
35151
+ const root = resolve29(String(args.project_dir || options.cwd || process.cwd()));
34794
35152
  const interval = Math.max(100, Math.min(1e4, Number(args.interval_ms || 300)));
34795
35153
  let fingerprint = "";
34796
35154
  let lastSync = null;
@@ -34810,9 +35168,9 @@ function registerRemoteDevTools(server, options = {}) {
34810
35168
  }
34811
35169
 
34812
35170
  // src/shared/tools/developer-experience-tools.ts
34813
- import { existsSync as existsSync19 } from "node:fs";
35171
+ import { existsSync as existsSync20 } from "node:fs";
34814
35172
  import { mkdir as mkdir9, readdir as readdir9, readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
34815
- import { dirname as dirname15, join as join22, resolve as resolve29 } from "node:path";
35173
+ import { dirname as dirname15, join as join23, resolve as resolve30 } from "node:path";
34816
35174
  var initToolSchema2 = {
34817
35175
  root: optional(String2(), "Project directory to initialize (default: current directory)"),
34818
35176
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
@@ -34846,7 +35204,7 @@ function textResult5(text, isError = false) {
34846
35204
  function jsonResult3(value, isError = false) {
34847
35205
  return textResult5(JSON.stringify(value, null, 2), isError);
34848
35206
  }
34849
- function record8(value) {
35207
+ function record9(value) {
34850
35208
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
34851
35209
  }
34852
35210
  function packageDependencies2(manifest) {
@@ -34864,17 +35222,17 @@ function outputDirectoryFor2(manifest) {
34864
35222
  return "dist";
34865
35223
  }
34866
35224
  async function readPackageManifest2(root) {
34867
- const path = join22(root, "package.json");
34868
- if (!existsSync19(path))
35225
+ const path = join23(root, "package.json");
35226
+ if (!existsSync20(path))
34869
35227
  return {};
34870
35228
  try {
34871
35229
  const parsed = JSON.parse(await readFile10(path, "utf8"));
34872
- const value = record8(parsed);
35230
+ const value = record9(parsed);
34873
35231
  if (!value)
34874
35232
  throw new Error("package.json must contain an object");
34875
- const scripts = record8(value.scripts);
34876
- const dependencies = record8(value.dependencies);
34877
- const devDependencies = record8(value.devDependencies);
35233
+ const scripts = record9(value.scripts);
35234
+ const dependencies = record9(value.dependencies);
35235
+ const devDependencies = record9(value.devDependencies);
34878
35236
  return {
34879
35237
  scripts: scripts ?? undefined,
34880
35238
  dependencies: dependencies ?? undefined,
@@ -34895,8 +35253,8 @@ async function writeNewFile2(path, content) {
34895
35253
  }
34896
35254
  }
34897
35255
  async function ensureGitignore2(root) {
34898
- const path = join22(root, ".gitignore");
34899
- const existing = existsSync19(path) ? await readFile10(path, "utf8") : "";
35256
+ const path = join23(root, ".gitignore");
35257
+ const existing = existsSync20(path) ? await readFile10(path, "utf8") : "";
34900
35258
  const required = [".env.supacloud.*", "!.env.supacloud.*.example"];
34901
35259
  const missing = required.filter((entry) => !existing.split(/\r?\n/).includes(entry));
34902
35260
  if (missing.length === 0)
@@ -34910,10 +35268,10 @@ async function ensureGitignore2(root) {
34910
35268
  return true;
34911
35269
  }
34912
35270
  async function initializeProject2(request, options = {}) {
34913
- const root = resolve29(request.root || options.cwd || process.cwd());
35271
+ const root = resolve30(request.root || options.cwd || process.cwd());
34914
35272
  await mkdir9(root, { recursive: true });
34915
- const configPath = join22(root, "supacloud.json");
34916
- if (existsSync19(configPath)) {
35273
+ const configPath = join23(root, "supacloud.json");
35274
+ if (existsSync20(configPath)) {
34917
35275
  throw new Error(`supacloud.json already exists in ${root}; init never overwrites project configuration`);
34918
35276
  }
34919
35277
  const manifest = await readPackageManifest2(root);
@@ -34940,10 +35298,10 @@ async function initializeProject2(request, options = {}) {
34940
35298
  throw error;
34941
35299
  }
34942
35300
  created.push("supacloud.json");
34943
- if (await writeNewFile2(join22(root, ".env.supacloud.test.example"), TEST_PROFILE2)) {
35301
+ if (await writeNewFile2(join23(root, ".env.supacloud.test.example"), TEST_PROFILE2)) {
34944
35302
  created.push(".env.supacloud.test.example");
34945
35303
  }
34946
- if (await writeNewFile2(join22(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE2)) {
35304
+ if (await writeNewFile2(join23(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE2)) {
34947
35305
  created.push(".env.supacloud.production.example");
34948
35306
  }
34949
35307
  if (await ensureGitignore2(root))
@@ -34954,7 +35312,7 @@ async function initializeProject2(request, options = {}) {
34954
35312
  root,
34955
35313
  created,
34956
35314
  detected: {
34957
- package_json: existsSync19(join22(root, "package.json")),
35315
+ package_json: existsSync20(join23(root, "package.json")),
34958
35316
  build_script: hasBuildScript,
34959
35317
  output_directory: outputDirectory
34960
35318
  },
@@ -34988,7 +35346,7 @@ async function environmentProfiles(root) {
34988
35346
  });
34989
35347
  return entries.filter((entry) => entry.isFile()).map((entry) => {
34990
35348
  const name = profileNameFromFile(entry.name);
34991
- return name ? { name, path: join22(root, entry.name), exists: true } : null;
35349
+ return name ? { name, path: join23(root, entry.name), exists: true } : null;
34992
35350
  }).filter((profile) => profile !== null).sort((left, right) => left.name.localeCompare(right.name));
34993
35351
  }
34994
35352
  function statusMissing(context) {
@@ -35027,14 +35385,14 @@ async function inspectProfile(profile) {
35027
35385
  environmentName: profile.name
35028
35386
  });
35029
35387
  const status = statusMissing(context);
35030
- const configText = await readFile10(join22(dirname15(profile.path), "supacloud.json"), "utf8").catch((error) => {
35388
+ const configText = await readFile10(join23(dirname15(profile.path), "supacloud.json"), "utf8").catch((error) => {
35031
35389
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
35032
35390
  return "{}";
35033
35391
  throw error;
35034
35392
  });
35035
- const config = record8(JSON.parse(configText));
35036
- const hasFrontend = record8(config?.frontend) !== null || Object.values(record8(config?.targets) ?? {}).some((target) => record8(target)?.type === "frontend");
35037
- const deploy = deployMissing(context, record8(config?.application), hasFrontend);
35393
+ const config = record9(JSON.parse(configText));
35394
+ const hasFrontend = record9(config?.frontend) !== null || Object.values(record9(config?.targets) ?? {}).some((target) => record9(target)?.type === "frontend");
35395
+ const deploy = deployMissing(context, record9(config?.application), hasFrontend);
35038
35396
  return {
35039
35397
  name: profile.name,
35040
35398
  path: profile.path,
@@ -35071,7 +35429,7 @@ async function inspectProfile(profile) {
35071
35429
  }
35072
35430
  }
35073
35431
  async function inspectEnvironment(request, options) {
35074
- const root = resolve29(request.root || options.cwd || process.cwd());
35432
+ const root = resolve30(request.root || options.cwd || process.cwd());
35075
35433
  const profiles = await environmentProfiles(root);
35076
35434
  if (request.action === "list") {
35077
35435
  const active = options.activeContext?.environment || null;
@@ -35133,9 +35491,9 @@ function registerDeveloperExperienceTools(server, options = {}) {
35133
35491
  }
35134
35492
 
35135
35493
  // src/shared/tools/configuration-tools.ts
35136
- import { existsSync as existsSync20 } from "node:fs";
35494
+ import { existsSync as existsSync21 } from "node:fs";
35137
35495
  import { mkdir as mkdir10, readFile as readFile11, writeFile as writeFile10 } from "node:fs/promises";
35138
- import { join as join23, resolve as resolve30 } from "node:path";
35496
+ import { join as join24, resolve as resolve31 } from "node:path";
35139
35497
  var MANAGEMENT_CONFIGURATION_KEYS = ["SUPACLOUD_API_URL", "SUPACLOUD_API_TOKEN", "SUPACLOUD_PROJECT_REF"];
35140
35498
  var APPLICATION_CONFIGURATION_KEYS = ["SUPABASE_URL", "SUPABASE_SERVICE_ROLE_KEY", "SUPACLOUD_PROJECT_REF"];
35141
35499
  var onboardToolSchema2 = {
@@ -35168,7 +35526,7 @@ function textResult6(text, isError = false) {
35168
35526
  function jsonResult4(value, isError = false) {
35169
35527
  return textResult6(JSON.stringify(value, null, 2), isError);
35170
35528
  }
35171
- function record9(value) {
35529
+ function record10(value) {
35172
35530
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
35173
35531
  }
35174
35532
  function unquote2(value) {
@@ -35191,10 +35549,10 @@ function parseEnvironment2(content) {
35191
35549
  return values;
35192
35550
  }
35193
35551
  async function readJsonObject2(path) {
35194
- if (!existsSync20(path))
35552
+ if (!existsSync21(path))
35195
35553
  return {};
35196
35554
  const parsed = JSON.parse(await readFile11(path, "utf8"));
35197
- const value = record9(parsed);
35555
+ const value = record10(parsed);
35198
35556
  if (!value)
35199
35557
  throw new Error(`${path} must contain a JSON object`);
35200
35558
  return value;
@@ -35204,13 +35562,13 @@ async function writeJsonObject2(path, value) {
35204
35562
  `, { encoding: "utf8", mode: 420 });
35205
35563
  }
35206
35564
  function contextFromConfig2(config) {
35207
- const context = record9(config.context);
35565
+ const context = record10(config.context);
35208
35566
  return context ?? {};
35209
35567
  }
35210
35568
  function environmentContext2(config, environment) {
35211
35569
  const context = contextFromConfig2(config);
35212
- const environments = record9(context.environments);
35213
- const selected = environments ? record9(environments[environment]) : null;
35570
+ const environments = record10(context.environments);
35571
+ const selected = environments ? record10(environments[environment]) : null;
35214
35572
  return selected ?? {};
35215
35573
  }
35216
35574
  function derivedValues(values) {
@@ -35295,13 +35653,13 @@ function onboardingPlan(args, root) {
35295
35653
  };
35296
35654
  }
35297
35655
  async function runOnboard(args, options) {
35298
- const root = resolve30(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35656
+ const root = resolve31(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35299
35657
  const plan = onboardingPlan(args, root);
35300
35658
  if (args.write === true) {
35301
35659
  await mkdir10(root, { recursive: true });
35302
- const path = join23(root, "supacloud.json");
35660
+ const path = join24(root, "supacloud.json");
35303
35661
  const config = await readJsonObject2(path);
35304
- if (existsSync20(path) && config.context !== undefined) {
35662
+ if (existsSync21(path) && config.context !== undefined) {
35305
35663
  throw new Error("supacloud.json already has context metadata; use env sync to update one environment");
35306
35664
  }
35307
35665
  config.context = {
@@ -35327,10 +35685,10 @@ async function runOnboard(args, options) {
35327
35685
  `));
35328
35686
  }
35329
35687
  async function runConfiguration(args, options) {
35330
- const root = resolve30(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35331
- const config = await readJsonObject2(join23(root, "supacloud.json"));
35688
+ const root = resolve31(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35689
+ const config = await readJsonObject2(join24(root, "supacloud.json"));
35332
35690
  const environment = options.activeContext?.environment || "";
35333
- const profileValues = environment && existsSync20(join23(root, `.env.supacloud.${environment}`)) ? parseEnvironment2(await readFile11(join23(root, `.env.supacloud.${environment}`), "utf8")) : {};
35691
+ const profileValues = environment && existsSync21(join24(root, `.env.supacloud.${environment}`)) ? parseEnvironment2(await readFile11(join24(root, `.env.supacloud.${environment}`), "utf8")) : {};
35334
35692
  const metadata = environment ? environmentContext2(config, environment) : {};
35335
35693
  const values = {
35336
35694
  ...Object.fromEntries(Object.entries(metadata).filter(([, value]) => typeof value === "string")),
@@ -35371,9 +35729,9 @@ function registerConfigurationTools(server, options = {}) {
35371
35729
  }
35372
35730
 
35373
35731
  // src/shared/tools/pipeline-tools.ts
35374
- import { existsSync as existsSync21 } from "node:fs";
35732
+ import { existsSync as existsSync22 } from "node:fs";
35375
35733
  import { mkdir as mkdir11, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
35376
- import { join as join24, resolve as resolve31 } from "node:path";
35734
+ import { join as join25, resolve as resolve32 } from "node:path";
35377
35735
  var pipelineToolSchema = {
35378
35736
  action: withDescription(stringEnum2(["connect"]), "Pipeline configuration action"),
35379
35737
  provider: optional(stringEnum2(["github", "gitlab"]), "[connect] Git provider (default: github)"),
@@ -35388,14 +35746,14 @@ function textResult7(text, isError = false) {
35388
35746
  function jsonResult5(value, isError = false) {
35389
35747
  return textResult7(JSON.stringify(value, null, 2), isError);
35390
35748
  }
35391
- function record10(value) {
35749
+ function record11(value) {
35392
35750
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
35393
35751
  }
35394
35752
  async function readJson2(path) {
35395
- if (!existsSync21(path))
35753
+ if (!existsSync22(path))
35396
35754
  return {};
35397
35755
  const parsed = JSON.parse(await readFile12(path, "utf8"));
35398
- return record10(parsed) ?? {};
35756
+ return record11(parsed) ?? {};
35399
35757
  }
35400
35758
  function workflow(provider, preview) {
35401
35759
  if (provider !== "github") {
@@ -35460,15 +35818,15 @@ jobs:
35460
35818
  ${previewSteps}`;
35461
35819
  }
35462
35820
  async function connectPipeline(args, options = {}) {
35463
- const root = resolve31(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35821
+ const root = resolve32(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35464
35822
  const provider = typeof args.provider === "string" ? args.provider : "github";
35465
- const config = await readJson2(join24(root, "supacloud.json"));
35466
- const frontend = record10(config.frontend);
35467
- const packageJson = await readJson2(join24(root, "package.json"));
35468
- const scripts = record10(packageJson.scripts);
35823
+ const config = await readJson2(join25(root, "supacloud.json"));
35824
+ const frontend = record11(config.frontend);
35825
+ const packageJson = await readJson2(join25(root, "package.json"));
35826
+ const scripts = record11(packageJson.scripts);
35469
35827
  const buildCommand = typeof frontend?.buildCommand === "string" ? frontend.buildCommand : typeof scripts?.build === "string" ? scripts.build : "(configure package.json build script)";
35470
35828
  const outputDirectory = typeof frontend?.outputDirectory === "string" ? frontend.outputDirectory : "dist";
35471
- const workflowPath = provider === "github" ? join24(root, ".github", "workflows", "supacloud-deploy.yml") : join24(root, ".gitlab-ci.yml");
35829
+ const workflowPath = provider === "github" ? join25(root, ".github", "workflows", "supacloud-deploy.yml") : join25(root, ".gitlab-ci.yml");
35472
35830
  const result = {
35473
35831
  schema: "supacloud.pipeline-connection.v1",
35474
35832
  provider,
@@ -35489,10 +35847,10 @@ async function connectPipeline(args, options = {}) {
35489
35847
  "No files were changed. Re-run with --write after reviewing the generated workflow."
35490
35848
  ].join(`
35491
35849
  `));
35492
- if (provider === "gitlab" && existsSync21(workflowPath)) {
35850
+ if (provider === "gitlab" && existsSync22(workflowPath)) {
35493
35851
  throw new Error(`Refusing to overwrite existing GitLab workflow: ${workflowPath}`);
35494
35852
  }
35495
- await mkdir11(resolve31(workflowPath, ".."), { recursive: true });
35853
+ await mkdir11(resolve32(workflowPath, ".."), { recursive: true });
35496
35854
  await writeFile11(workflowPath, workflow(provider, args.preview === true), { encoding: "utf8", mode: 420 });
35497
35855
  return jsonResult5({ ...result, written: true });
35498
35856
  }
@@ -35625,7 +35983,7 @@ async function runProjectDeployment(http, args) {
35625
35983
  // package.json
35626
35984
  var package_default = {
35627
35985
  name: "@supacloud/cli",
35628
- version: "0.123.2",
35986
+ version: "0.124.0",
35629
35987
  description: "Project-scoped CLI for SupaCloud users",
35630
35988
  type: "module",
35631
35989
  main: "./dist/index.js",