@runa-ai/runa-cli 0.7.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/{build-HQMSVN6N.js → build-P2A6345N.js} +2 -2
  2. package/dist/{check-PCSQPYDM.js → check-4TZHNOZU.js} +4 -4
  3. package/dist/{chunk-DRSUEMAK.js → chunk-B7C7CLW2.js} +2 -5
  4. package/dist/{chunk-B3POLMII.js → chunk-BQ336L5T.js} +1 -1
  5. package/dist/{chunk-6FAU4IGR.js → chunk-ELXXQIGW.js} +4 -1
  6. package/dist/{chunk-FWMGC5FP.js → chunk-EXR4J2JT.js} +289 -16
  7. package/dist/{chunk-AO554K3G.js → chunk-GKBE7EIE.js} +1 -1
  8. package/dist/{chunk-JMJP4A47.js → chunk-GT5DMS5R.js} +20 -2
  9. package/dist/{chunk-3JO6YP3T.js → chunk-IEKYTCYA.js} +1 -1
  10. package/dist/{chunk-WPMR7RQ4.js → chunk-IWVXI5O4.js} +2 -2
  11. package/dist/chunk-KUH3G522.js +72 -0
  12. package/dist/{chunk-VSH3IXDQ.js → chunk-MAFJAA2P.js} +1 -1
  13. package/dist/{chunk-CCKG5R4Y.js → chunk-MILCC3B6.js} +1 -1
  14. package/dist/{chunk-5NKWR4FF.js → chunk-OERS32LW.js} +1 -1
  15. package/dist/{chunk-2QX7T24B.js → chunk-QKGL6Q2S.js} +1 -1
  16. package/dist/{chunk-OBYZDT2E.js → chunk-URWDB7YL.js} +15 -78
  17. package/dist/{chunk-CKRLVEIO.js → chunk-WGRVAGSR.js} +16 -11
  18. package/dist/chunk-YRNQEJQW.js +9043 -0
  19. package/dist/chunk-ZWDWFMOX.js +1514 -0
  20. package/dist/{ci-Z4525QW6.js → ci-S5KSBECX.js} +1226 -1207
  21. package/dist/{cli-SVXOSMW6.js → cli-TJZCAMB2.js} +30 -30
  22. package/dist/commands/ci/commands/ci-prod-db-operations.d.ts +12 -17
  23. package/dist/commands/ci/commands/ci-prod-utils.d.ts +7 -0
  24. package/dist/commands/ci/commands/ci-resolvers.d.ts +1 -2
  25. package/dist/commands/ci/commands/layer4-discovery.d.ts +2 -0
  26. package/dist/commands/ci/machine/actors/db/production-preview.d.ts +4 -3
  27. package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +5 -1
  28. package/dist/commands/ci/machine/actors/setup/pr-common.d.ts +1 -1
  29. package/dist/commands/ci/machine/actors/test/capabilities.d.ts +2 -13
  30. package/dist/commands/ci/machine/actors/test/index.d.ts +1 -0
  31. package/dist/commands/ci/machine/actors/test/layer-content.d.ts +11 -0
  32. package/dist/commands/ci/machine/commands/ci-pr-internal-profile.d.ts +7 -0
  33. package/dist/commands/ci/machine/commands/ci-step-registry.d.ts +25 -0
  34. package/dist/commands/ci/machine/commands/step-telemetry.d.ts +1 -2
  35. package/dist/commands/ci/machine/contract.d.ts +9 -1
  36. package/dist/commands/ci/machine/guards.d.ts +19 -10
  37. package/dist/commands/ci/machine/helpers.d.ts +1 -1
  38. package/dist/commands/ci/machine/machine-execution-helpers.d.ts +5 -2
  39. package/dist/commands/ci/machine/machine.d.ts +34 -32
  40. package/dist/commands/ci/machine/selectors.d.ts +6 -0
  41. package/dist/commands/ci/machine/types.d.ts +3 -1
  42. package/dist/commands/ci/utils/ci-logging.d.ts +16 -0
  43. package/dist/commands/ci/utils/rls-verification.d.ts +3 -2
  44. package/dist/commands/db/apply/actors/pg-schema-diff-actors.d.ts +1 -0
  45. package/dist/commands/db/apply/actors/seed-actors.d.ts +1 -0
  46. package/dist/commands/db/apply/contract.d.ts +232 -0
  47. package/dist/commands/db/apply/helpers/fresh-db-handler.d.ts +3 -1
  48. package/dist/commands/db/apply/helpers/hazard-handler.d.ts +19 -8
  49. package/dist/commands/db/apply/helpers/index.d.ts +5 -2
  50. package/dist/commands/db/apply/helpers/no-change-plan.d.ts +2 -0
  51. package/dist/commands/db/apply/helpers/plan-ast-sql-helpers.d.ts +19 -0
  52. package/dist/commands/db/apply/helpers/plan-ast.d.ts +1 -2
  53. package/dist/commands/db/apply/helpers/plan-check-filter.d.ts +11 -14
  54. package/dist/commands/db/apply/helpers/plan-validator.d.ts +34 -0
  55. package/dist/commands/db/apply/helpers/planner-artifact.d.ts +65 -0
  56. package/dist/commands/db/apply/helpers/retry-logic.d.ts +5 -0
  57. package/dist/commands/db/apply/machine.d.ts +100 -14
  58. package/dist/commands/db/commands/db-apply-error.d.ts +6 -1
  59. package/dist/commands/db/commands/db-apply.d.ts +5 -0
  60. package/dist/commands/db/commands/db-plan.d.ts +3 -0
  61. package/dist/commands/db/commands/db-preview-profile.d.ts +23 -0
  62. package/dist/commands/db/commands/db-preview.d.ts +3 -0
  63. package/dist/commands/db/sync/actors.d.ts +1 -0
  64. package/dist/commands/db/sync/contract.d.ts +16 -0
  65. package/dist/commands/db/sync/guardrail-orchestrator.d.ts +15 -0
  66. package/dist/commands/db/sync/guardrail-reporting.d.ts +12 -0
  67. package/dist/commands/db/sync/index.d.ts +4 -0
  68. package/dist/commands/db/sync/machine.d.ts +18 -13
  69. package/dist/commands/db/sync/schema-guardrail-config-test-support.d.ts +15 -0
  70. package/dist/commands/db/sync/schema-guardrail-config.d.ts +11 -0
  71. package/dist/commands/db/sync/schema-guardrail-ddl-order.d.ts +36 -0
  72. package/dist/commands/db/sync/schema-guardrail-graph-guidance.d.ts +15 -0
  73. package/dist/commands/db/sync/schema-guardrail-graph-metadata.d.ts +41 -0
  74. package/dist/commands/db/sync/schema-guardrail-graph-nodes.d.ts +61 -0
  75. package/dist/commands/db/sync/schema-guardrail-graph-sql-helpers.d.ts +31 -0
  76. package/dist/commands/db/sync/schema-guardrail-graph-types.d.ts +56 -0
  77. package/dist/commands/db/sync/schema-guardrail-graph.d.ts +20 -0
  78. package/dist/commands/db/sync/schema-guardrail-local-blockers.d.ts +7 -0
  79. package/dist/commands/db/sync/schema-guardrail-phases.d.ts +26 -0
  80. package/dist/commands/db/sync/schema-guardrail-production-check.d.ts +23 -0
  81. package/dist/commands/db/sync/schema-guardrail-rewrite.d.ts +46 -0
  82. package/dist/commands/db/sync/schema-guardrail-runtime.d.ts +5 -0
  83. package/dist/commands/db/sync/schema-guardrail-semantic-warnings.d.ts +9 -0
  84. package/dist/commands/db/sync/schema-guardrail-types.d.ts +243 -0
  85. package/dist/commands/db/sync/schema-guardrail.d.ts +10 -0
  86. package/dist/commands/db/utils/declarative-dependency-sql-utils.d.ts +1 -1
  87. package/dist/commands/db/utils/duplicate-function-ownership.d.ts +61 -0
  88. package/dist/commands/db/utils/plan-size-guard.d.ts +16 -0
  89. package/dist/commands/db/utils/policy-cross-schema-refs.d.ts +12 -0
  90. package/dist/commands/db/utils/preflight-checks/duplicate-function-ownership-checks.d.ts +4 -0
  91. package/dist/commands/db/utils/sql-table-extractor.d.ts +6 -0
  92. package/dist/commands/test/commands/layer4-prereqs.d.ts +15 -0
  93. package/dist/{config-loader-GT3HAQ7U.js → config-loader-N5ODNMD5.js} +2 -2
  94. package/dist/db-D2OLJDYW.js +12757 -0
  95. package/dist/{dev-MLRKIP7F.js → dev-LGSMDFJN.js} +7 -6
  96. package/dist/{doctor-ROSWSMLH.js → doctor-GYX73IEW.js} +4 -4
  97. package/dist/{env-WNHJVLOT.js → env-KYR6Q7WO.js} +15 -10
  98. package/dist/{env-files-HRNUGZ5O.js → env-files-ONBC47I6.js} +3 -3
  99. package/dist/{hotfix-Z5EGVSMH.js → hotfix-RJIAPLAM.js} +4 -4
  100. package/dist/index.js +3 -3
  101. package/dist/{init-35JLDFHI.js → init-2O6ODG5Z.js} +2 -2
  102. package/dist/{inject-test-attrs-XN4I2AOR.js → inject-test-attrs-F5A346UV.js} +3 -3
  103. package/dist/{manifest-EGCAZ4TK.js → manifest-CI4BRWEB.js} +2 -2
  104. package/dist/{observability-CJA5UFIC.js → observability-WNSCJ5FV.js} +2 -2
  105. package/dist/pg-schema-diff-helpers-7377FS2D.js +7 -0
  106. package/dist/{sdk-XK6HQU7S.js → sdk-BTIVPEE5.js} +1 -1
  107. package/dist/{test-V4KQL574.js → test-QCPN6Z47.js} +74 -46
  108. package/dist/{upgrade-7L4JIE4K.js → upgrade-QZKEI3NJ.js} +2 -2
  109. package/dist/utils/db-url-utils.d.ts +4 -77
  110. package/dist/{vuln-check-D575VXIQ.js → vuln-check-5NUTETPW.js} +1 -1
  111. package/dist/{vuln-checker-QV6XODTJ.js → vuln-checker-UV342N66.js} +1 -1
  112. package/dist/{watch-AL4LCBRM.js → watch-RFVCEQLH.js} +3 -3
  113. package/dist/{workflow-UZIZ2JUS.js → workflow-UOG6ZZMH.js} +3 -3
  114. package/package.json +3 -3
  115. package/dist/chunk-4XHZQRRK.js +0 -215
  116. package/dist/db-S4V4ETDR.js +0 -17556
