engramx 2.1.0 → 3.0.0

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runMigrations
3
- } from "./chunk-PEH54LYC.js";
3
+ } from "./chunk-645NBY6L.js";
4
4
 
5
5
  // src/core.ts
6
6
  import { join as join4, resolve as resolve2, relative as relative2 } from "path";
@@ -98,8 +98,8 @@ var GraphStore = class _GraphStore {
98
98
  }
99
99
  upsertNode(node) {
100
100
  this.db.run(
101
- `INSERT OR REPLACE INTO nodes (id, label, kind, source_file, source_location, confidence, confidence_score, last_verified, query_count, metadata)
102
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
101
+ `INSERT OR REPLACE INTO nodes (id, label, kind, source_file, source_location, confidence, confidence_score, last_verified, query_count, metadata, valid_until, invalidated_by_commit)
102
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
103
103
  [
104
104
  node.id,
105
105
  node.label,
@@ -110,7 +110,9 @@ var GraphStore = class _GraphStore {
110
110
  node.confidenceScore,
111
111
  node.lastVerified,
112
112
  node.queryCount,
113
- JSON.stringify(node.metadata)
113
+ JSON.stringify(node.metadata),
114
+ node.validUntil ?? null,
115
+ node.invalidatedByCommit ?? null
114
116
  ]
115
117
  );
116
118
  }
@@ -502,6 +504,8 @@ var GraphStore = class _GraphStore {
502
504
  this.db.close();
503
505
  }
504
506
  rowToNode(row) {
507
+ const validUntilRaw = row.valid_until;
508
+ const invalidatedByRaw = row.invalidated_by_commit;
505
509
  return {
506
510
  id: row.id,
507
511
  label: row.label,
@@ -512,7 +516,9 @@ var GraphStore = class _GraphStore {
512
516
  confidenceScore: row.confidence_score ?? 1,
513
517
  lastVerified: row.last_verified ?? 0,
514
518
  queryCount: row.query_count ?? 0,
515
- metadata: JSON.parse(row.metadata || "{}")
519
+ metadata: JSON.parse(row.metadata || "{}"),
520
+ validUntil: validUntilRaw === null || validUntilRaw === void 0 ? void 0 : validUntilRaw,
521
+ invalidatedByCommit: invalidatedByRaw === null || invalidatedByRaw === void 0 ? void 0 : invalidatedByRaw
516
522
  };
517
523
  }
518
524
  rowToEdge(row) {
@@ -1246,6 +1252,7 @@ function getPatterns(lang) {
1246
1252
  return { classes: [], functions: [], imports: [], exports: [] };
1247
1253
  }
1248
1254
  }
1255
+ var MAX_DEPTH = 100;
1249
1256
  var DEFAULT_SKIP_DIRS = /* @__PURE__ */ new Set([
1250
1257
  "node_modules",
1251
1258
  "dist",
@@ -1297,7 +1304,8 @@ function extractDirectory(dirPath, rootDir, options = {}) {
1297
1304
  if (ignorePatterns.has(name)) return true;
1298
1305
  return false;
1299
1306
  }
1300
- function walk(dir) {
1307
+ function walk(dir, depth) {
1308
+ if (depth > MAX_DEPTH) return;
1301
1309
  let realDir;
1302
1310
  try {
1303
1311
  realDir = realpathSync(dir);
@@ -1306,12 +1314,17 @@ function extractDirectory(dirPath, rootDir, options = {}) {
1306
1314
  }
1307
1315
  if (visitedDirs.has(realDir)) return;
1308
1316
  visitedDirs.add(realDir);
1309
- const entries = readdirSync(dir, { withFileTypes: true });
1317
+ let entries;
1318
+ try {
1319
+ entries = readdirSync(dir, { withFileTypes: true });
1320
+ } catch {
1321
+ return;
1322
+ }
1310
1323
  for (const entry of entries) {
1311
1324
  const fullPath = join(dir, entry.name);
1312
1325
  if (entry.isDirectory()) {
1313
1326
  if (shouldSkipDir(entry.name)) continue;
1314
- walk(fullPath);
1327
+ walk(fullPath, depth + 1);
1315
1328
  continue;
1316
1329
  }
1317
1330
  if (!entry.isFile()) continue;
@@ -1337,7 +1350,7 @@ function extractDirectory(dirPath, rootDir, options = {}) {
1337
1350
  options.onProgress?.(fileCount, skippedCount, relPath);
1338
1351
  }
1339
1352
  }
1340
- walk(dirPath);
1353
+ walk(dirPath, 0);
1341
1354
  return { nodes: allNodes, edges: allEdges, fileCount, totalLines, mtimes, skippedCount };
1342
1355
  }
1343
1356
 
@@ -1384,6 +1397,8 @@ function mineGitHistory(projectRoot, maxCommits = 200) {
1384
1397
  const fileChangeCount = /* @__PURE__ */ new Map();
1385
1398
  const authorMap = /* @__PURE__ */ new Map();
1386
1399
  const commitBlocks = log.split("\n\n").filter(Boolean);
1400
+ const SKIP_PREFIXES = ["dist/", "build/", "node_modules/", ".venv/", "target/", "coverage/"];
1401
+ const MAX_FILES_PER_COMMIT = 50;
1387
1402
  for (const block of commitBlocks) {
1388
1403
  const lines = block.split("\n").filter(Boolean);
1389
1404
  if (lines.length === 0) continue;
@@ -1391,9 +1406,12 @@ function mineGitHistory(projectRoot, maxCommits = 200) {
1391
1406
  const parts = header.split("|");
1392
1407
  if (parts.length < 3) continue;
1393
1408
  const author = parts[1];
1394
- const files = fileLines.filter(
1395
- (f) => f.length > 0 && !f.includes("|") && !f.startsWith(" ") && f.includes(".")
1409
+ let files = fileLines.filter(
1410
+ (f) => f.length > 0 && !f.includes("|") && !f.startsWith(" ") && f.includes(".") && !SKIP_PREFIXES.some((p) => f.startsWith(p))
1396
1411
  );
1412
+ if (files.length > MAX_FILES_PER_COMMIT) {
1413
+ files = files.slice(0, MAX_FILES_PER_COMMIT);
1414
+ }
1397
1415
  for (const file of files) {
1398
1416
  fileChangeCount.set(file, (fileChangeCount.get(file) ?? 0) + 1);
1399
1417
  if (!authorMap.has(file)) authorMap.set(file, /* @__PURE__ */ new Set());
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatThousands
3
- } from "./chunk-ZVWRIVWQ.js";
3
+ } from "./chunk-B4UOE64J.js";
4
4
 
5
5
  // src/intercept/stats.ts
6
6
  var ESTIMATED_TOKENS_PER_READ_DENY = 1200;