kaabalah 4.9.1 → 5.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.
package/dist/cli.js ADDED
@@ -0,0 +1,996 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var chunk3WVZRLPG_js = require('./chunk-3WVZRLPG.js');
5
+ var chunkFVEVTAM7_js = require('./chunk-FVEVTAM7.js');
6
+ var chunkU77YFJXJ_js = require('./chunk-U77YFJXJ.js');
7
+ var chunkKUH2YDQ2_js = require('./chunk-KUH2YDQ2.js');
8
+ var chunkG5BG73Y5_js = require('./chunk-G5BG73Y5.js');
9
+ var chunkFM7WUVZV_js = require('./chunk-FM7WUVZV.js');
10
+ require('dotenv/config');
11
+
12
+ var VERSION = "4.9.1";
13
+ var GLOBAL_FLAGS = [
14
+ { name: "json", type: "boolean", default: false, description: "Output as JSON (auto-enabled when stdout is not a TTY)" },
15
+ { name: "no-json", type: "boolean", default: false, description: "Force human-readable output even when piped" },
16
+ { name: "compact", type: "boolean", default: false, description: "Minified JSON output (no indentation)" },
17
+ { name: "fields", type: "string", description: "Comma-separated dot-paths to filter JSON output (e.g. --fields=a.b,c.d)" },
18
+ { name: "input-json", type: "string", description: "JSON string with command parameters (alternative to positional args)" }
19
+ ];
20
+ var COMMANDS = [
21
+ {
22
+ name: "gematria",
23
+ description: "Calculate gematria for a word/phrase",
24
+ args: [{ name: "text", type: "string", required: true, description: "Text to calculate gematria for" }],
25
+ flags: [
26
+ { name: "missing", type: "boolean", default: false, description: "Show missing gematria values" },
27
+ { name: "percentages", type: "boolean", default: false, description: "Show letter percentages" }
28
+ ],
29
+ examples: ['kaabalah gematria "Mat Moura"', 'kaabalah gematria "Mat Moura" --json']
30
+ },
31
+ {
32
+ name: "gematria:reverse",
33
+ description: "Find letter combos matching a gematria value",
34
+ args: [{ name: "target", type: "number", required: true, description: "Target synthesis number" }],
35
+ flags: [
36
+ { name: "max-results", type: "number", default: 20, description: "Maximum results to return (max 10000)" },
37
+ { name: "min-length", type: "number", default: 2, description: "Minimum letters per combination" },
38
+ { name: "max-length", type: "number", default: 6, description: "Maximum letters per combination" },
39
+ { name: "include-digraphs", type: "boolean", default: false, description: "Include digraphs like PH, SH" }
40
+ ],
41
+ examples: ["kaabalah gematria:reverse 22", "kaabalah gematria:reverse 22 --max-results=50 --json"]
42
+ },
43
+ {
44
+ name: "numerology",
45
+ description: "Full numerological profile for a birth date",
46
+ args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
47
+ flags: [],
48
+ examples: ["kaabalah numerology 1990-01-15", "kaabalah numerology 1990-01-15 --json --fields=kaabalistic.lifePath.reducedValue"]
49
+ },
50
+ {
51
+ name: "numerology:lifepath",
52
+ description: "Life path number (kaabalistic method)",
53
+ args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
54
+ flags: [],
55
+ examples: ["kaabalah numerology:lifepath 1990-01-15"]
56
+ },
57
+ {
58
+ name: "numerology:cycles",
59
+ description: "Personal cycles (year, month, periods)",
60
+ args: [
61
+ { name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" },
62
+ { name: "firstName", type: "string", required: false, description: "First name for personal cycles" }
63
+ ],
64
+ flags: [],
65
+ examples: ["kaabalah numerology:cycles 1990-01-15", "kaabalah numerology:cycles 1990-01-15 Mateus"]
66
+ },
67
+ {
68
+ name: "numerology:challenges",
69
+ description: "Challenges from birth date",
70
+ args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
71
+ flags: [],
72
+ examples: ["kaabalah numerology:challenges 1990-01-15"]
73
+ },
74
+ {
75
+ name: "numerology:fibonacci",
76
+ description: "Fibonacci cycle for current age",
77
+ args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
78
+ flags: [],
79
+ examples: ["kaabalah numerology:fibonacci 1990-01-15"]
80
+ },
81
+ {
82
+ name: "tarot",
83
+ description: "Draw tarot cards (default: 3)",
84
+ args: [{ name: "count", type: "number", required: false, description: "Number of cards to draw (1-78, default: 3)" }],
85
+ flags: [
86
+ { name: "inverted", type: "boolean", default: false, description: "Include inverted cards" },
87
+ { name: "shuffle-count", type: "number", default: 7, description: "Number of times to shuffle the deck" }
88
+ ],
89
+ examples: ["kaabalah tarot 5 --inverted", "kaabalah tarot --json"]
90
+ },
91
+ {
92
+ name: "tarot:card",
93
+ description: "Look up a specific card (1-78)",
94
+ args: [{ name: "number", type: "number", required: true, description: "Card number (1-78)" }],
95
+ flags: [],
96
+ examples: ["kaabalah tarot:card 7", "kaabalah tarot:card 22 --json"]
97
+ },
98
+ {
99
+ name: "ifa",
100
+ description: "Calculate Odu from a date",
101
+ args: [{ name: "date", type: "date", required: true, description: "Date in YYYY-MM-DD format" }],
102
+ flags: [],
103
+ examples: ["kaabalah ifa 1990-01-15"]
104
+ },
105
+ {
106
+ name: "tree",
107
+ description: "Show Tree of Life structure",
108
+ args: [],
109
+ flags: [],
110
+ examples: ["kaabalah tree", "kaabalah tree --json"]
111
+ },
112
+ {
113
+ name: "astrology",
114
+ description: "Calculate birth chart using Swiss Ephemeris",
115
+ args: [
116
+ { name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" },
117
+ { name: "time", type: "string", required: false, description: "Birth time in HH:MM format (default: 12:00)" }
118
+ ],
119
+ flags: [
120
+ { name: "lat", type: "number", description: "Latitude (-90 to 90)" },
121
+ { name: "lon", type: "number", description: "Longitude (-180 to 180)" },
122
+ { name: "location", type: "string", description: "Location string for geocoding (requires GOOGLE_MAPS_API_KEY env var)" },
123
+ { name: "house-system", type: "string", default: "placidus", description: "House system: placidus, koch, porphyrius, regiomontanus, campanus, equal, whole-sign, meridian, morinus, krusinski, alcabitius" },
124
+ { name: "timezone", type: "string", description: "IANA timezone string (e.g. America/New_York). Auto-resolved from coordinates if omitted" }
125
+ ],
126
+ 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"',
129
+ "kaabalah astrology 1990-01-15 --lat=40.7128 --lon=-74.006 --json"
130
+ ]
131
+ },
132
+ {
133
+ name: "help",
134
+ description: "Show help message",
135
+ args: [{ name: "command", type: "string", required: false, description: "Command to show help for" }],
136
+ flags: [],
137
+ examples: ["kaabalah help", "kaabalah help --json", "kaabalah help astrology --json"]
138
+ }
139
+ ];
140
+ function parseArgs(argv) {
141
+ const args = [];
142
+ const flags = {};
143
+ for (const arg of argv.slice(2)) {
144
+ if (arg.startsWith("--")) {
145
+ const eqIdx = arg.indexOf("=");
146
+ if (eqIdx !== -1) {
147
+ flags[arg.slice(2, eqIdx)] = arg.slice(eqIdx + 1);
148
+ } else {
149
+ flags[arg.slice(2)] = true;
150
+ }
151
+ } else {
152
+ args.push(arg);
153
+ }
154
+ }
155
+ if (!process.stdout.isTTY && flags["no-json"] !== true) {
156
+ flags.json = true;
157
+ }
158
+ return { args, flags };
159
+ }
160
+ function getFlagString(flags, name) {
161
+ const v = flags[name];
162
+ return typeof v === "string" ? v : void 0;
163
+ }
164
+ function getFlagNumber(flags, name) {
165
+ const v = flags[name];
166
+ if (typeof v === "string") {
167
+ const n = Number(v);
168
+ return isNaN(n) ? void 0 : n;
169
+ }
170
+ return void 0;
171
+ }
172
+ function getFlagBool(flags, name) {
173
+ return flags[name] === true;
174
+ }
175
+ function isJsonMode(flags) {
176
+ return flags.json === true || typeof flags.json === "string";
177
+ }
178
+ function parseInputJson(flags) {
179
+ const raw = getFlagString(flags, "input-json");
180
+ if (!raw) return null;
181
+ try {
182
+ const parsed = JSON.parse(raw);
183
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
184
+ exitWithError("INVALID_JSON", "--input-json must be a JSON object", flags);
185
+ }
186
+ return parsed;
187
+ } catch {
188
+ exitWithError("INVALID_JSON", `Invalid JSON in --input-json: ${raw}`, flags);
189
+ }
190
+ }
191
+ function sanitizeInput(str) {
192
+ return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
193
+ }
194
+ function validateDateRange(dateStr, flags) {
195
+ const match = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
196
+ if (!match) {
197
+ exitWithError("INVALID_DATE", `Invalid date: "${dateStr}". Use YYYY-MM-DD format.`, flags);
198
+ }
199
+ const year = parseInt(match[1], 10);
200
+ if (year < 1 || year > 9999) {
201
+ exitWithError("INVALID_DATE", `Year must be between 0001 and 9999, got ${year}.`, flags);
202
+ }
203
+ }
204
+ function capNumber(value, max) {
205
+ if (value > max) return max;
206
+ if (value < 0) return 0;
207
+ return value;
208
+ }
209
+ var MAX_TEXT_LENGTH = 1e3;
210
+ var MAX_RESULTS_CAP = 1e4;
211
+ function exitWithError(code, message, flags) {
212
+ if (isJsonMode(flags)) {
213
+ const out = JSON.stringify({ error: true, code, message });
214
+ process.stdout.write(out + "\n");
215
+ } else {
216
+ process.stderr.write(message + "\n");
217
+ }
218
+ process.exit(1);
219
+ }
220
+ function pickFields(obj, paths) {
221
+ if (typeof obj !== "object" || obj === null) return obj;
222
+ const result = {};
223
+ for (const path of paths) {
224
+ const parts = path.split(".");
225
+ let current = obj;
226
+ for (const part of parts) {
227
+ if (current === null || current === void 0 || typeof current !== "object") {
228
+ current = void 0;
229
+ break;
230
+ }
231
+ current = current[part];
232
+ }
233
+ if (current !== void 0) {
234
+ let target = result;
235
+ for (let i = 0; i < parts.length - 1; i++) {
236
+ if (!(parts[i] in target) || typeof target[parts[i]] !== "object") {
237
+ target[parts[i]] = {};
238
+ }
239
+ target = target[parts[i]];
240
+ }
241
+ target[parts[parts.length - 1]] = current;
242
+ }
243
+ }
244
+ return result;
245
+ }
246
+ function outputJson(data, flags) {
247
+ let output = data;
248
+ const fieldsStr = getFlagString(flags, "fields");
249
+ if (fieldsStr) {
250
+ const paths = fieldsStr.split(",").map((s) => s.trim()).filter(Boolean);
251
+ if (paths.length > 0) {
252
+ output = pickFields(output, paths);
253
+ }
254
+ }
255
+ const indent = getFlagBool(flags, "compact") ? void 0 : 2;
256
+ console.log(JSON.stringify(output, null, indent));
257
+ }
258
+ function parseDate(str, flags) {
259
+ validateDateRange(str, flags);
260
+ const d = /* @__PURE__ */ new Date(str + "T12:00:00Z");
261
+ if (isNaN(d.getTime())) {
262
+ exitWithError("INVALID_DATE", `Invalid date: "${str}". Use YYYY-MM-DD format.`, flags);
263
+ }
264
+ return d;
265
+ }
266
+ function generateHelp() {
267
+ const lines = [];
268
+ lines.push("");
269
+ lines.push("kaabalah - CLI for esoteric calculations");
270
+ lines.push("");
271
+ lines.push("USAGE");
272
+ lines.push(" kaabalah <command> [options]");
273
+ lines.push("");
274
+ lines.push("COMMANDS");
275
+ for (const cmd of COMMANDS) {
276
+ const argsStr = cmd.args.map((a) => a.required ? `<${a.name}>` : `[${a.name}]`).join(" ");
277
+ const line = ` ${cmd.name} ${argsStr}`.padEnd(42) + cmd.description;
278
+ lines.push(line);
279
+ }
280
+ lines.push("");
281
+ lines.push("GLOBAL OPTIONS");
282
+ for (const f of GLOBAL_FLAGS) {
283
+ const def = f.default !== void 0 ? ` (default: ${f.default})` : "";
284
+ const line = ` --${f.name}`.padEnd(30) + f.description + def;
285
+ lines.push(line);
286
+ }
287
+ lines.push("");
288
+ lines.push("EXAMPLES");
289
+ lines.push(' kaabalah gematria "Mat Moura"');
290
+ lines.push(" kaabalah numerology 1990-01-15");
291
+ lines.push(" kaabalah numerology:cycles 1990-01-15 Mateus");
292
+ lines.push(" kaabalah tarot 5 --inverted");
293
+ lines.push(" kaabalah tarot:card 7");
294
+ lines.push(" kaabalah gematria:reverse 22");
295
+ 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"');
298
+ lines.push(" kaabalah help --json");
299
+ lines.push("");
300
+ return lines.join("\n");
301
+ }
302
+ function cmdHelp(args, flags) {
303
+ const subcommand = args[0];
304
+ if (isJsonMode(flags)) {
305
+ if (subcommand) {
306
+ const cmd = COMMANDS.find((c) => c.name === subcommand);
307
+ if (!cmd) {
308
+ exitWithError("UNKNOWN_COMMAND", `Unknown command: "${subcommand}".`, flags);
309
+ }
310
+ outputJson({ version: VERSION, command: cmd, globalFlags: GLOBAL_FLAGS }, flags);
311
+ } else {
312
+ outputJson({ version: VERSION, commands: COMMANDS, globalFlags: GLOBAL_FLAGS }, flags);
313
+ }
314
+ return;
315
+ }
316
+ if (subcommand) {
317
+ const cmd = COMMANDS.find((c) => c.name === subcommand);
318
+ if (!cmd) {
319
+ exitWithError("UNKNOWN_COMMAND", `Unknown command: "${subcommand}".`, flags);
320
+ }
321
+ console.log(`
322
+ ${cmd.name} - ${cmd.description}
323
+ `);
324
+ console.log("USAGE");
325
+ const argsStr = cmd.args.map((a) => a.required ? `<${a.name}>` : `[${a.name}]`).join(" ");
326
+ console.log(` kaabalah ${cmd.name} ${argsStr}
327
+ `);
328
+ if (cmd.args.length > 0) {
329
+ console.log("ARGUMENTS");
330
+ for (const a of cmd.args) {
331
+ const req = a.required ? "(required)" : "(optional)";
332
+ console.log(` ${a.name.padEnd(20)} ${a.type.padEnd(10)} ${req} ${a.description}`);
333
+ }
334
+ console.log();
335
+ }
336
+ if (cmd.flags.length > 0) {
337
+ console.log("FLAGS");
338
+ for (const f of cmd.flags) {
339
+ const def = f.default !== void 0 ? ` (default: ${f.default})` : "";
340
+ console.log(` --${f.name.padEnd(24)} ${f.description}${def}`);
341
+ }
342
+ console.log();
343
+ }
344
+ if (cmd.examples.length > 0) {
345
+ console.log("EXAMPLES");
346
+ for (const e of cmd.examples) {
347
+ console.log(` ${e}`);
348
+ }
349
+ console.log();
350
+ }
351
+ } else {
352
+ console.log(generateHelp());
353
+ }
354
+ }
355
+ async function geocodeLocation(location, flags) {
356
+ const apiKey = process.env.GOOGLE_MAPS_API_KEY;
357
+ if (!apiKey) {
358
+ exitWithError(
359
+ "GEOCODE_ERROR",
360
+ "GOOGLE_MAPS_API_KEY environment variable is required for --location. Set it or use --lat/--lon directly.",
361
+ flags
362
+ );
363
+ }
364
+ const url = "https://places.googleapis.com/v1/places:searchText";
365
+ let response;
366
+ try {
367
+ response = await fetch(url, {
368
+ method: "POST",
369
+ headers: {
370
+ "Content-Type": "application/json",
371
+ "X-Goog-Api-Key": apiKey,
372
+ "X-Goog-FieldMask": "places.displayName,places.formattedAddress,places.location"
373
+ },
374
+ body: JSON.stringify({ textQuery: location, maxResultCount: 1 })
375
+ });
376
+ } catch (err) {
377
+ exitWithError("GEOCODE_ERROR", `Geocoding request failed: ${err instanceof Error ? err.message : String(err)}`, flags);
378
+ }
379
+ const data = await response.json();
380
+ if (data.error) {
381
+ exitWithError(
382
+ "GEOCODE_ERROR",
383
+ `Geocoding failed for "${location}": ${data.error.message}`,
384
+ flags
385
+ );
386
+ }
387
+ if (!data.places || data.places.length === 0 || !data.places[0].location) {
388
+ exitWithError(
389
+ "GEOCODE_ERROR",
390
+ `No results found for "${location}".`,
391
+ flags
392
+ );
393
+ }
394
+ const place = data.places[0];
395
+ return {
396
+ latitude: place.location.latitude,
397
+ longitude: place.location.longitude,
398
+ formattedAddress: place.formattedAddress ?? place.displayName?.text ?? location
399
+ };
400
+ }
401
+ var HOUSE_SYSTEM_MAP = {
402
+ placidus: "P",
403
+ koch: "K",
404
+ porphyrius: "O",
405
+ regiomontanus: "R",
406
+ campanus: "C",
407
+ equal: "E",
408
+ "whole-sign": "W",
409
+ meridian: "X",
410
+ morinus: "M",
411
+ krusinski: "U",
412
+ alcabitius: "B"
413
+ };
414
+ function cmdGematria(text, flags) {
415
+ if (text.length > MAX_TEXT_LENGTH) {
416
+ exitWithError("INVALID_ARGUMENT", `Text exceeds maximum length of ${MAX_TEXT_LENGTH} characters.`, flags);
417
+ }
418
+ const sanitized = sanitizeInput(text);
419
+ const result = chunkU77YFJXJ_js.calculateGematria(sanitized, {
420
+ missing: getFlagBool(flags, "missing"),
421
+ percentages: getFlagBool(flags, "percentages")
422
+ });
423
+ if (isJsonMode(flags)) {
424
+ outputJson(result, flags);
425
+ return;
426
+ }
427
+ console.log(`
428
+ Gematria: "${sanitized}"
429
+ `);
430
+ console.log(` Vowels: ${result.vowels.originalSum} -> [${result.vowels.reductionSteps.join(", ")}] = ${result.vowels.finalValue}`);
431
+ console.log(` Consonants: ${result.consonants.originalSum} -> [${result.consonants.reductionSteps.join(", ")}] = ${result.consonants.finalValue}`);
432
+ console.log(` Synthesis: ${result.synthesis.originalSum} -> [${result.synthesis.reductionSteps.join(", ")}] = ${result.synthesis.finalValue}`);
433
+ if (result.includedLetters.length > 0) {
434
+ console.log(`
435
+ Letters:`);
436
+ for (const l of result.includedLetters) {
437
+ const vowelTag = l.isVowel ? " (vowel)" : "";
438
+ console.log(` ${l.hebrewCharacter} value=${l.value}${vowelTag}`);
439
+ }
440
+ }
441
+ if (result.missingGematriaValues && result.missingGematriaValues.length > 0) {
442
+ console.log(`
443
+ Missing values: ${result.missingGematriaValues.map((m) => m.value).join(", ")}`);
444
+ }
445
+ if (result.letterPercentages) {
446
+ console.log(`
447
+ Vowel %: ${result.letterPercentages.percentageOfVowels.toFixed(1)}%`);
448
+ console.log(` Consonant %: ${result.letterPercentages.percentageOfConsonants.toFixed(1)}%`);
449
+ }
450
+ console.log();
451
+ }
452
+ function cmdReverseGematria(target, flags, inputPayload) {
453
+ const targetNum = inputPayload?.targetSynthesis != null ? Number(inputPayload.targetSynthesis) : parseInt(target, 10);
454
+ if (isNaN(targetNum)) {
455
+ exitWithError("INVALID_ARGUMENT", `Invalid target number: "${target}"`, flags);
456
+ }
457
+ let maxResults = inputPayload?.maxResults != null ? Number(inputPayload.maxResults) : getFlagNumber(flags, "max-results") ?? 20;
458
+ maxResults = capNumber(maxResults, MAX_RESULTS_CAP);
459
+ let minLength = inputPayload?.minLength != null ? Number(inputPayload.minLength) : getFlagNumber(flags, "min-length") ?? 2;
460
+ let maxLength = inputPayload?.maxLength != null ? Number(inputPayload.maxLength) : getFlagNumber(flags, "max-length") ?? 6;
461
+ const includeDigraphs = inputPayload?.includeDigraphs != null ? Boolean(inputPayload.includeDigraphs) : getFlagBool(flags, "include-digraphs");
462
+ const result = chunkU77YFJXJ_js.reverseGematria({
463
+ targetSynthesis: targetNum,
464
+ maxResults,
465
+ minLength,
466
+ maxLength,
467
+ includeDigraphs
468
+ });
469
+ if (isJsonMode(flags)) {
470
+ outputJson(result, flags);
471
+ return;
472
+ }
473
+ console.log(`
474
+ Reverse Gematria: target synthesis = ${targetNum}
475
+ `);
476
+ console.log(` Found: ${result.totalFound} combinations${result.hasMore ? ` (showing first ${maxResults})` : ""}
477
+ `);
478
+ for (const r of result.results) {
479
+ console.log(` ${r.letters.padEnd(12)} vowels=${r.vowelsSum} consonants=${r.consonantsSum} synthesis=${r.synthesisSum}`);
480
+ }
481
+ console.log();
482
+ }
483
+ function cmdNumerology(dateStr, flags) {
484
+ const date = parseDate(dateStr, flags);
485
+ const kaabalistic = chunkFVEVTAM7_js.calculateKaabalisticLifePath(date);
486
+ const straight = chunkFVEVTAM7_js.calculateStraightAcrossReductionLifePath(date);
487
+ const challenges = chunkFVEVTAM7_js.calculateChallenges(date);
488
+ const energies = chunkFVEVTAM7_js.getDateEnergies(date);
489
+ const personalYear = chunkFVEVTAM7_js.calculatePersonalYear(date);
490
+ const fibonacci = chunkFVEVTAM7_js.calculateFibonacciCycle(date, /* @__PURE__ */ new Date());
491
+ if (isJsonMode(flags)) {
492
+ outputJson({ kaabalistic, straight, challenges, energies, personalYear, fibonacci }, flags);
493
+ return;
494
+ }
495
+ console.log(`
496
+ Numerology Profile: ${dateStr}
497
+ `);
498
+ console.log(` Kaabalistic Life Path: ${kaabalistic.lifePath.reducedValue}`);
499
+ console.log(` Steps: [${kaabalistic.lifePath.reductionSteps.join(", ")}]`);
500
+ console.log(` Personal Mythology: [${kaabalistic.personalMythologyNumbers.join(", ")}]`);
501
+ console.log(`
502
+ Straight Across Life Path: ${straight.lifePath.reducedValue}`);
503
+ console.log(` Day energy: ${straight.dayEnergy.reducedValue}`);
504
+ console.log(` Month energy: ${straight.monthEnergy.reducedValue}`);
505
+ console.log(` Year energy: ${straight.yearEnergy.reducedValue}`);
506
+ console.log(`
507
+ Challenges:`);
508
+ console.log(` Main: ${challenges.mainChallenge}`);
509
+ console.log(` Sub 1: ${challenges.subChallenge1}`);
510
+ console.log(` Sub 2: ${challenges.subChallenge2}`);
511
+ console.log(`
512
+ Date Energies:`);
513
+ console.log(` Day: ${energies.dayEnergy.reducedValue}`);
514
+ console.log(` Month: ${energies.monthEnergy.reducedValue}`);
515
+ console.log(` Year: ${energies.yearEnergy.reducedValue}`);
516
+ console.log(`
517
+ Personal Year: ${personalYear.reducedValue}`);
518
+ console.log(`
519
+ Fibonacci Cycle (age ${fibonacci.currentAge}):`);
520
+ for (let i = 1; i <= 7; i++) {
521
+ const cycle = fibonacci[`cycle${i}`];
522
+ console.log(` Cycle ${i}: ${cycle.reducedValue}`);
523
+ }
524
+ console.log();
525
+ }
526
+ function cmdLifePath(dateStr, flags) {
527
+ const date = parseDate(dateStr, flags);
528
+ const result = chunkFVEVTAM7_js.calculateKaabalisticLifePath(date);
529
+ if (isJsonMode(flags)) {
530
+ outputJson(result, flags);
531
+ return;
532
+ }
533
+ console.log(`
534
+ Kaabalistic Life Path: ${dateStr}
535
+ `);
536
+ console.log(` Life Path: ${result.lifePath.reducedValue}`);
537
+ console.log(` Steps: [${result.lifePath.reductionSteps.join(", ")}]`);
538
+ console.log(` Personal Mythology: [${result.personalMythologyNumbers.join(", ")}]`);
539
+ console.log(` Parts: day=${result.reducedParts.reducedDay} month=${result.reducedParts.reducedMonth} year1=${result.reducedParts.reducedYear1} year2=${result.reducedParts.reducedYear2}`);
540
+ console.log();
541
+ }
542
+ function cmdCycles(dateStr, firstName, flags) {
543
+ const date = parseDate(dateStr, flags);
544
+ const today = /* @__PURE__ */ new Date();
545
+ if (firstName) {
546
+ const result = chunkFVEVTAM7_js.calculatePersonalCycles(date, today, firstName);
547
+ if (isJsonMode(flags)) {
548
+ outputJson(result, flags);
549
+ return;
550
+ }
551
+ console.log(`
552
+ Personal Cycles: ${dateStr} (${firstName})
553
+ `);
554
+ console.log(` Age: ${result.currentAge}`);
555
+ console.log(` Life Path: ${result.lifePath.reducedValue}`);
556
+ console.log(` Soul Number: ${result.soulNumber?.reducedValue}`);
557
+ console.log(` Personal Year: ${result.personalYear.reducedValue}`);
558
+ console.log(` Current Period: ${result.currentPersonalPeriod + 1}/3`);
559
+ console.log(` Current Month: ${result.currentPersonalMonth + 1}/12`);
560
+ console.log(`
561
+ Periods:`);
562
+ for (let i = 0; i < result.personalPeriods.length; i++) {
563
+ const p = result.personalPeriods[i];
564
+ const active = i === result.currentPersonalPeriod ? " <--" : "";
565
+ console.log(` Period ${i + 1} (months ${p.startMonth}-${p.endMonth}): ${p.value.reducedValue}${active}`);
566
+ }
567
+ console.log(`
568
+ Monthly energies:`);
569
+ for (let i = 0; i < result.personalMonths.length; i++) {
570
+ const m = result.personalMonths[i];
571
+ const active = i === result.currentPersonalMonth ? " <--" : "";
572
+ console.log(` Month ${m.month}: ${m.value.reducedValue}${active}`);
573
+ }
574
+ } else {
575
+ const result = chunkFVEVTAM7_js.calculateCycles(date, today);
576
+ if (isJsonMode(flags)) {
577
+ outputJson(result, flags);
578
+ return;
579
+ }
580
+ console.log(`
581
+ Heptad Cycles: ${dateStr}
582
+ `);
583
+ console.log(` Total days since last birthday: ${result.totalDays}`);
584
+ if (result.currentAgeCycle) {
585
+ console.log(`
586
+ Age Cycles (current: ${result.currentAgeCycle}):`);
587
+ for (const c of result.ageCycles) {
588
+ const active = c.isActive ? " <--" : "";
589
+ console.log(` Cycle ${c.number}: ${c.description}${active}`);
590
+ }
591
+ }
592
+ if (result.currentYearlyCycle) {
593
+ console.log(`
594
+ Yearly Cycles (current: ${result.currentYearlyCycle}):`);
595
+ for (const c of result.yearlyCycles) {
596
+ const active = c.isActive ? " <--" : "";
597
+ console.log(` Cycle ${c.number}: ${c.description}${active}`);
598
+ }
599
+ }
600
+ console.log(`
601
+ Monthly Cycles (current: ${result.currentMonthlyCycle}, day ${result.daysInMonthlyCycle}):`);
602
+ for (const c of result.monthlyCycles) {
603
+ const active = c.isActive ? " <--" : "";
604
+ console.log(` Cycle ${c.number}: ${c.description}${active}`);
605
+ }
606
+ }
607
+ console.log();
608
+ }
609
+ function cmdChallenges(dateStr, flags) {
610
+ const date = parseDate(dateStr, flags);
611
+ const result = chunkFVEVTAM7_js.calculateChallenges(date);
612
+ if (isJsonMode(flags)) {
613
+ outputJson(result, flags);
614
+ return;
615
+ }
616
+ console.log(`
617
+ Challenges: ${dateStr}
618
+ `);
619
+ console.log(` Day: ${result.day}`);
620
+ console.log(` Month: ${result.month}`);
621
+ console.log(` Year: ${result.year}`);
622
+ console.log(` Main: ${result.mainChallenge}`);
623
+ console.log(` Sub 1: ${result.subChallenge1}`);
624
+ console.log(` Sub 2: ${result.subChallenge2}`);
625
+ console.log();
626
+ }
627
+ function cmdFibonacci(dateStr, flags) {
628
+ const date = parseDate(dateStr, flags);
629
+ const result = chunkFVEVTAM7_js.calculateFibonacciCycle(date, /* @__PURE__ */ new Date());
630
+ if (isJsonMode(flags)) {
631
+ outputJson(result, flags);
632
+ return;
633
+ }
634
+ console.log(`
635
+ Fibonacci Cycle: ${dateStr} (age ${result.currentAge})
636
+ `);
637
+ for (let i = 1; i <= 7; i++) {
638
+ const cycle = result[`cycle${i}`];
639
+ console.log(` Cycle ${i}: ${cycle.reducedValue} [${cycle.reductionSteps.join(", ")}]`);
640
+ }
641
+ console.log();
642
+ }
643
+ async function cmdTarot(countStr, flags) {
644
+ const count = countStr ? parseInt(countStr, 10) : 3;
645
+ if (isNaN(count) || count < 1 || count > 78) {
646
+ exitWithError("INVALID_ARGUMENT", "Card count must be between 1 and 78.", flags);
647
+ }
648
+ const shuffleCount = getFlagNumber(flags, "shuffle-count") ?? 7;
649
+ const deck = await chunkG5BG73Y5_js.shuffleTarotDeck(chunkG5BG73Y5_js.ARKANNUS, getFlagBool(flags, "inverted"), shuffleCount);
650
+ const drawn = deck.slice(0, count);
651
+ if (isJsonMode(flags)) {
652
+ outputJson(drawn, flags);
653
+ return;
654
+ }
655
+ console.log(`
656
+ Tarot Draw: ${count} card${count > 1 ? "s" : ""}
657
+ `);
658
+ for (const card of drawn) {
659
+ const inverted = card.isInverted ? " (INVERTED)" : "";
660
+ console.log(` #${String(card.number).padStart(2, "0")} ${card.tarotCard}${inverted}`);
661
+ console.log(` ${card.meaning}`);
662
+ if (card.egyptianCardName) {
663
+ console.log(` Egyptian: ${card.egyptianCardName}`);
664
+ }
665
+ if (card.papusMeaning) {
666
+ console.log(` Papus: ${card.papusMeaning}`);
667
+ }
668
+ console.log();
669
+ }
670
+ }
671
+ function cmdTarotCard(numberStr, flags) {
672
+ const num = parseInt(numberStr, 10);
673
+ const card = chunkG5BG73Y5_js.ARKANNUS.find((c) => c.number === num);
674
+ if (!card) {
675
+ exitWithError("CARD_NOT_FOUND", `Card #${num} not found. Valid range: 1-78.`, flags);
676
+ }
677
+ if (isJsonMode(flags)) {
678
+ outputJson(card, flags);
679
+ return;
680
+ }
681
+ console.log(`
682
+ #${String(card.number).padStart(2, "0")} ${card.tarotCard}`);
683
+ console.log(` Type: ${card.type} | Suit: ${card.suit ?? "major"} | Deck: ${card.deck}`);
684
+ console.log(` Meaning: ${card.meaning}`);
685
+ if (card.egyptianCardName) console.log(` Egyptian: ${card.egyptianCardName}`);
686
+ if (card.papusMeaning) console.log(` Papus: ${card.papusMeaning}`);
687
+ console.log();
688
+ }
689
+ function cmdIfa(dateStr, flags) {
690
+ const date = parseDate(dateStr, flags);
691
+ const result = chunk3WVZRLPG_js.calculateOdu(date);
692
+ if (isJsonMode(flags)) {
693
+ outputJson(result, flags);
694
+ return;
695
+ }
696
+ console.log(`
697
+ Odu: ${dateStr}
698
+ `);
699
+ console.log(` Left: [${result.leftNumbers.join(", ")}]`);
700
+ console.log(` Right: [${result.rightNumbers.join(", ")}]`);
701
+ console.log(` North: ${result.north}`);
702
+ console.log(` South: ${result.south}`);
703
+ console.log(` East: ${result.east}`);
704
+ console.log(` West: ${result.west}`);
705
+ console.log(` Center: ${result.center}`);
706
+ console.log();
707
+ }
708
+ function cmdTree(flags) {
709
+ const tree = chunkKUH2YDQ2_js.createTree({ system: chunkKUH2YDQ2_js.SYSTEM, parts: ["westernAstrology", "tarot"] });
710
+ const allNodes = tree.getNodes();
711
+ 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);
713
+ return;
714
+ }
715
+ console.log(`
716
+ Tree of Life (${chunkKUH2YDQ2_js.SYSTEM})
717
+ `);
718
+ console.log(` Total nodes: ${allNodes.length}`);
719
+ const byType = /* @__PURE__ */ new Map();
720
+ for (const node of allNodes) {
721
+ const t = node.type;
722
+ if (!byType.has(t)) byType.set(t, []);
723
+ byType.get(t).push(node);
724
+ }
725
+ for (const [type, nodes] of byType) {
726
+ console.log(`
727
+ ${type} (${nodes.length}):`);
728
+ for (const n of nodes.slice(0, 15)) {
729
+ const d = n.data;
730
+ const name = d?.name ?? d?.character ?? "";
731
+ console.log(` ${n.id}${name ? ` \u2014 ${name}` : ""}`);
732
+ }
733
+ if (nodes.length > 15) {
734
+ console.log(` ... and ${nodes.length - 15} more`);
735
+ }
736
+ }
737
+ console.log();
738
+ }
739
+ async function cmdAstrology(args, flags, inputPayload) {
740
+ const dateStr = inputPayload?.date ?? args[0];
741
+ if (!dateStr) {
742
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah astrology <YYYY-MM-DD> [HH:MM] --lat=<N> --lon=<N>", flags);
743
+ }
744
+ parseDate(dateStr, flags);
745
+ const timeStr = inputPayload?.time ?? args[1] ?? "12:00";
746
+ const timeMatch = timeStr.match(/^(\d{1,2}):(\d{2})$/);
747
+ if (!timeMatch) {
748
+ exitWithError("INVALID_ARGUMENT", `Invalid time format: "${timeStr}". Use HH:MM format.`, flags);
749
+ }
750
+ const hour = parseInt(timeMatch[1], 10);
751
+ const minute = parseInt(timeMatch[2], 10);
752
+ if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
753
+ exitWithError("INVALID_ARGUMENT", `Invalid time: "${timeStr}". Hours 0-23, minutes 0-59.`, flags);
754
+ }
755
+ let latitude;
756
+ let longitude;
757
+ let resolvedLocation;
758
+ const locationStr = inputPayload?.location ?? getFlagString(flags, "location");
759
+ const latFlag = inputPayload?.lat != null ? Number(inputPayload.lat) : getFlagNumber(flags, "lat");
760
+ const lonFlag = inputPayload?.lon != null ? Number(inputPayload.lon) : getFlagNumber(flags, "lon");
761
+ if (latFlag != null && lonFlag != null) {
762
+ latitude = latFlag;
763
+ longitude = lonFlag;
764
+ } else if (locationStr) {
765
+ const geo = await geocodeLocation(locationStr, flags);
766
+ latitude = geo.latitude;
767
+ longitude = geo.longitude;
768
+ resolvedLocation = geo.formattedAddress;
769
+ } else {
770
+ exitWithError(
771
+ "MISSING_ARGUMENT",
772
+ 'Location is required. Use --lat=<N> --lon=<N> or --location="City, Country" (requires GOOGLE_MAPS_API_KEY).',
773
+ flags
774
+ );
775
+ }
776
+ if (latitude < -90 || latitude > 90) {
777
+ exitWithError("INVALID_ARGUMENT", `Latitude must be between -90 and 90, got ${latitude}.`, flags);
778
+ }
779
+ if (longitude < -180 || longitude > 180) {
780
+ exitWithError("INVALID_ARGUMENT", `Longitude must be between -180 and 180, got ${longitude}.`, flags);
781
+ }
782
+ const houseSystemStr = inputPayload?.houseSystem ?? getFlagString(flags, "house-system") ?? "placidus";
783
+ const houseSystemCode = HOUSE_SYSTEM_MAP[houseSystemStr.toLowerCase()];
784
+ if (!houseSystemCode) {
785
+ exitWithError(
786
+ "INVALID_ARGUMENT",
787
+ `Unknown house system: "${houseSystemStr}". Valid: ${Object.keys(HOUSE_SYSTEM_MAP).join(", ")}`,
788
+ flags
789
+ );
790
+ }
791
+ const timezoneStr = inputPayload?.timezone ?? getFlagString(flags, "timezone");
792
+ const dateParts = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
793
+ const birthDate = new Date(
794
+ parseInt(dateParts[1], 10),
795
+ parseInt(dateParts[2], 10) - 1,
796
+ parseInt(dateParts[3], 10),
797
+ hour,
798
+ minute,
799
+ 0
800
+ );
801
+ const path = chunkFM7WUVZV_js.__require("path");
802
+ const { getSwissEph, closeSwissEph, getBirthChart, HouseSystem } = await import('./astrology/index.js');
803
+ const wasmPath = path.resolve(__dirname, "../wasm/build/swisseph.node.wasm");
804
+ const ephePath = path.resolve(__dirname, "../ephe");
805
+ try {
806
+ await getSwissEph({ wasmPath, ephePath });
807
+ } catch (err) {
808
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
809
+ }
810
+ try {
811
+ const timeZoneSettings = {};
812
+ if (timezoneStr) {
813
+ timeZoneSettings.timeZone = timezoneStr;
814
+ } else {
815
+ timeZoneSettings.autoTimeZone = true;
816
+ }
817
+ const chart = await getBirthChart({
818
+ date: birthDate,
819
+ latitude,
820
+ longitude,
821
+ houseSystem: houseSystemCode,
822
+ timeZoneSettings
823
+ });
824
+ if (isJsonMode(flags)) {
825
+ const result = { ...chart };
826
+ if (resolvedLocation) {
827
+ result.resolvedLocation = resolvedLocation;
828
+ }
829
+ result.input = {
830
+ date: dateStr,
831
+ time: timeStr,
832
+ latitude,
833
+ longitude,
834
+ houseSystem: houseSystemStr,
835
+ timezone: timezoneStr ?? "auto"
836
+ };
837
+ outputJson(result, flags);
838
+ } else {
839
+ console.log(`
840
+ Birth Chart: ${dateStr} ${timeStr}
841
+ `);
842
+ if (resolvedLocation) {
843
+ console.log(` Location: ${resolvedLocation}`);
844
+ }
845
+ console.log(` Coordinates: ${latitude.toFixed(4)}, ${longitude.toFixed(4)}`);
846
+ console.log(` House System: ${houseSystemStr}`);
847
+ console.log(` UTC Date: ${chart.dateUtc.toISOString()}`);
848
+ console.log(`
849
+ Planets:`);
850
+ for (const [name, planet] of Object.entries(chart.planets)) {
851
+ const zp = planet.zodiacPosition;
852
+ console.log(` ${name.padEnd(14)} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} House ${zp.house}`);
853
+ }
854
+ console.log(`
855
+ Houses:`);
856
+ console.log(` Ascendant: ${chart.houses.ascendant.sign} ${chart.houses.ascendant.traditionalFormat}`);
857
+ console.log(` Midheaven: ${chart.houses.mc.sign} ${chart.houses.mc.traditionalFormat}`);
858
+ console.log(` Descendant: ${chart.houses.dc.sign} ${chart.houses.dc.traditionalFormat}`);
859
+ console.log(` IC: ${chart.houses.ic.sign} ${chart.houses.ic.traditionalFormat}`);
860
+ console.log(`
861
+ House Cusps:`);
862
+ for (let i = 0; i < chart.houses.houses.length; i++) {
863
+ const h = chart.houses.houses[i];
864
+ console.log(` House ${String(i + 1).padStart(2)}: ${h.sign.padEnd(12)} ${h.traditionalFormat}`);
865
+ }
866
+ if (chart.nodes && Object.keys(chart.nodes).length > 0) {
867
+ console.log(`
868
+ Nodes:`);
869
+ for (const [, node] of Object.entries(chart.nodes)) {
870
+ console.log(` ${node.name.padEnd(18)} ${node.sign.padEnd(12)} ${node.traditionalFormat.padEnd(8)} House ${node.house}`);
871
+ }
872
+ }
873
+ console.log();
874
+ }
875
+ } finally {
876
+ closeSwissEph();
877
+ }
878
+ }
879
+ async function main() {
880
+ const { args, flags } = parseArgs(process.argv);
881
+ if (getFlagBool(flags, "version")) {
882
+ if (isJsonMode(flags)) {
883
+ outputJson({ version: VERSION }, flags);
884
+ } else {
885
+ console.log(`kaabalah v${VERSION}`);
886
+ }
887
+ process.exit(0);
888
+ }
889
+ if (args.length === 0) {
890
+ cmdHelp([], flags);
891
+ process.exit(0);
892
+ }
893
+ const command = args[0];
894
+ if (getFlagBool(flags, "help") && command !== "help") {
895
+ cmdHelp([command], flags);
896
+ process.exit(0);
897
+ }
898
+ const inputPayload = parseInputJson(flags);
899
+ switch (command) {
900
+ case "help":
901
+ cmdHelp(args.slice(1), flags);
902
+ break;
903
+ case "gematria":
904
+ if (!args[1] && !inputPayload?.text) {
905
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah gematria <text>", flags);
906
+ }
907
+ cmdGematria(inputPayload?.text ?? args.slice(1).join(" "), flags);
908
+ break;
909
+ case "gematria:reverse":
910
+ if (!args[1] && inputPayload?.targetSynthesis == null) {
911
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah gematria:reverse <target-number>", flags);
912
+ }
913
+ cmdReverseGematria(args[1] ?? String(inputPayload?.targetSynthesis ?? ""), flags, inputPayload);
914
+ break;
915
+ case "numerology":
916
+ if (!args[1] && !inputPayload?.date) {
917
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology <YYYY-MM-DD>", flags);
918
+ }
919
+ cmdNumerology(inputPayload?.date ?? args[1], flags);
920
+ break;
921
+ case "numerology:lifepath":
922
+ if (!args[1] && !inputPayload?.date) {
923
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:lifepath <YYYY-MM-DD>", flags);
924
+ }
925
+ cmdLifePath(inputPayload?.date ?? args[1], flags);
926
+ break;
927
+ case "numerology:cycles":
928
+ if (!args[1] && !inputPayload?.date) {
929
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:cycles <YYYY-MM-DD> [firstName]", flags);
930
+ }
931
+ cmdCycles(
932
+ inputPayload?.date ?? args[1],
933
+ inputPayload?.firstName ?? args[2],
934
+ flags
935
+ );
936
+ break;
937
+ case "numerology:challenges":
938
+ if (!args[1] && !inputPayload?.date) {
939
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:challenges <YYYY-MM-DD>", flags);
940
+ }
941
+ cmdChallenges(inputPayload?.date ?? args[1], flags);
942
+ break;
943
+ case "numerology:fibonacci":
944
+ if (!args[1] && !inputPayload?.date) {
945
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:fibonacci <YYYY-MM-DD>", flags);
946
+ }
947
+ cmdFibonacci(inputPayload?.date ?? args[1], flags);
948
+ break;
949
+ case "tarot":
950
+ await cmdTarot(inputPayload?.count ?? args[1], flags);
951
+ break;
952
+ case "tarot:card":
953
+ if (!args[1] && inputPayload?.number == null) {
954
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah tarot:card <number>", flags);
955
+ }
956
+ cmdTarotCard((inputPayload?.number != null ? String(inputPayload.number) : void 0) ?? args[1], flags);
957
+ break;
958
+ case "ifa":
959
+ if (!args[1] && !inputPayload?.date) {
960
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah ifa <YYYY-MM-DD>", flags);
961
+ }
962
+ cmdIfa(inputPayload?.date ?? args[1], flags);
963
+ break;
964
+ case "tree":
965
+ cmdTree(flags);
966
+ break;
967
+ case "astrology":
968
+ await cmdAstrology(args.slice(1), flags, inputPayload);
969
+ break;
970
+ case "--version":
971
+ if (isJsonMode(flags)) {
972
+ outputJson({ version: VERSION }, flags);
973
+ } else {
974
+ console.log(`kaabalah v${VERSION}`);
975
+ }
976
+ break;
977
+ default:
978
+ exitWithError("UNKNOWN_COMMAND", `Unknown command: "${command}". Run "kaabalah help" for usage.`, flags);
979
+ }
980
+ }
981
+ main().catch((err) => {
982
+ const hasJson = process.argv.some((a) => a === "--json") || !process.stdout.isTTY;
983
+ if (hasJson) {
984
+ const out = JSON.stringify({
985
+ error: true,
986
+ code: "INTERNAL_ERROR",
987
+ message: err instanceof Error ? err.message : String(err)
988
+ });
989
+ process.stdout.write(out + "\n");
990
+ } else {
991
+ console.error(err instanceof Error ? err.message : err);
992
+ }
993
+ process.exit(1);
994
+ });
995
+ //# sourceMappingURL=cli.js.map
996
+ //# sourceMappingURL=cli.js.map