@@ -2,9 +2,9 @@
2
2
  import { createRequire } from 'module';
3
3
  import './chunk-QDF7QXBL.js';
4
4
  import { getSnapshotStateName, isSnapshotComplete } from './chunk-XVNDDHAF.js';
5
- import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-VSH3IXDQ.js';
5
+ import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-MAFJAA2P.js';
6
6
  import { findRepoRoot } from './chunk-3WDV32GA.js';
7
- import { runLogged } from './chunk-6FAU4IGR.js';
7
+ import { runLogged } from './chunk-ELXXQIGW.js';
8
8
  import { createMachineStateChangeLogger } from './chunk-5FT3F36G.js';
9
9
  import './chunk-II7VYQEM.js';
10
10
  import './chunk-QSEF4T3Y.js';
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- export { checkCommand, runCheckCommand } from './chunk-2QX7T24B.js';
4
- import './chunk-WPMR7RQ4.js';
5
- import './chunk-DRSUEMAK.js';
3
+ export { checkCommand, runCheckCommand } from './chunk-QKGL6Q2S.js';
4
+ import './chunk-IWVXI5O4.js';
5
+ import './chunk-B7C7CLW2.js';
6
6
  import './chunk-KE6QJBZG.js';
7
7
  import './chunk-WJXC4MVY.js';
