@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.
Files changed (98) hide show
  1. package/dist/chunk-6HSUVCTR.js +363 -0
  2. package/dist/chunk-BKAUN5QH.js +300 -0
  3. package/dist/chunk-DMOLJWWW.js +3321 -0
  4. package/dist/chunk-EDD55PWL.js +119 -0
  5. package/dist/chunk-H64RC3YS.js +254 -0
  6. package/dist/chunk-JMIC5NKB.js +235 -0
  7. package/dist/chunk-L6YKDTAQ.js +275 -0
  8. package/dist/chunk-MJ2QXNH6.js +130 -0
  9. package/dist/chunk-OIHMDOIN.js +1326 -0
  10. package/dist/chunk-PDX44BCA.js +11 -0
  11. package/dist/chunk-URUC6ZZP.js +4781 -0
  12. package/dist/client/assets/index-EyRsq1SH.css +1 -0
  13. package/dist/client/assets/index-WfKR7Xp6.js +232 -0
  14. package/dist/client/favicon.svg +16 -4
  15. package/dist/client/index.html +25 -20
  16. package/dist/fallback-MQLGS4KL.js +46 -0
  17. package/dist/flow-serve-G5MSSB3G.js +18 -0
  18. package/dist/focus-sync-3D3XWCTI.js +17 -0
  19. package/dist/generate-UPFERQMD.js +20 -0
  20. package/dist/harness/default/v0.1.0/flows/sdlc.yaml +179 -0
  21. package/dist/harness/default/v0.1.0/gates/all-acs-passing.yaml +8 -0
  22. package/dist/harness/default/v0.1.0/gates/has-spec-file.yaml +7 -0
  23. package/dist/harness/default/v0.1.0/gates/human-approved-code.yaml +8 -0
  24. package/dist/harness/default/v0.1.0/gates/human-approved-spec.yaml +8 -0
  25. package/dist/harness/default/v0.1.0/gates/security-clear.yaml +8 -0
  26. package/dist/harness/default/v0.1.0/policies/sdlc-default.json +20 -0
  27. package/dist/harness/default/v0.1.0/roles/analyst.yaml +9 -0
  28. package/dist/harness/default/v0.1.0/roles/builder.yaml +9 -0
  29. package/dist/harness/default/v0.1.0/roles/pr-bot.yaml +8 -0
  30. package/dist/harness/default/v0.1.0/roles/reviewer.yaml +10 -0
  31. package/dist/harness/default/v0.1.0/roles/security.yaml +8 -0
  32. package/dist/harness/default/v0.1.1/flows/flow-main.yaml +61 -0
  33. package/dist/harness/default/v0.1.1/flows/sdlc.yaml +179 -0
  34. package/dist/harness/default/v0.1.1/gates/all-acs-passing.yaml +8 -0
  35. package/dist/harness/default/v0.1.1/gates/has-spec-file.yaml +7 -0
  36. package/dist/harness/default/v0.1.1/gates/human-approved-code.yaml +8 -0
  37. package/dist/harness/default/v0.1.1/gates/human-approved-spec.yaml +8 -0
  38. package/dist/harness/default/v0.1.1/gates/security-clear.yaml +8 -0
  39. package/dist/harness/default/v0.1.1/policies/sdlc-default.json +20 -0
  40. package/dist/harness/default/v0.1.1/roles/analyst.yaml +9 -0
  41. package/dist/harness/default/v0.1.1/roles/builder.yaml +9 -0
  42. package/dist/harness/default/v0.1.1/roles/pr-bot.yaml +8 -0
  43. package/dist/harness/default/v0.1.1/roles/reviewer.yaml +10 -0
  44. package/dist/harness/default/v0.1.1/roles/security.yaml +8 -0
  45. package/dist/harness/default/v0.1.2/flows/flow-main.yaml +86 -0
  46. package/dist/harness/default/v0.1.2/flows/sdlc.yaml +179 -0
  47. package/dist/harness/default/v0.1.2/gates/all-acs-passing.yaml +8 -0
  48. package/dist/harness/default/v0.1.2/gates/has-spec-file.yaml +7 -0
  49. package/dist/harness/default/v0.1.2/gates/human-approved-code.yaml +8 -0
  50. package/dist/harness/default/v0.1.2/gates/human-approved-spec.yaml +8 -0
  51. package/dist/harness/default/v0.1.2/gates/security-clear.yaml +8 -0
  52. package/dist/harness/default/v0.1.2/policies/sdlc-default.json +20 -0
  53. package/dist/harness/default/v0.1.2/roles/analyst.yaml +9 -0
  54. package/dist/harness/default/v0.1.2/roles/builder.yaml +9 -0
  55. package/dist/harness/default/v0.1.2/roles/pr-bot.yaml +8 -0
  56. package/dist/harness/default/v0.1.2/roles/reviewer.yaml +10 -0
  57. package/dist/harness/default/v0.1.2/roles/security.yaml +8 -0
  58. package/dist/harness/default/v0.1.3/flows/flow-main.yaml +90 -0
  59. package/dist/harness/default/v0.1.3/flows/sdlc.yaml +179 -0
  60. package/dist/harness/default/v0.1.3/gates/all-acs-passing.yaml +8 -0
  61. package/dist/harness/default/v0.1.3/gates/has-spec-file.yaml +7 -0
  62. package/dist/harness/default/v0.1.3/gates/human-approved-code.yaml +9 -0
  63. package/dist/harness/default/v0.1.3/gates/human-approved-spec.yaml +9 -0
  64. package/dist/harness/default/v0.1.3/gates/security-clear.yaml +8 -0
  65. package/dist/harness/default/v0.1.3/policies/sdlc-default.json +20 -0
  66. package/dist/harness/default/v0.1.3/roles/analyst.yaml +9 -0
  67. package/dist/harness/default/v0.1.3/roles/builder.yaml +9 -0
  68. package/dist/harness/default/v0.1.3/roles/pr-bot.yaml +8 -0
  69. package/dist/harness/default/v0.1.3/roles/reviewer.yaml +10 -0
  70. package/dist/harness/default/v0.1.3/roles/security.yaml +8 -0
  71. package/dist/harness/default/v0.2.0/executors/registry.yaml +51 -0
  72. package/dist/harness/default/v0.2.0/flows/flow-main.yaml +249 -0
  73. package/dist/harness/default/v0.2.0/gates/code-reviewed.yaml +7 -0
  74. package/dist/harness/default/v0.2.0/gates/human-approved.yaml +10 -0
  75. package/dist/harness/default/v0.2.0/gates/security-clear.yaml +7 -0
  76. package/dist/harness/default/v0.2.0/gates/spec-approved.yaml +10 -0
  77. package/dist/harness/default/v0.2.0/policies/sdlc-default.json +20 -0
  78. package/dist/harness/default/v0.2.0/roles/analyst.yaml +16 -0
  79. package/dist/harness/default/v0.2.0/roles/implementer.yaml +17 -0
  80. package/dist/harness/default/v0.2.0/roles/reviewer.yaml +17 -0
  81. package/dist/harness/default/v0.2.0/roles/security.yaml +17 -0
  82. package/dist/health-record-YDVXEVLR.js +21 -0
  83. package/dist/index.js +1951 -2530
  84. package/dist/init-wizard-NODBBNKO.js +178 -0
  85. package/dist/push-VJRSQGUD.js +116 -0
  86. package/dist/registry-6VPIA3EG.js +18 -0
  87. package/dist/server-P6GKRWDX.js +423 -0
  88. package/dist/service-2JN2KI4D.js +29 -0
  89. package/dist/session-log-WTQ5JBEN.js +21 -0
  90. package/dist/sitrep-OKNZJICV.js +16 -0
  91. package/package.json +37 -28
  92. package/dist/chunk-56GTTLC4.js +0 -1322
  93. package/dist/chunk-QWT5M4XU.js +0 -643
  94. package/dist/client/assets/index-CuLfFw4K.js +0 -85
  95. package/dist/client/assets/index-iyLqZcWx.css +0 -1
  96. package/dist/generate-BF5R5GGA.js +0 -7
  97. package/dist/sitrep-SI6ZFIAM.js +0 -10
  98. package/tsup.config.ts +0 -11
