@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 0.1.4-dev.03584818ede5
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 +146 -5
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +137 -0
- package/dist/bridge/bridge-chat.types.d.ts +121 -0
- package/dist/bridge/bridge-chat.types.js +416 -0
- package/dist/bridge/bridge.base.d.ts +13 -1
- package/dist/bridge/bridge.service.d.ts +155 -4
- package/dist/bridge/bridge.service.js +1805 -155
- package/dist/bridge/bridge.types.d.ts +68 -1
- package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
- package/dist/bridge/dispatch-result-outbox.js +87 -0
- package/dist/bridge/dispatch-result-worker.d.ts +2 -0
- package/dist/bridge/dispatch-result-worker.js +122 -0
- package/dist/bridge/internals.d.ts +2 -0
- package/dist/bridge/internals.js +1 -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 +21 -0
- package/dist/bridge/readiness-result-outbox.js +54 -0
- package/dist/bridge/readiness-result-worker.d.ts +2 -0
- package/dist/bridge/readiness-result-worker.js +121 -0
- package/dist/bridge/runner-host-capabilities.d.ts +20 -0
- package/dist/bridge/runner-host-capabilities.js +110 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup.service.d.ts +10 -0
- package/dist/cleanup/cleanup.service.js +128 -104
- package/dist/cleanup/cleanup.types.d.ts +4 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -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 +22 -4
- package/dist/cli/cli.service.d.ts +30 -6
- package/dist/cli/cli.service.js +216 -31
- package/dist/cli/local-config.d.ts +5 -0
- package/dist/cli/local-config.js +30 -4
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +36 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +429 -0
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
- package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
- package/dist/runtime/attempt-path-operation.d.ts +21 -0
- package/dist/runtime/attempt-path-operation.js +94 -0
- package/dist/runtime/attempt-private-directory.d.ts +6 -0
- package/dist/runtime/attempt-private-directory.js +54 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
- package/dist/runtime/attempt-process-supervisor.js +144 -23
- package/dist/runtime/canonical-source-file.d.ts +3 -0
- package/dist/runtime/canonical-source-file.js +54 -0
- package/dist/runtime/docker-engine-probe.d.ts +90 -0
- package/dist/runtime/docker-engine-probe.js +333 -0
- package/dist/runtime/generated-output-reset.d.ts +10 -0
- package/dist/runtime/generated-output-reset.js +62 -8
- package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
- package/dist/runtime/host-database-capability-boundary.js +63 -0
- package/dist/runtime/host-diagnostics.d.ts +11 -0
- package/dist/runtime/host-diagnostics.js +192 -0
- package/dist/runtime/host-execution-root.d.ts +4 -0
- package/dist/runtime/host-execution-root.js +39 -0
- package/dist/runtime/host-facts.d.ts +36 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-listener-inspector.d.ts +8 -1
- package/dist/runtime/host-listener-inspector.js +121 -60
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -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 +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +184 -0
- package/dist/runtime/host-load-governor.js +632 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +149 -0
- package/dist/runtime/host-load-sampler.js +291 -0
- 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 +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -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 +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +16 -1
- package/dist/runtime/host-runtime-contract.js +174 -56
- package/dist/runtime/host-runtime-lease.d.ts +163 -9
- package/dist/runtime/host-runtime-lease.js +1464 -121
- package/dist/runtime/host-runtime-promotion.d.ts +35 -3
- package/dist/runtime/host-runtime-promotion.js +107 -12
- 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.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +607 -0
- package/dist/runtime/memory-capacity.d.ts +70 -0
- package/dist/runtime/memory-capacity.js +123 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +25 -0
- package/dist/runtime/native-test-postgres-fallback.js +91 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
- package/dist/runtime/node-host-runtime-adapter.js +29 -11
- package/dist/runtime/pinned-directory-process.d.ts +9 -0
- package/dist/runtime/pinned-directory-process.js +61 -0
- package/dist/runtime/pinned-source-directory.d.ts +17 -0
- package/dist/runtime/pinned-source-directory.js +94 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
- package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
- package/dist/runtime/prepared-runtime-identity.js +218 -0
- package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
- package/dist/runtime/prepared-runtime-readiness.js +285 -0
- package/dist/runtime/runner-settings.d.ts +100 -0
- package/dist/runtime/runner-settings.js +214 -0
- package/dist/runtime/runtime-isolation-lease.js +4 -1
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -0
- package/dist/sandbox/host-capacity-broker.d.ts +113 -0
- package/dist/sandbox/host-capacity-broker.js +334 -0
- package/dist/sandbox/preflight.d.ts +31 -1
- package/dist/sandbox/preflight.js +237 -51
- package/dist/sandbox/repository-lock.d.ts +2 -1
- package/dist/sandbox/repository-lock.js +19 -9
- package/dist/sandbox/runtime.d.ts +16 -2
- package/dist/sandbox/runtime.js +182 -109
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox.types.d.ts +7 -0
- package/dist/sandbox/workspace.service.js +2 -0
- 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 +44 -1
- package/dist/session/managed-attempt-tools.js +816 -46
- package/dist/session/managed-build-coordinator.d.ts +5 -0
- package/dist/session/managed-build-coordinator.js +109 -0
- package/dist/session/managed-build-receipt.d.ts +21 -0
- package/dist/session/managed-build-receipt.js +337 -0
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/managed-verification-timeouts.d.ts +8 -0
- package/dist/session/managed-verification-timeouts.js +17 -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.artifacts.d.ts +24 -0
- package/dist/session/phase-completion.artifacts.js +319 -44
- 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 +15 -1
- package/dist/session/phase-completion.helpers.d.ts +5 -0
- package/dist/session/phase-completion.helpers.js +43 -19
- package/dist/session/phase-completion.js +18 -3
- package/dist/session/phase-completion.prompts.js +22 -18
- package/dist/session/phase-completion.runtime.d.ts +6 -2
- package/dist/session/phase-completion.runtime.js +191 -47
- 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 +250 -226
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +135 -89
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.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 +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +87 -0
- package/dist/session/pre-publication-validation.js +668 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
- package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
- package/dist/session/provider-cli/claude-background-work.js +180 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
- package/dist/session/provider-cli/pre-publication-repair.js +243 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +73 -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.js +34 -2
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +92 -14
- package/dist/session/provider-cli/provider-cli.process.js +583 -210
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +200 -25
- package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +14 -1
- package/dist/session/provider-cli/provider-cli.runtime.js +61 -3
- package/dist/session/provider-cli/provider-cli.service.d.ts +33 -5
- package/dist/session/provider-cli/provider-cli.service.js +819 -84
- package/dist/session/provider-cli/provider-cli.types.d.ts +32 -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-in-flight-work.d.ts +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -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 +18 -0
- package/dist/session/provider-cli/provider-output-state.js +376 -17
- package/dist/session/provider-cli/provider-usage.d.ts +9 -1
- package/dist/session/provider-cli/provider-usage.js +28 -5
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +238 -0
- package/dist/session/session-redaction.js +434 -9
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +264 -27
- package/dist/session/session.types.d.ts +150 -2
- package/dist/session/session.types.js +599 -7
- package/dist/session/unreferenced-exports.d.ts +12 -0
- package/dist/session/unreferenced-exports.js +59 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/format/format-bytes.d.ts +1 -0
- package/dist/shared/format/format-bytes.js +9 -0
- package/dist/shared/git/git.js +2 -1
- package/dist/shared/path/path.d.ts +1 -0
- package/dist/shared/path/path.js +18 -0
- package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
- package/dist/shared/process/dotnet-toolchain.js +307 -0
- package/dist/shared/process/host-process-recovery.js +3 -2
- package/dist/shared/process/host-process-supervisor.d.ts +3 -0
- package/dist/shared/process/host-process-supervisor.js +61 -12
- 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 +69 -0
- package/dist/shared/process/process.js +223 -16
- 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 +3 -0
- package/dist/shared/provider-capabilities.js +84 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +39 -3
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +66 -9
- package/dist/worktree/dependency-warmer.js +609 -24
- package/dist/worktree/index.d.ts +1 -1
- package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
- package/dist/worktree/story-qa-reference-hydrator.js +253 -0
- package/dist/worktree/worktree.service.d.ts +17 -1
- package/dist/worktree/worktree.service.js +293 -21
- package/dist/worktree/worktree.types.d.ts +14 -1
- package/package.json +8 -6
- package/runtime/windows-job-supervisor.ps1 +380 -14
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
3
5
|
import { completionPhaseFromDispatch, completionPhaseOrder, completionRedactionSecretsEnv, completionToolNamesForDebugGate, completionToolNamesForDecomposeGate, completionToolNamesForDraftGate, completionToolNamesForPhase, completionToolNamesForQaGate, debugCompletionPhaseOrder, decomposeCompletionGateOrder, draftCompletionGateOrder, qaCompletionGateOrder, toolServerName, usesArchitectCycleCompletion, usesDebugCycleCompletion, usesDevelopCycleCompletion, usesQaCycleCompletion } from "./phase-completion.js";
|
|
4
|
-
import { asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseOptionalJsonObject, parseStrictCompletionPhase, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeFileAtomic, writeJsonRpc } from "./phase-completion.validation.js";
|
|
6
|
+
import { CompletionPayloadValidationError, asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseOptionalJsonObject, parseStrictCompletionPhase, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeFileAtomic, writeJsonRpc } from "./phase-completion.validation.js";
|
|
5
7
|
import { completionPromptForDebugCycle, completionPromptForDecomposeCycle, completionPromptForDevelopCycle, completionPromptForDraftCycle, completionPromptForPhase, completionPromptForQaCycle, completionToolNextInstruction, completionToolNextInstructionForDebugGate, completionToolNextInstructionForDecomposeGate, completionToolNextInstructionForDraftGate, completionToolNextInstructionForQaGate, nextDebugPhaseAfter, nextPhaseAfter } from "./phase-completion.prompts.js";
|
|
8
|
+
import { configuredNativeTestPostgresFallbackPath, nativeTestPostgresFallbackConfigEnvironment, } from "../runtime/native-test-postgres-fallback.js";
|
|
9
|
+
import { isHostLoadChildEnvironmentName } from "../runtime/host-load-child-environment.js";
|
|
6
10
|
import { toolDescription, toolInputSchema } from "./phase-completion.schemas.js";
|
|
11
|
+
import { coerceJsonStringArguments, emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
|
|
7
12
|
import { writeCompletionArtifact, writeDecomposeGateCompletionArtifact, writeDraftGateCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
8
|
-
import { callManagedAttemptTool, isManagedAttemptTool, managedAttemptToolDefinition, managedAttemptToolNames, } from "./managed-attempt-tools.js";
|
|
13
|
+
import { callManagedAttemptTool, isManagedAttemptTool, managedAttemptToolDefinition, managedAttemptToolInputSchema, managedAttemptToolNames, runWithOwnerShutdown, } from "./managed-attempt-tools.js";
|
|
9
14
|
export async function prepareCompletionToolRuntime(options) {
|
|
10
15
|
const phase = options.phase ?? completionPhaseFromDispatch(options.dispatch);
|
|
11
16
|
const worktreePath = path.resolve(options.worktree.worktreePath);
|
|
@@ -33,13 +38,17 @@ export async function prepareCompletionToolRuntime(options) {
|
|
|
33
38
|
serverName: toolServerName,
|
|
34
39
|
command: process.execPath,
|
|
35
40
|
args: [forgeBridgeCliBinPath(), ...mcpArgs],
|
|
36
|
-
env: completionToolRuntimeEnvironment(options.runtimeEnvironment),
|
|
41
|
+
env: completionToolRuntimeEnvironment(options.runtimeEnvironment, configuredNativeTestPostgresFallbackPath(), options.hostLoadEnvironment),
|
|
37
42
|
cleanup: async () => undefined
|
|
38
43
|
};
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
const provider = options.dispatch.execution.provider.trim().toLowerCase();
|
|
45
|
+
if (provider === "cursor") {
|
|
46
|
+
return await prepareCursorCompletionToolRuntime(worktreePath, runtime);
|
|
41
47
|
}
|
|
42
|
-
|
|
48
|
+
if (provider === "claude") {
|
|
49
|
+
return await prepareClaudeCompletionToolRuntime(runtime);
|
|
50
|
+
}
|
|
51
|
+
return runtime;
|
|
43
52
|
}
|
|
44
53
|
export function buildCompletionToolServerArgs(config) {
|
|
45
54
|
const args = [
|
|
@@ -101,6 +110,14 @@ export function cursorMcpServerConfig(runtime) {
|
|
|
101
110
|
env: runtime.env
|
|
102
111
|
};
|
|
103
112
|
}
|
|
113
|
+
export function claudeMcpServerConfig(runtime) {
|
|
114
|
+
return {
|
|
115
|
+
type: "stdio",
|
|
116
|
+
command: runtime.command,
|
|
117
|
+
args: [...runtime.args],
|
|
118
|
+
env: runtime.env
|
|
119
|
+
};
|
|
120
|
+
}
|
|
104
121
|
export function completionToolNamesForServer(config) {
|
|
105
122
|
return config.decomposeCycle
|
|
106
123
|
? decomposeCompletionGateOrder.flatMap((gate) => completionToolNamesForDecomposeGate(gate))
|
|
@@ -142,23 +159,26 @@ export class CompletionToolServerSession {
|
|
|
142
159
|
: completionPromptForPhase(this.currentPhase, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId));
|
|
143
160
|
}
|
|
144
161
|
toolDefinitions() {
|
|
145
|
-
const completionTools = completionToolNamesForServer(this.config).map(
|
|
162
|
+
const completionTools = completionToolNamesForServer(this.config).map(toolDefinition);
|
|
146
163
|
return managedAttemptToolsAvailable()
|
|
147
164
|
? [...completionTools, ...managedAttemptToolNames.map(managedAttemptToolDefinition)]
|
|
148
165
|
: completionTools;
|
|
149
166
|
}
|
|
150
|
-
async callTool(toolName,
|
|
167
|
+
async callTool(toolName, rawInput) {
|
|
151
168
|
if (isManagedAttemptTool(toolName)) {
|
|
152
169
|
if (!managedAttemptToolsAvailable()) {
|
|
153
170
|
throw new Error("Forge managed-attempt tools require an active managed host runtime.");
|
|
154
171
|
}
|
|
155
|
-
const
|
|
172
|
+
const managedInput = coerceJsonStringArguments(rawInput, managedAttemptToolInputSchema(toolName));
|
|
173
|
+
const result = await callManagedAttemptTool(toolName, managedInput, this.config.worktreePath);
|
|
156
174
|
if (Array.isArray(result.structuredContent.command)) {
|
|
157
175
|
this.managedCommandReceipts.push(result.structuredContent);
|
|
158
176
|
}
|
|
159
177
|
return result;
|
|
160
178
|
}
|
|
161
179
|
const requestedPhase = phaseFromToolName(toolName);
|
|
180
|
+
// Clients sometimes send a declared array/object argument as its JSON text.
|
|
181
|
+
const input = coerceJsonStringArguments(rawInput, completionToolInputSchema(toolName));
|
|
162
182
|
if (this.completed) {
|
|
163
183
|
throw new Error("Forge completion cycle is already complete; no more completion calls are accepted.");
|
|
164
184
|
}
|
|
@@ -185,9 +205,11 @@ export class CompletionToolServerSession {
|
|
|
185
205
|
? this.advanceAfterPass(completedPhase)
|
|
186
206
|
: completedPhase;
|
|
187
207
|
const nextInstruction = completionToolNextInstruction(completedPhase, status, nextPhase);
|
|
188
|
-
const reason =
|
|
189
|
-
?
|
|
190
|
-
:
|
|
208
|
+
const reason = completedPhase === "qa"
|
|
209
|
+
? `QA artifact recorded locally with status ${status}; API ingestion and acceptance are pending.`
|
|
210
|
+
: pass
|
|
211
|
+
? `${completedPhase} completion artifact accepted.`
|
|
212
|
+
: `${completedPhase} completion artifact recorded with status ${status}; rework is required before phase progression.`;
|
|
191
213
|
return {
|
|
192
214
|
content: [
|
|
193
215
|
{
|
|
@@ -197,6 +219,7 @@ export class CompletionToolServerSession {
|
|
|
197
219
|
],
|
|
198
220
|
structuredContent: {
|
|
199
221
|
...reference,
|
|
222
|
+
...acceptedArtifactReceipt(reference),
|
|
200
223
|
gate: {
|
|
201
224
|
phase: completedPhase,
|
|
202
225
|
status,
|
|
@@ -234,6 +257,7 @@ export class CompletionToolServerSession {
|
|
|
234
257
|
content: [{ type: "text", text: `Forge recorded ${completedGate} artifact ${path.relative(reference.repoPath, reference.path)} (${reference.status}, ${reference.contentHash}). ${nextInstruction}` }],
|
|
235
258
|
structuredContent: {
|
|
236
259
|
...reference,
|
|
260
|
+
...acceptedArtifactReceipt(reference),
|
|
237
261
|
gate: { phase: "decompose", decomposeGate: completedGate, status, allowed: pass, reason },
|
|
238
262
|
nextPhase,
|
|
239
263
|
nextInstruction
|
|
@@ -251,14 +275,26 @@ export class CompletionToolServerSession {
|
|
|
251
275
|
const completedGate = this.currentDraftGate;
|
|
252
276
|
const reference = await writeDraftGateCompletionArtifact(this.config, completedGate, toolName, input);
|
|
253
277
|
const status = reference.status.trim().toLowerCase();
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
278
|
+
// Only a pass completes a Draft gate; needs_revision, needs_rework, and blocked keep the same
|
|
279
|
+
// gate selected so it is retried, never skipped.
|
|
280
|
+
const pass = status === "pass";
|
|
281
|
+
const nextGate = pass ? this.advanceAfterDraftGate(completedGate) : completedGate;
|
|
282
|
+
const nextPhase = pass ? (nextGate ? "draft" : "sign_off_ready") : "draft";
|
|
283
|
+
const nextInstruction = completionToolNextInstructionForDraftGate(completedGate, status, pass ? nextGate : null);
|
|
257
284
|
return {
|
|
258
285
|
content: [{ type: "text", text: `Forge recorded ${completedGate} artifact ${path.relative(reference.repoPath, reference.path)} (${reference.status}, ${reference.contentHash}). ${nextInstruction}` }],
|
|
259
286
|
structuredContent: {
|
|
260
287
|
...reference,
|
|
261
|
-
|
|
288
|
+
...acceptedArtifactReceipt(reference),
|
|
289
|
+
gate: {
|
|
290
|
+
phase: "draft",
|
|
291
|
+
draftGate: completedGate,
|
|
292
|
+
status,
|
|
293
|
+
allowed: pass,
|
|
294
|
+
reason: !pass
|
|
295
|
+
? `${completedGate} artifact recorded with status ${status}; rework is required before continuing.`
|
|
296
|
+
: nextGate ? `${completedGate} artifact accepted; continue to ${nextGate}.` : `Draft proposal artifact accepted with status ${status}.`
|
|
297
|
+
},
|
|
262
298
|
nextPhase,
|
|
263
299
|
nextInstruction
|
|
264
300
|
}
|
|
@@ -291,6 +327,7 @@ export class CompletionToolServerSession {
|
|
|
291
327
|
],
|
|
292
328
|
structuredContent: {
|
|
293
329
|
...reference,
|
|
330
|
+
...acceptedArtifactReceipt(reference),
|
|
294
331
|
gate: {
|
|
295
332
|
phase: completedGate,
|
|
296
333
|
status,
|
|
@@ -321,8 +358,8 @@ export class CompletionToolServerSession {
|
|
|
321
358
|
const nextInstruction = completionToolNextInstructionForQaGate(completedGate, status, nextGate);
|
|
322
359
|
const allowed = status !== "blocked";
|
|
323
360
|
const reason = nextGate
|
|
324
|
-
? `${completedGate} artifact accepted; continue to ${nextGate}.`
|
|
325
|
-
: `QA verdict artifact
|
|
361
|
+
? `${completedGate} artifact accepted locally; continue to ${nextGate}.`
|
|
362
|
+
: `QA verdict artifact recorded locally with status ${status}; API ingestion and acceptance are pending.`;
|
|
326
363
|
return {
|
|
327
364
|
content: [
|
|
328
365
|
{
|
|
@@ -332,6 +369,7 @@ export class CompletionToolServerSession {
|
|
|
332
369
|
],
|
|
333
370
|
structuredContent: {
|
|
334
371
|
...reference,
|
|
372
|
+
...acceptedArtifactReceipt(reference),
|
|
335
373
|
gate: {
|
|
336
374
|
phase: "qa",
|
|
337
375
|
qaGate: completedGate,
|
|
@@ -412,22 +450,51 @@ const completionToolRuntimeEnvironmentNames = [
|
|
|
412
450
|
"FORGE_RUNTIME_MODE",
|
|
413
451
|
"FORGE_RESOURCE_LEASE_ID",
|
|
414
452
|
"FORGE_DISPATCH_ATTEMPT_ID",
|
|
453
|
+
"FORGE_E2E_OWNERSHIP_MODE",
|
|
454
|
+
"FORGE_E2E_OWNERSHIP_TOKEN",
|
|
455
|
+
"FORGE_WORKTREE_PATH",
|
|
415
456
|
"FORGE_LOG_DIR",
|
|
457
|
+
"FORGE_CACHE_DIR",
|
|
416
458
|
"FORGE_TEST_OUTPUT_DIR",
|
|
459
|
+
"FORGE_ATTEMPT_DATABASE_SCHEMA",
|
|
460
|
+
"FORGE_ATTEMPT_DATABASE_READINESS_PATH",
|
|
461
|
+
"FORGE_ATTEMPT_DATABASE_CAPABILITY",
|
|
462
|
+
"FORGE_CI_REPAIR_READINESS_PATH",
|
|
463
|
+
"FORGE_CI_REPAIR_HANDOFF_PATH",
|
|
464
|
+
"FORGE_CI_REPAIR_PROVIDER_ONLY_SPECS",
|
|
465
|
+
"FORGE_PLAYWRIGHT_CONFIG",
|
|
466
|
+
"FORGE_API_URL",
|
|
467
|
+
"FORGE_WEB_URL",
|
|
468
|
+
"FORGE_E2E_API_URL",
|
|
469
|
+
"FORGE_E2E_WEB_URL",
|
|
470
|
+
"PLAYWRIGHT_BROWSERS_PATH",
|
|
417
471
|
"FORGE_TMPDIR",
|
|
472
|
+
"NPM_CONFIG_CACHE",
|
|
418
473
|
"TMPDIR",
|
|
419
474
|
"TMP",
|
|
420
475
|
"TEMP",
|
|
421
476
|
];
|
|
422
|
-
export function completionToolRuntimeEnvironment(runtimeEnvironment) {
|
|
423
|
-
if (!runtimeEnvironment)
|
|
424
|
-
return {};
|
|
477
|
+
export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestPostgresFallbackPath, hostLoadEnvironment) {
|
|
425
478
|
const env = {};
|
|
479
|
+
// Without a runtime environment the server gets nothing from it, but it still
|
|
480
|
+
// joins the host ledger when the bridge handed it the governor's variables.
|
|
481
|
+
if (!runtimeEnvironment && !hostLoadEnvironment)
|
|
482
|
+
return env;
|
|
426
483
|
for (const name of completionToolRuntimeEnvironmentNames) {
|
|
427
|
-
const value = runtimeEnvironment[name]?.trim();
|
|
484
|
+
const value = runtimeEnvironment?.[name]?.trim();
|
|
428
485
|
if (value)
|
|
429
486
|
env[name] = value;
|
|
430
487
|
}
|
|
488
|
+
// The host load governor's flag, state root and tuning: managed commands join its ledger.
|
|
489
|
+
for (const [name, value] of Object.entries(hostLoadEnvironment ?? {})) {
|
|
490
|
+
if (isHostLoadChildEnvironmentName(name) && value.trim())
|
|
491
|
+
env[name] = value.trim();
|
|
492
|
+
}
|
|
493
|
+
// Managed verification reads the operator's native test cluster only through
|
|
494
|
+
// this explicit path, and only while Docker is unavailable.
|
|
495
|
+
if (runtimeEnvironment && nativeTestPostgresFallbackPath) {
|
|
496
|
+
env[nativeTestPostgresFallbackConfigEnvironment] = nativeTestPostgresFallbackPath;
|
|
497
|
+
}
|
|
431
498
|
return env;
|
|
432
499
|
}
|
|
433
500
|
const minimumManagedSolutionTestTimeoutMs = 45 * 60 * 1000;
|
|
@@ -453,7 +520,8 @@ export function assertManagedQaRegressionEvidence(input, receipts) {
|
|
|
453
520
|
const managedCommandId = entry.managed_command_id;
|
|
454
521
|
if (typeof managedCommandId !== "string" || !managedCommandId.trim()) {
|
|
455
522
|
throw new Error(`qa_regression_managed_command_id_required: commands[${index}] runs the solution-wide Forge test. `
|
|
456
|
-
+ "Run it with forge.start_managed_command, continue independent work, call forge.wait_managed_command
|
|
523
|
+
+ "Run it with forge.start_managed_command, continue independent work, then call forge.wait_managed_command for a transport-safe receipt. "
|
|
524
|
+
+ "If command_continues=true, continue useful work or wait again after retry_after_ms. Include the terminal managed_command_id in this command evidence.");
|
|
457
525
|
}
|
|
458
526
|
const matchingReceipts = receipts.filter((receipt) => {
|
|
459
527
|
const tokens = receipt.command;
|
|
@@ -464,7 +532,8 @@ export function assertManagedQaRegressionEvidence(input, receipts) {
|
|
|
464
532
|
});
|
|
465
533
|
if (matchingReceipts.length === 0) {
|
|
466
534
|
throw new Error(`qa_regression_managed_command_required: commands[${index}] runs the solution-wide Forge test. `
|
|
467
|
-
+ "Run it with forge.start_managed_command, continue independent work, call forge.wait_managed_command
|
|
535
|
+
+ "Run it with forge.start_managed_command, continue independent work, then call forge.wait_managed_command for a transport-safe receipt. "
|
|
536
|
+
+ "If command_continues=true, continue useful work or wait again after retry_after_ms. Include its matching terminal managed_command_id; generic-shell timeout evidence is not accepted on a managed host.");
|
|
468
537
|
}
|
|
469
538
|
const terminalReceipts = matchingReceipts.filter((receipt) => typeof receipt.status === "string" && [
|
|
470
539
|
"pass",
|
|
@@ -475,7 +544,7 @@ export function assertManagedQaRegressionEvidence(input, receipts) {
|
|
|
475
544
|
].includes(receipt.status));
|
|
476
545
|
if (terminalReceipts.length === 0) {
|
|
477
546
|
throw new Error(`qa_regression_managed_command_in_progress: commands[${index}] has not produced a terminal managed receipt. `
|
|
478
|
-
+ "Call forge.wait_managed_command
|
|
547
|
+
+ "Call forge.wait_managed_command. If command_continues=true, continue useful work or wait again after retry_after_ms; resubmit this gate only after the receipt is terminal.");
|
|
479
548
|
}
|
|
480
549
|
const adequateReceipt = terminalReceipts.some((receipt) => {
|
|
481
550
|
if (receipt.timed_out !== true)
|
|
@@ -506,24 +575,29 @@ function managedAttemptToolsAvailable() {
|
|
|
506
575
|
}
|
|
507
576
|
export async function runCompletionMcpServer(config) {
|
|
508
577
|
const session = new CompletionToolServerSession(config);
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
buffer
|
|
517
|
-
|
|
518
|
-
|
|
578
|
+
// This server is the only supervisor of the managed commands it starts, and they run in
|
|
579
|
+
// their own process groups. When the provider closes the connection or stops this server,
|
|
580
|
+
// stop them first so none outlives its supervisor and receipt writer.
|
|
581
|
+
await runWithOwnerShutdown(async () => {
|
|
582
|
+
process.stdin.setEncoding("utf8");
|
|
583
|
+
let buffer = "";
|
|
584
|
+
for await (const chunk of process.stdin) {
|
|
585
|
+
buffer += chunk;
|
|
586
|
+
let newlineIndex = buffer.indexOf("\n");
|
|
587
|
+
while (newlineIndex >= 0) {
|
|
588
|
+
const rawLine = buffer.slice(0, newlineIndex).trim();
|
|
589
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
590
|
+
if (rawLine.length > 0) {
|
|
591
|
+
await handleJsonRpcLine(session, rawLine);
|
|
592
|
+
}
|
|
593
|
+
newlineIndex = buffer.indexOf("\n");
|
|
519
594
|
}
|
|
520
|
-
newlineIndex = buffer.indexOf("\n");
|
|
521
595
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
596
|
+
const trailing = buffer.trim();
|
|
597
|
+
if (trailing.length > 0) {
|
|
598
|
+
await handleJsonRpcLine(session, trailing);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
527
601
|
}
|
|
528
602
|
export function parseCompletionMcpArgs(argv) {
|
|
529
603
|
let worktreePath = null;
|
|
@@ -559,7 +633,7 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
559
633
|
const rawPhase = argv[++index];
|
|
560
634
|
const parsedPhase = parseStrictCompletionPhase(rawPhase);
|
|
561
635
|
if (!parsedPhase) {
|
|
562
|
-
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
636
|
+
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, comment-repair, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
563
637
|
}
|
|
564
638
|
phase = parsedPhase;
|
|
565
639
|
}
|
|
@@ -621,7 +695,10 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
621
695
|
ownerId,
|
|
622
696
|
phase,
|
|
623
697
|
producedBy,
|
|
624
|
-
redactionSecrets:
|
|
698
|
+
redactionSecrets: [
|
|
699
|
+
...parseCompletionRedactionSecrets(process.env[completionRedactionSecretsEnv]),
|
|
700
|
+
...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
|
|
701
|
+
],
|
|
625
702
|
developCycle,
|
|
626
703
|
qaCycle,
|
|
627
704
|
debugCycle,
|
|
@@ -664,6 +741,28 @@ async function prepareCursorCompletionToolRuntime(worktreePath, runtime) {
|
|
|
664
741
|
}
|
|
665
742
|
};
|
|
666
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Claude Code takes MCP servers from `--mcp-config <file>`. The file lives in an attempt-owned
|
|
746
|
+
* temp directory (never the worktree) because its env block can carry redaction secrets, and
|
|
747
|
+
* passing the JSON inline would not survive Windows shim quoting.
|
|
748
|
+
*/
|
|
749
|
+
async function prepareClaudeCompletionToolRuntime(runtime) {
|
|
750
|
+
const configDir = await fs.mkdtemp(path.join(os.tmpdir(), "forge-claude-mcp-"));
|
|
751
|
+
const configPath = path.join(configDir, "mcp.json");
|
|
752
|
+
const config = {
|
|
753
|
+
mcpServers: {
|
|
754
|
+
[runtime.serverName]: claudeMcpServerConfig(runtime)
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
758
|
+
return {
|
|
759
|
+
...runtime,
|
|
760
|
+
claudeMcpConfigPath: configPath,
|
|
761
|
+
cleanup: async () => {
|
|
762
|
+
await fs.rm(configDir, { recursive: true, force: true });
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
667
766
|
async function handleJsonRpcLine(session, rawLine) {
|
|
668
767
|
let message;
|
|
669
768
|
try {
|
|
@@ -718,14 +817,59 @@ async function handleJsonRpcRequest(session, method, params) {
|
|
|
718
817
|
const call = asRecord(params, "tools/call params");
|
|
719
818
|
const name = requiredString(call, "name");
|
|
720
819
|
const args = call.arguments ?? {};
|
|
721
|
-
|
|
820
|
+
try {
|
|
821
|
+
return await session.callTool(name, args);
|
|
822
|
+
}
|
|
823
|
+
catch (error) {
|
|
824
|
+
if (isManagedAttemptTool(name))
|
|
825
|
+
throw error;
|
|
826
|
+
return completionToolRejectedResult(name, error, args);
|
|
827
|
+
}
|
|
722
828
|
}
|
|
723
829
|
throw new Error(`Unsupported MCP method: ${method}`);
|
|
724
830
|
}
|
|
725
|
-
function
|
|
831
|
+
export function completionToolRejectedResult(toolName, error, input) {
|
|
832
|
+
const issues = error instanceof CompletionPayloadValidationError
|
|
833
|
+
? [...error.issues]
|
|
834
|
+
: [errorMessage(error)];
|
|
835
|
+
if (input !== undefined && isEmptyToolInput(input)) {
|
|
836
|
+
issues.push(`${emptyToolInputHint} Keep long free text such as report_markdown short.`);
|
|
837
|
+
}
|
|
838
|
+
const repairInstruction = "Repair every listed issue and resubmit this same gate once. Do not inspect the artifact path: rejected calls never write or replace completion artifacts.";
|
|
839
|
+
return {
|
|
840
|
+
content: [{
|
|
841
|
+
type: "text",
|
|
842
|
+
text: `Forge rejected ${toolName}. No artifact was written.\n${issues.map(issue => `- ${issue}`).join("\n")}\n${repairInstruction}`,
|
|
843
|
+
}],
|
|
844
|
+
structuredContent: {
|
|
845
|
+
status: "rejected",
|
|
846
|
+
tool_name: toolName,
|
|
847
|
+
artifact_written: false,
|
|
848
|
+
issues,
|
|
849
|
+
repair_instruction: repairInstruction,
|
|
850
|
+
},
|
|
851
|
+
isError: true,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function acceptedArtifactReceipt(reference) {
|
|
855
|
+
return {
|
|
856
|
+
artifact_written: true,
|
|
857
|
+
artifact_receipt: {
|
|
858
|
+
schema_version: 1,
|
|
859
|
+
path: reference.path,
|
|
860
|
+
report_path: reference.reportPath,
|
|
861
|
+
content_hash: reference.contentHash,
|
|
862
|
+
},
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function toolDefinition(name) {
|
|
726
866
|
return {
|
|
727
867
|
name,
|
|
728
|
-
description: toolDescription(
|
|
729
|
-
inputSchema:
|
|
868
|
+
description: toolDescription(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name)),
|
|
869
|
+
inputSchema: completionToolInputSchema(name)
|
|
730
870
|
};
|
|
731
871
|
}
|
|
872
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
873
|
+
export function completionToolInputSchema(name) {
|
|
874
|
+
return toolInputSchema(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name));
|
|
875
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function browserCheckSchema(required: readonly string[]): unknown;
|
|
2
|
+
export declare function qaSidecarsSchema(): unknown;
|
|
3
|
+
export declare function qaEvidenceWrapperSchema(): unknown;
|
|
4
|
+
/** QA evidence gates read only sidecars from the nested wrapper; the other evidence fields go at the top level. */
|
|
5
|
+
export declare function qaGateEvidenceWrapperSchema(): unknown;
|
|
6
|
+
export declare function findingEvidenceSchema(rule: string): unknown;
|
|
7
|
+
export declare function objectToolSchema(properties: Record<string, unknown>, required: readonly string[], description: string): unknown;
|
|
8
|
+
export declare function evidenceObjectSchema(required: readonly string[], properties: Record<string, unknown>): unknown;
|
|
9
|
+
export declare function qaScopeSchema(description: string): unknown;
|
|
10
|
+
export declare function commandEvidenceSchema(): unknown;
|
|
11
|
+
export declare function resolvedFindingSchema(): unknown;
|
|
12
|
+
export declare function acceptanceCriteriaSchema(): unknown;
|
|
13
|
+
export declare function reviewSectionSchema(): {
|
|
14
|
+
readonly type: "object";
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly additionalProperties: true;
|
|
17
|
+
readonly properties: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
export declare function reviewSectionProperties(): Record<string, unknown>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared JSON Schema building blocks for the completion tool input schemas in
|
|
3
|
+
* phase-completion.schemas.ts.
|
|
4
|
+
*/
|
|
5
|
+
import { qaScopeAuthorities, qaScopeConfidence, qaScopeEvidence, qaScopeSources, qaScopeSurfaces, resolvedFindingStatusValues } from "./phase-completion.js";
|
|
6
|
+
export function browserCheckSchema(required) {
|
|
7
|
+
return evidenceObjectSchema(required, {
|
|
8
|
+
summary: { type: "string" },
|
|
9
|
+
url: { type: "string", description: "Page URL; required unless route is given." },
|
|
10
|
+
route: { type: "string", description: "App route; required unless url is given." },
|
|
11
|
+
status: { type: "string", default: "pass", description: "pass when the check succeeded; a QA pass verdict requires pass." },
|
|
12
|
+
screenshot: { type: "string" },
|
|
13
|
+
trace: { type: "string" }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function qaSidecarsSchema() {
|
|
17
|
+
return {
|
|
18
|
+
type: "array",
|
|
19
|
+
description: "Optional QA sidecar files already written under the dispatch-provided QA artifacts path (.../artifacts/qa/), each with its worktree-relative path, sha256 content_hash, and byte size. Send a JSON array, not a quoted string.",
|
|
20
|
+
items: evidenceObjectSchema(["path", "content_hash", "bytes"], {
|
|
21
|
+
path: { type: "string", description: "Worktree-relative path under the QA artifacts qa/ directory." },
|
|
22
|
+
content_hash: { type: "string", description: "sha256 of the file contents (hex, optionally prefixed sha256:)." },
|
|
23
|
+
bytes: { type: "number", minimum: 1, description: "File size in bytes; must match the file." }
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function qaEvidenceWrapperSchema() {
|
|
28
|
+
return {
|
|
29
|
+
type: "object",
|
|
30
|
+
description: "Optional wrapper for the final QA verdict containing commands, browser_checks, sidecars, and notes when a client prefers nested evidence. Top-level fields take precedence.",
|
|
31
|
+
additionalProperties: true,
|
|
32
|
+
properties: {
|
|
33
|
+
commands: { type: "array", items: commandEvidenceSchema() },
|
|
34
|
+
browser_checks: { type: "array", items: browserCheckSchema(["summary", "status"]) },
|
|
35
|
+
sidecars: qaSidecarsSchema(),
|
|
36
|
+
notes: { type: "string" }
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** QA evidence gates read only sidecars from the nested wrapper; the other evidence fields go at the top level. */
|
|
41
|
+
export function qaGateEvidenceWrapperSchema() {
|
|
42
|
+
return {
|
|
43
|
+
type: "object",
|
|
44
|
+
description: "Optional wrapper for sidecars only; send commands, browser_checks, and notes at the top level. Top-level sidecars take precedence.",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
properties: {
|
|
47
|
+
sidecars: qaSidecarsSchema()
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function findingEvidenceSchema(rule) {
|
|
52
|
+
return {
|
|
53
|
+
type: "object",
|
|
54
|
+
additionalProperties: true,
|
|
55
|
+
minProperties: 1,
|
|
56
|
+
description: `${rule} A JSON object (not a string) with at least one concrete reference, for example {"summary": "...", "screenshot": "..."}.`,
|
|
57
|
+
properties: {
|
|
58
|
+
summary: { type: "string" },
|
|
59
|
+
command: { type: "string" },
|
|
60
|
+
screenshot: { type: "string" },
|
|
61
|
+
trace: { type: "string" },
|
|
62
|
+
log: { type: "string" },
|
|
63
|
+
url: { type: "string" }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function objectToolSchema(properties, required, description) {
|
|
68
|
+
return {
|
|
69
|
+
type: "object",
|
|
70
|
+
additionalProperties: true,
|
|
71
|
+
description,
|
|
72
|
+
properties,
|
|
73
|
+
required: [...required]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function evidenceObjectSchema(required, properties) {
|
|
77
|
+
return {
|
|
78
|
+
type: "object",
|
|
79
|
+
additionalProperties: true,
|
|
80
|
+
properties,
|
|
81
|
+
required: [...required]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function qaScopeSchema(description) {
|
|
85
|
+
return {
|
|
86
|
+
type: "object",
|
|
87
|
+
additionalProperties: false,
|
|
88
|
+
description: `${description} Rules: surface ui_browser requires browser_manual in required_evidence, and surface api_route requires api_http; browser_required and api_required, when sent, must match whether required_evidence includes browser_manual and api_http; an evidence kind cannot be both required and not_applicable.`,
|
|
89
|
+
properties: {
|
|
90
|
+
schema_version: { type: "number", enum: [1] },
|
|
91
|
+
surface: { type: "array", items: { type: "string", enum: [...qaScopeSurfaces] } },
|
|
92
|
+
required_evidence: { type: "array", items: { type: "string", enum: [...qaScopeEvidence] } },
|
|
93
|
+
required_capabilities: {
|
|
94
|
+
type: "array",
|
|
95
|
+
description: "Runner facilities required by implementation and validation. Use docker_engine when tests or project services require access to a Docker daemon, even when the agent itself runs in a managed host worktree.",
|
|
96
|
+
items: { type: "string", enum: ["docker_engine"] }
|
|
97
|
+
},
|
|
98
|
+
not_applicable: { type: "array", items: { type: "string", enum: [...qaScopeEvidence] } },
|
|
99
|
+
browser_required: { type: "boolean" },
|
|
100
|
+
api_required: { type: "boolean" },
|
|
101
|
+
source: { type: "string", enum: [...qaScopeSources] },
|
|
102
|
+
authority: { type: "string", enum: [...qaScopeAuthorities] },
|
|
103
|
+
confidence: { type: "string", enum: [...qaScopeConfidence] },
|
|
104
|
+
confirmed_by_user: { type: "boolean" },
|
|
105
|
+
locked: { type: "boolean" },
|
|
106
|
+
derived_from: {
|
|
107
|
+
type: "object",
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
properties: {
|
|
110
|
+
work_item_id: { type: "string" },
|
|
111
|
+
mode: { type: "string" }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
rationale: { type: "string" }
|
|
115
|
+
},
|
|
116
|
+
required: ["schema_version", "required_evidence", "not_applicable"]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function commandEvidenceSchema() {
|
|
120
|
+
return evidenceObjectSchema(["command", "exit_code", "status", "summary"], {
|
|
121
|
+
command: { type: "string", description: "The command line that ran." },
|
|
122
|
+
managed_command_id: { type: "string", description: "Receipt ID returned by forge.start_managed_command after forge.wait_managed_command reports a terminal receipt. A transport-safe wait can return command_continues=true; wait again after retry_after_ms before submitting the gate." },
|
|
123
|
+
exit_code: { type: ["number", "null"], description: "Process exit code, or null when the managed runner timed out or could not launch the process. A passing gate needs 0." },
|
|
124
|
+
status: { type: "string", default: "pass", description: "pass when the command succeeded; otherwise fail, timed_out, or blocked. A passing gate needs pass with exit_code 0." },
|
|
125
|
+
summary: { type: "string", description: "What the command proved." },
|
|
126
|
+
classification: {
|
|
127
|
+
type: "string",
|
|
128
|
+
enum: ["out_of_scope_failure", "baseline_failure"],
|
|
129
|
+
description: "Only for a verified non-blocking failure in a passing QA regression gate. Never use for an in-scope or unexplained failure."
|
|
130
|
+
},
|
|
131
|
+
candidate_bug_id: { type: "string", description: "Required for a classified non-blocking failure; links the preserved failure to candidate_bugs." },
|
|
132
|
+
scope_evidence: { type: "string", description: "Required proof that the failing surface is outside the current acceptance criteria and changed-file scope." },
|
|
133
|
+
acceptance_criteria_independent: { type: "boolean", description: "Required and true only when the current item can be judged independently of this failure." },
|
|
134
|
+
repro_command: { type: "string", description: "Required for out_of_scope_failure; focused command that reproduced the unrelated failure." },
|
|
135
|
+
repro_exit_code: { type: "number", description: "Required non-zero focused repro exit code for out_of_scope_failure." },
|
|
136
|
+
baseline_ref: { type: "string", description: "Required for baseline_failure; immutable ref where the same failure was observed." },
|
|
137
|
+
baseline_exit_code: { type: "number", description: "Required non-zero baseline command exit code for baseline_failure." },
|
|
138
|
+
failure_signature_match: { type: "boolean", description: "Required and true for baseline_failure after matching failing test/error signatures." }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function resolvedFindingSchema() {
|
|
142
|
+
return evidenceObjectSchema([
|
|
143
|
+
"qa_id",
|
|
144
|
+
"status",
|
|
145
|
+
"summary",
|
|
146
|
+
"evidence",
|
|
147
|
+
"changed_files",
|
|
148
|
+
"tests_added_or_updated",
|
|
149
|
+
"regression_evidence"
|
|
150
|
+
], {
|
|
151
|
+
qa_id: { type: "string" },
|
|
152
|
+
status: {
|
|
153
|
+
type: "string",
|
|
154
|
+
enum: [...resolvedFindingStatusValues],
|
|
155
|
+
description: "Use resolved when fixed, disputed when the QA finding is incorrect/out-of-scope, or not_reproduced when retesting cannot reproduce it."
|
|
156
|
+
},
|
|
157
|
+
summary: { type: "string" },
|
|
158
|
+
evidence: { description: "Concrete evidence for the resolution." },
|
|
159
|
+
changed_files: { type: "array", description: "Required and non-empty when status is resolved." },
|
|
160
|
+
tests_added_or_updated: { type: "array", description: "Required and non-empty when status is resolved." },
|
|
161
|
+
regression_evidence: { description: "Concrete regression evidence for this QA finding." }
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
export function acceptanceCriteriaSchema() {
|
|
165
|
+
return {
|
|
166
|
+
type: "array",
|
|
167
|
+
description: "Required for pass. Every entry must be an object with status: satisfied and non-empty evidence.",
|
|
168
|
+
items: evidenceObjectSchema(["criterion", "evidence", "status"], {
|
|
169
|
+
criterion: { type: "string" },
|
|
170
|
+
evidence: { type: "string" },
|
|
171
|
+
status: { type: "string", enum: ["satisfied"] }
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function reviewSectionSchema() {
|
|
176
|
+
return {
|
|
177
|
+
type: "object",
|
|
178
|
+
description: "Required for pass. Use status pass/fail/needs_rework/not_applicable plus notes.",
|
|
179
|
+
additionalProperties: true,
|
|
180
|
+
properties: reviewSectionProperties()
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export function reviewSectionProperties() {
|
|
184
|
+
return {
|
|
185
|
+
status: { type: "string", default: "pass" },
|
|
186
|
+
notes: { type: "string" }
|
|
187
|
+
};
|
|
188
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type CompletionPhase, type DecomposeCompletionGate, type QaCompletionGate } from "./phase-completion.js";
|
|
2
|
-
export declare function toolDescription(phase: CompletionPhase, qaGate?: QaCompletionGate | null, decomposeGate?: DecomposeCompletionGate | null): string;
|
|
3
|
-
export declare function toolInputSchema(phase: CompletionPhase, qaGate?: QaCompletionGate | null, decomposeGate?: DecomposeCompletionGate | null): unknown;
|
|
1
|
+
import { type CompletionPhase, type DecomposeCompletionGate, type DraftCompletionGate, type QaCompletionGate } from "./phase-completion.js";
|
|
2
|
+
export declare function toolDescription(phase: CompletionPhase, qaGate?: QaCompletionGate | null, decomposeGate?: DecomposeCompletionGate | null, draftGate?: DraftCompletionGate | null): string;
|
|
3
|
+
export declare function toolInputSchema(phase: CompletionPhase, qaGate?: QaCompletionGate | null, decomposeGate?: DecomposeCompletionGate | null, draftGate?: DraftCompletionGate | null): unknown;
|