forgeos 0.1.0-alpha.4 → 0.1.0-alpha.41
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 +10 -0
- package/AGENTS.md +142 -90
- package/CHANGELOG.md +433 -0
- package/LICENSE +21 -0
- package/README.md +67 -8
- package/adapters/go/README.md +23 -0
- package/adapters/go/go.mod +3 -0
- package/adapters/go/http.go +149 -0
- package/adapters/go/registry.go +234 -0
- package/adapters/go/types.go +136 -0
- package/adapters/java/README.md +68 -0
- package/adapters/java/pom.xml +34 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Auth.java +20 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Diagnostic.java +16 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Entry.java +38 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/EntryKind.java +16 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ErrorInfo.java +4 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Forge.java +94 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ForgeCall.java +12 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ForgeContext.java +11 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ForgeHandler.java +8 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ForgeHttpHandler.java +179 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ForgeRegistry.java +121 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Json.java +14 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Manifest.java +14 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/RequestEnvelope.java +6 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/ResponseEnvelope.java +25 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Risk.java +18 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Schemas.java +36 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/Service.java +65 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/TransactionMode.java +18 -0
- package/adapters/java/src/main/java/dev/forgeos/adapter/TypedForgeHandler.java +6 -0
- package/adapters/java-spring-boot-starter/README.md +32 -0
- package/adapters/java-spring-boot-starter/pom.xml +36 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeCommand.java +22 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeExternalService.java +15 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeQuery.java +16 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeServiceBeanCondition.java +18 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeSpringAutoConfiguration.java +16 -0
- package/adapters/java-spring-boot-starter/src/main/java/dev/forgeos/adapter/spring/ForgeSpringRuntime.java +104 -0
- package/adapters/java-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +1 -0
- package/bin/forge.mjs +18 -0
- package/docs/cair-protocol.md +103 -0
- package/docs/changelog.md +548 -0
- package/docs/forge-protocol.md +189 -0
- package/examples/go-billing/go.mod +7 -0
- package/examples/go-billing/main.go +120 -0
- package/examples/java-billing/pom.xml +52 -0
- package/examples/java-billing/src/main/java/dev/forgeos/examples/billing/CreateInvoiceInput.java +4 -0
- package/examples/java-billing/src/main/java/dev/forgeos/examples/billing/Invoice.java +11 -0
- package/examples/java-billing/src/main/java/dev/forgeos/examples/billing/Main.java +127 -0
- package/package.json +31 -3
- package/schemas/forge-manifest.schema.json +57 -0
- package/src/forge/_generated/releaseManifest.json +1 -2
- package/src/forge/_generated/releaseManifest.ts +3 -3
- package/src/forge/agent-adapters/index.ts +1584 -125
- package/src/forge/agent-adapters/types.ts +224 -1
- package/src/forge/agent-memory/bridge.ts +1333 -0
- package/src/forge/agent-memory/context-pack.ts +277 -0
- package/src/forge/agent-memory/hook-runner.ts +312 -0
- package/src/forge/agent-memory/mcp.ts +224 -0
- package/src/forge/agent-memory/normalize.ts +498 -0
- package/src/forge/agent-memory/redaction.ts +103 -0
- package/src/forge/agent-memory/sources/claude-code.ts +51 -0
- package/src/forge/agent-memory/sources/codex-hook-runner.mjs +273 -0
- package/src/forge/agent-memory/sources/codex.ts +119 -0
- package/src/forge/agent-memory/sources/cursor.ts +35 -0
- package/src/forge/agent-memory/types.ts +204 -0
- package/src/forge/bench.ts +248 -0
- package/src/forge/brownfield-import/index.ts +801 -0
- package/src/forge/brownfield-import/types.ts +127 -0
- package/src/forge/cair/action-journal.ts +61 -0
- package/src/forge/cair/action-parser.ts +314 -0
- package/src/forge/cair/action-validator.ts +40 -0
- package/src/forge/cair/actions.ts +1818 -0
- package/src/forge/cair/format.ts +77 -0
- package/src/forge/cair/index.ts +106 -0
- package/src/forge/cair/query.ts +478 -0
- package/src/forge/cair/snapshot.ts +315 -0
- package/src/forge/cair/types.ts +248 -0
- package/src/forge/cli/ai.ts +339 -21
- package/src/forge/cli/auth.ts +348 -10
- package/src/forge/cli/authmd.ts +441 -0
- package/src/forge/cli/baseline.ts +112 -0
- package/src/forge/cli/build.ts +20 -4
- package/src/forge/cli/changed.ts +437 -0
- package/src/forge/cli/codex-app-server.ts +877 -0
- package/src/forge/cli/commands.ts +1620 -20
- package/src/forge/cli/db.ts +209 -2
- package/src/forge/cli/deploy.ts +887 -0
- package/src/forge/cli/deps.ts +82 -13
- package/src/forge/cli/dev.ts +961 -46
- package/src/forge/cli/docs.ts +265 -0
- package/src/forge/cli/doctor.ts +297 -0
- package/src/forge/cli/field-test.ts +329 -0
- package/src/forge/cli/handoff.ts +336 -0
- package/src/forge/cli/index.ts +1 -0
- package/src/forge/cli/last-run.ts +84 -0
- package/src/forge/cli/main.ts +107 -3
- package/src/forge/cli/new.ts +152 -13
- package/src/forge/cli/next-actions.ts +23 -0
- package/src/forge/cli/output.ts +389 -6
- package/src/forge/cli/parse.ts +1050 -34
- package/src/forge/cli/progress.ts +51 -0
- package/src/forge/cli/query.ts +32 -0
- package/src/forge/cli/release.ts +35 -11
- package/src/forge/cli/rls.ts +43 -4
- package/src/forge/cli/run.ts +41 -0
- package/src/forge/cli/security.ts +112 -0
- package/src/forge/cli/self-host.ts +56 -14
- package/src/forge/cli/studio.ts +2218 -0
- package/src/forge/cli/verify.ts +1455 -32
- package/src/forge/cli/windows.ts +23 -0
- package/src/forge/cli/workos.ts +1020 -0
- package/src/forge/compiler/agent-contract/build.ts +670 -64
- package/src/forge/compiler/agent-contract/types.ts +45 -2
- package/src/forge/compiler/ai-registry/parse.ts +71 -2
- package/src/forge/compiler/api-surface/build.ts +47 -0
- package/src/forge/compiler/app-graph/build.ts +112 -9
- package/src/forge/compiler/app-graph/extract.ts +107 -0
- package/src/forge/compiler/app-graph/module-graph.ts +73 -78
- package/src/forge/compiler/app-graph/parser.ts +24 -24
- package/src/forge/compiler/app-graph/profile.ts +26 -0
- package/src/forge/compiler/app-graph/versions.ts +1 -1
- package/src/forge/compiler/classifier/capabilities.ts +3 -2
- package/src/forge/compiler/classifier/classify.ts +32 -8
- package/src/forge/compiler/classifier/secrets.ts +3 -2
- package/src/forge/compiler/classifier/signals.ts +91 -1
- package/src/forge/compiler/client-sdk/build-manifest.ts +59 -0
- package/src/forge/compiler/client-sdk/render-client.ts +295 -13
- package/src/forge/compiler/data-graph/parse.ts +20 -4
- package/src/forge/compiler/data-graph/sql/ddl.ts +144 -31
- package/src/forge/compiler/data-graph/sql/serialize.ts +4 -0
- package/src/forge/compiler/data-graph/sql/types.ts +1 -0
- package/src/forge/compiler/diagnostics/codes.ts +30 -0
- package/src/forge/compiler/diagnostics/create.ts +21 -2
- package/src/forge/compiler/diagnostics/index.ts +2 -0
- package/src/forge/compiler/emitter/barrel.ts +3 -0
- package/src/forge/compiler/emitter/render.ts +9 -0
- package/src/forge/compiler/external-manifest/registry.ts +205 -0
- package/src/forge/compiler/external-manifest/types.ts +91 -0
- package/src/forge/compiler/external-manifest/validate.ts +373 -0
- package/src/forge/compiler/frontend-graph/build.ts +142 -14
- package/src/forge/compiler/integration/add.ts +618 -24
- package/src/forge/compiler/integration/plan.ts +43 -12
- package/src/forge/compiler/integration/render.ts +29 -0
- package/src/forge/compiler/integration/snapshot.ts +2 -0
- package/src/forge/compiler/integration/templates/convex.ts +70 -0
- package/src/forge/compiler/integration/templates/index.ts +1 -0
- package/src/forge/compiler/integration/templates/render.ts +38 -0
- package/src/forge/compiler/integration/templates/types.ts +3 -0
- package/src/forge/compiler/integration/templates/workos.ts +1219 -0
- package/src/forge/compiler/make-registry/build.ts +8 -9
- package/src/forge/compiler/orchestrator/fast-check.ts +4 -0
- package/src/forge/compiler/orchestrator/generate-lock.ts +14 -3
- package/src/forge/compiler/orchestrator/manifest.ts +1 -1
- package/src/forge/compiler/orchestrator/plan-profile.ts +23 -0
- package/src/forge/compiler/orchestrator/plan.ts +247 -10
- package/src/forge/compiler/orchestrator/profile.ts +65 -0
- package/src/forge/compiler/orchestrator/run.ts +97 -31
- package/src/forge/compiler/orchestrator/serialize.ts +33 -8
- package/src/forge/compiler/orchestrator/types.ts +1 -1
- package/src/forge/compiler/package-graph/compiler.ts +3 -1
- package/src/forge/compiler/package-graph/constants.ts +1 -1
- package/src/forge/compiler/package-manager/adapter.ts +4 -1
- package/src/forge/compiler/package-manager/commands.ts +4 -0
- package/src/forge/compiler/package-manager/executor.ts +30 -1
- package/src/forge/compiler/package-manager/version.ts +36 -12
- package/src/forge/compiler/package-upgrades/planner.ts +155 -18
- package/src/forge/compiler/package-upgrades/types.ts +2 -0
- package/src/forge/compiler/policy-registry/build.ts +47 -2
- package/src/forge/compiler/policy-registry/parse.ts +32 -2
- package/src/forge/compiler/recipes/definitions.ts +63 -0
- package/src/forge/compiler/recipes/index.ts +2 -0
- package/src/forge/compiler/recipes/registry.ts +6 -0
- package/src/forge/compiler/test-graph/build.ts +11 -3
- package/src/forge/compiler/types/app-graph.ts +8 -2
- package/src/forge/compiler/types/cli.ts +75 -1
- package/src/forge/compiler/types/dev-manifest.ts +4 -0
- package/src/forge/compiler/types/emit.ts +2 -0
- package/src/forge/compiler/types/frontend-graph.ts +2 -2
- package/src/forge/compiler/types/integration.ts +1 -0
- package/src/forge/compiler/types/package-graph.ts +6 -0
- package/src/forge/compiler/types/policy-registry.ts +3 -1
- package/src/forge/delta/classifier.ts +52 -0
- package/src/forge/delta/explain.ts +238 -0
- package/src/forge/delta/git-observer.ts +43 -0
- package/src/forge/delta/ids.ts +44 -0
- package/src/forge/delta/index.ts +25 -0
- package/src/forge/delta/recorder.ts +540 -0
- package/src/forge/delta/redaction.ts +50 -0
- package/src/forge/delta/schema.ts +240 -0
- package/src/forge/delta/session.ts +142 -0
- package/src/forge/delta/status.ts +1202 -0
- package/src/forge/delta/store.ts +3284 -0
- package/src/forge/delta/timeline.ts +178 -0
- package/src/forge/dev/server.ts +808 -17
- package/src/forge/dev/types.ts +15 -1
- package/src/forge/dev/watch.ts +17 -7
- package/src/forge/dev-console/cycle.ts +280 -33
- package/src/forge/dev-console/types.ts +47 -1
- package/src/forge/impact/index.ts +204 -9
- package/src/forge/impact/types.ts +33 -1
- package/src/forge/intent/index.ts +35 -16
- package/src/forge/make/fields.ts +26 -0
- package/src/forge/make/index.ts +40 -6
- package/src/forge/make/templates.ts +155 -2
- package/src/forge/make/types.ts +2 -1
- package/src/forge/policy.ts +1 -1
- package/src/forge/react/index.ts +160 -2
- package/src/forge/refactor/index.ts +1 -0
- package/src/forge/repair/rules/index.ts +2 -2
- package/src/forge/review/index.ts +158 -12
- package/src/forge/review/types.ts +15 -0
- package/src/forge/runtime/auth/config.ts +17 -0
- package/src/forge/runtime/auth/evaluate.ts +15 -2
- package/src/forge/runtime/auth/resolve.ts +61 -6
- package/src/forge/runtime/auth/types.ts +1 -0
- package/src/forge/runtime/db/factory.ts +1 -3
- package/src/forge/runtime/db/generated-client.ts +13 -2
- package/src/forge/runtime/db/memory-adapter.ts +139 -32
- package/src/forge/runtime/db/pglite-adapter.ts +263 -2
- package/src/forge/runtime/db/postgres-adapter.ts +6 -3
- package/src/forge/runtime/executor.ts +129 -16
- package/src/forge/runtime/external/bridge.ts +649 -0
- package/src/forge/runtime/runner/run-entry.ts +16 -7
- package/src/forge/runtime/telemetry/buffer.ts +4 -1
- package/src/forge/runtime/telemetry/scrubber.ts +35 -5
- package/src/forge/runtime/webhooks/security.ts +12 -7
- package/src/forge/server.ts +17 -3
- package/src/forge/ui/index.ts +209 -0
- package/src/forge/ui/types.ts +1 -0
- package/src/forge/version.ts +1 -1
- package/src/forge/vue/index.ts +422 -0
- package/src/forge/workspace/baseline.ts +112 -0
- package/src/forge/workspace/change-summary.ts +250 -0
- package/src/forge/workspace/forge-cli.ts +42 -0
- package/src/forge/workspace/git-summary.ts +391 -0
- package/templates/agent-workroom/AGENTS.md +29 -0
- package/templates/agent-workroom/README.md +34 -0
- package/templates/agent-workroom/forge.config.ts +3 -0
- package/templates/agent-workroom/package.json +33 -0
- package/templates/agent-workroom/src/actions/indexAgentSignal.ts +10 -0
- package/templates/agent-workroom/src/commands/openWorkroom.ts +61 -0
- package/templates/agent-workroom/src/commands/recordAgentSignal.ts +119 -0
- package/templates/agent-workroom/src/commands/recordCheckRun.ts +52 -0
- package/templates/agent-workroom/src/forge/schema.ts +54 -0
- package/templates/agent-workroom/src/policies.ts +6 -0
- package/templates/agent-workroom/src/queries/listWorkrooms.ts +11 -0
- package/templates/agent-workroom/src/queries/liveWorkroom.ts +63 -0
- package/templates/agent-workroom/tsconfig.json +16 -0
- package/templates/agent-workroom/web/index.html +12 -0
- package/templates/agent-workroom/web/package.json +21 -0
- package/templates/agent-workroom/web/src/App.tsx +345 -0
- package/templates/agent-workroom/web/src/lib/forge.ts +13 -0
- package/templates/agent-workroom/web/src/main.tsx +13 -0
- package/templates/agent-workroom/web/src/styles.css +545 -0
- package/templates/agent-workroom/web/tsconfig.json +27 -0
- package/templates/b2b-support-web/package.json +1 -0
- package/templates/b2b-support-web/web/package.json +1 -1
- package/templates/minimal-web/package.json +1 -1
- package/templates/minimal-web/web/package.json +2 -2
- package/templates/nuxt-web/.vscode/settings.json +14 -0
- package/templates/nuxt-web/README.md +30 -0
- package/templates/nuxt-web/forge.config.ts +3 -0
- package/templates/nuxt-web/package.json +33 -0
- package/templates/nuxt-web/src/actions/logNoteCreated.ts +11 -0
- package/templates/nuxt-web/src/commands/createNote.ts +26 -0
- package/templates/nuxt-web/src/forge/schema.ts +12 -0
- package/templates/nuxt-web/src/policies.ts +6 -0
- package/templates/nuxt-web/src/queries/listNotes.ts +8 -0
- package/templates/nuxt-web/src/queries/liveNotes.ts +8 -0
- package/templates/nuxt-web/tsconfig.json +17 -0
- package/templates/nuxt-web/web/app.vue +67 -0
- package/templates/nuxt-web/web/components/LiveNotes.vue +89 -0
- package/templates/nuxt-web/web/components/NoteComposer.vue +100 -0
- package/templates/nuxt-web/web/composables/forge.ts +13 -0
- package/templates/nuxt-web/web/composables/useNotes.ts +24 -0
- package/templates/nuxt-web/web/nuxt.config.ts +11 -0
- package/templates/nuxt-web/web/package.json +18 -0
- package/templates/nuxt-web/web/plugins/forge.client.ts +10 -0
- package/templates/nuxt-web/web/plugins/forge.server.ts +10 -0
- package/templates/nuxt-web/web/server/api/forge-health.get.ts +7 -0
- package/templates/nuxt-web/web/tsconfig.json +6 -0
- package/src/forge/_generated/actionSubscriptions.json +0 -2
- package/src/forge/_generated/actionSubscriptions.ts +0 -10
- package/src/forge/_generated/agentAdapterManifest.json +0 -2
- package/src/forge/_generated/agentAdapterManifest.ts +0 -73
- package/src/forge/_generated/agentContract.json +0 -2
- package/src/forge/_generated/agentContract.ts +0 -7829
- package/src/forge/_generated/agentQuickstart.md +0 -34
- package/src/forge/_generated/agentTools.json +0 -2
- package/src/forge/_generated/agentTools.md +0 -16
- package/src/forge/_generated/agentTools.ts +0 -12
- package/src/forge/_generated/aiContext.ts +0 -125
- package/src/forge/_generated/aiModels.json +0 -2
- package/src/forge/_generated/aiModels.ts +0 -51
- package/src/forge/_generated/aiProviders.json +0 -2
- package/src/forge/_generated/aiProviders.ts +0 -23
- package/src/forge/_generated/aiRegistry.json +0 -2
- package/src/forge/_generated/aiRegistry.ts +0 -31
- package/src/forge/_generated/api.json +0 -2
- package/src/forge/_generated/api.ts +0 -8
- package/src/forge/_generated/appGraph.json +0 -2
- package/src/forge/_generated/appGraph.ts +0 -14919
- package/src/forge/_generated/appMap.md +0 -55
- package/src/forge/_generated/artifactManifest.json +0 -2
- package/src/forge/_generated/artifactManifest.ts +0 -7
- package/src/forge/_generated/authClaims.json +0 -2
- package/src/forge/_generated/authClaims.ts +0 -13
- package/src/forge/_generated/authConfig.json +0 -2
- package/src/forge/_generated/authConfig.ts +0 -17
- package/src/forge/_generated/authContext.ts +0 -23
- package/src/forge/_generated/authRegistry.json +0 -2
- package/src/forge/_generated/authRegistry.ts +0 -25
- package/src/forge/_generated/buildInfo.json +0 -2
- package/src/forge/_generated/buildInfo.ts +0 -9
- package/src/forge/_generated/capabilityMap.json +0 -2
- package/src/forge/_generated/capabilityMap.md +0 -15
- package/src/forge/_generated/capabilityMap.ts +0 -17
- package/src/forge/_generated/client.ts +0 -282
- package/src/forge/_generated/clientApi.ts +0 -9
- package/src/forge/_generated/clientManifest.json +0 -2
- package/src/forge/_generated/clientManifest.ts +0 -39
- package/src/forge/_generated/clientTypes.ts +0 -78
- package/src/forge/_generated/configRegistry.json +0 -2
- package/src/forge/_generated/configRegistry.ts +0 -4
- package/src/forge/_generated/dataGraph.json +0 -2
- package/src/forge/_generated/dataGraph.ts +0 -8
- package/src/forge/_generated/db.json +0 -2
- package/src/forge/_generated/db.ts +0 -2
- package/src/forge/_generated/dbSecurityManifest.json +0 -2
- package/src/forge/_generated/dbSecurityManifest.ts +0 -15
- package/src/forge/_generated/dbSessionContext.json +0 -2
- package/src/forge/_generated/dbSessionContext.ts +0 -39
- package/src/forge/_generated/deployManifest.json +0 -2
- package/src/forge/_generated/deployManifest.ts +0 -14
- package/src/forge/_generated/devManifest.json +0 -2
- package/src/forge/_generated/devManifest.ts +0 -62
- package/src/forge/_generated/envSchema.json +0 -2
- package/src/forge/_generated/envSchema.ts +0 -59
- package/src/forge/_generated/frontendGraph.json +0 -2
- package/src/forge/_generated/frontendGraph.ts +0 -27
- package/src/forge/_generated/importGuards.json +0 -2
- package/src/forge/_generated/importGuards.ts +0 -686
- package/src/forge/_generated/index.ts +0 -68
- package/src/forge/_generated/liveProductionManifest.json +0 -2
- package/src/forge/_generated/liveProductionManifest.ts +0 -23
- package/src/forge/_generated/liveProtocol.json +0 -2
- package/src/forge/_generated/liveProtocol.ts +0 -21
- package/src/forge/_generated/liveQueryRegistry.json +0 -2
- package/src/forge/_generated/liveQueryRegistry.ts +0 -9
- package/src/forge/_generated/liveTransportConfig.json +0 -2
- package/src/forge/_generated/liveTransportConfig.ts +0 -19
- package/src/forge/_generated/makeRegistry.json +0 -2
- package/src/forge/_generated/makeRegistry.ts +0 -177
- package/src/forge/_generated/makeTemplates.json +0 -2
- package/src/forge/_generated/makeTemplates.ts +0 -66
- package/src/forge/_generated/mockMap.json +0 -2
- package/src/forge/_generated/mockMap.ts +0 -7
- package/src/forge/_generated/operationPlaybooks.md +0 -167
- package/src/forge/_generated/packageGraph.json +0 -2
- package/src/forge/_generated/packageGraph.ts +0 -249334
- package/src/forge/_generated/packageUpgradeRegistry.json +0 -2
- package/src/forge/_generated/packageUpgradeRegistry.ts +0 -15
- package/src/forge/_generated/permissionMatrix.json +0 -2
- package/src/forge/_generated/permissionMatrix.ts +0 -7
- package/src/forge/_generated/policyRegistry.json +0 -2
- package/src/forge/_generated/policyRegistry.ts +0 -11
- package/src/forge/_generated/queryRegistry.json +0 -2
- package/src/forge/_generated/queryRegistry.ts +0 -9
- package/src/forge/_generated/react.d.ts +0 -22
- package/src/forge/_generated/react.ts +0 -29
- package/src/forge/_generated/reactManifest.json +0 -2
- package/src/forge/_generated/reactManifest.ts +0 -19
- package/src/forge/_generated/rlsPolicies.json +0 -2
- package/src/forge/_generated/rlsPolicies.sql +0 -34
- package/src/forge/_generated/rlsPolicies.ts +0 -6
- package/src/forge/_generated/runtimeGraph.json +0 -2
- package/src/forge/_generated/runtimeGraph.ts +0 -8
- package/src/forge/_generated/runtimeMatrix.json +0 -2
- package/src/forge/_generated/runtimeMatrix.ts +0 -334130
- package/src/forge/_generated/runtimeRegistry.ts +0 -2
- package/src/forge/_generated/runtimeRules.md +0 -91
- package/src/forge/_generated/secretRegistry.json +0 -2
- package/src/forge/_generated/secretRegistry.ts +0 -50
- package/src/forge/_generated/secretsContext.ts +0 -11
- package/src/forge/_generated/serverApi.ts +0 -10
- package/src/forge/_generated/sourceMapManifest.json +0 -2
- package/src/forge/_generated/sourceMapManifest.ts +0 -7
- package/src/forge/_generated/sqlPlan.json +0 -2
- package/src/forge/_generated/sqlPlan.ts +0 -88
- package/src/forge/_generated/subscriptionManifest.json +0 -2
- package/src/forge/_generated/subscriptionManifest.ts +0 -7
- package/src/forge/_generated/symbolicationManifest.json +0 -2
- package/src/forge/_generated/symbolicationManifest.ts +0 -17
- package/src/forge/_generated/telemetryRegistry.json +0 -2
- package/src/forge/_generated/telemetryRegistry.ts +0 -9
- package/src/forge/_generated/telemetrySinks.json +0 -2
- package/src/forge/_generated/telemetrySinks.ts +0 -11
- package/src/forge/_generated/tenantScope.json +0 -2
- package/src/forge/_generated/tenantScope.ts +0 -8
- package/src/forge/_generated/testGraph.json +0 -2
- package/src/forge/_generated/testGraph.ts +0 -3430
- package/src/forge/_generated/testPlanRegistry.json +0 -2
- package/src/forge/_generated/testPlanRegistry.ts +0 -33
- package/src/forge/_generated/uiRoutes.json +0 -2
- package/src/forge/_generated/uiRoutes.ts +0 -16
- package/src/forge/_generated/uiScenarios.json +0 -2
- package/src/forge/_generated/uiScenarios.ts +0 -30
- package/src/forge/_generated/uiTestManifest.json +0 -2
- package/src/forge/_generated/uiTestManifest.ts +0 -27
- package/src/forge/_generated/workflowRegistry.json +0 -2
- package/src/forge/_generated/workflowRegistry.ts +0 -9
- package/src/forge/_generated/workflowSubscriptions.json +0 -2
- package/src/forge/_generated/workflowSubscriptions.ts +0 -10
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { runNewCommand, type NewPackageManager, type NewTemplateName } from "./new.ts";
|
|
5
|
+
import { normalizeForgeCliCommandsInValue } from "../workspace/forge-cli.ts";
|
|
6
|
+
|
|
7
|
+
export type FieldTestSubcommand = "create" | "run" | "report";
|
|
8
|
+
|
|
9
|
+
export interface FieldTestCommandOptions {
|
|
10
|
+
subcommand: FieldTestSubcommand;
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
json: boolean;
|
|
13
|
+
name?: string;
|
|
14
|
+
template: NewTemplateName;
|
|
15
|
+
templates?: NewTemplateName[];
|
|
16
|
+
packageManager: NewPackageManager;
|
|
17
|
+
packageManagers?: NewPackageManager[];
|
|
18
|
+
forgeSpec?: string;
|
|
19
|
+
auth?: "none" | "workos";
|
|
20
|
+
dryRun: boolean;
|
|
21
|
+
keep: boolean;
|
|
22
|
+
runtimeProbes: boolean;
|
|
23
|
+
authProbes: boolean;
|
|
24
|
+
timeoutMs: number;
|
|
25
|
+
writeReport?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FieldTestCommandResult {
|
|
29
|
+
schemaVersion: "0.1.0";
|
|
30
|
+
ok: boolean;
|
|
31
|
+
kind: "field-test";
|
|
32
|
+
action: FieldTestSubcommand;
|
|
33
|
+
data?: unknown;
|
|
34
|
+
summary?: unknown;
|
|
35
|
+
command?: string[];
|
|
36
|
+
reportPath?: string;
|
|
37
|
+
stdout?: string;
|
|
38
|
+
stderr?: string;
|
|
39
|
+
nextActions: string[];
|
|
40
|
+
exitCode: 0 | 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function scriptPath(workspaceRoot: string): string {
|
|
44
|
+
return join(workspaceRoot, "scripts", "field-test-forgeos.mjs");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compact(text: string, limit = 12000): string {
|
|
48
|
+
if (text.length <= limit) return text;
|
|
49
|
+
const half = Math.floor(limit / 2);
|
|
50
|
+
return `${text.slice(0, half)}\n...[truncated ${text.length - limit} chars]...\n${text.slice(-half)}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function defaultReportPath(): string {
|
|
54
|
+
return ".forge/field-test-report.json";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseJsonOutput(text: string): unknown | null {
|
|
58
|
+
const trimmed = text.trim();
|
|
59
|
+
if (!trimmed) return null;
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(trimmed) as unknown;
|
|
62
|
+
} catch {
|
|
63
|
+
const start = trimmed.indexOf("{");
|
|
64
|
+
const end = trimmed.lastIndexOf("}");
|
|
65
|
+
if (start === -1 || end <= start) return null;
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(trimmed.slice(start, end + 1)) as unknown;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function summarizeReport(data: unknown) {
|
|
75
|
+
const root = data && typeof data === "object" ? data as Record<string, unknown> : {};
|
|
76
|
+
const results = Array.isArray(root.results) ? root.results as Array<Record<string, unknown>> : [];
|
|
77
|
+
const plannedCases = Array.isArray(root.cases) ? root.cases as Array<Record<string, unknown>> : [];
|
|
78
|
+
const failed = results.filter((result) => result.ok === false && result.skipped !== true);
|
|
79
|
+
const skipped = results.filter((result) => result.skipped === true);
|
|
80
|
+
const runtimeProbeSteps = results.flatMap((result) => {
|
|
81
|
+
const runtime = result.runtime && typeof result.runtime === "object"
|
|
82
|
+
? result.runtime as Record<string, unknown>
|
|
83
|
+
: {};
|
|
84
|
+
return Array.isArray(runtime.steps) ? runtime.steps as unknown[] : [];
|
|
85
|
+
});
|
|
86
|
+
const ok = root.ok === true;
|
|
87
|
+
const runtimeProbes = root.runtimeProbes === true;
|
|
88
|
+
const authProbes = root.authProbes === true;
|
|
89
|
+
const productionEvidenceMissing = [
|
|
90
|
+
...(!ok ? ["passing field-test report"] : []),
|
|
91
|
+
...(!runtimeProbes ? ["runtime probes"] : []),
|
|
92
|
+
...(!authProbes ? ["auth probes"] : []),
|
|
93
|
+
...(failed.length > 0 ? ["zero failed cases"] : []),
|
|
94
|
+
];
|
|
95
|
+
return {
|
|
96
|
+
ok,
|
|
97
|
+
cases: results.length || plannedCases.length,
|
|
98
|
+
executedCases: results.length,
|
|
99
|
+
plannedCases: plannedCases.length,
|
|
100
|
+
passed: results.filter((result) => result.ok === true && result.skipped !== true).length,
|
|
101
|
+
failed: failed.length,
|
|
102
|
+
skipped: skipped.length,
|
|
103
|
+
runtimeProbes,
|
|
104
|
+
authProbes,
|
|
105
|
+
runtimeProbeSteps: runtimeProbeSteps.length,
|
|
106
|
+
productionEvidence: {
|
|
107
|
+
readyForDeployCheck: productionEvidenceMissing.length === 0,
|
|
108
|
+
missing: productionEvidenceMissing,
|
|
109
|
+
deployCheckCommand: "forge deploy check --production --json",
|
|
110
|
+
note: "This proves field-test evidence only; deploy check still validates production auth, database, metadata, lockfile, and tenant posture.",
|
|
111
|
+
},
|
|
112
|
+
failedCases: failed.map((result) => ({
|
|
113
|
+
template: result.template,
|
|
114
|
+
packageManager: result.packageManager,
|
|
115
|
+
reason: result.reason,
|
|
116
|
+
})),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function runCommandForOptions(templates: NewTemplateName[], packageManagers: NewPackageManager[]): string {
|
|
121
|
+
return [
|
|
122
|
+
"forge field-test run",
|
|
123
|
+
`--templates ${templates.join(",")}`,
|
|
124
|
+
`--package-managers ${packageManagers.join(",")}`,
|
|
125
|
+
"--runtime-probes",
|
|
126
|
+
"--auth-probes",
|
|
127
|
+
"--json",
|
|
128
|
+
].join(" ");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function createFieldTestApp(options: FieldTestCommandOptions): Promise<FieldTestCommandResult> {
|
|
132
|
+
if (!options.name) {
|
|
133
|
+
return {
|
|
134
|
+
schemaVersion: "0.1.0",
|
|
135
|
+
ok: false,
|
|
136
|
+
kind: "field-test",
|
|
137
|
+
action: "create",
|
|
138
|
+
data: { error: "forge field-test create requires an app name" },
|
|
139
|
+
nextActions: ["forge field-test create vendor-access --auth workos --template minimal-web --json"],
|
|
140
|
+
exitCode: 1,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (options.dryRun) {
|
|
144
|
+
return normalizeForgeCliCommandsInValue(options.workspaceRoot, {
|
|
145
|
+
schemaVersion: "0.1.0",
|
|
146
|
+
ok: true,
|
|
147
|
+
kind: "field-test",
|
|
148
|
+
action: "create",
|
|
149
|
+
data: {
|
|
150
|
+
dryRun: true,
|
|
151
|
+
name: options.name,
|
|
152
|
+
template: options.template,
|
|
153
|
+
packageManager: options.packageManager,
|
|
154
|
+
auth: options.auth,
|
|
155
|
+
command: `forge new ${options.name} --template ${options.template} --package-manager ${options.packageManager} --field-test --install`,
|
|
156
|
+
},
|
|
157
|
+
nextActions: [`forge new ${options.name} --template ${options.template} --package-manager ${options.packageManager} --field-test --install`],
|
|
158
|
+
exitCode: 0,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const created = await runNewCommand({
|
|
162
|
+
name: options.name,
|
|
163
|
+
template: options.template,
|
|
164
|
+
packageManager: options.packageManager,
|
|
165
|
+
install: true,
|
|
166
|
+
git: true,
|
|
167
|
+
fieldTest: options.auth === "workos",
|
|
168
|
+
forgePackageSpec: options.forgeSpec,
|
|
169
|
+
workspaceRoot: options.workspaceRoot,
|
|
170
|
+
});
|
|
171
|
+
const createdFieldTest = created.fieldTest?.steps ?? [];
|
|
172
|
+
return normalizeForgeCliCommandsInValue(options.workspaceRoot, {
|
|
173
|
+
schemaVersion: "0.1.0",
|
|
174
|
+
ok: created.exitCode === 0,
|
|
175
|
+
kind: "field-test",
|
|
176
|
+
action: "create",
|
|
177
|
+
data: {
|
|
178
|
+
...created,
|
|
179
|
+
auth: options.auth,
|
|
180
|
+
setup: options.auth === "workos"
|
|
181
|
+
? {
|
|
182
|
+
applied: createdFieldTest.length > 0 && createdFieldTest.every((step) => step.ok),
|
|
183
|
+
steps: createdFieldTest,
|
|
184
|
+
}
|
|
185
|
+
: {
|
|
186
|
+
applied: false,
|
|
187
|
+
steps: [],
|
|
188
|
+
note: "auth=none creates a plain app; pass --auth workos for WorkOS/AuthKit/auth.md field-test setup.",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
nextActions: [
|
|
192
|
+
`cd ${created.targetDir}`,
|
|
193
|
+
`${options.packageManager} run forge -- agent onboard --target codex --json`,
|
|
194
|
+
`${options.packageManager} run forge -- generate`,
|
|
195
|
+
`${options.packageManager} run forge -- check --json`,
|
|
196
|
+
...(options.auth === "workos"
|
|
197
|
+
? [
|
|
198
|
+
`${options.packageManager} run forge -- authmd check --json`,
|
|
199
|
+
`${options.packageManager} run forge -- workos doctor --json`,
|
|
200
|
+
`${options.packageManager} run forge -- workos seed --file workos-seed.yml --dry-run --json`,
|
|
201
|
+
`${options.packageManager} run forge -- workos setup --file workos-seed.yml --json`,
|
|
202
|
+
]
|
|
203
|
+
: []),
|
|
204
|
+
`${options.packageManager} run forge -- dev --once --json`,
|
|
205
|
+
`${options.packageManager} run forge -- verify --smoke --json`,
|
|
206
|
+
`${options.packageManager} run forge -- handoff --json`,
|
|
207
|
+
],
|
|
208
|
+
exitCode: created.exitCode,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function runHarness(options: FieldTestCommandOptions): FieldTestCommandResult {
|
|
213
|
+
const script = scriptPath(options.workspaceRoot);
|
|
214
|
+
if (!existsSync(script)) {
|
|
215
|
+
return {
|
|
216
|
+
schemaVersion: "0.1.0",
|
|
217
|
+
ok: false,
|
|
218
|
+
kind: "field-test",
|
|
219
|
+
action: "run",
|
|
220
|
+
data: { error: "field-test harness script not found", script },
|
|
221
|
+
nextActions: ["run from the ForgeOS framework checkout or use npm run field:test"],
|
|
222
|
+
exitCode: 1,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const reportPath = options.writeReport ?? (options.dryRun ? undefined : defaultReportPath());
|
|
226
|
+
const templates = options.templates?.length ? options.templates : [options.template];
|
|
227
|
+
const packageManagers = options.packageManagers?.length ? options.packageManagers : [options.packageManager];
|
|
228
|
+
const args = [
|
|
229
|
+
script,
|
|
230
|
+
"--templates",
|
|
231
|
+
templates.join(","),
|
|
232
|
+
"--package-managers",
|
|
233
|
+
packageManagers.join(","),
|
|
234
|
+
"--timeout-ms",
|
|
235
|
+
String(options.timeoutMs),
|
|
236
|
+
];
|
|
237
|
+
if (options.dryRun) args.push("--dry-run");
|
|
238
|
+
if (options.keep) args.push("--keep");
|
|
239
|
+
if (options.runtimeProbes) args.push("--runtime-probes");
|
|
240
|
+
if (options.authProbes) args.push("--auth-probes");
|
|
241
|
+
if (options.forgeSpec) args.push("--forge-spec", options.forgeSpec);
|
|
242
|
+
if (reportPath) args.push("--write-report", reportPath);
|
|
243
|
+
if (options.json) args.push("--json");
|
|
244
|
+
const result = spawnSync(process.execPath, args, {
|
|
245
|
+
cwd: options.workspaceRoot,
|
|
246
|
+
encoding: "utf8",
|
|
247
|
+
windowsHide: true,
|
|
248
|
+
});
|
|
249
|
+
const reportAbsolute = reportPath ? join(options.workspaceRoot, reportPath) : null;
|
|
250
|
+
const reportData = reportAbsolute && existsSync(reportAbsolute)
|
|
251
|
+
? JSON.parse(readFileSync(reportAbsolute, "utf8")) as unknown
|
|
252
|
+
: parseJsonOutput(result.stdout ?? "");
|
|
253
|
+
return normalizeForgeCliCommandsInValue(options.workspaceRoot, {
|
|
254
|
+
schemaVersion: "0.1.0",
|
|
255
|
+
ok: result.status === 0,
|
|
256
|
+
kind: "field-test",
|
|
257
|
+
action: "run",
|
|
258
|
+
command: [process.execPath, ...args],
|
|
259
|
+
reportPath,
|
|
260
|
+
data: reportData ?? undefined,
|
|
261
|
+
summary: reportData ? summarizeReport(reportData) : undefined,
|
|
262
|
+
stdout: compact(result.stdout ?? ""),
|
|
263
|
+
stderr: compact(result.stderr ?? ""),
|
|
264
|
+
nextActions: result.status === 0
|
|
265
|
+
? options.dryRun
|
|
266
|
+
? [runCommandForOptions(templates, packageManagers)]
|
|
267
|
+
: [`forge field-test report --file ${reportPath ?? defaultReportPath()} --json`, "forge deploy check --production --json"]
|
|
268
|
+
: ["inspect field-test stdout/stderr", "forge doctor pglite --json"],
|
|
269
|
+
exitCode: result.status === 0 ? 0 : 1,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function readReport(options: FieldTestCommandOptions): FieldTestCommandResult {
|
|
274
|
+
const candidates = [
|
|
275
|
+
options.writeReport,
|
|
276
|
+
".forge/field-test-report.json",
|
|
277
|
+
"field-reports/full-alpha.json",
|
|
278
|
+
].filter(Boolean) as string[];
|
|
279
|
+
const report = candidates.find((candidate) => existsSync(join(options.workspaceRoot, candidate)));
|
|
280
|
+
if (!report) {
|
|
281
|
+
return {
|
|
282
|
+
schemaVersion: "0.1.0",
|
|
283
|
+
ok: false,
|
|
284
|
+
kind: "field-test",
|
|
285
|
+
action: "report",
|
|
286
|
+
data: { searched: candidates },
|
|
287
|
+
nextActions: ["forge field-test run --runtime-probes --auth-probes --write-report .forge/field-test-report.json --json"],
|
|
288
|
+
exitCode: 1,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const data = JSON.parse(readFileSync(join(options.workspaceRoot, report), "utf8")) as unknown;
|
|
292
|
+
const summary = summarizeReport(data);
|
|
293
|
+
const productionEvidence = (summary as { productionEvidence?: { readyForDeployCheck?: boolean } }).productionEvidence;
|
|
294
|
+
return {
|
|
295
|
+
schemaVersion: "0.1.0",
|
|
296
|
+
ok: (data && typeof data === "object" && "ok" in data) ? (data as { ok?: unknown }).ok === true : true,
|
|
297
|
+
kind: "field-test",
|
|
298
|
+
action: "report",
|
|
299
|
+
reportPath: report,
|
|
300
|
+
summary,
|
|
301
|
+
data,
|
|
302
|
+
nextActions: productionEvidence?.readyForDeployCheck
|
|
303
|
+
? ["forge deploy check --production --json"]
|
|
304
|
+
: ["forge field-test run --runtime-probes --auth-probes --write-report .forge/field-test-report.json --json"],
|
|
305
|
+
exitCode: (data && typeof data === "object" && "ok" in data && (data as { ok?: unknown }).ok !== true) ? 1 : 0,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export async function runFieldTestCommand(options: FieldTestCommandOptions): Promise<FieldTestCommandResult> {
|
|
310
|
+
if (options.subcommand === "create") return createFieldTestApp(options);
|
|
311
|
+
if (options.subcommand === "run") return runHarness(options);
|
|
312
|
+
return readReport(options);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export function formatFieldTestJson(result: FieldTestCommandResult): string {
|
|
316
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export function formatFieldTestHuman(result: FieldTestCommandResult): string {
|
|
320
|
+
const lines = [
|
|
321
|
+
`field-test ${result.action} ${result.ok ? "ok" : "failed"}`,
|
|
322
|
+
...(result.reportPath ? [`report: ${result.reportPath}`] : []),
|
|
323
|
+
...(result.command ? [`command: ${result.command.join(" ")}`] : []),
|
|
324
|
+
...(result.stdout ? ["", result.stdout] : []),
|
|
325
|
+
...(result.stderr ? ["", result.stderr] : []),
|
|
326
|
+
...(result.nextActions.length ? ["", "Next:", ...result.nextActions.map((action) => ` ${action}`)] : []),
|
|
327
|
+
];
|
|
328
|
+
return `${lines.join("\n")}\n`;
|
|
329
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { nodeFileSystem } from "../compiler/fs/index.ts";
|
|
3
|
+
import type { Diagnostic } from "../compiler/types/diagnostic.ts";
|
|
4
|
+
import { runDevConsoleCycle } from "../dev-console/cycle.ts";
|
|
5
|
+
import type { DevConsoleCycle, DevConsolePhase } from "../dev-console/types.ts";
|
|
6
|
+
import type { TestRunRecord } from "../impact/types.ts";
|
|
7
|
+
import type { UiRunReport } from "../ui/types.ts";
|
|
8
|
+
import { summarizeChangeTypes, type CategorizedFileSummary } from "../workspace/change-summary.ts";
|
|
9
|
+
import { forgeCliCommandsForWorkspace } from "../workspace/forge-cli.ts";
|
|
10
|
+
import { buildWorkspaceGitSummary } from "../workspace/git-summary.ts";
|
|
11
|
+
import { runChangedCommand } from "./changed.ts";
|
|
12
|
+
|
|
13
|
+
export interface HandoffCommandOptions {
|
|
14
|
+
workspaceRoot: string;
|
|
15
|
+
json: boolean;
|
|
16
|
+
commitReady?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface HandoffCommandResult {
|
|
20
|
+
schemaVersion: "0.1.0";
|
|
21
|
+
ok: boolean;
|
|
22
|
+
summary: {
|
|
23
|
+
projectRoot: string;
|
|
24
|
+
safeToEdit: boolean;
|
|
25
|
+
generatedFresh: boolean;
|
|
26
|
+
generatedChanged: boolean;
|
|
27
|
+
generatedChangedFiles: number;
|
|
28
|
+
frontendReady: boolean;
|
|
29
|
+
changedFiles: number;
|
|
30
|
+
commitReadyFiles: number;
|
|
31
|
+
stagedFiles: number;
|
|
32
|
+
unstagedFiles: number;
|
|
33
|
+
untrackedFiles: number;
|
|
34
|
+
lastTestRun: "passed" | "failed" | "missing";
|
|
35
|
+
lastUiRun: "passed" | "failed" | "missing";
|
|
36
|
+
workspaceMode: "git" | "nonGit";
|
|
37
|
+
tracking: string;
|
|
38
|
+
};
|
|
39
|
+
dev: {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
primaryAction?: DevConsoleCycle["summary"]["primaryAction"];
|
|
42
|
+
agentContext: DevConsoleCycle["summary"]["agentContext"];
|
|
43
|
+
phases: Array<Pick<DevConsolePhase, "name" | "status" | "message">>;
|
|
44
|
+
};
|
|
45
|
+
git: {
|
|
46
|
+
available: boolean;
|
|
47
|
+
branch?: string;
|
|
48
|
+
commit?: string;
|
|
49
|
+
changed: {
|
|
50
|
+
count: number;
|
|
51
|
+
sample: string[];
|
|
52
|
+
hidden: number;
|
|
53
|
+
};
|
|
54
|
+
staged: {
|
|
55
|
+
count: number;
|
|
56
|
+
sample: string[];
|
|
57
|
+
hidden: number;
|
|
58
|
+
};
|
|
59
|
+
unstaged: {
|
|
60
|
+
count: number;
|
|
61
|
+
sample: string[];
|
|
62
|
+
hidden: number;
|
|
63
|
+
};
|
|
64
|
+
untracked: {
|
|
65
|
+
count: number;
|
|
66
|
+
sample: string[];
|
|
67
|
+
hidden: number;
|
|
68
|
+
};
|
|
69
|
+
changeSummary: {
|
|
70
|
+
changed: CategorizedFileSummary;
|
|
71
|
+
staged: CategorizedFileSummary;
|
|
72
|
+
unstaged: CategorizedFileSummary;
|
|
73
|
+
untracked: CategorizedFileSummary;
|
|
74
|
+
};
|
|
75
|
+
workspaceMode?: string;
|
|
76
|
+
tracking?: string;
|
|
77
|
+
baseline?: unknown;
|
|
78
|
+
error?: string;
|
|
79
|
+
};
|
|
80
|
+
recentRuns: {
|
|
81
|
+
test?: {
|
|
82
|
+
id?: string;
|
|
83
|
+
ok: boolean;
|
|
84
|
+
failed: string[];
|
|
85
|
+
durationMs?: number;
|
|
86
|
+
};
|
|
87
|
+
ui?: {
|
|
88
|
+
id?: string;
|
|
89
|
+
ok: boolean;
|
|
90
|
+
failedScenarios: string[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
nextAgent: {
|
|
94
|
+
openingBrief: string;
|
|
95
|
+
recommendedReadFiles: string[];
|
|
96
|
+
recommendedCommands: string[];
|
|
97
|
+
risks: string[];
|
|
98
|
+
};
|
|
99
|
+
commitReady?: {
|
|
100
|
+
count: number;
|
|
101
|
+
files: string[];
|
|
102
|
+
};
|
|
103
|
+
diagnosticSummary: {
|
|
104
|
+
total: number;
|
|
105
|
+
sample: Diagnostic[];
|
|
106
|
+
hidden: number;
|
|
107
|
+
bySeverity: Record<string, number>;
|
|
108
|
+
byCode: Record<string, number>;
|
|
109
|
+
fullDiagnosticsCommands: string[];
|
|
110
|
+
};
|
|
111
|
+
diagnostics: Diagnostic[];
|
|
112
|
+
nextActions: string[];
|
|
113
|
+
exitCode: 0 | 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function readJson<T>(workspaceRoot: string, relativePath: string): T | null {
|
|
117
|
+
const absolute = join(workspaceRoot, relativePath);
|
|
118
|
+
if (!nodeFileSystem.exists(absolute)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return JSON.parse(nodeFileSystem.readText(absolute) ?? "null") as T;
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function summarizeRecentRuns(workspaceRoot: string): HandoffCommandResult["recentRuns"] {
|
|
129
|
+
const test = readJson<TestRunRecord>(workspaceRoot, ".forge/test-runs/last.json");
|
|
130
|
+
const ui = readJson<UiRunReport>(workspaceRoot, ".forge/ui-runs/last.json");
|
|
131
|
+
const failedScenarios = (ui?.scenarios ?? [])
|
|
132
|
+
.filter((scenario) => !scenario.ok)
|
|
133
|
+
.map((scenario) => scenario.name);
|
|
134
|
+
return {
|
|
135
|
+
...(test
|
|
136
|
+
? {
|
|
137
|
+
test: {
|
|
138
|
+
id: test.id,
|
|
139
|
+
ok: test.failed.length === 0,
|
|
140
|
+
failed: test.failed,
|
|
141
|
+
durationMs: test.durationMs,
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
: {}),
|
|
145
|
+
...(ui
|
|
146
|
+
? {
|
|
147
|
+
ui: {
|
|
148
|
+
id: ui.id,
|
|
149
|
+
ok: failedScenarios.length === 0 && ui.diagnostics.every((diagnostic) => diagnostic.severity !== "error"),
|
|
150
|
+
failedScenarios,
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
: {}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function buildOpeningBrief(input: {
|
|
158
|
+
dev: DevConsoleCycle;
|
|
159
|
+
git: HandoffCommandResult["git"];
|
|
160
|
+
recentRuns: HandoffCommandResult["recentRuns"];
|
|
161
|
+
commitReady?: HandoffCommandResult["commitReady"];
|
|
162
|
+
}): string {
|
|
163
|
+
const agent = input.dev.summary.agentContext;
|
|
164
|
+
const changedByType = summarizeChangeTypes(input.git.changeSummary.changed);
|
|
165
|
+
const changedFiles = Math.max(agent.changedFiles, input.git.changed.count);
|
|
166
|
+
const commitReadyNote = input.commitReady && input.commitReady.count !== changedFiles
|
|
167
|
+
? `; ${input.commitReady.count} commit-ready file(s) after excluding generated/operational artifacts`
|
|
168
|
+
: "";
|
|
169
|
+
const tests = input.recentRuns.test
|
|
170
|
+
? input.recentRuns.test.ok
|
|
171
|
+
? "last test run passed"
|
|
172
|
+
: "last test run failed"
|
|
173
|
+
: "no last test run";
|
|
174
|
+
const blockers = agent.blockingIssues.length > 0
|
|
175
|
+
? `${agent.blockingIssues.length} blocking issue(s)`
|
|
176
|
+
: "no blocking issues";
|
|
177
|
+
return [
|
|
178
|
+
`ForgeOS handoff: ${input.dev.ok ? "dev diagnostics are clean" : "dev diagnostics need attention"}.`,
|
|
179
|
+
`${changedFiles} changed file(s)${changedByType ? `: ${changedByType}` : ""}${commitReadyNote}; ${input.git.staged.count} staged, ${input.git.untracked.count} untracked.`,
|
|
180
|
+
`${tests}; ${blockers}.`,
|
|
181
|
+
`Next command: ${input.dev.summary.primaryAction?.command ?? input.dev.nextActions[0]?.command ?? "forge dev"}.`,
|
|
182
|
+
].join(" ");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function compactDiagnostics(
|
|
186
|
+
workspaceRoot: string,
|
|
187
|
+
diagnostics: Diagnostic[],
|
|
188
|
+
sampleSize = 8,
|
|
189
|
+
): HandoffCommandResult["diagnosticSummary"] {
|
|
190
|
+
const bySeverity: Record<string, number> = {};
|
|
191
|
+
const byCode: Record<string, number> = {};
|
|
192
|
+
for (const diagnostic of diagnostics) {
|
|
193
|
+
bySeverity[diagnostic.severity] = (bySeverity[diagnostic.severity] ?? 0) + 1;
|
|
194
|
+
byCode[diagnostic.code] = (byCode[diagnostic.code] ?? 0) + 1;
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
total: diagnostics.length,
|
|
198
|
+
sample: diagnostics.slice(0, sampleSize),
|
|
199
|
+
hidden: Math.max(0, diagnostics.length - sampleSize),
|
|
200
|
+
bySeverity,
|
|
201
|
+
byCode,
|
|
202
|
+
fullDiagnosticsCommands: forgeCliCommandsForWorkspace(workspaceRoot, [
|
|
203
|
+
"forge dev --once --json",
|
|
204
|
+
"forge inspect all --full --json",
|
|
205
|
+
"forge generate --check --json",
|
|
206
|
+
]),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function runHandoffCommand(options: HandoffCommandOptions): Promise<HandoffCommandResult> {
|
|
211
|
+
const workspaceRoot = options.workspaceRoot.replace(/\\/g, "/");
|
|
212
|
+
const dev = await runDevConsoleCycle({
|
|
213
|
+
workspaceRoot,
|
|
214
|
+
mode: "once",
|
|
215
|
+
generatedMode: "check",
|
|
216
|
+
includeImpact: true,
|
|
217
|
+
});
|
|
218
|
+
const git = buildWorkspaceGitSummary(workspaceRoot);
|
|
219
|
+
const commitReady = runChangedCommand(workspaceRoot, { commitReady: true }).data.commitReady as { count: number; files: string[] } | undefined;
|
|
220
|
+
const recentRuns = summarizeRecentRuns(workspaceRoot);
|
|
221
|
+
const agent = dev.summary.agentContext;
|
|
222
|
+
const risks = [
|
|
223
|
+
...agent.blockingIssues,
|
|
224
|
+
...(!git.available && git.source === "forge-baseline"
|
|
225
|
+
? ["git status is unavailable; using Forge workspace baseline for non-git change tracking"]
|
|
226
|
+
: !git.available
|
|
227
|
+
? ["git status is unavailable; using filesystem inventory as untracked-file analysis"]
|
|
228
|
+
: []),
|
|
229
|
+
...(git.untracked.count > 0 && git.source !== "forge-baseline" ? [`${git.untracked.count} untracked file(s) are not in git history`] : []),
|
|
230
|
+
...(commitReady && git.changed.count > commitReady.count
|
|
231
|
+
? [`${git.changed.count - commitReady.count} generated or operational file(s) are excluded from the commit-ready view`]
|
|
232
|
+
: []),
|
|
233
|
+
...(recentRuns.test && !recentRuns.test.ok ? ["last test run failed"] : []),
|
|
234
|
+
...(recentRuns.ui && !recentRuns.ui.ok ? ["last UI run failed"] : []),
|
|
235
|
+
];
|
|
236
|
+
const nextActions = [
|
|
237
|
+
...agent.recommendedCommands,
|
|
238
|
+
...forgeCliCommandsForWorkspace(workspaceRoot, [
|
|
239
|
+
...(git.changed.count > 0 ? ["forge review run --changed --json"] : []),
|
|
240
|
+
...(git.changed.count > 0 ? ["forge changed --commit-ready --json"] : []),
|
|
241
|
+
"forge handoff --json",
|
|
242
|
+
]),
|
|
243
|
+
];
|
|
244
|
+
const ok = dev.ok &&
|
|
245
|
+
agent.blockingIssues.length === 0 &&
|
|
246
|
+
(!recentRuns.test || recentRuns.test.ok) &&
|
|
247
|
+
(!recentRuns.ui || recentRuns.ui.ok);
|
|
248
|
+
const changedFiles = Math.max(agent.changedFiles, git.changed.count);
|
|
249
|
+
const diagnosticSummary = compactDiagnostics(workspaceRoot, dev.diagnostics);
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
schemaVersion: "0.1.0",
|
|
253
|
+
ok,
|
|
254
|
+
summary: {
|
|
255
|
+
projectRoot: workspaceRoot,
|
|
256
|
+
safeToEdit: agent.safeToEdit,
|
|
257
|
+
generatedFresh: agent.generatedFresh,
|
|
258
|
+
generatedChanged: agent.generatedChanged,
|
|
259
|
+
generatedChangedFiles: agent.generatedChangedFiles,
|
|
260
|
+
frontendReady: agent.frontendReady,
|
|
261
|
+
changedFiles,
|
|
262
|
+
commitReadyFiles: commitReady?.count ?? changedFiles,
|
|
263
|
+
stagedFiles: git.staged.count,
|
|
264
|
+
unstagedFiles: git.unstaged.count,
|
|
265
|
+
untrackedFiles: git.untracked.count,
|
|
266
|
+
lastTestRun: recentRuns.test ? (recentRuns.test.ok ? "passed" : "failed") : "missing",
|
|
267
|
+
lastUiRun: recentRuns.ui ? (recentRuns.ui.ok ? "passed" : "failed") : "missing",
|
|
268
|
+
workspaceMode: git.workspaceMode ?? (git.available ? "git" : "nonGit"),
|
|
269
|
+
tracking: git.tracking ?? git.source ?? "git",
|
|
270
|
+
},
|
|
271
|
+
dev: {
|
|
272
|
+
ok: dev.ok,
|
|
273
|
+
...(dev.summary.primaryAction ? { primaryAction: dev.summary.primaryAction } : {}),
|
|
274
|
+
agentContext: agent,
|
|
275
|
+
phases: dev.phases.map((phase) => ({
|
|
276
|
+
name: phase.name,
|
|
277
|
+
status: phase.status,
|
|
278
|
+
...(phase.message ? { message: phase.message } : {}),
|
|
279
|
+
})),
|
|
280
|
+
},
|
|
281
|
+
git,
|
|
282
|
+
recentRuns,
|
|
283
|
+
nextAgent: {
|
|
284
|
+
openingBrief: buildOpeningBrief({ dev, git, recentRuns, commitReady }),
|
|
285
|
+
recommendedReadFiles: agent.recommendedReadFiles,
|
|
286
|
+
recommendedCommands: [...new Set(nextActions)].slice(0, 10),
|
|
287
|
+
risks,
|
|
288
|
+
},
|
|
289
|
+
...(commitReady ? { commitReady } : {}),
|
|
290
|
+
diagnosticSummary,
|
|
291
|
+
diagnostics: diagnosticSummary.sample,
|
|
292
|
+
nextActions: [...new Set(nextActions)].slice(0, 10),
|
|
293
|
+
exitCode: ok ? 0 : 1,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function formatHandoffJson(result: HandoffCommandResult): string {
|
|
298
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export function formatHandoffHuman(result: HandoffCommandResult): string {
|
|
302
|
+
const lines = [
|
|
303
|
+
`Forge handoff: ${result.ok ? "ready" : "needs attention"}`,
|
|
304
|
+
result.nextAgent.openingBrief,
|
|
305
|
+
"",
|
|
306
|
+
"Read first:",
|
|
307
|
+
...result.nextAgent.recommendedReadFiles.slice(0, 6).map((file) => ` ${file}`),
|
|
308
|
+
"",
|
|
309
|
+
"Next commands:",
|
|
310
|
+
...result.nextActions.slice(0, 6).map((command) => ` ${command}`),
|
|
311
|
+
];
|
|
312
|
+
if (result.nextAgent.risks.length > 0) {
|
|
313
|
+
lines.push("", "Risks:");
|
|
314
|
+
lines.push(...result.nextAgent.risks.slice(0, 6).map((risk) => ` ${risk}`));
|
|
315
|
+
}
|
|
316
|
+
if (result.diagnosticSummary.total > 0) {
|
|
317
|
+
lines.push(
|
|
318
|
+
"",
|
|
319
|
+
"Diagnostics:",
|
|
320
|
+
` ${result.diagnosticSummary.total} total` +
|
|
321
|
+
(result.diagnosticSummary.hidden > 0 ? ` (${result.diagnosticSummary.hidden} hidden in compact handoff)` : ""),
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
if (result.commitReady) {
|
|
325
|
+
lines.push("", "Commit-ready files:", ` ${result.commitReady.count}`);
|
|
326
|
+
lines.push(...result.commitReady.files.slice(0, 8).map((file) => ` ${file}`));
|
|
327
|
+
if (result.commitReady.files.length > 8) {
|
|
328
|
+
lines.push(` ... ${result.commitReady.files.length - 8} more`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const changedTypes = summarizeChangeTypes(result.git.changeSummary.changed);
|
|
332
|
+
if (changedTypes) {
|
|
333
|
+
lines.push("", "Change types:", ` ${changedTypes}`);
|
|
334
|
+
}
|
|
335
|
+
return `${lines.join("\n")}\n`;
|
|
336
|
+
}
|
package/src/forge/cli/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { CLI_VERSION } from "./version.ts";
|
|
|
2
2
|
export { parseCli, hasUnknownOption, type ParsedCli, type ForgeCommand } from "./parse.ts";
|
|
3
3
|
export { runNewCommand, type NewCommandOptions, type NewCommandResult } from "./new.ts";
|
|
4
4
|
export { runSelfHostCommand, type SelfHostCommandOptions } from "./self-host.ts";
|
|
5
|
+
export { runDocsCheckCommand, type DocsCheckResult } from "./docs.ts";
|
|
5
6
|
export { runBuildCommand, type BuildCommandOptions } from "./build.ts";
|
|
6
7
|
export { runServeCommand, type ServeCommandOptions } from "./serve.ts";
|
|
7
8
|
export { runWorkerCommand, type WorkerCommandOptions } from "./worker.ts";
|