kaabalah 5.5.1 → 5.6.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.
Files changed (54) hide show
  1. package/README.md +25 -0
  2. package/dist/{chunk-BJUCABP4.js → chunk-3HYK4Q4B.js} +123 -10
  3. package/dist/chunk-3HYK4Q4B.js.map +1 -0
  4. package/dist/{chunk-27IU6FA2.mjs → chunk-3SFBJHP2.mjs} +3 -3
  5. package/dist/{chunk-27IU6FA2.mjs.map → chunk-3SFBJHP2.mjs.map} +1 -1
  6. package/dist/chunk-4NMXTZX4.mjs +525 -0
  7. package/dist/chunk-4NMXTZX4.mjs.map +1 -0
  8. package/dist/{chunk-PEAOQ7YH.js → chunk-EVQ432JA.js} +23 -23
  9. package/dist/{chunk-PEAOQ7YH.js.map → chunk-EVQ432JA.js.map} +1 -1
  10. package/dist/{chunk-PPSRTX52.mjs → chunk-IHQPXEB7.mjs} +123 -11
  11. package/dist/chunk-IHQPXEB7.mjs.map +1 -0
  12. package/dist/{chunk-3IPH7UTM.mjs → chunk-OGWTKRJK.js} +196 -3
  13. package/dist/chunk-OGWTKRJK.js.map +1 -0
  14. package/dist/{chunk-W5UTGQI2.mjs → chunk-S6BFRUJQ.mjs} +3 -3
  15. package/dist/{chunk-W5UTGQI2.mjs.map → chunk-S6BFRUJQ.mjs.map} +1 -1
  16. package/dist/{chunk-FYR5Z7M2.js → chunk-U3JFWP24.mjs} +185 -6
  17. package/dist/chunk-U3JFWP24.mjs.map +1 -0
  18. package/dist/chunk-XB6PXEKO.js +529 -0
  19. package/dist/chunk-XB6PXEKO.js.map +1 -0
  20. package/dist/{chunk-ZQ2ZZPOW.js → chunk-XTVGQXCL.js} +4 -4
  21. package/dist/{chunk-ZQ2ZZPOW.js.map → chunk-XTVGQXCL.js.map} +1 -1
  22. package/dist/cli.js +881 -46
  23. package/dist/cli.js.map +1 -1
  24. package/dist/{registry-DOiHyH-r.d.mts → constants-DbFwuCjR.d.mts} +1 -177
  25. package/dist/{registry-DOiHyH-r.d.ts → constants-DbFwuCjR.d.ts} +1 -177
  26. package/dist/core/index.d.mts +66 -3
  27. package/dist/core/index.d.ts +66 -3
  28. package/dist/core/index.js +55 -39
  29. package/dist/core/index.mjs +2 -2
  30. package/dist/correspondence-model-D8c42J4c.d.mts +281 -0
  31. package/dist/correspondence-model-DhmBYoMf.d.ts +281 -0
  32. package/dist/gematria/index.d.mts +2 -1
  33. package/dist/gematria/index.d.ts +2 -1
  34. package/dist/gematria/index.js +5 -5
  35. package/dist/gematria/index.mjs +2 -2
  36. package/dist/index.d.mts +4 -3
  37. package/dist/index.d.ts +4 -3
  38. package/dist/index.js +109 -69
  39. package/dist/index.mjs +5 -5
  40. package/dist/numerology/index.js +18 -18
  41. package/dist/numerology/index.mjs +3 -3
  42. package/dist/tarot/index.d.mts +64 -2
  43. package/dist/tarot/index.d.ts +64 -2
  44. package/dist/tarot/index.js +30 -4
  45. package/dist/tarot/index.mjs +3 -1
  46. package/package.json +1 -1
  47. package/dist/chunk-3IPH7UTM.mjs.map +0 -1
  48. package/dist/chunk-AD7T42HJ.js +0 -4
  49. package/dist/chunk-AD7T42HJ.js.map +0 -1
  50. package/dist/chunk-BJUCABP4.js.map +0 -1
  51. package/dist/chunk-FYR5Z7M2.js.map +0 -1
  52. package/dist/chunk-PPSRTX52.mjs.map +0 -1
  53. package/dist/chunk-RFSO3JRG.mjs +0 -3
  54. package/dist/chunk-RFSO3JRG.mjs.map +0 -1
package/dist/cli.js CHANGED
@@ -8735,7 +8735,7 @@ var import_config3 = require("dotenv/config");
8735
8735
  // package.json
