@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f07274d438b
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/README.md +183 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
- package/dist/bridge/bridge-chat-provider-command.js +230 -0
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +15 -0
- package/dist/bridge/bridge-state-io.js +68 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +102 -14
- package/dist/bridge/bridge.service.js +499 -471
- package/dist/bridge/bridge.types.d.ts +37 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +31 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +11 -0
- package/dist/cleanup/forge-owned-paths.js +62 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +75 -13
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +161 -228
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +18 -1
- package/dist/cli/local-config.js +67 -5
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +72 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +40 -0
- package/dist/runtime/host-load-child-environment.js +110 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +82 -0
- package/dist/runtime/host-load-governor-config.js +104 -0
- package/dist/runtime/host-load-governor.d.ts +273 -0
- package/dist/runtime/host-load-governor.js +831 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +92 -2
- package/dist/runtime/host-load-sampler.js +166 -8
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +107 -0
- package/dist/runtime/host-load-step-run.js +158 -0
- package/dist/runtime/host-load-test-slot.d.ts +46 -0
- package/dist/runtime/host-load-test-slot.js +100 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +39 -6
- package/dist/runtime/host-runtime-lease.d.ts +101 -6
- package/dist/runtime/host-runtime-lease.js +408 -294
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +101 -2
- package/dist/runtime/host-runtime-promotion.js +355 -14
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +11 -3
- package/dist/sandbox/runtime.js +53 -20
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +204 -141
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +52 -0
- package/dist/session/managed-command-host-load.js +87 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +9 -17
- package/dist/session/phase-completion.artifacts.js +158 -190
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +31 -2
- package/dist/session/phase-completion.helpers.js +18 -65
- package/dist/session/phase-completion.js +19 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +20 -1
- package/dist/session/phase-completion.runtime.d.ts +13 -12
- package/dist/session/phase-completion.runtime.js +113 -214
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +219 -232
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +58 -94
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +112 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +32 -19
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +39 -22
- package/dist/session/pre-publication-validation.js +241 -207
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +281 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +41 -432
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
- package/dist/session/provider-cli/provider-cli.service.js +127 -317
- package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +279 -0
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +16 -2
- package/dist/session/session.service.js +208 -155
- package/dist/session/session.types.d.ts +8 -0
- package/dist/session/session.types.js +13 -83
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +23 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +58 -5
- package/dist/worktree/worktree.service.js +237 -161
- package/dist/worktree/worktree.types.d.ts +54 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { RepositoryCoordinatorLock } from "../../sandbox/repository-lock.js";
|
|
4
3
|
import { GitClient } from "../../shared/git/git.js";
|
|
4
|
+
import { sandboxHostLoadGateFromEnvironment } from "../sandbox-host-capacity-gate.js";
|
|
5
5
|
import { buildSpecBody, selectLaneCommand } from "../../worktree/artifact-injector.js";
|
|
6
|
-
import { defaultWorktreeCoordinatorStateRoot } from "../../worktree/worktree-paths.js";
|
|
7
6
|
import { completionPhaseFromDispatch, prepareCompletionToolRuntime, readCompletionArtifact, usesDebugCycleCompletion, usesDevelopCycleCompletion } from "../phase-completion.js";
|
|
8
7
|
import { ForgeFailureError } from "../session.types.js";
|
|
9
8
|
import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtifact, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitDecomposeGateArtifacts, emitDraftGateArtifacts, emitPhaseCompletionEvent, emitPhaseGateEvents, emitQaArtifactRecorded, emitQaStructuredEvents, enforceQaBrowserLaunchTargetGate, LiveArchitectArtifactEmitter, LiveCompletionArtifactEmitter, LiveQaArtifactEmitter, readCompletionArtifactsForRun, readQaCompletionArtifactBundle, waitForCompletionArtifact } from "./provider-cli.artifacts.js";
|
|
10
9
|
import { diffClaimedChangedFiles, findUnpublishedWorktreePaths, normalizeChangedFilePath, stagePublishableWorktreeChangeSet, } from "../publishable-worktree-changes.js";
|
|
11
10
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
12
|
-
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { buildArchitectPrompt, buildConflictResolvePrompt, withReapplyConflictInstruction, withRemainingReapplyConflictInstruction, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch, shouldPipePromptToStdin, usesManagedWindowsHost } from "./provider-cli.prompts.js";
|
|
12
|
+
import { providerCompletionToolMissingFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
13
|
+
import { admitUserConfigIsolatedProvider, emitProviderUsageEvent, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
14
|
+
import { defaultPublicationCoordinator, ProviderToolActivityHeartbeat, providerCliExitFailure, } from "./provider-cli.service-support.js";
|
|
15
|
+
import { runPrReviewSession } from "./provider-cli.pr-review.js";
|
|
15
16
|
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
16
17
|
import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
|
|
17
18
|
import { assertRepairHeadEpoch } from "./provider-cli.repair-epoch.js";
|
|
18
|
-
import {
|
|
19
|
-
|
|
19
|
+
import { PrePublicationValidator } from "../pre-publication-validation.js";
|
|
20
|
+
import { prePublicationRepairTurnsFromEnvironment, prepareRepairTurnLaunch, validatePrePublicationWithRepair, } from "./pre-publication-repair.js";
|
|
20
21
|
const maxQaCompletionRecoveryTurns = 2;
|
|
21
22
|
function assertCommentRepairArtifactMatchesDispatch(dispatch, artifact) {
|
|
22
23
|
const pullRequest = dispatch.pullRequest;
|
|
@@ -159,6 +160,7 @@ export { parseClaudeMcpToolName } from "./provider-output-state.js";
|
|
|
159
160
|
export { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
160
161
|
export { buildProviderCliCommand, codexSandboxModeForPlatform, formatProviderCliCommand, formatProviderCliCommandForCheckpoint } from "./provider-cli.prompts.js";
|
|
161
162
|
export { buildProviderChildEnvironment, chooseWindowsCommandCandidate, resolveCodexNpmDirectLaunch, resolveClaudeNpmDirectLaunch, resolvePackageManagerDirectLaunch, resolveWindowsCommandFromPath, PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS, CodexModelsCacheRecoveringProcessRunner, CodexResumeRecoveringProcessRunner, isTransientCodexProviderNotFoundFailure, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
163
|
+
export { isProviderCapacityFailure, isProviderConfigurationFailure, isProviderContextWindowExhausted } from "./provider-cli.service-support.js";
|
|
162
164
|
export { buildWindowsLaunchCommand } from "../../shared/process/windows-launch.js";
|
|
163
165
|
async function pushWorktreeBranch(git, worktreePath, branchName, repoPath, coordinator, signal, emit, expectedRemoteHeadSha) {
|
|
164
166
|
return await coordinator.withLock(repoPath, async () => {
|
|
@@ -212,18 +214,6 @@ async function pushWorktreeBranch(git, worktreePath, branchName, repoPath, coord
|
|
|
212
214
|
function providerOwnsBranchPublication(context) {
|
|
213
215
|
return context.dispatch.sandbox?.executionMode !== "docker";
|
|
214
216
|
}
|
|
215
|
-
function prePublicationExecution(context, environment, defaultRunner, baselineRevision) {
|
|
216
|
-
if (context.processRunner)
|
|
217
|
-
return { baselineRevision, environment, processRunner: context.processRunner };
|
|
218
|
-
if (context.dispatch.sandbox?.executionMode !== "docker")
|
|
219
|
-
return { baselineRevision, environment };
|
|
220
|
-
const expectedSandboxId = context.dispatch.sandbox.dispatchAttemptId;
|
|
221
|
-
const observedSandboxId = context.runtimeEnvironment?.FORGE_SANDBOX_ID ?? process.env.FORGE_SANDBOX_ID;
|
|
222
|
-
if (observedSandboxId !== expectedSandboxId) {
|
|
223
|
-
throw new ForgeFailureError("prepublication_execution_scope_invalid", `prepublication_execution_scope_invalid: Docker attempt ${expectedSandboxId} has no runner proven to execute inside that sandbox.`, "bridge");
|
|
224
|
-
}
|
|
225
|
-
return { baselineRevision, environment, processRunner: defaultRunner };
|
|
226
|
-
}
|
|
227
217
|
function remoteTrackingRefspec(branchName) {
|
|
228
218
|
return `refs/heads/${branchName}:refs/remotes/origin/${branchName}`;
|
|
229
219
|
}
|
|
@@ -238,93 +228,6 @@ function isNonFastForwardPushError(err) {
|
|
|
238
228
|
function errorMessage(err) {
|
|
239
229
|
return err instanceof Error ? err.message : String(err);
|
|
240
230
|
}
|
|
241
|
-
function providerCliExitFailure(command, result) {
|
|
242
|
-
const output = [result.stderr.trim(), result.stdout.trim()]
|
|
243
|
-
.filter(value => value.length > 0)
|
|
244
|
-
.join("\n");
|
|
245
|
-
const detail = clipTail(output, 1200);
|
|
246
|
-
const suffix = detail ? `: ${detail}` : "";
|
|
247
|
-
if (isProviderConfigurationFailure(command, result)) {
|
|
248
|
-
return new ForgeFailureError("provider_configuration_invalid", `${command} rejected its model configuration; correct the configuration before retrying${suffix}`, "provider");
|
|
249
|
-
}
|
|
250
|
-
if (isTransientCodexProviderNotFoundFailure(command, result)) {
|
|
251
|
-
return new ForgeFailureError("provider_request_not_found", `${command} received a transient not-found response from its provider service${suffix}`, "provider");
|
|
252
|
-
}
|
|
253
|
-
if (isProviderCapacityFailure(result)) {
|
|
254
|
-
return new ForgeFailureError("provider_capacity_unavailable", `${command} was deferred because the selected provider model is temporarily at capacity${suffix}`, "provider");
|
|
255
|
-
}
|
|
256
|
-
if (isProviderContextWindowExhausted(command, result)) {
|
|
257
|
-
return new ForgeFailureError("provider_context_window_exhausted", `${command} exhausted the provider context window and must continue in a fresh session${suffix}`, "provider");
|
|
258
|
-
}
|
|
259
|
-
return new Error(`${command} exited ${result.exitCode}${suffix}`);
|
|
260
|
-
}
|
|
261
|
-
function clipTail(value, maximumLength) {
|
|
262
|
-
if (value.length <= maximumLength)
|
|
263
|
-
return value;
|
|
264
|
-
return `...${value.slice(-(maximumLength - 3))}`;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Capacity is trusted only when a nonzero provider process writes one of the
|
|
268
|
-
* narrow service-level messages to stderr. Stdout can contain arbitrary agent
|
|
269
|
-
* command output and account usage-limit messages remain ordinary failures.
|
|
270
|
-
*/
|
|
271
|
-
export function isProviderCapacityFailure(result) {
|
|
272
|
-
if (result.exitCode === 0)
|
|
273
|
-
return false;
|
|
274
|
-
const capacityMessages = new Set([
|
|
275
|
-
"the selected model is at capacity. please try again later.",
|
|
276
|
-
"the selected model is currently at capacity. please try again later.",
|
|
277
|
-
"the model is currently overloaded. please try again later.",
|
|
278
|
-
"the provider is currently overloaded. please try again later.",
|
|
279
|
-
]);
|
|
280
|
-
return result.stderr
|
|
281
|
-
.split(/\r?\n/u)
|
|
282
|
-
.map(line => line.trim().toLowerCase().replace(/^error:\s*/u, ""))
|
|
283
|
-
.some(line => capacityMessages.has(line));
|
|
284
|
-
}
|
|
285
|
-
/** Only a nonzero Codex service diagnostic can classify a configuration rejection.
|
|
286
|
-
* JSONL turn.failed is a provider envelope; item/tool output is not retry authority. */
|
|
287
|
-
export function isProviderConfigurationFailure(command, result) {
|
|
288
|
-
const names = [path.posix.parse(command).name, path.win32.parse(command).name];
|
|
289
|
-
if (result.exitCode === 0 || !names.some(name => name.toLowerCase() === "codex"))
|
|
290
|
-
return false;
|
|
291
|
-
const reasoningRejected = /Unsupported value: '[^'\r\n]+' is not supported with the '[^'\r\n]+' model\./u.test(result.stderr)
|
|
292
|
-
&& result.stderr.includes("reasoning.effort")
|
|
293
|
-
&& result.stderr.includes("invalid_request_error")
|
|
294
|
-
&& result.stderr.includes("unsupported_value");
|
|
295
|
-
if (reasoningRejected)
|
|
296
|
-
return true;
|
|
297
|
-
return [result.stderr, result.stdout].some(output => output.split(/\r?\n/u).some(line => {
|
|
298
|
-
try {
|
|
299
|
-
const event = JSON.parse(line);
|
|
300
|
-
if (event.type !== "turn.failed")
|
|
301
|
-
return false;
|
|
302
|
-
const error = event.error;
|
|
303
|
-
if (typeof error?.message !== "string")
|
|
304
|
-
return false;
|
|
305
|
-
const service = JSON.parse(error.message);
|
|
306
|
-
return service.type === "error" && service.status === 400
|
|
307
|
-
&& service.error?.type === "invalid_request_error"
|
|
308
|
-
&& typeof service.error.message === "string"
|
|
309
|
-
&& /^The '[^'\r\n]+' model is not supported when using Codex with a ChatGPT account\.$/u.test(service.error.message);
|
|
310
|
-
}
|
|
311
|
-
catch {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* A context limit is trusted only at the provider process boundary. The exact
|
|
318
|
-
* Codex message can be embedded in its JSONL stderr envelope, so substring
|
|
319
|
-
* matching is intentional but remains narrow and stderr-only.
|
|
320
|
-
*/
|
|
321
|
-
export function isProviderContextWindowExhausted(command, result) {
|
|
322
|
-
const executableNames = [path.posix.parse(command).name, path.win32.parse(command).name]
|
|
323
|
-
.map(name => name.toLowerCase());
|
|
324
|
-
if (result.exitCode === 0 || !executableNames.includes("codex"))
|
|
325
|
-
return false;
|
|
326
|
-
return result.stderr.toLowerCase().includes("codex ran out of room in the model's context window");
|
|
327
|
-
}
|
|
328
231
|
const defaultProviderToolHeartbeatIntervalMs = 60_000;
|
|
329
232
|
const defaultManagedVerificationProgressIntervalMs = 30_000;
|
|
330
233
|
function compareManagedVerificationSnapshots(left, right) {
|
|
@@ -432,7 +335,8 @@ export class ManagedVerificationProgressEmitter {
|
|
|
432
335
|
}
|
|
433
336
|
}
|
|
434
337
|
function isManagedVerificationNonterminal(status) {
|
|
435
|
-
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
338
|
+
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
339
|
+
|| status === "waiting_for_host_capacity";
|
|
436
340
|
}
|
|
437
341
|
async function parseManagedVerificationSnapshot(receiptPath) {
|
|
438
342
|
try {
|
|
@@ -467,58 +371,6 @@ function formatElapsed(milliseconds) {
|
|
|
467
371
|
const minutes = Math.floor(seconds / 60);
|
|
468
372
|
return minutes > 0 ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
|
|
469
373
|
}
|
|
470
|
-
class ProviderToolActivityHeartbeat {
|
|
471
|
-
outputState;
|
|
472
|
-
emit;
|
|
473
|
-
intervalMs;
|
|
474
|
-
timer = null;
|
|
475
|
-
/** Lets the provider runner hold its end-of-turn timers while a tool call is in flight. */
|
|
476
|
-
isToolCallInFlight = () => this.outputState.hasActiveToolCall;
|
|
477
|
-
/** Forgets tool calls a previous generation left open; called before every relaunch. */
|
|
478
|
-
startGeneration = () => this.outputState.resetActiveToolCalls();
|
|
479
|
-
constructor(outputState, emit, intervalMs) {
|
|
480
|
-
this.outputState = outputState;
|
|
481
|
-
this.emit = emit;
|
|
482
|
-
this.intervalMs = intervalMs;
|
|
483
|
-
// Each heartbeat watches one provider generation. Calls an earlier generation left
|
|
484
|
-
// open died with it; inheriting them would hold the new generation's timers forever.
|
|
485
|
-
this.outputState.resetActiveToolCalls();
|
|
486
|
-
}
|
|
487
|
-
async consume(line) {
|
|
488
|
-
const events = this.outputState.consume(line);
|
|
489
|
-
this.sync();
|
|
490
|
-
for (const event of events) {
|
|
491
|
-
await this.emit(event);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
stop() {
|
|
495
|
-
if (this.timer) {
|
|
496
|
-
clearInterval(this.timer);
|
|
497
|
-
this.timer = null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
sync() {
|
|
501
|
-
if (!this.outputState.hasActiveToolCall) {
|
|
502
|
-
this.stop();
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
if (this.timer) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
this.timer = setInterval(() => {
|
|
509
|
-
if (!this.outputState.hasActiveToolCall) {
|
|
510
|
-
this.stop();
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
void this.emit({
|
|
514
|
-
role: "runner",
|
|
515
|
-
kind: "status",
|
|
516
|
-
content: "A supervised provider tool is still running.",
|
|
517
|
-
eventType: "provider_tool_heartbeat",
|
|
518
|
-
}).catch(() => undefined);
|
|
519
|
-
}, Math.max(1, this.intervalMs));
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
374
|
const fakeWorkerModel = "server-local-fake-worker";
|
|
523
375
|
export class RoutingProviderCliService {
|
|
524
376
|
realProvider;
|
|
@@ -547,6 +399,11 @@ export class RoutingProviderCliService {
|
|
|
547
399
|
? await this.deterministicProvider.runConflictResolve(context)
|
|
548
400
|
: await this.realProvider.runConflictResolve(context);
|
|
549
401
|
}
|
|
402
|
+
async runPrReview(context) {
|
|
403
|
+
return isFakeWorkerModel(context.dispatch.execution.model)
|
|
404
|
+
? await this.deterministicProvider.runPrReview(context)
|
|
405
|
+
: await this.realProvider.runPrReview(context);
|
|
406
|
+
}
|
|
550
407
|
async runQa(context) {
|
|
551
408
|
return isFakeWorkerModel(context.dispatch.execution.model)
|
|
552
409
|
? await this.deterministicProvider.runQa(context)
|
|
@@ -564,26 +421,32 @@ export class ProcessBackedProviderCliService {
|
|
|
564
421
|
providerToolHeartbeatIntervalMs;
|
|
565
422
|
publicationCoordinator;
|
|
566
423
|
prePublicationValidator;
|
|
567
|
-
|
|
424
|
+
prePublicationRepairTurns;
|
|
425
|
+
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator = defaultPublicationCoordinator(),
|
|
426
|
+
// The Docker sandbox worker (`forge` run-once via ForgeBridgeCliService) builds
|
|
427
|
+
// this default. A container cannot reach the host ledger, so when the host
|
|
428
|
+
// bridge enabled it, its steps ask the bridge for tokens over the sandbox
|
|
429
|
+
// channel (decision 0013); elsewhere the gate is absent and validation is ungated.
|
|
430
|
+
prePublicationValidator = new PrePublicationValidator(undefined, undefined, undefined, sandboxHostLoadGateFromEnvironment()), prePublicationRepairTurns = prePublicationRepairTurnsFromEnvironment()) {
|
|
568
431
|
this.processRunner = processRunner;
|
|
569
432
|
this.git = git;
|
|
570
433
|
this.providerToolHeartbeatIntervalMs = providerToolHeartbeatIntervalMs;
|
|
571
434
|
this.publicationCoordinator = publicationCoordinator;
|
|
572
435
|
this.prePublicationValidator = prePublicationValidator;
|
|
436
|
+
this.prePublicationRepairTurns = prePublicationRepairTurns;
|
|
573
437
|
}
|
|
574
438
|
async runDraft(context) {
|
|
575
|
-
const { dispatch } = context;
|
|
439
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
576
440
|
if (!dispatch.draft) {
|
|
577
441
|
throw new Error("Draft dispatch context is missing.");
|
|
578
442
|
}
|
|
579
|
-
const { worktree } = context;
|
|
580
443
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
581
444
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
582
445
|
await fs.writeFile(path.join(metadataRoot, "draft-input.json"), JSON.stringify(durableDraftInput(dispatch), null, 2) + "\n", "utf8");
|
|
583
446
|
await fs.writeFile(path.join(metadataRoot, "spec.md"), buildDraftSpec(dispatch), "utf8");
|
|
584
447
|
const stagedAttachments = await stageDraftAttachments(dispatch, metadataRoot);
|
|
585
448
|
const decomposeDraft = isDecomposeDraftDispatch(dispatch);
|
|
586
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment });
|
|
449
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
587
450
|
const draftPrompt = buildDraftPrompt(dispatch, { attachmentReferences: stagedAttachments.textReferences });
|
|
588
451
|
const providerPrompt = buildProviderCliPrompt(dispatch, draftPrompt, context.runtimeEnvironment);
|
|
589
452
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -751,7 +614,7 @@ export class ProcessBackedProviderCliService {
|
|
|
751
614
|
}
|
|
752
615
|
}
|
|
753
616
|
async runImplementation(context) {
|
|
754
|
-
const { dispatch, worktree } = context;
|
|
617
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
755
618
|
const validationBaselineRevision = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
756
619
|
const phase = completionPhaseFromDispatch(dispatch);
|
|
757
620
|
const developCycle = usesDevelopCycleCompletion(dispatch);
|
|
@@ -766,12 +629,12 @@ export class ProcessBackedProviderCliService {
|
|
|
766
629
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
767
630
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
768
631
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
769
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment });
|
|
770
|
-
const implementationPrompt = debugCycle
|
|
632
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
633
|
+
const implementationPrompt = withReapplyConflictInstruction(debugCycle
|
|
771
634
|
? buildDebugCyclePrompt(dispatch, phase)
|
|
772
635
|
: developCycle
|
|
773
636
|
? buildDevelopCyclePrompt(dispatch, phase)
|
|
774
|
-
: buildImplementationPrompt(dispatch, phase);
|
|
637
|
+
: buildImplementationPrompt(dispatch, phase), context.reapplyConflicts, context.projectStartDeferred);
|
|
775
638
|
const providerPrompt = buildProviderCliPrompt(dispatch, implementationPrompt, context.runtimeEnvironment);
|
|
776
639
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
777
640
|
const command = buildProviderCliCommand(dispatch, {
|
|
@@ -831,9 +694,8 @@ export class ProcessBackedProviderCliService {
|
|
|
831
694
|
await liveCompletionEvents.stop();
|
|
832
695
|
await cleanupCompletionTools(completionTools, context.emit);
|
|
833
696
|
}
|
|
834
|
-
if (result.exitCode !== 0)
|
|
697
|
+
if (result.exitCode !== 0)
|
|
835
698
|
throw providerCliExitFailure(command.command, result);
|
|
836
|
-
}
|
|
837
699
|
await context.emit({
|
|
838
700
|
role: "runner",
|
|
839
701
|
kind: "checkpoint",
|
|
@@ -903,7 +765,7 @@ export class ProcessBackedProviderCliService {
|
|
|
903
765
|
};
|
|
904
766
|
}
|
|
905
767
|
async runArchitect(context) {
|
|
906
|
-
const { dispatch, worktree } = context;
|
|
768
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
907
769
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
908
770
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
909
771
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -914,7 +776,7 @@ export class ProcessBackedProviderCliService {
|
|
|
914
776
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
915
777
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
916
778
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "pending_approval", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
917
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment });
|
|
779
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
918
780
|
const architectPrompt = buildArchitectPrompt(dispatch);
|
|
919
781
|
const providerPrompt = buildProviderCliPrompt(dispatch, architectPrompt, context.runtimeEnvironment);
|
|
920
782
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -1008,7 +870,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1008
870
|
};
|
|
1009
871
|
}
|
|
1010
872
|
async runQa(context) {
|
|
1011
|
-
const { dispatch, worktree } = context;
|
|
873
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1012
874
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
1013
875
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
1014
876
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -1019,7 +881,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1019
881
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1020
882
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1021
883
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
1022
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment });
|
|
884
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
1023
885
|
const qaPrompt = buildQaPrompt(dispatch, specBody);
|
|
1024
886
|
const providerPrompt = buildProviderCliPrompt(dispatch, qaPrompt, context.runtimeEnvironment);
|
|
1025
887
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -1133,12 +995,13 @@ export class ProcessBackedProviderCliService {
|
|
|
1133
995
|
return await this.runPullRequestRepair(context, "conflict_resolve");
|
|
1134
996
|
}
|
|
1135
997
|
async runPullRequestRepair(context, route) {
|
|
1136
|
-
const { dispatch, worktree } = context;
|
|
998
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1137
999
|
const { expectedRepairHeadSha, preparedHeadSha } = await assertRepairHeadEpoch(context, this.git);
|
|
1138
1000
|
const repairChecks = route === "ci_repair" || isPullRequestCheckRepairDispatch(dispatch);
|
|
1139
1001
|
const addressComments = !repairChecks && isPullRequestCommentsDispatch(dispatch);
|
|
1140
1002
|
let repairSpec = null;
|
|
1141
1003
|
let repairEnvironment = context.runtimeEnvironment;
|
|
1004
|
+
let ciRepairSpecPath = null;
|
|
1142
1005
|
let completionTools = null;
|
|
1143
1006
|
if (repairChecks) {
|
|
1144
1007
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
@@ -1149,6 +1012,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1149
1012
|
}
|
|
1150
1013
|
const specBody = buildSpecBody(laneCommand, dispatch.workItem, "ci_repair");
|
|
1151
1014
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1015
|
+
ciRepairSpecPath = specPath;
|
|
1152
1016
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1153
1017
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), `${JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" })}\n`, "utf8");
|
|
1154
1018
|
repairSpec = {
|
|
@@ -1160,7 +1024,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1160
1024
|
};
|
|
1161
1025
|
const readiness = await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, specPath, context.runtimeEnvironment);
|
|
1162
1026
|
repairEnvironment = readiness.environment;
|
|
1163
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1027
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1028
|
+
dispatch, worktree, phase: "ci_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1029
|
+
});
|
|
1164
1030
|
await context.emit({
|
|
1165
1031
|
role: "runner",
|
|
1166
1032
|
kind: "checkpoint",
|
|
@@ -1175,7 +1041,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1175
1041
|
});
|
|
1176
1042
|
}
|
|
1177
1043
|
if (addressComments) {
|
|
1178
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1044
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1045
|
+
dispatch, worktree, phase: "comment_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1046
|
+
});
|
|
1179
1047
|
await context.emit({
|
|
1180
1048
|
role: "runner",
|
|
1181
1049
|
kind: "checkpoint",
|
|
@@ -1183,11 +1051,11 @@ export class ProcessBackedProviderCliService {
|
|
|
1183
1051
|
eventType: "completion_tools_configured",
|
|
1184
1052
|
});
|
|
1185
1053
|
}
|
|
1186
|
-
const repairPrompt = repairChecks
|
|
1054
|
+
const repairPrompt = withReapplyConflictInstruction(repairChecks
|
|
1187
1055
|
? buildPullRequestCheckRepairPrompt(dispatch, worktree.branchName)
|
|
1188
1056
|
: addressComments
|
|
1189
1057
|
? buildPullRequestCommentsPrompt(dispatch, worktree.branchName)
|
|
1190
|
-
: buildConflictResolvePrompt(dispatch, worktree.branchName);
|
|
1058
|
+
: buildConflictResolvePrompt(dispatch, worktree.branchName), context.reapplyConflicts, context.projectStartDeferred);
|
|
1191
1059
|
const providerPrompt = buildProviderCliPrompt(dispatch, repairPrompt, repairEnvironment);
|
|
1192
1060
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
1193
1061
|
const command = buildProviderCliCommand(dispatch, {
|
|
@@ -1299,6 +1167,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1299
1167
|
: addressComments
|
|
1300
1168
|
? "comment_repair"
|
|
1301
1169
|
: "conflict_repair";
|
|
1170
|
+
const readinessSpecPath = ciRepairSpecPath;
|
|
1302
1171
|
await this.validatePrePublicationWithRecovery({
|
|
1303
1172
|
context,
|
|
1304
1173
|
validationProfile,
|
|
@@ -1306,6 +1175,10 @@ export class ProcessBackedProviderCliService {
|
|
|
1306
1175
|
outputState,
|
|
1307
1176
|
preparedHeadSha,
|
|
1308
1177
|
repairScope: "pull_request",
|
|
1178
|
+
...(readinessSpecPath ? {
|
|
1179
|
+
// The readiness manifest records the attempt URLs; a restart must not leave it pointing at the old stack.
|
|
1180
|
+
onRuntimeEnvironmentRefreshed: async (runtimeEnvironment) => (await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, readinessSpecPath, runtimeEnvironment)).environment,
|
|
1181
|
+
} : {}),
|
|
1309
1182
|
});
|
|
1310
1183
|
const stagedChangeSet = await stagePublishableWorktreeChangeSet(this.git, worktree.worktreePath);
|
|
1311
1184
|
const stagedChangedFiles = stagedChangeSet.publishable;
|
|
@@ -1347,6 +1220,19 @@ export class ProcessBackedProviderCliService {
|
|
|
1347
1220
|
artifacts: repairArtifact ? [repairArtifact] : [],
|
|
1348
1221
|
};
|
|
1349
1222
|
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Review-only session for a pull request head. Never routed through implementation: the worktree
|
|
1225
|
+
* is detached at the dispatched head, the provider cannot change or publish anything, and the
|
|
1226
|
+
* review is handed to Forge only through the completion tool. No commit, push or GitHub call
|
|
1227
|
+
* is made here; a worktree that differs after the session fails with `guardrail_violation`.
|
|
1228
|
+
*/
|
|
1229
|
+
async runPrReview(context) {
|
|
1230
|
+
return await runPrReviewSession({
|
|
1231
|
+
git: this.git,
|
|
1232
|
+
processRunner: this.processRunner,
|
|
1233
|
+
providerToolHeartbeatIntervalMs: this.providerToolHeartbeatIntervalMs,
|
|
1234
|
+
}, admitUserConfigIsolatedProvider(context));
|
|
1235
|
+
}
|
|
1350
1236
|
async recoverMissingQaCompletion(options) {
|
|
1351
1237
|
const { context, outputState } = options;
|
|
1352
1238
|
const { dispatch, worktree } = context;
|
|
@@ -1367,7 +1253,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1367
1253
|
...dispatch,
|
|
1368
1254
|
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1369
1255
|
};
|
|
1370
|
-
const recoveryPrompt = [
|
|
1256
|
+
const recoveryPrompt = await withRemainingReapplyConflictInstruction([
|
|
1371
1257
|
"Your previous turn ended before Forge received the QA verdict, so the provider process exited.",
|
|
1372
1258
|
"Background watchers, monitors and notifications from that turn did not survive and will never report back.",
|
|
1373
1259
|
"Resume QA exactly where it stopped. Do not repeat gates you already recorded.",
|
|
@@ -1375,7 +1261,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1375
1261
|
"and block on long commands with forge.wait_managed_command, calling it again while command_continues is true.",
|
|
1376
1262
|
"Do not end your turn until you have called every remaining QA gate through forge.complete_qa_verdict.",
|
|
1377
1263
|
"If a gate cannot get evidence, record it as blocked with the reason instead of ending the turn.",
|
|
1378
|
-
].join(" ");
|
|
1264
|
+
].join(" "), context);
|
|
1379
1265
|
for (let turn = 1; turn <= maxQaCompletionRecoveryTurns; turn += 1) {
|
|
1380
1266
|
const providerPrompt = buildProviderCliPrompt(recoveryDispatch, recoveryPrompt, context.runtimeEnvironment);
|
|
1381
1267
|
const pipePromptToStdin = shouldPipePromptToStdin(recoveryDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(recoveryDispatch));
|
|
@@ -1384,6 +1270,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1384
1270
|
worktree,
|
|
1385
1271
|
phase: "qa",
|
|
1386
1272
|
runtimeEnvironment: context.runtimeEnvironment,
|
|
1273
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1387
1274
|
});
|
|
1388
1275
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1389
1276
|
worktreePath: worktree.worktreePath,
|
|
@@ -1475,7 +1362,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1475
1362
|
...dispatch,
|
|
1476
1363
|
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1477
1364
|
};
|
|
1478
|
-
const recoveryPrompt = [
|
|
1365
|
+
const recoveryPrompt = await withRemainingReapplyConflictInstruction([
|
|
1479
1366
|
"Forge did not receive the required forge.complete_comment_repair call from your previous turn, so the provider process exited.",
|
|
1480
1367
|
"Background watchers, monitors and notifications from that turn did not survive and will never report back,",
|
|
1481
1368
|
"and Forge stopped any managed command that process was still running; its receipt reports that.",
|
|
@@ -1485,7 +1372,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1485
1372
|
"and block on long commands with forge.wait_managed_command, calling it again while command_continues is true.",
|
|
1486
1373
|
"Do not end your turn until you have called forge.complete_comment_repair with an evidence-backed disposition for every actionable finding.",
|
|
1487
1374
|
"Do not commit or push; Forge owns publication after the completion gate succeeds.",
|
|
1488
|
-
].join(" ");
|
|
1375
|
+
].join(" "), context);
|
|
1489
1376
|
const providerPrompt = buildProviderCliPrompt(recoveryDispatch, recoveryPrompt, repairEnvironment);
|
|
1490
1377
|
const pipePromptToStdin = shouldPipePromptToStdin(recoveryDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(recoveryDispatch));
|
|
1491
1378
|
const completionTools = await prepareCompletionToolRuntime({
|
|
@@ -1493,6 +1380,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1493
1380
|
worktree,
|
|
1494
1381
|
phase: "comment_repair",
|
|
1495
1382
|
runtimeEnvironment: repairEnvironment,
|
|
1383
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1496
1384
|
});
|
|
1497
1385
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1498
1386
|
worktreePath: worktree.worktreePath,
|
|
@@ -1572,141 +1460,75 @@ export class ProcessBackedProviderCliService {
|
|
|
1572
1460
|
return artifact;
|
|
1573
1461
|
}
|
|
1574
1462
|
async validatePrePublicationWithRecovery(options) {
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1463
|
+
const processRunner = recoveringProviderProcessRunner(options.context.processRunner ?? this.processRunner);
|
|
1464
|
+
await validatePrePublicationWithRepair(options, {
|
|
1465
|
+
validator: this.prePublicationValidator,
|
|
1466
|
+
defaultProcessRunner: this.processRunner,
|
|
1467
|
+
maxRepairTurns: this.prePublicationRepairTurns,
|
|
1468
|
+
runRepairTurn: async (turn) => await this.runPrePublicationRepairTurn(options, processRunner, turn),
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was.
|
|
1473
|
+
* The turn launches with its own Forge MCP server (prepareRepairTurnLaunch), removed when it exits.
|
|
1474
|
+
*/
|
|
1475
|
+
async runPrePublicationRepairTurn(options, processRunner, turn) {
|
|
1476
|
+
const { context, outputState, preparedHeadSha } = options;
|
|
1477
|
+
const { worktree } = context;
|
|
1478
|
+
const { repairTurn: nextRepairTurn, maxRepairTurns, environment } = turn;
|
|
1479
|
+
const { repairDispatch, providerPrompt, pipePromptToStdin, completionTools, command } = await prepareRepairTurnLaunch(context, turn);
|
|
1480
|
+
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1481
|
+
let result;
|
|
1482
|
+
let providerStarted = false;
|
|
1483
|
+
try {
|
|
1484
|
+
result = await processRunner.run({
|
|
1485
|
+
command: command.command,
|
|
1486
|
+
args: command.args,
|
|
1487
|
+
cwd: worktree.worktreePath,
|
|
1488
|
+
env: environment,
|
|
1489
|
+
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1490
|
+
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1491
|
+
}, {
|
|
1492
|
+
onStarted: async () => {
|
|
1584
1493
|
await context.emit({
|
|
1585
1494
|
role: "runner",
|
|
1586
1495
|
kind: "checkpoint",
|
|
1587
|
-
content: `
|
|
1588
|
-
eventType: "
|
|
1589
|
-
data: JSON.stringify({ repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1496
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} is supervised and ready.`,
|
|
1497
|
+
eventType: "provider_cli_started",
|
|
1590
1498
|
});
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1499
|
+
providerStarted = true;
|
|
1500
|
+
},
|
|
1501
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1502
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1503
|
+
onStdoutLine: async (line) => {
|
|
1504
|
+
await toolHeartbeat.consume(line);
|
|
1505
|
+
},
|
|
1506
|
+
}, context.signal);
|
|
1507
|
+
}
|
|
1508
|
+
finally {
|
|
1509
|
+
toolHeartbeat.stop();
|
|
1510
|
+
try {
|
|
1511
|
+
if (providerStarted) {
|
|
1598
1512
|
await context.emit({
|
|
1599
1513
|
role: "runner",
|
|
1600
|
-
kind: "
|
|
1601
|
-
content: `
|
|
1602
|
-
eventType: "
|
|
1603
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurns: repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1514
|
+
kind: "checkpoint",
|
|
1515
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} exited.`,
|
|
1516
|
+
eventType: "provider_cli_completed",
|
|
1604
1517
|
});
|
|
1605
|
-
throw error;
|
|
1606
|
-
}
|
|
1607
|
-
const providerThreadId = outputState.providerThreadId?.trim();
|
|
1608
|
-
if (!providerThreadId) {
|
|
1609
|
-
throw new Error(`prepublication_repair_unavailable: ${error.message}; provider did not report a resumable thread id, so Forge preserved the dirty worktree without starting a blind replacement run.`, { cause: error });
|
|
1610
|
-
}
|
|
1611
|
-
const nextRepairTurn = repairTurn + 1;
|
|
1612
|
-
const focusedPrompt = buildPrePublicationRepairPrompt(error, nextRepairTurn, repairScope);
|
|
1613
|
-
const repairDispatch = {
|
|
1614
|
-
...dispatch,
|
|
1615
|
-
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1616
|
-
};
|
|
1617
|
-
const providerPrompt = buildProviderCliPrompt(repairDispatch, focusedPrompt, repairEnvironment);
|
|
1618
|
-
const pipePromptToStdin = shouldPipePromptToStdin(repairDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(repairDispatch));
|
|
1619
|
-
const command = buildProviderCliCommand(repairDispatch, {
|
|
1620
|
-
worktreePath: worktree.worktreePath,
|
|
1621
|
-
prompt: focusedPrompt,
|
|
1622
|
-
promptFromStdin: pipePromptToStdin,
|
|
1623
|
-
runtimeEnvironment: repairEnvironment,
|
|
1624
|
-
});
|
|
1625
|
-
await context.emit({
|
|
1626
|
-
role: "runner",
|
|
1627
|
-
kind: "checkpoint",
|
|
1628
|
-
content: `Resuming ${dispatch.execution.provider} ${outputState.sessionLabel ?? "provider thread"} for bounded pre-publication repair ${nextRepairTurn}/${maxPrePublicationRepairTurns} after '${error.checkId}' failed.`,
|
|
1629
|
-
eventType: "prepublication_repair_started",
|
|
1630
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurn: nextRepairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1631
|
-
});
|
|
1632
|
-
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1633
|
-
let result;
|
|
1634
|
-
let providerStarted = false;
|
|
1635
|
-
try {
|
|
1636
|
-
result = await processRunner.run({
|
|
1637
|
-
command: command.command,
|
|
1638
|
-
args: command.args,
|
|
1639
|
-
cwd: worktree.worktreePath,
|
|
1640
|
-
env: environment,
|
|
1641
|
-
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1642
|
-
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1643
|
-
}, {
|
|
1644
|
-
onStarted: async () => {
|
|
1645
|
-
await context.emit({
|
|
1646
|
-
role: "runner",
|
|
1647
|
-
kind: "checkpoint",
|
|
1648
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} is supervised and ready.`,
|
|
1649
|
-
eventType: "provider_cli_started",
|
|
1650
|
-
});
|
|
1651
|
-
providerStarted = true;
|
|
1652
|
-
},
|
|
1653
|
-
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1654
|
-
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1655
|
-
onStdoutLine: async (line) => {
|
|
1656
|
-
await toolHeartbeat.consume(line);
|
|
1657
|
-
},
|
|
1658
|
-
}, context.signal);
|
|
1659
|
-
}
|
|
1660
|
-
finally {
|
|
1661
|
-
toolHeartbeat.stop();
|
|
1662
|
-
if (providerStarted) {
|
|
1663
|
-
await context.emit({
|
|
1664
|
-
role: "runner",
|
|
1665
|
-
kind: "checkpoint",
|
|
1666
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} exited.`,
|
|
1667
|
-
eventType: "provider_cli_completed",
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
if (result.exitCode !== 0)
|
|
1672
|
-
throw providerCliExitFailure(command.command, result);
|
|
1673
|
-
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1674
|
-
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1675
|
-
throw new Error(`provider_publication_boundary_violation: pre-publication repair changed HEAD from ${preparedHeadSha} to ${postRepairHeadSha}; Forge requires provider changes to remain uncommitted and unpushed until validation passes.`, { cause: error });
|
|
1676
1518
|
}
|
|
1677
1519
|
}
|
|
1520
|
+
finally {
|
|
1521
|
+
await cleanupCompletionTools(completionTools, context.emit);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
if (result.exitCode !== 0)
|
|
1525
|
+
throw providerCliExitFailure(command.command, result);
|
|
1526
|
+
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1527
|
+
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1528
|
+
throw new Error(`provider_publication_boundary_violation: pre-publication repair changed HEAD from ${preparedHeadSha} to ${postRepairHeadSha}; Forge requires provider changes to remain uncommitted and unpushed until validation passes.`, { cause: turn.failure });
|
|
1678
1529
|
}
|
|
1679
1530
|
}
|
|
1680
1531
|
}
|
|
1681
|
-
function buildPrePublicationRepairPrompt(error, repairTurn, repairScope) {
|
|
1682
|
-
const invocation = [error.command, ...error.args].join(" ");
|
|
1683
|
-
const priorWork = repairScope === "implementation"
|
|
1684
|
-
? "Keep the completed implementation and its Forge-owned completion artifacts intact."
|
|
1685
|
-
: "Keep the existing PR-comment or CI repairs intact.";
|
|
1686
|
-
return [
|
|
1687
|
-
`Forge pre-publication validation failed after your ${repairScope === "implementation" ? "implementation" : "PR repair"} turn.`,
|
|
1688
|
-
`This is bounded in-place repair turn ${repairTurn}/${maxPrePublicationRepairTurns}.`,
|
|
1689
|
-
`Failed check: ${error.checkId}`,
|
|
1690
|
-
`Command: ${invocation}`,
|
|
1691
|
-
`Exit code: ${error.exitCode}`,
|
|
1692
|
-
"Diagnostics:",
|
|
1693
|
-
error.detail || "The validation command returned no diagnostic output.",
|
|
1694
|
-
"Fix the root cause in the current worktree and run the focused failing check.",
|
|
1695
|
-
`${priorWork} Do not commit, push, rebase, or modify Forge-owned protocol artifacts.`,
|
|
1696
|
-
"When the focused check passes, stop; Bridge will rerun the complete required pre-publication profile and owns commit/push.",
|
|
1697
|
-
].join("\n\n");
|
|
1698
|
-
}
|
|
1699
|
-
function publicationCapabilities(context, runtimeEnvironment) {
|
|
1700
|
-
const capabilities = new Set();
|
|
1701
|
-
const launchTarget = context.dispatch.qaBrowser?.launchTarget;
|
|
1702
|
-
if (runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG
|
|
1703
|
-
|| launchTarget?.url
|
|
1704
|
-
|| launchTarget?.command
|
|
1705
|
-
|| launchTarget?.managed_runtime_port) {
|
|
1706
|
-
capabilities.add("browser_launch");
|
|
1707
|
-
}
|
|
1708
|
-
return capabilities;
|
|
1709
|
-
}
|
|
1710
1532
|
async function stageDraftAttachments(dispatch, metadataRoot) {
|
|
1711
1533
|
const attachments = dispatch.draft?.attachments ?? [];
|
|
1712
1534
|
const stageable = attachments.filter((attachment) => (attachment.kind === "text" && typeof attachment.textContent === "string")
|
|
@@ -1768,18 +1590,6 @@ function clipFileName(fileName, maxLength) {
|
|
|
1768
1590
|
const maxStemLength = Math.max(1, maxLength - extension.length);
|
|
1769
1591
|
return `${stem.slice(0, maxStemLength)}${extension}`;
|
|
1770
1592
|
}
|
|
1771
|
-
const providerPromptStdinThreshold = 8_000;
|
|
1772
|
-
function shouldPipePromptToStdin(provider, prompt, force = false) {
|
|
1773
|
-
const normalized = provider.trim().toLowerCase();
|
|
1774
|
-
if (normalized === "claude") {
|
|
1775
|
-
return true;
|
|
1776
|
-
}
|
|
1777
|
-
return normalized === "codex"
|
|
1778
|
-
&& (force || Buffer.byteLength(prompt, "utf8") > providerPromptStdinThreshold);
|
|
1779
|
-
}
|
|
1780
|
-
function usesManagedWindowsHost(dispatch) {
|
|
1781
|
-
return process.platform === "win32" && dispatch.sandbox?.executionMode === "host";
|
|
1782
|
-
}
|
|
1783
1593
|
function isFakeWorkerModel(model) {
|
|
1784
1594
|
return model.trim().toLowerCase() === fakeWorkerModel;
|
|
1785
1595
|
}
|