@facet-tools/ui 0.0.0-stage → 0.1.0-rc.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.
Files changed (82) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +6 -0
  3. package/README.md +24 -2
  4. package/THIRD_PARTY.md +673 -0
  5. package/dist/NOTICE +6 -0
  6. package/dist/THIRD_PARTY.md +15 -0
  7. package/dist/atlas-BsWEDCxa.d.cts +4861 -0
  8. package/dist/atlas-BsWEDCxa.d.ts +4861 -0
  9. package/dist/chunk-7FW4IMVY.cjs +2013 -0
  10. package/dist/chunk-7FW4IMVY.cjs.map +1 -0
  11. package/dist/chunk-7SLSRYM3.cjs +6324 -0
  12. package/dist/chunk-7SLSRYM3.cjs.map +1 -0
  13. package/dist/chunk-A4BERWE6.js +19973 -0
  14. package/dist/chunk-A4BERWE6.js.map +1 -0
  15. package/dist/chunk-EZP2CCQY.js +6209 -0
  16. package/dist/chunk-EZP2CCQY.js.map +1 -0
  17. package/dist/chunk-FR6DIALV.js +511 -0
  18. package/dist/chunk-FR6DIALV.js.map +1 -0
  19. package/dist/chunk-GDFKDECN.cjs +1788 -0
  20. package/dist/chunk-GDFKDECN.cjs.map +1 -0
  21. package/dist/chunk-K2OVG2BC.cjs +20035 -0
  22. package/dist/chunk-K2OVG2BC.cjs.map +1 -0
  23. package/dist/chunk-LOI5RY3Y.js +1754 -0
  24. package/dist/chunk-LOI5RY3Y.js.map +1 -0
  25. package/dist/chunk-SWCO2XQL.js +1968 -0
  26. package/dist/chunk-SWCO2XQL.js.map +1 -0
  27. package/dist/chunk-WAG2ZZJH.cjs +514 -0
  28. package/dist/chunk-WAG2ZZJH.cjs.map +1 -0
  29. package/dist/classic.cjs +467 -0
  30. package/dist/classic.cjs.map +1 -0
  31. package/dist/classic.css +635 -0
  32. package/dist/classic.d.cts +4 -0
  33. package/dist/classic.d.ts +4 -0
  34. package/dist/classic.js +6 -0
  35. package/dist/classic.js.map +1 -0
  36. package/dist/companion-BUs0yNdX.d.cts +110 -0
  37. package/dist/companion-DOQ435G6.d.ts +110 -0
  38. package/dist/core/fixtures.cjs +268 -0
  39. package/dist/core/fixtures.cjs.map +1 -0
  40. package/dist/core/fixtures.d.cts +11 -0
  41. package/dist/core/fixtures.d.ts +11 -0
  42. package/dist/core/fixtures.js +261 -0
  43. package/dist/core/fixtures.js.map +1 -0
  44. package/dist/core.cjs +310 -0
  45. package/dist/core.cjs.map +1 -0
  46. package/dist/core.d.cts +268 -0
  47. package/dist/core.d.ts +268 -0
  48. package/dist/core.js +5 -0
  49. package/dist/core.js.map +1 -0
  50. package/dist/elements.cjs +616 -0
  51. package/dist/elements.cjs.map +1 -0
  52. package/dist/elements.d.cts +20 -0
  53. package/dist/elements.d.ts +20 -0
  54. package/dist/elements.js +612 -0
  55. package/dist/elements.js.map +1 -0
  56. package/dist/facet/atlas.cjs +25 -0
  57. package/dist/facet/atlas.cjs.map +1 -0
  58. package/dist/facet/atlas.d.cts +2 -0
  59. package/dist/facet/atlas.d.ts +2 -0
  60. package/dist/facet/atlas.js +4 -0
  61. package/dist/facet/atlas.js.map +1 -0
  62. package/dist/facet-ui.standalone.js +104 -0
  63. package/dist/facet.cjs +253 -0
  64. package/dist/facet.cjs.map +1 -0
  65. package/dist/facet.css +10649 -0
  66. package/dist/facet.d.cts +91 -0
  67. package/dist/facet.d.ts +91 -0
  68. package/dist/facet.js +4 -0
  69. package/dist/facet.js.map +1 -0
  70. package/dist/index.cjs +467 -0
  71. package/dist/index.cjs.map +1 -0
  72. package/dist/index.d.cts +1584 -0
  73. package/dist/index.d.ts +1584 -0
  74. package/dist/index.js +6 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/licenses/react-dom@19.2.8/LICENSE +21 -0
  77. package/dist/licenses/react@19.2.8/LICENSE +21 -0
  78. package/dist/licenses/scheduler@0.27.0/LICENSE +21 -0
  79. package/dist/tokens.css +635 -0
  80. package/dist/types-DkZBrIXE.d.cts +527 -0
  81. package/dist/types-DkZBrIXE.d.ts +527 -0
  82. package/package.json +169 -4
