@getchomp/cli 0.0.0-stage → 0.2.43

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -2
  3. package/dist/commands/analyze.d.ts +49 -0
  4. package/dist/commands/analyze.js +280 -0
  5. package/dist/commands/connect.d.ts +12 -0
  6. package/dist/commands/connect.js +255 -0
  7. package/dist/commands/export.d.ts +29 -0
  8. package/dist/commands/export.js +356 -0
  9. package/dist/commands/health.d.ts +19 -0
  10. package/dist/commands/health.js +259 -0
  11. package/dist/commands/init.d.ts +40 -0
  12. package/dist/commands/init.js +659 -0
  13. package/dist/commands/mcp.d.ts +2 -0
  14. package/dist/commands/mcp.js +12 -0
  15. package/dist/commands/plugin.d.ts +8 -0
  16. package/dist/commands/plugin.js +198 -0
  17. package/dist/commands/ui.d.ts +20 -0
  18. package/dist/commands/ui.js +252 -0
  19. package/dist/commands/uninstall.d.ts +8 -0
  20. package/dist/commands/uninstall.js +246 -0
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.js +37 -0
  23. package/dist/ports/portHydrator.d.ts +63 -0
  24. package/dist/ports/portHydrator.js +954 -0
  25. package/dist/ports/portHydratorWorker.d.ts +22 -0
  26. package/dist/ports/portHydratorWorker.js +75 -0
  27. package/dist/server/buildStatusTracker.d.ts +45 -0
  28. package/dist/server/buildStatusTracker.js +122 -0
  29. package/dist/server/graphLayoutState.d.ts +205 -0
  30. package/dist/server/graphLayoutState.js +930 -0
  31. package/dist/server/loopbackSecurity.d.ts +18 -0
  32. package/dist/server/loopbackSecurity.js +57 -0
  33. package/dist/server/routes/authSourceRoutes.d.ts +18 -0
  34. package/dist/server/routes/authSourceRoutes.js +231 -0
  35. package/dist/server/routes/layoutRoutes.d.ts +3 -0
  36. package/dist/server/routes/layoutRoutes.js +857 -0
  37. package/dist/server/routes/pluginRoutes.d.ts +3 -0
  38. package/dist/server/routes/pluginRoutes.js +368 -0
  39. package/dist/server/routes/viewRulesRoutes.d.ts +3 -0
  40. package/dist/server/routes/viewRulesRoutes.js +173 -0
  41. package/dist/server/uiHotkeys.d.ts +26 -0
  42. package/dist/server/uiHotkeys.js +160 -0
  43. package/dist/utils/branding.d.ts +126 -0
  44. package/dist/utils/branding.js +978 -0
  45. package/dist/utils/credentials.d.ts +22 -0
  46. package/dist/utils/credentials.js +126 -0
  47. package/dist/utils/git.d.ts +95 -0
  48. package/dist/utils/git.js +780 -0
  49. package/dist/utils/masterContext.d.ts +112 -0
  50. package/dist/utils/masterContext.js +642 -0
  51. package/dist/visualizer/cloudLayoutClient.d.ts +84 -0
  52. package/dist/visualizer/cloudLayoutClient.js +1200 -0
  53. package/dist/visualizer/layoutCache.d.ts +25 -0
  54. package/dist/visualizer/layoutCache.js +406 -0
  55. package/dist/visualizer/localEngineBridge.d.ts +50 -0
  56. package/dist/visualizer/localEngineBridge.js +80 -0
  57. package/dist/visualizer/pluginPresentationApi.d.ts +111 -0
  58. package/dist/visualizer/pluginPresentationApi.js +432 -0
  59. package/dist/visualizer/rulesConfig.d.ts +11 -0
  60. package/dist/visualizer/rulesConfig.js +266 -0
  61. package/dist/visualizer/sourceAccess.d.ts +45 -0
  62. package/dist/visualizer/sourceAccess.js +204 -0
  63. package/package.json +52 -3
