@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f8fb73715e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
- package/dist/bridge/bridge-chat-provider-command.js +230 -0
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +15 -0
- package/dist/bridge/bridge-state-io.js +68 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +102 -14
- package/dist/bridge/bridge.service.js +499 -471
- package/dist/bridge/bridge.types.d.ts +37 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +31 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +11 -0
- package/dist/cleanup/forge-owned-paths.js +62 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +75 -13
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +161 -228
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +18 -1
- package/dist/cli/local-config.js +67 -5
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +72 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +40 -0
- package/dist/runtime/host-load-child-environment.js +110 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +82 -0
- package/dist/runtime/host-load-governor-config.js +104 -0
- package/dist/runtime/host-load-governor.d.ts +273 -0
- package/dist/runtime/host-load-governor.js +831 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +92 -2
- package/dist/runtime/host-load-sampler.js +166 -8
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +107 -0
- package/dist/runtime/host-load-step-run.js +158 -0
- package/dist/runtime/host-load-test-slot.d.ts +46 -0
- package/dist/runtime/host-load-test-slot.js +100 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +39 -6
- package/dist/runtime/host-runtime-lease.d.ts +101 -6
- package/dist/runtime/host-runtime-lease.js +408 -294
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +101 -2
- package/dist/runtime/host-runtime-promotion.js +355 -14
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +11 -3
- package/dist/sandbox/runtime.js +53 -20
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +204 -141
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +52 -0
- package/dist/session/managed-command-host-load.js +87 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +9 -17
- package/dist/session/phase-completion.artifacts.js +158 -190
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +31 -2
- package/dist/session/phase-completion.helpers.js +18 -65
- package/dist/session/phase-completion.js +19 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +20 -1
- package/dist/session/phase-completion.runtime.d.ts +13 -12
- package/dist/session/phase-completion.runtime.js +113 -214
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +219 -232
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +58 -94
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +112 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +32 -19
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +39 -22
- package/dist/session/pre-publication-validation.js +241 -207
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +281 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +41 -432
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
- package/dist/session/provider-cli/provider-cli.service.js +127 -317
- package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +279 -0
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +16 -2
- package/dist/session/session.service.js +208 -155
- package/dist/session/session.types.d.ts +8 -0
- package/dist/session/session.types.js +13 -83
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +23 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +58 -5
- package/dist/worktree/worktree.service.js +237 -161
- package/dist/worktree/worktree.types.d.ts +54 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { RunOnceDispatchPacket } from "./session.types.js";
|
|
2
|
+
import { type CompletionToolCallResult, type CompletionToolRuntime, type CompletionToolRuntimeOptions, type CompletionToolServerConfig, type PrReviewCompletionContext } from "./phase-completion.js";
|
|
2
3
|
import { type ManagedAttemptToolResult } from "./managed-attempt-tools.js";
|
|
3
4
|
export declare function prepareCompletionToolRuntime(options: CompletionToolRuntimeOptions): Promise<CompletionToolRuntime>;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The pull-request facts the pr_review completion tool holds a review to: the admitted head
|
|
7
|
+
* (prReview.headSha, never the live pull request head) and the prior review threads the
|
|
8
|
+
* dispatch lists, and the dispatched base commit the payload's base_sha must resolve to.
|
|
9
|
+
*/
|
|
10
|
+
export declare function prReviewContextFromDispatch(dispatch: RunOnceDispatchPacket): PrReviewCompletionContext | undefined;
|
|
5
11
|
export declare function codexMcpConfigArgs(runtime: CompletionToolRuntime): readonly string[];
|
|
6
12
|
export declare function cursorMcpServerConfig(runtime: CompletionToolRuntime): unknown;
|
|
7
13
|
export declare function claudeMcpServerConfig(runtime: CompletionToolRuntime): unknown;
|
|
@@ -17,7 +23,7 @@ export declare class CompletionToolServerSession {
|
|
|
17
23
|
constructor(config: CompletionToolServerConfig);
|
|
18
24
|
get instructions(): string;
|
|
19
25
|
toolDefinitions(): readonly unknown[];
|
|
20
|
-
callTool(toolName: string,
|
|
26
|
+
callTool(toolName: string, rawInput: unknown): Promise<CompletionToolCallResult | ManagedAttemptToolResult>;
|
|
21
27
|
private callDecomposeGateTool;
|
|
22
28
|
private callDraftGateTool;
|
|
23
29
|
private callDebugGateTool;
|
|
@@ -28,7 +34,7 @@ export declare class CompletionToolServerSession {
|
|
|
28
34
|
private advanceAfterQaGate;
|
|
29
35
|
private advanceAfterDebugGate;
|
|
30
36
|
}
|
|
31
|
-
export declare function completionToolRuntimeEnvironment(runtimeEnvironment?: Readonly<Record<string, string>>, nativeTestPostgresFallbackPath?: string | null): Readonly<Record<string, string>>;
|
|
37
|
+
export declare function completionToolRuntimeEnvironment(runtimeEnvironment?: Readonly<Record<string, string>>, nativeTestPostgresFallbackPath?: string | null, hostLoadEnvironment?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
32
38
|
/**
|
|
33
39
|
* A solution-wide Forge test is long enough that a generic provider shell can
|
|
34
40
|
* expire while VSTest is still healthy. On managed host attempts, only the
|
|
@@ -38,12 +44,7 @@ export declare function completionToolRuntimeEnvironment(runtimeEnvironment?: Re
|
|
|
38
44
|
*/
|
|
39
45
|
export declare function assertManagedQaRegressionEvidence(input: unknown, receipts: readonly Readonly<Record<string, unknown>>[]): void;
|
|
40
46
|
export declare function runCompletionMcpServer(config: CompletionToolServerConfig): Promise<void>;
|
|
41
|
-
export declare function parseCompletionMcpArgs(argv: readonly string[]): {
|
|
42
|
-
readonly ok: true;
|
|
43
|
-
readonly config: CompletionToolServerConfig;
|
|
44
|
-
} | {
|
|
45
|
-
readonly ok: false;
|
|
46
|
-
readonly error: string;
|
|
47
|
-
};
|
|
48
47
|
export declare function completionRedactionEnv(secrets: readonly string[]): Readonly<Record<string, string>>;
|
|
49
|
-
export declare function completionToolRejectedResult(toolName: string, error: unknown): Readonly<Record<string, unknown>>;
|
|
48
|
+
export declare function completionToolRejectedResult(toolName: string, error: unknown, input?: unknown): Readonly<Record<string, unknown>>;
|
|
49
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
50
|
+
export declare function completionToolInputSchema(name: string): unknown;
|
|
@@ -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,67 +27,53 @@ 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),
|
|
41
|
+
prReview: phase === "pr_review" ? prReviewContextFromDispatch(options.dispatch) : undefined
|
|
34
42
|
});
|
|
35
43
|
const runtime = {
|
|
36
44
|
serverName: toolServerName,
|
|
37
45
|
command: process.execPath,
|
|
38
46
|
args: [forgeBridgeCliBinPath(), ...mcpArgs],
|
|
39
|
-
env: completionToolRuntimeEnvironment(options.runtimeEnvironment, configuredNativeTestPostgresFallbackPath()),
|
|
47
|
+
env: completionToolRuntimeEnvironment(options.runtimeEnvironment, configuredNativeTestPostgresFallbackPath(), options.hostLoadEnvironment),
|
|
40
48
|
cleanup: async () => undefined
|
|
41
49
|
};
|
|
42
50
|
const provider = options.dispatch.execution.provider.trim().toLowerCase();
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
// Provider phases refuse these at entry (admitUserConfigIsolatedProvider, provider-cli.runtime.ts);
|
|
52
|
+
// this guards any other caller before the Claude MCP config is written.
|
|
53
|
+
if (!isProviderUserConfigIsolated(provider)) {
|
|
54
|
+
throw providerUserConfigIsolationUnsupported(options.dispatch.execution.provider);
|
|
45
55
|
}
|
|
46
56
|
if (provider === "claude") {
|
|
47
57
|
return await prepareClaudeCompletionToolRuntime(runtime);
|
|
48
58
|
}
|
|
49
59
|
return runtime;
|
|
50
60
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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");
|
|
61
|
+
/**
|
|
62
|
+
* The pull-request facts the pr_review completion tool holds a review to: the admitted head
|
|
63
|
+
* (prReview.headSha, never the live pull request head) and the prior review threads the
|
|
64
|
+
* dispatch lists, and the dispatched base commit the payload's base_sha must resolve to.
|
|
65
|
+
*/
|
|
66
|
+
export function prReviewContextFromDispatch(dispatch) {
|
|
67
|
+
const prReview = dispatch.prReview;
|
|
68
|
+
if (!prReview) {
|
|
69
|
+
return undefined;
|
|
84
70
|
}
|
|
85
|
-
|
|
71
|
+
const threadIds = prReview.priorThreads.map((thread) => thread.threadId);
|
|
72
|
+
return {
|
|
73
|
+
headSha: prReview.headSha.trim() || undefined,
|
|
74
|
+
baseSha: prReview.baseSha.trim() || undefined,
|
|
75
|
+
threadIds: threadIds.length > 0 ? threadIds : undefined
|
|
76
|
+
};
|
|
86
77
|
}
|
|
87
78
|
export function codexMcpConfigArgs(runtime) {
|
|
88
79
|
const prefix = `mcp_servers.${runtime.serverName}`;
|
|
@@ -131,6 +122,10 @@ export function completionToolNamesForServer(config) {
|
|
|
131
122
|
? completionToolNamesForPhase("architect")
|
|
132
123
|
: completionToolNamesForPhase(config.phase);
|
|
133
124
|
}
|
|
125
|
+
const managedToolsOnlyInstructions = "Forge serves only its managed-attempt tools in this turn: "
|
|
126
|
+
+ "forge.start_managed_verification, forge.start_managed_command, forge.wait_managed_command, forge.get_managed_command, "
|
|
127
|
+
+ "forge.run_managed_command and forge.reset_generated_outputs. No completion tool is available; the phase's completion "
|
|
128
|
+
+ "artifacts are already recorded and must stay as they are.";
|
|
134
129
|
export class CompletionToolServerSession {
|
|
135
130
|
config;
|
|
136
131
|
currentPhase;
|
|
@@ -144,36 +139,46 @@ export class CompletionToolServerSession {
|
|
|
144
139
|
this.currentPhase = config.phase;
|
|
145
140
|
}
|
|
146
141
|
get instructions() {
|
|
147
|
-
return this.config.
|
|
148
|
-
?
|
|
149
|
-
: this.config.
|
|
150
|
-
?
|
|
151
|
-
: this.config.
|
|
152
|
-
?
|
|
153
|
-
: this.config.
|
|
154
|
-
?
|
|
155
|
-
: this.config.
|
|
156
|
-
?
|
|
157
|
-
:
|
|
142
|
+
return this.config.managedToolsOnly
|
|
143
|
+
? managedToolsOnlyInstructions
|
|
144
|
+
: this.config.decomposeCycle
|
|
145
|
+
? completionPromptForDecomposeCycle(this.currentDecomposeGate)
|
|
146
|
+
: this.config.draftCycle
|
|
147
|
+
? completionPromptForDraftCycle(this.currentDraftGate)
|
|
148
|
+
: this.config.debugCycle
|
|
149
|
+
? completionPromptForDebugCycle(asDebugCompletionPhase(this.currentPhase))
|
|
150
|
+
: this.config.qaCycle
|
|
151
|
+
? completionPromptForQaCycle(this.currentQaGate, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId))
|
|
152
|
+
: this.config.developCycle
|
|
153
|
+
? completionPromptForDevelopCycle(this.currentPhase)
|
|
154
|
+
: completionPromptForPhase(this.currentPhase, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId));
|
|
158
155
|
}
|
|
159
156
|
toolDefinitions() {
|
|
160
|
-
const completionTools =
|
|
157
|
+
const completionTools = this.config.managedToolsOnly
|
|
158
|
+
? []
|
|
159
|
+
: completionToolNamesForServer(this.config).map(toolDefinition);
|
|
161
160
|
return managedAttemptToolsAvailable()
|
|
162
161
|
? [...completionTools, ...managedAttemptToolNames.map(managedAttemptToolDefinition)]
|
|
163
162
|
: completionTools;
|
|
164
163
|
}
|
|
165
|
-
async callTool(toolName,
|
|
164
|
+
async callTool(toolName, rawInput) {
|
|
166
165
|
if (isManagedAttemptTool(toolName)) {
|
|
167
166
|
if (!managedAttemptToolsAvailable()) {
|
|
168
167
|
throw new Error("Forge managed-attempt tools require an active managed host runtime.");
|
|
169
168
|
}
|
|
170
|
-
const
|
|
169
|
+
const managedInput = coerceJsonStringArguments(rawInput, managedAttemptToolInputSchema(toolName));
|
|
170
|
+
const result = await callManagedAttemptTool(toolName, managedInput, this.config.worktreePath);
|
|
171
171
|
if (Array.isArray(result.structuredContent.command)) {
|
|
172
172
|
this.managedCommandReceipts.push(result.structuredContent);
|
|
173
173
|
}
|
|
174
174
|
return result;
|
|
175
175
|
}
|
|
176
|
+
if (this.config.managedToolsOnly) {
|
|
177
|
+
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.`);
|
|
178
|
+
}
|
|
176
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));
|
|
177
182
|
if (this.completed) {
|
|
178
183
|
throw new Error("Forge completion cycle is already complete; no more completion calls are accepted.");
|
|
179
184
|
}
|
|
@@ -195,7 +200,8 @@ export class CompletionToolServerSession {
|
|
|
195
200
|
const completedPhase = this.currentPhase;
|
|
196
201
|
const reference = await writeCompletionArtifact({ ...this.config, phase: completedPhase }, toolName, input);
|
|
197
202
|
const status = reference.status.trim().toLowerCase();
|
|
198
|
-
|
|
203
|
+
// pr_review accepts reviewed, stale_head and blocked; each ends the lane, and an invalid payload throws above.
|
|
204
|
+
const pass = completedPhase === "pr_review" || status === "pass";
|
|
199
205
|
const nextPhase = pass
|
|
200
206
|
? this.advanceAfterPass(completedPhase)
|
|
201
207
|
: completedPhase;
|
|
@@ -270,15 +276,26 @@ export class CompletionToolServerSession {
|
|
|
270
276
|
const completedGate = this.currentDraftGate;
|
|
271
277
|
const reference = await writeDraftGateCompletionArtifact(this.config, completedGate, toolName, input);
|
|
272
278
|
const status = reference.status.trim().toLowerCase();
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
279
|
+
// Only a pass completes a Draft gate; needs_revision, needs_rework, and blocked keep the same
|
|
280
|
+
// gate selected so it is retried, never skipped.
|
|
281
|
+
const pass = status === "pass";
|
|
282
|
+
const nextGate = pass ? this.advanceAfterDraftGate(completedGate) : completedGate;
|
|
283
|
+
const nextPhase = pass ? (nextGate ? "draft" : "sign_off_ready") : "draft";
|
|
284
|
+
const nextInstruction = completionToolNextInstructionForDraftGate(completedGate, status, pass ? nextGate : null);
|
|
276
285
|
return {
|
|
277
286
|
content: [{ type: "text", text: `Forge recorded ${completedGate} artifact ${path.relative(reference.repoPath, reference.path)} (${reference.status}, ${reference.contentHash}). ${nextInstruction}` }],
|
|
278
287
|
structuredContent: {
|
|
279
288
|
...reference,
|
|
280
289
|
...acceptedArtifactReceipt(reference),
|
|
281
|
-
gate: {
|
|
290
|
+
gate: {
|
|
291
|
+
phase: "draft",
|
|
292
|
+
draftGate: completedGate,
|
|
293
|
+
status,
|
|
294
|
+
allowed: pass,
|
|
295
|
+
reason: !pass
|
|
296
|
+
? `${completedGate} artifact recorded with status ${status}; rework is required before continuing.`
|
|
297
|
+
: nextGate ? `${completedGate} artifact accepted; continue to ${nextGate}.` : `Draft proposal artifact accepted with status ${status}.`
|
|
298
|
+
},
|
|
282
299
|
nextPhase,
|
|
283
300
|
nextInstruction
|
|
284
301
|
}
|
|
@@ -367,6 +384,10 @@ export class CompletionToolServerSession {
|
|
|
367
384
|
};
|
|
368
385
|
}
|
|
369
386
|
advanceAfterPass(phase) {
|
|
387
|
+
if (phase === "pr_review") {
|
|
388
|
+
this.completed = true;
|
|
389
|
+
return "pr_review_complete";
|
|
390
|
+
}
|
|
370
391
|
if (phase === "qa") {
|
|
371
392
|
this.completed = true;
|
|
372
393
|
return "sign_off_ready";
|
|
@@ -458,18 +479,25 @@ const completionToolRuntimeEnvironmentNames = [
|
|
|
458
479
|
"TMP",
|
|
459
480
|
"TEMP",
|
|
460
481
|
];
|
|
461
|
-
export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestPostgresFallbackPath) {
|
|
462
|
-
if (!runtimeEnvironment)
|
|
463
|
-
return {};
|
|
482
|
+
export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestPostgresFallbackPath, hostLoadEnvironment) {
|
|
464
483
|
const env = {};
|
|
484
|
+
// Without a runtime environment the server gets nothing from it, but it still
|
|
485
|
+
// joins the host ledger when the bridge handed it the governor's variables.
|
|
486
|
+
if (!runtimeEnvironment && !hostLoadEnvironment)
|
|
487
|
+
return env;
|
|
465
488
|
for (const name of completionToolRuntimeEnvironmentNames) {
|
|
466
|
-
const value = runtimeEnvironment[name]?.trim();
|
|
489
|
+
const value = runtimeEnvironment?.[name]?.trim();
|
|
467
490
|
if (value)
|
|
468
491
|
env[name] = value;
|
|
469
492
|
}
|
|
493
|
+
// The host load governor's flag, state root and tuning: managed commands join its ledger.
|
|
494
|
+
for (const [name, value] of Object.entries(hostLoadEnvironment ?? {})) {
|
|
495
|
+
if (isHostLoadChildEnvironmentName(name) && value.trim())
|
|
496
|
+
env[name] = value.trim();
|
|
497
|
+
}
|
|
470
498
|
// Managed verification reads the operator's native test cluster only through
|
|
471
|
-
// this explicit path
|
|
472
|
-
if (nativeTestPostgresFallbackPath) {
|
|
499
|
+
// this explicit path; the file's `use` decides whether Docker comes first.
|
|
500
|
+
if (runtimeEnvironment && nativeTestPostgresFallbackPath) {
|
|
473
501
|
env[nativeTestPostgresFallbackConfigEnvironment] = nativeTestPostgresFallbackPath;
|
|
474
502
|
}
|
|
475
503
|
return env;
|
|
@@ -576,148 +604,12 @@ export async function runCompletionMcpServer(config) {
|
|
|
576
604
|
}
|
|
577
605
|
});
|
|
578
606
|
}
|
|
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
607
|
export function completionRedactionEnv(secrets) {
|
|
689
608
|
const filtered = secrets.filter((secret) => secret.length > 0);
|
|
690
609
|
return filtered.length > 0
|
|
691
610
|
? { [completionRedactionSecretsEnv]: JSON.stringify(filtered) }
|
|
692
611
|
: {};
|
|
693
612
|
}
|
|
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
613
|
/**
|
|
722
614
|
* Claude Code takes MCP servers from `--mcp-config <file>`. The file lives in an attempt-owned
|
|
723
615
|
* temp directory (never the worktree) because its env block can carry redaction secrets, and
|
|
@@ -800,15 +692,18 @@ async function handleJsonRpcRequest(session, method, params) {
|
|
|
800
692
|
catch (error) {
|
|
801
693
|
if (isManagedAttemptTool(name))
|
|
802
694
|
throw error;
|
|
803
|
-
return completionToolRejectedResult(name, error);
|
|
695
|
+
return completionToolRejectedResult(name, error, args);
|
|
804
696
|
}
|
|
805
697
|
}
|
|
806
698
|
throw new Error(`Unsupported MCP method: ${method}`);
|
|
807
699
|
}
|
|
808
|
-
export function completionToolRejectedResult(toolName, error) {
|
|
700
|
+
export function completionToolRejectedResult(toolName, error, input) {
|
|
809
701
|
const issues = error instanceof CompletionPayloadValidationError
|
|
810
702
|
? [...error.issues]
|
|
811
703
|
: [errorMessage(error)];
|
|
704
|
+
if (input !== undefined && isEmptyToolInput(input)) {
|
|
705
|
+
issues.push(`${emptyToolInputHint} Keep long free text such as report_markdown short.`);
|
|
706
|
+
}
|
|
812
707
|
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
708
|
return {
|
|
814
709
|
content: [{
|
|
@@ -836,10 +731,14 @@ function acceptedArtifactReceipt(reference) {
|
|
|
836
731
|
},
|
|
837
732
|
};
|
|
838
733
|
}
|
|
839
|
-
function toolDefinition(name
|
|
734
|
+
function toolDefinition(name) {
|
|
840
735
|
return {
|
|
841
736
|
name,
|
|
842
|
-
description: toolDescription(
|
|
843
|
-
inputSchema:
|
|
737
|
+
description: toolDescription(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name)),
|
|
738
|
+
inputSchema: completionToolInputSchema(name)
|
|
844
739
|
};
|
|
845
740
|
}
|
|
741
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
742
|
+
export function completionToolInputSchema(name) {
|
|
743
|
+
return toolInputSchema(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name));
|
|
744
|
+
}
|
|
@@ -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>;
|