@letra-ai/cli 0.5.3 → 0.6.2
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/chunk-6HSUVCTR.js +363 -0
- package/dist/chunk-BKAUN5QH.js +300 -0
- package/dist/chunk-DMOLJWWW.js +3321 -0
- package/dist/chunk-EDD55PWL.js +119 -0
- package/dist/chunk-H64RC3YS.js +254 -0
- package/dist/chunk-JMIC5NKB.js +235 -0
- package/dist/chunk-L6YKDTAQ.js +275 -0
- package/dist/chunk-MJ2QXNH6.js +130 -0
- package/dist/chunk-OIHMDOIN.js +1326 -0
- package/dist/chunk-PDX44BCA.js +11 -0
- package/dist/chunk-URUC6ZZP.js +4781 -0
- package/dist/client/assets/index-EyRsq1SH.css +1 -0
- package/dist/client/assets/index-WfKR7Xp6.js +232 -0
- package/dist/client/favicon.svg +16 -4
- package/dist/client/index.html +25 -20
- package/dist/fallback-MQLGS4KL.js +46 -0
- package/dist/flow-serve-G5MSSB3G.js +18 -0
- package/dist/focus-sync-3D3XWCTI.js +17 -0
- package/dist/generate-UPFERQMD.js +20 -0
- package/dist/harness/default/v0.1.0/flows/sdlc.yaml +179 -0
- package/dist/harness/default/v0.1.0/gates/all-acs-passing.yaml +8 -0
- package/dist/harness/default/v0.1.0/gates/has-spec-file.yaml +7 -0
- package/dist/harness/default/v0.1.0/gates/human-approved-code.yaml +8 -0
- package/dist/harness/default/v0.1.0/gates/human-approved-spec.yaml +8 -0
- package/dist/harness/default/v0.1.0/gates/security-clear.yaml +8 -0
- package/dist/harness/default/v0.1.0/policies/sdlc-default.json +20 -0
- package/dist/harness/default/v0.1.0/roles/analyst.yaml +9 -0
- package/dist/harness/default/v0.1.0/roles/builder.yaml +9 -0
- package/dist/harness/default/v0.1.0/roles/pr-bot.yaml +8 -0
- package/dist/harness/default/v0.1.0/roles/reviewer.yaml +10 -0
- package/dist/harness/default/v0.1.0/roles/security.yaml +8 -0
- package/dist/harness/default/v0.1.1/flows/flow-main.yaml +61 -0
- package/dist/harness/default/v0.1.1/flows/sdlc.yaml +179 -0
- package/dist/harness/default/v0.1.1/gates/all-acs-passing.yaml +8 -0
- package/dist/harness/default/v0.1.1/gates/has-spec-file.yaml +7 -0
- package/dist/harness/default/v0.1.1/gates/human-approved-code.yaml +8 -0
- package/dist/harness/default/v0.1.1/gates/human-approved-spec.yaml +8 -0
- package/dist/harness/default/v0.1.1/gates/security-clear.yaml +8 -0
- package/dist/harness/default/v0.1.1/policies/sdlc-default.json +20 -0
- package/dist/harness/default/v0.1.1/roles/analyst.yaml +9 -0
- package/dist/harness/default/v0.1.1/roles/builder.yaml +9 -0
- package/dist/harness/default/v0.1.1/roles/pr-bot.yaml +8 -0
- package/dist/harness/default/v0.1.1/roles/reviewer.yaml +10 -0
- package/dist/harness/default/v0.1.1/roles/security.yaml +8 -0
- package/dist/harness/default/v0.1.2/flows/flow-main.yaml +86 -0
- package/dist/harness/default/v0.1.2/flows/sdlc.yaml +179 -0
- package/dist/harness/default/v0.1.2/gates/all-acs-passing.yaml +8 -0
- package/dist/harness/default/v0.1.2/gates/has-spec-file.yaml +7 -0
- package/dist/harness/default/v0.1.2/gates/human-approved-code.yaml +8 -0
- package/dist/harness/default/v0.1.2/gates/human-approved-spec.yaml +8 -0
- package/dist/harness/default/v0.1.2/gates/security-clear.yaml +8 -0
- package/dist/harness/default/v0.1.2/policies/sdlc-default.json +20 -0
- package/dist/harness/default/v0.1.2/roles/analyst.yaml +9 -0
- package/dist/harness/default/v0.1.2/roles/builder.yaml +9 -0
- package/dist/harness/default/v0.1.2/roles/pr-bot.yaml +8 -0
- package/dist/harness/default/v0.1.2/roles/reviewer.yaml +10 -0
- package/dist/harness/default/v0.1.2/roles/security.yaml +8 -0
- package/dist/harness/default/v0.1.3/flows/flow-main.yaml +90 -0
- package/dist/harness/default/v0.1.3/flows/sdlc.yaml +179 -0
- package/dist/harness/default/v0.1.3/gates/all-acs-passing.yaml +8 -0
- package/dist/harness/default/v0.1.3/gates/has-spec-file.yaml +7 -0
- package/dist/harness/default/v0.1.3/gates/human-approved-code.yaml +9 -0
- package/dist/harness/default/v0.1.3/gates/human-approved-spec.yaml +9 -0
- package/dist/harness/default/v0.1.3/gates/security-clear.yaml +8 -0
- package/dist/harness/default/v0.1.3/policies/sdlc-default.json +20 -0
- package/dist/harness/default/v0.1.3/roles/analyst.yaml +9 -0
- package/dist/harness/default/v0.1.3/roles/builder.yaml +9 -0
- package/dist/harness/default/v0.1.3/roles/pr-bot.yaml +8 -0
- package/dist/harness/default/v0.1.3/roles/reviewer.yaml +10 -0
- package/dist/harness/default/v0.1.3/roles/security.yaml +8 -0
- package/dist/harness/default/v0.2.0/executors/registry.yaml +51 -0
- package/dist/harness/default/v0.2.0/flows/flow-main.yaml +249 -0
- package/dist/harness/default/v0.2.0/gates/code-reviewed.yaml +7 -0
- package/dist/harness/default/v0.2.0/gates/human-approved.yaml +10 -0
- package/dist/harness/default/v0.2.0/gates/security-clear.yaml +7 -0
- package/dist/harness/default/v0.2.0/gates/spec-approved.yaml +10 -0
- package/dist/harness/default/v0.2.0/policies/sdlc-default.json +20 -0
- package/dist/harness/default/v0.2.0/roles/analyst.yaml +16 -0
- package/dist/harness/default/v0.2.0/roles/implementer.yaml +17 -0
- package/dist/harness/default/v0.2.0/roles/reviewer.yaml +17 -0
- package/dist/harness/default/v0.2.0/roles/security.yaml +17 -0
- package/dist/health-record-YDVXEVLR.js +21 -0
- package/dist/index.js +1951 -2530
- package/dist/init-wizard-NODBBNKO.js +178 -0
- package/dist/push-VJRSQGUD.js +116 -0
- package/dist/registry-6VPIA3EG.js +18 -0
- package/dist/server-P6GKRWDX.js +423 -0
- package/dist/service-2JN2KI4D.js +29 -0
- package/dist/session-log-WTQ5JBEN.js +21 -0
- package/dist/sitrep-OKNZJICV.js +16 -0
- package/package.json +37 -28
- package/dist/chunk-56GTTLC4.js +0 -1322
- package/dist/chunk-QWT5M4XU.js +0 -643
- package/dist/client/assets/index-CuLfFw4K.js +0 -85
- package/dist/client/assets/index-iyLqZcWx.css +0 -1
- package/dist/generate-BF5R5GGA.js +0 -7
- package/dist/sitrep-SI6ZFIAM.js +0 -10
- package/tsup.config.ts +0 -11
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getLetraDir2 as getLetraDir
|
|
4
|
+
} from "./chunk-6HSUVCTR.js";
|
|
5
|
+
|
|
6
|
+
// src/adapters/focus-sync.ts
|
|
7
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
import { pathToFileURL } from "url";
|
|
10
|
+
function syncFocus(rootDir, workflow, recommendedActions = []) {
|
|
11
|
+
const focusFile = join(getLetraDir(rootDir), "focus.md");
|
|
12
|
+
const focusData = readFocusFile(rootDir);
|
|
13
|
+
let cleared = false;
|
|
14
|
+
let generated = false;
|
|
15
|
+
let diverged = false;
|
|
16
|
+
if (focusData && workflow) {
|
|
17
|
+
const itemExists = workflow.items.some((i) => i.id === focusData.itemId);
|
|
18
|
+
if (!itemExists) {
|
|
19
|
+
clearFocusFile(rootDir);
|
|
20
|
+
cleared = true;
|
|
21
|
+
} else {
|
|
22
|
+
const item = workflow.items.find((i) => i.id === focusData.itemId);
|
|
23
|
+
if (item?.spec && item.spec !== focusData.specName) {
|
|
24
|
+
diverged = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!focusData && workflow) {
|
|
29
|
+
const activeItem = findActiveItem(workflow);
|
|
30
|
+
if (activeItem?.spec) {
|
|
31
|
+
writeFocusFile(rootDir, activeItem.spec, activeItem.id, recommendedActions);
|
|
32
|
+
generated = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (focusData && !workflow) {
|
|
36
|
+
clearFocusFile(rootDir);
|
|
37
|
+
cleared = true;
|
|
38
|
+
}
|
|
39
|
+
return { cleared, generated, diverged };
|
|
40
|
+
}
|
|
41
|
+
function findActiveItem(workflow) {
|
|
42
|
+
const activeStages = workflow.stages.filter(
|
|
43
|
+
(s) => s.zone === "doing" || !s.zone && s.order > 0 && s.order < workflow.stages.length - 1
|
|
44
|
+
).map((s) => s.id);
|
|
45
|
+
const stageSet = new Set(activeStages);
|
|
46
|
+
if (stageSet.size === 0) {
|
|
47
|
+
const mid = Math.floor(workflow.stages.length / 2);
|
|
48
|
+
const stage = workflow.stages[mid];
|
|
49
|
+
if (stage) stageSet.add(stage.id);
|
|
50
|
+
}
|
|
51
|
+
const items = workflow.items.filter((i) => stageSet.has(i.stage));
|
|
52
|
+
if (items.length === 0) return null;
|
|
53
|
+
return items.reduce((a, b) => new Date(a.createdAt) > new Date(b.createdAt) ? a : b);
|
|
54
|
+
}
|
|
55
|
+
function extractOutcome(rootDir, specName) {
|
|
56
|
+
const specFile = join(getLetraDir(rootDir), "specs", specName, "spec.md");
|
|
57
|
+
if (!existsSync(specFile)) return null;
|
|
58
|
+
const content = readFileSync(specFile, "utf-8");
|
|
59
|
+
const match = content.match(/## Outcome\s+([\s\S]*?)(?=\n## |\n*$)/);
|
|
60
|
+
return match ? match[1].trim() : null;
|
|
61
|
+
}
|
|
62
|
+
function writeFocusFile(rootDir, specName, itemId, recommendedActions = []) {
|
|
63
|
+
const focusFile = join(getLetraDir(rootDir), "focus.md");
|
|
64
|
+
const outcome = extractOutcome(rootDir, specName) || specName;
|
|
65
|
+
const letraDir = getLetraDir(rootDir);
|
|
66
|
+
const content = [
|
|
67
|
+
`# Focus: ${specName}`,
|
|
68
|
+
"",
|
|
69
|
+
`**Path**: .letra/specs/${specName}/`,
|
|
70
|
+
`**Item**: ${itemId}`,
|
|
71
|
+
`**Outcome**: ${outcome}`,
|
|
72
|
+
"",
|
|
73
|
+
...recommendedActions.length > 0 ? [
|
|
74
|
+
"## A\xE7\xF5es Recomendadas",
|
|
75
|
+
"",
|
|
76
|
+
...recommendedActions.map((action) => {
|
|
77
|
+
const detail = action.description ? `${action.label}: ${action.description}` : action.label;
|
|
78
|
+
return `- \`${action.command}\` \u2014 ${detail}`;
|
|
79
|
+
}),
|
|
80
|
+
""
|
|
81
|
+
] : [],
|
|
82
|
+
"## Links",
|
|
83
|
+
"",
|
|
84
|
+
`- [Spec: ${specName}](${pathToFileURL(join(letraDir, "specs", specName, "spec.md")).href})`,
|
|
85
|
+
`- [${itemId}](${pathToFileURL(join(letraDir, "workflow.json")).href})`,
|
|
86
|
+
`- [Constitution](${pathToFileURL(join(letraDir, "constitution.md")).href})`,
|
|
87
|
+
`- [Constraints](${pathToFileURL(join(letraDir, "constraints.md")).href})`,
|
|
88
|
+
""
|
|
89
|
+
].join("\n");
|
|
90
|
+
writeFileSync(focusFile, content, "utf-8");
|
|
91
|
+
}
|
|
92
|
+
function clearFocusFile(rootDir) {
|
|
93
|
+
const focusFile = join(getLetraDir(rootDir), "focus.md");
|
|
94
|
+
if (existsSync(focusFile)) {
|
|
95
|
+
unlinkSync(focusFile);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function readFocusFile(rootDir) {
|
|
99
|
+
const focusFile = join(getLetraDir(rootDir), "focus.md");
|
|
100
|
+
if (!existsSync(focusFile)) return null;
|
|
101
|
+
const content = readFileSync(focusFile, "utf-8");
|
|
102
|
+
const specMatch = content.match(/# Focus:\s*(.+)/);
|
|
103
|
+
const itemMatch = content.match(/\*\*Item\*\*:\s*(.+)/);
|
|
104
|
+
const outcomeMatch = content.match(/\*\*Outcome\*\*:\s*([\s\S]*?)(?=\n\*\*|\n## |\n*$)/);
|
|
105
|
+
if (!specMatch) return null;
|
|
106
|
+
return {
|
|
107
|
+
specName: specMatch[1].trim(),
|
|
108
|
+
itemId: itemMatch ? itemMatch[1].trim() : "",
|
|
109
|
+
outcome: outcomeMatch ? outcomeMatch[1].trim() : ""
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
syncFocus,
|
|
115
|
+
extractOutcome,
|
|
116
|
+
writeFocusFile,
|
|
117
|
+
clearFocusFile,
|
|
118
|
+
readFocusFile
|
|
119
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_HARNESS_VERSION,
|
|
4
|
+
parseSimpleYaml,
|
|
5
|
+
resolveActiveFlowFor,
|
|
6
|
+
resolveHarnessRoot
|
|
7
|
+
} from "./chunk-DMOLJWWW.js";
|
|
8
|
+
import {
|
|
9
|
+
queryLog
|
|
10
|
+
} from "./chunk-BKAUN5QH.js";
|
|
11
|
+
import {
|
|
12
|
+
writeFocusFile
|
|
13
|
+
} from "./chunk-EDD55PWL.js";
|
|
14
|
+
import {
|
|
15
|
+
getLetraDir2 as getLetraDir
|
|
16
|
+
} from "./chunk-6HSUVCTR.js";
|
|
17
|
+
|
|
18
|
+
// src/adapters/focus-recommendations.ts
|
|
19
|
+
var ACTIVITY_ORDER = ["design", "implement", "review", "diagnose", "gate"];
|
|
20
|
+
function collectFocusRecommendations(workflow, flow, itemId) {
|
|
21
|
+
const item = workflow.items.find((candidate) => candidate.id === itemId);
|
|
22
|
+
if (!item || !flow) return [];
|
|
23
|
+
const stage = flow.stages.find((candidate) => candidate.id === item.stage);
|
|
24
|
+
if (!stage?.activity) return [];
|
|
25
|
+
const sortedStages = [...flow.stages].sort((left, right) => left.order - right.order);
|
|
26
|
+
const stageIndex = sortedStages.findIndex((candidate) => candidate.id === stage.id);
|
|
27
|
+
const nextStageId = stageIndex >= 0 ? sortedStages[stageIndex + 1]?.id : void 0;
|
|
28
|
+
const seen = /* @__PURE__ */ new Set();
|
|
29
|
+
const recommendations = [];
|
|
30
|
+
for (const kind of ACTIVITY_ORDER) {
|
|
31
|
+
for (const hint of stage.activity[kind]?.commands ?? []) {
|
|
32
|
+
const command = hint.command.replaceAll("<ITEM-ID>", item.id).replaceAll("<NEXT-STAGE>", nextStageId ?? "<NEXT-STAGE>");
|
|
33
|
+
if (seen.has(command)) continue;
|
|
34
|
+
seen.add(command);
|
|
35
|
+
recommendations.push({
|
|
36
|
+
command,
|
|
37
|
+
label: hint.label,
|
|
38
|
+
description: hint.description
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return recommendations;
|
|
43
|
+
}
|
|
44
|
+
function resolveFocusRecommendations(root, itemId) {
|
|
45
|
+
const resolution = resolveActiveFlowFor(root);
|
|
46
|
+
if (!resolution.workflow) return [];
|
|
47
|
+
return collectFocusRecommendations(resolution.workflow, resolution.flow, itemId);
|
|
48
|
+
}
|
|
49
|
+
function writeFocusWithRecommendations(root, specName, itemId) {
|
|
50
|
+
writeFocusFile(root, specName, itemId, resolveFocusRecommendations(root, itemId));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/harness/gate-checker.ts
|
|
54
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
55
|
+
import { join } from "path";
|
|
56
|
+
function loadGateStatusFromDisk(root, gateId) {
|
|
57
|
+
const candidates = [
|
|
58
|
+
join(getLetraDir(root), "harness", "gates"),
|
|
59
|
+
join(root, ".letra", "harness", "gates")
|
|
60
|
+
];
|
|
61
|
+
for (const gatesDir of candidates) {
|
|
62
|
+
if (!existsSync(gatesDir)) continue;
|
|
63
|
+
const files = [join(gatesDir, `${gateId}.yaml`), join(gatesDir, `${gateId}.yml`)];
|
|
64
|
+
for (const f of files) {
|
|
65
|
+
if (existsSync(f)) {
|
|
66
|
+
const raw = parseSimpleYaml(readFileSync(f, "utf-8"));
|
|
67
|
+
return {
|
|
68
|
+
blocksHandoff: raw.blocksHandoff === true,
|
|
69
|
+
status: raw.status === "approved" ? "approved" : "pending"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function loadManifestGates(root) {
|
|
77
|
+
const candidates = [
|
|
78
|
+
join(getLetraDir(root), "harness", DEFAULT_HARNESS_VERSION),
|
|
79
|
+
join(resolveHarnessRoot(root, DEFAULT_HARNESS_VERSION))
|
|
80
|
+
];
|
|
81
|
+
const gates = {};
|
|
82
|
+
for (const harnessDir of candidates) {
|
|
83
|
+
const gatesDir = join(harnessDir, "gates");
|
|
84
|
+
if (!existsSync(gatesDir)) continue;
|
|
85
|
+
for (const file of readdirSync(gatesDir)) {
|
|
86
|
+
if (!file.endsWith(".yaml")) continue;
|
|
87
|
+
try {
|
|
88
|
+
const raw = parseSimpleYaml(readFileSync(join(gatesDir, file), "utf-8"));
|
|
89
|
+
const id = String(raw.id ?? file.replace(/\.ya?ml$/, ""));
|
|
90
|
+
gates[id] = {
|
|
91
|
+
id,
|
|
92
|
+
name: String(raw.name ?? id),
|
|
93
|
+
type: ["human", "automated", "external"].includes(raw.type) ? raw.type : "automated",
|
|
94
|
+
blocking: raw.blocking === true,
|
|
95
|
+
blocksHandoff: raw.blocksHandoff === true,
|
|
96
|
+
policyRef: typeof raw.policyRef === "string" ? raw.policyRef : void 0,
|
|
97
|
+
description: String(raw.description ?? ""),
|
|
98
|
+
decisions: raw.decisions && typeof raw.decisions === "object" ? Object.fromEntries(
|
|
99
|
+
Object.entries(raw.decisions).filter(
|
|
100
|
+
([, v]) => typeof v === "string" && v.trim()
|
|
101
|
+
).map(([k, v]) => [k, v.trim()])
|
|
102
|
+
) : void 0
|
|
103
|
+
};
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (Object.keys(gates).length > 0) break;
|
|
108
|
+
}
|
|
109
|
+
return gates;
|
|
110
|
+
}
|
|
111
|
+
var GateChecker = class {
|
|
112
|
+
root;
|
|
113
|
+
manifestGates;
|
|
114
|
+
constructor(root, manifest) {
|
|
115
|
+
this.root = root;
|
|
116
|
+
this.manifestGates = manifest?.gates ?? loadManifestGates(root);
|
|
117
|
+
}
|
|
118
|
+
getGate(gateId) {
|
|
119
|
+
return this.manifestGates[gateId];
|
|
120
|
+
}
|
|
121
|
+
getRuntimeStatus(gateId) {
|
|
122
|
+
return loadGateStatusFromDisk(this.root, gateId);
|
|
123
|
+
}
|
|
124
|
+
checkBlocksHandoff(gateId) {
|
|
125
|
+
const gate = this.getGate(gateId);
|
|
126
|
+
if (gate) return gate.blocksHandoff === true;
|
|
127
|
+
const status = this.getRuntimeStatus(gateId);
|
|
128
|
+
if (status) return status.blocksHandoff;
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
checkHandoffAllowed(gateId, item) {
|
|
132
|
+
if (!gateId) return { allowed: true };
|
|
133
|
+
const blocksHandoff = this.checkBlocksHandoff(gateId);
|
|
134
|
+
if (!blocksHandoff) {
|
|
135
|
+
return { allowed: true };
|
|
136
|
+
}
|
|
137
|
+
const gateResult = this.check(gateId, item);
|
|
138
|
+
if (!gateResult.allowed) {
|
|
139
|
+
return {
|
|
140
|
+
...gateResult,
|
|
141
|
+
blocksHandoff: true
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const runtime = this.getRuntimeStatus(gateId);
|
|
145
|
+
if (runtime && runtime.status !== "approved") {
|
|
146
|
+
return {
|
|
147
|
+
allowed: false,
|
|
148
|
+
reason: `Gate "${gateId}" blocks handoff and is not approved`,
|
|
149
|
+
blocksHandoff: true
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return { allowed: true };
|
|
153
|
+
}
|
|
154
|
+
check(gateId, item) {
|
|
155
|
+
const gate = this.getGate(gateId);
|
|
156
|
+
if (!gate) {
|
|
157
|
+
return this.checkByConvention(gateId, item);
|
|
158
|
+
}
|
|
159
|
+
switch (gate.type) {
|
|
160
|
+
case "human":
|
|
161
|
+
return this.checkHumanGate(gate);
|
|
162
|
+
case "automated":
|
|
163
|
+
return this.checkAutomatedGate(gate, item);
|
|
164
|
+
case "external":
|
|
165
|
+
return this.checkExternalGate(gate);
|
|
166
|
+
default:
|
|
167
|
+
return { allowed: true };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
checkByConvention(gateId, item) {
|
|
171
|
+
if (gateId === "has-spec-file") return this.checkHasSpecFile(item);
|
|
172
|
+
if (gateId === "all-acs-passing") return this.checkAllAcsPassing(item);
|
|
173
|
+
return { allowed: true };
|
|
174
|
+
}
|
|
175
|
+
checkHumanGate(gate) {
|
|
176
|
+
const runtime = this.getRuntimeStatus(gate.id);
|
|
177
|
+
if (!runtime) {
|
|
178
|
+
return { allowed: false, reason: `Gate "${gate.id}" n\xE3o encontrado` };
|
|
179
|
+
}
|
|
180
|
+
if (runtime.status !== "approved") {
|
|
181
|
+
const decisionLabel = gate.decisions?.approve ?? "aprova\xE7\xE3o";
|
|
182
|
+
return { allowed: false, reason: `Gate "${gate.id}" pendente de ${decisionLabel}` };
|
|
183
|
+
}
|
|
184
|
+
return { allowed: true };
|
|
185
|
+
}
|
|
186
|
+
checkAutomatedGate(gate, item) {
|
|
187
|
+
if (gate.id === "has-spec-file") return this.checkHasSpecFile(item);
|
|
188
|
+
if (gate.id === "all-acs-passing") return this.checkAllAcsPassing(item);
|
|
189
|
+
const runtime = this.getRuntimeStatus(gate.id);
|
|
190
|
+
if (!runtime) {
|
|
191
|
+
return { allowed: false, reason: `Gate "${gate.id}" n\xE3o encontrado` };
|
|
192
|
+
}
|
|
193
|
+
if (runtime.status !== "approved") {
|
|
194
|
+
return { allowed: false, reason: `Gate "${gate.id}" pendente de aprova\xE7\xE3o` };
|
|
195
|
+
}
|
|
196
|
+
return { allowed: true };
|
|
197
|
+
}
|
|
198
|
+
checkExternalGate(gate) {
|
|
199
|
+
const runtime = this.getRuntimeStatus(gate.id);
|
|
200
|
+
if (!runtime) {
|
|
201
|
+
return { allowed: false, reason: `Gate "${gate.id}" n\xE3o encontrado` };
|
|
202
|
+
}
|
|
203
|
+
if (runtime.status !== "approved") {
|
|
204
|
+
return { allowed: false, reason: `Gate "${gate.id}" pendente de valida\xE7\xE3o externa` };
|
|
205
|
+
}
|
|
206
|
+
return { allowed: true };
|
|
207
|
+
}
|
|
208
|
+
checkHasSpecFile(item) {
|
|
209
|
+
if (!item.spec) {
|
|
210
|
+
return { allowed: false, reason: "Item sem spec vinculada" };
|
|
211
|
+
}
|
|
212
|
+
const specDir = join(getLetraDir(this.root), "specs", item.spec);
|
|
213
|
+
if (!existsSync(specDir)) {
|
|
214
|
+
return { allowed: false, reason: `Pasta de spec n\xE3o encontrada: ${item.spec}` };
|
|
215
|
+
}
|
|
216
|
+
return { allowed: true };
|
|
217
|
+
}
|
|
218
|
+
checkAllAcsPassing(item) {
|
|
219
|
+
if (!item.spec) {
|
|
220
|
+
return { allowed: false, reason: "Item sem spec vinculada" };
|
|
221
|
+
}
|
|
222
|
+
const specPath = join(getLetraDir(this.root), "specs", item.spec, "spec.md");
|
|
223
|
+
if (!existsSync(specPath)) {
|
|
224
|
+
return { allowed: false, reason: `Spec n\xE3o encontrada: ${item.spec}` };
|
|
225
|
+
}
|
|
226
|
+
const content = readFileSync(specPath, "utf-8");
|
|
227
|
+
const pending = (content.match(/^- \[ \]/gm) || []).length;
|
|
228
|
+
if (pending > 0) {
|
|
229
|
+
return {
|
|
230
|
+
allowed: false,
|
|
231
|
+
reason: `${pending} AC(s) pendente(s) em "${item.spec}"`
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const done = (content.match(/^- \[[xX]\]/gm) || []).length;
|
|
235
|
+
const logEntries = queryLog(this.root, {
|
|
236
|
+
itemId: item.id,
|
|
237
|
+
action: "ac_done",
|
|
238
|
+
limit: 999
|
|
239
|
+
});
|
|
240
|
+
if (done > logEntries.length) {
|
|
241
|
+
return {
|
|
242
|
+
allowed: false,
|
|
243
|
+
reason: `${done - logEntries.length} AC(s) marcado(s) sem confirma\xE7\xE3o "ac done"`
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return { allowed: true };
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export {
|
|
251
|
+
resolveFocusRecommendations,
|
|
252
|
+
writeFocusWithRecommendations,
|
|
253
|
+
GateChecker
|
|
254
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/adapters/registry.ts
|
|
4
|
+
var ADAPTER_ARTIFACTS = {
|
|
5
|
+
"cursor-rules": {
|
|
6
|
+
id: "cursor-rules",
|
|
7
|
+
path: ".cursorrules",
|
|
8
|
+
format: "at",
|
|
9
|
+
kind: "instructions",
|
|
10
|
+
consumers: ["cursor"],
|
|
11
|
+
ownership: "letra-owned"
|
|
12
|
+
},
|
|
13
|
+
"claude-instructions": {
|
|
14
|
+
id: "claude-instructions",
|
|
15
|
+
path: "CLAUDE.md",
|
|
16
|
+
format: "text",
|
|
17
|
+
kind: "instructions",
|
|
18
|
+
consumers: ["claude-code"],
|
|
19
|
+
ownership: "letra-owned"
|
|
20
|
+
},
|
|
21
|
+
"windsurf-rules": {
|
|
22
|
+
id: "windsurf-rules",
|
|
23
|
+
path: ".windsurfrules",
|
|
24
|
+
format: "at",
|
|
25
|
+
kind: "instructions",
|
|
26
|
+
consumers: ["windsurf"],
|
|
27
|
+
ownership: "letra-owned"
|
|
28
|
+
},
|
|
29
|
+
"vscode-instructions": {
|
|
30
|
+
id: "vscode-instructions",
|
|
31
|
+
path: ".github/copilot-instructions.md",
|
|
32
|
+
format: "text",
|
|
33
|
+
kind: "instructions",
|
|
34
|
+
consumers: ["vscode"],
|
|
35
|
+
ownership: "letra-owned"
|
|
36
|
+
},
|
|
37
|
+
"opencode-instructions": {
|
|
38
|
+
id: "opencode-instructions",
|
|
39
|
+
path: ".opencode/instructions.md",
|
|
40
|
+
format: "text",
|
|
41
|
+
kind: "instructions",
|
|
42
|
+
consumers: ["opencode"],
|
|
43
|
+
ownership: "letra-owned"
|
|
44
|
+
},
|
|
45
|
+
"agents-md-shared": {
|
|
46
|
+
id: "agents-md-shared",
|
|
47
|
+
path: "AGENTS.md",
|
|
48
|
+
format: "text",
|
|
49
|
+
kind: "instructions",
|
|
50
|
+
consumers: ["opencode", "codex"],
|
|
51
|
+
ownership: "letra-owned"
|
|
52
|
+
},
|
|
53
|
+
"codex-project-config": {
|
|
54
|
+
id: "codex-project-config",
|
|
55
|
+
path: ".codex/config.toml",
|
|
56
|
+
format: "toml",
|
|
57
|
+
kind: "config",
|
|
58
|
+
consumers: ["codex"],
|
|
59
|
+
ownership: "managed-section"
|
|
60
|
+
},
|
|
61
|
+
"letra-harness-skill": {
|
|
62
|
+
id: "letra-harness-skill",
|
|
63
|
+
path: ".agents/skills/letra-harness/SKILL.md",
|
|
64
|
+
format: "skill",
|
|
65
|
+
kind: "skill",
|
|
66
|
+
consumers: ["codex"],
|
|
67
|
+
ownership: "letra-owned"
|
|
68
|
+
},
|
|
69
|
+
"hermes-instructions": {
|
|
70
|
+
id: "hermes-instructions",
|
|
71
|
+
path: ".hermes/instructions.md",
|
|
72
|
+
format: "text",
|
|
73
|
+
kind: "instructions",
|
|
74
|
+
consumers: ["hermes"],
|
|
75
|
+
ownership: "letra-owned"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var staticCapabilities = {
|
|
79
|
+
instructions: true,
|
|
80
|
+
nestedInstructions: false,
|
|
81
|
+
skills: false,
|
|
82
|
+
mcp: false,
|
|
83
|
+
hooks: false,
|
|
84
|
+
liveContext: "none",
|
|
85
|
+
refreshMode: "session-start"
|
|
86
|
+
};
|
|
87
|
+
var ADAPTER_REGISTRY = {
|
|
88
|
+
cursor: {
|
|
89
|
+
id: "cursor",
|
|
90
|
+
displayName: "Cursor",
|
|
91
|
+
capabilities: staticCapabilities,
|
|
92
|
+
artifactIds: ["cursor-rules"],
|
|
93
|
+
detectionPaths: [".cursorrules"],
|
|
94
|
+
fallbackTransport: "cli-json"
|
|
95
|
+
},
|
|
96
|
+
"claude-code": {
|
|
97
|
+
id: "claude-code",
|
|
98
|
+
displayName: "Claude Code",
|
|
99
|
+
capabilities: staticCapabilities,
|
|
100
|
+
artifactIds: ["claude-instructions"],
|
|
101
|
+
detectionPaths: ["CLAUDE.md"],
|
|
102
|
+
fallbackTransport: "cli-json"
|
|
103
|
+
},
|
|
104
|
+
windsurf: {
|
|
105
|
+
id: "windsurf",
|
|
106
|
+
displayName: "Windsurf",
|
|
107
|
+
capabilities: staticCapabilities,
|
|
108
|
+
artifactIds: ["windsurf-rules"],
|
|
109
|
+
detectionPaths: [".windsurfrules"],
|
|
110
|
+
fallbackTransport: "cli-json"
|
|
111
|
+
},
|
|
112
|
+
vscode: {
|
|
113
|
+
id: "vscode",
|
|
114
|
+
displayName: "VSCode Copilot",
|
|
115
|
+
capabilities: staticCapabilities,
|
|
116
|
+
artifactIds: ["vscode-instructions"],
|
|
117
|
+
detectionPaths: [".github/copilot-instructions.md"],
|
|
118
|
+
fallbackTransport: "cli-json"
|
|
119
|
+
},
|
|
120
|
+
opencode: {
|
|
121
|
+
id: "opencode",
|
|
122
|
+
displayName: "OpenCode",
|
|
123
|
+
capabilities: {
|
|
124
|
+
...staticCapabilities,
|
|
125
|
+
skills: true
|
|
126
|
+
},
|
|
127
|
+
artifactIds: ["opencode-instructions", "agents-md-shared"],
|
|
128
|
+
detectionPaths: [".opencode/instructions.md", "AGENTS.md"],
|
|
129
|
+
fallbackTransport: "cli-json"
|
|
130
|
+
},
|
|
131
|
+
codex: {
|
|
132
|
+
id: "codex",
|
|
133
|
+
displayName: "Codex",
|
|
134
|
+
capabilities: {
|
|
135
|
+
instructions: true,
|
|
136
|
+
nestedInstructions: true,
|
|
137
|
+
skills: true,
|
|
138
|
+
mcp: true,
|
|
139
|
+
hooks: true,
|
|
140
|
+
liveContext: "mcp",
|
|
141
|
+
refreshMode: "on-demand"
|
|
142
|
+
},
|
|
143
|
+
artifactIds: ["agents-md-shared", "codex-project-config", "letra-harness-skill"],
|
|
144
|
+
detectionPaths: [".codex/config.toml"],
|
|
145
|
+
fallbackTransport: "cli-json"
|
|
146
|
+
},
|
|
147
|
+
hermes: {
|
|
148
|
+
id: "hermes",
|
|
149
|
+
displayName: "Hermes Agent",
|
|
150
|
+
capabilities: staticCapabilities,
|
|
151
|
+
artifactIds: ["hermes-instructions"],
|
|
152
|
+
detectionPaths: [".hermes/instructions.md"],
|
|
153
|
+
fallbackTransport: "cli-json"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
function adapterInstructionTargets() {
|
|
157
|
+
return Object.fromEntries(
|
|
158
|
+
Object.values(ADAPTER_REGISTRY).map((adapter) => {
|
|
159
|
+
const artifacts = adapter.artifactIds.map((id) => ADAPTER_ARTIFACTS[id]).filter((artifact) => artifact.kind === "instructions");
|
|
160
|
+
const format = artifacts[0]?.format;
|
|
161
|
+
if (format !== "at" && format !== "text") {
|
|
162
|
+
throw new Error(`Adapter "${adapter.id}" has no instruction artifact.`);
|
|
163
|
+
}
|
|
164
|
+
if (artifacts.some((artifact) => artifact.format !== format)) {
|
|
165
|
+
throw new Error(`Adapter "${adapter.id}" mixes instruction formats.`);
|
|
166
|
+
}
|
|
167
|
+
return [
|
|
168
|
+
adapter.id,
|
|
169
|
+
{
|
|
170
|
+
paths: artifacts.map((artifact) => artifact.path),
|
|
171
|
+
format,
|
|
172
|
+
displayName: adapter.displayName
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
function adapterDiagnosticFiles() {
|
|
179
|
+
const instructionTargets = adapterInstructionTargets();
|
|
180
|
+
return Object.fromEntries(
|
|
181
|
+
Object.values(ADAPTER_REGISTRY).map((adapter) => {
|
|
182
|
+
const target = instructionTargets[adapter.id];
|
|
183
|
+
const sharedAgentsPath = target.paths.includes("AGENTS.md") ? "AGENTS.md" : null;
|
|
184
|
+
return [
|
|
185
|
+
adapter.id,
|
|
186
|
+
{
|
|
187
|
+
path: sharedAgentsPath ?? target.paths[0],
|
|
188
|
+
format: target.format
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
function instructionArtifactsForAdapters(adapterIds) {
|
|
195
|
+
const selected = new Set(adapterIds.filter((id) => id in ADAPTER_REGISTRY));
|
|
196
|
+
return Object.values(ADAPTER_ARTIFACTS).filter(
|
|
197
|
+
(artifact) => artifact.kind === "instructions" && artifact.consumers.some((consumer) => selected.has(consumer))
|
|
198
|
+
).map((artifact) => {
|
|
199
|
+
if (artifact.format !== "at" && artifact.format !== "text") {
|
|
200
|
+
throw new Error(`Artifact "${artifact.id}" is not an instruction format.`);
|
|
201
|
+
}
|
|
202
|
+
const selectedConsumers = artifact.consumers.filter(
|
|
203
|
+
(consumer) => selected.has(consumer)
|
|
204
|
+
);
|
|
205
|
+
const displayName = artifact.id === "agents-md-shared" ? "OpenCode + Codex" : ADAPTER_REGISTRY[selectedConsumers[0]].displayName;
|
|
206
|
+
return {
|
|
207
|
+
id: artifact.id,
|
|
208
|
+
path: artifact.path,
|
|
209
|
+
paths: [artifact.path],
|
|
210
|
+
format: artifact.format,
|
|
211
|
+
displayName,
|
|
212
|
+
tool: selectedConsumers.join(",")
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function supportedAdapterTools() {
|
|
217
|
+
const targets = adapterInstructionTargets();
|
|
218
|
+
return Object.values(ADAPTER_REGISTRY).map((adapter) => ({
|
|
219
|
+
...adapter,
|
|
220
|
+
label: adapter.displayName,
|
|
221
|
+
paths: [...targets[adapter.id].paths],
|
|
222
|
+
detectionPaths: [...adapter.detectionPaths],
|
|
223
|
+
artifactIds: [...adapter.artifactIds],
|
|
224
|
+
capabilities: { ...adapter.capabilities }
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
ADAPTER_ARTIFACTS,
|
|
230
|
+
ADAPTER_REGISTRY,
|
|
231
|
+
adapterInstructionTargets,
|
|
232
|
+
adapterDiagnosticFiles,
|
|
233
|
+
instructionArtifactsForAdapters,
|
|
234
|
+
supportedAdapterTools
|
|
235
|
+
};
|