stonecut 1.2.1 → 1.4.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.
- package/README.md +10 -10
- package/package.json +4 -1
- package/src/cli.ts +31 -333
- package/src/execute.ts +159 -0
- package/src/git.ts +1 -20
- package/src/import.ts +1 -1
- package/src/local.ts +28 -2
- package/src/logger.ts +4 -0
- package/src/prd.ts +136 -0
- package/src/runner.ts +42 -81
- package/src/runners/claude.ts +140 -56
- package/src/runners/codex.ts +134 -54
- package/src/runners/index.ts +4 -4
- package/src/skills/stonecut-issues/SKILL.md +4 -4
- package/src/skills/stonecut-prd/SKILL.md +1 -3
- package/src/skills/stonecut-review-architecture/SKILL.md +1 -1
- package/src/sources/github.ts +1 -12
- package/src/spawn.ts +22 -0
- package/src/sync-back.ts +88 -0
- package/src/types.ts +9 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Ideas can come from anywhere — Jira tickets, Slack threads, MCP servers, or ju
|
|
|
14
14
|
1. **`/stonecut-interview`** — Stress-test the idea. Get grilled on the plan until it's solid.
|
|
15
15
|
2. **`/stonecut-prd`** — Turn the validated idea into a PRD (local file or GitHub issue).
|
|
16
16
|
3. **`/stonecut-issues`** — Break the PRD into independently-grabbable issues (local markdown files or GitHub sub-issues).
|
|
17
|
-
4. **`stonecut import`** _(optional)_ — If the PRD lives in GitHub, import it and its issues into `.stonecut/`.
|
|
17
|
+
4. **`stonecut import`** _(optional)_ — If the PRD lives in GitHub, import it and its issues into `.stonecut/specs/`.
|
|
18
18
|
5. **`stonecut`** — Execute the issues sequentially with an agentic coding CLI.
|
|
19
19
|
|
|
20
20
|
**From a technical exploration:** `RFC issue → PRD → issues → execute`
|
|
@@ -83,7 +83,7 @@ Running bare `stonecut` starts the interactive run wizard — the primary workfl
|
|
|
83
83
|
|
|
84
84
|
### `stonecut` — Interactive wizard
|
|
85
85
|
|
|
86
|
-
Stonecut uses a local-first execution model: `stonecut run` always reads from `.stonecut/<name>/`. External sources like GitHub are handled via `stonecut import`, which pulls PRDs and issues into the local structure before execution.
|
|
86
|
+
Stonecut uses a local-first execution model: `stonecut run` always reads from `.stonecut/specs/<name>/`. External sources like GitHub are handled via `stonecut import`, which pulls PRDs and issues into the local structure before execution.
|
|
87
87
|
|
|
88
88
|
When flags are omitted, Stonecut prompts for each missing parameter:
|
|
89
89
|
|
|
@@ -100,7 +100,7 @@ stonecut -i all
|
|
|
100
100
|
|
|
101
101
|
You can also use `stonecut run` explicitly — it's identical to bare `stonecut`.
|
|
102
102
|
|
|
103
|
-
The wizard scans `.stonecut/*/` for local PRDs and presents them with completion counts (e.g. "my-feature (3/7 done)"). An "Import from GitHub" option is always available at the bottom of the list for importing PRDs inline.
|
|
103
|
+
The wizard scans `.stonecut/specs/*/` for local PRDs and presents them with completion counts (e.g. "my-feature (3/7 done)"). An "Import from GitHub" option is always available at the bottom of the list for importing PRDs inline.
|
|
104
104
|
|
|
105
105
|
Flags provided via CLI skip the corresponding prompts. When all flags are given, the command runs without any prompts.
|
|
106
106
|
|
|
@@ -143,7 +143,7 @@ When config is present, the wizard uses these as default values — you can hit
|
|
|
143
143
|
|
|
144
144
|
### `stonecut import` — Import from external sources
|
|
145
145
|
|
|
146
|
-
Pulls a PRD and its sub-issues from an external source into `.stonecut/<name>/` so they can be executed locally with `stonecut run`.
|
|
146
|
+
Pulls a PRD and its sub-issues from an external source into `.stonecut/specs/<name>/` so they can be executed locally with `stonecut run`.
|
|
147
147
|
|
|
148
148
|
```sh
|
|
149
149
|
# Import GitHub PRD #42 — spec name derived from PRD title
|
|
@@ -161,7 +161,7 @@ The import command:
|
|
|
161
161
|
1. Fetches the PRD content and title from the source.
|
|
162
162
|
2. Fetches all sub-issues, ordered by number.
|
|
163
163
|
3. Derives a local spec name from the PRD title (e.g. "Add user authentication" becomes `add-user-authentication`). Override with `--name`.
|
|
164
|
-
4. Writes `prd.md` and numbered issue files into `.stonecut/<name>/issues/`.
|
|
164
|
+
4. Writes `prd.md` and numbered issue files into `.stonecut/specs/<name>/issues/`.
|
|
165
165
|
5. Creates initial `status.json` and `progress.txt`.
|
|
166
166
|
|
|
167
167
|
Import errors if the spec directory already exists (to avoid overwriting in-progress work). Use `--force` to overwrite intentionally.
|
|
@@ -220,7 +220,7 @@ When issues imported from GitHub are completed, Stonecut automatically closes th
|
|
|
220
220
|
|
|
221
221
|
| Flag | Short | Required | Description |
|
|
222
222
|
| -------------- | ----- | -------- | ------------------------------------------------------------------------ |
|
|
223
|
-
| `--local` | — | No | Local PRD name (`.stonecut/<name>/`). Prompted if omitted.
|
|
223
|
+
| `--local` | — | No | Local PRD name (`.stonecut/specs/<name>/`). Prompted if omitted. |
|
|
224
224
|
| `--iterations` | `-i` | No | Positive integer or `all`. Prompted with default `all` if omitted. |
|
|
225
225
|
| `--runner` | — | No | Agentic CLI runner (`claude`, `codex`). Default from config or `claude`. |
|
|
226
226
|
|
|
@@ -260,10 +260,10 @@ For imported PRDs, the PR body includes a `Closes #<number>` reference to the pa
|
|
|
260
260
|
|
|
261
261
|
## Local PRD structure
|
|
262
262
|
|
|
263
|
-
All execution reads from `.stonecut/<name>/` directories with this structure:
|
|
263
|
+
All execution reads from `.stonecut/specs/<name>/` directories with this structure:
|
|
264
264
|
|
|
265
265
|
```
|
|
266
|
-
.stonecut/my-feature/
|
|
266
|
+
.stonecut/specs/my-feature/
|
|
267
267
|
├── prd.md # The full PRD
|
|
268
268
|
├── issues/
|
|
269
269
|
│ ├── 01-setup.md # Issue files, numbered for ordering
|
|
@@ -279,7 +279,7 @@ PRDs and issues are committed to git; runtime state (`status.json`, `progress.tx
|
|
|
279
279
|
|
|
280
280
|
Issue and PRD files support YAML frontmatter for metadata. Locally-authored files don't need frontmatter — it's added automatically by `stonecut import`.
|
|
281
281
|
|
|
282
|
-
**PRD frontmatter** (`.stonecut/<name>/prd.md`):
|
|
282
|
+
**PRD frontmatter** (`.stonecut/specs/<name>/prd.md`):
|
|
283
283
|
|
|
284
284
|
```markdown
|
|
285
285
|
---
|
|
@@ -291,7 +291,7 @@ title: Add user authentication
|
|
|
291
291
|
The actual PRD content starts here...
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
**Issue frontmatter** (`.stonecut/<name>/issues/01-setup.md`):
|
|
294
|
+
**Issue frontmatter** (`.stonecut/specs/<name>/issues/01-setup.md`):
|
|
295
295
|
|
|
296
296
|
```markdown
|
|
297
297
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stonecut",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "CLI that drives PRD-driven development with agentic coding CLIs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,11 +27,14 @@
|
|
|
27
27
|
"lint": "eslint src/ tests/",
|
|
28
28
|
"format": "prettier --write .",
|
|
29
29
|
"format:check": "prettier --check .",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
30
31
|
"test": "bun test",
|
|
31
32
|
"prepare": "husky"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
35
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.92",
|
|
34
36
|
"@clack/prompts": "^0.10.0",
|
|
37
|
+
"@openai/codex-sdk": "^0.118.0",
|
|
35
38
|
"commander": "^13.1.0"
|
|
36
39
|
},
|
|
37
40
|
"lint-staged": {
|
package/src/cli.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Stonecut CLI — PRD-driven development workflow orchestrator.
|
|
5
5
|
*
|
|
6
|
+
* Commander definitions, validation helpers, wizard prompts, and entry point.
|
|
6
7
|
* Modules throw errors; only this file catches them, formats user-facing
|
|
7
8
|
* messages, and calls process.exit().
|
|
8
9
|
*/
|
|
@@ -10,27 +11,15 @@
|
|
|
10
11
|
import * as clack from "@clack/prompts";
|
|
11
12
|
import { Command, InvalidArgumentError } from "commander";
|
|
12
13
|
import { createRequire } from "module";
|
|
13
|
-
import {
|
|
14
|
-
checkoutOrCreateBranch,
|
|
15
|
-
createPr,
|
|
16
|
-
defaultBranch,
|
|
17
|
-
ensureCleanTree,
|
|
18
|
-
pushBranch,
|
|
19
|
-
} from "./git";
|
|
20
|
-
import { LocalSource } from "./local";
|
|
14
|
+
import { defaultBranch, ensureCleanTree } from "./git";
|
|
21
15
|
import { slugifyBranchComponent } from "./naming";
|
|
22
|
-
import { renderLocal } from "./prompt";
|
|
23
|
-
import { Logger } from "./logger";
|
|
24
|
-
import { defaultGitOps, runAfkLoop } from "./runner";
|
|
25
|
-
import { getRunner } from "./runners/index";
|
|
26
16
|
import { setupSkills, removeSkills } from "./skills";
|
|
27
17
|
import { init } from "./init";
|
|
28
18
|
import { importSpec } from "./import";
|
|
29
19
|
import { loadConfig } from "./config";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import type { Issue, IterationResult, Session } from "./types";
|
|
20
|
+
import { existsSync } from "fs";
|
|
21
|
+
import { promptForPrd } from "./prd";
|
|
22
|
+
import { executeLocal } from "./execute";
|
|
34
23
|
|
|
35
24
|
const require = createRequire(import.meta.url);
|
|
36
25
|
const { version } = require("../package.json");
|
|
@@ -75,292 +64,6 @@ export function validateRunSource(
|
|
|
75
64
|
return { kind: "prompt" };
|
|
76
65
|
}
|
|
77
66
|
|
|
78
|
-
/** A locally available PRD with its completion status. */
|
|
79
|
-
export interface LocalPrdEntry {
|
|
80
|
-
name: string;
|
|
81
|
-
completed: number;
|
|
82
|
-
total: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Scan .stonecut subdirectories for directories containing prd.md and compute
|
|
87
|
-
* completion counts from status.json.
|
|
88
|
-
*/
|
|
89
|
-
export function scanLocalPrds(baseDir: string = ".stonecut/prd"): LocalPrdEntry[] {
|
|
90
|
-
if (!existsSync(baseDir)) return [];
|
|
91
|
-
|
|
92
|
-
const entries: LocalPrdEntry[] = [];
|
|
93
|
-
for (const name of readdirSync(baseDir)) {
|
|
94
|
-
const specDir = join(baseDir, name);
|
|
95
|
-
if (!statSync(specDir).isDirectory()) continue;
|
|
96
|
-
if (!existsSync(join(specDir, "prd.md"))) continue;
|
|
97
|
-
|
|
98
|
-
const issuesDir = join(specDir, "issues");
|
|
99
|
-
let total = 0;
|
|
100
|
-
if (existsSync(issuesDir) && statSync(issuesDir).isDirectory()) {
|
|
101
|
-
total = readdirSync(issuesDir).filter((f) => f.endsWith(".md")).length;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let completed = 0;
|
|
105
|
-
const statusPath = join(specDir, "status.json");
|
|
106
|
-
if (existsSync(statusPath)) {
|
|
107
|
-
try {
|
|
108
|
-
const data = JSON.parse(readFileSync(statusPath, "utf-8"));
|
|
109
|
-
completed = Array.isArray(data.completed) ? data.completed.length : 0;
|
|
110
|
-
} catch {
|
|
111
|
-
// Malformed status.json — treat as 0 completed
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
entries.push({ name, completed, total });
|
|
116
|
-
}
|
|
117
|
-
return entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Format a PRD entry for display in the wizard.
|
|
122
|
-
*/
|
|
123
|
-
function formatPrdOption(entry: LocalPrdEntry): string {
|
|
124
|
-
if (entry.total === 0) return `${entry.name} (no issues)`;
|
|
125
|
-
if (entry.completed === 0) return `${entry.name} (not started)`;
|
|
126
|
-
return `${entry.name} (${entry.completed}/${entry.total} done)`;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** Sentinel value for the "Import from GitHub" wizard option. */
|
|
130
|
-
const IMPORT_FROM_GITHUB = "__import_from_github__";
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Prompt the user to select a local PRD or import from GitHub.
|
|
134
|
-
* Returns the local spec name to run.
|
|
135
|
-
*/
|
|
136
|
-
export async function promptForPrd(): Promise<{ kind: "local"; name: string }> {
|
|
137
|
-
const prds = scanLocalPrds();
|
|
138
|
-
|
|
139
|
-
const options: Array<{ value: string; label: string }> = prds.map((entry) => ({
|
|
140
|
-
value: entry.name,
|
|
141
|
-
label: formatPrdOption(entry),
|
|
142
|
-
}));
|
|
143
|
-
options.push({ value: IMPORT_FROM_GITHUB, label: "Import from GitHub" });
|
|
144
|
-
|
|
145
|
-
const selection = await clack.select({
|
|
146
|
-
message: "Select a PRD:",
|
|
147
|
-
options,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (clack.isCancel(selection)) {
|
|
151
|
-
throw new Error("Cancelled.");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (selection === IMPORT_FROM_GITHUB) {
|
|
155
|
-
const specName = await inlineGitHubImport();
|
|
156
|
-
return { kind: "local", name: specName };
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return { kind: "local", name: selection as string };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Inline GitHub import flow within the wizard.
|
|
164
|
-
* Lists PRDs by `prd` label, user picks one, import runs.
|
|
165
|
-
* Returns the imported spec name.
|
|
166
|
-
*/
|
|
167
|
-
async function inlineGitHubImport(): Promise<string> {
|
|
168
|
-
const provider = getSourceProvider("github");
|
|
169
|
-
const prdList = await provider.listPrds();
|
|
170
|
-
|
|
171
|
-
if (prdList.length === 0) {
|
|
172
|
-
throw new Error("No open PRDs with the 'prd' label found on GitHub.");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const prdOptions = prdList.map((p) => ({
|
|
176
|
-
value: String(p.number),
|
|
177
|
-
label: `#${p.number}: ${p.title}`,
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
const selected = await clack.select({
|
|
181
|
-
message: "Select a GitHub PRD to import:",
|
|
182
|
-
options: prdOptions,
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (clack.isCancel(selected)) {
|
|
186
|
-
throw new Error("Cancelled.");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const result = await importSpec({
|
|
190
|
-
provider: "github",
|
|
191
|
-
identifier: selected as string,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
console.log(
|
|
195
|
-
`Imported PRD #${result.prdIssueNumber} → ${result.specDir}/ (${result.issueCount} issues)`,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
return result.specName;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ---------------------------------------------------------------------------
|
|
202
|
-
// Stonecut report
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Build the Stonecut Report section for a PR body.
|
|
207
|
-
*/
|
|
208
|
-
export function buildReport(
|
|
209
|
-
results: IterationResult[],
|
|
210
|
-
runnerName: string,
|
|
211
|
-
prdNumber?: number,
|
|
212
|
-
): string {
|
|
213
|
-
const lines = ["## Stonecut Report", `**Runner:** ${runnerName}`, ""];
|
|
214
|
-
for (const r of results) {
|
|
215
|
-
if (r.success) {
|
|
216
|
-
lines.push(`- #${r.issueNumber} ${r.issueFilename}: completed`);
|
|
217
|
-
} else {
|
|
218
|
-
const reason = r.error || "unknown error";
|
|
219
|
-
lines.push(`- #${r.issueNumber} ${r.issueFilename}: failed — ${reason}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (prdNumber !== undefined && results.every((r) => r.success)) {
|
|
224
|
-
lines.push("");
|
|
225
|
-
lines.push(`Closes #${prdNumber}`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return lines.join("\n");
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ---------------------------------------------------------------------------
|
|
232
|
-
// Pre-execution flow
|
|
233
|
-
// ---------------------------------------------------------------------------
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Run pre-execution prompts and git checks.
|
|
237
|
-
* Returns [branch, baseBranch].
|
|
238
|
-
*/
|
|
239
|
-
export async function preExecution(
|
|
240
|
-
suggestedBranch: string,
|
|
241
|
-
prefilled?: { branch?: string; baseBranch?: string },
|
|
242
|
-
): Promise<[string, string]> {
|
|
243
|
-
let branch: string;
|
|
244
|
-
if (prefilled?.branch) {
|
|
245
|
-
branch = prefilled.branch;
|
|
246
|
-
} else {
|
|
247
|
-
const branchInput = await clack.text({
|
|
248
|
-
message: "Branch name:",
|
|
249
|
-
defaultValue: suggestedBranch,
|
|
250
|
-
placeholder: suggestedBranch,
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
if (clack.isCancel(branchInput)) {
|
|
254
|
-
throw new Error("Cancelled.");
|
|
255
|
-
}
|
|
256
|
-
branch = branchInput;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
let baseBranch: string;
|
|
260
|
-
if (prefilled?.baseBranch) {
|
|
261
|
-
baseBranch = prefilled.baseBranch;
|
|
262
|
-
} else {
|
|
263
|
-
const detectedDefault = defaultBranch();
|
|
264
|
-
const baseBranchInput = await clack.text({
|
|
265
|
-
message: "Base branch / PR target:",
|
|
266
|
-
defaultValue: detectedDefault,
|
|
267
|
-
placeholder: detectedDefault,
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
if (clack.isCancel(baseBranchInput)) {
|
|
271
|
-
throw new Error("Cancelled.");
|
|
272
|
-
}
|
|
273
|
-
baseBranch = baseBranchInput;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
checkoutOrCreateBranch(branch);
|
|
277
|
-
console.log("");
|
|
278
|
-
|
|
279
|
-
return [branch, baseBranch];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// ---------------------------------------------------------------------------
|
|
283
|
-
// Post-loop: push and conditionally create PR
|
|
284
|
-
// ---------------------------------------------------------------------------
|
|
285
|
-
|
|
286
|
-
export async function pushAndMaybePr(
|
|
287
|
-
results: IterationResult[],
|
|
288
|
-
source: { getRemainingCount(): Promise<[number, number]> },
|
|
289
|
-
branch: string,
|
|
290
|
-
baseBranch: string,
|
|
291
|
-
prTitle: string,
|
|
292
|
-
runnerName: string,
|
|
293
|
-
logger: { log(message: string): void },
|
|
294
|
-
prdNumber?: number,
|
|
295
|
-
): Promise<void> {
|
|
296
|
-
if (!results.some((r) => r.success)) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
pushBranch(branch);
|
|
301
|
-
logger.log(`Pushed branch '${branch}'.`);
|
|
302
|
-
|
|
303
|
-
const [remaining, total] = await source.getRemainingCount();
|
|
304
|
-
if (remaining === 0) {
|
|
305
|
-
const body = buildReport(results, runnerName, prdNumber);
|
|
306
|
-
createPr(prTitle, body, baseBranch);
|
|
307
|
-
logger.log("Created PR.");
|
|
308
|
-
} else {
|
|
309
|
-
logger.log(`${remaining}/${total} issues remaining — PR deferred.`);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// ---------------------------------------------------------------------------
|
|
314
|
-
// Execution paths
|
|
315
|
-
// ---------------------------------------------------------------------------
|
|
316
|
-
|
|
317
|
-
export async function runLocal(
|
|
318
|
-
name: string,
|
|
319
|
-
iterations: number | "all",
|
|
320
|
-
runnerName: string,
|
|
321
|
-
prefilled?: { branch?: string; baseBranch?: string },
|
|
322
|
-
): Promise<void> {
|
|
323
|
-
const runner = getRunner(runnerName);
|
|
324
|
-
const source = new LocalSource(name);
|
|
325
|
-
const prdIdentifier = slugifyBranchComponent(name) || "spec";
|
|
326
|
-
const logger = new Logger(prdIdentifier);
|
|
327
|
-
|
|
328
|
-
const session: Session = { logger, git: defaultGitOps, runner, runnerName };
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
const suggestedBranch = prdIdentifier ? `stonecut/${prdIdentifier}` : "stonecut/spec";
|
|
332
|
-
const [branch, baseBranch] = await preExecution(suggestedBranch, prefilled);
|
|
333
|
-
|
|
334
|
-
const prdContent = await source.getPrdContent();
|
|
335
|
-
const results = await runAfkLoop<Issue>(
|
|
336
|
-
source,
|
|
337
|
-
iterations,
|
|
338
|
-
(issue) =>
|
|
339
|
-
renderLocal({
|
|
340
|
-
prdContent,
|
|
341
|
-
issueNumber: issue.number,
|
|
342
|
-
issueFilename: issue.filename,
|
|
343
|
-
issueContent: issue.content,
|
|
344
|
-
}),
|
|
345
|
-
(issue) => issue.filename,
|
|
346
|
-
(issue) => `Issue ${issue.number}: ${issue.filename}`,
|
|
347
|
-
session,
|
|
348
|
-
);
|
|
349
|
-
|
|
350
|
-
await pushAndMaybePr(
|
|
351
|
-
results,
|
|
352
|
-
source,
|
|
353
|
-
branch,
|
|
354
|
-
baseBranch,
|
|
355
|
-
`Stonecut: ${name}`,
|
|
356
|
-
runnerName,
|
|
357
|
-
logger,
|
|
358
|
-
);
|
|
359
|
-
} finally {
|
|
360
|
-
logger.close();
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
67
|
// ---------------------------------------------------------------------------
|
|
365
68
|
// Program definition
|
|
366
69
|
// ---------------------------------------------------------------------------
|
|
@@ -378,17 +81,17 @@ export function buildProgram(): Command {
|
|
|
378
81
|
program
|
|
379
82
|
.command("run", { isDefault: true })
|
|
380
83
|
.description("Execute issues from a local PRD.")
|
|
381
|
-
.option("--local <name>", "Local PRD name (.stonecut/
|
|
84
|
+
.option("--local <name>", "Local PRD name (.stonecut/specs/<name>/)")
|
|
382
85
|
.option("-i, --iterations <value>", "Number of issues to process, or 'all'")
|
|
86
|
+
.option("--branch <name>", "Branch name for the run")
|
|
87
|
+
.option("--base-branch <name>", "Base branch / PR target")
|
|
383
88
|
.option("--runner <name>", "Agentic CLI runner (claude, codex)")
|
|
384
89
|
.action(async (opts) => {
|
|
385
90
|
ensureCleanTree();
|
|
386
|
-
|
|
387
91
|
const config = loadConfig();
|
|
388
92
|
|
|
389
93
|
const validated = validateRunSource(opts.local);
|
|
390
94
|
let source: { kind: "local"; name: string };
|
|
391
|
-
|
|
392
95
|
if (validated.kind === "local") {
|
|
393
96
|
source = validated;
|
|
394
97
|
} else {
|
|
@@ -419,40 +122,45 @@ export function buildProgram(): Command {
|
|
|
419
122
|
}
|
|
420
123
|
|
|
421
124
|
const isWizard = validated.kind === "prompt" || needsIterationPrompt;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (!existsSync(".stonecut")) {
|
|
426
|
-
console.log("Hint: run `stonecut init` to set up project config and gitignore.\n");
|
|
427
|
-
}
|
|
125
|
+
if (isWizard && !existsSync(".stonecut")) {
|
|
126
|
+
console.log("Hint: run `stonecut init` to set up project config and gitignore.\n");
|
|
127
|
+
}
|
|
428
128
|
|
|
129
|
+
let branch: string;
|
|
130
|
+
if (opts.branch) {
|
|
131
|
+
branch = opts.branch;
|
|
132
|
+
} else {
|
|
429
133
|
const branchPrefix = config?.branchPrefix ?? "stonecut/";
|
|
430
134
|
const suggestedBranch = `${branchPrefix}${slugifyBranchComponent(source.name) || "spec"}`;
|
|
431
|
-
|
|
432
|
-
const branch = await clack.text({
|
|
135
|
+
const branchInput = await clack.text({
|
|
433
136
|
message: "Branch name:",
|
|
434
137
|
defaultValue: suggestedBranch,
|
|
435
138
|
placeholder: suggestedBranch,
|
|
436
139
|
});
|
|
437
|
-
if (clack.isCancel(
|
|
140
|
+
if (clack.isCancel(branchInput)) {
|
|
438
141
|
throw new Error("Cancelled.");
|
|
439
142
|
}
|
|
143
|
+
branch = branchInput;
|
|
144
|
+
}
|
|
440
145
|
|
|
146
|
+
let baseBranch: string;
|
|
147
|
+
if (opts.baseBranch) {
|
|
148
|
+
baseBranch = opts.baseBranch;
|
|
149
|
+
} else {
|
|
441
150
|
const detectedDefault = config?.baseBranch ?? defaultBranch();
|
|
442
|
-
const
|
|
151
|
+
const baseBranchInput = await clack.text({
|
|
443
152
|
message: "Base branch / PR target:",
|
|
444
153
|
defaultValue: detectedDefault,
|
|
445
154
|
placeholder: detectedDefault,
|
|
446
155
|
});
|
|
447
|
-
if (clack.isCancel(
|
|
156
|
+
if (clack.isCancel(baseBranchInput)) {
|
|
448
157
|
throw new Error("Cancelled.");
|
|
449
158
|
}
|
|
450
|
-
|
|
451
|
-
prefilled = { branch, baseBranch };
|
|
159
|
+
baseBranch = baseBranchInput;
|
|
452
160
|
}
|
|
453
161
|
|
|
454
162
|
const runnerName: string = opts.runner ?? config?.runner ?? "claude";
|
|
455
|
-
await
|
|
163
|
+
await executeLocal(source.name, branch, baseBranch, iterations, runnerName);
|
|
456
164
|
});
|
|
457
165
|
|
|
458
166
|
program
|
|
@@ -473,14 +181,12 @@ export function buildProgram(): Command {
|
|
|
473
181
|
if (opts.github === undefined) {
|
|
474
182
|
throw new Error("Specify a source: --github <number>");
|
|
475
183
|
}
|
|
476
|
-
|
|
477
184
|
const result = await importSpec({
|
|
478
185
|
provider: "github",
|
|
479
186
|
identifier: String(opts.github),
|
|
480
187
|
name: opts.name,
|
|
481
188
|
force: opts.force,
|
|
482
189
|
});
|
|
483
|
-
|
|
484
190
|
console.log(
|
|
485
191
|
`Imported PRD #${result.prdIssueNumber} → ${result.specDir}/ (${result.issueCount} issues)`,
|
|
486
192
|
);
|
|
@@ -495,12 +201,8 @@ export function buildProgram(): Command {
|
|
|
495
201
|
)
|
|
496
202
|
.action((opts) => {
|
|
497
203
|
const result = setupSkills(opts.target);
|
|
498
|
-
for (const msg of result.messages)
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
for (const warn of result.warnings) {
|
|
502
|
-
console.error(warn);
|
|
503
|
-
}
|
|
204
|
+
for (const msg of result.messages) console.log(msg);
|
|
205
|
+
for (const warn of result.warnings) console.error(warn);
|
|
504
206
|
});
|
|
505
207
|
|
|
506
208
|
program
|
|
@@ -512,12 +214,8 @@ export function buildProgram(): Command {
|
|
|
512
214
|
)
|
|
513
215
|
.action((opts) => {
|
|
514
216
|
const result = removeSkills(opts.target);
|
|
515
|
-
for (const msg of result.messages)
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
for (const warn of result.warnings) {
|
|
519
|
-
console.error(warn);
|
|
520
|
-
}
|
|
217
|
+
for (const msg of result.messages) console.log(msg);
|
|
218
|
+
for (const warn of result.warnings) console.error(warn);
|
|
521
219
|
});
|
|
522
220
|
|
|
523
221
|
return program;
|