@neat.is/core 0.9.8-dev.20260829 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  resolveHost,
7
7
  resolveNeatVersion,
8
8
  writeDaemonRecord
9
- } from "./chunk-JSUPWMH3.js";
9
+ } from "./chunk-I2I5MMO5.js";
10
10
  import {
11
11
  buildSearchIndex
12
12
  } from "./chunk-BC53SCT7.js";
@@ -75,7 +75,7 @@ import {
75
75
  startStalenessLoop,
76
76
  upsertConnectorEntry,
77
77
  validateConnectorEntry
78
- } from "./chunk-KZBFP7L6.js";
78
+ } from "./chunk-G4A6FCKG.js";
79
79
  import {
80
80
  startOtelGrpcReceiver
81
81
  } from "./chunk-ERE47MCR.js";
@@ -540,7 +540,7 @@ async function startWatch(graph, opts) {
540
540
  writeErrorEventInline: false,
541
541
  onPolicyTrigger
542
542
  });
543
- const onErrorSpanSync = makeErrorSpanWriter(opts.errorsPath, graph, opts.scanPath);
543
+ const onErrorSpanSync = makeErrorSpanWriter(opts.errorsPath, graph, opts.scanPath, projectName);
544
544
  const otelHttp = await buildOtelReceiver({ onSpan, onErrorSpanSync });
545
545
  const otelAddress = await listenSteppingOtlp(otelHttp, otelPort, host);
546
546
  const boundOtelPort = portFromListenAddress(otelAddress, otelPort);
@@ -6604,6 +6604,19 @@ function formatPolicyLine(v) {
6604
6604
  function policyJson(v) {
6605
6605
  return JSON.stringify({ kind: "policy", ...v });
6606
6606
  }
6607
+ function formatIncidentLine(card) {
6608
+ let tag = "";
6609
+ if (card.rootCause) {
6610
+ const rc = card.rootCause;
6611
+ const provs = rc.chain.map((h) => h.provenance).join("\xB7");
6612
+ const cls = rc.classification ? `${rc.classification} ` : "";
6613
+ tag = ` \xB7 ${cls}${rc.confidence.toFixed(2)}${provs ? ` [${provs}]` : ""}`;
6614
+ }
6615
+ return `\u2716 incident [${card.incidentKind}] ${card.headline}${tag}`;
6616
+ }
6617
+ function incidentJson(card) {
6618
+ return JSON.stringify(card);
6619
+ }
6607
6620
  var MonitorEmitter = class {
6608
6621
  constructor(opts) {
6609
6622
  this.opts = opts;
@@ -6661,6 +6674,17 @@ var MonitorEmitter = class {
6661
6674
  }
6662
6675
  return emitted;
6663
6676
  }
6677
+ // Emit one incident card once, keyed on the incident id. Unlike the other
6678
+ // facts this is event-driven, not a re-read of derivable state, so there is no
6679
+ // baseline dump on connect — only incidents that arrive live after the monitor
6680
+ // is watching reach stdout.
6681
+ emitIncident(card) {
6682
+ const key = `incident|${card.id}`;
6683
+ if (this.seen.has(key)) return false;
6684
+ this.seen.add(key);
6685
+ this.out(this.opts.json ? incidentJson(card) : formatIncidentLine(card));
6686
+ return true;
6687
+ }
6664
6688
  };
6665
6689
  function parseFrame(raw) {
6666
6690
  let event = "message";
@@ -6782,6 +6806,18 @@ async function runMonitor(opts) {
6782
6806
  const result = await client.get(policiesPath);
6783
6807
  emitter.emitPolicies(result);
6784
6808
  }, debounceMs);
6809
+ const readIncidentCard = async (incidentId, affectedNode) => {
6810
+ try {
6811
+ const card = await client.get(
6812
+ projectPath2(
6813
+ opts.project,
6814
+ `/graph/incident-card/${encodeURIComponent(affectedNode)}?errorId=${encodeURIComponent(incidentId)}`
6815
+ )
6816
+ );
6817
+ emitter.emitIncident(card);
6818
+ } catch {
6819
+ }
6820
+ };
6785
6821
  const onFrame = (frame) => {
6786
6822
  switch (frame.event) {
6787
6823
  case "extraction-complete":
@@ -6806,6 +6842,13 @@ async function runMonitor(opts) {
6806
6842
  case "policy-violation":
6807
6843
  policies.schedule();
6808
6844
  break;
6845
+ case "incident": {
6846
+ const payload = safeParse(frame.data);
6847
+ const incidentId = payload && typeof payload.incidentId === "string" ? payload.incidentId : void 0;
6848
+ const affectedNode = payload && typeof payload.affectedNode === "string" ? payload.affectedNode : void 0;
6849
+ if (incidentId && affectedNode) void readIncidentCard(incidentId, affectedNode);
6850
+ break;
6851
+ }
6809
6852
  default:
6810
6853
  break;
6811
6854
  }