forgeos 0.1.0-alpha.0 → 0.1.0-alpha.2

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 (283) hide show
  1. package/.npmignore +9 -1
  2. package/AGENTS.md +6 -1
  3. package/CHANGELOG.md +30 -0
  4. package/CONTRIBUTING.md +22 -1
  5. package/README.md +30 -3
  6. package/bin/forge.mjs +4 -3
  7. package/package.json +3 -1
  8. package/packages/eslint-plugin-forge/index.ts +15 -15
  9. package/packages/eslint-plugin-forge/package.json +10 -10
  10. package/packages/eslint-plugin-forge/src/check-source.ts +95 -95
  11. package/packages/eslint-plugin-forge/src/load-artifacts.ts +24 -24
  12. package/packages/eslint-plugin-forge/src/rule-no-forge-guard-violation.ts +93 -93
  13. package/src/forge/_generated/actionSubscriptions.json +2 -2
  14. package/src/forge/_generated/actionSubscriptions.ts +3 -3
  15. package/src/forge/_generated/agentAdapterManifest.json +2 -2
  16. package/src/forge/_generated/agentAdapterManifest.ts +3 -3
  17. package/src/forge/_generated/agentContract.json +2 -2
  18. package/src/forge/_generated/agentContract.ts +6786 -2
  19. package/src/forge/_generated/agentQuickstart.md +1 -1
  20. package/src/forge/_generated/aiContext.ts +1 -1
  21. package/src/forge/_generated/aiModels.json +1 -1
  22. package/src/forge/_generated/aiModels.ts +1 -1
  23. package/src/forge/_generated/aiProviders.json +1 -1
  24. package/src/forge/_generated/aiProviders.ts +1 -1
  25. package/src/forge/_generated/aiRegistry.json +2 -2
  26. package/src/forge/_generated/aiRegistry.ts +3 -3
  27. package/src/forge/_generated/api.json +2 -2
  28. package/src/forge/_generated/api.ts +1 -1
  29. package/src/forge/_generated/appGraph.json +2 -2
  30. package/src/forge/_generated/appGraph.ts +1297 -1141
  31. package/src/forge/_generated/appMap.md +1 -1
  32. package/src/forge/_generated/artifactManifest.json +2 -2
  33. package/src/forge/_generated/artifactManifest.ts +2 -2
  34. package/src/forge/_generated/authClaims.json +1 -1
  35. package/src/forge/_generated/authClaims.ts +1 -1
  36. package/src/forge/_generated/authConfig.json +1 -1
  37. package/src/forge/_generated/authConfig.ts +1 -1
  38. package/src/forge/_generated/authContext.ts +1 -1
  39. package/src/forge/_generated/authRegistry.json +1 -1
  40. package/src/forge/_generated/authRegistry.ts +1 -1
  41. package/src/forge/_generated/buildInfo.json +2 -2
  42. package/src/forge/_generated/buildInfo.ts +4 -4
  43. package/src/forge/_generated/capabilityMap.json +2 -2
  44. package/src/forge/_generated/capabilityMap.md +1 -1
  45. package/src/forge/_generated/capabilityMap.ts +2 -2
  46. package/src/forge/_generated/client.ts +1 -1
  47. package/src/forge/_generated/clientApi.ts +1 -1
  48. package/src/forge/_generated/clientManifest.json +2 -2
  49. package/src/forge/_generated/clientManifest.ts +3 -3
  50. package/src/forge/_generated/clientTypes.ts +1 -1
  51. package/src/forge/_generated/configRegistry.json +1 -1
  52. package/src/forge/_generated/configRegistry.ts +1 -1
  53. package/src/forge/_generated/dataGraph.json +2 -2
  54. package/src/forge/_generated/dataGraph.ts +3 -3
  55. package/src/forge/_generated/db.json +1 -1
  56. package/src/forge/_generated/db.ts +1 -1
  57. package/src/forge/_generated/dbSecurityManifest.json +1 -1
  58. package/src/forge/_generated/dbSecurityManifest.ts +1 -1
  59. package/src/forge/_generated/dbSessionContext.json +1 -1
  60. package/src/forge/_generated/dbSessionContext.ts +1 -1
  61. package/src/forge/_generated/deployManifest.json +2 -2
  62. package/src/forge/_generated/deployManifest.ts +7 -7
  63. package/src/forge/_generated/devManifest.json +2 -2
  64. package/src/forge/_generated/devManifest.ts +3 -3
  65. package/src/forge/_generated/envSchema.json +1 -1
  66. package/src/forge/_generated/envSchema.ts +1 -1
  67. package/src/forge/_generated/frontendGraph.json +1 -1
  68. package/src/forge/_generated/frontendGraph.ts +1 -1
  69. package/src/forge/_generated/importGuards.json +2 -2
  70. package/src/forge/_generated/importGuards.ts +35 -1
  71. package/src/forge/_generated/index.ts +1 -1
  72. package/src/forge/_generated/liveProductionManifest.json +1 -1
  73. package/src/forge/_generated/liveProductionManifest.ts +1 -1
  74. package/src/forge/_generated/liveProtocol.json +1 -1
  75. package/src/forge/_generated/liveProtocol.ts +1 -1
  76. package/src/forge/_generated/liveQueryRegistry.json +2 -2
  77. package/src/forge/_generated/liveQueryRegistry.ts +3 -3
  78. package/src/forge/_generated/liveTransportConfig.json +1 -1
  79. package/src/forge/_generated/liveTransportConfig.ts +1 -1
  80. package/src/forge/_generated/makeRegistry.json +2 -2
  81. package/src/forge/_generated/makeRegistry.ts +2 -2
  82. package/src/forge/_generated/makeTemplates.json +1 -1
  83. package/src/forge/_generated/makeTemplates.ts +1 -1
  84. package/src/forge/_generated/mockMap.json +1 -1
  85. package/src/forge/_generated/mockMap.ts +1 -1
  86. package/src/forge/_generated/operationPlaybooks.md +7 -5
  87. package/src/forge/_generated/packageGraph.json +2 -2
  88. package/src/forge/_generated/packageGraph.ts +90964 -14284
  89. package/src/forge/_generated/packageUpgradeRegistry.json +2 -2
  90. package/src/forge/_generated/packageUpgradeRegistry.ts +2 -2
  91. package/src/forge/_generated/permissionMatrix.json +2 -2
  92. package/src/forge/_generated/permissionMatrix.ts +3 -3
  93. package/src/forge/_generated/policyRegistry.json +2 -2
  94. package/src/forge/_generated/policyRegistry.ts +3 -3
  95. package/src/forge/_generated/queryRegistry.json +2 -2
  96. package/src/forge/_generated/queryRegistry.ts +3 -3
  97. package/src/forge/_generated/react.d.ts +1 -1
  98. package/src/forge/_generated/react.ts +1 -1
  99. package/src/forge/_generated/reactManifest.json +2 -2
  100. package/src/forge/_generated/reactManifest.ts +3 -3
  101. package/src/forge/_generated/releaseManifest.json +2 -2
  102. package/src/forge/_generated/releaseManifest.ts +3 -3
  103. package/src/forge/_generated/rlsPolicies.json +1 -1
  104. package/src/forge/_generated/rlsPolicies.sql +1 -1
  105. package/src/forge/_generated/rlsPolicies.ts +1 -1
  106. package/src/forge/_generated/runtimeGraph.json +2 -2
  107. package/src/forge/_generated/runtimeGraph.ts +3 -3
  108. package/src/forge/_generated/runtimeMatrix.json +2 -2
  109. package/src/forge/_generated/runtimeMatrix.ts +106177 -7917
  110. package/src/forge/_generated/runtimeRegistry.ts +1 -1
  111. package/src/forge/_generated/runtimeRules.md +1 -1
  112. package/src/forge/_generated/secretRegistry.json +1 -1
  113. package/src/forge/_generated/secretRegistry.ts +1 -1
  114. package/src/forge/_generated/secretsContext.ts +1 -1
  115. package/src/forge/_generated/serverApi.ts +1 -1
  116. package/src/forge/_generated/sourceMapManifest.json +2 -2
  117. package/src/forge/_generated/sourceMapManifest.ts +2 -2
  118. package/src/forge/_generated/sqlPlan.json +1 -1
  119. package/src/forge/_generated/sqlPlan.ts +1 -1
  120. package/src/forge/_generated/subscriptionManifest.json +2 -2
  121. package/src/forge/_generated/subscriptionManifest.ts +3 -3
  122. package/src/forge/_generated/symbolicationManifest.json +2 -2
  123. package/src/forge/_generated/symbolicationManifest.ts +2 -2
  124. package/src/forge/_generated/telemetryRegistry.json +2 -2
  125. package/src/forge/_generated/telemetryRegistry.ts +3 -3
  126. package/src/forge/_generated/telemetrySinks.json +2 -2
  127. package/src/forge/_generated/telemetrySinks.ts +2 -2
  128. package/src/forge/_generated/tenantScope.json +2 -2
  129. package/src/forge/_generated/tenantScope.ts +3 -3
  130. package/src/forge/_generated/testGraph.json +2 -2
  131. package/src/forge/_generated/testGraph.ts +129 -75
  132. package/src/forge/_generated/testPlanRegistry.json +2 -2
  133. package/src/forge/_generated/testPlanRegistry.ts +2 -2
  134. package/src/forge/_generated/uiRoutes.json +1 -1
  135. package/src/forge/_generated/uiRoutes.ts +1 -1
  136. package/src/forge/_generated/uiScenarios.json +1 -1
  137. package/src/forge/_generated/uiScenarios.ts +1 -1
  138. package/src/forge/_generated/uiTestManifest.json +2 -2
  139. package/src/forge/_generated/uiTestManifest.ts +2 -2
  140. package/src/forge/_generated/workflowRegistry.json +2 -2
  141. package/src/forge/_generated/workflowRegistry.ts +3 -3
  142. package/src/forge/_generated/workflowSubscriptions.json +2 -2
  143. package/src/forge/_generated/workflowSubscriptions.ts +3 -3
  144. package/src/forge/cli/commands.ts +861 -861
  145. package/src/forge/cli/deps.ts +178 -11
  146. package/src/forge/cli/dev.ts +32 -5
  147. package/src/forge/cli/index.ts +7 -7
  148. package/src/forge/cli/main.ts +54 -54
  149. package/src/forge/cli/new.ts +29 -1
  150. package/src/forge/cli/output.ts +97 -97
  151. package/src/forge/cli/parse.ts +679 -673
  152. package/src/forge/cli/version.ts +1 -1
  153. package/src/forge/compiler/agent-contract/build.ts +28 -0
  154. package/src/forge/compiler/agent-contract/types.ts +16 -0
  155. package/src/forge/compiler/app-graph/build.ts +112 -112
  156. package/src/forge/compiler/app-graph/classify.ts +10 -10
  157. package/src/forge/compiler/app-graph/dup-symbol.ts +29 -29
  158. package/src/forge/compiler/app-graph/extract.ts +123 -123
  159. package/src/forge/compiler/app-graph/forge-apis.ts +29 -29
  160. package/src/forge/compiler/app-graph/index.ts +11 -11
  161. package/src/forge/compiler/app-graph/module-graph.ts +316 -316
  162. package/src/forge/compiler/app-graph/parser.ts +119 -119
  163. package/src/forge/compiler/app-graph/symbols.ts +48 -48
  164. package/src/forge/compiler/app-graph/tsconfig-hash.ts +62 -62
  165. package/src/forge/compiler/app-graph/types.ts +43 -43
  166. package/src/forge/compiler/app-graph/versions.ts +14 -14
  167. package/src/forge/compiler/cache/index.ts +17 -17
  168. package/src/forge/compiler/cache/key.ts +46 -46
  169. package/src/forge/compiler/cache/scheduler.ts +72 -72
  170. package/src/forge/compiler/cache/store.ts +78 -78
  171. package/src/forge/compiler/classifier/capabilities.ts +78 -78
  172. package/src/forge/compiler/classifier/classify.ts +113 -113
  173. package/src/forge/compiler/classifier/contexts.ts +188 -188
  174. package/src/forge/compiler/classifier/index.ts +18 -18
  175. package/src/forge/compiler/classifier/runtime-matrix.ts +45 -45
  176. package/src/forge/compiler/classifier/secrets.ts +41 -41
  177. package/src/forge/compiler/classifier/signals.ts +129 -129
  178. package/src/forge/compiler/diagnostics/codes.ts +125 -120
  179. package/src/forge/compiler/diagnostics/create.ts +87 -87
  180. package/src/forge/compiler/diagnostics/index.ts +41 -41
  181. package/src/forge/compiler/emitter/artifact-kind.ts +14 -14
  182. package/src/forge/compiler/emitter/barrel.ts +38 -38
  183. package/src/forge/compiler/emitter/constants.ts +7 -7
  184. package/src/forge/compiler/emitter/emit.ts +234 -237
  185. package/src/forge/compiler/emitter/index.ts +24 -24
  186. package/src/forge/compiler/emitter/lock.ts +61 -61
  187. package/src/forge/compiler/emitter/render.ts +73 -73
  188. package/src/forge/compiler/guards/artifacts.ts +96 -96
  189. package/src/forge/compiler/guards/check-import-guards.ts +106 -106
  190. package/src/forge/compiler/guards/index.ts +11 -11
  191. package/src/forge/compiler/guards/propagate-contexts.ts +57 -57
  192. package/src/forge/compiler/index.ts +17 -17
  193. package/src/forge/compiler/integration/add.ts +493 -493
  194. package/src/forge/compiler/integration/index.ts +17 -17
  195. package/src/forge/compiler/integration/plan.ts +279 -279
  196. package/src/forge/compiler/integration/render.ts +189 -189
  197. package/src/forge/compiler/integration/snapshot.ts +52 -52
  198. package/src/forge/compiler/orchestrator/discover.ts +214 -214
  199. package/src/forge/compiler/orchestrator/guards.ts +5 -5
  200. package/src/forge/compiler/orchestrator/index.ts +27 -27
  201. package/src/forge/compiler/orchestrator/manifest.ts +69 -69
  202. package/src/forge/compiler/orchestrator/orphans.ts +51 -51
  203. package/src/forge/compiler/orchestrator/plan.ts +804 -804
  204. package/src/forge/compiler/orchestrator/run.ts +178 -178
  205. package/src/forge/compiler/orchestrator/serialize.ts +859 -859
  206. package/src/forge/compiler/orchestrator/types.ts +23 -23
  207. package/src/forge/compiler/orchestrator/verify.ts +35 -35
  208. package/src/forge/compiler/package-graph/capabilities-stub.ts +33 -33
  209. package/src/forge/compiler/package-graph/checksum.ts +107 -97
  210. package/src/forge/compiler/package-graph/compiler.ts +444 -363
  211. package/src/forge/compiler/package-graph/constants.ts +4 -4
  212. package/src/forge/compiler/package-graph/exports-discovery.ts +91 -84
  213. package/src/forge/compiler/package-graph/extract-dts.ts +32 -32
  214. package/src/forge/compiler/package-graph/index.ts +24 -24
  215. package/src/forge/compiler/package-graph/jsdoc.ts +50 -50
  216. package/src/forge/compiler/package-graph/oracle.ts +326 -0
  217. package/src/forge/compiler/package-graph/read-file.ts +21 -21
  218. package/src/forge/compiler/package-graph/resolve.ts +131 -127
  219. package/src/forge/compiler/package-manager/adapter.ts +232 -232
  220. package/src/forge/compiler/package-manager/commands.ts +47 -47
  221. package/src/forge/compiler/package-manager/detect.ts +65 -65
  222. package/src/forge/compiler/package-manager/executor.ts +29 -29
  223. package/src/forge/compiler/package-manager/index.ts +22 -22
  224. package/src/forge/compiler/package-manager/parse-spec.ts +16 -16
  225. package/src/forge/compiler/package-manager/version.ts +20 -20
  226. package/src/forge/compiler/primitives/compare.ts +26 -26
  227. package/src/forge/compiler/primitives/hash.ts +42 -33
  228. package/src/forge/compiler/primitives/header.ts +43 -43
  229. package/src/forge/compiler/primitives/index.ts +45 -45
  230. package/src/forge/compiler/primitives/paths.ts +24 -24
  231. package/src/forge/compiler/primitives/serialize.ts +66 -66
  232. package/src/forge/compiler/primitives/sort.ts +87 -87
  233. package/src/forge/compiler/recipes/definitions.ts +269 -269
  234. package/src/forge/compiler/recipes/helpers.ts +37 -37
  235. package/src/forge/compiler/recipes/index.ts +21 -21
  236. package/src/forge/compiler/recipes/registry.ts +87 -87
  237. package/src/forge/compiler/sandbox/artifact-sanitize.ts +26 -26
  238. package/src/forge/compiler/sandbox/backends/child.ts +123 -123
  239. package/src/forge/compiler/sandbox/backends/docker.ts +173 -173
  240. package/src/forge/compiler/sandbox/index.ts +51 -51
  241. package/src/forge/compiler/sandbox/inspect.ts +143 -143
  242. package/src/forge/compiler/sandbox/inspector-entry.ts +115 -115
  243. package/src/forge/compiler/sandbox/limits.ts +31 -31
  244. package/src/forge/compiler/sandbox/scrub-env.ts +60 -60
  245. package/src/forge/compiler/sandbox/secret-scan.ts +54 -54
  246. package/src/forge/compiler/sandbox/serialize.ts +106 -106
  247. package/src/forge/compiler/sandbox/types.ts +7 -7
  248. package/src/forge/compiler/types/app-graph.ts +71 -71
  249. package/src/forge/compiler/types/capability.ts +29 -29
  250. package/src/forge/compiler/types/classification.ts +9 -9
  251. package/src/forge/compiler/types/cli.ts +85 -85
  252. package/src/forge/compiler/types/diagnostic.ts +2 -2
  253. package/src/forge/compiler/types/emit.ts +25 -25
  254. package/src/forge/compiler/types/import-guards.ts +19 -19
  255. package/src/forge/compiler/types/index.ts +98 -98
  256. package/src/forge/compiler/types/integration.ts +25 -25
  257. package/src/forge/compiler/types/json.ts +3 -3
  258. package/src/forge/compiler/types/lock.ts +37 -37
  259. package/src/forge/compiler/types/package-graph.ts +122 -77
  260. package/src/forge/compiler/types/runtime-matrix.ts +16 -16
  261. package/src/forge/compiler/types/runtime.ts +30 -30
  262. package/src/forge/compiler/types/sandbox.ts +24 -24
  263. package/src/forge/dev/server.ts +16 -2
  264. package/src/forge/refactor/index.ts +10 -2
  265. package/src/forge/refactor/runtime-rename.ts +598 -0
  266. package/src/forge/runtime/executor.ts +3 -2
  267. package/src/forge/runtime/live/live-query-runner.ts +2 -1
  268. package/src/forge/runtime/outbox/process.ts +2 -1
  269. package/src/forge/runtime/query/run-query.ts +2 -1
  270. package/src/forge/runtime/runner/run-entry.ts +2 -1
  271. package/src/forge/runtime/telemetry/sinks/posthog.ts +4 -5
  272. package/src/forge/runtime/telemetry/sinks/sentry.ts +4 -5
  273. package/src/forge/runtime/workflows/resolve-step.ts +2 -1
  274. package/src/forge/version.ts +3 -0
  275. package/templates/b2b-support-web/src/actions/captureTicketCreated.ts +7 -2
  276. package/templates/b2b-support-web/src/commands/closeTicket.ts +6 -1
  277. package/templates/b2b-support-web/src/commands/createTicket.ts +8 -2
  278. package/templates/b2b-support-web/src/queries/getTicket.ts +8 -1
  279. package/templates/b2b-support-web/web/components/CreateTicketForm.tsx +1 -2
  280. package/templates/b2b-support-web/web/components/PolicyDeniedDemo.tsx +1 -2
  281. package/templates/b2b-support-web/web/components/TicketList.tsx +1 -2
  282. package/templates/b2b-support-web/web/components/TraceDetails.tsx +1 -1
  283. package/templates/b2b-support-web/web/lib/forge.ts +1 -0
