@loucompanion/forge-bridge 0.1.3-dev.2c3feac3af65 → 0.1.3-dev.ab8510b71f9b
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/dist/session/phase-completion.js +13 -1
- package/dist/session/provider-cli/provider-cli.service.js +34 -0
- package/dist/session/session.types.d.ts +17 -0
- package/dist/session/session.types.js +39 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/worktree.service.d.ts +2 -1
- package/dist/worktree/worktree.service.js +32 -12
- package/package.json +1 -1
|
@@ -501,7 +501,7 @@ Required order:
|
|
|
501
501
|
5. Follow the returned dependency-graph instruction, validate keys/dependencies/order, then call \`forge.complete_decompose_dependency_graph(...)\`.
|
|
502
502
|
6. Follow the returned critic instruction, critique scope, DAG safety, manual reconciliation risk, and missing acceptance detail, then call \`forge.complete_decompose_critic(...)\`.
|
|
503
503
|
7. Follow the returned proposal instruction, then call \`forge.complete_decompose_proposal(...)\` with final JSON in \`proposal_json\`.
|
|
504
|
-
The final proposal tool writes \`decompose.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. The proposal_json object must contain summary, optional blockedReason, and candidates. Work Order-to-Feature candidates may include \`estimated_qa_scope\`; Feature-to-Story candidates should include \`qa_scope\` with schema_version 1.`;
|
|
504
|
+
The final proposal tool writes \`decompose.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. The proposal_json object must contain summary, optional blockedReason, and candidates. Work Order-to-Feature candidates may include \`estimated_qa_scope\`; Feature-to-Story candidates should include \`qa_scope\` with schema_version 1 plus scheduleIndex, waveIndex, expectedOutput, handoffSummary, and dependencyReason for dependency handoff.`;
|
|
505
505
|
}
|
|
506
506
|
export function completionPromptForDebugCycle(currentGate = "debug_repro") {
|
|
507
507
|
return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
|
|
@@ -2137,6 +2137,18 @@ function decomposeGateToolInputSchema(gate, baseProperties) {
|
|
|
2137
2137
|
acceptanceCriteria: { type: "string" },
|
|
2138
2138
|
planningPacket: { type: "string" },
|
|
2139
2139
|
sortOrder: { type: "number" },
|
|
2140
|
+
scheduleIndex: { type: "number", description: "Feature-to-Story total schedule order for dependency-safe execution." },
|
|
2141
|
+
schedule_index: { type: "number", description: "Snake_case alias for scheduleIndex." },
|
|
2142
|
+
waveIndex: { type: "number", description: "Feature-to-Story parallel wave number." },
|
|
2143
|
+
wave_index: { type: "number", description: "Snake_case alias for waveIndex." },
|
|
2144
|
+
featureScheduleIndex: { type: "number", description: "Optional ordering within the Feature." },
|
|
2145
|
+
feature_schedule_index: { type: "number", description: "Snake_case alias for featureScheduleIndex." },
|
|
2146
|
+
expectedOutput: { type: "string", description: "Durable output this Story should produce for dependents." },
|
|
2147
|
+
expected_output: { type: "string", description: "Snake_case alias for expectedOutput." },
|
|
2148
|
+
handoffSummary: { type: "string", description: "How dependent Stories should consume this Story output." },
|
|
2149
|
+
handoff_summary: { type: "string", description: "Snake_case alias for handoffSummary." },
|
|
2150
|
+
dependencyReason: { type: "string", description: "Why this Story depends on its dependsOn predecessors." },
|
|
2151
|
+
dependency_reason: { type: "string", description: "Snake_case alias for dependencyReason." },
|
|
2140
2152
|
points: { type: "number" },
|
|
2141
2153
|
dependsOn: { type: "array", items: { type: "string" } },
|
|
2142
2154
|
estimatedQaScope: qaScopeSchema("Work Order-to-Feature planning QA estimate. This is not dispatch-authoritative QA scope."),
|
|
@@ -2363,6 +2363,7 @@ Work item: ${dispatch.workItem.id} — ${dispatch.workItem.title}
|
|
|
2363
2363
|
Plan only. Do not implement source changes, do not create Develop phase artifacts, and do not mark the spec approved.
|
|
2364
2364
|
Read injected Forge context under .forge plus the repository shape, then produce a repo-grounded implementation DAG with task tests, phase gates, final QA coverage, and a pending-approval spec.
|
|
2365
2365
|
Implementation DAG tasks are Develop child tasks only: include focused repo/product implementation changes. Do not create child Develop tasks for parent-story QA, sign-off, materialized child inventory, child-count evidence, parent plan artifact checks, or final integrated acceptance proof; put those checks in qa_plan.final_qa.
|
|
2366
|
+
${architectDependencyInstruction(dispatch)}
|
|
2366
2367
|
${architectRevisionInstruction(dispatch)}
|
|
2367
2368
|
Forge owns protocol files: write Architect artifacts only through the completion MCP tool.
|
|
2368
2369
|
|
|
@@ -2370,6 +2371,39 @@ ${completionPromptForPhase("architect")}
|
|
|
2370
2371
|
|
|
2371
2372
|
Finish only after calling forge.complete_architect_plan with implementation_plan, qa_plan, status, summary, and report/report_markdown.`;
|
|
2372
2373
|
}
|
|
2374
|
+
function architectDependencyInstruction(dispatch) {
|
|
2375
|
+
if (!dispatch.architectDependencies || dispatch.architectDependencies.prerequisites.length === 0) {
|
|
2376
|
+
return "";
|
|
2377
|
+
}
|
|
2378
|
+
const dependencies = dispatch.architectDependencies.prerequisites
|
|
2379
|
+
.map((dependency, index) => {
|
|
2380
|
+
const schedule = dependency.scheduleIndex === null || dependency.scheduleIndex === undefined
|
|
2381
|
+
? "schedule index unknown"
|
|
2382
|
+
: `schedule index ${dependency.scheduleIndex}`;
|
|
2383
|
+
const wave = dependency.waveIndex === null || dependency.waveIndex === undefined
|
|
2384
|
+
? "wave unknown"
|
|
2385
|
+
: `wave ${dependency.waveIndex}`;
|
|
2386
|
+
const featureSchedule = dependency.featureScheduleIndex === null || dependency.featureScheduleIndex === undefined
|
|
2387
|
+
? ""
|
|
2388
|
+
: `, feature schedule ${dependency.featureScheduleIndex}`;
|
|
2389
|
+
const outputSource = dependency.pullRequestNumber === null || dependency.pullRequestNumber === undefined
|
|
2390
|
+
? `manual completion on ${dependency.targetBranch}`
|
|
2391
|
+
: `merged PR ${dependency.pullRequestNumber} into ${dependency.targetBranch}`;
|
|
2392
|
+
return `${index + 1}. ${dependency.title} (${dependency.storyId}, ${schedule}, ${wave}${featureSchedule})
|
|
2393
|
+
- Expected output: ${dependency.expectedOutput ?? "Predecessor output recorded by Work Order dependency graph."}
|
|
2394
|
+
- Handoff summary: ${dependency.handoffSummary ?? "Use the predecessor implementation as the foundation for this story."}
|
|
2395
|
+
- Dependency reason: ${dependency.dependencyReason ?? "This story depends on predecessor output."}
|
|
2396
|
+
- Output source: ${outputSource}`;
|
|
2397
|
+
})
|
|
2398
|
+
.join("\n");
|
|
2399
|
+
return `
|
|
2400
|
+
Dependency Schedule Context:
|
|
2401
|
+
This story is scheduled after predecessor work that should already be available on base branch ${dispatch.architectDependencies.baseBranch}.
|
|
2402
|
+
|
|
2403
|
+
${dependencies}
|
|
2404
|
+
|
|
2405
|
+
Use this predecessor output as foundation. Do not redesign or recreate predecessor scope. If the expected output is unavailable in the checkout/base branch, stop and report dependency_output_unavailable.`;
|
|
2406
|
+
}
|
|
2373
2407
|
function architectRevisionInstruction(dispatch) {
|
|
2374
2408
|
if (!dispatch.architectRevision) {
|
|
2375
2409
|
return "";
|
|
@@ -16,6 +16,7 @@ export interface RunOnceDispatchPacket {
|
|
|
16
16
|
readonly qaScope?: DispatchQaScope | null;
|
|
17
17
|
readonly qaRework?: DispatchQaReworkContext | null;
|
|
18
18
|
readonly architectRevision?: DispatchArchitectRevisionContext | null;
|
|
19
|
+
readonly architectDependencies?: DispatchArchitectDependencyContext | null;
|
|
19
20
|
readonly storyDevelop?: DispatchStoryDevelopContext | null;
|
|
20
21
|
readonly storyQa?: DispatchStoryQaContext | null;
|
|
21
22
|
readonly draft?: DispatchDraftPrompt | null;
|
|
@@ -69,6 +70,22 @@ export interface DispatchArchitectRevisionContext {
|
|
|
69
70
|
readonly priorContentHash: string;
|
|
70
71
|
readonly feedback: string;
|
|
71
72
|
}
|
|
73
|
+
export interface DispatchArchitectDependencyContext {
|
|
74
|
+
readonly baseBranch: string;
|
|
75
|
+
readonly prerequisites: readonly DispatchArchitectDependencyItemContext[];
|
|
76
|
+
}
|
|
77
|
+
export interface DispatchArchitectDependencyItemContext {
|
|
78
|
+
readonly storyId: string;
|
|
79
|
+
readonly title: string;
|
|
80
|
+
readonly scheduleIndex?: number | null;
|
|
81
|
+
readonly waveIndex?: number | null;
|
|
82
|
+
readonly featureScheduleIndex?: number | null;
|
|
83
|
+
readonly expectedOutput?: string | null;
|
|
84
|
+
readonly handoffSummary?: string | null;
|
|
85
|
+
readonly dependencyReason?: string | null;
|
|
86
|
+
readonly pullRequestNumber?: number | null;
|
|
87
|
+
readonly targetBranch: string;
|
|
88
|
+
}
|
|
72
89
|
export interface DispatchStoryDevelopContext {
|
|
73
90
|
readonly storyWorkItemId: string;
|
|
74
91
|
readonly planId: string;
|
|
@@ -23,6 +23,7 @@ export function parseRunOnceDispatchPacket(value) {
|
|
|
23
23
|
qaScope: parseQaScope(packet.qaScope ?? packet.qa_scope),
|
|
24
24
|
qaRework: parseQaRework(packet.qaRework),
|
|
25
25
|
architectRevision: parseArchitectRevision(packet.architectRevision),
|
|
26
|
+
architectDependencies: parseArchitectDependencies(packet.architectDependencies),
|
|
26
27
|
storyDevelop: parseStoryDevelop(packet.storyDevelop),
|
|
27
28
|
storyQa: parseStoryQa(packet.storyQa),
|
|
28
29
|
draft: parseDraftPrompt(packet.draft)
|
|
@@ -282,6 +283,34 @@ function parseArchitectRevision(value) {
|
|
|
282
283
|
feedback: requiredString(revision, "feedback")
|
|
283
284
|
};
|
|
284
285
|
}
|
|
286
|
+
function parseArchitectDependencies(value) {
|
|
287
|
+
if (value === undefined || value === null) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const context = asObject(value, "architectDependencies");
|
|
291
|
+
const prerequisites = context.prerequisites;
|
|
292
|
+
if (!Array.isArray(prerequisites)) {
|
|
293
|
+
throw new Error("architectDependencies.prerequisites must be an array.");
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
baseBranch: requiredString(context, "baseBranch").trim(),
|
|
297
|
+
prerequisites: prerequisites.map((entry, index) => {
|
|
298
|
+
const prerequisite = asObject(entry, `architectDependencies.prerequisites[${index}]`);
|
|
299
|
+
return {
|
|
300
|
+
storyId: requiredString(prerequisite, "storyId").trim(),
|
|
301
|
+
title: requiredString(prerequisite, "title").trim(),
|
|
302
|
+
scheduleIndex: optionalNonNegativeInteger(prerequisite, "scheduleIndex"),
|
|
303
|
+
waveIndex: optionalNonNegativeInteger(prerequisite, "waveIndex"),
|
|
304
|
+
featureScheduleIndex: optionalNonNegativeInteger(prerequisite, "featureScheduleIndex"),
|
|
305
|
+
expectedOutput: optionalString(prerequisite, "expectedOutput"),
|
|
306
|
+
handoffSummary: optionalString(prerequisite, "handoffSummary"),
|
|
307
|
+
dependencyReason: optionalString(prerequisite, "dependencyReason"),
|
|
308
|
+
pullRequestNumber: optionalPositiveInteger(prerequisite, "pullRequestNumber"),
|
|
309
|
+
targetBranch: requiredString(prerequisite, "targetBranch").trim()
|
|
310
|
+
};
|
|
311
|
+
})
|
|
312
|
+
};
|
|
313
|
+
}
|
|
285
314
|
function parseStoryDevelop(value) {
|
|
286
315
|
if (value === undefined || value === null) {
|
|
287
316
|
return null;
|
|
@@ -481,6 +510,16 @@ function optionalPositiveInteger(source, key) {
|
|
|
481
510
|
}
|
|
482
511
|
return value;
|
|
483
512
|
}
|
|
513
|
+
function optionalNonNegativeInteger(source, key) {
|
|
514
|
+
const value = source[key];
|
|
515
|
+
if (value === undefined || value === null) {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
519
|
+
throw new Error(`${key} must be a non-negative integer when provided.`);
|
|
520
|
+
}
|
|
521
|
+
return value;
|
|
522
|
+
}
|
|
484
523
|
function requiredNumber(source, key) {
|
|
485
524
|
const value = source[key];
|
|
486
525
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const forgeBridgeVersion = "0.1.3-dev.
|
|
1
|
+
export declare const forgeBridgeVersion = "0.1.3-dev.ab8510b71f9b";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const forgeBridgeVersion = "0.1.3-dev.
|
|
1
|
+
export const forgeBridgeVersion = "0.1.3-dev.ab8510b71f9b";
|
|
@@ -9,7 +9,8 @@ export declare class GitWorktreeService implements WorktreeService {
|
|
|
9
9
|
private resolveRepoPath;
|
|
10
10
|
private findExistingRepoPath;
|
|
11
11
|
private resolveMatchingRepo;
|
|
12
|
-
private
|
|
12
|
+
private resolveBaseStartPoint;
|
|
13
|
+
private resetWorktreeToBase;
|
|
13
14
|
private gitRefExists;
|
|
14
15
|
private currentBranch;
|
|
15
16
|
private ensureGitIdentity;
|
|
@@ -14,7 +14,7 @@ export class GitWorktreeService {
|
|
|
14
14
|
const baseBranch = normalizeBranchName(request.baseBranch, "develop");
|
|
15
15
|
const repoPath = await this.resolveRepoPath(request.repo, allowedRoot, baseBranch);
|
|
16
16
|
await this.ensureGitIdentity(repoPath);
|
|
17
|
-
await this.
|
|
17
|
+
const baseStartPoint = await this.resolveBaseStartPoint(repoPath, baseBranch);
|
|
18
18
|
const shortId = request.workItem.id.replace(/-/g, "").slice(0, 12);
|
|
19
19
|
const kind = safeSegment(request.workItem.kind, "work-item");
|
|
20
20
|
const fallbackWorktreeKey = `${kind}/${shortId}`;
|
|
@@ -30,7 +30,7 @@ export class GitWorktreeService {
|
|
|
30
30
|
const exists = await directoryExists(worktreePath);
|
|
31
31
|
let resolvedWorktreePath;
|
|
32
32
|
if (!exists) {
|
|
33
|
-
await this.git.run(repoPath, ["worktree", "add", "-B", branchName, worktreePath,
|
|
33
|
+
await this.git.run(repoPath, ["worktree", "add", "-B", branchName, worktreePath, baseStartPoint]);
|
|
34
34
|
resolvedWorktreePath = await resolveExistingDirectoryPath(worktreePath);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
@@ -42,6 +42,9 @@ export class GitWorktreeService {
|
|
|
42
42
|
if (currentBranch !== branchName) {
|
|
43
43
|
throw new Error(`Existing worktree ${resolvedWorktreePath} is on branch '${currentBranch}', expected '${branchName}'.`);
|
|
44
44
|
}
|
|
45
|
+
if (shouldResetExistingWorktree(request)) {
|
|
46
|
+
await this.resetWorktreeToBase(resolvedWorktreePath, baseStartPoint);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
await this.ensureGitIdentity(resolvedWorktreePath);
|
|
47
50
|
await clearRunArtifactRoots(resolvedWorktreePath, request);
|
|
@@ -164,21 +167,27 @@ export class GitWorktreeService {
|
|
|
164
167
|
const resolved = await resolveExistingDirectoryPath(candidate);
|
|
165
168
|
return isSubPath(allowedRoot, resolved) ? resolved : null;
|
|
166
169
|
}
|
|
167
|
-
async
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
170
|
+
async resolveBaseStartPoint(repoPath, baseBranch) {
|
|
171
|
+
const localRef = `refs/heads/${baseBranch}`;
|
|
172
|
+
const remoteRef = `refs/remotes/origin/${baseBranch}`;
|
|
171
173
|
const origin = await this.git.run(repoPath, ["remote", "get-url", "origin"]).catch(() => "");
|
|
172
|
-
if (origin.trim().length
|
|
173
|
-
|
|
174
|
+
if (origin.trim().length > 0) {
|
|
175
|
+
const fetched = await this.git.run(repoPath, ["fetch", "--prune", "origin"])
|
|
176
|
+
.then(() => true)
|
|
177
|
+
.catch(() => false);
|
|
178
|
+
if (fetched && await this.gitRefExists(repoPath, remoteRef)) {
|
|
179
|
+
return remoteRef;
|
|
180
|
+
}
|
|
174
181
|
}
|
|
175
|
-
await this.
|
|
176
|
-
|
|
177
|
-
await this.git.run(repoPath, ["branch", baseBranch, `refs/remotes/origin/${baseBranch}`]);
|
|
178
|
-
return;
|
|
182
|
+
if (await this.gitRefExists(repoPath, localRef)) {
|
|
183
|
+
return localRef;
|
|
179
184
|
}
|
|
180
185
|
throw new Error(`Base branch '${baseBranch}' was not found locally or on origin.`);
|
|
181
186
|
}
|
|
187
|
+
async resetWorktreeToBase(worktreePath, baseStartPoint) {
|
|
188
|
+
await this.git.run(worktreePath, ["reset", "--hard", baseStartPoint]);
|
|
189
|
+
await this.git.run(worktreePath, ["clean", "-fd"]);
|
|
190
|
+
}
|
|
182
191
|
async gitRefExists(repoPath, gitRef) {
|
|
183
192
|
return this.git.run(repoPath, ["show-ref", "--verify", "--quiet", gitRef]).then(() => true).catch(() => false);
|
|
184
193
|
}
|
|
@@ -269,6 +278,17 @@ function normalizeOwnerType(value) {
|
|
|
269
278
|
}
|
|
270
279
|
return null;
|
|
271
280
|
}
|
|
281
|
+
function shouldResetExistingWorktree(request) {
|
|
282
|
+
const lane = request.lane.trim().toLowerCase();
|
|
283
|
+
const phase = request.phase.trim().toLowerCase().replace(/-/g, "_");
|
|
284
|
+
if (lane === "develop" && (phase === "implementation" || phase === "self_review" || phase === "validation")) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (lane === "qa" || phase === "qa") {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
272
292
|
function qaReworkPacketFileName(packetPath) {
|
|
273
293
|
const normalized = packetPath.trim().replace(/\\/g, "/");
|
|
274
294
|
const fileName = normalized.split("/").filter(Boolean).at(-1) ?? "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.3-dev.
|
|
3
|
+
"version": "0.1.3-dev.ab8510b71f9b",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|