@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,362 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
validate
|
|
4
|
+
} from "./chunk-IEFSLCJL.js";
|
|
5
|
+
import {
|
|
6
|
+
GateChecker,
|
|
7
|
+
writeFocusWithRecommendations
|
|
8
|
+
} from "./chunk-ELBTIPYN.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveActiveFlow,
|
|
11
|
+
resolveAgentDirection
|
|
12
|
+
} from "./chunk-MSF44WWE.js";
|
|
13
|
+
import {
|
|
14
|
+
createWorkspaceBoundary,
|
|
15
|
+
generateAdapters,
|
|
16
|
+
loadWorkflow,
|
|
17
|
+
writeWorkflow
|
|
18
|
+
} from "./chunk-4QDEU6KP.js";
|
|
19
|
+
import {
|
|
20
|
+
logEntry
|
|
21
|
+
} from "./chunk-BKAUN5QH.js";
|
|
22
|
+
import {
|
|
23
|
+
getLetraDir2 as getLetraDir
|
|
24
|
+
} from "./chunk-6HSUVCTR.js";
|
|
25
|
+
|
|
26
|
+
// src/domain-operations/service.ts
|
|
27
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
28
|
+
import { join, resolve } from "path";
|
|
29
|
+
function audit(root, action, direction, input) {
|
|
30
|
+
return logEntry(root, action, input.reason, {
|
|
31
|
+
itemId: input.itemId,
|
|
32
|
+
acId: input.acId,
|
|
33
|
+
details: {
|
|
34
|
+
adapter: "codex",
|
|
35
|
+
by: input.actor ?? "agent:codex",
|
|
36
|
+
revision: direction.revision,
|
|
37
|
+
outcome: input.outcome,
|
|
38
|
+
reasonCode: input.reasonCode,
|
|
39
|
+
...input.details
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function result(direction, entryId, outcome, reasonCode, reason, nextDirection = direction, extra = {}) {
|
|
44
|
+
return {
|
|
45
|
+
outcome,
|
|
46
|
+
auditId: entryId,
|
|
47
|
+
beforeRevision: direction.revision,
|
|
48
|
+
afterRevision: nextDirection.revision,
|
|
49
|
+
reasonCode,
|
|
50
|
+
reason,
|
|
51
|
+
nextDirection,
|
|
52
|
+
...extra
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function rejected(root, direction, reasonCode, reason, context, subject) {
|
|
56
|
+
const entry = audit(root, "agent_operation_rejected", direction, {
|
|
57
|
+
outcome: "rejected",
|
|
58
|
+
reasonCode,
|
|
59
|
+
reason,
|
|
60
|
+
actor: context.actor,
|
|
61
|
+
itemId: subject.itemId,
|
|
62
|
+
acId: subject.acId,
|
|
63
|
+
details: { operation: subject.operation }
|
|
64
|
+
});
|
|
65
|
+
return result(direction, entry.id, "rejected", reasonCode, reason);
|
|
66
|
+
}
|
|
67
|
+
function checkRevision(root, direction, context, subject) {
|
|
68
|
+
if (context.expectedRevision === direction.revision) return null;
|
|
69
|
+
return rejected(
|
|
70
|
+
root,
|
|
71
|
+
direction,
|
|
72
|
+
"DIRECTION_STALE",
|
|
73
|
+
"A dire\xE7\xE3o mudou desde a \xFAltima consulta. Consulte get_direction e tente novamente.",
|
|
74
|
+
context,
|
|
75
|
+
subject
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
function normalizeAcId(value) {
|
|
79
|
+
const match = value.trim().match(/^AC[\s-]?(\d+(?:\.\d+)*)$/i);
|
|
80
|
+
return match ? `AC${match[1]}` : value.trim().toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
function markPendingAc(content, acId) {
|
|
83
|
+
const lines = content.split("\n");
|
|
84
|
+
const expected = normalizeAcId(acId);
|
|
85
|
+
const index = lines.findIndex((line) => {
|
|
86
|
+
if (!/^\s*-\s*\[ \]\s*\*\*/.test(line)) return false;
|
|
87
|
+
const label = line.match(/\*\*([^*]+)\*\*/)?.[1] ?? "";
|
|
88
|
+
const id = label.match(/\bAC[\s-]?(\d+(?:\.\d+)*)\b/i);
|
|
89
|
+
return id ? `AC${id[1]}` === expected : false;
|
|
90
|
+
});
|
|
91
|
+
if (index < 0) return null;
|
|
92
|
+
lines[index] = lines[index].replace(/\[ \]/, "[x]");
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|
|
95
|
+
async function runValidationOperation(root, context) {
|
|
96
|
+
const workspaceRoot = createWorkspaceBoundary(resolve(root)).root;
|
|
97
|
+
const before = resolveAgentDirection(workspaceRoot);
|
|
98
|
+
const stale = checkRevision(workspaceRoot, before, context, { operation: "validate" });
|
|
99
|
+
if (stale) return stale;
|
|
100
|
+
const validation = await validate(workspaceRoot, {
|
|
101
|
+
format: "silent",
|
|
102
|
+
exit: false,
|
|
103
|
+
log: false
|
|
104
|
+
});
|
|
105
|
+
const after = resolveAgentDirection(workspaceRoot);
|
|
106
|
+
const entry = audit(workspaceRoot, "agent_validation_run", before, {
|
|
107
|
+
outcome: validation.failed === 0 ? "accepted" : "rejected",
|
|
108
|
+
reasonCode: validation.failed === 0 ? "VALIDATION_COMPLETED" : "VALIDATION_FAILED",
|
|
109
|
+
reason: context.reason,
|
|
110
|
+
actor: context.actor,
|
|
111
|
+
itemId: before.item?.id,
|
|
112
|
+
details: { validation }
|
|
113
|
+
});
|
|
114
|
+
return result(
|
|
115
|
+
before,
|
|
116
|
+
entry.id,
|
|
117
|
+
validation.failed === 0 ? "accepted" : "rejected",
|
|
118
|
+
validation.failed === 0 ? "VALIDATION_COMPLETED" : "VALIDATION_FAILED",
|
|
119
|
+
context.reason,
|
|
120
|
+
after,
|
|
121
|
+
{ validation }
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function completeAcOperation(root, input) {
|
|
125
|
+
const boundary = createWorkspaceBoundary(resolve(root));
|
|
126
|
+
const workspaceRoot = boundary.root;
|
|
127
|
+
const before = resolveAgentDirection(workspaceRoot);
|
|
128
|
+
const subject = { itemId: before.item?.id, acId: input.acId, operation: "complete_ac" };
|
|
129
|
+
const stale = checkRevision(workspaceRoot, before, input, subject);
|
|
130
|
+
if (stale) return stale;
|
|
131
|
+
const evidence = input.evidence.map((item) => item.trim()).filter(Boolean);
|
|
132
|
+
if (evidence.length === 0) {
|
|
133
|
+
return rejected(
|
|
134
|
+
workspaceRoot,
|
|
135
|
+
before,
|
|
136
|
+
"REGRESSION_EVIDENCE_REQUIRED",
|
|
137
|
+
"\xC9 obrigat\xF3ria ao menos uma evid\xEAncia verific\xE1vel de regress\xE3o.",
|
|
138
|
+
input,
|
|
139
|
+
subject
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const requestedAc = normalizeAcId(input.acId);
|
|
143
|
+
if (!before.pendingAC || normalizeAcId(before.pendingAC.id) !== requestedAc) {
|
|
144
|
+
return rejected(
|
|
145
|
+
workspaceRoot,
|
|
146
|
+
before,
|
|
147
|
+
"AC_NOT_CURRENT",
|
|
148
|
+
`O AC solicitado n\xE3o \xE9 o crit\xE9rio pendente vigente (${before.pendingAC?.id ?? "nenhum"}).`,
|
|
149
|
+
input,
|
|
150
|
+
subject
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const spec = before.item?.spec;
|
|
154
|
+
if (!spec || !/^[a-zA-Z0-9._-]+$/.test(spec)) {
|
|
155
|
+
return rejected(
|
|
156
|
+
workspaceRoot,
|
|
157
|
+
before,
|
|
158
|
+
"ACTIVE_SPEC_REQUIRED",
|
|
159
|
+
"O item vigente n\xE3o possui uma spec v\xE1lida vinculada.",
|
|
160
|
+
input,
|
|
161
|
+
subject
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
const specDir = join(getLetraDir(workspaceRoot), "specs", spec);
|
|
165
|
+
const specPath = boundary.assertPath(join(specDir, "spec.md"));
|
|
166
|
+
if (!existsSync(specPath)) {
|
|
167
|
+
return rejected(
|
|
168
|
+
workspaceRoot,
|
|
169
|
+
before,
|
|
170
|
+
"ACTIVE_SPEC_REQUIRED",
|
|
171
|
+
"A spec vigente n\xE3o foi encontrada no workspace.",
|
|
172
|
+
input,
|
|
173
|
+
subject
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const updatedSpec = markPendingAc(readFileSync(specPath, "utf-8"), requestedAc);
|
|
177
|
+
if (!updatedSpec) {
|
|
178
|
+
return rejected(
|
|
179
|
+
workspaceRoot,
|
|
180
|
+
before,
|
|
181
|
+
"AC_NOT_PENDING",
|
|
182
|
+
"O AC solicitado n\xE3o est\xE1 pendente na spec vigente.",
|
|
183
|
+
input,
|
|
184
|
+
subject
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
const acceptancePath = boundary.assertPath(join(specDir, "acceptance.md"));
|
|
188
|
+
const updatedAcceptance = existsSync(acceptancePath) ? markPendingAc(readFileSync(acceptancePath, "utf-8"), requestedAc) : null;
|
|
189
|
+
const specTmp = `${specPath}.tmp`;
|
|
190
|
+
writeFileSync(specTmp, updatedSpec, "utf-8");
|
|
191
|
+
renameSync(specTmp, specPath);
|
|
192
|
+
if (updatedAcceptance) {
|
|
193
|
+
const acceptanceTmp = `${acceptancePath}.tmp`;
|
|
194
|
+
writeFileSync(acceptanceTmp, updatedAcceptance, "utf-8");
|
|
195
|
+
renameSync(acceptanceTmp, acceptancePath);
|
|
196
|
+
}
|
|
197
|
+
const workflow = loadWorkflow(workspaceRoot);
|
|
198
|
+
if (workflow?.tools?.length) {
|
|
199
|
+
generateAdapters(workspaceRoot, workflow.tools, {
|
|
200
|
+
source: "flow-ac",
|
|
201
|
+
quiet: true,
|
|
202
|
+
confineWrites: true
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const after = resolveAgentDirection(workspaceRoot);
|
|
206
|
+
const entry = audit(workspaceRoot, "agent_ac_completion_requested", before, {
|
|
207
|
+
outcome: "accepted",
|
|
208
|
+
reasonCode: "AC_COMPLETED",
|
|
209
|
+
reason: input.reason,
|
|
210
|
+
actor: input.actor,
|
|
211
|
+
itemId: before.item?.id,
|
|
212
|
+
acId: requestedAc,
|
|
213
|
+
details: { spec, evidence, afterRevision: after.revision }
|
|
214
|
+
});
|
|
215
|
+
return result(before, entry.id, "accepted", "AC_COMPLETED", input.reason, after);
|
|
216
|
+
}
|
|
217
|
+
async function requestTransitionOperation(root, input) {
|
|
218
|
+
const workspaceRoot = createWorkspaceBoundary(resolve(root)).root;
|
|
219
|
+
const before = resolveAgentDirection(workspaceRoot);
|
|
220
|
+
const subject = { itemId: input.itemId, operation: "request_transition" };
|
|
221
|
+
const stale = checkRevision(workspaceRoot, before, input, subject);
|
|
222
|
+
if (stale) return stale;
|
|
223
|
+
if (!before.item || before.item.id !== input.itemId) {
|
|
224
|
+
return rejected(
|
|
225
|
+
workspaceRoot,
|
|
226
|
+
before,
|
|
227
|
+
"ITEM_NOT_CURRENT",
|
|
228
|
+
"A transi\xE7\xE3o somente pode ser solicitada para o item vigente.",
|
|
229
|
+
input,
|
|
230
|
+
subject
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (before.pendingAC) {
|
|
234
|
+
return rejected(
|
|
235
|
+
workspaceRoot,
|
|
236
|
+
before,
|
|
237
|
+
"PENDING_ACCEPTANCE_CRITERIA",
|
|
238
|
+
`O item ainda possui o crit\xE9rio pendente ${before.pendingAC.id}.`,
|
|
239
|
+
input,
|
|
240
|
+
subject
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
const workflow = loadWorkflow(workspaceRoot);
|
|
244
|
+
const item = workflow?.items.find((candidate) => candidate.id === input.itemId);
|
|
245
|
+
const target = workflow?.stages.find((stage) => stage.id === input.targetStageId);
|
|
246
|
+
if (!workflow || !item || !target) {
|
|
247
|
+
return rejected(
|
|
248
|
+
workspaceRoot,
|
|
249
|
+
before,
|
|
250
|
+
"INVALID_TRANSITION",
|
|
251
|
+
"O item ou est\xE1gio de destino n\xE3o existe no workflow vigente.",
|
|
252
|
+
input,
|
|
253
|
+
subject
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
if (item.stage === target.id) {
|
|
257
|
+
return rejected(
|
|
258
|
+
workspaceRoot,
|
|
259
|
+
before,
|
|
260
|
+
"INVALID_TRANSITION",
|
|
261
|
+
"O item j\xE1 est\xE1 no est\xE1gio solicitado.",
|
|
262
|
+
input,
|
|
263
|
+
subject
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
if (before.allowedStageIds.length > 0 && !before.allowedStageIds.includes(target.id)) {
|
|
267
|
+
return rejected(
|
|
268
|
+
workspaceRoot,
|
|
269
|
+
before,
|
|
270
|
+
"STAGE_NOT_ALLOWED",
|
|
271
|
+
"O papel vigente n\xE3o permite transi\xE7\xE3o para o est\xE1gio solicitado.",
|
|
272
|
+
input,
|
|
273
|
+
subject
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
const activeFlow = resolveActiveFlow(workspaceRoot).flow;
|
|
277
|
+
const sourceDefinition = activeFlow?.stages.find((stage) => stage.id === item.stage);
|
|
278
|
+
const targetDefinition = activeFlow?.stages.find((stage) => stage.id === target.id);
|
|
279
|
+
const blockingGate = [sourceDefinition?.gate, targetDefinition?.gate].find(
|
|
280
|
+
(gate) => gate?.blocking
|
|
281
|
+
);
|
|
282
|
+
if (blockingGate) {
|
|
283
|
+
const checker = new GateChecker(workspaceRoot);
|
|
284
|
+
const gateResult = checker.check(blockingGate.id, item);
|
|
285
|
+
if (blockingGate.type === "human") {
|
|
286
|
+
const gateHint = targetDefinition?.activity?.gate;
|
|
287
|
+
const reviewHint = targetDefinition?.activity?.review;
|
|
288
|
+
const enriched = {
|
|
289
|
+
...before,
|
|
290
|
+
allowedStageIds: targetDefinition ? [...new Set(targetDefinition.roles.flatMap((role) => role.allowedStages))] : before.allowedStageIds,
|
|
291
|
+
prohibitions: [...gateHint?.mustNotDo ?? reviewHint?.mustNotDo ?? []],
|
|
292
|
+
requiredEvidence: gateHint?.evidence ? [gateHint.evidence] : []
|
|
293
|
+
};
|
|
294
|
+
enriched.pendingAC = void 0;
|
|
295
|
+
const entry2 = audit(workspaceRoot, "agent_transition_requested", before, {
|
|
296
|
+
outcome: "approval-required",
|
|
297
|
+
reasonCode: "HUMAN_APPROVAL_REQUIRED",
|
|
298
|
+
reason: `O gate "${blockingGate.name}" exige decis\xE3o humana expl\xEDcita.`,
|
|
299
|
+
actor: input.actor,
|
|
300
|
+
itemId: item.id,
|
|
301
|
+
details: { from: item.stage, to: target.id, gateId: blockingGate.id }
|
|
302
|
+
});
|
|
303
|
+
return result(
|
|
304
|
+
before,
|
|
305
|
+
entry2.id,
|
|
306
|
+
"approval-required",
|
|
307
|
+
"HUMAN_APPROVAL_REQUIRED",
|
|
308
|
+
`O gate "${blockingGate.name}" exige decis\xE3o humana expl\xEDcita.`,
|
|
309
|
+
enriched
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
if (!gateResult.allowed) {
|
|
313
|
+
return rejected(
|
|
314
|
+
workspaceRoot,
|
|
315
|
+
before,
|
|
316
|
+
"BLOCKING_GATE",
|
|
317
|
+
gateResult.reason ?? `O gate "${blockingGate.name}" deve ser satisfeito antes da transi\xE7\xE3o.`,
|
|
318
|
+
input,
|
|
319
|
+
subject
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const from = item.stage;
|
|
324
|
+
item.stage = target.id;
|
|
325
|
+
workflow.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
326
|
+
const writeResult = await writeWorkflow(workspaceRoot, {
|
|
327
|
+
workflow,
|
|
328
|
+
source: "flow-move",
|
|
329
|
+
primaryItemId: item.id,
|
|
330
|
+
skipSitrep: true,
|
|
331
|
+
skipLog: true,
|
|
332
|
+
quiet: true,
|
|
333
|
+
confineAdapterWrites: true
|
|
334
|
+
});
|
|
335
|
+
if (!writeResult.ok) {
|
|
336
|
+
return rejected(
|
|
337
|
+
workspaceRoot,
|
|
338
|
+
before,
|
|
339
|
+
"TRANSITION_WRITE_FAILED",
|
|
340
|
+
writeResult.error ?? "A persist\xEAncia da transi\xE7\xE3o falhou.",
|
|
341
|
+
input,
|
|
342
|
+
subject
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
if (item.spec) writeFocusWithRecommendations(workspaceRoot, item.spec, item.id);
|
|
346
|
+
const after = resolveAgentDirection(workspaceRoot);
|
|
347
|
+
const entry = audit(workspaceRoot, "agent_transition_requested", before, {
|
|
348
|
+
outcome: "accepted",
|
|
349
|
+
reasonCode: "TRANSITION_COMPLETED",
|
|
350
|
+
reason: input.reason,
|
|
351
|
+
actor: input.actor,
|
|
352
|
+
itemId: item.id,
|
|
353
|
+
details: { from, to: target.id, afterRevision: after.revision }
|
|
354
|
+
});
|
|
355
|
+
return result(before, entry.id, "accepted", "TRANSITION_COMPLETED", input.reason, after);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export {
|
|
359
|
+
runValidationOperation,
|
|
360
|
+
completeAcOperation,
|
|
361
|
+
requestTransitionOperation
|
|
362
|
+
};
|