@@ -1,92 +1,92 @@
1
- import { nodeFileSystem } from "../compiler/fs/index.ts";
2
- import { join } from "node:path";
3
- import { stripDeterministicHeader } from "../compiler/primitives/header.ts";
4
- import { classify } from "../compiler/classifier/classify.ts";
5
- import { buildRuntimeMatrix } from "../compiler/classifier/runtime-matrix.ts";
6
- import { createDiagnostic } from "../compiler/diagnostics/create.ts";
7
- import { forgeAdd } from "../compiler/integration/add.ts";
8
- import { checkImportGuards } from "../compiler/guards/check-import-guards.ts";
9
- import { checkDirectProcessEnvUsage } from "../compiler/guards/check-process-env.ts";
10
- import { checkAiUsageInApp } from "../compiler/guards/check-ai-usage.ts";
11
- import { checkQueryUsageInApp } from "../compiler/guards/check-query-usage.ts";
12
- import { loadSecretRegistry } from "../runtime/secrets/check.ts";
13
- import { run } from "../compiler/orchestrator/run.ts";
14
- import {
15
- buildAppGraphForSession,
16
- discoverForSession,
17
- getCompileSession,
18
- } from "../compiler/orchestrator/session.ts";
19
- import { resolveByPackageName } from "../compiler/recipes/registry.ts";
20
- import { PackageGraphCompiler } from "../compiler/package-graph/compiler.ts";
1
+ import { nodeFileSystem } from "../compiler/fs/index.ts";
2
+ import { join } from "node:path";
3
+ import { stripDeterministicHeader } from "../compiler/primitives/header.ts";
4
+ import { classify } from "../compiler/classifier/classify.ts";
5
+ import { buildRuntimeMatrix } from "../compiler/classifier/runtime-matrix.ts";
6
+ import { createDiagnostic } from "../compiler/diagnostics/create.ts";
7
+ import { forgeAdd } from "../compiler/integration/add.ts";
8
+ import { checkImportGuards } from "../compiler/guards/check-import-guards.ts";
9
+ import { checkDirectProcessEnvUsage } from "../compiler/guards/check-process-env.ts";
10
+ import { checkAiUsageInApp } from "../compiler/guards/check-ai-usage.ts";
11
+ import { checkQueryUsageInApp } from "../compiler/guards/check-query-usage.ts";
12
+ import { loadSecretRegistry } from "../runtime/secrets/check.ts";
13
+ import { run } from "../compiler/orchestrator/run.ts";
14
+ import {
15
+ buildAppGraphForSession,
16
+ discoverForSession,
17
+ getCompileSession,
18
+ } from "../compiler/orchestrator/session.ts";
19
+ import { resolveByPackageName } from "../compiler/recipes/registry.ts";
20
+ import { PackageGraphCompiler } from "../compiler/package-graph/compiler.ts";
21
21
  import type {
22
22
  ForgeAddResult,
23
23
  GenerateOptions,
24
24
  GenerateResult,
25
25
  InspectResult,
26
- InspectTarget,
27
- VerifyOptions,
28
- VerifyResult,
26
+ InspectTarget,
27
+ VerifyOptions,
28
+ VerifyResult,
29
29
  } from "../compiler/types/cli.ts";
