@mrciphersmith/keryx 0.4.53 → 0.4.54

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/cli.js CHANGED
@@ -38284,7 +38284,7 @@ var package_default;
38284
38284
  var init_package = __esm(() => {
38285
38285
  package_default = {
38286
38286
  name: "@mrciphersmith/keryx",
38287
- version: "0.4.53",
38287
+ version: "0.4.54",
38288
38288
  description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
38289
38289
  private: false,
38290
38290
  publishConfig: {
@@ -40923,9 +40923,15 @@ function rankMetaprojectSearchHits(query, nodes, hits) {
40923
40923
  }
40924
40924
  return result.concat(partial.slice(0, METAPROJECT_NODE_LIMIT - result.length));
40925
40925
  }
40926
+ function metaprojectWikiGroupKey(node) {
40927
+ return node.pageType || METAPROJECT_WIKI_UNTYPED_GROUP;
40928
+ }
40926
40929
  function isMetaprojectScope(value) {
40927
40930
  return METAPROJECT_SCOPES.some((scope) => scope === value);
40928
40931
  }
40932
+ function isMetaprojectTreeScope(value) {
40933
+ return METAPROJECT_TREE_SCOPES.some((scope) => scope === value);
40934
+ }
40929
40935
  function isMetaprojectV2EdgeKind(value) {
40930
40936
  return METAPROJECT_EDGE_KINDS_V2.some((kind) => kind === value);
40931
40937
  }
@@ -40944,6 +40950,9 @@ function validId(value) {
40944
40950
  function validDirection(value) {
40945
40951
  return value === "both" || value === "incoming" || value === "outgoing";
40946
40952
  }
40953
+ function validTreeParent(scope, value) {
40954
+ return scope === "graph" ? isMetaprojectRelativePath(value) : validId(value);
40955
+ }
40947
40956
  function parseV2(input) {
40948
40957
  const keys = Object.keys(input);
40949
40958
  const exact = (...allowed) => keys.every((key) => allowed.includes(key));
@@ -40955,7 +40964,7 @@ function parseV2(input) {
40955
40964
  if (input.expectedSnapshotId !== undefined && !isSha256(input.expectedSnapshotId))
40956
40965
  throw invalid();
40957
40966
  const base = { version: 2, ...input.expectedSnapshotId !== undefined && { expectedSnapshotId: input.expectedSnapshotId } };
40958
- const { action, id, artifact, section, digest, scopes, query, collection, cursor, depth, kinds, direction, includeArchive } = input;
40967
+ const { action, id, artifact, section, digest, scopes, query, collection, cursor, depth, kinds, direction, includeArchive, scope, parent } = input;
40959
40968
  switch (action) {
40960
40969
  case "catalog":
40961
40970
  if (allowed())
@@ -40993,6 +41002,11 @@ function parseV2(input) {
40993
41002
  return { ...base, action, id, ...cursor !== undefined && { cursor } };
40994
41003
  }
40995
41004
  break;
41005
+ case "tree":
41006
+ if (allowed("scope", "parent", "cursor") && isMetaprojectTreeScope(scope) && (parent === undefined || validTreeParent(scope, parent)) && (cursor === undefined || validId(cursor))) {
41007
+ return { ...base, action, scope, ...parent !== undefined && { parent }, ...cursor !== undefined && { cursor } };
41008
+ }
41009
+ break;
40996
41010
  }
40997
41011
  throw invalid();
40998
41012
  }
@@ -41003,7 +41017,7 @@ function parseExplorerRequest(value) {
41003
41017
  throw new MetaprojectRequestError("unsupported-version", "Unsupported Metaproject request version.");
41004
41018
  return parseV2(value);
41005
41019
  }
41006
- var METAPROJECT_SCHEMA = 1, METAPROJECT_NODE_LIMIT = 200, METAPROJECT_EDGE_LIMIT = 400, METAPROJECT_EDGE_KINDS, METAPROJECT_EDGE_KINDS_V2, METAPROJECT_SCHEMA_V2 = 2, METAPROJECT_RESPONSE_BYTES_V2, METAPROJECT_PAGE_SIZE_V2 = 100, METAPROJECT_CAPABILITIES, METAPROJECT_SCOPES, MetaprojectRequestError;
41020
+ var METAPROJECT_SCHEMA = 1, METAPROJECT_NODE_LIMIT = 200, METAPROJECT_EDGE_LIMIT = 400, METAPROJECT_EDGE_KINDS, METAPROJECT_EDGE_KINDS_V2, METAPROJECT_SCHEMA_V2 = 2, METAPROJECT_RESPONSE_BYTES_V2, METAPROJECT_PAGE_SIZE_V2 = 100, METAPROJECT_CAPABILITIES, METAPROJECT_SCOPES, METAPROJECT_TREE_SCOPES, METAPROJECT_WIKI_UNTYPED_GROUP = "other", MetaprojectRequestError;
41007
41021
  var init_metaproject_explorer_contract = __esm(() => {
41008
41022
  METAPROJECT_EDGE_KINDS = ["imports", "asset", "describes", "links", "contains", "defines", "calls"];
41009
41023
  METAPROJECT_EDGE_KINDS_V2 = [...METAPROJECT_EDGE_KINDS, "changes-spec", "spec-context"];
@@ -41014,9 +41028,11 @@ var init_metaproject_explorer_contract = __esm(() => {
41014
41028
  "search",
41015
41029
  "neighbors",
41016
41030
  "openspec-list",
41017
- "openspec-history"
41031
+ "openspec-history",
41032
+ "tree"
41018
41033
  ];
41019
41034
  METAPROJECT_SCOPES = ["graph", "wiki", "spec", "change", "archive"];
41035
+ METAPROJECT_TREE_SCOPES = ["graph", "wiki"];
41020
41036
  MetaprojectRequestError = class MetaprojectRequestError extends Error {
41021
41037
  code;
41022
41038
  constructor(code, message) {
@@ -42390,6 +42406,72 @@ function cursorValue(snapshotId, key, value) {
42390
42406
  throw new MetaprojectRequestError("invalid-input", "The Metaproject cursor does not match this request.");
42391
42407
  }
42392
42408
  }
42409
+ function offsetPage(items, offset, { next, action, item, byteLimit }) {
42410
+ if (typeof offset !== "number" || offset > 0 && offset >= items.length) {
42411
+ throw new MetaprojectRequestError("invalid-input", `The Metaproject ${action} cursor offset is out of range.`);
42412
+ }
42413
+ const page = boundedItems2(items.slice(offset), METAPROJECT_PAGE_SIZE_V2, byteLimit);
42414
+ if (!page.length && offset < items.length)
42415
+ throw new MetaprojectRequestError("response-limit", `Metaproject ${action} ${item} exceeds the response limit.`);
42416
+ const end = offset + page.length;
42417
+ return { page, ...end < items.length && { nextCursor: next(end) } };
42418
+ }
42419
+ function notFoundParent() {
42420
+ return new MetaprojectRequestError("not-found", "Unknown Metaproject tree parent.");
42421
+ }
42422
+ function graphTree(model, parent) {
42423
+ if (!model.graphPresent)
42424
+ return { entries: [], partial: true };
42425
+ const prefix = parent === undefined ? "" : `${parent}/`;
42426
+ const folders = new Map;
42427
+ const files = [];
42428
+ const modules = new Map;
42429
+ for (const node of model.nodes) {
42430
+ if (node.kind === "module")
42431
+ modules.set(node.path, node);
42432
+ if (node.kind !== "file" || !node.path.startsWith(prefix))
42433
+ continue;
42434
+ const rest = node.path.slice(prefix.length);
42435
+ const slash = rest.indexOf("/");
42436
+ if (slash < 0)
42437
+ files.push(node);
42438
+ else
42439
+ folders.set(rest.slice(0, slash), (folders.get(rest.slice(0, slash)) ?? 0) + 1);
42440
+ }
42441
+ if (parent !== undefined && !folders.size && !files.length)
42442
+ throw notFoundParent();
42443
+ const folderEntries = [...folders].sort(([a], [b]) => compareText2(a, b)).map(([name, count]) => {
42444
+ const folderPath = `${prefix}${name}`;
42445
+ const module = modules.get(folderPath);
42446
+ return { type: "folder", path: folderPath, name, files: count, ...module && { module } };
42447
+ });
42448
+ const fileEntries = files.sort((a, b) => compareText2(a.path, b.path)).map((node) => ({ type: "node", node }));
42449
+ return { entries: [...folderEntries, ...fileEntries], partial: false };
42450
+ }
42451
+ function wikiGroupName(key) {
42452
+ const words = key.replaceAll("-", " ");
42453
+ return words.charAt(0).toUpperCase() + words.slice(1);
42454
+ }
42455
+ function wikiTree(nodes, parent) {
42456
+ const groups = new Map;
42457
+ for (const node of nodes) {
42458
+ if (node.kind !== "wiki")
42459
+ continue;
42460
+ const key = metaprojectWikiGroupKey(node);
42461
+ const group = groups.get(key);
42462
+ if (group)
42463
+ group.push(node);
42464
+ else
42465
+ groups.set(key, [node]);
42466
+ }
42467
+ if (parent === undefined) {
42468
+ return [...groups].map(([key, pages]) => ({ type: "group", key, name: wikiGroupName(key), pages: pages.length })).sort((a, b) => compareText2(a.name, b.name) || compareText2(a.key, b.key));
42469
+ }
42470
+ const pages = groups.get(parent);
42471
+ if (!pages)
42472
+ throw notFoundParent();
42473
+ return pages.sort((a, b) => compareText2(a.title, b.title) || compareText2(a.path, b.path)).map((node) => ({ type: "node", node }));
42474
+ }
42393
42475
  function graphRequest(request) {
42394
42476
  switch (request.action) {
42395
42477
  case "detail":
@@ -42555,6 +42637,8 @@ class V2Read {
42555
42637
  return this.list(request.collection, request.cursor);
42556
42638
  case "openspec-history":
42557
42639
  return this.history(request.id, request.cursor);
42640
+ case "tree":
42641
+ return this.tree(request);
42558
42642
  }
42559
42643
  }
42560
42644
  catalog({ graph, graphReason }) {
@@ -42643,19 +42727,26 @@ class V2Read {
42643
42727
  }
42644
42728
  }))
42645
42729
  ]);
42646
- if (typeof offset !== "number" || offset > 0 && offset >= hits.length) {
42647
- throw new MetaprojectRequestError("invalid-input", "The Metaproject search cursor offset is out of range.");
42648
- }
42649
- const page = boundedItems2(hits.slice(offset), METAPROJECT_PAGE_SIZE_V2, SEARCH_ITEMS_BYTES);
42650
- if (!page.length && offset < hits.length)
42651
- throw new MetaprojectRequestError("response-limit", "Metaproject search hit exceeds the response limit.");
42652
- const next = offset + page.length;
42653
- return {
42654
- ...this.base,
42655
- hits: page,
42656
- partial: partial || legacy.partial,
42657
- ...next < hits.length && { nextCursor: cursor(this.base.snapshotId, key, next) }
42658
- };
42730
+ const { page, nextCursor } = offsetPage(hits, offset, {
42731
+ next: (end) => cursor(this.base.snapshotId, key, end),
42732
+ action: "search",
42733
+ item: "hit",
42734
+ byteLimit: SEARCH_ITEMS_BYTES
42735
+ });
42736
+ return { ...this.base, hits: page, partial: partial || legacy.partial, ...nextCursor && { nextCursor } };
42737
+ }
42738
+ tree(request) {
42739
+ const { scope, parent } = request;
42740
+ const key = hash3(["tree", scope, parent ?? null]);
42741
+ const offset = cursorValue(this.base.snapshotId, key, request.cursor) ?? 0;
42742
+ const { entries, partial } = scope === "graph" ? graphTree(this.model, parent) : { entries: wikiTree(this.model.nodes, parent), partial: false };
42743
+ const { page, nextCursor } = offsetPage(entries, offset, {
42744
+ next: (end) => cursor(this.base.snapshotId, key, end),
42745
+ action: "tree",
42746
+ item: "entry",
42747
+ byteLimit: TREE_ITEMS_BYTES
42748
+ });
42749
+ return { ...this.base, scope, parent: parent ?? null, entries: page, partial, ...nextCursor && { nextCursor } };
42659
42750
  }
42660
42751
  openSpecSearch(needle, scope, scopes) {
42661
42752
  if (!needle || !scope.length)
@@ -42723,7 +42814,7 @@ async function metaprojectExplorerV2(projectRoot, request, load) {
42723
42814
  throw new MetaprojectRequestError("source-unavailable", "Metaproject sources could not be read.");
42724
42815
  }
42725
42816
  }
42726
- var DEFAULT_SCOPES, MAX_DIAGNOSTICS2 = 64, MAX_EDGE_EVIDENCE = 3, MAX_DETAIL_RELATIONSHIPS = 40, CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES, MAX_LEGACY_HITS_PER_SCOPE = 12000, bytes = (value) => Buffer.byteLength(JSON.stringify(value)), hash3 = (value) => createHash22("sha256").update(JSON.stringify(value)).digest("hex"), compareText2 = (a, b) => a < b ? -1 : Number(a > b);
42817
+ var DEFAULT_SCOPES, MAX_DIAGNOSTICS2 = 64, MAX_EDGE_EVIDENCE = 3, MAX_DETAIL_RELATIONSHIPS = 40, CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES, TREE_ITEMS_BYTES, MAX_LEGACY_HITS_PER_SCOPE = 12000, bytes = (value) => Buffer.byteLength(JSON.stringify(value)), hash3 = (value) => createHash22("sha256").update(JSON.stringify(value)).digest("hex"), compareText2 = (a, b) => a < b ? -1 : Number(a > b);
42727
42818
  var init_metaproject_explorer_v2 = __esm(() => {
42728
42819
  init_service2();
42729
42820
  init_metaproject_explorer_contract();
@@ -42731,6 +42822,7 @@ var init_metaproject_explorer_v2 = __esm(() => {
42731
42822
  DEFAULT_SCOPES = ["graph", "wiki", "spec", "change"];
42732
42823
  CATALOG_METADATA_BYTES = 128 * 1024;
42733
42824
  SEARCH_ITEMS_BYTES = 900 * 1024;
42825
+ TREE_ITEMS_BYTES = 900 * 1024;
42734
42826
  });
42735
42827
 
42736
42828
  // src/integrations/metaproject-explorer.ts
package/dist/core.js CHANGED
@@ -14573,13 +14573,14 @@ var init_service = __esm(() => {
14573
14573
  });
14574
14574
 
14575
14575
  // src/integrations/metaproject-explorer-v2.ts
14576
- var CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES;
14576
+ var CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES, TREE_ITEMS_BYTES;
14577
14577
  var init_metaproject_explorer_v2 = __esm(() => {
14578
14578
  init_service();
14579
14579
  init_metaproject_explorer_contract();
14580
14580
  init_metaproject_projection();
14581
14581
  CATALOG_METADATA_BYTES = 128 * 1024;
14582
14582
  SEARCH_ITEMS_BYTES = 900 * 1024;
14583
+ TREE_ITEMS_BYTES = 900 * 1024;
14583
14584
  });
14584
14585
 
14585
14586
  // src/integrations/metaproject-explorer.ts
@@ -14847,13 +14847,14 @@ var init_service = __esm(() => {
14847
14847
  });
14848
14848
 
14849
14849
  // src/integrations/metaproject-explorer-v2.ts
14850
- var CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES;
14850
+ var CATALOG_METADATA_BYTES, SEARCH_ITEMS_BYTES, TREE_ITEMS_BYTES;
14851
14851
  var init_metaproject_explorer_v2 = __esm(() => {
14852
14852
  init_service();
14853
14853
  init_metaproject_explorer_contract();
14854
14854
  init_metaproject_projection();
14855
14855
  CATALOG_METADATA_BYTES = 128 * 1024;
14856
14856
  SEARCH_ITEMS_BYTES = 900 * 1024;
14857
+ TREE_ITEMS_BYTES = 900 * 1024;
14857
14858
  });
14858
14859
 
14859
14860
  // src/integrations/metaproject-explorer.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/keryx",
3
- "version": "0.4.53",
3
+ "version": "0.4.54",
4
4
  "description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
5
5
  "private": false,
6
6
  "publishConfig": {