8
8
  import './chunk-HKUWEGUX.js';
9
- import './chunk-JMJP4A47.js';
9
+ import './chunk-GT5DMS5R.js';
10
10
  import './chunk-VRXHCR5K.js';
11
11
 
12
12
  createRequire(import.meta.url);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
3
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
4
- import { existsSync, realpathSync } from 'fs';
4
+ import { realpathSync } from 'fs';
5
5
  import { resolve, sep, isAbsolute, relative, normalize } from 'path';
6
6
 
7
7
  createRequire(import.meta.url);
@@ -10,10 +10,7 @@ createRequire(import.meta.url);
10
10
  init_esm_shims();
11
11
  function safeRealpath(targetPath) {
12
12
  try {
13
- if (existsSync(targetPath)) {
14
- return realpathSync(targetPath);
15
- }
16
- return targetPath;
13
+ return realpathSync(targetPath);
17
14
  } catch {
18
15
  return targetPath;
19
16
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { isPathContained } from './chunk-DRSUEMAK.js';
3
+ import { isPathContained } from './chunk-B7C7CLW2.js';
4
4
  import { emitJsonSuccess } from './chunk-KE6QJBZG.js';
5
5
  import { init_esm_shims, __dirname as __dirname$1 } from './chunk-VRXHCR5K.js';
6
6
  import * as fs2 from 'fs';
@@ -44,7 +44,10 @@ async function ensureRunaTmpDir(cwd) {
44
44
  return dir;
45
45
  }
46
46
  function runLogged(params) {
47
- console.log(`\u25B6 ${params.label}: ${params.command} ${redactArgsForLog(params.args).join(" ")}`);
47
+ process.stderr.write(
48
+ `\u25B6 ${params.label}: ${params.command} ${redactArgsForLog(params.args).join(" ")}
49
+ `
50
+ );
48
51
  const proc = execa(params.command, params.args, {
49
52
  cwd: params.cwd,
50
53
  env: { DOTENVX_QUIET: "1", ...params.env },
@@ -1,14 +1,294 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { init_esm_shims, __require } from './chunk-VRXHCR5K.js';
4
- import { existsSync, createWriteStream } from 'fs';
5
- import path from 'path';
6
- import { loadRunaConfig, CLIError } from '@runa-ai/runa';
7
- import { writeFile, readFile } from 'fs/promises';
3
+ import { detectEnvironment } from './chunk-GT5DMS5R.js';
4
+ import { init_esm_shims } from './chunk-VRXHCR5K.js';
5
+ import { appendFile, writeFile, readFile } from 'fs/promises';
6
+ import { CLIError, formatDuration, loadRunaConfig } from '@runa-ai/runa';
8
7
  import { z } from 'zod';
8
+ import { existsSync, createWriteStream, readFileSync, readdirSync } from 'fs';
9
+ import path from 'path';
9
10
 
10
11
  createRequire(import.meta.url);
11
12
 
13
+ // src/commands/ci/utils/github.ts
14
+ init_esm_shims();
15
+ async function appendGithubStepSummary(markdown) {
16
+ const file = process.env.GITHUB_STEP_SUMMARY;
17
+ if (!file) return;
18
+ await appendFile(file, `${markdown.trimEnd()}
19
+
20
+ `, "utf-8");
21
+ }
22
+ function addGithubMask(value) {
23
+ if (!value) return;
24
+ console.log(`::add-mask::${value}`);
25
+ }
26
+ z.object({
27
+ action: z.string().optional(),
28
+ pull_request: z.object({
29
+ number: z.number().int()
30
+ })
31
+ }).passthrough();
32
+
33
+ // src/commands/ci/commands/ci-prod-utils.ts
34
+ init_esm_shims();
35
+ function requireEnv(name) {
36
+ const v = process.env[name];
37
+ if (v && v.trim().length > 0) return v.trim();
38
+ throw new CLIError(
39
+ `Missing required environment variable: ${name}`,
40
+ "CI_INPUT_MISSING",
41
+ [`Set ${name} in GitHub Actions secrets/env`, "If unsure, run: runa check"],
42
+ void 0,
43
+ 10
44
+ );
45
+ }
46
+ function resolveRepoKind() {
47
+ const env = detectEnvironment(process.cwd());
48
+ const result = env === "runa-repo" ? "monorepo" : env === "pj-repo" ? "pj-repo" : "unknown";
49
+ if (process.env.RUNA_DEBUG === "true") {
50
+ console.error("[DEBUG:resolveRepoKind]", {
51
+ cwd: process.cwd(),
52
+ detectedEnv: env,
53
+ result
54
+ });
55
+ }
56
+ return result;
57
+ }
58
+ function createInitialSummary(params) {
59
+ return {
60
+ version: "1.0",
61
+ mode: params.mode,
62
+ command: "ci prod-apply",
63
+ status: "failure",
64
+ startedAt: params.startedAt.toISOString(),
65
+ endedAt: params.startedAt.toISOString(),
66
+ durationMs: 0,
67
+ repoKind: resolveRepoKind(),
68
+ detected: {},
69
+ diagnostics: {},
70
+ steps: {},
71
+ layers: {},
72
+ errors: []
73
+ };
74
+ }
75
+ function requireCiAutoApprove(params) {
76
+ if (params.mode !== "github-actions") return;
77
+ if (params.autoApprove === true) return;
78
+ throw new CLIError(
79
+ "Missing required flag: --auto-approve (required in CI mode)",
80
+ "CI_AUTO_APPROVE_REQUIRED",
81
+ ["Re-run with: runa ci prod-apply --auto-approve", "Keep CI non-interactive and deterministic"],
82
+ void 0,
83
+ 10
84
+ );
85
+ }
86
+ function resolveProdApplyInputs() {
87
+ const productionDatabaseUrlAdmin = requireEnv("GH_DATABASE_URL_ADMIN");
88
+ const productionDatabaseUrl = requireEnv("GH_DATABASE_URL");
89
+ addGithubMask(productionDatabaseUrlAdmin);
90
+ addGithubMask(productionDatabaseUrl);
91
+ return {
92
+ productionDatabaseUrlAdmin,
93
+ productionDatabaseUrl,
94
+ githubSha: process.env.GITHUB_SHA ?? "unknown",
95
+ githubActor: process.env.GITHUB_ACTOR ?? "unknown",
96
+ githubRepository: process.env.GITHUB_REPOSITORY ?? "unknown"
97
+ };
98
+ }
99
+ function classifyCiProdApplyError(error) {
100
+ if (error instanceof CLIError) {
101
+ return {
102
+ code: error.code ?? "CI_ERROR",
103
+ message: error.message,
104
+ retryable: false
105
+ };
106
+ }
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ if (message.startsWith("artifact_retry_requires_replan:")) {
109
+ return {
110
+ code: "artifact_retry_requires_replan",
111
+ message,
112
+ retryable: false
113
+ };
114
+ }
115
+ if (/timed out|timeout/i.test(message)) {
116
+ return {
117
+ code: "PHASE_TIMEOUT",
118
+ message,
119
+ retryable: true
120
+ };
121
+ }
122
+ return {
123
+ code: "CI_ERROR",
124
+ message,
125
+ retryable: false
126
+ };
127
+ }
128
+ function setSummaryErrorFromUnknown(summary, error) {
129
+ const classified = classifyCiProdApplyError(error);
130
+ summary.errors.push({
131
+ code: classified.code,
132
+ message: classified.message,
133
+ step: "ci prod-apply",
134
+ details: error instanceof CLIError && error.cause instanceof Error ? error.cause.message : void 0
135
+ });
136
+ }
137
+ function buildCiProdApplyStepSummaryMarkdown(params) {
138
+ const { summary } = params;
139
+ const lines = [];
140
+ const statusEmoji = summary.status === "success" ? "\u2705" : "\u274C";
141
+ const duration = formatDuration(summary.durationMs);
142
+ lines.push(
143
+ `## ${statusEmoji} Production Deploy ${summary.status === "success" ? "Completed" : "Failed"}`
144
+ );
145
+ lines.push("");
146
+ lines.push(`**Duration**: ${duration}`);
147
+ lines.push("");
148
+ if (summary.dbOutcome) {
149
+ lines.push(`**Exit mode**: \`${summary.dbOutcome.exitMode}\``);
150
+ const failedPhase = summary.dbOutcome.phases.find(
151
+ (phase) => phase.status === "failed" || phase.status === "timeout"
152
+ );
153
+ if (failedPhase) {
154
+ lines.push(`**Failed phase**: \`${failedPhase.id}\``);
155
+ }
156
+ if (summary.dbOutcome.summary.warnings > 0) {
157
+ lines.push(`**Warnings**: ${summary.dbOutcome.summary.warnings}`);
158
+ }
159
+ lines.push("");
160
+ }
161
+ const planSource = typeof summary.detected.dbPlanSource === "string" ? summary.detected.dbPlanSource : null;
162
+ const planReuseReason = typeof summary.detected.dbPlanReuseReason === "string" ? summary.detected.dbPlanReuseReason : null;
163
+ const planReuseMessage = typeof summary.detected.dbPlanReuseMessage === "string" ? summary.detected.dbPlanReuseMessage : null;
164
+ const planHasChanges = typeof summary.detected.dbPlanHasChanges === "boolean" ? summary.detected.dbPlanHasChanges : void 0;
165
+ if (planSource) {
166
+ lines.push(`**Plan source**: \`${planSource}\``);
167
+ if (planReuseReason) {
168
+ lines.push(
169
+ `**Plan reuse fallback**: \`${planReuseReason}\`${planReuseMessage ? ` \u2014 ${planReuseMessage}` : ""}`
170
+ );
171
+ }
172
+ if (planHasChanges === false) {
173
+ lines.push("**Plan result**: `no_changes`");
174
+ }
175
+ lines.push("");
176
+ }
177
+ if (summary.errors.length > 0) {
178
+ lines.push("### \u274C Errors");
179
+ lines.push("");
180
+ for (const e of summary.errors) {
181
+ lines.push(`- **${e.code}**: ${e.message}`);
182
+ }
183
+ lines.push("");
184
+ }
185
+ lines.push("<details>");
186
+ lines.push("<summary>\u{1F4CB} Technical Details</summary>");
187
+ lines.push("");
188
+ lines.push(`- Command: \`${summary.command}\``);
189
+ lines.push(`- Mode: \`${summary.mode}\``);
190
+ lines.push(`- Summary: \`${params.summaryPath}\``);
191
+ if (summary.dbOutcome) {
192
+ lines.push(`- DB exit mode: \`${summary.dbOutcome.exitMode}\``);
193
+ }
194
+ lines.push("");
195
+ lines.push("</details>");
196
+ lines.push("");
197
+ return lines.join("\n");
198
+ }
199
+
200
+ // src/commands/ci/commands/ci-resolvers.ts
201
+ init_esm_shims();
202
+
203
+ // src/commands/ci/utils/config-readers.ts
204
+ init_esm_shims();
205
+ function readNested(value, keyPath, guard) {
206
+ let current = value;
207
+ for (const key of keyPath) {
208
+ if (typeof current !== "object" || current === null) return null;
209
+ if (!(key in current)) return null;
210
+ current = current[key];
211
+ }
212
+ return guard(current) ? current : null;
213
+ }
214
+ var isBoolean = (v) => typeof v === "boolean";
215
+ var isString = (v) => typeof v === "string";
216
+ function readNestedBoolean(params) {
217
+ return readNested(params.value, params.keyPath, isBoolean);
218
+ }
219
+ function readNestedString(params) {
220
+ return readNested(params.value, params.keyPath, isString);
221
+ }
222
+
223
+ // src/commands/ci/commands/ci-resolvers.ts
224
+ function resolveMode(modeRaw) {
225
+ if (modeRaw === "github-actions" || modeRaw === "local") return modeRaw;
226
+ return process.env.GITHUB_ACTIONS === "true" ? "github-actions" : "local";
227
+ }
228
+ function resolveCiPrProfile(params) {
229
+ const raw = readNestedString({ value: params.config, keyPath: ["ci", "pr", "profile"] });
230
+ if (raw === "runa-strict" || raw === "pj-stable") return raw;
231
+ if (params.repoKind === "pj-repo") return "pj-stable";
232
+ return "runa-strict";
233
+ }
234
+ function debugLogPolicy(label, policy) {
235
+ if (process.env.RUNA_DEBUG === "true") {
236
+ console.error(`[DEBUG:resolveCiPrPolicy] \u2192 ${label}:`, policy);
237
+ }
238
+ }
239
+ var DEFAULT_POLICIES = {
240
+ monorepo: {
241
+ allowLocalFallback: false,
242
+ source: "default"
243
+ },
244
+ "pj-repo": {
245
+ allowLocalFallback: true,
246
+ source: "default"
247
+ },
248
+ "pj-stable-profile": {
249
+ allowLocalFallback: true,
250
+ source: "config"
251
+ },
252
+ unknown: {
253
+ allowLocalFallback: false,
254
+ source: "default"
255
+ }
256
+ };
257
+ function resolveCiPrPolicy(params) {
258
+ const allowLocalFallback = readNestedBoolean({
259
+ value: params.config,
260
+ keyPath: ["ci", "pr", "allowLocalFallback"]
261
+ });
262
+ if (process.env.RUNA_DEBUG === "true") {
263
+ console.error("[DEBUG:resolveCiPrPolicy] Inputs:", {
264
+ repoKind: params.repoKind,
265
+ hasConfig: params.config !== null && params.config !== void 0,
266
+ configValues: { allowLocalFallback }
267
+ });
268
+ }
269
+ if (typeof allowLocalFallback === "boolean") {
270
+ const policy2 = {
271
+ allowLocalFallback,
272
+ source: "config"
273
+ };
274
+ debugLogPolicy("config override", policy2);
275
+ return policy2;
276
+ }
277
+ const profile = resolveCiPrProfile({ repoKind: params.repoKind, config: params.config });
278
+ if (profile === "pj-stable") {
279
+ const policy2 = DEFAULT_POLICIES["pj-stable-profile"];
280
+ debugLogPolicy("pj-stable profile", policy2);
281
+ return policy2;
282
+ }
283
+ const policy = DEFAULT_POLICIES[params.repoKind] ?? DEFAULT_POLICIES.unknown;
284
+ debugLogPolicy(`${params.repoKind} default`, policy);
285
+ return policy;
286
+ }
287
+ function parseIntOr(value, fallback) {
288
+ const n = Number.parseInt(String(value ?? ""), 10);
289
+ return Number.isNaN(n) ? fallback : n;
290
+ }
291
+
12
292
  // src/commands/ci/machine/actors/setup/pr-common.ts
13
293
  init_esm_shims();
14
294
  function resolvePrContext(input) {
@@ -22,12 +302,8 @@ function resolvePrContext(input) {
22
302
  headBranch: input.githubHeadRef ?? null
23
303
  };
24
304
  }
25
- function resolvePolicy(_config, _repoKind) {
26
- return {
27
- allowLocalFallback: true,
28
- allowPartialPhases: false,
29
- source: "default"
30
- };
305
+ function resolvePolicy(config, repoKind) {
306
+ return resolveCiPrPolicy({ config, repoKind });
31
307
  }
32
308
  function detectRepoKind(repoRoot) {
33
309
  const hasApps = existsSync(path.join(repoRoot, "apps"));
@@ -70,7 +346,6 @@ function hasPackageJson(dir) {
70
346
  }
71
347
  function readAppsSubdirectoryNames(appsDir) {
72
348
  try {
73
- const { readdirSync } = __require("fs");
74
349
  const entries = readdirSync(appsDir, { withFileTypes: true });
75
350
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
76
351
  } catch {
@@ -114,7 +389,6 @@ function readPortFromScripts(appDir) {
114
389
  const pkgPath = path.join(appDir, "package.json");
115
390
  if (!existsSync(pkgPath)) return 3e3;
116
391
  try {
117
- const { readFileSync } = __require("fs");
118
392
  const raw = readFileSync(pkgPath, "utf-8");
119
393
  const parsed = JSON.parse(raw);
120
394
  const scripts = parsed.scripts;
@@ -176,7 +450,6 @@ function createErrorOutput(repoRoot, error, extraFields) {
176
450
  prContext: { prNumber: null, action: null, sha: null, baseBranch: null, headBranch: null },
177
451
  policy: {
178
452
  allowLocalFallback: true,
179
- allowPartialPhases: false,
180
453
  source: "default"
181
454
  },
182
455
  app: null,
@@ -201,7 +474,7 @@ async function executePrSetupBase(input, ensureTmpDir) {
201
474
  githubBaseRef: input.githubBaseRef,
202
475
  githubHeadRef: input.githubHeadRef
203
476
  });
204
- const policy = resolvePolicy(input.config);
477
+ const policy = resolvePolicy(input.config, repoKind);
205
478
  const configResult = loadRunaConfig(repoRoot);
206
479
  const appConfigOverride = configResult?.config?.app?.directory ? {
207
480
  directory: configResult.config.app.directory
@@ -458,4 +731,4 @@ async function waitForAppReady(params) {
458
731
  });
459
732
  }
460
733
 
461
- export { createErrorOutput, detectApp, executePrSetupBase, startAppBackground, waitForAppReady, writeEnvLocal };
734
+ export { addGithubMask, appendGithubStepSummary, buildCiProdApplyStepSummaryMarkdown, classifyCiProdApplyError, createErrorOutput, createInitialSummary, detectApp, executePrSetupBase, parseIntOr, requireCiAutoApprove, resolveMode, resolveProdApplyInputs, setSummaryErrorFromUnknown, startAppBackground, waitForAppReady, writeEnvLocal };
@@ -6,7 +6,7 @@ createRequire(import.meta.url);
6
6
 
7
7
  // src/version.ts
8
8
  init_esm_shims();
9
- var CLI_VERSION = "0.7.3";
9
+ var CLI_VERSION = "0.9.0";
10
10
  var HAS_ADMIN_COMMAND = false;
11
11
 
12
12
  export { CLI_VERSION, HAS_ADMIN_COMMAND };
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from 'module';
3
3
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
4
4
  import { existsSync, readFileSync, realpathSync } from 'fs';
5
- import { join, isAbsolute, normalize, resolve, relative } from 'path';
5
+ import { join, resolve, dirname, isAbsolute, normalize, relative } from 'path';
6
6
  import { findWorkspaceRoot as findWorkspaceRoot$1 } from '@runa-ai/runa';
7
7
 
8
8
  createRequire(import.meta.url);
@@ -200,5 +200,23 @@ function detectEnvironment(from = process.cwd()) {
200
200
  }
201
201
  return "unknown";
202
202
  }
203
+ function findRunaConfig(from = process.cwd()) {
204
+ let current = resolve(from);
205
+ while (true) {
206
+ const configPath = join(current, "runa.config.ts");
207
+ if (existsSync(configPath)) {
208
+ return configPath;
209
+ }
210
+ if (existsSync(join(current, ".git"))) {
211
+ return null;
212
+ }
213
+ const parent = dirname(current);
214
+ if (parent === current) {
215
+ break;
216
+ }
217
+ current = parent;
218
+ }
219
+ return null;
220
+ }
203
221
 
204
- export { detectEnvironment, findPackage, findWorkspaceRoot };
222
+ export { detectEnvironment, findPackage, findRunaConfig, findWorkspaceRoot };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { isPathContained } from './chunk-DRSUEMAK.js';
3
+ import { isPathContained } from './chunk-B7C7CLW2.js';
4
4
  import { secureGh, securePnpm } from './chunk-RZLYEO4U.js';
5
5
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
6
6
  import fs from 'fs';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { validateEnvSuffix, isPathContained, MAX_DIRECTORY_TRAVERSAL_DEPTH } from './chunk-DRSUEMAK.js';
4
- import { findWorkspaceRoot } from './chunk-JMJP4A47.js';
3
+ import { validateEnvSuffix, isPathContained, MAX_DIRECTORY_TRAVERSAL_DEPTH } from './chunk-B7C7CLW2.js';
4
+ import { findWorkspaceRoot } from './chunk-GT5DMS5R.js';
5
5
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
6
6
  import { existsSync, readFileSync } from 'fs';
7
7
  import path from 'path';
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module';
3
+ import { init_esm_shims } from './chunk-VRXHCR5K.js';
4
+ import { existsSync, writeFileSync, unlinkSync, readFileSync } from 'fs';
5
+ import path from 'path';
6
+
7
+ createRequire(import.meta.url);
8
+
9
+ // src/utils/env-local-bridge.ts
10
+ init_esm_shims();
11
+ var DEFAULT_API_PORT = 54321;
12
+ var DEFAULT_DB_PORT = 54322;
13
+ var RUNA_ENV_LOCAL_MARKER = "# RUNA_AUTO_GENERATED \u2014 do not edit (created by `runa db start`)";
14
+ function envLocalPath(projectRoot) {
15
+ return path.join(projectRoot, ".env.local");
16
+ }
17
+ function isNonDefaultPorts(config) {
18
+ return config.api !== DEFAULT_API_PORT || config.db !== DEFAULT_DB_PORT;
19
+ }
20
+ function buildEnvLocalContent(config) {
21
+ const dbUrl = `postgresql://postgres:postgres@${config.host}:${config.db}/postgres`;
22
+ return [
23
+ RUNA_ENV_LOCAL_MARKER,
24
+ `# Supabase is running on non-default ports (default: api=${DEFAULT_API_PORT}, db=${DEFAULT_DB_PORT}).`,
25
+ "# This file overrides .env.development so that `pnpm dev` uses correct ports.",
26
+ "# Removed automatically by `runa db stop`. Safe to delete manually.",
27
+ `DATABASE_URL=${dbUrl}`,
28
+ `DATABASE_URL_LISTENER=${dbUrl}`,
29
+ `DATABASE_URL_ADMIN=${dbUrl}`,
30
+ `DATABASE_URL_SERVICE=${dbUrl}`,
31
+ `NEXT_PUBLIC_SUPABASE_URL=http://${config.host}:${config.api}`,
32
+ ""
33
+ ].join("\n");
34
+ }
35
+ function isRunaManagedEnvLocal(projectRoot) {
36
+ const filePath = envLocalPath(projectRoot);
37
+ try {
38
+ const content = readFileSync(filePath, "utf-8");
39
+ return content.startsWith(RUNA_ENV_LOCAL_MARKER);
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ function writeEnvLocalBridge(projectRoot, config) {
45
+ const filePath = envLocalPath(projectRoot);
46
+ const fileExists = existsSync(filePath);
47
+ if (isNonDefaultPorts(config)) {
48
+ if (fileExists && !isRunaManagedEnvLocal(projectRoot)) {
49
+ return { written: false, reason: "user-managed" };
50
+ }
51
+ writeFileSync(filePath, buildEnvLocalContent(config), "utf-8");
52
+ return { written: true, ports: { api: config.api, db: config.db } };
53
+ }
54
+ if (fileExists && isRunaManagedEnvLocal(projectRoot)) {
55
+ unlinkSync(filePath);
56
+ return { written: false, reason: "stale-removed" };
57
+ }
58
+ return { written: false, reason: "default-ports" };
59
+ }
60
+ function removeEnvLocalBridge(projectRoot) {
61
+ const filePath = envLocalPath(projectRoot);
62
+ if (!existsSync(filePath)) {
63
+ return { removed: false, reason: "not-found" };
64
+ }
65
+ if (!isRunaManagedEnvLocal(projectRoot)) {
66
+ return { removed: false, reason: "user-managed" };
67
+ }
68
+ unlinkSync(filePath);
69
+ return { removed: true };
70
+ }
71
+
72
+ export { removeEnvLocalBridge, writeEnvLocalBridge };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { runLogged } from './chunk-6FAU4IGR.js';
3
+ import { runLogged } from './chunk-ELXXQIGW.js';
4
4
  import { init_constants, detectSupabasePorts } from './chunk-QSEF4T3Y.js';
5
5
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
6
6
  import { execSync, spawnSync } from 'child_process';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { getDatabasePackagePath } from './chunk-5NKWR4FF.js';
3
+ import { getDatabasePackagePath } from './chunk-OERS32LW.js';
4
4
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
5
5
  import { existsSync } from 'fs';
6
6
  import { join } from 'path';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { findPackage, findWorkspaceRoot } from './chunk-JMJP4A47.js';
3
+ import { findPackage, findWorkspaceRoot } from './chunk-GT5DMS5R.js';
4
4
  import { init_esm_shims } from './chunk-VRXHCR5K.js';
5
5
  import { existsSync, readFileSync } from 'fs';
6
6
  import path, { join } from 'path';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { loadEnvFiles } from './chunk-WPMR7RQ4.js';
3
+ import { loadEnvFiles } from './chunk-IWVXI5O4.js';
4
4
  import { emitJsonSuccess } from './chunk-KE6QJBZG.js';
5
5
  import { getOutputFormatFromEnv } from './chunk-HKUWEGUX.js';
6
6
  import { init_esm_shims } from './chunk-VRXHCR5K.js';