@neat.is/core 0.2.6 → 0.2.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/index.d.cts CHANGED
@@ -13,6 +13,7 @@ interface ExtractResult {
13
13
  }
14
14
  interface ExtractOptions {
15
15
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
16
+ project?: string;
16
17
  }
17
18
  declare function extractFromDirectory(graph: NeatGraph, scanPath: string, opts?: ExtractOptions): Promise<ExtractResult>;
18
19
 
@@ -184,6 +185,7 @@ declare function startOtelGrpcReceiver(opts: BuildOtelGrpcReceiverOptions & {
184
185
  interface IngestContext {
185
186
  graph: NeatGraph;
186
187
  errorsPath: string;
188
+ project?: string;
187
189
  now?: () => number;
188
190
  writeErrorEventInline?: boolean;
189
191
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
@@ -207,6 +209,7 @@ interface MarkStaleOptions {
207
209
  thresholds?: Record<string, number>;
208
210
  now?: number;
209
211
  staleEventsPath?: string;
212
+ project?: string;
210
213
  }
211
214
  declare function markStaleEdges(graph: NeatGraph, options?: MarkStaleOptions): Promise<{
212
215
  count: number;
@@ -217,6 +220,7 @@ interface StalenessLoopOptions {
217
220
  thresholds?: Record<string, number>;
218
221
  intervalMs?: number;
219
222
  staleEventsPath?: string;
223
+ project?: string;
220
224
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
221
225
  }
222
226
  declare function startStalenessLoop(graph: NeatGraph, options?: StalenessLoopOptions): () => void;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ interface ExtractResult {
13
13
  }
14
14
  interface ExtractOptions {
15
15
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
16
+ project?: string;
16
17
  }
17
18
  declare function extractFromDirectory(graph: NeatGraph, scanPath: string, opts?: ExtractOptions): Promise<ExtractResult>;
18
19
 
@@ -184,6 +185,7 @@ declare function startOtelGrpcReceiver(opts: BuildOtelGrpcReceiverOptions & {
184
185
  interface IngestContext {
185
186
  graph: NeatGraph;
186
187
  errorsPath: string;
188
+ project?: string;
187
189
  now?: () => number;
188
190
  writeErrorEventInline?: boolean;
189
191
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
@@ -207,6 +209,7 @@ interface MarkStaleOptions {
207
209
  thresholds?: Record<string, number>;
208
210
  now?: number;
209
211
  staleEventsPath?: string;
212
+ project?: string;
210
213
  }
211
214
  declare function markStaleEdges(graph: NeatGraph, options?: MarkStaleOptions): Promise<{
212
215
  count: number;
@@ -217,6 +220,7 @@ interface StalenessLoopOptions {
217
220
  thresholds?: Record<string, number>;
218
221
  intervalMs?: number;
219
222
  staleEventsPath?: string;
223
+ project?: string;
220
224
  onPolicyTrigger?: (graph: NeatGraph) => Promise<void> | void;
221
225
  }
222
226
  declare function startStalenessLoop(graph: NeatGraph, options?: StalenessLoopOptions): () => void;
package/dist/index.js CHANGED
@@ -1,47 +1,45 @@
1
1
  import {
2
2
  routeSpanToProject,
3
3
  startDaemon
4
- } from "./chunk-6JT6L2OV.js";
5
- import {
6
- ProjectNameCollisionError,
7
- addProject,
8
- getProject,
9
- listProjects,
10
- normalizeProjectPath,
11
- readRegistry,
12
- registryLockPath,
13
- registryPath,
14
- removeProject,
15
- setStatus,
16
- touchLastSeen,
17
- writeAtomically
18
- } from "./chunk-WX55TLUT.js";
4
+ } from "./chunk-HWO746IM.js";
19
5
  import {
20
6
  buildApi,
21
7
  computeGraphDiff,
22
8
  loadSnapshotForDiff
23
- } from "./chunk-T2U4U256.js";
9
+ } from "./chunk-FTKDVKBC.js";
24
10
  import {
11
+ ProjectNameCollisionError,
12
+ addProject,
25
13
  checkCompatibility,
26
14
  compatPairs,
27
15
  confidenceForEdge,
28
16
  extractFromDirectory,
29
17
  getBlastRadius,
30
18
  getGraph,
19
+ getProject,
31
20
  getRootCause,
32
21
  handleSpan,
22
+ listProjects,
33
23
  loadGraphFromDisk,
34
24
  makeSpanHandler,
35
25
  markStaleEdges,
26
+ normalizeProjectPath,
36
27
  readErrorEvents,
28
+ readRegistry,
37
29
  readStaleEvents,
30
+ registryLockPath,
31
+ registryPath,
32
+ removeProject,
38
33
  resetGraph,
39
34
  saveGraphToDisk,
35
+ setStatus,
40
36
  startPersistLoop,
41
37
  startStalenessLoop,
42
38
  stitchTrace,
43
- thresholdForEdgeType
44
- } from "./chunk-6SFEITLJ.js";
39
+ thresholdForEdgeType,
40
+ touchLastSeen,
41
+ writeAtomically
42
+ } from "./chunk-GAYTAGEH.js";
45
43
  import {
46
44
  buildOtelReceiver,
47
45
  logSpanHandler,
package/dist/neatd.cjs CHANGED
@@ -376,6 +376,17 @@ function deprecatedApis() {
376
376
  return currentMatrix().deprecatedApis ?? [];
377
377
  }
378
378
 
379
+ // src/events.ts
380
+ var import_node_events = require("events");
381
+ var EVENT_BUS_CHANNEL = "event";
382
+ var NeatEventBus = class extends import_node_events.EventEmitter {
383
+ };
384
+ var eventBus = new NeatEventBus();
385
+ eventBus.setMaxListeners(0);
386
+ function emitNeatEvent(envelope) {
387
+ eventBus.emit(EVENT_BUS_CHANNEL, envelope);
388
+ }
389
+
379
390
  // src/traverse.ts
380
391
  var import_types = require("@neat.is/types");
381
392
  var BLAST_RADIUS_DEFAULT_DEPTH = 10;
@@ -2103,7 +2114,15 @@ async function addHttpCallEdges(graph, services) {
2103
2114
  const seenTargets = /* @__PURE__ */ new Map();
2104
2115
  for (const file of files) {
2105
2116
  const parser = import_node_path18.default.extname(file.path) === ".py" ? pyParser : jsParser;
2106
- const targets = callsFromSource(file.content, parser, knownHosts);
2117
+ let targets;
2118
+ try {
2119
+ targets = callsFromSource(file.content, parser, knownHosts);
2120
+ } catch (err) {
2121
+ console.warn(
2122
+ `[neat] http call extraction skipped ${file.path}: ${err.message}`
2123
+ );
2124
+ continue;
2125
+ }
2107
2126
  for (const t of targets) {
2108
2127
  const targetId = hostToNodeId.get(t);
2109
2128
  if (!targetId || targetId === service.node.id) continue;
@@ -2620,11 +2639,22 @@ async function extractFromDirectory(graph, scanPath, opts = {}) {
2620
2639
  const phase5 = await addInfra(graph, scanPath, services);
2621
2640
  const frontiersPromoted = promoteFrontierNodes(graph);
2622
2641
  if (opts.onPolicyTrigger) await opts.onPolicyTrigger(graph);
2623
- return {
2642
+ const result = {
2624
2643
  nodesAdded: phase1Nodes + phase2.nodesAdded + phase3.nodesAdded + phase4.nodesAdded + phase5.nodesAdded,
2625
2644
  edgesAdded: phase2.edgesAdded + phase3.edgesAdded + phase4.edgesAdded + phase5.edgesAdded,
2626
2645
  frontiersPromoted
2627
2646
  };
2647
+ emitNeatEvent({
2648
+ type: "extraction-complete",
2649
+ project: opts.project ?? DEFAULT_PROJECT,
2650
+ payload: {
2651
+ project: opts.project ?? DEFAULT_PROJECT,
2652
+ fileCount: services.length,
2653
+ nodesAdded: result.nodesAdded,
2654
+ edgesAdded: result.edgesAdded
2655
+ }
2656
+ });
2657
+ return result;
2628
2658
  }
2629
2659
 
2630
2660
  // src/persist.ts