@letra-ai/cli 0.5.3 → 0.6.1
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-4QDEU6KP.js +2765 -0
- package/dist/chunk-6HSUVCTR.js +363 -0
- package/dist/chunk-BKAUN5QH.js +300 -0
- package/dist/chunk-BTPFUKHG.js +275 -0
- package/dist/chunk-EDD55PWL.js +119 -0
- package/dist/chunk-ELBTIPYN.js +256 -0
- package/dist/chunk-IEFSLCJL.js +837 -0
- package/dist/chunk-JMIC5NKB.js +235 -0
- package/dist/chunk-KGQLHMGZ.js +4494 -0
- package/dist/chunk-MJ2QXNH6.js +130 -0
- package/dist/chunk-MSF44WWE.js +443 -0
- package/dist/chunk-PDX44BCA.js +11 -0
- package/dist/chunk-QIVKP3EY.js +362 -0
- package/dist/client/assets/index-BuABgOyz.js +232 -0
- package/dist/client/assets/index-CpseCZh9.css +1 -0
- package/dist/client/favicon.svg +16 -4
- package/dist/client/index.html +25 -20
- package/dist/fallback-UXSZ4LNR.js +47 -0
- package/dist/flow-serve-MTB6KZMR.js +19 -0
- package/dist/focus-sync-3D3XWCTI.js +17 -0
- package/dist/generate-N22QOXUF.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 +247 -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 +1932 -2528
- package/dist/init-wizard-NODBBNKO.js +178 -0
- package/dist/push-5JEYSXBY.js +116 -0
- package/dist/registry-6VPIA3EG.js +18 -0
- package/dist/server-FUP3APZA.js +415 -0
- package/dist/service-OGF7BMCQ.js +21 -0
- package/dist/session-log-WTQ5JBEN.js +21 -0
- package/dist/sitrep-DJXTP3JO.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,415 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
completeAcOperation,
|
|
4
|
+
requestTransitionOperation,
|
|
5
|
+
runValidationOperation
|
|
6
|
+
} from "./chunk-QIVKP3EY.js";
|
|
7
|
+
import "./chunk-IEFSLCJL.js";
|
|
8
|
+
import "./chunk-ELBTIPYN.js";
|
|
9
|
+
import {
|
|
10
|
+
loadHarnessForWorkflow,
|
|
11
|
+
resolveActiveFlowFor,
|
|
12
|
+
resolveAgentDirection
|
|
13
|
+
} from "./chunk-MSF44WWE.js";
|
|
14
|
+
import {
|
|
15
|
+
createWorkspaceBoundary,
|
|
16
|
+
loadWorkflow
|
|
17
|
+
} from "./chunk-4QDEU6KP.js";
|
|
18
|
+
import {
|
|
19
|
+
logEntry
|
|
20
|
+
} from "./chunk-BKAUN5QH.js";
|
|
21
|
+
import "./chunk-JMIC5NKB.js";
|
|
22
|
+
import "./chunk-EDD55PWL.js";
|
|
23
|
+
import {
|
|
24
|
+
getActiveEntries,
|
|
25
|
+
loadHealthRecord
|
|
26
|
+
} from "./chunk-MJ2QXNH6.js";
|
|
27
|
+
import {
|
|
28
|
+
getLetraDir2 as getLetraDir,
|
|
29
|
+
resolveWorkspaceRoot
|
|
30
|
+
} from "./chunk-6HSUVCTR.js";
|
|
31
|
+
import "./chunk-PDX44BCA.js";
|
|
32
|
+
|
|
33
|
+
// src/mcp/server.ts
|
|
34
|
+
import { existsSync, readFileSync } from "fs";
|
|
35
|
+
import { join, resolve } from "path";
|
|
36
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
37
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
function jsonText(value) {
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: "text", text: JSON.stringify(value, null, 2) }]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function safeActiveSpec(root, boundary) {
|
|
45
|
+
const direction = resolveAgentDirection(root);
|
|
46
|
+
const name = direction.item?.spec ?? null;
|
|
47
|
+
if (!name || !/^[a-zA-Z0-9._-]+$/.test(name)) {
|
|
48
|
+
return { name, path: null, content: null };
|
|
49
|
+
}
|
|
50
|
+
const specsRoot = resolve(root, ".letra", "specs");
|
|
51
|
+
const specDir = resolve(specsRoot, name);
|
|
52
|
+
if (specDir !== specsRoot && !specDir.startsWith(`${specsRoot}\\`) && !specDir.startsWith(`${specsRoot}/`)) {
|
|
53
|
+
return { name, path: null, content: null };
|
|
54
|
+
}
|
|
55
|
+
const acceptancePath = join(specDir, "acceptance.md");
|
|
56
|
+
const specPath = join(specDir, "spec.md");
|
|
57
|
+
const selectedPath = existsSync(acceptancePath) ? acceptancePath : existsSync(specPath) ? specPath : null;
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
path: selectedPath ? boundary.assertPath(selectedPath).replace(/\\/g, "/") : null,
|
|
61
|
+
content: selectedPath ? readFileSync(boundary.assertPath(selectedPath), "utf-8") : null
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function gateIdFromRef(gateRef) {
|
|
65
|
+
return gateRef.replace(/^.*[\\/]/, "").replace(/\.ya?ml$/, "");
|
|
66
|
+
}
|
|
67
|
+
function loadHarnessManifest(root) {
|
|
68
|
+
return loadHarnessForWorkflow(root, loadWorkflow(root));
|
|
69
|
+
}
|
|
70
|
+
function collectGates(root) {
|
|
71
|
+
const harness = loadHarnessManifest(root);
|
|
72
|
+
return harness ? Object.values(harness.gates) : [];
|
|
73
|
+
}
|
|
74
|
+
function collectRoles(root) {
|
|
75
|
+
const resolution = resolveActiveFlowFor(root);
|
|
76
|
+
return [...resolution.flow?.roles ?? []];
|
|
77
|
+
}
|
|
78
|
+
function healthPayload(root) {
|
|
79
|
+
const record = loadHealthRecord(root);
|
|
80
|
+
return {
|
|
81
|
+
scannedAt: record.lastScanAt ?? null,
|
|
82
|
+
active: getActiveEntries(record)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function resourceText(uri, text, mimeType = "application/json") {
|
|
86
|
+
return {
|
|
87
|
+
contents: [{ uri, mimeType, text }]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createLetraMcpServer(root) {
|
|
91
|
+
const resolution = resolveWorkspaceRoot(root);
|
|
92
|
+
const workspaceDir = resolution.workspaceDir;
|
|
93
|
+
const boundary = createWorkspaceBoundary(workspaceDir);
|
|
94
|
+
const workspaceRoot = boundary.root;
|
|
95
|
+
const auditedReads = /* @__PURE__ */ new Set();
|
|
96
|
+
const server = new McpServer({
|
|
97
|
+
name: "letra",
|
|
98
|
+
version: "0.5.3"
|
|
99
|
+
});
|
|
100
|
+
const readOnlyAnnotations = {
|
|
101
|
+
readOnlyHint: true,
|
|
102
|
+
destructiveHint: false,
|
|
103
|
+
idempotentHint: true,
|
|
104
|
+
openWorldHint: false
|
|
105
|
+
};
|
|
106
|
+
const verificationAnnotations = {
|
|
107
|
+
readOnlyHint: false,
|
|
108
|
+
destructiveHint: false,
|
|
109
|
+
idempotentHint: false,
|
|
110
|
+
openWorldHint: false
|
|
111
|
+
};
|
|
112
|
+
const mutationAnnotations = {
|
|
113
|
+
readOnlyHint: false,
|
|
114
|
+
destructiveHint: true,
|
|
115
|
+
idempotentHint: false,
|
|
116
|
+
openWorldHint: false
|
|
117
|
+
};
|
|
118
|
+
const expectedRevision = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
119
|
+
const reason = z.string().trim().min(1).max(500);
|
|
120
|
+
const clientIdentity = () => {
|
|
121
|
+
const client = server.server.getClientVersion();
|
|
122
|
+
return {
|
|
123
|
+
actor: client?.name ? `mcp:${client.name}` : "mcp:unknown",
|
|
124
|
+
clientVersion: client?.version ?? null
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const auditRead = (resource, direction = resolveAgentDirection(workspaceRoot)) => {
|
|
128
|
+
const key = `${resource}:${direction.revision}`;
|
|
129
|
+
if (auditedReads.has(key)) return direction;
|
|
130
|
+
auditedReads.add(key);
|
|
131
|
+
const client = clientIdentity();
|
|
132
|
+
logEntry(workspaceRoot, "agent_direction_read", `MCP read: ${resource}`, {
|
|
133
|
+
itemId: direction.item?.id,
|
|
134
|
+
acId: direction.pendingAC?.id,
|
|
135
|
+
details: {
|
|
136
|
+
adapter: "codex",
|
|
137
|
+
by: client.actor,
|
|
138
|
+
clientVersion: client.clientVersion,
|
|
139
|
+
resource,
|
|
140
|
+
revision: direction.revision,
|
|
141
|
+
reason: "Consulta de contexto pelo transporte MCP.",
|
|
142
|
+
outcome: "accepted"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return direction;
|
|
146
|
+
};
|
|
147
|
+
server.registerTool(
|
|
148
|
+
"get_direction",
|
|
149
|
+
{
|
|
150
|
+
description: "Retorna a dire\xE7\xE3o vigente e versionada do harness para o workspace atual.",
|
|
151
|
+
annotations: readOnlyAnnotations
|
|
152
|
+
},
|
|
153
|
+
async () => jsonText(auditRead("direction"))
|
|
154
|
+
);
|
|
155
|
+
server.registerTool(
|
|
156
|
+
"get_active_spec",
|
|
157
|
+
{
|
|
158
|
+
description: "Retorna a spec ativa e seus crit\xE9rios de aceita\xE7\xE3o.",
|
|
159
|
+
annotations: readOnlyAnnotations
|
|
160
|
+
},
|
|
161
|
+
async () => {
|
|
162
|
+
auditRead("active-spec");
|
|
163
|
+
return jsonText(safeActiveSpec(workspaceRoot, boundary));
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
server.registerTool(
|
|
167
|
+
"get_health",
|
|
168
|
+
{
|
|
169
|
+
description: "Retorna alertas operacionais ativos do workspace.",
|
|
170
|
+
annotations: readOnlyAnnotations
|
|
171
|
+
},
|
|
172
|
+
async () => {
|
|
173
|
+
auditRead("health");
|
|
174
|
+
return jsonText(healthPayload(workspaceRoot));
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
server.registerTool(
|
|
178
|
+
"validate",
|
|
179
|
+
{
|
|
180
|
+
description: "Valida o workspace pela implementa\xE7\xE3o can\xF4nica e registra o resultado.",
|
|
181
|
+
inputSchema: {
|
|
182
|
+
expectedRevision,
|
|
183
|
+
reason
|
|
184
|
+
},
|
|
185
|
+
annotations: verificationAnnotations
|
|
186
|
+
},
|
|
187
|
+
async (input) => jsonText(
|
|
188
|
+
await runValidationOperation(workspaceRoot, {
|
|
189
|
+
...input,
|
|
190
|
+
actor: clientIdentity().actor
|
|
191
|
+
})
|
|
192
|
+
)
|
|
193
|
+
);
|
|
194
|
+
server.registerTool(
|
|
195
|
+
"complete_ac",
|
|
196
|
+
{
|
|
197
|
+
description: "Conclui o AC vigente ap\xF3s validar revis\xE3o e evid\xEAncia de regress\xE3o.",
|
|
198
|
+
inputSchema: {
|
|
199
|
+
acId: z.string().regex(/^AC\d+(?:\.\d+)*$/i),
|
|
200
|
+
expectedRevision,
|
|
201
|
+
evidence: z.array(z.string().trim().min(1).max(500)).max(20),
|
|
202
|
+
reason
|
|
203
|
+
},
|
|
204
|
+
annotations: mutationAnnotations
|
|
205
|
+
},
|
|
206
|
+
async (input) => jsonText(
|
|
207
|
+
completeAcOperation(workspaceRoot, {
|
|
208
|
+
...input,
|
|
209
|
+
actor: clientIdentity().actor
|
|
210
|
+
})
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
server.registerTool(
|
|
214
|
+
"request_transition",
|
|
215
|
+
{
|
|
216
|
+
description: "Solicita transi\xE7\xE3o do item vigente sem contornar ACs, pap\xE9is ou gates.",
|
|
217
|
+
inputSchema: {
|
|
218
|
+
itemId: z.string().regex(/^ITEM-\d+$/i),
|
|
219
|
+
targetStageId: z.string().regex(/^[a-zA-Z0-9._-]+$/),
|
|
220
|
+
expectedRevision,
|
|
221
|
+
reason
|
|
222
|
+
},
|
|
223
|
+
annotations: mutationAnnotations
|
|
224
|
+
},
|
|
225
|
+
async (input) => jsonText(
|
|
226
|
+
await requestTransitionOperation(workspaceRoot, {
|
|
227
|
+
...input,
|
|
228
|
+
actor: clientIdentity().actor
|
|
229
|
+
})
|
|
230
|
+
)
|
|
231
|
+
);
|
|
232
|
+
server.registerResource(
|
|
233
|
+
"direction",
|
|
234
|
+
"letra://direction",
|
|
235
|
+
{ title: "Dire\xE7\xE3o vigente do harness", mimeType: "application/json" },
|
|
236
|
+
async () => resourceText("letra://direction", JSON.stringify(auditRead("direction"), null, 2))
|
|
237
|
+
);
|
|
238
|
+
server.registerResource(
|
|
239
|
+
"active-spec",
|
|
240
|
+
"letra://spec/active",
|
|
241
|
+
{ title: "Spec ativa", mimeType: "text/markdown" },
|
|
242
|
+
async () => resourceText(
|
|
243
|
+
"letra://spec/active",
|
|
244
|
+
(auditRead("active-spec"), safeActiveSpec(workspaceRoot, boundary).content ?? ""),
|
|
245
|
+
"text/markdown"
|
|
246
|
+
)
|
|
247
|
+
);
|
|
248
|
+
server.registerResource(
|
|
249
|
+
"constitution",
|
|
250
|
+
"letra://constitution",
|
|
251
|
+
{ title: "Constitui\xE7\xE3o do workspace", mimeType: "text/markdown" },
|
|
252
|
+
async () => {
|
|
253
|
+
auditRead("constitution");
|
|
254
|
+
const path = boundary.assertPath(join(getLetraDir(workspaceRoot), "constitution.md"));
|
|
255
|
+
const content = existsSync(path) ? readFileSync(path, "utf-8") : "";
|
|
256
|
+
logEntry(workspaceRoot, "constitution_read", "Constitution read via MCP", {
|
|
257
|
+
details: {
|
|
258
|
+
adapter: "mcp",
|
|
259
|
+
by: "mcp:constitution-resource",
|
|
260
|
+
available: existsSync(path),
|
|
261
|
+
version: content.match(/\*\*Version:\*\*\s*(.+)/)?.[1]?.trim() ?? null
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return resourceText("letra://constitution", content, "text/markdown");
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
server.registerResource(
|
|
268
|
+
"health",
|
|
269
|
+
"letra://health",
|
|
270
|
+
{ title: "Sa\xFAde operacional", mimeType: "application/json" },
|
|
271
|
+
async () => resourceText(
|
|
272
|
+
"letra://health",
|
|
273
|
+
JSON.stringify((auditRead("health"), healthPayload(workspaceRoot)), null, 2)
|
|
274
|
+
)
|
|
275
|
+
);
|
|
276
|
+
const auditHarnessRead = (resource) => {
|
|
277
|
+
const direction = resolveAgentDirection(workspaceRoot);
|
|
278
|
+
const key = `harness:${resource}:${direction.revision}`;
|
|
279
|
+
if (auditedReads.has(key)) return;
|
|
280
|
+
auditedReads.add(key);
|
|
281
|
+
const client = clientIdentity();
|
|
282
|
+
logEntry(workspaceRoot, "agent_harness_read", `MCP harness read: ${resource}`, {
|
|
283
|
+
itemId: direction.item?.id,
|
|
284
|
+
acId: direction.pendingAC?.id,
|
|
285
|
+
details: {
|
|
286
|
+
adapter: "codex",
|
|
287
|
+
by: client.actor,
|
|
288
|
+
clientVersion: client.clientVersion,
|
|
289
|
+
resource,
|
|
290
|
+
revision: direction.revision,
|
|
291
|
+
outcome: "accepted"
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
server.registerResource(
|
|
296
|
+
"harness-templates",
|
|
297
|
+
"letra://harness/templates",
|
|
298
|
+
{ title: "Templates dispon\xEDveis no harness", mimeType: "application/json" },
|
|
299
|
+
async () => {
|
|
300
|
+
auditHarnessRead("templates");
|
|
301
|
+
const workflow = loadWorkflow(workspaceRoot);
|
|
302
|
+
const harness = loadHarnessForWorkflow(workspaceRoot, workflow);
|
|
303
|
+
const templateIds = harness ? Object.keys(harness.flows).sort() : [];
|
|
304
|
+
return resourceText("letra://harness/templates", JSON.stringify(templateIds, null, 2));
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
server.resource(
|
|
308
|
+
"harness-template",
|
|
309
|
+
new ResourceTemplate("letra://harness/templates/{flowId}", { list: void 0 }),
|
|
310
|
+
async (uri, variables) => {
|
|
311
|
+
const flowId = variables.flowId;
|
|
312
|
+
auditHarnessRead(`templates/${flowId}`);
|
|
313
|
+
const workflow = loadWorkflow(workspaceRoot);
|
|
314
|
+
const harness = loadHarnessForWorkflow(workspaceRoot, workflow);
|
|
315
|
+
if (!harness) {
|
|
316
|
+
return resourceText(uri.href, JSON.stringify({ error: "Harness not available" }));
|
|
317
|
+
}
|
|
318
|
+
const template = harness.flows[flowId];
|
|
319
|
+
if (!template) {
|
|
320
|
+
return resourceText(
|
|
321
|
+
uri.href,
|
|
322
|
+
JSON.stringify({ error: `Template "${flowId}" not found` })
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
const resolvedStages = template.stages.map((stage) => {
|
|
326
|
+
const gateId = stage.gate ? gateIdFromRef(stage.gate) : null;
|
|
327
|
+
return {
|
|
328
|
+
id: stage.id,
|
|
329
|
+
name: stage.name,
|
|
330
|
+
order: stage.order,
|
|
331
|
+
zone: stage.zone,
|
|
332
|
+
description: stage.description,
|
|
333
|
+
gate: gateId && harness.gates[gateId] ? harness.gates[gateId] : null,
|
|
334
|
+
roles: stage.agents.map((roleId) => harness.roles[roleId]).filter(Boolean),
|
|
335
|
+
phases: stage.phases,
|
|
336
|
+
activity: stage.activity
|
|
337
|
+
};
|
|
338
|
+
});
|
|
339
|
+
const policyId = template.defaultPolicy ? template.defaultPolicy.replace(/^.*[\\/]/, "").replace(/\.json$/, "") : null;
|
|
340
|
+
return resourceText(
|
|
341
|
+
uri.href,
|
|
342
|
+
JSON.stringify(
|
|
343
|
+
{
|
|
344
|
+
id: template.id,
|
|
345
|
+
version: template.version,
|
|
346
|
+
name: template.name,
|
|
347
|
+
description: template.description,
|
|
348
|
+
defaultPolicy: template.defaultPolicy,
|
|
349
|
+
stages: resolvedStages,
|
|
350
|
+
gates: Object.values(harness.gates),
|
|
351
|
+
roles: Object.values(harness.roles),
|
|
352
|
+
policy: policyId && harness.policies[policyId] ? harness.policies[policyId] : null
|
|
353
|
+
},
|
|
354
|
+
null,
|
|
355
|
+
2
|
|
356
|
+
)
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
server.registerResource(
|
|
361
|
+
"harness-gates",
|
|
362
|
+
"letra://harness/gates",
|
|
363
|
+
{ title: "Gates do harness", mimeType: "application/json" },
|
|
364
|
+
async () => {
|
|
365
|
+
auditHarnessRead("gates");
|
|
366
|
+
return resourceText(
|
|
367
|
+
"letra://harness/gates",
|
|
368
|
+
JSON.stringify(collectGates(workspaceRoot), null, 2)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
server.registerResource(
|
|
373
|
+
"harness-roles",
|
|
374
|
+
"letra://harness/roles",
|
|
375
|
+
{ title: "Roles do harness", mimeType: "application/json" },
|
|
376
|
+
async () => {
|
|
377
|
+
auditHarnessRead("roles");
|
|
378
|
+
return resourceText(
|
|
379
|
+
"letra://harness/roles",
|
|
380
|
+
JSON.stringify(collectRoles(workspaceRoot), null, 2)
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
server.registerTool(
|
|
385
|
+
"list_gates",
|
|
386
|
+
{
|
|
387
|
+
description: "Lista todos os gates do template ativo do harness.",
|
|
388
|
+
annotations: readOnlyAnnotations
|
|
389
|
+
},
|
|
390
|
+
async () => {
|
|
391
|
+
auditHarnessRead("gates");
|
|
392
|
+
return jsonText(collectGates(workspaceRoot));
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
server.registerTool(
|
|
396
|
+
"list_roles",
|
|
397
|
+
{
|
|
398
|
+
description: "Lista todos os roles do template ativo do harness.",
|
|
399
|
+
annotations: readOnlyAnnotations
|
|
400
|
+
},
|
|
401
|
+
async () => {
|
|
402
|
+
auditHarnessRead("roles");
|
|
403
|
+
return jsonText(collectRoles(workspaceRoot));
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
return server;
|
|
407
|
+
}
|
|
408
|
+
async function startLetraMcpServer(root) {
|
|
409
|
+
const server = createLetraMcpServer(root);
|
|
410
|
+
await server.connect(new StdioServerTransport());
|
|
411
|
+
}
|
|
412
|
+
export {
|
|
413
|
+
createLetraMcpServer,
|
|
414
|
+
startLetraMcpServer
|
|
415
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
completeAcOperation,
|
|
4
|
+
requestTransitionOperation,
|
|
5
|
+
runValidationOperation
|
|
6
|
+
} from "./chunk-QIVKP3EY.js";
|
|
7
|
+
import "./chunk-IEFSLCJL.js";
|
|
8
|
+
import "./chunk-ELBTIPYN.js";
|
|
9
|
+
import "./chunk-MSF44WWE.js";
|
|
10
|
+
import "./chunk-4QDEU6KP.js";
|
|
11
|
+
import "./chunk-BKAUN5QH.js";
|
|
12
|
+
import "./chunk-JMIC5NKB.js";
|
|
13
|
+
import "./chunk-EDD55PWL.js";
|
|
14
|
+
import "./chunk-MJ2QXNH6.js";
|
|
15
|
+
import "./chunk-6HSUVCTR.js";
|
|
16
|
+
import "./chunk-PDX44BCA.js";
|
|
17
|
+
export {
|
|
18
|
+
completeAcOperation,
|
|
19
|
+
requestTransitionOperation,
|
|
20
|
+
runValidationOperation
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
closeSessionLogHandles,
|
|
4
|
+
loadSessionLog,
|
|
5
|
+
logEntry,
|
|
6
|
+
pruneSessionLog,
|
|
7
|
+
queryLog,
|
|
8
|
+
queryLogWithMeta,
|
|
9
|
+
saveSessionLog
|
|
10
|
+
} from "./chunk-BKAUN5QH.js";
|
|
11
|
+
import "./chunk-6HSUVCTR.js";
|
|
12
|
+
import "./chunk-PDX44BCA.js";
|
|
13
|
+
export {
|
|
14
|
+
closeSessionLogHandles,
|
|
15
|
+
loadSessionLog,
|
|
16
|
+
logEntry,
|
|
17
|
+
pruneSessionLog,
|
|
18
|
+
queryLog,
|
|
19
|
+
queryLogWithMeta,
|
|
20
|
+
saveSessionLog
|
|
21
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
sitrep,
|
|
4
|
+
sitrep_default
|
|
5
|
+
} from "./chunk-BTPFUKHG.js";
|
|
6
|
+
import "./chunk-4QDEU6KP.js";
|
|
7
|
+
import "./chunk-BKAUN5QH.js";
|
|
8
|
+
import "./chunk-JMIC5NKB.js";
|
|
9
|
+
import "./chunk-EDD55PWL.js";
|
|
10
|
+
import "./chunk-MJ2QXNH6.js";
|
|
11
|
+
import "./chunk-6HSUVCTR.js";
|
|
12
|
+
import "./chunk-PDX44BCA.js";
|
|
13
|
+
export {
|
|
14
|
+
sitrep_default as default,
|
|
15
|
+
sitrep
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@letra-ai/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"bin": {
|
|
6
|
-
"letra": "dist/index.js"
|
|
7
|
-
},
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@letra-ai/cli",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"letra": "dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": ["dist"],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"build": "node ../../scripts/build-cli.mjs",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
23
|
+
"chalk": "^5.4.1",
|
|
24
|
+
"commander": "^12.1.0",
|
|
25
|
+
"glob": "^11.0.0",
|
|
26
|
+
"ink": "^7.1.0",
|
|
27
|
+
"ora": "^9.3.0",
|
|
28
|
+
"react": "^19.2.7",
|
|
29
|
+
"zod": "^3.25.76"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@letra/types": "*",
|
|
33
|
+
"tsup": "^8.5.0",
|
|
34
|
+
"typescript": "^5.8.3",
|
|
35
|
+
"vitest": "^3.2.4"
|
|
36
|
+
}
|
|
37
|
+
}
|