forge-cc 0.1.4 → 0.1.6
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 +96 -10
- package/dist/cli.js +225 -7
- package/dist/cli.js.map +1 -1
- package/dist/go/auto-chain.d.ts +37 -5
- package/dist/go/auto-chain.js +220 -81
- package/dist/go/auto-chain.js.map +1 -1
- package/dist/go/executor.d.ts +2 -0
- package/dist/go/executor.js.map +1 -1
- package/dist/hooks/pre-commit.js +9 -3
- package/dist/hooks/pre-commit.js.map +1 -1
- package/dist/reporter/human.d.ts +5 -0
- package/dist/reporter/human.js +30 -0
- package/dist/reporter/human.js.map +1 -1
- package/dist/setup/templates.js +97 -122
- package/dist/setup/templates.js.map +1 -1
- package/dist/spec/generator.d.ts +20 -0
- package/dist/spec/generator.js +23 -2
- package/dist/spec/generator.js.map +1 -1
- package/dist/spec/interview.d.ts +20 -2
- package/dist/spec/interview.js +8 -0
- package/dist/spec/interview.js.map +1 -1
- package/dist/spec/scanner.d.ts +34 -0
- package/dist/spec/scanner.js +93 -0
- package/dist/spec/scanner.js.map +1 -1
- package/dist/spec/templates.d.ts +22 -0
- package/dist/spec/templates.js +8 -0
- package/dist/spec/templates.js.map +1 -1
- package/dist/utils/platform.d.ts +29 -0
- package/dist/utils/platform.js +90 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/worktree/identity.d.ts +9 -0
- package/dist/worktree/identity.js +32 -0
- package/dist/worktree/identity.js.map +1 -0
- package/dist/worktree/manager.d.ts +70 -0
- package/dist/worktree/manager.js +217 -0
- package/dist/worktree/manager.js.map +1 -0
- package/dist/worktree/parallel.d.ts +87 -0
- package/dist/worktree/parallel.js +328 -0
- package/dist/worktree/parallel.js.map +1 -0
- package/dist/worktree/session.d.ts +64 -0
- package/dist/worktree/session.js +193 -0
- package/dist/worktree/session.js.map +1 -0
- package/dist/worktree/state-merge.d.ts +43 -0
- package/dist/worktree/state-merge.js +162 -0
- package/dist/worktree/state-merge.js.map +1 -0
- package/hooks/pre-commit-verify.js +9 -3
- package/hooks/version-check.js +78 -78
- package/package.json +1 -1
- package/skills/forge-go.md +39 -0
- package/skills/forge-setup.md +183 -157
- package/skills/forge-spec.md +50 -12
- package/skills/forge-update.md +92 -72
package/dist/setup/templates.js
CHANGED
|
@@ -11,148 +11,123 @@ export function forgeConfigTemplate(ctx) {
|
|
|
11
11
|
// ── Project CLAUDE.md ───────────────────────────────────────────────
|
|
12
12
|
export function claudeMdTemplate(ctx) {
|
|
13
13
|
const gatesList = ctx.gates.map((g) => `\`${g}\``).join(", ");
|
|
14
|
-
return `# ${ctx.projectName} — Claude Code Instructions
|
|
15
|
-
|
|
16
|
-
## What This Is
|
|
17
|
-
${ctx.description}
|
|
18
|
-
|
|
19
|
-
**Tech:** ${ctx.techStack}
|
|
20
|
-
|
|
21
|
-
## Quick Reference
|
|
22
|
-
|
|
23
|
-
| Action | Command |
|
|
24
|
-
|--------|---------|
|
|
25
|
-
| Run verification | \`npx forge verify\` |
|
|
26
|
-
| Run specific gates | \`npx forge verify --gate ${ctx.gates.join(",")}\` |
|
|
27
|
-
| Check status | \`npx forge status\` |
|
|
28
|
-
| Build | \`npm run build\` |
|
|
29
|
-
| Test | \`npm test\` |
|
|
30
|
-
|
|
31
|
-
## Code Map
|
|
32
|
-
|
|
33
|
-
\`\`\`
|
|
34
|
-
src/
|
|
35
|
-
(add your project structure here)
|
|
36
|
-
\`\`\`
|
|
37
|
-
|
|
38
|
-
## Key Docs
|
|
39
|
-
|
|
40
|
-
| File | Purpose |
|
|
41
|
-
|------|---------|
|
|
42
|
-
| \`.planning/STATE.md\` | Current session state (<80 lines) |
|
|
43
|
-
| \`.planning/ROADMAP.md\` | Milestone progress tracker |
|
|
44
|
-
| \`tasks/lessons.md\` | Lessons learned (max 10 active) |
|
|
45
|
-
|
|
46
|
-
## Session Protocol
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
##
|
|
63
|
-
|
|
14
|
+
return `# ${ctx.projectName} — Claude Code Instructions
|
|
15
|
+
|
|
16
|
+
## What This Is
|
|
17
|
+
${ctx.description}
|
|
18
|
+
|
|
19
|
+
**Tech:** ${ctx.techStack}
|
|
20
|
+
|
|
21
|
+
## Quick Reference
|
|
22
|
+
|
|
23
|
+
| Action | Command |
|
|
24
|
+
|--------|---------|
|
|
25
|
+
| Run verification | \`npx forge verify\` |
|
|
26
|
+
| Run specific gates | \`npx forge verify --gate ${ctx.gates.join(",")}\` |
|
|
27
|
+
| Check status | \`npx forge status\` |
|
|
28
|
+
| Build | \`npm run build\` |
|
|
29
|
+
| Test | \`npm test\` |
|
|
30
|
+
|
|
31
|
+
## Code Map
|
|
32
|
+
|
|
33
|
+
\`\`\`
|
|
34
|
+
src/
|
|
35
|
+
(add your project structure here)
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
## Key Docs
|
|
39
|
+
|
|
40
|
+
| File | Purpose |
|
|
41
|
+
|------|---------|
|
|
42
|
+
| \`.planning/STATE.md\` | Current session state (<80 lines) |
|
|
43
|
+
| \`.planning/ROADMAP.md\` | Milestone progress tracker |
|
|
44
|
+
| \`tasks/lessons.md\` | Lessons learned (max 10 active) |
|
|
45
|
+
|
|
46
|
+
## Session Protocol
|
|
47
|
+
- **On start:** Read CLAUDE.md → .planning/STATE.md → .planning/ROADMAP.md → tasks/lessons.md
|
|
48
|
+
- **When lost:** Re-read planning docs, don't guess from stale context
|
|
49
|
+
|
|
50
|
+
## Session Protocol END (Mandatory)
|
|
51
|
+
1. \`.planning/STATE.md\` — replace, don't append
|
|
52
|
+
2. \`.planning/ROADMAP.md\` — check off completed milestones
|
|
53
|
+
3. \`tasks/lessons.md\` — add/refine lessons (max 10, promote when full)
|
|
54
|
+
4. Commit doc updates to the feature branch
|
|
55
|
+
|
|
56
|
+
## Execution Rules
|
|
57
|
+
- **Plan before building.** Read the PRD before touching code.
|
|
58
|
+
- **Verify everything.** Run \`npx forge verify\` after changes land.
|
|
59
|
+
- **All changes via PR.** Never commit directly to main.
|
|
60
|
+
- **Branch naming:** \`feat/short-description\` or \`fix/short-description\`
|
|
61
|
+
|
|
62
|
+
## Verification Gates
|
|
63
|
+
Active gates: ${gatesList}
|
|
64
|
+
|
|
65
|
+
## Learned Rules
|
|
66
|
+
(none yet)
|
|
64
67
|
`;
|
|
65
68
|
}
|
|
66
69
|
// ── .planning/STATE.md ──────────────────────────────────────────────
|
|
67
70
|
export function stateMdTemplate(ctx) {
|
|
68
|
-
return `# State — ${ctx.projectName}
|
|
69
|
-
|
|
70
|
-
## Current Status
|
|
71
|
-
- **Phase:** Setup complete
|
|
72
|
-
- **Active project:** None
|
|
73
|
-
- **Branch:** main
|
|
74
|
-
|
|
75
|
-
## What Was Done
|
|
76
|
-
- Initialized forge-cc scaffolding (${ctx.date})
|
|
77
|
-
- Created .forge.json, CLAUDE.md, planning docs
|
|
78
|
-
|
|
79
|
-
## Next Actions
|
|
80
|
-
- Run \`/forge:spec\` to create a PRD for the first feature
|
|
71
|
+
return `# State — ${ctx.projectName}
|
|
72
|
+
|
|
73
|
+
## Current Status
|
|
74
|
+
- **Phase:** Setup complete
|
|
75
|
+
- **Active project:** None
|
|
76
|
+
- **Branch:** main
|
|
77
|
+
|
|
78
|
+
## What Was Done
|
|
79
|
+
- Initialized forge-cc scaffolding (${ctx.date})
|
|
80
|
+
- Created .forge.json, CLAUDE.md, planning docs
|
|
81
|
+
|
|
82
|
+
## Next Actions
|
|
83
|
+
- Run \`/forge:spec\` to create a PRD for the first feature
|
|
81
84
|
`;
|
|
82
85
|
}
|
|
83
86
|
// ── .planning/ROADMAP.md ────────────────────────────────────────────
|
|
84
87
|
export function roadmapMdTemplate(ctx) {
|
|
85
|
-
return `# Roadmap — ${ctx.projectName}
|
|
86
|
-
|
|
87
|
-
## Projects
|
|
88
|
-
|
|
89
|
-
| Project | Status | PRD | Milestones |
|
|
90
|
-
|---------|--------|-----|------------|
|
|
91
|
-
| (none yet) | — | — | — |
|
|
92
|
-
|
|
93
|
-
## Completed
|
|
94
|
-
(none yet)
|
|
88
|
+
return `# Roadmap — ${ctx.projectName}
|
|
89
|
+
|
|
90
|
+
## Projects
|
|
91
|
+
|
|
92
|
+
| Project | Status | PRD | Milestones |
|
|
93
|
+
|---------|--------|-----|------------|
|
|
94
|
+
| (none yet) | — | — | — |
|
|
95
|
+
|
|
96
|
+
## Completed
|
|
97
|
+
(none yet)
|
|
95
98
|
`;
|
|
96
99
|
}
|
|
97
100
|
// ── tasks/lessons.md ────────────────────────────────────────────────
|
|
98
101
|
export function lessonsMdTemplate(ctx) {
|
|
99
|
-
return `# Lessons Learned — ${ctx.projectName}
|
|
100
|
-
|
|
101
|
-
<!-- Max 10 active one-liners. Format: - **[topic]** The rule -->
|
|
102
|
-
<!-- When full, promote the most battle-tested to CLAUDE.md ## Learned Rules -->
|
|
103
|
-
|
|
104
|
-
(none yet)
|
|
102
|
+
return `# Lessons Learned — ${ctx.projectName}
|
|
103
|
+
|
|
104
|
+
<!-- Max 10 active one-liners. Format: - **[topic]** The rule -->
|
|
105
|
+
<!-- When full, promote the most battle-tested to CLAUDE.md ## Learned Rules -->
|
|
106
|
+
|
|
107
|
+
(none yet)
|
|
105
108
|
`;
|
|
106
109
|
}
|
|
107
110
|
// ── ~/.claude/CLAUDE.md (global, for fresh installs) ────────────────
|
|
108
111
|
export function globalClaudeMdTemplate() {
|
|
109
|
-
return `# Global Claude Code Instructions
|
|
110
|
-
|
|
111
|
-
##
|
|
112
|
-
|
|
113
|
-
- **Default to action.** Plan internally, execute
|
|
114
|
-
- **
|
|
115
|
-
- **
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- **On start:** Read CLAUDE.md → STATE.md → ROADMAP.md → lessons files
|
|
124
|
-
- **On finish (MANDATORY — work is not done without these):**
|
|
125
|
-
1. Update \`.planning/STATE.md\` — replace, don't append, <80 lines
|
|
126
|
-
2. Update \`.planning/ROADMAP.md\` — check off completed items
|
|
127
|
-
3. Update \`tasks/lessons.md\` — max 10 one-liners, promote to CLAUDE.md Learned Rules when full (max 15)
|
|
128
|
-
4. Commit and push doc updates on the feature branch
|
|
129
|
-
5. Write handoff summary
|
|
130
|
-
- **Fresh sessions preferred** over long sessions with context bloat
|
|
131
|
-
- **When lost:** Re-read planning docs rather than guessing from stale context
|
|
132
|
-
|
|
133
|
-
## Verification (Mandatory)
|
|
134
|
-
|
|
135
|
-
- Never mark a task complete without proving it works
|
|
136
|
-
- Build must pass. Tests must pass. No exceptions.
|
|
137
|
-
- Run tests, check logs, demonstrate correctness
|
|
138
|
-
- If verification fails, fix it and re-verify
|
|
139
|
-
|
|
140
|
-
## Lessons System
|
|
141
|
-
|
|
142
|
-
- **\`tasks/lessons.md\`**: max 10 active one-liners
|
|
143
|
-
- **\`CLAUDE.md ## Learned Rules\`**: max 15 permanent one-liners (promoted from lessons.md)
|
|
144
|
-
- **When to write:** After any correction, and when agents hit issues
|
|
145
|
-
|
|
146
|
-
## Core Principles
|
|
147
|
-
|
|
148
|
-
- **Simplicity First:** Make every change as simple as possible.
|
|
149
|
-
- **No Laziness:** Find root causes. No temporary fixes.
|
|
150
|
-
- **Minimal Impact:** Changes should only touch what's necessary.
|
|
112
|
+
return `# Global Claude Code Instructions
|
|
113
|
+
|
|
114
|
+
## How to Work
|
|
115
|
+
- **Follow instructions exactly.** Skills, CLAUDE.md rules, and workflow steps are tested — execute every step as written, including all AskUserQuestion prompts.
|
|
116
|
+
- **Default to action.** Don't ask for confirmation. Plan internally, execute, verify.
|
|
117
|
+
- **Iterate on failure.** Fix what breaks. Only stop to ask when truly blocked on missing credentials, ambiguous business requirements, or destructive actions on shared infrastructure.
|
|
118
|
+
- **Use agent teams** for non-trivial work (3+ files or 3+ steps).
|
|
119
|
+
|
|
120
|
+
## Verification
|
|
121
|
+
- Never mark complete without proving it works.
|
|
122
|
+
- Build and tests must pass. Run them.
|
|
123
|
+
|
|
124
|
+
## Principles
|
|
125
|
+
- Simple changes only. Find root causes. Touch only what's necessary.
|
|
151
126
|
`;
|
|
152
127
|
}
|
|
153
128
|
// ── .gitignore lines ────────────────────────────────────────────────
|
|
154
129
|
export function gitignoreForgeLines() {
|
|
155
|
-
return `.forge/
|
|
130
|
+
return `.forge/
|
|
156
131
|
`;
|
|
157
132
|
}
|
|
158
133
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/setup/templates.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAU5E,uEAAuE;AAEvE,MAAM,UAAU,mBAAmB,CAAC,GAAiB;IACnD,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,aAAa,EAAE,CAAC;KACjB,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAChD,CAAC;AAED,uEAAuE;AAEvE,MAAM,UAAU,gBAAgB,CAAC,GAAiB;IAChD,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE9D,OAAO,KAAK,GAAG,CAAC,WAAW;;;EAG3B,GAAG,CAAC,WAAW;;YAEL,GAAG,CAAC,SAAS;;;;;;;mDAO0B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/setup/templates.ts"],"names":[],"mappings":"AAAA,uEAAu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UAAU,mBAAmB;IACjC,OAAO;CACR,CAAC;AACF,CAAC"}
|
package/dist/spec/generator.d.ts
CHANGED
|
@@ -12,3 +12,23 @@ export declare function generateDraftPRD(data: Partial<PRDData>): string;
|
|
|
12
12
|
* Validates PRD data, generates markdown, and writes to disk.
|
|
13
13
|
*/
|
|
14
14
|
export declare function writePRDToFile(data: PRDData, outputPath: string): void;
|
|
15
|
+
export interface WorktreePRDResult {
|
|
16
|
+
/** Absolute path where the PRD was written in the worktree. */
|
|
17
|
+
prdPath: string;
|
|
18
|
+
/** Relative path from the worktree root (used for merging back). */
|
|
19
|
+
relativePath: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Write a PRD to a worktree directory.
|
|
23
|
+
*
|
|
24
|
+
* Validates and generates the PRD markdown, then writes it to
|
|
25
|
+
* `<worktreePath>/<relativePrdPath>`. Returns both the absolute path
|
|
26
|
+
* and the relative path so callers can locate the file or merge it
|
|
27
|
+
* back to the main working tree.
|
|
28
|
+
*
|
|
29
|
+
* @param data - The PRD data to generate and write.
|
|
30
|
+
* @param worktreePath - Absolute path to the worktree root.
|
|
31
|
+
* @param relativePrdPath - Path relative to the worktree root where
|
|
32
|
+
* the PRD should be written (e.g. "tasks/prd.md").
|
|
33
|
+
*/
|
|
34
|
+
export declare function writePRDToWorktree(data: PRDData, worktreePath: string, relativePrdPath: string): WorktreePRDResult;
|
package/dist/spec/generator.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeFileSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { dirname } from "node:path";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
3
|
import { validatePRD } from "./templates.js";
|
|
4
4
|
// ── Section Generators ───────────────────────────────────────────────
|
|
5
5
|
function renderHeader(data) {
|
|
@@ -82,8 +82,11 @@ function renderMilestone(milestone) {
|
|
|
82
82
|
`### Milestone ${milestone.number}: ${milestone.name}`,
|
|
83
83
|
`**Assigned To:** ${milestone.assignedTo}`,
|
|
84
84
|
`**Goal:** ${milestone.goal}`,
|
|
85
|
-
"",
|
|
86
85
|
];
|
|
86
|
+
if (milestone.dependsOn && milestone.dependsOn.length > 0) {
|
|
87
|
+
lines.push(`**dependsOn:** ${milestone.dependsOn.join(", ")}`);
|
|
88
|
+
}
|
|
89
|
+
lines.push("");
|
|
87
90
|
for (const wave of milestone.waves) {
|
|
88
91
|
const agentCount = wave.agents.length;
|
|
89
92
|
lines.push(`**Wave ${wave.waveNumber} (${agentCount} agent${agentCount !== 1 ? "s" : ""} parallel):**`);
|
|
@@ -203,4 +206,22 @@ export function writePRDToFile(data, outputPath) {
|
|
|
203
206
|
mkdirSync(dirname(outputPath), { recursive: true });
|
|
204
207
|
writeFileSync(outputPath, markdown, "utf-8");
|
|
205
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Write a PRD to a worktree directory.
|
|
211
|
+
*
|
|
212
|
+
* Validates and generates the PRD markdown, then writes it to
|
|
213
|
+
* `<worktreePath>/<relativePrdPath>`. Returns both the absolute path
|
|
214
|
+
* and the relative path so callers can locate the file or merge it
|
|
215
|
+
* back to the main working tree.
|
|
216
|
+
*
|
|
217
|
+
* @param data - The PRD data to generate and write.
|
|
218
|
+
* @param worktreePath - Absolute path to the worktree root.
|
|
219
|
+
* @param relativePrdPath - Path relative to the worktree root where
|
|
220
|
+
* the PRD should be written (e.g. "tasks/prd.md").
|
|
221
|
+
*/
|
|
222
|
+
export function writePRDToWorktree(data, worktreePath, relativePrdPath) {
|
|
223
|
+
const prdPath = join(worktreePath, relativePrdPath);
|
|
224
|
+
writePRDToFile(data, prdPath);
|
|
225
|
+
return { prdPath, relativePath: relativePrdPath };
|
|
226
|
+
}
|
|
206
227
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/spec/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS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AS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACxC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAWD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAa,EACb,YAAoB,EACpB,eAAuB;IAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IACpD,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AACpD,CAAC"}
|
package/dist/spec/interview.d.ts
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* The interview leads with recommendations derived from codebase scan results,
|
|
6
6
|
* follows interesting threads based on user responses, and determines when
|
|
7
7
|
* enough info has been gathered for each PRD section.
|
|
8
|
+
*
|
|
9
|
+
* **Rendering contract:** {@link InterviewQuestion} objects are designed to be
|
|
10
|
+
* rendered via Claude Code's **AskUserQuestion** tool with structured
|
|
11
|
+
* multiple-choice options — they must NEVER be printed as numbered text in
|
|
12
|
+
* chat. The caller (the /forge:spec skill) is responsible for converting each
|
|
13
|
+
* question's `text` and `context` fields into an AskUserQuestion call with
|
|
14
|
+
* 2-4 predefined options derived from scan context, plus an "Other" escape
|
|
15
|
+
* hatch for free-text input.
|
|
8
16
|
*/
|
|
9
17
|
import type { ScanAllResult } from "./scanner.js";
|
|
10
18
|
/** PRD sections in priority order */
|
|
@@ -12,12 +20,22 @@ export declare const PRD_SECTIONS: readonly ["problem_and_goals", "user_stories"
|
|
|
12
20
|
export type PRDSection = (typeof PRD_SECTIONS)[number];
|
|
13
21
|
/** Human-readable labels for each section */
|
|
14
22
|
export declare const SECTION_LABELS: Record<PRDSection, string>;
|
|
15
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* A single interview question.
|
|
25
|
+
*
|
|
26
|
+
* **Rendering:** Must be presented to the user via Claude Code's
|
|
27
|
+
* AskUserQuestion tool with 2-4 multiple-choice options — NEVER as numbered
|
|
28
|
+
* text in chat output. The `text` field becomes the AskUserQuestion question
|
|
29
|
+
* string, and the `context` field provides scan-derived framing that informs
|
|
30
|
+
* option generation.
|
|
31
|
+
*/
|
|
16
32
|
export interface InterviewQuestion {
|
|
17
33
|
id: string;
|
|
18
34
|
section: PRDSection;
|
|
35
|
+
/** The question to present via AskUserQuestion */
|
|
19
36
|
text: string;
|
|
20
|
-
/** Recommendation or observation
|
|
37
|
+
/** Recommendation or observation from the codebase scan that motivates
|
|
38
|
+
* this question and informs the multiple-choice options */
|
|
21
39
|
context: string;
|
|
22
40
|
/** Follow-up depth — 0 = top-level, 1+ = follow-up */
|
|
23
41
|
depth: number;
|
package/dist/spec/interview.js
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* The interview leads with recommendations derived from codebase scan results,
|
|
6
6
|
* follows interesting threads based on user responses, and determines when
|
|
7
7
|
* enough info has been gathered for each PRD section.
|
|
8
|
+
*
|
|
9
|
+
* **Rendering contract:** {@link InterviewQuestion} objects are designed to be
|
|
10
|
+
* rendered via Claude Code's **AskUserQuestion** tool with structured
|
|
11
|
+
* multiple-choice options — they must NEVER be printed as numbered text in
|
|
12
|
+
* chat. The caller (the /forge:spec skill) is responsible for converting each
|
|
13
|
+
* question's `text` and `context` fields into an AskUserQuestion call with
|
|
14
|
+
* 2-4 predefined options derived from scan context, plus an "Other" escape
|
|
15
|
+
* hatch for free-text input.
|
|
8
16
|
*/
|
|
9
17
|
// ---------------------------------------------------------------------------
|
|
10
18
|
// Types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interview.js","sourceRoot":"","sources":["../../src/spec/interview.ts"],"names":[],"m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,aAAa,CAAC,IAAI,CAAC;gBACjB,OAAO,EAAE,oBAAoB;gBAC7B,IAAI,EAAE,0HAA0H;gBAChI,OAAO,EAAE,uDAAuD;gBAChE,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,CAAC;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/spec/scanner.d.ts
CHANGED
|
@@ -43,3 +43,37 @@ export declare function scanStructure(projectDir: string): Promise<StructureScan
|
|
|
43
43
|
export declare function scanRoutes(projectDir: string): Promise<RoutesScanResult>;
|
|
44
44
|
export declare function scanDataAPIs(projectDir: string): Promise<DataAPIsScanResult>;
|
|
45
45
|
export declare function scanAll(projectDir: string): Promise<ScanAllResult>;
|
|
46
|
+
export interface SpecSessionOptions {
|
|
47
|
+
/** Main project directory to scan. */
|
|
48
|
+
projectDir: string;
|
|
49
|
+
/** Git repo root (defaults to detected from projectDir). */
|
|
50
|
+
repoRoot?: string;
|
|
51
|
+
/** User name for worktree branch naming (defaults to git config). */
|
|
52
|
+
userName?: string;
|
|
53
|
+
/** Project slug for worktree naming (e.g. "my-feature"). */
|
|
54
|
+
slug?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SpecSession {
|
|
57
|
+
sessionId: string;
|
|
58
|
+
worktreePath: string;
|
|
59
|
+
worktreeBranch: string;
|
|
60
|
+
scanResult: ScanAllResult;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Start a spec session: create worktree, register session, scan project.
|
|
64
|
+
*
|
|
65
|
+
* The caller should use `worktreePath` to write PRD files (via
|
|
66
|
+
* `writePRDToWorktree`), then call `completeSpecSession` when done.
|
|
67
|
+
* The scan runs against `projectDir` (the real codebase), not the worktree.
|
|
68
|
+
*/
|
|
69
|
+
export declare function startSpecSession(options: SpecSessionOptions): Promise<SpecSession>;
|
|
70
|
+
/**
|
|
71
|
+
* Complete a spec session: commit PRD files in the worktree, merge the
|
|
72
|
+
* worktree branch into `targetBranch`, deregister session, and remove
|
|
73
|
+
* the worktree.
|
|
74
|
+
*
|
|
75
|
+
* @param repoRoot - The main repo root directory.
|
|
76
|
+
* @param session - The spec session returned by `startSpecSession`.
|
|
77
|
+
* @param targetBranch - The branch to merge the PRD files into.
|
|
78
|
+
*/
|
|
79
|
+
export declare function completeSpecSession(repoRoot: string, session: SpecSession, targetBranch: string): void;
|
package/dist/spec/scanner.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
2
3
|
import { join, relative, extname, basename } from "node:path";
|
|
4
|
+
import { createWorktree, removeWorktree, getRepoRoot } from "../worktree/manager.js";
|
|
5
|
+
import { registerSession, deregisterSession, updateSessionStatus } from "../worktree/session.js";
|
|
6
|
+
import { getCurrentUser } from "../worktree/identity.js";
|
|
3
7
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
4
8
|
const IGNORE_DIRS = new Set([
|
|
5
9
|
"node_modules", ".git", "dist", "build", ".next", ".nuxt",
|
|
@@ -470,4 +474,93 @@ export async function scanAll(projectDir) {
|
|
|
470
474
|
]);
|
|
471
475
|
return { structure, routes, dataAPIs };
|
|
472
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Start a spec session: create worktree, register session, scan project.
|
|
479
|
+
*
|
|
480
|
+
* The caller should use `worktreePath` to write PRD files (via
|
|
481
|
+
* `writePRDToWorktree`), then call `completeSpecSession` when done.
|
|
482
|
+
* The scan runs against `projectDir` (the real codebase), not the worktree.
|
|
483
|
+
*/
|
|
484
|
+
export async function startSpecSession(options) {
|
|
485
|
+
const repoRoot = options.repoRoot ?? getRepoRoot(options.projectDir);
|
|
486
|
+
const user = getCurrentUser(repoRoot);
|
|
487
|
+
const userName = options.userName ?? user.name;
|
|
488
|
+
const slug = options.slug ?? "spec";
|
|
489
|
+
const branchName = `forge/${userName}/spec-${slug}`;
|
|
490
|
+
// 1. Create a worktree for isolation
|
|
491
|
+
const wt = createWorktree(repoRoot, `spec-${slug}`, userName, {
|
|
492
|
+
branchName,
|
|
493
|
+
});
|
|
494
|
+
// 2. Register the session
|
|
495
|
+
const session = registerSession(repoRoot, {
|
|
496
|
+
user,
|
|
497
|
+
skill: "spec",
|
|
498
|
+
branch: wt.branch,
|
|
499
|
+
worktreePath: wt.worktreePath,
|
|
500
|
+
});
|
|
501
|
+
// 3. Scan the main project directory (not the worktree)
|
|
502
|
+
let scanResult;
|
|
503
|
+
try {
|
|
504
|
+
scanResult = await scanAll(options.projectDir);
|
|
505
|
+
}
|
|
506
|
+
catch (err) {
|
|
507
|
+
// Cleanup on scan failure
|
|
508
|
+
deregisterSession(repoRoot, session.id);
|
|
509
|
+
removeWorktree(repoRoot, wt.worktreePath);
|
|
510
|
+
throw err;
|
|
511
|
+
}
|
|
512
|
+
return {
|
|
513
|
+
sessionId: session.id,
|
|
514
|
+
worktreePath: wt.worktreePath,
|
|
515
|
+
worktreeBranch: wt.branch,
|
|
516
|
+
scanResult,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Complete a spec session: commit PRD files in the worktree, merge the
|
|
521
|
+
* worktree branch into `targetBranch`, deregister session, and remove
|
|
522
|
+
* the worktree.
|
|
523
|
+
*
|
|
524
|
+
* @param repoRoot - The main repo root directory.
|
|
525
|
+
* @param session - The spec session returned by `startSpecSession`.
|
|
526
|
+
* @param targetBranch - The branch to merge the PRD files into.
|
|
527
|
+
*/
|
|
528
|
+
export function completeSpecSession(repoRoot, session, targetBranch) {
|
|
529
|
+
try {
|
|
530
|
+
// Mark session as completing
|
|
531
|
+
updateSessionStatus(repoRoot, session.sessionId, "completing");
|
|
532
|
+
// 1. Stage and commit all new/changed files in the worktree
|
|
533
|
+
try {
|
|
534
|
+
execSync("git add -A", {
|
|
535
|
+
cwd: session.worktreePath,
|
|
536
|
+
encoding: "utf-8",
|
|
537
|
+
stdio: "pipe",
|
|
538
|
+
});
|
|
539
|
+
execSync('git commit -m "spec: add PRD from spec session"', {
|
|
540
|
+
cwd: session.worktreePath,
|
|
541
|
+
encoding: "utf-8",
|
|
542
|
+
stdio: "pipe",
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
// No changes to commit — that's fine, the worktree may be empty
|
|
547
|
+
}
|
|
548
|
+
// 2. Checkout the target branch, then merge the worktree branch into it
|
|
549
|
+
execSync(`git checkout ${targetBranch}`, {
|
|
550
|
+
cwd: repoRoot,
|
|
551
|
+
encoding: "utf-8",
|
|
552
|
+
stdio: "pipe",
|
|
553
|
+
});
|
|
554
|
+
execSync(`git merge --no-edit ${session.worktreeBranch}`, {
|
|
555
|
+
cwd: repoRoot,
|
|
556
|
+
encoding: "utf-8",
|
|
557
|
+
stdio: "pipe",
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
// 3. Always clean up: deregister + remove worktree
|
|
562
|
+
deregisterSession(repoRoot, session.sessionId);
|
|
563
|
+
removeWorktree(repoRoot, session.worktreePath);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
473
566
|
//# sourceMappingURL=scanner.js.map
|