30
30
  import type { RuntimeMatrix } from "../compiler/types/runtime-matrix.ts";
31
31
  import type { FrontendGraph } from "../compiler/types/frontend-graph.ts";
32
- import { GENERATED_DIR } from "../compiler/emitter/constants.ts";
32
+ import { GENERATED_DIR } from "../compiler/emitter/constants.ts";
33
33
  import {
34
34
  attachFailureKind,
35
- buildAddJson,
36
- buildGenerateJson,
37
- buildInspectJson,
38
- formatJsonResult,
39
- writeHumanAdd,
40
- writeHumanGenerate,
41
- writeHumanInspect,
42
- buildVerifyJson,
43
- writeHumanVerify,
35
+ buildAddJson,
36
+ buildGenerateJson,
37
+ buildInspectJson,
38
+ formatJsonResult,
39
+ writeHumanAdd,
40
+ writeHumanGenerate,
41
+ writeHumanInspect,
42
+ buildVerifyJson,
43
+ writeHumanVerify,
44
44
  } from "./output.ts";
45
45
  import { INSPECT_TARGETS, TOP_LEVEL_COMMANDS, type ForgeCommand } from "./parse.ts";
46
- import { runVerifyCommand } from "./verify.ts";
47
- import {
48
- formatRunJson,
49
- formatRunListHuman,
50
- formatRunResultHuman,
51
- runRunCommand,
52
- } from "./run.ts";
53
- import { runDevCommand } from "./dev.ts";
54
- import { initializeRuntimeEnv } from "../runtime/context/create-context.ts";
55
- import { formatDbHuman, formatDbJson, runDbCommand } from "./db.ts";
56
- import { formatOutboxHuman, formatOutboxJson, runOutboxCommand } from "./outbox.ts";
57
- import {
58
- formatWorkflowHuman,
59
- formatWorkflowJson,
60
- runWorkflowCommand,
61
- } from "./workflow.ts";
62
- import {
63
- formatTelemetryHuman,
64
- formatTelemetryJson,
65
- runTelemetryCommand,
66
- } from "./telemetry.ts";
67
- import {
68
- formatPolicyHuman,
69
- formatPolicyJson,
70
- runPolicyCommand,
71
- } from "./policy.ts";
72
- import {
73
- formatEnvHuman,
74
- formatEnvJson,
75
- formatSecretsHuman,
76
- formatSecretsJson,
77
- runEnvCommand,
78
- runSecretsCommand,
79
- } from "./secrets.ts";
80
- import { formatAiHuman, formatAiJson, runAiCommand } from "./ai.ts";
81
- import { formatNewHuman, runNewCommand } from "./new.ts";
82
- import { formatBuildHuman, runBuildCommand } from "./build.ts";
83
- import { runServeCommand } from "./serve.ts";
84
- import { runWorkerCommand } from "./worker.ts";
85
- import { formatSelfHostHuman, runSelfHostCommand } from "./self-host.ts";
86
- import {
87
- formatAgentContractHuman,
88
- runAgentContractPrint,
89
- } from "./agent-contract.ts";
46
+ import { runVerifyCommand } from "./verify.ts";
47
+ import {
48
+ formatRunJson,
49
+ formatRunListHuman,
50
+ formatRunResultHuman,
51
+ runRunCommand,
52
+ } from "./run.ts";
53
+ import { runDevCommand } from "./dev.ts";
54
+ import { initializeRuntimeEnv } from "../runtime/context/create-context.ts";
55
+ import { formatDbHuman, formatDbJson, runDbCommand } from "./db.ts";
56
+ import { formatOutboxHuman, formatOutboxJson, runOutboxCommand } from "./outbox.ts";
57
+ import {
58
+ formatWorkflowHuman,
59
+ formatWorkflowJson,
60
+ runWorkflowCommand,
61
+ } from "./workflow.ts";
62
+ import {
63
+ formatTelemetryHuman,
64
+ formatTelemetryJson,
65
+ runTelemetryCommand,
66
+ } from "./telemetry.ts";
67
+ import {
68
+ formatPolicyHuman,
69
+ formatPolicyJson,
70
+ runPolicyCommand,
71
+ } from "./policy.ts";
72
+ import {
73
+ formatEnvHuman,
74
+ formatEnvJson,
75
+ formatSecretsHuman,
76
+ formatSecretsJson,
77
+ runEnvCommand,
78
+ runSecretsCommand,
79
+ } from "./secrets.ts";
80
+ import { formatAiHuman, formatAiJson, runAiCommand } from "./ai.ts";
81
+ import { formatNewHuman, runNewCommand } from "./new.ts";
82
+ import { formatBuildHuman, runBuildCommand } from "./build.ts";
83
+ import { runServeCommand } from "./serve.ts";
84
+ import { runWorkerCommand } from "./worker.ts";
85
+ import { formatSelfHostHuman, runSelfHostCommand } from "./self-host.ts";
86
+ import {
87
+ formatAgentContractHuman,
88
+ runAgentContractPrint,
89
+ } from "./agent-contract.ts";
90
90
  import {
91
91
  formatDoctorHuman,
92
92
  formatDoctorJson,
@@ -100,23 +100,23 @@ import {
100
100
  runWindowsDoctorCommand,
101
101
  runWindowsSetupCommand,
102
102
  } from "./windows.ts";
103
- import { formatAuthHuman, formatAuthJson, runAuthCommand } from "./auth.ts";
104
- import { formatRlsHuman, formatRlsJson, runRlsCommand } from "./rls.ts";
105
- import { formatDepsHuman, formatDepsJson, runDepsCommand } from "./deps.ts";
106
- import {
107
- formatReleaseHuman,
108
- formatReleaseJson,
109
- runReleaseCommand,
110
- } from "./release.ts";
111
- import { formatMakeHuman, formatMakeJson, runMakeCommand } from "./make.ts";
112
- import { formatFeatureHuman, formatFeatureJson, runFeatureCommand } from "./feature.ts";
113
- import { formatRefactorHuman, formatRefactorJson, runRefactorCommand } from "./refactor.ts";
114
- import {
115
- formatImpactHuman,
116
- formatImpactJson,
117
- runImpactCommand,
118
- runTestCommand,
119
- } from "../impact/index.ts";
103
+ import { formatAuthHuman, formatAuthJson, runAuthCommand } from "./auth.ts";
104
+ import { formatRlsHuman, formatRlsJson, runRlsCommand } from "./rls.ts";
105
+ import { formatDepsHuman, formatDepsJson, runDepsCommand } from "./deps.ts";
106
+ import {
107
+ formatReleaseHuman,
108
+ formatReleaseJson,
109
+ runReleaseCommand,
110
+ } from "./release.ts";
111
+ import { formatMakeHuman, formatMakeJson, runMakeCommand } from "./make.ts";
112
+ import { formatFeatureHuman, formatFeatureJson, runFeatureCommand } from "./feature.ts";
113
+ import { formatRefactorHuman, formatRefactorJson, runRefactorCommand } from "./refactor.ts";
114
+ import {
115
+ formatImpactHuman,
116
+ formatImpactJson,
117
+ runImpactCommand,
118
+ runTestCommand,
119
+ } from "../impact/index.ts";
120
120
  import {
121
121
  formatRepairHuman,
122
122
  formatRepairJson,
@@ -132,44 +132,44 @@ import {
132
132
  formatAgentJson,
133
133
  runAgentCommand,
134
134
  } from "../agent-adapters/index.ts";
135
- import {
136
- formatReviewHuman,
137
- formatReviewJson,
138
- runReviewCommand,
139
- renderReviewMarkdown,
140
- renderSarif,
141
- } from "../review/index.ts";
142
- import {
143
- formatUiHuman,
144
- formatUiJson,
145
- runUiCommand,
146
- runUiListCommand,
147
- } from "../ui/index.ts";
148
- import {
149
- formatQueryJson,
150
- formatQueryListHuman,
151
- formatQueryResultHuman,
152
- runQueryCommand,
153
- } from "./query.ts";
154
- import { runLiveCommand } from "./live.ts";
155
- import { runQuery } from "../runtime/query/run-query.ts";
156
- import { resolveAuthFromCli } from "../runtime/auth/resolve.ts";
157
- import { getActiveDbAdapter } from "../runtime/executor.ts";
158
-
159
- function readGeneratedJson<T>(workspaceRoot: string, relative: string): T | null {
160
- const absolute = join(workspaceRoot, relative);
161
- if (!nodeFileSystem.exists(absolute)) {
162
- return null;
163
- }
164
- const raw = stripDeterministicHeader((nodeFileSystem.readText(absolute) ?? ""));
165
- return JSON.parse(raw) as T;
166
- }
167
-
135
+ import {
136
+ formatReviewHuman,
137
+ formatReviewJson,
138
+ runReviewCommand,
139
+ renderReviewMarkdown,
140
+ renderSarif,
141
+ } from "../review/index.ts";
142
+ import {
143
+ formatUiHuman,
144
+ formatUiJson,
145
+ runUiCommand,
146
+ runUiListCommand,
147
+ } from "../ui/index.ts";
148
+ import {
149
+ formatQueryJson,
150
+ formatQueryListHuman,
151
+ formatQueryResultHuman,
152
+ runQueryCommand,
153
+ } from "./query.ts";
154
+ import { runLiveCommand } from "./live.ts";
155
+ import { runQuery } from "../runtime/query/run-query.ts";
156
+ import { resolveAuthFromCli } from "../runtime/auth/resolve.ts";
157
+ import { getActiveDbAdapter } from "../runtime/executor.ts";
158
+
159
+ function readGeneratedJson<T>(workspaceRoot: string, relative: string): T | null {
160
+ const absolute = join(workspaceRoot, relative);
161
+ if (!nodeFileSystem.exists(absolute)) {
162
+ return null;
163
+ }
164
+ const raw = stripDeterministicHeader((nodeFileSystem.readText(absolute) ?? ""));
165
+ return JSON.parse(raw) as T;
166
+ }
167
+
168
168
  function readGeneratedText(workspaceRoot: string, relative: string): string | null {
169
- const absolute = join(workspaceRoot, relative);
170
- if (!nodeFileSystem.exists(absolute)) {
171
- return null;
172
- }
169
+ const absolute = join(workspaceRoot, relative);
170
+ if (!nodeFileSystem.exists(absolute)) {
171
+ return null;
172
+ }
173
173
  return stripDeterministicHeader((nodeFileSystem.readText(absolute) ?? ""));
174
174
  }
175
175
 
@@ -269,70 +269,70 @@ function buildFrameworkInspect(workspaceRoot: string): Record<string, unknown> {
269
269
  },
270
270
  };
271
271
  }
