forge-cc 0.1.41 → 1.0.1

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.
Files changed (203) hide show
  1. package/README.md +454 -338
  2. package/dist/cli.js +194 -935
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config/loader.d.ts +1 -1
  5. package/dist/config/loader.js +49 -56
  6. package/dist/config/loader.js.map +1 -1
  7. package/dist/config/schema.d.ts +37 -125
  8. package/dist/config/schema.js +13 -28
  9. package/dist/config/schema.js.map +1 -1
  10. package/dist/doctor.d.ts +10 -0
  11. package/dist/doctor.js +148 -0
  12. package/dist/doctor.js.map +1 -0
  13. package/dist/gates/index.d.ts +14 -12
  14. package/dist/gates/index.js +53 -105
  15. package/dist/gates/index.js.map +1 -1
  16. package/dist/gates/lint-gate.d.ts +2 -2
  17. package/dist/gates/lint-gate.js +60 -66
  18. package/dist/gates/lint-gate.js.map +1 -1
  19. package/dist/gates/tests-gate.d.ts +2 -4
  20. package/dist/gates/tests-gate.js +75 -203
  21. package/dist/gates/tests-gate.js.map +1 -1
  22. package/dist/gates/types-gate.d.ts +2 -2
  23. package/dist/gates/types-gate.js +53 -59
  24. package/dist/gates/types-gate.js.map +1 -1
  25. package/dist/linear/client.d.ts +31 -108
  26. package/dist/linear/client.js +88 -388
  27. package/dist/linear/client.js.map +1 -1
  28. package/dist/linear/sync.d.ts +15 -0
  29. package/dist/linear/sync.js +102 -0
  30. package/dist/linear/sync.js.map +1 -0
  31. package/dist/runner/loop.d.ts +4 -0
  32. package/dist/runner/loop.js +168 -0
  33. package/dist/runner/loop.js.map +1 -0
  34. package/dist/runner/prompt.d.ts +14 -0
  35. package/dist/runner/prompt.js +59 -0
  36. package/dist/runner/prompt.js.map +1 -0
  37. package/dist/runner/update.d.ts +1 -0
  38. package/dist/runner/update.js +72 -0
  39. package/dist/runner/update.js.map +1 -0
  40. package/dist/server.d.ts +6 -2
  41. package/dist/server.js +43 -101
  42. package/dist/server.js.map +1 -1
  43. package/dist/setup.d.ts +5 -0
  44. package/dist/setup.js +208 -0
  45. package/dist/setup.js.map +1 -0
  46. package/dist/state/cache.d.ts +3 -0
  47. package/dist/state/cache.js +23 -0
  48. package/dist/state/cache.js.map +1 -0
  49. package/dist/state/status.d.ts +66 -0
  50. package/dist/state/status.js +96 -0
  51. package/dist/state/status.js.map +1 -0
  52. package/dist/types.d.ts +46 -114
  53. package/dist/worktree/manager.d.ts +6 -103
  54. package/dist/worktree/manager.js +25 -296
  55. package/dist/worktree/manager.js.map +1 -1
  56. package/hooks/pre-commit-verify.js +109 -109
  57. package/package.json +5 -3
  58. package/skills/forge-go.md +20 -13
  59. package/skills/forge-setup.md +149 -388
  60. package/skills/forge-spec.md +367 -342
  61. package/skills/forge-triage.md +179 -133
  62. package/skills/forge-update.md +87 -93
  63. package/dist/gates/codex-gate.d.ts +0 -51
  64. package/dist/gates/codex-gate.js +0 -121
  65. package/dist/gates/codex-gate.js.map +0 -1
  66. package/dist/gates/prd-gate.d.ts +0 -7
  67. package/dist/gates/prd-gate.js +0 -193
  68. package/dist/gates/prd-gate.js.map +0 -1
  69. package/dist/gates/remediation.d.ts +0 -46
  70. package/dist/gates/remediation.js +0 -423
  71. package/dist/gates/remediation.js.map +0 -1
  72. package/dist/gates/review-gate.d.ts +0 -16
  73. package/dist/gates/review-gate.js +0 -479
  74. package/dist/gates/review-gate.js.map +0 -1
  75. package/dist/gates/runtime-gate.d.ts +0 -5
  76. package/dist/gates/runtime-gate.js +0 -99
  77. package/dist/gates/runtime-gate.js.map +0 -1
  78. package/dist/gates/test-analysis.d.ts +0 -21
  79. package/dist/gates/test-analysis.js +0 -394
  80. package/dist/gates/test-analysis.js.map +0 -1
  81. package/dist/gates/visual-capture.d.ts +0 -24
  82. package/dist/gates/visual-capture.js +0 -144
  83. package/dist/gates/visual-capture.js.map +0 -1
  84. package/dist/gates/visual-gate.d.ts +0 -18
  85. package/dist/gates/visual-gate.js +0 -234
  86. package/dist/gates/visual-gate.js.map +0 -1
  87. package/dist/gates/visual-reviewer.d.ts +0 -11
  88. package/dist/gates/visual-reviewer.js +0 -211
  89. package/dist/gates/visual-reviewer.js.map +0 -1
  90. package/dist/go/auto-chain.d.ts +0 -136
  91. package/dist/go/auto-chain.js +0 -389
  92. package/dist/go/auto-chain.js.map +0 -1
  93. package/dist/go/executor.d.ts +0 -137
  94. package/dist/go/executor.js +0 -447
  95. package/dist/go/executor.js.map +0 -1
  96. package/dist/go/finalize.d.ts +0 -108
  97. package/dist/go/finalize.js +0 -331
  98. package/dist/go/finalize.js.map +0 -1
  99. package/dist/go/linear-sync-cli.d.ts +0 -55
  100. package/dist/go/linear-sync-cli.js +0 -192
  101. package/dist/go/linear-sync-cli.js.map +0 -1
  102. package/dist/go/linear-sync.d.ts +0 -112
  103. package/dist/go/linear-sync.js +0 -375
  104. package/dist/go/linear-sync.js.map +0 -1
  105. package/dist/go/prd-queue.d.ts +0 -43
  106. package/dist/go/prd-queue.js +0 -67
  107. package/dist/go/prd-queue.js.map +0 -1
  108. package/dist/go/prd-selector.d.ts +0 -57
  109. package/dist/go/prd-selector.js +0 -101
  110. package/dist/go/prd-selector.js.map +0 -1
  111. package/dist/go/verify-loop.d.ts +0 -64
  112. package/dist/go/verify-loop.js +0 -327
  113. package/dist/go/verify-loop.js.map +0 -1
  114. package/dist/hooks/pre-commit.d.ts +0 -5
  115. package/dist/hooks/pre-commit.js +0 -75
  116. package/dist/hooks/pre-commit.js.map +0 -1
  117. package/dist/linear/issues.d.ts +0 -22
  118. package/dist/linear/issues.js +0 -51
  119. package/dist/linear/issues.js.map +0 -1
  120. package/dist/linear/milestones.d.ts +0 -11
  121. package/dist/linear/milestones.js +0 -32
  122. package/dist/linear/milestones.js.map +0 -1
  123. package/dist/linear/projects.d.ts +0 -16
  124. package/dist/linear/projects.js +0 -51
  125. package/dist/linear/projects.js.map +0 -1
  126. package/dist/reporter/human.d.ts +0 -7
  127. package/dist/reporter/human.js +0 -93
  128. package/dist/reporter/human.js.map +0 -1
  129. package/dist/reporter/json.d.ts +0 -2
  130. package/dist/reporter/json.js +0 -4
  131. package/dist/reporter/json.js.map +0 -1
  132. package/dist/setup/structural-templates.d.ts +0 -12
  133. package/dist/setup/structural-templates.js +0 -288
  134. package/dist/setup/structural-templates.js.map +0 -1
  135. package/dist/setup/templates.d.ts +0 -17
  136. package/dist/setup/templates.js +0 -109
  137. package/dist/setup/templates.js.map +0 -1
  138. package/dist/setup/test-planner.d.ts +0 -38
  139. package/dist/setup/test-planner.js +0 -91
  140. package/dist/setup/test-planner.js.map +0 -1
  141. package/dist/setup/test-scaffold.d.ts +0 -31
  142. package/dist/setup/test-scaffold.js +0 -209
  143. package/dist/setup/test-scaffold.js.map +0 -1
  144. package/dist/setup/test-templates.d.ts +0 -37
  145. package/dist/setup/test-templates.js +0 -313
  146. package/dist/setup/test-templates.js.map +0 -1
  147. package/dist/spec/generator.d.ts +0 -34
  148. package/dist/spec/generator.js +0 -227
  149. package/dist/spec/generator.js.map +0 -1
  150. package/dist/spec/interview.d.ts +0 -142
  151. package/dist/spec/interview.js +0 -287
  152. package/dist/spec/interview.js.map +0 -1
  153. package/dist/spec/linear-sync.d.ts +0 -48
  154. package/dist/spec/linear-sync.js +0 -125
  155. package/dist/spec/linear-sync.js.map +0 -1
  156. package/dist/spec/scanner.d.ts +0 -79
  157. package/dist/spec/scanner.js +0 -566
  158. package/dist/spec/scanner.js.map +0 -1
  159. package/dist/spec/templates.d.ts +0 -375
  160. package/dist/spec/templates.js +0 -95
  161. package/dist/spec/templates.js.map +0 -1
  162. package/dist/state/prd-status.d.ts +0 -62
  163. package/dist/state/prd-status.js +0 -122
  164. package/dist/state/prd-status.js.map +0 -1
  165. package/dist/state/reader.d.ts +0 -7
  166. package/dist/state/reader.js +0 -43
  167. package/dist/state/reader.js.map +0 -1
  168. package/dist/state/writer.d.ts +0 -21
  169. package/dist/state/writer.js +0 -106
  170. package/dist/state/writer.js.map +0 -1
  171. package/dist/team/consensus.d.ts +0 -28
  172. package/dist/team/consensus.js +0 -130
  173. package/dist/team/consensus.js.map +0 -1
  174. package/dist/team/index.d.ts +0 -4
  175. package/dist/team/index.js +0 -5
  176. package/dist/team/index.js.map +0 -1
  177. package/dist/team/lifecycle.d.ts +0 -37
  178. package/dist/team/lifecycle.js +0 -92
  179. package/dist/team/lifecycle.js.map +0 -1
  180. package/dist/team/reviewer.d.ts +0 -10
  181. package/dist/team/reviewer.js +0 -345
  182. package/dist/team/reviewer.js.map +0 -1
  183. package/dist/team/types.d.ts +0 -269
  184. package/dist/team/types.js +0 -70
  185. package/dist/team/types.js.map +0 -1
  186. package/dist/utils/browser.d.ts +0 -10
  187. package/dist/utils/browser.js +0 -96
  188. package/dist/utils/browser.js.map +0 -1
  189. package/dist/utils/platform.d.ts +0 -29
  190. package/dist/utils/platform.js +0 -90
  191. package/dist/utils/platform.js.map +0 -1
  192. package/dist/worktree/identity.d.ts +0 -9
  193. package/dist/worktree/identity.js +0 -32
  194. package/dist/worktree/identity.js.map +0 -1
  195. package/dist/worktree/parallel.d.ts +0 -87
  196. package/dist/worktree/parallel.js +0 -328
  197. package/dist/worktree/parallel.js.map +0 -1
  198. package/dist/worktree/session.d.ts +0 -67
  199. package/dist/worktree/session.js +0 -194
  200. package/dist/worktree/session.js.map +0 -1
  201. package/dist/worktree/state-merge.d.ts +0 -43
  202. package/dist/worktree/state-merge.js +0 -162
  203. package/dist/worktree/state-merge.js.map +0 -1
