@neat.is/core 0.3.2 → 0.3.3

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
@@ -21,7 +21,9 @@ import {
21
21
  ensureCompatLoaded,
22
22
  evaluateAllPolicies,
23
23
  extractFromDirectory,
24
+ formatExtractionBanner,
24
25
  getGraph,
26
+ isStrictExtractionEnabled,
25
27
  listProjects,
26
28
  loadGraphFromDisk,
27
29
  loadPolicyFile,
@@ -31,11 +33,12 @@ import {
31
33
  promoteFrontierNodes,
32
34
  removeProject,
33
35
  resetGraph,
36
+ retireEdgesByFile,
34
37
  saveGraphToDisk,
35
38
  setStatus,
36
39
  startPersistLoop,
37
40
  startStalenessLoop
38
- } from "./chunk-FIXKIYNF.js";
41
+ } from "./chunk-VABXPLDT.js";
39
42
  import {
40
43
  startOtelGrpcReceiver
41
44
  } from "./chunk-G3PDTGOW.js";
@@ -51,23 +54,6 @@ import { promises as fs4 } from "fs";
51
54
  import fs from "fs";
52
55
  import path from "path";
53
56
  import chokidar from "chokidar";
54
-
55
- // src/extract/retire.ts
56
- import { Provenance } from "@neat.is/types";
57
- function retireEdgesByFile(graph, file) {
58
- const normalized = file.split("\\").join("/");
59
- const toDrop = [];
60
- graph.forEachEdge((id, attrs) => {
61
- const edge = attrs;
62
- if (edge.provenance !== Provenance.EXTRACTED) return;
63
- if (!edge.evidence?.file) return;
64
- if (edge.evidence.file === normalized) toDrop.push(id);
65
- });
66
- for (const id of toDrop) graph.dropEdge(id);
67
- return toDrop.length;
68
- }
69
-
70
- // src/watch.ts
71
57
  var ALL_PHASES = [
72
58
  "services",
73
59
  "aliases",
@@ -806,7 +792,7 @@ function renderPatch(sections) {
806
792
  import { DivergenceTypeSchema } from "@neat.is/types";
807
793
 
808
794
  // src/cli-client.ts
809
- import { Provenance as Provenance2 } from "@neat.is/types";
795
+ import { Provenance } from "@neat.is/types";
810
796
  var HttpError = class extends Error {
811
797
  constructor(status, message, responseBody = "") {
812
798
  super(message);
@@ -941,7 +927,7 @@ async function runBlastRadius(client, input) {
941
927
  }
942
928
  }
943
929
  function formatBlastEntry(n) {
944
- const tag = n.edgeProvenance === Provenance2.STALE ? " [STALE \u2014 last seen too long ago]" : "";
930
+ const tag = n.edgeProvenance === Provenance.STALE ? " [STALE \u2014 last seen too long ago]" : "";
945
931
  return ` \u2022 ${n.nodeId} (distance ${n.distance}, ${n.edgeProvenance})${tag}`;
946
932
  }
947
933
  async function runDependencies(client, input) {
@@ -987,9 +973,9 @@ async function runObservedDependencies(client, input) {
987
973
  const edges = await client.get(
988
974
  projectPath(input.project, `/graph/edges/${encodeURIComponent(input.nodeId)}`)
989
975
  );
990
- const observed = edges.outbound.filter((e) => e.provenance === Provenance2.OBSERVED);
976
+ const observed = edges.outbound.filter((e) => e.provenance === Provenance.OBSERVED);
991
977
  if (observed.length === 0) {
992
- const hasExtracted = edges.outbound.some((e) => e.provenance === Provenance2.EXTRACTED);
978
+ const hasExtracted = edges.outbound.some((e) => e.provenance === Provenance.EXTRACTED);
993
979
  const note = hasExtracted ? " Static (EXTRACTED) dependencies exist but no runtime traffic has been seen \u2014 is OTel running?" : "";
994
980
  return { summary: `No OBSERVED dependencies for ${input.nodeId}.${note}` };
995
981
  }
@@ -997,7 +983,7 @@ async function runObservedDependencies(client, input) {
997
983
  return {
998
984
  summary: `${input.nodeId} has ${observed.length} runtime dependenc${observed.length === 1 ? "y" : "ies"} confirmed by OTel.`,
999
985
  block: blockLines.join("\n"),
1000
- provenance: Provenance2.OBSERVED
986
+ provenance: Provenance.OBSERVED
1001
987
  };
1002
988
  } catch (err) {
1003
989
  if (err instanceof HttpError && err.status === 404) {
@@ -1051,7 +1037,7 @@ async function runIncidents(client, input) {
1051
1037
  return {
1052
1038
  summary: `${target} has ${body.total} recorded incident${body.total === 1 ? "" : "s"}; showing the ${ordered.length} most recent.`,
1053
1039
  block: blockLines.join("\n"),
1054
- provenance: Provenance2.OBSERVED
1040
+ provenance: Provenance.OBSERVED
1055
1041
  };
1056
1042
  } catch (err) {
1057
1043
  if (err instanceof HttpError && err.status === 404) {
@@ -1160,7 +1146,7 @@ async function runStaleEdges(client, input) {
1160
1146
  return {
1161
1147
  summary: `${events.length} stale-edge transition${events.length === 1 ? "" : "s"} recorded${input.edgeType ? ` for ${input.edgeType}` : ""}.`,
1162
1148
  block: blockLines.join("\n"),
1163
- provenance: Provenance2.STALE
1149
+ provenance: Provenance.STALE
1164
1150
  };
1165
1151
  }
1166
1152
  async function runPolicies(client, input) {
@@ -1569,7 +1555,12 @@ async function runInit(opts) {
1569
1555
  const graphKey = opts.projectExplicit ? opts.project : DEFAULT_PROJECT;
1570
1556
  resetGraph(graphKey);
1571
1557
  const graph = getGraph(graphKey);
1572
- const result = await extractFromDirectory(graph, opts.scanPath);
1558
+ const projectPaths = pathsForProject(
1559
+ graphKey,
1560
+ path4.join(opts.scanPath, "neat-out")
1561
+ );
1562
+ const errorsPath = path4.join(path4.dirname(opts.outPath), path4.basename(projectPaths.errorsPath));
1563
+ const result = await extractFromDirectory(graph, opts.scanPath, { errorsPath });
1573
1564
  await saveGraphToDisk(graph, opts.outPath);
1574
1565
  written.push(opts.outPath);
1575
1566
  const languages = [...new Set(services.map((s) => s.node.language))].sort();
@@ -1614,6 +1605,10 @@ async function runInit(opts) {
1614
1605
  console.log(`added: ${result.nodesAdded} nodes, ${result.edgesAdded} edges`);
1615
1606
  console.log(`total: ${graph.order} nodes, ${graph.size} edges`);
1616
1607
  console.log(summarise(nodes, edges));
1608
+ console.log(formatExtractionBanner(result.extractionErrors));
1609
+ if (result.extractionErrors > 0) {
1610
+ console.log(`errors: ${errorsPath}`);
1611
+ }
1617
1612
  const incompatibilities = findIncompatibilities(nodes);
1618
1613
  if (incompatibilities.length > 0) {
1619
1614
  console.log("");
@@ -1624,6 +1619,9 @@ async function runInit(opts) {
1624
1619
  }
1625
1620
  }
1626
1621
  }
1622
+ if (result.extractionErrors > 0 && isStrictExtractionEnabled()) {
1623
+ return { exitCode: 4, writtenFiles: written };
1624
+ }
1627
1625
  return { exitCode: 0, writtenFiles: written };
1628
1626
  }
1629
1627
  var CLAUDE_SKILL_CONFIG = {