@loucompanion/forge-bridge 0.2.1-dev.573a8a5fa582 → 0.2.1-dev.7171bf414613
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 +38 -2
- package/dist/bridge/bridge-state-io.d.ts +6 -2
- package/dist/bridge/bridge-state-io.js +22 -4
- package/dist/bridge/bridge.service.d.ts +10 -0
- package/dist/bridge/bridge.service.js +62 -92
- package/dist/bridge/bridge.types.d.ts +6 -0
- 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/cleanup/cleanup-wip.js +3 -3
- package/dist/cleanup/forge-owned-paths.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.js +9 -0
- package/dist/cli/cli.help.js +1 -1
- package/dist/cli/cli.service.js +3 -3
- package/dist/cli/local-config.d.ts +2 -0
- package/dist/cli/local-config.js +3 -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 +13 -0
- package/dist/runtime/host-load-child-environment.js +35 -1
- package/dist/runtime/host-load-governor-config.d.ts +23 -2
- package/dist/runtime/host-load-governor-config.js +20 -2
- package/dist/runtime/host-load-governor.d.ts +81 -1
- package/dist/runtime/host-load-governor.js +184 -15
- 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-sampler.d.ts +17 -0
- package/dist/runtime/host-load-sampler.js +24 -0
- package/dist/runtime/host-load-step-run.d.ts +37 -3
- package/dist/runtime/host-load-step-run.js +63 -7
- package/dist/runtime/host-load-test-slot.d.ts +3 -0
- package/dist/runtime/host-load-test-slot.js +19 -7
- package/dist/sandbox/runtime.d.ts +1 -2
- package/dist/sandbox/runtime.js +7 -13
- 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/managed-attempt-tools.js +6 -29
- package/dist/session/managed-build-receipt.d.ts +3 -1
- package/dist/session/managed-build-receipt.js +5 -2
- 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 +10 -5
- package/dist/session/managed-command-host-load.js +18 -14
- 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 +2 -17
- package/dist/session/phase-completion.artifacts.js +63 -165
- package/dist/session/phase-completion.d.ts +25 -2
- package/dist/session/phase-completion.helpers.js +5 -53
- package/dist/session/phase-completion.js +15 -32
- package/dist/session/phase-completion.mcp-args.js +69 -2
- 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-threads.d.ts +34 -0
- package/dist/session/phase-completion.pr-review-threads.js +90 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +215 -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 +14 -0
- package/dist/session/phase-completion.runtime.js +9 -3
- package/dist/session/phase-completion.schemas.js +12 -2
- package/dist/session/phase-completion.validation.d.ts +1 -0
- package/dist/session/phase-completion.validation.js +9 -1
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +45 -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.js +6 -5
- package/dist/session/pre-publication-process.js +3 -2
- package/dist/session/pre-publication-validation.d.ts +2 -1
- package/dist/session/pre-publication-validation.js +31 -36
- 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/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 +11 -0
- package/dist/session/provider-cli/pr-review-prompt.js +132 -0
- package/dist/session/provider-cli/pre-publication-repair.js +7 -3
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -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.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.prompts.d.ts +10 -13
- package/dist/session/provider-cli/provider-cli.prompts.js +123 -107
- 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 +7 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +14 -0
- 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 +11 -17
- package/dist/session/provider-cli/provider-cli.service.js +24 -139
- package/dist/session/sandbox-host-capacity-gate.js +28 -6
- 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 +2 -1
- package/dist/session/session.service.js +40 -95
- package/dist/session/session.types.d.ts +4 -0
- package/dist/session/session.types.js +7 -77
- package/dist/session/session.types.pr-review.d.ts +59 -0
- package/dist/session/session.types.pr-review.js +53 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/worktree.service.d.ts +22 -0
- package/dist/worktree/worktree.service.js +116 -12
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
1
|
import fs from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { redactSecrets } from "../shared/redaction/redaction.js";
|
|
5
4
|
import { assertQaSidecarJsonShape, ensureNoSymbolicLinkPathSegments, isPathUnderRoot, sha256File } from "./qa-sidecar-validation.js";
|
|
6
5
|
import { assertClaimedChangedFilesMatchPublishableDiff } from "./publishable-worktree-changes.js";
|
|
7
6
|
import { coerceJsonStringArguments } from "./mcp-argument-coercion.js";
|
|
7
|
+
import { assertStructuralFieldsUnchanged, postRedactionValidationError, publishArtifactBundleAtomic, validatePostRedaction } from "./phase-completion.artifact-bundle.js";
|
|
8
8
|
import { toolInputSchema } from "./phase-completion.schemas.js";
|
|
9
9
|
import { artifactRootFor, artifactRootForOwner, completionArtifactJsonPath, completionArtifactReportPath, decomposeGateFileNames, draftGateFileNames, phaseFiles, qaGateFileNames, decomposeStatuses, draftStatuses } from "./phase-completion.js";
|
|
10
|
-
import {
|
|
10
|
+
import { assertPrReviewMatchesRepository, prReviewReportMarkdown } from "./phase-completion.pr-review.js";
|
|
11
|
+
import { artifactOwnerFields, artifactReferenceOwnerFields, artifactOwnerRelativeRoot, defaultQaChecklist, fallbackReport, isNodeError, jsonText, normalizeArtifactPayload, normalizeCompletionStatus, normalizeQaGateArtifactPayload, normalizeQaGateStatus, normalizedString, optionalString, numberOrDefault, parseJsonObject, parseOptionalJsonObject, phaseFromToolName, qaArray, qaArtifactRelativePath, qaArtifactRelativePathForOwner, qaEvidenceSource, qaObjectArray, qaPolicyWarnings, qaEvidenceGates, qaStringArray, readOptionalFile, reportMarkdown, requireField, requiredRecord, requiredString, qaGateFromToolName, sha256, stableStringify, validateOptionalWorkItemId, validatePayloadShape, validatePrReviewPayloadShape, validateQaGatePayloadShape, validateQaScopeRecord, writeFileAtomic, asRecord } from "./phase-completion.validation.js";
|
|
11
12
|
export async function writeDecomposeGateCompletionArtifact(config, gate, toolName, input) {
|
|
12
13
|
const payload = asRecord(input, "Decompose completion payload");
|
|
13
14
|
const status = validateDecomposeGatePayload(gate, payload);
|
|
@@ -184,6 +185,9 @@ export async function writeCompletionArtifact(config, toolName, input) {
|
|
|
184
185
|
if (qaGate && qaGate !== "qa_verdict") {
|
|
185
186
|
return await writeQaGateCompletionArtifact(config, qaGate, input);
|
|
186
187
|
}
|
|
188
|
+
if (phase === "pr_review") {
|
|
189
|
+
return await writePrReviewCompletionArtifact(config, input);
|
|
190
|
+
}
|
|
187
191
|
const payload = asRecord(input, "completion payload");
|
|
188
192
|
const status = normalizeCompletionStatus(requiredString(payload, "status"), phase);
|
|
189
193
|
let validationPayload = { ...payload, status };
|
|
@@ -244,6 +248,62 @@ export async function writeCompletionArtifact(config, toolName, input) {
|
|
|
244
248
|
producedBy
|
|
245
249
|
};
|
|
246
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Writes pr-review.result.json and pr-review.report.md. This gate only records the review:
|
|
253
|
+
* Forge posts it to the pull request afterwards, so a pass ends the lane without any
|
|
254
|
+
* publication step here. `stale_head` and `blocked` are accepted terminal outcomes.
|
|
255
|
+
*/
|
|
256
|
+
async function writePrReviewCompletionArtifact(config, input) {
|
|
257
|
+
const phase = "pr_review";
|
|
258
|
+
const payload = asRecord(input, "completion payload");
|
|
259
|
+
const status = normalizeCompletionStatus(requiredString(payload, "status"), phase);
|
|
260
|
+
const validationPayload = { ...payload, status };
|
|
261
|
+
validatePrReviewPayloadShape(validationPayload, status, config.prReview);
|
|
262
|
+
validateOptionalWorkItemId(validationPayload, config.workItemId);
|
|
263
|
+
if (status === "reviewed") {
|
|
264
|
+
await assertPrReviewMatchesRepository(config.worktreePath, validationPayload, config.prReview);
|
|
265
|
+
}
|
|
266
|
+
const redactedPayload = redactSecrets(validationPayload, config.redactionSecrets ?? []);
|
|
267
|
+
assertStructuralFieldsUnchanged(validationPayload, redactedPayload);
|
|
268
|
+
validatePostRedaction(() => {
|
|
269
|
+
validatePrReviewPayloadShape(redactedPayload, status, config.prReview);
|
|
270
|
+
validateOptionalWorkItemId(redactedPayload, config.workItemId);
|
|
271
|
+
});
|
|
272
|
+
const producedBy = optionalString(redactedPayload, "produced_by")
|
|
273
|
+
?? optionalString(redactedPayload, "producedBy")
|
|
274
|
+
?? config.producedBy
|
|
275
|
+
?? "forge-completion-tool";
|
|
276
|
+
const artifactWithoutHash = normalizeArtifactPayload(redactedPayload, {
|
|
277
|
+
phase,
|
|
278
|
+
workItemId: config.workItemId,
|
|
279
|
+
ownerType: config.ownerType,
|
|
280
|
+
ownerId: config.ownerId,
|
|
281
|
+
producedBy,
|
|
282
|
+
status
|
|
283
|
+
});
|
|
284
|
+
const contentHash = sha256(stableStringify(artifactWithoutHash));
|
|
285
|
+
const artifactJson = `${JSON.stringify({ ...artifactWithoutHash, content_hash: contentHash }, null, 2)}\n`;
|
|
286
|
+
const report = optionalString(redactedPayload, "report_markdown")
|
|
287
|
+
? reportMarkdown(redactedPayload, phase, status, producedBy, contentHash)
|
|
288
|
+
: prReviewReportMarkdown(artifactWithoutHash, contentHash);
|
|
289
|
+
const artifactPath = completionArtifactJsonPath(config.worktreePath, config.workItemId, phase);
|
|
290
|
+
const reportPath = completionArtifactReportPath(config.worktreePath, config.workItemId, phase);
|
|
291
|
+
await publishArtifactBundleAtomic(path.dirname(artifactPath), [
|
|
292
|
+
{ fileName: path.basename(reportPath), content: report },
|
|
293
|
+
{ fileName: path.basename(artifactPath), content: artifactJson }
|
|
294
|
+
], path.basename(artifactPath));
|
|
295
|
+
return {
|
|
296
|
+
phase,
|
|
297
|
+
workItemId: config.workItemId,
|
|
298
|
+
...artifactReferenceOwnerFields(config),
|
|
299
|
+
repoPath: path.resolve(config.worktreePath),
|
|
300
|
+
path: artifactPath,
|
|
301
|
+
reportPath,
|
|
302
|
+
contentHash,
|
|
303
|
+
status,
|
|
304
|
+
producedBy
|
|
305
|
+
};
|
|
306
|
+
}
|
|
247
307
|
export async function writeArchitectCompletionArtifact(config, payload, status, producedBy) {
|
|
248
308
|
const ownerFields = artifactOwnerFields(config);
|
|
249
309
|
const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
|
|
@@ -738,166 +798,4 @@ export async function readCompletionArtifact(worktreePath, workItemId, phase, ow
|
|
|
738
798
|
phase
|
|
739
799
|
};
|
|
740
800
|
}
|
|
741
|
-
|
|
742
|
-
* Stages a complete phase bundle outside the live artifact directory, then
|
|
743
|
-
* publishes its canonical verdict/marker last. Consumers treat the marker as
|
|
744
|
-
* the bundle's commit point, so they can observe either the old complete bundle
|
|
745
|
-
* or the new complete bundle, never a partially written set. A failed or
|
|
746
|
-
* cancelled publication rolls every touched file back before rejecting.
|
|
747
|
-
*/
|
|
748
|
-
export async function publishArtifactBundleAtomic(artifactRoot, files, commitFileName, options = {}) {
|
|
749
|
-
validateArtifactBundleFiles(files, commitFileName);
|
|
750
|
-
throwIfPublicationCancelled(options.signal);
|
|
751
|
-
const parent = path.dirname(artifactRoot);
|
|
752
|
-
const transactionId = `${process.pid}.${crypto.randomUUID()}`;
|
|
753
|
-
const stagingRoot = path.join(parent, `.${path.basename(artifactRoot)}.${transactionId}.publish`);
|
|
754
|
-
const backupRoot = path.join(stagingRoot, ".previous");
|
|
755
|
-
const orderedFiles = [
|
|
756
|
-
...files.filter((file) => file.fileName !== commitFileName),
|
|
757
|
-
files.find((file) => file.fileName === commitFileName)
|
|
758
|
-
];
|
|
759
|
-
const backedUp = new Set();
|
|
760
|
-
const published = new Set();
|
|
761
|
-
try {
|
|
762
|
-
await fs.mkdir(parent, { recursive: true });
|
|
763
|
-
await fs.mkdir(stagingRoot, { recursive: false });
|
|
764
|
-
for (const file of orderedFiles) {
|
|
765
|
-
throwIfPublicationCancelled(options.signal);
|
|
766
|
-
const handle = await fs.open(path.join(stagingRoot, file.fileName), "wx");
|
|
767
|
-
try {
|
|
768
|
-
await handle.writeFile(file.content, { encoding: "utf8", signal: options.signal });
|
|
769
|
-
await handle.sync();
|
|
770
|
-
}
|
|
771
|
-
finally {
|
|
772
|
-
await handle.close();
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
throwIfPublicationCancelled(options.signal);
|
|
776
|
-
await fs.mkdir(artifactRoot, { recursive: true });
|
|
777
|
-
await fs.mkdir(backupRoot, { recursive: true });
|
|
778
|
-
// Hide the previous commit marker before changing any supporting file.
|
|
779
|
-
for (const fileName of [commitFileName, ...orderedFiles.map((file) => file.fileName).filter((name) => name !== commitFileName)]) {
|
|
780
|
-
const livePath = path.join(artifactRoot, fileName);
|
|
781
|
-
try {
|
|
782
|
-
await fs.rename(livePath, path.join(backupRoot, fileName));
|
|
783
|
-
backedUp.add(fileName);
|
|
784
|
-
}
|
|
785
|
-
catch (error) {
|
|
786
|
-
if (!isNodeError(error) || error.code !== "ENOENT") {
|
|
787
|
-
throw error;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
for (const [index, file] of orderedFiles.entries()) {
|
|
792
|
-
throwIfPublicationCancelled(options.signal);
|
|
793
|
-
await options.beforePublishFile?.(file.fileName, index);
|
|
794
|
-
await fs.rename(path.join(stagingRoot, file.fileName), path.join(artifactRoot, file.fileName));
|
|
795
|
-
published.add(file.fileName);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
catch (error) {
|
|
799
|
-
const rollbackErrors = [];
|
|
800
|
-
for (const file of [...orderedFiles].reverse()) {
|
|
801
|
-
if (!published.has(file.fileName))
|
|
802
|
-
continue;
|
|
803
|
-
await fs.rm(path.join(artifactRoot, file.fileName), { force: true }).catch(() => {
|
|
804
|
-
rollbackErrors.push(file.fileName);
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
// Restore the previous marker last for the same observable commit boundary.
|
|
808
|
-
const restoreOrder = [
|
|
809
|
-
...orderedFiles.filter((file) => file.fileName !== commitFileName),
|
|
810
|
-
orderedFiles.find((file) => file.fileName === commitFileName)
|
|
811
|
-
];
|
|
812
|
-
for (const file of restoreOrder) {
|
|
813
|
-
if (!backedUp.has(file.fileName))
|
|
814
|
-
continue;
|
|
815
|
-
await fs.rename(path.join(backupRoot, file.fileName), path.join(artifactRoot, file.fileName)).catch(() => {
|
|
816
|
-
rollbackErrors.push(file.fileName);
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
if (rollbackErrors.length === 0
|
|
820
|
-
&& error instanceof Error
|
|
821
|
-
&& error.message.startsWith("artifact_atomic_publish_cancelled:")) {
|
|
822
|
-
throw error;
|
|
823
|
-
}
|
|
824
|
-
const suffix = rollbackErrors.length > 0 ? " Rollback did not restore every bundle file." : "";
|
|
825
|
-
throw new Error(`artifact_atomic_publish_failure: completion artifact bundle was not published.${suffix}`, { cause: error });
|
|
826
|
-
}
|
|
827
|
-
finally {
|
|
828
|
-
await fs.rm(stagingRoot, { recursive: true, force: true }).catch(() => undefined);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
function validateArtifactBundleFiles(files, commitFileName) {
|
|
832
|
-
if (files.length === 0 || !files.some((file) => file.fileName === commitFileName)) {
|
|
833
|
-
throw new Error("artifact_atomic_publish_failure: bundle commit file is missing.");
|
|
834
|
-
}
|
|
835
|
-
const names = new Set();
|
|
836
|
-
for (const file of files) {
|
|
837
|
-
if (!file.fileName || path.basename(file.fileName) !== file.fileName || names.has(file.fileName)) {
|
|
838
|
-
throw new Error("artifact_atomic_publish_failure: bundle file names must be unique safe base names.");
|
|
839
|
-
}
|
|
840
|
-
names.add(file.fileName);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
function throwIfPublicationCancelled(signal) {
|
|
844
|
-
if (signal?.aborted) {
|
|
845
|
-
throw new Error("artifact_atomic_publish_cancelled: completion artifact bundle publication was cancelled.");
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
function validatePostRedaction(validate) {
|
|
849
|
-
try {
|
|
850
|
-
validate();
|
|
851
|
-
}
|
|
852
|
-
catch (error) {
|
|
853
|
-
throw postRedactionValidationError(error);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
function postRedactionValidationError(error) {
|
|
857
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
858
|
-
return new Error(`artifact_post_redaction_validation_failed: ${message}`, { cause: error });
|
|
859
|
-
}
|
|
860
|
-
function assertStructuralFieldsUnchanged(original, redacted) {
|
|
861
|
-
if (structuralFieldFingerprint(original) !== structuralFieldFingerprint(redacted)) {
|
|
862
|
-
// This stable code is intentionally safe for telemetry: it does not include
|
|
863
|
-
// the structural value or any candidate secret.
|
|
864
|
-
throw new Error("artifact_redaction_changed_structural_field: redaction changed a structural identifier; the bundle was not published.");
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
function structuralFieldFingerprint(value, key = "", result = []) {
|
|
868
|
-
if (Array.isArray(value)) {
|
|
869
|
-
if (isStructuralFieldKey(key) && value.every((item) => item === null || typeof item !== "object")) {
|
|
870
|
-
result.push(stableStringify(value));
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
for (const item of value)
|
|
874
|
-
structuralFieldFingerprint(item, key, result);
|
|
875
|
-
}
|
|
876
|
-
return result.join("\n");
|
|
877
|
-
}
|
|
878
|
-
if (!value || typeof value !== "object") {
|
|
879
|
-
if (isStructuralFieldKey(key))
|
|
880
|
-
result.push(stableStringify(value));
|
|
881
|
-
return result.join("\n");
|
|
882
|
-
}
|
|
883
|
-
for (const [childKey, child] of Object.entries(value)) {
|
|
884
|
-
if (isStructuralFieldKey(childKey)) {
|
|
885
|
-
result.push(`${childKey}:${stableStringify(child)}`);
|
|
886
|
-
}
|
|
887
|
-
else {
|
|
888
|
-
structuralFieldFingerprint(child, childKey, result);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
return result.join("\n");
|
|
892
|
-
}
|
|
893
|
-
function isStructuralFieldKey(key) {
|
|
894
|
-
return key === "id"
|
|
895
|
-
|| key === "before"
|
|
896
|
-
|| key === "after"
|
|
897
|
-
|| key === "from"
|
|
898
|
-
|| key === "to"
|
|
899
|
-
|| key === "tasks"
|
|
900
|
-
|| key === "phases"
|
|
901
|
-
|| /(?:^|_)(?:id|ids)$/i.test(key)
|
|
902
|
-
|| /(?:Id|Ids)$/.test(key);
|
|
903
|
-
}
|
|
801
|
+
export { publishArtifactBundleAtomic } from "./phase-completion.artifact-bundle.js";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { PrReviewOpenThreadAnchor } from "./phase-completion.pr-review-threads.js";
|
|
1
2
|
import type { RunOnceDispatchPacket } from "./session.types.js";
|
|
2
3
|
import type { WorktreeHandle } from "../worktree/worktree.types.js";
|
|
3
4
|
export { isDebugCompletionPhase } from "./phase-completion.validation.js";
|
|
4
5
|
export { readCompletionArtifact, writeCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
6
|
+
export { recordedPrReviewArtifactProblem } from "./phase-completion.pr-review.js";
|
|
7
|
+
export { prReviewContextFromDispatch } from "./phase-completion.pr-review-threads.js";
|
|
5
8
|
export * from "./phase-completion.prompts.js";
|
|
6
9
|
export * from "./phase-completion.runtime.js";
|
|
7
10
|
export * from "./phase-completion.mcp-args.js";
|
|
@@ -12,7 +15,8 @@ export type DraftCompletionPhase = "draft";
|
|
|
12
15
|
export type DecomposeCompletionPhase = "decompose";
|
|
13
16
|
export type CiRepairCompletionPhase = "ci_repair";
|
|
14
17
|
export type CommentRepairCompletionPhase = "comment_repair";
|
|
15
|
-
export type
|
|
18
|
+
export type PrReviewCompletionPhase = "pr_review";
|
|
19
|
+
export type CompletionPhase = DevelopCompletionPhase | "qa" | DebugCompletionPhase | ArchitectCompletionPhase | DraftCompletionPhase | DecomposeCompletionPhase | CiRepairCompletionPhase | CommentRepairCompletionPhase | PrReviewCompletionPhase;
|
|
16
20
|
export type QaCompletionGate = "qa_plan" | "qa_regression" | "qa_api" | "qa_manual_web" | "qa_bug_repro" | "qa_findings" | "qa_verdict";
|
|
17
21
|
export type DraftCompletionGate = "draft_intent" | "draft_repo_context" | "draft_graph_context" | "draft_product_scope" | "draft_work_order_plan" | "draft_critic" | "draft_proposal";
|
|
18
22
|
export type DecomposeCompletionGate = "decompose_subject_intake" | "decompose_context_review" | "decompose_breakdown_strategy" | "decompose_child_items" | "decompose_dependency_graph" | "decompose_critic" | "decompose_proposal";
|
|
@@ -39,6 +43,21 @@ export interface CompletionToolRuntimeOptions {
|
|
|
39
43
|
*/
|
|
40
44
|
readonly managedToolsOnly?: boolean;
|
|
41
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* What Forge knows about the pull request under review, handed to the pr_review completion
|
|
48
|
+
* tool so it can reject a review bound to the wrong head or citing threads the dispatch never
|
|
49
|
+
* listed. Every field is optional: whatever is absent is verified against the worktree instead.
|
|
50
|
+
*/
|
|
51
|
+
export interface PrReviewCompletionContext {
|
|
52
|
+
readonly headSha?: string;
|
|
53
|
+
readonly baseSha?: string;
|
|
54
|
+
/** Thread ids the dispatch lists as prior review threads. Enforced only when non-empty. */
|
|
55
|
+
readonly threadIds?: readonly string[];
|
|
56
|
+
/** Unresolved threads still on the new side of the diff: a finding inside one's lines repeats it. */
|
|
57
|
+
readonly openThreads?: readonly PrReviewOpenThreadAnchor[];
|
|
58
|
+
/** Unresolved threads the reviewer was shown: each must be reported in prior_threads. */
|
|
59
|
+
readonly requiredThreadIds?: readonly string[];
|
|
60
|
+
}
|
|
42
61
|
export interface CompletionToolServerConfig {
|
|
43
62
|
readonly worktreePath: string;
|
|
44
63
|
readonly workItemId: string;
|
|
@@ -53,6 +72,7 @@ export interface CompletionToolServerConfig {
|
|
|
53
72
|
readonly architectCycle?: boolean;
|
|
54
73
|
readonly draftCycle?: boolean;
|
|
55
74
|
readonly decomposeCycle?: boolean;
|
|
75
|
+
readonly prReview?: PrReviewCompletionContext;
|
|
56
76
|
readonly managedToolsOnly?: boolean;
|
|
57
77
|
}
|
|
58
78
|
export interface CompletionToolCallResult {
|
|
@@ -77,7 +97,7 @@ export interface CompletionToolCallResult {
|
|
|
77
97
|
readonly allowed: boolean;
|
|
78
98
|
readonly reason: string;
|
|
79
99
|
};
|
|
80
|
-
readonly nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready" | "provider_checks_ready";
|
|
100
|
+
readonly nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready" | "provider_checks_ready" | "pr_review_complete";
|
|
81
101
|
readonly nextInstruction: string;
|
|
82
102
|
};
|
|
83
103
|
}
|
|
@@ -127,6 +147,9 @@ export declare const qaScopeAuthorities: Set<string>;
|
|
|
127
147
|
export declare const qaScopeConfidence: Set<string>;
|
|
128
148
|
export declare const qaScopeFields: Set<string>;
|
|
129
149
|
export declare const phaseFiles: Record<CompletionPhase, CompletionArtifactFiles>;
|
|
150
|
+
/** Statuses `forge.complete_pr_review` accepts; each one ends the review lane. */
|
|
151
|
+
export declare const prReviewStatuses: readonly ["reviewed", "stale_head", "blocked"];
|
|
152
|
+
export type PrReviewStatus = (typeof prReviewStatuses)[number];
|
|
130
153
|
export declare function completionPhaseFromDispatch(dispatch: RunOnceDispatchPacket): CompletionPhase;
|
|
131
154
|
export declare function normalizeCompletionPhase(value: string | null | undefined): CompletionPhase;
|
|
132
155
|
export declare function usesDevelopCycleCompletion(dispatch: RunOnceDispatchPacket): boolean;
|
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { debugCompletionPhaseOrder, debugGateToolNames, decomposeCompletionGateOrder, decomposeGateToolNames, draftCompletionGateOrder, draftGateToolNames, qaCompletionGateOrder, qaGateToolNames, resolvedFindingStatuses } from "./phase-completion.js";
|
|
6
6
|
import { structuredTypeHint } from "./mcp-argument-coercion.js";
|
|
7
|
+
import { completionPhaseFromAlias, singleGatePhaseFromToolName } from "./phase-completion.phase-aliases.js";
|
|
7
8
|
export function normalizeArtifactPayload(payload, defaults) {
|
|
8
9
|
const normalized = stripUndefined({ ...payload });
|
|
9
10
|
delete normalized.report_markdown;
|
|
@@ -61,38 +62,7 @@ ${summary}
|
|
|
61
62
|
}
|
|
62
63
|
export function parseStrictCompletionPhase(value) {
|
|
63
64
|
const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
|
|
64
|
-
|
|
65
|
-
if (debugPhase) {
|
|
66
|
-
return debugPhase;
|
|
67
|
-
}
|
|
68
|
-
if (normalized === "implementation" || normalized === "implement" || normalized === "develop") {
|
|
69
|
-
return "implementation";
|
|
70
|
-
}
|
|
71
|
-
if (normalized === "self_review" || normalized === "selfreview" || normalized === "review") {
|
|
72
|
-
return "self_review";
|
|
73
|
-
}
|
|
74
|
-
if (normalized === "validate" || normalized === "validation") {
|
|
75
|
-
return "validation";
|
|
76
|
-
}
|
|
77
|
-
if (normalized === "qa" || normalized === "quality_assurance" || normalized === "qualityassurance") {
|
|
78
|
-
return "qa";
|
|
79
|
-
}
|
|
80
|
-
if (normalized === "architect" || normalized === "architect_plan" || normalized === "planning" || normalized === "plan") {
|
|
81
|
-
return "architect";
|
|
82
|
-
}
|
|
83
|
-
if (normalized === "draft" || normalized === "drafting" || normalized === "draft_work_order") {
|
|
84
|
-
return "draft";
|
|
85
|
-
}
|
|
86
|
-
if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
|
|
87
|
-
return "decompose";
|
|
88
|
-
}
|
|
89
|
-
if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
|
|
90
|
-
return "ci_repair";
|
|
91
|
-
}
|
|
92
|
-
if (normalized === "comment_repair" || normalized === "pr_comments" || normalized === "repair_pr_comments") {
|
|
93
|
-
return "comment_repair";
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
65
|
+
return normalizeDebugCompletionPhase(normalized) ?? completionPhaseFromAlias(normalized);
|
|
96
66
|
}
|
|
97
67
|
export function normalizeDebugCompletionPhase(value) {
|
|
98
68
|
const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
|
|
@@ -147,27 +117,9 @@ export function parseCompletionRedactionSecrets(raw) {
|
|
|
147
117
|
}
|
|
148
118
|
}
|
|
149
119
|
export function phaseFromToolName(toolName) {
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
if (normalized === "forge.complete_self_review" || normalized === "complete_self_review") {
|
|
155
|
-
return "self_review";
|
|
156
|
-
}
|
|
157
|
-
if (normalized === "forge.complete_validation" || normalized === "complete_validation") {
|
|
158
|
-
return "validation";
|
|
159
|
-
}
|
|
160
|
-
if (normalized === "forge.complete_qa" || normalized === "complete_qa") {
|
|
161
|
-
return "qa";
|
|
162
|
-
}
|
|
163
|
-
if (normalized === "forge.complete_architect_plan" || normalized === "complete_architect_plan") {
|
|
164
|
-
return "architect";
|
|
165
|
-
}
|
|
166
|
-
if (normalized === "forge.complete_ci_repair" || normalized === "complete_ci_repair") {
|
|
167
|
-
return "ci_repair";
|
|
168
|
-
}
|
|
169
|
-
if (normalized === "forge.complete_comment_repair" || normalized === "complete_comment_repair") {
|
|
170
|
-
return "comment_repair";
|
|
120
|
+
const singleGatePhase = singleGatePhaseFromToolName(toolName);
|
|
121
|
+
if (singleGatePhase) {
|
|
122
|
+
return singleGatePhase;
|
|
171
123
|
}
|
|
172
124
|
if (draftGateFromToolName(toolName)) {
|
|
173
125
|
return "draft";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { completionPhaseFromAlias } from "./phase-completion.phase-aliases.js";
|
|
2
3
|
import { artifactOwnerDirectory, isDebugCompletionPhase, normalizeDebugCompletionPhase, safePathSegment } from "./phase-completion.validation.js";
|
|
3
4
|
export { isDebugCompletionPhase } from "./phase-completion.validation.js";
|
|
4
5
|
export { readCompletionArtifact, writeCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
6
|
+
export { recordedPrReviewArtifactProblem } from "./phase-completion.pr-review.js";
|
|
7
|
+
export { prReviewContextFromDispatch } from "./phase-completion.pr-review-threads.js";
|
|
5
8
|
export * from "./phase-completion.prompts.js";
|
|
6
9
|
export * from "./phase-completion.runtime.js";
|
|
7
10
|
export * from "./phase-completion.mcp-args.js";
|
|
@@ -210,42 +213,20 @@ export const phaseFiles = {
|
|
|
210
213
|
comment_repair: {
|
|
211
214
|
jsonFileName: "comment-repair.handoff.json",
|
|
212
215
|
reportFileName: "comment-repair.report.md"
|
|
216
|
+
},
|
|
217
|
+
pr_review: {
|
|
218
|
+
jsonFileName: "pr-review.result.json",
|
|
219
|
+
reportFileName: "pr-review.report.md"
|
|
213
220
|
}
|
|
214
221
|
};
|
|
222
|
+
/** Statuses `forge.complete_pr_review` accepts; each one ends the review lane. */
|
|
223
|
+
export const prReviewStatuses = ["reviewed", "stale_head", "blocked"];
|
|
215
224
|
export function completionPhaseFromDispatch(dispatch) {
|
|
216
225
|
return normalizeCompletionPhase(dispatch.cycleRun.phase || dispatch.execution.lane || dispatch.execution.role);
|
|
217
226
|
}
|
|
218
227
|
export function normalizeCompletionPhase(value) {
|
|
219
228
|
const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
|
|
220
|
-
|
|
221
|
-
if (debugPhase) {
|
|
222
|
-
return debugPhase;
|
|
223
|
-
}
|
|
224
|
-
if (normalized === "self_review" || normalized === "selfreview" || normalized === "review") {
|
|
225
|
-
return "self_review";
|
|
226
|
-
}
|
|
227
|
-
if (normalized === "validate" || normalized === "validation") {
|
|
228
|
-
return "validation";
|
|
229
|
-
}
|
|
230
|
-
if (normalized === "qa" || normalized === "quality_assurance" || normalized === "qualityassurance") {
|
|
231
|
-
return "qa";
|
|
232
|
-
}
|
|
233
|
-
if (normalized === "architect" || normalized === "architect_plan" || normalized === "planning" || normalized === "plan") {
|
|
234
|
-
return "architect";
|
|
235
|
-
}
|
|
236
|
-
if (normalized === "draft" || normalized === "drafting" || normalized === "draft_work_order") {
|
|
237
|
-
return "draft";
|
|
238
|
-
}
|
|
239
|
-
if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
|
|
240
|
-
return "decompose";
|
|
241
|
-
}
|
|
242
|
-
if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
|
|
243
|
-
return "ci_repair";
|
|
244
|
-
}
|
|
245
|
-
if (normalized === "comment_repair" || normalized === "pr_comments" || normalized === "repair_pr_comments") {
|
|
246
|
-
return "comment_repair";
|
|
247
|
-
}
|
|
248
|
-
return "implementation";
|
|
229
|
+
return normalizeDebugCompletionPhase(normalized) ?? completionPhaseFromAlias(normalized) ?? "implementation";
|
|
249
230
|
}
|
|
250
231
|
export function usesDevelopCycleCompletion(dispatch) {
|
|
251
232
|
const kind = dispatch.cycleRun.kind.trim().toLowerCase();
|
|
@@ -300,9 +281,11 @@ export function completionToolNamesForPhase(phase) {
|
|
|
300
281
|
? "complete_ci_repair"
|
|
301
282
|
: phase === "comment_repair"
|
|
302
283
|
? "complete_comment_repair"
|
|
303
|
-
: phase === "
|
|
304
|
-
? "
|
|
305
|
-
: "
|
|
284
|
+
: phase === "pr_review"
|
|
285
|
+
? "complete_pr_review"
|
|
286
|
+
: phase === "architect"
|
|
287
|
+
? "complete_architect_plan"
|
|
288
|
+
: "complete_qa";
|
|
306
289
|
return [`forge.${base}`, base];
|
|
307
290
|
}
|
|
308
291
|
export function completionToolNamesForQaGate(gate) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
3
3
|
import { completionRedactionSecretsEnv, } from "./phase-completion.js";
|
|
4
|
+
import { decodePrReviewOpenThread, encodePrReviewOpenThread, } from "./phase-completion.pr-review-threads.js";
|
|
4
5
|
import { isDebugCompletionPhase, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseStrictCompletionPhase, } from "./phase-completion.validation.js";
|
|
5
6
|
// The `forge-bridge mcp` command line: the arguments the Bridge launches its completion-tool server
|
|
6
7
|
// with, and the parsing that server applies to them.
|
|
@@ -41,6 +42,7 @@ export function buildCompletionToolServerArgs(config) {
|
|
|
41
42
|
if (config.managedToolsOnly) {
|
|
42
43
|
args.push("--managed-tools-only");
|
|
43
44
|
}
|
|
45
|
+
args.push(...prReviewServerArgs(config.prReview));
|
|
44
46
|
return args;
|
|
45
47
|
}
|
|
46
48
|
const completionMcpFlags = {
|
|
@@ -62,6 +64,7 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
62
64
|
let phase = "implementation";
|
|
63
65
|
let ownerType;
|
|
64
66
|
const values = {};
|
|
67
|
+
const prReview = { threadIds: [], openThreads: [], requiredThreadIds: [] };
|
|
65
68
|
const flags = {
|
|
66
69
|
developCycle: false,
|
|
67
70
|
qaCycle: false,
|
|
@@ -79,6 +82,9 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
79
82
|
else if (Object.hasOwn(completionMcpValues, arg)) {
|
|
80
83
|
values[completionMcpValues[arg]] = argv[++index];
|
|
81
84
|
}
|
|
85
|
+
else if (applyPrReviewArg(prReview, arg, () => argv[++index])) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
82
88
|
else if (arg === "--owner-type") {
|
|
83
89
|
ownerType = normalizedOwnerType(argv[++index]);
|
|
84
90
|
if (!ownerType) {
|
|
@@ -89,7 +95,7 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
89
95
|
const rawPhase = argv[++index];
|
|
90
96
|
const parsedPhase = parseStrictCompletionPhase(rawPhase);
|
|
91
97
|
if (!parsedPhase) {
|
|
92
|
-
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." };
|
|
98
|
+
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, comment-repair, pr-review, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
93
99
|
}
|
|
94
100
|
phase = parsedPhase;
|
|
95
101
|
}
|
|
@@ -111,11 +117,72 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
111
117
|
producedBy,
|
|
112
118
|
redactionSecrets: redactionSecretsFromEnvironment(),
|
|
113
119
|
...cycles,
|
|
114
|
-
...(managedToolsOnly ? { managedToolsOnly } : {})
|
|
120
|
+
...(managedToolsOnly ? { managedToolsOnly } : {}),
|
|
121
|
+
...prReviewConfig(prReview)
|
|
115
122
|
};
|
|
116
123
|
const modeError = completionMcpModeError(config);
|
|
117
124
|
return modeError ? { ok: false, error: modeError } : { ok: true, config };
|
|
118
125
|
}
|
|
126
|
+
/** Applies one pr_review dispatch-context flag; false when the flag is not one of them. */
|
|
127
|
+
function applyPrReviewArg(state, arg, next) {
|
|
128
|
+
switch (arg) {
|
|
129
|
+
case "--pr-review-head":
|
|
130
|
+
state.headSha = next()?.trim() || undefined;
|
|
131
|
+
return true;
|
|
132
|
+
case "--pr-review-base":
|
|
133
|
+
state.baseSha = next()?.trim() || undefined;
|
|
134
|
+
return true;
|
|
135
|
+
case "--pr-review-thread":
|
|
136
|
+
pushTrimmed(state.threadIds, next());
|
|
137
|
+
return true;
|
|
138
|
+
case "--pr-review-open-thread": {
|
|
139
|
+
const anchor = decodePrReviewOpenThread(next());
|
|
140
|
+
if (anchor)
|
|
141
|
+
state.openThreads.push(anchor);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
case "--pr-review-required-thread":
|
|
145
|
+
pushTrimmed(state.requiredThreadIds, next());
|
|
146
|
+
return true;
|
|
147
|
+
default:
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function prReviewServerArgs(prReview) {
|
|
152
|
+
if (!prReview)
|
|
153
|
+
return [];
|
|
154
|
+
const args = [];
|
|
155
|
+
if (prReview.headSha)
|
|
156
|
+
args.push("--pr-review-head", prReview.headSha);
|
|
157
|
+
if (prReview.baseSha)
|
|
158
|
+
args.push("--pr-review-base", prReview.baseSha);
|
|
159
|
+
for (const threadId of prReview.threadIds ?? [])
|
|
160
|
+
args.push("--pr-review-thread", threadId);
|
|
161
|
+
for (const thread of prReview.openThreads ?? [])
|
|
162
|
+
args.push("--pr-review-open-thread", encodePrReviewOpenThread(thread));
|
|
163
|
+
for (const threadId of prReview.requiredThreadIds ?? [])
|
|
164
|
+
args.push("--pr-review-required-thread", threadId);
|
|
165
|
+
return args;
|
|
166
|
+
}
|
|
167
|
+
function pushTrimmed(values, value) {
|
|
168
|
+
const trimmed = value?.trim();
|
|
169
|
+
if (trimmed)
|
|
170
|
+
values.push(trimmed);
|
|
171
|
+
}
|
|
172
|
+
function prReviewConfig(state) {
|
|
173
|
+
const { headSha, baseSha, threadIds, openThreads, requiredThreadIds } = state;
|
|
174
|
+
if (!headSha && !baseSha && threadIds.length === 0)
|
|
175
|
+
return {};
|
|
176
|
+
return {
|
|
177
|
+
prReview: {
|
|
178
|
+
headSha,
|
|
179
|
+
baseSha,
|
|
180
|
+
threadIds: threadIds.length > 0 ? threadIds : undefined,
|
|
181
|
+
...(openThreads.length > 0 ? { openThreads } : {}),
|
|
182
|
+
...(requiredThreadIds.length > 0 ? { requiredThreadIds } : {})
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
119
186
|
/** The secrets the server redacts from what it records: the Bridge's list and the attempt database capability. */
|
|
120
187
|
function redactionSecretsFromEnvironment() {
|
|
121
188
|
return [
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CompletionPhase } from "./phase-completion.js";
|
|
2
|
+
/** Resolves an already-normalized (trimmed, lower-case, underscore) phase alias, or null. */
|
|
3
|
+
export declare function completionPhaseFromAlias(normalized: string): CompletionPhase | null;
|
|
4
|
+
/** Resolves a fixed single-gate completion tool name (with or without the forge. prefix), or null. */
|
|
5
|
+
export declare function singleGatePhaseFromToolName(toolName: string): CompletionPhase | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Table-driven phase aliases and tool names. Debug phases are resolved separately because they
|
|
2
|
+
// have their own normalizer. Aliases are disjoint, so lookup order never changes a result.
|
|
3
|
+
const phaseAliases = [
|
|
4
|
+
["implementation", ["implementation", "implement", "develop"]],
|
|
5
|
+
["self_review", ["self_review", "selfreview", "review"]],
|
|
6
|
+
["validation", ["validate", "validation"]],
|
|
7
|
+
["qa", ["qa", "quality_assurance", "qualityassurance"]],
|
|
8
|
+
["architect", ["architect", "architect_plan", "planning", "plan"]],
|
|
9
|
+
["draft", ["draft", "drafting", "draft_work_order"]],
|
|
10
|
+
["decompose", ["decompose", "decomposition", "work_order_decomposition", "feature_decomposition"]],
|
|
11
|
+
["ci_repair", ["ci_repair", "pr_checks", "repair_pr_checks"]],
|
|
12
|
+
["comment_repair", ["comment_repair", "pr_comments", "repair_pr_comments"]],
|
|
13
|
+
["pr_review", ["pr_review", "prreview", "pull_request_review"]]
|
|
14
|
+
];
|
|
15
|
+
/** Resolves an already-normalized (trimmed, lower-case, underscore) phase alias, or null. */
|
|
16
|
+
export function completionPhaseFromAlias(normalized) {
|
|
17
|
+
for (const [phase, aliases] of phaseAliases) {
|
|
18
|
+
if (aliases.includes(normalized)) {
|
|
19
|
+
return phase;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const phaseToolNames = [
|
|
25
|
+
["implementation", "complete_implementation"],
|
|
26
|
+
["self_review", "complete_self_review"],
|
|
27
|
+
["validation", "complete_validation"],
|
|
28
|
+
["qa", "complete_qa"],
|
|
29
|
+
["architect", "complete_architect_plan"],
|
|
30
|
+
["ci_repair", "complete_ci_repair"],
|
|
31
|
+
["comment_repair", "complete_comment_repair"],
|
|
32
|
+
["pr_review", "complete_pr_review"]
|
|
33
|
+
];
|
|
34
|
+
/** Resolves a fixed single-gate completion tool name (with or without the forge. prefix), or null. */
|
|
35
|
+
export function singleGatePhaseFromToolName(toolName) {
|
|
36
|
+
const normalized = toolName.trim().toLowerCase();
|
|
37
|
+
for (const [phase, base] of phaseToolNames) {
|
|
38
|
+
if (normalized === `forge.${base}` || normalized === base) {
|
|
39
|
+
return phase;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prReviewToolInputSchema(): unknown;
|