@loucompanion/forge-bridge 0.1.4-dev.4677bbd22f17 → 0.1.4-dev.4e7855579f82
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 +142 -1
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -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 +11 -0
- package/dist/bridge/bridge-state-io.js +50 -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 +89 -14
- package/dist/bridge/bridge.service.js +423 -342
- package/dist/bridge/bridge.types.d.ts +21 -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 +17 -0
- 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/cleanup/cleanup.service.d.ts +9 -0
- package/dist/cleanup/cleanup.service.js +72 -109
- 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 +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +152 -187
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- 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 +5 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +138 -6
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -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-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 +75 -2
- package/dist/runtime/host-load-sampler.js +142 -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 +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 +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 +33 -2
- package/dist/runtime/host-runtime-lease.d.ts +74 -4
- package/dist/runtime/host-runtime-lease.js +285 -55
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +48 -0
- 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/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/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/sandbox/host-capacity-broker.d.ts +113 -0
- package/dist/sandbox/host-capacity-broker.js +334 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -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 +2 -7
- package/dist/session/managed-attempt-tools.js +200 -92
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -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 +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- 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 +12 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -11
- package/dist/session/phase-completion.runtime.js +91 -215
- 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 +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- 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-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 +23 -11
- 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 +37 -21
- package/dist/session/pre-publication-validation.js +221 -182
- 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/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -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.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 +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +72 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +98 -173
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -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 +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +238 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +120 -5
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +5 -5
- 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/process/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- 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.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/worktree.service.d.ts +10 -1
- package/dist/worktree/worktree.service.js +42 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +2 -2
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
5
4
|
import { completionPhaseFromDispatch, completionPhaseOrder, completionRedactionSecretsEnv, completionToolNamesForDebugGate, completionToolNamesForDecomposeGate, completionToolNamesForDraftGate, completionToolNamesForPhase, completionToolNamesForQaGate, debugCompletionPhaseOrder, decomposeCompletionGateOrder, draftCompletionGateOrder, qaCompletionGateOrder, toolServerName, usesArchitectCycleCompletion, usesDebugCycleCompletion, usesDevelopCycleCompletion, usesQaCycleCompletion } from "./phase-completion.js";
|
|
6
|
-
import { CompletionPayloadValidationError, asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch,
|
|
5
|
+
import { CompletionPayloadValidationError, asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, normalizedOwnerType, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeJsonRpc } from "./phase-completion.validation.js";
|
|
7
6
|
import { completionPromptForDebugCycle, completionPromptForDecomposeCycle, completionPromptForDevelopCycle, completionPromptForDraftCycle, completionPromptForPhase, completionPromptForQaCycle, completionToolNextInstruction, completionToolNextInstructionForDebugGate, completionToolNextInstructionForDecomposeGate, completionToolNextInstructionForDraftGate, completionToolNextInstructionForQaGate, nextDebugPhaseAfter, nextPhaseAfter } from "./phase-completion.prompts.js";
|
|
8
7
|
import { configuredNativeTestPostgresFallbackPath, nativeTestPostgresFallbackConfigEnvironment, } from "../runtime/native-test-postgres-fallback.js";
|
|
8
|
+
import { isHostLoadChildEnvironmentName } from "../runtime/host-load-child-environment.js";
|
|
9
|
+
import { isProviderUserConfigIsolated, providerUserConfigIsolationUnsupported } from "./provider-cli/provider-user-config-isolation.js";
|
|
9
10
|
import { toolDescription, toolInputSchema } from "./phase-completion.schemas.js";
|
|
11
|
+
import { coerceJsonStringArguments, emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
|
|
10
12
|
import { writeCompletionArtifact, writeDecomposeGateCompletionArtifact, writeDraftGateCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
11
|
-
import {
|
|
13
|
+
import { buildCompletionToolServerArgs } from "./phase-completion.mcp-args.js";
|
|
14
|
+
import { callManagedAttemptTool, isManagedAttemptTool, managedAttemptToolDefinition, managedAttemptToolInputSchema, managedAttemptToolNames, runWithOwnerShutdown, } from "./managed-attempt-tools.js";
|
|
12
15
|
export async function prepareCompletionToolRuntime(options) {
|
|
13
16
|
const phase = options.phase ?? completionPhaseFromDispatch(options.dispatch);
|
|
14
17
|
const worktreePath = path.resolve(options.worktree.worktreePath);
|
|
15
18
|
const workItemId = options.dispatch.workItem.id;
|
|
16
19
|
const ownerType = normalizedOwnerType(options.dispatch.cycleRun.ownerType) ?? "work_item";
|
|
17
20
|
const ownerId = options.dispatch.cycleRun.ownerId ?? workItemId;
|
|
21
|
+
// A managed-tools-only server records no completion artifact, so it takes no cycle mode.
|
|
22
|
+
const cycles = !options.managedToolsOnly;
|
|
18
23
|
const mcpArgs = buildCompletionToolServerArgs({
|
|
19
24
|
worktreePath,
|
|
20
25
|
workItemId,
|
|
@@ -22,68 +27,36 @@ export async function prepareCompletionToolRuntime(options) {
|
|
|
22
27
|
ownerId,
|
|
23
28
|
phase,
|
|
24
29
|
producedBy: `${options.dispatch.execution.provider}-cli`,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
managedToolsOnly: options.managedToolsOnly,
|
|
31
|
+
developCycle: cycles && usesDevelopCycleCompletion(options.dispatch),
|
|
32
|
+
qaCycle: cycles && usesQaCycleCompletion(options.dispatch),
|
|
33
|
+
debugCycle: cycles && usesDebugCycleCompletion(options.dispatch),
|
|
34
|
+
architectCycle: cycles && usesArchitectCycleCompletion(options.dispatch),
|
|
35
|
+
draftCycle: cycles
|
|
36
|
+
&& (phase === "draft"
|
|
37
|
+
|| options.dispatch.execution.lane.trim().toLowerCase() === "draft"
|
|
38
|
+
|| options.dispatch.cycleRun.kind.trim().toLowerCase() === "draft")
|
|
32
39
|
&& !isDecomposeDispatch(options.dispatch),
|
|
33
|
-
decomposeCycle: isDecomposeDispatch(options.dispatch)
|
|
40
|
+
decomposeCycle: cycles && isDecomposeDispatch(options.dispatch)
|
|
34
41
|
});
|
|
35
42
|
const runtime = {
|
|
36
43
|
serverName: toolServerName,
|
|
37
44
|
command: process.execPath,
|
|
38
45
|
args: [forgeBridgeCliBinPath(), ...mcpArgs],
|
|
39
|
-
env: completionToolRuntimeEnvironment(options.runtimeEnvironment, configuredNativeTestPostgresFallbackPath()),
|
|
46
|
+
env: completionToolRuntimeEnvironment(options.runtimeEnvironment, configuredNativeTestPostgresFallbackPath(), options.hostLoadEnvironment),
|
|
40
47
|
cleanup: async () => undefined
|
|
41
48
|
};
|
|
42
49
|
const provider = options.dispatch.execution.provider.trim().toLowerCase();
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
// Provider phases refuse these at entry (admitUserConfigIsolatedProvider, provider-cli.runtime.ts);
|
|
51
|
+
// this guards any other caller before the Claude MCP config is written.
|
|
52
|
+
if (!isProviderUserConfigIsolated(provider)) {
|
|
53
|
+
throw providerUserConfigIsolationUnsupported(options.dispatch.execution.provider);
|
|
45
54
|
}
|
|
46
55
|
if (provider === "claude") {
|
|
47
56
|
return await prepareClaudeCompletionToolRuntime(runtime);
|
|
48
57
|
}
|
|
49
58
|
return runtime;
|
|
50
59
|
}
|
|
51
|
-
export function buildCompletionToolServerArgs(config) {
|
|
52
|
-
const args = [
|
|
53
|
-
"mcp",
|
|
54
|
-
"--worktree",
|
|
55
|
-
path.resolve(config.worktreePath),
|
|
56
|
-
"--work-item-id",
|
|
57
|
-
config.workItemId,
|
|
58
|
-
"--phase",
|
|
59
|
-
config.phase,
|
|
60
|
-
"--produced-by",
|
|
61
|
-
config.producedBy ?? "forge-completion-tool"
|
|
62
|
-
];
|
|
63
|
-
if (config.ownerType || config.ownerId) {
|
|
64
|
-
args.push("--owner-type", normalizedOwnerType(config.ownerType) ?? "work_item");
|
|
65
|
-
args.push("--owner-id", config.ownerId ?? config.workItemId);
|
|
66
|
-
}
|
|
67
|
-
if (config.developCycle) {
|
|
68
|
-
args.push("--develop-cycle");
|
|
69
|
-
}
|
|
70
|
-
if (config.qaCycle) {
|
|
71
|
-
args.push("--qa-cycle");
|
|
72
|
-
}
|
|
73
|
-
if (config.debugCycle) {
|
|
74
|
-
args.push("--debug-cycle");
|
|
75
|
-
}
|
|
76
|
-
if (config.architectCycle) {
|
|
77
|
-
args.push("--architect-cycle");
|
|
78
|
-
}
|
|
79
|
-
if (config.draftCycle) {
|
|
80
|
-
args.push("--draft-cycle");
|
|
81
|
-
}
|
|
82
|
-
if (config.decomposeCycle) {
|
|
83
|
-
args.push("--decompose-cycle");
|
|
84
|
-
}
|
|
85
|
-
return args;
|
|
86
|
-
}
|
|
87
60
|
export function codexMcpConfigArgs(runtime) {
|
|
88
61
|
const prefix = `mcp_servers.${runtime.serverName}`;
|
|
89
62
|
const args = [
|
|
@@ -131,6 +104,10 @@ export function completionToolNamesForServer(config) {
|
|
|
131
104
|
? completionToolNamesForPhase("architect")
|
|
132
105
|
: completionToolNamesForPhase(config.phase);
|
|
133
106
|
}
|
|
107
|
+
const managedToolsOnlyInstructions = "Forge serves only its managed-attempt tools in this turn: "
|
|
108
|
+
+ "forge.start_managed_verification, forge.start_managed_command, forge.wait_managed_command, forge.get_managed_command, "
|
|
109
|
+
+ "forge.run_managed_command and forge.reset_generated_outputs. No completion tool is available; the phase's completion "
|
|
110
|
+
+ "artifacts are already recorded and must stay as they are.";
|
|
134
111
|
export class CompletionToolServerSession {
|
|
135
112
|
config;
|
|
136
113
|
currentPhase;
|
|
@@ -144,36 +121,46 @@ export class CompletionToolServerSession {
|
|
|
144
121
|
this.currentPhase = config.phase;
|
|
145
122
|
}
|
|
146
123
|
get instructions() {
|
|
147
|
-
return this.config.
|
|
148
|
-
?
|
|
149
|
-
: this.config.
|
|
150
|
-
?
|
|
151
|
-
: this.config.
|
|
152
|
-
?
|
|
153
|
-
: this.config.
|
|
154
|
-
?
|
|
155
|
-
: this.config.
|
|
156
|
-
?
|
|
157
|
-
:
|
|
124
|
+
return this.config.managedToolsOnly
|
|
125
|
+
? managedToolsOnlyInstructions
|
|
126
|
+
: this.config.decomposeCycle
|
|
127
|
+
? completionPromptForDecomposeCycle(this.currentDecomposeGate)
|
|
128
|
+
: this.config.draftCycle
|
|
129
|
+
? completionPromptForDraftCycle(this.currentDraftGate)
|
|
130
|
+
: this.config.debugCycle
|
|
131
|
+
? completionPromptForDebugCycle(asDebugCompletionPhase(this.currentPhase))
|
|
132
|
+
: this.config.qaCycle
|
|
133
|
+
? completionPromptForQaCycle(this.currentQaGate, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId))
|
|
134
|
+
: this.config.developCycle
|
|
135
|
+
? completionPromptForDevelopCycle(this.currentPhase)
|
|
136
|
+
: completionPromptForPhase(this.currentPhase, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId));
|
|
158
137
|
}
|
|
159
138
|
toolDefinitions() {
|
|
160
|
-
const completionTools =
|
|
139
|
+
const completionTools = this.config.managedToolsOnly
|
|
140
|
+
? []
|
|
141
|
+
: completionToolNamesForServer(this.config).map(toolDefinition);
|
|
161
142
|
return managedAttemptToolsAvailable()
|
|
162
143
|
? [...completionTools, ...managedAttemptToolNames.map(managedAttemptToolDefinition)]
|
|
163
144
|
: completionTools;
|
|
164
145
|
}
|
|
165
|
-
async callTool(toolName,
|
|
146
|
+
async callTool(toolName, rawInput) {
|
|
166
147
|
if (isManagedAttemptTool(toolName)) {
|
|
167
148
|
if (!managedAttemptToolsAvailable()) {
|
|
168
149
|
throw new Error("Forge managed-attempt tools require an active managed host runtime.");
|
|
169
150
|
}
|
|
170
|
-
const
|
|
151
|
+
const managedInput = coerceJsonStringArguments(rawInput, managedAttemptToolInputSchema(toolName));
|
|
152
|
+
const result = await callManagedAttemptTool(toolName, managedInput, this.config.worktreePath);
|
|
171
153
|
if (Array.isArray(result.structuredContent.command)) {
|
|
172
154
|
this.managedCommandReceipts.push(result.structuredContent);
|
|
173
155
|
}
|
|
174
156
|
return result;
|
|
175
157
|
}
|
|
158
|
+
if (this.config.managedToolsOnly) {
|
|
159
|
+
throw new Error(`${toolName} is not available in this turn: Forge serves only its managed-attempt tools during a pre-publication repair turn, and the phase's completion artifacts are already recorded. Fix the failing checks and stop; Bridge reruns validation.`);
|
|
160
|
+
}
|
|
176
161
|
const requestedPhase = phaseFromToolName(toolName);
|
|
162
|
+
// Clients sometimes send a declared array/object argument as its JSON text.
|
|
163
|
+
const input = coerceJsonStringArguments(rawInput, completionToolInputSchema(toolName));
|
|
177
164
|
if (this.completed) {
|
|
178
165
|
throw new Error("Forge completion cycle is already complete; no more completion calls are accepted.");
|
|
179
166
|
}
|
|
@@ -270,15 +257,26 @@ export class CompletionToolServerSession {
|
|
|
270
257
|
const completedGate = this.currentDraftGate;
|
|
271
258
|
const reference = await writeDraftGateCompletionArtifact(this.config, completedGate, toolName, input);
|
|
272
259
|
const status = reference.status.trim().toLowerCase();
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
260
|
+
// Only a pass completes a Draft gate; needs_revision, needs_rework, and blocked keep the same
|
|
261
|
+
// gate selected so it is retried, never skipped.
|
|
262
|
+
const pass = status === "pass";
|
|
263
|
+
const nextGate = pass ? this.advanceAfterDraftGate(completedGate) : completedGate;
|
|
264
|
+
const nextPhase = pass ? (nextGate ? "draft" : "sign_off_ready") : "draft";
|
|
265
|
+
const nextInstruction = completionToolNextInstructionForDraftGate(completedGate, status, pass ? nextGate : null);
|
|
276
266
|
return {
|
|
277
267
|
content: [{ type: "text", text: `Forge recorded ${completedGate} artifact ${path.relative(reference.repoPath, reference.path)} (${reference.status}, ${reference.contentHash}). ${nextInstruction}` }],
|
|
278
268
|
structuredContent: {
|
|
279
269
|
...reference,
|
|
280
270
|
...acceptedArtifactReceipt(reference),
|
|
281
|
-
gate: {
|
|
271
|
+
gate: {
|
|
272
|
+
phase: "draft",
|
|
273
|
+
draftGate: completedGate,
|
|
274
|
+
status,
|
|
275
|
+
allowed: pass,
|
|
276
|
+
reason: !pass
|
|
277
|
+
? `${completedGate} artifact recorded with status ${status}; rework is required before continuing.`
|
|
278
|
+
: nextGate ? `${completedGate} artifact accepted; continue to ${nextGate}.` : `Draft proposal artifact accepted with status ${status}.`
|
|
279
|
+
},
|
|
282
280
|
nextPhase,
|
|
283
281
|
nextInstruction
|
|
284
282
|
}
|
|
@@ -458,18 +456,25 @@ const completionToolRuntimeEnvironmentNames = [
|
|
|
458
456
|
"TMP",
|
|
459
457
|
"TEMP",
|
|
460
458
|
];
|
|
461
|
-
export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestPostgresFallbackPath) {
|
|
462
|
-
if (!runtimeEnvironment)
|
|
463
|
-
return {};
|
|
459
|
+
export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestPostgresFallbackPath, hostLoadEnvironment) {
|
|
464
460
|
const env = {};
|
|
461
|
+
// Without a runtime environment the server gets nothing from it, but it still
|
|
462
|
+
// joins the host ledger when the bridge handed it the governor's variables.
|
|
463
|
+
if (!runtimeEnvironment && !hostLoadEnvironment)
|
|
464
|
+
return env;
|
|
465
465
|
for (const name of completionToolRuntimeEnvironmentNames) {
|
|
466
|
-
const value = runtimeEnvironment[name]?.trim();
|
|
466
|
+
const value = runtimeEnvironment?.[name]?.trim();
|
|
467
467
|
if (value)
|
|
468
468
|
env[name] = value;
|
|
469
469
|
}
|
|
470
|
+
// The host load governor's flag, state root and tuning: managed commands join its ledger.
|
|
471
|
+
for (const [name, value] of Object.entries(hostLoadEnvironment ?? {})) {
|
|
472
|
+
if (isHostLoadChildEnvironmentName(name) && value.trim())
|
|
473
|
+
env[name] = value.trim();
|
|
474
|
+
}
|
|
470
475
|
// Managed verification reads the operator's native test cluster only through
|
|
471
|
-
// this explicit path
|
|
472
|
-
if (nativeTestPostgresFallbackPath) {
|
|
476
|
+
// this explicit path; the file's `use` decides whether Docker comes first.
|
|
477
|
+
if (runtimeEnvironment && nativeTestPostgresFallbackPath) {
|
|
473
478
|
env[nativeTestPostgresFallbackConfigEnvironment] = nativeTestPostgresFallbackPath;
|
|
474
479
|
}
|
|
475
480
|
return env;
|
|
@@ -576,148 +581,12 @@ export async function runCompletionMcpServer(config) {
|
|
|
576
581
|
}
|
|
577
582
|
});
|
|
578
583
|
}
|
|
579
|
-
export function parseCompletionMcpArgs(argv) {
|
|
580
|
-
let worktreePath = null;
|
|
581
|
-
let workItemId = null;
|
|
582
|
-
let phase = "implementation";
|
|
583
|
-
let ownerType;
|
|
584
|
-
let ownerId;
|
|
585
|
-
let producedBy;
|
|
586
|
-
let developCycle = false;
|
|
587
|
-
let qaCycle = false;
|
|
588
|
-
let debugCycle = false;
|
|
589
|
-
let architectCycle = false;
|
|
590
|
-
let draftCycle = false;
|
|
591
|
-
let decomposeCycle = false;
|
|
592
|
-
for (let index = 1; index < argv.length; index += 1) {
|
|
593
|
-
const arg = argv[index];
|
|
594
|
-
if (arg === "--worktree") {
|
|
595
|
-
worktreePath = argv[++index] ?? null;
|
|
596
|
-
}
|
|
597
|
-
else if (arg === "--work-item-id") {
|
|
598
|
-
workItemId = argv[++index] ?? null;
|
|
599
|
-
}
|
|
600
|
-
else if (arg === "--owner-type") {
|
|
601
|
-
ownerType = normalizedOwnerType(argv[++index]);
|
|
602
|
-
if (!ownerType) {
|
|
603
|
-
return { ok: false, error: "mcp --owner-type must be work_item or story." };
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
else if (arg === "--owner-id") {
|
|
607
|
-
ownerId = argv[++index] ?? undefined;
|
|
608
|
-
}
|
|
609
|
-
else if (arg === "--phase") {
|
|
610
|
-
const rawPhase = argv[++index];
|
|
611
|
-
const parsedPhase = parseStrictCompletionPhase(rawPhase);
|
|
612
|
-
if (!parsedPhase) {
|
|
613
|
-
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." };
|
|
614
|
-
}
|
|
615
|
-
phase = parsedPhase;
|
|
616
|
-
}
|
|
617
|
-
else if (arg === "--produced-by") {
|
|
618
|
-
producedBy = argv[++index] ?? undefined;
|
|
619
|
-
}
|
|
620
|
-
else if (arg === "--develop-cycle") {
|
|
621
|
-
developCycle = true;
|
|
622
|
-
}
|
|
623
|
-
else if (arg === "--qa-cycle") {
|
|
624
|
-
qaCycle = true;
|
|
625
|
-
}
|
|
626
|
-
else if (arg === "--debug-cycle") {
|
|
627
|
-
debugCycle = true;
|
|
628
|
-
}
|
|
629
|
-
else if (arg === "--architect-cycle") {
|
|
630
|
-
architectCycle = true;
|
|
631
|
-
}
|
|
632
|
-
else if (arg === "--draft-cycle") {
|
|
633
|
-
draftCycle = true;
|
|
634
|
-
}
|
|
635
|
-
else if (arg === "--decompose-cycle") {
|
|
636
|
-
decomposeCycle = true;
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
return { ok: false, error: `Unknown mcp argument: ${arg}` };
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (!worktreePath?.trim() || !workItemId?.trim()) {
|
|
643
|
-
return { ok: false, error: "mcp requires --worktree and --work-item-id." };
|
|
644
|
-
}
|
|
645
|
-
if ([developCycle, qaCycle, debugCycle, architectCycle, draftCycle, decomposeCycle].filter(Boolean).length > 1) {
|
|
646
|
-
return { ok: false, error: "mcp accepts only one cycle mode." };
|
|
647
|
-
}
|
|
648
|
-
if (developCycle && !isDevelopCompletionPhase(phase)) {
|
|
649
|
-
return { ok: false, error: "mcp --develop-cycle requires --phase implementation, self-review, or validation." };
|
|
650
|
-
}
|
|
651
|
-
if (qaCycle && phase !== "qa") {
|
|
652
|
-
return { ok: false, error: "mcp --qa-cycle requires --phase qa." };
|
|
653
|
-
}
|
|
654
|
-
if (debugCycle && !isDebugCompletionPhase(phase)) {
|
|
655
|
-
return { ok: false, error: "mcp --debug-cycle requires --phase debug-repro, debug-root-cause, debug-fix, or debug-regression." };
|
|
656
|
-
}
|
|
657
|
-
if (architectCycle && phase !== "architect") {
|
|
658
|
-
return { ok: false, error: "mcp --architect-cycle requires --phase architect." };
|
|
659
|
-
}
|
|
660
|
-
if (draftCycle && phase !== "draft") {
|
|
661
|
-
return { ok: false, error: "mcp --draft-cycle requires --phase draft." };
|
|
662
|
-
}
|
|
663
|
-
if (decomposeCycle && phase !== "decompose") {
|
|
664
|
-
return { ok: false, error: "mcp --decompose-cycle requires --phase decompose." };
|
|
665
|
-
}
|
|
666
|
-
return {
|
|
667
|
-
ok: true,
|
|
668
|
-
config: {
|
|
669
|
-
worktreePath: path.resolve(worktreePath),
|
|
670
|
-
workItemId,
|
|
671
|
-
ownerType,
|
|
672
|
-
ownerId,
|
|
673
|
-
phase,
|
|
674
|
-
producedBy,
|
|
675
|
-
redactionSecrets: [
|
|
676
|
-
...parseCompletionRedactionSecrets(process.env[completionRedactionSecretsEnv]),
|
|
677
|
-
...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
|
|
678
|
-
],
|
|
679
|
-
developCycle,
|
|
680
|
-
qaCycle,
|
|
681
|
-
debugCycle,
|
|
682
|
-
architectCycle,
|
|
683
|
-
draftCycle,
|
|
684
|
-
decomposeCycle
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
584
|
export function completionRedactionEnv(secrets) {
|
|
689
585
|
const filtered = secrets.filter((secret) => secret.length > 0);
|
|
690
586
|
return filtered.length > 0
|
|
691
587
|
? { [completionRedactionSecretsEnv]: JSON.stringify(filtered) }
|
|
692
588
|
: {};
|
|
693
589
|
}
|
|
694
|
-
async function prepareCursorCompletionToolRuntime(worktreePath, runtime) {
|
|
695
|
-
const cursorDir = path.join(worktreePath, ".cursor");
|
|
696
|
-
const configPath = path.join(cursorDir, "mcp.json");
|
|
697
|
-
const original = await fs.readFile(configPath, "utf8").then((content) => ({ existed: true, content }), () => ({ existed: false, content: "" }));
|
|
698
|
-
const existing = original.existed ? parseOptionalJsonObject(original.content, configPath) : {};
|
|
699
|
-
const servers = asMutableRecord(existing.mcpServers);
|
|
700
|
-
servers[runtime.serverName] = cursorMcpServerConfig(runtime);
|
|
701
|
-
const next = {
|
|
702
|
-
...existing,
|
|
703
|
-
mcpServers: servers
|
|
704
|
-
};
|
|
705
|
-
await fs.mkdir(cursorDir, { recursive: true });
|
|
706
|
-
await writeFileAtomic(configPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
707
|
-
return {
|
|
708
|
-
...runtime,
|
|
709
|
-
cursorMcpConfigPath: configPath,
|
|
710
|
-
cleanup: async () => {
|
|
711
|
-
if (original.existed) {
|
|
712
|
-
await writeFileAtomic(configPath, original.content);
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
await fs.rm(configPath, { force: true });
|
|
716
|
-
await fs.rmdir(cursorDir).catch(() => undefined);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
590
|
/**
|
|
722
591
|
* Claude Code takes MCP servers from `--mcp-config <file>`. The file lives in an attempt-owned
|
|
723
592
|
* temp directory (never the worktree) because its env block can carry redaction secrets, and
|
|
@@ -800,15 +669,18 @@ async function handleJsonRpcRequest(session, method, params) {
|
|
|
800
669
|
catch (error) {
|
|
801
670
|
if (isManagedAttemptTool(name))
|
|
802
671
|
throw error;
|
|
803
|
-
return completionToolRejectedResult(name, error);
|
|
672
|
+
return completionToolRejectedResult(name, error, args);
|
|
804
673
|
}
|
|
805
674
|
}
|
|
806
675
|
throw new Error(`Unsupported MCP method: ${method}`);
|
|
807
676
|
}
|
|
808
|
-
export function completionToolRejectedResult(toolName, error) {
|
|
677
|
+
export function completionToolRejectedResult(toolName, error, input) {
|
|
809
678
|
const issues = error instanceof CompletionPayloadValidationError
|
|
810
679
|
? [...error.issues]
|
|
811
680
|
: [errorMessage(error)];
|
|
681
|
+
if (input !== undefined && isEmptyToolInput(input)) {
|
|
682
|
+
issues.push(`${emptyToolInputHint} Keep long free text such as report_markdown short.`);
|
|
683
|
+
}
|
|
812
684
|
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.";
|
|
813
685
|
return {
|
|
814
686
|
content: [{
|
|
@@ -836,10 +708,14 @@ function acceptedArtifactReceipt(reference) {
|
|
|
836
708
|
},
|
|
837
709
|
};
|
|
838
710
|
}
|
|
839
|
-
function toolDefinition(name
|
|
711
|
+
function toolDefinition(name) {
|
|
840
712
|
return {
|
|
841
713
|
name,
|
|
842
|
-
description: toolDescription(
|
|
843
|
-
inputSchema:
|
|
714
|
+
description: toolDescription(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name)),
|
|
715
|
+
inputSchema: completionToolInputSchema(name)
|
|
844
716
|
};
|
|
845
717
|
}
|
|
718
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
719
|
+
export function completionToolInputSchema(name) {
|
|
720
|
+
return toolInputSchema(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name));
|
|
721
|
+
}
|
|
@@ -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;
|