@letra-ai/cli 0.2.0 → 0.3.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/.letra/brand/logo-01-terminal.svg +6 -0
- package/.letra/brand/logo-02-bookmark.svg +6 -0
- package/.letra/brand/logo-03-diamond.svg +7 -0
- package/.letra/constitution.md +35 -35
- package/.letra/context.md +29 -29
- package/.letra/decisions/flow-mvp-escopo-enxuto-3-comandos-valor-imediato.md +35 -35
- package/.letra/glossary.md +21 -21
- package/.letra/lessons-learned.md +20 -20
- package/.letra/specs/_template.md +27 -27
- package/.letra/specs/adapter-claude-code/acceptance.md +6 -6
- package/.letra/specs/adapter-claude-code/spec.md +27 -27
- package/.letra/specs/adapter-codex-cli/acceptance.md +6 -6
- package/.letra/specs/adapter-cursor/acceptance.md +6 -6
- package/.letra/specs/adapter-cursor/spec.md +29 -29
- package/.letra/specs/adapter-opencode/acceptance.md +6 -6
- package/.letra/specs/adapter-opencode/spec.md +35 -35
- package/.letra/specs/adapter-vscode/acceptance.md +6 -6
- package/.letra/specs/adapter-vscode/spec.md +29 -29
- package/.letra/specs/adapter-windsurf/acceptance.md +6 -6
- package/.letra/specs/adapter-windsurf/spec.md +27 -27
- package/.letra/specs/ci-cd-pipeline/acceptance.md +6 -6
- package/.letra/specs/ci-cd-pipeline/spec.md +30 -30
- package/.letra/specs/cli-skeleton/acceptance.md +7 -7
- package/.letra/specs/cli-skeleton/spec.md +30 -30
- package/.letra/specs/flow-edit-diff/acceptance.md +6 -6
- package/.letra/specs/flow-edit-diff/spec.md +30 -30
- package/.letra/specs/flow-export-import/acceptance.md +6 -6
- package/.letra/specs/flow-export-import/spec.md +27 -27
- package/.letra/specs/flow-mvp/roadmap.md +40 -40
- package/.letra/specs/flow-mvp/spec.md +40 -40
- package/.letra/specs/flow-serve/spec.md +47 -0
- package/.letra/specs/flow-visualize/acceptance.md +6 -6
- package/.letra/specs/flow-visualize/spec.md +28 -28
- package/.letra/specs/validate-config/acceptance.md +9 -9
- package/.letra/specs/validate-intelligence/acceptance.md +9 -9
- package/.letra/specs/validate-intelligence/spec.md +30 -30
- package/.letra/workflow.json +47 -0
- package/LICENSE +21 -21
- package/README.md +240 -240
- package/dist/index.js +592 -147
- package/package.json +61 -61
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { join as
|
|
4
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
5
|
+
import { join as join13, resolve as resolve15 } from "path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
import { Command as Command4 } from "commander";
|
|
8
8
|
|
|
@@ -104,12 +104,12 @@ import ora from "ora";
|
|
|
104
104
|
function askText(query, defaultValue) {
|
|
105
105
|
if (!process.stdin.isTTY) return Promise.resolve(defaultValue);
|
|
106
106
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
107
|
-
return new Promise((
|
|
107
|
+
return new Promise((resolve16) => {
|
|
108
108
|
const formatted = `${chalk2.cyan(query)} ${chalk2.gray(`(default: ${defaultValue})`)}
|
|
109
109
|
> `;
|
|
110
110
|
rl.question(formatted, (answer) => {
|
|
111
111
|
rl.close();
|
|
112
|
-
|
|
112
|
+
resolve16(answer.trim() || defaultValue);
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -818,9 +818,447 @@ function flowMoveAction(targetPath, itemId, options) {
|
|
|
818
818
|
flowMove(root, itemId, options.to);
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
+
// src/commands/flow-serve.ts
|
|
822
|
+
import {
|
|
823
|
+
existsSync as existsSync6,
|
|
824
|
+
readFileSync as readFileSync5,
|
|
825
|
+
readdirSync as readdirSync3,
|
|
826
|
+
statSync,
|
|
827
|
+
watch
|
|
828
|
+
} from "fs";
|
|
829
|
+
import {
|
|
830
|
+
createServer
|
|
831
|
+
} from "http";
|
|
832
|
+
import { join as join6, resolve as resolve8 } from "path";
|
|
833
|
+
var DEFAULT_PORT = 3e3;
|
|
834
|
+
function loadSpecs(root) {
|
|
835
|
+
const specsDir = join6(root, ".letra", "specs");
|
|
836
|
+
if (!existsSync6(specsDir)) return [];
|
|
837
|
+
return readdirSync3(specsDir).filter((entry) => {
|
|
838
|
+
const specFile = join6(specsDir, entry, "spec.md");
|
|
839
|
+
return statSync(join6(specsDir, entry)).isDirectory() && existsSync6(specFile);
|
|
840
|
+
}).map((entry) => {
|
|
841
|
+
const content = readFileSync5(join6(specsDir, entry, "spec.md"), "utf-8");
|
|
842
|
+
return { name: entry, content };
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
function findItemSpec(item, specs) {
|
|
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; }
|
|
987
|
+
}
|
|
988
|
+
</style>
|
|
989
|
+
</head>
|
|
990
|
+
<body>
|
|
991
|
+
<header>
|
|
992
|
+
<div class="brand">
|
|
993
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" fill="none">
|
|
994
|
+
<rect width="40" height="40" rx="8" fill="#d29922"/>
|
|
995
|
+
<path d="M20 10l10 14-10 14-10-14L20 10z" fill="#0f1117"/>
|
|
996
|
+
<circle cx="20" cy="24" r="3" fill="#d29922"/>
|
|
997
|
+
</svg>
|
|
998
|
+
<div class="brand-text">letra<span>.dev</span></div>
|
|
999
|
+
</div>
|
|
1000
|
+
<div class="header-status">
|
|
1001
|
+
<span class="live"></span>
|
|
1002
|
+
<span id="status">connected</span>
|
|
1003
|
+
<span>· updated ${updatedAt}</span>
|
|
1004
|
+
</div>
|
|
1005
|
+
</header>
|
|
1006
|
+
<div class="project-desc" id="projectDesc">
|
|
1007
|
+
<h1>${name}</h1>
|
|
1008
|
+
${workflow?.description ? `<p>${esc(workflow.description)}</p>` : ""}
|
|
1009
|
+
</div>
|
|
1010
|
+
<div class="board-scroll">
|
|
1011
|
+
<div class="board" id="board">
|
|
1012
|
+
${stageCards}
|
|
1013
|
+
</div>
|
|
1014
|
+
</div>
|
|
1015
|
+
<div id="modal" class="modal hidden">
|
|
1016
|
+
<div class="modal-backdrop" id="modalBackdrop"></div>
|
|
1017
|
+
<div class="modal-content">
|
|
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;
|
|
1059
|
+
}
|
|
1060
|
+
return null;
|
|
1061
|
+
}
|
|
1062
|
+
function renderBoard(wf) {
|
|
1063
|
+
const sorted = (wf.stages || []).sort((a, b) => a.order - b.order);
|
|
1064
|
+
const itemsByStage = {};
|
|
1065
|
+
for (const s of sorted) itemsByStage[s.id] = [];
|
|
1066
|
+
for (const it of (wf.items || [])) {
|
|
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;
|
|
1116
|
+
}
|
|
1117
|
+
document.getElementById("modalTitle").textContent = "Spec: " + name;
|
|
1118
|
+
document.getElementById("modalBody").textContent = spec.content;
|
|
1119
|
+
document.getElementById("modal").classList.remove("hidden");
|
|
1120
|
+
}
|
|
1121
|
+
document.getElementById("modalClose").addEventListener("click", () => {
|
|
1122
|
+
document.getElementById("modal").classList.add("hidden");
|
|
1123
|
+
});
|
|
1124
|
+
document.getElementById("modalBackdrop").addEventListener("click", () => {
|
|
1125
|
+
document.getElementById("modal").classList.add("hidden");
|
|
1126
|
+
});
|
|
1127
|
+
document.addEventListener("keydown", (e) => {
|
|
1128
|
+
if (e.key === "Escape") document.getElementById("modal").classList.add("hidden");
|
|
1129
|
+
});
|
|
1130
|
+
attachSpecButtons();
|
|
1131
|
+
<${"/script"}>
|
|
1132
|
+
</body>
|
|
1133
|
+
</html>`;
|
|
1134
|
+
}
|
|
1135
|
+
function esc(s) {
|
|
1136
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1137
|
+
}
|
|
1138
|
+
var FlowServer = class {
|
|
1139
|
+
server;
|
|
1140
|
+
watcher;
|
|
1141
|
+
clients = /* @__PURE__ */ new Set();
|
|
1142
|
+
root;
|
|
1143
|
+
port;
|
|
1144
|
+
loadWorkflow;
|
|
1145
|
+
constructor(root, port = DEFAULT_PORT) {
|
|
1146
|
+
this.root = root;
|
|
1147
|
+
this.port = port;
|
|
1148
|
+
this.loadWorkflow = () => loadWorkflow(root);
|
|
1149
|
+
}
|
|
1150
|
+
handleRequest = (req, res) => {
|
|
1151
|
+
const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
1152
|
+
const path = url.pathname;
|
|
1153
|
+
if (path === "/events") {
|
|
1154
|
+
res.writeHead(200, {
|
|
1155
|
+
"Content-Type": "text/event-stream",
|
|
1156
|
+
"Cache-Control": "no-cache",
|
|
1157
|
+
Connection: "keep-alive"
|
|
1158
|
+
});
|
|
1159
|
+
res.write("event: connected\ndata: {}\n\n");
|
|
1160
|
+
this.clients.add(res);
|
|
1161
|
+
req.on("close", () => this.clients.delete(res));
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (path === "/api/workflow") {
|
|
1165
|
+
const wf2 = this.loadWorkflow();
|
|
1166
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1167
|
+
res.end(JSON.stringify(wf2 ?? { error: "No workflow found" }));
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
if (path === "/api/specs") {
|
|
1171
|
+
const specs2 = loadSpecs(this.root);
|
|
1172
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1173
|
+
res.end(JSON.stringify(specs2));
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const wf = this.loadWorkflow();
|
|
1177
|
+
const specs = loadSpecs(this.root);
|
|
1178
|
+
const html = boardHtml(wf, specs);
|
|
1179
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
1180
|
+
res.end(html);
|
|
1181
|
+
};
|
|
1182
|
+
broadcast() {
|
|
1183
|
+
if (this.clients.size === 0) return;
|
|
1184
|
+
const data = "event: workflow-updated\ndata: {}\n\n";
|
|
1185
|
+
for (const client of this.clients) {
|
|
1186
|
+
try {
|
|
1187
|
+
client.write(data);
|
|
1188
|
+
} catch {
|
|
1189
|
+
this.clients.delete(client);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
start() {
|
|
1194
|
+
return new Promise((resolve16, reject) => {
|
|
1195
|
+
this.server = createServer(this.handleRequest);
|
|
1196
|
+
this.server.listen(this.port, () => {
|
|
1197
|
+
const wfPath = join6(this.root, ".letra", "workflow.json");
|
|
1198
|
+
if (existsSync6(wfPath)) {
|
|
1199
|
+
try {
|
|
1200
|
+
this.watcher = watch(wfPath, () => this.broadcast());
|
|
1201
|
+
} catch {
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
resolve16();
|
|
1205
|
+
});
|
|
1206
|
+
this.server.on("error", reject);
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
stop() {
|
|
1210
|
+
if (this.watcher) this.watcher.close();
|
|
1211
|
+
if (this.server) this.server.close();
|
|
1212
|
+
for (const client of this.clients) {
|
|
1213
|
+
client.destroy();
|
|
1214
|
+
}
|
|
1215
|
+
this.clients.clear();
|
|
1216
|
+
}
|
|
1217
|
+
getPort() {
|
|
1218
|
+
return this.port;
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
async function flowServeAction(targetPath, options) {
|
|
1222
|
+
const root = resolve8(process.cwd(), targetPath ?? ".");
|
|
1223
|
+
const port = options?.port ?? DEFAULT_PORT;
|
|
1224
|
+
const wf = loadWorkflow(root);
|
|
1225
|
+
if (!wf) {
|
|
1226
|
+
console.log("No workflow found. Run 'letra flow init --quick' first");
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
const server = new FlowServer(root, port);
|
|
1230
|
+
try {
|
|
1231
|
+
await server.start();
|
|
1232
|
+
console.log(`
|
|
1233
|
+
Flow Board \u2192 http://localhost:${port}
|
|
1234
|
+
`);
|
|
1235
|
+
console.log(" Press Ctrl+C to stop\n");
|
|
1236
|
+
if (options?.open) {
|
|
1237
|
+
const { execSync: execSync2 } = await import("child_process");
|
|
1238
|
+
const cmd = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
1239
|
+
try {
|
|
1240
|
+
execSync2(`${cmd} http://localhost:${port}`, { stdio: "ignore" });
|
|
1241
|
+
} catch {
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
await new Promise((resolve16) => {
|
|
1245
|
+
process.on("SIGINT", () => {
|
|
1246
|
+
server.stop();
|
|
1247
|
+
resolve16();
|
|
1248
|
+
});
|
|
1249
|
+
});
|
|
1250
|
+
} catch (err) {
|
|
1251
|
+
console.error(
|
|
1252
|
+
`Failed to start server on port ${port}:`,
|
|
1253
|
+
err.message
|
|
1254
|
+
);
|
|
1255
|
+
process.exit(1);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
|
|
821
1259
|
// src/commands/flow-visualize.ts
|
|
822
1260
|
import { writeFileSync as writeFileSync6 } from "fs";
|
|
823
|
-
import { resolve as
|
|
1261
|
+
import { resolve as resolve9 } from "path";
|
|
824
1262
|
import chalk8 from "chalk";
|
|
825
1263
|
var MERMAID_LIVE = "https://mermaid.live/edit#";
|
|
826
1264
|
function generateMermaid(workflow) {
|
|
@@ -880,7 +1318,7 @@ function flowVisualize(root, options) {
|
|
|
880
1318
|
}
|
|
881
1319
|
const mermaid = generateMermaid(workflow);
|
|
882
1320
|
if (options?.output) {
|
|
883
|
-
const outputPath =
|
|
1321
|
+
const outputPath = resolve9(root, options.output);
|
|
884
1322
|
const ext = options.output.toLowerCase().split(".").pop();
|
|
885
1323
|
let content;
|
|
886
1324
|
let label;
|
|
@@ -907,7 +1345,7 @@ Copy to ${MERMAID_LIVE} to render`));
|
|
|
907
1345
|
}
|
|
908
1346
|
}
|
|
909
1347
|
function flowVisualizeAction(targetPath, options) {
|
|
910
|
-
const root =
|
|
1348
|
+
const root = resolve9(process.cwd(), targetPath || ".");
|
|
911
1349
|
flowVisualize(root, options);
|
|
912
1350
|
}
|
|
913
1351
|
|
|
@@ -936,6 +1374,12 @@ function flowCommand() {
|
|
|
936
1374
|
cmd.command("import <file>").description("Import workflow from a JSON file").action((file) => {
|
|
937
1375
|
flowImportAction(void 0, file);
|
|
938
1376
|
});
|
|
1377
|
+
cmd.command("serve").option("--port <number>", "Port to listen on", "3000").option("--open", "Open browser automatically").description("Start local web server with live board").action((options) => {
|
|
1378
|
+
flowServeAction(void 0, {
|
|
1379
|
+
port: options.port ? Number(options.port) : void 0,
|
|
1380
|
+
open: options.open
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
939
1383
|
cmd.command("visualize").option("--output <file>", "Save diagram to file").description("Generate Mermaid diagram of workflow").action((options) => {
|
|
940
1384
|
flowVisualizeAction(void 0, options);
|
|
941
1385
|
});
|
|
@@ -950,23 +1394,23 @@ function flowCommand() {
|
|
|
950
1394
|
}
|
|
951
1395
|
|
|
952
1396
|
// src/commands/focus.ts
|
|
953
|
-
import { existsSync as
|
|
954
|
-
import { join as
|
|
1397
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, unlinkSync, writeFileSync as writeFileSync7 } from "fs";
|
|
1398
|
+
import { join as join7, resolve as resolve10 } from "path";
|
|
955
1399
|
import chalk9 from "chalk";
|
|
956
1400
|
import { Command as Command3 } from "commander";
|
|
957
1401
|
function extractOutcome(specDir) {
|
|
958
|
-
const specFile =
|
|
959
|
-
if (!
|
|
960
|
-
const content =
|
|
1402
|
+
const specFile = join7(specDir, "spec.md");
|
|
1403
|
+
if (!existsSync7(specFile)) return null;
|
|
1404
|
+
const content = readFileSync6(specFile, "utf-8");
|
|
961
1405
|
const match = content.match(/## Outcome\s+([\s\S]*?)(?=\n## |\n*$)/);
|
|
962
1406
|
return match ? match[1].trim() : null;
|
|
963
1407
|
}
|
|
964
1408
|
function focus_default() {
|
|
965
1409
|
return new Command3("focus").argument("[spec]", "Spec name to focus on").option("--clear", "Remove focus file").action((spec, options) => {
|
|
966
|
-
const root =
|
|
967
|
-
const focusFile =
|
|
1410
|
+
const root = resolve10(process.cwd());
|
|
1411
|
+
const focusFile = join7(root, ".letra", "focus.md");
|
|
968
1412
|
if (options.clear) {
|
|
969
|
-
if (
|
|
1413
|
+
if (existsSync7(focusFile)) {
|
|
970
1414
|
unlinkSync(focusFile);
|
|
971
1415
|
console.log(chalk9.green("Focus removed."));
|
|
972
1416
|
} else {
|
|
@@ -975,9 +1419,9 @@ function focus_default() {
|
|
|
975
1419
|
return;
|
|
976
1420
|
}
|
|
977
1421
|
if (spec) {
|
|
978
|
-
const specDir =
|
|
979
|
-
const specFile =
|
|
980
|
-
if (!
|
|
1422
|
+
const specDir = join7(root, ".letra", "specs", spec);
|
|
1423
|
+
const specFile = join7(specDir, "spec.md");
|
|
1424
|
+
if (!existsSync7(specFile)) {
|
|
981
1425
|
console.log(chalk9.red(`Spec "${spec}" not found`));
|
|
982
1426
|
process.exit(1);
|
|
983
1427
|
}
|
|
@@ -994,8 +1438,8 @@ function focus_default() {
|
|
|
994
1438
|
console.log(chalk9.green(`Focus set to "${spec}".`));
|
|
995
1439
|
return;
|
|
996
1440
|
}
|
|
997
|
-
if (
|
|
998
|
-
console.log(
|
|
1441
|
+
if (existsSync7(focusFile)) {
|
|
1442
|
+
console.log(readFileSync6(focusFile, "utf-8"));
|
|
999
1443
|
} else {
|
|
1000
1444
|
console.log("Nenhum foco definido.");
|
|
1001
1445
|
}
|
|
@@ -1005,11 +1449,11 @@ function focus_default() {
|
|
|
1005
1449
|
// src/commands/init.ts
|
|
1006
1450
|
import {
|
|
1007
1451
|
copyFileSync,
|
|
1008
|
-
existsSync as
|
|
1452
|
+
existsSync as existsSync8,
|
|
1009
1453
|
mkdirSync as mkdirSync4,
|
|
1010
1454
|
writeFileSync as writeFileSync8
|
|
1011
1455
|
} from "fs";
|
|
1012
|
-
import { join as
|
|
1456
|
+
import { join as join8, resolve as resolve11 } from "path";
|
|
1013
1457
|
import { createInterface as createInterface2 } from "readline";
|
|
1014
1458
|
import { fileURLToPath } from "url";
|
|
1015
1459
|
import chalk10 from "chalk";
|
|
@@ -1018,20 +1462,20 @@ var __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
|
1018
1462
|
function ask(query, options) {
|
|
1019
1463
|
if (!process.stdin.isTTY) return Promise.resolve(options[0]);
|
|
1020
1464
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
1021
|
-
return new Promise((
|
|
1465
|
+
return new Promise((resolve16) => {
|
|
1022
1466
|
const formatted = `${chalk10.cyan(query)} ${options.map((o) => chalk10.gray(`(${o})`)).join(" ")}
|
|
1023
1467
|
> `;
|
|
1024
1468
|
rl.question(formatted, (answer) => {
|
|
1025
1469
|
rl.close();
|
|
1026
1470
|
const trimmed = answer.trim().toLowerCase();
|
|
1027
1471
|
if (trimmed && options.some((o) => o.toLowerCase().startsWith(trimmed))) {
|
|
1028
|
-
|
|
1472
|
+
resolve16(
|
|
1029
1473
|
options.find((o) => o.toLowerCase().startsWith(trimmed)) ?? options[0]
|
|
1030
1474
|
);
|
|
1031
1475
|
} else if (trimmed && options.includes(trimmed)) {
|
|
1032
|
-
|
|
1476
|
+
resolve16(trimmed);
|
|
1033
1477
|
} else {
|
|
1034
|
-
|
|
1478
|
+
resolve16(options[0]);
|
|
1035
1479
|
}
|
|
1036
1480
|
});
|
|
1037
1481
|
});
|
|
@@ -1102,48 +1546,48 @@ ${format === "at" ? "# Context\n@.letra/context.md\n@.letra/constitution.md\n@.l
|
|
|
1102
1546
|
switch (tool) {
|
|
1103
1547
|
case "cursor":
|
|
1104
1548
|
adapters.push({
|
|
1105
|
-
path:
|
|
1549
|
+
path: join8(root, ".cursorrules"),
|
|
1106
1550
|
content: baseContent("Cursor", "at")
|
|
1107
1551
|
});
|
|
1108
1552
|
break;
|
|
1109
1553
|
case "claude-code":
|
|
1110
1554
|
adapters.push({
|
|
1111
|
-
path:
|
|
1555
|
+
path: join8(root, "CLAUDE.md"),
|
|
1112
1556
|
content: baseContent("Claude Code", "text")
|
|
1113
1557
|
});
|
|
1114
1558
|
break;
|
|
1115
1559
|
case "windsurf":
|
|
1116
1560
|
adapters.push({
|
|
1117
|
-
path:
|
|
1561
|
+
path: join8(root, ".windsurfrules"),
|
|
1118
1562
|
content: baseContent("Windsurf", "at")
|
|
1119
1563
|
});
|
|
1120
1564
|
break;
|
|
1121
1565
|
case "vscode":
|
|
1122
1566
|
adapters.push({
|
|
1123
|
-
path:
|
|
1567
|
+
path: join8(root, ".github", "copilot-instructions.md"),
|
|
1124
1568
|
content: baseContent("VSCode Copilot", "text")
|
|
1125
1569
|
});
|
|
1126
1570
|
break;
|
|
1127
1571
|
case "opencode":
|
|
1128
1572
|
adapters.push({
|
|
1129
|
-
path:
|
|
1573
|
+
path: join8(root, "AGENTS.md"),
|
|
1130
1574
|
content: baseContent("OpenCode", "text")
|
|
1131
1575
|
});
|
|
1132
1576
|
break;
|
|
1133
1577
|
}
|
|
1134
1578
|
}
|
|
1135
1579
|
for (const { path, content } of adapters) {
|
|
1136
|
-
const dir =
|
|
1137
|
-
if (!
|
|
1580
|
+
const dir = join8(path, "..");
|
|
1581
|
+
if (!existsSync8(dir)) mkdirSync4(dir, { recursive: true });
|
|
1138
1582
|
writeFileSync8(path, content);
|
|
1139
1583
|
console.log(` ${chalk10.gray("Created")} ${path.replace(`${root}/`, "")}`);
|
|
1140
1584
|
}
|
|
1141
1585
|
}
|
|
1142
1586
|
async function init(targetPath, options) {
|
|
1143
|
-
const root =
|
|
1144
|
-
const letraDir =
|
|
1587
|
+
const root = resolve11(process.cwd(), targetPath || ".");
|
|
1588
|
+
const letraDir = join8(root, ".letra");
|
|
1145
1589
|
const spinner = ora2("Initializing Letra...").start();
|
|
1146
|
-
if (
|
|
1590
|
+
if (existsSync8(letraDir)) {
|
|
1147
1591
|
spinner.warn(chalk10.yellow(".letra/ already exists"));
|
|
1148
1592
|
return;
|
|
1149
1593
|
}
|
|
@@ -1173,10 +1617,10 @@ async function init(targetPath, options) {
|
|
|
1173
1617
|
tool = answer.toLowerCase();
|
|
1174
1618
|
spinner.start();
|
|
1175
1619
|
}
|
|
1176
|
-
mkdirSync4(
|
|
1177
|
-
mkdirSync4(
|
|
1178
|
-
mkdirSync4(
|
|
1179
|
-
const templateDir =
|
|
1620
|
+
mkdirSync4(join8(letraDir, "decisions"), { recursive: true });
|
|
1621
|
+
mkdirSync4(join8(letraDir, "specs", "_template"), { recursive: true });
|
|
1622
|
+
mkdirSync4(join8(letraDir, "adapters"), { recursive: true });
|
|
1623
|
+
const templateDir = join8(__dirname, "..", "..", ".letra");
|
|
1180
1624
|
const templates = [
|
|
1181
1625
|
"context.md",
|
|
1182
1626
|
"constitution.md",
|
|
@@ -1184,11 +1628,11 @@ async function init(targetPath, options) {
|
|
|
1184
1628
|
"lessons-learned.md"
|
|
1185
1629
|
];
|
|
1186
1630
|
for (const file of templates) {
|
|
1187
|
-
const src =
|
|
1188
|
-
const dest =
|
|
1189
|
-
if (
|
|
1631
|
+
const src = join8(templateDir, file);
|
|
1632
|
+
const dest = join8(letraDir, file);
|
|
1633
|
+
if (existsSync8(src)) copyFileSync(src, dest);
|
|
1190
1634
|
}
|
|
1191
|
-
const specTemplate =
|
|
1635
|
+
const specTemplate = join8(letraDir, "specs", "_template.md");
|
|
1192
1636
|
const specContent = `# Spec Template
|
|
1193
1637
|
|
|
1194
1638
|
## Outcome
|
|
@@ -1207,15 +1651,15 @@ O que explicitamente N\xC3O est\xE1 neste escopo.
|
|
|
1207
1651
|
Por que estamos construindo isso.
|
|
1208
1652
|
`;
|
|
1209
1653
|
writeFileSync8(specTemplate, specContent);
|
|
1210
|
-
const configPath =
|
|
1654
|
+
const configPath = join8(letraDir, "config.json");
|
|
1211
1655
|
writeFileSync8(configPath, adaptConfig(projectType));
|
|
1212
1656
|
console.log(` ${chalk10.gray("Created")} .letra/config.json`);
|
|
1213
1657
|
const tools = adaptersForTool(tool);
|
|
1214
1658
|
generateAdapterFiles(root, tools);
|
|
1215
1659
|
if (tool === "todos" || tool === "vscode") {
|
|
1216
|
-
const vscodeDir =
|
|
1217
|
-
if (!
|
|
1218
|
-
const vscodeSettingsPath =
|
|
1660
|
+
const vscodeDir = join8(root, ".vscode");
|
|
1661
|
+
if (!existsSync8(vscodeDir)) mkdirSync4(vscodeDir, { recursive: true });
|
|
1662
|
+
const vscodeSettingsPath = join8(vscodeDir, "settings.json");
|
|
1219
1663
|
const vscodeSettingsContent = `{
|
|
1220
1664
|
"editor.formatOnSave": true,
|
|
1221
1665
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
@@ -1242,8 +1686,8 @@ Por que estamos construindo isso.
|
|
|
1242
1686
|
}
|
|
1243
1687
|
|
|
1244
1688
|
// src/commands/lint.ts
|
|
1245
|
-
import { existsSync as
|
|
1246
|
-
import { join as
|
|
1689
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, readdirSync as readdirSync5 } from "fs";
|
|
1690
|
+
import { join as join9, resolve as resolve12 } from "path";
|
|
1247
1691
|
import chalk11 from "chalk";
|
|
1248
1692
|
var REQUIRED_SECTIONS = [
|
|
1249
1693
|
"## Outcome",
|
|
@@ -1253,9 +1697,9 @@ var REQUIRED_SECTIONS = [
|
|
|
1253
1697
|
"## Context"
|
|
1254
1698
|
];
|
|
1255
1699
|
async function lint(targetPath) {
|
|
1256
|
-
const root =
|
|
1257
|
-
const specsDir =
|
|
1258
|
-
if (!
|
|
1700
|
+
const root = resolve12(process.cwd(), targetPath || ".");
|
|
1701
|
+
const specsDir = join9(root, ".letra", "specs");
|
|
1702
|
+
if (!existsSync9(specsDir)) {
|
|
1259
1703
|
console.log(
|
|
1260
1704
|
chalk11.red("Error: .letra/specs/ not found. Run 'letra init' first.")
|
|
1261
1705
|
);
|
|
@@ -1264,16 +1708,16 @@ async function lint(targetPath) {
|
|
|
1264
1708
|
const results = [];
|
|
1265
1709
|
let totalErrors = 0;
|
|
1266
1710
|
let totalWarnings = 0;
|
|
1267
|
-
const entries =
|
|
1711
|
+
const entries = readdirSync5(specsDir, { withFileTypes: true });
|
|
1268
1712
|
for (const entry of entries) {
|
|
1269
1713
|
if (!entry.isDirectory() || entry.name.startsWith("_")) continue;
|
|
1270
|
-
const specFile =
|
|
1714
|
+
const specFile = join9(specsDir, entry.name, "spec.md");
|
|
1271
1715
|
const errors = [];
|
|
1272
1716
|
const warnings = [];
|
|
1273
|
-
if (!
|
|
1717
|
+
if (!existsSync9(specFile)) {
|
|
1274
1718
|
errors.push("Missing spec.md");
|
|
1275
1719
|
} else {
|
|
1276
|
-
const content =
|
|
1720
|
+
const content = readFileSync7(specFile, "utf-8");
|
|
1277
1721
|
for (const section of REQUIRED_SECTIONS) {
|
|
1278
1722
|
if (!content.includes(section)) {
|
|
1279
1723
|
errors.push(`Missing section: ${section}`);
|
|
@@ -1321,13 +1765,13 @@ ${results.length} spec(s) with issues: ${totalErrors} error(s), ${totalWarnings}
|
|
|
1321
1765
|
|
|
1322
1766
|
// src/commands/spec.ts
|
|
1323
1767
|
import {
|
|
1324
|
-
existsSync as
|
|
1768
|
+
existsSync as existsSync10,
|
|
1325
1769
|
mkdirSync as mkdirSync5,
|
|
1326
|
-
readFileSync as
|
|
1327
|
-
readdirSync as
|
|
1770
|
+
readFileSync as readFileSync8,
|
|
1771
|
+
readdirSync as readdirSync6,
|
|
1328
1772
|
writeFileSync as writeFileSync9
|
|
1329
1773
|
} from "fs";
|
|
1330
|
-
import { join as
|
|
1774
|
+
import { join as join10, resolve as resolve13 } from "path";
|
|
1331
1775
|
import chalk12 from "chalk";
|
|
1332
1776
|
import ora3 from "ora";
|
|
1333
1777
|
var builtInTemplates = {
|
|
@@ -1433,9 +1877,9 @@ Template para features mobile nativas. Adaptado para o framework espec\xEDfico (
|
|
|
1433
1877
|
};
|
|
1434
1878
|
function listTemplates(root) {
|
|
1435
1879
|
const names = Object.keys(builtInTemplates);
|
|
1436
|
-
const customDir =
|
|
1437
|
-
if (
|
|
1438
|
-
for (const file of
|
|
1880
|
+
const customDir = join10(root, ".letra", "templates");
|
|
1881
|
+
if (existsSync10(customDir)) {
|
|
1882
|
+
for (const file of readdirSync6(customDir)) {
|
|
1439
1883
|
if (file.endsWith(".md")) {
|
|
1440
1884
|
const name = file.replace(/\.md$/, "");
|
|
1441
1885
|
if (!names.includes(name)) names.push(name);
|
|
@@ -1447,16 +1891,16 @@ function listTemplates(root) {
|
|
|
1447
1891
|
function findTemplate(root, type) {
|
|
1448
1892
|
const lower = type.toLowerCase();
|
|
1449
1893
|
if (builtInTemplates[lower]) return builtInTemplates[lower];
|
|
1450
|
-
const customFile =
|
|
1451
|
-
const customAcceptance =
|
|
1894
|
+
const customFile = join10(root, ".letra", "templates", `${type}.md`);
|
|
1895
|
+
const customAcceptance = join10(
|
|
1452
1896
|
root,
|
|
1453
1897
|
".letra",
|
|
1454
1898
|
"templates",
|
|
1455
1899
|
`${type}-acceptance.md`
|
|
1456
1900
|
);
|
|
1457
|
-
if (
|
|
1458
|
-
const spec =
|
|
1459
|
-
const acceptance =
|
|
1901
|
+
if (existsSync10(customFile)) {
|
|
1902
|
+
const spec = readFileSync8(customFile, "utf-8");
|
|
1903
|
+
const acceptance = existsSync10(customAcceptance) ? readFileSync8(customAcceptance, "utf-8") : `# Acceptance Criteria \u2014 ${type}
|
|
1460
1904
|
|
|
1461
1905
|
- [ ] **Crit\xE9rio 1**: Descri\xE7\xE3o bin\xE1ria (passa/falha).
|
|
1462
1906
|
`;
|
|
@@ -1468,14 +1912,14 @@ function applyPlaceholders(content, name) {
|
|
|
1468
1912
|
return content.replace(/\{\{name\}\}/g, name);
|
|
1469
1913
|
}
|
|
1470
1914
|
async function specNew(name, options) {
|
|
1471
|
-
const root =
|
|
1472
|
-
const letraDir =
|
|
1473
|
-
const specDir =
|
|
1474
|
-
if (!
|
|
1915
|
+
const root = resolve13(process.cwd());
|
|
1916
|
+
const letraDir = join10(root, ".letra");
|
|
1917
|
+
const specDir = join10(letraDir, "specs", name);
|
|
1918
|
+
if (!existsSync10(letraDir)) {
|
|
1475
1919
|
console.log(chalk12.red(".letra/ not found. Run 'letra init' first."));
|
|
1476
1920
|
process.exit(1);
|
|
1477
1921
|
}
|
|
1478
|
-
if (
|
|
1922
|
+
if (existsSync10(specDir)) {
|
|
1479
1923
|
console.log(chalk12.yellow(`Spec "${name}" already exists`));
|
|
1480
1924
|
return;
|
|
1481
1925
|
}
|
|
@@ -1496,8 +1940,8 @@ async function specNew(name, options) {
|
|
|
1496
1940
|
if (template) {
|
|
1497
1941
|
const specContent = applyPlaceholders(template.spec, name);
|
|
1498
1942
|
const acceptanceContent = applyPlaceholders(template.acceptance, name);
|
|
1499
|
-
writeFileSync9(
|
|
1500
|
-
writeFileSync9(
|
|
1943
|
+
writeFileSync9(join10(specDir, "spec.md"), specContent);
|
|
1944
|
+
writeFileSync9(join10(specDir, "acceptance.md"), acceptanceContent);
|
|
1501
1945
|
} else {
|
|
1502
1946
|
const specContent = `# Spec: ${name}
|
|
1503
1947
|
|
|
@@ -1520,8 +1964,8 @@ Por que estamos construindo isso. Trade-offs considerados.
|
|
|
1520
1964
|
|
|
1521
1965
|
- [ ] **Crit\xE9rio 1**: Descri\xE7\xE3o bin\xE1ria (passa/falha).
|
|
1522
1966
|
`;
|
|
1523
|
-
writeFileSync9(
|
|
1524
|
-
writeFileSync9(
|
|
1967
|
+
writeFileSync9(join10(specDir, "spec.md"), specContent);
|
|
1968
|
+
writeFileSync9(join10(specDir, "acceptance.md"), acceptanceContent);
|
|
1525
1969
|
}
|
|
1526
1970
|
spinner.succeed(
|
|
1527
1971
|
chalk12.green(`Spec "${name}" created at .letra/specs/${name}/`)
|
|
@@ -1535,21 +1979,21 @@ Por que estamos construindo isso. Trade-offs considerados.
|
|
|
1535
1979
|
// src/commands/validate.ts
|
|
1536
1980
|
import { execSync } from "child_process";
|
|
1537
1981
|
import {
|
|
1538
|
-
existsSync as
|
|
1982
|
+
existsSync as existsSync12,
|
|
1539
1983
|
mkdtempSync,
|
|
1540
|
-
readFileSync as
|
|
1541
|
-
readdirSync as
|
|
1984
|
+
readFileSync as readFileSync10,
|
|
1985
|
+
readdirSync as readdirSync7,
|
|
1542
1986
|
rmSync,
|
|
1543
|
-
statSync as
|
|
1544
|
-
watch
|
|
1987
|
+
statSync as statSync3,
|
|
1988
|
+
watch as watch2
|
|
1545
1989
|
} from "fs";
|
|
1546
1990
|
import { tmpdir } from "os";
|
|
1547
|
-
import { join as
|
|
1991
|
+
import { join as join12, resolve as resolve14 } from "path";
|
|
1548
1992
|
import chalk13 from "chalk";
|
|
1549
1993
|
|
|
1550
1994
|
// src/config.ts
|
|
1551
|
-
import { existsSync as
|
|
1552
|
-
import { join as
|
|
1995
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
|
|
1996
|
+
import { join as join11 } from "path";
|
|
1553
1997
|
var DEFAULT_HEURISTICS = {
|
|
1554
1998
|
"conteudo-minimo": { severity: "warning", minChars: 50 },
|
|
1555
1999
|
"consistencia-terminologia": { severity: "warning" },
|
|
@@ -1564,14 +2008,14 @@ var DEFAULT_HEURISTICS = {
|
|
|
1564
2008
|
"validate-conflict": { severity: "warning" }
|
|
1565
2009
|
};
|
|
1566
2010
|
function loadConfig(root) {
|
|
1567
|
-
const configPath =
|
|
2011
|
+
const configPath = join11(root, ".letra", "config.json");
|
|
1568
2012
|
const heuristics = {};
|
|
1569
2013
|
for (const [key, value] of Object.entries(DEFAULT_HEURISTICS)) {
|
|
1570
2014
|
heuristics[key] = { ...value };
|
|
1571
2015
|
}
|
|
1572
|
-
if (
|
|
2016
|
+
if (existsSync11(configPath)) {
|
|
1573
2017
|
try {
|
|
1574
|
-
const raw = JSON.parse(
|
|
2018
|
+
const raw = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
1575
2019
|
if (raw.heuristics && typeof raw.heuristics === "object") {
|
|
1576
2020
|
for (const [key, value] of Object.entries(raw.heuristics)) {
|
|
1577
2021
|
if (heuristics[key]) {
|
|
@@ -1638,12 +2082,12 @@ var lowConfidenceMarkers = [
|
|
|
1638
2082
|
"teoricamente"
|
|
1639
2083
|
];
|
|
1640
2084
|
function checkSpecContent(specDir, label, description, config) {
|
|
1641
|
-
const cfg = config ?? loadConfig(
|
|
1642
|
-
const specFile =
|
|
1643
|
-
const glossaryFile =
|
|
1644
|
-
if (!
|
|
2085
|
+
const cfg = config ?? loadConfig(join12(specDir, "..", "..", ".."));
|
|
2086
|
+
const specFile = join12(specDir, "spec.md");
|
|
2087
|
+
const glossaryFile = join12(specDir, "..", "..", "glossary.md");
|
|
2088
|
+
if (!existsSync12(specFile))
|
|
1645
2089
|
return { status: "FAIL", note: "(spec.md not found)" };
|
|
1646
|
-
const specContent =
|
|
2090
|
+
const specContent = readFileSync10(specFile, "utf-8");
|
|
1647
2091
|
const now6 = /* @__PURE__ */ new Date();
|
|
1648
2092
|
if (label.includes("Conte\xFAdo M\xEDnimo")) {
|
|
1649
2093
|
const outcomeMatch = specContent.match(/## Outcome\s+([\s\S]*?)(?=\n## )/);
|
|
@@ -1664,13 +2108,13 @@ function checkSpecContent(specDir, label, description, config) {
|
|
|
1664
2108
|
};
|
|
1665
2109
|
}
|
|
1666
2110
|
if (label.includes("Consist\xEAncia de Terminologia") || label.includes("Terminologia")) {
|
|
1667
|
-
if (!
|
|
2111
|
+
if (!existsSync12(glossaryFile)) {
|
|
1668
2112
|
return {
|
|
1669
2113
|
status: "PASS",
|
|
1670
2114
|
note: "(no glossary to check against)"
|
|
1671
2115
|
};
|
|
1672
2116
|
}
|
|
1673
|
-
const glossaryContent =
|
|
2117
|
+
const glossaryContent = readFileSync10(glossaryFile, "utf-8");
|
|
1674
2118
|
const terms = glossaryContent.match(/\*\*(.+?)\*\*/g) || [];
|
|
1675
2119
|
const extractedTerms = terms.map((t) => t.replace(/\*\*/g, "").trim()).filter((t) => t.length > 3);
|
|
1676
2120
|
const missingTerms = extractedTerms.filter(
|
|
@@ -1708,7 +2152,7 @@ function checkSpecContent(specDir, label, description, config) {
|
|
|
1708
2152
|
};
|
|
1709
2153
|
}
|
|
1710
2154
|
if (label.includes("Drift Temporal") || label.includes("Temporal")) {
|
|
1711
|
-
const stat =
|
|
2155
|
+
const stat = statSync3(specFile);
|
|
1712
2156
|
const daysOld = Math.floor(
|
|
1713
2157
|
(now6.getTime() - stat.mtimeMs) / (1e3 * 60 * 60 * 24)
|
|
1714
2158
|
);
|
|
@@ -1897,13 +2341,13 @@ function detectConflict(textA, textB) {
|
|
|
1897
2341
|
}
|
|
1898
2342
|
function checkConflicts(specsDir, config) {
|
|
1899
2343
|
const results = [];
|
|
1900
|
-
const entries =
|
|
2344
|
+
const entries = readdirSync7(specsDir, { withFileTypes: true });
|
|
1901
2345
|
const specDirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith("_")).map((e) => e.name);
|
|
1902
2346
|
const specs = [];
|
|
1903
2347
|
for (const dir of specDirs) {
|
|
1904
|
-
const acceptanceFile =
|
|
1905
|
-
if (!
|
|
1906
|
-
const content =
|
|
2348
|
+
const acceptanceFile = join12(specsDir, dir, "acceptance.md");
|
|
2349
|
+
if (!existsSync12(acceptanceFile)) continue;
|
|
2350
|
+
const content = readFileSync10(acceptanceFile, "utf-8");
|
|
1907
2351
|
const acLines = content.match(/- \[[ x]\] \*\*(.+?)\*\*: (.+)/g) || [];
|
|
1908
2352
|
const acs = acLines.map((line) => {
|
|
1909
2353
|
const m = line.match(/- \[[ x]\] \*\*(.+?)\*\*: (.+)/);
|
|
@@ -2007,10 +2451,10 @@ Results: ${totalPass} passed, ${totalFail} failed${totalWarning > 0 ? `, ${total
|
|
|
2007
2451
|
);
|
|
2008
2452
|
}
|
|
2009
2453
|
async function validate(targetPath, options) {
|
|
2010
|
-
const root =
|
|
2011
|
-
const specsDir =
|
|
2454
|
+
const root = resolve14(process.cwd(), targetPath || ".");
|
|
2455
|
+
const specsDir = join12(root, ".letra", "specs");
|
|
2012
2456
|
const fmt = options?.format || "text";
|
|
2013
|
-
if (!
|
|
2457
|
+
if (!existsSync12(specsDir)) {
|
|
2014
2458
|
const msg = "Error: .letra/specs/ not found. Run 'letra init' first.";
|
|
2015
2459
|
if (fmt === "github-annotation") {
|
|
2016
2460
|
console.log(`::error file=,title=Init Required::${msg}`);
|
|
@@ -2021,34 +2465,34 @@ async function validate(targetPath, options) {
|
|
|
2021
2465
|
}
|
|
2022
2466
|
async function runValidation() {
|
|
2023
2467
|
const config = loadConfig(root);
|
|
2024
|
-
const entries =
|
|
2468
|
+
const entries = readdirSync7(specsDir, { withFileTypes: true });
|
|
2025
2469
|
let totalPass = 0;
|
|
2026
2470
|
let totalFail = 0;
|
|
2027
2471
|
let totalWarning = 0;
|
|
2028
2472
|
const specGroups = /* @__PURE__ */ new Map();
|
|
2029
2473
|
const allResults = [];
|
|
2030
|
-
const entryPoint =
|
|
2474
|
+
const entryPoint = join12(root, "src/index.ts");
|
|
2031
2475
|
const opts = {
|
|
2032
2476
|
stdio: "pipe",
|
|
2033
2477
|
encoding: "utf-8",
|
|
2034
2478
|
shell: process.platform === "win32" ? "cmd.exe" : true
|
|
2035
2479
|
};
|
|
2036
|
-
const ciFile =
|
|
2037
|
-
const cursorRulesFile =
|
|
2038
|
-
const copilotFile =
|
|
2039
|
-
const vscodeSettingsFile =
|
|
2480
|
+
const ciFile = join12(root, ".github", "workflows", "ci.yml");
|
|
2481
|
+
const cursorRulesFile = join12(root, ".cursorrules");
|
|
2482
|
+
const copilotFile = join12(root, ".github", "copilot-instructions.md");
|
|
2483
|
+
const vscodeSettingsFile = join12(root, ".vscode", "settings.json");
|
|
2040
2484
|
if (fmt !== "junit") {
|
|
2041
2485
|
out(fmt, "info", null, "", "\nLetra Validation\n", "");
|
|
2042
2486
|
}
|
|
2043
2487
|
for (const entry of entries) {
|
|
2044
2488
|
if (!entry.isDirectory() || entry.name.startsWith("_")) continue;
|
|
2045
|
-
const acceptanceFile =
|
|
2046
|
-
const specFile =
|
|
2489
|
+
const acceptanceFile = join12(specsDir, entry.name, "acceptance.md");
|
|
2490
|
+
const specFile = join12(specsDir, entry.name, "spec.md");
|
|
2047
2491
|
let content;
|
|
2048
|
-
if (
|
|
2049
|
-
content =
|
|
2050
|
-
} else if (
|
|
2051
|
-
content =
|
|
2492
|
+
if (existsSync12(acceptanceFile)) {
|
|
2493
|
+
content = readFileSync10(acceptanceFile, "utf-8");
|
|
2494
|
+
} else if (existsSync12(specFile)) {
|
|
2495
|
+
content = readFileSync10(specFile, "utf-8");
|
|
2052
2496
|
} else {
|
|
2053
2497
|
out(
|
|
2054
2498
|
fmt,
|
|
@@ -2061,7 +2505,7 @@ async function validate(targetPath, options) {
|
|
|
2061
2505
|
continue;
|
|
2062
2506
|
}
|
|
2063
2507
|
const criteriaLines = content.match(/- \[ \] \*\*(.+?)\*\*: (.+)/g) || [];
|
|
2064
|
-
const specContent =
|
|
2508
|
+
const specContent = existsSync12(specFile) ? readFileSync10(specFile, "utf-8") : null;
|
|
2065
2509
|
out(fmt, "info", entry.name, "", `Spec: ${entry.name}`, "");
|
|
2066
2510
|
if (criteriaLines.length === 0) {
|
|
2067
2511
|
out(fmt, "info", entry.name, "", "No criteria found", "");
|
|
@@ -2078,7 +2522,7 @@ async function validate(targetPath, options) {
|
|
|
2078
2522
|
let intelligenceResult = null;
|
|
2079
2523
|
try {
|
|
2080
2524
|
intelligenceResult = checkSpecContent(
|
|
2081
|
-
|
|
2525
|
+
join12(specsDir, entry.name),
|
|
2082
2526
|
label,
|
|
2083
2527
|
description,
|
|
2084
2528
|
config
|
|
@@ -2087,20 +2531,20 @@ async function validate(targetPath, options) {
|
|
|
2087
2531
|
status = intelligenceResult.status;
|
|
2088
2532
|
note = intelligenceResult.note;
|
|
2089
2533
|
} else if (label.includes("letra init")) {
|
|
2090
|
-
const tmp = mkdtempSync(
|
|
2534
|
+
const tmp = mkdtempSync(join12(tmpdir(), "letra-test-"));
|
|
2091
2535
|
execSync(`npx tsx "${entryPoint}" init "${tmp}"`, { ...opts });
|
|
2092
|
-
if (
|
|
2536
|
+
if (existsSync12(join12(tmp, ".letra", "context.md")))
|
|
2093
2537
|
status = "PASS";
|
|
2094
2538
|
rmSync(tmp, { recursive: true });
|
|
2095
2539
|
} else if (label.includes("letra spec")) {
|
|
2096
|
-
const tmp = mkdtempSync(
|
|
2540
|
+
const tmp = mkdtempSync(join12(tmpdir(), "letra-test-"));
|
|
2097
2541
|
execSync(`npx tsx "${entryPoint}" init "${tmp}"`, { ...opts });
|
|
2098
2542
|
execSync(`npx tsx "${entryPoint}" spec smoke-test`, {
|
|
2099
2543
|
...opts,
|
|
2100
2544
|
cwd: tmp
|
|
2101
2545
|
});
|
|
2102
|
-
if (
|
|
2103
|
-
|
|
2546
|
+
if (existsSync12(
|
|
2547
|
+
join12(tmp, ".letra", "specs", "smoke-test", "spec.md")
|
|
2104
2548
|
))
|
|
2105
2549
|
status = "PASS";
|
|
2106
2550
|
rmSync(tmp, { recursive: true });
|
|
@@ -2109,23 +2553,23 @@ async function validate(targetPath, options) {
|
|
|
2109
2553
|
status = "PASS";
|
|
2110
2554
|
} else if (label.includes("letra validate")) {
|
|
2111
2555
|
status = "PASS";
|
|
2112
|
-
} else if (label.includes("Workflow Ativo") || label.includes("CI") &&
|
|
2556
|
+
} else if (label.includes("Workflow Ativo") || label.includes("CI") && existsSync12(ciFile)) {
|
|
2113
2557
|
status = "PASS";
|
|
2114
2558
|
} else if (label.includes("Lint Gate") || label.includes("Lint")) {
|
|
2115
|
-
const ciContent =
|
|
2559
|
+
const ciContent = readFileSync10(ciFile, "utf-8");
|
|
2116
2560
|
if (ciContent.includes("letra lint") || ciContent.includes("lint"))
|
|
2117
2561
|
status = "PASS";
|
|
2118
2562
|
} else if (label.includes("Test Gate") || label.includes("Test")) {
|
|
2119
|
-
const ciContent =
|
|
2563
|
+
const ciContent = readFileSync10(ciFile, "utf-8");
|
|
2120
2564
|
if (ciContent.includes("npm test") || ciContent.includes("vitest") || ciContent.includes("test"))
|
|
2121
2565
|
status = "PASS";
|
|
2122
2566
|
} else if (label.includes("Valida\xE7\xE3o de Formato") || label.includes("Formato")) {
|
|
2123
|
-
const ciContent =
|
|
2567
|
+
const ciContent = readFileSync10(ciFile, "utf-8");
|
|
2124
2568
|
if (ciContent.includes("tsc") || ciContent.includes("typecheck"))
|
|
2125
2569
|
status = "PASS";
|
|
2126
2570
|
} else if (label.includes("Distribui\xE7\xE3o npm") || label.includes("npm")) {
|
|
2127
2571
|
const pkgJson = JSON.parse(
|
|
2128
|
-
|
|
2572
|
+
readFileSync10(join12(root, "package.json"), "utf-8")
|
|
2129
2573
|
);
|
|
2130
2574
|
if (pkgJson.bin && pkgJson.name) {
|
|
2131
2575
|
status = "PASS";
|
|
@@ -2137,39 +2581,39 @@ async function validate(targetPath, options) {
|
|
|
2137
2581
|
status = "PASS";
|
|
2138
2582
|
note = "(npm distribution preferred)";
|
|
2139
2583
|
} else if (label.includes("Gera\xE7\xE3o de Regras") || label.includes("Gera\xE7\xE3o")) {
|
|
2140
|
-
if (
|
|
2141
|
-
const rulesContent =
|
|
2584
|
+
if (existsSync12(cursorRulesFile)) {
|
|
2585
|
+
const rulesContent = readFileSync10(cursorRulesFile, "utf-8");
|
|
2142
2586
|
if (rulesContent.includes(".letra/context.md") && rulesContent.includes(".letra/constitution.md")) {
|
|
2143
2587
|
status = "PASS";
|
|
2144
2588
|
}
|
|
2145
2589
|
}
|
|
2146
2590
|
} else if (label.includes("Inje\xE7\xE3o de Contexto")) {
|
|
2147
|
-
if (
|
|
2148
|
-
const rulesContent =
|
|
2591
|
+
if (existsSync12(cursorRulesFile)) {
|
|
2592
|
+
const rulesContent = readFileSync10(cursorRulesFile, "utf-8");
|
|
2149
2593
|
if (rulesContent.includes("@.letra/")) status = "PASS";
|
|
2150
|
-
} else if (
|
|
2151
|
-
const copilotContent =
|
|
2594
|
+
} else if (existsSync12(copilotFile)) {
|
|
2595
|
+
const copilotContent = readFileSync10(copilotFile, "utf-8");
|
|
2152
2596
|
if (copilotContent.includes(".letra/")) status = "PASS";
|
|
2153
2597
|
}
|
|
2154
2598
|
} else if (label.includes("Acesso a Valida\xE7\xE3o")) {
|
|
2155
|
-
if (
|
|
2156
|
-
const rulesContent =
|
|
2599
|
+
if (existsSync12(cursorRulesFile)) {
|
|
2600
|
+
const rulesContent = readFileSync10(cursorRulesFile, "utf-8");
|
|
2157
2601
|
if (rulesContent.includes("letra validate")) status = "PASS";
|
|
2158
2602
|
}
|
|
2159
2603
|
} else if (label.includes("N\xE3o-intrusivo")) {
|
|
2160
|
-
if (
|
|
2604
|
+
if (existsSync12(cursorRulesFile) || existsSync12(copilotFile)) {
|
|
2161
2605
|
status = "PASS";
|
|
2162
2606
|
}
|
|
2163
2607
|
} else if (label.includes("Gera\xE7\xE3o de Instru\xE7\xF5es")) {
|
|
2164
|
-
if (
|
|
2165
|
-
const copilotContent =
|
|
2608
|
+
if (existsSync12(copilotFile)) {
|
|
2609
|
+
const copilotContent = readFileSync10(copilotFile, "utf-8");
|
|
2166
2610
|
if (copilotContent.includes(".letra/context.md") && copilotContent.includes(".letra/constitution.md")) {
|
|
2167
2611
|
status = "PASS";
|
|
2168
2612
|
}
|
|
2169
2613
|
}
|
|
2170
2614
|
} else if (label.includes("Settings do Editor")) {
|
|
2171
|
-
if (
|
|
2172
|
-
const settingsContent =
|
|
2615
|
+
if (existsSync12(vscodeSettingsFile)) {
|
|
2616
|
+
const settingsContent = readFileSync10(
|
|
2173
2617
|
vscodeSettingsFile,
|
|
2174
2618
|
"utf-8"
|
|
2175
2619
|
);
|
|
@@ -2178,9 +2622,9 @@ async function validate(targetPath, options) {
|
|
|
2178
2622
|
}
|
|
2179
2623
|
}
|
|
2180
2624
|
} else if (label.includes("Arquivo de Config")) {
|
|
2181
|
-
const configFile =
|
|
2182
|
-
if (
|
|
2183
|
-
const cfgContent =
|
|
2625
|
+
const configFile = join12(root, ".letra", "config.json");
|
|
2626
|
+
if (existsSync12(configFile)) {
|
|
2627
|
+
const cfgContent = readFileSync10(configFile, "utf-8");
|
|
2184
2628
|
try {
|
|
2185
2629
|
const parsed = JSON.parse(cfgContent);
|
|
2186
2630
|
if (parsed.heuristics) {
|
|
@@ -2402,7 +2846,7 @@ async function validate(targetPath, options) {
|
|
|
2402
2846
|
if (options?.watch) {
|
|
2403
2847
|
let timer = null;
|
|
2404
2848
|
console.log(chalk13.gray("\nWatching for changes... (Ctrl+C to stop)"));
|
|
2405
|
-
const watcher =
|
|
2849
|
+
const watcher = watch2(specsDir, { recursive: true });
|
|
2406
2850
|
watcher.on("change", () => {
|
|
2407
2851
|
if (timer) clearTimeout(timer);
|
|
2408
2852
|
timer = setTimeout(async () => {
|
|
@@ -2429,12 +2873,13 @@ async function validate(targetPath, options) {
|
|
|
2429
2873
|
// src/index.ts
|
|
2430
2874
|
var __dirname2 = fileURLToPath2(new URL(".", import.meta.url));
|
|
2431
2875
|
var pkg = JSON.parse(
|
|
2432
|
-
|
|
2876
|
+
readFileSync11(join13(resolve15(__dirname2, ".."), "package.json"), "utf-8")
|
|
2433
2877
|
);
|
|
2434
2878
|
var program = new Command4();
|
|
2435
2879
|
program.name("letra").description("SDD-agnostic memory framework for AI coding agents").version(pkg.version);
|
|
2436
2880
|
program.command("init [path]").option("--yes", "Skip prompts and use defaults").description("Initialize .letra/ directory with templates").action((path, options) => init(path, { ...options }));
|
|
2437
|
-
program.command("spec
|
|
2881
|
+
var specCmd = program.command("spec").description("Manage specs");
|
|
2882
|
+
specCmd.command("new <name>").option(
|
|
2438
2883
|
"--template <type>",
|
|
2439
2884
|
"Template type: web-api, cli-tool, mobile-feature"
|
|
2440
2885
|
).description("Create a new spec from template").action((name, options) => specNew(name, { ...options }));
|