@neat.is/core 0.3.2 → 0.3.4

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