8736
8736
  var package_default = {
8737
8737
  name: "kaabalah",
8738
- version: "5.5.1",
8738
+ version: "5.6.0",
8739
8739
  description: "The de-facto library for any esoteric calculations and tooling",
8740
8740
  engines: {
8741
8741
  node: ">=18.18.0"
@@ -8961,7 +8961,7 @@ var COMMANDS = [
8961
8961
  },
8962
8962
  {
8963
8963
  name: "tree",
8964
- description: "Show Tree of Life structure with all nodes, data, and edges",
8964
+ description: "Show Tree of Life structure with nodes and first-class correspondence edges",
8965
8965
  args: [],
8966
8966
  flags: [],
8967
8967
  examples: ["kaabalah tree --json --compact", "kaabalah tree --json --fields=nodes"]
@@ -8981,6 +8981,20 @@ var COMMANDS = [
8981
8981
  "kaabalah tree:node path:1 --depth=2 --json"
8982
8982
  ]
8983
8983
  },
8984
+ {
8985
+ name: "tree:find",
8986
+ description: "Find tree nodes by ID, name, or type",
8987
+ args: [{ name: "query", type: "string", required: false, description: "Search string matched against node IDs and names" }],
8988
+ flags: [
8989
+ { name: "type", type: "string", description: "Filter matches by node type (e.g. sphere, tarotArkAnnu, planet)" },
8990
+ { name: "limit", type: "number", default: 20, description: "Maximum matches to return (default: 20)" }
8991
+ ],
8992
+ examples: [
8993
+ "kaabalah tree:find magician --json",
8994
+ "kaabalah tree:find --type=planet --json",
8995
+ "kaabalah tree:find kether --type=sphere --json --compact"
8996
+ ]
8997
+ },
8984
8998
  {
8985
8999
  name: "tree:types",
8986
9000
  description: "List all node types and their counts",
@@ -13273,6 +13287,11 @@ var COLORS_DATA = {
13273
13287
  }
13274
13288
  };
13275
13289
 
13290
+ // src/core/correspondence-model.ts
13291
+ function makeCorrespondenceId(left, right) {
13292
+ return [left, right].sort().join("<->");
13293
+ }
13294
+
13276
13295
  // src/core/systems/hermetic-qabalah.ts
13277
13296
  var hermetic_qabalah_exports = {};
13278
13297
  __export(hermetic_qabalah_exports, {
@@ -17619,7 +17638,13 @@ var ModuleManager = class {
17619
17638
  if (!loadedSystem) {
17620
17639
  throw new Error(`System ${systemKey} not found`);
17621
17640
  }
17622
- loadedSystem.LOADERS.base(this.t);
17641
+ this.t.runWithMutationSource(
17642
+ {
17643
+ kind: "system",
17644
+ system: systemKey
17645
+ },
17646
+ () => loadedSystem.LOADERS.base(this.t)
17647
+ );
17623
17648
  this.activeSystem = systemKey;
17624
17649
  this.loadedParts.clear();
17625
17650
  this.loadedParts.add("base");
@@ -17639,13 +17664,28 @@ var ModuleManager = class {
17639
17664
  if (this.loadedParts.has(partKey)) {
17640
17665
  return;
17641
17666
  }
17642
- system.LOADERS[partKey](this.t);
17667
+ this.t.runWithMutationSource(
17668
+ {
17669
+ kind: "part",
17670
+ system: this.activeSystem,
17671
+ part: partKey
17672
+ },
17673
+ () => system.LOADERS[partKey](this.t)
17674
+ );
17643
17675
  this.loadedParts.add(partKey);
17644
17676
  const possiblePartBridges = system.BRIDGES.filter(
17645
17677
  (b) => b.needs.includes(partKey) && !this.bridgedParts.has(b.id) && b.needs.every((n) => this.loadedParts.has(n))
17646
17678
  );
17647
17679
  for (const bridge of possiblePartBridges) {
17648
- bridge.run(this.t);
17680
+ this.t.runWithMutationSource(
17681
+ {
17682
+ kind: "bridge",
17683
+ system: this.activeSystem,
17684
+ bridgeId: bridge.id,
17685
+ parts: [...bridge.needs]
17686
+ },
17687
+ () => bridge.run(this.t)
17688
+ );
17649
17689
  this.bridgedParts.add(bridge.id);
17650
17690
  }
17651
17691
  }
@@ -17682,7 +17722,15 @@ var ModuleManager = class {
17682
17722
  throw new Error(`Bridge ${bridgeKey} not found`);
17683
17723
  }
17684
17724
  if (!this.bridgedParts.has(bridge.id) && bridge.needs.every((n) => this.loadedParts.has(n))) {
17685
- bridge.run(this.t);
17725
+ this.t.runWithMutationSource(
17726
+ {
17727
+ kind: "bridge",
17728
+ system: this.activeSystem,
17729
+ bridgeId: bridge.id,
17730
+ parts: [...bridge.needs]
17731
+ },
17732
+ () => bridge.run(this.t)
17733
+ );
17686
17734
  this.bridgedParts.add(bridge.id);
17687
17735
  }
17688
17736
  }
@@ -17718,12 +17766,60 @@ var ModuleManager = class {
17718
17766
  };
17719
17767
 
17720
17768
  // src/core/tree-of-life.ts
17769
+ function mergeCorrespondenceMetadata(current, next) {
17770
+ if (!current) {
17771
+ return next ? { ...next } : void 0;
17772
+ }
17773
+ if (!next) {
17774
+ return { ...current };
17775
+ }
17776
+ return {
17777
+ ...current,
17778
+ ...next,
17779
+ tags: [.../* @__PURE__ */ new Set([...current.tags ?? [], ...next.tags ?? []])],
17780
+ attributes: {
17781
+ ...current.attributes ?? {},
17782
+ ...next.attributes ?? {}
17783
+ }
17784
+ };
17785
+ }
17786
+ function mergeCorrespondenceSources(current, next) {
17787
+ const seen = /* @__PURE__ */ new Set();
17788
+ const merged = [];
17789
+ for (const source of [...current, next]) {
17790
+ const key = JSON.stringify(source);
17791
+ if (seen.has(key)) {
17792
+ continue;
17793
+ }
17794
+ seen.add(key);
17795
+ merged.push({
17796
+ ...source,
17797
+ ...source.kind === "bridge" ? { parts: [...source.parts] } : {}
17798
+ });
17799
+ }
17800
+ return merged;
17801
+ }
17721
17802
  var TreeOfLife = class {
17722
17803
  constructor() {
17723
17804
  this.nodes = /* @__PURE__ */ new Map();
17724
17805
  this.adjacent = /* @__PURE__ */ new Map();
17806
+ this.edges = /* @__PURE__ */ new Map();
17807
+ this.mutationSources = [{ kind: "manual" }];
17725
17808
  this.modules = new ModuleManager(this);
17726
17809
  }
17810
+ getCurrentMutationSource() {
17811
+ return this.mutationSources[this.mutationSources.length - 1] ?? {
17812
+ kind: "manual"
17813
+ };
17814
+ }
17815
+ runWithMutationSource(source, fn) {
17816
+ this.mutationSources.push(source);
17817
+ try {
17818
+ return fn();
17819
+ } finally {
17820
+ this.mutationSources.pop();
17821
+ }
17822
+ }
17727
17823
  /**
17728
17824
  * Loads the tree of life system to be used
17729
17825
  * @param systemKey - the key of the system to load
@@ -17785,28 +17881,57 @@ var TreeOfLife = class {
17785
17881
  getNodes() {
17786
17882
  return [...this.nodes.values()];
17787
17883
  }
17884
+ getEdge(left, right) {
17885
+ return this.edges.get(makeCorrespondenceId(left, right));
17886
+ }
17887
+ getEdges(nodeId) {
17888
+ if (!nodeId) {
17889
+ return [...this.edges.values()];
17890
+ }
17891
+ return [...this.adjacent.get(nodeId) ?? []].map((relatedNodeId) => this.getEdge(nodeId, relatedNodeId)).filter((edge) => Boolean(edge));
17892
+ }
17788
17893
  /**
17789
17894
  * Links two nodes bi-directionally
17790
17895
  * @param firstNode - the id of the first node
17791
17896
  * @param secondNode - the id of the second node
17792
17897
  */
17793
- link(firstNode, secondNode) {
17898
+ link(firstNode, secondNode, options = {}) {
17794
17899
  if (!this.nodes.has(firstNode) || !this.nodes.has(secondNode)) {
17795
17900
  throw new Error("unknown node id");
17796
17901
  }
17797
17902
  if (firstNode === secondNode) {
17798
17903
  return;
17799
17904
  }
17800
- if (this.adjacent.has(firstNode) && this.adjacent.get(firstNode)?.has(secondNode)) {
17801
- return;
17802
- }
17905
+ const edgeId = makeCorrespondenceId(firstNode, secondNode);
17906
+ const source = options.source ?? this.getCurrentMutationSource();
17907
+ const existingEdge = this.edges.get(edgeId);
17803
17908
  const put = (leftNode, rightNode) => {
17804
17909
  const set = this.adjacent.get(leftNode) ?? /* @__PURE__ */ new Set();
17805
17910
  set.add(rightNode);
17806
17911
  this.adjacent.set(leftNode, set);
17807
17912
  };
17913
+ if (existingEdge) {
17914
+ this.edges.set(edgeId, {
17915
+ ...existingEdge,
17916
+ metadata: mergeCorrespondenceMetadata(
17917
+ existingEdge.metadata,
17918
+ options.metadata
17919
+ ),
17920
+ sources: mergeCorrespondenceSources(existingEdge.sources, source)
17921
+ });
17922
+ put(firstNode, secondNode);
17923
+ put(secondNode, firstNode);
17924
+ return;
17925
+ }
17808
17926
  put(firstNode, secondNode);
17809
17927
  put(secondNode, firstNode);
17928
+ this.edges.set(edgeId, {
17929
+ id: edgeId,
17930
+ left: firstNode,
17931
+ right: secondNode,
17932
+ metadata: mergeCorrespondenceMetadata(void 0, options.metadata),
17933
+ sources: mergeCorrespondenceSources([], source)
17934
+ });
17810
17935
  }
17811
17936
  /**
17812
17937
  * Gets the current node and all its direct relations, or, when filtered by node type, only the direct relations of that type.
@@ -17891,6 +18016,7 @@ var TreeOfLife = class {
17891
18016
  const neighbors = this.adjacent.get(id2);
17892
18017
  if (neighbors) {
17893
18018
  for (const neighbor of neighbors) {
18019
+ this.edges.delete(makeCorrespondenceId(id2, neighbor));
17894
18020
  const set = this.adjacent.get(neighbor);
17895
18021
  if (!set) {
17896
18022
  continue;
@@ -19908,7 +20034,551 @@ Fibonacci Cycle: ${dateStr} (age ${result.currentAge})
19908
20034
  console.log();
19909
20035
  }
19910
20036
 
20037
+ // src/core/workspace.ts
20038
+ function cloneNode(node) {
20039
+ return Object.freeze({
20040
+ id: node.id,
20041
+ type: node.type,
20042
+ name: node.name,
20043
+ data: node.data && typeof node.data === "object" ? { ...node.data } : node.data
20044
+ });
20045
+ }
20046
+ function cloneMetadata(metadata) {
20047
+ if (!metadata) {
20048
+ return void 0;
20049
+ }
20050
+ return {
20051
+ ...metadata,
20052
+ tags: metadata.tags ? [...metadata.tags] : void 0,
20053
+ attributes: metadata.attributes ? { ...metadata.attributes } : void 0
20054
+ };
20055
+ }
20056
+ function cloneSource(source) {
20057
+ if (source.kind === "bridge") {
20058
+ return {
20059
+ ...source,
20060
+ parts: [...source.parts]
20061
+ };
20062
+ }
20063
+ return { ...source };
20064
+ }
20065
+ function cloneEdge(edge) {
20066
+ return Object.freeze({
20067
+ ...edge,
20068
+ metadata: cloneMetadata(edge.metadata),
20069
+ sources: edge.sources.map(cloneSource)
20070
+ });
20071
+ }
20072
+ function cloneNote(note) {
20073
+ return Object.freeze({
20074
+ ...note,
20075
+ target: { ...note.target },
20076
+ metadata: note.metadata ? { ...note.metadata } : void 0
20077
+ });
20078
+ }
20079
+ function mergeMetadata(current, next) {
20080
+ if (!current) {
20081
+ return cloneMetadata(next);
20082
+ }
20083
+ if (!next) {
20084
+ return cloneMetadata(current);
20085
+ }
20086
+ return {
20087
+ ...current,
20088
+ ...next,
20089
+ tags: [.../* @__PURE__ */ new Set([...current.tags ?? [], ...next.tags ?? []])],
20090
+ attributes: {
20091
+ ...current.attributes ?? {},
20092
+ ...next.attributes ?? {}
20093
+ }
20094
+ };
20095
+ }
20096
+ function mergeSources(current, next) {
20097
+ const seen = /* @__PURE__ */ new Set();
20098
+ const merged = [];
20099
+ for (const source of [...current, next]) {
20100
+ const key = JSON.stringify(source);
20101
+ if (seen.has(key)) {
20102
+ continue;
20103
+ }
20104
+ seen.add(key);
20105
+ merged.push(cloneSource(source));
20106
+ }
20107
+ return merged;
20108
+ }
20109
+ function normalizeTypes(type) {
20110
+ if (!type) {
20111
+ return void 0;
20112
+ }
20113
+ return new Set(Array.isArray(type) ? type : [type]);
20114
+ }
20115
+ function sortNodes(nodes) {
20116
+ return [...nodes].sort((left, right) => {
20117
+ if (left.type !== right.type) {
20118
+ return left.type.localeCompare(right.type);
20119
+ }
20120
+ const leftLabel = String(left.name ?? left.id);
20121
+ const rightLabel = String(right.name ?? right.id);
20122
+ return leftLabel.localeCompare(rightLabel);
20123
+ });
20124
+ }
20125
+ function sortMatches(matches) {
20126
+ return [...matches].sort((left, right) => {
20127
+ if (left.distance !== right.distance) {
20128
+ return left.distance - right.distance;
20129
+ }
20130
+ if (left.node.type !== right.node.type) {
20131
+ return left.node.type.localeCompare(right.node.type);
20132
+ }
20133
+ const leftLabel = String(left.node.name ?? left.node.id);
20134
+ const rightLabel = String(right.node.name ?? right.node.id);
20135
+ return leftLabel.localeCompare(rightLabel);
20136
+ });
20137
+ }
20138
+ function createGraphData(descriptor, nodes, edges, notes) {
20139
+ const nodesById = /* @__PURE__ */ new Map();
20140
+ const nodeIdsByType = /* @__PURE__ */ new Map();
20141
+ const edgesById = /* @__PURE__ */ new Map();
20142
+ const edgeIdsByNodeId = /* @__PURE__ */ new Map();
20143
+ const notesById = /* @__PURE__ */ new Map();
20144
+ const noteIdsByNodeId = /* @__PURE__ */ new Map();
20145
+ const noteIdsByCorrespondenceId = /* @__PURE__ */ new Map();
20146
+ for (const node of nodes) {
20147
+ const clonedNode = cloneNode(node);
20148
+ nodesById.set(clonedNode.id, clonedNode);
20149
+ const typedIds = nodeIdsByType.get(clonedNode.type) ?? [];
20150
+ typedIds.push(clonedNode.id);
20151
+ nodeIdsByType.set(clonedNode.type, typedIds);
20152
+ }
20153
+ for (const edge of edges) {
20154
+ const clonedEdge = cloneEdge(edge);
20155
+ edgesById.set(clonedEdge.id, clonedEdge);
20156
+ const leftEdges = edgeIdsByNodeId.get(clonedEdge.left) ?? [];
20157
+ leftEdges.push(clonedEdge.id);
20158
+ edgeIdsByNodeId.set(clonedEdge.left, leftEdges);
20159
+ const rightEdges = edgeIdsByNodeId.get(clonedEdge.right) ?? [];
20160
+ rightEdges.push(clonedEdge.id);
20161
+ edgeIdsByNodeId.set(clonedEdge.right, rightEdges);
20162
+ }
20163
+ for (const note of notes) {
20164
+ const clonedNote = cloneNote(note);
20165
+ notesById.set(clonedNote.id, clonedNote);
20166
+ if (clonedNote.target.kind === "node") {
20167
+ const nodeNoteIds = noteIdsByNodeId.get(clonedNote.target.nodeId) ?? [];
20168
+ nodeNoteIds.push(clonedNote.id);
20169
+ noteIdsByNodeId.set(clonedNote.target.nodeId, nodeNoteIds);
20170
+ continue;
20171
+ }
20172
+ const edgeId = makeCorrespondenceId(
20173
+ clonedNote.target.left,
20174
+ clonedNote.target.right
20175
+ );
20176
+ const correspondenceNoteIds = noteIdsByCorrespondenceId.get(edgeId) ?? [];
20177
+ correspondenceNoteIds.push(clonedNote.id);
20178
+ noteIdsByCorrespondenceId.set(edgeId, correspondenceNoteIds);
20179
+ }
20180
+ for (const ids of nodeIdsByType.values()) {
20181
+ ids.sort((left, right) => String(left).localeCompare(String(right)));
20182
+ }
20183
+ for (const ids of edgeIdsByNodeId.values()) {
20184
+ ids.sort((left, right) => left.localeCompare(right));
20185
+ }
20186
+ for (const ids of noteIdsByNodeId.values()) {
20187
+ ids.sort((left, right) => left.localeCompare(right));
20188
+ }
20189
+ for (const ids of noteIdsByCorrespondenceId.values()) {
20190
+ ids.sort((left, right) => left.localeCompare(right));
20191
+ }
20192
+ return {
20193
+ descriptor: Object.freeze({ ...descriptor }),
20194
+ nodesById,
20195
+ nodeIdsByType,
20196
+ edgesById,
20197
+ edgeIdsByNodeId,
20198
+ notesById,
20199
+ noteIdsByNodeId,
20200
+ noteIdsByCorrespondenceId
20201
+ };
20202
+ }
20203
+ function normalizeBase(base) {
20204
+ if (!base) {
20205
+ return {
20206
+ descriptor: {},
20207
+ nodes: [],
20208
+ edges: [],
20209
+ notes: []
20210
+ };
20211
+ }
20212
+ if (base instanceof TreeWorkspace) {
20213
+ return {
20214
+ descriptor: base.descriptor,
20215
+ nodes: base.getNodes(),
20216
+ edges: base.getEdges(),
20217
+ notes: base.getNotes()
20218
+ };
20219
+ }
20220
+ return {
20221
+ descriptor: {
20222
+ system: base.activeSystem ?? void 0,
20223
+ parts: base.loadedParts.filter((part) => part !== "base")
20224
+ },
20225
+ nodes: base.getNodes(),
20226
+ edges: base.getEdges(),
20227
+ notes: []
20228
+ };
20229
+ }
20230
+ function applyOverlays(base, overlays) {
20231
+ const nodesById = /* @__PURE__ */ new Map();
20232
+ const edgesById = /* @__PURE__ */ new Map();
20233
+ const notes = [];
20234
+ for (const node of base.nodes) {
20235
+ nodesById.set(node.id, cloneNode(node));
20236
+ }
20237
+ for (const edge of base.edges) {
20238
+ edgesById.set(edge.id, cloneEdge(edge));
20239
+ }
20240
+ for (const note of base.notes) {
20241
+ notes.push(cloneNote(note));
20242
+ }
20243
+ for (const overlay of overlays) {
20244
+ for (const node of overlay.nodes ?? []) {
20245
+ const existing = nodesById.get(node.id);
20246
+ if (existing && existing.type !== node.type) {
20247
+ throw new Error(
20248
+ `Overlay ${overlay.id} tried to upsert ${node.id} with a different type`
20249
+ );
20250
+ }
20251
+ nodesById.set(
20252
+ node.id,
20253
+ cloneNode(
20254
+ existing ? {
20255
+ ...existing,
20256
+ ...node,
20257
+ data: {
20258
+ ...existing.data ?? {},
20259
+ ...node.data ?? {}
20260
+ }
20261
+ } : node
20262
+ )
20263
+ );
20264
+ }
20265
+ for (const correspondence of overlay.correspondences ?? []) {
20266
+ if (!nodesById.has(correspondence.left) || !nodesById.has(correspondence.right)) {
20267
+ throw new Error(
20268
+ `Overlay ${overlay.id} references unknown nodes in ${correspondence.left} <-> ${correspondence.right}`
20269
+ );
20270
+ }
20271
+ const edgeId = makeCorrespondenceId(
20272
+ correspondence.left,
20273
+ correspondence.right
20274
+ );
20275
+ if (correspondence.op === "remove") {
20276
+ edgesById.delete(edgeId);
20277
+ continue;
20278
+ }
20279
+ const existingEdge = edgesById.get(edgeId);
20280
+ const overlaySource = {
20281
+ kind: "overlay",
20282
+ overlayId: overlay.id,
20283
+ label: overlay.name
20284
+ };
20285
+ if (!existingEdge) {
20286
+ if (correspondence.op !== "add") {
20287
+ throw new Error(
20288
+ `Overlay ${overlay.id} cannot annotate missing correspondence ${edgeId}`
20289
+ );
20290
+ }
20291
+ edgesById.set(
20292
+ edgeId,
20293
+ cloneEdge({
20294
+ id: edgeId,
20295
+ left: correspondence.left,
20296
+ right: correspondence.right,
20297
+ metadata: cloneMetadata(correspondence.metadata),
20298
+ sources: [overlaySource]
20299
+ })
20300
+ );
20301
+ continue;
20302
+ }
20303
+ edgesById.set(
20304
+ edgeId,
20305
+ cloneEdge({
20306
+ ...existingEdge,
20307
+ metadata: mergeMetadata(existingEdge.metadata, correspondence.metadata),
20308
+ sources: mergeSources(existingEdge.sources, overlaySource)
20309
+ })
20310
+ );
20311
+ }
20312
+ for (const note of overlay.notes ?? []) {
20313
+ notes.push(
20314
+ cloneNote({
20315
+ ...note,
20316
+ metadata: note.metadata ? { ...note.metadata } : void 0
20317
+ })
20318
+ );
20319
+ }
20320
+ }
20321
+ const filteredNotes = notes.filter((note) => {
20322
+ if (note.target.kind === "node") {
20323
+ return nodesById.has(note.target.nodeId);
20324
+ }
20325
+ return edgesById.has(
20326
+ makeCorrespondenceId(note.target.left, note.target.right)
20327
+ );
20328
+ });
20329
+ return {
20330
+ nodes: [...nodesById.values()],
20331
+ edges: [...edgesById.values()],
20332
+ notes: filteredNotes
20333
+ };
20334
+ }
20335
+ function reconstructPath(startId, targetId, previous, edgesById) {
20336
+ const steps = [];
20337
+ let current = targetId;
20338
+ while (current !== startId) {
20339
+ const link = previous.get(current);
20340
+ if (!link) {
20341
+ break;
20342
+ }
20343
+ const edge = edgesById.get(link.edgeId);
20344
+ if (!edge) {
20345
+ break;
20346
+ }
20347
+ steps.push({
20348
+ from: link.from,
20349
+ to: current,
20350
+ edge
20351
+ });
20352
+ current = link.from;
20353
+ }
20354
+ return steps.reverse();
20355
+ }
20356
+ function buildCanonicalDescriptor(opts, cacheKey) {
20357
+ return {
20358
+ id: `canonical:${cacheKey}`,
20359
+ name: "Canonical Tree",
20360
+ system: opts.system,
20361
+ parts: [...opts.parts ?? []],
20362
+ cacheKey
20363
+ };
20364
+ }
20365
+ var canonicalTreeCache = /* @__PURE__ */ new Map();
20366
+ var TreeWorkspace = class {
20367
+ constructor(graph, visualResolvers = []) {
20368
+ this.graph = graph;
20369
+ this.visualResolvers = visualResolvers;
20370
+ this.descriptor = graph.descriptor;
20371
+ }
20372
+ getNode(id2) {
20373
+ return this.graph.nodesById.get(id2);
20374
+ }
20375
+ hasNode(id2) {
20376
+ return this.graph.nodesById.has(id2);
20377
+ }
20378
+ getNodes(type) {
20379
+ if (!type) {
20380
+ return sortNodes(
20381
+ [...this.graph.nodesById.values()]
20382
+ );
20383
+ }
20384
+ const ids = this.graph.nodeIdsByType.get(type) ?? [];
20385
+ return ids.map((id2) => this.graph.nodesById.get(id2)).filter((node) => Boolean(node));
20386
+ }
20387
+ findNodes(options = {}) {
20388
+ const typeFilter = normalizeTypes(options.type);
20389
+ const search = options.search?.trim().toLowerCase();
20390
+ const candidates = options.ids ? options.ids.map((id2) => this.graph.nodesById.get(id2)).filter((node) => Boolean(node)) : typeFilter ? [...typeFilter].flatMap((type) => this.getNodes(type)) : this.getNodes();
20391
+ return sortNodes(
20392
+ candidates.filter((node) => {
20393
+ if (typeFilter && !typeFilter.has(node.type)) {
20394
+ return false;
20395
+ }
20396
+ if (search) {
20397
+ const haystacks = [
20398
+ String(node.id).toLowerCase(),
20399
+ String(node.name ?? "").toLowerCase()
20400
+ ];
20401
+ if (!haystacks.some((value) => value.includes(search))) {
20402
+ return false;
20403
+ }
20404
+ }
20405
+ return options.predicate ? options.predicate(node) : true;
20406
+ })
20407
+ );
20408
+ }
20409
+ getEdge(left, right) {
20410
+ return this.graph.edgesById.get(makeCorrespondenceId(left, right));
20411
+ }
20412
+ getEdges(nodeId) {
20413
+ if (!nodeId) {
20414
+ return [...this.graph.edgesById.values()];
20415
+ }
20416
+ return (this.graph.edgeIdsByNodeId.get(nodeId) ?? []).map((edgeId) => this.graph.edgesById.get(edgeId)).filter((edge) => Boolean(edge));
20417
+ }
20418
+ getNotes(target) {
20419
+ if (!target) {
20420
+ return [...this.graph.notesById.values()];
20421
+ }
20422
+ if (target.kind === "node") {
20423
+ return (this.graph.noteIdsByNodeId.get(target.nodeId) ?? []).map((noteId) => this.graph.notesById.get(noteId)).filter((note) => Boolean(note));
20424
+ }
20425
+ const edgeId = makeCorrespondenceId(target.left, target.right);
20426
+ return (this.graph.noteIdsByCorrespondenceId.get(edgeId) ?? []).map((noteId) => this.graph.notesById.get(noteId)).filter((note) => Boolean(note));
20427
+ }
20428
+ getCorrespondences(nodeId, options = {}) {
20429
+ if (!this.graph.nodesById.has(nodeId)) {
20430
+ return [];
20431
+ }
20432
+ const typeFilter = normalizeTypes(options.type);
20433
+ const includeSelf = options.includeSelf ?? false;
20434
+ const depth = Math.max(1, options.depth ?? 1);
20435
+ const limit = options.limit ?? Infinity;
20436
+ const previous = /* @__PURE__ */ new Map();
20437
+ const visited = /* @__PURE__ */ new Set([nodeId]);
20438
+ const queue = [
20439
+ {
20440
+ nodeId,
20441
+ distance: 0
20442
+ }
20443
+ ];
20444
+ const matches = [];
20445
+ while (queue.length > 0 && matches.length < limit) {
20446
+ const current = queue.shift();
20447
+ if (current.distance >= depth) {
20448
+ continue;
20449
+ }
20450
+ for (const edgeId of this.graph.edgeIdsByNodeId.get(current.nodeId) ?? []) {
20451
+ const edge = this.graph.edgesById.get(edgeId);
20452
+ if (!edge) {
20453
+ continue;
20454
+ }
20455
+ const nextNodeId = edge.left === current.nodeId ? edge.right : edge.left;
20456
+ if (visited.has(nextNodeId)) {
20457
+ continue;
20458
+ }
20459
+ visited.add(nextNodeId);
20460
+ previous.set(nextNodeId, {
20461
+ from: current.nodeId,
20462
+ edgeId
20463
+ });
20464
+ const distance = current.distance + 1;
20465
+ const nextNode = this.graph.nodesById.get(nextNodeId);
20466
+ if (!nextNode) {
20467
+ continue;
20468
+ }
20469
+ if ((!typeFilter || typeFilter.has(nextNode.type)) && distance > 0) {
20470
+ matches.push({
20471
+ node: nextNode,
20472
+ distance,
20473
+ path: reconstructPath(
20474
+ nodeId,
20475
+ nextNodeId,
20476
+ previous,
20477
+ this.graph.edgesById
20478
+ )
20479
+ });
20480
+ }
20481
+ queue.push({
20482
+ nodeId: nextNodeId,
20483
+ distance
20484
+ });
20485
+ }
20486
+ }
20487
+ if (includeSelf) {
20488
+ const sourceNode = this.graph.nodesById.get(nodeId);
20489
+ if (sourceNode && (!typeFilter || typeFilter.has(sourceNode.type)) && matches.length < limit) {
20490
+ matches.unshift({
20491
+ node: sourceNode,
20492
+ distance: 0,
20493
+ path: []
20494
+ });
20495
+ }
20496
+ }
20497
+ return sortMatches(matches).slice(0, limit);
20498
+ }
20499
+ getCorrespondenceMap(nodeId, options = {}) {
20500
+ const grouped = {};
20501
+ for (const match of this.getCorrespondences(nodeId, options)) {
20502
+ const typeKey = match.node.type;
20503
+ const typeMatches = grouped[typeKey] ?? [];
20504
+ typeMatches.push(match);
20505
+ grouped[typeKey] = typeMatches;
20506
+ }
20507
+ return grouped;
20508
+ }
20509
+ resolveVisual(request) {
20510
+ for (const resolver of this.visualResolvers) {
20511
+ const resolved = resolver({
20512
+ request,
20513
+ workspace: this
20514
+ });
20515
+ if (resolved) {
20516
+ return resolved;
20517
+ }
20518
+ }
20519
+ return void 0;
20520
+ }
20521
+ };
20522
+ function createTreeWorkspace(options = {}) {
20523
+ const base = normalizeBase(options.base);
20524
+ const overlays = options.overlays ?? [];
20525
+ const applied = applyOverlays(base, overlays);
20526
+ const descriptor = {
20527
+ ...base.descriptor,
20528
+ ...options.descriptor
20529
+ };
20530
+ return new TreeWorkspace(
20531
+ createGraphData(descriptor, applied.nodes, applied.edges, applied.notes),
20532
+ options.visualResolvers ?? []
20533
+ );
20534
+ }
20535
+ function getCanonicalTree(opts = {
20536
+ system: "kaabalah",
20537
+ parts: []
20538
+ }) {
20539
+ const parts = [...opts.parts ?? []];
20540
+ const cacheKey = `${opts.system}:${parts.join(",")}`;
20541
+ const cachedTree = canonicalTreeCache.get(cacheKey);
20542
+ if (cachedTree) {
20543
+ return cachedTree;
20544
+ }
20545
+ const tree = createTree({
20546
+ system: opts.system,
20547
+ parts
20548
+ });
20549
+ const canonicalTree = createTreeWorkspace({
20550
+ base: tree,
20551
+ descriptor: buildCanonicalDescriptor(opts, cacheKey)
20552
+ });
20553
+ canonicalTreeCache.set(cacheKey, canonicalTree);
20554
+ return canonicalTree;
20555
+ }
20556
+
19911
20557
  // src/tarot/index.ts
20558
+ var majorArcana = [
20559
+ "01_the_magician",
20560
+ "02_the_high_priestess",
20561
+ "03_the_empress",
20562
+ "04_the_emperor",
20563
+ "05_the_hierophant",
20564
+ "06_the_lover",
20565
+ "07_the_chariot",
20566
+ "08_justice",
20567
+ "09_the_hermit",
20568
+ "10_the_wheel_of_fortune",
20569
+ "11_strength",
20570
+ "12_the_hanged_man",
20571
+ "13_death",
20572
+ "14_temperance",
20573
+ "15_the_devil",
20574
+ "16_the_house_of_god",
20575
+ "17_the_star",
20576
+ "18_the_moon",
20577
+ "19_the_sun",
20578
+ "20_judgement",
20579
+ "21_the_fool",
20580
+ "22_the_world"
20581
+ ];
19912
20582
  var ARKANNUS = [
19913
20583
  // Major Arcana (1-22)
19914
20584
  {
@@ -20758,6 +21428,9 @@ async function shuffleTarotDeck(cards, includeInvertedCards = false, shuffleCoun
20758
21428
  }
20759
21429
  return shuffledCards;
20760
21430
  }
21431
+ var MAJOR_ARCANA_CARDS = ARKANNUS.filter(
21432
+ (card) => card.type === "major" && majorArcana.includes(card.tarotCardFilename)
21433
+ );
20761
21434
 
20762
21435
  // src/cli/commands/tarot.ts
20763
21436
  function findCardsByQuery(query) {
@@ -20858,7 +21531,10 @@ function cmdTarotSpread(cardQueries, flags) {
20858
21531
 
20859
21532
  // src/cli/commands/tree.ts
20860
21533
  function getTree() {
20861
- return createTree({ system: SYSTEM2, parts: ["westernAstrology", "tarot"] });
21534
+ return getCanonicalTree({
21535
+ system: SYSTEM2,
21536
+ parts: ["westernAstrology", "tarot"]
21537
+ });
20862
21538
  }
20863
21539
  function serializeNode(node) {
20864
21540
  const result = { id: node.id, type: node.type };
@@ -20870,37 +21546,109 @@ function serializeNode(node) {
20870
21546
  }
20871
21547
  return result;
20872
21548
  }
21549
+ function serializeSource(source) {
21550
+ return source.kind === "bridge" ? { ...source, parts: [...source.parts] } : { ...source };
21551
+ }
21552
+ function serializeEdge(edge) {
21553
+ const serialized = {
21554
+ id: edge.id,
21555
+ from: edge.left,
21556
+ to: edge.right
21557
+ };
21558
+ if (edge.metadata) {
21559
+ serialized.metadata = edge.metadata;
21560
+ }
21561
+ if (edge.sources.length > 0) {
21562
+ serialized.sources = edge.sources.map(serializeSource);
21563
+ }
21564
+ return serialized;
21565
+ }
21566
+ function serializeMatch(match) {
21567
+ return {
21568
+ node: serializeNode(match.node),
21569
+ distance: match.distance,
21570
+ path: match.path.map((step) => ({
21571
+ from: step.from,
21572
+ to: step.to,
21573
+ edge: serializeEdge(step.edge)
21574
+ }))
21575
+ };
21576
+ }
21577
+ function getRelatedTypes(tree, nodeId) {
21578
+ return [...new Set(
21579
+ tree.getEdges(nodeId).map((edge) => {
21580
+ const relatedNodeId = edge.left === nodeId ? edge.right : edge.left;
21581
+ return tree.getNode(relatedNodeId)?.type;
21582
+ }).filter((type) => Boolean(type))
21583
+ )].sort((left, right) => left.localeCompare(right));
21584
+ }
21585
+ function groupSerializedMatches(matches) {
21586
+ const grouped = {};
21587
+ for (const match of matches) {
21588
+ const bucket = grouped[match.node.type] ?? [];
21589
+ bucket.push(serializeMatch(match));
21590
+ grouped[match.node.type] = bucket;
21591
+ }
21592
+ return grouped;
21593
+ }
21594
+ function humanLabel(node) {
21595
+ const data = node.data;
21596
+ return data?.name ?? data?.character ?? data?.englishName ?? data?.meaning ?? node.name ?? "";
21597
+ }
21598
+ function describeSources(edge) {
21599
+ const parts = /* @__PURE__ */ new Set();
21600
+ for (const source of edge.sources) {
21601
+ if (source.kind === "system") {
21602
+ parts.add(`system:${source.system}`);
21603
+ continue;
21604
+ }
21605
+ if (source.kind === "part") {
21606
+ parts.add(`part:${source.part}`);
21607
+ continue;
21608
+ }
21609
+ if (source.kind === "bridge") {
21610
+ parts.add(`bridge:${source.bridgeId}`);
21611
+ continue;
21612
+ }
21613
+ if (source.kind === "overlay") {
21614
+ parts.add(`overlay:${source.overlayId}`);
21615
+ continue;
21616
+ }
21617
+ parts.add(source.kind);
21618
+ }
21619
+ return [...parts].join(", ");
21620
+ }
20873
21621
  function cmdTree(flags) {
20874
21622
  const tree = getTree();
20875
21623
  const allNodes = tree.getNodes();
20876
21624
  if (isJsonMode(flags)) {
20877
21625
  const nodes = allNodes.map((node) => {
20878
21626
  const serialized = serializeNode(node);
20879
- const relatedTypes = tree.relatedTypes(node.id);
21627
+ const relatedTypes = getRelatedTypes(tree, node.id);
20880
21628
  if (relatedTypes.length > 0) {
20881
21629
  serialized.relatedTypes = relatedTypes;
20882
21630
  }
20883
21631
  return serialized;
20884
21632
  });
20885
- const edgeSet = /* @__PURE__ */ new Set();
20886
- const edges = [];
20887
- for (const node of allNodes) {
20888
- const related = tree.related(node.id);
20889
- for (const relation of related) {
20890
- const key = node.id < relation.id ? `${node.id}|${relation.id}` : `${relation.id}|${node.id}`;
20891
- if (!edgeSet.has(key)) {
20892
- edgeSet.add(key);
20893
- edges.push({ from: node.id, to: relation.id });
20894
- }
20895
- }
20896
- }
20897
- outputJson({ system: SYSTEM2, totalNodes: allNodes.length, totalEdges: edges.length, nodes, edges }, flags);
21633
+ const edges = tree.getEdges().map(serializeEdge);
21634
+ outputJson(
21635
+ {
21636
+ descriptor: tree.descriptor,
21637
+ system: SYSTEM2,
21638
+ totalNodes: allNodes.length,
21639
+ totalEdges: edges.length,
21640
+ nodes,
21641
+ edges
21642
+ },
21643
+ flags
21644
+ );
20898
21645
  return;
20899
21646
  }
20900
21647
  console.log(`
20901
21648
  Tree of Life (${SYSTEM2})
20902
21649
  `);
20903
21650
  console.log(` Total nodes: ${allNodes.length}`);
21651
+ console.log(` Total correspondences: ${tree.getEdges().length}`);
20904
21652
  const byType = /* @__PURE__ */ new Map();
20905
21653
  for (const node of allNodes) {
20906
21654
  if (!byType.has(node.type)) {
@@ -20912,9 +21660,8 @@ Tree of Life (${SYSTEM2})
20912
21660
  console.log(`
20913
21661
  ${type} (${nodes.length}):`);
20914
21662
  for (const node of nodes.slice(0, 15)) {
20915
- const data = node.data;
20916
- const name = data?.name ?? data?.character ?? "";
20917
- console.log(` ${node.id}${name ? ` \u2014 ${name}` : ""}`);
21663
+ const label = humanLabel(node);
21664
+ console.log(` ${node.id}${label ? ` \u2014 ${label}` : ""}`);
20918
21665
  }
20919
21666
  if (nodes.length > 15) {
20920
21667
  console.log(` ... and ${nodes.length - 15} more`);
@@ -20926,17 +21673,36 @@ function cmdTreeNode(idStr, flags) {
20926
21673
  const tree = getTree();
20927
21674
  const node = tree.getNode(idStr);
20928
21675
  if (!node) {
20929
- exitWithError("INVALID_ARGUMENT", `Node "${idStr}" not found. Use "kaabalah tree:types --json" to see valid node types, or "kaabalah tree --json --fields=nodes" to list all node IDs.`, flags);
21676
+ exitWithError(
21677
+ "INVALID_ARGUMENT",
21678
+ `Node "${idStr}" not found. Use "kaabalah tree:types --json" to see valid node types, or "kaabalah tree --json --fields=nodes" to list all node IDs.`,
21679
+ flags
21680
+ );
20930
21681
  }
20931
21682
  const typeFilter = getFlagString(flags, "type");
20932
21683
  const depth = getFlagNumber(flags, "depth") ?? 1;
20933
- const related = depth > 1 ? tree.walk(node.id, depth, typeFilter || void 0) : typeFilter ? tree.related(node.id, typeFilter) : tree.related(node.id);
21684
+ const correspondences = tree.getCorrespondences(node.id, {
21685
+ depth,
21686
+ type: typeFilter ?? void 0
21687
+ });
21688
+ const related = correspondences.map(({ node: relatedNode }) => relatedNode);
21689
+ const directEdges = tree.getEdges(node.id);
21690
+ const relatedTypes = getRelatedTypes(tree, node.id);
20934
21691
  if (isJsonMode(flags)) {
20935
- outputJson({
20936
- node: serializeNode(node),
20937
- relatedTypes: tree.relatedTypes(node.id),
20938
- related: related.map(serializeNode)
20939
- }, flags);
21692
+ outputJson(
21693
+ {
21694
+ descriptor: tree.descriptor,
21695
+ node: serializeNode(node),
21696
+ relatedTypes,
21697
+ depth,
21698
+ ...typeFilter ? { typeFilter } : {},
21699
+ related: related.map(serializeNode),
21700
+ directEdges: directEdges.map(serializeEdge),
21701
+ correspondences: correspondences.map(serializeMatch),
21702
+ correspondenceMap: groupSerializedMatches(correspondences)
21703
+ },
21704
+ flags
21705
+ );
20940
21706
  return;
20941
21707
  }
20942
21708
  console.log(`
@@ -20950,21 +21716,26 @@ function cmdTreeNode(idStr, flags) {
20950
21716
  }
20951
21717
  }
20952
21718
  console.log(`
20953
- Related types: ${tree.relatedTypes(node.id).join(", ")}`);
21719
+ Related types: ${relatedTypes.join(", ")}`);
20954
21720
  const byType = /* @__PURE__ */ new Map();
20955
- for (const relation of related) {
20956
- if (!byType.has(relation.type)) {
20957
- byType.set(relation.type, []);
21721
+ for (const relation of correspondences) {
21722
+ if (!byType.has(relation.node.type)) {
21723
+ byType.set(relation.node.type, []);
20958
21724
  }
20959
- byType.get(relation.type).push(relation);
21725
+ byType.get(relation.node.type).push(relation);
20960
21726
  }
20961
- for (const [type, nodes] of byType) {
21727
+ for (const [type, matches] of byType) {
20962
21728
  console.log(`
20963
21729
  ${type}:`);
20964
- for (const relation of nodes) {
20965
- const relationData = relation.data;
20966
- const label = relationData?.name ?? relationData?.character ?? relationData?.englishName ?? relationData?.meaning ?? "";
20967
- console.log(` ${relation.id}${label ? ` \u2014 ${label}` : ""}`);
21730
+ for (const match of matches) {
21731
+ const label = humanLabel(match.node);
21732
+ const sources = match.path.length > 0 ? describeSources(match.path[match.path.length - 1].edge) : "";
21733
+ const details = [
21734
+ label ? `\u2014 ${label}` : "",
21735
+ match.distance > 1 ? `(depth ${match.distance})` : "",
21736
+ sources ? `[${sources}]` : ""
21737
+ ].filter(Boolean).join(" ");
21738
+ console.log(` ${match.node.id}${details ? ` ${details}` : ""}`);
20968
21739
  }
20969
21740
  }
20970
21741
  console.log();
@@ -20981,7 +21752,13 @@ function cmdTreeTypes(flags) {
20981
21752
  counts[node.type].ids.push(node.id);
20982
21753
  }
20983
21754
  if (isJsonMode(flags)) {
20984
- outputJson(counts, flags);
21755
+ outputJson(
21756
+ {
21757
+ descriptor: tree.descriptor,
21758
+ types: counts
21759
+ },
21760
+ flags
21761
+ );
20985
21762
  return;
20986
21763
  }
20987
21764
  console.log(`
@@ -20992,6 +21769,58 @@ Node types (${Object.keys(counts).length}):
20992
21769
  }
20993
21770
  console.log();
20994
21771
  }
21772
+ function cmdTreeFind(query, flags) {
21773
+ const tree = getTree();
21774
+ const typeFilter = getFlagString(flags, "type");
21775
+ const limit = getFlagNumber(flags, "limit") ?? 20;
21776
+ const search = query?.trim() || void 0;
21777
+ if (!search && !typeFilter) {
21778
+ exitWithError(
21779
+ "MISSING_ARGUMENT",
21780
+ "Usage: kaabalah tree:find <query> [--type=<nodeType>] or kaabalah tree:find --type=<nodeType>",
21781
+ flags
21782
+ );
21783
+ }
21784
+ const matches = tree.findNodes({
21785
+ search,
21786
+ type: typeFilter ?? void 0
21787
+ });
21788
+ const limitedMatches = matches.slice(0, Math.max(1, limit));
21789
+ if (isJsonMode(flags)) {
21790
+ outputJson(
21791
+ {
21792
+ descriptor: tree.descriptor,
21793
+ query: search ?? null,
21794
+ ...typeFilter ? { typeFilter } : {},
21795
+ totalMatches: matches.length,
21796
+ returnedMatches: limitedMatches.length,
21797
+ matches: limitedMatches.map(serializeNode)
21798
+ },
21799
+ flags
21800
+ );
21801
+ return;
21802
+ }
21803
+ console.log(`
21804
+ Tree search
21805
+ `);
21806
+ if (search) {
21807
+ console.log(` Query: ${search}`);
21808
+ }
21809
+ if (typeFilter) {
21810
+ console.log(` Type: ${typeFilter}`);
21811
+ }
21812
+ console.log(` Matches: ${matches.length}
21813
+ `);
21814
+ for (const match of limitedMatches) {
21815
+ const label = humanLabel(match);
21816
+ console.log(` ${match.id}${label ? ` \u2014 ${label}` : ""}`);
21817
+ }
21818
+ if (matches.length > limitedMatches.length) {
21819
+ console.log(`
21820
+ ... and ${matches.length - limitedMatches.length} more`);
21821
+ }
21822
+ console.log();
21823
+ }
20995
21824
 
20996
21825
  // src/cli/app.ts
20997
21826
  function outputVersion(flags) {
@@ -21148,6 +21977,12 @@ async function runCli(argv) {
21148
21977
  }
21149
21978
  cmdTreeNode(inputPayload?.id ?? args.slice(1).join(" "), flags);
21150
21979
  return;
21980
+ case "tree:find":
21981
+ cmdTreeFind(
21982
+ inputPayload?.query ?? (args.slice(1).join(" ") || void 0),
21983
+ flags
21984
+ );
21985
+ return;
21151
21986
  case "tree:types":
21152
21987
  cmdTreeTypes(flags);
21153
21988
  return;