@letra-ai/cli 0.3.0 → 0.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/dist/client/assets/index-BDvDDvsh.css +1 -0
- package/dist/client/assets/index-CUvZ9Y9b.js +84 -0
- package/dist/client/index.html +13 -0
- package/dist/index.js +1042 -669
- package/package.json +2 -35
- package/.letra/adapters/opencode.json +0 -21
- package/.letra/brand/logo-01-terminal.svg +0 -6
- package/.letra/brand/logo-02-bookmark.svg +0 -6
- package/.letra/brand/logo-03-diamond.svg +0 -7
- package/.letra/constitution.md +0 -35
- package/.letra/context.md +0 -29
- package/.letra/decisions/flow-mvp-escopo-enxuto-3-comandos-valor-imediato.md +0 -35
- package/.letra/glossary.md +0 -21
- package/.letra/lessons-learned.md +0 -20
- package/.letra/specs/_template.md +0 -27
- package/.letra/specs/adapter-claude-code/acceptance.md +0 -6
- package/.letra/specs/adapter-claude-code/spec.md +0 -27
- package/.letra/specs/adapter-codex-cli/acceptance.md +0 -6
- package/.letra/specs/adapter-codex-cli/spec.md +0 -27
- package/.letra/specs/adapter-cursor/acceptance.md +0 -6
- package/.letra/specs/adapter-cursor/spec.md +0 -29
- package/.letra/specs/adapter-opencode/acceptance.md +0 -6
- package/.letra/specs/adapter-opencode/spec.md +0 -35
- package/.letra/specs/adapter-vscode/acceptance.md +0 -6
- package/.letra/specs/adapter-vscode/spec.md +0 -29
- package/.letra/specs/adapter-windsurf/acceptance.md +0 -6
- package/.letra/specs/adapter-windsurf/spec.md +0 -27
- package/.letra/specs/ci-cd-pipeline/acceptance.md +0 -6
- package/.letra/specs/ci-cd-pipeline/spec.md +0 -30
- package/.letra/specs/cli-skeleton/acceptance.md +0 -7
- package/.letra/specs/cli-skeleton/spec.md +0 -30
- package/.letra/specs/decision-new/acceptance.md +0 -7
- package/.letra/specs/decision-new/spec.md +0 -29
- package/.letra/specs/flow-edit-diff/acceptance.md +0 -7
- package/.letra/specs/flow-edit-diff/spec.md +0 -30
- package/.letra/specs/flow-export-import/acceptance.md +0 -7
- package/.letra/specs/flow-export-import/spec.md +0 -27
- package/.letra/specs/flow-mvp/roadmap.md +0 -40
- package/.letra/specs/flow-mvp/spec.md +0 -40
- package/.letra/specs/flow-serve/spec.md +0 -47
- package/.letra/specs/flow-visualize/acceptance.md +0 -7
- package/.letra/specs/flow-visualize/spec.md +0 -28
- package/.letra/specs/init-interactive/acceptance.md +0 -7
- package/.letra/specs/init-interactive/spec.md +0 -29
- package/.letra/specs/session-focus/acceptance.md +0 -7
- package/.letra/specs/session-focus/spec.md +0 -30
- package/.letra/specs/spec-templates-domain/acceptance.md +0 -7
- package/.letra/specs/spec-templates-domain/spec.md +0 -29
- package/.letra/specs/validate-config/acceptance.md +0 -9
- package/.letra/specs/validate-config/spec.md +0 -32
- package/.letra/specs/validate-conflict/acceptance.md +0 -7
- package/.letra/specs/validate-conflict/spec.md +0 -29
- package/.letra/specs/validate-format-pr/acceptance.md +0 -7
- package/.letra/specs/validate-format-pr/spec.md +0 -28
- package/.letra/specs/validate-intelligence/acceptance.md +0 -9
- package/.letra/specs/validate-intelligence/spec.md +0 -30
- package/.letra/specs/validate-watch/acceptance.md +0 -7
- package/.letra/specs/validate-watch/spec.md +0 -29
- package/.letra/workflow.json +0 -47
- package/.letra/workspace.schema.json +0 -32
- package/LICENSE +0 -21
- package/README.md +0 -240
package/dist/index.js
CHANGED
|
@@ -2,18 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { readFileSync as readFileSync11 } from "fs";
|
|
5
|
-
import { join as join13, resolve as
|
|
6
|
-
import { fileURLToPath as
|
|
5
|
+
import { join as join13, resolve as resolve16 } from "path";
|
|
6
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
7
7
|
import { Command as Command4 } from "commander";
|
|
8
8
|
|
|
9
9
|
// src/commands/decision.ts
|
|
10
|
-
import {
|
|
11
|
-
existsSync,
|
|
12
|
-
mkdirSync,
|
|
13
|
-
readFileSync,
|
|
14
|
-
readdirSync,
|
|
15
|
-
writeFileSync
|
|
16
|
-
} from "fs";
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
17
11
|
import { join, resolve } from "path";
|
|
18
12
|
import chalk from "chalk";
|
|
19
13
|
import { Command } from "commander";
|
|
@@ -35,9 +29,7 @@ function decisionCommand() {
|
|
|
35
29
|
}
|
|
36
30
|
if (existsSync(filePath)) {
|
|
37
31
|
console.log(
|
|
38
|
-
chalk.red(
|
|
39
|
-
`Decision "${slug}" already exists at .letra/decisions/${slug}.md`
|
|
40
|
-
)
|
|
32
|
+
chalk.red(`Decision "${slug}" already exists at .letra/decisions/${slug}.md`)
|
|
41
33
|
);
|
|
42
34
|
return;
|
|
43
35
|
}
|
|
@@ -59,19 +51,13 @@ What was decided?
|
|
|
59
51
|
What are the trade-offs? What does this enable or prevent?
|
|
60
52
|
`;
|
|
61
53
|
writeFileSync(filePath, content);
|
|
62
|
-
console.log(
|
|
63
|
-
chalk.green(
|
|
64
|
-
`Decision "${slug}" created at .letra/decisions/${slug}.md`
|
|
65
|
-
)
|
|
66
|
-
);
|
|
54
|
+
console.log(chalk.green(`Decision "${slug}" created at .letra/decisions/${slug}.md`));
|
|
67
55
|
});
|
|
68
56
|
cmd.command("list").description("Lista todos os Architecture Decision Records").action(() => {
|
|
69
57
|
const root = resolve(process.cwd());
|
|
70
58
|
const decisionsDir = join(root, ".letra", "decisions");
|
|
71
59
|
if (!existsSync(decisionsDir)) {
|
|
72
|
-
console.log(
|
|
73
|
-
chalk.yellow("No decisions directory found at .letra/decisions/")
|
|
74
|
-
);
|
|
60
|
+
console.log(chalk.yellow("No decisions directory found at .letra/decisions/"));
|
|
75
61
|
return;
|
|
76
62
|
}
|
|
77
63
|
const files = readdirSync(decisionsDir).filter((f) => f.endsWith(".md")).sort();
|
|
@@ -104,12 +90,12 @@ import ora from "ora";
|
|
|
104
90
|
function askText(query, defaultValue) {
|
|
105
91
|
if (!process.stdin.isTTY) return Promise.resolve(defaultValue);
|
|
106
92
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
107
|
-
return new Promise((
|
|
93
|
+
return new Promise((resolve17) => {
|
|
108
94
|
const formatted = `${chalk2.cyan(query)} ${chalk2.gray(`(default: ${defaultValue})`)}
|
|
109
95
|
> `;
|
|
110
96
|
rl.question(formatted, (answer) => {
|
|
111
97
|
rl.close();
|
|
112
|
-
|
|
98
|
+
resolve17(answer.trim() || defaultValue);
|
|
113
99
|
});
|
|
114
100
|
});
|
|
115
101
|
}
|
|
@@ -119,8 +105,7 @@ function detectExistingTools(root) {
|
|
|
119
105
|
if (existsSync2(join2(root, "CLAUDE.md"))) tools.push("claude-code");
|
|
120
106
|
if (existsSync2(join2(root, ".windsurfrules"))) tools.push("windsurf");
|
|
121
107
|
if (existsSync2(join2(root, "AGENTS.md"))) tools.push("opencode");
|
|
122
|
-
if (existsSync2(join2(root, ".github", "copilot-instructions.md")))
|
|
123
|
-
tools.push("vscode");
|
|
108
|
+
if (existsSync2(join2(root, ".github", "copilot-instructions.md"))) tools.push("vscode");
|
|
124
109
|
return tools;
|
|
125
110
|
}
|
|
126
111
|
function detectProjectName(root) {
|
|
@@ -163,13 +148,23 @@ function loadWorkflow(root) {
|
|
|
163
148
|
function saveWorkflow(root, workflow) {
|
|
164
149
|
const dir = join2(root, ".letra");
|
|
165
150
|
if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
|
|
166
|
-
|
|
151
|
+
const filePath = workflowFilePath(root);
|
|
152
|
+
if (existsSync2(filePath)) {
|
|
153
|
+
const backupDir = join2(root, ".letra", "backups");
|
|
154
|
+
if (!existsSync2(backupDir)) mkdirSync2(backupDir, { recursive: true });
|
|
155
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
156
|
+
const backupPath = join2(backupDir, `workflow-${ts}.json`);
|
|
157
|
+
try {
|
|
158
|
+
const existing = readFileSync2(filePath, "utf-8");
|
|
159
|
+
writeFileSync2(backupPath, existing, "utf-8");
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
writeFileSync2(filePath, JSON.stringify(workflow, null, 2));
|
|
167
164
|
}
|
|
168
165
|
async function flowInit(root, options) {
|
|
169
166
|
if (!process.stdin.isTTY && !options?.quick) {
|
|
170
|
-
console.log(
|
|
171
|
-
chalk2.yellow("Non-TTY: usando defaults. Passe --quick para confirmar.")
|
|
172
|
-
);
|
|
167
|
+
console.log(chalk2.yellow("Non-TTY: usando defaults. Passe --quick para confirmar."));
|
|
173
168
|
return flowInitQuick(root);
|
|
174
169
|
}
|
|
175
170
|
if (options?.quick) {
|
|
@@ -202,10 +197,7 @@ async function flowInitQuick(root) {
|
|
|
202
197
|
const detected = detectExistingTools(root);
|
|
203
198
|
const defaultTools = detected.length > 0 ? detected.join(", ") : "cursor, opencode";
|
|
204
199
|
const name = await askText("Workflow name?", defaultName);
|
|
205
|
-
const stagesInput = await askText(
|
|
206
|
-
"Stages (comma-separated)?",
|
|
207
|
-
defaultStagesList
|
|
208
|
-
);
|
|
200
|
+
const stagesInput = await askText("Stages (comma-separated)?", defaultStagesList);
|
|
209
201
|
const stages = stagesFromInput(stagesInput);
|
|
210
202
|
const toolsInput = await askText("Tools (comma-separated)?", defaultTools);
|
|
211
203
|
const tools = toolsInput.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
@@ -224,9 +216,7 @@ async function flowInitAction(targetPath, options) {
|
|
|
224
216
|
const root = resolve2(process.cwd(), targetPath || ".");
|
|
225
217
|
const filePath = workflowFilePath(root);
|
|
226
218
|
if (existsSync2(filePath)) {
|
|
227
|
-
console.log(
|
|
228
|
-
chalk2.yellow("Workflow already exists at .letra/workflow.json")
|
|
229
|
-
);
|
|
219
|
+
console.log(chalk2.yellow("Workflow already exists at .letra/workflow.json"));
|
|
230
220
|
return;
|
|
231
221
|
}
|
|
232
222
|
const spinner = ora("Setting up workflow...").start();
|
|
@@ -238,18 +228,14 @@ async function flowInitAction(targetPath, options) {
|
|
|
238
228
|
spinner.succeed(chalk2.green("Workflow created at .letra/workflow.json"));
|
|
239
229
|
console.log("");
|
|
240
230
|
console.log(` Name: ${chalk2.cyan(workflow.name)}`);
|
|
241
|
-
console.log(
|
|
242
|
-
` Stages: ${chalk2.cyan(workflow.stages.map((s) => s.name).join(" \u2192 "))}`
|
|
243
|
-
);
|
|
231
|
+
console.log(` Stages: ${chalk2.cyan(workflow.stages.map((s) => s.name).join(" \u2192 "))}`);
|
|
244
232
|
console.log(` Tools: ${chalk2.cyan(workflow.tools.join(", "))}`);
|
|
245
233
|
console.log("");
|
|
246
234
|
console.log(" Next steps:");
|
|
247
235
|
console.log(
|
|
248
236
|
` ${chalk2.cyan("letra flow backlog add <desc>")} Add items to your backlog`
|
|
249
237
|
);
|
|
250
|
-
console.log(
|
|
251
|
-
` ${chalk2.cyan("letra flow board")} View your board`
|
|
252
|
-
);
|
|
238
|
+
console.log(` ${chalk2.cyan("letra flow board")} View your board`);
|
|
253
239
|
} catch (error) {
|
|
254
240
|
spinner.fail(chalk2.red("Failed to create workflow"));
|
|
255
241
|
process.exit(1);
|
|
@@ -281,9 +267,7 @@ function backlogAdd(root, description) {
|
|
|
281
267
|
}
|
|
282
268
|
const workflow = workflowExists(root);
|
|
283
269
|
if (!workflow) {
|
|
284
|
-
console.log(
|
|
285
|
-
chalk3.red("No workflow found. Run 'letra flow init --quick' first")
|
|
286
|
-
);
|
|
270
|
+
console.log(chalk3.red("No workflow found. Run 'letra flow init --quick' first"));
|
|
287
271
|
process.exit(1);
|
|
288
272
|
}
|
|
289
273
|
if (workflow.stages.length === 0) {
|
|
@@ -307,9 +291,7 @@ function backlogAdd(root, description) {
|
|
|
307
291
|
function backlogList(root) {
|
|
308
292
|
const workflow = workflowExists(root);
|
|
309
293
|
if (!workflow) {
|
|
310
|
-
console.log(
|
|
311
|
-
chalk3.yellow("No workflow found. Run 'letra flow init --quick' first")
|
|
312
|
-
);
|
|
294
|
+
console.log(chalk3.yellow("No workflow found. Run 'letra flow init --quick' first"));
|
|
313
295
|
return;
|
|
314
296
|
}
|
|
315
297
|
if (workflow.items.length === 0) {
|
|
@@ -325,9 +307,7 @@ function backlogList(root) {
|
|
|
325
307
|
for (const item of workflow.items) {
|
|
326
308
|
const stageName2 = stageNames.get(item.stage) || item.stage;
|
|
327
309
|
const created = new Date(item.createdAt);
|
|
328
|
-
const age = Math.floor(
|
|
329
|
-
(Date.now() - created.getTime()) / (1e3 * 60 * 60 * 24)
|
|
330
|
-
);
|
|
310
|
+
const age = Math.floor((Date.now() - created.getTime()) / (1e3 * 60 * 60 * 24));
|
|
331
311
|
const ageStr = age === 0 ? "today" : `${age}d`;
|
|
332
312
|
const desc = item.description.length > 28 ? `${item.description.slice(0, 27)}\u2026` : item.description.padEnd(30);
|
|
333
313
|
console.log(
|
|
@@ -350,17 +330,13 @@ import { resolve as resolve4 } from "path";
|
|
|
350
330
|
import chalk4 from "chalk";
|
|
351
331
|
function ageLabel(createdAt) {
|
|
352
332
|
const created = new Date(createdAt);
|
|
353
|
-
const age = Math.floor(
|
|
354
|
-
(Date.now() - created.getTime()) / (1e3 * 60 * 60 * 24)
|
|
355
|
-
);
|
|
333
|
+
const age = Math.floor((Date.now() - created.getTime()) / (1e3 * 60 * 60 * 24));
|
|
356
334
|
return age === 0 ? "today" : `${age}d`;
|
|
357
335
|
}
|
|
358
336
|
function flowBoard(root) {
|
|
359
337
|
const workflow = loadWorkflow(root);
|
|
360
338
|
if (!workflow) {
|
|
361
|
-
console.log(
|
|
362
|
-
chalk4.yellow("No workflow found. Run 'letra flow init --quick' first")
|
|
363
|
-
);
|
|
339
|
+
console.log(chalk4.yellow("No workflow found. Run 'letra flow init --quick' first"));
|
|
364
340
|
return;
|
|
365
341
|
}
|
|
366
342
|
console.log(`
|
|
@@ -431,13 +407,9 @@ function loadVersion(root, version) {
|
|
|
431
407
|
function getLatestBackupVersion(root) {
|
|
432
408
|
const dir = join3(root, ".letra");
|
|
433
409
|
if (!existsSync3(dir)) return null;
|
|
434
|
-
const files = readdirSync2(dir).filter(
|
|
435
|
-
(f) => f.startsWith("workflow.v") && f.endsWith(".json")
|
|
436
|
-
);
|
|
410
|
+
const files = readdirSync2(dir).filter((f) => f.startsWith("workflow.v") && f.endsWith(".json"));
|
|
437
411
|
if (files.length === 0) return null;
|
|
438
|
-
const versions = files.map(
|
|
439
|
-
(f) => f.replace("workflow.v", "").replace(".json", "")
|
|
440
|
-
);
|
|
412
|
+
const versions = files.map((f) => f.replace("workflow.v", "").replace(".json", ""));
|
|
441
413
|
versions.sort((a, b) => {
|
|
442
414
|
const pa = a.split(".").map(Number);
|
|
443
415
|
const pb = b.split(".").map(Number);
|
|
@@ -454,9 +426,7 @@ function backupFilePath(root, version) {
|
|
|
454
426
|
function flowEdit(root, options) {
|
|
455
427
|
const workflow = loadWorkflow(root);
|
|
456
428
|
if (!workflow) {
|
|
457
|
-
console.log(
|
|
458
|
-
chalk5.yellow("No workflow found. Run 'letra flow init --quick' first")
|
|
459
|
-
);
|
|
429
|
+
console.log(chalk5.yellow("No workflow found. Run 'letra flow init --quick' first"));
|
|
460
430
|
return;
|
|
461
431
|
}
|
|
462
432
|
const currentVersion = normalizeVersion(workflow.version);
|
|
@@ -563,9 +533,7 @@ function flowDiff(root, v1, v2) {
|
|
|
563
533
|
const wf1 = loadVersion(root, stripVPrefix(v1));
|
|
564
534
|
const wf2 = loadVersion(root, stripVPrefix(v2));
|
|
565
535
|
if (!wf1 && !wf2) {
|
|
566
|
-
console.log(
|
|
567
|
-
chalk5.yellow(`No backups found for versions ${v1} and ${v2}`)
|
|
568
|
-
);
|
|
536
|
+
console.log(chalk5.yellow(`No backups found for versions ${v1} and ${v2}`));
|
|
569
537
|
return;
|
|
570
538
|
}
|
|
571
539
|
if (!wf1) {
|
|
@@ -587,9 +555,7 @@ function flowDiff(root, v1, v2) {
|
|
|
587
555
|
}
|
|
588
556
|
const backup = loadBackup(root, latestVersion);
|
|
589
557
|
if (!backup) {
|
|
590
|
-
console.log(
|
|
591
|
-
chalk5.yellow(`Failed to load backup version ${latestVersion}`)
|
|
592
|
-
);
|
|
558
|
+
console.log(chalk5.yellow(`Failed to load backup version ${latestVersion}`));
|
|
593
559
|
return;
|
|
594
560
|
}
|
|
595
561
|
const diff = computeDiff(backup, current);
|
|
@@ -651,39 +617,229 @@ function flowImport(root, filePath) {
|
|
|
651
617
|
const imported = parsed;
|
|
652
618
|
const existingWorkflow = loadWorkflow(root);
|
|
653
619
|
if (existingWorkflow) {
|
|
654
|
-
const backup = join4(
|
|
655
|
-
root,
|
|
656
|
-
".letra",
|
|
657
|
-
`workflow.v${existingWorkflow.version}.json`
|
|
658
|
-
);
|
|
620
|
+
const backup = join4(root, ".letra", `workflow.v${existingWorkflow.version}.json`);
|
|
659
621
|
if (!existsSync4(backup)) {
|
|
660
622
|
writeFileSync4(backup, JSON.stringify(existingWorkflow, null, 2));
|
|
661
623
|
console.log(
|
|
662
|
-
chalk6.gray(
|
|
663
|
-
`Backup saved: .letra/workflow.v${existingWorkflow.version}.json`
|
|
664
|
-
)
|
|
624
|
+
chalk6.gray(`Backup saved: .letra/workflow.v${existingWorkflow.version}.json`)
|
|
665
625
|
);
|
|
666
626
|
}
|
|
667
627
|
}
|
|
668
628
|
imported.createdAt = now4();
|
|
669
629
|
imported.updatedAt = now4();
|
|
670
630
|
saveWorkflow(root, imported);
|
|
671
|
-
console.log(
|
|
672
|
-
chalk6.green(`Workflow imported: ${imported.name} (${imported.version})`)
|
|
673
|
-
);
|
|
631
|
+
console.log(chalk6.green(`Workflow imported: ${imported.name} (${imported.version})`));
|
|
674
632
|
}
|
|
675
633
|
function flowImportAction(targetPath, filePath) {
|
|
676
634
|
const root = resolve6(process.cwd(), targetPath || ".");
|
|
677
635
|
flowImport(root, filePath);
|
|
678
636
|
}
|
|
679
637
|
|
|
680
|
-
// src/commands/flow-
|
|
681
|
-
import {
|
|
682
|
-
import { join as join5, resolve as resolve7 } from "path";
|
|
638
|
+
// src/commands/flow-import-issues.ts
|
|
639
|
+
import { resolve as resolve7 } from "path";
|
|
683
640
|
import chalk7 from "chalk";
|
|
684
641
|
function now5() {
|
|
685
642
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
686
643
|
}
|
|
644
|
+
function nextItemId2(workflow) {
|
|
645
|
+
let max = 0;
|
|
646
|
+
for (const item of workflow.items) {
|
|
647
|
+
const match = item.id.match(/^ITEM-(\d+)$/);
|
|
648
|
+
if (match) {
|
|
649
|
+
const num = Number.parseInt(match[1], 10);
|
|
650
|
+
if (num > max) max = num;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return `ITEM-${max + 1}`;
|
|
654
|
+
}
|
|
655
|
+
function ensureWorkflow(root) {
|
|
656
|
+
const workflow = loadWorkflow(root);
|
|
657
|
+
if (!workflow) {
|
|
658
|
+
console.log(chalk7.red("No workflow found. Run 'letra flow init --quick' first"));
|
|
659
|
+
process.exit(1);
|
|
660
|
+
}
|
|
661
|
+
if (workflow.stages.length === 0) {
|
|
662
|
+
console.log(chalk7.red("Workflow has no stages defined"));
|
|
663
|
+
process.exit(1);
|
|
664
|
+
}
|
|
665
|
+
return workflow;
|
|
666
|
+
}
|
|
667
|
+
async function backlogImportGitHub(root, repo, options) {
|
|
668
|
+
const workflow = ensureWorkflow(root);
|
|
669
|
+
const limit = options?.limit ?? 50;
|
|
670
|
+
const token = process.env.GITHUB_TOKEN;
|
|
671
|
+
const url = new URL(`https://api.github.com/repos/${repo}/issues`);
|
|
672
|
+
url.searchParams.set("state", "open");
|
|
673
|
+
url.searchParams.set("per_page", String(limit));
|
|
674
|
+
if (options?.label) {
|
|
675
|
+
url.searchParams.set("labels", options.label);
|
|
676
|
+
}
|
|
677
|
+
const headers = {
|
|
678
|
+
Accept: "application/vnd.github.v3+json",
|
|
679
|
+
"User-Agent": "letra-cli"
|
|
680
|
+
};
|
|
681
|
+
if (token) {
|
|
682
|
+
headers.Authorization = `Bearer ${token}`;
|
|
683
|
+
}
|
|
684
|
+
let response;
|
|
685
|
+
try {
|
|
686
|
+
response = await fetch(url.toString(), { headers });
|
|
687
|
+
} catch (err) {
|
|
688
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
689
|
+
console.log(chalk7.red(`Failed to fetch issues: ${msg}`));
|
|
690
|
+
process.exit(1);
|
|
691
|
+
}
|
|
692
|
+
if (!response.ok) {
|
|
693
|
+
const text = await response.text().catch(() => "unknown error");
|
|
694
|
+
if (response.status === 404) {
|
|
695
|
+
console.log(chalk7.red(`Repository "${repo}" not found or is private`));
|
|
696
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
697
|
+
console.log(chalk7.red(`GitHub API error (${response.status}). Check GITHUB_TOKEN`));
|
|
698
|
+
} else {
|
|
699
|
+
console.log(chalk7.red(`GitHub API error (${response.status}): ${text}`));
|
|
700
|
+
}
|
|
701
|
+
process.exit(1);
|
|
702
|
+
}
|
|
703
|
+
let issues;
|
|
704
|
+
try {
|
|
705
|
+
issues = await response.json();
|
|
706
|
+
} catch {
|
|
707
|
+
console.log(chalk7.red("Failed to parse GitHub response"));
|
|
708
|
+
process.exit(1);
|
|
709
|
+
}
|
|
710
|
+
issues = issues.filter((i) => !("pull_request" in i));
|
|
711
|
+
if (issues.length === 0) {
|
|
712
|
+
console.log(chalk7.yellow("No open issues found"));
|
|
713
|
+
return { imported: 0, total: 0 };
|
|
714
|
+
}
|
|
715
|
+
const firstStage = workflow.stages[0].id;
|
|
716
|
+
let imported = 0;
|
|
717
|
+
for (const issue of issues) {
|
|
718
|
+
const labels = issue.labels?.map((l) => l.name).join(", ") || "";
|
|
719
|
+
const description = labels ? `[${issue.number}] ${issue.title} (${labels})` : `[${issue.number}] ${issue.title}`;
|
|
720
|
+
const item = {
|
|
721
|
+
id: nextItemId2(workflow),
|
|
722
|
+
description,
|
|
723
|
+
stage: firstStage,
|
|
724
|
+
createdAt: now5(),
|
|
725
|
+
source: "github",
|
|
726
|
+
sourceUrl: issue.html_url
|
|
727
|
+
};
|
|
728
|
+
workflow.items.push(item);
|
|
729
|
+
imported++;
|
|
730
|
+
}
|
|
731
|
+
workflow.updatedAt = now5();
|
|
732
|
+
saveWorkflow(root, workflow);
|
|
733
|
+
console.log(
|
|
734
|
+
` ${chalk7.green("\u2713")} Imported ${chalk7.cyan(String(imported))} issue${imported !== 1 ? "s" : ""} from ${chalk7.cyan(repo)}`
|
|
735
|
+
);
|
|
736
|
+
return { imported, total: issues.length };
|
|
737
|
+
}
|
|
738
|
+
async function backlogImportLinear(root, team, options) {
|
|
739
|
+
const apiKey = process.env.LINEAR_API_KEY;
|
|
740
|
+
if (!apiKey) {
|
|
741
|
+
console.log(chalk7.red("LINEAR_API_KEY environment variable is required for Linear import"));
|
|
742
|
+
process.exit(1);
|
|
743
|
+
}
|
|
744
|
+
const workflow = ensureWorkflow(root);
|
|
745
|
+
const limit = options?.limit ?? 50;
|
|
746
|
+
const query = `
|
|
747
|
+
query($team: String!, $limit: Int!) {
|
|
748
|
+
team(key: $team) {
|
|
749
|
+
issues(first: $limit, filter: { state: { type: { in: [todo, inProgress] } } }) {
|
|
750
|
+
nodes {
|
|
751
|
+
id
|
|
752
|
+
title
|
|
753
|
+
url
|
|
754
|
+
identifier
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}`;
|
|
759
|
+
let response;
|
|
760
|
+
try {
|
|
761
|
+
response = await fetch("https://api.linear.app/graphql", {
|
|
762
|
+
method: "POST",
|
|
763
|
+
headers: {
|
|
764
|
+
"Content-Type": "application/json",
|
|
765
|
+
Authorization: apiKey
|
|
766
|
+
},
|
|
767
|
+
body: JSON.stringify({ query, variables: { team, limit } })
|
|
768
|
+
});
|
|
769
|
+
} catch (err) {
|
|
770
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
771
|
+
console.log(chalk7.red(`Failed to fetch Linear issues: ${msg}`));
|
|
772
|
+
process.exit(1);
|
|
773
|
+
}
|
|
774
|
+
if (!response.ok) {
|
|
775
|
+
const text = await response.text().catch(() => "unknown error");
|
|
776
|
+
if (response.status === 401) {
|
|
777
|
+
console.log(chalk7.red("Invalid Linear API key. Check LINEAR_API_KEY"));
|
|
778
|
+
} else {
|
|
779
|
+
console.log(chalk7.red(`Linear API error (${response.status}): ${text}`));
|
|
780
|
+
}
|
|
781
|
+
process.exit(1);
|
|
782
|
+
}
|
|
783
|
+
let data;
|
|
784
|
+
try {
|
|
785
|
+
data = await response.json();
|
|
786
|
+
} catch {
|
|
787
|
+
console.log(chalk7.red("Failed to parse Linear response"));
|
|
788
|
+
process.exit(1);
|
|
789
|
+
}
|
|
790
|
+
if (data.data?.team?.issues?.nodes == null) {
|
|
791
|
+
const errMsg = data?.data?.team == null ? `Team "${team}" not found` : "Failed to fetch Linear issues";
|
|
792
|
+
console.log(chalk7.red(errMsg));
|
|
793
|
+
process.exit(1);
|
|
794
|
+
}
|
|
795
|
+
const issues = data.data.team.issues.nodes;
|
|
796
|
+
if (issues.length === 0) {
|
|
797
|
+
console.log(chalk7.yellow(`No open issues found for team "${team}"`));
|
|
798
|
+
return { imported: 0, total: 0 };
|
|
799
|
+
}
|
|
800
|
+
const firstStage = workflow.stages[0].id;
|
|
801
|
+
let imported = 0;
|
|
802
|
+
for (const issue of issues) {
|
|
803
|
+
const description = `${issue.identifier} ${issue.title}`;
|
|
804
|
+
const item = {
|
|
805
|
+
id: nextItemId2(workflow),
|
|
806
|
+
description,
|
|
807
|
+
stage: firstStage,
|
|
808
|
+
createdAt: now5(),
|
|
809
|
+
source: "linear",
|
|
810
|
+
sourceUrl: issue.url
|
|
811
|
+
};
|
|
812
|
+
workflow.items.push(item);
|
|
813
|
+
imported++;
|
|
814
|
+
}
|
|
815
|
+
workflow.updatedAt = now5();
|
|
816
|
+
saveWorkflow(root, workflow);
|
|
817
|
+
console.log(
|
|
818
|
+
` ${chalk7.green("\u2713")} Imported ${chalk7.cyan(String(imported))} issue${imported !== 1 ? "s" : ""} from Linear team ${chalk7.cyan(team)}`
|
|
819
|
+
);
|
|
820
|
+
return { imported, total: issues.length };
|
|
821
|
+
}
|
|
822
|
+
async function backlogImportGitHubAction(targetPath, repo, options) {
|
|
823
|
+
const root = resolve7(process.cwd(), targetPath || ".");
|
|
824
|
+
await backlogImportGitHub(root, repo, {
|
|
825
|
+
label: options.label,
|
|
826
|
+
limit: options.limit ? Number(options.limit) : void 0
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
async function backlogImportLinearAction(targetPath, team, options) {
|
|
830
|
+
const root = resolve7(process.cwd(), targetPath || ".");
|
|
831
|
+
await backlogImportLinear(root, team, {
|
|
832
|
+
limit: options.limit ? Number(options.limit) : void 0
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// src/commands/flow-move.ts
|
|
837
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
838
|
+
import { join as join5, resolve as resolve8 } from "path";
|
|
839
|
+
import chalk8 from "chalk";
|
|
840
|
+
function now6() {
|
|
841
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
842
|
+
}
|
|
687
843
|
function resolveStage(workflow, input) {
|
|
688
844
|
const lower = input.toLowerCase();
|
|
689
845
|
for (const stage of workflow.stages) {
|
|
@@ -760,380 +916,133 @@ function generateAdapters(root, tools, content) {
|
|
|
760
916
|
const dir = join5(path, "..");
|
|
761
917
|
if (!existsSync5(dir)) mkdirSync3(dir, { recursive: true });
|
|
762
918
|
writeFileSync5(path, fileContent);
|
|
763
|
-
console.log(` ${
|
|
919
|
+
console.log(` ${chalk8.gray("Updated")} ${path.replace(`${root}/`, "")}`);
|
|
764
920
|
}
|
|
765
921
|
}
|
|
766
922
|
function flowMove(root, itemId, targetStageInput) {
|
|
767
923
|
const workflow = loadWorkflow(root);
|
|
768
924
|
if (!workflow) {
|
|
769
|
-
console.log(
|
|
770
|
-
chalk7.red("No workflow found. Run 'letra flow init --quick' first")
|
|
771
|
-
);
|
|
925
|
+
console.log(chalk8.red("No workflow found. Run 'letra flow init --quick' first"));
|
|
772
926
|
process.exit(1);
|
|
773
927
|
}
|
|
774
928
|
const item = workflow.items.find((i) => i.id === itemId) || workflow.items.find((i) => i.description === itemId);
|
|
775
929
|
if (!item) {
|
|
776
|
-
console.log(
|
|
930
|
+
console.log(chalk8.red(`Item "${itemId}" not found`));
|
|
777
931
|
process.exit(1);
|
|
778
932
|
}
|
|
779
933
|
const targetStageId = resolveStage(workflow, targetStageInput);
|
|
780
934
|
if (!targetStageId) {
|
|
781
935
|
const valid = workflow.stages.map((s) => `${s.id} (${s.name})`).join(", ");
|
|
782
|
-
console.log(
|
|
783
|
-
chalk7.red(
|
|
784
|
-
`Stage "${targetStageInput}" not found. Valid stages: ${valid}`
|
|
785
|
-
)
|
|
786
|
-
);
|
|
936
|
+
console.log(chalk8.red(`Stage "${targetStageInput}" not found. Valid stages: ${valid}`));
|
|
787
937
|
process.exit(1);
|
|
788
938
|
}
|
|
789
939
|
if (item.stage === targetStageId) {
|
|
790
|
-
console.log(
|
|
791
|
-
chalk7.yellow(`Item ${itemId} is already in stage "${targetStageId}"`)
|
|
792
|
-
);
|
|
940
|
+
console.log(chalk8.yellow(`Item ${itemId} is already in stage "${targetStageId}"`));
|
|
793
941
|
return;
|
|
794
942
|
}
|
|
795
943
|
const fromStage = workflow.stages.find((s) => s.id === item.stage)?.name || item.stage;
|
|
796
944
|
const toStage = workflow.stages.find((s) => s.id === targetStageId)?.name || targetStageId;
|
|
797
945
|
item.stage = targetStageId;
|
|
798
|
-
workflow.updatedAt =
|
|
946
|
+
workflow.updatedAt = now6();
|
|
799
947
|
saveWorkflow(root, workflow);
|
|
800
948
|
const stageNames = new Map(workflow.stages.map((s) => [s.id, s.name]));
|
|
801
949
|
const currentStageName = stageNames.get(targetStageId) || targetStageId;
|
|
802
|
-
const content = adapterContent(
|
|
803
|
-
workflow.name,
|
|
804
|
-
currentStageName,
|
|
805
|
-
workflow.items,
|
|
806
|
-
stageNames
|
|
807
|
-
);
|
|
950
|
+
const content = adapterContent(workflow.name, currentStageName, workflow.items, stageNames);
|
|
808
951
|
generateAdapters(root, workflow.tools, content);
|
|
809
952
|
console.log(
|
|
810
|
-
` ${
|
|
811
|
-
);
|
|
812
|
-
console.log(
|
|
813
|
-
` ${chalk7.gray("Adapters regenerated for:")} ${workflow.tools.join(", ")}`
|
|
953
|
+
` ${chalk8.green("\u2713")} Item ${chalk8.cyan(itemId)} moved: ${chalk8.yellow(fromStage)} \u2192 ${chalk8.green(toStage)}`
|
|
814
954
|
);
|
|
955
|
+
console.log(` ${chalk8.gray("Adapters regenerated for:")} ${workflow.tools.join(", ")}`);
|
|
815
956
|
}
|
|
816
957
|
function flowMoveAction(targetPath, itemId, options) {
|
|
817
|
-
const root =
|
|
958
|
+
const root = resolve8(process.cwd(), targetPath || ".");
|
|
818
959
|
flowMove(root, itemId, options.to);
|
|
819
960
|
}
|
|
820
961
|
|
|
821
962
|
// src/commands/flow-serve.ts
|
|
822
|
-
import {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
statSync,
|
|
827
|
-
watch
|
|
828
|
-
} from "fs";
|
|
829
|
-
import {
|
|
830
|
-
createServer
|
|
831
|
-
} from "http";
|
|
832
|
-
import { join as join6, resolve as resolve8 } from "path";
|
|
963
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync5, readdirSync as readdirSync3, watch, writeFileSync as writeFileSync6 } from "fs";
|
|
964
|
+
import { createServer } from "http";
|
|
965
|
+
import { dirname, extname, join as join6, resolve as resolve9 } from "path";
|
|
966
|
+
import { fileURLToPath } from "url";
|
|
833
967
|
var DEFAULT_PORT = 3e3;
|
|
834
|
-
function loadSpecs(root) {
|
|
968
|
+
function loadSpecs(root, workflow) {
|
|
969
|
+
const result = [];
|
|
970
|
+
if (workflow?.specLinks) {
|
|
971
|
+
for (const [id, link] of Object.entries(workflow.specLinks)) {
|
|
972
|
+
const filePath = join6(root, link.path);
|
|
973
|
+
if (existsSync6(filePath)) {
|
|
974
|
+
result.push({ id, content: readFileSync5(filePath, "utf-8") });
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
835
978
|
const specsDir = join6(root, ".letra", "specs");
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
const desc = item.description.toLowerCase();
|
|
847
|
-
return specs.find(
|
|
848
|
-
(s) => desc.includes(s.name.toLowerCase().replace(/-/g, " ")) || desc.includes(s.name.toLowerCase())
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
function boardHtml(workflow, specs = []) {
|
|
852
|
-
const stages = workflow?.stages ?? [];
|
|
853
|
-
const items = workflow?.items ?? [];
|
|
854
|
-
const itemsByStage = /* @__PURE__ */ new Map();
|
|
855
|
-
for (const s of stages) itemsByStage.set(s.id, []);
|
|
856
|
-
for (const it of items) {
|
|
857
|
-
const list = itemsByStage.get(it.stage);
|
|
858
|
-
if (list) list.push(it);
|
|
859
|
-
}
|
|
860
|
-
function ageLabel2(createdAt) {
|
|
861
|
-
const age = Math.floor(
|
|
862
|
-
(Date.now() - new Date(createdAt).getTime()) / (1e3 * 60 * 60 * 24)
|
|
863
|
-
);
|
|
864
|
-
if (age === 0) return "today";
|
|
865
|
-
if (age === 1) return "1d ago";
|
|
866
|
-
return `${age}d ago`;
|
|
867
|
-
}
|
|
868
|
-
const stageCards = stages.map((s) => {
|
|
869
|
-
const stageItems = itemsByStage.get(s.id) ?? [];
|
|
870
|
-
const itemsHtml = stageItems.length === 0 ? '<div class="empty">(empty)</div>' : stageItems.map((it) => {
|
|
871
|
-
const spec = findItemSpec(it, specs);
|
|
872
|
-
const specBtn = spec ? `<button class="spec-btn" data-spec="${esc(spec.name)}">spec</button>` : "";
|
|
873
|
-
return `<div class="item stage-${esc(s.id)}"><span class="item-id">${it.id}</span><span class="item-desc">${esc(it.description)}</span><span class="item-bottom">${specBtn}<span class="item-age">${ageLabel2(it.createdAt)}</span></span></div>`;
|
|
874
|
-
}).join("");
|
|
875
|
-
const count = stageItems.length;
|
|
876
|
-
return `<div class="stage stage-${esc(s.id)}"><h2>${esc(s.name)} <span class="count">${count} ${count === 1 ? "item" : "items"}</span></h2><div class="items">${itemsHtml}</div></div>`;
|
|
877
|
-
}).join("\n");
|
|
878
|
-
const name = workflow ? esc(workflow.name) : "No workflow";
|
|
879
|
-
const updatedAt = workflow ? new Date(workflow.updatedAt).toLocaleString() : "-";
|
|
880
|
-
return `<!DOCTYPE html>
|
|
881
|
-
<html lang="en">
|
|
882
|
-
<head>
|
|
883
|
-
<meta charset="UTF-8">
|
|
884
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
885
|
-
<title>${name} \u2014 Flow Board</title>
|
|
886
|
-
<style>
|
|
887
|
-
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
888
|
-
body {
|
|
889
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
890
|
-
background: #0f1117; color: #e1e4e8;
|
|
891
|
-
padding: 2rem 1rem; max-width: 1200px; margin: 0 auto;
|
|
892
|
-
}
|
|
893
|
-
header {
|
|
894
|
-
display: flex; justify-content: space-between; align-items: center;
|
|
895
|
-
}
|
|
896
|
-
.brand {
|
|
897
|
-
display: flex; align-items: center; gap: 0.625rem;
|
|
898
|
-
}
|
|
899
|
-
.brand svg { width: 36px; height: 36px; flex-shrink: 0; }
|
|
900
|
-
.brand-text { font-weight: 600; font-size: 1rem; color: #e1e4e8; }
|
|
901
|
-
.brand-text span { color: #8b949e; font-weight: 300; }
|
|
902
|
-
.header-status { color: #8b949e; font-size: 0.75rem; }
|
|
903
|
-
.live { color: #3fb950; }
|
|
904
|
-
.live::before { content: "\u25CF"; margin-right: 0.3rem; }
|
|
905
|
-
.project-desc { margin: 15px 0 1.5rem; }
|
|
906
|
-
.project-desc h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
|
|
907
|
-
.project-desc p { color: #8b949e; font-size: 0.9rem; line-height: 1.4; }
|
|
908
|
-
.board-scroll { overflow-x: auto; padding-bottom: 0.5rem; }
|
|
909
|
-
.board { display: flex; gap: 1rem; }
|
|
910
|
-
.stage {
|
|
911
|
-
flex: 0 0 280px; width: 280px;
|
|
912
|
-
background: #161b22; border: 1px solid #30363d; border-top: 3px solid #30363d;
|
|
913
|
-
border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem;
|
|
914
|
-
transition: border-top-color .2s;
|
|
915
|
-
}
|
|
916
|
-
.stage.stage-backlog { border-top-color: #8b949e; }
|
|
917
|
-
.stage.stage-design { border-top-color: #d29922; }
|
|
918
|
-
.stage.stage-code { border-top-color: #58a6ff; }
|
|
919
|
-
.stage.stage-review { border-top-color: #bc8cff; }
|
|
920
|
-
.stage.stage-done { border-top-color: #3fb950; }
|
|
921
|
-
.stage h2 { font-size: 1rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
|
|
922
|
-
.count { font-size: 0.7rem; color: #8b949e; font-weight: 400; background: rgba(139,148,158,0.1); padding: 0.15rem 0.5rem; border-radius: 10px; }
|
|
923
|
-
.items { display: flex; flex-direction: column; gap: 0.5rem; min-height: 2rem; }
|
|
924
|
-
.empty { color: #484f58; font-size: 0.8rem; padding: 0.75rem 0; text-align: center; border: 1px dashed #21262d; border-radius: 6px; }
|
|
925
|
-
.item {
|
|
926
|
-
background: #0f1117; border-radius: 8px; padding: 0.625rem 0.75rem;
|
|
927
|
-
display: flex; flex-direction: column; gap: 0.3rem;
|
|
928
|
-
border-left: 3px solid #30363d; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
|
|
929
|
-
transition: border-color .15s, transform .15s, box-shadow .15s;
|
|
930
|
-
}
|
|
931
|
-
.item:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.3); }
|
|
932
|
-
.item.stage-backlog { border-left-color: #8b949e; }
|
|
933
|
-
.item.stage-design { border-left-color: #d29922; }
|
|
934
|
-
.item.stage-code { border-left-color: #58a6ff; }
|
|
935
|
-
.item.stage-review { border-left-color: #bc8cff; }
|
|
936
|
-
.item.stage-done { border-left-color: #3fb950; }
|
|
937
|
-
.item-id {
|
|
938
|
-
font-family: monospace; font-size: 0.65rem; color: #58a6ff; font-weight: 600;
|
|
939
|
-
background: rgba(88,166,255,0.1); padding: 0.1rem 0.4rem; border-radius: 4px;
|
|
940
|
-
display: inline-block; width: fit-content;
|
|
941
|
-
}
|
|
942
|
-
.item-desc { font-size: 0.85rem; color: #e1e4e8; line-height: 1.35; margin-top: 0.1rem; }
|
|
943
|
-
.item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 0.2rem; }
|
|
944
|
-
.item-age { font-size: 0.65rem; color: #8b949e; }
|
|
945
|
-
.spec-btn {
|
|
946
|
-
background: none; border: 1px solid #30363d; border-radius: 4px;
|
|
947
|
-
color: #8b949e; font-size: 0.6rem; padding: 0.1rem 0.4rem;
|
|
948
|
-
cursor: pointer; font-family: monospace; transition: .15s;
|
|
949
|
-
}
|
|
950
|
-
.spec-btn:hover { border-color: #58a6ff; color: #58a6ff; background: rgba(88,166,255,0.08); }
|
|
951
|
-
.board-fade { animation: fadeIn .3s ease; }
|
|
952
|
-
@keyframes fadeIn { from { opacity: 0.5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
|
953
|
-
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
|
|
954
|
-
.modal.hidden { display: none; }
|
|
955
|
-
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
|
|
956
|
-
.modal-content {
|
|
957
|
-
position: relative; background: #161b22; border: 1px solid #30363d;
|
|
958
|
-
border-radius: 12px; max-width: 700px; width: 90%; max-height: 80vh;
|
|
959
|
-
display: flex; flex-direction: column;
|
|
960
|
-
}
|
|
961
|
-
.modal-header {
|
|
962
|
-
display: flex; justify-content: space-between; align-items: center;
|
|
963
|
-
padding: 1rem 1.25rem; border-bottom: 1px solid #30363d;
|
|
964
|
-
}
|
|
965
|
-
.modal-header h2 { font-size: 1rem; font-weight: 600; }
|
|
966
|
-
.modal-close {
|
|
967
|
-
background: none; border: none; color: #8b949e; font-size: 1.5rem;
|
|
968
|
-
cursor: pointer; line-height: 1; padding: 0;
|
|
969
|
-
}
|
|
970
|
-
.modal-close:hover { color: #e1e4e8; }
|
|
971
|
-
.modal-body {
|
|
972
|
-
padding: 1.25rem; overflow-y: auto; font-size: 0.875rem; line-height: 1.6;
|
|
973
|
-
white-space: pre-wrap; font-family: monospace; color: #e1e4e8;
|
|
974
|
-
}
|
|
975
|
-
.modal-body h1, .modal-body h2, .modal-body h3 { font-family: system-ui; margin: 1rem 0 0.5rem; }
|
|
976
|
-
.modal-body h1 { font-size: 1.2rem; }
|
|
977
|
-
.modal-body h2 { font-size: 1rem; color: #58a6ff; }
|
|
978
|
-
.modal-body h3 { font-size: 0.9rem; color: #d29922; }
|
|
979
|
-
.modal-body ul, .modal-body ol { padding-left: 1.5rem; margin: 0.5rem 0; }
|
|
980
|
-
.modal-body li { margin-bottom: 0.25rem; }
|
|
981
|
-
.modal-body code { background: #0f1117; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.8rem; }
|
|
982
|
-
.modal-body pre { background: #0f1117; padding: 0.75rem; border-radius: 6px; overflow-x: auto; margin: 0.5rem 0; }
|
|
983
|
-
.modal-body pre code { background: none; padding: 0; }
|
|
984
|
-
@media (max-width: 600px) {
|
|
985
|
-
.board { grid-template-columns: 1fr; }
|
|
986
|
-
body { padding: 1rem 0.5rem; }
|
|
979
|
+
const registered = new Set(result.map((s) => s.id));
|
|
980
|
+
if (existsSync6(specsDir)) {
|
|
981
|
+
for (const entry of readdirSync3(specsDir, { withFileTypes: true })) {
|
|
982
|
+
if (entry.isDirectory() && !registered.has(entry.name)) {
|
|
983
|
+
const specPath = join6(specsDir, entry.name, "spec.md");
|
|
984
|
+
if (existsSync6(specPath)) {
|
|
985
|
+
result.push({ id: entry.name, content: readFileSync5(specPath, "utf-8") });
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
987
989
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
<div class="modal-header">
|
|
1019
|
-
<h2 id="modalTitle"></h2>
|
|
1020
|
-
<button class="modal-close" id="modalClose">×</button>
|
|
1021
|
-
</div>
|
|
1022
|
-
<div class="modal-body" id="modalBody"></div>
|
|
1023
|
-
</div>
|
|
1024
|
-
</div>
|
|
1025
|
-
<script>
|
|
1026
|
-
var __specs = null;
|
|
1027
|
-
fetch("/api/specs").then(r => r.json()).then(s => { __specs = s; attachSpecButtons(); }).catch(() => {});
|
|
1028
|
-
const evtSource = new EventSource("/events");
|
|
1029
|
-
evtSource.addEventListener("workflow-updated", () => {
|
|
1030
|
-
document.getElementById("status").textContent = "refreshing...";
|
|
1031
|
-
fetch("/api/workflow")
|
|
1032
|
-
.then(r => r.json())
|
|
1033
|
-
.then(data => {
|
|
1034
|
-
document.getElementById("status").textContent = "updated " + new Date().toLocaleTimeString();
|
|
1035
|
-
renderBoard(data);
|
|
1036
|
-
})
|
|
1037
|
-
.catch(() => {
|
|
1038
|
-
document.getElementById("status").textContent = "update failed";
|
|
1039
|
-
});
|
|
1040
|
-
});
|
|
1041
|
-
evtSource.onerror = () => {
|
|
1042
|
-
document.getElementById("status").textContent = "disconnected";
|
|
1043
|
-
};
|
|
1044
|
-
function esc(s) {
|
|
1045
|
-
const d = document.createElement("div");
|
|
1046
|
-
d.textContent = s;
|
|
1047
|
-
return d.innerHTML;
|
|
1048
|
-
}
|
|
1049
|
-
function ageLabel(createdAt) {
|
|
1050
|
-
const age = Math.floor((Date.now() - new Date(createdAt).getTime()) / (1000 * 60 * 60 * 24));
|
|
1051
|
-
if (age === 0) return "today";
|
|
1052
|
-
if (age === 1) return "1d ago";
|
|
1053
|
-
return age + "d ago";
|
|
1054
|
-
}
|
|
1055
|
-
function matchSpec(desc, specs) {
|
|
1056
|
-
const lower = desc.toLowerCase();
|
|
1057
|
-
for (const s of specs) {
|
|
1058
|
-
if (lower.includes(s.name.replace(/-/g, " ")) || lower.includes(s.name)) return s.name;
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
var TEMPLATES = {
|
|
993
|
+
padrao: {
|
|
994
|
+
name: "Padr\xE3o",
|
|
995
|
+
stages: [
|
|
996
|
+
{ id: "backlog", name: "Backlog", zone: "todo" },
|
|
997
|
+
{ id: "design", name: "Design", zone: "doing" },
|
|
998
|
+
{ id: "code", name: "Code", zone: "doing" },
|
|
999
|
+
{ id: "review", name: "Review", zone: "doing" },
|
|
1000
|
+
{ id: "done", name: "Done", zone: "done" }
|
|
1001
|
+
]
|
|
1002
|
+
},
|
|
1003
|
+
kanban: {
|
|
1004
|
+
name: "Kanban",
|
|
1005
|
+
stages: [
|
|
1006
|
+
{ id: "todo", name: "A Fazer", zone: "todo" },
|
|
1007
|
+
{ id: "doing", name: "Fazendo", zone: "doing" },
|
|
1008
|
+
{ id: "done", name: "Feito", zone: "done" }
|
|
1009
|
+
]
|
|
1010
|
+
},
|
|
1011
|
+
agil: {
|
|
1012
|
+
name: "\xC1gil",
|
|
1013
|
+
stages: [
|
|
1014
|
+
{ id: "product-backlog", name: "Product Backlog", zone: "todo" },
|
|
1015
|
+
{ id: "sprint-backlog", name: "Sprint Backlog", zone: "todo" },
|
|
1016
|
+
{ id: "in-progress", name: "In Progress", zone: "doing" },
|
|
1017
|
+
{ id: "review", name: "Review", zone: "doing" },
|
|
1018
|
+
{ id: "done", name: "Done", zone: "done" }
|
|
1019
|
+
]
|
|
1059
1020
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
const list = itemsByStage[it.stage];
|
|
1068
|
-
if (list) list.push(it);
|
|
1069
|
-
}
|
|
1070
|
-
const html = sorted.map(s => {
|
|
1071
|
-
const stageItems = itemsByStage[s.id] || [];
|
|
1072
|
-
const itemsHtml = stageItems.length === 0
|
|
1073
|
-
? '<div class="empty">(empty)</div>'
|
|
1074
|
-
: stageItems.map(it => {
|
|
1075
|
-
const specName = matchSpec(it.description, __specs || []);
|
|
1076
|
-
const specBtn = specName ? '<button class="spec-btn" data-spec="' + esc(specName) + '">spec</button>' : "";
|
|
1077
|
-
return '<div class="item stage-' + esc(s.id) + '"><span class="item-id">' + esc(it.id) + '</span><span class="item-desc">' + esc(it.description) + '</span><span class="item-bottom">' + specBtn + '<span class="item-age">' + ageLabel(it.createdAt) + '</span></span></div>';
|
|
1078
|
-
}).join("");
|
|
1079
|
-
return '<div class="stage stage-' + esc(s.id) + '"><h2>' + esc(s.name) + ' <span class="count">' + stageItems.length + ' ' + (stageItems.length === 1 ? "item" : "items") + '</span></h2><div class="items">' + itemsHtml + '</div></div>';
|
|
1080
|
-
}).join("\\n");
|
|
1081
|
-
const board = document.getElementById("board");
|
|
1082
|
-
board.classList.remove("board-fade");
|
|
1083
|
-
board.innerHTML = html;
|
|
1084
|
-
void board.offsetWidth;
|
|
1085
|
-
board.classList.add("board-fade");
|
|
1086
|
-
document.getElementById("projectDesc").querySelector("h1").textContent = wf.name || "Flow Board";
|
|
1087
|
-
updateMeta(wf.updatedAt);
|
|
1088
|
-
attachSpecButtons();
|
|
1089
|
-
}
|
|
1090
|
-
function updateMeta(updatedAt) {
|
|
1091
|
-
const status = document.getElementById("status");
|
|
1092
|
-
if (status) status.textContent = "connected" + (updatedAt ? " \xB7 updated " + new Date(updatedAt).toLocaleString() : "");
|
|
1093
|
-
}
|
|
1094
|
-
function attachSpecButtons() {
|
|
1095
|
-
document.querySelectorAll(".spec-btn").forEach(btn => {
|
|
1096
|
-
btn.addEventListener("click", () => openSpec(btn.dataset.spec));
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
function openSpec(name) {
|
|
1100
|
-
const spec = (__specs || []).find(s => s.name === name);
|
|
1101
|
-
if (!spec) {
|
|
1102
|
-
document.getElementById("modalTitle").textContent = "Spec: " + name;
|
|
1103
|
-
document.getElementById("modalBody").textContent = "Loading...";
|
|
1104
|
-
document.getElementById("modal").classList.remove("hidden");
|
|
1105
|
-
fetch("/api/specs").then(r => r.json()).then(all => {
|
|
1106
|
-
__specs = all;
|
|
1107
|
-
const s = all.find(x => x.name === name);
|
|
1108
|
-
if (s) {
|
|
1109
|
-
document.getElementById("modalTitle").textContent = "Spec: " + name;
|
|
1110
|
-
document.getElementById("modalBody").textContent = s.content;
|
|
1111
|
-
}
|
|
1112
|
-
}).catch(() => {
|
|
1113
|
-
document.getElementById("modalBody").textContent = "Failed to load spec.";
|
|
1114
|
-
});
|
|
1115
|
-
return;
|
|
1021
|
+
};
|
|
1022
|
+
function createWorkflowFromTemplate(root, templateId, options) {
|
|
1023
|
+
const t = TEMPLATES[templateId];
|
|
1024
|
+
if (!t) {
|
|
1025
|
+
throw new Error(
|
|
1026
|
+
`Template "${templateId}" not found. Available: ${Object.keys(TEMPLATES).join(", ")}`
|
|
1027
|
+
);
|
|
1116
1028
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1135
|
-
function esc(s) {
|
|
1136
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1029
|
+
const stages = t.stages.map((s, i) => ({
|
|
1030
|
+
id: s.id,
|
|
1031
|
+
name: s.name,
|
|
1032
|
+
order: i,
|
|
1033
|
+
zone: s.zone
|
|
1034
|
+
}));
|
|
1035
|
+
const existing = loadWorkflow(root);
|
|
1036
|
+
return {
|
|
1037
|
+
version: "1.0",
|
|
1038
|
+
name: options?.name ?? detectProjectName(root) ?? t.name,
|
|
1039
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1040
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1041
|
+
stages,
|
|
1042
|
+
items: existing?.items ?? [],
|
|
1043
|
+
specLinks: existing?.specLinks ?? void 0,
|
|
1044
|
+
tools: options?.tools ?? existing?.tools ?? []
|
|
1045
|
+
};
|
|
1137
1046
|
}
|
|
1138
1047
|
var FlowServer = class {
|
|
1139
1048
|
server;
|
|
@@ -1162,23 +1071,479 @@ var FlowServer = class {
|
|
|
1162
1071
|
return;
|
|
1163
1072
|
}
|
|
1164
1073
|
if (path === "/api/workflow") {
|
|
1165
|
-
const
|
|
1074
|
+
const wf = this.loadWorkflow();
|
|
1166
1075
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1167
|
-
res.end(JSON.stringify(
|
|
1076
|
+
res.end(JSON.stringify(wf ?? { error: "No workflow found" }));
|
|
1168
1077
|
return;
|
|
1169
1078
|
}
|
|
1170
|
-
if (path === "/api/
|
|
1171
|
-
|
|
1079
|
+
if (path === "/api/workflow/template" && req.method === "POST") {
|
|
1080
|
+
let body = "";
|
|
1081
|
+
req.on("data", (chunk) => {
|
|
1082
|
+
body += chunk;
|
|
1083
|
+
});
|
|
1084
|
+
req.on("end", () => {
|
|
1085
|
+
try {
|
|
1086
|
+
const data = JSON.parse(body);
|
|
1087
|
+
let wf;
|
|
1088
|
+
if (data.stages) {
|
|
1089
|
+
const stages = data.stages.map(
|
|
1090
|
+
(s, i) => ({
|
|
1091
|
+
id: s.id,
|
|
1092
|
+
name: s.name,
|
|
1093
|
+
order: i,
|
|
1094
|
+
zone: s.zone
|
|
1095
|
+
})
|
|
1096
|
+
);
|
|
1097
|
+
const existing = loadWorkflow(this.root);
|
|
1098
|
+
wf = {
|
|
1099
|
+
version: "1.0",
|
|
1100
|
+
name: data.name ?? detectProjectName(this.root) ?? "Personalizado",
|
|
1101
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1102
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1103
|
+
stages,
|
|
1104
|
+
items: existing?.items ?? [],
|
|
1105
|
+
specLinks: existing?.specLinks ?? void 0,
|
|
1106
|
+
tools: data.tools ?? existing?.tools ?? []
|
|
1107
|
+
};
|
|
1108
|
+
} else {
|
|
1109
|
+
wf = createWorkflowFromTemplate(this.root, data.template, {
|
|
1110
|
+
name: data.name,
|
|
1111
|
+
tools: data.tools
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
saveWorkflow(this.root, wf);
|
|
1115
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1116
|
+
res.end(JSON.stringify(wf));
|
|
1117
|
+
} catch (e) {
|
|
1118
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1119
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
if (path === "/api/specs" && req.method === "GET") {
|
|
1125
|
+
try {
|
|
1126
|
+
const wf = this.loadWorkflow();
|
|
1127
|
+
const specs = loadSpecs(this.root, wf);
|
|
1128
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1129
|
+
res.end(JSON.stringify(specs));
|
|
1130
|
+
} catch {
|
|
1131
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1132
|
+
res.end(JSON.stringify([]));
|
|
1133
|
+
}
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
if (path === "/api/specs" && req.method === "POST") {
|
|
1137
|
+
let body = "";
|
|
1138
|
+
req.on("data", (chunk) => {
|
|
1139
|
+
body += chunk;
|
|
1140
|
+
});
|
|
1141
|
+
req.on("end", () => {
|
|
1142
|
+
try {
|
|
1143
|
+
const { id, content } = JSON.parse(body);
|
|
1144
|
+
if (!id || !content) {
|
|
1145
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1146
|
+
res.end(JSON.stringify({ error: "id and content required" }));
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const specDir = join6(this.root, ".letra", "specs", id);
|
|
1150
|
+
if (!existsSync6(specDir)) mkdirSync4(specDir, { recursive: true });
|
|
1151
|
+
writeFileSync6(join6(specDir, "spec.md"), content, "utf-8");
|
|
1152
|
+
const wf = this.loadWorkflow();
|
|
1153
|
+
if (wf) {
|
|
1154
|
+
if (!wf.specLinks) wf.specLinks = {};
|
|
1155
|
+
wf.specLinks[id] = { path: `.letra/specs/${id}/spec.md` };
|
|
1156
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1157
|
+
saveWorkflow(this.root, wf);
|
|
1158
|
+
this.broadcast();
|
|
1159
|
+
}
|
|
1160
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1161
|
+
res.end(JSON.stringify({ id, content }));
|
|
1162
|
+
} catch (e) {
|
|
1163
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1164
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (path.startsWith("/api/specs/") && req.method === "DELETE") {
|
|
1170
|
+
const specId = path.replace("/api/specs/", "").split("/")[0];
|
|
1171
|
+
if (!specId) {
|
|
1172
|
+
res.writeHead(400);
|
|
1173
|
+
res.end(JSON.stringify({ error: "spec id required" }));
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const specDir = join6(this.root, ".letra", "specs", specId);
|
|
1177
|
+
if (existsSync6(specDir)) {
|
|
1178
|
+
writeFileSync6(join6(specDir, "spec.md"), "", "utf-8");
|
|
1179
|
+
}
|
|
1180
|
+
const wf = this.loadWorkflow();
|
|
1181
|
+
if (wf?.specLinks) {
|
|
1182
|
+
delete wf.specLinks[specId];
|
|
1183
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1184
|
+
saveWorkflow(this.root, wf);
|
|
1185
|
+
this.broadcast();
|
|
1186
|
+
}
|
|
1172
1187
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1173
|
-
res.end(JSON.stringify(
|
|
1188
|
+
res.end(JSON.stringify({ deleted: specId }));
|
|
1174
1189
|
return;
|
|
1175
1190
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1191
|
+
if (path.startsWith("/api/specs/") && req.method === "PUT") {
|
|
1192
|
+
const specId = path.replace("/api/specs/", "").split("/")[0];
|
|
1193
|
+
if (!specId) {
|
|
1194
|
+
res.writeHead(400);
|
|
1195
|
+
res.end(JSON.stringify({ error: "spec id required" }));
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
let body = "";
|
|
1199
|
+
req.on("data", (chunk) => {
|
|
1200
|
+
body += chunk;
|
|
1201
|
+
});
|
|
1202
|
+
req.on("end", () => {
|
|
1203
|
+
try {
|
|
1204
|
+
const { content } = JSON.parse(body);
|
|
1205
|
+
if (content === void 0) {
|
|
1206
|
+
res.writeHead(400);
|
|
1207
|
+
res.end(JSON.stringify({ error: "content required" }));
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
const specDir = join6(this.root, ".letra", "specs", specId);
|
|
1211
|
+
if (!existsSync6(specDir)) mkdirSync4(specDir, { recursive: true });
|
|
1212
|
+
writeFileSync6(join6(specDir, "spec.md"), content, "utf-8");
|
|
1213
|
+
const wf = this.loadWorkflow();
|
|
1214
|
+
if (wf) {
|
|
1215
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1216
|
+
saveWorkflow(this.root, wf);
|
|
1217
|
+
this.broadcast();
|
|
1218
|
+
}
|
|
1219
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1220
|
+
res.end(JSON.stringify({ id: specId, content }));
|
|
1221
|
+
} catch (e) {
|
|
1222
|
+
res.writeHead(400);
|
|
1223
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
if (path.match(/^\/api\/specs\/[^/]+\/validate$/) && req.method === "POST") {
|
|
1229
|
+
const specId = path.replace("/api/specs/", "").split("/")[0];
|
|
1230
|
+
const specDir = join6(this.root, ".letra", "specs", specId);
|
|
1231
|
+
const specFile = join6(specDir, "spec.md");
|
|
1232
|
+
const issues = [];
|
|
1233
|
+
if (!existsSync6(specFile)) {
|
|
1234
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1235
|
+
res.end(
|
|
1236
|
+
JSON.stringify({
|
|
1237
|
+
id: specId,
|
|
1238
|
+
issues: [{ type: "error", msg: "spec.md not found" }],
|
|
1239
|
+
valid: false
|
|
1240
|
+
})
|
|
1241
|
+
);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const content = readFileSync5(specFile, "utf-8");
|
|
1245
|
+
const requiredSections = [
|
|
1246
|
+
"Outcome",
|
|
1247
|
+
"Constraints",
|
|
1248
|
+
"Exclusions",
|
|
1249
|
+
"Acceptance Criteria",
|
|
1250
|
+
"Context"
|
|
1251
|
+
];
|
|
1252
|
+
for (const section of requiredSections) {
|
|
1253
|
+
const re = new RegExp(`## ${section}`);
|
|
1254
|
+
if (!re.test(content)) {
|
|
1255
|
+
issues.push({ type: "error", msg: `Missing section: ## ${section}` });
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
const acMatch = content.match(/## Acceptance Criteria\s+([\s\S]*?)(?=\n## |$)/);
|
|
1259
|
+
if (acMatch) {
|
|
1260
|
+
const acSection = acMatch[1];
|
|
1261
|
+
const items = [...acSection.matchAll(/-\s+\[(\s|x)\]\s+/g)];
|
|
1262
|
+
if (items.length === 0) {
|
|
1263
|
+
issues.push({
|
|
1264
|
+
type: "warning",
|
|
1265
|
+
msg: "Acceptance Criteria section has no checklist items"
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
if (content.length > 3e3) {
|
|
1270
|
+
issues.push({ type: "warning", msg: "Spec exceeds 3000 chars (should be thin)" });
|
|
1271
|
+
}
|
|
1272
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1273
|
+
res.end(
|
|
1274
|
+
JSON.stringify({
|
|
1275
|
+
id: specId,
|
|
1276
|
+
issues,
|
|
1277
|
+
valid: issues.filter((i) => i.type === "error").length === 0
|
|
1278
|
+
})
|
|
1279
|
+
);
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
if (path === "/api/items" && req.method === "POST") {
|
|
1283
|
+
let body = "";
|
|
1284
|
+
req.on("data", (chunk) => {
|
|
1285
|
+
body += chunk;
|
|
1286
|
+
});
|
|
1287
|
+
req.on("end", () => {
|
|
1288
|
+
try {
|
|
1289
|
+
const { id, description, stage } = JSON.parse(body);
|
|
1290
|
+
if (!id || !description || !stage) {
|
|
1291
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1292
|
+
res.end(JSON.stringify({ error: "id, description, and stage required" }));
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
const wf = this.loadWorkflow();
|
|
1296
|
+
if (!wf) {
|
|
1297
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1298
|
+
res.end(JSON.stringify({ error: "No workflow" }));
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const item = {
|
|
1302
|
+
id,
|
|
1303
|
+
description,
|
|
1304
|
+
stage,
|
|
1305
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1306
|
+
tasks: []
|
|
1307
|
+
};
|
|
1308
|
+
wf.items.push(item);
|
|
1309
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1310
|
+
saveWorkflow(this.root, wf);
|
|
1311
|
+
this.broadcast();
|
|
1312
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1313
|
+
res.end(JSON.stringify(item));
|
|
1314
|
+
} catch (e) {
|
|
1315
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1316
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (path.match(/^\/api\/items\/[^/]+$/) && req.method === "PATCH") {
|
|
1322
|
+
const itemId = path.replace("/api/items/", "");
|
|
1323
|
+
let body = "";
|
|
1324
|
+
req.on("data", (chunk) => {
|
|
1325
|
+
body += chunk;
|
|
1326
|
+
});
|
|
1327
|
+
req.on("end", () => {
|
|
1328
|
+
try {
|
|
1329
|
+
const data = JSON.parse(body);
|
|
1330
|
+
const wf = this.loadWorkflow();
|
|
1331
|
+
if (!wf) {
|
|
1332
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1333
|
+
res.end(JSON.stringify({ error: "No workflow" }));
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const item = wf.items.find((i) => i.id === itemId);
|
|
1337
|
+
if (!item) {
|
|
1338
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1339
|
+
res.end(JSON.stringify({ error: "Item not found" }));
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
const oldStage = item.stage;
|
|
1343
|
+
if (data.stage !== void 0) item.stage = data.stage;
|
|
1344
|
+
if (data.description !== void 0) item.description = data.description;
|
|
1345
|
+
if (data.tasks !== void 0) item.tasks = data.tasks;
|
|
1346
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1347
|
+
saveWorkflow(this.root, wf);
|
|
1348
|
+
this.broadcast();
|
|
1349
|
+
if (data.stage !== void 0 && data.stage !== oldStage) {
|
|
1350
|
+
this.fireWebhooks("item.moved", {
|
|
1351
|
+
itemId: item.id,
|
|
1352
|
+
itemDescription: item.description,
|
|
1353
|
+
sourceStage: oldStage,
|
|
1354
|
+
targetStage: data.stage
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1358
|
+
res.end(JSON.stringify(item));
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1361
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
if (path.match(/^\/api\/items\/[^/]+$/) && req.method === "DELETE") {
|
|
1367
|
+
const itemId = path.replace("/api/items/", "");
|
|
1368
|
+
const wf = this.loadWorkflow();
|
|
1369
|
+
if (!wf) {
|
|
1370
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1371
|
+
res.end(JSON.stringify({ error: "No workflow" }));
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
const idx = wf.items.findIndex((i) => i.id === itemId);
|
|
1375
|
+
if (idx === -1) {
|
|
1376
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1377
|
+
res.end(JSON.stringify({ error: "Item not found" }));
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
wf.items.splice(idx, 1);
|
|
1381
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1382
|
+
saveWorkflow(this.root, wf);
|
|
1383
|
+
this.broadcast();
|
|
1384
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1385
|
+
res.end(JSON.stringify({ deleted: itemId }));
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
if (path === "/api/workflow" && req.method === "PATCH") {
|
|
1389
|
+
let body = "";
|
|
1390
|
+
req.on("data", (chunk) => {
|
|
1391
|
+
body += chunk;
|
|
1392
|
+
});
|
|
1393
|
+
req.on("end", () => {
|
|
1394
|
+
try {
|
|
1395
|
+
const data = JSON.parse(body);
|
|
1396
|
+
const wf = this.loadWorkflow();
|
|
1397
|
+
if (!wf) {
|
|
1398
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1399
|
+
res.end(JSON.stringify({ error: "No workflow" }));
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
if (data.stages !== void 0) wf.stages = data.stages;
|
|
1403
|
+
if (data.name !== void 0) wf.name = data.name;
|
|
1404
|
+
if (data.description !== void 0) wf.description = data.description;
|
|
1405
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1406
|
+
saveWorkflow(this.root, wf);
|
|
1407
|
+
this.broadcast();
|
|
1408
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1409
|
+
res.end(JSON.stringify(wf));
|
|
1410
|
+
} catch (e) {
|
|
1411
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1412
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (path === "/api/move") {
|
|
1418
|
+
const itemId = url.searchParams.get("item");
|
|
1419
|
+
const stage = url.searchParams.get("stage");
|
|
1420
|
+
if (itemId && stage) {
|
|
1421
|
+
const wf = this.loadWorkflow();
|
|
1422
|
+
if (wf) {
|
|
1423
|
+
const item = wf.items.find((i) => i.id === itemId);
|
|
1424
|
+
if (item) {
|
|
1425
|
+
item.stage = stage;
|
|
1426
|
+
wf.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1427
|
+
saveWorkflow(this.root, wf);
|
|
1428
|
+
this.broadcast();
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
res.writeHead(302, { Location: "/" });
|
|
1433
|
+
res.end();
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
if (path === "/api/focus") {
|
|
1437
|
+
const focusFile = join6(this.root, ".letra", "focus.md");
|
|
1438
|
+
if (existsSync6(focusFile)) {
|
|
1439
|
+
const content = readFileSync5(focusFile, "utf-8");
|
|
1440
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1441
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
1442
|
+
res.end(
|
|
1443
|
+
JSON.stringify({
|
|
1444
|
+
active: true,
|
|
1445
|
+
spec: lines[0]?.replace(/^#\s*/, "") || "",
|
|
1446
|
+
content
|
|
1447
|
+
})
|
|
1448
|
+
);
|
|
1449
|
+
} else {
|
|
1450
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1451
|
+
res.end(JSON.stringify({ active: false }));
|
|
1452
|
+
}
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (path === "/api/context") {
|
|
1456
|
+
const file = url.searchParams.get("file") || "context.md";
|
|
1457
|
+
const letraDir = join6(this.root, ".letra");
|
|
1458
|
+
const allowedFiles = ["context.md", "constitution.md", "glossary.md"];
|
|
1459
|
+
if (file === "decisions") {
|
|
1460
|
+
const decisionsDir = join6(letraDir, "decisions");
|
|
1461
|
+
const files = [];
|
|
1462
|
+
if (existsSync6(decisionsDir)) {
|
|
1463
|
+
const names = readdirSync3(decisionsDir).filter((f) => f.endsWith(".md"));
|
|
1464
|
+
for (const name of names.sort().reverse()) {
|
|
1465
|
+
const content2 = readFileSync5(join6(decisionsDir, name), "utf-8");
|
|
1466
|
+
files.push({ name, content: content2 });
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1470
|
+
res.end(JSON.stringify(files));
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
if (!allowedFiles.includes(file)) {
|
|
1474
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1475
|
+
res.end(JSON.stringify({ error: `Invalid file: ${file}` }));
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const filePath = join6(letraDir, file);
|
|
1479
|
+
if (!existsSync6(filePath)) {
|
|
1480
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1481
|
+
res.end(JSON.stringify({ error: `File not found: ${file}` }));
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
1485
|
+
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
1486
|
+
res.end(content);
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
this.serveClient(path, req, res);
|
|
1181
1490
|
};
|
|
1491
|
+
clientDir = null;
|
|
1492
|
+
serveClient(path, req, res) {
|
|
1493
|
+
if (!this.clientDir) {
|
|
1494
|
+
const cliDir = dirname(fileURLToPath(import.meta.url));
|
|
1495
|
+
const builtIn = join6(cliDir, "client");
|
|
1496
|
+
const monorepoDev = join6(this.root, "packages", "client", "dist");
|
|
1497
|
+
const candidates = [builtIn, monorepoDev];
|
|
1498
|
+
for (const dir of candidates) {
|
|
1499
|
+
const idx = join6(dir, "index.html");
|
|
1500
|
+
if (existsSync6(idx)) {
|
|
1501
|
+
this.clientDir = dir;
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
if (!this.clientDir) {
|
|
1507
|
+
this.proxyToVite(req, res);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
let filePath = join6(this.clientDir, path === "/" ? "index.html" : path);
|
|
1511
|
+
if (!existsSync6(filePath)) {
|
|
1512
|
+
filePath = join6(this.clientDir, "index.html");
|
|
1513
|
+
}
|
|
1514
|
+
const ext = extname(filePath);
|
|
1515
|
+
const mime = {
|
|
1516
|
+
".html": "text/html; charset=utf-8",
|
|
1517
|
+
".js": "application/javascript; charset=utf-8",
|
|
1518
|
+
".css": "text/css; charset=utf-8",
|
|
1519
|
+
".svg": "image/svg+xml",
|
|
1520
|
+
".png": "image/png",
|
|
1521
|
+
".ico": "image/x-icon",
|
|
1522
|
+
".json": "application/json"
|
|
1523
|
+
};
|
|
1524
|
+
const contentType = mime[ext] ?? "application/octet-stream";
|
|
1525
|
+
res.writeHead(200, { "Content-Type": contentType });
|
|
1526
|
+
res.end(readFileSync5(filePath));
|
|
1527
|
+
}
|
|
1528
|
+
proxyToVite(req, res) {
|
|
1529
|
+
const proxyUrl = `http://localhost:5173${req.url}`;
|
|
1530
|
+
fetch(proxyUrl).then((proxyRes) => {
|
|
1531
|
+
res.writeHead(proxyRes.status, Object.fromEntries(proxyRes.headers));
|
|
1532
|
+
proxyRes.body?.pipeTo(
|
|
1533
|
+
new WritableStream({
|
|
1534
|
+
write(chunk) {
|
|
1535
|
+
res.write(chunk);
|
|
1536
|
+
},
|
|
1537
|
+
close() {
|
|
1538
|
+
res.end();
|
|
1539
|
+
}
|
|
1540
|
+
})
|
|
1541
|
+
);
|
|
1542
|
+
}).catch(() => {
|
|
1543
|
+
res.writeHead(502, { "Content-Type": "text/plain" });
|
|
1544
|
+
res.end("Vite dev server not running on http://localhost:5173");
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1182
1547
|
broadcast() {
|
|
1183
1548
|
if (this.clients.size === 0) return;
|
|
1184
1549
|
const data = "event: workflow-updated\ndata: {}\n\n";
|
|
@@ -1190,8 +1555,34 @@ var FlowServer = class {
|
|
|
1190
1555
|
}
|
|
1191
1556
|
}
|
|
1192
1557
|
}
|
|
1558
|
+
async fireWebhooks(event, payload) {
|
|
1559
|
+
const wf = this.loadWorkflow();
|
|
1560
|
+
if (!wf?.webhooks || wf.webhooks.length === 0) return;
|
|
1561
|
+
const matching = wf.webhooks.filter((wh) => wh.events.includes(event));
|
|
1562
|
+
if (matching.length === 0) return;
|
|
1563
|
+
const body = JSON.stringify({
|
|
1564
|
+
event,
|
|
1565
|
+
workflow: wf.name,
|
|
1566
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1567
|
+
...payload
|
|
1568
|
+
});
|
|
1569
|
+
for (const wh of matching) {
|
|
1570
|
+
try {
|
|
1571
|
+
const res = await fetch(wh.url, {
|
|
1572
|
+
method: "POST",
|
|
1573
|
+
headers: { "Content-Type": "application/json" },
|
|
1574
|
+
body
|
|
1575
|
+
});
|
|
1576
|
+
wh.lastStatus = res.ok ? "ok" : "error";
|
|
1577
|
+
} catch {
|
|
1578
|
+
wh.lastStatus = "error";
|
|
1579
|
+
}
|
|
1580
|
+
wh.lastSentAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1581
|
+
}
|
|
1582
|
+
saveWorkflow(this.root, wf);
|
|
1583
|
+
}
|
|
1193
1584
|
start() {
|
|
1194
|
-
return new Promise((
|
|
1585
|
+
return new Promise((resolve17, reject) => {
|
|
1195
1586
|
this.server = createServer(this.handleRequest);
|
|
1196
1587
|
this.server.listen(this.port, () => {
|
|
1197
1588
|
const wfPath = join6(this.root, ".letra", "workflow.json");
|
|
@@ -1201,7 +1592,7 @@ var FlowServer = class {
|
|
|
1201
1592
|
} catch {
|
|
1202
1593
|
}
|
|
1203
1594
|
}
|
|
1204
|
-
|
|
1595
|
+
resolve17();
|
|
1205
1596
|
});
|
|
1206
1597
|
this.server.on("error", reject);
|
|
1207
1598
|
});
|
|
@@ -1219,7 +1610,7 @@ var FlowServer = class {
|
|
|
1219
1610
|
}
|
|
1220
1611
|
};
|
|
1221
1612
|
async function flowServeAction(targetPath, options) {
|
|
1222
|
-
const root =
|
|
1613
|
+
const root = resolve9(process.cwd(), targetPath ?? ".");
|
|
1223
1614
|
const port = options?.port ?? DEFAULT_PORT;
|
|
1224
1615
|
const wf = loadWorkflow(root);
|
|
1225
1616
|
if (!wf) {
|
|
@@ -1241,25 +1632,22 @@ async function flowServeAction(targetPath, options) {
|
|
|
1241
1632
|
} catch {
|
|
1242
1633
|
}
|
|
1243
1634
|
}
|
|
1244
|
-
await new Promise((
|
|
1635
|
+
await new Promise((resolve17) => {
|
|
1245
1636
|
process.on("SIGINT", () => {
|
|
1246
1637
|
server.stop();
|
|
1247
|
-
|
|
1638
|
+
resolve17();
|
|
1248
1639
|
});
|
|
1249
1640
|
});
|
|
1250
1641
|
} catch (err) {
|
|
1251
|
-
console.error(
|
|
1252
|
-
`Failed to start server on port ${port}:`,
|
|
1253
|
-
err.message
|
|
1254
|
-
);
|
|
1642
|
+
console.error(`Failed to start server on port ${port}:`, err.message);
|
|
1255
1643
|
process.exit(1);
|
|
1256
1644
|
}
|
|
1257
1645
|
}
|
|
1258
1646
|
|
|
1259
1647
|
// src/commands/flow-visualize.ts
|
|
1260
|
-
import { writeFileSync as
|
|
1261
|
-
import { resolve as
|
|
1262
|
-
import
|
|
1648
|
+
import { writeFileSync as writeFileSync7 } from "fs";
|
|
1649
|
+
import { resolve as resolve10 } from "path";
|
|
1650
|
+
import chalk9 from "chalk";
|
|
1263
1651
|
var MERMAID_LIVE = "https://mermaid.live/edit#";
|
|
1264
1652
|
function generateMermaid(workflow) {
|
|
1265
1653
|
const sorted = [...workflow.stages].sort((a, b) => a.order - b.order);
|
|
@@ -1281,9 +1669,7 @@ function generateMermaid(workflow) {
|
|
|
1281
1669
|
` ${sorted[0].id}["${labelFor(sorted[0])}"] --> ${sorted[1].id}["${labelFor(sorted[1])}"]`
|
|
1282
1670
|
);
|
|
1283
1671
|
for (let i = 1; i < sorted.length - 1; i++) {
|
|
1284
|
-
lines.push(
|
|
1285
|
-
` ${sorted[i].id} --> ${sorted[i + 1].id}["${labelFor(sorted[i + 1])}"]`
|
|
1286
|
-
);
|
|
1672
|
+
lines.push(` ${sorted[i].id} --> ${sorted[i + 1].id}["${labelFor(sorted[i + 1])}"]`);
|
|
1287
1673
|
}
|
|
1288
1674
|
return lines.join("\n");
|
|
1289
1675
|
}
|
|
@@ -1311,14 +1697,12 @@ ${mermaid}
|
|
|
1311
1697
|
function flowVisualize(root, options) {
|
|
1312
1698
|
const workflow = loadWorkflow(root);
|
|
1313
1699
|
if (!workflow) {
|
|
1314
|
-
console.log(
|
|
1315
|
-
chalk8.yellow("No workflow found. Run 'letra flow init --quick' first")
|
|
1316
|
-
);
|
|
1700
|
+
console.log(chalk9.yellow("No workflow found. Run 'letra flow init --quick' first"));
|
|
1317
1701
|
return;
|
|
1318
1702
|
}
|
|
1319
1703
|
const mermaid = generateMermaid(workflow);
|
|
1320
1704
|
if (options?.output) {
|
|
1321
|
-
const outputPath =
|
|
1705
|
+
const outputPath = resolve10(root, options.output);
|
|
1322
1706
|
const ext = options.output.toLowerCase().split(".").pop();
|
|
1323
1707
|
let content;
|
|
1324
1708
|
let label;
|
|
@@ -1336,16 +1720,16 @@ ${mermaid}
|
|
|
1336
1720
|
`;
|
|
1337
1721
|
label = "Diagram file";
|
|
1338
1722
|
}
|
|
1339
|
-
|
|
1723
|
+
writeFileSync7(outputPath, content);
|
|
1340
1724
|
console.log(`${label} saved to ${options.output}`);
|
|
1341
1725
|
} else {
|
|
1342
1726
|
console.log(mermaid);
|
|
1343
|
-
console.log(
|
|
1727
|
+
console.log(chalk9.dim(`
|
|
1344
1728
|
Copy to ${MERMAID_LIVE} to render`));
|
|
1345
1729
|
}
|
|
1346
1730
|
}
|
|
1347
1731
|
function flowVisualizeAction(targetPath, options) {
|
|
1348
|
-
const root =
|
|
1732
|
+
const root = resolve10(process.cwd(), targetPath || ".");
|
|
1349
1733
|
flowVisualize(root, options);
|
|
1350
1734
|
}
|
|
1351
1735
|
|
|
@@ -1362,6 +1746,13 @@ function flowCommand() {
|
|
|
1362
1746
|
backlog.command("list").description("List all items with stage and age").action(() => {
|
|
1363
1747
|
backlogActionList(void 0);
|
|
1364
1748
|
});
|
|
1749
|
+
const importCmd = backlog.command("import").description("Import issues from external sources");
|
|
1750
|
+
importCmd.command("github <repo>").option("--label <label>", "Filter by label").option("--limit <number>", "Max issues to import", "50").description("Import open issues from a GitHub repository").action((repo, options) => {
|
|
1751
|
+
backlogImportGitHubAction(void 0, repo, options);
|
|
1752
|
+
});
|
|
1753
|
+
importCmd.command("linear <team>").option("--limit <number>", "Max issues to import", "50").description("Import issues from a Linear team").action((team, options) => {
|
|
1754
|
+
backlogImportLinearAction(void 0, team, options);
|
|
1755
|
+
});
|
|
1365
1756
|
cmd.command("move <item-id>").requiredOption("--to <stage>", "Target stage id or name").description("Move item to another stage and regenerate adapters").action((itemId, options) => {
|
|
1366
1757
|
flowMoveAction(void 0, itemId, options);
|
|
1367
1758
|
});
|
|
@@ -1394,9 +1785,9 @@ function flowCommand() {
|
|
|
1394
1785
|
}
|
|
1395
1786
|
|
|
1396
1787
|
// src/commands/focus.ts
|
|
1397
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6, unlinkSync, writeFileSync as
|
|
1398
|
-
import { join as join7, resolve as
|
|
1399
|
-
import
|
|
1788
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, unlinkSync, writeFileSync as writeFileSync8 } from "fs";
|
|
1789
|
+
import { join as join7, resolve as resolve11 } from "path";
|
|
1790
|
+
import chalk10 from "chalk";
|
|
1400
1791
|
import { Command as Command3 } from "commander";
|
|
1401
1792
|
function extractOutcome(specDir) {
|
|
1402
1793
|
const specFile = join7(specDir, "spec.md");
|
|
@@ -1407,14 +1798,14 @@ function extractOutcome(specDir) {
|
|
|
1407
1798
|
}
|
|
1408
1799
|
function focus_default() {
|
|
1409
1800
|
return new Command3("focus").argument("[spec]", "Spec name to focus on").option("--clear", "Remove focus file").action((spec, options) => {
|
|
1410
|
-
const root =
|
|
1801
|
+
const root = resolve11(process.cwd());
|
|
1411
1802
|
const focusFile = join7(root, ".letra", "focus.md");
|
|
1412
1803
|
if (options.clear) {
|
|
1413
1804
|
if (existsSync7(focusFile)) {
|
|
1414
1805
|
unlinkSync(focusFile);
|
|
1415
|
-
console.log(
|
|
1806
|
+
console.log(chalk10.green("Focus removed."));
|
|
1416
1807
|
} else {
|
|
1417
|
-
console.log(
|
|
1808
|
+
console.log(chalk10.yellow("No focus to remove."));
|
|
1418
1809
|
}
|
|
1419
1810
|
return;
|
|
1420
1811
|
}
|
|
@@ -1422,7 +1813,7 @@ function focus_default() {
|
|
|
1422
1813
|
const specDir = join7(root, ".letra", "specs", spec);
|
|
1423
1814
|
const specFile = join7(specDir, "spec.md");
|
|
1424
1815
|
if (!existsSync7(specFile)) {
|
|
1425
|
-
console.log(
|
|
1816
|
+
console.log(chalk10.red(`Spec "${spec}" not found`));
|
|
1426
1817
|
process.exit(1);
|
|
1427
1818
|
}
|
|
1428
1819
|
const outcome = extractOutcome(specDir);
|
|
@@ -1434,8 +1825,8 @@ function focus_default() {
|
|
|
1434
1825
|
outcomeLine,
|
|
1435
1826
|
""
|
|
1436
1827
|
].join("\n");
|
|
1437
|
-
|
|
1438
|
-
console.log(
|
|
1828
|
+
writeFileSync8(focusFile, focusContent);
|
|
1829
|
+
console.log(chalk10.green(`Focus set to "${spec}".`));
|
|
1439
1830
|
return;
|
|
1440
1831
|
}
|
|
1441
1832
|
if (existsSync7(focusFile)) {
|
|
@@ -1447,35 +1838,28 @@ function focus_default() {
|
|
|
1447
1838
|
}
|
|
1448
1839
|
|
|
1449
1840
|
// src/commands/init.ts
|
|
1450
|
-
import {
|
|
1451
|
-
|
|
1452
|
-
existsSync as existsSync8,
|
|
1453
|
-
mkdirSync as mkdirSync4,
|
|
1454
|
-
writeFileSync as writeFileSync8
|
|
1455
|
-
} from "fs";
|
|
1456
|
-
import { join as join8, resolve as resolve11 } from "path";
|
|
1841
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
1842
|
+
import { join as join8, resolve as resolve12 } from "path";
|
|
1457
1843
|
import { createInterface as createInterface2 } from "readline";
|
|
1458
|
-
import { fileURLToPath } from "url";
|
|
1459
|
-
import
|
|
1844
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1845
|
+
import chalk11 from "chalk";
|
|
1460
1846
|
import ora2 from "ora";
|
|
1461
|
-
var __dirname =
|
|
1847
|
+
var __dirname = fileURLToPath2(new URL(".", import.meta.url));
|
|
1462
1848
|
function ask(query, options) {
|
|
1463
1849
|
if (!process.stdin.isTTY) return Promise.resolve(options[0]);
|
|
1464
1850
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
1465
|
-
return new Promise((
|
|
1466
|
-
const formatted = `${
|
|
1851
|
+
return new Promise((resolve17) => {
|
|
1852
|
+
const formatted = `${chalk11.cyan(query)} ${options.map((o) => chalk11.gray(`(${o})`)).join(" ")}
|
|
1467
1853
|
> `;
|
|
1468
1854
|
rl.question(formatted, (answer) => {
|
|
1469
1855
|
rl.close();
|
|
1470
1856
|
const trimmed = answer.trim().toLowerCase();
|
|
1471
1857
|
if (trimmed && options.some((o) => o.toLowerCase().startsWith(trimmed))) {
|
|
1472
|
-
|
|
1473
|
-
options.find((o) => o.toLowerCase().startsWith(trimmed)) ?? options[0]
|
|
1474
|
-
);
|
|
1858
|
+
resolve17(options.find((o) => o.toLowerCase().startsWith(trimmed)) ?? options[0]);
|
|
1475
1859
|
} else if (trimmed && options.includes(trimmed)) {
|
|
1476
|
-
|
|
1860
|
+
resolve17(trimmed);
|
|
1477
1861
|
} else {
|
|
1478
|
-
|
|
1862
|
+
resolve17(options[0]);
|
|
1479
1863
|
}
|
|
1480
1864
|
});
|
|
1481
1865
|
});
|
|
@@ -1486,16 +1870,7 @@ function adaptConfig(projectType) {
|
|
|
1486
1870
|
"consistencia-terminologia": { severity: "warning" },
|
|
1487
1871
|
"detecao-tom": {
|
|
1488
1872
|
severity: "warning",
|
|
1489
|
-
blacklist: [
|
|
1490
|
-
"tipo",
|
|
1491
|
-
"t\xE1",
|
|
1492
|
-
"pra",
|
|
1493
|
-
"blz",
|
|
1494
|
-
"kkk",
|
|
1495
|
-
"eita",
|
|
1496
|
-
"oi",
|
|
1497
|
-
"oi pessoal"
|
|
1498
|
-
]
|
|
1873
|
+
blacklist: ["tipo", "t\xE1", "pra", "blz", "kkk", "eita", "oi", "oi pessoal"]
|
|
1499
1874
|
},
|
|
1500
1875
|
"drift-temporal": { severity: "warning", maxDays: 30 },
|
|
1501
1876
|
"secoes-vazias": { severity: "warning" },
|
|
@@ -1578,19 +1953,24 @@ ${format === "at" ? "# Context\n@.letra/context.md\n@.letra/constitution.md\n@.l
|
|
|
1578
1953
|
}
|
|
1579
1954
|
for (const { path, content } of adapters) {
|
|
1580
1955
|
const dir = join8(path, "..");
|
|
1581
|
-
if (!existsSync8(dir))
|
|
1582
|
-
|
|
1583
|
-
console.log(` ${
|
|
1956
|
+
if (!existsSync8(dir)) mkdirSync5(dir, { recursive: true });
|
|
1957
|
+
writeFileSync9(path, content);
|
|
1958
|
+
console.log(` ${chalk11.gray("Created")} ${path.replace(`${root}/`, "")}`);
|
|
1584
1959
|
}
|
|
1585
1960
|
}
|
|
1586
1961
|
async function init(targetPath, options) {
|
|
1587
|
-
const root =
|
|
1962
|
+
const root = resolve12(process.cwd(), targetPath || ".");
|
|
1588
1963
|
const letraDir = join8(root, ".letra");
|
|
1589
|
-
const spinner = ora2("Initializing Letra...").start();
|
|
1590
1964
|
if (existsSync8(letraDir)) {
|
|
1591
|
-
|
|
1965
|
+
if (options?.serve) {
|
|
1966
|
+
console.log(chalk11.cyan(".letra/ already exists \u2014 starting UI..."));
|
|
1967
|
+
await flowServeAction(targetPath, { open: true });
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
console.log(chalk11.yellow(".letra/ already exists"));
|
|
1592
1971
|
return;
|
|
1593
1972
|
}
|
|
1973
|
+
const spinner = ora2("Initializing Letra...").start();
|
|
1594
1974
|
try {
|
|
1595
1975
|
let projectType = "web-app";
|
|
1596
1976
|
let tool = "cursor";
|
|
@@ -1599,12 +1979,7 @@ async function init(targetPath, options) {
|
|
|
1599
1979
|
tool = "todos";
|
|
1600
1980
|
} else {
|
|
1601
1981
|
spinner.stop();
|
|
1602
|
-
projectType = await ask("Project type?", [
|
|
1603
|
-
"web-app",
|
|
1604
|
-
"cli",
|
|
1605
|
-
"library",
|
|
1606
|
-
"mobile"
|
|
1607
|
-
]);
|
|
1982
|
+
projectType = await ask("Project type?", ["web-app", "cli", "library", "mobile"]);
|
|
1608
1983
|
const toolNames = [
|
|
1609
1984
|
"Cursor",
|
|
1610
1985
|
"Windsurf",
|
|
@@ -1617,24 +1992,91 @@ async function init(targetPath, options) {
|
|
|
1617
1992
|
tool = answer.toLowerCase();
|
|
1618
1993
|
spinner.start();
|
|
1619
1994
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1995
|
+
mkdirSync5(join8(letraDir, "decisions"), { recursive: true });
|
|
1996
|
+
mkdirSync5(join8(letraDir, "specs", "_template"), { recursive: true });
|
|
1997
|
+
mkdirSync5(join8(letraDir, "adapters"), { recursive: true });
|
|
1998
|
+
const templateFiles = {
|
|
1999
|
+
"context.md": `# Context
|
|
2000
|
+
|
|
2001
|
+
> Updated: 2026-05-01
|
|
2002
|
+
> Owner: letra-dev
|
|
2003
|
+
|
|
2004
|
+
## Intent
|
|
2005
|
+
|
|
2006
|
+
Letra \xE9 um framework de Specification-Driven Development (SDD) agn\xF3stico a ferramentas.
|
|
2007
|
+
Captura dire\xE7\xE3o, inten\xE7\xE3o e contexto, enriquecendo prompts de agentes de c\xF3digo.
|
|
2008
|
+
|
|
2009
|
+
## Dom\xEDnio
|
|
2010
|
+
|
|
2011
|
+
- **Produto**: CLI + adapters + formato de mem\xF3ria .letra/
|
|
2012
|
+
- **P\xFAblico**: 1. N\xE3o-devs
|
|
2013
|
+
|
|
2014
|
+
## Restri\xE7\xF5es Reais
|
|
2015
|
+
|
|
2016
|
+
- Specs devem ser thin (m\xE1x 1 p\xE1gina por feature)
|
|
2017
|
+
- Sem lock-in de IDE
|
|
2018
|
+
- Drift detection deve funcionar para qualquer dom\xEDnio (n\xE3o s\xF3 c\xF3digo)
|
|
2019
|
+
|
|
2020
|
+
## Porqu\xEAs
|
|
2021
|
+
|
|
2022
|
+
- Escolhemos TypeScript porque 82% dos novos pacotes npm s\xE3o TS em 2026
|
|
2023
|
+
- Escolhemos Markdown checklist porque n\xE3o-devs precisam ler e escrever specs
|
|
2024
|
+
`,
|
|
2025
|
+
"constitution.md": `# Constitution
|
|
2026
|
+
|
|
2027
|
+
## Arquitetura
|
|
2028
|
+
- Adapter layer desde o dia 1 \u2014 nunca travar em uma IDE
|
|
2029
|
+
- Formato .letra/ \xE9 a fonte da verdade, n\xE3o o c\xF3digo
|
|
2030
|
+
- CLI deve ser extens\xEDvel via plugins
|
|
2031
|
+
|
|
2032
|
+
## C\xF3digo
|
|
2033
|
+
- TypeScript estrito (strict: true)
|
|
2034
|
+
- Zero dependencies desnecess\xE1rias
|
|
2035
|
+
|
|
2036
|
+
## Specs
|
|
2037
|
+
- Thin specs: m\xE1ximo 1 p\xE1gina por feature
|
|
2038
|
+
- Markdown checklist para acceptance criteria
|
|
2039
|
+
- Toda spec deve ter: Outcome, Constraints, Exclusions, Acceptance Criteria, Context
|
|
2040
|
+
|
|
2041
|
+
## Seguran\xE7a
|
|
2042
|
+
- Nunca incluir secrets, tokens ou chaves no reposit\xF3rio
|
|
2043
|
+
`,
|
|
2044
|
+
"glossary.md": `# Glossary
|
|
2045
|
+
|
|
2046
|
+
| Termo | Defini\xE7\xE3o |
|
|
2047
|
+
|-------|-----------|
|
|
2048
|
+
| **Spec** | Especifica\xE7\xE3o thin que define o que deve ser constru\xEDdo. |
|
|
2049
|
+
| **Drift** | Diverg\xEAncia entre o que a spec diz e o que o artefato realmente entrega. |
|
|
2050
|
+
| **Adapter** | Tradutor que converte .letra/ para o formato que uma IDE/agent entende. |
|
|
2051
|
+
| **Context** | Documento que captura intent, dom\xEDnio, restri\xE7\xF5es reais e "porqu\xEAs" do projeto. |
|
|
2052
|
+
| **Constitution** | Regras n\xE3o-negoci\xE1veis de arquitetura, c\xF3digo e workflow. |
|
|
2053
|
+
| **Thin Spec** | Spec de no m\xE1ximo 1 p\xE1gina, focada em outcome. |
|
|
2054
|
+
`,
|
|
2055
|
+
"lessons-learned.md": `# Lessons Learned
|
|
2056
|
+
|
|
2057
|
+
## O que funcionou
|
|
2058
|
+
- Pesquisar dores reais do SDD antes de definir arquitetura
|
|
2059
|
+
- Decidir por evid\xEAncias (m\xE9tricas, dados) e n\xE3o por intui\xE7\xE3o
|
|
2060
|
+
|
|
2061
|
+
## O que aprendemos
|
|
2062
|
+
- Drift detection n\xE3o pode ser code-centric \u2014 p\xFAblico prim\xE1rio s\xE3o n\xE3o-devs
|
|
2063
|
+
- Obsidian nunca deve ser requisito \u2014 barreira de ado\xE7\xE3o
|
|
2064
|
+
- TypeScript domina CLIs em 2026 (82% dos novos pacotes npm)
|
|
2065
|
+
|
|
2066
|
+
## Padr\xF5es a evitar
|
|
2067
|
+
- Specs gigantes (Markdown Madness)
|
|
2068
|
+
- Lock-in de IDE
|
|
2069
|
+
- Spec que vira pseudo-c\xF3digo
|
|
2070
|
+
`
|
|
2071
|
+
};
|
|
2072
|
+
for (const [file, content] of Object.entries(templateFiles)) {
|
|
2073
|
+
writeFileSync9(join8(letraDir, file), content, "utf-8");
|
|
1634
2074
|
}
|
|
1635
2075
|
const specTemplate = join8(letraDir, "specs", "_template.md");
|
|
1636
2076
|
const specContent = `# Spec Template
|
|
1637
2077
|
|
|
2078
|
+
> Updated: YYYY-MM-DD
|
|
2079
|
+
|
|
1638
2080
|
## Outcome
|
|
1639
2081
|
O que o usu\xE1rio consegue fazer quando isso estiver pronto.
|
|
1640
2082
|
|
|
@@ -1650,15 +2092,15 @@ O que explicitamente N\xC3O est\xE1 neste escopo.
|
|
|
1650
2092
|
## Context
|
|
1651
2093
|
Por que estamos construindo isso.
|
|
1652
2094
|
`;
|
|
1653
|
-
|
|
2095
|
+
writeFileSync9(specTemplate, specContent);
|
|
1654
2096
|
const configPath = join8(letraDir, "config.json");
|
|
1655
|
-
|
|
1656
|
-
console.log(` ${
|
|
2097
|
+
writeFileSync9(configPath, adaptConfig(projectType));
|
|
2098
|
+
console.log(` ${chalk11.gray("Created")} .letra/config.json`);
|
|
1657
2099
|
const tools = adaptersForTool(tool);
|
|
1658
2100
|
generateAdapterFiles(root, tools);
|
|
1659
2101
|
if (tool === "todos" || tool === "vscode") {
|
|
1660
2102
|
const vscodeDir = join8(root, ".vscode");
|
|
1661
|
-
if (!existsSync8(vscodeDir))
|
|
2103
|
+
if (!existsSync8(vscodeDir)) mkdirSync5(vscodeDir, { recursive: true });
|
|
1662
2104
|
const vscodeSettingsPath = join8(vscodeDir, "settings.json");
|
|
1663
2105
|
const vscodeSettingsContent = `{
|
|
1664
2106
|
"editor.formatOnSave": true,
|
|
@@ -1669,26 +2111,32 @@ Por que estamos construindo isso.
|
|
|
1669
2111
|
"files.autoSave": "onFocusChange"
|
|
1670
2112
|
}
|
|
1671
2113
|
`;
|
|
1672
|
-
|
|
1673
|
-
console.log(` ${
|
|
2114
|
+
writeFileSync9(vscodeSettingsPath, vscodeSettingsContent);
|
|
2115
|
+
console.log(` ${chalk11.gray("Created")} .vscode/settings.json`);
|
|
1674
2116
|
}
|
|
1675
|
-
spinner.succeed(
|
|
2117
|
+
spinner.succeed(chalk11.green(".letra/ initialized successfully"));
|
|
1676
2118
|
console.log("");
|
|
1677
2119
|
console.log(" Next steps:");
|
|
1678
|
-
console.log(
|
|
1679
|
-
|
|
1680
|
-
);
|
|
1681
|
-
|
|
2120
|
+
console.log(` ${chalk11.cyan("letra spec new <name>")} Create your first spec`);
|
|
2121
|
+
console.log(` ${chalk11.cyan("letra lint")} Validate specs`);
|
|
2122
|
+
console.log(` ${chalk11.cyan("letra init --serve")} Open web UI to configure workflow`);
|
|
2123
|
+
if (options?.serve) {
|
|
2124
|
+
console.log(`
|
|
2125
|
+
${chalk11.cyan("Opening web UI...")}
|
|
2126
|
+
`);
|
|
2127
|
+
await flowServeAction(targetPath, { open: true });
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
1682
2130
|
} catch (error) {
|
|
1683
|
-
spinner.fail(
|
|
2131
|
+
spinner.fail(chalk11.red("Failed to initialize Letra"));
|
|
1684
2132
|
process.exit(1);
|
|
1685
2133
|
}
|
|
1686
2134
|
}
|
|
1687
2135
|
|
|
1688
2136
|
// src/commands/lint.ts
|
|
1689
2137
|
import { existsSync as existsSync9, readFileSync as readFileSync7, readdirSync as readdirSync5 } from "fs";
|
|
1690
|
-
import { join as join9, resolve as
|
|
1691
|
-
import
|
|
2138
|
+
import { join as join9, resolve as resolve13 } from "path";
|
|
2139
|
+
import chalk12 from "chalk";
|
|
1692
2140
|
var REQUIRED_SECTIONS = [
|
|
1693
2141
|
"## Outcome",
|
|
1694
2142
|
"## Constraints",
|
|
@@ -1697,12 +2145,10 @@ var REQUIRED_SECTIONS = [
|
|
|
1697
2145
|
"## Context"
|
|
1698
2146
|
];
|
|
1699
2147
|
async function lint(targetPath) {
|
|
1700
|
-
const root =
|
|
2148
|
+
const root = resolve13(process.cwd(), targetPath || ".");
|
|
1701
2149
|
const specsDir = join9(root, ".letra", "specs");
|
|
1702
2150
|
if (!existsSync9(specsDir)) {
|
|
1703
|
-
console.log(
|
|
1704
|
-
chalk11.red("Error: .letra/specs/ not found. Run 'letra init' first.")
|
|
1705
|
-
);
|
|
2151
|
+
console.log(chalk12.red("Error: .letra/specs/ not found. Run 'letra init' first."));
|
|
1706
2152
|
process.exit(1);
|
|
1707
2153
|
}
|
|
1708
2154
|
const results = [];
|
|
@@ -1728,9 +2174,7 @@ async function lint(targetPath) {
|
|
|
1728
2174
|
}
|
|
1729
2175
|
const hasChecklist = /-\s*\[[ x]\]\s*\*\*/i.test(content);
|
|
1730
2176
|
if (!hasChecklist && content.includes("## Acceptance Criteria")) {
|
|
1731
|
-
errors.push(
|
|
1732
|
-
"Acceptance Criteria section exists but has no checklist items"
|
|
1733
|
-
);
|
|
2177
|
+
errors.push("Acceptance Criteria section exists but has no checklist items");
|
|
1734
2178
|
}
|
|
1735
2179
|
}
|
|
1736
2180
|
if (errors.length > 0 || warnings.length > 0) {
|
|
@@ -1740,22 +2184,22 @@ async function lint(targetPath) {
|
|
|
1740
2184
|
}
|
|
1741
2185
|
}
|
|
1742
2186
|
if (results.length === 0) {
|
|
1743
|
-
console.log(
|
|
2187
|
+
console.log(chalk12.green("All specs are valid"));
|
|
1744
2188
|
process.exit(0);
|
|
1745
2189
|
}
|
|
1746
2190
|
console.log("");
|
|
1747
2191
|
for (const result of results) {
|
|
1748
|
-
console.log(
|
|
2192
|
+
console.log(chalk12.bold(`
|
|
1749
2193
|
Spec: ${result.file}`));
|
|
1750
2194
|
for (const error of result.errors) {
|
|
1751
|
-
console.log(
|
|
2195
|
+
console.log(chalk12.red(` \u2717 ${error}`));
|
|
1752
2196
|
}
|
|
1753
2197
|
for (const warning of result.warnings) {
|
|
1754
|
-
console.log(
|
|
2198
|
+
console.log(chalk12.yellow(` \u26A0 ${warning}`));
|
|
1755
2199
|
}
|
|
1756
2200
|
}
|
|
1757
2201
|
console.log(
|
|
1758
|
-
|
|
2202
|
+
chalk12.gray(
|
|
1759
2203
|
`
|
|
1760
2204
|
${results.length} spec(s) with issues: ${totalErrors} error(s), ${totalWarnings} warning(s)`
|
|
1761
2205
|
)
|
|
@@ -1764,20 +2208,16 @@ ${results.length} spec(s) with issues: ${totalErrors} error(s), ${totalWarnings}
|
|
|
1764
2208
|
}
|
|
1765
2209
|
|
|
1766
2210
|
// src/commands/spec.ts
|
|
1767
|
-
import {
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
readFileSync as readFileSync8,
|
|
1771
|
-
readdirSync as readdirSync6,
|
|
1772
|
-
writeFileSync as writeFileSync9
|
|
1773
|
-
} from "fs";
|
|
1774
|
-
import { join as join10, resolve as resolve13 } from "path";
|
|
1775
|
-
import chalk12 from "chalk";
|
|
2211
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync8, readdirSync as readdirSync6, writeFileSync as writeFileSync10 } from "fs";
|
|
2212
|
+
import { join as join10, resolve as resolve14 } from "path";
|
|
2213
|
+
import chalk13 from "chalk";
|
|
1776
2214
|
import ora3 from "ora";
|
|
1777
2215
|
var builtInTemplates = {
|
|
1778
2216
|
"web-api": {
|
|
1779
2217
|
spec: `# Spec: {{name}}
|
|
1780
2218
|
|
|
2219
|
+
> Updated: {{date}}
|
|
2220
|
+
|
|
1781
2221
|
## Outcome
|
|
1782
2222
|
Usu\xE1rio consegue fazer requisi\xE7\xF5es HTTP para a API e receber respostas padronizadas.
|
|
1783
2223
|
|
|
@@ -1811,6 +2251,8 @@ Template para APIs REST. Adaptado para o dom\xEDnio espec\xEDfico do projeto.`,
|
|
|
1811
2251
|
"cli-tool": {
|
|
1812
2252
|
spec: `# Spec: {{name}}
|
|
1813
2253
|
|
|
2254
|
+
> Updated: {{date}}
|
|
2255
|
+
|
|
1814
2256
|
## Outcome
|
|
1815
2257
|
Usu\xE1rio instala e executa a CLI, recebendo output formatado no terminal.
|
|
1816
2258
|
|
|
@@ -1844,6 +2286,8 @@ Template para ferramentas de linha de comando. Adaptado para o escopo espec\xEDf
|
|
|
1844
2286
|
"mobile-feature": {
|
|
1845
2287
|
spec: `# Spec: {{name}}
|
|
1846
2288
|
|
|
2289
|
+
> Updated: {{date}}
|
|
2290
|
+
|
|
1847
2291
|
## Outcome
|
|
1848
2292
|
Usu\xE1rio consegue acessar e interagir com a nova funcionalidade no aplicativo mobile.
|
|
1849
2293
|
|
|
@@ -1892,12 +2336,7 @@ function findTemplate(root, type) {
|
|
|
1892
2336
|
const lower = type.toLowerCase();
|
|
1893
2337
|
if (builtInTemplates[lower]) return builtInTemplates[lower];
|
|
1894
2338
|
const customFile = join10(root, ".letra", "templates", `${type}.md`);
|
|
1895
|
-
const customAcceptance = join10(
|
|
1896
|
-
root,
|
|
1897
|
-
".letra",
|
|
1898
|
-
"templates",
|
|
1899
|
-
`${type}-acceptance.md`
|
|
1900
|
-
);
|
|
2339
|
+
const customAcceptance = join10(root, ".letra", "templates", `${type}-acceptance.md`);
|
|
1901
2340
|
if (existsSync10(customFile)) {
|
|
1902
2341
|
const spec = readFileSync8(customFile, "utf-8");
|
|
1903
2342
|
const acceptance = existsSync10(customAcceptance) ? readFileSync8(customAcceptance, "utf-8") : `# Acceptance Criteria \u2014 ${type}
|
|
@@ -1908,43 +2347,42 @@ function findTemplate(root, type) {
|
|
|
1908
2347
|
}
|
|
1909
2348
|
return null;
|
|
1910
2349
|
}
|
|
1911
|
-
function applyPlaceholders(content, name) {
|
|
1912
|
-
return content.replace(/\{\{name\}\}/g, name);
|
|
2350
|
+
function applyPlaceholders(content, name, date) {
|
|
2351
|
+
return content.replace(/\{\{name\}\}/g, name).replace(/\{\{date\}\}/g, date);
|
|
1913
2352
|
}
|
|
1914
2353
|
async function specNew(name, options) {
|
|
1915
|
-
const root =
|
|
2354
|
+
const root = resolve14(process.cwd());
|
|
1916
2355
|
const letraDir = join10(root, ".letra");
|
|
1917
2356
|
const specDir = join10(letraDir, "specs", name);
|
|
1918
2357
|
if (!existsSync10(letraDir)) {
|
|
1919
|
-
console.log(
|
|
2358
|
+
console.log(chalk13.red(".letra/ not found. Run 'letra init' first."));
|
|
1920
2359
|
process.exit(1);
|
|
1921
2360
|
}
|
|
1922
2361
|
if (existsSync10(specDir)) {
|
|
1923
|
-
console.log(
|
|
2362
|
+
console.log(chalk13.yellow(`Spec "${name}" already exists`));
|
|
1924
2363
|
return;
|
|
1925
2364
|
}
|
|
1926
2365
|
const templateType = options?.template || "_default";
|
|
1927
2366
|
const template = templateType === "_default" ? null : findTemplate(root, templateType);
|
|
1928
2367
|
if (options?.template && !template) {
|
|
1929
2368
|
const available = listTemplates(root).join(", ");
|
|
1930
|
-
console.log(
|
|
1931
|
-
chalk12.red(
|
|
1932
|
-
`Template "${options.template}" not found. Available: ${available}`
|
|
1933
|
-
)
|
|
1934
|
-
);
|
|
2369
|
+
console.log(chalk13.red(`Template "${options.template}" not found. Available: ${available}`));
|
|
1935
2370
|
process.exit(1);
|
|
1936
2371
|
}
|
|
1937
2372
|
const spinner = ora3(`Creating spec "${name}"...`).start();
|
|
1938
2373
|
try {
|
|
1939
|
-
|
|
2374
|
+
const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
2375
|
+
mkdirSync6(specDir, { recursive: true });
|
|
1940
2376
|
if (template) {
|
|
1941
|
-
const specContent = applyPlaceholders(template.spec, name);
|
|
1942
|
-
const acceptanceContent = applyPlaceholders(template.acceptance, name);
|
|
1943
|
-
|
|
1944
|
-
|
|
2377
|
+
const specContent = applyPlaceholders(template.spec, name, today2);
|
|
2378
|
+
const acceptanceContent = applyPlaceholders(template.acceptance, name, today2);
|
|
2379
|
+
writeFileSync10(join10(specDir, "spec.md"), specContent);
|
|
2380
|
+
writeFileSync10(join10(specDir, "acceptance.md"), acceptanceContent);
|
|
1945
2381
|
} else {
|
|
1946
2382
|
const specContent = `# Spec: ${name}
|
|
1947
2383
|
|
|
2384
|
+
> Updated: ${today2}
|
|
2385
|
+
|
|
1948
2386
|
## Outcome
|
|
1949
2387
|
O que o usu\xE1rio consegue fazer quando isso estiver pronto.
|
|
1950
2388
|
|
|
@@ -1964,14 +2402,12 @@ Por que estamos construindo isso. Trade-offs considerados.
|
|
|
1964
2402
|
|
|
1965
2403
|
- [ ] **Crit\xE9rio 1**: Descri\xE7\xE3o bin\xE1ria (passa/falha).
|
|
1966
2404
|
`;
|
|
1967
|
-
|
|
1968
|
-
|
|
2405
|
+
writeFileSync10(join10(specDir, "spec.md"), specContent);
|
|
2406
|
+
writeFileSync10(join10(specDir, "acceptance.md"), acceptanceContent);
|
|
1969
2407
|
}
|
|
1970
|
-
spinner.succeed(
|
|
1971
|
-
chalk12.green(`Spec "${name}" created at .letra/specs/${name}/`)
|
|
1972
|
-
);
|
|
2408
|
+
spinner.succeed(chalk13.green(`Spec "${name}" created at .letra/specs/${name}/`));
|
|
1973
2409
|
} catch (error) {
|
|
1974
|
-
spinner.fail(
|
|
2410
|
+
spinner.fail(chalk13.red("Failed to create spec"));
|
|
1975
2411
|
process.exit(1);
|
|
1976
2412
|
}
|
|
1977
2413
|
}
|
|
@@ -1984,12 +2420,12 @@ import {
|
|
|
1984
2420
|
readFileSync as readFileSync10,
|
|
1985
2421
|
readdirSync as readdirSync7,
|
|
1986
2422
|
rmSync,
|
|
1987
|
-
statSync as
|
|
2423
|
+
statSync as statSync2,
|
|
1988
2424
|
watch as watch2
|
|
1989
2425
|
} from "fs";
|
|
1990
2426
|
import { tmpdir } from "os";
|
|
1991
|
-
import { join as join12, resolve as
|
|
1992
|
-
import
|
|
2427
|
+
import { join as join12, resolve as resolve15 } from "path";
|
|
2428
|
+
import chalk14 from "chalk";
|
|
1993
2429
|
|
|
1994
2430
|
// src/config.ts
|
|
1995
2431
|
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
|
|
@@ -2085,14 +2521,12 @@ function checkSpecContent(specDir, label, description, config) {
|
|
|
2085
2521
|
const cfg = config ?? loadConfig(join12(specDir, "..", "..", ".."));
|
|
2086
2522
|
const specFile = join12(specDir, "spec.md");
|
|
2087
2523
|
const glossaryFile = join12(specDir, "..", "..", "glossary.md");
|
|
2088
|
-
if (!existsSync12(specFile))
|
|
2089
|
-
return { status: "FAIL", note: "(spec.md not found)" };
|
|
2524
|
+
if (!existsSync12(specFile)) return { status: "FAIL", note: "(spec.md not found)" };
|
|
2090
2525
|
const specContent = readFileSync10(specFile, "utf-8");
|
|
2091
|
-
const
|
|
2526
|
+
const now7 = /* @__PURE__ */ new Date();
|
|
2092
2527
|
if (label.includes("Conte\xFAdo M\xEDnimo")) {
|
|
2093
2528
|
const outcomeMatch = specContent.match(/## Outcome\s+([\s\S]*?)(?=\n## )/);
|
|
2094
|
-
if (!outcomeMatch)
|
|
2095
|
-
return { status: "FAIL", note: "(no Outcome section)" };
|
|
2529
|
+
if (!outcomeMatch) return { status: "FAIL", note: "(no Outcome section)" };
|
|
2096
2530
|
const outcomeContent = outcomeMatch[1].trim();
|
|
2097
2531
|
const heurConfig = getHeuristicConfig(cfg, label);
|
|
2098
2532
|
const minChars = heurConfig.minChars ?? 50;
|
|
@@ -2152,10 +2586,8 @@ function checkSpecContent(specDir, label, description, config) {
|
|
|
2152
2586
|
};
|
|
2153
2587
|
}
|
|
2154
2588
|
if (label.includes("Drift Temporal") || label.includes("Temporal")) {
|
|
2155
|
-
const stat =
|
|
2156
|
-
const daysOld = Math.floor(
|
|
2157
|
-
(now6.getTime() - stat.mtimeMs) / (1e3 * 60 * 60 * 24)
|
|
2158
|
-
);
|
|
2589
|
+
const stat = statSync2(specFile);
|
|
2590
|
+
const daysOld = Math.floor((now7.getTime() - stat.mtimeMs) / (1e3 * 60 * 60 * 24));
|
|
2159
2591
|
const heurConfig = getHeuristicConfig(cfg, label);
|
|
2160
2592
|
const maxDays = heurConfig.maxDays ?? 30;
|
|
2161
2593
|
if (daysOld < maxDays) {
|
|
@@ -2207,9 +2639,7 @@ function checkEmptySections(specContent) {
|
|
|
2207
2639
|
};
|
|
2208
2640
|
}
|
|
2209
2641
|
function checkBinaryCriteria(specContent) {
|
|
2210
|
-
const acMatch = specContent.match(
|
|
2211
|
-
/## Acceptance Criteria\s+([\s\S]*?)(?=\n## |\n*$)/
|
|
2212
|
-
);
|
|
2642
|
+
const acMatch = specContent.match(/## Acceptance Criteria\s+([\s\S]*?)(?=\n## |\n*$)/);
|
|
2213
2643
|
if (!acMatch) {
|
|
2214
2644
|
return {
|
|
2215
2645
|
status: "FAIL",
|
|
@@ -2224,9 +2654,7 @@ function checkBinaryCriteria(specContent) {
|
|
|
2224
2654
|
for (const line of criteriaLines) {
|
|
2225
2655
|
const description = line.replace(/- \[[ x]\] \*\*.+?\*\*:\s*/, "");
|
|
2226
2656
|
const hasMetric = /\d+/.test(description);
|
|
2227
|
-
const hasVagueVerb = vagueVerbs.some(
|
|
2228
|
-
(v) => description.toLowerCase().includes(v)
|
|
2229
|
-
);
|
|
2657
|
+
const hasVagueVerb = vagueVerbs.some((v) => description.toLowerCase().includes(v));
|
|
2230
2658
|
if (!hasMetric && hasVagueVerb) {
|
|
2231
2659
|
const labelMatch = line.match(/\*\*(.+?)\*\*/);
|
|
2232
2660
|
if (labelMatch) nonBinary.push(labelMatch[1]);
|
|
@@ -2397,13 +2825,11 @@ function out(format, level, spec, label, message, note) {
|
|
|
2397
2825
|
if (format === "junit") {
|
|
2398
2826
|
return;
|
|
2399
2827
|
}
|
|
2400
|
-
const icon = level === "pass" ?
|
|
2828
|
+
const icon = level === "pass" ? chalk14.green("\u2713") : level === "fail" ? chalk14.red("\u2717") : level === "warning" ? chalk14.yellow("\u26A0") : "";
|
|
2401
2829
|
if (level === "info") {
|
|
2402
2830
|
console.log(` ${message}`);
|
|
2403
2831
|
} else {
|
|
2404
|
-
console.log(
|
|
2405
|
-
` [${icon}] ${chalk13.cyan(label)}: ${message} ${chalk13.gray(note)}`
|
|
2406
|
-
);
|
|
2832
|
+
console.log(` [${icon}] ${chalk14.cyan(label)}: ${message} ${chalk14.gray(note)}`);
|
|
2407
2833
|
}
|
|
2408
2834
|
}
|
|
2409
2835
|
function buildJunitXml(results) {
|
|
@@ -2444,14 +2870,14 @@ function flushResults(results, format, specGroups, totalPass, totalFail, totalWa
|
|
|
2444
2870
|
}
|
|
2445
2871
|
}
|
|
2446
2872
|
console.log(
|
|
2447
|
-
|
|
2873
|
+
chalk14.gray(
|
|
2448
2874
|
`
|
|
2449
2875
|
Results: ${totalPass} passed, ${totalFail} failed${totalWarning > 0 ? `, ${totalWarning} warnings` : ""}`
|
|
2450
2876
|
)
|
|
2451
2877
|
);
|
|
2452
2878
|
}
|
|
2453
2879
|
async function validate(targetPath, options) {
|
|
2454
|
-
const root =
|
|
2880
|
+
const root = resolve15(process.cwd(), targetPath || ".");
|
|
2455
2881
|
const specsDir = join12(root, ".letra", "specs");
|
|
2456
2882
|
const fmt = options?.format || "text";
|
|
2457
2883
|
if (!existsSync12(specsDir)) {
|
|
@@ -2459,7 +2885,7 @@ async function validate(targetPath, options) {
|
|
|
2459
2885
|
if (fmt === "github-annotation") {
|
|
2460
2886
|
console.log(`::error file=,title=Init Required::${msg}`);
|
|
2461
2887
|
} else {
|
|
2462
|
-
console.log(
|
|
2888
|
+
console.log(chalk14.red(msg));
|
|
2463
2889
|
}
|
|
2464
2890
|
process.exit(1);
|
|
2465
2891
|
}
|
|
@@ -2533,8 +2959,7 @@ async function validate(targetPath, options) {
|
|
|
2533
2959
|
} else if (label.includes("letra init")) {
|
|
2534
2960
|
const tmp = mkdtempSync(join12(tmpdir(), "letra-test-"));
|
|
2535
2961
|
execSync(`npx tsx "${entryPoint}" init "${tmp}"`, { ...opts });
|
|
2536
|
-
if (existsSync12(join12(tmp, ".letra", "context.md")))
|
|
2537
|
-
status = "PASS";
|
|
2962
|
+
if (existsSync12(join12(tmp, ".letra", "context.md"))) status = "PASS";
|
|
2538
2963
|
rmSync(tmp, { recursive: true });
|
|
2539
2964
|
} else if (label.includes("letra spec")) {
|
|
2540
2965
|
const tmp = mkdtempSync(join12(tmpdir(), "letra-test-"));
|
|
@@ -2543,9 +2968,7 @@ async function validate(targetPath, options) {
|
|
|
2543
2968
|
...opts,
|
|
2544
2969
|
cwd: tmp
|
|
2545
2970
|
});
|
|
2546
|
-
if (existsSync12(
|
|
2547
|
-
join12(tmp, ".letra", "specs", "smoke-test", "spec.md")
|
|
2548
|
-
))
|
|
2971
|
+
if (existsSync12(join12(tmp, ".letra", "specs", "smoke-test", "spec.md")))
|
|
2549
2972
|
status = "PASS";
|
|
2550
2973
|
rmSync(tmp, { recursive: true });
|
|
2551
2974
|
} else if (label.includes("letra lint")) {
|
|
@@ -2613,10 +3036,7 @@ async function validate(targetPath, options) {
|
|
|
2613
3036
|
}
|
|
2614
3037
|
} else if (label.includes("Settings do Editor")) {
|
|
2615
3038
|
if (existsSync12(vscodeSettingsFile)) {
|
|
2616
|
-
const settingsContent = readFileSync10(
|
|
2617
|
-
vscodeSettingsFile,
|
|
2618
|
-
"utf-8"
|
|
2619
|
-
);
|
|
3039
|
+
const settingsContent = readFileSync10(vscodeSettingsFile, "utf-8");
|
|
2620
3040
|
if (settingsContent.includes("editor.formatOnSave")) {
|
|
2621
3041
|
status = "PASS";
|
|
2622
3042
|
}
|
|
@@ -2651,14 +3071,7 @@ async function validate(targetPath, options) {
|
|
|
2651
3071
|
note = `(error: ${err.message?.split("\n")[0] || "unknown"})`;
|
|
2652
3072
|
}
|
|
2653
3073
|
if (status === "PASS") {
|
|
2654
|
-
collectResult(
|
|
2655
|
-
allResults,
|
|
2656
|
-
"pass",
|
|
2657
|
-
entry.name,
|
|
2658
|
-
label,
|
|
2659
|
-
description,
|
|
2660
|
-
note
|
|
2661
|
-
);
|
|
3074
|
+
collectResult(allResults, "pass", entry.name, label, description, note);
|
|
2662
3075
|
totalPass++;
|
|
2663
3076
|
specPass++;
|
|
2664
3077
|
} else if (intelligenceResult) {
|
|
@@ -2675,37 +3088,16 @@ async function validate(targetPath, options) {
|
|
|
2675
3088
|
totalWarning++;
|
|
2676
3089
|
specWarning++;
|
|
2677
3090
|
} else {
|
|
2678
|
-
collectResult(
|
|
2679
|
-
allResults,
|
|
2680
|
-
"fail",
|
|
2681
|
-
entry.name,
|
|
2682
|
-
label,
|
|
2683
|
-
description,
|
|
2684
|
-
note
|
|
2685
|
-
);
|
|
3091
|
+
collectResult(allResults, "fail", entry.name, label, description, note);
|
|
2686
3092
|
totalFail++;
|
|
2687
3093
|
specFail++;
|
|
2688
3094
|
}
|
|
2689
3095
|
} else if (note.includes("manual check needed")) {
|
|
2690
|
-
collectResult(
|
|
2691
|
-
allResults,
|
|
2692
|
-
"warning",
|
|
2693
|
-
entry.name,
|
|
2694
|
-
label,
|
|
2695
|
-
description,
|
|
2696
|
-
note
|
|
2697
|
-
);
|
|
3096
|
+
collectResult(allResults, "warning", entry.name, label, description, note);
|
|
2698
3097
|
totalWarning++;
|
|
2699
3098
|
specWarning++;
|
|
2700
3099
|
} else {
|
|
2701
|
-
collectResult(
|
|
2702
|
-
allResults,
|
|
2703
|
-
"fail",
|
|
2704
|
-
entry.name,
|
|
2705
|
-
label,
|
|
2706
|
-
description,
|
|
2707
|
-
note
|
|
2708
|
-
);
|
|
3100
|
+
collectResult(allResults, "fail", entry.name, label, description, note);
|
|
2709
3101
|
totalFail++;
|
|
2710
3102
|
specFail++;
|
|
2711
3103
|
}
|
|
@@ -2812,14 +3204,7 @@ async function validate(targetPath, options) {
|
|
|
2812
3204
|
for (const cr of conflictResults) {
|
|
2813
3205
|
if (cr.passed) continue;
|
|
2814
3206
|
const level = conflictCfg.severity === "warning" ? "warning" : "fail";
|
|
2815
|
-
collectResult(
|
|
2816
|
-
allResults,
|
|
2817
|
-
level,
|
|
2818
|
-
"(cross-spec)",
|
|
2819
|
-
cr.label,
|
|
2820
|
-
cr.message,
|
|
2821
|
-
""
|
|
2822
|
-
);
|
|
3207
|
+
collectResult(allResults, level, "(cross-spec)", cr.label, cr.message, "");
|
|
2823
3208
|
if (level === "warning") {
|
|
2824
3209
|
totalWarning++;
|
|
2825
3210
|
} else {
|
|
@@ -2832,27 +3217,20 @@ async function validate(targetPath, options) {
|
|
|
2832
3217
|
out(fmt, r.level, r.spec, r.label, r.message, r.note);
|
|
2833
3218
|
}
|
|
2834
3219
|
}
|
|
2835
|
-
flushResults(
|
|
2836
|
-
allResults,
|
|
2837
|
-
fmt,
|
|
2838
|
-
specGroups,
|
|
2839
|
-
totalPass,
|
|
2840
|
-
totalFail,
|
|
2841
|
-
totalWarning
|
|
2842
|
-
);
|
|
3220
|
+
flushResults(allResults, fmt, specGroups, totalPass, totalFail, totalWarning);
|
|
2843
3221
|
return totalFail;
|
|
2844
3222
|
}
|
|
2845
3223
|
const exitCode = await runValidation();
|
|
2846
3224
|
if (options?.watch) {
|
|
2847
3225
|
let timer = null;
|
|
2848
|
-
console.log(
|
|
3226
|
+
console.log(chalk14.gray("\nWatching for changes... (Ctrl+C to stop)"));
|
|
2849
3227
|
const watcher = watch2(specsDir, { recursive: true });
|
|
2850
3228
|
watcher.on("change", () => {
|
|
2851
3229
|
if (timer) clearTimeout(timer);
|
|
2852
3230
|
timer = setTimeout(async () => {
|
|
2853
3231
|
console.clear();
|
|
2854
3232
|
const code = await runValidation();
|
|
2855
|
-
console.log(
|
|
3233
|
+
console.log(chalk14.gray("\nWatching for changes... (Ctrl+C to stop)"));
|
|
2856
3234
|
}, 300);
|
|
2857
3235
|
});
|
|
2858
3236
|
process.on("SIGINT", () => {
|
|
@@ -2871,18 +3249,13 @@ async function validate(targetPath, options) {
|
|
|
2871
3249
|
}
|
|
2872
3250
|
|
|
2873
3251
|
// src/index.ts
|
|
2874
|
-
var __dirname2 =
|
|
2875
|
-
var pkg = JSON.parse(
|
|
2876
|
-
readFileSync11(join13(resolve15(__dirname2, ".."), "package.json"), "utf-8")
|
|
2877
|
-
);
|
|
3252
|
+
var __dirname2 = fileURLToPath3(new URL(".", import.meta.url));
|
|
3253
|
+
var pkg = JSON.parse(readFileSync11(join13(resolve16(__dirname2, ".."), "package.json"), "utf-8"));
|
|
2878
3254
|
var program = new Command4();
|
|
2879
3255
|
program.name("letra").description("SDD-agnostic memory framework for AI coding agents").version(pkg.version);
|
|
2880
|
-
program.command("init [path]").option("--yes", "Skip prompts and use defaults").description("Initialize .letra/ directory with templates").action((path, options) => init(path, { ...options }));
|
|
3256
|
+
program.command("init [path]").option("--yes", "Skip prompts and use defaults").option("--serve", "Open web UI after init (starts flow serve)").description("Initialize .letra/ directory with templates").action((path, options) => init(path, { ...options }));
|
|
2881
3257
|
var specCmd = program.command("spec").description("Manage specs");
|
|
2882
|
-
specCmd.command("new <name>").option(
|
|
2883
|
-
"--template <type>",
|
|
2884
|
-
"Template type: web-api, cli-tool, mobile-feature"
|
|
2885
|
-
).description("Create a new spec from template").action((name, options) => specNew(name, { ...options }));
|
|
3258
|
+
specCmd.command("new <name>").option("--template <type>", "Template type: web-api, cli-tool, mobile-feature").description("Create a new spec from template").action((name, options) => specNew(name, { ...options }));
|
|
2886
3259
|
program.command("lint [path]").description("Validate spec format and completeness").action(lint);
|
|
2887
3260
|
program.command("validate [path]").option("--watch", "Watch specs and re-validate on change").option("--format <type>", "Output format: text, github-annotation, junit").description("Check if artifacts meet acceptance criteria").action((path, options) => validate(path, { ...options }));
|
|
2888
3261
|
program.addCommand(decisionCommand());
|