kaabalah 5.0.0 → 5.1.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.
package/README.md CHANGED
@@ -70,6 +70,76 @@ const gematriaValue = calculateGematria('kaabalah');
70
70
  const spread = getRandomSpread(3, true);
71
71
  ```
72
72
 
73
+ ## CLI
74
+
75
+ Kaabalah includes a command-line interface for quick calculations without writing code.
76
+
77
+ ```bash
78
+ # Install globally
79
+ npm install -g kaabalah
80
+
81
+ # Or run directly with npx
82
+ npx kaabalah help
83
+ ```
84
+
85
+ ### Commands
86
+
87
+ | Command | Description |
88
+ |---------|-------------|
89
+ | `gematria <text>` | Calculate gematria for a word or phrase |
90
+ | `gematria:reverse <number>` | Find letter combinations matching a gematria value |
91
+ | `numerology <date>` | Full numerological profile for a birth date |
92
+ | `numerology:lifepath <date>` | Life path number (kaabalistic method) |
93
+ | `numerology:cycles <date> [name]` | Personal cycles (year, month, periods) |
94
+ | `numerology:challenges <date>` | Challenges from birth date |
95
+ | `numerology:fibonacci <date>` | Fibonacci cycle for current age |
96
+ | `astrology <date> [time]` | Calculate birth chart using Swiss Ephemeris |
97
+ | `tarot [count]` | Draw tarot cards (default: 3) |
98
+ | `tarot:card <number>` | Look up a specific card (1-78) |
99
+ | `ifa <date>` | Calculate Odu from a date |
100
+ | `tree` | Show Tree of Life structure with all nodes, data, and edges |
101
+ | `tree:node <id>` | Look up a node and all its correspondences |
102
+ | `tree:types` | List all node types and their counts |
103
+
104
+ ### Examples
105
+
106
+ ```bash
107
+ kaabalah gematria "Hello World"
108
+ kaabalah numerology 1990-01-15
109
+ kaabalah numerology:cycles 1990-01-15 John
110
+ kaabalah tarot 5 --inverted
111
+ kaabalah tarot:card 7
112
+ kaabalah gematria:reverse 22
113
+ kaabalah ifa 1990-01-15
114
+ kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006
115
+ kaabalah astrology 1990-01-15 14:30 --location="New York, USA"
116
+
117
+ # Tree of Life correspondences
118
+ kaabalah tree:node path:1 --json
119
+ kaabalah tree:node "tarotArkAnnu:The Magician" --depth=2 --json
120
+ kaabalah tree:node sphere:Kether --type=tarotArkAnnu --json
121
+ ```
122
+
123
+ ### Global Flags
124
+
125
+ | Flag | Description |
126
+ |------|-------------|
127
+ | `--json` | JSON output (auto-enabled when stdout is not a TTY) |
128
+ | `--no-json` | Force human-readable output even when piped |
129
+ | `--compact` | Minified JSON (no indentation) |
130
+ | `--fields=a.b,c.d` | Filter JSON output to specified dot-paths |
131
+ | `--input-json='{"key":"val"}'` | Pass all parameters as a JSON object |
132
+
133
+ ### Schema Introspection
134
+
135
+ ```bash
136
+ # Full schema of all commands
137
+ kaabalah help --json
138
+
139
+ # Schema for a specific command
140
+ kaabalah help astrology --json
141
+ ```
142
+
73
143
  ## Development
74
144
 
75
145
  This project uses TypeScript and WebAssembly for the Swiss Ephemeris calculations.
package/dist/cli.js CHANGED
@@ -26,7 +26,7 @@ var COMMANDS = [
26
26
  { name: "missing", type: "boolean", default: false, description: "Show missing gematria values" },
27
27
  { name: "percentages", type: "boolean", default: false, description: "Show letter percentages" }
28
28
  ],
29
- examples: ['kaabalah gematria "Mat Moura"', 'kaabalah gematria "Mat Moura" --json']
29
+ examples: ['kaabalah gematria "Hello World"', 'kaabalah gematria "Hello World" --json']
30
30
  },
31
31
  {
32
32
  name: "gematria:reverse",
@@ -62,7 +62,7 @@ var COMMANDS = [
62
62
  { name: "firstName", type: "string", required: false, description: "First name for personal cycles" }
63
63
  ],
64
64
  flags: [],
65
- examples: ["kaabalah numerology:cycles 1990-01-15", "kaabalah numerology:cycles 1990-01-15 Mateus"]
65
+ examples: ["kaabalah numerology:cycles 1990-01-15", "kaabalah numerology:cycles 1990-01-15 John"]
66
66
  },
67
67
  {
68
68
  name: "numerology:challenges",
@@ -104,10 +104,32 @@ var COMMANDS = [
104
104
  },
105
105
  {
106
106
  name: "tree",
107
- description: "Show Tree of Life structure",
107
+ description: "Show Tree of Life structure with all nodes, data, and edges",
108
108
  args: [],
109
109
  flags: [],
110
- examples: ["kaabalah tree", "kaabalah tree --json"]
110
+ examples: ["kaabalah tree --json --compact", "kaabalah tree --json --fields=nodes"]
111
+ },
112
+ {
113
+ name: "tree:node",
114
+ description: "Look up a node and all its correspondences",
115
+ args: [{ name: "id", type: "string", required: true, description: "Node ID (e.g. path:1, sphere:Kether, tarotArkAnnu:The Magician)" }],
116
+ flags: [
117
+ { name: "type", type: "string", description: "Filter related nodes by type (e.g. hebrewLetter, planet, tarotArkAnnu)" },
118
+ { name: "depth", type: "number", default: 1, description: "Traversal depth (default: 1)" }
119
+ ],
120
+ examples: [
121
+ "kaabalah tree:node path:1 --json",
122
+ "kaabalah tree:node sphere:Kether --type=tarotArkAnnu --json",
123
+ 'kaabalah tree:node "tarotArkAnnu:The Magician" --json',
124
+ "kaabalah tree:node path:1 --depth=2 --json"
125
+ ]
126
+ },
127
+ {
128
+ name: "tree:types",
129
+ description: "List all node types and their counts",
130
+ args: [],
131
+ flags: [],
132
+ examples: ["kaabalah tree:types --json"]
111
133
  },
112
134
  {
113
135
  name: "astrology",
@@ -124,8 +146,8 @@ var COMMANDS = [
124
146
  { name: "timezone", type: "string", description: "IANA timezone string (e.g. America/New_York). Auto-resolved from coordinates if omitted" }
125
147
  ],
126
148
  examples: [
127
- "kaabalah astrology 1990-01-15 14:30 --lat=-23.5505 --lon=-46.6333",
128
- 'kaabalah astrology 1990-01-15 14:30 --location="S\xE3o Paulo, Brazil"',
149
+ "kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006",
150
+ 'kaabalah astrology 1990-01-15 14:30 --location="New York, USA"',
129
151
  "kaabalah astrology 1990-01-15 --lat=40.7128 --lon=-74.006 --json"
130
152
  ]
131
153
  },
@@ -286,15 +308,15 @@ function generateHelp() {
286
308
  }
287
309
  lines.push("");
288
310
  lines.push("EXAMPLES");
289
- lines.push(' kaabalah gematria "Mat Moura"');
311
+ lines.push(' kaabalah gematria "Hello World"');
290
312
  lines.push(" kaabalah numerology 1990-01-15");
291
- lines.push(" kaabalah numerology:cycles 1990-01-15 Mateus");
313
+ lines.push(" kaabalah numerology:cycles 1990-01-15 John");
292
314
  lines.push(" kaabalah tarot 5 --inverted");
293
315
  lines.push(" kaabalah tarot:card 7");
294
316
  lines.push(" kaabalah gematria:reverse 22");
295
317
  lines.push(" kaabalah ifa 1990-01-15");
296
- lines.push(" kaabalah astrology 1990-01-15 14:30 --lat=-23.5505 --lon=-46.6333");
297
- lines.push(' kaabalah astrology 1990-01-15 14:30 --location="S\xE3o Paulo, Brazil"');
318
+ lines.push(" kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006");
319
+ lines.push(' kaabalah astrology 1990-01-15 14:30 --location="New York, USA"');
298
320
  lines.push(" kaabalah help --json");
299
321
  lines.push("");
300
322
  return lines.join("\n");
@@ -705,11 +727,42 @@ Odu: ${dateStr}
705
727
  console.log(` Center: ${result.center}`);
706
728
  console.log();
707
729
  }
730
+ function getTree() {
731
+ return chunkKUH2YDQ2_js.createTree({ system: chunkKUH2YDQ2_js.SYSTEM, parts: ["westernAstrology", "tarot"] });
732
+ }
733
+ function serializeNode(n) {
734
+ const result = { id: n.id, type: n.type };
735
+ if (n.data && typeof n.data === "object" && Object.keys(n.data).length > 0) {
736
+ result.data = n.data;
737
+ }
738
+ if (n.name) result.name = n.name;
739
+ return result;
740
+ }
708
741
  function cmdTree(flags) {
709
- const tree = chunkKUH2YDQ2_js.createTree({ system: chunkKUH2YDQ2_js.SYSTEM, parts: ["westernAstrology", "tarot"] });
742
+ const tree = getTree();
710
743
  const allNodes = tree.getNodes();
711
744
  if (isJsonMode(flags)) {
712
- outputJson(allNodes.map((n) => ({ id: n.id, type: n.type, name: n.data && "name" in n.data ? n.data?.name : void 0 })), flags);
745
+ const nodes = allNodes.map((n) => {
746
+ const node = serializeNode(n);
747
+ const relatedTypes = tree.relatedTypes(n.id);
748
+ if (relatedTypes.length > 0) {
749
+ node.relatedTypes = relatedTypes;
750
+ }
751
+ return node;
752
+ });
753
+ const edgeSet = /* @__PURE__ */ new Set();
754
+ const edges = [];
755
+ for (const n of allNodes) {
756
+ const related = tree.related(n.id);
757
+ for (const r of related) {
758
+ const key = n.id < r.id ? `${n.id}|${r.id}` : `${r.id}|${n.id}`;
759
+ if (!edgeSet.has(key)) {
760
+ edgeSet.add(key);
761
+ edges.push({ from: n.id, to: r.id });
762
+ }
763
+ }
764
+ }
765
+ outputJson({ system: chunkKUH2YDQ2_js.SYSTEM, totalNodes: allNodes.length, totalEdges: edges.length, nodes, edges }, flags);
713
766
  return;
714
767
  }
715
768
  console.log(`
