forgeos 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +1 -0
- package/AGENTS.md +277 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +58 -0
- package/README.md +377 -0
- package/bin/forge-bun.mjs +110 -0
- package/bin/forge.mjs +19 -0
- package/package.json +96 -0
- package/packages/eslint-plugin-forge/index.ts +15 -0
- package/packages/eslint-plugin-forge/package.json +10 -0
- package/packages/eslint-plugin-forge/src/check-source.ts +95 -0
- package/packages/eslint-plugin-forge/src/load-artifacts.ts +24 -0
- package/packages/eslint-plugin-forge/src/rule-no-forge-guard-violation.ts +93 -0
- package/src/forge/_generated/actionSubscriptions.json +2 -0
- package/src/forge/_generated/actionSubscriptions.ts +10 -0
- package/src/forge/_generated/agentAdapterManifest.json +2 -0
- package/src/forge/_generated/agentAdapterManifest.ts +73 -0
- package/src/forge/_generated/agentContract.json +2 -0
- package/src/forge/_generated/agentContract.ts +912 -0
- package/src/forge/_generated/agentQuickstart.md +32 -0
- package/src/forge/_generated/aiContext.ts +59 -0
- package/src/forge/_generated/aiModels.json +2 -0
- package/src/forge/_generated/aiModels.ts +35 -0
- package/src/forge/_generated/aiProviders.json +2 -0
- package/src/forge/_generated/aiProviders.ts +23 -0
- package/src/forge/_generated/aiRegistry.json +2 -0
- package/src/forge/_generated/aiRegistry.ts +29 -0
- package/src/forge/_generated/api.json +2 -0
- package/src/forge/_generated/api.ts +8 -0
- package/src/forge/_generated/appGraph.json +2 -0
- package/src/forge/_generated/appGraph.ts +14511 -0
- package/src/forge/_generated/appMap.md +35 -0
- package/src/forge/_generated/artifactManifest.json +2 -0
- package/src/forge/_generated/artifactManifest.ts +7 -0
- package/src/forge/_generated/authClaims.json +2 -0
- package/src/forge/_generated/authClaims.ts +13 -0
- package/src/forge/_generated/authConfig.json +2 -0
- package/src/forge/_generated/authConfig.ts +17 -0
- package/src/forge/_generated/authContext.ts +23 -0
- package/src/forge/_generated/authRegistry.json +2 -0
- package/src/forge/_generated/authRegistry.ts +25 -0
- package/src/forge/_generated/buildInfo.json +2 -0
- package/src/forge/_generated/buildInfo.ts +9 -0
- package/src/forge/_generated/capabilityMap.json +2 -0
- package/src/forge/_generated/capabilityMap.md +15 -0
- package/src/forge/_generated/capabilityMap.ts +17 -0
- package/src/forge/_generated/client.ts +282 -0
- package/src/forge/_generated/clientApi.ts +9 -0
- package/src/forge/_generated/clientManifest.json +2 -0
- package/src/forge/_generated/clientManifest.ts +39 -0
- package/src/forge/_generated/clientTypes.ts +78 -0
- package/src/forge/_generated/configRegistry.json +2 -0
- package/src/forge/_generated/configRegistry.ts +4 -0
- package/src/forge/_generated/dataGraph.json +2 -0
- package/src/forge/_generated/dataGraph.ts +8 -0
- package/src/forge/_generated/db.json +2 -0
- package/src/forge/_generated/db.ts +2 -0
- package/src/forge/_generated/dbSecurityManifest.json +2 -0
- package/src/forge/_generated/dbSecurityManifest.ts +15 -0
- package/src/forge/_generated/dbSessionContext.json +2 -0
- package/src/forge/_generated/dbSessionContext.ts +39 -0
- package/src/forge/_generated/deployManifest.json +2 -0
- package/src/forge/_generated/deployManifest.ts +14 -0
- package/src/forge/_generated/devManifest.json +2 -0
- package/src/forge/_generated/devManifest.ts +47 -0
- package/src/forge/_generated/envSchema.json +2 -0
- package/src/forge/_generated/envSchema.ts +59 -0
- package/src/forge/_generated/frontendGraph.json +2 -0
- package/src/forge/_generated/frontendGraph.ts +27 -0
- package/src/forge/_generated/importGuards.json +2 -0
- package/src/forge/_generated/importGuards.ts +652 -0
- package/src/forge/_generated/index.ts +67 -0
- package/src/forge/_generated/liveProductionManifest.json +2 -0
- package/src/forge/_generated/liveProductionManifest.ts +23 -0
- package/src/forge/_generated/liveProtocol.json +2 -0
- package/src/forge/_generated/liveProtocol.ts +21 -0
- package/src/forge/_generated/liveQueryRegistry.json +2 -0
- package/src/forge/_generated/liveQueryRegistry.ts +9 -0
- package/src/forge/_generated/liveTransportConfig.json +2 -0
- package/src/forge/_generated/liveTransportConfig.ts +19 -0
- package/src/forge/_generated/makeRegistry.json +2 -0
- package/src/forge/_generated/makeRegistry.ts +163 -0
- package/src/forge/_generated/makeTemplates.json +2 -0
- package/src/forge/_generated/makeTemplates.ts +61 -0
- package/src/forge/_generated/mockMap.json +2 -0
- package/src/forge/_generated/mockMap.ts +7 -0
- package/src/forge/_generated/operationPlaybooks.md +145 -0
- package/src/forge/_generated/packageGraph.json +2 -0
- package/src/forge/_generated/packageGraph.ts +168569 -0
- package/src/forge/_generated/packageUpgradeRegistry.json +2 -0
- package/src/forge/_generated/packageUpgradeRegistry.ts +15 -0
- package/src/forge/_generated/permissionMatrix.json +2 -0
- package/src/forge/_generated/permissionMatrix.ts +7 -0
- package/src/forge/_generated/policyRegistry.json +2 -0
- package/src/forge/_generated/policyRegistry.ts +11 -0
- package/src/forge/_generated/queryRegistry.json +2 -0
- package/src/forge/_generated/queryRegistry.ts +9 -0
- package/src/forge/_generated/react.d.ts +22 -0
- package/src/forge/_generated/react.ts +29 -0
- package/src/forge/_generated/reactManifest.json +2 -0
- package/src/forge/_generated/reactManifest.ts +19 -0
- package/src/forge/_generated/releaseManifest.json +2 -0
- package/src/forge/_generated/releaseManifest.ts +25 -0
- package/src/forge/_generated/rlsPolicies.json +2 -0
- package/src/forge/_generated/rlsPolicies.sql +34 -0
- package/src/forge/_generated/rlsPolicies.ts +6 -0
- package/src/forge/_generated/runtimeGraph.json +2 -0
- package/src/forge/_generated/runtimeGraph.ts +8 -0
- package/src/forge/_generated/runtimeMatrix.json +2 -0
- package/src/forge/_generated/runtimeMatrix.ts +229125 -0
- package/src/forge/_generated/runtimeRegistry.ts +2 -0
- package/src/forge/_generated/runtimeRules.md +79 -0
- package/src/forge/_generated/secretRegistry.json +2 -0
- package/src/forge/_generated/secretRegistry.ts +50 -0
- package/src/forge/_generated/secretsContext.ts +11 -0
- package/src/forge/_generated/serverApi.ts +10 -0
- package/src/forge/_generated/sourceMapManifest.json +2 -0
- package/src/forge/_generated/sourceMapManifest.ts +7 -0
- package/src/forge/_generated/sqlPlan.json +2 -0
- package/src/forge/_generated/sqlPlan.ts +88 -0
- package/src/forge/_generated/subscriptionManifest.json +2 -0
- package/src/forge/_generated/subscriptionManifest.ts +7 -0
- package/src/forge/_generated/symbolicationManifest.json +2 -0
- package/src/forge/_generated/symbolicationManifest.ts +17 -0
- package/src/forge/_generated/telemetryRegistry.json +2 -0
- package/src/forge/_generated/telemetryRegistry.ts +9 -0
- package/src/forge/_generated/telemetrySinks.json +2 -0
- package/src/forge/_generated/telemetrySinks.ts +11 -0
- package/src/forge/_generated/tenantScope.json +2 -0
- package/src/forge/_generated/tenantScope.ts +8 -0
- package/src/forge/_generated/testGraph.json +2 -0
- package/src/forge/_generated/testGraph.ts +3054 -0
- package/src/forge/_generated/testPlanRegistry.json +2 -0
- package/src/forge/_generated/testPlanRegistry.ts +33 -0
- package/src/forge/_generated/uiRoutes.json +2 -0
- package/src/forge/_generated/uiRoutes.ts +16 -0
- package/src/forge/_generated/uiScenarios.json +2 -0
- package/src/forge/_generated/uiScenarios.ts +30 -0
- package/src/forge/_generated/uiTestManifest.json +2 -0
- package/src/forge/_generated/uiTestManifest.ts +27 -0
- package/src/forge/_generated/workflowRegistry.json +2 -0
- package/src/forge/_generated/workflowRegistry.ts +9 -0
- package/src/forge/_generated/workflowSubscriptions.json +2 -0
- package/src/forge/_generated/workflowSubscriptions.ts +10 -0
- package/src/forge/agent-adapters/index.ts +1002 -0
- package/src/forge/agent-adapters/types.ts +135 -0
- package/src/forge/cli/agent-contract.ts +50 -0
- package/src/forge/cli/ai.ts +148 -0
- package/src/forge/cli/auth.ts +198 -0
- package/src/forge/cli/build.ts +105 -0
- package/src/forge/cli/bun-exec.ts +4 -0
- package/src/forge/cli/commands.ts +1130 -0
- package/src/forge/cli/db.ts +316 -0
- package/src/forge/cli/deps.ts +277 -0
- package/src/forge/cli/dev.ts +529 -0
- package/src/forge/cli/doctor.ts +209 -0
- package/src/forge/cli/feature.ts +485 -0
- package/src/forge/cli/index.ts +25 -0
- package/src/forge/cli/lint-forge.ts +119 -0
- package/src/forge/cli/live.ts +179 -0
- package/src/forge/cli/main.ts +92 -0
- package/src/forge/cli/make.ts +133 -0
- package/src/forge/cli/new.ts +505 -0
- package/src/forge/cli/outbox.ts +297 -0
- package/src/forge/cli/output.ts +114 -0
- package/src/forge/cli/parse.ts +2211 -0
- package/src/forge/cli/policy.ts +204 -0
- package/src/forge/cli/query.ts +91 -0
- package/src/forge/cli/refactor.ts +221 -0
- package/src/forge/cli/release.ts +285 -0
- package/src/forge/cli/rls.ts +322 -0
- package/src/forge/cli/run.ts +76 -0
- package/src/forge/cli/secrets.ts +274 -0
- package/src/forge/cli/self-host.ts +468 -0
- package/src/forge/cli/serve.ts +93 -0
- package/src/forge/cli/telemetry.ts +219 -0
- package/src/forge/cli/verify.ts +587 -0
- package/src/forge/cli/version.ts +1 -0
- package/src/forge/cli/windows.ts +413 -0
- package/src/forge/cli/worker.ts +87 -0
- package/src/forge/cli/workflow.ts +424 -0
- package/src/forge/compiler/action-subscriptions/build.ts +116 -0
- package/src/forge/compiler/action-subscriptions/constants.ts +2 -0
- package/src/forge/compiler/action-subscriptions/index.ts +6 -0
- package/src/forge/compiler/action-subscriptions/parse.ts +6 -0
- package/src/forge/compiler/agent-contract/build.ts +1651 -0
- package/src/forge/compiler/agent-contract/types.ts +326 -0
- package/src/forge/compiler/ai-registry/build.ts +165 -0
- package/src/forge/compiler/ai-registry/constants.ts +2 -0
- package/src/forge/compiler/ai-registry/parse.ts +56 -0
- package/src/forge/compiler/api-surface/build.ts +107 -0
- package/src/forge/compiler/app-graph/build.ts +121 -0
- package/src/forge/compiler/app-graph/classify.ts +10 -0
- package/src/forge/compiler/app-graph/dup-symbol.ts +29 -0
- package/src/forge/compiler/app-graph/extract.ts +124 -0
- package/src/forge/compiler/app-graph/forge-apis.ts +29 -0
- package/src/forge/compiler/app-graph/index.ts +15 -0
- package/src/forge/compiler/app-graph/module-graph.ts +320 -0
- package/src/forge/compiler/app-graph/parser.ts +119 -0
- package/src/forge/compiler/app-graph/symbols.ts +48 -0
- package/src/forge/compiler/app-graph/tsconfig-hash.ts +62 -0
- package/src/forge/compiler/app-graph/types.ts +43 -0
- package/src/forge/compiler/app-graph/versions.ts +14 -0
- package/src/forge/compiler/cache/index.ts +17 -0
- package/src/forge/compiler/cache/key.ts +46 -0
- package/src/forge/compiler/cache/scheduler.ts +72 -0
- package/src/forge/compiler/cache/store.ts +78 -0
- package/src/forge/compiler/classifier/capabilities.ts +78 -0
- package/src/forge/compiler/classifier/classify.ts +113 -0
- package/src/forge/compiler/classifier/contexts.ts +188 -0
- package/src/forge/compiler/classifier/index.ts +18 -0
- package/src/forge/compiler/classifier/runtime-matrix.ts +45 -0
- package/src/forge/compiler/classifier/secrets.ts +41 -0
- package/src/forge/compiler/classifier/signals.ts +129 -0
- package/src/forge/compiler/client-sdk/build-manifest.ts +151 -0
- package/src/forge/compiler/client-sdk/render-client.ts +432 -0
- package/src/forge/compiler/data-graph/build.ts +131 -0
- package/src/forge/compiler/data-graph/constants.ts +5 -0
- package/src/forge/compiler/data-graph/index.ts +6 -0
- package/src/forge/compiler/data-graph/parse.ts +176 -0
- package/src/forge/compiler/data-graph/rls/build.ts +222 -0
- package/src/forge/compiler/data-graph/rls/types.ts +62 -0
- package/src/forge/compiler/data-graph/sql/ddl.ts +390 -0
- package/src/forge/compiler/data-graph/sql/naming.ts +10 -0
- package/src/forge/compiler/data-graph/sql/serialize.ts +85 -0
- package/src/forge/compiler/data-graph/sql/types.ts +37 -0
- package/src/forge/compiler/dev-manifest/build.ts +170 -0
- package/src/forge/compiler/dev-manifest/constants.ts +5 -0
- package/src/forge/compiler/diagnostics/codes.ts +611 -0
- package/src/forge/compiler/diagnostics/create.ts +245 -0
- package/src/forge/compiler/diagnostics/index.ts +55 -0
- package/src/forge/compiler/emitter/artifact-kind.ts +14 -0
- package/src/forge/compiler/emitter/barrel.ts +44 -0
- package/src/forge/compiler/emitter/constants.ts +7 -0
- package/src/forge/compiler/emitter/emit.ts +237 -0
- package/src/forge/compiler/emitter/index.ts +24 -0
- package/src/forge/compiler/emitter/lock.ts +62 -0
- package/src/forge/compiler/emitter/render.ts +73 -0
- package/src/forge/compiler/emitter/write.ts +35 -0
- package/src/forge/compiler/frontend-graph/build.ts +495 -0
- package/src/forge/compiler/fs/index.ts +23 -0
- package/src/forge/compiler/fs/memory.ts +233 -0
- package/src/forge/compiler/fs/node.ts +139 -0
- package/src/forge/compiler/fs/profile.ts +108 -0
- package/src/forge/compiler/fs/types.ts +52 -0
- package/src/forge/compiler/guards/artifacts.ts +96 -0
- package/src/forge/compiler/guards/check-ai-usage.ts +98 -0
- package/src/forge/compiler/guards/check-import-guards.ts +106 -0
- package/src/forge/compiler/guards/check-process-env.ts +98 -0
- package/src/forge/compiler/guards/check-query-usage.ts +76 -0
- package/src/forge/compiler/guards/index.ts +11 -0
- package/src/forge/compiler/guards/propagate-contexts.ts +57 -0
- package/src/forge/compiler/index.ts +17 -0
- package/src/forge/compiler/integration/add.ts +496 -0
- package/src/forge/compiler/integration/index.ts +17 -0
- package/src/forge/compiler/integration/plan.ts +283 -0
- package/src/forge/compiler/integration/render.ts +189 -0
- package/src/forge/compiler/integration/snapshot.ts +52 -0
- package/src/forge/compiler/integration/templates/ai.ts +131 -0
- package/src/forge/compiler/integration/templates/index.ts +8 -0
- package/src/forge/compiler/integration/templates/posthog.ts +145 -0
- package/src/forge/compiler/integration/templates/render.ts +113 -0
- package/src/forge/compiler/integration/templates/sentry.ts +151 -0
- package/src/forge/compiler/integration/templates/stripe.ts +109 -0
- package/src/forge/compiler/integration/templates/types.ts +14 -0
- package/src/forge/compiler/integration/templates/zod.ts +55 -0
- package/src/forge/compiler/live-production/types.ts +122 -0
- package/src/forge/compiler/live-query-registry/build.ts +150 -0
- package/src/forge/compiler/live-query-registry/constants.ts +2 -0
- package/src/forge/compiler/make-registry/build.ts +179 -0
- package/src/forge/compiler/orchestrator/discover.ts +214 -0
- package/src/forge/compiler/orchestrator/fast-check.ts +117 -0
- package/src/forge/compiler/orchestrator/generate-lock.ts +138 -0
- package/src/forge/compiler/orchestrator/guards.ts +5 -0
- package/src/forge/compiler/orchestrator/index.ts +27 -0
- package/src/forge/compiler/orchestrator/manifest-hashes.ts +21 -0
- package/src/forge/compiler/orchestrator/manifest.ts +92 -0
- package/src/forge/compiler/orchestrator/orphans.ts +51 -0
- package/src/forge/compiler/orchestrator/plan.ts +876 -0
- package/src/forge/compiler/orchestrator/profile.ts +36 -0
- package/src/forge/compiler/orchestrator/run.ts +277 -0
- package/src/forge/compiler/orchestrator/serialize.ts +886 -0
- package/src/forge/compiler/orchestrator/session.ts +96 -0
- package/src/forge/compiler/orchestrator/types.ts +31 -0
- package/src/forge/compiler/orchestrator/verify.ts +38 -0
- package/src/forge/compiler/orchestrator/workspace-index.ts +154 -0
- package/src/forge/compiler/package-graph/capabilities-stub.ts +33 -0
- package/src/forge/compiler/package-graph/checksum.ts +97 -0
- package/src/forge/compiler/package-graph/compiler.ts +392 -0
- package/src/forge/compiler/package-graph/constants.ts +4 -0
- package/src/forge/compiler/package-graph/dts-extractor.ts +142 -0
- package/src/forge/compiler/package-graph/exports-discovery.ts +84 -0
- package/src/forge/compiler/package-graph/extract-dts.ts +32 -0
- package/src/forge/compiler/package-graph/index.ts +33 -0
- package/src/forge/compiler/package-graph/jsdoc.ts +62 -0
- package/src/forge/compiler/package-graph/read-file.ts +21 -0
- package/src/forge/compiler/package-graph/resolve.ts +127 -0
- package/src/forge/compiler/package-manager/adapter.ts +237 -0
- package/src/forge/compiler/package-manager/bun-executable.ts +92 -0
- package/src/forge/compiler/package-manager/commands.ts +47 -0
- package/src/forge/compiler/package-manager/detect.ts +79 -0
- package/src/forge/compiler/package-manager/executor.ts +117 -0
- package/src/forge/compiler/package-manager/index.ts +22 -0
- package/src/forge/compiler/package-manager/parse-spec.ts +16 -0
- package/src/forge/compiler/package-manager/version.ts +27 -0
- package/src/forge/compiler/package-upgrades/apply.ts +195 -0
- package/src/forge/compiler/package-upgrades/comparator.ts +181 -0
- package/src/forge/compiler/package-upgrades/impact.ts +139 -0
- package/src/forge/compiler/package-upgrades/markdown.ts +97 -0
- package/src/forge/compiler/package-upgrades/planner.ts +532 -0
- package/src/forge/compiler/package-upgrades/risk.ts +208 -0
- package/src/forge/compiler/package-upgrades/types.ts +174 -0
- package/src/forge/compiler/policy-registry/build.ts +266 -0
- package/src/forge/compiler/policy-registry/constants.ts +2 -0
- package/src/forge/compiler/policy-registry/parse.ts +81 -0
- package/src/forge/compiler/primitives/compare.ts +26 -0
- package/src/forge/compiler/primitives/hash.ts +40 -0
- package/src/forge/compiler/primitives/header.ts +45 -0
- package/src/forge/compiler/primitives/index.ts +45 -0
- package/src/forge/compiler/primitives/paths.ts +24 -0
- package/src/forge/compiler/primitives/result.ts +164 -0
- package/src/forge/compiler/primitives/serialize.ts +66 -0
- package/src/forge/compiler/primitives/sort.ts +87 -0
- package/src/forge/compiler/query-registry/build.ts +114 -0
- package/src/forge/compiler/query-registry/constants.ts +2 -0
- package/src/forge/compiler/recipes/definitions.ts +289 -0
- package/src/forge/compiler/recipes/helpers.ts +37 -0
- package/src/forge/compiler/recipes/index.ts +21 -0
- package/src/forge/compiler/recipes/registry.ts +102 -0
- package/src/forge/compiler/release/build.ts +100 -0
- package/src/forge/compiler/release/types.ts +119 -0
- package/src/forge/compiler/runtime-graph/build.ts +137 -0
- package/src/forge/compiler/runtime-graph/constants.ts +5 -0
- package/src/forge/compiler/runtime-graph/index.ts +5 -0
- package/src/forge/compiler/sandbox/artifact-sanitize.ts +26 -0
- package/src/forge/compiler/sandbox/backends/child.ts +123 -0
- package/src/forge/compiler/sandbox/backends/docker.ts +173 -0
- package/src/forge/compiler/sandbox/index.ts +51 -0
- package/src/forge/compiler/sandbox/inspect.ts +143 -0
- package/src/forge/compiler/sandbox/inspector-entry.ts +115 -0
- package/src/forge/compiler/sandbox/limits.ts +31 -0
- package/src/forge/compiler/sandbox/scrub-env.ts +60 -0
- package/src/forge/compiler/sandbox/secret-scan.ts +54 -0
- package/src/forge/compiler/sandbox/serialize.ts +106 -0
- package/src/forge/compiler/sandbox/types.ts +7 -0
- package/src/forge/compiler/secret-registry/build.ts +123 -0
- package/src/forge/compiler/telemetry-registry/build.ts +89 -0
- package/src/forge/compiler/telemetry-registry/constants.ts +2 -0
- package/src/forge/compiler/telemetry-registry/parse.ts +13 -0
- package/src/forge/compiler/test-graph/build.ts +277 -0
- package/src/forge/compiler/types/action-subscriptions.ts +19 -0
- package/src/forge/compiler/types/ai-registry.ts +33 -0
- package/src/forge/compiler/types/app-graph.ts +80 -0
- package/src/forge/compiler/types/capability.ts +29 -0
- package/src/forge/compiler/types/classification.ts +9 -0
- package/src/forge/compiler/types/cli.ts +159 -0
- package/src/forge/compiler/types/data-graph.ts +24 -0
- package/src/forge/compiler/types/dev-manifest.ts +41 -0
- package/src/forge/compiler/types/diagnostic.ts +12 -0
- package/src/forge/compiler/types/emit.ts +25 -0
- package/src/forge/compiler/types/frontend-graph.ts +81 -0
- package/src/forge/compiler/types/import-guards.ts +19 -0
- package/src/forge/compiler/types/index.ts +98 -0
- package/src/forge/compiler/types/integration.ts +25 -0
- package/src/forge/compiler/types/json.ts +3 -0
- package/src/forge/compiler/types/live-query-registry.ts +32 -0
- package/src/forge/compiler/types/lock.ts +37 -0
- package/src/forge/compiler/types/package-graph.ts +84 -0
- package/src/forge/compiler/types/policy-registry.ts +69 -0
- package/src/forge/compiler/types/query-registry.ts +18 -0
- package/src/forge/compiler/types/runtime-graph.ts +30 -0
- package/src/forge/compiler/types/runtime-matrix.ts +16 -0
- package/src/forge/compiler/types/runtime.ts +30 -0
- package/src/forge/compiler/types/sandbox.ts +24 -0
- package/src/forge/compiler/types/secret-registry.ts +38 -0
- package/src/forge/compiler/types/telemetry-registry.ts +26 -0
- package/src/forge/compiler/types/test-graph.ts +45 -0
- package/src/forge/compiler/types/workflow-registry.ts +42 -0
- package/src/forge/compiler/workflow-registry/build.ts +180 -0
- package/src/forge/compiler/workflow-registry/constants.ts +2 -0
- package/src/forge/compiler/workflow-registry/index.ts +5 -0
- package/src/forge/compiler/workflow-registry/parse.ts +19 -0
- package/src/forge/dev/server.ts +1379 -0
- package/src/forge/dev/types.ts +49 -0
- package/src/forge/dev/watch.ts +109 -0
- package/src/forge/dev-console/cycle.ts +652 -0
- package/src/forge/dev-console/types.ts +99 -0
- package/src/forge/feature/compiler.ts +656 -0
- package/src/forge/feature/examples.ts +125 -0
- package/src/forge/feature/types.ts +177 -0
- package/src/forge/impact/index.ts +1160 -0
- package/src/forge/impact/types.ts +151 -0
- package/src/forge/intent/index.ts +490 -0
- package/src/forge/intent/types.ts +73 -0
- package/src/forge/make/fields.ts +146 -0
- package/src/forge/make/index.ts +1101 -0
- package/src/forge/make/naming.ts +42 -0
- package/src/forge/make/templates.ts +525 -0
- package/src/forge/make/types.ts +151 -0
- package/src/forge/platform/module.ts +20 -0
- package/src/forge/policy.ts +1 -0
- package/src/forge/react/index.ts +418 -0
- package/src/forge/refactor/index.ts +1936 -0
- package/src/forge/refactor/text-utils.ts +34 -0
- package/src/forge/refactor/types.ts +191 -0
- package/src/forge/refactor/workspace-fs.ts +171 -0
- package/src/forge/repair/index.ts +656 -0
- package/src/forge/repair/rules/index.ts +476 -0
- package/src/forge/repair/types.ts +175 -0
- package/src/forge/review/index.ts +992 -0
- package/src/forge/review/types.ts +196 -0
- package/src/forge/runtime/ai/check.ts +86 -0
- package/src/forge/runtime/ai/context.ts +394 -0
- package/src/forge/runtime/ai/cost-estimator.ts +41 -0
- package/src/forge/runtime/ai/mock.ts +49 -0
- package/src/forge/runtime/ai/providers.ts +78 -0
- package/src/forge/runtime/ai/state.ts +17 -0
- package/src/forge/runtime/ai/types.ts +67 -0
- package/src/forge/runtime/auth/authenticate.ts +58 -0
- package/src/forge/runtime/auth/claims.ts +119 -0
- package/src/forge/runtime/auth/config.ts +148 -0
- package/src/forge/runtime/auth/errors.ts +45 -0
- package/src/forge/runtime/auth/evaluate.ts +126 -0
- package/src/forge/runtime/auth/resolve.ts +74 -0
- package/src/forge/runtime/auth/types.ts +87 -0
- package/src/forge/runtime/auth/verifier.ts +138 -0
- package/src/forge/runtime/context/create-context.ts +204 -0
- package/src/forge/runtime/context/create-query-context.ts +34 -0
- package/src/forge/runtime/db/adapter.ts +31 -0
- package/src/forge/runtime/db/factory.ts +83 -0
- package/src/forge/runtime/db/generated-client.ts +294 -0
- package/src/forge/runtime/db/memory-adapter.ts +706 -0
- package/src/forge/runtime/db/migrate.ts +132 -0
- package/src/forge/runtime/db/outbox.ts +54 -0
- package/src/forge/runtime/db/pglite-adapter.ts +51 -0
- package/src/forge/runtime/db/postgres-adapter.ts +112 -0
- package/src/forge/runtime/db/read-only-client.ts +97 -0
- package/src/forge/runtime/db/session-context.ts +62 -0
- package/src/forge/runtime/executor.ts +446 -0
- package/src/forge/runtime/live/dependency-tracker.ts +57 -0
- package/src/forge/runtime/live/invalidation-log.ts +189 -0
- package/src/forge/runtime/live/live-query-runner.ts +267 -0
- package/src/forge/runtime/live/registry.ts +28 -0
- package/src/forge/runtime/live/sse.ts +75 -0
- package/src/forge/runtime/live/subscription-manager.ts +443 -0
- package/src/forge/runtime/live/types.ts +143 -0
- package/src/forge/runtime/outbox/claim.ts +153 -0
- package/src/forge/runtime/outbox/process.ts +298 -0
- package/src/forge/runtime/outbox/retry.ts +8 -0
- package/src/forge/runtime/outbox/subscriptions.ts +33 -0
- package/src/forge/runtime/outbox/types.ts +69 -0
- package/src/forge/runtime/policy/check.ts +157 -0
- package/src/forge/runtime/policy/load.ts +55 -0
- package/src/forge/runtime/query/registry.ts +19 -0
- package/src/forge/runtime/query/run-query.ts +347 -0
- package/src/forge/runtime/release/runtime.ts +322 -0
- package/src/forge/runtime/release/symbolicate.ts +175 -0
- package/src/forge/runtime/runner/command-transaction.ts +193 -0
- package/src/forge/runtime/runner/run-entry.ts +226 -0
- package/src/forge/runtime/secrets/check.ts +78 -0
- package/src/forge/runtime/secrets/create-context.ts +138 -0
- package/src/forge/runtime/secrets/env-loader.ts +94 -0
- package/src/forge/runtime/secrets/runtime-bundle.ts +47 -0
- package/src/forge/runtime/secrets/types.ts +31 -0
- package/src/forge/runtime/telemetry/buffer.ts +87 -0
- package/src/forge/runtime/telemetry/context.ts +192 -0
- package/src/forge/runtime/telemetry/correlation.ts +13 -0
- package/src/forge/runtime/telemetry/flush.ts +190 -0
- package/src/forge/runtime/telemetry/process.ts +20 -0
- package/src/forge/runtime/telemetry/scrubber.ts +115 -0
- package/src/forge/runtime/telemetry/sinks/local-jsonl.ts +39 -0
- package/src/forge/runtime/telemetry/sinks/posthog.ts +64 -0
- package/src/forge/runtime/telemetry/sinks/sentry.ts +60 -0
- package/src/forge/runtime/telemetry/spans.ts +58 -0
- package/src/forge/runtime/telemetry/types.ts +64 -0
- package/src/forge/runtime/workflows/cancel.ts +26 -0
- package/src/forge/runtime/workflows/create-run.ts +98 -0
- package/src/forge/runtime/workflows/process-run.ts +182 -0
- package/src/forge/runtime/workflows/process-step.ts +190 -0
- package/src/forge/runtime/workflows/process.ts +260 -0
- package/src/forge/runtime/workflows/registry.ts +51 -0
- package/src/forge/runtime/workflows/resolve-step.ts +46 -0
- package/src/forge/runtime/workflows/retry-run.ts +44 -0
- package/src/forge/runtime/workflows/retry.ts +8 -0
- package/src/forge/runtime/workflows/sanitize.ts +19 -0
- package/src/forge/runtime/workflows/start-from-outbox.ts +71 -0
- package/src/forge/runtime/workflows/types.ts +77 -0
- package/src/forge/server.ts +96 -0
- package/src/forge/ui/index.ts +770 -0
- package/src/forge/ui/types.ts +191 -0
- package/templates/b2b-support-web/.env.example +22 -0
- package/templates/b2b-support-web/.vscode/settings.json +14 -0
- package/templates/b2b-support-web/AGENTS.md +108 -0
- package/templates/b2b-support-web/README.md +48 -0
- package/templates/b2b-support-web/forge.config.ts +3 -0
- package/templates/b2b-support-web/package.json +34 -0
- package/templates/b2b-support-web/src/actions/captureTicketCreated.ts +14 -0
- package/templates/b2b-support-web/src/commands/closeTicket.ts +20 -0
- package/templates/b2b-support-web/src/commands/createTicket.ts +47 -0
- package/templates/b2b-support-web/src/commands/manageBilling.ts +9 -0
- package/templates/b2b-support-web/src/forge/schema.ts +35 -0
- package/templates/b2b-support-web/src/policies.ts +9 -0
- package/templates/b2b-support-web/src/queries/getTicket.ts +6 -0
- package/templates/b2b-support-web/src/queries/listTickets.ts +6 -0
- package/templates/b2b-support-web/src/queries/liveTickets.ts +9 -0
- package/templates/b2b-support-web/src/workflows/triageTicketWorkflow.ts +64 -0
- package/templates/b2b-support-web/tsconfig.json +14 -0
- package/templates/b2b-support-web/web/app/globals.css +77 -0
- package/templates/b2b-support-web/web/app/layout.tsx +13 -0
- package/templates/b2b-support-web/web/app/page.tsx +13 -0
- package/templates/b2b-support-web/web/app/providers.tsx +21 -0
- package/templates/b2b-support-web/web/app/tickets/page.tsx +21 -0
- package/templates/b2b-support-web/web/components/CreateTicketForm.tsx +43 -0
- package/templates/b2b-support-web/web/components/PolicyDeniedDemo.tsx +31 -0
- package/templates/b2b-support-web/web/components/TicketList.tsx +52 -0
- package/templates/b2b-support-web/web/components/TraceDetails.tsx +18 -0
- package/templates/b2b-support-web/web/components/TriageStatus.tsx +13 -0
- package/templates/b2b-support-web/web/lib/forge.ts +13 -0
- package/templates/b2b-support-web/web/next-env.d.ts +5 -0
- package/templates/b2b-support-web/web/next.config.ts +8 -0
- package/templates/b2b-support-web/web/package.json +21 -0
- package/templates/b2b-support-web/web/tsconfig.json +30 -0
- package/templates/minimal-web/.vscode/settings.json +14 -0
- package/templates/minimal-web/README.md +21 -0
- package/templates/minimal-web/forge.config.ts +3 -0
- package/templates/minimal-web/package.json +32 -0
- package/templates/minimal-web/src/actions/logNoteCreated.ts +11 -0
- package/templates/minimal-web/src/commands/createNote.ts +26 -0
- package/templates/minimal-web/src/forge/schema.ts +12 -0
- package/templates/minimal-web/src/policies.ts +6 -0
- package/templates/minimal-web/src/queries/listNotes.ts +8 -0
- package/templates/minimal-web/src/queries/liveNotes.ts +8 -0
- package/templates/minimal-web/tsconfig.json +15 -0
- package/templates/minimal-web/web/index.html +12 -0
- package/templates/minimal-web/web/package.json +21 -0
- package/templates/minimal-web/web/src/App.tsx +89 -0
- package/templates/minimal-web/web/src/lib/forge.ts +13 -0
- package/templates/minimal-web/web/src/main.tsx +13 -0
- package/templates/minimal-web/web/src/styles.css +156 -0
- package/templates/minimal-web/web/tsconfig.json +18 -0
|
@@ -0,0 +1,1130 @@
|
|
|
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
|
+
import type {
|
|
22
|
+
ForgeAddResult,
|
|
23
|
+
GenerateOptions,
|
|
24
|
+
GenerateResult,
|
|
25
|
+
InspectResult,
|
|
26
|
+
InspectTarget,
|
|
27
|
+
VerifyOptions,
|
|
28
|
+
VerifyResult,
|
|
29
|
+
} from "../compiler/types/cli.ts";
|
|
30
|
+
import type { RuntimeMatrix } from "../compiler/types/runtime-matrix.ts";
|
|
31
|
+
import type { FrontendGraph } from "../compiler/types/frontend-graph.ts";
|
|
32
|
+
import { GENERATED_DIR } from "../compiler/emitter/constants.ts";
|
|
33
|
+
import {
|
|
34
|
+
attachFailureKind,
|
|
35
|
+
buildAddJson,
|
|
36
|
+
buildGenerateJson,
|
|
37
|
+
buildInspectJson,
|
|
38
|
+
formatJsonResult,
|
|
39
|
+
writeHumanAdd,
|
|
40
|
+
writeHumanGenerate,
|
|
41
|
+
writeHumanInspect,
|
|
42
|
+
buildVerifyJson,
|
|
43
|
+
writeHumanVerify,
|
|
44
|
+
} from "./output.ts";
|
|
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";
|
|
90
|
+
import {
|
|
91
|
+
formatDoctorHuman,
|
|
92
|
+
formatDoctorJson,
|
|
93
|
+
runDoctorCommand,
|
|
94
|
+
} from "./doctor.ts";
|
|
95
|
+
import {
|
|
96
|
+
formatWindowsDoctorHuman,
|
|
97
|
+
formatWindowsDoctorJson,
|
|
98
|
+
formatWindowsSetupHuman,
|
|
99
|
+
formatWindowsSetupJson,
|
|
100
|
+
runWindowsDoctorCommand,
|
|
101
|
+
runWindowsSetupCommand,
|
|
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";
|
|
120
|
+
import {
|
|
121
|
+
formatRepairHuman,
|
|
122
|
+
formatRepairJson,
|
|
123
|
+
runRepairCommand,
|
|
124
|
+
} from "../repair/index.ts";
|
|
125
|
+
import {
|
|
126
|
+
formatForgeDoHuman,
|
|
127
|
+
formatForgeDoJson,
|
|
128
|
+
runForgeDoCommand,
|
|
129
|
+
} from "../intent/index.ts";
|
|
130
|
+
import {
|
|
131
|
+
formatAgentHuman,
|
|
132
|
+
formatAgentJson,
|
|
133
|
+
runAgentCommand,
|
|
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
|
+
|
|
168
|
+
function readGeneratedText(workspaceRoot: string, relative: string): string | null {
|
|
169
|
+
const absolute = join(workspaceRoot, relative);
|
|
170
|
+
if (!nodeFileSystem.exists(absolute)) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return stripDeterministicHeader((nodeFileSystem.readText(absolute) ?? ""));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function readPackageJson(workspaceRoot: string): Record<string, unknown> {
|
|
177
|
+
try {
|
|
178
|
+
return JSON.parse(nodeFileSystem.readText(join(workspaceRoot, "package.json")) ?? "{}") as Record<string, unknown>;
|
|
179
|
+
} catch {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function hasPath(workspaceRoot: string, relative: string): boolean {
|
|
185
|
+
return nodeFileSystem.exists(join(workspaceRoot, relative));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function sortedDirectoryNames(workspaceRoot: string, relative: string): string[] {
|
|
189
|
+
const absolute = join(workspaceRoot, relative);
|
|
190
|
+
if (!nodeFileSystem.exists(absolute)) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
return nodeFileSystem
|
|
194
|
+
.readDir(absolute)
|
|
195
|
+
.filter((entry) => entry.isDirectory)
|
|
196
|
+
.map((entry) => entry.name)
|
|
197
|
+
.sort();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function buildFrameworkInspect(workspaceRoot: string): Record<string, unknown> {
|
|
201
|
+
const pkg = readPackageJson(workspaceRoot);
|
|
202
|
+
const scripts = pkg.scripts && typeof pkg.scripts === "object"
|
|
203
|
+
? Object.keys(pkg.scripts as Record<string, string>).sort()
|
|
204
|
+
: [];
|
|
205
|
+
const dependencies = pkg.dependencies && typeof pkg.dependencies === "object"
|
|
206
|
+
? Object.keys(pkg.dependencies as Record<string, string>).sort()
|
|
207
|
+
: [];
|
|
208
|
+
const devDependencies = pkg.devDependencies && typeof pkg.devDependencies === "object"
|
|
209
|
+
? Object.keys(pkg.devDependencies as Record<string, string>).sort()
|
|
210
|
+
: [];
|
|
211
|
+
const templates = sortedDirectoryNames(workspaceRoot, "templates").map((name) => ({
|
|
212
|
+
name,
|
|
213
|
+
hasWeb: hasPath(workspaceRoot, `templates/${name}/web`),
|
|
214
|
+
hasAgentsMd: hasPath(workspaceRoot, `templates/${name}/AGENTS.md`),
|
|
215
|
+
packageJson: `templates/${name}/package.json`,
|
|
216
|
+
}));
|
|
217
|
+
const examples = sortedDirectoryNames(workspaceRoot, "examples").map((name) => ({
|
|
218
|
+
name,
|
|
219
|
+
sourceOnly: !hasPath(workspaceRoot, `examples/${name}/src/forge/_generated`) &&
|
|
220
|
+
!hasPath(workspaceRoot, `examples/${name}/forge.lock`),
|
|
221
|
+
hasWeb: hasPath(workspaceRoot, `examples/${name}/web`),
|
|
222
|
+
hasAgentsMd: hasPath(workspaceRoot, `examples/${name}/AGENTS.md`),
|
|
223
|
+
}));
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
schemaVersion: "0.1.0",
|
|
227
|
+
project: {
|
|
228
|
+
name: typeof pkg.name === "string" ? pkg.name : "unknown",
|
|
229
|
+
version: typeof pkg.version === "string" ? pkg.version : "unknown",
|
|
230
|
+
private: pkg.private === true,
|
|
231
|
+
type: "forgeos-framework",
|
|
232
|
+
},
|
|
233
|
+
packageManager: pkg.packageManager ?? "bun",
|
|
234
|
+
scripts,
|
|
235
|
+
dependencies,
|
|
236
|
+
devDependencies,
|
|
237
|
+
cli: {
|
|
238
|
+
topLevelCommands: [...TOP_LEVEL_COMMANDS],
|
|
239
|
+
inspectTargets: [...INSPECT_TARGETS],
|
|
240
|
+
preferredEntryPoints: [
|
|
241
|
+
"forge do <objective> --json",
|
|
242
|
+
"forge dev --once --json",
|
|
243
|
+
"forge inspect all --json",
|
|
244
|
+
"forge inspect framework --json",
|
|
245
|
+
"forge verify --strict",
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
modules: sortedDirectoryNames(workspaceRoot, "src/forge").map((name) => ({
|
|
249
|
+
name,
|
|
250
|
+
path: `src/forge/${name}`,
|
|
251
|
+
})),
|
|
252
|
+
templates,
|
|
253
|
+
examples,
|
|
254
|
+
tests: sortedDirectoryNames(workspaceRoot, "tests").map((name) => ({
|
|
255
|
+
name,
|
|
256
|
+
path: `tests/${name}`,
|
|
257
|
+
})),
|
|
258
|
+
generated: {
|
|
259
|
+
directory: GENERATED_DIR,
|
|
260
|
+
rootArtifacts: ["AGENTS.md", "forge.lock"],
|
|
261
|
+
sourceOnlyExamples: examples
|
|
262
|
+
.filter((example) => example.sourceOnly)
|
|
263
|
+
.map((example) => example.name),
|
|
264
|
+
},
|
|
265
|
+
documentation: {
|
|
266
|
+
readme: hasPath(workspaceRoot, "README.md"),
|
|
267
|
+
agents: hasPath(workspaceRoot, "AGENTS.md"),
|
|
268
|
+
ci: hasPath(workspaceRoot, ".github/workflows/ci.yml"),
|
|
269
|
+
},
|
|
270
|
+
};
|
|
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
|
+
|
|
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> {
|
|
325
|
+
const session = getCompileSession(workspaceRoot);
|
|
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
|
+
);
|
|
336
|
+
const aiDiagnostics = checkAiUsageInApp(appGraph);
|
|
337
|
+
const queryDiagnostics = checkQueryUsageInApp(appGraph);
|
|
338
|
+
const frontendDiagnostics =
|
|
339
|
+
readGeneratedJson<FrontendGraph>(workspaceRoot, `${GENERATED_DIR}/frontendGraph.json`)
|
|
340
|
+
?.diagnostics ?? [];
|
|
341
|
+
const capabilityDiagnostics =
|
|
342
|
+
readGeneratedJson<{ diagnostics?: import("../compiler/types/diagnostic.ts").Diagnostic[] }>(
|
|
343
|
+
workspaceRoot,
|
|
344
|
+
`${GENERATED_DIR}/capabilityMap.json`,
|
|
345
|
+
)?.diagnostics ?? [];
|
|
346
|
+
|
|
347
|
+
const allDiagnostics = [
|
|
348
|
+
...guardDiagnostics,
|
|
349
|
+
...processEnvDiagnostics,
|
|
350
|
+
...aiDiagnostics,
|
|
351
|
+
...queryDiagnostics,
|
|
352
|
+
...frontendDiagnostics,
|
|
353
|
+
...capabilityDiagnostics,
|
|
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`,
|
|
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`,
|
|
392
|
+
api: `${GENERATED_DIR}/api.json`,
|
|
393
|
+
client: `${GENERATED_DIR}/clientManifest.json`,
|
|
394
|
+
frontend: `${GENERATED_DIR}/frontendGraph.json`,
|
|
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`,
|
|
404
|
+
make: `${GENERATED_DIR}/makeRegistry.json`,
|
|
405
|
+
"test-graph": `${GENERATED_DIR}/testGraph.json`,
|
|
406
|
+
"test-plans": `${GENERATED_DIR}/testPlanRegistry.json`,
|
|
407
|
+
"agent-contract": `${GENERATED_DIR}/agentContract.json`,
|
|
408
|
+
"agent-adapters": `${GENERATED_DIR}/agentAdapterManifest.json`,
|
|
409
|
+
"capability-map": `${GENERATED_DIR}/capabilityMap.json`,
|
|
410
|
+
ui: `${GENERATED_DIR}/uiTestManifest.json`,
|
|
411
|
+
"ui-scenarios": `${GENERATED_DIR}/uiScenarios.json`,
|
|
412
|
+
"ui-routes": `${GENERATED_DIR}/uiRoutes.json`,
|
|
413
|
+
rules: `${GENERATED_DIR}/runtimeRules.md`,
|
|
414
|
+
map: `${GENERATED_DIR}/appMap.md`,
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
if (target === "framework") {
|
|
418
|
+
return {
|
|
419
|
+
target,
|
|
420
|
+
data: buildFrameworkInspect(workspaceRoot),
|
|
421
|
+
warnings: [],
|
|
422
|
+
errors: [],
|
|
423
|
+
exitCode: 0,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
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`],
|
|
439
|
+
["client", `${GENERATED_DIR}/clientManifest.json`],
|
|
440
|
+
["frontend", `${GENERATED_DIR}/frontendGraph.json`],
|
|
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`],
|
|
451
|
+
["testGraph", `${GENERATED_DIR}/testGraph.json`],
|
|
452
|
+
["testPlanRegistry", `${GENERATED_DIR}/testPlanRegistry.json`],
|
|
453
|
+
["agentContract", `${GENERATED_DIR}/agentContract.json`],
|
|
454
|
+
["agentAdapters", `${GENERATED_DIR}/agentAdapterManifest.json`],
|
|
455
|
+
["capabilityMap", `${GENERATED_DIR}/capabilityMap.json`],
|
|
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
|
+
}
|
|
476
|
+
}
|
|
477
|
+
data.framework = buildFrameworkInspect(workspaceRoot);
|
|
478
|
+
data.diagnostics = errors;
|
|
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,
|
|
544
|
+
packageManager: command.packageManager,
|
|
545
|
+
install: command.install,
|
|
546
|
+
git: command.git,
|
|
547
|
+
forgePackageSpec: command.forgePackageSpec,
|
|
548
|
+
localForge: command.localForge,
|
|
549
|
+
workspaceRoot: command.workspaceRoot,
|
|
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
|
+
}
|
|
607
|
+
case "doctor": {
|
|
608
|
+
if (command.target === "windows") {
|
|
609
|
+
const result = await runWindowsDoctorCommand({ workspaceRoot: command.workspaceRoot });
|
|
610
|
+
if (command.json) {
|
|
611
|
+
process.stdout.write(formatWindowsDoctorJson(result));
|
|
612
|
+
} else {
|
|
613
|
+
process.stdout.write(formatWindowsDoctorHuman(result));
|
|
614
|
+
}
|
|
615
|
+
return result.exitCode;
|
|
616
|
+
}
|
|
617
|
+
const result = await runDoctorCommand({ workspaceRoot: command.workspaceRoot });
|
|
618
|
+
if (command.json) {
|
|
619
|
+
process.stdout.write(formatDoctorJson(result));
|
|
620
|
+
} else {
|
|
621
|
+
process.stdout.write(formatDoctorHuman(result));
|
|
622
|
+
}
|
|
623
|
+
return result.exitCode;
|
|
624
|
+
}
|
|
625
|
+
case "setup": {
|
|
626
|
+
const result = await runWindowsSetupCommand({
|
|
627
|
+
workspaceRoot: command.workspaceRoot,
|
|
628
|
+
yes: command.yes,
|
|
629
|
+
});
|
|
630
|
+
if (command.json) {
|
|
631
|
+
process.stdout.write(formatWindowsSetupJson(result));
|
|
632
|
+
} else {
|
|
633
|
+
process.stdout.write(formatWindowsSetupHuman(result));
|
|
634
|
+
}
|
|
635
|
+
return result.exitCode;
|
|
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
|
+
}
|
|
722
|
+
case "repair": {
|
|
723
|
+
const result = await runRepairCommand(command.options);
|
|
724
|
+
if (command.options.json) {
|
|
725
|
+
process.stdout.write(formatRepairJson(result));
|
|
726
|
+
} else {
|
|
727
|
+
process.stdout.write(formatRepairHuman(result));
|
|
728
|
+
}
|
|
729
|
+
return result.exitCode;
|
|
730
|
+
}
|
|
731
|
+
case "do": {
|
|
732
|
+
const result = runForgeDoCommand(command.options);
|
|
733
|
+
if (command.options.json) {
|
|
734
|
+
process.stdout.write(formatForgeDoJson(result));
|
|
735
|
+
} else {
|
|
736
|
+
process.stdout.write(formatForgeDoHuman(result));
|
|
737
|
+
}
|
|
738
|
+
return result.exitCode;
|
|
739
|
+
}
|
|
740
|
+
case "agent": {
|
|
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,
|
|
907
|
+
databaseUrl: command.databaseUrl,
|
|
908
|
+
worker: command.worker,
|
|
909
|
+
withWeb: command.withWeb,
|
|
910
|
+
apiOnly: command.apiOnly,
|
|
911
|
+
webOnly: command.webOnly,
|
|
912
|
+
open: command.open,
|
|
913
|
+
webPort: command.webPort,
|
|
914
|
+
telemetry: command.telemetry,
|
|
915
|
+
envFile: command.envFile,
|
|
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 };
|