@neat.is/core 0.4.20-dev.20260620 → 0.4.20-dev.20260622

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
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  startDaemon
4
- } from "./chunk-ZV7GHZ2D.js";
4
+ } from "./chunk-62ELQVIP.js";
5
5
  import {
6
6
  listProjects,
7
7
  registryPath
8
- } from "./chunk-Q5EDVWKZ.js";
8
+ } from "./chunk-GNAX2CBF.js";
9
9
  import {
10
10
  BindAuthorityError,
11
11
  __require
package/dist/server.cjs CHANGED
@@ -2403,13 +2403,14 @@ var parentSpanCache = /* @__PURE__ */ new Map();
2403
2403
  function parentSpanKey(traceId, spanId) {
2404
2404
  return `${traceId}:${spanId}`;
2405
2405
  }
2406
- function cacheSpanService(span, now) {
2406
+ function cacheSpanService(span, now, callSite) {
2407
2407
  if (!span.traceId || !span.spanId) return;
2408
2408
  const key = parentSpanKey(span.traceId, span.spanId);
2409
2409
  parentSpanCache.delete(key);
2410
2410
  parentSpanCache.set(key, {
2411
2411
  service: span.service,
2412
2412
  env: span.env ?? "unknown",
2413
+ ...callSite ? { callSite } : {},
2413
2414
  expiresAt: now + PARENT_SPAN_CACHE_TTL_MS
2414
2415
  });
2415
2416
  while (parentSpanCache.size > PARENT_SPAN_CACHE_SIZE) {
@@ -2425,7 +2426,11 @@ function lookupParentSpan(traceId, parentSpanId, now) {
2425
2426
  parentSpanCache.delete(parentSpanKey(traceId, parentSpanId));
2426
2427
  return null;
2427
2428
  }
2428
- return { service: entry.service, env: entry.env };
2429
+ return {
2430
+ service: entry.service,
2431
+ env: entry.env,
2432
+ ...entry.callSite ? { callSite: entry.callSite } : {}
2433
+ };
2429
2434
  }
2430
2435
  function resolveServiceId(graph, host, env) {
2431
2436
  const envTagged = (0, import_types4.serviceId)(host, env);
@@ -2673,9 +2678,9 @@ async function handleSpan(ctx, span) {
2673
2678
  }
2674
2679
  const sourceId = ensureServiceNode(ctx.graph, span.service, env);
2675
2680
  const isError = span.statusCode === 2;
2676
- cacheSpanService(span, nowMs);
2677
2681
  const sourceServiceNode = ctx.graph.getNodeAttributes(sourceId);
2678
2682
  const callSite = callSiteFromSpan(span, sourceServiceNode, ctx.scanPath);
2683
+ cacheSpanService(span, nowMs, callSite);
2679
2684
  const observedSource = () => callSite ? ensureObservedFileNode(ctx.graph, span.service, sourceId, callSite) : sourceId;
2680
2685
  const callSiteEvidence = callSite ? { file: callSite.relPath, ...callSite.line !== void 0 ? { line: callSite.line } : {} } : void 0;
2681
2686
  let affectedNode = sourceId;
@@ -2732,13 +2737,19 @@ async function handleSpan(ctx, span) {
2732
2737
  const parent = lookupParentSpan(span.traceId, span.parentSpanId, nowMs);
2733
2738
  if (parent && parent.service !== span.service) {
2734
2739
  const parentId = ensureServiceNode(ctx.graph, parent.service, parent.env);
2740
+ const fallbackSource = parent.callSite ? ensureObservedFileNode(ctx.graph, parent.service, parentId, parent.callSite) : parentId;
2741
+ const fallbackEvidence = parent.callSite ? {
2742
+ file: parent.callSite.relPath,
2743
+ ...parent.callSite.line !== void 0 ? { line: parent.callSite.line } : {}
2744
+ } : void 0;
2735
2745
  upsertObservedEdge(
2736
2746
  ctx.graph,
2737
2747
  import_types4.EdgeType.CALLS,
2738
- parentId,
2748
+ fallbackSource,
2739
2749
  sourceId,
2740
2750
  ts,
2741
- isError
2751
+ isError,
2752
+ fallbackEvidence
2742
2753
  );
2743
2754
  }
2744
2755
  }
@@ -3328,6 +3339,9 @@ function workspaceGlobs(pkg) {
3328
3339
  if (Array.isArray(ws.packages)) return ws.packages.length > 0 ? ws.packages : null;
3329
3340
  return null;
3330
3341
  }
3342
+ async function hasPythonManifest(dir) {
3343
+ return await exists2(import_node_path10.default.join(dir, "pyproject.toml")) || await exists2(import_node_path10.default.join(dir, "requirements.txt")) || await exists2(import_node_path10.default.join(dir, "setup.py"));
3344
+ }
3331
3345
  async function loadGitignore(scanPath) {
3332
3346
  const gitignorePath = import_node_path10.default.join(scanPath, ".gitignore");
3333
3347
  if (!await exists2(gitignorePath)) return null;
@@ -3394,6 +3408,13 @@ function detectJsFramework(pkg) {
3394
3408
  if (deps["astro"] !== void 0) return "astro";
3395
3409
  return void 0;
3396
3410
  }
3411
+ async function detectJsServiceLanguage(dir, pkg) {
3412
+ const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
3413
+ if (deps["typescript"] !== void 0) return "typescript";
3414
+ const entries = await import_node_fs10.promises.readdir(dir).catch(() => []);
3415
+ if (entries.some((name) => /^tsconfig(\..+)?\.json$/.test(name))) return "typescript";
3416
+ return "javascript";
3417
+ }
3397
3418
  async function discoverNodeService(scanPath, dir) {
3398
3419
  const pkgPath = import_node_path10.default.join(dir, "package.json");
3399
3420
  if (!await exists2(pkgPath)) return null;
@@ -3406,11 +3427,12 @@ async function discoverNodeService(scanPath, dir) {
3406
3427
  }
3407
3428
  if (!pkg.name) return null;
3408
3429
  const framework = detectJsFramework(pkg);
3430
+ const language = await detectJsServiceLanguage(dir, pkg);
3409
3431
  const node = {
3410
3432
  id: (0, import_types6.serviceId)(pkg.name),
3411
3433
  type: import_types6.NodeType.ServiceNode,
3412
3434
  name: pkg.name,
3413
- language: "javascript",
3435
+ language,
3414
3436
  version: pkg.version,
3415
3437
  dependencies: pkg.dependencies ?? {},
3416
3438
  repoPath: import_node_path10.default.relative(scanPath, dir),
@@ -3453,7 +3475,11 @@ async function discoverServices(scanPath) {
3453
3475
  if (wsGlobs) {
3454
3476
  candidateDirs.push(...await expandWorkspaceGlobs(scanPath, wsGlobs));
3455
3477
  } else {
3456
- if (rootPkg && rootPkg.name) candidateDirs.push(scanPath);
3478
+ if (rootPkg && rootPkg.name) {
3479
+ candidateDirs.push(scanPath);
3480
+ } else if (await hasPythonManifest(scanPath)) {
3481
+ candidateDirs.push(scanPath);
3482
+ }
3457
3483
  const ig = await loadGitignore(scanPath);
3458
3484
  await walkDirs(
3459
3485
  scanPath,
@@ -3462,7 +3488,7 @@ async function discoverServices(scanPath) {
3462
3488
  async (dir) => {
3463
3489
  if (await exists2(import_node_path10.default.join(dir, "package.json"))) {
3464
3490
  candidateDirs.push(dir);
3465
- } else if (await exists2(import_node_path10.default.join(dir, "pyproject.toml")) || await exists2(import_node_path10.default.join(dir, "requirements.txt")) || await exists2(import_node_path10.default.join(dir, "setup.py"))) {
3491
+ } else if (await hasPythonManifest(dir)) {
3466
3492
  candidateDirs.push(dir);
3467
3493
  }
3468
3494
  }