@@ -1,389 +0,0 @@
1
- /**
2
- * Auto-Chain — Multi-Milestone Execution Orchestrator
3
- *
4
- * After a milestone completes, spawns a fresh agent with clean context for the
5
- * next milestone. Fresh agent reads CLAUDE.md + next milestone section only.
6
- * Loops until all milestones done or a failure stops the chain.
7
- *
8
- * This module is the data/logic layer. It does NOT spawn agents — that is
9
- * the skill file's job (via Claude Code's Task tool). Auto-chain prepares
10
- * the context and tracks results across milestones.
11
- */
12
- import { readFile } from "node:fs/promises";
13
- import { execSync } from "node:child_process";
14
- import { join } from "node:path";
15
- import { readCurrentMilestone } from "../state/reader.js";
16
- import { findNextPendingMilestone, countPendingMilestones, updateMilestoneStatus, } from "../state/prd-status.js";
17
- import { isLastMilestone, commitMilestoneWork, } from "../state/writer.js";
18
- import { buildMilestoneContext } from "./executor.js";
19
- import { createWorktree, removeWorktree, deleteBranch, getRepoRoot, } from "../worktree/manager.js";
20
- import { registerSession, deregisterSession, updateSessionStatus, } from "../worktree/session.js";
21
- import { getCurrentUser } from "../worktree/identity.js";
22
- import { buildScheduleFromPRD } from "../worktree/parallel.js";
23
- // ---------------------------------------------------------------------------
24
- // Helpers
25
- // ---------------------------------------------------------------------------
26
- async function safeRead(filePath) {
27
- try {
28
- return await readFile(filePath, "utf-8");
29
- }
30
- catch {
31
- return "";
32
- }
33
- }
34
- /**
35
- * Extract the "Quick Context" section from CLAUDE.md.
36
- *
37
- * Returns just the abbreviated context block (from "## Quick Context" to the
38
- * next `##` heading or end of file). Falls back to the first 30 lines of
39
- * the file if the section header isn't found.
40
- */
41
- function extractQuickContext(claudeMd) {
42
- if (!claudeMd)
43
- return "";
44
- const quickMatch = claudeMd.match(/##\s*Quick Context\s*\n([\s\S]*?)(?=\n##\s|$)/);
45
- if (quickMatch) {
46
- return `## Quick Context\n${quickMatch[1].trim()}`;
47
- }
48
- // Fallback: first 30 lines (enough context without bloating the prompt)
49
- const lines = claudeMd.split("\n").slice(0, 30);
50
- return lines.join("\n").trim();
51
- }
52
- // ---------------------------------------------------------------------------
53
- // buildFreshSessionPrompt
54
- // ---------------------------------------------------------------------------
55
- /**
56
- * Build the fresh-context prompt for a milestone agent (Ralph Loop pattern).
57
- *
58
- * Reads CLAUDE.md (abbreviated to Quick Context) and the current milestone
59
- * section from the PRD. The total is kept as small as possible (~200-300
60
- * lines) while giving the agent enough context to work.
61
- */
62
- export async function buildFreshSessionPrompt(projectDir, prdPath, milestoneNumber) {
63
- const [claudeMd, milestoneSection] = await Promise.all([
64
- safeRead(join(projectDir, "CLAUDE.md")),
65
- readCurrentMilestone(prdPath, milestoneNumber),
66
- ]);
67
- const lines = [];
68
- // 1. Abbreviated CLAUDE.md
69
- const quickContext = extractQuickContext(claudeMd);
70
- if (quickContext) {
71
- lines.push("# Project Context");
72
- lines.push("");
73
- lines.push(quickContext);
74
- lines.push("");
75
- }
76
- // 2. Current milestone section from PRD
77
- if (milestoneSection) {
78
- lines.push("# Current Milestone");
79
- lines.push("");
80
- lines.push(milestoneSection.trim());
81
- lines.push("");
82
- }
83
- else {
84
- lines.push(`# Current Milestone`);
85
- lines.push("");
86
- lines.push(`Milestone ${milestoneNumber} section not found in PRD at ${prdPath}.`);
87
- lines.push("");
88
- }
89
- // 3. Session instructions (minimal)
90
- lines.push("# Session Instructions");
91
- lines.push("");
92
- lines.push("You are executing the milestone described above. Follow the PRD precisely.");
93
- lines.push("- Run `npx tsc --noEmit` after all changes to verify types.");
94
- lines.push("- Stage only files you create/modify (never `git add .`).");
95
- lines.push("- Do not commit — the orchestrator handles commits.");
96
- lines.push("- On completion, the orchestrator will update the status JSON automatically.");
97
- lines.push("- NEVER modify .forge.json, CLAUDE.md, or tasks/lessons.md to resolve verification errors.");
98
- lines.push("");
99
- return lines.join("\n");
100
- }
101
- // Re-export findNextPendingMilestone and countPendingMilestones from prd-status
102
- // so that existing consumers (cli.ts, tests) can continue importing from auto-chain.
103
- export { findNextPendingMilestone, countPendingMilestones };
104
- // ---------------------------------------------------------------------------
105
- // runAutoChain
106
- // ---------------------------------------------------------------------------
107
- /**
108
- * Auto-chain orchestrator: manages multi-milestone execution with context resets.
109
- *
110
- * For each pending milestone:
111
- * 1. Determines the starting milestone (from options or per-PRD status)
112
- * 2. Creates a git worktree for isolated execution
113
- * 3. Registers a session in the session registry
114
- * 4. Builds a fresh-context prompt for the milestone agent
115
- * 5. Calls the milestone context builder for structured data
116
- * 6. Returns results so the calling skill can spawn agents and drive execution
117
- * 7. On completion or failure, deregisters the session and cleans up the worktree
118
- *
119
- * The worktree is created ONCE per /forge:go session, not per milestone.
120
- * All milestones in the chain execute in the same worktree.
121
- *
122
- * The chain stops on the first milestone failure, or when all milestones
123
- * are complete. The caller is responsible for actually executing each
124
- * milestone (spawning agents, running waves) — this function provides the
125
- * orchestration loop and context management.
126
- */
127
- export async function runAutoChain(options) {
128
- const { projectDir, prdPath, config, branch, project, prdSlug, activePrd, developer, onMilestoneStart, onMilestoneComplete, onChainComplete, } = options;
129
- const completed = [];
130
- // Determine starting milestone
131
- let currentMilestoneNumber;
132
- if (options.startMilestone !== undefined) {
133
- currentMilestoneNumber = options.startMilestone;
134
- }
135
- else {
136
- // Auto-detect from per-PRD status
137
- const nextPending = await findNextPendingMilestone(projectDir, prdSlug);
138
- if (!nextPending) {
139
- // All milestones are already complete
140
- const result = {
141
- completed: [],
142
- stopped: false,
143
- allComplete: true,
144
- };
145
- onChainComplete?.([]);
146
- return result;
147
- }
148
- currentMilestoneNumber = nextPending.number;
149
- }
150
- // --- Worktree lifecycle: create once for the entire chain ---
151
- const repoRoot = options.repoRoot ?? getRepoRoot(projectDir);
152
- const user = getCurrentUser(projectDir);
153
- const slug = `${project}-m${currentMilestoneNumber}`;
154
- const worktreeResult = createWorktree(repoRoot, slug, user.name, {
155
- baseBranch: branch,
156
- });
157
- const { worktreePath, branch: worktreeBranch } = worktreeResult;
158
- const session = registerSession(repoRoot, {
159
- user,
160
- skill: "go",
161
- milestone: `M${currentMilestoneNumber}`,
162
- prdSlug,
163
- branch: worktreeBranch,
164
- worktreePath,
165
- });
166
- // Use worktree path as the effective project directory for code execution.
167
- // CLAUDE.md is read from the main projectDir (see buildFreshSessionPrompt),
168
- // PRD files and milestone context come from the worktree.
169
- const effectiveProjectDir = worktreePath;
170
- try {
171
- // Loop through milestones until we run out or hit a failure
172
- while (true) {
173
- // Update session milestone tracking
174
- updateSessionStatus(repoRoot, session.id, "active");
175
- // Build fresh-context prompt: CLAUDE.md from main project,
176
- // PRD path resolved relative to the worktree
177
- const effectivePrdPath = join(effectiveProjectDir, prdPath);
178
- const freshPrompt = await buildFreshSessionPrompt(projectDir, effectivePrdPath, currentMilestoneNumber);
179
- // Build structured context from the worktree (validates milestone exists in PRD)
180
- let context;
181
- try {
182
- context = await buildMilestoneContext({
183
- projectDir: effectiveProjectDir,
184
- prdPath,
185
- milestoneNumber: currentMilestoneNumber,
186
- config,
187
- prdSlug,
188
- });
189
- // Attach worktree path to context
190
- context.worktreePath = worktreePath;
191
- }
192
- catch (err) {
193
- // Milestone not found in PRD — chain cannot continue
194
- const errorMessage = err instanceof Error ? err.message : String(err);
195
- const failResult = {
196
- milestoneNumber: currentMilestoneNumber,
197
- milestoneName: "Unknown",
198
- success: false,
199
- isLast: false,
200
- freshPrompt,
201
- worktreePath,
202
- errors: [errorMessage],
203
- };
204
- completed.push(failResult);
205
- onMilestoneComplete?.(currentMilestoneNumber, failResult);
206
- const chainResult = {
207
- completed,
208
- stopped: true,
209
- stoppedAt: currentMilestoneNumber,
210
- allComplete: false,
211
- };
212
- onChainComplete?.(completed);
213
- return chainResult;
214
- }
215
- // Notify: milestone starting
216
- onMilestoneStart?.(currentMilestoneNumber, context.milestoneName);
217
- // Build the milestone result with the fresh prompt.
218
- // The caller uses `freshPrompt` to spawn an agent, then calls
219
- // `completeMilestone()` after the agent finishes.
220
- const milestoneResult = {
221
- milestoneNumber: currentMilestoneNumber,
222
- milestoneName: context.milestoneName,
223
- success: true, // Optimistic; caller updates via completeMilestone
224
- isLast: await isLastMilestone(effectiveProjectDir, prdSlug, currentMilestoneNumber),
225
- freshPrompt,
226
- worktreePath,
227
- errors: [],
228
- };
229
- completed.push(milestoneResult);
230
- // Notify: milestone complete (caller will drive actual execution)
231
- onMilestoneComplete?.(currentMilestoneNumber, milestoneResult);
232
- // If this was the last milestone, we're done
233
- if (milestoneResult.isLast) {
234
- const chainResult = {
235
- completed,
236
- stopped: false,
237
- allComplete: true,
238
- };
239
- onChainComplete?.(completed);
240
- return chainResult;
241
- }
242
- // Find the next pending milestone
243
- const nextPending = await findNextPendingMilestone(effectiveProjectDir, prdSlug);
244
- if (!nextPending) {
245
- // All milestones are complete
246
- const chainResult = {
247
- completed,
248
- stopped: false,
249
- allComplete: true,
250
- };
251
- onChainComplete?.(completed);
252
- return chainResult;
253
- }
254
- currentMilestoneNumber = nextPending.number;
255
- }
256
- }
257
- finally {
258
- // --- Worktree cleanup: always runs, even on error ---
259
- try {
260
- deregisterSession(repoRoot, session.id);
261
- }
262
- catch {
263
- // Non-fatal: best-effort deregistration
264
- }
265
- try {
266
- removeWorktree(repoRoot, worktreePath);
267
- }
268
- catch {
269
- // Non-fatal: best-effort cleanup
270
- }
271
- // Delete the worktree branch — force-delete since it was merged via worktree flow
272
- deleteBranch(repoRoot, worktreeBranch, { force: true });
273
- }
274
- }
275
- // ---------------------------------------------------------------------------
276
- // completeMilestone — post-execution bookkeeping
277
- // ---------------------------------------------------------------------------
278
- /**
279
- * Called after a milestone's agent finishes execution.
280
- *
281
- * Handles:
282
- * 1. Updating milestone status in per-PRD status JSON
283
- * 2. Committing milestone work to git (in the worktree if one was used)
284
- * 3. Merging worktree branch into the feature branch (if worktree was used)
285
- * 4. Returning the commit SHA for the milestone result
286
- *
287
- * The caller should update the MilestoneResult with the returned commit info.
288
- */
289
- export async function completeMilestone(options) {
290
- const { projectDir, prdSlug, milestoneNumber, milestoneName, branch, filesToStage, push, worktreePath, repoRoot, } = options;
291
- // The effective directory for status updates and commits:
292
- // if a worktree was used, commit there; otherwise use projectDir
293
- const commitDir = worktreePath ?? projectDir;
294
- // Check if this is the last milestone
295
- const last = await isLastMilestone(commitDir, prdSlug, milestoneNumber);
296
- // Update per-PRD status JSON
297
- await updateMilestoneStatus(commitDir, prdSlug, milestoneNumber, "complete");
298
- // Commit milestone work (in the worktree if one was used)
299
- const commitResult = commitMilestoneWork({
300
- projectDir: commitDir,
301
- milestoneNumber,
302
- milestoneName,
303
- filesToStage,
304
- push: false, // Don't push from worktree; push happens after merge
305
- branch,
306
- });
307
- // If a worktree was used, merge the worktree branch into the feature branch
308
- if (worktreePath && repoRoot) {
309
- const worktreeBranch = execSync("git rev-parse --abbrev-ref HEAD", {
310
- cwd: worktreePath,
311
- encoding: "utf-8",
312
- stdio: "pipe",
313
- }).trim();
314
- mergeWorktreeBranch(repoRoot, worktreeBranch, branch);
315
- // Optionally push the feature branch after merge
316
- if (push) {
317
- try {
318
- execSync(`git push origin ${branch}`, {
319
- cwd: repoRoot,
320
- stdio: "pipe",
321
- encoding: "utf-8",
322
- });
323
- }
324
- catch {
325
- // Non-fatal: push failure doesn't invalidate the milestone
326
- }
327
- }
328
- }
329
- else if (push) {
330
- // No worktree — push directly from projectDir (original behavior)
331
- try {
332
- execSync(`git push origin ${branch}`, {
333
- cwd: projectDir,
334
- stdio: "pipe",
335
- encoding: "utf-8",
336
- });
337
- }
338
- catch {
339
- // Non-fatal
340
- }
341
- }
342
- return { commitResult, isLast: last };
343
- }
344
- // ---------------------------------------------------------------------------
345
- // mergeWorktreeBranch — brings worktree commits into the feature branch
346
- // ---------------------------------------------------------------------------
347
- /**
348
- * Merge worktree branch commits into the target branch.
349
- * Used after milestone completion to bring worktree work back to the feature branch.
350
- *
351
- * Checks out the target branch in the main repo, merges the worktree branch,
352
- * then returns. The caller is responsible for pushing if desired.
353
- */
354
- function mergeWorktreeBranch(repoRoot, worktreeBranch, targetBranch) {
355
- // Ensure we're on the target branch in the main repo
356
- execSync(`git checkout ${targetBranch}`, {
357
- cwd: repoRoot,
358
- stdio: "pipe",
359
- encoding: "utf-8",
360
- });
361
- // Merge the worktree branch into the target branch
362
- execSync(`git merge ${worktreeBranch} --no-edit`, {
363
- cwd: repoRoot,
364
- stdio: "pipe",
365
- encoding: "utf-8",
366
- });
367
- }
368
- // ---------------------------------------------------------------------------
369
- // buildParallelPlan — parallel execution planner
370
- // ---------------------------------------------------------------------------
371
- /**
372
- * Build a parallel execution plan for all milestones in a PRD.
373
- *
374
- * Parses the PRD markdown for milestone definitions and `dependsOn` fields,
375
- * builds a dependency DAG, and computes parallel execution waves showing
376
- * which milestones can run simultaneously.
377
- *
378
- * If no `dependsOn` fields are found in the PRD, all milestones are treated
379
- * as roots (no dependencies) and placed in a single wave. This is backward
380
- * compatible — the caller can process them sequentially by milestone number.
381
- *
382
- * @param prdPath - Absolute path to the PRD markdown file
383
- * @returns The wave schedule showing which milestones can run simultaneously
384
- * @throws If a dependency cycle is detected or a referenced dependency doesn't exist
385
- */
386
- export async function buildParallelPlan(prdPath) {
387
- return buildScheduleFromPRD(prdPath);
388
- }
389
- //# sourceMappingURL=auto-chain.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-chain.js","sourceRoot":"","sources":["../../src/go/auto-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EACL,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AA0D/D,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,KAAK,UAAU,QAAQ,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,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,CAAC,gBAAgB,YAAY,EAAE,EAAE;QACvC,GAAG,EAAE,QAAQ;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,mDAAmD;IACnD,QAAQ,CAAC,aAAa,cAAc,YAAY,EAAE;QAChD,GAAG,EAAE,QAAQ;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,iDAAiD;AACjD,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe;IAEf,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
@@ -1,137 +0,0 @@
1
- /**
2
- * Milestone Execution Engine
3
- *
4
- * Programmatic module that reads a PRD milestone definition, prepares
5
- * wave-based agent prompts, tracks results, runs verification between
6
- * waves, and produces structured output.
7
- *
8
- * This module does NOT spawn agents — that is the skill file's job
9
- * (via Claude Code's Task tool). The executor is the data/logic layer.
10
- */
11
- import type { SessionContext } from "../state/reader.js";
12
- import type { TeamConfig } from "../team/types.js";
13
- import type { ForgeConfig, PipelineResult } from "../types.js";
14
- import type { MilestoneWave } from "../spec/templates.js";
15
- export interface ExecuteMilestoneOptions {
16
- projectDir: string;
17
- prdPath: string;
18
- milestoneNumber: number;
19
- config: ForgeConfig;
20
- /** PRD slug for per-PRD status tracking */
21
- prdSlug?: string;
22
- /** Log prompts but don't run verification (for testing) */
23
- dryRun?: boolean;
24
- }
25
- export interface AgentPrompt {
26
- name: string;
27
- task: string;
28
- files: string[];
29
- prompt: string;
30
- }
31
- export interface WaveExecution {
32
- waveNumber: number;
33
- agents: AgentPrompt[];
34
- }
35
- export interface AgentResult {
36
- name: string;
37
- task: string;
38
- success: boolean;
39
- error?: string;
40
- filesCreated: string[];
41
- filesModified: string[];
42
- }
43
- export interface WaveResult {
44
- waveNumber: number;
45
- agents: AgentResult[];
46
- verification: PipelineResult | null;
47
- }
48
- export interface ExecutionResult {
49
- milestoneNumber: number;
50
- milestoneName: string;
51
- success: boolean;
52
- waves: WaveResult[];
53
- totalFilesCreated: number;
54
- totalFilesModified: number;
55
- errors: string[];
56
- }
57
- export interface MilestoneContext {
58
- milestoneNumber: number;
59
- milestoneName: string;
60
- milestoneGoal: string;
61
- milestoneSection: string;
62
- waves: MilestoneWave[];
63
- verificationCommands: string[];
64
- sessionContext: SessionContext;
65
- lessons: string;
66
- claudeMd: string;
67
- /** Path to the worktree used for isolated execution (if any) */
68
- worktreePath?: string;
69
- /** Team configuration for agent team lifecycle (M2 integration) */
70
- teamConfig?: TeamConfig;
71
- }
72
- /**
73
- * Build the full context needed to execute a milestone.
74
- * Reads PRD milestone section, CLAUDE.md, lessons, and per-PRD status JSON.
75
- */
76
- export declare function buildMilestoneContext(options: ExecuteMilestoneOptions): Promise<MilestoneContext>;
77
- /**
78
- * Build a prompt for a single agent within a milestone wave.
79
- *
80
- * The prompt includes:
81
- * - The agent's specific task and files
82
- * - Milestone goal and context
83
- * - Key existing code (inlined, not just paths)
84
- * - Lessons from tasks/lessons.md
85
- * - CLAUDE.md rules (abbreviated)
86
- */
87
- export declare function buildAgentPrompt(agent: MilestoneWave["agents"][number], context: MilestoneContext, existingCode?: string): string;
88
- /**
89
- * Prepare all waves for execution.
90
- * Returns structured wave data with agent prompts ready for the skill
91
- * to pass to Claude Code's Task tool.
92
- */
93
- export declare function prepareWaves(context: MilestoneContext, existingCodeMap?: Map<string, string>): WaveExecution[];
94
- /**
95
- * Run forge verification pipeline after a wave completes.
96
- * Returns the pipeline result with human-readable report.
97
- */
98
- export declare function runWaveVerification(options: ExecuteMilestoneOptions): Promise<PipelineResult>;
99
- /**
100
- * Create an empty execution result for a milestone.
101
- */
102
- export declare function createExecutionResult(context: MilestoneContext): ExecutionResult;
103
- /**
104
- * Record a completed wave's results into the execution result.
105
- */
106
- export declare function recordWaveResult(execution: ExecutionResult, waveResult: WaveResult): ExecutionResult;
107
- /**
108
- * Execute a single milestone end-to-end.
109
- *
110
- * In dryRun mode: builds context and prompts, runs no verification, returns
111
- * the prepared execution plan.
112
- *
113
- * In normal mode: the caller (skill file) should use this module's functions
114
- * step by step:
115
- * 1. `buildMilestoneContext()` — read PRD and build context
116
- * 2. `prepareWaves()` — get agent prompts for each wave
117
- * 3. For each wave: spawn agents, collect results
118
- * 4. `runWaveVerification()` — verify after each wave
119
- * 5. `recordWaveResult()` — track results
120
- *
121
- * This `executeMilestone` function is the simplified orchestrator for
122
- * programmatic/testing use. For real execution, the skill drives each step.
123
- */
124
- export declare function executeMilestone(options: ExecuteMilestoneOptions): Promise<{
125
- context: MilestoneContext;
126
- waves: WaveExecution[];
127
- result: ExecutionResult;
128
- }>;
129
- /**
130
- * Format an execution result as a human-readable summary.
131
- */
132
- export declare function formatExecutionSummary(result: ExecutionResult): string;
133
- /**
134
- * Format verification errors into a structured prompt for fix agents.
135
- * Used by the self-healing verify loop.
136
- */
137
- export declare function formatErrorsForFixAgent(verification: PipelineResult): string;