272
-
273
- export async function runGenerateCommand(
274
- options: GenerateOptions,
275
- ): Promise<GenerateResult> {
276
- const result = await run(options);
277
- return attachFailureKind(result);
278
- }
279
-
280
- export async function runAddCommand(
281
- alias: string,
282
- options: Extract<ForgeCommand, { kind: "add" }>["options"],
283
- ): Promise<ForgeAddResult> {
284
- const result = await forgeAdd(alias, options);
285
- return attachFailureKind(result);
286
- }
287
-
288
- async function loadRuntimeMatrixForCheck(
289
- workspaceRoot: string,
290
- ): Promise<RuntimeMatrix> {
291
- const fromDisk = readGeneratedJson<RuntimeMatrix>(
292
- workspaceRoot,
293
- `${GENERATED_DIR}/runtimeMatrix.json`,
294
- );
295
- if (fromDisk) {
296
- return fromDisk;
297
- }
298
-
272
+
273
+ export async function runGenerateCommand(
274
+ options: GenerateOptions,
275
+ ): Promise<GenerateResult> {
276
+ const result = await run(options);
277
+ return attachFailureKind(result);
278
+ }
279
+
280
+ export async function runAddCommand(
281
+ alias: string,
282
+ options: Extract<ForgeCommand, { kind: "add" }>["options"],
283
+ ): Promise<ForgeAddResult> {
284
+ const result = await forgeAdd(alias, options);
285
+ return attachFailureKind(result);
286
+ }
287
+
288
+ async function loadRuntimeMatrixForCheck(
289
+ workspaceRoot: string,
290
+ ): Promise<RuntimeMatrix> {
291
+ const fromDisk = readGeneratedJson<RuntimeMatrix>(
292
+ workspaceRoot,
293
+ `${GENERATED_DIR}/runtimeMatrix.json`,
294
+ );
295
+ if (fromDisk) {
296
+ return fromDisk;
297
+ }
298
+
299
299
  const ctx = discoverForSession(getCompileSession(workspaceRoot));
300
- const compiler = new PackageGraphCompiler();
301
- const classified = await Promise.all(
302
- ctx.dependencies.map(async (dep) => {
303
- const recipe = resolveByPackageName(dep.name) ?? undefined;
304
- const api = await compiler.analyze(dep, {
305
- runtimeInspect: false,
306
- resolutionMode: "nodenext",
307
- cacheDir: ctx.cacheDir,
308
- recipeVersion: recipe?.recipeVersion,
309
- });
310
- return {
311
- api,
312
- classification: classify(api, recipe),
313
- recipe,
314
- };
315
- }),
316
- );
317
-
318
- return buildRuntimeMatrix(classified);
319
- }
320
-
321
- export async function runCheckCommand(
322
- workspaceRoot: string,
323
- options?: { strictSecrets?: boolean },
324
- ): Promise<GenerateResult> {
300
+ const compiler = new PackageGraphCompiler();
301
+ const classified = await Promise.all(
302
+ ctx.dependencies.map(async (dep) => {
303
+ const recipe = resolveByPackageName(dep.name) ?? undefined;
304
+ const api = await compiler.analyze(dep, {
305
+ runtimeInspect: false,
306
+ resolutionMode: "nodenext",
307
+ cacheDir: ctx.cacheDir,
308
+ recipeVersion: recipe?.recipeVersion,
309
+ });
310
+ return {
311
+ api,
312
+ classification: classify(api, recipe),
313
+ recipe,
314
+ };
315
+ }),
316
+ );
317
+
318
+ return buildRuntimeMatrix(classified);
319
+ }
320
+
321
+ export async function runCheckCommand(
322
+ workspaceRoot: string,
323
+ options?: { strictSecrets?: boolean },
324
+ ): Promise<GenerateResult> {
325
325
  const session = getCompileSession(workspaceRoot);
326
326
  const appGraph = await buildAppGraphForSession(session);
327
-
328
- const matrix = await loadRuntimeMatrixForCheck(workspaceRoot);
329
- const guardDiagnostics = checkImportGuards(appGraph.moduleGraph, matrix);
330
- const secretRegistry = loadSecretRegistry(workspaceRoot);
331
- const processEnvDiagnostics = checkDirectProcessEnvUsage(
332
- workspaceRoot,
333
- secretRegistry,
334
- options?.strictSecrets ?? false,
335
- );
327
+
328
+ const matrix = await loadRuntimeMatrixForCheck(workspaceRoot);
329
+ const guardDiagnostics = checkImportGuards(appGraph.moduleGraph, matrix);
330
+ const secretRegistry = loadSecretRegistry(workspaceRoot);
331
+ const processEnvDiagnostics = checkDirectProcessEnvUsage(
332
+ workspaceRoot,
333
+ secretRegistry,
334
+ options?.strictSecrets ?? false,
335
+ );
336
336
  const aiDiagnostics = checkAiUsageInApp(appGraph);
337
337
  const queryDiagnostics = checkQueryUsageInApp(appGraph);
338
338
  const frontendDiagnostics =
@@ -352,55 +352,55 @@ export async function runCheckCommand(
352
352
  ...frontendDiagnostics,
353
353
  ...capabilityDiagnostics,
354
354
  ];
355
- const errors = allDiagnostics.filter(
356
- (diagnostic) => diagnostic.severity === "error",
357
- );
358
- const warnings = allDiagnostics.filter(
359
- (diagnostic) => diagnostic.severity === "warning",
360
- );
361
-
362
- return attachFailureKind({
363
- changed: [],
364
- unchanged: [],
365
- warnings,
366
- errors,
367
- exitCode: errors.length > 0 ? 1 : 0,
368
- failureKind: errors.length > 0 ? "guard_violation" : undefined,
369
- });
370
- }
371
-
372
- export async function runInspectCommand(
373
- target: InspectTarget,
374
- workspaceRoot: string,
375
- ): Promise<InspectResult> {
376
- const dataPaths: Partial<Record<InspectTarget, string>> = {
377
- app: `${GENERATED_DIR}/appGraph.json`,
378
- packages: `${GENERATED_DIR}/packageGraph.json`,
355
+ const errors = allDiagnostics.filter(
356
+ (diagnostic) => diagnostic.severity === "error",
357
+ );
358
+ const warnings = allDiagnostics.filter(
359
+ (diagnostic) => diagnostic.severity === "warning",
360
+ );
361
+
362
+ return attachFailureKind({
363
+ changed: [],
364
+ unchanged: [],
365
+ warnings,
366
+ errors,
367
+ exitCode: errors.length > 0 ? 1 : 0,
368
+ failureKind: errors.length > 0 ? "guard_violation" : undefined,
369
+ });
370
+ }
371
+
372
+ export async function runInspectCommand(
373
+ target: InspectTarget,
374
+ workspaceRoot: string,
375
+ ): Promise<InspectResult> {
376
+ const dataPaths: Partial<Record<InspectTarget, string>> = {
377
+ app: `${GENERATED_DIR}/appGraph.json`,
378
+ packages: `${GENERATED_DIR}/packageGraph.json`,
379
379
  capabilities: `${GENERATED_DIR}/capabilityMap.json`,
380
- "runtime-matrix": `${GENERATED_DIR}/runtimeMatrix.json`,
381
- data: `${GENERATED_DIR}/dataGraph.json`,
382
- runtime: `${GENERATED_DIR}/runtimeGraph.json`,
383
- dev: `${GENERATED_DIR}/devManifest.json`,
384
- subscriptions: `${GENERATED_DIR}/actionSubscriptions.json`,
385
- workflows: `${GENERATED_DIR}/workflowRegistry.json`,
386
- telemetry: `${GENERATED_DIR}/telemetryRegistry.json`,
387
- policies: `${GENERATED_DIR}/policyRegistry.json`,
388
- secrets: `${GENERATED_DIR}/secretRegistry.json`,
389
- env: `${GENERATED_DIR}/envSchema.json`,
390
- ai: `${GENERATED_DIR}/aiRegistry.json`,
391
- queries: `${GENERATED_DIR}/queryRegistry.json`,
380
+ "runtime-matrix": `${GENERATED_DIR}/runtimeMatrix.json`,
381
+ data: `${GENERATED_DIR}/dataGraph.json`,
382
+ runtime: `${GENERATED_DIR}/runtimeGraph.json`,
383
+ dev: `${GENERATED_DIR}/devManifest.json`,
384
+ subscriptions: `${GENERATED_DIR}/actionSubscriptions.json`,
385
+ workflows: `${GENERATED_DIR}/workflowRegistry.json`,
386
+ telemetry: `${GENERATED_DIR}/telemetryRegistry.json`,
387
+ policies: `${GENERATED_DIR}/policyRegistry.json`,
388
+ secrets: `${GENERATED_DIR}/secretRegistry.json`,
389
+ env: `${GENERATED_DIR}/envSchema.json`,
390
+ ai: `${GENERATED_DIR}/aiRegistry.json`,
391
+ queries: `${GENERATED_DIR}/queryRegistry.json`,
392
392
  api: `${GENERATED_DIR}/api.json`,
393
393
  client: `${GENERATED_DIR}/clientManifest.json`,
394
394
  frontend: `${GENERATED_DIR}/frontendGraph.json`,
395
395
  auth: `${GENERATED_DIR}/authRegistry.json`,
396
- rls: `${GENERATED_DIR}/rlsPolicies.json`,
397
- "db-security": `${GENERATED_DIR}/dbSecurityManifest.json`,
398
- release: `${GENERATED_DIR}/releaseManifest.json`,
399
- artifacts: `${GENERATED_DIR}/artifactManifest.json`,
400
- sourcemaps: `${GENERATED_DIR}/sourceMapManifest.json`,
401
- "live-production": `${GENERATED_DIR}/liveProductionManifest.json`,
402
- "live-protocol": `${GENERATED_DIR}/liveProtocol.json`,
403
- "live-transport": `${GENERATED_DIR}/liveTransportConfig.json`,
396
+ rls: `${GENERATED_DIR}/rlsPolicies.json`,
397
+ "db-security": `${GENERATED_DIR}/dbSecurityManifest.json`,
398
+ release: `${GENERATED_DIR}/releaseManifest.json`,
399
+ artifacts: `${GENERATED_DIR}/artifactManifest.json`,
400
+ sourcemaps: `${GENERATED_DIR}/sourceMapManifest.json`,
401
+ "live-production": `${GENERATED_DIR}/liveProductionManifest.json`,
402
+ "live-protocol": `${GENERATED_DIR}/liveProtocol.json`,
403
+ "live-transport": `${GENERATED_DIR}/liveTransportConfig.json`,
404
404
  make: `${GENERATED_DIR}/makeRegistry.json`,
405
405
  "test-graph": `${GENERATED_DIR}/testGraph.json`,
406
406
  "test-plans": `${GENERATED_DIR}/testPlanRegistry.json`,
@@ -408,8 +408,8 @@ export async function runInspectCommand(
408
408
  "agent-adapters": `${GENERATED_DIR}/agentAdapterManifest.json`,
409
409
  "capability-map": `${GENERATED_DIR}/capabilityMap.json`,
410
410
  ui: `${GENERATED_DIR}/uiTestManifest.json`,
411
- "ui-scenarios": `${GENERATED_DIR}/uiScenarios.json`,
412
- "ui-routes": `${GENERATED_DIR}/uiRoutes.json`,
411
+ "ui-scenarios": `${GENERATED_DIR}/uiScenarios.json`,
412
+ "ui-routes": `${GENERATED_DIR}/uiRoutes.json`,
413
413
  rules: `${GENERATED_DIR}/runtimeRules.md`,
414
414
  map: `${GENERATED_DIR}/appMap.md`,
415
415
  };
@@ -425,122 +425,122 @@ export async function runInspectCommand(
425
425
  }
426
426
 
427
427
  if (target === "all") {
428
- const aggregatePaths: Array<[string, string]> = [
429
- ["app", `${GENERATED_DIR}/appGraph.json`],
430
- ["data", `${GENERATED_DIR}/dataGraph.json`],
431
- ["packages", `${GENERATED_DIR}/packageGraph.json`],
432
- ["runtimeMatrix", `${GENERATED_DIR}/runtimeMatrix.json`],
433
- ["runtime", `${GENERATED_DIR}/runtimeGraph.json`],
434
- ["policies", `${GENERATED_DIR}/policyRegistry.json`],
435
- ["secrets", `${GENERATED_DIR}/secretRegistry.json`],
436
- ["workflows", `${GENERATED_DIR}/workflowRegistry.json`],
437
- ["telemetry", `${GENERATED_DIR}/telemetryRegistry.json`],
438
- ["ai", `${GENERATED_DIR}/aiRegistry.json`],
428
+ const aggregatePaths: Array<[string, string]> = [
429
+ ["app", `${GENERATED_DIR}/appGraph.json`],
430
+ ["data", `${GENERATED_DIR}/dataGraph.json`],
431
+ ["packages", `${GENERATED_DIR}/packageGraph.json`],
432
+ ["runtimeMatrix", `${GENERATED_DIR}/runtimeMatrix.json`],
433
+ ["runtime", `${GENERATED_DIR}/runtimeGraph.json`],
434
+ ["policies", `${GENERATED_DIR}/policyRegistry.json`],
435
+ ["secrets", `${GENERATED_DIR}/secretRegistry.json`],
436
+ ["workflows", `${GENERATED_DIR}/workflowRegistry.json`],
437
+ ["telemetry", `${GENERATED_DIR}/telemetryRegistry.json`],
438
+ ["ai", `${GENERATED_DIR}/aiRegistry.json`],
439
439
  ["client", `${GENERATED_DIR}/clientManifest.json`],
440
440
  ["frontend", `${GENERATED_DIR}/frontendGraph.json`],
441
441
  ["auth", `${GENERATED_DIR}/authRegistry.json`],
442
- ["rls", `${GENERATED_DIR}/rlsPolicies.json`],
443
- ["dbSecurity", `${GENERATED_DIR}/dbSecurityManifest.json`],
444
- ["release", `${GENERATED_DIR}/releaseManifest.json`],
445
- ["artifacts", `${GENERATED_DIR}/artifactManifest.json`],
446
- ["sourceMaps", `${GENERATED_DIR}/sourceMapManifest.json`],
447
- ["liveProduction", `${GENERATED_DIR}/liveProductionManifest.json`],
448
- ["liveProtocol", `${GENERATED_DIR}/liveProtocol.json`],
449
- ["liveTransport", `${GENERATED_DIR}/liveTransportConfig.json`],
450
- ["make", `${GENERATED_DIR}/makeRegistry.json`],
442
+ ["rls", `${GENERATED_DIR}/rlsPolicies.json`],
443
+ ["dbSecurity", `${GENERATED_DIR}/dbSecurityManifest.json`],
444
+ ["release", `${GENERATED_DIR}/releaseManifest.json`],
445
+ ["artifacts", `${GENERATED_DIR}/artifactManifest.json`],
446
+ ["sourceMaps", `${GENERATED_DIR}/sourceMapManifest.json`],
447
+ ["liveProduction", `${GENERATED_DIR}/liveProductionManifest.json`],
448
+ ["liveProtocol", `${GENERATED_DIR}/liveProtocol.json`],
449
+ ["liveTransport", `${GENERATED_DIR}/liveTransportConfig.json`],
450
+ ["make", `${GENERATED_DIR}/makeRegistry.json`],
451
451
  ["testGraph", `${GENERATED_DIR}/testGraph.json`],
452
452
  ["testPlanRegistry", `${GENERATED_DIR}/testPlanRegistry.json`],
453
453
  ["agentContract", `${GENERATED_DIR}/agentContract.json`],
454
454
  ["agentAdapters", `${GENERATED_DIR}/agentAdapterManifest.json`],
455
455
  ["capabilityMap", `${GENERATED_DIR}/capabilityMap.json`],
456
456
  ["ui", `${GENERATED_DIR}/uiTestManifest.json`],
457
- ["uiScenarios", `${GENERATED_DIR}/uiScenarios.json`],
458
- ["uiRoutes", `${GENERATED_DIR}/uiRoutes.json`],
459
- ];
460
- const data: Record<string, unknown> = {};
461
- const errors = [];
462
- for (const [key, relative] of aggregatePaths) {
463
- const value = readGeneratedJson<unknown>(workspaceRoot, relative);
464
- if (value === null) {
465
- errors.push(
466
- createDiagnostic({
467
- severity: "error",
468
- code: "FORGE_INSPECT_MISSING",
469
- message: `missing generated artifact: ${relative}; run forge generate first`,
470
- file: relative,
471
- }),
472
- );
473
- } else {
474
- data[key] = value;
475
- }
457
+ ["uiScenarios", `${GENERATED_DIR}/uiScenarios.json`],
458
+ ["uiRoutes", `${GENERATED_DIR}/uiRoutes.json`],
459
+ ];
460
+ const data: Record<string, unknown> = {};
461
+ const errors = [];
462
+ for (const [key, relative] of aggregatePaths) {
463
+ const value = readGeneratedJson<unknown>(workspaceRoot, relative);
464
+ if (value === null) {
465
+ errors.push(
466
+ createDiagnostic({
467
+ severity: "error",
468
+ code: "FORGE_INSPECT_MISSING",
469
+ message: `missing generated artifact: ${relative}; run forge generate first`,
470
+ file: relative,
471
+ }),
472
+ );
473
+ } else {
474
+ data[key] = value;
475
+ }
476
476
  }
477
477
  data.framework = buildFrameworkInspect(workspaceRoot);
478
478
  data.diagnostics = errors;
479
479
  return {
480
- target,
481
- data,
482
- warnings: [],
483
- errors,
484
- exitCode: errors.length > 0 ? 1 : 0,
485
- failureKind: errors.length > 0 ? "missing_artifact" : undefined,
486
- };
487
- }
488
-
489
- const relative = dataPaths[target];
490
- if (!relative) {
491
- return {
492
- target,
493
- data: null,
494
- warnings: [],
495
- errors: [
496
- createDiagnostic({
497
- severity: "error",
498
- code: "FORGE_INSPECT_MISSING",
499
- message: `unsupported inspect target: ${target}`,
500
- }),
501
- ],
502
- exitCode: 1,
503
- failureKind: "missing_artifact",
504
- };
505
- }
506
- const data =
507
- target === "rules" || target === "map"
508
- ? readGeneratedText(workspaceRoot, relative)
509
- : readGeneratedJson<unknown>(workspaceRoot, relative);
510
-
511
- if (data === null) {
512
- return {
513
- target,
514
- data: null,
515
- warnings: [],
516
- errors: [
517
- createDiagnostic({
518
- severity: "error",
519
- code: "FORGE_INSPECT_MISSING",
520
- message: `missing generated artifact: ${relative}; run forge generate first`,
521
- file: relative,
522
- }),
523
- ],
524
- exitCode: 1,
525
- failureKind: "missing_artifact",
526
- };
527
- }
528
-
529
- return {
530
- target,
531
- data,
532
- warnings: [],
533
- errors: [],
534
- exitCode: 0,
535
- };
536
- }
537
-
538
- export async function executeCommand(command: ForgeCommand): Promise<number> {
539
- switch (command.kind) {
540
- case "new": {
541
- const result = await runNewCommand({
542
- name: command.name,
543
- template: command.template,
480
+ target,
481
+ data,
482
+ warnings: [],
483
+ errors,
484
+ exitCode: errors.length > 0 ? 1 : 0,
485
+ failureKind: errors.length > 0 ? "missing_artifact" : undefined,
486
+ };
487
+ }
488
+
489
+ const relative = dataPaths[target];
490
+ if (!relative) {
491
+ return {
492
+ target,
493
+ data: null,
494
+ warnings: [],
495
+ errors: [
496
+ createDiagnostic({
497
+ severity: "error",
498
+ code: "FORGE_INSPECT_MISSING",
499
+ message: `unsupported inspect target: ${target}`,
500
+ }),
501
+ ],
502
+ exitCode: 1,
503
+ failureKind: "missing_artifact",
504
+ };
505
+ }
506
+ const data =
507
+ target === "rules" || target === "map"
508
+ ? readGeneratedText(workspaceRoot, relative)
509
+ : readGeneratedJson<unknown>(workspaceRoot, relative);
510
+
511
+ if (data === null) {
512
+ return {
513
+ target,
514
+ data: null,
515
+ warnings: [],
516
+ errors: [
517
+ createDiagnostic({
518
+ severity: "error",
519
+ code: "FORGE_INSPECT_MISSING",
520
+ message: `missing generated artifact: ${relative}; run forge generate first`,
521
+ file: relative,
522
+ }),
523
+ ],
524
+ exitCode: 1,
525
+ failureKind: "missing_artifact",
526
+ };
527
+ }
528
+
529
+ return {
530
+ target,
531
+ data,
532
+ warnings: [],
533
+ errors: [],
534
+ exitCode: 0,
535
+ };
536
+ }
537
+
538
+ export async function executeCommand(command: ForgeCommand): Promise<number> {
539
+ switch (command.kind) {
540
+ case "new": {
541
+ const result = await runNewCommand({
542
+ name: command.name,
543
+ template: command.template,
544
544
  packageManager: command.packageManager,
545
545
  install: command.install,
546
546
  git: command.git,
@@ -548,62 +548,62 @@ export async function executeCommand(command: ForgeCommand): Promise<number> {
548
548
  localForge: command.localForge,
549
549
  workspaceRoot: command.workspaceRoot,
550
550
  });
551
- process.stdout.write(formatNewHuman(result));
552
- return result.exitCode;
553
- }
554
- case "build": {
555
- const result = await runBuildCommand({
556
- workspaceRoot: command.workspaceRoot,
557
- json: command.json,
558
- });
559
- if (command.json) {
560
- process.stdout.write(`${JSON.stringify(result)}\n`);
561
- } else {
562
- process.stdout.write(formatBuildHuman(result));
563
- }
564
- return result.exitCode;
565
- }
566
- case "serve":
567
- return runServeCommand(command);
568
- case "worker": {
569
- const result = await runWorkerCommand(command);
570
- return result.exitCode;
571
- }
572
- case "self-host": {
573
- const result = await runSelfHostCommand(command);
574
- if (command.json) {
575
- process.stdout.write(`${JSON.stringify(result)}\n`);
576
- } else {
577
- process.stdout.write(formatSelfHostHuman(result));
578
- }
579
- return result.exitCode;
580
- }
581
- case "agent-contract": {
582
- if (command.subcommand === "print") {
583
- const result = runAgentContractPrint(command.workspaceRoot);
584
- if (command.json) {
585
- process.stdout.write(`${JSON.stringify(result.data, null, 2)}\n`);
586
- } else {
587
- process.stdout.write(formatAgentContractHuman(command.subcommand, result));
588
- }
589
- return result.exitCode;
590
- }
591
-
592
- const result = await runGenerateCommand({
593
- workspaceRoot: command.workspaceRoot,
594
- check: command.subcommand === "check",
595
- dryRun: false,
596
- json: command.json,
597
- concurrency: 4,
598
- });
599
- if (command.json) {
600
- process.stdout.write(formatJsonResult(buildGenerateJson(result)));
601
- } else {
602
- process.stdout.write(formatAgentContractHuman(command.subcommand, result));
603
- writeHumanGenerate(result);
604
- }
605
- return result.exitCode;
606
- }
551
+ process.stdout.write(formatNewHuman(result));
552
+ return result.exitCode;
553
+ }
554
+ case "build": {
555
+ const result = await runBuildCommand({
556
+ workspaceRoot: command.workspaceRoot,
557
+ json: command.json,
558
+ });
559
+ if (command.json) {
560
+ process.stdout.write(`${JSON.stringify(result)}\n`);
561
+ } else {
562
+ process.stdout.write(formatBuildHuman(result));
563
+ }
564
+ return result.exitCode;
565
+ }
566
+ case "serve":
567
+ return runServeCommand(command);
568
+ case "worker": {
569
+ const result = await runWorkerCommand(command);
570
+ return result.exitCode;
571
+ }
572
+ case "self-host": {
573
+ const result = await runSelfHostCommand(command);
574
+ if (command.json) {
575
+ process.stdout.write(`${JSON.stringify(result)}\n`);
576
+ } else {
577
+ process.stdout.write(formatSelfHostHuman(result));
578
+ }
579
+ return result.exitCode;
580
+ }
581
+ case "agent-contract": {
582
+ if (command.subcommand === "print") {
583
+ const result = runAgentContractPrint(command.workspaceRoot);
584
+ if (command.json) {
585
+ process.stdout.write(`${JSON.stringify(result.data, null, 2)}\n`);
586
+ } else {
587
+ process.stdout.write(formatAgentContractHuman(command.subcommand, result));
588
+ }
589
+ return result.exitCode;
590
+ }
591
+
592
+ const result = await runGenerateCommand({
593
+ workspaceRoot: command.workspaceRoot,
594
+ check: command.subcommand === "check",
595
+ dryRun: false,
596
+ json: command.json,
597
+ concurrency: 4,
598
+ });
599
+ if (command.json) {
600
+ process.stdout.write(formatJsonResult(buildGenerateJson(result)));
601
+ } else {
602
+ process.stdout.write(formatAgentContractHuman(command.subcommand, result));
603
+ writeHumanGenerate(result);
604
+ }
605
+ return result.exitCode;
606
+ }
607
607
  case "doctor": {
608
608
  if (command.target === "windows") {
609
609
  const result = await runWindowsDoctorCommand({ workspaceRoot: command.workspaceRoot });
@@ -634,91 +634,91 @@ export async function executeCommand(command: ForgeCommand): Promise<number> {
634
634
  }
635
635
  return result.exitCode;
636
636
  }
637
- case "auth": {
638
- const result = await runAuthCommand(command);
639
- if (command.json) {
640
- process.stdout.write(formatAuthJson(result));
641
- } else {
642
- process.stdout.write(formatAuthHuman(result));
643
- }
644
- return result.exitCode;
645
- }
646
- case "rls": {
647
- const result = await runRlsCommand(command);
648
- if (command.json) {
649
- process.stdout.write(formatRlsJson(result));
650
- } else {
651
- process.stdout.write(formatRlsHuman(command.subcommand, result));
652
- }
653
- return result.exitCode;
654
- }
655
- case "deps": {
656
- const result = await runDepsCommand(command);
657
- if (command.json) {
658
- process.stdout.write(formatDepsJson(result));
659
- } else {
660
- process.stdout.write(formatDepsHuman(command.subcommand, result));
661
- }
662
- return result.exitCode;
663
- }
664
- case "release": {
665
- const result = await runReleaseCommand({
666
- ...command,
667
- provider: command.provider as import("../compiler/release/types.ts").ReleaseExportProvider | undefined,
668
- target: command.target as import("../compiler/release/types.ts").ReleaseExportProvider | undefined,
669
- });
670
- if (command.json) {
671
- process.stdout.write(formatReleaseJson(result));
672
- } else {
673
- process.stdout.write(formatReleaseHuman(result));
674
- }
675
- return result.exitCode;
676
- }
677
- case "make": {
678
- const result = await runMakeCommand(command.options);
679
- if (command.options.json) {
680
- process.stdout.write(formatMakeJson(result));
681
- } else {
682
- process.stdout.write(formatMakeHuman(result));
683
- }
684
- return result.exitCode;
685
- }
686
- case "feature": {
687
- const result = await runFeatureCommand(command.options);
688
- if (command.options.json) {
689
- process.stdout.write(formatFeatureJson(result));
690
- } else {
691
- process.stdout.write(formatFeatureHuman(result));
692
- }
693
- return result.exitCode;
694
- }
695
- case "refactor": {
696
- const result = await runRefactorCommand(command.options);
697
- if (command.options.json) {
698
- process.stdout.write(formatRefactorJson(result));
699
- } else {
700
- process.stdout.write(formatRefactorHuman(result));
701
- }
702
- return result.exitCode;
703
- }
704
- case "impact": {
705
- const result = runImpactCommand(command.options);
706
- if (command.options.json) {
707
- process.stdout.write(formatImpactJson(result));
708
- } else {
709
- process.stdout.write(formatImpactHuman(result));
710
- }
711
- return result.exitCode;
712
- }
713
- case "test": {
714
- const result = await runTestCommand(command.options);
715
- if (command.options.json) {
716
- process.stdout.write(formatImpactJson(result));
717
- } else {
718
- process.stdout.write(formatImpactHuman(result));
719
- }
720
- return result.exitCode;
721
- }
637
+ case "auth": {
638
+ const result = await runAuthCommand(command);
639
+ if (command.json) {
640
+ process.stdout.write(formatAuthJson(result));
641
+ } else {
642
+ process.stdout.write(formatAuthHuman(result));
643
+ }
644
+ return result.exitCode;
645
+ }
646
+ case "rls": {
647
+ const result = await runRlsCommand(command);
648
+ if (command.json) {
649
+ process.stdout.write(formatRlsJson(result));
650
+ } else {
651
+ process.stdout.write(formatRlsHuman(command.subcommand, result));
652
+ }
653
+ return result.exitCode;
654
+ }
655
+ case "deps": {
656
+ const result = await runDepsCommand(command);
657
+ if (command.json) {
658
+ process.stdout.write(formatDepsJson(result));
659
+ } else {
660
+ process.stdout.write(formatDepsHuman(command.subcommand, result));
661
+ }
662
+ return result.exitCode;
663
+ }
664
+ case "release": {
665
+ const result = await runReleaseCommand({
666
+ ...command,
667
+ provider: command.provider as import("../compiler/release/types.ts").ReleaseExportProvider | undefined,
668
+ target: command.target as import("../compiler/release/types.ts").ReleaseExportProvider | undefined,
669
+ });
670
+ if (command.json) {
671
+ process.stdout.write(formatReleaseJson(result));
672
+ } else {
673
+ process.stdout.write(formatReleaseHuman(result));
674
+ }
675
+ return result.exitCode;
676
+ }
677
+ case "make": {
678
+ const result = await runMakeCommand(command.options);
679
+ if (command.options.json) {
680
+ process.stdout.write(formatMakeJson(result));
681
+ } else {
682
+ process.stdout.write(formatMakeHuman(result));
683
+ }
684
+ return result.exitCode;
685
+ }
686
+ case "feature": {
687
+ const result = await runFeatureCommand(command.options);
688
+ if (command.options.json) {
689
+ process.stdout.write(formatFeatureJson(result));
690
+ } else {
691
+ process.stdout.write(formatFeatureHuman(result));
692
+ }
693
+ return result.exitCode;
694
+ }
695
+ case "refactor": {
696
+ const result = await runRefactorCommand(command.options);
697
+ if (command.options.json) {
698
+ process.stdout.write(formatRefactorJson(result));
699
+ } else {
700
+ process.stdout.write(formatRefactorHuman(result));
701
+ }
702
+ return result.exitCode;
703
+ }
704
+ case "impact": {
705
+ const result = runImpactCommand(command.options);
706
+ if (command.options.json) {
707
+ process.stdout.write(formatImpactJson(result));
708
+ } else {
709
+ process.stdout.write(formatImpactHuman(result));
710
+ }
711
+ return result.exitCode;
712
+ }
713
+ case "test": {
714
+ const result = await runTestCommand(command.options);
715
+ if (command.options.json) {
716
+ process.stdout.write(formatImpactJson(result));
717
+ } else {
718
+ process.stdout.write(formatImpactHuman(result));
719
+ }
720
+ return result.exitCode;
721
+ }
722
722
  case "repair": {
723
723
  const result = await runRepairCommand(command.options);
724
724
  if (command.options.json) {
@@ -739,171 +739,171 @@ export async function executeCommand(command: ForgeCommand): Promise<number> {
739
739
  }
740
740
  case "agent": {
741
741
  const result = await runAgentCommand(command.options);
742
- if (command.options.json) {
743
- process.stdout.write(formatAgentJson(result));
744
- } else {
745
- process.stdout.write(formatAgentHuman(result));
746
- }
747
- return result.exitCode;
748
- }
749
- case "review": {
750
- const result = runReviewCommand(command.options);
751
- if (command.options.json) {
752
- process.stdout.write(formatReviewJson(result));
753
- } else if (command.options.md && result.report) {
754
- process.stdout.write(renderReviewMarkdown(result.report));
755
- } else if (command.options.sarif && result.report && !command.options.write) {
756
- process.stdout.write(renderSarif(result.report));
757
- } else {
758
- process.stdout.write(formatReviewHuman(result));
759
- }
760
- return result.exitCode;
761
- }
762
- case "ui": {
763
- const result =
764
- command.options.subcommand === "list"
765
- ? runUiListCommand(command.options.workspaceRoot)
766
- : await runUiCommand(command.options);
767
- if (command.options.json) {
768
- process.stdout.write(formatUiJson(result));
769
- } else {
770
- process.stdout.write(formatUiHuman(result));
771
- }
772
- return result.exitCode;
773
- }
774
- case "generate": {
775
- const result = await runGenerateCommand({
776
- workspaceRoot: process.cwd(),
777
- check: command.check,
778
- dryRun: command.dryRun,
779
- json: command.json,
780
- concurrency: command.concurrency,
781
- });
782
-
783
- if (command.json) {
784
- process.stdout.write(formatJsonResult(buildGenerateJson(result)));
785
- } else {
786
- writeHumanGenerate(result);
787
- }
788
-
789
- return result.exitCode;
790
- }
791
- case "add": {
792
- const result = await runAddCommand(command.alias, command.options);
793
- if (command.options.json) {
794
- process.stdout.write(formatJsonResult(buildAddJson(result)));
795
- } else {
796
- writeHumanAdd(result);
797
- }
798
- return result.exitCode;
799
- }
800
- case "inspect": {
801
- const result = await runInspectCommand(
802
- command.target,
803
- process.cwd(),
804
- );
805
- if (command.json) {
806
- process.stdout.write(formatJsonResult(buildInspectJson(result)));
807
- } else if (typeof result.data === "string") {
808
- process.stdout.write(result.data);
809
- } else {
810
- writeHumanInspect(result);
811
- }
812
- return result.exitCode;
813
- }
814
- case "check": {
815
- const result = await runCheckCommand(process.cwd(), {
816
- strictSecrets: command.strictSecrets,
817
- });
818
- if (command.json) {
819
- process.stdout.write(formatJsonResult(buildGenerateJson(result)));
820
- } else {
821
- writeHumanGenerate(result);
822
- }
823
- return result.exitCode;
824
- }
825
- case "verify": {
826
- const result = await runVerifyCommand(command.options);
827
- if (command.options.json) {
828
- process.stdout.write(formatJsonResult(buildVerifyJson(result)));
829
- } else {
830
- writeHumanVerify(result);
831
- }
832
- return result.exitCode;
833
- }
834
- case "run": {
835
- initializeRuntimeEnv(
836
- command.workspaceRoot,
837
- command.envFile ? [command.envFile] : undefined,
838
- );
839
-
840
- if (command.queryMode && command.name) {
841
- const tableMap = readGeneratedJson<{ tableMap: Record<string, import("../compiler/data-graph/sql/serialize.ts").TableMapEntry> }>(
842
- command.workspaceRoot,
843
- `${GENERATED_DIR}/db.json`,
844
- )?.tableMap;
845
-
846
- const run = await runQuery(
847
- command.workspaceRoot,
848
- command.name,
849
- {
850
- args: command.args,
851
- auth: resolveAuthFromCli({
852
- userId: command.userId,
853
- tenantId: command.tenantId,
854
- role: command.role,
855
- }),
856
- },
857
- {
858
- adapter: getActiveDbAdapter(),
859
- tableMap,
860
- },
861
- );
862
-
863
- if (command.json) {
864
- process.stdout.write(`${JSON.stringify({ run }, null, 2)}\n`);
865
- } else {
866
- process.stdout.write(formatQueryResultHuman(run));
867
- }
868
- return run.exitCode;
869
- }
870
-
871
- const result = await runRunCommand({
872
- name: command.name,
873
- list: command.list,
874
- json: command.json,
875
- mock: command.mock,
876
- userId: command.userId,
877
- tenantId: command.tenantId,
878
- role: command.role,
879
- workspaceRoot: command.workspaceRoot,
880
- });
881
-
882
- if (command.json) {
883
- process.stdout.write(formatRunJson(result));
884
- } else if (result.list) {
885
- process.stdout.write(formatRunListHuman(result.list));
886
- } else if (result.run) {
887
- process.stdout.write(formatRunResultHuman(result.run));
888
- }
889
-
890
- return result.exitCode;
891
- }
892
- case "dev": {
893
- initializeRuntimeEnv(
894
- command.workspaceRoot,
895
- command.envFile ? [command.envFile] : undefined,
896
- );
897
- const result = await runDevCommand({
898
- workspaceRoot: command.workspaceRoot,
899
- host: command.host,
900
- port: command.port,
901
- mock: command.mock,
902
- mockAi: command.mockAi,
903
- once: command.once,
904
- watch: command.watch,
905
- json: command.json,
906
- db: command.db,
742
+ if (command.options.json) {
743
+ process.stdout.write(formatAgentJson(result));
744
+ } else {
745
+ process.stdout.write(formatAgentHuman(result));
746
+ }
747
+ return result.exitCode;
748
+ }
749
+ case "review": {
750
+ const result = runReviewCommand(command.options);
751
+ if (command.options.json) {
752
+ process.stdout.write(formatReviewJson(result));
753
+ } else if (command.options.md && result.report) {
754
+ process.stdout.write(renderReviewMarkdown(result.report));
755
+ } else if (command.options.sarif && result.report && !command.options.write) {
756
+ process.stdout.write(renderSarif(result.report));
757
+ } else {
758
+ process.stdout.write(formatReviewHuman(result));
759
+ }
760
+ return result.exitCode;
761
+ }
762
+ case "ui": {
763
+ const result =
764
+ command.options.subcommand === "list"
765
+ ? runUiListCommand(command.options.workspaceRoot)
766
+ : await runUiCommand(command.options);
767
+ if (command.options.json) {
768
+ process.stdout.write(formatUiJson(result));
769
+ } else {
770
+ process.stdout.write(formatUiHuman(result));
771
+ }
772
+ return result.exitCode;
773
+ }
774
+ case "generate": {
775
+ const result = await runGenerateCommand({
776
+ workspaceRoot: process.cwd(),
777
+ check: command.check,
778
+ dryRun: command.dryRun,
779
+ json: command.json,
780
+ concurrency: command.concurrency,
781
+ });
782
+
783
+ if (command.json) {
784
+ process.stdout.write(formatJsonResult(buildGenerateJson(result)));
785
+ } else {
786
+ writeHumanGenerate(result);
787
+ }
788
+
789
+ return result.exitCode;
790
+ }
791
+ case "add": {
792
+ const result = await runAddCommand(command.alias, command.options);
793
+ if (command.options.json) {
794
+ process.stdout.write(formatJsonResult(buildAddJson(result)));
795
+ } else {
796
+ writeHumanAdd(result);
797
+ }
798
+ return result.exitCode;
799
+ }
800
+ case "inspect": {
801
+ const result = await runInspectCommand(
802
+ command.target,
803
+ process.cwd(),
804
+ );
805
+ if (command.json) {
806
+ process.stdout.write(formatJsonResult(buildInspectJson(result)));
807
+ } else if (typeof result.data === "string") {
808
+ process.stdout.write(result.data);
809
+ } else {
810
+ writeHumanInspect(result);
811
+ }
812
+ return result.exitCode;
813
+ }
814
+ case "check": {
815
+ const result = await runCheckCommand(process.cwd(), {
816
+ strictSecrets: command.strictSecrets,
817
+ });
818
+ if (command.json) {
819
+ process.stdout.write(formatJsonResult(buildGenerateJson(result)));
820
+ } else {
821
+ writeHumanGenerate(result);
822
+ }
823
+ return result.exitCode;
824
+ }
825
+ case "verify": {
826
+ const result = await runVerifyCommand(command.options);
827
+ if (command.options.json) {
828
+ process.stdout.write(formatJsonResult(buildVerifyJson(result)));
829
+ } else {
830
+ writeHumanVerify(result);
831
+ }
832
+ return result.exitCode;
833
+ }
834
+ case "run": {
835
+ initializeRuntimeEnv(
836
+ command.workspaceRoot,
837
+ command.envFile ? [command.envFile] : undefined,
838
+ );
839
+
840
+ if (command.queryMode && command.name) {
841
+ const tableMap = readGeneratedJson<{ tableMap: Record<string, import("../compiler/data-graph/sql/serialize.ts").TableMapEntry> }>(
842
+ command.workspaceRoot,
843
+ `${GENERATED_DIR}/db.json`,
844
+ )?.tableMap;
845
+
846
+ const run = await runQuery(
847
+ command.workspaceRoot,
848
+ command.name,
849
+ {
850
+ args: command.args,
851
+ auth: resolveAuthFromCli({
852
+ userId: command.userId,
853
+ tenantId: command.tenantId,
854
+ role: command.role,
855
+ }),
856
+ },
857
+ {
858
+ adapter: getActiveDbAdapter(),
859
+ tableMap,
860
+ },
861
+ );
862
+
863
+ if (command.json) {
864
+ process.stdout.write(`${JSON.stringify({ run }, null, 2)}\n`);
865
+ } else {
866
+ process.stdout.write(formatQueryResultHuman(run));
867
+ }
868
+ return run.exitCode;
869
+ }
870
+
871
+ const result = await runRunCommand({
872
+ name: command.name,
873
+ list: command.list,
874
+ json: command.json,
875
+ mock: command.mock,
876
+ userId: command.userId,
877
+ tenantId: command.tenantId,
878
+ role: command.role,
879
+ workspaceRoot: command.workspaceRoot,
880
+ });
881
+
882
+ if (command.json) {
883
+ process.stdout.write(formatRunJson(result));
884
+ } else if (result.list) {
885
+ process.stdout.write(formatRunListHuman(result.list));
886
+ } else if (result.run) {
887
+ process.stdout.write(formatRunResultHuman(result.run));
888
+ }
889
+
890
+ return result.exitCode;
891
+ }
892
+ case "dev": {
893
+ initializeRuntimeEnv(
894
+ command.workspaceRoot,
895
+ command.envFile ? [command.envFile] : undefined,
896
+ );
897
+ const result = await runDevCommand({
898
+ workspaceRoot: command.workspaceRoot,
899
+ host: command.host,
900
+ port: command.port,
901
+ mock: command.mock,
902
+ mockAi: command.mockAi,
903
+ once: command.once,
904
+ watch: command.watch,
905
+ json: command.json,
906
+ db: command.db,
907
907
  databaseUrl: command.databaseUrl,
908
908
  worker: command.worker,
909
909
  withWeb: command.withWeb,
@@ -914,217 +914,217 @@ export async function executeCommand(command: ForgeCommand): Promise<number> {
914
914
  telemetry: command.telemetry,
915
915
  envFile: command.envFile,
916
916
  });
917
- return result.exitCode;
918
- }
919
- case "db": {
920
- if (command.subcommand === "rls-check") {
921
- const result = await runRlsCommand({
922
- subcommand: "check",
923
- workspaceRoot: command.workspaceRoot,
924
- db: command.db,
925
- databaseUrl: command.databaseUrl,
926
- json: command.json,
927
- });
928
- if (command.json) {
929
- process.stdout.write(formatRlsJson(result));
930
- } else {
931
- process.stdout.write(formatRlsHuman("check", result));
932
- }
933
- return result.exitCode;
934
- }
935
-
936
- const result = await runDbCommand({
937
- subcommand: command.subcommand,
938
- workspaceRoot: command.workspaceRoot,
939
- db: command.db,
940
- databaseUrl: command.databaseUrl,
941
- json: command.json,
942
- });
943
-
944
- if (command.json) {
945
- process.stdout.write(formatDbJson(result));
946
- } else {
947
- process.stdout.write(formatDbHuman(command.subcommand, result));
948
- }
949
-
950
- return result.exitCode;
951
- }
952
- case "outbox": {
953
- const result = await runOutboxCommand({
954
- subcommand: command.subcommand,
955
- workspaceRoot: command.workspaceRoot,
956
- db: command.db,
957
- databaseUrl: command.databaseUrl,
958
- json: command.json,
959
- once: command.once,
960
- watch: command.watch,
961
- limit: command.limit,
962
- deliveryId: command.deliveryId,
963
- mock: command.mock,
964
- });
965
-
966
- if (command.json) {
967
- process.stdout.write(formatOutboxJson(result));
968
- } else {
969
- process.stdout.write(formatOutboxHuman(command.subcommand, result));
970
- }
971
-
972
- return result.exitCode;
973
- }
974
- case "workflow": {
975
- const result = await runWorkflowCommand({
976
- subcommand: command.subcommand,
977
- workspaceRoot: command.workspaceRoot,
978
- db: command.db,
979
- databaseUrl: command.databaseUrl,
980
- json: command.json,
981
- once: command.once,
982
- watch: command.watch,
983
- limit: command.limit,
984
- workflowName: command.workflowName,
985
- runId: command.runId,
986
- stepName: command.stepName,
987
- input: command.input,
988
- mock: command.mock,
989
- });
990
-
991
- if (command.json) {
992
- process.stdout.write(formatWorkflowJson(result));
993
- } else {
994
- process.stdout.write(formatWorkflowHuman(command.subcommand, result));
995
- }
996
-
997
- return result.exitCode;
998
- }
999
- case "telemetry": {
1000
- const result = await runTelemetryCommand({
1001
- subcommand: command.subcommand,
1002
- workspaceRoot: command.workspaceRoot,
1003
- db: command.db,
1004
- databaseUrl: command.databaseUrl,
1005
- json: command.json,
1006
- traceId: command.traceId,
1007
- sink: command.sink,
1008
- file: command.file,
1009
- });
1010
-
1011
- if (command.json) {
1012
- process.stdout.write(formatTelemetryJson(result));
1013
- } else {
1014
- process.stdout.write(formatTelemetryHuman(command.subcommand, result));
1015
- }
1016
-
1017
- return result.exitCode;
1018
- }
1019
- case "policy": {
1020
- const result = await runPolicyCommand({
1021
- subcommand: command.subcommand,
1022
- workspaceRoot: command.workspaceRoot,
1023
- json: command.json,
1024
- policy: command.policy,
1025
- role: command.role,
1026
- strictPolicies: command.strictPolicies,
1027
- });
1028
-
1029
- if (command.json) {
1030
- process.stdout.write(formatPolicyJson(result));
1031
- } else {
1032
- process.stdout.write(formatPolicyHuman(command.subcommand, result));
1033
- }
1034
-
1035
- return result.exitCode;
1036
- }
1037
- case "secrets": {
1038
- const result = await runSecretsCommand({
1039
- subcommand: command.subcommand,
1040
- workspaceRoot: command.workspaceRoot,
1041
- json: command.json,
1042
- redacted: command.redacted,
1043
- name: command.name,
1044
- value: command.value,
1045
- });
1046
-
1047
- if (command.json) {
1048
- process.stdout.write(formatSecretsJson(result));
1049
- } else {
1050
- process.stdout.write(formatSecretsHuman(command.subcommand, result));
1051
- }
1052
-
1053
- return result.exitCode;
1054
- }
1055
- case "env": {
1056
- const result = await runEnvCommand({
1057
- subcommand: command.subcommand,
1058
- workspaceRoot: command.workspaceRoot,
1059
- json: command.json,
1060
- redacted: command.redacted,
1061
- });
1062
-
1063
- if (command.json) {
1064
- process.stdout.write(formatEnvJson(result));
1065
- } else {
1066
- process.stdout.write(formatEnvHuman(command.subcommand, result));
1067
- }
1068
-
1069
- return result.exitCode;
1070
- }
1071
- case "query": {
1072
- const result = await runQueryCommand({
1073
- subcommand: command.subcommand,
1074
- name: command.name,
1075
- args: command.args,
1076
- json: command.json,
1077
- userId: command.userId,
1078
- tenantId: command.tenantId,
1079
- role: command.role,
1080
- workspaceRoot: command.workspaceRoot,
1081
- });
1082
-
1083
- if (command.json) {
1084
- process.stdout.write(formatQueryJson(result));
1085
- } else if (result.list) {
1086
- process.stdout.write(formatQueryListHuman(result.list));
1087
- } else if (result.run) {
1088
- process.stdout.write(formatQueryResultHuman(result.run));
1089
- }
1090
-
1091
- return result.exitCode;
1092
- }
1093
- case "live": {
1094
- return runLiveCommand({
1095
- subcommand: command.subcommand,
1096
- name: command.name,
1097
- args: command.args,
1098
- json: command.json,
1099
- userId: command.userId,
1100
- tenantId: command.tenantId,
1101
- role: command.role,
1102
- url: command.url,
1103
- });
1104
- }
1105
- case "ai": {
1106
- const result = await runAiCommand({
1107
- subcommand: command.subcommand,
1108
- workspaceRoot: command.workspaceRoot,
1109
- json: command.json,
1110
- provider: command.provider,
1111
- model: command.model,
1112
- prompt: command.prompt,
1113
- mock: command.mock,
1114
- });
1115
-
1116
- if (command.json) {
1117
- process.stdout.write(formatAiJson(result));
1118
- } else {
1119
- process.stdout.write(formatAiHuman(command.subcommand, result));
1120
- }
1121
-
1122
- return result.exitCode;
1123
- }
1124
- default:
1125
- return 1;
1126
- }
1127
- }
1128
-
1129
- export { runVerifyCommand };
1130
- export type { VerifyOptions, VerifyResult };
917
+ return result.exitCode;
918
+ }
919
+ case "db": {
920
+ if (command.subcommand === "rls-check") {
921
+ const result = await runRlsCommand({
922
+ subcommand: "check",
923
+ workspaceRoot: command.workspaceRoot,
924
+ db: command.db,
925
+ databaseUrl: command.databaseUrl,
926
+ json: command.json,
927
+ });
928
+ if (command.json) {
929
+ process.stdout.write(formatRlsJson(result));
930
+ } else {
931
+ process.stdout.write(formatRlsHuman("check", result));
932
+ }
933
+ return result.exitCode;
934
+ }
935
+
936
+ const result = await runDbCommand({
937
+ subcommand: command.subcommand,
938
+ workspaceRoot: command.workspaceRoot,
939
+ db: command.db,
940
+ databaseUrl: command.databaseUrl,
941
+ json: command.json,
942
+ });
943
+
944
+ if (command.json) {
945
+ process.stdout.write(formatDbJson(result));
946
+ } else {
947
+ process.stdout.write(formatDbHuman(command.subcommand, result));
948
+ }
949
+
950
+ return result.exitCode;
951
+ }
952
+ case "outbox": {
953
+ const result = await runOutboxCommand({
954
+ subcommand: command.subcommand,
955
+ workspaceRoot: command.workspaceRoot,
956
+ db: command.db,
957
+ databaseUrl: command.databaseUrl,
958
+ json: command.json,
959
+ once: command.once,
960
+ watch: command.watch,
961
+ limit: command.limit,
962
+ deliveryId: command.deliveryId,
963
+ mock: command.mock,
964
+ });
965
+
966
+ if (command.json) {
967
+ process.stdout.write(formatOutboxJson(result));
968
+ } else {
969
+ process.stdout.write(formatOutboxHuman(command.subcommand, result));
970
+ }
971
+
972
+ return result.exitCode;
973
+ }
974
+ case "workflow": {
975
+ const result = await runWorkflowCommand({
976
+ subcommand: command.subcommand,
977
+ workspaceRoot: command.workspaceRoot,
978
+ db: command.db,
979
+ databaseUrl: command.databaseUrl,
980
+ json: command.json,
981
+ once: command.once,
982
+ watch: command.watch,
983
+ limit: command.limit,
984
+ workflowName: command.workflowName,
985
+ runId: command.runId,
986
+ stepName: command.stepName,
987
+ input: command.input,
988
+ mock: command.mock,
989
+ });
990
+
991
+ if (command.json) {
992
+ process.stdout.write(formatWorkflowJson(result));
993
+ } else {
994
+ process.stdout.write(formatWorkflowHuman(command.subcommand, result));
995
+ }
996
+
997
+ return result.exitCode;
998
+ }
999
+ case "telemetry": {
1000
+ const result = await runTelemetryCommand({
1001
+ subcommand: command.subcommand,
1002
+ workspaceRoot: command.workspaceRoot,
1003
+ db: command.db,
1004
+ databaseUrl: command.databaseUrl,
1005
+ json: command.json,
1006
+ traceId: command.traceId,
1007
+ sink: command.sink,
1008
+ file: command.file,
1009
+ });
1010
+
1011
+ if (command.json) {
1012
+ process.stdout.write(formatTelemetryJson(result));
1013
+ } else {
1014
+ process.stdout.write(formatTelemetryHuman(command.subcommand, result));
1015
+ }
1016
+
1017
+ return result.exitCode;
1018
+ }
1019
+ case "policy": {
1020
+ const result = await runPolicyCommand({
1021
+ subcommand: command.subcommand,
1022
+ workspaceRoot: command.workspaceRoot,
1023
+ json: command.json,
1024
+ policy: command.policy,
1025
+ role: command.role,
1026
+ strictPolicies: command.strictPolicies,
1027
+ });
1028
+
1029
+ if (command.json) {
1030
+ process.stdout.write(formatPolicyJson(result));
1031
+ } else {
1032
+ process.stdout.write(formatPolicyHuman(command.subcommand, result));
1033
+ }
1034
+
1035
+ return result.exitCode;
1036
+ }
1037
+ case "secrets": {
1038
+ const result = await runSecretsCommand({
1039
+ subcommand: command.subcommand,
1040
+ workspaceRoot: command.workspaceRoot,
1041
+ json: command.json,
1042
+ redacted: command.redacted,
1043
+ name: command.name,
1044
+ value: command.value,
1045
+ });
1046
+
1047
+ if (command.json) {
1048
+ process.stdout.write(formatSecretsJson(result));
1049
+ } else {
1050
+ process.stdout.write(formatSecretsHuman(command.subcommand, result));
1051
+ }
1052
+
1053
+ return result.exitCode;
1054
+ }
1055
+ case "env": {
1056
+ const result = await runEnvCommand({
1057
+ subcommand: command.subcommand,
1058
+ workspaceRoot: command.workspaceRoot,
1059
+ json: command.json,
1060
+ redacted: command.redacted,
1061
+ });
1062
+
1063
+ if (command.json) {
1064
+ process.stdout.write(formatEnvJson(result));
1065
+ } else {
1066
+ process.stdout.write(formatEnvHuman(command.subcommand, result));
1067
+ }
1068
+
1069
+ return result.exitCode;
1070
+ }
1071
+ case "query": {
1072
+ const result = await runQueryCommand({
1073
+ subcommand: command.subcommand,
1074
+ name: command.name,
1075
+ args: command.args,
1076
+ json: command.json,
1077
+ userId: command.userId,
1078
+ tenantId: command.tenantId,
1079
+ role: command.role,
1080
+ workspaceRoot: command.workspaceRoot,
1081
+ });
1082
+
1083
+ if (command.json) {
1084
+ process.stdout.write(formatQueryJson(result));
1085
+ } else if (result.list) {
1086
+ process.stdout.write(formatQueryListHuman(result.list));
1087
+ } else if (result.run) {
1088
+ process.stdout.write(formatQueryResultHuman(result.run));
1089
+ }
1090
+
1091
+ return result.exitCode;
1092
+ }
1093
+ case "live": {
1094
+ return runLiveCommand({
1095
+ subcommand: command.subcommand,
1096
+ name: command.name,
1097
+ args: command.args,
1098
+ json: command.json,
1099
+ userId: command.userId,
1100
+ tenantId: command.tenantId,
1101
+ role: command.role,
1102
+ url: command.url,
1103
+ });
1104
+ }
1105
+ case "ai": {
1106
+ const result = await runAiCommand({
1107
+ subcommand: command.subcommand,
1108
+ workspaceRoot: command.workspaceRoot,
1109
+ json: command.json,
1110
+ provider: command.provider,
1111
+ model: command.model,
1112
+ prompt: command.prompt,
1113
+ mock: command.mock,
1114
+ });
1115
+
1116
+ if (command.json) {
1117
+ process.stdout.write(formatAiJson(result));
1118
+ } else {
1119
+ process.stdout.write(formatAiHuman(command.subcommand, result));
1120
+ }
1121
+
1122
+ return result.exitCode;
1123
+ }
1124
+ default:
1125
+ return 1;
1126
+ }
1127
+ }
1128
+
1129
+ export { runVerifyCommand };
1130
+ export type { VerifyOptions, VerifyResult };