@neat.is/core 0.10.4 → 0.10.5-dev.20261002

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/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-2OQVIBZZ.js";
5
+ } from "./chunk-TONL5O2E.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-TUGYIRUT.js";
9
+ } from "./chunk-HHAPD6JD.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -2540,6 +2540,10 @@ function languageForPath(relPath) {
2540
2540
  return void 0;
2541
2541
  }
2542
2542
  }
2543
+ var currentSource;
2544
+ function setExtractionSource(source) {
2545
+ currentSource = source;
2546
+ }
2543
2547
  function ensureFileNode(graph, serviceName, serviceNodeId, relPath) {
2544
2548
  let nodesAdded = 0;
2545
2549
  let edgesAdded = 0;
@@ -2552,10 +2556,16 @@ function ensureFileNode(graph, serviceName, serviceNodeId, relPath) {
2552
2556
  service: serviceName,
2553
2557
  path: relPath,
2554
2558
  ...language ? { language } : {},
2559
+ ...currentSource ? { source: currentSource } : {},
2555
2560
  discoveredVia: "static"
2556
2561
  };
2557
2562
  graph.addNode(fileNodeId, node);
2558
2563
  nodesAdded++;
2564
+ } else if (currentSource) {
2565
+ const existing = graph.getNodeAttributes(fileNodeId);
2566
+ if (existing.source !== currentSource) {
2567
+ graph.replaceNodeAttributes(fileNodeId, { ...existing, source: currentSource });
2568
+ }
2559
2569
  }
2560
2570
  const containsId = (0, import_types4.extractedEdgeId)(serviceNodeId, fileNodeId, import_types4.EdgeType.CONTAINS);
2561
2571
  if (!graph.hasEdge(containsId)) {
@@ -17388,10 +17398,12 @@ init_cjs_shims();
17388
17398
  var import_node_fs35 = require("fs");
17389
17399
  var import_node_path70 = __toESM(require("path"), 1);
17390
17400
  var import_types59 = require("@neat.is/types");
17391
- function dropOrphanedFileNodes(graph) {
17401
+ function dropOrphanedFileNodes(graph, source) {
17392
17402
  const orphans = [];
17393
17403
  graph.forEachNode((id, attrs) => {
17394
- if (attrs.type !== import_types59.NodeType.FileNode) return;
17404
+ const node = attrs;
17405
+ if (node.type !== import_types59.NodeType.FileNode) return;
17406
+ if (source && node.source !== source) return;
17395
17407
  if (graph.inboundEdges(id).length === 0 && graph.outboundEdges(id).length === 0) {
17396
17408
  orphans.push(id);
17397
17409
  }
@@ -17399,12 +17411,23 @@ function dropOrphanedFileNodes(graph) {
17399
17411
  for (const id of orphans) graph.dropNode(id);
17400
17412
  return orphans.length;
17401
17413
  }
17402
- function retireExtractedEdgesByMissingFile(graph, scanPath, serviceDirs = []) {
17414
+ function outOfScope(graph, edge, source) {
17415
+ if (!source) return false;
17416
+ for (const endpoint2 of [edge.source, edge.target]) {
17417
+ if (!graph.hasNode(endpoint2)) continue;
17418
+ const node = graph.getNodeAttributes(endpoint2);
17419
+ if (node.type !== import_types59.NodeType.FileNode) continue;
17420
+ return node.source !== source;
17421
+ }
17422
+ return false;
17423
+ }
17424
+ function retireExtractedEdgesByMissingFile(graph, scanPath, serviceDirs = [], source) {
17403
17425
  const toDrop = [];
17404
17426
  const bases = [scanPath, ...serviceDirs];
17405
17427
  graph.forEachEdge((id, attrs) => {
17406
17428
  const edge = attrs;
17407
17429
  if (edge.provenance !== import_types59.Provenance.EXTRACTED) return;
17430
+ if (outOfScope(graph, edge, source)) return;
17408
17431
  const evidenceFile = edge.evidence?.file;
17409
17432
  if (!evidenceFile) return;
17410
17433
  if (import_node_path70.default.isAbsolute(evidenceFile)) {
@@ -17415,7 +17438,7 @@ function retireExtractedEdgesByMissingFile(graph, scanPath, serviceDirs = []) {
17415
17438
  if (!found) toDrop.push(id);
17416
17439
  });
17417
17440
  for (const id of toDrop) graph.dropEdge(id);
17418
- dropOrphanedFileNodes(graph);
17441
+ dropOrphanedFileNodes(graph, source);
17419
17442
  return toDrop.length;
17420
17443
  }
17421
17444
 
@@ -17424,6 +17447,7 @@ async function extractFromDirectory(graph, scanPath, opts = {}) {
17424
17447
  await ensureCompatLoaded();
17425
17448
  drainExtractionErrors();
17426
17449
  drainSkippedFiles();
17450
+ setExtractionSource(opts.source);
17427
17451
  const services = await discoverServices(scanPath);
17428
17452
  const phase1Nodes = addServiceNodes(graph, services);
17429
17453
  await addServiceAliases(graph, scanPath, services);
@@ -17444,7 +17468,8 @@ async function extractFromDirectory(graph, scanPath, opts = {}) {
17444
17468
  const ghostsRetired = retireExtractedEdgesByMissingFile(
17445
17469
  graph,
17446
17470
  scanPath,
17447
- services.map((s) => s.dir)
17471
+ services.map((s) => s.dir),
17472
+ opts.source
17448
17473
  );
17449
17474
  const frontiersPromoted = promoteFrontierNodes(graph);
17450
17475
  if (opts.onPolicyTrigger) await opts.onPolicyTrigger(graph);
@@ -17479,6 +17504,7 @@ async function extractFromDirectory(graph, scanPath, opts = {}) {
17479
17504
  );
17480
17505
  }
17481
17506
  }
17507
+ setExtractionSource(void 0);
17482
17508
  const result = {
17483
17509
  nodesAdded: phase1Nodes + fileEnum.nodesAdded + symbolEnum.nodesAdded + importGraph.nodesAdded + symbolEdges.nodesAdded + actionPhase.nodesAdded + phase2.nodesAdded + phase3.nodesAdded + routePhase.nodesAdded + grpcPhase.nodesAdded + phase4.nodesAdded + tableEdges.nodesAdded + phase5.nodesAdded + zodPhase.nodesAdded + firestoreRulesPhase.nodesAdded,
17484
17510
  edgesAdded: fileEnum.edgesAdded + symbolEnum.edgesAdded + importGraph.edgesAdded + symbolEdges.edgesAdded + actionPhase.edgesAdded + phase2.edgesAdded + phase3.edgesAdded + routePhase.edgesAdded + grpcPhase.edgesAdded + phase4.edgesAdded + tableEdges.edgesAdded + phase5.edgesAdded + zodPhase.edgesAdded + firestoreRulesPhase.edgesAdded,