@@ -0,0 +1,275 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ loadWorkflow
4
+ } from "./chunk-DMOLJWWW.js";
5
+ import {
6
+ logEntry
7
+ } from "./chunk-BKAUN5QH.js";
8
+ import {
9
+ getSummary,
10
+ loadHealthRecord
11
+ } from "./chunk-MJ2QXNH6.js";
12
+ import {
13
+ getLetraDir2 as getLetraDir,
14
+ resolveWorkspaceRoot
15
+ } from "./chunk-6HSUVCTR.js";
16
+
17
+ // src/commands/sitrep.ts
18
+ import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
19
+ import { join } from "path";
20
+ import chalk from "chalk";
21
+ import { Command } from "commander";
22
+ var START_MARKER = "<!-- sitrep:start -->";
23
+ var END_MARKER = "<!-- sitrep:end -->";
24
+ function getRecentDecisions(root, max) {
25
+ const dir = join(getLetraDir(root), "decisions");
26
+ if (!existsSync(dir)) return [];
27
+ try {
28
+ const files = readdirSync(dir).filter((f) => f.endsWith(".md")).map((f) => ({
29
+ name: f,
30
+ mtime: statSync(join(dir, f)).mtimeMs
31
+ })).sort((a, b) => b.mtime - a.mtime).slice(0, max);
32
+ return files.map((f) => ({
33
+ title: f.name.replace(/\.md$/, "").replace(/-/g, " "),
34
+ date: new Date(f.mtime).toLocaleDateString("pt-BR")
35
+ }));
36
+ } catch {
37
+ return [];
38
+ }
39
+ }
40
+ function countItemACs(root, specName) {
41
+ const specDir = join(getLetraDir(root), "specs", specName);
42
+ const acceptanceFile = join(specDir, "acceptance.md");
43
+ const specFile = join(specDir, "spec.md");
44
+ const countInText = (text) => {
45
+ const pending = (text.match(/-\s*\[ \]\s*\*\*(.+?)\*\*/g) || []).length;
46
+ const done = (text.match(/-\s*\[[xX]\]\s*\*\*(.+?)\*\*/g) || []).length;
47
+ return { pending, total: pending + done };
48
+ };
49
+ if (existsSync(acceptanceFile)) {
50
+ return countInText(readFileSync(acceptanceFile, "utf-8"));
51
+ }
52
+ if (existsSync(specFile)) {
53
+ const content = readFileSync(specFile, "utf-8");
54
+ const match = content.match(/## Acceptance Criteria\s+([\s\S]*?)(?=\n## |\n*$)/);
55
+ return match ? countInText(match[1]) : { pending: 0, total: 0 };
56
+ }
57
+ return { pending: 0, total: 0 };
58
+ }
59
+ function findCurrentItem(workflow) {
60
+ const activeStages = workflow.stages.filter(
61
+ (s) => s.zone === "doing" || !s.zone && s.order > 0 && s.order < workflow.stages.length - 1
62
+ ).map((s) => s.id);
63
+ const stageSet = new Set(activeStages);
64
+ if (stageSet.size === 0) {
65
+ const mid = Math.floor(workflow.stages.length / 2);
66
+ const stage = workflow.stages[mid];
67
+ if (stage) stageSet.add(stage.id);
68
+ }
69
+ const items = workflow.items.filter((i) => stageSet.has(i.stage));
70
+ if (items.length === 0) return null;
71
+ return items.reduce((a, b) => new Date(a.createdAt) > new Date(b.createdAt) ? a : b);
72
+ }
73
+ function getStageName(stageId, workflow) {
74
+ if (!workflow) return stageId;
75
+ return workflow.stages?.find((s) => s.id === stageId)?.name ?? stageId;
76
+ }
77
+ function extractSection(content, heading) {
78
+ const esc = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
79
+ const regex = new RegExp(`## ${esc}\\s+([\\s\\S]*?)(?=\\n## |\\n*$)`);
80
+ const match = content.match(regex);
81
+ return match ? match[1].trim() : null;
82
+ }
83
+ function buildSitrepBlock(data) {
84
+ const lines = [];
85
+ if (data.currentItem) {
86
+ lines.push(`**Est\xE1gio**: ${getStageName(data.currentItem.stage, data.workflow)}`);
87
+ const item = data.currentItem;
88
+ let itemLine = `**Item atual**: ${item.id} \u2014 ${item.description}`;
89
+ if (item.spec) itemLine += ` (spec: ${item.spec})`;
90
+ lines.push(itemLine);
91
+ if (data.acCounts) {
92
+ const { pending, total } = data.acCounts;
93
+ const done = total - pending;
94
+ lines.push(`**ACs**: ${pending}/${total} pendentes | ${done} feito(s)`);
95
+ }
96
+ } else if (data.workflow) {
97
+ lines.push("**Est\xE1gio**: sem item ativo");
98
+ } else {
99
+ lines.push("**Est\xE1gio**: sem workflow definido");
100
+ }
101
+ const s = data.alertSummary;
102
+ const alertParts = [];
103
+ if (s.novo > 0) alertParts.push(`${s.novo} novo(s)`);
104
+ if (s.ciente > 0) alertParts.push(`${s.ciente} em acompanhamento`);
105
+ if (s.resolvido > 0) alertParts.push(`${s.resolvido} resolvido(s)`);
106
+ lines.push(`**Alertas**: ${alertParts.length > 0 ? alertParts.join(" \xB7 ") : "0 alertas"}`);
107
+ if (s.alta > 0) {
108
+ lines.push(`\u26A0 ${s.alta} alerta(s) de severidade alta`);
109
+ }
110
+ if (data.decisions.length > 0) {
111
+ const decStr = data.decisions.map((d) => `"${d.title}" (${d.date})`).join(", ");
112
+ lines.push(`**\xDAltimas decis\xF5es**: ${decStr}`);
113
+ }
114
+ return lines.join("\n");
115
+ }
116
+ function rewriteContextFile(content, dynamicBlock, stack, restricoes, porques) {
117
+ const headerMatch = content.match(/^# Context[\s\S]*?(?=\n## )/);
118
+ const header = headerMatch ? headerMatch[0].trim() : "# Context";
119
+ const intent = extractSection(content, "Intent");
120
+ const dominio = extractSection(content, "Dom\xEDnio");
121
+ const ignoreIdx = content.indexOf("<!-- sitrep:ignore -->");
122
+ let ignoredContent = "";
123
+ if (ignoreIdx !== -1) {
124
+ ignoredContent = content.slice(ignoreIdx);
125
+ }
126
+ const sections = [header];
127
+ if (intent) {
128
+ sections.push(`## Intent
129
+
130
+ ${intent}`);
131
+ }
132
+ if (dominio) {
133
+ sections.push(`## Dom\xEDnio
134
+
135
+ ${dominio}`);
136
+ }
137
+ sections.push(`${START_MARKER}
138
+ ${dynamicBlock}
139
+ ${END_MARKER}`);
140
+ if (stack) {
141
+ sections.push(`## Stack
142
+
143
+ ${stack}`);
144
+ }
145
+ if (restricoes) {
146
+ sections.push(`## Restri\xE7\xF5es Reais
147
+
148
+ ${restricoes}`);
149
+ }
150
+ if (porques) {
151
+ sections.push(`## Porqu\xEAs
152
+
153
+ ${porques}`);
154
+ }
155
+ let result = `${sections.join("\n\n")}
156
+ `;
157
+ if (ignoredContent) {
158
+ result += `
159
+ ${ignoredContent}
160
+ `;
161
+ }
162
+ return result;
163
+ }
164
+ function showDiff(original, modified) {
165
+ const origLines = original.split("\n");
166
+ const modLines = modified.split("\n");
167
+ const maxLen = Math.max(origLines.length, modLines.length);
168
+ for (let i = 0; i < maxLen; i++) {
169
+ const o = origLines[i] ?? "";
170
+ const m = modLines[i] ?? "";
171
+ if (o !== m) {
172
+ if (i < origLines.length) {
173
+ console.log(chalk.red(`- ${o}`));
174
+ }
175
+ if (i < modLines.length) {
176
+ console.log(chalk.green(`+ ${m}`));
177
+ }
178
+ }
179
+ }
180
+ }
181
+ function logChanges(original, modified) {
182
+ if (original === modified) {
183
+ console.log(chalk.gray(" Nenhuma altera\xE7\xE3o necess\xE1ria."));
184
+ return;
185
+ }
186
+ const sections = [];
187
+ if (original.match(/^> Updated:.*$/m) !== modified.match(/^> Updated:.*$/m)) {
188
+ sections.push("Updated");
189
+ }
190
+ const origHasSitrep = original.includes(START_MARKER);
191
+ const modHasSitrep = modified.includes(START_MARKER);
192
+ if (origHasSitrep !== modHasSitrep) {
193
+ sections.push(modHasSitrep ? "Bloco sitrep (inserido)" : "Bloco sitrep (removido)");
194
+ } else if (origHasSitrep) {
195
+ sections.push("Bloco sitrep (atualizado)");
196
+ }
197
+ if (sections.length > 0) {
198
+ console.log(chalk.gray(` Se\xE7\xF5es alteradas: ${sections.join(", ")}`));
199
+ } else {
200
+ console.log(chalk.gray(" Apenas data atualizada."));
201
+ }
202
+ }
203
+ async function sitrep(rootPath, options) {
204
+ const contextFile = join(getLetraDir(rootPath), "context.md");
205
+ if (!existsSync(contextFile)) {
206
+ if (!options?.quiet) console.log(chalk.yellow("Aviso: .letra/context.md n\xE3o encontrado"));
207
+ return;
208
+ }
209
+ const workflow = loadWorkflow(rootPath);
210
+ const healthRecord = loadHealthRecord(rootPath);
211
+ const alertSummary = getSummary(healthRecord);
212
+ let currentItem = null;
213
+ let acCounts = null;
214
+ if (workflow) {
215
+ currentItem = findCurrentItem(workflow);
216
+ if (currentItem?.spec) {
217
+ acCounts = countItemACs(rootPath, currentItem.spec);
218
+ }
219
+ }
220
+ const decisions = getRecentDecisions(rootPath, 4);
221
+ const data = {
222
+ stage: currentItem?.stage ?? "sem item ativo",
223
+ currentItem,
224
+ acCounts,
225
+ alertSummary,
226
+ decisions,
227
+ workflow
228
+ };
229
+ const dynamicBlock = buildSitrepBlock(data);
230
+ const originalContent = readFileSync(contextFile, "utf-8");
231
+ const stack = extractSection(originalContent, "Stack");
232
+ const restricoes = extractSection(originalContent, "Restri\xE7\xF5es Reais");
233
+ const porques = extractSection(originalContent, "Porqu\xEAs");
234
+ const withUpdated = originalContent.replace(
235
+ /^(> Updated:).*$/m,
236
+ `$1 ${(/* @__PURE__ */ new Date()).toISOString()}`
237
+ );
238
+ const newContent = rewriteContextFile(withUpdated, dynamicBlock, stack, restricoes, porques);
239
+ if (options?.dryRun) {
240
+ console.log(chalk.bold("\n\u{1F4CB} Simula\xE7\xE3o de atualiza\xE7\xE3o \u2014 dry-run\n"));
241
+ showDiff(originalContent, newContent);
242
+ return;
243
+ }
244
+ writeFileSync(contextFile, newContent, "utf-8");
245
+ if (!options?.quiet) {
246
+ console.log(chalk.green("\u2713 Situa\xE7\xE3o atualizada em .letra/context.md"));
247
+ logChanges(originalContent, newContent);
248
+ }
249
+ if (!options?.skipLog) {
250
+ logEntry(rootPath, "sitrep", "context.md atualizado com estado do workspace", {
251
+ details: {
252
+ hasItem: !!currentItem,
253
+ itemId: currentItem?.id,
254
+ alertsNovo: alertSummary.novo
255
+ }
256
+ });
257
+ }
258
+ }
259
+ function sitrep_default() {
260
+ const cmd = new Command("sitrep").description(
261
+ "Atualizar .letra/context.md com estado real do workspace"
262
+ );
263
+ cmd.option("--dry-run", "Exibir diff sem modificar o arquivo").action(
264
+ async (options) => {
265
+ const resolution = resolveWorkspaceRoot(process.cwd());
266
+ await sitrep(resolution.workspaceRoot, options);
267
+ }
268
+ );
269
+ return cmd;
270
+ }
271
+
272
+ export {
273
+ sitrep,
274
+ sitrep_default
275
+ };
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getLetraDir2 as getLetraDir
4
+ } from "./chunk-6HSUVCTR.js";
5
+
6
+ // src/health-record.ts
7
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
8
+ import { join } from "path";
9
+ var RECORD_FILE = "health-record.json";
10
+ var SCHEMA_VERSION = 1;
11
+ var CLEANUP_DAYS = 90;
12
+ function recordPath(root) {
13
+ return join(getLetraDir(root), RECORD_FILE);
14
+ }
15
+ function loadHealthRecord(root) {
16
+ const file = recordPath(root);
17
+ if (!existsSync(file)) {
18
+ return { schemaVersion: SCHEMA_VERSION, lastScanAt: (/* @__PURE__ */ new Date()).toISOString(), entries: [] };
19
+ }
20
+ try {
21
+ const raw = readFileSync(file, "utf-8");
22
+ const record = JSON.parse(raw);
23
+ if (!record.entries) record.entries = [];
24
+ return record;
25
+ } catch {
26
+ return { schemaVersion: SCHEMA_VERSION, lastScanAt: (/* @__PURE__ */ new Date()).toISOString(), entries: [] };
27
+ }
28
+ }
29
+ function saveHealthRecord(root, record) {
30
+ const dir = getLetraDir(root);
31
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
32
+ record.lastScanAt = (/* @__PURE__ */ new Date()).toISOString();
33
+ writeFileSync(recordPath(root), JSON.stringify(record, null, 2), "utf-8");
34
+ }
35
+ function hashResult(result) {
36
+ const key = `${result.detector}:${result.title}`;
37
+ let hash = 0;
38
+ for (let i = 0; i < key.length; i++) {
39
+ const char = key.charCodeAt(i);
40
+ hash = (hash << 5) - hash + char;
41
+ hash |= 0;
42
+ }
43
+ return `hr-${Math.abs(hash).toString(16).padStart(6, "0")}`;
44
+ }
45
+ function severityFromType(type) {
46
+ if (type === "error") return "alta";
47
+ if (type === "warning") return "media";
48
+ return "baixa";
49
+ }
50
+ function mergeScanResults(record, results) {
51
+ const now = (/* @__PURE__ */ new Date()).toISOString();
52
+ for (const result of results) {
53
+ const id = hashResult(result);
54
+ const existing = record.entries.find((e) => e.id === id);
55
+ if (!existing) {
56
+ record.entries.push({
57
+ id,
58
+ type: result.type,
59
+ title: result.title,
60
+ status: "novo",
61
+ severity: severityFromType(result.type),
62
+ source: result.detector,
63
+ detectedAt: now,
64
+ resolvedAt: null,
65
+ dismissedAt: null,
66
+ dismissReason: null,
67
+ acknowledgedAt: null
68
+ });
69
+ } else if (existing.status === "resolvido") {
70
+ existing.status = "novo";
71
+ existing.detectedAt = now;
72
+ existing.resolvedAt = null;
73
+ }
74
+ }
75
+ for (const entry of record.entries) {
76
+ if (entry.status === "descartado") continue;
77
+ const stillPresent = results.some((r) => hashResult(r) === entry.id);
78
+ if (!stillPresent && entry.status !== "resolvido") {
79
+ entry.status = "resolvido";
80
+ entry.resolvedAt = now;
81
+ }
82
+ }
83
+ record.entries = cleanupOldEntries(record.entries);
84
+ return record;
85
+ }
86
+ function cleanupOldEntries(entries) {
87
+ const cutoff = Date.now() - CLEANUP_DAYS * 24 * 60 * 60 * 1e3;
88
+ return entries.filter((e) => {
89
+ if (e.status !== "resolvido" && e.status !== "descartado") return true;
90
+ const refDate = e.resolvedAt ?? e.dismissedAt ?? e.detectedAt;
91
+ return new Date(refDate).getTime() > cutoff;
92
+ });
93
+ }
94
+ function ackEntry(record, id) {
95
+ const entry = record.entries.find((e) => e.id === id);
96
+ if (!entry) return false;
97
+ entry.status = "ciente";
98
+ entry.acknowledgedAt = (/* @__PURE__ */ new Date()).toISOString();
99
+ return true;
100
+ }
101
+ function dismissEntry(record, id, reason) {
102
+ const entry = record.entries.find((e) => e.id === id);
103
+ if (!entry) return false;
104
+ entry.status = "descartado";
105
+ entry.dismissedAt = (/* @__PURE__ */ new Date()).toISOString();
106
+ entry.dismissReason = reason ?? null;
107
+ return true;
108
+ }
109
+ function getActiveEntries(record) {
110
+ return record.entries.filter((e) => e.status === "novo" || e.status === "ciente");
111
+ }
112
+ function getSummary(record) {
113
+ return {
114
+ novo: record.entries.filter((e) => e.status === "novo").length,
115
+ ciente: record.entries.filter((e) => e.status === "ciente").length,
116
+ descartado: record.entries.filter((e) => e.status === "descartado").length,
117
+ resolvido: record.entries.filter((e) => e.status === "resolvido").length,
118
+ alta: record.entries.filter((e) => e.status === "novo" && e.severity === "alta").length
119
+ };
120
+ }
121
+
122
+ export {
123
+ loadHealthRecord,
124
+ saveHealthRecord,
125
+ mergeScanResults,
126
+ ackEntry,
127
+ dismissEntry,
128
+ getActiveEntries,
129
+ getSummary
130
+ };