@@ -0,0 +1,432 @@
1
+ /**
2
+ * packages/cli/src/visualizer/pluginPresentationApi.ts
3
+ *
4
+ * Server-side model for the Plugin Presentation Contract ([PAT-VIS-36]). Pure functions (no Express, no DB)
5
+ * so they are unit-testable:
6
+ *
7
+ * - `splitOverlays` – the heavy `payload.presentation` is deferred out of the structural
8
+ * `/api/layout` & `/api/graph` payloads (other payload fields stay, because
9
+ * custom rules and node badges may read them).
10
+ * - `computeStructureFingerprint` / `computePluginFingerprint`
11
+ * – independent fingerprints so the client re-lays-out only when the structure
12
+ * changes and re-fetches plugin data when only plugins changed.
13
+ * - `buildPluginsOverview` – HUD cards (`GET /api/plugins`).
14
+ * - `buildEntityPresentations` – inspector sections for one entity (`GET /api/plugins/presentation`).
15
+ * - `startPluginRun` & co. – in-memory run state for UI-triggered plugin runs.
16
+ */
17
+ import { createHash } from "node:crypto";
18
+ import { deferPresentationInPayload, payloadHasPresentation, readPresentationFromPayload, } from "@getchomp/core";
19
+ export function isPluginOverlay(ov) {
20
+ return payloadHasPresentation(ov.payload);
21
+ }
22
+ /**
23
+ * `layout`: every overlay in structural form (presentation deferred, `presentationAvailable` marker set).
24
+ * `plugin`: the overlays that carry a presentation, in full, for `/api/plugins/*`.
25
+ */
26
+ export function splitOverlays(overlays) {
27
+ const layout = [];
28
+ const plugin = [];
29
+ for (const ov of overlays) {
30
+ if (isPluginOverlay(ov)) {
31
+ plugin.push(ov);
32
+ layout.push({ ...ov, payload: deferPresentationInPayload(ov.payload) });
33
+ }
34
+ else {
35
+ layout.push(ov);
36
+ }
37
+ }
38
+ return { layout, plugin };
39
+ }
40
+ /** Do the user's custom rules read overlay data? If so, plugin writes can legitimately change the layout. */
41
+ export function rulesReferenceOverlays(customRules) {
42
+ return (customRules ?? []).some((r) => Boolean(r.match?.overlayLayer || r.match?.overlaySource || r.match?.overlayField));
43
+ }
44
+ function isStructuralShimOverlay(ov) {
45
+ if (ov.layer !== "L1_SHIMS")
46
+ return false;
47
+ const p = ov.payload;
48
+ return Boolean(p &&
49
+ ((Array.isArray(p.shimmedEdges) && p.shimmedEdges.length > 0) ||
50
+ (Array.isArray(p.syntheticConnectors) && p.syntheticConnectors.length > 0)));
51
+ }
52
+ /**
53
+ * Overlays that participate in the structure fingerprint: all non-plugin overlays, `L1_SHIMS`
54
+ * overlays that project edges/connectors onto the story graph, plus other plugin overlays
55
+ * (in structural form) only when rules reference overlays. Otherwise presentation-only plugin runs
56
+ * never force a re-layout.
57
+ */
58
+ export function overlaysForStructureFingerprint(split, rulesUseOverlays, isStructuralOverlay = isStructuralShimOverlay) {
59
+ if (rulesUseOverlays)
60
+ return split.layout;
61
+ const pluginKeys = new Set(split.plugin.map((o) => `${o.entityId}\u0000${o.layer}\u0000${o.source}\u0000${o.environment}`));
62
+ return split.layout.filter((o) => {
63
+ if (o.layer === "L1_PORTS") {
64
+ const diags = o.payload?.diagnostics;
65
+ return Array.isArray(diags) && diags.length > 0;
66
+ }
67
+ return (isStructuralOverlay(o) ||
68
+ !pluginKeys.has(`${o.entityId}\u0000${o.layer}\u0000${o.source}\u0000${o.environment}`));
69
+ });
70
+ }
71
+ function sha(parts) {
72
+ return createHash("sha1").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
73
+ }
74
+ /**
75
+ * Content-based: unchanged when a re-analysis produces the same structure, and unaffected by
76
+ * plugin overlay writes.
77
+ */
78
+ export function computeStructureFingerprint(nodes, edges, structuralOverlays) {
79
+ const h = createHash("sha1");
80
+ for (const n of nodes)
81
+ h.update(`${n.id}:${String(n.metadata?.bodyHash ?? "")};`);
82
+ h.update("|");
83
+ for (const e of edges)
84
+ h.update(`${e.id ?? ""}>${e.targetId ?? ""}:${e.status ?? ""};`);
85
+ h.update("|");
86
+ for (const o of structuralOverlays) {
87
+ h.update(`${o.entityId}:${o.layer}:${o.source}:${o.environment}:${o.runId ?? ""}:${o.updatedAt ?? ""}:${JSON.stringify(o.payload ?? {}).length};`);
88
+ }
89
+ return h.digest("hex").slice(0, 16);
90
+ }
91
+ export function computePluginFingerprint(pluginOverlays, runs, registry) {
92
+ return sha([
93
+ pluginOverlays
94
+ .map((o) => [o.entityId, o.layer, o.source, o.environment, o.runId ?? "", o.updatedAt ?? "", o.stale ?? false])
95
+ .sort((a, b) => String(a[0]).localeCompare(String(b[0])) || String(a[2]).localeCompare(String(b[2]))),
96
+ Object.entries(runs)
97
+ .map(([k, v]) => [k, v.state, v.startedAt ?? "", v.finishedAt ?? "", v.error ?? ""])
98
+ .sort((a, b) => String(a[0]).localeCompare(String(b[0]))),
99
+ ...(registry
100
+ ? [
101
+ registry
102
+ .map((m) => [
103
+ m.name,
104
+ m.order ?? null,
105
+ m.settings ?? {},
106
+ m.envStatus ?? {},
107
+ m.lastRun?.finishedAt ?? "",
108
+ m.lastRun?.status ?? "",
109
+ m.lastRun?.error ?? "",
110
+ m.lastRun?.presentationWarnings ?? [],
111
+ ])
112
+ .sort((a, b) => String(a[0]).localeCompare(String(b[0]))),
113
+ ]
114
+ : []),
115
+ ]);
116
+ }
117
+ function humanize(layer) {
118
+ const cleaned = layer.replace(/^PLUGIN:/i, "").replace(/^L\d+_/, "").replace(/[_-]+/g, " ").trim().toLowerCase();
119
+ return cleaned ? cleaned.charAt(0).toUpperCase() + cleaned.slice(1) : layer;
120
+ }
121
+ const STATUS_RANK = { error: 4, warn: 3, unknown: 2, "n/a": 1, ok: 0 };
122
+ function worstStatus(summaries) {
123
+ let worst;
124
+ for (const s of summaries) {
125
+ if (!s.status)
126
+ continue;
127
+ if (worst === undefined || STATUS_RANK[s.status] > STATUS_RANK[worst])
128
+ worst = s.status;
129
+ }
130
+ return worst;
131
+ }
132
+ function packageLabelOf(node) {
133
+ const label = node.name.replace(/^Deployment Unit:\s*/i, "").trim();
134
+ return { label, key: label.replace(/^@[^/]+\//, "") };
135
+ }
136
+ function normalizeOverlayEnv(env) {
137
+ const clean = (env ?? "").trim();
138
+ return clean || "default";
139
+ }
140
+ export function collectAvailableOverlayEnvironments(pluginOverlays) {
141
+ const envs = new Set();
142
+ for (const ov of pluginOverlays) {
143
+ envs.add(normalizeOverlayEnv(ov.environment));
144
+ }
145
+ const rank = (e) => (e === "default" ? 0 : e === "production" ? 1 : 2);
146
+ return [...envs].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
147
+ }
148
+ function selectEffectiveEnvironment(overlays, requestedEnv) {
149
+ const envs = new Set(overlays.map((o) => normalizeOverlayEnv(o.environment)));
150
+ if (envs.has(requestedEnv))
151
+ return requestedEnv;
152
+ if (envs.has("default"))
153
+ return "default";
154
+ if (requestedEnv === "default" && envs.has("production"))
155
+ return "production";
156
+ return [...envs].sort((a, b) => a.localeCompare(b))[0] ?? requestedEnv;
157
+ }
158
+ export function buildPluginsOverview(params) {
159
+ const { pluginOverlays, nodes, registry, runs, structureFp } = params;
160
+ const requestedEnv = normalizeOverlayEnv(params.environment);
161
+ const availableEnvironments = collectAvailableOverlayEnvironments(pluginOverlays);
162
+ const nodeById = new Map(nodes.map((n) => [n.id, n]));
163
+ const metaBySource = new Map(registry.map((m) => [m.name, m]));
164
+ const groups = new Map();
165
+ for (const ov of pluginOverlays) {
166
+ const key = `${ov.source}\u0000${ov.layer}`;
167
+ let list = groups.get(key);
168
+ if (!list) {
169
+ list = [];
170
+ groups.set(key, list);
171
+ }
172
+ list.push(ov);
173
+ }
174
+ const entries = [];
175
+ for (const [key, rawGroup] of groups) {
176
+ const [source, layer] = key.split("\u0000");
177
+ const effectiveEnv = selectEffectiveEnvironment(rawGroup, requestedEnv);
178
+ const overlays = rawGroup.filter((o) => normalizeOverlayEnv(o.environment) === effectiveEnv);
179
+ const meta = metaBySource.get(source);
180
+ const packages = [];
181
+ for (const ov of overlays) {
182
+ const node = nodeById.get(ov.entityId);
183
+ if (!node || node.entityType !== "DEPLOYMENT_UNIT")
184
+ continue;
185
+ const p = readPresentationFromPayload(ov.payload);
186
+ if (!p?.summary)
187
+ continue;
188
+ const { label, key: pkgKey } = packageLabelOf(node);
189
+ packages.push({ entityId: ov.entityId, label, key: pkgKey, summary: p.summary });
190
+ }
191
+ packages.sort((a, b) => a.label.localeCompare(b.label));
192
+ const summaries = packages.map((p) => p.summary);
193
+ const issueCount = summaries.reduce((n, s) => n + (s.issueCount ?? 0), 0);
194
+ const firstPrompt = summaries.find((s) => s.prompt)?.prompt;
195
+ const repoPrompt = summaries.find((s) => s.repoPrompt)?.repoPrompt ?? firstPrompt;
196
+ const summaryDescription = summaries.find((s) => s.description)?.description;
197
+ const explicitRepoHeadline = summaries.find((s) => s.repoHeadline)?.repoHeadline;
198
+ let summary;
199
+ if (packages.length === 1) {
200
+ summary = packages[0].summary;
201
+ }
202
+ else if (packages.length > 1) {
203
+ const status = worstStatus(summaries);
204
+ const mergedViews = packages.flatMap((pkg) => (pkg.summary.views ?? []).map((v) => ({
205
+ ...v,
206
+ id: `${pkg.key}:${v.id}`,
207
+ title: `${pkg.label} · ${v.title}`,
208
+ })));
209
+ const aggregatedItemsMap = new Map();
210
+ for (const s of summaries) {
211
+ for (const item of s.items ?? []) {
212
+ const existing = aggregatedItemsMap.get(item.label);
213
+ if (!existing) {
214
+ aggregatedItemsMap.set(item.label, {
215
+ label: item.label,
216
+ numTotal: typeof item.value === "number" ? item.value : 0,
217
+ hasNum: typeof item.value === "number",
218
+ strVal: typeof item.value === "string" ? item.value : undefined,
219
+ mono: item.mono,
220
+ });
221
+ }
222
+ else {
223
+ if (typeof item.value === "number") {
224
+ existing.numTotal += item.value;
225
+ existing.hasNum = true;
226
+ }
227
+ else if (typeof item.value === "string" && !existing.strVal) {
228
+ existing.strVal = item.value;
229
+ }
230
+ if (item.mono)
231
+ existing.mono = true;
232
+ }
233
+ }
234
+ }
235
+ const mergedItems = [...aggregatedItemsMap.values()]
236
+ .sort((a, b) => (b.hasNum ? b.numTotal : -1) - (a.hasNum ? a.numTotal : -1) || a.label.localeCompare(b.label))
237
+ .slice(0, 6)
238
+ .map((it) => ({
239
+ label: it.label,
240
+ ...(it.hasNum ? { value: it.numTotal } : it.strVal !== undefined ? { value: it.strVal } : {}),
241
+ ...(it.mono ? { mono: true } : {}),
242
+ }));
243
+ const allUnknown = summaries.length > 0 && summaries.every((s) => s.status === "unknown");
244
+ const badge = allUnknown && summaries[0]?.badge
245
+ ? summaries[0].badge
246
+ : {
247
+ text: `${packages.length} packages`,
248
+ tone: status === "ok" ? "good" : status === "warn" ? "warn" : "neutral",
249
+ };
250
+ const headline = explicitRepoHeadline ??
251
+ (issueCount > 0
252
+ ? `${issueCount} open finding(s) across ${packages.length} package(s)`
253
+ : allUnknown
254
+ ? (summaries[0]?.headline ?? `Needs run across ${packages.length} package(s)`)
255
+ : mergedViews.length > 0
256
+ ? `${mergedViews.length} view(s) across ${packages.length} package(s)`
257
+ : `Active across ${packages.length} package(s)`);
258
+ summary = {
259
+ ...(status ? { status } : {}),
260
+ badge,
261
+ issueCount,
262
+ headline,
263
+ ...(summaryDescription ? { description: summaryDescription } : {}),
264
+ ...(mergedItems.length > 0 ? { items: mergedItems } : {}),
265
+ ...(mergedViews.length > 0 ? { views: mergedViews } : {}),
266
+ ...(repoPrompt ? { prompt: repoPrompt } : {}),
267
+ ...(summaries.length > 0 && summaries.every((s) => s.hideInHud === true)
268
+ ? { hideInHud: true }
269
+ : {}),
270
+ };
271
+ }
272
+ const updatedAt = overlays
273
+ .map((o) => o.updatedAt)
274
+ .filter((u) => Boolean(u))
275
+ .sort()
276
+ .pop();
277
+ const runId = overlays.find((o) => o.runId)?.runId ?? null;
278
+ entries.push({
279
+ source,
280
+ layer,
281
+ displayName: meta?.displayName ?? (meta ? humanize(meta.name) : humanize(layer)),
282
+ ...(meta?.description ? { description: meta.description } : {}),
283
+ ...(meta?.version ? { version: meta.version } : {}),
284
+ ...(meta?.order !== undefined ? { order: meta.order } : {}),
285
+ ...(meta?.defaultEnabled !== undefined ? { defaultEnabled: meta.defaultEnabled } : {}),
286
+ ...(meta?.stateDir ? { stateDir: meta.stateDir } : {}),
287
+ ...(meta?.settingsSchema ? { settingsSchema: meta.settingsSchema } : {}),
288
+ ...(meta?.settings ? { settings: meta.settings } : {}),
289
+ ...(meta?.envStatus ? { envStatus: meta.envStatus } : {}),
290
+ ...(meta?.mcpTools ? { mcpTools: meta.mcpTools } : {}),
291
+ environment: effectiveEnv,
292
+ runId,
293
+ ...(updatedAt ? { updatedAt } : {}),
294
+ overlayCount: overlays.length,
295
+ issueCount,
296
+ ...(summary ? { summary } : {}),
297
+ packages,
298
+ run: runs[source] ?? { state: "idle" },
299
+ ...(meta?.lastRun ? { lastRun: meta.lastRun } : {}),
300
+ });
301
+ }
302
+ // Registered plugins that have not produced presentation data yet still get a card (so they can be run).
303
+ for (const meta of registry) {
304
+ if (entries.some((e) => e.source === meta.name))
305
+ continue;
306
+ entries.push({
307
+ source: meta.name,
308
+ layer: meta.layer ?? meta.name,
309
+ displayName: meta.displayName ?? humanize(meta.name),
310
+ ...(meta.description ? { description: meta.description } : {}),
311
+ ...(meta.version ? { version: meta.version } : {}),
312
+ ...(meta.order !== undefined ? { order: meta.order } : {}),
313
+ ...(meta.defaultEnabled !== undefined ? { defaultEnabled: meta.defaultEnabled } : {}),
314
+ ...(meta.stateDir ? { stateDir: meta.stateDir } : {}),
315
+ ...(meta.settingsSchema ? { settingsSchema: meta.settingsSchema } : {}),
316
+ ...(meta.settings ? { settings: meta.settings } : {}),
317
+ ...(meta.envStatus ? { envStatus: meta.envStatus } : {}),
318
+ ...(meta.mcpTools ? { mcpTools: meta.mcpTools } : {}),
319
+ environment: requestedEnv,
320
+ runId: null,
321
+ overlayCount: 0,
322
+ issueCount: 0,
323
+ ...(meta.description
324
+ ? {
325
+ summary: {
326
+ status: "unknown",
327
+ headline: "Not analyzed yet",
328
+ description: meta.description,
329
+ },
330
+ }
331
+ : {}),
332
+ packages: [],
333
+ run: runs[meta.name] ?? { state: "idle" },
334
+ ...(meta.lastRun ? { lastRun: meta.lastRun } : {}),
335
+ });
336
+ }
337
+ entries.sort((a, b) => (a.order ?? 100) - (b.order ?? 100) ||
338
+ a.displayName.localeCompare(b.displayName));
339
+ return {
340
+ plugins: entries,
341
+ fingerprint: { structureFp, pluginFp: computePluginFingerprint(pluginOverlays, runs, registry) },
342
+ environment: requestedEnv,
343
+ ...(availableEnvironments.length > 0 ? { availableEnvironments } : {}),
344
+ };
345
+ }
346
+ export function buildEntityPresentations(params) {
347
+ const { pluginOverlays, entityId, registry, nodes } = params;
348
+ const requestedEnv = normalizeOverlayEnv(params.environment);
349
+ const metaBySource = new Map(registry.map((m) => [m.name, m]));
350
+ const entityNode = nodes?.find((n) => n.id === entityId);
351
+ const entityScope = nodes
352
+ ? entityNode?.entityType === "DEPLOYMENT_UNIT"
353
+ ? "package"
354
+ : "node"
355
+ : undefined;
356
+ const entityGroups = new Map();
357
+ for (const ov of pluginOverlays) {
358
+ if (ov.entityId !== entityId)
359
+ continue;
360
+ const meta = metaBySource.get(ov.source);
361
+ if (entityScope && meta?.inspectorScopes && !meta.inspectorScopes.includes(entityScope)) {
362
+ continue;
363
+ }
364
+ const key = `${ov.source}\u0000${ov.layer}`;
365
+ let list = entityGroups.get(key);
366
+ if (!list) {
367
+ list = [];
368
+ entityGroups.set(key, list);
369
+ }
370
+ list.push(ov);
371
+ }
372
+ const out = [];
373
+ for (const [, rawGroup] of entityGroups) {
374
+ const effectiveEnv = selectEffectiveEnvironment(rawGroup, requestedEnv);
375
+ const matching = rawGroup.filter((o) => normalizeOverlayEnv(o.environment) === effectiveEnv);
376
+ for (const ov of matching) {
377
+ const presentation = readPresentationFromPayload(ov.payload);
378
+ if (!presentation)
379
+ continue;
380
+ const meta = metaBySource.get(ov.source);
381
+ out.push({
382
+ source: ov.source,
383
+ layer: ov.layer,
384
+ displayName: meta?.displayName ?? (meta ? humanize(meta.name) : humanize(ov.layer)),
385
+ entityId,
386
+ environment: effectiveEnv,
387
+ runId: ov.runId ?? null,
388
+ ...(ov.updatedAt ? { updatedAt: ov.updatedAt } : {}),
389
+ ...(ov.stale ? { stale: true } : {}),
390
+ presentation,
391
+ });
392
+ }
393
+ }
394
+ out.sort((a, b) => a.displayName.localeCompare(b.displayName) || a.layer.localeCompare(b.layer));
395
+ return out;
396
+ }
397
+ const nowIso = () => new Date().toISOString();
398
+ export function getPluginRun(runs, name) {
399
+ return runs.get(name) ?? { state: "idle" };
400
+ }
401
+ export function snapshotPluginRuns(runs) {
402
+ return Object.fromEntries(runs);
403
+ }
404
+ export function isPluginRunning(runs, name) {
405
+ return getPluginRun(runs, name).state === "running";
406
+ }
407
+ export function startPluginRun(runs, name, now = nowIso) {
408
+ const status = { state: "running", startedAt: now() };
409
+ runs.set(name, status);
410
+ return status;
411
+ }
412
+ export function finishPluginRun(runs, name, now = nowIso) {
413
+ const prev = getPluginRun(runs, name);
414
+ const status = {
415
+ state: "idle",
416
+ ...(prev.startedAt ? { startedAt: prev.startedAt } : {}),
417
+ finishedAt: now(),
418
+ };
419
+ runs.set(name, status);
420
+ return status;
421
+ }
422
+ export function failPluginRun(runs, name, error, now = nowIso) {
423
+ const prev = getPluginRun(runs, name);
424
+ const status = {
425
+ state: "error",
426
+ ...(prev.startedAt ? { startedAt: prev.startedAt } : {}),
427
+ finishedAt: now(),
428
+ error: error.slice(0, 500),
429
+ };
430
+ runs.set(name, status);
431
+ return status;
432
+ }
@@ -0,0 +1,11 @@
1
+ import { matchesCustomRule, type BuiltInRulesConfig, type ChompRulesConfig, type CustomClassificationRule, type CustomRuleAction, type CustomRuleBadgeMode, type CustomRuleMatch, type SystemRuleStatus } from "@getchomp/core";
2
+ export { matchesCustomRule, type BuiltInRulesConfig, type ChompRulesConfig, type CustomClassificationRule, type CustomRuleAction, type CustomRuleBadgeMode, type CustomRuleMatch, type SystemRuleStatus, };
3
+ export declare function getDefaultOverlayLayers(): Record<string, boolean>;
4
+ export declare const DEFAULT_OVERLAY_LAYERS: Record<string, boolean>;
5
+ export declare const DEFAULT_RULES_CONFIG: ChompRulesConfig;
6
+ export declare function normalizeRulesConfig(raw: any): ChompRulesConfig;
7
+ export declare function resolveRulesFilePath(chompDirOrDbPath: string): string;
8
+ export declare function detectSystemRules(chompDirOrDbPath: string): SystemRuleStatus[];
9
+ export declare function loadRulesConfig(chompDirOrDbPath: string): ChompRulesConfig;
10
+ export declare function saveRulesConfig(chompDirOrDbPath: string, config: ChompRulesConfig): ChompRulesConfig;
11
+ export declare function getRulesFingerprint(chompDirOrDbPath: string): string;