@letra-ai/cli 0.6.2 → 0.7.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.
Files changed (52) hide show
  1. package/dist/chunk-2GRNAFBQ.js +5305 -0
  2. package/dist/{chunk-MJ2QXNH6.js → chunk-42RST74I.js} +1 -1
  3. package/dist/chunk-HC24XMPZ.js +269 -0
  4. package/dist/chunk-LUPN3TRC.js +554 -0
  5. package/dist/{chunk-URUC6ZZP.js → chunk-MUCIMQAU.js} +1735 -861
  6. package/dist/chunk-POGWTSEA.js +125 -0
  7. package/dist/chunk-TNF7XTFG.js +6178 -0
  8. package/dist/{chunk-BKAUN5QH.js → chunk-UMC5PDL2.js} +227 -33
  9. package/dist/{chunk-6HSUVCTR.js → chunk-YAQ2TKSK.js} +82 -30
  10. package/dist/client/assets/index-C-6kWNFi.js +232 -0
  11. package/dist/client/assets/index-QV-zN0V8.css +1 -0
  12. package/dist/client/index.html +2 -2
  13. package/dist/fallback-CXCCKHBA.js +56 -0
  14. package/dist/flow-serve-LFILD3EV.js +19 -0
  15. package/dist/{generate-UPFERQMD.js → generate-3R7POT7L.js} +4 -5
  16. package/dist/harness/default/v0.1.0/gates/all-acs-passing.yaml +1 -0
  17. package/dist/harness/default/v0.1.0/gates/has-spec-file.yaml +1 -0
  18. package/dist/harness/default/v0.1.1/gates/all-acs-passing.yaml +1 -0
  19. package/dist/harness/default/v0.1.1/gates/has-spec-file.yaml +1 -0
  20. package/dist/harness/default/v0.1.2/gates/all-acs-passing.yaml +1 -0
  21. package/dist/harness/default/v0.1.2/gates/has-spec-file.yaml +1 -0
  22. package/dist/harness/default/v0.1.3/gates/all-acs-passing.yaml +1 -0
  23. package/dist/harness/default/v0.1.3/gates/has-spec-file.yaml +1 -0
  24. package/dist/harness/default/v0.2.0/executors/registry.yaml +17 -0
  25. package/dist/harness/default/v0.2.0/flows/flow-main.yaml +81 -3
  26. package/dist/harness/default/v0.2.0/gates/code-reviewed.yaml +1 -0
  27. package/dist/harness/default/v0.2.0/gates/human-approved.yaml +1 -0
  28. package/dist/harness/default/v0.2.0/gates/security-clear.yaml +1 -0
  29. package/dist/{health-record-YDVXEVLR.js → health-record-JO2ZTIMR.js} +2 -2
  30. package/dist/index.js +2284 -1168
  31. package/dist/{push-VJRSQGUD.js → push-2ZCQSOHF.js} +37 -49
  32. package/dist/server-WUYVNSH7.js +677 -0
  33. package/dist/service-SVEAXQBX.js +28 -0
  34. package/dist/service-TOBY3OHO.js +22 -0
  35. package/dist/service-USTAY5E3.js +62 -0
  36. package/dist/{session-log-WTQ5JBEN.js → session-log-X2Q4XKQN.js} +6 -2
  37. package/dist/specs-CQRB7LPA.js +21 -0
  38. package/dist/sync-LIVPQXEW.js +21 -0
  39. package/package.json +1 -1
  40. package/dist/chunk-DMOLJWWW.js +0 -3321
  41. package/dist/chunk-EDD55PWL.js +0 -119
  42. package/dist/chunk-H64RC3YS.js +0 -254
  43. package/dist/chunk-L6YKDTAQ.js +0 -275
  44. package/dist/chunk-OIHMDOIN.js +0 -1326
  45. package/dist/client/assets/index-EyRsq1SH.css +0 -1
  46. package/dist/client/assets/index-WfKR7Xp6.js +0 -232
  47. package/dist/fallback-MQLGS4KL.js +0 -46
  48. package/dist/flow-serve-G5MSSB3G.js +0 -18
  49. package/dist/focus-sync-3D3XWCTI.js +0 -17
  50. package/dist/server-P6GKRWDX.js +0 -423
  51. package/dist/service-2JN2KI4D.js +0 -29
  52. package/dist/sitrep-OKNZJICV.js +0 -16
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ readSpecCatalog
4
+ } from "./chunk-LUPN3TRC.js";
5
+ import {
6
+ getLetraDir2 as getLetraDir
7
+ } from "./chunk-YAQ2TKSK.js";
8
+
9
+ // src/flow-serve/specs.ts
10
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, readdirSync, writeFileSync } from "fs";
11
+ import { join } from "path";
12
+
13
+ // src/validation/structure.ts
14
+ import { existsSync, readFileSync } from "fs";
15
+ var REQUIRED_SECTIONS = [
16
+ "## Outcome",
17
+ "## Constraints",
18
+ "## Exclusions",
19
+ "## Acceptance Criteria",
20
+ "## Context"
21
+ ];
22
+ function checkRequiredSections(content) {
23
+ return REQUIRED_SECTIONS.filter((section) => !content.includes(section));
24
+ }
25
+ function checkSpecLength(content, maxChars = 3e3) {
26
+ return content.length > maxChars ? `Spec exceeds ${maxChars} chars (should be thin \u2014 max 1 page)` : null;
27
+ }
28
+ function checkChecklist(content) {
29
+ const hasChecklist = /-\s*\[[ x]\]\s*\*\*/i.test(content);
30
+ if (!hasChecklist && content.includes("## Acceptance Criteria")) {
31
+ return "Acceptance Criteria section exists but has no checklist items";
32
+ }
33
+ return null;
34
+ }
35
+ function validateSpecStructure(specFile) {
36
+ const errors = [];
37
+ const warnings = [];
38
+ if (!existsSync(specFile)) {
39
+ errors.push("Missing spec.md");
40
+ return { errors, warnings };
41
+ }
42
+ const content = readFileSync(specFile, "utf-8");
43
+ const missingSections = checkRequiredSections(content);
44
+ errors.push(...missingSections.map((s) => `Missing section: ${s}`));
45
+ const lengthWarning = checkSpecLength(content);
46
+ if (lengthWarning) warnings.push(lengthWarning);
47
+ const checklistError = checkChecklist(content);
48
+ if (checklistError) errors.push(checklistError);
49
+ return { errors, warnings };
50
+ }
51
+
52
+ // src/flow-serve/specs.ts
53
+ function loadResolvedSpecs(root, workflow) {
54
+ const result = [];
55
+ const catalog = readSpecCatalog(root);
56
+ const isActiveSpec = (id) => {
57
+ const disposition = catalog?.specs.find((spec) => spec.id === id)?.disposition.disposition;
58
+ return disposition !== "archived";
59
+ };
60
+ if (workflow?.specLinks) {
61
+ for (const [id, link] of Object.entries(workflow.specLinks)) {
62
+ if (!isActiveSpec(id)) continue;
63
+ const filePath = join(root, link.path);
64
+ if (existsSync2(filePath)) {
65
+ result.push({ id, content: readFileSync2(filePath, "utf-8") });
66
+ }
67
+ }
68
+ }
69
+ const specsDir = join(getLetraDir(root), "specs");
70
+ const registered = new Set(result.map((entry) => entry.id));
71
+ if (!existsSync2(specsDir)) return result;
72
+ for (const entry of readdirSync(specsDir, { withFileTypes: true })) {
73
+ if (!entry.isDirectory() || registered.has(entry.name) || !isActiveSpec(entry.name)) continue;
74
+ const specPath = join(specsDir, entry.name, "spec.md");
75
+ if (!existsSync2(specPath)) continue;
76
+ result.push({ id: entry.name, content: readFileSync2(specPath, "utf-8") });
77
+ }
78
+ return result;
79
+ }
80
+ function readAllowedContextFile(workspaceDir, file) {
81
+ const allowedFiles = /* @__PURE__ */ new Set(["context.md", "constitution.md", "glossary.md"]);
82
+ if (!allowedFiles.has(file)) return null;
83
+ const filePath = join(workspaceDir, file);
84
+ if (!existsSync2(filePath)) return null;
85
+ const content = readFileSync2(filePath, "utf-8");
86
+ return file === "context.md" ? stripSitrepSnapshots(content) : content;
87
+ }
88
+ function stripSitrepSnapshots(content) {
89
+ return content.replace(/\r?\n?<!-- sitrep:start -->[\s\S]*?<!-- sitrep:end -->\r?\n?/g, "\n").trimEnd() + "\n";
90
+ }
91
+ function writeSpec(workspaceDir, id, content) {
92
+ const specDir = join(workspaceDir, "specs", id);
93
+ if (!existsSync2(specDir)) mkdirSync(specDir, { recursive: true });
94
+ writeFileSync(join(specDir, "spec.md"), content, "utf-8");
95
+ }
96
+ function clearSpec(workspaceDir, id) {
97
+ const specFile = join(workspaceDir, "specs", id, "spec.md");
98
+ if (existsSync2(specFile)) writeFileSync(specFile, "", "utf-8");
99
+ }
100
+ function validateSpec(workspaceDir, id) {
101
+ const specFile = join(workspaceDir, "specs", id, "spec.md");
102
+ if (!existsSync2(specFile)) {
103
+ return {
104
+ id,
105
+ issues: [{ type: "error", msg: "spec.md not found" }],
106
+ valid: false
107
+ };
108
+ }
109
+ const { errors, warnings } = validateSpecStructure(specFile);
110
+ const issues = [
111
+ ...errors.map((msg) => ({ type: "error", msg })),
112
+ ...warnings.map((msg) => ({ type: "warning", msg }))
113
+ ];
114
+ return { id, issues, valid: errors.length === 0 };
115
+ }
116
+
117
+ export {
118
+ validateSpecStructure,
119
+ loadResolvedSpecs,
120
+ readAllowedContextFile,
121
+ stripSitrepSnapshots,
122
+ writeSpec,
123
+ clearSpec,
124
+ validateSpec
125
+ };