@@ -0,0 +1,1968 @@
1
+ import { remainingText, pct, formatNumber, GHERKIN_LABEL, coverage } from './chunk-LOI5RY3Y.js';
2
+ import { labelText } from './chunk-FR6DIALV.js';
3
+
4
+ // src/core/markdown.ts
5
+ var FENCE = /^\s*(`{3,}|~{3,})\s*([A-Za-z0-9+#.-]*)\s*$/;
6
+ var HEADING = /^(#{1,6})\s+(.*)$/;
7
+ var BULLET = /^\s{0,3}[-*+]\s+(.*)$/;
8
+ var ORDERED = /^\s{0,3}\d+[.)]\s+(.*)$/;
9
+ var QUOTE = /^\s{0,3}>\s?(.*)$/;
10
+ var RULE = /^\s{0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/;
11
+ function parseMarkdown(text) {
12
+ const lines = String(text ?? "").replace(/\r\n?/g, "\n").split("\n");
13
+ const blocks = [];
14
+ let i = 0;
15
+ while (i < lines.length) {
16
+ const line = lines[i];
17
+ if (!line.trim()) {
18
+ i++;
19
+ continue;
20
+ }
21
+ const fence = FENCE.exec(line);
22
+ if (fence) {
23
+ const marker = fence[1][0];
24
+ const body = [];
25
+ i++;
26
+ while (i < lines.length && !isClosing(lines[i], marker)) {
27
+ body.push(lines[i]);
28
+ i++;
29
+ }
30
+ i++;
31
+ blocks.push({ kind: "code", language: fence[2] ?? "", text: body.join("\n") });
32
+ continue;
33
+ }
34
+ if (RULE.test(line)) {
35
+ blocks.push({ kind: "rule" });
36
+ i++;
37
+ continue;
38
+ }
39
+ const heading = HEADING.exec(line);
40
+ if (heading) {
41
+ blocks.push({
42
+ kind: "heading",
43
+ level: heading[1].length,
44
+ inline: parseInline(heading[2].trim())
45
+ });
46
+ i++;
47
+ continue;
48
+ }
49
+ if (QUOTE.test(line)) {
50
+ const body = [];
51
+ while (i < lines.length && QUOTE.test(lines[i])) {
52
+ body.push(QUOTE.exec(lines[i])[1]);
53
+ i++;
54
+ }
55
+ blocks.push({ kind: "quote", inline: parseInline(body.join(" ").trim()) });
56
+ continue;
57
+ }
58
+ if (BULLET.test(line) || ORDERED.test(line)) {
59
+ const ordered = !BULLET.test(line);
60
+ const items = [];
61
+ while (i < lines.length) {
62
+ const item = ordered ? ORDERED.exec(lines[i]) : BULLET.exec(lines[i]);
63
+ if (!item) break;
64
+ const parts = [item[1]];
65
+ i++;
66
+ while (i < lines.length && lines[i].trim() && !isBlockStart(lines[i])) {
67
+ parts.push(lines[i].trim());
68
+ i++;
69
+ }
70
+ items.push(parseInline(parts.join(" ")));
71
+ }
72
+ blocks.push({ kind: "list", ordered, items });
73
+ continue;
74
+ }
75
+ const paragraph = [];
76
+ while (i < lines.length && lines[i].trim() && !isBlockStart(lines[i])) {
77
+ paragraph.push(lines[i].trim());
78
+ i++;
79
+ }
80
+ if (paragraph.length)
81
+ blocks.push({ kind: "paragraph", inline: parseInline(paragraph.join(" ")) });
82
+ else i++;
83
+ }
84
+ return blocks;
85
+ }
86
+ function isClosing(line, marker) {
87
+ const fence = FENCE.exec(line);
88
+ return Boolean(fence) && fence[1][0] === marker;
89
+ }
90
+ function isBlockStart(line) {
91
+ return FENCE.test(line) || HEADING.test(line) || BULLET.test(line) || ORDERED.test(line) || QUOTE.test(line) || RULE.test(line);
92
+ }
93
+ function parseInline(text) {
94
+ const out = [];
95
+ let rest = String(text ?? "");
96
+ const pattern = /(`+)([^`]*?)\1|\[([^\]]+)\]\(([^)\s]+)\)|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*]+)\*|(?<![A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/;
97
+ for (; ; ) {
98
+ const match = pattern.exec(rest);
99
+ if (!match) break;
100
+ if (match.index > 0) out.push({ kind: "text", text: rest.slice(0, match.index) });
101
+ if (match[1] !== void 0) out.push({ kind: "code", text: match[2] });
102
+ else if (match[3] !== void 0) out.push({ kind: "link", text: match[3], href: match[4] });
103
+ else if (match[5] !== void 0) out.push({ kind: "strong", text: match[5] });
104
+ else if (match[6] !== void 0) out.push({ kind: "strong", text: match[6] });
105
+ else if (match[7] !== void 0) out.push({ kind: "em", text: match[7] });
106
+ else if (match[8] !== void 0) out.push({ kind: "em", text: match[8] });
107
+ rest = rest.slice(match.index + match[0].length);
108
+ }
109
+ if (rest) out.push({ kind: "text", text: rest });
110
+ return out.length ? out : [{ kind: "text", text: "" }];
111
+ }
112
+ function isSafeHref(href) {
113
+ return /^https?:\/\//i.test(String(href ?? "").trim());
114
+ }
115
+
116
+ // src/core/codeCoverage.ts
117
+ function topDirOf(path) {
118
+ const i = path.indexOf("/");
119
+ return i === -1 ? "." : path.slice(0, i);
120
+ }
121
+ function codeCoverageOf(model) {
122
+ const { anchoredFiles, unanchoredFiles } = model.scan;
123
+ if (!Array.isArray(anchoredFiles) || !Array.isArray(unanchoredFiles)) return null;
124
+ const anchorCountByPath = {};
125
+ model.anchorPairs.forEach((anchor) => {
126
+ anchorCountByPath[anchor.path] = (anchorCountByPath[anchor.path] ?? 0) + 1;
127
+ });
128
+ const dirs = /* @__PURE__ */ new Map();
129
+ const dirOf = (path) => {
130
+ const key = topDirOf(path);
131
+ let entry = dirs.get(key);
132
+ if (!entry) {
133
+ entry = {
134
+ dir: key,
135
+ filesTotal: 0,
136
+ filesAnchored: 0,
137
+ locTotal: 0,
138
+ locAnchored: 0,
139
+ unanchored: [],
140
+ anchored: []
141
+ };
142
+ dirs.set(key, entry);
143
+ }
144
+ return entry;
145
+ };
146
+ anchoredFiles.forEach((file) => {
147
+ const entry = dirOf(file.path);
148
+ entry.filesTotal += 1;
149
+ entry.filesAnchored += 1;
150
+ entry.locTotal += file.loc;
151
+ entry.locAnchored += file.loc;
152
+ const anchors = anchorCountByPath[file.path] ?? 0;
153
+ entry.anchored.push({
154
+ ...file,
155
+ anchors,
156
+ locPerAnchor: anchors > 0 ? file.loc / anchors : null
157
+ });
158
+ });
159
+ unanchoredFiles.forEach((file) => {
160
+ const entry = dirOf(file.path);
161
+ entry.filesTotal += 1;
162
+ entry.locTotal += file.loc;
163
+ entry.unanchored.push(file);
164
+ });
165
+ const byPath = (a, b) => a.path.localeCompare(b.path);
166
+ const dirList = [...dirs.values()].map((entry) => ({
167
+ ...entry,
168
+ unanchored: [...entry.unanchored].sort(byPath),
169
+ anchored: [...entry.anchored].sort(byPath)
170
+ })).sort((a, b) => a.dir.localeCompare(b.dir));
171
+ return {
172
+ filesTotal: anchoredFiles.length + unanchoredFiles.length,
173
+ filesAnchored: anchoredFiles.length,
174
+ locTotal: dirList.reduce((sum, d) => sum + d.locTotal, 0),
175
+ locAnchored: dirList.reduce((sum, d) => sum + d.locAnchored, 0),
176
+ dirs: dirList
177
+ };
178
+ }
179
+
180
+ // src/i18n/legacy/shared.ts
181
+ var germanText = {
182
+ text1: "\n -Anchor bindet den Code an ihn.\n ",
183
+ text2: "Kopieren",
184
+ text3: "Abbrechen",
185
+ text4: "Versatz",
186
+ text5: "Einstellungen",
187
+ text6: "Entfernen",
188
+ text7: "Lage",
189
+ text8: "Alle",
190
+ text9: "51\u201375 von 480",
191
+ text10: "0\u20130 von 0",
192
+ text11: "Werkzeug",
193
+ text12: "Kopieren",
194
+ text13: /Kopieren/,
195
+ text14: "zu",
196
+ text15: "Typische Fehler",
197
+ text16: "alle 15 min",
198
+ text17: "Grundbegriff",
199
+ text18: "Anker",
200
+ text19: "Annahme",
201
+ text20: "Friedhof",
202
+ text21: "Merkmal",
203
+ text22: "Szenario",
204
+ text23: "Zusage",
205
+ text24: "suche",
206
+ text25: "festgelegt",
207
+ text26: "Prozesse",
208
+ text27: "Frag Atlas darf Elemente eines Prozesses nachschlagen.",
209
+ text28: "Suche leeren",
210
+ text29: /Einstellungen/,
211
+ text30: "Dem System folgen",
212
+ text31: "Alle 1 leeren \xB7 2,0 KB",
213
+ text32: "facet.atlas.v3.verlauf",
214
+ text33: /Alle 0 leeren/,
215
+ text34: "Angemeldet",
216
+ text35: "gesperrt",
217
+ text36: "Modell",
218
+ text37: "Befehl kopieren",
219
+ text38: "Alle Plugins",
220
+ text39: "Begriff vorschlagen",
221
+ text40: "Ersten Begriff vorschlagen",
222
+ text41: "| `lint_anchors.go` | Anker |",
223
+ text42: "Satz",
224
+ text43: "61\u2013120 von 480",
225
+ text44: "Zu kurz",
226
+ text45: "Befunde des Parsers",
227
+ text46: /Befunde des Parsers/,
228
+ text47: "Alle Prozesse",
229
+ text48: "Frage",
230
+ text49: "Abgebrochen nach 6 s.",
231
+ text50: "Zeitlimit des Hosts",
232
+ text51: "Befehle",
233
+ text52: "Frage an Atlas",
234
+ text53: "Frage?",
235
+ text54: "Modell opus",
236
+ text55: "Senden",
237
+ text56: "Frag Atlas \u2026 ( / f\xFCr Befehle )",
238
+ text57: "Stopp",
239
+ text58: "\u21B5 senden \xB7 \u21E7\u21B5 Zeile",
240
+ text59: "senden",
241
+ text60: "Gehe zu",
242
+ text61: /Lage/,
243
+ text62: "alle ",
244
+ text63: "Akte ",
245
+ text64: "von ",
246
+ text65: "Alle Formen",
247
+ text66: "im Leser",
248
+ text68: "im BPMN-Plugin",
249
+ text69: "im Commit-Gate",
250
+ text70: "im MCP-Server",
251
+ text71: "im Devcontainer",
252
+ text72: "im Hook-Pfad",
253
+ text73: "Freigabe eines Werkzeugs",
254
+ text74: "Szenario beweisen",
255
+ text75: "Welche Records nennt ADR 0002",
256
+ text76: "Drift seit dem letzten Release",
257
+ text77: "Welche Tests beweisen den Commit-Gate",
258
+ text78: "Letzte Antwort als Markdown kopieren",
259
+ text79: "Bereiche & Kategorien",
260
+ text80: "Akte \xB7 14:08",
261
+ text81: "Akte \xB7 13:58",
262
+ text82: "Link zu diesem Ort kopieren",
263
+ text83: "Verlauf leeren",
264
+ text84: "Plugin-Befehle",
265
+ text85: "Prozesse: Durchlauf starten",
266
+ text86: "Verlauf",
267
+ text87: "Inhalte",
268
+ text88: /Akte/,
269
+ text89: "\u201ERecord\u201C steht schon im Glossar.",
270
+ text90: "Begriff",
271
+ text91: "Vollen Hash kopieren",
272
+ text92: "Records als YAML neben dem Code",
273
+ text93: "BPMN als Datei im Repositorium",
274
+ text94: "Wo Records liegen, deren Merkmal entfernt wurde.",
275
+ text95: "Lets a member work with the header in board: when the task is overdue, every member sees the same order. It also covers what happens when two edits arrive at once \u2014 the change is kept and shown at once. The header count, the list and the search results agree. An earlier version stays available for thirty days. The same rule applies on the web board, the des\u2026",
276
+ text96: /Gehe zu, Record/,
277
+ text97: "Bereiche",
278
+ text98: "Alle Records, gestreamt",
279
+ text99: /facet init kopieren/,
280
+ text100: "11\u201320 von 140",
281
+ text101: "Versatz nach Tag",
282
+ text102: "^Versatz: ",
283
+ text103: "Tests nach Art",
284
+ text104: "Wo zu finden",
285
+ text105: "Nach rechts drehen",
286
+ text106: "Nach links drehen",
287
+ text107: /Bereiche/,
288
+ text108: "Records im Produkt",
289
+ text109: " von ",
290
+ text110: "Verbindung zu facet ui verloren",
291
+ text111: /Versatz/,
292
+ text112: "Einstiege im Code",
293
+ text113: "Ende-zu-Ende",
294
+ text114: "erste Frage",
295
+ text115: "aus",
296
+ text116: "nochmal aus",
297
+ text117: "Fertig \xB7 offene Punkte",
298
+ text118: "Einstiege im Code \xB7 Tests",
299
+ text119: /^Diese Software besteht aus /,
300
+ text120: " % des zugesagten Verhaltens",
301
+ text121: "ENDE-ZU-ENDE",
302
+ text122: "BEREICHE",
303
+ text123: "EINSTIEGE IM CODE",
304
+ text124: "Wo im Code?",
305
+ text125: "settle()-Aufruf im Checkout.",
306
+ text126: /^Verlauf/,
307
+ text127: /^Beziehungen/,
308
+ text128: "Z. 5 von 9",
309
+ text129: "Art: Annahme",
310
+ text130: "Nach Lebenszyklus",
311
+ text131: "Unlesbare Antwort des facet-Servers: ",
312
+ text132: "Von ",
313
+ text133: " Einstiege im Code zu ",
314
+ text134: "Diese Software besteht aus ",
315
+ text135: "Genutzt von",
316
+ text136: "user_id zu Rolle",
317
+ text137: "Alle Records",
318
+ text138: "Was sichert last write wins zu?",
319
+ text139: /Anker/,
320
+ text140: "Annahme \xB7 sync",
321
+ text141: "5 Bereichen + 1 Annahme",
322
+ text142: "Alle 19 zeigen",
323
+ text143: "Alle 22 zeigen",
324
+ text144: "Ganzen Verlauf zeigen",
325
+ text145: "Id kopieren",
326
+ text146: "Anker kopieren",
327
+ text147: "Annahme.",
328
+ text148: /Verlauf/,
329
+ text149: "Quelltext am Anker",
330
+ text150: "im Gleichstand",
331
+ text151: "jeder Pfad im Repositorium",
332
+ text152: "Alle ",
333
+ text153: "Nichts zu zeigen.",
334
+ text154: "31 von 38 bewiesen",
335
+ text155: "\u2192 weiter",
336
+ text156: "Nichts zu belegen.",
337
+ text157: "weiter",
338
+ text158: "aus den Modultests abgeleitet",
339
+ text159: "Was passiert bei Netzverlust?",
340
+ text160: "1 Frage",
341
+ text161: "Nichts gefunden zu \u201E",
342
+ text162: "Tippen, um zu suchen.",
343
+ text163: "fehler",
344
+ text164: "alle 16",
345
+ text165: "alle 16 \u2192",
346
+ text166: "Zusage \u2014 leer",
347
+ text167: "1 Zusage",
348
+ text168: "Stopp",
349
+ text169: "antwortet aus den gelesenen Records",
350
+ text170: "Frage Nummer ",
351
+ text171: "Fehler",
352
+ text172: "alles belegt",
353
+ text173: "Wert",
354
+ text174: "wert",
355
+ text175: "Einstiege im Code",
356
+ text176: "7 von 17",
357
+ text177: "7 von 17 Records gelesen",
358
+ text178: "Warte auf den facet-Server",
359
+ text179: "Anker suchen",
360
+ text180: "Modell bauen",
361
+ text181: " Anker",
362
+ text182: " von",
363
+ text183: "aus dem Repo-Scan",
364
+ text184: "96 (aus dem Repo-Scan)",
365
+ text185: "belegt"
366
+ };
367
+
368
+ // src/i18n/legacy/core/live.ts
369
+ var localized = {
370
+ text1: "Der facet-Server hat den Lauf abgebrochen.",
371
+ text2: "Keine Verbindung zum facet-Server (",
372
+ text3: "Dieser Host kennt kein EventSource \u2014 bitte `open` mitgeben."
373
+ };
374
+
375
+ // src/core/live.ts
376
+ var INDEX_PHASES = [
377
+ "connect",
378
+ "config",
379
+ "records",
380
+ "enumerate",
381
+ "index",
382
+ "model",
383
+ "ready"
384
+ ];
385
+ function phaseRank(phase) {
386
+ return INDEX_PHASES.indexOf(phase);
387
+ }
388
+ function initialStatus() {
389
+ return {
390
+ phase: "connect",
391
+ file: "",
392
+ done: 0,
393
+ total: 0,
394
+ records: 0,
395
+ files: 0,
396
+ anchors: 0,
397
+ root: "",
398
+ registry: ""
399
+ };
400
+ }
401
+ function mergeStatus(previous, patch) {
402
+ return {
403
+ phase: patch.phase ?? previous.phase,
404
+ file: patch.file ?? "",
405
+ done: patch.done ?? 0,
406
+ total: patch.total ?? 0,
407
+ records: patch.records ?? previous.records,
408
+ files: patch.files ?? previous.files,
409
+ anchors: patch.anchors ?? previous.anchors,
410
+ root: patch.root ?? previous.root,
411
+ registry: patch.registry ?? previous.registry
412
+ };
413
+ }
414
+ function subscribeCorpus(url, handlers = {}, options = {}) {
415
+ const open = options.open ?? defaultOpen;
416
+ const stream = open(url);
417
+ let status = initialStatus();
418
+ let closed = false;
419
+ const close = () => {
420
+ if (closed) return;
421
+ closed = true;
422
+ stream.close();
423
+ };
424
+ const fail = (error) => {
425
+ if (closed) return;
426
+ close();
427
+ handlers.onError?.(error);
428
+ };
429
+ stream.addEventListener("status", (event) => {
430
+ const patch = decode(event.data);
431
+ if (patch instanceof Error) return fail(patch);
432
+ status = mergeStatus(status, patch);
433
+ handlers.onStatus?.(status);
434
+ });
435
+ stream.addEventListener("ready", (event) => {
436
+ const source = decode(event.data);
437
+ if (source instanceof Error) return fail(source);
438
+ if (closed) return;
439
+ close();
440
+ handlers.onReady?.(source);
441
+ });
442
+ stream.addEventListener("failed", (event) => {
443
+ const payload = decode(event.data);
444
+ if (payload instanceof Error) return fail(payload);
445
+ fail(new Error(payload.message || localized.text1));
446
+ });
447
+ stream.addEventListener("error", () => {
448
+ fail(new Error(`${localized.text2}${url}).`));
449
+ });
450
+ return close;
451
+ }
452
+ function defaultOpen(url) {
453
+ if (typeof EventSource === "undefined") {
454
+ throw new Error(localized.text3);
455
+ }
456
+ return new EventSource(url);
457
+ }
458
+ function decode(data) {
459
+ try {
460
+ return JSON.parse(data);
461
+ } catch (error) {
462
+ return new Error(`${germanText.text131}${error.message}`);
463
+ }
464
+ }
465
+
466
+ // src/i18n/legacy/core/roles.ts
467
+ var localized2 = {
468
+ text1: "GESCH\xC4FTSF\xDCHRUNG",
469
+ text2: "Gesch\xE4ftsf\xFChrung",
470
+ text3: "Kopplung \xB7 Ketten \xB7 Abl\xF6sungen",
471
+ text4: "QUALIT\xC4T",
472
+ text5: "Qualit\xE4tssicherung",
473
+ text6: "Zusagen \xB7 Testabdeckung",
474
+ text7: "Zustand \xB7 Wissen \xB7 Begr\xFCndung",
475
+ text8: "Klauseln \xB7 Pr\xFCfungen \xB7 Daten",
476
+ text9: "SLOs \xB7 Alarme \xB7 Pr\xFCfungen"
477
+ };
478
+
479
+ // src/core/roles.ts
480
+ var ROLES = [
481
+ {
482
+ key: "c",
483
+ tag: localized2.text1,
484
+ title: localized2.text2,
485
+ hint: labelText.text378
486
+ },
487
+ { key: "arch", tag: labelText.text379, title: labelText.text380, hint: localized2.text3 },
488
+ {
489
+ key: "delivery",
490
+ tag: labelText.text381,
491
+ title: labelText.text382,
492
+ hint: germanText.text117
493
+ },
494
+ { key: "eng", tag: labelText.text383, title: labelText.text49, hint: germanText.text118 },
495
+ { key: "qa", tag: localized2.text4, title: localized2.text5, hint: localized2.text6 },
496
+ { key: "po", tag: labelText.text384, title: labelText.text43, hint: localized2.text7 },
497
+ { key: "gov", tag: "COMPLIANCE", title: "Compliance", hint: localized2.text8 },
498
+ { key: "ops", tag: remainingText.text58, title: remainingText.text15, hint: localized2.text9 }
499
+ ];
500
+ function roleByKey(key) {
501
+ return ROLES.find((r) => r.key === key) ?? ROLES[0];
502
+ }
503
+ function nextRole(key) {
504
+ const index = ROLES.findIndex((r) => r.key === key);
505
+ return ROLES[(index + 1) % ROLES.length].key;
506
+ }
507
+
508
+ // src/i18n/legacy/core/lead.ts
509
+ var localized3 = {
510
+ text1: "Der Bestand h\xE4ngt \xFCber ",
511
+ text2: " Kanten zusammen, die l\xE4ngste Kette ist ",
512
+ text3: " Records sind abgel\xF6st.",
513
+ text4: " Kernfunktionen sind ",
514
+ text5: " vollst\xE4ndig mit Tests verkn\xFCpft, verankert und aktiv. Offen bleiben ",
515
+ text6: " Zusagen ohne Test, verteilt auf ",
516
+ text7: "Es gibt ",
517
+ text8: " aktive Funktionen haben keinen, und ",
518
+ text9: " Zusagen keinen Test.",
519
+ text10: " des zugesagten Verhaltens hat eine Testzuordnung: ",
520
+ text11: " Zusagen. Ohne Testzuordnung bleiben ",
521
+ text12: " Kernfunktionen sind live, ",
522
+ text13: " Wissensfragen sind beantwortet, ",
523
+ text14: " Zusagen sind messbar.",
524
+ text15: " Pr\xFCfungen sind \xFCberf\xE4llig, ",
525
+ text16: " Felder sind personenbezogen und ",
526
+ text17: " Annahmen lange ungepr\xFCft.",
527
+ text18: " SLOs und ",
528
+ text19: " Alarme sind hinterlegt. ",
529
+ text20: " Alarme haben keine Anleitung, ",
530
+ text21: " aktive Funktionen werden gar nicht gemessen.",
531
+ text22: " des zugesagten Verhaltens hat eine Testzuordnung, ",
532
+ text23: " Pr\xFCfungen sind \xFCberf\xE4llig \u2014 und "
533
+ };
534
+
535
+ // src/i18n/legacy/core/focus.ts
536
+ var localized4 = {
537
+ text1: "ohne Team",
538
+ text2: "kein Zustandswechsel beschrieben",
539
+ text3: /MUSS|MÜSSEN|MUST/,
540
+ text4: "Pr\xFCfung ",
541
+ text5: " f\xE4llig",
542
+ text6: "Pr\xFCfung",
543
+ text7: "keine",
544
+ text8: " Monaten nicht gepr\xFCft",
545
+ text9: "ohne Beschreibung",
546
+ text10: "Wenn falsch",
547
+ text11: "kein Risiko beschrieben",
548
+ text12: "Kritikalit\xE4t",
549
+ text13: "keine Referenz",
550
+ text14: "kein Beleg",
551
+ text15: "Alarm ohne Anleitung",
552
+ text16: "fehlt \u2014 im Alarmfall gibt es keinen beschriebenen Weg",
553
+ text17: "aktiv, aber kein Einstieg im Code",
554
+ text18: "ohne Beschreibung",
555
+ text19: "Zusagen",
556
+ text20: " \xB7 mit Testzuordnung ",
557
+ text21: "\xC4nderungen am Code lassen sich diesem Record nicht zuordnen.",
558
+ text22: "Zusage ohne Test",
559
+ text23: "Zustand",
560
+ text24: "ohne Zust\xE4ndigkeit",
561
+ text25: "ohne Beschreibung",
562
+ text26: "Es gibt niemanden, der \xFCber diesen Record entscheidet.",
563
+ text27: "ohne Beschreibung",
564
+ text28: "Warum es dieses Verhalten gibt, ist nicht festgehalten.",
565
+ text29: "aktiv, aber nichts wird gemessen",
566
+ text30: "ohne Beschreibung",
567
+ text31: "Ein Ausfall dieses Verhaltens f\xE4llt niemandem automatisch auf.",
568
+ text32: "Verweis ohne Record",
569
+ text33: "Ein Record verweist hierauf, es existiert aber keine Datei daf\xFCr."
570
+ };
571
+
572
+ // src/core/focus.ts
573
+ var KIND_WORD = {
574
+ feature: remainingText.text20,
575
+ policy: remainingText.text21,
576
+ assumption: germanText.text19,
577
+ entity: remainingText.text22
578
+ };
579
+ function gherkinLine(step) {
580
+ const label = step.keyword ? GHERKIN_LABEL[step.keyword] : "";
581
+ return label ? `${label} \xB7 ${step.text}` : step.text;
582
+ }
583
+ function teamOf(record) {
584
+ return record.team || localized4.text1;
585
+ }
586
+ function stateOf(scenario) {
587
+ const describe = (value, word) => {
588
+ if (!value || typeof value !== "object") return "";
589
+ const entries = Object.entries(value);
590
+ return entries.length ? `${word}: ${entries.map(([k, v]) => `${k} ${v}`).join(", ")}` : "";
591
+ };
592
+ const lines = [
593
+ describe(scenario.pre, labelText.text279),
594
+ describe(scenario.post, labelText.text280)
595
+ ].filter(Boolean);
596
+ return lines.length ? lines.join("\n") : localized4.text2;
597
+ }
598
+ function focusItems(model) {
599
+ const items = [];
600
+ model.overdueList.forEach(({ rec, check }) => {
601
+ const must = rec.clauses.filter(
602
+ (clause) => localized4.text3.test(String(clause.requirement))
603
+ ).length;
604
+ items.push({
605
+ severity: 0,
606
+ id: rec.id,
607
+ section: "rules",
608
+ title: rec.label,
609
+ why: `${localized4.text4}${check.id} war am ${check.next_due}${localized4.text5}`,
610
+ meta: teamOf(rec),
611
+ body: [
612
+ { label: localized4.text6, value: String(check.id ?? "\u2014") },
613
+ { label: labelText.text293, value: String(check.frequency ?? "\u2014") },
614
+ { label: labelText.text417, value: String(check.last_established ?? "\u2014") },
615
+ { label: labelText.text418, value: rec.artifacts.join("\n") || localized4.text7 },
616
+ { label: labelText.text419, value: `${rec.clauses.length} \xB7 davon verpflichtend ${must}` }
617
+ ]
618
+ });
619
+ });
620
+ model.assumptions.filter((assumption) => assumption.stale).forEach((assumption) => {
621
+ items.push({
622
+ severity: 0,
623
+ id: assumption.id,
624
+ section: "rules",
625
+ title: assumption.label,
626
+ why: `${labelText.text332}${assumption.ageMonths}${localized4.text8}`,
627
+ meta: teamOf(assumption),
628
+ body: [
629
+ { label: germanText.text19, value: assumption.summary || localized4.text9 },
630
+ { label: localized4.text10, value: assumption.risk || localized4.text11 },
631
+ { label: localized4.text12, value: assumption.criticality || "\u2014" },
632
+ {
633
+ label: germanText.text135,
634
+ value: assumption.referencedBy.join("\n") || localized4.text13
635
+ },
636
+ {
637
+ label: remainingText.text51,
638
+ value: assumption.evidence.map((entry) => [entry.date, entry.kind, entry.note].filter(Boolean).join(" \xB7 ")).join("\n") || localized4.text14
639
+ }
640
+ ]
641
+ });
642
+ });
643
+ model.alerts.filter((alert) => !alert.runbook).forEach((alert) => {
644
+ items.push({
645
+ severity: 1,
646
+ id: alert.rec.id,
647
+ section: "ops",
648
+ title: String(alert.name ?? alert.id ?? labelText.text285),
649
+ why: localized4.text15,
650
+ meta: teamOf(alert.rec),
651
+ body: [
652
+ { label: labelText.text420, value: String(alert.condition ?? "\u2014") },
653
+ { label: labelText.text421, value: String(alert.severity ?? "\u2014") },
654
+ { label: "Record", value: alert.rec.id },
655
+ {
656
+ label: labelText.text295,
657
+ value: localized4.text16
658
+ }
659
+ ]
660
+ });
661
+ });
662
+ model.unanchored.forEach((record) => {
663
+ items.push({
664
+ severity: 1,
665
+ id: record.id,
666
+ section: "code",
667
+ title: record.label,
668
+ why: localized4.text17,
669
+ meta: teamOf(record),
670
+ body: [
671
+ { label: labelText.text422, value: record.summary || localized4.text18 },
672
+ { label: localized4.text19, value: `${record.total}${localized4.text20}${record.proven}` },
673
+ {
674
+ label: labelText.text423,
675
+ value: localized4.text21
676
+ }
677
+ ]
678
+ });
679
+ });
680
+ model.allScn.filter((scenario) => !scenario.proven).forEach((scenario) => {
681
+ items.push({
682
+ severity: 1,
683
+ id: scenario.rec.id,
684
+ section: "promises",
685
+ title: scenario.id,
686
+ why: localized4.text22,
687
+ meta: teamOf(scenario.rec),
688
+ body: [
689
+ { label: "Record", value: scenario.rec.id },
690
+ { label: germanText.text23, value: scenario.steps.map(gherkinLine).join("\n") },
691
+ { label: localized4.text23, value: stateOf(scenario) },
692
+ { label: "Test", value: "keiner benannt" }
693
+ ]
694
+ });
695
+ });
696
+ model.noOwner.forEach((record) => {
697
+ items.push({
698
+ severity: 2,
699
+ id: record.id,
700
+ section: "teams",
701
+ title: record.label,
702
+ why: localized4.text24,
703
+ meta: "\u2014",
704
+ body: [
705
+ { label: labelText.text424, value: KIND_WORD[record.kind] ?? record.kind },
706
+ { label: labelText.text422, value: record.summary || localized4.text25 },
707
+ { label: labelText.text423, value: localized4.text26 }
708
+ ]
709
+ });
710
+ });
711
+ model.noIntent.forEach((record) => {
712
+ items.push({
713
+ severity: 2,
714
+ id: record.id,
715
+ section: "records",
716
+ title: record.label,
717
+ why: localized4.text27,
718
+ meta: teamOf(record),
719
+ body: [
720
+ { label: labelText.text424, value: KIND_WORD[record.kind] ?? record.kind },
721
+ {
722
+ label: labelText.text423,
723
+ value: localized4.text28
724
+ }
725
+ ]
726
+ });
727
+ });
728
+ model.noObs.forEach((record) => {
729
+ items.push({
730
+ severity: 2,
731
+ id: record.id,
732
+ section: "ops",
733
+ title: record.label,
734
+ why: localized4.text29,
735
+ meta: teamOf(record),
736
+ body: [
737
+ { label: labelText.text422, value: record.summary || localized4.text30 },
738
+ {
739
+ label: labelText.text423,
740
+ value: localized4.text31
741
+ }
742
+ ]
743
+ });
744
+ });
745
+ model.ghosts.forEach((ghost) => {
746
+ items.push({
747
+ severity: 2,
748
+ id: ghost,
749
+ section: "graph",
750
+ title: String(ghost).split("/").pop() ?? ghost,
751
+ why: localized4.text32,
752
+ meta: "\u2014",
753
+ body: [
754
+ { label: labelText.text425, value: ghost },
755
+ {
756
+ label: labelText.text423,
757
+ value: localized4.text33
758
+ }
759
+ ]
760
+ });
761
+ });
762
+ return items.sort((a, b) => a.severity - b.severity);
763
+ }
764
+ function leadSentenceFacts(model) {
765
+ return {
766
+ open: focusItems(model).length,
767
+ overdue: model.overdue,
768
+ untested: model.scnTotal - model.scnProven,
769
+ unanchored: model.unanchored.length,
770
+ features: model.features.length,
771
+ domains: model.domains.length,
772
+ coverage: model.scnTotal ? Math.round(model.scnProven / model.scnTotal * 100) : 0
773
+ };
774
+ }
775
+
776
+ // src/core/lead.ts
777
+ var t = (text) => ({ kind: "text", text });
778
+ var n = (value, probe) => ({
779
+ kind: "probe",
780
+ text: typeof value === "number" ? formatNumber(value) : value,
781
+ probe
782
+ });
783
+ function leadFor(model, role) {
784
+ const coverage2 = pct(model.scnProven, model.scnTotal);
785
+ const open = focusItems(model).length;
786
+ const untested = model.scnTotal - model.scnProven;
787
+ switch (role) {
788
+ case "arch":
789
+ return [
790
+ t(localized3.text1),
791
+ n(model.edges.length, "edges"),
792
+ t(localized3.text2),
793
+ n(model.maxDepth, "edges"),
794
+ t(remainingText.text47),
795
+ n(model.ghosts.length, "edges"),
796
+ t(remainingText.text48),
797
+ n(model.superseded.length, "edges"),
798
+ t(localized3.text3)
799
+ ];
800
+ case "delivery":
801
+ return [
802
+ t(germanText.text132),
803
+ n(model.features.length, "features"),
804
+ t(localized3.text4),
805
+ n(model.complete.length, "coverage"),
806
+ t(localized3.text5),
807
+ n(untested, "coverage"),
808
+ t(localized3.text6),
809
+ n(Object.keys(model.teams).length, "teams"),
810
+ t(" Teams.")
811
+ ];
812
+ case "eng":
813
+ return [
814
+ t(localized3.text7),
815
+ n(model.anchorPairs.length, "anchors"),
816
+ t(germanText.text133),
817
+ n(Object.keys(model.anchorMap).length, "anchors"),
818
+ t(" Kernfunktionen. "),
819
+ n(model.unanchored.length, "anchors"),
820
+ t(localized3.text8),
821
+ n(untested, "coverage"),
822
+ t(localized3.text9)
823
+ ];
824
+ case "qa":
825
+ return [
826
+ n(`${coverage2} %`, "coverage"),
827
+ t(localized3.text10),
828
+ n(model.scnProven, "coverage"),
829
+ t(germanText.text109),
830
+ n(model.scnTotal, "coverage"),
831
+ t(localized3.text11),
832
+ n(untested, "coverage"),
833
+ t(".")
834
+ ];
835
+ case "po":
836
+ return [
837
+ n(model.lifecycles.active ?? 0, "features"),
838
+ t(localized3.text12),
839
+ n(model.lifecycles.planned ?? 0, "features"),
840
+ t(remainingText.text49),
841
+ n(model.knowAnswered, "know"),
842
+ t(germanText.text109),
843
+ n(model.knowSlots, "know"),
844
+ t(localized3.text13),
845
+ n(model.slos.length, "ops"),
846
+ t(localized3.text14)
847
+ ];
848
+ case "gov":
849
+ return [
850
+ n(model.clauseCount, "overdue"),
851
+ t(labelText.text409),
852
+ n(model.mustCount, "overdue"),
853
+ t(" davon verpflichtend. "),
854
+ n(model.overdue, "overdue"),
855
+ t(localized3.text15),
856
+ n(model.pii, "pii"),
857
+ t(localized3.text16),
858
+ n(model.stale, "overdue"),
859
+ t(localized3.text17)
860
+ ];
861
+ case "ops":
862
+ return [
863
+ n(model.slos.length, "ops"),
864
+ t(localized3.text18),
865
+ n(model.alerts.length, "ops"),
866
+ t(localized3.text19),
867
+ n(model.noRunbook, "ops"),
868
+ t(localized3.text20),
869
+ n(model.noObs.length, "ops"),
870
+ t(localized3.text21)
871
+ ];
872
+ default:
873
+ return [
874
+ t(germanText.text134),
875
+ n(model.features.length, "features"),
876
+ t(" Kernfunktionen in "),
877
+ n(model.domains.length, "features"),
878
+ t(remainingText.text50),
879
+ n(`${coverage2} %`, "coverage"),
880
+ t(localized3.text22),
881
+ n(model.overdue, "overdue"),
882
+ t(localized3.text23),
883
+ n(open, "open"),
884
+ t(" Punkte warten auf jemanden.")
885
+ ];
886
+ }
887
+ }
888
+
889
+ // src/i18n/legacy/core/probes.ts
890
+ var localized5 = {
891
+ text1: "OHNE TEST",
892
+ text2: " Testdateien \xB7 Zeilenabdeckung nicht angebunden",
893
+ text3: " mit Testzuordnung",
894
+ text4: "\xDCBERF\xC4LLIG",
895
+ text5: "UNGEPR\xDCFTE ANNAHMEN",
896
+ text6: "ZUSAGEN OHNE TEST",
897
+ text7: "OHNE ANLEITUNG",
898
+ text8: "OHNE CODE-EINSTIEG",
899
+ text9: "OHNE ZUST\xC4NDIGKEIT",
900
+ text10: "OHNE BESCHREIBUNG",
901
+ text11: "OHNE REGELWERK",
902
+ text12: "OHNE MESSUNG",
903
+ text13: "VERWEISE OHNE RECORD",
904
+ text14: "Summe = die Fokusliste darunter",
905
+ text15: "\xDCBERF\xC4LLIG",
906
+ text16: "PR\xDCFUNGEN",
907
+ text17: " \xB7 f\xE4llig ",
908
+ text18: "keine Frist verstrichen",
909
+ text20: "alle Verweise aufl\xF6sbar",
910
+ text21: "OHNE EINSTIEG",
911
+ text22: "VERSCHL\xDCSSELT",
912
+ text23: "OHNE ANLEITUNG",
913
+ text24: "LAUFENDE PR\xDCFUNGEN",
914
+ text25: "keine Messquelle benannt",
915
+ text26: "OHNE BESCHREIBUNG",
916
+ text27: " \xB7 offen",
917
+ text28: "alle Fragen beantwortet",
918
+ text29: "ZUST\xC4NDIGKEIT",
919
+ text30: "OHNE ZUST\xC4NDIGKEIT",
920
+ text31: "kein Kontakt",
921
+ text32: "keine Aufbewahrung",
922
+ text19: "ABGEL\xD6ST"
923
+ };
924
+
925
+ // src/core/probes.ts
926
+ var row = (label, value, meaning = "neutral", sectionKey) => ({
927
+ label,
928
+ value: typeof value === "number" ? formatNumber(value) : value,
929
+ meaning,
930
+ sectionKey
931
+ });
932
+ var gap = (count) => count > 0 ? "signal" : "neutral";
933
+ var due = (count) => count > 0 ? "deadline" : "neutral";
934
+ var KIND_LABEL = {
935
+ unit: remainingText.text62,
936
+ property: remainingText.text63,
937
+ integration: "INTEGRATION",
938
+ e2e: germanText.text121
939
+ };
940
+ var KINDS = ["unit", "property", "integration", "e2e"];
941
+ function probeOf(model, key) {
942
+ switch (key) {
943
+ case "coverage": {
944
+ const testLoc = typeof model.scan.testLoc === "number" ? model.scan.testLoc : 0;
945
+ const totalLoc = typeof model.scan.totalLoc === "number" ? model.scan.totalLoc : 0;
946
+ const testFiles = typeof model.scan.testFiles === "number" ? model.scan.testFiles : 0;
947
+ return {
948
+ head: "TESTZUORDNUNGEN",
949
+ rows: [
950
+ row(
951
+ "TEST ZUGEORDNET",
952
+ `${formatNumber(model.scnProven)}/${formatNumber(model.scnTotal)}`
953
+ ),
954
+ row(
955
+ localized5.text1,
956
+ model.scnTotal - model.scnProven,
957
+ gap(model.scnTotal - model.scnProven)
958
+ ),
959
+ ...KINDS.filter((kind) => model.testKinds[kind]).map(
960
+ (kind) => row(KIND_LABEL[kind], model.testKinds[kind])
961
+ )
962
+ ],
963
+ note: testLoc && totalLoc ? [
964
+ `${labelText.text358}${pct(testLoc, totalLoc)} % \xB7 ${formatNumber(testLoc)}${germanText.text109}${formatNumber(totalLoc)}${labelText.text359}`,
965
+ `${formatNumber(testFiles)}${localized5.text2}`
966
+ ] : []
967
+ };
968
+ }
969
+ case "features":
970
+ return {
971
+ head: "BESTAND",
972
+ rows: [
973
+ row("KERNFUNKTIONEN", model.features.length),
974
+ row("REGELWERKE", model.policies.length),
975
+ row(labelText.text360, model.assumptions.length),
976
+ row("DATENOBJEKTE", model.entities.length),
977
+ row(germanText.text122, model.domains.length)
978
+ ],
979
+ note: model.domainCov.map(
980
+ (domain) => `${domain.name} \xB7 ${domain.proven}/${domain.total}${localized5.text3}`
981
+ )
982
+ };
983
+ case "open":
984
+ return {
985
+ head: "OFFENE PUNKTE",
986
+ rows: [
987
+ row(localized5.text4, model.overdue, due(model.overdue)),
988
+ row(localized5.text5, model.stale, due(model.stale)),
989
+ row(
990
+ localized5.text6,
991
+ model.scnTotal - model.scnProven,
992
+ gap(model.scnTotal - model.scnProven)
993
+ ),
994
+ row(localized5.text7, model.noRunbook, gap(model.noRunbook)),
995
+ row(localized5.text8, model.unanchored.length, gap(model.unanchored.length)),
996
+ row(localized5.text9, model.noOwner.length, gap(model.noOwner.length)),
997
+ row(localized5.text10, model.noIntent.length, gap(model.noIntent.length)),
998
+ row(localized5.text11, model.uncovered.length, gap(model.uncovered.length)),
999
+ row(localized5.text12, model.noObs.length, gap(model.noObs.length)),
1000
+ row(localized5.text13, model.ghosts.length, gap(model.ghosts.length))
1001
+ ],
1002
+ note: [localized5.text14]
1003
+ };
1004
+ case "overdue":
1005
+ return {
1006
+ head: remainingText.text38,
1007
+ rows: [
1008
+ row(localized5.text15, model.overdue, due(model.overdue)),
1009
+ row(localized5.text16, model.checks.length),
1010
+ row(labelText.text361, model.clauseCount),
1011
+ row("VERPFLICHTEND", model.mustCount)
1012
+ ],
1013
+ note: model.overdueList.length ? model.overdueList.map(
1014
+ ({ rec, check }) => `${rec.label} \xB7 ${check.id}${localized5.text17}${check.next_due}`
1015
+ ) : [localized5.text18]
1016
+ };
1017
+ case "edges":
1018
+ return {
1019
+ head: labelText.text362,
1020
+ rows: [
1021
+ row("KANTEN", model.edges.length),
1022
+ row("DEPTH", model.maxDepth),
1023
+ row(remainingText.text45, model.ghosts.length, gap(model.ghosts.length)),
1024
+ row(localized5.text19, model.superseded.length)
1025
+ ],
1026
+ note: model.ghosts.length ? model.ghosts : [localized5.text20]
1027
+ };
1028
+ case "anchors": {
1029
+ const drift = model.scan.drift ?? [];
1030
+ return {
1031
+ head: germanText.text123,
1032
+ rows: [
1033
+ row(labelText.text363, model.anchorPairs.length),
1034
+ row("KERNFUNKTIONEN", Object.keys(model.anchorMap).length),
1035
+ row(localized5.text21, model.unanchored.length, gap(model.unanchored.length)),
1036
+ row(labelText.text364, drift.length, due(drift.length))
1037
+ ],
1038
+ note: drift.map((entry) => `${labelText.text365}${entry.id}`)
1039
+ };
1040
+ }
1041
+ case "pii":
1042
+ return {
1043
+ head: labelText.extra7,
1044
+ rows: [
1045
+ row(labelText.text366, model.pii, due(model.pii)),
1046
+ row(localized5.text22, model.enc),
1047
+ row("DATENOBJEKTE", model.entities.length)
1048
+ ],
1049
+ note: model.entities.map(
1050
+ (entity) => `${entity.label} \xB7 ${entity.fields.length}${labelText.text301}${retentionOf(entity.retention)}`
1051
+ )
1052
+ };
1053
+ case "ops":
1054
+ return {
1055
+ head: remainingText.text58,
1056
+ rows: [
1057
+ row("SLOS", model.slos.length),
1058
+ row(labelText.text367, model.alerts.length),
1059
+ row(localized5.text23, model.noRunbook, gap(model.noRunbook)),
1060
+ row(localized5.text24, model.checks.length)
1061
+ ],
1062
+ note: model.sources.length ? [model.sources.join(", ")] : [localized5.text25]
1063
+ };
1064
+ case "know": {
1065
+ const openQuestions = model.features.filter(
1066
+ (feature) => feature.knowledge.some((slot) => !slot.answer)
1067
+ );
1068
+ return {
1069
+ head: remainingText.text64,
1070
+ rows: [
1071
+ row(
1072
+ "BEANTWORTET",
1073
+ `${formatNumber(model.knowAnswered)}/${formatNumber(model.knowSlots)}`
1074
+ ),
1075
+ row(localized5.text26, model.noIntent.length, gap(model.noIntent.length)),
1076
+ row(
1077
+ "ENTSCHEIDUNGSVERWEISE",
1078
+ model.decisionTargets.reduce((sum, entry) => sum + entry.count, 0),
1079
+ "neutral",
1080
+ "decisions"
1081
+ )
1082
+ ],
1083
+ note: openQuestions.length ? openQuestions.map((feature) => `${feature.label}${localized5.text27}`) : [localized5.text28]
1084
+ };
1085
+ }
1086
+ case "teams":
1087
+ return {
1088
+ head: localized5.text29,
1089
+ rows: [
1090
+ row("TEAMS", Object.keys(model.teams).length),
1091
+ row(localized5.text30, model.noOwner.length, gap(model.noOwner.length))
1092
+ ],
1093
+ note: Object.keys(model.teams).map(
1094
+ (team) => `${team} \xB7 ${model.teams[team].contact || localized5.text31}`
1095
+ )
1096
+ };
1097
+ }
1098
+ }
1099
+ function retentionOf(retention) {
1100
+ if (retention && typeof retention === "object" && !Array.isArray(retention)) {
1101
+ const duration = retention.duration;
1102
+ if (typeof duration === "string" && duration) return duration;
1103
+ }
1104
+ return localized5.text32;
1105
+ }
1106
+
1107
+ // src/core/knowledge.ts
1108
+ var KNOWLEDGE_SLOT_KEYS = [
1109
+ "prerequisite_knowledge",
1110
+ "not_for",
1111
+ "success_signal",
1112
+ "common_pitfalls",
1113
+ "discoverability"
1114
+ ];
1115
+ function slotStateFor(record, key) {
1116
+ const slot = record.knowledge.find((s) => s.key === key);
1117
+ if (!slot) return "missing";
1118
+ return slot.answer ? "answered" : "question";
1119
+ }
1120
+ function emptyCounts() {
1121
+ return Object.fromEntries(
1122
+ KNOWLEDGE_SLOT_KEYS.map((key) => [key, { answered: 0, question: 0, missing: 0 }])
1123
+ );
1124
+ }
1125
+ function knowledgeCoverage(model) {
1126
+ const groups = /* @__PURE__ */ new Map();
1127
+ model.features.filter((record) => record.lifecycle === "active").forEach((record) => {
1128
+ const groupKey = `${record.domain}/${record.capability}`;
1129
+ let group = groups.get(groupKey);
1130
+ if (!group) {
1131
+ group = {
1132
+ domain: record.domain,
1133
+ capability: record.capability,
1134
+ records: [],
1135
+ noKnowledge: [],
1136
+ slots: emptyCounts(),
1137
+ answered: 0,
1138
+ total: 0
1139
+ };
1140
+ groups.set(groupKey, group);
1141
+ }
1142
+ group.records.push(record);
1143
+ if (!record.present.knowledge) group.noKnowledge.push(record);
1144
+ KNOWLEDGE_SLOT_KEYS.forEach((slotKey) => {
1145
+ const state = slotStateFor(record, slotKey);
1146
+ group.slots[slotKey][state] += 1;
1147
+ group.total += 1;
1148
+ if (state === "answered") group.answered += 1;
1149
+ });
1150
+ });
1151
+ return [...groups.values()].sort((a, b) => {
1152
+ if (a.domain !== b.domain) return a.domain.localeCompare(b.domain);
1153
+ return a.capability.localeCompare(b.capability);
1154
+ });
1155
+ }
1156
+
1157
+ // src/i18n/legacy/core/companion.ts
1158
+ var localized6 = {
1159
+ text1: "Frag mich nach den geladenen Records: nach einem Record beim Namen, nach offenen Zusagen oder nach Zust\xE4ndigkeiten.",
1160
+ text2: "antwortet aus den gelesenen Records \xB7 mit Suchindex auch aus ihrem Wortlaut \xB7 mit Claude Code im Repo auch aus dem Code",
1161
+ text3: " \xB7 offen ",
1162
+ text4: "Was ist bei ",
1163
+ text5: " offen?",
1164
+ text6: "Wo liegt das im Code?",
1165
+ text7: "Wer ist zust\xE4ndig?",
1166
+ text8: "Was ist \xFCberf\xE4llig?",
1167
+ text9: "Wie hoch ist die Testabdeckung?",
1168
+ text10: "Welche Funktionen sind nicht im Code verankert?",
1169
+ text11: "\xFCberf\xE4llig",
1170
+ text12: "pr\xFCfung",
1171
+ text13: "zust\xE4nd",
1172
+ text14: "l\xF6schfrist",
1173
+ text15: "abh\xE4ng",
1174
+ text16: " Dateien",
1175
+ text17: " Fragen",
1176
+ text18: "ZUSTAND",
1177
+ text19: "ZUSAGEN",
1178
+ text20: " mit Testzuordnung",
1179
+ text21: "eine Zusage ohne Test",
1180
+ text22: " Zusagen ohne Test",
1181
+ text23: "kein Einstieg im Code",
1182
+ text24: "nichts wird gemessen",
1183
+ text25: "eine Datei mit Anker hat sich ge\xE4ndert",
1184
+ text26: "Offen ist: ",
1185
+ text27: "Nach den Records und dem Code ist hier nichts offen.",
1186
+ text28: "Wer ist f\xFCr ",
1187
+ text29: " zust\xE4ndig?",
1188
+ text30: " \xB7 f\xE4llig ",
1189
+ text31: "Eine Pr\xFCfung ist \xFCberf\xE4llig:",
1190
+ text32: " Pr\xFCfungen sind \xFCberf\xE4llig:",
1191
+ text33: "Keine Annahme liegt l\xE4nger als ein Jahr ungepr\xFCft.",
1192
+ text34: "Dazu eine Annahme, die seit \xFCber einem Jahr nicht gepr\xFCft wurde.",
1193
+ text35: " Annahmen, die seit \xFCber einem Jahr nicht gepr\xFCft wurden.",
1194
+ text36: "Keine Pr\xFCfung ist \xFCberf\xE4llig. ",
1195
+ text37: "\xDCBERF\xC4LLIG",
1196
+ text38: " % des zugesagten Verhaltens hat eine Testzuordnung \u2014 ",
1197
+ text39: " Zusagen.\n\n",
1198
+ text40: "Schw\xE4chster Bereich: ",
1199
+ text41: " mit ",
1200
+ text42: " Zeilen in Tests; eine Zeilenabdeckung ist nicht angebunden.",
1201
+ text43: "OHNE TEST",
1202
+ text44: "Welche Zusagen haben keinen Test?",
1203
+ text45: "Es steht ein Punkt offen:",
1204
+ text46: " Punkte offen. Die ersten ",
1205
+ text47: "ist",
1206
+ text48: " sind",
1207
+ text49: "Fristen zuerst: sie sind die einzigen Punkte mit einem Datum, das schon vorbei ist.",
1208
+ text50: "OFFEN",
1209
+ text51: "OHNE TEST",
1210
+ text52: "Was ist \xFCberf\xE4llig?",
1211
+ text53: "Was hat die gr\xF6\xDFte Reichweite ohne Nachweis?",
1212
+ text54: "Ein Team tr\xE4gt Records. ",
1213
+ text55: "kein Kontakt",
1214
+ text56: "\n\nOhne Zust\xE4ndigkeit: ",
1215
+ text57: "\n\nJeder Record hat ein Team.",
1216
+ text58: "OHNE TEAM",
1217
+ text59: "Welches Team hat die meisten offenen Zusagen?",
1218
+ text60: " Felder sind als personenbezogen ausgewiesen, ",
1219
+ text61: " als verschl\xFCsselt.\n",
1220
+ text62: "VERSCHL\xDCSSELT",
1221
+ text63: "Welche Regelwerke gelten f\xFCr personenbezogene Felder?",
1222
+ text64: "Ge\xE4ndert seit dem letzten Stand: ",
1223
+ text65: "Jede aktive Funktion ist verankert.",
1224
+ text66: "Eine aktive Funktion hat keinen Einstieg: ",
1225
+ text67: " aktive Funktionen haben keinen Einstieg: ",
1226
+ text68: "\nUmgekehrt zeigt eine Stelle im Code auf einen Record, den es nicht gibt.",
1227
+ text69: " Stellen im Code auf Records, die es nicht gibt.",
1228
+ text70: "OHNE EINSTIEG",
1229
+ text71: "GE\xC4NDERT",
1230
+ text72: "Welche Funktion ist aktiv, aber nicht im Code verankert?",
1231
+ text73: "Der Bestand h\xE4ngt \xFCber ",
1232
+ text74: " Kanten zusammen, die l\xE4ngste Kette ist ",
1233
+ text75: "Alle Verweise l\xF6sen sich auf.",
1234
+ text76: "Ins Leere zeigt: ",
1235
+ text77: "Was ist am st\xE4rksten gekoppelt?",
1236
+ text78: " SLOs und ",
1237
+ text79: " Alarme sind hinterlegt.\n",
1238
+ text80: "Jeder Alarm hat eine Anleitung.",
1239
+ text81: "Ein Alarm hat keine Anleitung.",
1240
+ text82: " Alarme haben keine Anleitung.",
1241
+ text83: "\nEine aktive Funktion wird gar nicht gemessen: ",
1242
+ text84: " aktive Funktionen werden gar nicht gemessen: ",
1243
+ text85: "OHNE ANLEITUNG",
1244
+ text86: "Welche Alarme haben keine Anleitung?",
1245
+ text87: "Ich lese die ",
1246
+ text88: " und die Codebase unter ",
1247
+ text89: "Frag nach einem Record beim Namen, oder nach Lage, Fristen, Tests, Daten, Betrieb, Code oder Zust\xE4ndigkeit.",
1248
+ text90: "DATEIEN",
1249
+ text91: "OFFEN",
1250
+ text92: "Was ist \xFCberf\xE4llig?",
1251
+ text93: "Wie hoch ist die Testabdeckung?"
1252
+ };
1253
+
1254
+ // src/core/companion.ts
1255
+ var fact = (label, value, meaning = "neutral") => ({
1256
+ label,
1257
+ value,
1258
+ meaning
1259
+ });
1260
+ var from = (record) => ({
1261
+ text: record.path,
1262
+ recordId: record.id
1263
+ });
1264
+ var COMPANION_INTRO = localized6.text1;
1265
+ var COMPANION_FOOT = localized6.text2;
1266
+ function companionScope(model, roleTag, openId) {
1267
+ const sources = asStrings(model.rc.sources);
1268
+ const lines = typeof model.scan.totalLoc === "number" ? model.scan.totalLoc : 0;
1269
+ return `sieht: ${formatNumber(model.recs.length)} Records \xB7 ${sources.join(", ") || "\u2014"} \xB7 ${formatNumber(lines)}${labelText.text386}${labelText.text387}${roleTag}${openId ? `${localized6.text3}${openId}` : ""}`;
1270
+ }
1271
+ function companionSuggestions(model, openId, asked) {
1272
+ const open = openId ? model.byId[openId] : null;
1273
+ if (open) {
1274
+ return [`${localized6.text4}${open.label}${localized6.text5}`, localized6.text6, localized6.text7];
1275
+ }
1276
+ if (asked) return [];
1277
+ return [labelText.text388, localized6.text8, localized6.text9, localized6.text10];
1278
+ }
1279
+ function companionRecord(model, question) {
1280
+ const q = question.toLowerCase();
1281
+ return model.recs.find(
1282
+ (record) => q.includes(record.label.toLowerCase()) || q.includes(record.id.toLowerCase()) || q.includes(String(record.id).split("/").pop().replace(/-/g, " "))
1283
+ ) ?? null;
1284
+ }
1285
+ function companionRoute(model, question) {
1286
+ const q = question.toLowerCase();
1287
+ const has = (...words) => words.some((word) => q.includes(word));
1288
+ if (companionRecord(model, question)) return "record";
1289
+ if (has(localized6.text11, "deadline", "compliance", localized6.text12, "audit")) return "rules";
1290
+ if (has("test", labelText.text389, "coverage", labelText.text13, labelText.extra8))
1291
+ return "tests";
1292
+ if (has(
1293
+ labelText.text390,
1294
+ labelText.text391,
1295
+ labelText.text392,
1296
+ labelText.text393,
1297
+ labelText.extra9,
1298
+ labelText.extra10
1299
+ ))
1300
+ return "open";
1301
+ if (has(localized6.text13, "team", labelText.text394, "owner", labelText.text395)) return "teams";
1302
+ if (has(
1303
+ labelText.extra11,
1304
+ "pii",
1305
+ labelText.text297,
1306
+ labelText.extra12,
1307
+ labelText.text396,
1308
+ localized6.text14
1309
+ ))
1310
+ return "data";
1311
+ if (has(
1312
+ "code",
1313
+ remainingText.text29,
1314
+ labelText.text397,
1315
+ labelText.text398,
1316
+ "drift",
1317
+ labelText.text399,
1318
+ labelText.extra13
1319
+ ))
1320
+ return "code";
1321
+ if (has(localized6.text15, labelText.text400, labelText.text401, "graph", labelText.text402))
1322
+ return "graph";
1323
+ if (has(remainingText.text30, "slo", labelText.text403, "runbook", labelText.text404, "monitoring"))
1324
+ return "ops";
1325
+ return "corpus";
1326
+ }
1327
+ function companionAnswer(model, question) {
1328
+ switch (companionRoute(model, question)) {
1329
+ case "record":
1330
+ return aboutRecord(model, companionRecord(model, question));
1331
+ case "rules":
1332
+ return aboutRules(model);
1333
+ case "tests":
1334
+ return aboutTests(model);
1335
+ case "open":
1336
+ return aboutOpen(model);
1337
+ case "teams":
1338
+ return aboutTeams(model);
1339
+ case "data":
1340
+ return aboutData(model);
1341
+ case "code":
1342
+ return aboutCode(model);
1343
+ case "graph":
1344
+ return aboutGraph(model);
1345
+ case "ops":
1346
+ return aboutOps(model);
1347
+ default:
1348
+ return aboutCorpus(model);
1349
+ }
1350
+ }
1351
+ function agentPlan(model, text, reads, searches = []) {
1352
+ const seen = reads.filter((path, index) => path && reads.indexOf(path) === index);
1353
+ const byPath = new Map(model.recs.map((record) => [record.path, record.id]));
1354
+ const facts = [
1355
+ fact("GELESEN", seen.length === 1 ? labelText.text405 : `${seen.length}${localized6.text16}`)
1356
+ ];
1357
+ const found = searches.filter((query, index) => query && searches.indexOf(query) === index);
1358
+ if (found.length) {
1359
+ facts.push(
1360
+ fact(
1361
+ "GESUCHT",
1362
+ found.length === 1 ? remainingText.text31 : `${found.length}${localized6.text17}`
1363
+ )
1364
+ );
1365
+ }
1366
+ return {
1367
+ text,
1368
+ facts,
1369
+ reads: seen,
1370
+ sources: seen.map((path) => ({ text: path, recordId: byPath.get(path) ?? null })),
1371
+ openId: null,
1372
+ section: null,
1373
+ follow: []
1374
+ };
1375
+ }
1376
+ function aboutRecord(model, hit) {
1377
+ const anchors = model.anchorMap[hit.id] ?? [];
1378
+ const facts = [fact(localized6.text18, hit.lifecycle), fact("TEAM", hit.team || "\u2014")];
1379
+ if (hit.total) {
1380
+ facts.push(
1381
+ fact(
1382
+ localized6.text19,
1383
+ `${hit.proven}/${hit.total}${localized6.text20}`,
1384
+ hit.proven === hit.total ? "neutral" : "signal"
1385
+ )
1386
+ );
1387
+ }
1388
+ if (anchors.length) facts.push(fact("CODE", `${anchors.length}${labelText.text406}`));
1389
+ if (hit.clauses.length) facts.push(fact(labelText.text361, String(hit.clauses.length)));
1390
+ if (hit.fields.length) facts.push(fact(labelText.text407, String(hit.fields.length)));
1391
+ const gaps = [];
1392
+ if (hit.total && hit.proven < hit.total) {
1393
+ const missing = hit.total - hit.proven;
1394
+ gaps.push(missing === 1 ? localized6.text21 : `${missing}${localized6.text22}`);
1395
+ }
1396
+ if (hit.lifecycle === "active" && !anchors.length) gaps.push(localized6.text23);
1397
+ if (!hit.slos.length && !hit.alerts.length && hit.kind === "feature") gaps.push(localized6.text24);
1398
+ if (model.driftIds[hit.id]?.length) gaps.push(localized6.text25);
1399
+ return {
1400
+ text: `${hit.summary || hit.label}
1401
+
1402
+ ${gaps.length ? `${localized6.text26}${gaps.join(", ")}.` : localized6.text27}`,
1403
+ facts,
1404
+ reads: [hit.path, ...anchors.map((anchor) => anchor.path)],
1405
+ sources: [
1406
+ from(hit),
1407
+ ...anchors.map((anchor) => ({ text: `${anchor.path}:${anchor.line}`, recordId: null }))
1408
+ ],
1409
+ openId: hit.id,
1410
+ section: null,
1411
+ follow: [
1412
+ `${localized6.text28}${hit.label}${localized6.text29}`,
1413
+ `${remainingText.text32}${hit.label}?`
1414
+ ]
1415
+ };
1416
+ }
1417
+ function aboutRules(model) {
1418
+ const rows = model.overdueList.map(
1419
+ ({ rec, check }) => `${rec.label} \xB7 ${check.id}${localized6.text30}${check.next_due}`
1420
+ );
1421
+ const head = model.overdue === 1 ? localized6.text31 : `${model.overdue}${localized6.text32}`;
1422
+ const tail = !model.stale ? localized6.text33 : model.stale === 1 ? localized6.text34 : `${labelText.text408}${model.stale}${localized6.text35}`;
1423
+ return {
1424
+ text: model.overdue ? `${head}
1425
+ ${rows.join("\n")}
1426
+
1427
+ ${tail}` : `${localized6.text36}${model.clauseCount}${labelText.text409}${model.mustCount} davon verpflichtend.
1428
+
1429
+ ${tail}`,
1430
+ facts: [
1431
+ fact(localized6.text37, String(model.overdue), model.overdue ? "deadline" : "neutral"),
1432
+ fact(labelText.text361, String(model.clauseCount)),
1433
+ fact("VERPFLICHTEND", String(model.mustCount)),
1434
+ fact(
1435
+ labelText.text410,
1436
+ String(model.policies.reduce((sum, policy) => sum + policy.artifacts.length, 0))
1437
+ )
1438
+ ],
1439
+ reads: model.policies.map((policy) => policy.path),
1440
+ sources: model.policies.map(from),
1441
+ openId: null,
1442
+ section: "rules",
1443
+ follow: [labelText.text411, remainingText.text33]
1444
+ };
1445
+ }
1446
+ function aboutTests(model) {
1447
+ const worst = [...model.domainCov].sort((a, b) => (a.pct ?? 0) - (b.pct ?? 0))[0];
1448
+ const testLoc = typeof model.scan.testLoc === "number" ? model.scan.testLoc : 0;
1449
+ const totalLoc = typeof model.scan.totalLoc === "number" ? model.scan.totalLoc : 0;
1450
+ return {
1451
+ text: `${pct(model.scnProven, model.scnTotal)}${localized6.text38}${model.scnProven}${remainingText.text34}${model.scnTotal}${localized6.text39}${localized6.text40}${worst ? `${worst.name}${localized6.text41}${worst.pct} %` : "\u2014"}. ${remainingText.text35}${formatNumber(testLoc)}${remainingText.text34}${formatNumber(totalLoc)}${localized6.text42}`,
1452
+ facts: [
1453
+ fact("TEST ZUGEORDNET", `${model.scnProven}/${model.scnTotal}`),
1454
+ fact(localized6.text43, String(model.scnTotal - model.scnProven), "signal")
1455
+ ],
1456
+ reads: model.features.map((feature) => feature.path),
1457
+ sources: model.features.map(from),
1458
+ openId: null,
1459
+ section: "promises",
1460
+ follow: [localized6.text44, remainingText.text36]
1461
+ };
1462
+ }
1463
+ function aboutOpen(model) {
1464
+ const all = focusItems(model);
1465
+ const items = all.slice(0, 5);
1466
+ return {
1467
+ text: `${all.length === 1 ? localized6.text45 : `${remainingText.text37}${all.length}${localized6.text46}${items.length === 1 ? localized6.text47 : `${items.length}${localized6.text48}`}:`}
1468
+ ${items.map((item, index) => `${index + 1}. ${item.title} \u2014 ${item.why}`).join("\n")}
1469
+
1470
+ ` + localized6.text49,
1471
+ facts: [
1472
+ fact(localized6.text50, String(all.length), all.length ? "signal" : "neutral"),
1473
+ fact(remainingText.text38, String(model.overdue), model.overdue ? "deadline" : "neutral"),
1474
+ fact(localized6.text51, String(model.scnTotal - model.scnProven), "signal")
1475
+ ],
1476
+ reads: model.paths.slice(0, 6),
1477
+ sources: items.map((item) => model.byId[item.id]).filter(Boolean).map(from),
1478
+ openId: null,
1479
+ section: null,
1480
+ follow: [localized6.text52, localized6.text53]
1481
+ };
1482
+ }
1483
+ function aboutTeams(model) {
1484
+ const names = Object.keys(model.teams);
1485
+ return {
1486
+ text: `${names.length === 1 ? localized6.text54 : `${names.length} Teams tragen Records. `}` + names.map(
1487
+ (team) => `${team} (${model.teams[team].items.length}, ${model.teams[team].contact || localized6.text55})`
1488
+ ).join("\n") + (model.noOwner.length ? `${localized6.text56}${model.noOwner.map((record) => record.label).join(", ")}.` : localized6.text57),
1489
+ facts: [
1490
+ fact("TEAMS", String(names.length)),
1491
+ fact(
1492
+ localized6.text58,
1493
+ String(model.noOwner.length),
1494
+ model.noOwner.length ? "signal" : "neutral"
1495
+ )
1496
+ ],
1497
+ reads: model.paths.slice(0, 5),
1498
+ sources: model.recs.slice(0, 5).map(from),
1499
+ openId: null,
1500
+ section: "teams",
1501
+ follow: [localized6.text59]
1502
+ };
1503
+ }
1504
+ function aboutData(model) {
1505
+ return {
1506
+ text: `${model.pii}${localized6.text60}${model.enc}${localized6.text61}` + model.entities.map((entity) => `${entity.label} \xB7 ${entity.fields.length}${labelText.text412}`).join("\n"),
1507
+ facts: [
1508
+ fact(labelText.text366, String(model.pii), model.pii ? "deadline" : "neutral"),
1509
+ fact(localized6.text62, String(model.enc)),
1510
+ fact("DATENOBJEKTE", String(model.entities.length))
1511
+ ],
1512
+ reads: model.entities.map((entity) => entity.path),
1513
+ sources: model.entities.map(from),
1514
+ openId: null,
1515
+ section: "data",
1516
+ follow: [localized6.text63]
1517
+ };
1518
+ }
1519
+ function aboutCode(model) {
1520
+ const drift = model.scan.drift ?? [];
1521
+ const orphans = (model.scan.orphanAnchors ?? []).length;
1522
+ return {
1523
+ text: `${model.anchorPairs.length}${remainingText.text39}${Object.keys(model.anchorMap).length}${remainingText.text40}` + (drift.length ? `${localized6.text64}${drift.map((entry) => entry.id).join(", ")}.
1524
+ ` : "") + (!model.unanchored.length ? localized6.text65 : model.unanchored.length === 1 ? `${localized6.text66}${model.unanchored[0].label}.` : `${model.unanchored.length}${localized6.text67}${model.unanchored.map((record) => record.label).join(", ")}.`) + (!orphans ? "" : orphans === 1 ? localized6.text68 : `${remainingText.text41}${orphans}${localized6.text69}`),
1525
+ facts: [
1526
+ fact(labelText.text363, String(model.anchorPairs.length)),
1527
+ fact(
1528
+ localized6.text70,
1529
+ String(model.unanchored.length),
1530
+ model.unanchored.length ? "signal" : "neutral"
1531
+ ),
1532
+ fact(localized6.text71, String(drift.length), drift.length ? "deadline" : "neutral")
1533
+ ],
1534
+ reads: model.anchorPairs.slice(0, 6).map((anchor) => anchor.path),
1535
+ sources: model.anchorPairs.slice(0, 6).map((anchor) => ({ text: `${anchor.path}:${anchor.line}`, recordId: null })),
1536
+ openId: null,
1537
+ section: "code",
1538
+ follow: [localized6.text72]
1539
+ };
1540
+ }
1541
+ function aboutGraph(model) {
1542
+ return {
1543
+ text: `${localized6.text73}${model.edges.length}${localized6.text74}${model.maxDepth}${model.maxDepth === 1 ? remainingText.text42 : remainingText.text43}` + (!model.ghosts.length ? localized6.text75 : `${model.ghosts.length === 1 ? localized6.text76 : remainingText.text44}${model.ghosts.join(", ")}.`),
1544
+ facts: [
1545
+ fact("KANTEN", String(model.edges.length)),
1546
+ fact("DEPTH", String(model.maxDepth)),
1547
+ fact(
1548
+ remainingText.text45,
1549
+ String(model.ghosts.length),
1550
+ model.ghosts.length ? "signal" : "neutral"
1551
+ )
1552
+ ],
1553
+ reads: model.paths.slice(0, 6),
1554
+ sources: model.recs.slice(0, 4).map(from),
1555
+ openId: null,
1556
+ section: "graph",
1557
+ follow: [localized6.text77]
1558
+ };
1559
+ }
1560
+ function aboutOps(model) {
1561
+ const measured = model.recs.filter((record) => record.slos.length || record.alerts.length);
1562
+ return {
1563
+ text: `${model.slos.length}${localized6.text78}${model.alerts.length}${localized6.text79}` + (!model.noRunbook ? localized6.text80 : model.noRunbook === 1 ? localized6.text81 : `${model.noRunbook}${localized6.text82}`) + (!model.noObs.length ? "" : model.noObs.length === 1 ? `${localized6.text83}${model.noObs[0].label}.` : `
1564
+ ${model.noObs.length}${localized6.text84}${model.noObs.map((feature) => feature.label).join(", ")}.`),
1565
+ facts: [
1566
+ fact("SLOS", String(model.slos.length)),
1567
+ fact(labelText.text367, String(model.alerts.length)),
1568
+ fact(localized6.text85, String(model.noRunbook), model.noRunbook ? "signal" : "neutral"),
1569
+ fact("MESSQUELLEN", model.sources.join(", ") || "\u2014")
1570
+ ],
1571
+ reads: measured.map((record) => record.path),
1572
+ sources: measured.map(from),
1573
+ openId: null,
1574
+ section: "ops",
1575
+ follow: [localized6.text86]
1576
+ };
1577
+ }
1578
+ function aboutCorpus(model) {
1579
+ const records = typeof model.rc.records === "string" ? model.rc.records : "docs/facets";
1580
+ const sources = asStrings(model.rc.sources);
1581
+ const lines = typeof model.scan.totalLoc === "number" ? model.scan.totalLoc : 0;
1582
+ const scannedAt = String(model.scan.scannedAt ?? "").slice(0, 10);
1583
+ return {
1584
+ text: `${localized6.text87}${model.recs.length} Records unter ${records}${localized6.text88}${sources.join(", ") || "sources"} \u2014 ${formatNumber(lines)}${labelText.text359}${scannedAt ? `, Stand ${scannedAt}` : ""}.
1585
+
1586
+ ` + localized6.text89,
1587
+ facts: [
1588
+ fact("RECORDS", String(model.recs.length)),
1589
+ fact(localized6.text90, String(model.paths.length)),
1590
+ fact(labelText.text413, formatNumber(lines)),
1591
+ fact(localized6.text91, String(focusItems(model).length), "signal")
1592
+ ],
1593
+ reads: [".facetrc.yaml", records],
1594
+ sources: model.recs.slice(0, 3).map(from),
1595
+ openId: null,
1596
+ section: null,
1597
+ follow: [labelText.text388, localized6.text92, localized6.text93]
1598
+ };
1599
+ }
1600
+ function asStrings(value) {
1601
+ return Array.isArray(value) ? value.map(String) : [];
1602
+ }
1603
+
1604
+ // src/i18n/legacy/core/agent.ts
1605
+ var localized7 = {
1606
+ text1: "Der Agent hat abgebrochen.",
1607
+ text2: "Kein Agent erreichbar.",
1608
+ text3: "Dieser Host kennt kein EventSource \u2014 bitte `open` mitgeben."
1609
+ };
1610
+
1611
+ // src/core/agent.ts
1612
+ var AGENT_PATH = "/api/companion";
1613
+ function askAgent(question, handlers = {}, options = {}) {
1614
+ const open = options.open ?? defaultOpen2;
1615
+ const params = new URLSearchParams({ q: question });
1616
+ if (options.session) params.set("session", options.session);
1617
+ if (options.model) params.set("model", options.model);
1618
+ if (options.mode) params.set("mode", options.mode);
1619
+ for (const entry of options.context ?? []) params.append("context", entry);
1620
+ let stream;
1621
+ try {
1622
+ stream = open(`${AGENT_PATH}?${params.toString()}`);
1623
+ } catch (error) {
1624
+ handlers.onError?.(error);
1625
+ return () => {
1626
+ };
1627
+ }
1628
+ let closed = false;
1629
+ const close = () => {
1630
+ if (closed) return;
1631
+ closed = true;
1632
+ stream.close();
1633
+ };
1634
+ const fail = (error) => {
1635
+ if (closed) return;
1636
+ close();
1637
+ handlers.onError?.(error);
1638
+ };
1639
+ stream.addEventListener("status", (event) => {
1640
+ const step = decode2(event.data);
1641
+ if (step instanceof Error) return fail(step);
1642
+ handlers.onStatus?.(step.text ?? "", step.tokens ?? 0);
1643
+ });
1644
+ stream.addEventListener("thinking", (event) => {
1645
+ const step = decode2(event.data);
1646
+ if (step instanceof Error) return fail(step);
1647
+ if (step.text) handlers.onThinking?.(step.text);
1648
+ });
1649
+ stream.addEventListener("compacted", () => handlers.onCompacted?.());
1650
+ stream.addEventListener("signin", (event) => {
1651
+ const step = decode2(event.data);
1652
+ if (step instanceof Error) return fail(step);
1653
+ close();
1654
+ handlers.onSignIn?.(step.text ?? "", step.hint ?? "");
1655
+ });
1656
+ stream.addEventListener("read", (event) => {
1657
+ const step = decode2(event.data);
1658
+ if (step instanceof Error) return fail(step);
1659
+ if (step.target) handlers.onRead?.(step.target, step.tool ?? "");
1660
+ });
1661
+ stream.addEventListener("text", (event) => {
1662
+ const step = decode2(event.data);
1663
+ if (step instanceof Error) return fail(step);
1664
+ if (step.text) handlers.onText?.(step.text);
1665
+ });
1666
+ stream.addEventListener("done", (event) => {
1667
+ const step = decode2(event.data);
1668
+ if (step instanceof Error) return fail(step);
1669
+ if (closed) return;
1670
+ close();
1671
+ handlers.onDone?.(step.session ?? "", step.cost ?? 0);
1672
+ });
1673
+ stream.addEventListener("failed", (event) => {
1674
+ const step = decode2(event.data);
1675
+ if (step instanceof Error) return fail(step);
1676
+ fail(new Error(step.text || localized7.text1));
1677
+ });
1678
+ stream.addEventListener("error", () => {
1679
+ fail(new Error(localized7.text2));
1680
+ });
1681
+ return close;
1682
+ }
1683
+ function defaultOpen2(url) {
1684
+ if (typeof EventSource === "undefined") {
1685
+ throw new Error(localized7.text3);
1686
+ }
1687
+ return new EventSource(url);
1688
+ }
1689
+ function decode2(data) {
1690
+ try {
1691
+ return JSON.parse(data);
1692
+ } catch (error) {
1693
+ return new Error(`Unreadable answer from the agent: ${error.message}`);
1694
+ }
1695
+ }
1696
+ var AGENT_STATE_PATH = "/api/companion/state";
1697
+ async function agentState(fetcher) {
1698
+ const get = fetcher ?? (typeof fetch === "function" ? fetch : null);
1699
+ if (!get) return null;
1700
+ try {
1701
+ const response = await get(AGENT_STATE_PATH, { headers: { accept: "application/json" } });
1702
+ if (!response.ok) return null;
1703
+ const body = await response.json();
1704
+ return meetsContract(body) ? body : null;
1705
+ } catch {
1706
+ return null;
1707
+ }
1708
+ }
1709
+ function meetsContract(body) {
1710
+ if (typeof body !== "object" || body === null) return false;
1711
+ const { auth, models } = body;
1712
+ if (typeof auth !== "object" || auth === null) return false;
1713
+ if (typeof auth.loggedIn !== "boolean") return false;
1714
+ return Array.isArray(models);
1715
+ }
1716
+
1717
+ // src/i18n/legacy/core/rag.ts
1718
+ var localized8 = {
1719
+ text1: " (N\xE4he ",
1720
+ text2: "Eine Stelle im Bestand liegt nah an der Frage:",
1721
+ text3: " Stellen im Bestand liegen nah an der Frage:",
1722
+ text4: "Der Index vergleicht W\xF6rter, keine Bedeutung \u2014 mit einem Einbettungsmodell in .facetrc.yaml wird das besser. Ich fasse nicht zusammen: aufmachen und lesen.",
1723
+ text5: "Ich fasse nicht zusammen. Die Stellen stehen oben mit ihrer Datei; die Antwort steht dort, nicht hier.",
1724
+ text6: "N\xC4HE",
1725
+ text7: "Was ist bei ",
1726
+ text8: " offen?",
1727
+ text9: "Wo liegt das im Code?",
1728
+ text10: "Im Bestand steht dazu nichts \u2014 weder in den Records noch in der erzeugten Dokumentation.\n\n",
1729
+ text11: "Das ist eine Antwort und kein Fehler: Was hier nicht dokumentiert ist, erfinde ich nicht."
1730
+ };
1731
+
1732
+ // src/core/rag.ts
1733
+ var RAG_PATH = "/api/rag";
1734
+ var RAG_TOOL = "mcp__facet__rag_query";
1735
+ function isRagTool(tool) {
1736
+ return tool.toLowerCase() === RAG_TOOL.toLowerCase();
1737
+ }
1738
+ function ragQueryOf(tool, target) {
1739
+ return isRagTool(tool) ? target.trim() || "" : null;
1740
+ }
1741
+ async function queryIndex(question, options = {}) {
1742
+ const get = options.fetcher ?? (typeof fetch === "function" ? fetch : null);
1743
+ if (!get) return null;
1744
+ const params = new URLSearchParams({ q: question });
1745
+ if (options.limit) params.set("n", String(options.limit));
1746
+ try {
1747
+ const response = await get(`${RAG_PATH}?${params.toString()}`, {
1748
+ headers: { accept: "application/json" },
1749
+ signal: options.signal
1750
+ });
1751
+ if (!response.ok) return null;
1752
+ const body = await response.json();
1753
+ if (!body || !Array.isArray(body.hits)) return null;
1754
+ return body;
1755
+ } catch {
1756
+ return null;
1757
+ }
1758
+ }
1759
+ var MIN_WORDS = 3;
1760
+ function shouldConsultIndex(model, question) {
1761
+ const words = question.trim().split(/\s+/).filter(Boolean);
1762
+ if (words.length < MIN_WORDS) return false;
1763
+ if (question.trim().startsWith("/")) return false;
1764
+ return companionRoute(model, question) === "corpus";
1765
+ }
1766
+ function ragPlan(response) {
1767
+ const hits = response.hits;
1768
+ const best = hits[0];
1769
+ const lines = hits.map((hit) => {
1770
+ const where = hit.feature ? `${hit.feature} \xB7 ${hit.facet}` : hit.path;
1771
+ return `${where} \u2014 ${hit.path}${localized8.text1}${hit.score.toFixed(2)})`;
1772
+ });
1773
+ const head = hits.length === 1 ? localized8.text2 : `${hits.length}${localized8.text3}`;
1774
+ const foot = response.lexical ? localized8.text4 : localized8.text5;
1775
+ return {
1776
+ text: `${head}
1777
+ ${lines.join("\n")}
1778
+
1779
+ ${foot}`,
1780
+ facts: [
1781
+ { label: "GEFUNDEN", value: String(hits.length), meaning: "neutral" },
1782
+ {
1783
+ label: localized8.text6,
1784
+ value: best ? best.score.toFixed(2) : "\u2014",
1785
+ meaning: best && best.score < 0.3 ? "signal" : "neutral"
1786
+ },
1787
+ {
1788
+ label: "DURCHSUCHT",
1789
+ value: `${response.chunks ?? 0}${labelText.text357}`,
1790
+ meaning: "neutral"
1791
+ }
1792
+ ],
1793
+ reads: hits.map((hit) => hit.path),
1794
+ sources: hits.map((hit) => ({ text: hit.path, recordId: hit.feature ?? null })),
1795
+ openId: best?.feature ?? null,
1796
+ section: null,
1797
+ follow: best?.feature ? [`${localized8.text7}${best.feature}${localized8.text8}`, localized8.text9] : []
1798
+ };
1799
+ }
1800
+ function ragEmptyPlan(response) {
1801
+ return {
1802
+ text: localized8.text10 + localized8.text11,
1803
+ facts: [
1804
+ { label: "GEFUNDEN", value: "0", meaning: "signal" },
1805
+ {
1806
+ label: "DURCHSUCHT",
1807
+ value: `${response.chunks ?? 0}${labelText.text357}`,
1808
+ meaning: "neutral"
1809
+ }
1810
+ ],
1811
+ reads: [],
1812
+ sources: [],
1813
+ openId: null,
1814
+ section: null,
1815
+ follow: []
1816
+ };
1817
+ }
1818
+
1819
+ // src/core/terms.ts
1820
+ var MIN_SUBSTANTIAL_CAPABILITY_RECORDS = 3;
1821
+ function termOwner(records) {
1822
+ const teams = new Set(records.map((record) => record.team).filter(Boolean));
1823
+ return teams.size === 1 ? [...teams][0] : "";
1824
+ }
1825
+ function sortEntries(entries) {
1826
+ return [...entries].sort(
1827
+ (a, b) => b.count !== a.count ? b.count - a.count : a.key.localeCompare(b.key)
1828
+ );
1829
+ }
1830
+ function domainEntries(model) {
1831
+ return sortEntries(
1832
+ model.domains.map((domain) => ({
1833
+ key: domain.name,
1834
+ kind: "domain",
1835
+ label: domain.name,
1836
+ count: domain.items.length,
1837
+ owner: termOwner(domain.items),
1838
+ records: domain.items.map((item) => item.id)
1839
+ }))
1840
+ );
1841
+ }
1842
+ function capabilityEntries(model) {
1843
+ const groups = /* @__PURE__ */ new Map();
1844
+ model.features.forEach((feature) => {
1845
+ if (!feature.capability) return;
1846
+ const key = `${feature.domain}/${feature.capability}`;
1847
+ const list = groups.get(key);
1848
+ if (list) list.push(feature);
1849
+ else groups.set(key, [feature]);
1850
+ });
1851
+ const entries = [];
1852
+ groups.forEach((records, key) => {
1853
+ if (records.length < MIN_SUBSTANTIAL_CAPABILITY_RECORDS) return;
1854
+ entries.push({
1855
+ key,
1856
+ kind: "capability",
1857
+ label: key,
1858
+ count: records.length,
1859
+ owner: termOwner(records),
1860
+ records: records.map((record) => record.id)
1861
+ });
1862
+ });
1863
+ return sortEntries(entries);
1864
+ }
1865
+ function usedByEntity(model, entity) {
1866
+ const usedBy = /* @__PURE__ */ new Set([...entity.readBy, ...entity.mutatedBy, ...entity.referencedBy]);
1867
+ model.recs.forEach((record) => {
1868
+ if (record.id === entity.id) return;
1869
+ if (record.relatedEntities.includes(entity.id)) usedBy.add(record.id);
1870
+ });
1871
+ usedBy.delete(entity.id);
1872
+ return [...usedBy].filter(Boolean).sort();
1873
+ }
1874
+ function entityEntries(model) {
1875
+ return sortEntries(
1876
+ model.entities.map((entity) => {
1877
+ const records = usedByEntity(model, entity);
1878
+ return {
1879
+ key: entity.id,
1880
+ kind: "entity",
1881
+ label: entity.label,
1882
+ count: records.length,
1883
+ owner: entity.team,
1884
+ records
1885
+ };
1886
+ })
1887
+ );
1888
+ }
1889
+ function policyEntries(model) {
1890
+ return sortEntries(
1891
+ model.policies.map((policy) => {
1892
+ const records = model.features.filter((feature) => coverage(policy, feature) !== null).map((feature) => feature.id).sort();
1893
+ return {
1894
+ key: policy.id,
1895
+ kind: "policy",
1896
+ label: policy.label,
1897
+ count: records.length,
1898
+ owner: policy.team,
1899
+ records
1900
+ };
1901
+ })
1902
+ );
1903
+ }
1904
+ function usedByAssumption(model, assumption) {
1905
+ const usedBy = new Set(assumption.referencedBy);
1906
+ model.recs.forEach((record) => {
1907
+ if (record.id === assumption.id) return;
1908
+ if (record.relatedAssumptions.includes(assumption.id)) usedBy.add(record.id);
1909
+ });
1910
+ usedBy.delete(assumption.id);
1911
+ return [...usedBy].filter(Boolean).sort();
1912
+ }
1913
+ function assumptionEntries(model) {
1914
+ return sortEntries(
1915
+ model.assumptions.map((assumption) => {
1916
+ const records = usedByAssumption(model, assumption);
1917
+ return {
1918
+ key: assumption.id,
1919
+ kind: "assumption",
1920
+ label: assumption.label,
1921
+ count: records.length,
1922
+ owner: assumption.team,
1923
+ records
1924
+ };
1925
+ })
1926
+ );
1927
+ }
1928
+ function buildTermIndex(model) {
1929
+ return {
1930
+ domains: domainEntries(model),
1931
+ capabilities: capabilityEntries(model),
1932
+ entities: entityEntries(model),
1933
+ policies: policyEntries(model),
1934
+ assumptions: assumptionEntries(model)
1935
+ };
1936
+ }
1937
+
1938
+ // src/i18n/legacy/core/quietLines.ts
1939
+ var localized9 = {
1940
+ text1: "Keine Pr\xFCfung ist \xFCberf\xE4llig.",
1941
+ text2: "Jeder aktive Record hat einen Einstieg im Code.",
1942
+ text3: "Jeder Record hat ein Team.",
1943
+ text4: "Kein Verweis zeigt ins Leere."
1944
+ };
1945
+
1946
+ // src/core/quietLines.ts
1947
+ function buildQuietLines(model) {
1948
+ const lines = [];
1949
+ const checksExist = model.policies.some((p) => p.complianceChecks.length > 0);
1950
+ if (checksExist && !model.overdue) {
1951
+ lines.push(localized9.text1);
1952
+ }
1953
+ const activeFeaturesExist = model.features.some((f) => f.activeAnywhere);
1954
+ if (activeFeaturesExist && !model.unanchored.length) {
1955
+ lines.push(localized9.text2);
1956
+ }
1957
+ if (model.recs.length > 0 && !model.noOwner.length) {
1958
+ lines.push(localized9.text3);
1959
+ }
1960
+ if (model.edges.length > 0 && !model.ghosts.length) {
1961
+ lines.push(localized9.text4);
1962
+ }
1963
+ return lines;
1964
+ }
1965
+
1966
+ export { AGENT_PATH, AGENT_STATE_PATH, COMPANION_FOOT, COMPANION_INTRO, INDEX_PHASES, KNOWLEDGE_SLOT_KEYS, MIN_SUBSTANTIAL_CAPABILITY_RECORDS, RAG_PATH, RAG_TOOL, ROLES, agentPlan, agentState, askAgent, buildQuietLines, buildTermIndex, codeCoverageOf, companionAnswer, companionRecord, companionRoute, companionScope, companionSuggestions, focusItems, germanText, initialStatus, isRagTool, isSafeHref, knowledgeCoverage, leadFor, leadSentenceFacts, mergeStatus, nextRole, parseInline, parseMarkdown, phaseRank, probeOf, queryIndex, ragEmptyPlan, ragPlan, ragQueryOf, roleByKey, shouldConsultIndex, slotStateFor, subscribeCorpus, termOwner };
1967
+ //# sourceMappingURL=chunk-SWCO2XQL.js.map
1968
+ //# sourceMappingURL=chunk-SWCO2XQL.js.map