@supacloud/cli 0.121.9 → 0.123.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9058,6 +9058,42 @@ function parseEnvFile(contents) {
9058
9058
  }
9059
9059
  return values;
9060
9060
  }
9061
+ function projectConfigValues(cwd, environment) {
9062
+ const path = resolve2(cwd, "supacloud.json");
9063
+ if (!existsSync(path))
9064
+ return {};
9065
+ try {
9066
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
9067
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
9068
+ return {};
9069
+ const root = parsed;
9070
+ const context = root.context;
9071
+ if (!context || typeof context !== "object" || Array.isArray(context))
9072
+ return {};
9073
+ const contextRecord = context;
9074
+ const environments = contextRecord.environments;
9075
+ if (!environments || typeof environments !== "object" || Array.isArray(environments))
9076
+ return {};
9077
+ const selected = environments[environment];
9078
+ if (!selected || typeof selected !== "object" || Array.isArray(selected))
9079
+ return {};
9080
+ const values = selected;
9081
+ const output = {};
9082
+ const mappings = {
9083
+ api_url: "SUPACLOUD_API_URL",
9084
+ project_ref: "SUPACLOUD_PROJECT_REF",
9085
+ application_id: "SUPACLOUD_APPLICATION_ID",
9086
+ environment_id: "SUPACLOUD_APPLICATION_ENVIRONMENT_ID"
9087
+ };
9088
+ for (const [source, target] of Object.entries(mappings)) {
9089
+ if (typeof values[source] === "string" && values[source].trim())
9090
+ output[target] = values[source].trim();
9091
+ }
9092
+ return output;
9093
+ } catch {
9094
+ return {};
9095
+ }
9096
+ }
9061
9097
  function readEnvFile(path, required) {
9062
9098
  if (!existsSync(path)) {
9063
9099
  if (required)
@@ -9158,17 +9194,31 @@ function explicitEnvironmentSource(cwd, envFile) {
9158
9194
  function contextSource(env, cwd, selection) {
9159
9195
  if (selection.environmentName && selection.envFile)
9160
9196
  throw new Error("Environment selectors are mutually exclusive");
9161
- if (selection.environmentName)
9162
- return namedEnvironmentSource(cwd, selection.environmentName);
9163
- if (selection.envFile)
9164
- return explicitEnvironmentSource(cwd, selection.envFile);
9197
+ if (selection.environmentName) {
9198
+ const source = namedEnvironmentSource(cwd, selection.environmentName);
9199
+ return {
9200
+ ...source,
9201
+ values: { ...projectConfigValues(cwd, source.environment), ...source.values }
9202
+ };
9203
+ }
9204
+ if (selection.envFile) {
9205
+ const source = explicitEnvironmentSource(cwd, selection.envFile);
9206
+ return {
9207
+ ...source,
9208
+ values: { ...projectConfigValues(cwd, source.environment), ...source.values }
9209
+ };
9210
+ }
9165
9211
  if (env.SUPACLOUD_ENV) {
9166
9212
  const environment = normalizeEnvironmentName(env.SUPACLOUD_ENV);
9167
- const values = processValues(env);
9213
+ const values = { ...projectConfigValues(cwd, environment), ...processValues(env) };
9168
9214
  if (completeProjectContext(values)) {
9169
9215
  return { values, kind: "process_env", path: null, environment };
9170
9216
  }
9171
- return namedEnvironmentSource(cwd, env.SUPACLOUD_ENV);
9217
+ const source = namedEnvironmentSource(cwd, env.SUPACLOUD_ENV);
9218
+ return {
9219
+ ...source,
9220
+ values: { ...projectConfigValues(cwd, source.environment), ...source.values }
9221
+ };
9172
9222
  }
9173
9223
  if (hasProcessContext(env)) {
9174
9224
  return { values: processValues(env), kind: "process_env", path: null, environment: "" };
@@ -9176,6 +9226,14 @@ function contextSource(env, cwd, selection) {
9176
9226
  const path = resolve2(cwd, ".env");
9177
9227
  const values = readEnvFile(path, false);
9178
9228
  const environment = values.SUPACLOUD_ENV ? normalizeEnvironmentName(values.SUPACLOUD_ENV) : "";
9229
+ if (environment) {
9230
+ return {
9231
+ values: { ...projectConfigValues(cwd, environment), ...values },
9232
+ kind: "legacy_dotenv",
9233
+ path: existsSync(path) ? path : null,
9234
+ environment
9235
+ };
9236
+ }
9179
9237
  return { values, kind: Object.keys(values).length ? "legacy_dotenv" : "none", path: existsSync(path) ? path : null, environment };
9180
9238
  }
9181
9239
  function resolveSupaCloudContext(env = process.env, cwd = process.cwd(), selection = {}) {
@@ -9267,10 +9325,16 @@ function parseGlobalOptions(args) {
9267
9325
 
9268
9326
  // src/shared/execution-policy.ts
9269
9327
  var ACTION_POLICY = {
9328
+ config: {
9329
+ read: ["doctor", "explain"]
9330
+ },
9331
+ pipeline: {
9332
+ local: ["connect"]
9333
+ },
9270
9334
  deploy: { local: ["init"], write: ["deploy"] },
9271
9335
  applications: {
9272
9336
  read: ["list_releases", "get_release", "get_runtime", "get_deployment_evidence", "get_configuration", "get_release_transfer_plan", "get_promotion_plan", "get_promotion_status", "get_rollback_snapshot", "get_history", "get_deploy_plan", "logs", "get_preview_plan", "list_previews", "get_preview"],
9273
- write: ["upload_release", "put_configuration", "deploy_application", "transfer_release", "promote_application", "reconcile_promotion", "create_preview", "reconcile_preview", "cleanup_preview", "activate_release", "deploy_release", "rollback_release", "reconcile_activation", "retire_activation"]
9337
+ write: ["upload_release", "put_configuration", "deploy_application", "transfer_release", "promote_application", "reconcile_promotion", "create_preview", "reconcile_preview", "cleanup_preview", "preview_pull_request", "activate_release", "deploy_release", "rollback_release", "reconcile_activation", "retire_activation"]
9274
9338
  },
9275
9339
  project: {
9276
9340
  read: ["get", "endpoints", "health", "logs", "api_keys", "settings", "tasks", "task_detail", "task_stats", "dlq", "background_settings"],
@@ -9366,11 +9430,11 @@ var ACTION_POLICY = {
9366
9430
  ai: { local: ["show_skill", "install_skill"] },
9367
9431
  mcp: { local: ["config"] },
9368
9432
  init: { local: ["init"] },
9369
- env: { local: ["list", "check"] },
9433
+ env: { local: ["list", "check", "sync"] },
9370
9434
  app: {
9371
9435
  local: ["init", "generate", "dev", "watch", "verify-plan", "compile", "check", "graph", "explain", "export-tools", "context", "lens", "doctor", "fix", "plan", "build"],
9372
9436
  read: ["status", "evidence", "logs", "transfer-plan", "promote-plan", "rollback-plan", "history", "deploy-plan", "diff", "promote-status", "preview-plan", "previews", "preview-list", "preview-status"],
9373
- write: ["release", "upload", "configure", "transfer", "promote", "promote-reconcile", "deploy", "rollback", "reconcile", "retire", "preview", "preview-create", "preview-reconcile", "preview-cleanup"]
9437
+ write: ["release", "upload", "configure", "transfer", "promote", "promote-reconcile", "deploy", "rollback", "reconcile", "retire", "preview", "preview-create", "preview-reconcile", "preview-cleanup", "preview-pr"]
9374
9438
  },
9375
9439
  db: {
9376
9440
  local: ["context", "lint", "explain", "diff", "role_sql"],
@@ -15857,7 +15921,7 @@ function scaffoldFiles(framework, slug) {
15857
15921
  "package.json": JSON.stringify({
15858
15922
  private: true,
15859
15923
  type: "module",
15860
- dependencies: { elysia: "2.0.0-rc.3" }
15924
+ dependencies: { elysia: "2.0.0-rc.4" }
15861
15925
  }, null, 2) + `
15862
15926
  `,
15863
15927
  "index.ts": `import { Elysia } from "elysia";
@@ -18436,7 +18500,8 @@ var APPLICATION_PREVIEW_ACTIONS = [
18436
18500
  "list_previews",
18437
18501
  "get_preview",
18438
18502
  "reconcile_preview",
18439
- "cleanup_preview"
18503
+ "cleanup_preview",
18504
+ "preview_pull_request"
18440
18505
  ];
18441
18506
  var previewIdSchema = String2({ pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$" });
18442
18507
  var branchRefSchema = String2({ pattern: "^[a-z0-9-]{1,20}$" });
@@ -18453,7 +18518,10 @@ var APPLICATION_PREVIEW_FIELDS = {
18453
18518
  data_mode: optional(stringEnum2(["schema_only", "full_clone"]), "[get_preview_plan/create_preview] Default schema_only; full_clone copies rows"),
18454
18519
  ttl_seconds: optional(ttlSecondsSchema, "[get_preview_plan/create_preview] Lifetime from 300 to 604800 seconds; creation defaults to the platform TTL"),
18455
18520
  wait: optional(Boolean2(), "[create_preview/get_preview] Wait for verified readiness of this preview only"),
18456
- timeout_seconds: optional(waitSecondsSchema, "[create_preview/get_preview] Observation budget with wait, from 1 to 3600 seconds (default 300)")
18521
+ timeout_seconds: optional(waitSecondsSchema, "[create_preview/get_preview] Observation budget with wait, from 1 to 3600 seconds (default 300)"),
18522
+ pull_request_action: optional(stringEnum2(["opened", "closed"]), "[preview_pull_request] Pull request lifecycle action"),
18523
+ repository: optional(String2({ pattern: "^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}$" }), "[preview_pull_request] Repository owner/name"),
18524
+ pull_request_number: optional(Integer({ minimum: 1, maximum: 1e9 }), "[preview_pull_request] Pull request number")
18457
18525
  };
18458
18526
  var strict = { additionalProperties: false };
18459
18527
  var phase2 = stringEnum2(["pending", "ready", "failed", "cleaned"]);
@@ -18518,7 +18586,8 @@ var actionFields = {
18518
18586
  list_previews: [],
18519
18587
  get_preview: ["preview_id", "wait", "timeout_seconds"],
18520
18588
  reconcile_preview: ["preview_id"],
18521
- cleanup_preview: ["preview_id"]
18589
+ cleanup_preview: ["preview_id"],
18590
+ preview_pull_request: ["pull_request_action", "repository", "pull_request_number", "release_id"]
18522
18591
  };
18523
18592
  function timestamp4(value) {
18524
18593
  return Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
@@ -18663,6 +18732,34 @@ async function applicationPreviewAction(http, args, project) {
18663
18732
  const identity = { project_ref: ref, application_id: id, environment_id: environment };
18664
18733
  const applicationPath = `/v1/projects/${project}/applications/${encodeURIComponent(id)}`;
18665
18734
  const path = `${applicationPath}/environments/${encodeURIComponent(environment)}`;
18735
+ if (action === "preview_pull_request") {
18736
+ const lifecycle = required5(args, "pull_request_action");
18737
+ const repository = required5(args, "repository");
18738
+ const releaseId = required5(args, "release_id");
18739
+ const number = args["pull_request_number"];
18740
+ if (!Check2(ApplicationReleaseIdSchema2, releaseId) || !/^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/.test(repository) || (typeof number !== "number" || !Number.isSafeInteger(number) || number < 1 || number > 1e9)) {
18741
+ throw new Error("Invalid pull request preview identity");
18742
+ }
18743
+ const result = await http.post(`${path}/preview-pull-requests`, {
18744
+ action: lifecycle,
18745
+ repository,
18746
+ number,
18747
+ release_id: releaseId
18748
+ }, { timeoutMs: 120000, maxJsonBytes: 1048576, responseTimeoutMs: 30000 });
18749
+ const payload = result.data && typeof result.data === "object" && !Array.isArray(result.data) ? result.data : null;
18750
+ if (!result.ok || !payload || payload["action"] !== lifecycle || typeof payload["preview_id"] !== "string" || typeof payload["status"] !== "string" || !Array.isArray(payload["leftovers"])) {
18751
+ return releaseControlFailure(operation, result.ok ? "INVALID_RESPONSE" : "HTTP_ERROR", result.transportError ? null : result.status, identity);
18752
+ }
18753
+ const preview = payload["receipt"] === null || payload["receipt"] === undefined ? null : receipt(payload["receipt"], { ref, id, environment, previewId: payload["preview_id"] });
18754
+ return releaseControlSuccess(operation, {
18755
+ ...identity,
18756
+ action: lifecycle,
18757
+ preview_id: payload["preview_id"],
18758
+ status: payload["status"],
18759
+ leftovers: payload["leftovers"].filter((value) => typeof value === "string").slice(0, 64),
18760
+ receipt: preview
18761
+ });
18762
+ }
18666
18763
  const previewId = action === "get_preview" || action === "reconcile_preview" || action === "cleanup_preview" ? required5(args, "preview_id") : action === "create_preview" ? typeof args["preview_id"] === "string" ? required5(args, "preview_id") : randomUUID() : action === "get_preview_plan" && typeof args["preview_id"] === "string" ? required5(args, "preview_id") : undefined;
18667
18764
  const mutation = action === "create_preview" || action === "reconcile_preview" || action === "cleanup_preview";
18668
18765
  const requestBudget = startedAt === undefined ? 120000 : Math.min(120000, timeoutSeconds * 1000);
@@ -22234,9 +22331,9 @@ function registerMcpTools(server, context) {
22234
22331
  }
22235
22332
 
22236
22333
  // src/shared/tools/app-tools.ts
22237
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
22238
- import { mkdir as mkdir5, readFile as readFile4, readdir as readdir5, writeFile as writeFile4 } from "node:fs/promises";
22239
- import { basename as basename7, dirname as dirname9, join as join13, relative as relative7, resolve as resolve18 } from "node:path";
22334
+ import { existsSync as existsSync12, readFileSync as readFileSync9 } from "node:fs";
22335
+ import { mkdir as mkdir6, readFile as readFile5, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
22336
+ import { basename as basename7, dirname as dirname9, join as join14, relative as relative7, resolve as resolve19 } from "node:path";
22240
22337
  import {
22241
22338
  applyDiagnosticFix,
22242
22339
  buildDeliveryProject,
@@ -22381,16 +22478,16 @@ var starter_metadata_default = {
22381
22478
  generatedBy: "supacloud/starter-metadata-v1",
22382
22479
  packages: {
22383
22480
  compiler: {
22384
- version: "0.62.6"
22481
+ version: "0.62.7"
22385
22482
  },
22386
22483
  app: {
22387
- version: "0.39.3",
22484
+ version: "0.39.4",
22388
22485
  dependencies: {
22389
22486
  rxjs: "7.8.2"
22390
22487
  }
22391
22488
  },
22392
22489
  elysia: {
22393
- version: "0.42.4"
22490
+ version: "0.42.5"
22394
22491
  },
22395
22492
  commands: {
22396
22493
  version: "0.12.0"
@@ -22399,15 +22496,15 @@ var starter_metadata_default = {
22399
22496
  version: "0.16.2"
22400
22497
  },
22401
22498
  db: {
22402
- version: "0.24.2",
22499
+ version: "0.25.1",
22403
22500
  dependencies: {},
22404
22501
  devDependencies: {},
22405
22502
  peerDependencies: {
22406
- "@supacloud/db-zenstack": "^0.1.0 || ^0.2.0"
22503
+ "@supacloud/db-zenstack": "^0.1.0 || ^0.2.0 || ^0.3.0"
22407
22504
  }
22408
22505
  },
22409
22506
  dbZenstack: {
22410
- version: "0.2.2",
22507
+ version: "0.3.1",
22411
22508
  dependencies: {
22412
22509
  "@zenstackhq/orm": "3.10.0",
22413
22510
  "@zenstackhq/schema": "3.10.0",
@@ -22415,15 +22512,16 @@ var starter_metadata_default = {
22415
22512
  "@zenstackhq/language": "3.10.0",
22416
22513
  "@zenstackhq/sdk": "3.10.0",
22417
22514
  kysely: "0.29.0"
22418
- },
22419
- devDependencies: {
22420
- "@zenstackhq/cli": "3.10.0",
22421
- prisma: "6.19.3",
22422
- pg: "8.23.1"
22515
+ }
22516
+ },
22517
+ modelTooling: {
22518
+ version: "0.1.1",
22519
+ dependencies: {
22520
+ "@supacloud/db-zenstack": "^0.3.0"
22423
22521
  }
22424
22522
  },
22425
22523
  sdk: {
22426
- version: "0.48.3",
22524
+ version: "0.48.4",
22427
22525
  peerDependencies: {
22428
22526
  "@supabase/supabase-js": "^2.118.0"
22429
22527
  }
@@ -22851,7 +22949,7 @@ function baseTemplateFiles(name, sdkDependencies) {
22851
22949
  "@supacloud/app": `^${appMetadata.version}`,
22852
22950
  "@supacloud/elysia": `^${elysiaMetadata.version}`,
22853
22951
  effect: "4.0.5",
22854
- elysia: "2.0.0-rc.3",
22952
+ elysia: "2.0.0-rc.4",
22855
22953
  ...sdkDependencies
22856
22954
  },
22857
22955
  devDependencies: {
@@ -23595,7 +23693,7 @@ GRANT SELECT, INSERT, UPDATE ON supacloud_commands.execution_receipts TO model_o
23595
23693
  GRANT SELECT, INSERT ON supacloud_commands.execution_audit TO model_orders_app;
23596
23694
  `;
23597
23695
  function modelCommandTemplateFiles(name, sdk) {
23598
- const { app, compiler, elysia, commands, contracts, db, dbZenstack } = starter_metadata_default.packages;
23696
+ const { app, compiler, elysia, commands, contracts, db, dbZenstack, modelTooling } = starter_metadata_default.packages;
23599
23697
  const files = baseTemplateFiles(name, sdk);
23600
23698
  delete files["scripts/dev.ts"];
23601
23699
  delete files["scripts/serve.ts"];
@@ -23618,7 +23716,9 @@ function modelCommandTemplateFiles(name, sdk) {
23618
23716
  scripts: {
23619
23717
  "db:generate": "supacloud-model generate && supacloud-db generate",
23620
23718
  "db:check": "supacloud-model check && supacloud-db check",
23621
- "db:diff": "supacloud-model diff",
23719
+ "db:diff": "supacloud db plan --dir migrations",
23720
+ "db:plan": "supacloud db plan --dir migrations",
23721
+ "db:apply": "supacloud db apply --dir migrations",
23622
23722
  "db:pull": "supacloud-model pull",
23623
23723
  compile: "supacloud-compiler compile",
23624
23724
  "check:generated": "supacloud-compiler check",
@@ -23639,10 +23739,10 @@ function modelCommandTemplateFiles(name, sdk) {
23639
23739
  ...dbZenstack.dependencies,
23640
23740
  typebox: "1.4.3",
23641
23741
  effect: "4.0.5",
23642
- elysia: "2.0.0-rc.3",
23742
+ elysia: "2.0.0-rc.4",
23643
23743
  ...sdk
23644
23744
  },
23645
- devDependencies: { "@supacloud/compiler": "^" + compiler.version, ...db.devDependencies, ...dbZenstack.devDependencies, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
23745
+ devDependencies: { "@supacloud/compiler": "^" + compiler.version, "@supacloud/model-tooling": "^" + modelTooling.version, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
23646
23746
  }),
23647
23747
  "supacloud.config.ts": `import { defineSupacloudConfig } from "@supacloud/compiler";
23648
23748
  export default defineSupacloudConfig({
@@ -23739,7 +23839,7 @@ The receipt migration uses the same supacloud_commands ledger as the platform. I
23739
23839
 
23740
23840
  The model_orders_app role is a trusted-server capability and does not set request.jwt.claims. Its SQL policy is a host bypass, not the model row projection; do not grant that role to PostgREST. Authenticated SELECT, INSERT and UPDATE policies are emitted from the ZModel @@allow rules and must stay in the migration. They do not grant privileges; add a reviewed GRANT before exposing the table through PostgREST.
23741
23841
 
23742
- To change the schema: bun run db:generate, bun run db:check, then bun run db:diff -- --candidate output/database-audit/change.sql against an explicit shadow database. Review forward SQL before promotion. Stop intake and drain HTTP/worker work before host.dispose(), then close the caller-owned pool.
23842
+ To change the schema: bun run db:generate, bun run db:check, then bun run db:plan. Review the Management API's remote plan and run bun run db:apply -- --approved_digest <digest> after approval. The CLI does not receive a database URL. Stop intake and drain HTTP/worker work before host.dispose(), then close the caller-owned pool.
23743
23843
  `
23744
23844
  };
23745
23845
  }
@@ -25019,20 +25119,24 @@ SQL, not the authenticated row-policy projection. Command writes still use the s
25019
25119
  transaction, receipt and audit boundary, not unrestricted CRUD. SQL constraints, RPCs
25020
25120
  and RLS remain explicit reviewed migrations when the model language cannot express them.
25021
25121
 
25022
- Use \`bun run db:diff -- --candidate output/database-audit/change.sql\` with an
25023
- explicit read-only SUPACLOUD_MODEL_DATABASE_URL. Review the SQL, then promote a new
25024
- forward migration through the existing SupaCloud plan/apply ledger. Never run
25025
- zen migrate deploy or db push against a managed production database.
25026
- \`bun run db:pull -- --candidate output/database-audit/schema.zmodel\` writes a
25027
- review candidate only; it never overwrites the maintained model. Add policies
25028
- before adopting introspection output. Keep one migration history and preserve RLS.
25122
+ Use \`bun run db:plan\` to send the reviewed migration directory to the
25123
+ Management API for a remote, read-only plan. Review the returned digest, then run
25124
+ \`bun run db:apply -- --approved_digest <digest>\` to apply the exact same bytes
25125
+ through the project migration ledger. Neither command needs DATABASE_URL or a
25126
+ public PostgreSQL port. Never run zen migrate deploy or db push against a managed
25127
+ production database.
25128
+ \`bun run db:pull -- --candidate output/database-audit/schema.zmodel\` uses the
25129
+ same Management API binding and writes a review candidate only; it never
25130
+ overwrites the maintained model. Add policies before adopting introspection
25131
+ output. Keep one migration history and preserve RLS.
25029
25132
 
25030
25133
  Adopting a database that has no model yet starts with the same command: pull
25031
- introspects through a temporary datasource-only model, so no hand-written ZModel
25032
- is required. Review the candidate, add the policy plugin and @@allow rules, move
25033
- it to zenstack/schema.zmodel, then run \`bun run db:generate\`. Until that file
25034
- exists, \`db:diff\` and \`db:generate\` fail closed instead of building from an
25035
- unreviewed introspection result. Keep the host wiring unchanged: one
25134
+ introspects through a temporary datasource-only model inside the Management API,
25135
+ so no hand-written ZModel is required. Review the candidate, add the policy
25136
+ plugin and @@allow rules, move it to zenstack/schema.zmodel, then run
25137
+ \`bun run db:generate\`. Until that file exists, \`db:plan\` and
25138
+ \`db:generate\` fail closed instead of building from an unreviewed
25139
+ introspection result. Keep the host wiring unchanged: one
25036
25140
  createZenStackDatabase composition root supplies read-only models and the
25037
25141
  transactional command store.
25038
25142
  `;
@@ -26362,7 +26466,7 @@ export async function createReviewTaskAdapters(options: ReviewTaskOptions): Prom
26362
26466
  `;
26363
26467
 
26364
26468
  // src/shared/tools/app-starter.ts
26365
- var { compiler: compilerMetadata2, app: appMetadata2, elysia: elysiaMetadata2, commands: commandsMetadata, contracts: contractsMetadata, db: dbMetadata, dbZenstack: dbZenstackMetadata, sdk: sdkMetadata } = starter_metadata_default.packages;
26469
+ var { compiler: compilerMetadata2, app: appMetadata2, elysia: elysiaMetadata2, commands: commandsMetadata, contracts: contractsMetadata, db: dbMetadata, dbZenstack: dbZenstackMetadata, modelTooling: modelToolingMetadata, sdk: sdkMetadata } = starter_metadata_default.packages;
26366
26470
  var json3 = (value) => `${JSON.stringify(value, null, 2)}
26367
26471
  `;
26368
26472
  function appStarterFiles(name) {
@@ -26386,7 +26490,9 @@ function appStarterFiles(name) {
26386
26490
  "db:generate": "supacloud-model generate && supacloud-db generate",
26387
26491
  "db:check": "supacloud-model check && supacloud-db check",
26388
26492
  "db:assess": "supacloud-db assess",
26389
- "db:diff": "supacloud-model diff",
26493
+ "db:diff": "supacloud db plan --dir migrations",
26494
+ "db:plan": "supacloud db plan --dir migrations",
26495
+ "db:apply": "supacloud db apply --dir migrations",
26390
26496
  "db:pull": "supacloud-model pull",
26391
26497
  check: "bun run db:check && bun run compile && bun run check:generated && bun run typecheck && bun run test",
26392
26498
  test: "bun run compile && bun --no-env-file scripts/environment.ts test bun test",
@@ -26410,13 +26516,12 @@ function appStarterFiles(name) {
26410
26516
  "@supacloud/js": `^${sdkMetadata.version}`,
26411
26517
  "@supabase/supabase-js": sdkMetadata.peerDependencies["@supabase/supabase-js"],
26412
26518
  effect: "4.0.5",
26413
- elysia: "2.0.0-rc.3",
26519
+ elysia: "2.0.0-rc.4",
26414
26520
  rxjs: appMetadata2.dependencies.rxjs
26415
26521
  },
26416
26522
  devDependencies: {
26417
26523
  "@supacloud/compiler": `^${compilerMetadata2.version}`,
26418
- ...dbMetadata.devDependencies,
26419
- ...dbZenstackMetadata.devDependencies,
26524
+ "@supacloud/model-tooling": `^${modelToolingMetadata.version}`,
26420
26525
  "@types/bun": "^1.4.4",
26421
26526
  typescript: "7.1.0-beta"
26422
26527
  }
@@ -29046,6 +29151,137 @@ async function applyScaffoldWrites(plan) {
29046
29151
  }
29047
29152
  }
29048
29153
 
29154
+ // src/shared/tools/configuration-tools.ts
29155
+ import { existsSync as existsSync11 } from "node:fs";
29156
+ import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
29157
+ import { join as join13, resolve as resolve18 } from "node:path";
29158
+ var onboardToolSchema = {
29159
+ root: optional(String2(), "Repository or configuration root (default: current directory)"),
29160
+ profile: optional(stringEnum2(["solo", "podman", "pigsty", "cluster"]), "Deployment profile (default: solo)"),
29161
+ domain: optional(String2(), "Public API domain; studio domain is derived from it"),
29162
+ database: optional(stringEnum2(["local", "external"]), "Database provider (default: local)"),
29163
+ storage: optional(stringEnum2(["juicefs", "external"]), "Storage provider (default: juicefs)"),
29164
+ write: optional(Boolean2(), "Write the generated context into supacloud.json"),
29165
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
29166
+ };
29167
+ var configurationToolSchema = {
29168
+ action: withDescription(stringEnum2(["doctor", "explain"]), "Configuration inspection action"),
29169
+ root: optional(String2(), "Repository or configuration root (default: current directory)"),
29170
+ key: optional(String2(), "[explain] Environment variable name"),
29171
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
29172
+ };
29173
+ var environmentSyncSchema = {
29174
+ action: withDescription(stringEnum2(["list", "check", "sync"]), "Environment profile action"),
29175
+ root: optional(String2(), "Project directory containing .env.supacloud.* files"),
29176
+ environment: optional(String2(), "[sync] Profile name; defaults to the selected environment"),
29177
+ write: optional(Boolean2(), "[sync] Persist derived context and the reduced profile example"),
29178
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
29179
+ };
29180
+ var SECRET_KEY = /(?:PASSWORD|PASS|SECRET|TOKEN|PRIVATE|CREDENTIAL|AUTHORIZATION|COOKIE|SESSION|DATABASE_URL|CONNECTION_STRING|DSN)/i;
29181
+ var PLATFORM_KEY = /^(?:SUPACLOUD|SUPABASE)_(?:API|PROJECT|ENV|HOST|SSH|APPLICATION|SERVICE_ROLE|ACCESS|URL|READ_ONLY|TLS|ANON|PUBLISHABLE)/;
29182
+ function textResult(text, isError = false) {
29183
+ return { isError, content: [{ type: "text", text }] };
29184
+ }
29185
+ function jsonResult(value, isError = false) {
29186
+ return textResult(JSON.stringify(value, null, 2), isError);
29187
+ }
29188
+ function record5(value) {
29189
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
29190
+ }
29191
+ function unquote(value) {
29192
+ const trimmed = value.trim();
29193
+ if (trimmed.length >= 2 && (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))) {
29194
+ return trimmed.slice(1, -1);
29195
+ }
29196
+ return trimmed;
29197
+ }
29198
+ function parseEnvironment(content) {
29199
+ const values = {};
29200
+ for (const rawLine of content.split(/\r?\n/)) {
29201
+ const line = rawLine.trim();
29202
+ if (!line || line.startsWith("#"))
29203
+ continue;
29204
+ const match = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
29205
+ if (match)
29206
+ values[match[1]] = unquote(match[2]);
29207
+ }
29208
+ return values;
29209
+ }
29210
+ async function readJsonObject(path) {
29211
+ if (!existsSync11(path))
29212
+ return {};
29213
+ const parsed = JSON.parse(await readFile4(path, "utf8"));
29214
+ const value = record5(parsed);
29215
+ if (!value)
29216
+ throw new Error(`${path} must contain a JSON object`);
29217
+ return value;
29218
+ }
29219
+ async function writeJsonObject(path, value) {
29220
+ await writeFile4(path, `${JSON.stringify(value, null, 2)}
29221
+ `, { encoding: "utf8", mode: 420 });
29222
+ }
29223
+ function contextFromConfig(config) {
29224
+ const context = record5(config.context);
29225
+ return context ?? {};
29226
+ }
29227
+ function environmentContext(config, environment) {
29228
+ const context = contextFromConfig(config);
29229
+ const environments = record5(context.environments);
29230
+ const selected = environments ? record5(environments[environment]) : null;
29231
+ return selected ?? {};
29232
+ }
29233
+ async function syncEnvironmentProfile(args, options) {
29234
+ const root = resolve18(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
29235
+ const environment = typeof args.environment === "string" && args.environment.trim() ? args.environment.trim() : options.activeContext?.environment;
29236
+ if (!environment)
29237
+ throw new Error("env sync requires --env <name> or SUPACLOUD_ENV");
29238
+ const profilePath = join13(root, `.env.supacloud.${environment}`);
29239
+ if (!existsSync11(profilePath))
29240
+ throw new Error(`Environment profile not found: ${profilePath}`);
29241
+ const values = parseEnvironment(await readFile4(profilePath, "utf8"));
29242
+ const configPath = join13(root, "supacloud.json");
29243
+ const config = await readJsonObject(configPath);
29244
+ const context = contextFromConfig(config);
29245
+ const environments = record5(context.environments) ?? {};
29246
+ const publicValues = Object.fromEntries(Object.entries(values).filter(([name]) => !SECRET_KEY.test(name) && !PLATFORM_KEY.test(name)));
29247
+ const secretNames = Object.keys(values).filter((name) => SECRET_KEY.test(name));
29248
+ const nextEnvironment = {
29249
+ api_url: values.SUPACLOUD_API_URL ?? null,
29250
+ project_ref: values.SUPACLOUD_PROJECT_REF ?? null,
29251
+ application_id: values.SUPACLOUD_APPLICATION_ID ?? null,
29252
+ environment_id: values.SUPACLOUD_APPLICATION_ENVIRONMENT_ID ?? environment,
29253
+ public: publicValues,
29254
+ secret_names: secretNames
29255
+ };
29256
+ const result = {
29257
+ schema: "supacloud.environment-sync.v1",
29258
+ environment,
29259
+ profile: profilePath,
29260
+ config: configPath,
29261
+ diff: { changed: nextEnvironment, secret_values_written: false },
29262
+ next: ["Secret values are never copied into supacloud.json", `supacloud --env ${environment} status`]
29263
+ };
29264
+ if (args.write !== true)
29265
+ return jsonResult({ ...result, written: false });
29266
+ config.context = { ...context, environments: { ...environments, [environment]: nextEnvironment } };
29267
+ await writeJsonObject(configPath, config);
29268
+ const reducedExample = [`SUPACLOUD_ENV=${environment}`, "SUPACLOUD_API_TOKEN=<inject-at-runtime>", ""].join(`
29269
+ `);
29270
+ await writeFile4(`${profilePath}.example`, reducedExample, { encoding: "utf8", mode: 384 });
29271
+ return jsonResult({ ...result, written: true, reduced_profile_example: `${profilePath}.example` });
29272
+ }
29273
+ async function readSecretGap(root, environment) {
29274
+ if (!environment)
29275
+ return { environment, required: [], present: [], missing: [] };
29276
+ const config = await readJsonObject(join13(root, "supacloud.json"));
29277
+ const metadata = environmentContext(config, environment);
29278
+ const required = Array.isArray(metadata.secret_names) ? metadata.secret_names.filter((value) => typeof value === "string" && /^[A-Z_][A-Z0-9_]*$/.test(value)).sort() : [];
29279
+ const profilePath = join13(root, `.env.supacloud.${environment}`);
29280
+ const values = existsSync11(profilePath) ? parseEnvironment(await readFile4(profilePath, "utf8")) : {};
29281
+ const present = required.filter((name) => values[name] !== undefined && values[name] !== "" && !/^<[^>]+>$/.test(values[name]));
29282
+ return { environment, required, present, missing: required.filter((name) => !present.includes(name)) };
29283
+ }
29284
+
29049
29285
  // src/shared/tools/app-tools.ts
29050
29286
  var REMOTE_APP_ACTIONS = {
29051
29287
  upload: "upload_release",
@@ -29058,6 +29294,7 @@ var REMOTE_APP_ACTIONS = {
29058
29294
  "preview-create": "create_preview",
29059
29295
  "preview-status": "get_preview",
29060
29296
  "preview-cleanup": "cleanup_preview",
29297
+ "preview-pr": "preview_pull_request",
29061
29298
  transfer: "transfer_release",
29062
29299
  configure: "put_configuration",
29063
29300
  deploy: "deploy_release",
@@ -29126,7 +29363,7 @@ async function initProject(args) {
29126
29363
  ];
29127
29364
  const note = template === "client" ? "Data-plane client only (@supabase/supabase-js). The forced default is app init (minimal compiler/Effect stack)." : template === "model-command" ? "Requires an explicitly selected database, reviewed migrations and trusted HTTP/worker identity authority; see README.md." : "Local demo only. Production requires persistent governance and identity adapters; see README.md.";
29128
29365
  if (args.format === "json")
29129
- return textResult(JSON.stringify({
29366
+ return textResult2(JSON.stringify({
29130
29367
  version: 1,
29131
29368
  ok: true,
29132
29369
  root,
@@ -29136,7 +29373,7 @@ async function initProject(args) {
29136
29373
  next,
29137
29374
  note
29138
29375
  }, null, 2));
29139
- return textResult([
29376
+ return textResult2([
29140
29377
  `Initialized ${name} in ${root} (${files.length} files, template: ${template}).`,
29141
29378
  `cd '${root.replaceAll("'", "'\\''")}'`,
29142
29379
  ...next,
@@ -29144,7 +29381,7 @@ async function initProject(args) {
29144
29381
  ].join(`
29145
29382
  `));
29146
29383
  }
29147
- function textResult(text, isError = false) {
29384
+ function textResult2(text, isError = false) {
29148
29385
  return { isError, content: [{ type: "text", text }] };
29149
29386
  }
29150
29387
  function pascalName(name) {
@@ -29259,7 +29496,7 @@ async function generateScaffold(args) {
29259
29496
  throw new ScaffoldError("SCAFFOLD_OPTION_INVALID", `--${flag.replaceAll("_", "-")} must be boolean`);
29260
29497
  }
29261
29498
  }
29262
- const root = resolve18(args.root || process.cwd());
29499
+ const root = resolve19(args.root || process.cwd());
29263
29500
  const dir = args.dir ?? "src/features";
29264
29501
  if (dir !== ".")
29265
29502
  scaffoldPath(root, dir);
@@ -29288,7 +29525,7 @@ async function generateScaffold(args) {
29288
29525
  let contractName;
29289
29526
  if (kind === "module" || kind === "resource" || kind === "feature") {
29290
29527
  const name = requireIdentifier(args.name, "name");
29291
- modulePath = join13(dir, name, kind === "feature" ? `${name}.feature.ts` : `${name}.module.ts`).replaceAll("\\", "/");
29528
+ modulePath = join14(dir, name, kind === "feature" ? `${name}.feature.ts` : `${name}.module.ts`).replaceAll("\\", "/");
29292
29529
  moduleSymbol = kind === "feature" ? `${pascalName(name)}Feature` : `${pascalName(name)}Module`;
29293
29530
  if (kind === "module")
29294
29531
  writes.push({ path: modulePath, content: moduleScaffold(name), overwrite: args.force === true });
@@ -29296,18 +29533,18 @@ async function generateScaffold(args) {
29296
29533
  for (const [file, content] of Object.entries(kind === "feature" ? featureScaffold(name, pascalName(name), {
29297
29534
  ...featureGovernance,
29298
29535
  databaseImportPath: (() => {
29299
- const source = relative7(join13(root, dir, name), join13(root, featureGovernance.database.source)).replaceAll("\\", "/").replace(/\.(?:[cm]?tsx?|mts|cts)$/, "");
29536
+ const source = relative7(join14(root, dir, name), join14(root, featureGovernance.database.source)).replaceAll("\\", "/").replace(/\.(?:[cm]?tsx?|mts|cts)$/, "");
29300
29537
  return source.startsWith(".") ? source : `./${source}`;
29301
29538
  })()
29302
29539
  }) : resourceScaffold(name, pascalName(name)))) {
29303
- writes.push({ path: join13(dir, name, file).replaceAll("\\", "/"), content });
29540
+ writes.push({ path: join14(dir, name, file).replaceAll("\\", "/"), content });
29304
29541
  }
29305
29542
  } else {
29306
29543
  const moduleName = requireIdentifier(args.module, "module");
29307
29544
  const name = kind === "controller" ? moduleName : requireIdentifier(args.name, "name");
29308
29545
  const subdir = kind === "command" ? "commands" : kind === "query" ? "queries" : kind === "job" ? "jobs" : kind === "contract" ? "contracts" : "";
29309
- const path = join13(dir, moduleName, subdir, `${name}.${kind}.ts`).replaceAll("\\", "/");
29310
- if (kind === "controller" && existsSync11(scaffoldPath(root, path))) {
29546
+ const path = join14(dir, moduleName, subdir, `${name}.${kind}.ts`).replaceAll("\\", "/");
29547
+ if (kind === "controller" && existsSync12(scaffoldPath(root, path))) {
29311
29548
  throw new ScaffoldError("SCAFFOLD_EXISTS", `Controller already exists: ${path}(请手工合并路由到现有 controller)`);
29312
29549
  }
29313
29550
  const content = kind === "command" ? commandScaffold(moduleName, name) : kind === "query" ? queryScaffold(moduleName, name) : kind === "job" ? jobScaffold(moduleName, name) : kind === "contract" ? contractScaffold(moduleName, name) : controllerScaffold(moduleName);
@@ -29325,7 +29562,7 @@ async function generateScaffold(args) {
29325
29562
  if (new RegExp(`\\b${moduleSymbol}\\b`).test(original)) {
29326
29563
  throw new ScaffoldError("SCAFFOLD_REGISTRATION_CONFLICT", `Registration target already references ${moduleSymbol}; review the import manually`);
29327
29564
  }
29328
- let importPath = relative7(dirname9(target), resolve18(root, modulePath)).replaceAll("\\", "/").replace(/\.ts$/, "");
29565
+ let importPath = relative7(dirname9(target), resolve19(root, modulePath)).replaceAll("\\", "/").replace(/\.ts$/, "");
29329
29566
  if (!importPath.startsWith("."))
29330
29567
  importPath = `./${importPath}`;
29331
29568
  const edit = await applyDiagnosticFix({
@@ -29335,7 +29572,7 @@ async function generateScaffold(args) {
29335
29572
  importPath,
29336
29573
  symbol: moduleSymbol
29337
29574
  }, { rootDir: root, dryRun: true });
29338
- if (await readFile4(target, "utf8") !== original)
29575
+ if (await readFile5(target, "utf8") !== original)
29339
29576
  throw new ScaffoldError("SCAFFOLD_CHANGED", "Registration source changed during planning");
29340
29577
  writes.push({ path: args.register_in, content: edit.content, expected: original });
29341
29578
  }
@@ -29348,7 +29585,7 @@ async function generateScaffold(args) {
29348
29585
  ...args.dry_run ? { content: write.content } : {}
29349
29586
  }));
29350
29587
  if (args.format === "json")
29351
- return textResult(JSON.stringify({
29588
+ return textResult2(JSON.stringify({
29352
29589
  version: 1,
29353
29590
  ok: true,
29354
29591
  kind,
@@ -29356,7 +29593,7 @@ async function generateScaffold(args) {
29356
29593
  written: !args.dry_run,
29357
29594
  changes
29358
29595
  }, null, 2));
29359
- const lines = changes.map((change) => `${args.dry_run ? "PREVIEW" : "✅"} ${change.action}: ${join13(plan.root, change.path)}`);
29596
+ const lines = changes.map((change) => `${args.dry_run ? "PREVIEW" : "✅"} ${change.action}: ${join14(plan.root, change.path)}`);
29360
29597
  if (args.dry_run)
29361
29598
  lines.push("No files written. Omit --dry-run to apply this generation.");
29362
29599
  if (kind === "resource")
@@ -29367,7 +29604,7 @@ async function generateScaffold(args) {
29367
29604
  const prefix = pascalName(contractName);
29368
29605
  lines.push("", "Next, bind the contract to a route so the compiler can check route/schema drift:", ` import { ${prefix}Body, ${prefix}Response } from "./contracts/${contractName}.contract";`, ` @Post("/", { body: ${prefix}Body, responses: { 200: ${prefix}Response } })`, "Fill in the schema fields and reuse them in command decoders; never widen them to unknown.");
29369
29606
  }
29370
- return textResult(lines.join(`
29607
+ return textResult2(lines.join(`
29371
29608
  `));
29372
29609
  }
29373
29610
  function formatDiagnostic(diagnostic) {
@@ -29394,17 +29631,17 @@ function parseInclude(include) {
29394
29631
  return patterns && patterns.length > 0 ? patterns : undefined;
29395
29632
  }
29396
29633
  function sourceRoot(args, root, configured) {
29397
- const hasConfig = ["ts", "mts", "js", "mjs"].some((extension) => existsSync11(join13(root, `supacloud.config.${extension}`)));
29634
+ const hasConfig = ["ts", "mts", "js", "mjs"].some((extension) => existsSync12(join14(root, `supacloud.config.${extension}`)));
29398
29635
  return args.root && !hasConfig ? "." : configured;
29399
29636
  }
29400
29637
  async function projectCompileConfig(args) {
29401
- const root = resolve18(args.root || process.cwd());
29402
- const configFile = ["ts", "mts", "js", "mjs"].map((extension) => join13(root, `supacloud.config.${extension}`)).find((candidate) => existsSync11(candidate)) ?? null;
29638
+ const root = resolve19(args.root || process.cwd());
29639
+ const configFile = ["ts", "mts", "js", "mjs"].map((extension) => join14(root, `supacloud.config.${extension}`)).find((candidate) => existsSync12(candidate)) ?? null;
29403
29640
  const loadedConfig = await loadSupacloudConfig(root);
29404
29641
  const defaults = resolveSupacloudConfig(loadedConfig, root);
29405
29642
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
29406
29643
  const include = parseInclude(args.include) ?? loadedConfig.include;
29407
- const outDir = args.out_dir ? resolve18(root, args.out_dir) : defaults.outDir;
29644
+ const outDir = args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir;
29408
29645
  const compileOptions = compileOptionsFromConfig({
29409
29646
  ...loadedConfig,
29410
29647
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
@@ -29416,12 +29653,12 @@ async function projectCompileConfig(args) {
29416
29653
  return { root, sourceDir: compileOptions.rootDir, configFile, outDir, result };
29417
29654
  }
29418
29655
  async function readAllowedDependencies(root) {
29419
- const path = join13(root, "package.json");
29420
- if (!existsSync11(path)) {
29656
+ const path = join14(root, "package.json");
29657
+ if (!existsSync12(path)) {
29421
29658
  return { dependencies: [], devDependencies: [], optionalDependencies: [], peerDependencies: [] };
29422
29659
  }
29423
29660
  try {
29424
- const parsed = JSON.parse(await readFile4(path, "utf8"));
29661
+ const parsed = JSON.parse(await readFile5(path, "utf8"));
29425
29662
  return {
29426
29663
  dependencies: Object.keys(parsed.dependencies ?? {}).sort(),
29427
29664
  devDependencies: Object.keys(parsed.devDependencies ?? {}).sort(),
@@ -29455,7 +29692,7 @@ async function runContext(args) {
29455
29692
  const subject = args.target?.trim();
29456
29693
  if (subject) {
29457
29694
  const pack = createContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject);
29458
- const execution = args.events === undefined ? undefined : createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject, await readExecutionMetadata(resolve18(root, args.events)), args.request_id);
29695
+ const execution = args.events === undefined ? undefined : createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, subject, await readExecutionMetadata(resolve19(root, args.events)), args.request_id);
29459
29696
  const verification = await createVerificationPlan(root, result.graph, pack.subject, sourceDir);
29460
29697
  const repairs = createDiagnosticRepairPlan(pack.diagnostics);
29461
29698
  const workflow = {
@@ -29486,7 +29723,7 @@ async function runContext(args) {
29486
29723
  },
29487
29724
  executed: false
29488
29725
  };
29489
- return textResult(args.format === "json" ? JSON.stringify({ ...pack, ...execution ? { execution } : {}, workflow }, null, 2) : [
29726
+ return textResult2(args.format === "json" ? JSON.stringify({ ...pack, ...execution ? { execution } : {}, workflow }, null, 2) : [
29490
29727
  formatModuleContextPack(pack),
29491
29728
  ` edit files (project-relative): ${workflow.editFiles.join(", ") || "-"}`,
29492
29729
  ` focused tests: ${verification.tests.join(", ") || "-"}`,
@@ -29535,8 +29772,8 @@ async function runContext(args) {
29535
29772
  }
29536
29773
  };
29537
29774
  if (args.format === "json")
29538
- return textResult(JSON.stringify(project, null, 2));
29539
- return textResult([
29775
+ return textResult2(JSON.stringify(project, null, 2));
29776
+ return textResult2([
29540
29777
  `CONTEXT ${root}`,
29541
29778
  ` config: ${configFile ?? "(none)"}`,
29542
29779
  ` generated: ${outDir}`,
@@ -29569,13 +29806,13 @@ async function runLens(args) {
29569
29806
  diagnostics: result.diagnostics
29570
29807
  };
29571
29808
  if (args.format === "json")
29572
- return textResult(JSON.stringify(output, null, 2), lens.conflicts.some((conflict) => conflict.severity === "error"));
29809
+ return textResult2(JSON.stringify(output, null, 2), lens.conflicts.some((conflict) => conflict.severity === "error"));
29573
29810
  const lines = [`LENS ${context?.subject ?? "application"}`, ` semantic hash: ${lens.snapshot.semanticHash}`, ` source hash: ${lens.snapshot.sourceHash}`];
29574
29811
  for (const item of lens.nodes)
29575
29812
  lines.push(` ${item.kind} ${item.id} ${item.hash}`);
29576
29813
  for (const conflict of lens.conflicts)
29577
29814
  lines.push(` ${conflict.severity.toUpperCase()} ${conflict.code}: ${conflict.message}`);
29578
- return textResult(lines.join(`
29815
+ return textResult2(lines.join(`
29579
29816
  `), lens.conflicts.some((conflict) => conflict.severity === "error"));
29580
29817
  }
29581
29818
  function doctorFixPlan(doctor) {
@@ -29597,7 +29834,7 @@ async function findUnwiredContracts(rootDir) {
29597
29834
  for (const entry of entries) {
29598
29835
  if (skip.has(entry.name))
29599
29836
  continue;
29600
- const path = join13(directory, entry.name);
29837
+ const path = join14(directory, entry.name);
29601
29838
  if (entry.isDirectory())
29602
29839
  await walk(path);
29603
29840
  else if (entry.isFile() && entry.name.endsWith(".ts"))
@@ -29608,10 +29845,10 @@ async function findUnwiredContracts(rootDir) {
29608
29845
  const contracts = files.filter((file) => file.endsWith(".contract.ts"));
29609
29846
  if (contracts.length === 0)
29610
29847
  return [];
29611
- const otherSources = await Promise.all(files.filter((file) => !contracts.includes(file)).map(async (file) => await readFile4(file, "utf8").catch(() => "")));
29848
+ const otherSources = await Promise.all(files.filter((file) => !contracts.includes(file)).map(async (file) => await readFile5(file, "utf8").catch(() => "")));
29612
29849
  const unwired = [];
29613
29850
  for (const contract of contracts) {
29614
- const source = await readFile4(contract, "utf8").catch(() => "");
29851
+ const source = await readFile5(contract, "utf8").catch(() => "");
29615
29852
  const symbols = [...source.matchAll(/export\s+const\s+([A-Za-z_$][A-Za-z0-9_$]*)/g)].map((match) => match[1]);
29616
29853
  if (symbols.length === 0)
29617
29854
  continue;
@@ -29627,6 +29864,15 @@ async function runDoctor(args) {
29627
29864
  const target = args.target?.trim();
29628
29865
  const context = target ? createContextPack({ ...result.graph, diagnostics: result.diagnostics }, target) : undefined;
29629
29866
  const doctor = doctorProject(root, outDir, { ...result.graph, ...context ? { modules: context.modules } : {}, diagnostics: [] }, result.upToDate, context?.diagnostics ?? result.diagnostics);
29867
+ const secretGap = await readSecretGap(root, process.env.SUPACLOUD_ENV?.trim() ?? "");
29868
+ if (secretGap.missing.length > 0) {
29869
+ doctor.errors += 1;
29870
+ doctor.diagnostics = [...doctor.diagnostics ?? [], {
29871
+ severity: "error",
29872
+ code: "SUPACLOUD_SECRET_MISSING",
29873
+ message: `Missing environment secrets: ${secretGap.missing.join(", ")}`
29874
+ }];
29875
+ }
29630
29876
  const database = context ? null : checkAppDatabaseSources(root);
29631
29877
  if (database) {
29632
29878
  doctor.checks.push(database);
@@ -29651,7 +29897,7 @@ async function runDoctor(args) {
29651
29897
  generatedArtifactCheck: "project-wide"
29652
29898
  } : undefined;
29653
29899
  if (args.format === "json") {
29654
- return textResult(JSON.stringify({
29900
+ return textResult2(JSON.stringify({
29655
29901
  ok: doctor.errors === 0,
29656
29902
  next,
29657
29903
  autoFixable,
@@ -29659,11 +29905,15 @@ async function runDoctor(args) {
29659
29905
  manualFixes,
29660
29906
  fixPlan,
29661
29907
  unwiredContracts,
29908
+ secretGap,
29662
29909
  ...scope ? { scope } : {},
29663
29910
  ...doctor
29664
29911
  }, null, 2), doctor.errors > 0);
29665
29912
  }
29666
29913
  const lines = doctor.checks.map((check) => formatDoctorCheck(check));
29914
+ if (secretGap.required.length > 0) {
29915
+ lines.push(`Environment secrets (${secretGap.environment}): ${secretGap.missing.length === 0 ? "ready" : `missing ${secretGap.missing.join(", ")}`}`);
29916
+ }
29667
29917
  if (scope)
29668
29918
  lines.unshift(`TARGET ${scope.target}; omitted project diagnostics=${scope.omittedProjectDiagnostics}; generated drift remains project-wide`);
29669
29919
  for (const diagnostic of doctor.diagnostics ?? []) {
@@ -29683,11 +29933,11 @@ async function runDoctor(args) {
29683
29933
  if (unwiredContracts.length > 0) {
29684
29934
  lines.push(`${unwiredContracts.length} unwired contract file(s): ${unwiredContracts.map((contract) => contract.file).join(", ")}. Import their schemas into a controller route or remove them.`);
29685
29935
  }
29686
- return textResult(lines.join(`
29936
+ return textResult2(lines.join(`
29687
29937
  `), doctor.errors > 0);
29688
29938
  }
29689
29939
  async function runFix(args) {
29690
- const root = resolve18(args.root || process.cwd());
29940
+ const root = resolve19(args.root || process.cwd());
29691
29941
  const fixPath = args.fix?.trim();
29692
29942
  const doctorPath = args.from_doctor?.trim();
29693
29943
  if (fixPath && doctorPath)
@@ -29702,7 +29952,7 @@ async function runFix(args) {
29702
29952
  if (!Number.isSafeInteger(rawIndex) || rawIndex === undefined || rawIndex < 0) {
29703
29953
  throw new Error("app fix --from-doctor requires a non-negative --fix-index <n>");
29704
29954
  }
29705
- const doctor = JSON.parse(await readFile4(resolve18(root, doctorPath), "utf8"));
29955
+ const doctor = JSON.parse(await readFile5(resolve19(root, doctorPath), "utf8"));
29706
29956
  if (!doctor || typeof doctor !== "object" || !Array.isArray(doctor.fixPlan)) {
29707
29957
  throw new Error("Invalid doctor output: expected a fixPlan array");
29708
29958
  }
@@ -29721,11 +29971,11 @@ async function runFix(args) {
29721
29971
  parsed = repairEntry.fix;
29722
29972
  source = "doctor";
29723
29973
  } else {
29724
- parsed = JSON.parse(await readFile4(resolve18(root, fixPath), "utf8"));
29974
+ parsed = JSON.parse(await readFile5(resolve19(root, fixPath), "utf8"));
29725
29975
  }
29726
29976
  const write = args.write === true;
29727
29977
  const applied = await applyDiagnosticFix(parsed, { rootDir: root, dryRun: !write });
29728
- return textResult(JSON.stringify({
29978
+ return textResult2(JSON.stringify({
29729
29979
  ok: true,
29730
29980
  source,
29731
29981
  ...source === "doctor" ? {
@@ -29770,7 +30020,7 @@ function devDatabase(profile, explicit) {
29770
30020
  }
29771
30021
  function readManifestModules(outDir) {
29772
30022
  try {
29773
- const parsed = JSON.parse(readFileSync9(join13(outDir, "app.manifest.json"), "utf8"));
30023
+ const parsed = JSON.parse(readFileSync9(join14(outDir, "app.manifest.json"), "utf8"));
29774
30024
  return Array.isArray(parsed.modules) ? parsed.modules.map((module) => module.name) : [];
29775
30025
  } catch {
29776
30026
  return [];
@@ -29804,21 +30054,21 @@ async function runAppDev(args, options) {
29804
30054
  profile: args.profile,
29805
30055
  databaseUrl: args.database_url,
29806
30056
  signal: options.signal,
29807
- onOutput: (text) => options.onDevProgress?.(textResult(args.format === "json" ? JSON.stringify({ version: 1, source: "application", output: text }) : text))
30057
+ onOutput: (text) => options.onDevProgress?.(textResult2(args.format === "json" ? JSON.stringify({ version: 1, source: "application", output: text }) : text))
29808
30058
  });
29809
- return textResult(JSON.stringify({ version: 1, ok: result.exitCode === 0, ...result }), result.exitCode !== 0);
30059
+ return textResult2(JSON.stringify({ version: 1, ok: result.exitCode === 0, ...result }), result.exitCode !== 0);
29810
30060
  }
29811
30061
  const profile = args.profile ?? "fast";
29812
30062
  if (profile !== "fast" && profile !== "integration") {
29813
30063
  throw new ScaffoldError("SCAFFOLD_OPTION_INVALID", "app dev --profile must be fast or integration");
29814
30064
  }
29815
30065
  const database = devDatabase(profile, args.database_url);
29816
- const root = resolve18(args.root || process.cwd());
30066
+ const root = resolve19(args.root || process.cwd());
29817
30067
  const loadedConfig = await loadSupacloudConfig(root);
29818
30068
  const defaults = resolveSupacloudConfig(loadedConfig, root);
29819
30069
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
29820
30070
  const include = parseInclude(args.include) ?? loadedConfig.include;
29821
- const outDir = args.out_dir ? resolve18(root, args.out_dir) : defaults.outDir;
30071
+ const outDir = args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir;
29822
30072
  const watch = args.once !== true && args.watch !== false;
29823
30073
  const compileOptions = compileOptionsFromConfig({
29824
30074
  ...loadedConfig,
@@ -29833,7 +30083,7 @@ async function runAppDev(args, options) {
29833
30083
  const artifacts = hasError ? "not-current" : "current";
29834
30084
  const notVerified = DEV_NOT_VERIFIED[profile];
29835
30085
  if (args.format === "json") {
29836
- return textResult(JSON.stringify({
30086
+ return textResult2(JSON.stringify({
29837
30087
  version: 1,
29838
30088
  ok: !hasError,
29839
30089
  profile,
@@ -29849,7 +30099,7 @@ async function runAppDev(args, options) {
29849
30099
  notVerified
29850
30100
  }, null, progress ? undefined : 2), hasError);
29851
30101
  }
29852
- return textResult([
30102
+ return textResult2([
29853
30103
  `app watch (compile-only, profile: ${profile}, watch: ${watch ? "on" : "off"}, state: ${state})`,
29854
30104
  ` root: ${root}`,
29855
30105
  ` outDir: ${outDir}`,
@@ -29904,7 +30154,7 @@ async function runAppDev(args, options) {
29904
30154
  return report(lastEvent, "stopped");
29905
30155
  }
29906
30156
  async function runCompile(args) {
29907
- const root = resolve18(args.root || process.cwd());
30157
+ const root = resolve19(args.root || process.cwd());
29908
30158
  const loadedConfig = await loadSupacloudConfig(root);
29909
30159
  const defaults = resolveSupacloudConfig(loadedConfig, root);
29910
30160
  const configuredRoot = sourceRoot(args, root, loadedConfig.root);
@@ -29913,7 +30163,7 @@ async function runCompile(args) {
29913
30163
  ...compileOptionsFromConfig({
29914
30164
  ...loadedConfig,
29915
30165
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
29916
- outDir: args.out_dir ? resolve18(root, args.out_dir) : defaults.outDir,
30166
+ outDir: args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir,
29917
30167
  ...include === undefined ? {} : { include },
29918
30168
  strict: args.strict ?? loadedConfig.strict ?? false
29919
30169
  }, root),
@@ -29921,7 +30171,7 @@ async function runCompile(args) {
29921
30171
  });
29922
30172
  const hasError = result.diagnostics.some((diagnostic) => diagnostic.severity === "error");
29923
30173
  if (args.format === "json")
29924
- return textResult(JSON.stringify({
30174
+ return textResult2(JSON.stringify({
29925
30175
  version: 1,
29926
30176
  ok: !hasError,
29927
30177
  diagnostics: result.diagnostics,
@@ -29934,10 +30184,10 @@ async function runCompile(args) {
29934
30184
  ...result.written.map((path) => ` ${path}`)
29935
30185
  ].join(`
29936
30186
  `);
29937
- return textResult(text, hasError);
30187
+ return textResult2(text, hasError);
29938
30188
  }
29939
30189
  async function runCheck(args) {
29940
- const root = resolve18(args.root || process.cwd());
30190
+ const root = resolve19(args.root || process.cwd());
29941
30191
  const database = checkAppDatabaseSources(root);
29942
30192
  const loadedConfig = await loadSupacloudConfig(root);
29943
30193
  const defaults = resolveSupacloudConfig(loadedConfig, root);
@@ -29946,7 +30196,7 @@ async function runCheck(args) {
29946
30196
  const config = compileOptionsFromConfig({
29947
30197
  ...loadedConfig,
29948
30198
  ...configuredRoot === undefined ? {} : { root: configuredRoot },
29949
- outDir: args.out_dir ? resolve18(root, args.out_dir) : defaults.outDir,
30199
+ outDir: args.out_dir ? resolve19(root, args.out_dir) : defaults.outDir,
29950
30200
  ...include === undefined ? {} : { include },
29951
30201
  strict: args.strict ?? loadedConfig.strict ?? false
29952
30202
  }, root);
@@ -29955,7 +30205,7 @@ async function runCheck(args) {
29955
30205
  const hasError = diagnosticError || result.mismatches.length > 0 || database?.ok === false;
29956
30206
  const next = hasError ? diagnosticError || database?.ok === false ? ["supacloud app doctor --format json"] : ["supacloud app compile", "supacloud app check --format json"] : ["supacloud app verify-plan --target <module>"];
29957
30207
  if (args.format === "json")
29958
- return textResult(JSON.stringify({
30208
+ return textResult2(JSON.stringify({
29959
30209
  version: 1,
29960
30210
  ok: !hasError,
29961
30211
  next,
@@ -29968,7 +30218,7 @@ async function runCheck(args) {
29968
30218
  ...database ? { database } : {}
29969
30219
  }, null, 2), hasError);
29970
30220
  const summary = `checked ${result.graph.modules.length} module(s), no files written`;
29971
- return textResult([
30221
+ return textResult2([
29972
30222
  formatDiagnostics(result.diagnostics),
29973
30223
  ...result.mismatches.map((path) => `generated artifact mismatch: ${path}`),
29974
30224
  ...database ? [formatDoctorCheck(database)] : [],
@@ -29979,12 +30229,12 @@ async function runCheck(args) {
29979
30229
  }
29980
30230
  async function readManifest(root, args) {
29981
30231
  const config = await loadSupacloudConfig(root);
29982
- const outDir = args.out_dir ? resolve18(root, args.out_dir) : resolveSupacloudConfig(config, root).outDir;
29983
- const manifestPath = join13(outDir, "app.manifest.json");
29984
- if (!existsSync11(manifestPath)) {
30232
+ const outDir = args.out_dir ? resolve19(root, args.out_dir) : resolveSupacloudConfig(config, root).outDir;
30233
+ const manifestPath = join14(outDir, "app.manifest.json");
30234
+ if (!existsSync12(manifestPath)) {
29985
30235
  throw new Error(`Manifest not found: ${manifestPath}(先运行 app compile 生成)`);
29986
30236
  }
29987
- const parsed = JSON.parse(await readFile4(manifestPath, "utf8"));
30237
+ const parsed = JSON.parse(await readFile5(manifestPath, "utf8"));
29988
30238
  if (!Array.isArray(parsed.modules)) {
29989
30239
  throw new Error(`Invalid manifest: ${manifestPath}`);
29990
30240
  }
@@ -30024,11 +30274,11 @@ function formatGraphText(manifest) {
30024
30274
  `);
30025
30275
  }
30026
30276
  async function runGraph(args) {
30027
- const root = resolve18(args.root || process.cwd());
30277
+ const root = resolve19(args.root || process.cwd());
30028
30278
  const manifest = await readManifest(root, args);
30029
30279
  if (args.format === "json")
30030
- return textResult(JSON.stringify(manifest, null, 2));
30031
- return textResult(formatGraphText(manifest));
30280
+ return textResult2(JSON.stringify(manifest, null, 2));
30281
+ return textResult2(formatGraphText(manifest));
30032
30282
  }
30033
30283
  function reverseDependencies(manifest, token) {
30034
30284
  const dependents = [];
@@ -30092,7 +30342,7 @@ async function runExplain(args) {
30092
30342
  const target = args.target?.trim();
30093
30343
  if (!target)
30094
30344
  throw new Error("app explain requires --target(provider 类名 / token 名 / command 名 / job 名)");
30095
- const root = resolve18(args.root || process.cwd());
30345
+ const root = resolve19(args.root || process.cwd());
30096
30346
  const manifest = await readManifest(root, args);
30097
30347
  for (const module of manifest.modules) {
30098
30348
  const job = module.jobs?.find((entry) => entry.name === target || entry.className === target);
@@ -30114,15 +30364,15 @@ async function runExplain(args) {
30114
30364
  lines.push(`idempotency: ${job.idempotency}`);
30115
30365
  const dependents = reverseDependencies(manifest, job.className);
30116
30366
  lines.push(`被依赖: ${dependents.length > 0 ? dependents.join(", ") : "(none)"}`);
30117
- return textResult(lines.join(`
30367
+ return textResult2(lines.join(`
30118
30368
  `));
30119
30369
  }
30120
30370
  const providerIndex = module.providers.findIndex((provider) => provider.token === target || provider.useClass === target);
30121
30371
  if (providerIndex >= 0)
30122
- return textResult(explainProvider(manifest, module, providerIndex));
30372
+ return textResult2(explainProvider(manifest, module, providerIndex));
30123
30373
  const controllerIndex = module.controllers.findIndex((controller) => controller.className === target);
30124
30374
  if (controllerIndex >= 0)
30125
- return textResult(explainController(manifest, module, controllerIndex));
30375
+ return textResult2(explainController(manifest, module, controllerIndex));
30126
30376
  const command = module.commands.find((entry) => entry.name === target || entry.className === target);
30127
30377
  if (command) {
30128
30378
  const lines = [
@@ -30141,12 +30391,12 @@ async function runExplain(args) {
30141
30391
  lines.push(`idempotency: ${command.idempotency}`);
30142
30392
  const dependents = reverseDependencies(manifest, command.className);
30143
30393
  lines.push(`被依赖: ${dependents.length > 0 ? dependents.join(", ") : "(none)"}`);
30144
- return textResult(lines.join(`
30394
+ return textResult2(lines.join(`
30145
30395
  `));
30146
30396
  }
30147
30397
  const query = module.queries.find((entry) => entry.name === target || entry.className === target);
30148
30398
  if (query) {
30149
- return textResult([
30399
+ return textResult2([
30150
30400
  `对象: ${query.name}`,
30151
30401
  "类型: query",
30152
30402
  `所属模块: ${module.name}`,
@@ -30157,28 +30407,28 @@ async function runExplain(args) {
30157
30407
  }
30158
30408
  if (manifest.externalTokens.includes(target)) {
30159
30409
  const dependents = reverseDependencies(manifest, target);
30160
- return textResult([
30410
+ return textResult2([
30161
30411
  `对象: ${target}`,
30162
30412
  "类型: externalToken(平台注入,无模块提供)",
30163
30413
  `被依赖: ${dependents.length > 0 ? dependents.join(", ") : "(none)"}`
30164
30414
  ].join(`
30165
30415
  `));
30166
30416
  }
30167
- return textResult(`未找到对象: ${target}`, true);
30417
+ return textResult2(`未找到对象: ${target}`, true);
30168
30418
  }
30169
30419
  async function runExportTools(args) {
30170
- const root = resolve18(args.root || process.cwd());
30420
+ const root = resolve19(args.root || process.cwd());
30171
30421
  const manifest = await readManifest(root, { ...args, out_dir: undefined });
30172
30422
  const definitions = buildToolDefinitions(manifest);
30173
- const outDir = resolve18(args.out_dir || join13(root, "generated"));
30423
+ const outDir = resolve19(args.out_dir || join14(root, "generated"));
30174
30424
  if (args.format === "json") {
30175
- return textResult(JSON.stringify(definitions, null, 2));
30425
+ return textResult2(JSON.stringify(definitions, null, 2));
30176
30426
  }
30177
- await mkdir5(outDir, { recursive: true });
30178
- const openaiPath = join13(outDir, "tool-definitions.openai.json");
30179
- const mcpPath = join13(outDir, "tool-definitions.mcp.json");
30180
- await writeFile4(openaiPath, JSON.stringify(definitions.openai, null, 2), "utf8");
30181
- await writeFile4(mcpPath, JSON.stringify(definitions.mcp, null, 2), "utf8");
30427
+ await mkdir6(outDir, { recursive: true });
30428
+ const openaiPath = join14(outDir, "tool-definitions.openai.json");
30429
+ const mcpPath = join14(outDir, "tool-definitions.mcp.json");
30430
+ await writeFile5(openaiPath, JSON.stringify(definitions.openai, null, 2), "utf8");
30431
+ await writeFile5(mcpPath, JSON.stringify(definitions.mcp, null, 2), "utf8");
30182
30432
  const summary = [
30183
30433
  `exported ${definitions.openai.length} tool(s):`,
30184
30434
  ` openai → ${openaiPath}`,
@@ -30188,29 +30438,29 @@ async function runExportTools(args) {
30188
30438
  `)
30189
30439
  ].join(`
30190
30440
  `);
30191
- return textResult(summary);
30441
+ return textResult2(summary);
30192
30442
  }
30193
30443
  async function runDelivery(args) {
30194
- const root = resolve18(args.root || process.cwd());
30444
+ const root = resolve19(args.root || process.cwd());
30195
30445
  if (args.action === "build") {
30196
30446
  const database = checkAppDatabaseSources(root);
30197
30447
  if (database && !database.ok) {
30198
- return textResult(JSON.stringify({ ok: false, database, written: [] }, null, 2), true);
30448
+ return textResult2(JSON.stringify({ ok: false, database, written: [] }, null, 2), true);
30199
30449
  }
30200
30450
  }
30201
30451
  const loaded = await loadSupacloudConfig(root);
30202
30452
  const options = compileOptionsFromConfig({
30203
30453
  ...loaded,
30204
- ...args.out_dir === undefined ? {} : { outDir: resolve18(root, args.out_dir) },
30454
+ ...args.out_dir === undefined ? {} : { outDir: resolve19(root, args.out_dir) },
30205
30455
  ...args.include === undefined ? {} : { include: parseInclude(args.include) },
30206
30456
  ...args.strict === undefined ? {} : { strict: args.strict }
30207
30457
  }, root);
30208
30458
  if (args.action === "plan") {
30209
30459
  const result = await planDeliveryProject(options, loaded.delivery);
30210
- return textResult(args.format === "json" ? JSON.stringify(result, null, 2) : formatDeliveryPlan(result), !result.ok);
30460
+ return textResult2(args.format === "json" ? JSON.stringify(result, null, 2) : formatDeliveryPlan(result), !result.ok);
30211
30461
  }
30212
30462
  const result = await buildDeliveryProject(options, loaded.delivery);
30213
- return textResult(JSON.stringify(result, null, 2), !result.ok);
30463
+ return textResult2(JSON.stringify(result, null, 2), !result.ok);
30214
30464
  }
30215
30465
  function resultObject(result) {
30216
30466
  try {
@@ -30250,7 +30500,7 @@ function releasePhaseFailure(phase, result, completed) {
30250
30500
  if (phaseResult?.expected_activation_id !== undefined) {
30251
30501
  payload.expected_activation_id = phaseResult.expected_activation_id;
30252
30502
  }
30253
- return textResult(JSON.stringify(payload, null, 2), true);
30503
+ return textResult2(JSON.stringify(payload, null, 2), true);
30254
30504
  }
30255
30505
  function releaseField(payload, container, field) {
30256
30506
  const value = payload?.[container];
@@ -30278,7 +30528,7 @@ async function runAppRelease(request, options, delegate) {
30278
30528
  if (request.activation_id !== undefined || request.expected_activation_id !== undefined) {
30279
30529
  throw new Error("app release generates one activation identity; use app deploy for an exact retry");
30280
30530
  }
30281
- const root = resolve18(request.root || process.cwd());
30531
+ const root = resolve19(request.root || process.cwd());
30282
30532
  const completed = {};
30283
30533
  let manifestPath;
30284
30534
  let buildReceipt;
@@ -30286,7 +30536,7 @@ async function runAppRelease(request, options, delegate) {
30286
30536
  if (request.manifest_path === undefined) {
30287
30537
  throw new Error("app release --skip_build requires --manifest_path");
30288
30538
  }
30289
- manifestPath = resolve18(root, request.manifest_path);
30539
+ manifestPath = resolve19(root, request.manifest_path);
30290
30540
  completed.build = { skipped: true, manifest_path: manifestPath };
30291
30541
  } else {
30292
30542
  const built = await runDelivery({ ...request, action: "build", root, format: "json" });
@@ -30296,7 +30546,7 @@ async function runAppRelease(request, options, delegate) {
30296
30546
  }
30297
30547
  const loaded = await loadSupacloudConfig(root);
30298
30548
  const resolved = resolveSupacloudConfig(loaded, root);
30299
- manifestPath = join13(resolved.outDir, "delivery", "delivery.manifest.json");
30549
+ manifestPath = join14(resolved.outDir, "delivery", "delivery.manifest.json");
30300
30550
  completed.build = {
30301
30551
  ok: true,
30302
30552
  manifest_path: manifestPath,
@@ -30323,7 +30573,7 @@ async function runAppRelease(request, options, delegate) {
30323
30573
  let configurationWrite;
30324
30574
  const activationId = crypto.randomUUID();
30325
30575
  if (request.configuration_path !== undefined) {
30326
- const configurationPath = resolve18(root, request.configuration_path);
30576
+ const configurationPath = resolve19(root, request.configuration_path);
30327
30577
  try {
30328
30578
  configurationWrite = parseApplicationConfigurationWrite(await Bun.file(configurationPath).json());
30329
30579
  configurationId = configurationWrite.configuration_id;
@@ -30384,7 +30634,7 @@ async function runAppRelease(request, options, delegate) {
30384
30634
  ...typeof deployReceipt.activation_id === "string" ? { activation_id: deployReceipt.activation_id } : {},
30385
30635
  ...deployReceipt.web === undefined ? {} : { web: deployReceipt.web }
30386
30636
  };
30387
- return request.format === "json" ? textResult(JSON.stringify(result, null, 2)) : textResult([
30637
+ return request.format === "json" ? textResult2(JSON.stringify(result, null, 2)) : textResult2([
30388
30638
  `${ref}/${id}/${environmentId}: ${deployReceipt.status === "accepted" ? "accepted" : result.no_op ? "no-op" : "released"}`,
30389
30639
  `Release: ${releaseId}`,
30390
30640
  `Configuration: ${configurationId}`,
@@ -30407,7 +30657,7 @@ function formatReleaseTransfer(result) {
30407
30657
  const data = plan ?? receipt;
30408
30658
  if (!data)
30409
30659
  return result;
30410
- return textResult([
30660
+ return textResult2([
30411
30661
  `${data.project_ref}/${data.application_id}: ${plan ? plan.action === "no-op" ? "No changes" : "Transfer required" : "Artifact transferred"}`,
30412
30662
  `Source: ${data.source.project_ref} / ${data.source.release_id}`,
30413
30663
  `Target release: ${data.candidate_release_id}`,
@@ -30454,7 +30704,7 @@ function historyText(result, request, projectRef) {
30454
30704
  }
30455
30705
  if (history.next_cursor)
30456
30706
  lines.push("", `Next cursor: ${history.next_cursor}`);
30457
- return textResult(lines.join(`
30707
+ return textResult2(lines.join(`
30458
30708
  `));
30459
30709
  } catch {
30460
30710
  return releaseControlFailure("applications.get_history", "INVALID_RESPONSE", null);
@@ -30474,7 +30724,7 @@ function formatRemoteDeployPlan(result) {
30474
30724
  ...names(plan.changes.targets.removed, "-"),
30475
30725
  ...names(plan.changes.targets.changed, "~")
30476
30726
  ];
30477
- return textResult([
30727
+ return textResult2([
30478
30728
  `${plan.project_ref}/${plan.application_id} [${plan.environment_id}]: ${plan.action === "no-op" ? "No changes" : "Activation required"}`,
30479
30729
  `Release: ${plan.candidate.release_id} (${plan.changes.release ? "changed" : "unchanged"})`,
30480
30730
  `Configuration: ${plan.candidate.configuration_id} (${plan.changes.configuration ? "changed" : "unchanged"})`,
@@ -30496,7 +30746,7 @@ function formatPromotionPlan2(result) {
30496
30746
  if (!payload || typeof payload !== "object" || !("plan" in payload))
30497
30747
  return result;
30498
30748
  const plan = parseApplicationPromotionPlan(payload.plan);
30499
- return textResult([
30749
+ return textResult2([
30500
30750
  `${plan.project_ref}/${plan.application_id}/${plan.environment_id}: ${plan.action}`,
30501
30751
  `Source: ${plan.source.project_ref}/${plan.source.environment_id}`,
30502
30752
  ...plan.blockers.length ? [`Blocked: ${plan.blockers.join(", ")}`] : [],
@@ -30523,7 +30773,7 @@ function formatPromotionExecution(result) {
30523
30773
  const receipt = payload.result;
30524
30774
  if (receipt.project_ref !== envelope.project_ref || receipt.application_id !== envelope.application_id || receipt.environment_id !== envelope.environment_id || receipt.mutation_id !== envelope.mutation_id || receipt.plan_sha256 !== envelope.plan_sha256)
30525
30775
  return result;
30526
- return textResult([
30776
+ return textResult2([
30527
30777
  `${String(envelope.project_ref)}/${String(envelope.application_id)}/${String(envelope.environment_id)}: promoted`,
30528
30778
  `Mutation: ${String(envelope.mutation_id)}`,
30529
30779
  `Activation: ${String(receipt.activation_id)}`,
@@ -30554,7 +30804,7 @@ function formatWorkflowObservation(result, action) {
30554
30804
  if (!data.mutation || typeof data.mutation !== "object" || !("mutation_id" in data.mutation) || typeof data.mutation.mutation_id !== "string")
30555
30805
  return result;
30556
30806
  const status = parsePromotionStatus({ ...identity, mutation: data.mutation, promotion: data.promotion }, { ...identity, mutation_id: data.mutation.mutation_id });
30557
- return textResult([
30807
+ return textResult2([
30558
30808
  `${label}: ${status.mutation.status}`,
30559
30809
  `Mutation: ${status.mutation.mutation_id}`,
30560
30810
  `Phase: ${status.promotion.phase ?? "not recorded"}`,
@@ -30564,15 +30814,21 @@ function formatWorkflowObservation(result, action) {
30564
30814
  }
30565
30815
  if (action === "preview-list" || action === "previews") {
30566
30816
  const list = parsePreviewList({ ...identity, previews: data.previews }, identity);
30567
- return textResult([
30817
+ return textResult2([
30568
30818
  `${label}: ${list.previews.length} preview(s)`,
30569
30819
  ...list.previews.map((preview) => `${preview.preview_id} ${preview.status} ${preview.resources.database_branch.branch_ref}`)
30570
30820
  ].join(`
30571
30821
  `));
30572
30822
  }
30573
- if (["preview-plan", "preview-create", "preview-status", "preview-reconcile", "preview-cleanup"].includes(action)) {
30823
+ if (action === "preview-pr") {
30824
+ const status = typeof data.status === "string" ? data.status : "unknown";
30825
+ const previewId = typeof data.preview_id === "string" ? data.preview_id : "unknown";
30826
+ return textResult2(`${label}: PR preview ${status}
30827
+ Preview: ${previewId}`);
30828
+ }
30829
+ if (["preview-plan", "preview-create", "preview-status", "preview-reconcile", "preview-cleanup", "preview-pr"].includes(action)) {
30574
30830
  const preview = parsePreviewReceipt(data.preview ?? data, identity);
30575
- return textResult([
30831
+ return textResult2([
30576
30832
  `${label}: ${preview.status}`,
30577
30833
  `Preview: ${preview.preview_id}`,
30578
30834
  `Branch: ${preview.resources.database_branch.branch_ref} (${preview.resources.database_branch.data_mode})`,
@@ -30601,16 +30857,16 @@ async function runPromotion(request, options, delegate) {
30601
30857
  try {
30602
30858
  payload = JSON.parse(planned.content[0]?.text ?? "");
30603
30859
  } catch {
30604
- return textResult("Promotion plan response was not valid JSON.", true);
30860
+ return textResult2("Promotion plan response was not valid JSON.", true);
30605
30861
  }
30606
30862
  if (!payload || typeof payload !== "object" || !("plan" in payload)) {
30607
- return textResult("Promotion plan response was invalid.", true);
30863
+ return textResult2("Promotion plan response was invalid.", true);
30608
30864
  }
30609
30865
  let plan;
30610
30866
  try {
30611
30867
  plan = parseApplicationPromotionPlan(payload.plan);
30612
30868
  } catch {
30613
- return textResult("Promotion plan failed immutable validation.", true);
30869
+ return textResult2("Promotion plan failed immutable validation.", true);
30614
30870
  }
30615
30871
  const identity = { project_ref: ref, application_id: request.id, environment_id: request.environment_id };
30616
30872
  if (plan.project_ref !== ref || plan.application_id !== request.id || plan.environment_id !== request.environment_id || plan.source.project_ref !== request.source_ref || plan.source.environment_id !== request.source_environment_id || plan.source.release_id !== request.source_release_id || request.configuration_id !== undefined && plan.target.configuration_id !== request.configuration_id) {
@@ -30625,14 +30881,14 @@ async function runPromotion(request, options, delegate) {
30625
30881
  no_op: true,
30626
30882
  execution_performed: false
30627
30883
  });
30628
- return format === "json" ? noOp : textResult(`${plan.project_ref}/${plan.application_id}/${plan.environment_id}: no-op
30884
+ return format === "json" ? noOp : textResult2(`${plan.project_ref}/${plan.application_id}/${plan.environment_id}: no-op
30629
30885
  Execution: skipped`);
30630
30886
  }
30631
30887
  if (plan.blockers.some((code) => !["MIGRATION_PENDING", "BACKUP_REQUIRED"].includes(code))) {
30632
30888
  return releaseControlFailure("applications.promote_application", "MUTATION_NOT_SUCCEEDED", null, { ...identity, plan, execution_performed: false });
30633
30889
  }
30634
30890
  if (!plan.target.configuration_id)
30635
- return textResult("Promotion plan has no target configuration revision.", true);
30891
+ return textResult2("Promotion plan has no target configuration revision.", true);
30636
30892
  const mutationId = crypto.randomUUID();
30637
30893
  const executeArgs = {
30638
30894
  ...remoteRequest,
@@ -30664,19 +30920,19 @@ async function runAppTool(request, options = {}) {
30664
30920
  if (request.action === "promote") {
30665
30921
  const delegate = options.getApplications?.();
30666
30922
  if (!delegate)
30667
- return textResult("App remote actions require a Management API context.", true);
30923
+ return textResult2("App remote actions require a Management API context.", true);
30668
30924
  return runPromotion(request, options, delegate);
30669
30925
  }
30670
30926
  if (request.action === "release") {
30671
30927
  const delegate = options.getApplications?.();
30672
30928
  if (!delegate)
30673
- return textResult("App remote actions require a Management API context.", true);
30929
+ return textResult2("App remote actions require a Management API context.", true);
30674
30930
  return runAppRelease(request, options, delegate);
30675
30931
  }
30676
30932
  if (Object.hasOwn(REMOTE_APP_ACTIONS, request.action)) {
30677
30933
  const delegate = options.getApplications?.();
30678
30934
  if (!delegate)
30679
- return textResult("App remote actions require a Management API context.", true);
30935
+ return textResult2("App remote actions require a Management API context.", true);
30680
30936
  const promotionDiff = request.action === "diff" && request.source_ref !== undefined && request.source_environment_id !== undefined && request.source_release_id !== undefined;
30681
30937
  const action = promotionDiff ? "get_promotion_plan" : REMOTE_APP_ACTIONS[request.action];
30682
30938
  const { format, ...remoteRequest } = request;
@@ -30693,13 +30949,13 @@ async function runAppTool(request, options = {}) {
30693
30949
  if (payload === null || typeof payload !== "object" || !("project_ref" in payload) || payload.project_ref !== args.ref || !("application_id" in payload) || payload.application_id !== request.id || !("environment_id" in payload) || payload.environment_id !== request.environment_id || !("evidence" in payload))
30694
30950
  throw new Error;
30695
30951
  if (payload.evidence === null)
30696
- return textResult("DEPLOYMENT incomplete: no recorded evidence. Read runtime status and obtain authenticated smoke and recovery evidence.");
30952
+ return textResult2("DEPLOYMENT incomplete: no recorded evidence. Read runtime status and obtain authenticated smoke and recovery evidence.");
30697
30953
  const evidence = parseDeploymentEvidence(payload.evidence);
30698
30954
  if (evidence.scope.project_ref !== args.ref || evidence.scope.application_id !== request.id || evidence.scope.environment_id !== request.environment_id)
30699
30955
  throw new Error;
30700
- return textResult(formatDeploymentEvidence(evidence));
30956
+ return textResult2(formatDeploymentEvidence(evidence));
30701
30957
  } catch {
30702
- return textResult("DEPLOYMENT unknown: invalid or mismatched evidence; no mutation was attempted.", true);
30958
+ return textResult2("DEPLOYMENT unknown: invalid or mismatched evidence; no mutation was attempted.", true);
30703
30959
  }
30704
30960
  }
30705
30961
  if (request.action === "history" && format !== "json") {
@@ -30721,7 +30977,7 @@ async function runAppTool(request, options = {}) {
30721
30977
  const { root, sourceDir, result } = await projectCompileConfig(request);
30722
30978
  const plan = await createVerificationPlan(root, result.graph, request.target.trim(), sourceDir);
30723
30979
  const ready = plan.ready && !result.diagnostics.some((item) => item.severity === "error");
30724
- return textResult(JSON.stringify({ ...plan, ready, diagnostics: result.diagnostics }, null, 2), !ready);
30980
+ return textResult2(JSON.stringify({ ...plan, ready, diagnostics: result.diagnostics }, null, 2), !ready);
30725
30981
  }
30726
30982
  case "dev":
30727
30983
  case "watch":
@@ -30737,7 +30993,7 @@ async function runAppTool(request, options = {}) {
30737
30993
  } catch (error) {
30738
30994
  if (request.format !== "json")
30739
30995
  throw error;
30740
- return textResult(JSON.stringify({
30996
+ return textResult2(JSON.stringify({
30741
30997
  version: 1,
30742
30998
  ok: false,
30743
30999
  code: error instanceof ScaffoldError ? error.code : "SCAFFOLD_FAILED",
@@ -30764,7 +31020,7 @@ async function runAppTool(request, options = {}) {
30764
31020
  case "fix":
30765
31021
  return runFix(request);
30766
31022
  default:
30767
- return textResult(`Unknown app action: ${String(request.action)}`, true);
31023
+ return textResult2(`Unknown app action: ${String(request.action)}`, true);
30768
31024
  }
30769
31025
  }
30770
31026
  function registerAppTools(server, options = {}) {
@@ -30811,6 +31067,7 @@ function registerAppTools(server, options = {}) {
30811
31067
  "preview-create",
30812
31068
  "preview-status",
30813
31069
  "preview-cleanup",
31070
+ "preview-pr",
30814
31071
  "preview-reconcile",
30815
31072
  "promote",
30816
31073
  "promote-status",
@@ -30852,8 +31109,8 @@ function registerAppTools(server, options = {}) {
30852
31109
  }
30853
31110
 
30854
31111
  // src/shared/tools/db-governance-tools.ts
30855
- import { existsSync as existsSync13 } from "node:fs";
30856
- import { join as join16, resolve as resolve21 } from "node:path";
31112
+ import { existsSync as existsSync14 } from "node:fs";
31113
+ import { join as join17, resolve as resolve22 } from "node:path";
30857
31114
  import {
30858
31115
  buildDatabaseManifest,
30859
31116
  explainObject,
@@ -30865,9 +31122,9 @@ import { databaseSources } from "@supacloud/db/source-contracts";
30865
31122
 
30866
31123
  // src/shared/tools/db-workflow.ts
30867
31124
  import { createHash as createHash9 } from "node:crypto";
30868
- import { lstat as lstat4, mkdir as mkdir6, mkdtemp, readFile as readFile5, readdir as readdir6, rename as rename3, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
31125
+ 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";
30869
31126
  import { tmpdir as tmpdir2 } from "node:os";
30870
- import { dirname as dirname11, isAbsolute as isAbsolute7, join as join15, relative as relative8, resolve as resolve20 } from "node:path";
31127
+ import { dirname as dirname11, isAbsolute as isAbsolute7, join as join16, relative as relative8, resolve as resolve21 } from "node:path";
30871
31128
  import {
30872
31129
  assertApplicationRoleRestricted,
30873
31130
  readDatabaseRole,
@@ -30878,8 +31135,8 @@ import {
30878
31135
  import { parseDatabaseSourcesConfig } from "@supacloud/db/source-contracts";
30879
31136
 
30880
31137
  // src/shared/tools/supabase-cli-tools.ts
30881
- import { chmodSync as chmodSync2, existsSync as existsSync12, mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync3 } from "node:fs";
30882
- import { dirname as dirname10, isAbsolute as isAbsolute6, join as join14, resolve as resolve19 } from "node:path";
31138
+ import { chmodSync as chmodSync2, existsSync as existsSync13, mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync3 } from "node:fs";
31139
+ import { dirname as dirname10, isAbsolute as isAbsolute6, join as join15, resolve as resolve20 } from "node:path";
30883
31140
  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;
30884
31141
  var VALID_VERSION2 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
30885
31142
  var VALID_MIGRATION_NAME2 = /^[A-Za-z0-9][A-Za-z0-9_-]{0,100}$/;
@@ -30939,12 +31196,12 @@ function schemaArguments2(schema) {
30939
31196
  function workdirArguments2(workdir) {
30940
31197
  if (!workdir)
30941
31198
  throw new Error("A workdir is required");
30942
- return ["--workdir", resolve19(workdir)];
31199
+ return ["--workdir", resolve20(workdir)];
30943
31200
  }
30944
31201
  function resolveOutputPath2(workdir, file, label) {
30945
31202
  if (!file || /[\r\n\0]/.test(file))
30946
31203
  throw new Error(`${label} file is required`);
30947
- return isAbsolute6(file) ? resolve19(file) : resolve19(workdir, file);
31204
+ return isAbsolute6(file) ? resolve20(file) : resolve20(workdir, file);
30948
31205
  }
30949
31206
  function databaseTargetArguments2(databaseUrl) {
30950
31207
  return databaseUrl ? ["--db-url", requirePostgresUrl2(databaseUrl)] : ["--local"];
@@ -31119,7 +31376,7 @@ function actionArguments2(request, workdir) {
31119
31376
  function buildOfficialSupabaseArgs2(request) {
31120
31377
  if (request.action === "version")
31121
31378
  return ["--version"];
31122
- const workdir = request.workdir ? resolve19(request.workdir) : undefined;
31379
+ const workdir = request.workdir ? resolve20(request.workdir) : undefined;
31123
31380
  if (!workdir)
31124
31381
  throw new Error("A workdir is required");
31125
31382
  return [...actionArguments2(request, workdir), ...workdirArguments2(workdir)];
@@ -31161,8 +31418,8 @@ function resolveOfficialSupabaseCommand2(workdir, environment = process.env) {
31161
31418
  }
31162
31419
  return ["npx", "--yes", `supabase@${version}`];
31163
31420
  }
31164
- const localPackageEntry = join14(resolve19(workdir), "node_modules", "supabase", "dist", "supabase.js");
31165
- if (existsSync12(localPackageEntry))
31421
+ const localPackageEntry = join15(resolve20(workdir), "node_modules", "supabase", "dist", "supabase.js");
31422
+ if (existsSync13(localPackageEntry))
31166
31423
  return [process.execPath, localPackageEntry];
31167
31424
  return ["supabase"];
31168
31425
  }
@@ -31180,7 +31437,7 @@ async function projectPath2(root, path) {
31180
31437
  }
31181
31438
  let current = root;
31182
31439
  for (const part of path.split("/")) {
31183
- current = join15(current, part);
31440
+ current = join16(current, part);
31184
31441
  try {
31185
31442
  if ((await lstat4(current)).isSymbolicLink())
31186
31443
  throw new Error("Symlink workflow paths are forbidden");
@@ -31202,8 +31459,8 @@ async function exists2(path) {
31202
31459
  }
31203
31460
  }
31204
31461
  async function boundary(root) {
31205
- const config = join15(root, "database.sources.json");
31206
- return await exists2(config) ? parseDatabaseSourcesConfig(JSON.parse(await readFile5(await projectPath2(root, "database.sources.json"), "utf8"))) : undefined;
31462
+ const config = join16(root, "database.sources.json");
31463
+ return await exists2(config) ? parseDatabaseSourcesConfig(JSON.parse(await readFile6(await projectPath2(root, "database.sources.json"), "utf8"))) : undefined;
31207
31464
  }
31208
31465
  var overlaps = (a, b) => a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
31209
31466
  async function candidatePath(root, path) {
@@ -31296,9 +31553,9 @@ async function runOfficial(root, workdir, args, environment, options) {
31296
31553
  async function initializeCandidate(stage, majorVersion = 18) {
31297
31554
  if (![15, 16, 17, 18].includes(majorVersion))
31298
31555
  throw new Error("Select a supported PostgreSQL major version (15-18)");
31299
- await mkdir6(join15(stage, "supabase/migrations"), { recursive: true });
31300
- await mkdir6(join15(stage, "supabase/schemas"), { recursive: true });
31301
- await writeFile5(join15(stage, "supabase/config.toml"), [
31556
+ await mkdir7(join16(stage, "supabase/migrations"), { recursive: true });
31557
+ await mkdir7(join16(stage, "supabase/schemas"), { recursive: true });
31558
+ await writeFile6(join16(stage, "supabase/config.toml"), [
31302
31559
  `project_id = "supacloud-candidate-${hash4(stage).slice(0, 12)}"`,
31303
31560
  "[db]",
31304
31561
  `major_version = ${majorVersion}`,
@@ -31311,14 +31568,14 @@ async function initializeCandidate(stage, majorVersion = 18) {
31311
31568
  async function copySqlSources(root, source, destination) {
31312
31569
  const path = await projectPath2(root, source);
31313
31570
  let count = 0;
31314
- await mkdir6(destination, { recursive: true });
31571
+ await mkdir7(destination, { recursive: true });
31315
31572
  for (const name of (await readdir6(path)).sort()) {
31316
31573
  const file = await projectPath2(root, `${source}/${name}`);
31317
31574
  const state = await lstat4(file);
31318
31575
  if (state.isDirectory())
31319
- count += await copySqlSources(root, `${source}/${name}`, join15(destination, name));
31576
+ count += await copySqlSources(root, `${source}/${name}`, join16(destination, name));
31320
31577
  else if (state.isFile() && name.endsWith(".sql")) {
31321
- await writeFile5(join15(destination, name), await readFile5(file));
31578
+ await writeFile6(join16(destination, name), await readFile6(file));
31322
31579
  count++;
31323
31580
  }
31324
31581
  }
@@ -31332,8 +31589,8 @@ async function reverse(args, root, options) {
31332
31589
  if (!selectedSchemas.length || selectedSchemas.some((schema) => !/^[a-z_][a-z0-9_$]*$/i.test(schema))) {
31333
31590
  throw new Error("Select valid PostgreSQL schemas");
31334
31591
  }
31335
- await mkdir6(dirname11(out), { recursive: true });
31336
- const stage = await mkdtemp(join15(dirname11(out), ".reverse-"));
31592
+ await mkdir7(dirname11(out), { recursive: true });
31593
+ const stage = await mkdtemp(join16(dirname11(out), ".reverse-"));
31337
31594
  try {
31338
31595
  const snapshot = await withDatabase(args, options, async (executor, url) => {
31339
31596
  const snapshot = await reverseDatabase(executor, selectedSchemas);
@@ -31349,10 +31606,10 @@ async function reverse(args, root, options) {
31349
31606
  }, options.environment ?? process.env, options);
31350
31607
  return snapshot;
31351
31608
  });
31352
- const generated = await readdir6(join15(stage, "supabase/schemas"), { recursive: true });
31609
+ const generated = await readdir6(join16(stage, "supabase/schemas"), { recursive: true });
31353
31610
  if (!generated.some((file) => file.endsWith(".sql")))
31354
31611
  throw new Error("Official reverse did not produce declarative SQL");
31355
- await writeFile5(join15(stage, "catalog.json"), renderReverseSnapshot(snapshot));
31612
+ await writeFile6(join16(stage, "catalog.json"), renderReverseSnapshot(snapshot));
31356
31613
  await rename3(stage, out);
31357
31614
  return result({
31358
31615
  ok: true,
@@ -31377,14 +31634,14 @@ async function diff2(args, root, options) {
31377
31634
  const input = await migrations(root, args.dir ?? (await boundary(root))?.migrations ?? "supabase/migrations");
31378
31635
  if (overlaps(input.dir, out))
31379
31636
  throw new Error("Candidate output overlaps reviewed migration history");
31380
- await mkdir6(dirname11(out), { recursive: true });
31381
- const stage = await mkdtemp(join15(dirname11(out), ".diff-"));
31637
+ await mkdir7(dirname11(out), { recursive: true });
31638
+ const stage = await mkdtemp(join16(dirname11(out), ".diff-"));
31382
31639
  try {
31383
31640
  await initializeCandidate(stage, args.db_major_version);
31384
- if (!await copySqlSources(root, sourcePath, join15(stage, "supabase/schemas")))
31641
+ if (!await copySqlSources(root, sourcePath, join16(stage, "supabase/schemas")))
31385
31642
  throw new Error("No declarative SQL sources");
31386
31643
  for (const { file, text } of input.files)
31387
- await writeFile5(join15(stage, "supabase/migrations", file), text);
31644
+ await writeFile6(join16(stage, "supabase/migrations", file), text);
31388
31645
  await runOfficial(root, stage, {
31389
31646
  action: "db_schema_declarative_sync",
31390
31647
  apply: false,
@@ -31394,15 +31651,15 @@ async function diff2(args, root, options) {
31394
31651
  }, options.environment ?? process.env, options);
31395
31652
  const history = new Map(input.files.map((file) => [file.file, file.text]));
31396
31653
  for (const [file, text] of history) {
31397
- if (await readFile5(join15(stage, "supabase/migrations", file), "utf8") !== text) {
31654
+ if (await readFile6(join16(stage, "supabase/migrations", file), "utf8") !== text) {
31398
31655
  throw new Error("Official diff changed reviewed migration history");
31399
31656
  }
31400
31657
  }
31401
- const names = (await readdir6(join15(stage, "supabase/migrations"))).filter((file) => file.endsWith(".sql") && !history.has(file));
31402
- const candidates = join15(stage, "candidates");
31403
- await mkdir6(candidates);
31658
+ const names = (await readdir6(join16(stage, "supabase/migrations"))).filter((file) => file.endsWith(".sql") && !history.has(file));
31659
+ const candidates = join16(stage, "candidates");
31660
+ await mkdir7(candidates);
31404
31661
  for (const file of names)
31405
- await writeFile5(join15(candidates, file), await readFile5(join15(stage, "supabase/migrations", file)));
31662
+ await writeFile6(join16(candidates, file), await readFile6(join16(stage, "supabase/migrations", file)));
31406
31663
  await rename3(candidates, out);
31407
31664
  } finally {
31408
31665
  await rm2(stage, { force: true, recursive: true });
@@ -31426,7 +31683,7 @@ async function migrations(root, path) {
31426
31683
  throw new Error("No forward migration files");
31427
31684
  const files = [];
31428
31685
  for (const file of names) {
31429
- const text = await readFile5(await projectPath2(root, `${path}/${file}`), "utf8");
31686
+ const text = await readFile6(await projectPath2(root, `${path}/${file}`), "utf8");
31430
31687
  files.push({ file, text, sha256: hash4(text) });
31431
31688
  }
31432
31689
  return { dir, files };
@@ -31440,10 +31697,10 @@ async function migrationAction(args, root, options) {
31440
31697
  throw new Error("Select a Management API and project ref");
31441
31698
  const path = args.dir ?? (await boundary(root))?.migrations ?? "supabase/migrations";
31442
31699
  const input = await migrations(root, path);
31443
- const stage = await mkdtemp(join15(tmpdir2(), "supacloud-reviewed-migrations-"));
31700
+ const stage = await mkdtemp(join16(tmpdir2(), "supacloud-reviewed-migrations-"));
31444
31701
  try {
31445
31702
  for (const { file, text } of input.files)
31446
- await writeFile5(join15(stage, file), text);
31703
+ await writeFile6(join16(stage, file), text);
31447
31704
  const preview = await run({ action: "push_migrations", ref, dir: stage, dry_run: true, strict: true });
31448
31705
  const dryRun = {
31449
31706
  isError: preview.isError === true,
@@ -31470,7 +31727,7 @@ async function migrationAction(args, root, options) {
31470
31727
  }
31471
31728
  }
31472
31729
  async function runDbWorkflow(args, projectRoot, options = {}) {
31473
- const root = resolve20(projectRoot);
31730
+ const root = resolve21(projectRoot);
31474
31731
  if ((await lstat4(root)).isSymbolicLink())
31475
31732
  throw new Error("Workflow root must not be a symlink");
31476
31733
  switch (args.action) {
@@ -31513,7 +31770,7 @@ async function runDbWorkflow(args, projectRoot, options = {}) {
31513
31770
  }
31514
31771
 
31515
31772
  // src/shared/tools/db-governance-tools.ts
31516
- function textResult2(text, isError = false) {
31773
+ function textResult3(text, isError = false) {
31517
31774
  return { isError, content: [{ type: "text", text }] };
31518
31775
  }
31519
31776
  function normalizeModule(candidate, sourcePath) {
@@ -31531,8 +31788,8 @@ function normalizeModule(candidate, sourcePath) {
31531
31788
  };
31532
31789
  }
31533
31790
  async function loadDatabaseModules(root, moduleFile) {
31534
- const filePath = moduleFile ? resolve21(root, moduleFile) : join16(root, "db", "modules.ts");
31535
- if (!existsSync13(filePath)) {
31791
+ const filePath = moduleFile ? resolve22(root, moduleFile) : join17(root, "db", "modules.ts");
31792
+ if (!existsSync14(filePath)) {
31536
31793
  throw new Error(moduleFile ? `Module file not found: ${filePath}` : `Module file not found: ${filePath}(用 --module_file 指定一个导出 defineDatabaseModule(...) 的文件)`);
31537
31794
  }
31538
31795
  let imported;
@@ -31621,7 +31878,7 @@ function buildDatabaseAiContext(modules, root, moduleName, target) {
31621
31878
  const objects = target ? allObjects.filter((object) => objectMatchesTarget(object, target)) : allObjects;
31622
31879
  if (target && objects.length === 0)
31623
31880
  throw new Error(`未找到数据库对象: ${target}`);
31624
- const sqlFirst = !existsSync13(join16(root, "zenstack/schema.zmodel")) && existsSync13(join16(root, "supabase/schemas"));
31881
+ const sqlFirst = !existsSync14(join17(root, "zenstack/schema.zmodel")) && existsSync14(join17(root, "supabase/schemas"));
31625
31882
  return {
31626
31883
  version: 1,
31627
31884
  scope: "database-ai-context",
@@ -31668,7 +31925,7 @@ async function collectLintIssues(args, root) {
31668
31925
  const issues = [];
31669
31926
  for (const module of selected) {
31670
31927
  const readSqlFile = async (path) => {
31671
- const absolute = resolve21(root, path);
31928
+ const absolute = resolve22(root, path);
31672
31929
  try {
31673
31930
  return await Bun.file(absolute).text();
31674
31931
  } catch (error) {
@@ -31686,13 +31943,13 @@ async function runLint(args, root) {
31686
31943
  const header = `linted ${selected.length} module(s): ${selected.map((module) => module.name).join(", ")}`;
31687
31944
  const body = issues.length > 0 ? issues.map(formatLintIssue).join(`
31688
31945
  `) : "no issues";
31689
- return textResult2(`${header}
31946
+ return textResult3(`${header}
31690
31947
  ${body}`, hasError);
31691
31948
  }
31692
31949
  async function runCheck2(args, root, environment, spawn, liteBinary, options) {
31693
31950
  const checks = [];
31694
31951
  let ok = true;
31695
- if (existsSync13(join16(root, "database.sources.json"))) {
31952
+ if (existsSync14(join17(root, "database.sources.json"))) {
31696
31953
  try {
31697
31954
  const source = await databaseSources(root, "check");
31698
31955
  checks.push({ name: "source-contract", ok: source.ok, findings: source.findings });
@@ -31705,8 +31962,8 @@ async function runCheck2(args, root, environment, spawn, liteBinary, options) {
31705
31962
  } else {
31706
31963
  checks.push({ name: "source-contract", skipped: true, reason: "database.sources.json not found" });
31707
31964
  }
31708
- const modulePath = args.module_file ? resolve21(root, args.module_file) : join16(root, "db/modules.ts");
31709
- if (existsSync13(modulePath)) {
31965
+ const modulePath = args.module_file ? resolve22(root, args.module_file) : join17(root, "db/modules.ts");
31966
+ if (existsSync14(modulePath)) {
31710
31967
  try {
31711
31968
  const { selected, issues } = await collectLintIssues(args, root);
31712
31969
  const lintOk = !issues.some((issue) => issue.severity === "error");
@@ -31744,7 +32001,7 @@ async function runCheck2(args, root, environment, spawn, liteBinary, options) {
31744
32001
  } else {
31745
32002
  checks.push({ name: "catalog", skipped: true, reason: "no --database_url, DATABASE_URL, --lite or --remote" });
31746
32003
  }
31747
- return textResult2(JSON.stringify({
32004
+ return textResult3(JSON.stringify({
31748
32005
  version: 1,
31749
32006
  scope: "database-check",
31750
32007
  root,
@@ -31759,11 +32016,11 @@ async function runExplain2(args, root) {
31759
32016
  const modules = await loadDatabaseModules(root, args.module_file);
31760
32017
  const manifest = buildDatabaseManifest(modules);
31761
32018
  const text = explainObject(manifest, target);
31762
- return textResult2(text, text.startsWith("未找到对象"));
32019
+ return textResult3(text, text.startsWith("未找到对象"));
31763
32020
  }
31764
32021
  async function runContext2(args, root) {
31765
32022
  const modules = await loadDatabaseModules(root, args.module_file);
31766
- return textResult2(JSON.stringify(buildDatabaseAiContext(modules, root, args.module, args.target), null, 2));
32023
+ return textResult3(JSON.stringify(buildDatabaseAiContext(modules, root, args.module, args.target), null, 2));
31767
32024
  }
31768
32025
  var defaultLiteSpawn = async (command, cwd) => {
31769
32026
  const proc = Bun.spawn({ cmd: command, cwd, stdout: "pipe", stderr: "pipe" });
@@ -31775,18 +32032,18 @@ var defaultLiteSpawn = async (command, cwd) => {
31775
32032
  return { exitCode, stdout, stderr };
31776
32033
  };
31777
32034
  async function runModuleCheckLite(args, root, spawn, liteBinary) {
31778
- const projectDir = resolve21(args.project_dir?.trim() || root);
32035
+ const projectDir = resolve22(args.project_dir?.trim() || root);
31779
32036
  const binary = liteBinary === undefined ? Bun.which("supacloud-lite") : liteBinary;
31780
32037
  if (!binary) {
31781
32038
  throw new Error("db module_check --lite 需要本机可用的 supacloud-lite(npm i -g @supacloud/lite,或加入 PATH)");
31782
32039
  }
31783
32040
  const command = [binary, "db", "check", "--project-dir", projectDir];
31784
32041
  if (args.module_file?.trim())
31785
- command.push("--module-file", resolve21(root, args.module_file.trim()));
32042
+ command.push("--module-file", resolve22(root, args.module_file.trim()));
31786
32043
  const result = await spawn(command, projectDir);
31787
32044
  const output = [result.stdout.trim(), result.stderr.trim()].filter(Boolean).join(`
31788
32045
  `);
31789
- return textResult2(output || "lite db check 无输出", result.exitCode !== 0);
32046
+ return textResult3(output || "lite db check 无输出", result.exitCode !== 0);
31790
32047
  }
31791
32048
  function remoteModuleManifest(modules) {
31792
32049
  return modules.map((module) => ({
@@ -31868,7 +32125,7 @@ async function runModuleCheckAction(args, root, environment, spawn, liteBinary,
31868
32125
  reports.push(await runModuleCheck(module, executor, schemas));
31869
32126
  }
31870
32127
  const hasError = reports.some((report) => !report.ok);
31871
- return textResult2(reports.map(formatReconcileReport).join(`
32128
+ return textResult3(reports.map(formatReconcileReport).join(`
31872
32129
  `), hasError);
31873
32130
  } catch (error) {
31874
32131
  const message = error instanceof Error ? error.message : String(error);
@@ -31902,7 +32159,7 @@ function registerDbGovernanceTools(server, options = {}) {
31902
32159
  migration_role: optional(String2(), "[role_sql] Privileged migration role"),
31903
32160
  database: optional(String2(), "[role_sql] PostgreSQL database name")
31904
32161
  }, async (request) => {
31905
- const root = resolve21(request.root || fallbackRoot);
32162
+ const root = resolve22(request.root || fallbackRoot);
31906
32163
  switch (request.action) {
31907
32164
  case "context":
31908
32165
  return runContext2(request, root);
@@ -31935,7 +32192,7 @@ function registerDbGovernanceTools(server, options = {}) {
31935
32192
  runDatabase: options.runDatabase
31936
32193
  });
31937
32194
  default:
31938
- return textResult2(`Unknown db action: ${String(request.action)}`, true);
32195
+ return textResult3(`Unknown db action: ${String(request.action)}`, true);
31939
32196
  }
31940
32197
  });
31941
32198
  }
@@ -31943,7 +32200,7 @@ function registerDbGovernanceTools(server, options = {}) {
31943
32200
  // src/shared/tools/scheduled-function-tools.ts
31944
32201
  import { randomUUID as randomUUID3 } from "node:crypto";
31945
32202
  import { readFileSync as readFileSync10, statSync as statSync9 } from "node:fs";
31946
- import { resolve as resolve22 } from "node:path";
32203
+ import { resolve as resolve23 } from "node:path";
31947
32204
  import { isDeepStrictEqual } from "node:util";
31948
32205
  var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;
31949
32206
  var ENVIRONMENT_NAME_PATTERN3 = /^[A-Za-z_][A-Za-z0-9_]{0,255}$/;
@@ -32027,7 +32284,7 @@ function validScheduledFunctionCron(expression) {
32027
32284
  function readScheduleBodyFile(bodyPathInput) {
32028
32285
  if (!bodyPathInput.trim())
32029
32286
  throw new Error("'body_file' must be a path");
32030
- const bodyPath = resolve22(bodyPathInput);
32287
+ const bodyPath = resolve23(bodyPathInput);
32031
32288
  const bodyStat = statSync9(bodyPath);
32032
32289
  if (!bodyStat.isFile() || bodyStat.size > MAX_BODY_FILE_BYTES) {
32033
32290
  throw new Error("Scheduled Function body file must be a regular file no larger than 1 MiB");
@@ -32411,8 +32668,8 @@ var MUTATION_TOOL_SCHEMA = {
32411
32668
 
32412
32669
  // src/shared/tools/release-tools.ts
32413
32670
  import { createHash as createHash10 } from "node:crypto";
32414
- import { existsSync as existsSync14, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "node:fs";
32415
- import { dirname as dirname12, join as join17, relative as relative9, resolve as resolve23 } from "node:path";
32671
+ import { existsSync as existsSync15, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "node:fs";
32672
+ import { dirname as dirname12, join as join18, relative as relative9, resolve as resolve24 } from "node:path";
32416
32673
  var SAFE_PROJECT_REF = /^[A-Za-z0-9_-]{1,64}$/;
32417
32674
  var SAFE_ENVIRONMENT_ID = /^[A-Za-z0-9_-]{1,64}$/;
32418
32675
  var BACKUP_ID = /^logical-full_[A-Za-z0-9_-]{1,64}_[a-f0-9]{32}$/;
@@ -32734,15 +32991,15 @@ function collectScopeFiles(cwd, file, files, dir, task) {
32734
32991
  const results = [];
32735
32992
  const resolvePathWithFallbacks = (filePath) => {
32736
32993
  const trimmed = filePath.trim();
32737
- const resolved = resolve23(cwd, trimmed);
32738
- if (existsSync14(resolved))
32994
+ const resolved = resolve24(cwd, trimmed);
32995
+ if (existsSync15(resolved))
32739
32996
  return resolved;
32740
32997
  const candidates = [
32741
- resolve23(cwd, "supacloud/fa/release-scopes", trimmed),
32742
- resolve23(cwd, "release-scopes", trimmed),
32743
- resolve23(cwd, "scopes", trimmed)
32998
+ resolve24(cwd, "supacloud/fa/release-scopes", trimmed),
32999
+ resolve24(cwd, "release-scopes", trimmed),
33000
+ resolve24(cwd, "scopes", trimmed)
32744
33001
  ];
32745
- const found = candidates.find(existsSync14);
33002
+ const found = candidates.find(existsSync15);
32746
33003
  if (found)
32747
33004
  return found;
32748
33005
  throw new Error(`Scope file not found: ${filePath}`);
@@ -32763,18 +33020,18 @@ function collectScopeFiles(cwd, file, files, dir, task) {
32763
33020
  if (!taskFilter && (!dir || typeof dir !== "string" || !dir.trim())) {
32764
33021
  throw new Error("At least one of --file, --files, or --task is required for scope_rebind");
32765
33022
  }
32766
- const candidates = typeof dir === "string" && dir.trim() ? [resolve23(cwd, dir.trim())] : [
32767
- resolve23(cwd, "supacloud/fa/release-scopes"),
32768
- resolve23(cwd, "release-scopes"),
32769
- resolve23(cwd, "scopes")
33023
+ const candidates = typeof dir === "string" && dir.trim() ? [resolve24(cwd, dir.trim())] : [
33024
+ resolve24(cwd, "supacloud/fa/release-scopes"),
33025
+ resolve24(cwd, "release-scopes"),
33026
+ resolve24(cwd, "scopes")
32770
33027
  ];
32771
33028
  for (const directory of candidates) {
32772
- if (existsSync14(directory)) {
33029
+ if (existsSync15(directory)) {
32773
33030
  try {
32774
33031
  const entries = readdirSync5(directory, { withFileTypes: true });
32775
33032
  for (const entry of entries) {
32776
33033
  if (entry.isFile() && entry.name.endsWith(".json")) {
32777
- const fullPath = join17(directory, entry.name);
33034
+ const fullPath = join18(directory, entry.name);
32778
33035
  if (!taskFilter) {
32779
33036
  results.push(fullPath);
32780
33037
  } else if (entry.name.toLowerCase().includes(taskFilter)) {
@@ -32800,7 +33057,7 @@ function collectScopeFiles(cwd, file, files, dir, task) {
32800
33057
  return [...new Set(results)];
32801
33058
  }
32802
33059
  function handleScopeRebind(args) {
32803
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve23(args.cwd.trim()) : process.cwd();
33060
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
32804
33061
  const targetBaseCommit = resolveGitBaseCommit(cwd, args.base_commit);
32805
33062
  const requestedEnvironmentId = requestedScopeEnvironment(args, "scope_rebind");
32806
33063
  const scopeFiles = collectScopeFiles(cwd, args.file, args.files, args.dir, args.task);
@@ -32858,20 +33115,20 @@ function handleScopeRebind(args) {
32858
33115
  });
32859
33116
  }
32860
33117
  function handleScopeInspect(args) {
32861
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve23(args.cwd.trim()) : process.cwd();
33118
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
32862
33119
  const requestedEnvironmentId = requestedScopeEnvironment(args, "scope_inspect");
32863
33120
  if (typeof args.file !== "string" || !args.file.trim()) {
32864
33121
  throw new Error("'file' is required for scope_inspect");
32865
33122
  }
32866
33123
  const trimmed = args.file.trim();
32867
- let filePath = resolve23(cwd, trimmed);
32868
- if (!existsSync14(filePath)) {
33124
+ let filePath = resolve24(cwd, trimmed);
33125
+ if (!existsSync15(filePath)) {
32869
33126
  const candidates = [
32870
- resolve23(cwd, "supacloud/fa/release-scopes", trimmed),
32871
- resolve23(cwd, "release-scopes", trimmed),
32872
- resolve23(cwd, "scopes", trimmed)
33127
+ resolve24(cwd, "supacloud/fa/release-scopes", trimmed),
33128
+ resolve24(cwd, "release-scopes", trimmed),
33129
+ resolve24(cwd, "scopes", trimmed)
32873
33130
  ];
32874
- const found = candidates.find(existsSync14);
33131
+ const found = candidates.find(existsSync15);
32875
33132
  if (found)
32876
33133
  filePath = found;
32877
33134
  else
@@ -32931,15 +33188,15 @@ function releaseComponentView(component) {
32931
33188
  return { kind: component.kind, artifact_sha256: component.artifactSha256 };
32932
33189
  }
32933
33190
  function handleContractPlan(args, fallbackRef) {
32934
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve23(args.cwd.trim()) : process.cwd();
33191
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
32935
33192
  const requestedRef = typeof args.ref === "string" && args.ref.trim() || fallbackRef;
32936
33193
  if (!requestedRef || !validProjectRef(requestedRef)) {
32937
33194
  throw new Error("'ref' is required for contract_plan and must identify one project");
32938
33195
  }
32939
33196
  const requestedEnvironmentId = requestedScopeEnvironment(args, "contract_plan");
32940
33197
  const file = typeof args.file === "string" && args.file.trim() ? args.file.trim() : "supacloud.release.json";
32941
- const filePath = resolve23(cwd, file);
32942
- if (!existsSync14(filePath)) {
33198
+ const filePath = resolve24(cwd, file);
33199
+ if (!existsSync15(filePath)) {
32943
33200
  throw new Error(`Release contract not found: ${file}`);
32944
33201
  }
32945
33202
  let parsedValue;
@@ -33001,7 +33258,7 @@ function parseCommaList(value) {
33001
33258
  return [];
33002
33259
  }
33003
33260
  function handleScopeCreate(args, fallbackRef) {
33004
- const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve23(args.cwd.trim()) : process.cwd();
33261
+ const cwd = typeof args.cwd === "string" && args.cwd.trim() ? resolve24(args.cwd.trim()) : process.cwd();
33005
33262
  if (typeof args.file !== "string" || !args.file.trim()) {
33006
33263
  throw new Error("'file' is required for scope_create");
33007
33264
  }
@@ -33017,7 +33274,7 @@ function handleScopeCreate(args, fallbackRef) {
33017
33274
  throw new Error("'ref' is invalid for release controls");
33018
33275
  }
33019
33276
  const targetBaseCommit = resolveGitBaseCommit(cwd, args.base_commit);
33020
- const filePath = resolve23(cwd, args.file.trim());
33277
+ const filePath = resolve24(cwd, args.file.trim());
33021
33278
  mkdirSync5(dirname12(filePath), { recursive: true });
33022
33279
  const scope = {
33023
33280
  baseCommit: targetBaseCommit,
@@ -33265,11 +33522,11 @@ function registerReleaseTools(server, http, options = {}) {
33265
33522
  }
33266
33523
 
33267
33524
  // src/shared/tools/deploy-tools.ts
33268
- import { access, lstat as lstat5, mkdtemp as mkdtemp2, opendir, readFile as readFile7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
33525
+ import { access, lstat as lstat5, mkdtemp as mkdtemp2, opendir, readFile as readFile8, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
33269
33526
  import { spawn as spawn2 } from "node:child_process";
33270
33527
  import { createHash as createHash11 } from "node:crypto";
33271
33528
  import { tmpdir as tmpdir3 } from "node:os";
33272
- import { basename as basename8, dirname as dirname14, join as join19, relative as relative10, resolve as resolve26, sep as sep5 } from "node:path";
33529
+ import { basename as basename8, dirname as dirname14, join as join20, relative as relative10, resolve as resolve27, sep as sep5 } from "node:path";
33273
33530
 
33274
33531
  // src/shared/tools/project-deployment.ts
33275
33532
  async function requireProjectDeploymentProtocol(http, projectRef, environmentId) {
@@ -33345,14 +33602,14 @@ async function readProjectDeploymentStatus(http, projectRef, environmentId, depl
33345
33602
  }
33346
33603
 
33347
33604
  // src/shared/tools/developer-experience-tools.ts
33348
- import { existsSync as existsSync16 } from "node:fs";
33349
- import { mkdir as mkdir7, readdir as readdir7, readFile as readFile6, writeFile as writeFile6 } from "node:fs/promises";
33350
- import { dirname as dirname13, join as join18, resolve as resolve25 } from "node:path";
33605
+ import { existsSync as existsSync17 } from "node:fs";
33606
+ import { mkdir as mkdir8, readdir as readdir7, readFile as readFile7, writeFile as writeFile7 } from "node:fs/promises";
33607
+ import { dirname as dirname13, join as join19, resolve as resolve26 } from "node:path";
33351
33608
 
33352
33609
  // src/shared/context.ts
33353
- import { existsSync as existsSync15, readFileSync as readFileSync12 } from "node:fs";
33610
+ import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
33354
33611
  import { homedir as homedir3 } from "node:os";
33355
- import { resolve as resolve24 } from "node:path";
33612
+ import { resolve as resolve25 } from "node:path";
33356
33613
  var CORE_CONTEXT_KEYS2 = [
33357
33614
  "SUPABASE_URL",
33358
33615
  "SUPABASE_SERVICE_ROLE_KEY",
@@ -33384,8 +33641,44 @@ function parseEnvFile2(contents) {
33384
33641
  }
33385
33642
  return values;
33386
33643
  }
33644
+ function projectConfigValues2(cwd, environment) {
33645
+ const path = resolve25(cwd, "supacloud.json");
33646
+ if (!existsSync16(path))
33647
+ return {};
33648
+ try {
33649
+ const parsed = JSON.parse(readFileSync12(path, "utf8"));
33650
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
33651
+ return {};
33652
+ const root = parsed;
33653
+ const context = root.context;
33654
+ if (!context || typeof context !== "object" || Array.isArray(context))
33655
+ return {};
33656
+ const contextRecord = context;
33657
+ const environments = contextRecord.environments;
33658
+ if (!environments || typeof environments !== "object" || Array.isArray(environments))
33659
+ return {};
33660
+ const selected = environments[environment];
33661
+ if (!selected || typeof selected !== "object" || Array.isArray(selected))
33662
+ return {};
33663
+ const values = selected;
33664
+ const output = {};
33665
+ const mappings = {
33666
+ api_url: "SUPACLOUD_API_URL",
33667
+ project_ref: "SUPACLOUD_PROJECT_REF",
33668
+ application_id: "SUPACLOUD_APPLICATION_ID",
33669
+ environment_id: "SUPACLOUD_APPLICATION_ENVIRONMENT_ID"
33670
+ };
33671
+ for (const [source, target] of Object.entries(mappings)) {
33672
+ if (typeof values[source] === "string" && values[source].trim())
33673
+ output[target] = values[source].trim();
33674
+ }
33675
+ return output;
33676
+ } catch {
33677
+ return {};
33678
+ }
33679
+ }
33387
33680
  function readEnvFile2(path, required) {
33388
- if (!existsSync15(path)) {
33681
+ if (!existsSync16(path)) {
33389
33682
  if (required)
33390
33683
  throw new Error(`SupaCloud environment file not found: ${path}`);
33391
33684
  return {};
@@ -33462,7 +33755,7 @@ function parseInsecureTls2(values) {
33462
33755
  }
33463
33756
  function namedEnvironmentSource2(cwd, selector) {
33464
33757
  const environment = normalizeEnvironmentName(selector);
33465
- const path = resolve24(cwd, `.env.supacloud.${selector}`);
33758
+ const path = resolve25(cwd, `.env.supacloud.${selector}`);
33466
33759
  const values = readEnvFile2(path, true);
33467
33760
  if (values.SUPACLOUD_ENV && normalizeEnvironmentName(values.SUPACLOUD_ENV) !== environment) {
33468
33761
  throw new Error(`SUPACLOUD_ENV in ${path} does not match selector ${selector}`);
@@ -33470,7 +33763,7 @@ function namedEnvironmentSource2(cwd, selector) {
33470
33763
  return { values, kind: "named_env_file", path, environment };
33471
33764
  }
33472
33765
  function explicitEnvironmentSource2(cwd, envFile) {
33473
- const path = resolve24(cwd, envFile);
33766
+ const path = resolve25(cwd, envFile);
33474
33767
  const values = readEnvFile2(path, true);
33475
33768
  if (!values.SUPACLOUD_ENV)
33476
33769
  throw new Error(`SUPACLOUD_ENV is required in ${path}`);
@@ -33484,25 +33777,47 @@ function explicitEnvironmentSource2(cwd, envFile) {
33484
33777
  function contextSource2(env, cwd, selection) {
33485
33778
  if (selection.environmentName && selection.envFile)
33486
33779
  throw new Error("Environment selectors are mutually exclusive");
33487
- if (selection.environmentName)
33488
- return namedEnvironmentSource2(cwd, selection.environmentName);
33489
- if (selection.envFile)
33490
- return explicitEnvironmentSource2(cwd, selection.envFile);
33780
+ if (selection.environmentName) {
33781
+ const source = namedEnvironmentSource2(cwd, selection.environmentName);
33782
+ return {
33783
+ ...source,
33784
+ values: { ...projectConfigValues2(cwd, source.environment), ...source.values }
33785
+ };
33786
+ }
33787
+ if (selection.envFile) {
33788
+ const source = explicitEnvironmentSource2(cwd, selection.envFile);
33789
+ return {
33790
+ ...source,
33791
+ values: { ...projectConfigValues2(cwd, source.environment), ...source.values }
33792
+ };
33793
+ }
33491
33794
  if (env.SUPACLOUD_ENV) {
33492
33795
  const environment = normalizeEnvironmentName(env.SUPACLOUD_ENV);
33493
- const values = processValues2(env);
33796
+ const values = { ...projectConfigValues2(cwd, environment), ...processValues2(env) };
33494
33797
  if (completeProjectContext2(values)) {
33495
33798
  return { values, kind: "process_env", path: null, environment };
33496
33799
  }
33497
- return namedEnvironmentSource2(cwd, env.SUPACLOUD_ENV);
33800
+ const source = namedEnvironmentSource2(cwd, env.SUPACLOUD_ENV);
33801
+ return {
33802
+ ...source,
33803
+ values: { ...projectConfigValues2(cwd, source.environment), ...source.values }
33804
+ };
33498
33805
  }
33499
33806
  if (hasProcessContext2(env)) {
33500
33807
  return { values: processValues2(env), kind: "process_env", path: null, environment: "" };
33501
33808
  }
33502
- const path = resolve24(cwd, ".env");
33809
+ const path = resolve25(cwd, ".env");
33503
33810
  const values = readEnvFile2(path, false);
33504
33811
  const environment = values.SUPACLOUD_ENV ? normalizeEnvironmentName(values.SUPACLOUD_ENV) : "";
33505
- return { values, kind: Object.keys(values).length ? "legacy_dotenv" : "none", path: existsSync15(path) ? path : null, environment };
33812
+ if (environment) {
33813
+ return {
33814
+ values: { ...projectConfigValues2(cwd, environment), ...values },
33815
+ kind: "legacy_dotenv",
33816
+ path: existsSync16(path) ? path : null,
33817
+ environment
33818
+ };
33819
+ }
33820
+ return { values, kind: Object.keys(values).length ? "legacy_dotenv" : "none", path: existsSync16(path) ? path : null, environment };
33506
33821
  }
33507
33822
  function resolveSupaCloudContext2(env = process.env, cwd = process.cwd(), selection = {}) {
33508
33823
  const source = contextSource2(env, cwd, selection);
@@ -33514,7 +33829,7 @@ function resolveSupaCloudContext2(env = process.env, cwd = process.cwd(), select
33514
33829
  host,
33515
33830
  sshUser: env.SUPACLOUD_SSH_USER ?? "root",
33516
33831
  sshPort: parseInt(env.SUPACLOUD_SSH_PORT ?? "22", 10),
33517
- sshKey: env.SUPACLOUD_SSH_KEY ?? resolve24(homedir3(), ".ssh", "id_rsa"),
33832
+ sshKey: env.SUPACLOUD_SSH_KEY ?? resolve25(homedir3(), ".ssh", "id_rsa"),
33518
33833
  sshPass: env.SUPACLOUD_SSH_PASS ?? "",
33519
33834
  apiUrl: core.apiUrl,
33520
33835
  apiToken: core.apiToken,
@@ -33543,7 +33858,7 @@ var initToolSchema = {
33543
33858
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
33544
33859
  };
33545
33860
  var environmentToolSchema = {
33546
- action: withDescription(stringEnum2(["list", "check"]), "Environment profile inspection action"),
33861
+ ...environmentSyncSchema,
33547
33862
  root: optional(String2(), "Project directory containing .env.supacloud.* files"),
33548
33863
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
33549
33864
  };
@@ -33565,13 +33880,13 @@ var PRODUCTION_PROFILE = [
33565
33880
  ""
33566
33881
  ].join(`
33567
33882
  `);
33568
- function textResult3(text, isError = false) {
33883
+ function textResult4(text, isError = false) {
33569
33884
  return { isError, content: [{ type: "text", text }] };
33570
33885
  }
33571
- function jsonResult(value, isError = false) {
33572
- return textResult3(JSON.stringify(value, null, 2), isError);
33886
+ function jsonResult2(value, isError = false) {
33887
+ return textResult4(JSON.stringify(value, null, 2), isError);
33573
33888
  }
33574
- function record5(value) {
33889
+ function record6(value) {
33575
33890
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
33576
33891
  }
33577
33892
  function packageDependencies(manifest) {
@@ -33589,17 +33904,17 @@ function outputDirectoryFor(manifest) {
33589
33904
  return "dist";
33590
33905
  }
33591
33906
  async function readPackageManifest(root) {
33592
- const path = join18(root, "package.json");
33593
- if (!existsSync16(path))
33907
+ const path = join19(root, "package.json");
33908
+ if (!existsSync17(path))
33594
33909
  return {};
33595
33910
  try {
33596
- const parsed = JSON.parse(await readFile6(path, "utf8"));
33597
- const value = record5(parsed);
33911
+ const parsed = JSON.parse(await readFile7(path, "utf8"));
33912
+ const value = record6(parsed);
33598
33913
  if (!value)
33599
33914
  throw new Error("package.json must contain an object");
33600
- const scripts = record5(value.scripts);
33601
- const dependencies = record5(value.dependencies);
33602
- const devDependencies = record5(value.devDependencies);
33915
+ const scripts = record6(value.scripts);
33916
+ const dependencies = record6(value.dependencies);
33917
+ const devDependencies = record6(value.devDependencies);
33603
33918
  return {
33604
33919
  scripts: scripts ?? undefined,
33605
33920
  dependencies: dependencies ?? undefined,
@@ -33611,7 +33926,7 @@ async function readPackageManifest(root) {
33611
33926
  }
33612
33927
  async function writeNewFile(path, content) {
33613
33928
  try {
33614
- await writeFile6(path, content, { encoding: "utf8", flag: "wx", mode: 384 });
33929
+ await writeFile7(path, content, { encoding: "utf8", flag: "wx", mode: 384 });
33615
33930
  return true;
33616
33931
  } catch (error) {
33617
33932
  if (error instanceof Error && "code" in error && error.code === "EEXIST")
@@ -33620,8 +33935,8 @@ async function writeNewFile(path, content) {
33620
33935
  }
33621
33936
  }
33622
33937
  async function ensureGitignore(root) {
33623
- const path = join18(root, ".gitignore");
33624
- const existing = existsSync16(path) ? await readFile6(path, "utf8") : "";
33938
+ const path = join19(root, ".gitignore");
33939
+ const existing = existsSync17(path) ? await readFile7(path, "utf8") : "";
33625
33940
  const required = [".env.supacloud.*", "!.env.supacloud.*.example"];
33626
33941
  const missing = required.filter((entry) => !existing.split(/\r?\n/).includes(entry));
33627
33942
  if (missing.length === 0)
@@ -33629,16 +33944,16 @@ async function ensureGitignore(root) {
33629
33944
  const prefix = existing.length > 0 && !existing.endsWith(`
33630
33945
  `) ? `${existing}
33631
33946
  ` : existing;
33632
- await writeFile6(path, `${prefix}${missing.join(`
33947
+ await writeFile7(path, `${prefix}${missing.join(`
33633
33948
  `)}
33634
33949
  `, "utf8");
33635
33950
  return true;
33636
33951
  }
33637
33952
  async function initializeProject(request, options = {}) {
33638
- const root = resolve25(request.root || options.cwd || process.cwd());
33639
- await mkdir7(root, { recursive: true });
33640
- const configPath = join18(root, "supacloud.json");
33641
- if (existsSync16(configPath)) {
33953
+ const root = resolve26(request.root || options.cwd || process.cwd());
33954
+ await mkdir8(root, { recursive: true });
33955
+ const configPath = join19(root, "supacloud.json");
33956
+ if (existsSync17(configPath)) {
33642
33957
  throw new Error(`supacloud.json already exists in ${root}; init never overwrites project configuration`);
33643
33958
  }
33644
33959
  const manifest = await readPackageManifest(root);
@@ -33652,7 +33967,7 @@ async function initializeProject(request, options = {}) {
33652
33967
  };
33653
33968
  const created = [];
33654
33969
  try {
33655
- await writeFile6(configPath, `${JSON.stringify(config, null, 2)}
33970
+ await writeFile7(configPath, `${JSON.stringify(config, null, 2)}
33656
33971
  `, {
33657
33972
  encoding: "utf8",
33658
33973
  flag: "wx",
@@ -33665,10 +33980,10 @@ async function initializeProject(request, options = {}) {
33665
33980
  throw error;
33666
33981
  }
33667
33982
  created.push("supacloud.json");
33668
- if (await writeNewFile(join18(root, ".env.supacloud.test.example"), TEST_PROFILE)) {
33983
+ if (await writeNewFile(join19(root, ".env.supacloud.test.example"), TEST_PROFILE)) {
33669
33984
  created.push(".env.supacloud.test.example");
33670
33985
  }
33671
- if (await writeNewFile(join18(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE)) {
33986
+ if (await writeNewFile(join19(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE)) {
33672
33987
  created.push(".env.supacloud.production.example");
33673
33988
  }
33674
33989
  if (await ensureGitignore(root))
@@ -33679,7 +33994,7 @@ async function initializeProject(request, options = {}) {
33679
33994
  root,
33680
33995
  created,
33681
33996
  detected: {
33682
- package_json: existsSync16(join18(root, "package.json")),
33997
+ package_json: existsSync17(join19(root, "package.json")),
33683
33998
  build_script: hasBuildScript,
33684
33999
  output_directory: outputDirectory
33685
34000
  },
@@ -33691,8 +34006,8 @@ async function initializeProject(request, options = {}) {
33691
34006
  ]
33692
34007
  };
33693
34008
  if (request.format === "json")
33694
- return jsonResult(result);
33695
- return textResult3([
34009
+ return jsonResult2(result);
34010
+ return textResult4([
33696
34011
  `Initialized SupaCloud deployment in ${root}.`,
33697
34012
  `Created: ${created.join(", ")}.`,
33698
34013
  hasBuildScript ? `Detected package.json build script; deploy output defaults to ${outputDirectory}.` : "No package.json build script detected; add one before deploying.",
@@ -33724,7 +34039,7 @@ var deployToolSchema = {
33724
34039
  status: optional(String2({ format: "uuid" }), "Read a backend deployment status without publishing"),
33725
34040
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
33726
34041
  };
33727
- function record6(candidate) {
34042
+ function record7(candidate) {
33728
34043
  return candidate && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
33729
34044
  }
33730
34045
  function requiredString(candidate, field) {
@@ -33734,7 +34049,7 @@ function requiredString(candidate, field) {
33734
34049
  return candidate.trim();
33735
34050
  }
33736
34051
  function frontendDeployment(candidate) {
33737
- const value = record6(candidate);
34052
+ const value = record7(candidate);
33738
34053
  if (!value)
33739
34054
  throw new Error("Invalid frontend deployment response");
33740
34055
  return {
@@ -33748,7 +34063,7 @@ function frontendDeployment(candidate) {
33748
34063
  }
33749
34064
  async function readJson(path) {
33750
34065
  try {
33751
- return JSON.parse(await readFile7(path, "utf8"));
34066
+ return JSON.parse(await readFile8(path, "utf8"));
33752
34067
  } catch (error) {
33753
34068
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
33754
34069
  return null;
@@ -33756,15 +34071,15 @@ async function readJson(path) {
33756
34071
  }
33757
34072
  }
33758
34073
  async function findDeployConfigRoot(startDirectory, environmentName) {
33759
- let directory = resolve26(startDirectory);
34074
+ let directory = resolve27(startDirectory);
33760
34075
  while (true) {
33761
34076
  const environmentFile = environmentName ? `.env.supacloud.${environmentName}` : null;
33762
- if (await pathExists(join19(directory, "supacloud.json")) || await pathExists(join19(directory, "supacloud.config.ts")) || environmentFile !== null && await pathExists(join19(directory, environmentFile))) {
34077
+ if (await pathExists(join20(directory, "supacloud.json")) || await pathExists(join20(directory, "supacloud.config.ts")) || environmentFile !== null && await pathExists(join20(directory, environmentFile))) {
33763
34078
  return directory;
33764
34079
  }
33765
34080
  const parent = dirname14(directory);
33766
34081
  if (parent === directory)
33767
- return resolve26(startDirectory);
34082
+ return resolve27(startDirectory);
33768
34083
  directory = parent;
33769
34084
  }
33770
34085
  }
@@ -33804,7 +34119,7 @@ function optionalStringArray(value, field) {
33804
34119
  });
33805
34120
  }
33806
34121
  function deployTargetConfig(candidate, name) {
33807
- const value = record6(candidate);
34122
+ const value = record7(candidate);
33808
34123
  if (!value || value.type !== "frontend" && value.type !== "edge_function") {
33809
34124
  throw new Error(`supacloud.json targets.${name}.type must be 'frontend' or 'edge_function'`);
33810
34125
  }
@@ -33829,14 +34144,14 @@ function deployTargetConfig(candidate, name) {
33829
34144
  };
33830
34145
  }
33831
34146
  async function readDeployConfig(configRoot) {
33832
- const configPath = join19(configRoot, "supacloud.json");
34147
+ const configPath = join20(configRoot, "supacloud.json");
33833
34148
  const candidate = await readJson(configPath);
33834
34149
  if (candidate === null)
33835
34150
  return {};
33836
- const config = record6(candidate);
33837
- const frontend = record6(config?.frontend);
33838
- const application = record6(config?.application);
33839
- const targetValues = record6(config?.targets);
34151
+ const config = record7(candidate);
34152
+ const frontend = record7(config?.frontend);
34153
+ const application = record7(config?.application);
34154
+ const targetValues = record7(config?.targets);
33840
34155
  if (!config || config.frontend !== undefined && !frontend || config.application !== undefined && !application || config.targets !== undefined && !targetValues) {
33841
34156
  throw new Error("supacloud.json must contain object-valued 'application', 'frontend' or 'targets' configuration");
33842
34157
  }
@@ -33876,16 +34191,16 @@ async function readDeployConfig(configRoot) {
33876
34191
  };
33877
34192
  }
33878
34193
  async function packageName(projectDirectory) {
33879
- const candidate = record6(await readJson(join19(projectDirectory, "package.json")));
34194
+ const candidate = record7(await readJson(join20(projectDirectory, "package.json")));
33880
34195
  return typeof candidate?.name === "string" && candidate.name.trim() ? candidate.name.trim() : null;
33881
34196
  }
33882
34197
  async function pathExists(path) {
33883
34198
  return access(path).then(() => true, () => false);
33884
34199
  }
33885
34200
  async function hasProjectReleaseManifest(root) {
33886
- if (await pathExists(join19(root, "deploy-manifest.json")))
34201
+ if (await pathExists(join20(root, "deploy-manifest.json")))
33887
34202
  return true;
33888
- const directory = await opendir(join19(root, "supacloud")).catch((error) => {
34203
+ const directory = await opendir(join20(root, "supacloud")).catch((error) => {
33889
34204
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
33890
34205
  return null;
33891
34206
  throw error;
@@ -33896,24 +34211,24 @@ async function hasProjectReleaseManifest(root) {
33896
34211
  for await (const entry of directory) {
33897
34212
  if (++entries > 128)
33898
34213
  throw new Error("Too many SupaCloud project roots to resolve a deployment");
33899
- if ((entry.isDirectory() || entry.isSymbolicLink()) && await pathExists(join19(root, "supacloud", entry.name, "deploy-manifest.json")))
34214
+ if ((entry.isDirectory() || entry.isSymbolicLink()) && await pathExists(join20(root, "supacloud", entry.name, "deploy-manifest.json")))
33900
34215
  return true;
33901
34216
  }
33902
34217
  return false;
33903
34218
  }
33904
34219
  async function defaultBuildCommand(projectDirectory, configRoot) {
33905
- const packageJson = record6(await readJson(join19(projectDirectory, "package.json")));
33906
- const scripts = record6(packageJson?.scripts);
34220
+ const packageJson = record7(await readJson(join20(projectDirectory, "package.json")));
34221
+ const scripts = record7(packageJson?.scripts);
33907
34222
  if (typeof scripts?.build !== "string" || !scripts.build.trim()) {
33908
34223
  throw new Error("No build command was configured and package.json has no build script");
33909
34224
  }
33910
34225
  let directory = projectDirectory;
33911
34226
  while (true) {
33912
- if (await pathExists(join19(directory, "bun.lock")) || await pathExists(join19(directory, "bun.lockb")))
34227
+ if (await pathExists(join20(directory, "bun.lock")) || await pathExists(join20(directory, "bun.lockb")))
33913
34228
  return "bun run build";
33914
- if (await pathExists(join19(directory, "pnpm-lock.yaml")))
34229
+ if (await pathExists(join20(directory, "pnpm-lock.yaml")))
33915
34230
  return "pnpm run build";
33916
- if (await pathExists(join19(directory, "yarn.lock")))
34231
+ if (await pathExists(join20(directory, "yarn.lock")))
33917
34232
  return "yarn build";
33918
34233
  if (directory === configRoot)
33919
34234
  break;
@@ -33925,7 +34240,7 @@ async function defaultBuildCommand(projectDirectory, configRoot) {
33925
34240
  return "npm run build";
33926
34241
  }
33927
34242
  function deploymentList(candidate) {
33928
- const values = Array.isArray(candidate) ? candidate : Array.isArray(record6(candidate)?.deployments) ? record6(candidate)?.deployments : null;
34243
+ const values = Array.isArray(candidate) ? candidate : Array.isArray(record7(candidate)?.deployments) ? record7(candidate)?.deployments : null;
33929
34244
  if (!values)
33930
34245
  throw new Error("Invalid frontend deployment list response");
33931
34246
  return values.map(frontendDeployment);
@@ -33985,9 +34300,9 @@ function selectFrontendTarget(configRoot, config) {
33985
34300
  throw new Error(`Multiple frontend deploy targets found (${targets.map(([name]) => name).sort().join(", ")}). Set defaultTarget to the Web target`);
33986
34301
  }
33987
34302
  function targetRoot(configRoot, target, name) {
33988
- const root = resolve26(configRoot, target.root || (name === "frontend" ? "." : name));
33989
- const prefix = `${resolve26(configRoot)}${sep5}`;
33990
- if (root !== resolve26(configRoot) && !root.startsWith(prefix)) {
34303
+ const root = resolve27(configRoot, target.root || (name === "frontend" ? "." : name));
34304
+ const prefix = `${resolve27(configRoot)}${sep5}`;
34305
+ if (root !== resolve27(configRoot) && !root.startsWith(prefix)) {
33991
34306
  throw new Error(`Deploy target '${name}' root must stay inside the repository root`);
33992
34307
  }
33993
34308
  return root;
@@ -34005,8 +34320,8 @@ function defaultOutputDirectory(framework) {
34005
34320
  }
34006
34321
  }
34007
34322
  function resolveInsideProject(projectDirectory, candidate, allowRoot = false) {
34008
- const resolved = resolve26(projectDirectory, candidate);
34009
- const projectRoot = resolve26(projectDirectory);
34323
+ const resolved = resolve27(projectDirectory, candidate);
34324
+ const projectRoot = resolve27(projectDirectory);
34010
34325
  const projectPrefix = `${projectRoot}${sep5}`;
34011
34326
  if (!allowRoot && resolved === projectRoot || resolved !== projectRoot && !resolved.startsWith(projectPrefix)) {
34012
34327
  throw new Error("Frontend output directory must stay inside the project directory");
@@ -34060,7 +34375,7 @@ async function collectArchiveFiles(root) {
34060
34375
  entries.push(entry);
34061
34376
  entries.sort((left, right) => left.name.localeCompare(right.name, "en"));
34062
34377
  for (const entry of entries) {
34063
- const path = join19(directory, entry.name);
34378
+ const path = join20(directory, entry.name);
34064
34379
  const stats = await lstat5(path);
34065
34380
  if (stats.isSymbolicLink())
34066
34381
  throw new Error(`Frontend output cannot contain symbolic links: ${path}`);
@@ -34079,7 +34394,7 @@ async function collectArchiveFiles(root) {
34079
34394
  const files = new Map;
34080
34395
  const digests = [];
34081
34396
  for (const path of paths) {
34082
- const data = new Uint8Array(await readFile7(path));
34397
+ const data = new Uint8Array(await readFile8(path));
34083
34398
  bytes += data.byteLength;
34084
34399
  if (bytes > MAX_SOURCE_BYTES)
34085
34400
  throw new Error(`Frontend output exceeds ${MAX_SOURCE_BYTES} bytes`);
@@ -34098,11 +34413,11 @@ async function collectArchiveFiles(root) {
34098
34413
  return { files, bytes, count: paths.length, treeSha256: tree.digest("hex") };
34099
34414
  }
34100
34415
  async function createCollectedFrontendArchive(outputDirectory, collected) {
34101
- const temporaryDirectory = await mkdtemp2(join19(tmpdir3(), "supacloud-deploy-"));
34102
- const archivePath = join19(temporaryDirectory, `${basename8(outputDirectory)}.tar.zst`);
34416
+ const temporaryDirectory = await mkdtemp2(join20(tmpdir3(), "supacloud-deploy-"));
34417
+ const archivePath = join20(temporaryDirectory, `${basename8(outputDirectory)}.tar.zst`);
34103
34418
  try {
34104
34419
  const archiveBytes = await createFrontendTarZstd(collected.files);
34105
- await writeFile7(archivePath, archiveBytes);
34420
+ await writeFile8(archivePath, archiveBytes);
34106
34421
  const sha256 = createHash11("sha256").update(archiveBytes).digest("hex");
34107
34422
  return {
34108
34423
  archivePath,
@@ -34147,7 +34462,7 @@ async function publishConfiguredFrontend(http, projectRef, configRoot, skipBuild
34147
34462
  }
34148
34463
  function registerDeployTools(server, http, options = {}) {
34149
34464
  registerTool(server, "deploy", "Build and publish the linked project with one command", deployToolSchema, async (args) => {
34150
- const invocationDirectory = resolve26(String(args.cwd || options.cwd || process.cwd()));
34465
+ const invocationDirectory = resolve27(String(args.cwd || options.cwd || process.cwd()));
34151
34466
  if (args.action === "init") {
34152
34467
  return initializeProject({
34153
34468
  ...typeof args.root === "string" ? { root: args.root } : {},
@@ -34228,11 +34543,11 @@ function registerDeployTools(server, http, options = {}) {
34228
34543
  }
34229
34544
 
34230
34545
  // src/shared/tools/remote-dev-tools.ts
34231
- import { existsSync as existsSync17 } from "node:fs";
34232
- import { readFile as readFile8 } from "node:fs/promises";
34546
+ import { existsSync as existsSync18 } from "node:fs";
34547
+ import { readFile as readFile9 } from "node:fs/promises";
34233
34548
  import { readdir as readdir8 } from "node:fs/promises";
34234
34549
  import { createHash as createHash12 } from "node:crypto";
34235
- import { join as join20, resolve as resolve27 } from "node:path";
34550
+ import { join as join21, resolve as resolve28 } from "node:path";
34236
34551
  import { compileProject as compileProject2 } from "@supacloud/compiler";
34237
34552
  var SAFE_TOKEN = /^[A-Za-z0-9._:@/+,-]+$/;
34238
34553
  var SAFE_REMOTE_ROOT = /^\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\/?$/;
@@ -34260,13 +34575,13 @@ async function runProcess(executable, args, cwd) {
34260
34575
  return { exitCode: exitCode ?? 1, stdout, stderr };
34261
34576
  }
34262
34577
  async function readProjectConfig(root) {
34263
- const file = join20(root, "supacloud.json");
34264
- if (!existsSync17(file))
34578
+ const file = join21(root, "supacloud.json");
34579
+ if (!existsSync18(file))
34265
34580
  return {};
34266
34581
  try {
34267
- const parsed = JSON.parse(await readFile8(file, "utf8"));
34582
+ const parsed = JSON.parse(await readFile9(file, "utf8"));
34268
34583
  if (parsed && typeof parsed === "object" && "dev" in parsed && parsed.dev && typeof parsed.dev === "object" && "database" in parsed.dev) {
34269
- throw new Error("dev.database was removed; use supacloud-model diff and db plan/apply");
34584
+ throw new Error("dev.database was removed; use db:plan/db:apply through the Management API");
34270
34585
  }
34271
34586
  return parsed && typeof parsed === "object" ? parsed : {};
34272
34587
  } catch (error) {
@@ -34282,7 +34597,7 @@ async function sourceFingerprint(root) {
34282
34597
  const visit = async (directory) => {
34283
34598
  const entries = await readdir8(directory, { withFileTypes: true });
34284
34599
  for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
34285
- const path = join20(directory, entry.name);
34600
+ const path = join21(directory, entry.name);
34286
34601
  if (entry.isDirectory() && ![".git", "node_modules", "dist", "generated", ".supacloud"].includes(entry.name))
34287
34602
  await visit(path);
34288
34603
  else if (entry.isFile())
@@ -34293,7 +34608,7 @@ async function sourceFingerprint(root) {
34293
34608
  const hash = createHash12("sha256");
34294
34609
  for (const file of files) {
34295
34610
  hash.update(file.slice(root.length).replace(/\\/g, "/"));
34296
- hash.update(await readFile8(file));
34611
+ hash.update(await readFile9(file));
34297
34612
  }
34298
34613
  return hash.digest("hex");
34299
34614
  }
@@ -34310,19 +34625,19 @@ function remoteRoot(value) {
34310
34625
  }
34311
34626
  function targetDirectory(root, target, functionSlug, config = {}) {
34312
34627
  if (target === "db")
34313
- return join20(root, "supabase", "migrations");
34628
+ return join21(root, "supabase", "migrations");
34314
34629
  if (target === "functions") {
34315
34630
  const targets = config["targets"];
34316
34631
  const entries = targets && typeof targets === "object" ? Object.values(targets) : [];
34317
34632
  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));
34318
- const base = match?.root ? resolve27(root, match.root) : join20(root, "supabase", "functions");
34319
- return match?.root ? base : functionSlug ? join20(base, safeToken(functionSlug, "function")) : base;
34633
+ const base = match?.root ? resolve28(root, match.root) : join21(root, "supabase", "functions");
34634
+ return match?.root ? base : functionSlug ? join21(base, safeToken(functionSlug, "function")) : base;
34320
34635
  }
34321
34636
  if (target === "frontend") {
34322
34637
  const targets = config["targets"];
34323
34638
  const entries = targets && typeof targets === "object" ? Object.values(targets) : [];
34324
34639
  const match = entries.find((entry) => entry !== null && typeof entry === "object" && ("type" in entry) && entry.type === "frontend" && (!("root" in entry) || typeof entry.root === "string"));
34325
- return match?.root ? resolve27(root, match.root) : join20(root, "apps", "web");
34640
+ return match?.root ? resolve28(root, match.root) : join21(root, "apps", "web");
34326
34641
  }
34327
34642
  return root;
34328
34643
  }
@@ -34361,10 +34676,10 @@ function reloadCommand(config, target, projectRef, functionSlug) {
34361
34676
  return [...command.split(" "), "--project-ref", safeToken(projectRef || "test", "project_ref"), "--target", targetConfigPath(target), ...functionSlug ? ["--function", safeToken(functionSlug, "function")] : []];
34362
34677
  }
34363
34678
  function sshArgs(connection, remoteCommand) {
34364
- return ["-p", String(connection.port), "-i", resolve27(connection.key), "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=yes", `${connection.user}@${connection.host}`, ...remoteCommand];
34679
+ return ["-p", String(connection.port), "-i", resolve28(connection.key), "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=yes", `${connection.user}@${connection.host}`, ...remoteCommand];
34365
34680
  }
34366
34681
  function rsyncArgs(connection, source, destination, excludes, deleteRemote) {
34367
- const args = ["-az", "--checksum", "--partial", "--protect-args", "-e", `ssh -p ${connection.port} -i ${resolve27(connection.key)} -o BatchMode=yes -o StrictHostKeyChecking=yes`];
34682
+ const args = ["-az", "--checksum", "--partial", "--protect-args", "-e", `ssh -p ${connection.port} -i ${resolve28(connection.key)} -o BatchMode=yes -o StrictHostKeyChecking=yes`];
34368
34683
  if (deleteRemote)
34369
34684
  args.push("--delete-delay");
34370
34685
  for (const exclude of excludes) {
@@ -34376,17 +34691,17 @@ function rsyncArgs(connection, source, destination, excludes, deleteRemote) {
34376
34691
  return args;
34377
34692
  }
34378
34693
  async function syncOnce(args, options) {
34379
- const root = resolve27(String(args.project_dir || options.cwd || process.cwd()));
34694
+ const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
34380
34695
  const projectConfig = await readProjectConfig(root);
34381
34696
  const config = projectConfig.dev || {};
34382
34697
  const target = String(args.target || "project");
34383
34698
  const source = targetDirectory(root, target, typeof args.function === "string" ? args.function : undefined, projectConfig);
34384
- if (!existsSync17(source))
34699
+ if (!existsSync18(source))
34385
34700
  throw new Error(`Dev source directory not found: ${source}`);
34386
34701
  let compiled = false;
34387
34702
  if (config.compile === true && target !== "db") {
34388
- const compileRoot = resolve27(root, config.compileRoot || ".");
34389
- const compileOutDir = resolve27(root, config.compileOutDir || "generated");
34703
+ const compileRoot = resolve28(root, config.compileRoot || ".");
34704
+ const compileOutDir = resolve28(root, config.compileOutDir || "generated");
34390
34705
  const compilation = await compileProject2({
34391
34706
  rootDir: compileRoot,
34392
34707
  outDir: compileOutDir,
@@ -34424,7 +34739,7 @@ function registerRemoteDevTools(server, options = {}) {
34424
34739
  if (["production", "prod"].includes((options.environment || "").toLowerCase()))
34425
34740
  throw new Error("Remote dev mode is forbidden for production environments");
34426
34741
  if (args.action === "status") {
34427
- const root = resolve27(String(args.project_dir || options.cwd || process.cwd()));
34742
+ const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
34428
34743
  const config = await readDevConfig(root);
34429
34744
  const connection = connectionArgs(options, config, args);
34430
34745
  const execute = options.execute || ((command, commandArgs, cwd) => runProcess(command, commandArgs, cwd));
@@ -34435,7 +34750,7 @@ function registerRemoteDevTools(server, options = {}) {
34435
34750
  return { content: [{ type: "text", text: JSON.stringify(await syncOnce(args, options), null, 2) }] };
34436
34751
  }
34437
34752
  if (args.action === "watch") {
34438
- const root = resolve27(String(args.project_dir || options.cwd || process.cwd()));
34753
+ const root = resolve28(String(args.project_dir || options.cwd || process.cwd()));
34439
34754
  const interval = Math.max(100, Math.min(1e4, Number(args.interval_ms || 300)));
34440
34755
  let fingerprint = "";
34441
34756
  let lastSync = null;
@@ -34455,15 +34770,15 @@ function registerRemoteDevTools(server, options = {}) {
34455
34770
  }
34456
34771
 
34457
34772
  // src/shared/tools/developer-experience-tools.ts
34458
- import { existsSync as existsSync18 } from "node:fs";
34459
- import { mkdir as mkdir8, readdir as readdir9, readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
34460
- import { dirname as dirname15, join as join21, resolve as resolve28 } from "node:path";
34773
+ import { existsSync as existsSync19 } from "node:fs";
34774
+ import { mkdir as mkdir9, readdir as readdir9, readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
34775
+ import { dirname as dirname15, join as join22, resolve as resolve29 } from "node:path";
34461
34776
  var initToolSchema2 = {
34462
34777
  root: optional(String2(), "Project directory to initialize (default: current directory)"),
34463
34778
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
34464
34779
  };
34465
34780
  var environmentToolSchema2 = {
34466
- action: withDescription(stringEnum2(["list", "check"]), "Environment profile inspection action"),
34781
+ ...environmentSyncSchema,
34467
34782
  root: optional(String2(), "Project directory containing .env.supacloud.* files"),
34468
34783
  format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
34469
34784
  };
@@ -34485,13 +34800,13 @@ var PRODUCTION_PROFILE2 = [
34485
34800
  ""
34486
34801
  ].join(`
34487
34802
  `);
34488
- function textResult4(text, isError = false) {
34803
+ function textResult5(text, isError = false) {
34489
34804
  return { isError, content: [{ type: "text", text }] };
34490
34805
  }
34491
- function jsonResult2(value, isError = false) {
34492
- return textResult4(JSON.stringify(value, null, 2), isError);
34806
+ function jsonResult3(value, isError = false) {
34807
+ return textResult5(JSON.stringify(value, null, 2), isError);
34493
34808
  }
34494
- function record7(value) {
34809
+ function record8(value) {
34495
34810
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
34496
34811
  }
34497
34812
  function packageDependencies2(manifest) {
@@ -34509,17 +34824,17 @@ function outputDirectoryFor2(manifest) {
34509
34824
  return "dist";
34510
34825
  }
34511
34826
  async function readPackageManifest2(root) {
34512
- const path = join21(root, "package.json");
34513
- if (!existsSync18(path))
34827
+ const path = join22(root, "package.json");
34828
+ if (!existsSync19(path))
34514
34829
  return {};
34515
34830
  try {
34516
- const parsed = JSON.parse(await readFile9(path, "utf8"));
34517
- const value = record7(parsed);
34831
+ const parsed = JSON.parse(await readFile10(path, "utf8"));
34832
+ const value = record8(parsed);
34518
34833
  if (!value)
34519
34834
  throw new Error("package.json must contain an object");
34520
- const scripts = record7(value.scripts);
34521
- const dependencies = record7(value.dependencies);
34522
- const devDependencies = record7(value.devDependencies);
34835
+ const scripts = record8(value.scripts);
34836
+ const dependencies = record8(value.dependencies);
34837
+ const devDependencies = record8(value.devDependencies);
34523
34838
  return {
34524
34839
  scripts: scripts ?? undefined,
34525
34840
  dependencies: dependencies ?? undefined,
@@ -34531,7 +34846,7 @@ async function readPackageManifest2(root) {
34531
34846
  }
34532
34847
  async function writeNewFile2(path, content) {
34533
34848
  try {
34534
- await writeFile8(path, content, { encoding: "utf8", flag: "wx", mode: 384 });
34849
+ await writeFile9(path, content, { encoding: "utf8", flag: "wx", mode: 384 });
34535
34850
  return true;
34536
34851
  } catch (error) {
34537
34852
  if (error instanceof Error && "code" in error && error.code === "EEXIST")
@@ -34540,8 +34855,8 @@ async function writeNewFile2(path, content) {
34540
34855
  }
34541
34856
  }
34542
34857
  async function ensureGitignore2(root) {
34543
- const path = join21(root, ".gitignore");
34544
- const existing = existsSync18(path) ? await readFile9(path, "utf8") : "";
34858
+ const path = join22(root, ".gitignore");
34859
+ const existing = existsSync19(path) ? await readFile10(path, "utf8") : "";
34545
34860
  const required = [".env.supacloud.*", "!.env.supacloud.*.example"];
34546
34861
  const missing = required.filter((entry) => !existing.split(/\r?\n/).includes(entry));
34547
34862
  if (missing.length === 0)
@@ -34549,16 +34864,16 @@ async function ensureGitignore2(root) {
34549
34864
  const prefix = existing.length > 0 && !existing.endsWith(`
34550
34865
  `) ? `${existing}
34551
34866
  ` : existing;
34552
- await writeFile8(path, `${prefix}${missing.join(`
34867
+ await writeFile9(path, `${prefix}${missing.join(`
34553
34868
  `)}
34554
34869
  `, "utf8");
34555
34870
  return true;
34556
34871
  }
34557
34872
  async function initializeProject2(request, options = {}) {
34558
- const root = resolve28(request.root || options.cwd || process.cwd());
34559
- await mkdir8(root, { recursive: true });
34560
- const configPath = join21(root, "supacloud.json");
34561
- if (existsSync18(configPath)) {
34873
+ const root = resolve29(request.root || options.cwd || process.cwd());
34874
+ await mkdir9(root, { recursive: true });
34875
+ const configPath = join22(root, "supacloud.json");
34876
+ if (existsSync19(configPath)) {
34562
34877
  throw new Error(`supacloud.json already exists in ${root}; init never overwrites project configuration`);
34563
34878
  }
34564
34879
  const manifest = await readPackageManifest2(root);
@@ -34572,7 +34887,7 @@ async function initializeProject2(request, options = {}) {
34572
34887
  };
34573
34888
  const created = [];
34574
34889
  try {
34575
- await writeFile8(configPath, `${JSON.stringify(config, null, 2)}
34890
+ await writeFile9(configPath, `${JSON.stringify(config, null, 2)}
34576
34891
  `, {
34577
34892
  encoding: "utf8",
34578
34893
  flag: "wx",
@@ -34585,10 +34900,10 @@ async function initializeProject2(request, options = {}) {
34585
34900
  throw error;
34586
34901
  }
34587
34902
  created.push("supacloud.json");
34588
- if (await writeNewFile2(join21(root, ".env.supacloud.test.example"), TEST_PROFILE2)) {
34903
+ if (await writeNewFile2(join22(root, ".env.supacloud.test.example"), TEST_PROFILE2)) {
34589
34904
  created.push(".env.supacloud.test.example");
34590
34905
  }
34591
- if (await writeNewFile2(join21(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE2)) {
34906
+ if (await writeNewFile2(join22(root, ".env.supacloud.production.example"), PRODUCTION_PROFILE2)) {
34592
34907
  created.push(".env.supacloud.production.example");
34593
34908
  }
34594
34909
  if (await ensureGitignore2(root))
@@ -34599,7 +34914,7 @@ async function initializeProject2(request, options = {}) {
34599
34914
  root,
34600
34915
  created,
34601
34916
  detected: {
34602
- package_json: existsSync18(join21(root, "package.json")),
34917
+ package_json: existsSync19(join22(root, "package.json")),
34603
34918
  build_script: hasBuildScript,
34604
34919
  output_directory: outputDirectory
34605
34920
  },
@@ -34611,8 +34926,8 @@ async function initializeProject2(request, options = {}) {
34611
34926
  ]
34612
34927
  };
34613
34928
  if (request.format === "json")
34614
- return jsonResult2(result);
34615
- return textResult4([
34929
+ return jsonResult3(result);
34930
+ return textResult5([
34616
34931
  `Initialized SupaCloud deployment in ${root}.`,
34617
34932
  `Created: ${created.join(", ")}.`,
34618
34933
  hasBuildScript ? `Detected package.json build script; deploy output defaults to ${outputDirectory}.` : "No package.json build script detected; add one before deploying.",
@@ -34633,7 +34948,7 @@ async function environmentProfiles(root) {
34633
34948
  });
34634
34949
  return entries.filter((entry) => entry.isFile()).map((entry) => {
34635
34950
  const name = profileNameFromFile(entry.name);
34636
- return name ? { name, path: join21(root, entry.name), exists: true } : null;
34951
+ return name ? { name, path: join22(root, entry.name), exists: true } : null;
34637
34952
  }).filter((profile) => profile !== null).sort((left, right) => left.name.localeCompare(right.name));
34638
34953
  }
34639
34954
  function statusMissing(context) {
@@ -34672,14 +34987,14 @@ async function inspectProfile(profile) {
34672
34987
  environmentName: profile.name
34673
34988
  });
34674
34989
  const status = statusMissing(context);
34675
- const configText = await readFile9(join21(dirname15(profile.path), "supacloud.json"), "utf8").catch((error) => {
34990
+ const configText = await readFile10(join22(dirname15(profile.path), "supacloud.json"), "utf8").catch((error) => {
34676
34991
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
34677
34992
  return "{}";
34678
34993
  throw error;
34679
34994
  });
34680
- const config = record7(JSON.parse(configText));
34681
- const hasFrontend = record7(config?.frontend) !== null || Object.values(record7(config?.targets) ?? {}).some((target) => record7(target)?.type === "frontend");
34682
- const deploy = deployMissing(context, record7(config?.application), hasFrontend);
34995
+ const config = record8(JSON.parse(configText));
34996
+ const hasFrontend = record8(config?.frontend) !== null || Object.values(record8(config?.targets) ?? {}).some((target) => record8(target)?.type === "frontend");
34997
+ const deploy = deployMissing(context, record8(config?.application), hasFrontend);
34683
34998
  return {
34684
34999
  name: profile.name,
34685
35000
  path: profile.path,
@@ -34716,7 +35031,7 @@ async function inspectProfile(profile) {
34716
35031
  }
34717
35032
  }
34718
35033
  async function inspectEnvironment(request, options) {
34719
- const root = resolve28(request.root || options.cwd || process.cwd());
35034
+ const root = resolve29(request.root || options.cwd || process.cwd());
34720
35035
  const profiles = await environmentProfiles(root);
34721
35036
  if (request.action === "list") {
34722
35037
  const active = options.activeContext?.environment || null;
@@ -34732,12 +35047,12 @@ async function inspectEnvironment(request, options) {
34732
35047
  }))
34733
35048
  };
34734
35049
  if (request.format === "json")
34735
- return jsonResult2(result);
35050
+ return jsonResult3(result);
34736
35051
  if (profiles.length === 0) {
34737
- return textResult4(`No .env.supacloud.<name> profiles found in ${root}.
35052
+ return textResult5(`No .env.supacloud.<name> profiles found in ${root}.
34738
35053
  Run \`supacloud deploy init\` to create safe examples.`);
34739
35054
  }
34740
- return textResult4([
35055
+ return textResult5([
34741
35056
  `Environment profiles in ${root}:`,
34742
35057
  ...result.environments.map((profile) => `${profile.active ? "*" : " "} ${profile.name} ${profile.path}`)
34743
35058
  ].join(`
@@ -34752,9 +35067,9 @@ Run \`supacloud deploy init\` to create safe examples.`);
34752
35067
  environments: reports
34753
35068
  };
34754
35069
  if (request.format === "json")
34755
- return jsonResult2(result, !result.ok);
35070
+ return jsonResult3(result, !result.ok);
34756
35071
  if (reports.length === 0) {
34757
- return textResult4(`No environment profiles found in ${root}.
35072
+ return textResult5(`No environment profiles found in ${root}.
34758
35073
  Run \`supacloud deploy init\` and copy an example profile.`, true);
34759
35074
  }
34760
35075
  const lines = reports.map((report) => {
@@ -34765,11 +35080,384 @@ Run \`supacloud deploy init\` and copy an example profile.`, true);
34765
35080
  const ref = report.projectRef ? `project=${report.projectRef}` : "project=unknown";
34766
35081
  return `${status} ${report.name} ${deploy} ${ref}`;
34767
35082
  });
34768
- return textResult4(lines.join(`
35083
+ return textResult5(lines.join(`
34769
35084
  `), !result.ok);
34770
35085
  }
34771
35086
  function registerDeveloperExperienceTools(server, options = {}) {
34772
- registerTool(server, "env", "List or locally validate named SupaCloud environment profiles without contacting the platform or printing secrets.", environmentToolSchema2, (request) => inspectEnvironment(request, options));
35087
+ registerTool(server, "env", "List or locally validate named SupaCloud environment profiles without contacting the platform or printing secrets.", environmentToolSchema2, (request) => {
35088
+ const input = request;
35089
+ if (input.action === "sync")
35090
+ return syncEnvironmentProfile(input, options);
35091
+ return inspectEnvironment(input, options);
35092
+ });
35093
+ }
35094
+
35095
+ // src/shared/tools/configuration-tools.ts
35096
+ import { existsSync as existsSync20 } from "node:fs";
35097
+ import { mkdir as mkdir10, readFile as readFile11, writeFile as writeFile10 } from "node:fs/promises";
35098
+ import { join as join23, resolve as resolve30 } from "node:path";
35099
+ var MANAGEMENT_CONFIGURATION_KEYS = ["SUPACLOUD_API_URL", "SUPACLOUD_API_TOKEN", "SUPACLOUD_PROJECT_REF"];
35100
+ var APPLICATION_CONFIGURATION_KEYS = ["SUPABASE_URL", "SUPABASE_SERVICE_ROLE_KEY", "SUPACLOUD_PROJECT_REF"];
35101
+ var onboardToolSchema2 = {
35102
+ root: optional(String2(), "Repository or configuration root (default: current directory)"),
35103
+ profile: optional(stringEnum2(["solo", "podman", "pigsty", "cluster"]), "Deployment profile (default: solo)"),
35104
+ domain: optional(String2(), "Public API domain; studio domain is derived from it"),
35105
+ database: optional(stringEnum2(["local", "external"]), "Database provider (default: local)"),
35106
+ storage: optional(stringEnum2(["juicefs", "external"]), "Storage provider (default: juicefs)"),
35107
+ write: optional(Boolean2(), "Write the generated context into supacloud.json"),
35108
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
35109
+ };
35110
+ var configurationToolSchema2 = {
35111
+ action: withDescription(stringEnum2(["doctor", "explain"]), "Configuration inspection action"),
35112
+ root: optional(String2(), "Repository or configuration root (default: current directory)"),
35113
+ key: optional(String2(), "[explain] Environment variable name"),
35114
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
35115
+ };
35116
+ var environmentSyncSchema2 = {
35117
+ action: withDescription(stringEnum2(["list", "check", "sync"]), "Environment profile action"),
35118
+ root: optional(String2(), "Project directory containing .env.supacloud.* files"),
35119
+ environment: optional(String2(), "[sync] Profile name; defaults to the selected environment"),
35120
+ write: optional(Boolean2(), "[sync] Persist derived context and the reduced profile example"),
35121
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
35122
+ };
35123
+ var SECRET_KEY2 = /(?:PASSWORD|PASS|SECRET|TOKEN|PRIVATE|CREDENTIAL|AUTHORIZATION|COOKIE|SESSION|DATABASE_URL|CONNECTION_STRING|DSN)/i;
35124
+ var PLATFORM_KEY2 = /^(?:SUPACLOUD|SUPABASE)_(?:API|PROJECT|ENV|HOST|SSH|APPLICATION|SERVICE_ROLE|ACCESS|URL|READ_ONLY|TLS|ANON|PUBLISHABLE)/;
35125
+ function textResult6(text, isError = false) {
35126
+ return { isError, content: [{ type: "text", text }] };
35127
+ }
35128
+ function jsonResult4(value, isError = false) {
35129
+ return textResult6(JSON.stringify(value, null, 2), isError);
35130
+ }
35131
+ function record9(value) {
35132
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
35133
+ }
35134
+ function unquote2(value) {
35135
+ const trimmed = value.trim();
35136
+ if (trimmed.length >= 2 && (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))) {
35137
+ return trimmed.slice(1, -1);
35138
+ }
35139
+ return trimmed;
35140
+ }
35141
+ function parseEnvironment2(content) {
35142
+ const values = {};
35143
+ for (const rawLine of content.split(/\r?\n/)) {
35144
+ const line = rawLine.trim();
35145
+ if (!line || line.startsWith("#"))
35146
+ continue;
35147
+ const match = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
35148
+ if (match)
35149
+ values[match[1]] = unquote2(match[2]);
35150
+ }
35151
+ return values;
35152
+ }
35153
+ async function readJsonObject2(path) {
35154
+ if (!existsSync20(path))
35155
+ return {};
35156
+ const parsed = JSON.parse(await readFile11(path, "utf8"));
35157
+ const value = record9(parsed);
35158
+ if (!value)
35159
+ throw new Error(`${path} must contain a JSON object`);
35160
+ return value;
35161
+ }
35162
+ async function writeJsonObject2(path, value) {
35163
+ await writeFile10(path, `${JSON.stringify(value, null, 2)}
35164
+ `, { encoding: "utf8", mode: 420 });
35165
+ }
35166
+ function contextFromConfig2(config) {
35167
+ const context = record9(config.context);
35168
+ return context ?? {};
35169
+ }
35170
+ function environmentContext2(config, environment) {
35171
+ const context = contextFromConfig2(config);
35172
+ const environments = record9(context.environments);
35173
+ const selected = environments ? record9(environments[environment]) : null;
35174
+ return selected ?? {};
35175
+ }
35176
+ function derivedValues(values) {
35177
+ const derived = {};
35178
+ const publicDomain = values.SUPABASE_PUBLIC_DOMAIN?.trim();
35179
+ if (publicDomain && !values.SUPABASE_STUDIO_DOMAIN) {
35180
+ derived.SUPABASE_STUDIO_DOMAIN = `studio.${publicDomain.replace(/^api\./, "")}`;
35181
+ }
35182
+ if (publicDomain && !values.SUPABASE_PUBLIC_URL) {
35183
+ derived.SUPABASE_PUBLIC_URL = `https://${publicDomain}`;
35184
+ }
35185
+ const host = values.SUPACLOUD_HOST?.trim();
35186
+ if (host && !values.SUPACLOUD_API_URL) {
35187
+ derived.SUPACLOUD_API_URL = `http://${host}:9090`;
35188
+ }
35189
+ if (values.SUPACLOUD_DEPLOYMENT_PROFILE === undefined) {
35190
+ derived.SUPACLOUD_DEPLOYMENT_PROFILE = "solo";
35191
+ }
35192
+ if (!values.S3_STORAGE_TYPE)
35193
+ derived.S3_STORAGE_TYPE = "juicefs";
35194
+ return derived;
35195
+ }
35196
+ function classify(name, value) {
35197
+ if (SECRET_KEY2.test(name))
35198
+ return "secret";
35199
+ if (PLATFORM_KEY2.test(name))
35200
+ return "platform";
35201
+ if (value === undefined || value === "")
35202
+ return "default";
35203
+ return "override";
35204
+ }
35205
+ function configurationEntries(values) {
35206
+ const derived = derivedValues(values);
35207
+ const names = [...new Set([...Object.keys(values), ...Object.keys(derived)])].sort();
35208
+ return names.map((name) => {
35209
+ const value = values[name] ?? derived[name];
35210
+ const kind = derived[name] !== undefined && values[name] === undefined ? "derived" : classify(name, values[name]);
35211
+ return {
35212
+ name,
35213
+ kind,
35214
+ source: kind === "derived" ? "platform-default" : values[name] === undefined ? "absent" : "profile",
35215
+ configured: value !== undefined && value !== "",
35216
+ value: kind === "secret" ? value ? "********" : null : value ?? null
35217
+ };
35218
+ });
35219
+ }
35220
+ function requiredConfigurationKeys(activeContext) {
35221
+ return activeContext?.credentialScope === "project_application" ? APPLICATION_CONFIGURATION_KEYS : MANAGEMENT_CONFIGURATION_KEYS;
35222
+ }
35223
+ function onboardingPlan(args, root) {
35224
+ const profile = typeof args.profile === "string" ? args.profile : "solo";
35225
+ const database = typeof args.database === "string" ? args.database : "local";
35226
+ const storage = typeof args.storage === "string" ? args.storage : "juicefs";
35227
+ const domain = typeof args.domain === "string" && args.domain.trim() ? args.domain.trim() : null;
35228
+ const required = ["profile"];
35229
+ if (domain === null)
35230
+ required.push("public_domain_or_explicit_ip");
35231
+ if (database === "external")
35232
+ required.push("database_url");
35233
+ if (storage === "external")
35234
+ required.push("s3_endpoint_and_credentials");
35235
+ return {
35236
+ schema: "supacloud.onboarding-plan.v1",
35237
+ root,
35238
+ profile,
35239
+ domain,
35240
+ database,
35241
+ storage,
35242
+ required_inputs: required,
35243
+ derived: {
35244
+ studio_domain: domain ? `studio.${domain.replace(/^api\./, "")}` : null,
35245
+ storage_backend: storage === "juicefs" ? "postgresql-large-object" : "external-s3",
35246
+ internal_service_urls: "allocated by the selected deployment profile",
35247
+ component_versions: "read from the verified release manifest"
35248
+ },
35249
+ writes: ["supacloud.json context metadata"],
35250
+ safety: [
35251
+ "unknown local PostgreSQL is never adopted automatically",
35252
+ "secret values are generated or injected and never printed",
35253
+ "external providers are requested only when selected"
35254
+ ]
35255
+ };
35256
+ }
35257
+ async function runOnboard(args, options) {
35258
+ const root = resolve30(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35259
+ const plan = onboardingPlan(args, root);
35260
+ if (args.write === true) {
35261
+ await mkdir10(root, { recursive: true });
35262
+ const path = join23(root, "supacloud.json");
35263
+ const config = await readJsonObject2(path);
35264
+ if (existsSync20(path) && config.context !== undefined) {
35265
+ throw new Error("supacloud.json already has context metadata; use env sync to update one environment");
35266
+ }
35267
+ config.context = {
35268
+ default_environment: "test",
35269
+ deployment_profile: plan.profile,
35270
+ public_domain: plan.domain,
35271
+ database: plan.database,
35272
+ storage: plan.storage,
35273
+ environments: {}
35274
+ };
35275
+ await writeJsonObject2(path, config);
35276
+ return jsonResult4({ ...plan, ok: true, written: path });
35277
+ }
35278
+ return args.format === "json" ? jsonResult4({ ...plan, ok: true, written: false }) : textResult6([
35279
+ "SupaCloud onboarding plan",
35280
+ `profile: ${String(plan.profile)}`,
35281
+ `database: ${String(plan.database)}`,
35282
+ `storage: ${String(plan.storage)}`,
35283
+ `domain: ${plan.domain ?? "(required)"}`,
35284
+ "",
35285
+ "No files were changed. Re-run with --write after reviewing the plan."
35286
+ ].join(`
35287
+ `));
35288
+ }
35289
+ async function runConfiguration(args, options) {
35290
+ const root = resolve30(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35291
+ const config = await readJsonObject2(join23(root, "supacloud.json"));
35292
+ const environment = options.activeContext?.environment || "";
35293
+ const profileValues = environment && existsSync20(join23(root, `.env.supacloud.${environment}`)) ? parseEnvironment2(await readFile11(join23(root, `.env.supacloud.${environment}`), "utf8")) : {};
35294
+ const metadata = environment ? environmentContext2(config, environment) : {};
35295
+ const values = {
35296
+ ...Object.fromEntries(Object.entries(metadata).filter(([, value]) => typeof value === "string")),
35297
+ ...profileValues
35298
+ };
35299
+ const entries = configurationEntries(Object.fromEntries([
35300
+ ...Object.entries(values),
35301
+ ...requiredConfigurationKeys(options.activeContext).map((name) => [name, values[name] ?? ""])
35302
+ ]));
35303
+ if (args.action === "explain") {
35304
+ const key = typeof args.key === "string" ? args.key.trim() : "";
35305
+ const selected = key ? entries.filter((entry) => entry.name === key) : entries;
35306
+ return jsonResult4({ schema: "supacloud.configuration.explain.v1", root, environment: environment || null, entries: selected });
35307
+ }
35308
+ const missing = entries.filter((entry) => entry.configured === false).map((entry) => entry.name);
35309
+ const secrets = entries.filter((entry) => entry.kind === "secret").map((entry) => entry.name);
35310
+ const result = {
35311
+ schema: "supacloud.configuration.doctor.v1",
35312
+ root,
35313
+ environment: environment || null,
35314
+ ok: missing.length === 0,
35315
+ missing,
35316
+ secret_names: secrets,
35317
+ entries,
35318
+ next: missing.length ? ["supacloud config explain"] : ["supacloud env sync --env test --write"]
35319
+ };
35320
+ return args.format === "json" ? jsonResult4(result, !result.ok) : textResult6([
35321
+ `Configuration: ${result.ok ? "OK" : "BLOCKED"}`,
35322
+ `environment: ${environment || "(none selected)"}`,
35323
+ missing.length ? `missing: ${missing.join(", ")}` : "missing: none",
35324
+ secrets.length ? `secrets: ${secrets.join(", ")}` : "secrets: none"
35325
+ ].join(`
35326
+ `), !result.ok);
35327
+ }
35328
+ function registerConfigurationTools(server, options = {}) {
35329
+ registerTool(server, "onboard", "Preview or write a minimal SupaCloud onboarding plan.", onboardToolSchema2, (args) => runOnboard(args, options));
35330
+ registerTool(server, "config", "Inspect configuration sources, derived values and missing inputs.", configurationToolSchema2, (args) => runConfiguration(args, options));
35331
+ }
35332
+
35333
+ // src/shared/tools/pipeline-tools.ts
35334
+ import { existsSync as existsSync21 } from "node:fs";
35335
+ import { mkdir as mkdir11, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
35336
+ import { join as join24, resolve as resolve31 } from "node:path";
35337
+ var pipelineToolSchema = {
35338
+ action: withDescription(stringEnum2(["connect"]), "Pipeline configuration action"),
35339
+ provider: optional(stringEnum2(["github", "gitlab"]), "[connect] Git provider (default: github)"),
35340
+ root: optional(String2(), "[connect] Repository root (default: current directory)"),
35341
+ write: optional(Boolean2(), "[connect] Write the generated workflow"),
35342
+ preview: optional(Boolean2(), "[connect] Include pull request Preview lifecycle"),
35343
+ format: optional(stringEnum2(["text", "json"]), "Output format (default: text)")
35344
+ };
35345
+ function textResult7(text, isError = false) {
35346
+ return { isError, content: [{ type: "text", text }] };
35347
+ }
35348
+ function jsonResult5(value, isError = false) {
35349
+ return textResult7(JSON.stringify(value, null, 2), isError);
35350
+ }
35351
+ function record10(value) {
35352
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
35353
+ }
35354
+ async function readJson2(path) {
35355
+ if (!existsSync21(path))
35356
+ return {};
35357
+ const parsed = JSON.parse(await readFile12(path, "utf8"));
35358
+ return record10(parsed) ?? {};
35359
+ }
35360
+ function workflow(provider, preview) {
35361
+ if (provider !== "github") {
35362
+ return [
35363
+ "stages:",
35364
+ " - deploy",
35365
+ "",
35366
+ "supacloud_deploy:",
35367
+ " stage: deploy",
35368
+ " image: node:24",
35369
+ " rules:",
35370
+ " - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'",
35371
+ " variables:",
35372
+ " SUPACLOUD_API_URL: $SUPACLOUD_API_URL",
35373
+ " SUPACLOUD_API_TOKEN: $SUPACLOUD_DEPLOY_TOKEN",
35374
+ " SUPACLOUD_PROJECT_REF: $SUPACLOUD_PROJECT_REF",
35375
+ " script:",
35376
+ " - npx @supacloud/cli deploy",
35377
+ ""
35378
+ ].join(`
35379
+ `);
35380
+ }
35381
+ const events = preview ? ` push:
35382
+ branches: [main]
35383
+ pull_request:
35384
+ types: [opened, synchronize, reopened, closed]` : ` push:
35385
+ branches: [main]`;
35386
+ const previewSteps = preview ? [
35387
+ " - name: Provision or reclaim PR Preview",
35388
+ " if: ${{ github.event_name == 'pull_request' }}",
35389
+ " env:",
35390
+ " SUPACLOUD_API_TOKEN: ${{ secrets.SUPACLOUD_DEPLOY_TOKEN }}",
35391
+ " SUPACLOUD_API_URL: ${{ secrets.SUPACLOUD_API_URL }}",
35392
+ " SUPACLOUD_PROJECT_REF: ${{ secrets.SUPACLOUD_PROJECT_REF }}",
35393
+ " run: >-",
35394
+ " npx @supacloud/cli --env test app preview-pr",
35395
+ " --id ${{ vars.SUPACLOUD_APPLICATION_ID }}",
35396
+ " --environment_id ${{ vars.SUPACLOUD_ENVIRONMENT_ID }}",
35397
+ " --pull_request_action ${{ github.event.action == 'closed' && 'closed' || 'opened' }}",
35398
+ " --repository ${{ github.repository }}",
35399
+ " --pull_request_number ${{ github.event.pull_request.number }}",
35400
+ " --release_id ${{ vars.SUPACLOUD_RELEASE_ID }}"
35401
+ ].join(`
35402
+ `) : "";
35403
+ return `name: SupaCloud deploy
35404
+
35405
+ on:
35406
+ ${events}
35407
+
35408
+ jobs:
35409
+ deploy:
35410
+ runs-on: ubuntu-latest
35411
+ steps:
35412
+ - uses: actions/checkout@v4
35413
+ - name: Deploy to SupaCloud
35414
+ if: \${{ github.event_name == 'push' || github.event.action == '' }}
35415
+ env:
35416
+ SUPACLOUD_API_URL: \${{ secrets.SUPACLOUD_API_URL }}
35417
+ SUPACLOUD_API_TOKEN: \${{ secrets.SUPACLOUD_DEPLOY_TOKEN }}
35418
+ SUPACLOUD_PROJECT_REF: \${{ secrets.SUPACLOUD_PROJECT_REF }}
35419
+ run: npx @supacloud/cli deploy
35420
+ ${previewSteps}`;
35421
+ }
35422
+ async function connectPipeline(args, options = {}) {
35423
+ const root = resolve31(typeof args.root === "string" ? args.root : options.cwd ?? process.cwd());
35424
+ const provider = typeof args.provider === "string" ? args.provider : "github";
35425
+ const config = await readJson2(join24(root, "supacloud.json"));
35426
+ const frontend = record10(config.frontend);
35427
+ const packageJson = await readJson2(join24(root, "package.json"));
35428
+ const scripts = record10(packageJson.scripts);
35429
+ const buildCommand = typeof frontend?.buildCommand === "string" ? frontend.buildCommand : typeof scripts?.build === "string" ? scripts.build : "(configure package.json build script)";
35430
+ const outputDirectory = typeof frontend?.outputDirectory === "string" ? frontend.outputDirectory : "dist";
35431
+ const workflowPath = provider === "github" ? join24(root, ".github", "workflows", "supacloud-deploy.yml") : join24(root, ".gitlab-ci.yml");
35432
+ const result = {
35433
+ schema: "supacloud.pipeline-connection.v1",
35434
+ provider,
35435
+ root,
35436
+ detected: { build_command: buildCommand, output_directory: outputDirectory },
35437
+ workflow: workflowPath,
35438
+ secrets: ["SUPACLOUD_DEPLOY_TOKEN", "SUPACLOUD_API_URL", "SUPACLOUD_PROJECT_REF"],
35439
+ variables: args.preview === true ? ["SUPACLOUD_APPLICATION_ID", "SUPACLOUD_ENVIRONMENT_ID", "SUPACLOUD_RELEASE_ID"] : [],
35440
+ preview: args.preview === true,
35441
+ safety: ["workflow contains no secret values", "provider token remains in the provider secret store"]
35442
+ };
35443
+ if (args.write !== true)
35444
+ return args.format === "json" ? jsonResult5({ ...result, written: false }) : textResult7([
35445
+ `Pipeline provider: ${provider}`,
35446
+ `build: ${buildCommand}`,
35447
+ `output: ${outputDirectory}`,
35448
+ `workflow: ${workflowPath}`,
35449
+ "No files were changed. Re-run with --write after reviewing the generated workflow."
35450
+ ].join(`
35451
+ `));
35452
+ if (provider === "gitlab" && existsSync21(workflowPath)) {
35453
+ throw new Error(`Refusing to overwrite existing GitLab workflow: ${workflowPath}`);
35454
+ }
35455
+ await mkdir11(resolve31(workflowPath, ".."), { recursive: true });
35456
+ await writeFile11(workflowPath, workflow(provider, args.preview === true), { encoding: "utf8", mode: 420 });
35457
+ return jsonResult5({ ...result, written: true });
35458
+ }
35459
+ function registerPipelineTools(server, options = {}) {
35460
+ registerTool(server, "pipeline", "Generate a provider workflow for deployment and optional PR Preview lifecycle.", pipelineToolSchema, (args) => connectPipeline(args, options));
34773
35461
  }
34774
35462
 
34775
35463
  // src/shared/tools/project-deployment.ts
@@ -34897,7 +35585,7 @@ async function runProjectDeployment(http, args) {
34897
35585
  // package.json
34898
35586
  var package_default = {
34899
35587
  name: "@supacloud/cli",
34900
- version: "0.121.9",
35588
+ version: "0.123.1",
34901
35589
  description: "Project-scoped CLI for SupaCloud users",
34902
35590
  type: "module",
34903
35591
  main: "./dist/index.js",
@@ -34949,26 +35637,26 @@ var package_default = {
34949
35637
  directory: "packages/cli"
34950
35638
  },
34951
35639
  dependencies: {
34952
- "@supacloud/compiler": "^0.62.6",
35640
+ "@supacloud/compiler": "^0.62.7",
34953
35641
  "@supacloud/delivery": "0.28.0",
34954
- "@supacloud/db": "0.24.2",
35642
+ "@supacloud/db": "0.25.1",
34955
35643
  typebox: "1.4.3"
34956
35644
  },
34957
35645
  overrides: {
34958
35646
  "@supacloud/contracts": "0.16.2",
34959
35647
  "@supacloud/delivery": "0.28.0",
34960
35648
  "@graphql-tools/utils": "^12.0.4",
34961
- "@supacloud/compiler": "^0.62.6",
34962
- "@supacloud/db": "0.24.2",
35649
+ "@supacloud/compiler": "^0.62.7",
35650
+ "@supacloud/db": "0.25.1",
34963
35651
  "deepmerge-ts": "8.0.2",
34964
35652
  prisma: "6.19.3"
34965
35653
  },
34966
35654
  devDependencies: {
34967
35655
  "@supabase/supabase-js": "2.118.0",
34968
- "@supacloud/elysia": "0.42.4",
35656
+ "@supacloud/elysia": "0.42.5",
34969
35657
  "@types/bun": "^1.4.4",
34970
35658
  effect: "4.0.5",
34971
- elysia: "2.0.0-rc.3",
35659
+ elysia: "2.0.0-rc.4",
34972
35660
  typescript: "7.1.0-beta"
34973
35661
  }
34974
35662
  };
@@ -35138,6 +35826,9 @@ USAGE
35138
35826
  ${preferredCommand} [global flags] deploy [--flags]
35139
35827
  ${preferredCommand} [global flags] <module> <action> [--flags]
35140
35828
  ${preferredCommand} deploy init [--root <directory>]
35829
+ ${preferredCommand} onboard [--profile solo] [--domain <domain>] [--write]
35830
+ ${preferredCommand} config <doctor|explain>
35831
+ ${preferredCommand} pipeline connect [--write] [--preview]
35141
35832
  ${preferredCommand} env <list|check> [--root <directory>]
35142
35833
  ${preferredCommand} [global flags] status
35143
35834
  ${preferredCommand} --help
@@ -35172,7 +35863,11 @@ DEFAULT CONTEXT
35172
35863
  EXAMPLES
35173
35864
 
35174
35865
  ${preferredCommand} deploy init
35866
+ ${preferredCommand} onboard
35867
+ ${preferredCommand} config doctor --format json
35868
+ ${preferredCommand} config explain --key SUPACLOUD_API_URL
35175
35869
  ${preferredCommand} env check
35870
+ ${preferredCommand} env sync --env test --write
35176
35871
  ${preferredCommand} env check --format json
35177
35872
  ${preferredCommand} status
35178
35873
  ${preferredCommand} deploy
@@ -35329,6 +36024,13 @@ function createCliTools(context, confirmProduction) {
35329
36024
  cwd: process.cwd(),
35330
36025
  activeContext: context
35331
36026
  })));
36027
+ Object.assign(tools, captureTools((server) => registerConfigurationTools(server, {
36028
+ cwd: process.cwd(),
36029
+ activeContext: context
36030
+ })));
36031
+ Object.assign(tools, captureTools((server) => registerPipelineTools(server, {
36032
+ cwd: process.cwd()
36033
+ })));
35332
36034
  Object.assign(tools, captureTools((server) => registerAppTools(server, { onDevProgress: writeDevProgress })));
35333
36035
  Object.assign(tools, captureTools((server) => registerDbGovernanceTools(server, {
35334
36036
  projectRef: context.projectRef || undefined,