@@ -736,6 +789,71 @@ Tree of Life (${chunkKUH2YDQ2_js.SYSTEM})
736
789
  }
737
790
  console.log();
738
791
  }
792
+ function cmdTreeNode(idStr, flags) {
793
+ const tree = getTree();
794
+ const node = tree.getNode(idStr);
795
+ if (!node) {
796
+ 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);
797
+ }
798
+ const typeFilter = getFlagString(flags, "type");
799
+ const depth = getFlagNumber(flags, "depth") ?? 1;
800
+ const related = depth > 1 ? tree.walk(node.id, depth, typeFilter || void 0) : typeFilter ? tree.related(node.id, typeFilter) : tree.related(node.id);
801
+ if (isJsonMode(flags)) {
802
+ outputJson({
803
+ node: serializeNode(node),
804
+ relatedTypes: tree.relatedTypes(node.id),
805
+ related: related.map(serializeNode)
806
+ }, flags);
807
+ return;
808
+ }
809
+ console.log(`
810
+ ${node.id}`);
811
+ const d = node.data;
812
+ if (d) {
813
+ for (const [k, v] of Object.entries(d)) {
814
+ if (v != null && typeof v !== "object") console.log(` ${k}: ${v}`);
815
+ }
816
+ }
817
+ const relatedTypes = tree.relatedTypes(node.id);
818
+ console.log(`
819
+ Related types: ${relatedTypes.join(", ")}`);
820
+ const byType = /* @__PURE__ */ new Map();
821
+ for (const r of related) {
822
+ if (!byType.has(r.type)) byType.set(r.type, []);
823
+ byType.get(r.type).push(r);
824
+ }
825
+ for (const [type, nodes] of byType) {
826
+ console.log(`
827
+ ${type}:`);
828
+ for (const n of nodes) {
829
+ const rd = n.data;
830
+ const label = rd?.name ?? rd?.character ?? rd?.englishName ?? rd?.meaning ?? "";
831
+ console.log(` ${n.id}${label ? ` \u2014 ${label}` : ""}`);
832
+ }
833
+ }
834
+ console.log();
835
+ }
836
+ function cmdTreeTypes(flags) {
837
+ const tree = getTree();
838
+ const allNodes = tree.getNodes();
839
+ const counts = {};
840
+ for (const n of allNodes) {
841
+ if (!counts[n.type]) counts[n.type] = { count: 0, ids: [] };
842
+ counts[n.type].count++;
843
+ counts[n.type].ids.push(n.id);
844
+ }
845
+ if (isJsonMode(flags)) {
846
+ outputJson(counts, flags);
847
+ return;
848
+ }
849
+ console.log(`
850
+ Node types (${Object.keys(counts).length}):
851
+ `);
852
+ for (const [type, info] of Object.entries(counts)) {
853
+ console.log(` ${type}: ${info.count}`);
854
+ }
855
+ console.log();
856
+ }
739
857
  async function cmdAstrology(args, flags, inputPayload) {
740
858
  const dateStr = inputPayload?.date ?? args[0];
741
859
  if (!dateStr) {
@@ -964,6 +1082,15 @@ async function main() {
964
1082
  case "tree":
965
1083
  cmdTree(flags);
966
1084
  break;
1085
+ case "tree:node":
1086
+ if (!args[1] && !inputPayload?.id) {
1087
+ exitWithError("MISSING_ARGUMENT", 'Usage: kaabalah tree:node <id> (e.g. tree:node path:1, tree:node "tarotArkAnnu:The Magician")', flags);
1088
+ }
1089
+ cmdTreeNode(inputPayload?.id ?? args.slice(1).join(" "), flags);
1090
+ break;
1091
+ case "tree:types":
1092
+ cmdTreeTypes(flags);
1093
+ break;
967
1094
  case "astrology":
968
1095
  await cmdAstrology(args.slice(1), flags, inputPayload);
969
1096
  break;