eminiar 0.6.0 → 0.6.2

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,7 +1,7 @@
1
1
  {
2
2
  "name": "eminiar",
3
3
  "displayName": "Eminiar",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "description": "Local-first context, memory and knowledge graph for Claude Code: sandboxed execution, FTS5 + vector search, session continuity, code graph.",
6
6
  "author": {
7
7
  "name": "Ryan Dick"
package/dist/cli.js CHANGED
@@ -41290,32 +41290,58 @@ function graphMap(ctx, opts = {}) {
41290
41290
  let files = db.graphFileNodes();
41291
41291
  if (opts.pathFilter)
41292
41292
  files = files.filter((f) => (f.path ?? f.name).includes(opts.pathFilter));
41293
- const ids = files.map((f) => f.id);
41294
- const idSet = new Set(ids);
41295
- const kinds = opts.coChanges === false ? ["imports"] : ["imports", "co_changes"];
41296
- const raw = db.graphEdgesFrom(ids, kinds).filter((e) => idSet.has(e.dst));
41293
+ const fileSet = new Set(files.map((f) => f.id));
41294
+ const kinds = opts.kinds ?? (opts.coChanges === false ? ["imports"] : ["imports", "co_changes"]);
41295
+ const lift = (id) => {
41296
+ const kind = parseId(id).kind;
41297
+ if (kind === "file" || kind === "sym") {
41298
+ const rel = fileOf(id);
41299
+ const f = rel === void 0 ? void 0 : fileId(rel);
41300
+ return f && fileSet.has(f) ? f : void 0;
41301
+ }
41302
+ return kind === "pkg" ? void 0 : id;
41303
+ };
41304
+ const merged = /* @__PURE__ */ new Map();
41305
+ for (const kind of kinds) {
41306
+ for (const e of db.graphEdgesByKind(kind, MAP_EDGES_PER_KIND)) {
41307
+ if (kind === "co_changes" && e.weight < 0.3) continue;
41308
+ const src = lift(e.src);
41309
+ const dst = lift(e.dst);
41310
+ if (!src || !dst || src === dst) continue;
41311
+ if (!fileSet.has(src) && !fileSet.has(dst)) continue;
41312
+ const key = kind === "co_changes" ? `${[src, dst].sort().join("|")}|co` : `${src}|${dst}|${kind}`;
41313
+ const prev = merged.get(key);
41314
+ if (prev)
41315
+ prev.weight = kind === "co_changes" ? Math.max(prev.weight, e.weight) : prev.weight + 1;
41316
+ else merged.set(key, { src, dst, kind, weight: kind === "co_changes" ? e.weight : 1 });
41317
+ }
41318
+ }
41297
41319
  const degree = /* @__PURE__ */ new Map();
41298
- for (const e of raw) {
41320
+ for (const e of merged.values()) {
41299
41321
  degree.set(e.src, (degree.get(e.src) ?? 0) + 1);
41300
41322
  degree.set(e.dst, (degree.get(e.dst) ?? 0) + 1);
41301
41323
  }
41302
41324
  const keep = new Set(
41303
41325
  [...files].sort((a, b) => (degree.get(b.id) ?? 0) - (degree.get(a.id) ?? 0)).slice(0, limit).map((f) => f.id)
41304
41326
  );
41305
- const seenEdge = /* @__PURE__ */ new Set();
41306
41327
  const edges = [];
41307
- for (const e of raw) {
41308
- if (!keep.has(e.src) || !keep.has(e.dst)) continue;
41309
- if (e.kind === "co_changes" && e.weight < 0.3) continue;
41310
- const key = e.kind === "co_changes" ? `${[e.src, e.dst].sort().join("|")}|co` : `${e.src}|${e.dst}|${e.kind}`;
41311
- if (seenEdge.has(key)) continue;
41312
- seenEdge.add(key);
41313
- edges.push({ src: e.src, dst: e.dst, kind: e.kind, weight: e.weight });
41314
- }
41328
+ const extra = /* @__PURE__ */ new Set();
41329
+ for (const e of merged.values()) {
41330
+ const srcOk = keep.has(e.src) || !fileSet.has(e.src) && keep.has(e.dst);
41331
+ const dstOk = keep.has(e.dst) || !fileSet.has(e.dst) && keep.has(e.src);
41332
+ if (!srcOk || !dstOk) continue;
41333
+ if (!keep.has(e.src)) extra.add(e.src);
41334
+ if (!keep.has(e.dst)) extra.add(e.dst);
41335
+ edges.push(e);
41336
+ }
41337
+ const extraRows = new Map(db.graphGetNodes([...extra]).map((n) => [n.id, n]));
41315
41338
  return {
41316
41339
  mode: "map",
41317
41340
  total: files.length,
41318
- nodes: files.filter((f) => keep.has(f.id)).map((f) => visNode(f, f.id)),
41341
+ nodes: [
41342
+ ...files.filter((f) => keep.has(f.id)).map((f) => visNode(f, f.id)),
41343
+ ...[...extra].map((id) => visNode(extraRows.get(id), id))
41344
+ ],
41319
41345
  edges
41320
41346
  };
41321
41347
  }
@@ -41477,7 +41503,7 @@ async function runAction(ctx, input2) {
41477
41503
  return done(false, `unknown action ${String(input2.action)}`);
41478
41504
  }
41479
41505
  }
41480
- var memoryKinds;
41506
+ var memoryKinds, MAP_EDGES_PER_KIND;
41481
41507
  var init_api2 = __esm({
41482
41508
  "src/ui/api.ts"() {
41483
41509
  "use strict";
@@ -41492,6 +41518,7 @@ var init_api2 = __esm({
41492
41518
  init_sync();
41493
41519
  init_queue();
41494
41520
  init_format2();
41521
+ init_ids();
41495
41522
  init_query2();
41496
41523
  init_doctor2();
41497
41524
  init_store();
@@ -41506,6 +41533,7 @@ var init_api2 = __esm({
41506
41533
  init_em_purge();
41507
41534
  init_em_search();
41508
41535
  memoryKinds = [...MEMORY_KINDS];
41536
+ MAP_EDGES_PER_KIND = 5e4;
41509
41537
  }
41510
41538
  });
41511
41539
 
@@ -43476,6 +43504,7 @@ async function serve(opts) {
43476
43504
  200,
43477
43505
  graphMap(ctx(), {
43478
43506
  limit: num2("limit", 150),
43507
+ kinds: q.has("kinds") ? strList(q.get("kinds")) : void 0,
43479
43508
  coChanges: q.get("cochanges") !== "0",
43480
43509
  pathFilter: str2("path")
43481
43510
  })