@callumvass/forgeflow-pm 0.1.0

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.
@@ -0,0 +1,88 @@
1
+ import * as fs from "node:fs";
2
+ import {
3
+ type AnyCtx,
4
+ emptyStage,
5
+ runAgent,
6
+ type StageResult,
7
+ signalExists,
8
+ TOOLS_ALL,
9
+ TOOLS_NO_EDIT,
10
+ } from "@callumvass/forgeflow-shared";
11
+ import { AGENTS_DIR } from "../resolve.js";
12
+
13
+ export async function runPrdQa(cwd: string, maxIterations: number, signal: AbortSignal, onUpdate: AnyCtx, ctx: AnyCtx) {
14
+ if (!fs.existsSync(`${cwd}/PRD.md`)) {
15
+ return {
16
+ content: [{ type: "text" as const, text: "PRD.md not found." }],
17
+ details: { pipeline: "prd-qa", stages: [] },
18
+ };
19
+ }
20
+
21
+ const stages: StageResult[] = [];
22
+ const opts = { agentsDir: AGENTS_DIR, cwd, signal, stages, pipeline: "prd-qa", onUpdate };
23
+
24
+ for (let i = 1; i <= maxIterations; i++) {
25
+ // Critic
26
+ stages.push(emptyStage("prd-critic"));
27
+ const criticResult = await runAgent(
28
+ "prd-critic",
29
+ "Review PRD.md for completeness. If it needs refinement, create QUESTIONS.md. If it's complete, do NOT create QUESTIONS.md.",
30
+ { ...opts, tools: TOOLS_NO_EDIT },
31
+ );
32
+
33
+ // No QUESTIONS.md = critic considers PRD complete
34
+ if (!signalExists(cwd, "questions")) {
35
+ if (criticResult.status === "failed") {
36
+ return {
37
+ content: [{ type: "text" as const, text: `Critic failed.\nStderr: ${criticResult.stderr.slice(0, 300)}` }],
38
+ details: { pipeline: "prd-qa", stages },
39
+ isError: true,
40
+ };
41
+ }
42
+ return {
43
+ content: [{ type: "text" as const, text: "PRD refinement complete. Ready for /create-issues." }],
44
+ details: { pipeline: "prd-qa", stages },
45
+ };
46
+ }
47
+
48
+ // Architect
49
+ stages.push(emptyStage("prd-architect"));
50
+ await runAgent(
51
+ "prd-architect",
52
+ "Read PRD.md and answer all questions in QUESTIONS.md. Write answers inline in QUESTIONS.md.",
53
+ { ...opts, tools: TOOLS_ALL },
54
+ );
55
+
56
+ // Integrator — incorporate answers into PRD before approval gate
57
+ stages.push(emptyStage("prd-integrator"));
58
+ await runAgent(
59
+ "prd-integrator",
60
+ "Incorporate answers from QUESTIONS.md into PRD.md, then delete QUESTIONS.md.",
61
+ opts,
62
+ );
63
+
64
+ // Approval gate — show PRD in editor, user can review/edit then decide
65
+ if (ctx.hasUI) {
66
+ const prdContent = fs.readFileSync(`${cwd}/PRD.md`, "utf-8");
67
+ const edited = await ctx.ui.editor(`Iteration ${i} — Review PRD (edit or close to continue)`, prdContent);
68
+
69
+ // If user edited, write changes back
70
+ if (edited != null && edited !== prdContent) {
71
+ fs.writeFileSync(`${cwd}/PRD.md`, edited, "utf-8");
72
+ }
73
+
74
+ const action = await ctx.ui.select("PRD updated. What next?", ["Continue refining", "Accept PRD"]);
75
+ if (action === "Accept PRD" || action == null) {
76
+ return {
77
+ content: [{ type: "text" as const, text: "PRD accepted." }],
78
+ details: { pipeline: "prd-qa", stages },
79
+ };
80
+ }
81
+ }
82
+ }
83
+
84
+ return {
85
+ content: [{ type: "text" as const, text: `PRD refinement did not complete after ${maxIterations} iterations.` }],
86
+ details: { pipeline: "prd-qa", stages },
87
+ };
88
+ }
package/src/resolve.ts ADDED
@@ -0,0 +1,6 @@
1
+ import * as path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ // After bundling: extensions/index.js → up one level → agents/
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ export const AGENTS_DIR = path.resolve(__dirname, "..", "agents");
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
6
+ "noEmit": true
7
+ },
8
+ "include": ["src/**/*.ts"],
9
+ "references": [
10
+ { "path": "../shared" }
11
+ ]
12
+ }