kaabalah 5.2.0 → 5.3.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 +20 -3
- package/dist/astrology/index.d.mts +7 -8
- package/dist/astrology/index.d.ts +7 -8
- package/dist/astrology/index.js +25 -21
- package/dist/astrology/index.mjs +1 -1
- package/dist/{chunk-IAKSKHGA.js → chunk-AHUZONHJ.js} +209 -67
- package/dist/chunk-AHUZONHJ.js.map +1 -0
- package/dist/{chunk-CYWQV2RL.mjs → chunk-VSTGPXLM.mjs} +209 -68
- package/dist/chunk-VSTGPXLM.mjs.map +1 -0
- package/dist/cli.js +18714 -1005
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -21
- package/dist/index.mjs +1 -1
- package/package.json +12 -2
- package/dist/chunk-CYWQV2RL.mjs.map +0 -1
- package/dist/chunk-IAKSKHGA.js.map +0 -1
- package/dist/cli.mjs +0 -1388
- package/dist/cli.mjs.map +0 -1
package/dist/cli.mjs
DELETED
|
@@ -1,1388 +0,0 @@
|
|
|
1
|
-
import { calculateOdu } from './chunk-YTZCZRJG.mjs';
|
|
2
|
-
import { calculateFibonacciCycle, calculateChallenges, calculatePersonalCycles, calculateCycles, calculateKaabalisticLifePath, calculateStraightAcrossReductionLifePath, getDateEnergies, calculatePersonalYear } from './chunk-XSAXO3D2.mjs';
|
|
3
|
-
import { reverseGematria, calculateGematria } from './chunk-5ID55YUP.mjs';
|
|
4
|
-
import { SYSTEM, createTree } from './chunk-2J6CVLH2.mjs';
|
|
5
|
-
import { shuffleTarotDeck, ARKANNUS } from './chunk-M7XQFDS4.mjs';
|
|
6
|
-
import { __require } from './chunk-WY6NIR2V.mjs';
|
|
7
|
-
import 'dotenv/config';
|
|
8
|
-
|
|
9
|
-
var VERSION = "4.9.1";
|
|
10
|
-
var GLOBAL_FLAGS = [
|
|
11
|
-
{ name: "json", type: "boolean", default: false, description: "Output as JSON (auto-enabled when stdout is not a TTY)" },
|
|
12
|
-
{ name: "no-json", type: "boolean", default: false, description: "Force human-readable output even when piped" },
|
|
13
|
-
{ name: "compact", type: "boolean", default: false, description: "Minified JSON output (no indentation)" },
|
|
14
|
-
{ name: "fields", type: "string", description: "Comma-separated dot-paths to filter JSON output (e.g. --fields=a.b,c.d)" },
|
|
15
|
-
{ name: "input-json", type: "string", description: "JSON string with command parameters (alternative to positional args)" }
|
|
16
|
-
];
|
|
17
|
-
var COMMANDS = [
|
|
18
|
-
{
|
|
19
|
-
name: "gematria",
|
|
20
|
-
description: "Calculate gematria for a word/phrase",
|
|
21
|
-
args: [{ name: "text", type: "string", required: true, description: "Text to calculate gematria for" }],
|
|
22
|
-
flags: [
|
|
23
|
-
{ name: "missing", type: "boolean", default: false, description: "Show missing gematria values" },
|
|
24
|
-
{ name: "percentages", type: "boolean", default: false, description: "Show letter percentages" }
|
|
25
|
-
],
|
|
26
|
-
examples: ['kaabalah gematria "Hello World"', 'kaabalah gematria "Hello World" --json']
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "gematria:reverse",
|
|
30
|
-
description: "Find letter combos matching a gematria value",
|
|
31
|
-
args: [{ name: "target", type: "number", required: true, description: "Target synthesis number" }],
|
|
32
|
-
flags: [
|
|
33
|
-
{ name: "max-results", type: "number", default: 20, description: "Maximum results to return (max 10000)" },
|
|
34
|
-
{ name: "min-length", type: "number", default: 2, description: "Minimum letters per combination" },
|
|
35
|
-
{ name: "max-length", type: "number", default: 6, description: "Maximum letters per combination" },
|
|
36
|
-
{ name: "include-digraphs", type: "boolean", default: false, description: "Include digraphs like PH, SH" }
|
|
37
|
-
],
|
|
38
|
-
examples: ["kaabalah gematria:reverse 22", "kaabalah gematria:reverse 22 --max-results=50 --json"]
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "numerology",
|
|
42
|
-
description: "Full numerological profile for a birth date",
|
|
43
|
-
args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
|
|
44
|
-
flags: [],
|
|
45
|
-
examples: ["kaabalah numerology 1990-01-15", "kaabalah numerology 1990-01-15 --json --fields=kaabalistic.lifePath.reducedValue"]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "numerology:lifepath",
|
|
49
|
-
description: "Life path number (kaabalistic method)",
|
|
50
|
-
args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
|
|
51
|
-
flags: [],
|
|
52
|
-
examples: ["kaabalah numerology:lifepath 1990-01-15"]
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: "numerology:cycles",
|
|
56
|
-
description: "Personal cycles (year, month, periods)",
|
|
57
|
-
args: [
|
|
58
|
-
{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" },
|
|
59
|
-
{ name: "firstName", type: "string", required: false, description: "First name for personal cycles" }
|
|
60
|
-
],
|
|
61
|
-
flags: [],
|
|
62
|
-
examples: ["kaabalah numerology:cycles 1990-01-15", "kaabalah numerology:cycles 1990-01-15 John"]
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "numerology:challenges",
|
|
66
|
-
description: "Challenges from birth date",
|
|
67
|
-
args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
|
|
68
|
-
flags: [],
|
|
69
|
-
examples: ["kaabalah numerology:challenges 1990-01-15"]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "numerology:fibonacci",
|
|
73
|
-
description: "Fibonacci cycle for current age",
|
|
74
|
-
args: [{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" }],
|
|
75
|
-
flags: [],
|
|
76
|
-
examples: ["kaabalah numerology:fibonacci 1990-01-15"]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "tarot",
|
|
80
|
-
description: "Draw tarot cards (default: 3)",
|
|
81
|
-
args: [{ name: "count", type: "number", required: false, description: "Number of cards to draw (1-78, default: 3)" }],
|
|
82
|
-
flags: [
|
|
83
|
-
{ name: "inverted", type: "boolean", default: false, description: "Include inverted cards" },
|
|
84
|
-
{ name: "shuffle-count", type: "number", default: 7, description: "Number of times to shuffle the deck" }
|
|
85
|
-
],
|
|
86
|
-
examples: ["kaabalah tarot 5 --inverted", "kaabalah tarot --json"]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "tarot:card",
|
|
90
|
-
description: "Look up a specific card by number or name",
|
|
91
|
-
args: [{ name: "query", type: "string", required: true, description: "Card number (1-78) or name (e.g. 'The Chariot', 'Two of Cups')" }],
|
|
92
|
-
flags: [],
|
|
93
|
-
examples: ["kaabalah tarot:card 7", 'kaabalah tarot:card "The Chariot" --json', "kaabalah tarot:card chariot --json"]
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: "tarot:spread",
|
|
97
|
-
description: "Look up multiple tarot cards by name or number",
|
|
98
|
-
args: [{ name: "cards", type: "string", required: true, description: "Card names or numbers, space-separated (quote multi-word names)" }],
|
|
99
|
-
flags: [],
|
|
100
|
-
examples: [
|
|
101
|
-
'kaabalah tarot:spread "Two of Cups" "The Chariot" 7',
|
|
102
|
-
`kaabalah tarot:spread --input-json='{"cards":["Two of Cups","The Chariot","7"]}'`
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: "ifa",
|
|
107
|
-
description: "Calculate Odu from a date",
|
|
108
|
-
args: [{ name: "date", type: "date", required: true, description: "Date in YYYY-MM-DD format" }],
|
|
109
|
-
flags: [],
|
|
110
|
-
examples: ["kaabalah ifa 1990-01-15"]
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "tree",
|
|
114
|
-
description: "Show Tree of Life structure with all nodes, data, and edges",
|
|
115
|
-
args: [],
|
|
116
|
-
flags: [],
|
|
117
|
-
examples: ["kaabalah tree --json --compact", "kaabalah tree --json --fields=nodes"]
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: "tree:node",
|
|
121
|
-
description: "Look up a node and all its correspondences",
|
|
122
|
-
args: [{ name: "id", type: "string", required: true, description: "Node ID (e.g. path:1, sphere:Kether, tarotArkAnnu:The Magician)" }],
|
|
123
|
-
flags: [
|
|
124
|
-
{ name: "type", type: "string", description: "Filter related nodes by type (e.g. hebrewLetter, planet, tarotArkAnnu)" },
|
|
125
|
-
{ name: "depth", type: "number", default: 1, description: "Traversal depth (default: 1)" }
|
|
126
|
-
],
|
|
127
|
-
examples: [
|
|
128
|
-
"kaabalah tree:node path:1 --json",
|
|
129
|
-
"kaabalah tree:node sphere:Kether --type=tarotArkAnnu --json",
|
|
130
|
-
'kaabalah tree:node "tarotArkAnnu:The Magician" --json',
|
|
131
|
-
"kaabalah tree:node path:1 --depth=2 --json"
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: "tree:types",
|
|
136
|
-
description: "List all node types and their counts",
|
|
137
|
-
args: [],
|
|
138
|
-
flags: [],
|
|
139
|
-
examples: ["kaabalah tree:types --json"]
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: "astrology",
|
|
143
|
-
description: "Calculate birth chart using Swiss Ephemeris",
|
|
144
|
-
args: [
|
|
145
|
-
{ name: "date", type: "date", required: true, description: "Birth date in YYYY-MM-DD format" },
|
|
146
|
-
{ name: "time", type: "string", required: false, description: "Birth time in HH:MM format (default: 12:00)" }
|
|
147
|
-
],
|
|
148
|
-
flags: [
|
|
149
|
-
{ name: "lat", type: "number", description: "Latitude (-90 to 90)" },
|
|
150
|
-
{ name: "lon", type: "number", description: "Longitude (-180 to 180)" },
|
|
151
|
-
{ name: "location", type: "string", description: "Location string for geocoding (requires GOOGLE_MAPS_API_KEY env var)" },
|
|
152
|
-
{ name: "house-system", type: "string", default: "placidus", description: "House system: placidus, koch, porphyrius, regiomontanus, campanus, equal, whole-sign, meridian, morinus, krusinski, alcabitius" },
|
|
153
|
-
{ name: "timezone", type: "string", description: "IANA timezone string (e.g. America/New_York). Auto-resolved from coordinates if omitted" }
|
|
154
|
-
],
|
|
155
|
-
examples: [
|
|
156
|
-
"kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006",
|
|
157
|
-
'kaabalah astrology 1990-01-15 14:30 --location="New York, USA"',
|
|
158
|
-
"kaabalah astrology 1990-01-15 --lat=40.7128 --lon=-74.006 --json"
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: "astrology:synastry",
|
|
163
|
-
description: "Calculate synastry (cross-chart aspects) between two birth charts",
|
|
164
|
-
args: [],
|
|
165
|
-
flags: [
|
|
166
|
-
{ name: "house-system", type: "string", default: "placidus", description: "House system for both charts" }
|
|
167
|
-
],
|
|
168
|
-
examples: [
|
|
169
|
-
`kaabalah astrology:synastry --input-json='{"chartA":{"date":"1990-01-15","time":"14:30","lat":40.71,"lon":-74},"chartB":{"date":"1992-06-20","time":"09:00","lat":51.5,"lon":-0.12}}' --json --compact`
|
|
170
|
-
]
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "astrology:composite",
|
|
174
|
-
description: "Calculate midpoint composite chart from two birth charts",
|
|
175
|
-
args: [],
|
|
176
|
-
flags: [
|
|
177
|
-
{ name: "house-system", type: "string", default: "placidus", description: "House system for both charts" }
|
|
178
|
-
],
|
|
179
|
-
examples: [
|
|
180
|
-
`kaabalah astrology:composite --input-json='{"chartA":{"date":"1990-01-15","time":"14:30","lat":40.71,"lon":-74},"chartB":{"date":"1992-06-20","time":"09:00","lat":51.5,"lon":-0.12}}' --json --compact`
|
|
181
|
-
]
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "help",
|
|
185
|
-
description: "Show help message",
|
|
186
|
-
args: [{ name: "command", type: "string", required: false, description: "Command to show help for" }],
|
|
187
|
-
flags: [],
|
|
188
|
-
examples: ["kaabalah help", "kaabalah help --json", "kaabalah help astrology --json"]
|
|
189
|
-
}
|
|
190
|
-
];
|
|
191
|
-
function parseArgs(argv) {
|
|
192
|
-
const args = [];
|
|
193
|
-
const flags = {};
|
|
194
|
-
for (const arg of argv.slice(2)) {
|
|
195
|
-
if (arg.startsWith("--")) {
|
|
196
|
-
const eqIdx = arg.indexOf("=");
|
|
197
|
-
if (eqIdx !== -1) {
|
|
198
|
-
flags[arg.slice(2, eqIdx)] = arg.slice(eqIdx + 1);
|
|
199
|
-
} else {
|
|
200
|
-
flags[arg.slice(2)] = true;
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
args.push(arg);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (!process.stdout.isTTY && flags["no-json"] !== true) {
|
|
207
|
-
flags.json = true;
|
|
208
|
-
}
|
|
209
|
-
return { args, flags };
|
|
210
|
-
}
|
|
211
|
-
function getFlagString(flags, name) {
|
|
212
|
-
const v = flags[name];
|
|
213
|
-
return typeof v === "string" ? v : void 0;
|
|
214
|
-
}
|
|
215
|
-
function getFlagNumber(flags, name) {
|
|
216
|
-
const v = flags[name];
|
|
217
|
-
if (typeof v === "string") {
|
|
218
|
-
const n = Number(v);
|
|
219
|
-
return isNaN(n) ? void 0 : n;
|
|
220
|
-
}
|
|
221
|
-
return void 0;
|
|
222
|
-
}
|
|
223
|
-
function getFlagBool(flags, name) {
|
|
224
|
-
return flags[name] === true;
|
|
225
|
-
}
|
|
226
|
-
function isJsonMode(flags) {
|
|
227
|
-
return flags.json === true || typeof flags.json === "string";
|
|
228
|
-
}
|
|
229
|
-
function parseInputJson(flags) {
|
|
230
|
-
const raw = getFlagString(flags, "input-json");
|
|
231
|
-
if (!raw) return null;
|
|
232
|
-
try {
|
|
233
|
-
const parsed = JSON.parse(raw);
|
|
234
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
235
|
-
exitWithError("INVALID_JSON", "--input-json must be a JSON object", flags);
|
|
236
|
-
}
|
|
237
|
-
return parsed;
|
|
238
|
-
} catch {
|
|
239
|
-
exitWithError("INVALID_JSON", `Invalid JSON in --input-json: ${raw}`, flags);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
function sanitizeInput(str) {
|
|
243
|
-
return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
|
|
244
|
-
}
|
|
245
|
-
function validateDateRange(dateStr, flags) {
|
|
246
|
-
const match = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
247
|
-
if (!match) {
|
|
248
|
-
exitWithError("INVALID_DATE", `Invalid date: "${dateStr}". Use YYYY-MM-DD format.`, flags);
|
|
249
|
-
}
|
|
250
|
-
const year = parseInt(match[1], 10);
|
|
251
|
-
if (year < 1 || year > 9999) {
|
|
252
|
-
exitWithError("INVALID_DATE", `Year must be between 0001 and 9999, got ${year}.`, flags);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function capNumber(value, max) {
|
|
256
|
-
if (value > max) return max;
|
|
257
|
-
if (value < 0) return 0;
|
|
258
|
-
return value;
|
|
259
|
-
}
|
|
260
|
-
var MAX_TEXT_LENGTH = 1e3;
|
|
261
|
-
var MAX_RESULTS_CAP = 1e4;
|
|
262
|
-
function exitWithError(code, message, flags) {
|
|
263
|
-
if (isJsonMode(flags)) {
|
|
264
|
-
const out = JSON.stringify({ error: true, code, message });
|
|
265
|
-
process.stdout.write(out + "\n");
|
|
266
|
-
} else {
|
|
267
|
-
process.stderr.write(message + "\n");
|
|
268
|
-
}
|
|
269
|
-
process.exit(1);
|
|
270
|
-
}
|
|
271
|
-
function pickFields(obj, paths) {
|
|
272
|
-
if (typeof obj !== "object" || obj === null) return obj;
|
|
273
|
-
const result = {};
|
|
274
|
-
for (const path of paths) {
|
|
275
|
-
const parts = path.split(".");
|
|
276
|
-
let current = obj;
|
|
277
|
-
for (const part of parts) {
|
|
278
|
-
if (current === null || current === void 0 || typeof current !== "object") {
|
|
279
|
-
current = void 0;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
current = current[part];
|
|
283
|
-
}
|
|
284
|
-
if (current !== void 0) {
|
|
285
|
-
let target = result;
|
|
286
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
287
|
-
if (!(parts[i] in target) || typeof target[parts[i]] !== "object") {
|
|
288
|
-
target[parts[i]] = {};
|
|
289
|
-
}
|
|
290
|
-
target = target[parts[i]];
|
|
291
|
-
}
|
|
292
|
-
target[parts[parts.length - 1]] = current;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return result;
|
|
296
|
-
}
|
|
297
|
-
function outputJson(data, flags) {
|
|
298
|
-
let output = data;
|
|
299
|
-
const fieldsStr = getFlagString(flags, "fields");
|
|
300
|
-
if (fieldsStr) {
|
|
301
|
-
const paths = fieldsStr.split(",").map((s) => s.trim()).filter(Boolean);
|
|
302
|
-
if (paths.length > 0) {
|
|
303
|
-
output = pickFields(output, paths);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
const indent = getFlagBool(flags, "compact") ? void 0 : 2;
|
|
307
|
-
console.log(JSON.stringify(output, null, indent));
|
|
308
|
-
}
|
|
309
|
-
function parseDate(str, flags) {
|
|
310
|
-
validateDateRange(str, flags);
|
|
311
|
-
const d = /* @__PURE__ */ new Date(str + "T12:00:00Z");
|
|
312
|
-
if (isNaN(d.getTime())) {
|
|
313
|
-
exitWithError("INVALID_DATE", `Invalid date: "${str}". Use YYYY-MM-DD format.`, flags);
|
|
314
|
-
}
|
|
315
|
-
return d;
|
|
316
|
-
}
|
|
317
|
-
function generateHelp() {
|
|
318
|
-
const lines = [];
|
|
319
|
-
lines.push("");
|
|
320
|
-
lines.push("kaabalah - CLI for esoteric calculations");
|
|
321
|
-
lines.push("");
|
|
322
|
-
lines.push("USAGE");
|
|
323
|
-
lines.push(" kaabalah <command> [options]");
|
|
324
|
-
lines.push("");
|
|
325
|
-
lines.push("COMMANDS");
|
|
326
|
-
for (const cmd of COMMANDS) {
|
|
327
|
-
const argsStr = cmd.args.map((a) => a.required ? `<${a.name}>` : `[${a.name}]`).join(" ");
|
|
328
|
-
const line = ` ${cmd.name} ${argsStr}`.padEnd(42) + cmd.description;
|
|
329
|
-
lines.push(line);
|
|
330
|
-
}
|
|
331
|
-
lines.push("");
|
|
332
|
-
lines.push("GLOBAL OPTIONS");
|
|
333
|
-
for (const f of GLOBAL_FLAGS) {
|
|
334
|
-
const def = f.default !== void 0 ? ` (default: ${f.default})` : "";
|
|
335
|
-
const line = ` --${f.name}`.padEnd(30) + f.description + def;
|
|
336
|
-
lines.push(line);
|
|
337
|
-
}
|
|
338
|
-
lines.push("");
|
|
339
|
-
lines.push("EXAMPLES");
|
|
340
|
-
lines.push(' kaabalah gematria "Hello World"');
|
|
341
|
-
lines.push(" kaabalah numerology 1990-01-15");
|
|
342
|
-
lines.push(" kaabalah numerology:cycles 1990-01-15 John");
|
|
343
|
-
lines.push(" kaabalah tarot 5 --inverted");
|
|
344
|
-
lines.push(" kaabalah tarot:card 7");
|
|
345
|
-
lines.push(" kaabalah gematria:reverse 22");
|
|
346
|
-
lines.push(" kaabalah ifa 1990-01-15");
|
|
347
|
-
lines.push(" kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006");
|
|
348
|
-
lines.push(' kaabalah astrology 1990-01-15 14:30 --location="New York, USA"');
|
|
349
|
-
lines.push(" kaabalah help --json");
|
|
350
|
-
lines.push("");
|
|
351
|
-
return lines.join("\n");
|
|
352
|
-
}
|
|
353
|
-
function cmdHelp(args, flags) {
|
|
354
|
-
const subcommand = args[0];
|
|
355
|
-
if (isJsonMode(flags)) {
|
|
356
|
-
if (subcommand) {
|
|
357
|
-
const cmd = COMMANDS.find((c) => c.name === subcommand);
|
|
358
|
-
if (!cmd) {
|
|
359
|
-
exitWithError("UNKNOWN_COMMAND", `Unknown command: "${subcommand}".`, flags);
|
|
360
|
-
}
|
|
361
|
-
outputJson({ version: VERSION, command: cmd, globalFlags: GLOBAL_FLAGS }, flags);
|
|
362
|
-
} else {
|
|
363
|
-
outputJson({ version: VERSION, commands: COMMANDS, globalFlags: GLOBAL_FLAGS }, flags);
|
|
364
|
-
}
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
if (subcommand) {
|
|
368
|
-
const cmd = COMMANDS.find((c) => c.name === subcommand);
|
|
369
|
-
if (!cmd) {
|
|
370
|
-
exitWithError("UNKNOWN_COMMAND", `Unknown command: "${subcommand}".`, flags);
|
|
371
|
-
}
|
|
372
|
-
console.log(`
|
|
373
|
-
${cmd.name} - ${cmd.description}
|
|
374
|
-
`);
|
|
375
|
-
console.log("USAGE");
|
|
376
|
-
const argsStr = cmd.args.map((a) => a.required ? `<${a.name}>` : `[${a.name}]`).join(" ");
|
|
377
|
-
console.log(` kaabalah ${cmd.name} ${argsStr}
|
|
378
|
-
`);
|
|
379
|
-
if (cmd.args.length > 0) {
|
|
380
|
-
console.log("ARGUMENTS");
|
|
381
|
-
for (const a of cmd.args) {
|
|
382
|
-
const req = a.required ? "(required)" : "(optional)";
|
|
383
|
-
console.log(` ${a.name.padEnd(20)} ${a.type.padEnd(10)} ${req} ${a.description}`);
|
|
384
|
-
}
|
|
385
|
-
console.log();
|
|
386
|
-
}
|
|
387
|
-
if (cmd.flags.length > 0) {
|
|
388
|
-
console.log("FLAGS");
|
|
389
|
-
for (const f of cmd.flags) {
|
|
390
|
-
const def = f.default !== void 0 ? ` (default: ${f.default})` : "";
|
|
391
|
-
console.log(` --${f.name.padEnd(24)} ${f.description}${def}`);
|
|
392
|
-
}
|
|
393
|
-
console.log();
|
|
394
|
-
}
|
|
395
|
-
if (cmd.examples.length > 0) {
|
|
396
|
-
console.log("EXAMPLES");
|
|
397
|
-
for (const e of cmd.examples) {
|
|
398
|
-
console.log(` ${e}`);
|
|
399
|
-
}
|
|
400
|
-
console.log();
|
|
401
|
-
}
|
|
402
|
-
} else {
|
|
403
|
-
console.log(generateHelp());
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
async function geocodeLocation(location, flags) {
|
|
407
|
-
const apiKey = process.env.GOOGLE_MAPS_API_KEY;
|
|
408
|
-
if (!apiKey) {
|
|
409
|
-
exitWithError(
|
|
410
|
-
"GEOCODE_ERROR",
|
|
411
|
-
"GOOGLE_MAPS_API_KEY environment variable is required for --location. Set it or use --lat/--lon directly.",
|
|
412
|
-
flags
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
const url = "https://places.googleapis.com/v1/places:searchText";
|
|
416
|
-
let response;
|
|
417
|
-
try {
|
|
418
|
-
response = await fetch(url, {
|
|
419
|
-
method: "POST",
|
|
420
|
-
headers: {
|
|
421
|
-
"Content-Type": "application/json",
|
|
422
|
-
"X-Goog-Api-Key": apiKey,
|
|
423
|
-
"X-Goog-FieldMask": "places.displayName,places.formattedAddress,places.location"
|
|
424
|
-
},
|
|
425
|
-
body: JSON.stringify({ textQuery: location, maxResultCount: 1 })
|
|
426
|
-
});
|
|
427
|
-
} catch (err) {
|
|
428
|
-
exitWithError("GEOCODE_ERROR", `Geocoding request failed: ${err instanceof Error ? err.message : String(err)}`, flags);
|
|
429
|
-
}
|
|
430
|
-
const data = await response.json();
|
|
431
|
-
if (data.error) {
|
|
432
|
-
exitWithError(
|
|
433
|
-
"GEOCODE_ERROR",
|
|
434
|
-
`Geocoding failed for "${location}": ${data.error.message}`,
|
|
435
|
-
flags
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
if (!data.places || data.places.length === 0 || !data.places[0].location) {
|
|
439
|
-
exitWithError(
|
|
440
|
-
"GEOCODE_ERROR",
|
|
441
|
-
`No results found for "${location}".`,
|
|
442
|
-
flags
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
const place = data.places[0];
|
|
446
|
-
return {
|
|
447
|
-
latitude: place.location.latitude,
|
|
448
|
-
longitude: place.location.longitude,
|
|
449
|
-
formattedAddress: place.formattedAddress ?? place.displayName?.text ?? location
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
var HOUSE_SYSTEM_MAP = {
|
|
453
|
-
placidus: "P",
|
|
454
|
-
koch: "K",
|
|
455
|
-
porphyrius: "O",
|
|
456
|
-
regiomontanus: "R",
|
|
457
|
-
campanus: "C",
|
|
458
|
-
equal: "E",
|
|
459
|
-
"whole-sign": "W",
|
|
460
|
-
meridian: "X",
|
|
461
|
-
morinus: "M",
|
|
462
|
-
krusinski: "U",
|
|
463
|
-
alcabitius: "B"
|
|
464
|
-
};
|
|
465
|
-
function cmdGematria(text, flags) {
|
|
466
|
-
if (text.length > MAX_TEXT_LENGTH) {
|
|
467
|
-
exitWithError("INVALID_ARGUMENT", `Text exceeds maximum length of ${MAX_TEXT_LENGTH} characters.`, flags);
|
|
468
|
-
}
|
|
469
|
-
const sanitized = sanitizeInput(text);
|
|
470
|
-
const result = calculateGematria(sanitized, {
|
|
471
|
-
missing: getFlagBool(flags, "missing"),
|
|
472
|
-
percentages: getFlagBool(flags, "percentages")
|
|
473
|
-
});
|
|
474
|
-
if (isJsonMode(flags)) {
|
|
475
|
-
outputJson(result, flags);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
console.log(`
|
|
479
|
-
Gematria: "${sanitized}"
|
|
480
|
-
`);
|
|
481
|
-
console.log(` Vowels: ${result.vowels.originalSum} -> [${result.vowels.reductionSteps.join(", ")}] = ${result.vowels.finalValue}`);
|
|
482
|
-
console.log(` Consonants: ${result.consonants.originalSum} -> [${result.consonants.reductionSteps.join(", ")}] = ${result.consonants.finalValue}`);
|
|
483
|
-
console.log(` Synthesis: ${result.synthesis.originalSum} -> [${result.synthesis.reductionSteps.join(", ")}] = ${result.synthesis.finalValue}`);
|
|
484
|
-
if (result.includedLetters.length > 0) {
|
|
485
|
-
console.log(`
|
|
486
|
-
Letters:`);
|
|
487
|
-
for (const l of result.includedLetters) {
|
|
488
|
-
const vowelTag = l.isVowel ? " (vowel)" : "";
|
|
489
|
-
console.log(` ${l.hebrewCharacter} value=${l.value}${vowelTag}`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
if (result.missingGematriaValues && result.missingGematriaValues.length > 0) {
|
|
493
|
-
console.log(`
|
|
494
|
-
Missing values: ${result.missingGematriaValues.map((m) => m.value).join(", ")}`);
|
|
495
|
-
}
|
|
496
|
-
if (result.letterPercentages) {
|
|
497
|
-
console.log(`
|
|
498
|
-
Vowel %: ${result.letterPercentages.percentageOfVowels.toFixed(1)}%`);
|
|
499
|
-
console.log(` Consonant %: ${result.letterPercentages.percentageOfConsonants.toFixed(1)}%`);
|
|
500
|
-
}
|
|
501
|
-
console.log();
|
|
502
|
-
}
|
|
503
|
-
function cmdReverseGematria(target, flags, inputPayload) {
|
|
504
|
-
const targetNum = inputPayload?.targetSynthesis != null ? Number(inputPayload.targetSynthesis) : parseInt(target, 10);
|
|
505
|
-
if (isNaN(targetNum)) {
|
|
506
|
-
exitWithError("INVALID_ARGUMENT", `Invalid target number: "${target}"`, flags);
|
|
507
|
-
}
|
|
508
|
-
let maxResults = inputPayload?.maxResults != null ? Number(inputPayload.maxResults) : getFlagNumber(flags, "max-results") ?? 20;
|
|
509
|
-
maxResults = capNumber(maxResults, MAX_RESULTS_CAP);
|
|
510
|
-
let minLength = inputPayload?.minLength != null ? Number(inputPayload.minLength) : getFlagNumber(flags, "min-length") ?? 2;
|
|
511
|
-
let maxLength = inputPayload?.maxLength != null ? Number(inputPayload.maxLength) : getFlagNumber(flags, "max-length") ?? 6;
|
|
512
|
-
const includeDigraphs = inputPayload?.includeDigraphs != null ? Boolean(inputPayload.includeDigraphs) : getFlagBool(flags, "include-digraphs");
|
|
513
|
-
const result = reverseGematria({
|
|
514
|
-
targetSynthesis: targetNum,
|
|
515
|
-
maxResults,
|
|
516
|
-
minLength,
|
|
517
|
-
maxLength,
|
|
518
|
-
includeDigraphs
|
|
519
|
-
});
|
|
520
|
-
if (isJsonMode(flags)) {
|
|
521
|
-
outputJson(result, flags);
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
console.log(`
|
|
525
|
-
Reverse Gematria: target synthesis = ${targetNum}
|
|
526
|
-
`);
|
|
527
|
-
console.log(` Found: ${result.totalFound} combinations${result.hasMore ? ` (showing first ${maxResults})` : ""}
|
|
528
|
-
`);
|
|
529
|
-
for (const r of result.results) {
|
|
530
|
-
console.log(` ${r.letters.padEnd(12)} vowels=${r.vowelsSum} consonants=${r.consonantsSum} synthesis=${r.synthesisSum}`);
|
|
531
|
-
}
|
|
532
|
-
console.log();
|
|
533
|
-
}
|
|
534
|
-
function cmdNumerology(dateStr, flags) {
|
|
535
|
-
const date = parseDate(dateStr, flags);
|
|
536
|
-
const kaabalistic = calculateKaabalisticLifePath(date);
|
|
537
|
-
const straight = calculateStraightAcrossReductionLifePath(date);
|
|
538
|
-
const challenges = calculateChallenges(date);
|
|
539
|
-
const energies = getDateEnergies(date);
|
|
540
|
-
const personalYear = calculatePersonalYear(date);
|
|
541
|
-
const fibonacci = calculateFibonacciCycle(date, /* @__PURE__ */ new Date());
|
|
542
|
-
if (isJsonMode(flags)) {
|
|
543
|
-
outputJson({ kaabalistic, straight, challenges, energies, personalYear, fibonacci }, flags);
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
console.log(`
|
|
547
|
-
Numerology Profile: ${dateStr}
|
|
548
|
-
`);
|
|
549
|
-
console.log(` Kaabalistic Life Path: ${kaabalistic.lifePath.reducedValue}`);
|
|
550
|
-
console.log(` Steps: [${kaabalistic.lifePath.reductionSteps.join(", ")}]`);
|
|
551
|
-
console.log(` Personal Mythology: [${kaabalistic.personalMythologyNumbers.join(", ")}]`);
|
|
552
|
-
console.log(`
|
|
553
|
-
Straight Across Life Path: ${straight.lifePath.reducedValue}`);
|
|
554
|
-
console.log(` Day energy: ${straight.dayEnergy.reducedValue}`);
|
|
555
|
-
console.log(` Month energy: ${straight.monthEnergy.reducedValue}`);
|
|
556
|
-
console.log(` Year energy: ${straight.yearEnergy.reducedValue}`);
|
|
557
|
-
console.log(`
|
|
558
|
-
Challenges:`);
|
|
559
|
-
console.log(` Main: ${challenges.mainChallenge}`);
|
|
560
|
-
console.log(` Sub 1: ${challenges.subChallenge1}`);
|
|
561
|
-
console.log(` Sub 2: ${challenges.subChallenge2}`);
|
|
562
|
-
console.log(`
|
|
563
|
-
Date Energies:`);
|
|
564
|
-
console.log(` Day: ${energies.dayEnergy.reducedValue}`);
|
|
565
|
-
console.log(` Month: ${energies.monthEnergy.reducedValue}`);
|
|
566
|
-
console.log(` Year: ${energies.yearEnergy.reducedValue}`);
|
|
567
|
-
console.log(`
|
|
568
|
-
Personal Year: ${personalYear.reducedValue}`);
|
|
569
|
-
console.log(`
|
|
570
|
-
Fibonacci Cycle (age ${fibonacci.currentAge}):`);
|
|
571
|
-
for (let i = 1; i <= 7; i++) {
|
|
572
|
-
const cycle = fibonacci[`cycle${i}`];
|
|
573
|
-
console.log(` Cycle ${i}: ${cycle.reducedValue}`);
|
|
574
|
-
}
|
|
575
|
-
console.log();
|
|
576
|
-
}
|
|
577
|
-
function cmdLifePath(dateStr, flags) {
|
|
578
|
-
const date = parseDate(dateStr, flags);
|
|
579
|
-
const result = calculateKaabalisticLifePath(date);
|
|
580
|
-
if (isJsonMode(flags)) {
|
|
581
|
-
outputJson(result, flags);
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
console.log(`
|
|
585
|
-
Kaabalistic Life Path: ${dateStr}
|
|
586
|
-
`);
|
|
587
|
-
console.log(` Life Path: ${result.lifePath.reducedValue}`);
|
|
588
|
-
console.log(` Steps: [${result.lifePath.reductionSteps.join(", ")}]`);
|
|
589
|
-
console.log(` Personal Mythology: [${result.personalMythologyNumbers.join(", ")}]`);
|
|
590
|
-
console.log(` Parts: day=${result.reducedParts.reducedDay} month=${result.reducedParts.reducedMonth} year1=${result.reducedParts.reducedYear1} year2=${result.reducedParts.reducedYear2}`);
|
|
591
|
-
console.log();
|
|
592
|
-
}
|
|
593
|
-
function cmdCycles(dateStr, firstName, flags) {
|
|
594
|
-
const date = parseDate(dateStr, flags);
|
|
595
|
-
const today = /* @__PURE__ */ new Date();
|
|
596
|
-
if (firstName) {
|
|
597
|
-
const result = calculatePersonalCycles(date, today, firstName);
|
|
598
|
-
if (isJsonMode(flags)) {
|
|
599
|
-
outputJson(result, flags);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
console.log(`
|
|
603
|
-
Personal Cycles: ${dateStr} (${firstName})
|
|
604
|
-
`);
|
|
605
|
-
console.log(` Age: ${result.currentAge}`);
|
|
606
|
-
console.log(` Life Path: ${result.lifePath.reducedValue}`);
|
|
607
|
-
console.log(` Soul Number: ${result.soulNumber?.reducedValue}`);
|
|
608
|
-
console.log(` Personal Year: ${result.personalYear.reducedValue}`);
|
|
609
|
-
console.log(` Current Period: ${result.currentPersonalPeriod + 1}/3`);
|
|
610
|
-
console.log(` Current Month: ${result.currentPersonalMonth + 1}/12`);
|
|
611
|
-
console.log(`
|
|
612
|
-
Periods:`);
|
|
613
|
-
for (let i = 0; i < result.personalPeriods.length; i++) {
|
|
614
|
-
const p = result.personalPeriods[i];
|
|
615
|
-
const active = i === result.currentPersonalPeriod ? " <--" : "";
|
|
616
|
-
console.log(` Period ${i + 1} (months ${p.startMonth}-${p.endMonth}): ${p.value.reducedValue}${active}`);
|
|
617
|
-
}
|
|
618
|
-
console.log(`
|
|
619
|
-
Monthly energies:`);
|
|
620
|
-
for (let i = 0; i < result.personalMonths.length; i++) {
|
|
621
|
-
const m = result.personalMonths[i];
|
|
622
|
-
const active = i === result.currentPersonalMonth ? " <--" : "";
|
|
623
|
-
console.log(` Month ${m.month}: ${m.value.reducedValue}${active}`);
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
const result = calculateCycles(date, today);
|
|
627
|
-
if (isJsonMode(flags)) {
|
|
628
|
-
outputJson(result, flags);
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
console.log(`
|
|
632
|
-
Heptad Cycles: ${dateStr}
|
|
633
|
-
`);
|
|
634
|
-
console.log(` Total days since last birthday: ${result.totalDays}`);
|
|
635
|
-
if (result.currentAgeCycle) {
|
|
636
|
-
console.log(`
|
|
637
|
-
Age Cycles (current: ${result.currentAgeCycle}):`);
|
|
638
|
-
for (const c of result.ageCycles) {
|
|
639
|
-
const active = c.isActive ? " <--" : "";
|
|
640
|
-
console.log(` Cycle ${c.number}: ${c.description}${active}`);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
if (result.currentYearlyCycle) {
|
|
644
|
-
console.log(`
|
|
645
|
-
Yearly Cycles (current: ${result.currentYearlyCycle}):`);
|
|
646
|
-
for (const c of result.yearlyCycles) {
|
|
647
|
-
const active = c.isActive ? " <--" : "";
|
|
648
|
-
console.log(` Cycle ${c.number}: ${c.description}${active}`);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
console.log(`
|
|
652
|
-
Monthly Cycles (current: ${result.currentMonthlyCycle}, day ${result.daysInMonthlyCycle}):`);
|
|
653
|
-
for (const c of result.monthlyCycles) {
|
|
654
|
-
const active = c.isActive ? " <--" : "";
|
|
655
|
-
console.log(` Cycle ${c.number}: ${c.description}${active}`);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
console.log();
|
|
659
|
-
}
|
|
660
|
-
function cmdChallenges(dateStr, flags) {
|
|
661
|
-
const date = parseDate(dateStr, flags);
|
|
662
|
-
const result = calculateChallenges(date);
|
|
663
|
-
if (isJsonMode(flags)) {
|
|
664
|
-
outputJson(result, flags);
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
console.log(`
|
|
668
|
-
Challenges: ${dateStr}
|
|
669
|
-
`);
|
|
670
|
-
console.log(` Day: ${result.day}`);
|
|
671
|
-
console.log(` Month: ${result.month}`);
|
|
672
|
-
console.log(` Year: ${result.year}`);
|
|
673
|
-
console.log(` Main: ${result.mainChallenge}`);
|
|
674
|
-
console.log(` Sub 1: ${result.subChallenge1}`);
|
|
675
|
-
console.log(` Sub 2: ${result.subChallenge2}`);
|
|
676
|
-
console.log();
|
|
677
|
-
}
|
|
678
|
-
function cmdFibonacci(dateStr, flags) {
|
|
679
|
-
const date = parseDate(dateStr, flags);
|
|
680
|
-
const result = calculateFibonacciCycle(date, /* @__PURE__ */ new Date());
|
|
681
|
-
if (isJsonMode(flags)) {
|
|
682
|
-
outputJson(result, flags);
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
console.log(`
|
|
686
|
-
Fibonacci Cycle: ${dateStr} (age ${result.currentAge})
|
|
687
|
-
`);
|
|
688
|
-
for (let i = 1; i <= 7; i++) {
|
|
689
|
-
const cycle = result[`cycle${i}`];
|
|
690
|
-
console.log(` Cycle ${i}: ${cycle.reducedValue} [${cycle.reductionSteps.join(", ")}]`);
|
|
691
|
-
}
|
|
692
|
-
console.log();
|
|
693
|
-
}
|
|
694
|
-
async function cmdTarot(countStr, flags) {
|
|
695
|
-
const count = countStr ? parseInt(countStr, 10) : 3;
|
|
696
|
-
if (isNaN(count) || count < 1 || count > 78) {
|
|
697
|
-
exitWithError("INVALID_ARGUMENT", "Card count must be between 1 and 78.", flags);
|
|
698
|
-
}
|
|
699
|
-
const shuffleCount = getFlagNumber(flags, "shuffle-count") ?? 7;
|
|
700
|
-
const deck = await shuffleTarotDeck(ARKANNUS, getFlagBool(flags, "inverted"), shuffleCount);
|
|
701
|
-
const drawn = deck.slice(0, count);
|
|
702
|
-
if (isJsonMode(flags)) {
|
|
703
|
-
outputJson(drawn, flags);
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
console.log(`
|
|
707
|
-
Tarot Draw: ${count} card${count > 1 ? "s" : ""}
|
|
708
|
-
`);
|
|
709
|
-
for (const card of drawn) {
|
|
710
|
-
const inverted = card.isInverted ? " (INVERTED)" : "";
|
|
711
|
-
console.log(` #${String(card.number).padStart(2, "0")} ${card.tarotCard}${inverted}`);
|
|
712
|
-
console.log(` ${card.meaning}`);
|
|
713
|
-
if (card.egyptianCardName) {
|
|
714
|
-
console.log(` Egyptian: ${card.egyptianCardName}`);
|
|
715
|
-
}
|
|
716
|
-
if (card.papusMeaning) {
|
|
717
|
-
console.log(` Papus: ${card.papusMeaning}`);
|
|
718
|
-
}
|
|
719
|
-
console.log();
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
function findCardsByQuery(query) {
|
|
723
|
-
const num = parseInt(query, 10);
|
|
724
|
-
if (!isNaN(num)) {
|
|
725
|
-
const card = ARKANNUS.find((c) => c.number === num);
|
|
726
|
-
return card ? { cards: [card], exact: true } : { cards: [], exact: false };
|
|
727
|
-
}
|
|
728
|
-
const q = query.toLowerCase();
|
|
729
|
-
const exactMatch = ARKANNUS.find((c) => c.tarotCard.toLowerCase() === q);
|
|
730
|
-
if (exactMatch) return { cards: [exactMatch], exact: true };
|
|
731
|
-
const substringMatches = ARKANNUS.filter((c) => c.tarotCard.toLowerCase().includes(q));
|
|
732
|
-
return { cards: substringMatches, exact: false };
|
|
733
|
-
}
|
|
734
|
-
function printCard(card) {
|
|
735
|
-
console.log(`
|
|
736
|
-
#${String(card.number).padStart(2, "0")} ${card.tarotCard}`);
|
|
737
|
-
console.log(` Type: ${card.type} | Suit: ${card.suit ?? "major"} | Deck: ${card.deck}`);
|
|
738
|
-
console.log(` Meaning: ${card.meaning}`);
|
|
739
|
-
if (card.egyptianCardName) console.log(` Egyptian: ${card.egyptianCardName}`);
|
|
740
|
-
if (card.papusMeaning) console.log(` Papus: ${card.papusMeaning}`);
|
|
741
|
-
console.log();
|
|
742
|
-
}
|
|
743
|
-
function cmdTarotCard(query, flags) {
|
|
744
|
-
const { cards } = findCardsByQuery(query);
|
|
745
|
-
if (cards.length === 0) {
|
|
746
|
-
exitWithError("CARD_NOT_FOUND", `No card found for "${query}". Use a number (1-78) or card name.`, flags);
|
|
747
|
-
}
|
|
748
|
-
if (isJsonMode(flags)) {
|
|
749
|
-
outputJson(cards.length === 1 ? cards[0] : cards, flags);
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
for (const card of cards) {
|
|
753
|
-
printCard(card);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
function cmdTarotSpread(cardQueries, flags) {
|
|
757
|
-
const results = [];
|
|
758
|
-
for (const q of cardQueries) {
|
|
759
|
-
const { cards } = findCardsByQuery(q);
|
|
760
|
-
if (cards.length === 0) {
|
|
761
|
-
results.push({ query: q, error: true, code: "CARD_NOT_FOUND", message: `No card found for "${q}".` });
|
|
762
|
-
} else if (cards.length === 1) {
|
|
763
|
-
results.push(cards[0]);
|
|
764
|
-
} else {
|
|
765
|
-
results.push(...cards);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
if (isJsonMode(flags)) {
|
|
769
|
-
outputJson(results, flags);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
for (const item of results) {
|
|
773
|
-
if ("error" in item && item.error) {
|
|
774
|
-
console.log(`
|
|
775
|
-
\u2717 "${item.query}": ${item.message}`);
|
|
776
|
-
} else {
|
|
777
|
-
printCard(item);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
function cmdIfa(dateStr, flags) {
|
|
782
|
-
const date = parseDate(dateStr, flags);
|
|
783
|
-
const result = calculateOdu(date);
|
|
784
|
-
if (isJsonMode(flags)) {
|
|
785
|
-
outputJson(result, flags);
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
console.log(`
|
|
789
|
-
Odu: ${dateStr}
|
|
790
|
-
`);
|
|
791
|
-
console.log(` Left: [${result.leftNumbers.join(", ")}]`);
|
|
792
|
-
console.log(` Right: [${result.rightNumbers.join(", ")}]`);
|
|
793
|
-
console.log(` North: ${result.north}`);
|
|
794
|
-
console.log(` South: ${result.south}`);
|
|
795
|
-
console.log(` East: ${result.east}`);
|
|
796
|
-
console.log(` West: ${result.west}`);
|
|
797
|
-
console.log(` Center: ${result.center}`);
|
|
798
|
-
console.log();
|
|
799
|
-
}
|
|
800
|
-
function getTree() {
|
|
801
|
-
return createTree({ system: SYSTEM, parts: ["westernAstrology", "tarot"] });
|
|
802
|
-
}
|
|
803
|
-
function serializeNode(n) {
|
|
804
|
-
const result = { id: n.id, type: n.type };
|
|
805
|
-
if (n.data && typeof n.data === "object" && Object.keys(n.data).length > 0) {
|
|
806
|
-
result.data = n.data;
|
|
807
|
-
}
|
|
808
|
-
if (n.name) result.name = n.name;
|
|
809
|
-
return result;
|
|
810
|
-
}
|
|
811
|
-
function cmdTree(flags) {
|
|
812
|
-
const tree = getTree();
|
|
813
|
-
const allNodes = tree.getNodes();
|
|
814
|
-
if (isJsonMode(flags)) {
|
|
815
|
-
const nodes = allNodes.map((n) => {
|
|
816
|
-
const node = serializeNode(n);
|
|
817
|
-
const relatedTypes = tree.relatedTypes(n.id);
|
|
818
|
-
if (relatedTypes.length > 0) {
|
|
819
|
-
node.relatedTypes = relatedTypes;
|
|
820
|
-
}
|
|
821
|
-
return node;
|
|
822
|
-
});
|
|
823
|
-
const edgeSet = /* @__PURE__ */ new Set();
|
|
824
|
-
const edges = [];
|
|
825
|
-
for (const n of allNodes) {
|
|
826
|
-
const related = tree.related(n.id);
|
|
827
|
-
for (const r of related) {
|
|
828
|
-
const key = n.id < r.id ? `${n.id}|${r.id}` : `${r.id}|${n.id}`;
|
|
829
|
-
if (!edgeSet.has(key)) {
|
|
830
|
-
edgeSet.add(key);
|
|
831
|
-
edges.push({ from: n.id, to: r.id });
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
outputJson({ system: SYSTEM, totalNodes: allNodes.length, totalEdges: edges.length, nodes, edges }, flags);
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
console.log(`
|
|
839
|
-
Tree of Life (${SYSTEM})
|
|
840
|
-
`);
|
|
841
|
-
console.log(` Total nodes: ${allNodes.length}`);
|
|
842
|
-
const byType = /* @__PURE__ */ new Map();
|
|
843
|
-
for (const node of allNodes) {
|
|
844
|
-
const t = node.type;
|
|
845
|
-
if (!byType.has(t)) byType.set(t, []);
|
|
846
|
-
byType.get(t).push(node);
|
|
847
|
-
}
|
|
848
|
-
for (const [type, nodes] of byType) {
|
|
849
|
-
console.log(`
|
|
850
|
-
${type} (${nodes.length}):`);
|
|
851
|
-
for (const n of nodes.slice(0, 15)) {
|
|
852
|
-
const d = n.data;
|
|
853
|
-
const name = d?.name ?? d?.character ?? "";
|
|
854
|
-
console.log(` ${n.id}${name ? ` \u2014 ${name}` : ""}`);
|
|
855
|
-
}
|
|
856
|
-
if (nodes.length > 15) {
|
|
857
|
-
console.log(` ... and ${nodes.length - 15} more`);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
console.log();
|
|
861
|
-
}
|
|
862
|
-
function cmdTreeNode(idStr, flags) {
|
|
863
|
-
const tree = getTree();
|
|
864
|
-
const node = tree.getNode(idStr);
|
|
865
|
-
if (!node) {
|
|
866
|
-
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);
|
|
867
|
-
}
|
|
868
|
-
const typeFilter = getFlagString(flags, "type");
|
|
869
|
-
const depth = getFlagNumber(flags, "depth") ?? 1;
|
|
870
|
-
const related = depth > 1 ? tree.walk(node.id, depth, typeFilter || void 0) : typeFilter ? tree.related(node.id, typeFilter) : tree.related(node.id);
|
|
871
|
-
if (isJsonMode(flags)) {
|
|
872
|
-
outputJson({
|
|
873
|
-
node: serializeNode(node),
|
|
874
|
-
relatedTypes: tree.relatedTypes(node.id),
|
|
875
|
-
related: related.map(serializeNode)
|
|
876
|
-
}, flags);
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
console.log(`
|
|
880
|
-
${node.id}`);
|
|
881
|
-
const d = node.data;
|
|
882
|
-
if (d) {
|
|
883
|
-
for (const [k, v] of Object.entries(d)) {
|
|
884
|
-
if (v != null && typeof v !== "object") console.log(` ${k}: ${v}`);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
const relatedTypes = tree.relatedTypes(node.id);
|
|
888
|
-
console.log(`
|
|
889
|
-
Related types: ${relatedTypes.join(", ")}`);
|
|
890
|
-
const byType = /* @__PURE__ */ new Map();
|
|
891
|
-
for (const r of related) {
|
|
892
|
-
if (!byType.has(r.type)) byType.set(r.type, []);
|
|
893
|
-
byType.get(r.type).push(r);
|
|
894
|
-
}
|
|
895
|
-
for (const [type, nodes] of byType) {
|
|
896
|
-
console.log(`
|
|
897
|
-
${type}:`);
|
|
898
|
-
for (const n of nodes) {
|
|
899
|
-
const rd = n.data;
|
|
900
|
-
const label = rd?.name ?? rd?.character ?? rd?.englishName ?? rd?.meaning ?? "";
|
|
901
|
-
console.log(` ${n.id}${label ? ` \u2014 ${label}` : ""}`);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
console.log();
|
|
905
|
-
}
|
|
906
|
-
function cmdTreeTypes(flags) {
|
|
907
|
-
const tree = getTree();
|
|
908
|
-
const allNodes = tree.getNodes();
|
|
909
|
-
const counts = {};
|
|
910
|
-
for (const n of allNodes) {
|
|
911
|
-
if (!counts[n.type]) counts[n.type] = { count: 0, ids: [] };
|
|
912
|
-
counts[n.type].count++;
|
|
913
|
-
counts[n.type].ids.push(n.id);
|
|
914
|
-
}
|
|
915
|
-
if (isJsonMode(flags)) {
|
|
916
|
-
outputJson(counts, flags);
|
|
917
|
-
return;
|
|
918
|
-
}
|
|
919
|
-
console.log(`
|
|
920
|
-
Node types (${Object.keys(counts).length}):
|
|
921
|
-
`);
|
|
922
|
-
for (const [type, info] of Object.entries(counts)) {
|
|
923
|
-
console.log(` ${type}: ${info.count}`);
|
|
924
|
-
}
|
|
925
|
-
console.log();
|
|
926
|
-
}
|
|
927
|
-
function parseChartInput(input, label, flags) {
|
|
928
|
-
const dateStr = input.date;
|
|
929
|
-
if (!dateStr) {
|
|
930
|
-
exitWithError("MISSING_ARGUMENT", `${label}: "date" is required (YYYY-MM-DD).`, flags);
|
|
931
|
-
}
|
|
932
|
-
parseDate(dateStr, flags);
|
|
933
|
-
const timeStr = input.time ?? "12:00";
|
|
934
|
-
const timeMatch = timeStr.match(/^(\d{1,2}):(\d{2})$/);
|
|
935
|
-
if (!timeMatch) {
|
|
936
|
-
exitWithError("INVALID_ARGUMENT", `${label}: Invalid time format "${timeStr}". Use HH:MM.`, flags);
|
|
937
|
-
}
|
|
938
|
-
const hour = parseInt(timeMatch[1], 10);
|
|
939
|
-
const minute = parseInt(timeMatch[2], 10);
|
|
940
|
-
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
|
941
|
-
exitWithError("INVALID_ARGUMENT", `${label}: Invalid time "${timeStr}". Hours 0-23, minutes 0-59.`, flags);
|
|
942
|
-
}
|
|
943
|
-
const latitude = input.lat != null ? Number(input.lat) : void 0;
|
|
944
|
-
const longitude = input.lon != null ? Number(input.lon) : void 0;
|
|
945
|
-
if (latitude == null || longitude == null) {
|
|
946
|
-
exitWithError("MISSING_ARGUMENT", `${label}: "lat" and "lon" are required.`, flags);
|
|
947
|
-
}
|
|
948
|
-
if (latitude < -90 || latitude > 90) {
|
|
949
|
-
exitWithError("INVALID_ARGUMENT", `${label}: Latitude must be between -90 and 90, got ${latitude}.`, flags);
|
|
950
|
-
}
|
|
951
|
-
if (longitude < -180 || longitude > 180) {
|
|
952
|
-
exitWithError("INVALID_ARGUMENT", `${label}: Longitude must be between -180 and 180, got ${longitude}.`, flags);
|
|
953
|
-
}
|
|
954
|
-
const houseSystem = input.houseSystem ?? "placidus";
|
|
955
|
-
const houseSystemCode = HOUSE_SYSTEM_MAP[houseSystem.toLowerCase()];
|
|
956
|
-
if (!houseSystemCode) {
|
|
957
|
-
exitWithError("INVALID_ARGUMENT", `${label}: Unknown house system "${houseSystem}". Valid: ${Object.keys(HOUSE_SYSTEM_MAP).join(", ")}`, flags);
|
|
958
|
-
}
|
|
959
|
-
const timezoneStr = input.timezone;
|
|
960
|
-
const timeZoneSettings = {};
|
|
961
|
-
if (timezoneStr) {
|
|
962
|
-
timeZoneSettings.timeZone = timezoneStr;
|
|
963
|
-
} else {
|
|
964
|
-
timeZoneSettings.autoTimeZone = true;
|
|
965
|
-
}
|
|
966
|
-
const dateParts = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
967
|
-
const birthDate = new Date(
|
|
968
|
-
parseInt(dateParts[1], 10),
|
|
969
|
-
parseInt(dateParts[2], 10) - 1,
|
|
970
|
-
parseInt(dateParts[3], 10),
|
|
971
|
-
hour,
|
|
972
|
-
minute,
|
|
973
|
-
0
|
|
974
|
-
);
|
|
975
|
-
return { birthDate, latitude, longitude, houseSystem, houseSystemCode, timeZoneSettings, dateStr, timeStr };
|
|
976
|
-
}
|
|
977
|
-
async function initWasm() {
|
|
978
|
-
const path = __require("path");
|
|
979
|
-
const wasmPath = path.resolve(__dirname, "../wasm/build/swisseph.node.wasm");
|
|
980
|
-
const ephePath = path.resolve(__dirname, "../ephe");
|
|
981
|
-
const { getSwissEph } = await import('./astrology/index.mjs');
|
|
982
|
-
await getSwissEph({ wasmPath, ephePath });
|
|
983
|
-
}
|
|
984
|
-
async function cmdAstrologySynastry(flags, inputPayload) {
|
|
985
|
-
if (!inputPayload?.chartA || !inputPayload?.chartB) {
|
|
986
|
-
exitWithError("MISSING_ARGUMENT", `Usage: kaabalah astrology:synastry --input-json='{"chartA":{...},"chartB":{...}}'`, flags);
|
|
987
|
-
}
|
|
988
|
-
const chartAInput = parseChartInput(inputPayload.chartA, "chartA", flags);
|
|
989
|
-
const chartBInput = parseChartInput(inputPayload.chartB, "chartB", flags);
|
|
990
|
-
const { getSynastryChart, closeSwissEph, HouseSystem } = await import('./astrology/index.mjs');
|
|
991
|
-
try {
|
|
992
|
-
await initWasm();
|
|
993
|
-
} catch (err) {
|
|
994
|
-
exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
|
|
995
|
-
}
|
|
996
|
-
try {
|
|
997
|
-
const result = await getSynastryChart({
|
|
998
|
-
chartA: {
|
|
999
|
-
date: chartAInput.birthDate,
|
|
1000
|
-
latitude: chartAInput.latitude,
|
|
1001
|
-
longitude: chartAInput.longitude,
|
|
1002
|
-
houseSystem: chartAInput.houseSystemCode,
|
|
1003
|
-
timeZoneSettings: chartAInput.timeZoneSettings
|
|
1004
|
-
},
|
|
1005
|
-
chartB: {
|
|
1006
|
-
date: chartBInput.birthDate,
|
|
1007
|
-
latitude: chartBInput.latitude,
|
|
1008
|
-
longitude: chartBInput.longitude,
|
|
1009
|
-
houseSystem: chartBInput.houseSystemCode,
|
|
1010
|
-
timeZoneSettings: chartBInput.timeZoneSettings
|
|
1011
|
-
},
|
|
1012
|
-
aspectSpecs: inputPayload.aspectSpecs
|
|
1013
|
-
});
|
|
1014
|
-
if (isJsonMode(flags)) {
|
|
1015
|
-
outputJson({
|
|
1016
|
-
...result,
|
|
1017
|
-
input: {
|
|
1018
|
-
chartA: { date: chartAInput.dateStr, time: chartAInput.timeStr, lat: chartAInput.latitude, lon: chartAInput.longitude, houseSystem: chartAInput.houseSystem },
|
|
1019
|
-
chartB: { date: chartBInput.dateStr, time: chartBInput.timeStr, lat: chartBInput.latitude, lon: chartBInput.longitude, houseSystem: chartBInput.houseSystem }
|
|
1020
|
-
}
|
|
1021
|
-
}, flags);
|
|
1022
|
-
} else {
|
|
1023
|
-
console.log(`
|
|
1024
|
-
Synastry Chart
|
|
1025
|
-
`);
|
|
1026
|
-
console.log(` Chart A: ${chartAInput.dateStr} ${chartAInput.timeStr} (${chartAInput.latitude}, ${chartAInput.longitude})`);
|
|
1027
|
-
console.log(` Chart B: ${chartBInput.dateStr} ${chartBInput.timeStr} (${chartBInput.latitude}, ${chartBInput.longitude})`);
|
|
1028
|
-
console.log(`
|
|
1029
|
-
Cross-chart Aspects (${result.aspects.length}):
|
|
1030
|
-
`);
|
|
1031
|
-
for (const a of result.aspects) {
|
|
1032
|
-
console.log(` ${a.planetA.padEnd(14)} ${a.aspect.padEnd(12)} ${a.planetB.padEnd(14)} orb ${a.orb.toFixed(2)}\xB0`);
|
|
1033
|
-
}
|
|
1034
|
-
console.log();
|
|
1035
|
-
}
|
|
1036
|
-
} finally {
|
|
1037
|
-
closeSwissEph();
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
async function cmdAstrologyComposite(flags, inputPayload) {
|
|
1041
|
-
if (!inputPayload?.chartA || !inputPayload?.chartB) {
|
|
1042
|
-
exitWithError("MISSING_ARGUMENT", `Usage: kaabalah astrology:composite --input-json='{"chartA":{...},"chartB":{...}}'`, flags);
|
|
1043
|
-
}
|
|
1044
|
-
const chartAInput = parseChartInput(inputPayload.chartA, "chartA", flags);
|
|
1045
|
-
const chartBInput = parseChartInput(inputPayload.chartB, "chartB", flags);
|
|
1046
|
-
const { getCompositeChart, closeSwissEph, HouseSystem } = await import('./astrology/index.mjs');
|
|
1047
|
-
try {
|
|
1048
|
-
await initWasm();
|
|
1049
|
-
} catch (err) {
|
|
1050
|
-
exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
|
|
1051
|
-
}
|
|
1052
|
-
try {
|
|
1053
|
-
const result = await getCompositeChart({
|
|
1054
|
-
chartA: {
|
|
1055
|
-
date: chartAInput.birthDate,
|
|
1056
|
-
latitude: chartAInput.latitude,
|
|
1057
|
-
longitude: chartAInput.longitude,
|
|
1058
|
-
houseSystem: chartAInput.houseSystemCode,
|
|
1059
|
-
timeZoneSettings: chartAInput.timeZoneSettings
|
|
1060
|
-
},
|
|
1061
|
-
chartB: {
|
|
1062
|
-
date: chartBInput.birthDate,
|
|
1063
|
-
latitude: chartBInput.latitude,
|
|
1064
|
-
longitude: chartBInput.longitude,
|
|
1065
|
-
houseSystem: chartBInput.houseSystemCode,
|
|
1066
|
-
timeZoneSettings: chartBInput.timeZoneSettings
|
|
1067
|
-
},
|
|
1068
|
-
aspectSpecs: inputPayload.aspectSpecs
|
|
1069
|
-
});
|
|
1070
|
-
if (isJsonMode(flags)) {
|
|
1071
|
-
outputJson({
|
|
1072
|
-
...result,
|
|
1073
|
-
input: {
|
|
1074
|
-
chartA: { date: chartAInput.dateStr, time: chartAInput.timeStr, lat: chartAInput.latitude, lon: chartAInput.longitude, houseSystem: chartAInput.houseSystem },
|
|
1075
|
-
chartB: { date: chartBInput.dateStr, time: chartBInput.timeStr, lat: chartBInput.latitude, lon: chartBInput.longitude, houseSystem: chartBInput.houseSystem }
|
|
1076
|
-
}
|
|
1077
|
-
}, flags);
|
|
1078
|
-
} else {
|
|
1079
|
-
console.log(`
|
|
1080
|
-
Composite Chart (Midpoint Method)
|
|
1081
|
-
`);
|
|
1082
|
-
console.log(` Chart A: ${chartAInput.dateStr} ${chartAInput.timeStr} (${chartAInput.latitude}, ${chartAInput.longitude})`);
|
|
1083
|
-
console.log(` Chart B: ${chartBInput.dateStr} ${chartBInput.timeStr} (${chartBInput.latitude}, ${chartBInput.longitude})`);
|
|
1084
|
-
console.log(`
|
|
1085
|
-
Composite Planets:`);
|
|
1086
|
-
for (const [name, planet] of Object.entries(result.compositePlanets)) {
|
|
1087
|
-
const zp = planet.zodiacPosition;
|
|
1088
|
-
console.log(` ${name.padEnd(14)} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} House ${zp.house}`);
|
|
1089
|
-
}
|
|
1090
|
-
console.log(`
|
|
1091
|
-
Composite House Cusps:`);
|
|
1092
|
-
for (let i = 0; i < result.compositeHouses.length; i++) {
|
|
1093
|
-
const h = result.compositeHouses[i];
|
|
1094
|
-
console.log(` House ${String(i + 1).padStart(2)}: ${h.sign.padEnd(12)} ${h.traditionalFormat}`);
|
|
1095
|
-
}
|
|
1096
|
-
console.log(`
|
|
1097
|
-
Composite Aspects (${result.aspects.length}):
|
|
1098
|
-
`);
|
|
1099
|
-
for (const a of result.aspects) {
|
|
1100
|
-
console.log(` ${a.planetA.padEnd(14)} ${a.aspect.padEnd(12)} ${a.planetB.padEnd(14)} orb ${a.orb.toFixed(2)}\xB0`);
|
|
1101
|
-
}
|
|
1102
|
-
console.log();
|
|
1103
|
-
}
|
|
1104
|
-
} finally {
|
|
1105
|
-
closeSwissEph();
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
async function cmdAstrology(args, flags, inputPayload) {
|
|
1109
|
-
const dateStr = inputPayload?.date ?? args[0];
|
|
1110
|
-
if (!dateStr) {
|
|
1111
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah astrology <YYYY-MM-DD> [HH:MM] --lat=<N> --lon=<N>", flags);
|
|
1112
|
-
}
|
|
1113
|
-
parseDate(dateStr, flags);
|
|
1114
|
-
const timeStr = inputPayload?.time ?? args[1] ?? "12:00";
|
|
1115
|
-
const timeMatch = timeStr.match(/^(\d{1,2}):(\d{2})$/);
|
|
1116
|
-
if (!timeMatch) {
|
|
1117
|
-
exitWithError("INVALID_ARGUMENT", `Invalid time format: "${timeStr}". Use HH:MM format.`, flags);
|
|
1118
|
-
}
|
|
1119
|
-
const hour = parseInt(timeMatch[1], 10);
|
|
1120
|
-
const minute = parseInt(timeMatch[2], 10);
|
|
1121
|
-
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
|
1122
|
-
exitWithError("INVALID_ARGUMENT", `Invalid time: "${timeStr}". Hours 0-23, minutes 0-59.`, flags);
|
|
1123
|
-
}
|
|
1124
|
-
let latitude;
|
|
1125
|
-
let longitude;
|
|
1126
|
-
let resolvedLocation;
|
|
1127
|
-
const locationStr = inputPayload?.location ?? getFlagString(flags, "location");
|
|
1128
|
-
const latFlag = inputPayload?.lat != null ? Number(inputPayload.lat) : getFlagNumber(flags, "lat");
|
|
1129
|
-
const lonFlag = inputPayload?.lon != null ? Number(inputPayload.lon) : getFlagNumber(flags, "lon");
|
|
1130
|
-
if (latFlag != null && lonFlag != null) {
|
|
1131
|
-
latitude = latFlag;
|
|
1132
|
-
longitude = lonFlag;
|
|
1133
|
-
} else if (locationStr) {
|
|
1134
|
-
const geo = await geocodeLocation(locationStr, flags);
|
|
1135
|
-
latitude = geo.latitude;
|
|
1136
|
-
longitude = geo.longitude;
|
|
1137
|
-
resolvedLocation = geo.formattedAddress;
|
|
1138
|
-
} else {
|
|
1139
|
-
exitWithError(
|
|
1140
|
-
"MISSING_ARGUMENT",
|
|
1141
|
-
'Location is required. Use --lat=<N> --lon=<N> or --location="City, Country" (requires GOOGLE_MAPS_API_KEY).',
|
|
1142
|
-
flags
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
if (latitude < -90 || latitude > 90) {
|
|
1146
|
-
exitWithError("INVALID_ARGUMENT", `Latitude must be between -90 and 90, got ${latitude}.`, flags);
|
|
1147
|
-
}
|
|
1148
|
-
if (longitude < -180 || longitude > 180) {
|
|
1149
|
-
exitWithError("INVALID_ARGUMENT", `Longitude must be between -180 and 180, got ${longitude}.`, flags);
|
|
1150
|
-
}
|
|
1151
|
-
const houseSystemStr = inputPayload?.houseSystem ?? getFlagString(flags, "house-system") ?? "placidus";
|
|
1152
|
-
const houseSystemCode = HOUSE_SYSTEM_MAP[houseSystemStr.toLowerCase()];
|
|
1153
|
-
if (!houseSystemCode) {
|
|
1154
|
-
exitWithError(
|
|
1155
|
-
"INVALID_ARGUMENT",
|
|
1156
|
-
`Unknown house system: "${houseSystemStr}". Valid: ${Object.keys(HOUSE_SYSTEM_MAP).join(", ")}`,
|
|
1157
|
-
flags
|
|
1158
|
-
);
|
|
1159
|
-
}
|
|
1160
|
-
const timezoneStr = inputPayload?.timezone ?? getFlagString(flags, "timezone");
|
|
1161
|
-
const dateParts = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
1162
|
-
const birthDate = new Date(
|
|
1163
|
-
parseInt(dateParts[1], 10),
|
|
1164
|
-
parseInt(dateParts[2], 10) - 1,
|
|
1165
|
-
parseInt(dateParts[3], 10),
|
|
1166
|
-
hour,
|
|
1167
|
-
minute,
|
|
1168
|
-
0
|
|
1169
|
-
);
|
|
1170
|
-
const path = __require("path");
|
|
1171
|
-
const { getSwissEph, closeSwissEph, getBirthChart, HouseSystem } = await import('./astrology/index.mjs');
|
|
1172
|
-
const wasmPath = path.resolve(__dirname, "../wasm/build/swisseph.node.wasm");
|
|
1173
|
-
const ephePath = path.resolve(__dirname, "../ephe");
|
|
1174
|
-
try {
|
|
1175
|
-
await getSwissEph({ wasmPath, ephePath });
|
|
1176
|
-
} catch (err) {
|
|
1177
|
-
exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
|
|
1178
|
-
}
|
|
1179
|
-
try {
|
|
1180
|
-
const timeZoneSettings = {};
|
|
1181
|
-
if (timezoneStr) {
|
|
1182
|
-
timeZoneSettings.timeZone = timezoneStr;
|
|
1183
|
-
} else {
|
|
1184
|
-
timeZoneSettings.autoTimeZone = true;
|
|
1185
|
-
}
|
|
1186
|
-
const chart = await getBirthChart({
|
|
1187
|
-
date: birthDate,
|
|
1188
|
-
latitude,
|
|
1189
|
-
longitude,
|
|
1190
|
-
houseSystem: houseSystemCode,
|
|
1191
|
-
timeZoneSettings
|
|
1192
|
-
});
|
|
1193
|
-
if (isJsonMode(flags)) {
|
|
1194
|
-
const result = { ...chart };
|
|
1195
|
-
if (resolvedLocation) {
|
|
1196
|
-
result.resolvedLocation = resolvedLocation;
|
|
1197
|
-
}
|
|
1198
|
-
result.input = {
|
|
1199
|
-
date: dateStr,
|
|
1200
|
-
time: timeStr,
|
|
1201
|
-
latitude,
|
|
1202
|
-
longitude,
|
|
1203
|
-
houseSystem: houseSystemStr,
|
|
1204
|
-
timezone: timezoneStr ?? "auto"
|
|
1205
|
-
};
|
|
1206
|
-
outputJson(result, flags);
|
|
1207
|
-
} else {
|
|
1208
|
-
console.log(`
|
|
1209
|
-
Birth Chart: ${dateStr} ${timeStr}
|
|
1210
|
-
`);
|
|
1211
|
-
if (resolvedLocation) {
|
|
1212
|
-
console.log(` Location: ${resolvedLocation}`);
|
|
1213
|
-
}
|
|
1214
|
-
console.log(` Coordinates: ${latitude.toFixed(4)}, ${longitude.toFixed(4)}`);
|
|
1215
|
-
console.log(` House System: ${houseSystemStr}`);
|
|
1216
|
-
console.log(` UTC Date: ${chart.dateUtc.toISOString()}`);
|
|
1217
|
-
console.log(`
|
|
1218
|
-
Planets:`);
|
|
1219
|
-
for (const [name, planet] of Object.entries(chart.planets)) {
|
|
1220
|
-
const zp = planet.zodiacPosition;
|
|
1221
|
-
console.log(` ${name.padEnd(14)} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} House ${zp.house}`);
|
|
1222
|
-
}
|
|
1223
|
-
console.log(`
|
|
1224
|
-
Houses:`);
|
|
1225
|
-
console.log(` Ascendant: ${chart.houses.ascendant.sign} ${chart.houses.ascendant.traditionalFormat}`);
|
|
1226
|
-
console.log(` Midheaven: ${chart.houses.mc.sign} ${chart.houses.mc.traditionalFormat}`);
|
|
1227
|
-
console.log(` Descendant: ${chart.houses.dc.sign} ${chart.houses.dc.traditionalFormat}`);
|
|
1228
|
-
console.log(` IC: ${chart.houses.ic.sign} ${chart.houses.ic.traditionalFormat}`);
|
|
1229
|
-
console.log(`
|
|
1230
|
-
House Cusps:`);
|
|
1231
|
-
for (let i = 0; i < chart.houses.houses.length; i++) {
|
|
1232
|
-
const h = chart.houses.houses[i];
|
|
1233
|
-
console.log(` House ${String(i + 1).padStart(2)}: ${h.sign.padEnd(12)} ${h.traditionalFormat}`);
|
|
1234
|
-
}
|
|
1235
|
-
if (chart.nodes && Object.keys(chart.nodes).length > 0) {
|
|
1236
|
-
console.log(`
|
|
1237
|
-
Nodes:`);
|
|
1238
|
-
for (const [, node] of Object.entries(chart.nodes)) {
|
|
1239
|
-
console.log(` ${node.name.padEnd(18)} ${node.sign.padEnd(12)} ${node.traditionalFormat.padEnd(8)} House ${node.house}`);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
console.log();
|
|
1243
|
-
}
|
|
1244
|
-
} finally {
|
|
1245
|
-
closeSwissEph();
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
async function main() {
|
|
1249
|
-
const { args, flags } = parseArgs(process.argv);
|
|
1250
|
-
if (getFlagBool(flags, "version")) {
|
|
1251
|
-
if (isJsonMode(flags)) {
|
|
1252
|
-
outputJson({ version: VERSION }, flags);
|
|
1253
|
-
} else {
|
|
1254
|
-
console.log(`kaabalah v${VERSION}`);
|
|
1255
|
-
}
|
|
1256
|
-
process.exit(0);
|
|
1257
|
-
}
|
|
1258
|
-
if (args.length === 0) {
|
|
1259
|
-
cmdHelp([], flags);
|
|
1260
|
-
process.exit(0);
|
|
1261
|
-
}
|
|
1262
|
-
const command = args[0];
|
|
1263
|
-
if (getFlagBool(flags, "help") && command !== "help") {
|
|
1264
|
-
cmdHelp([command], flags);
|
|
1265
|
-
process.exit(0);
|
|
1266
|
-
}
|
|
1267
|
-
const inputPayload = parseInputJson(flags);
|
|
1268
|
-
switch (command) {
|
|
1269
|
-
case "help":
|
|
1270
|
-
cmdHelp(args.slice(1), flags);
|
|
1271
|
-
break;
|
|
1272
|
-
case "gematria":
|
|
1273
|
-
if (!args[1] && !inputPayload?.text) {
|
|
1274
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah gematria <text>", flags);
|
|
1275
|
-
}
|
|
1276
|
-
cmdGematria(inputPayload?.text ?? args.slice(1).join(" "), flags);
|
|
1277
|
-
break;
|
|
1278
|
-
case "gematria:reverse":
|
|
1279
|
-
if (!args[1] && inputPayload?.targetSynthesis == null) {
|
|
1280
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah gematria:reverse <target-number>", flags);
|
|
1281
|
-
}
|
|
1282
|
-
cmdReverseGematria(args[1] ?? String(inputPayload?.targetSynthesis ?? ""), flags, inputPayload);
|
|
1283
|
-
break;
|
|
1284
|
-
case "numerology":
|
|
1285
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1286
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology <YYYY-MM-DD>", flags);
|
|
1287
|
-
}
|
|
1288
|
-
cmdNumerology(inputPayload?.date ?? args[1], flags);
|
|
1289
|
-
break;
|
|
1290
|
-
case "numerology:lifepath":
|
|
1291
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1292
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:lifepath <YYYY-MM-DD>", flags);
|
|
1293
|
-
}
|
|
1294
|
-
cmdLifePath(inputPayload?.date ?? args[1], flags);
|
|
1295
|
-
break;
|
|
1296
|
-
case "numerology:cycles":
|
|
1297
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1298
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:cycles <YYYY-MM-DD> [firstName]", flags);
|
|
1299
|
-
}
|
|
1300
|
-
cmdCycles(
|
|
1301
|
-
inputPayload?.date ?? args[1],
|
|
1302
|
-
inputPayload?.firstName ?? args[2],
|
|
1303
|
-
flags
|
|
1304
|
-
);
|
|
1305
|
-
break;
|
|
1306
|
-
case "numerology:challenges":
|
|
1307
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1308
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:challenges <YYYY-MM-DD>", flags);
|
|
1309
|
-
}
|
|
1310
|
-
cmdChallenges(inputPayload?.date ?? args[1], flags);
|
|
1311
|
-
break;
|
|
1312
|
-
case "numerology:fibonacci":
|
|
1313
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1314
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah numerology:fibonacci <YYYY-MM-DD>", flags);
|
|
1315
|
-
}
|
|
1316
|
-
cmdFibonacci(inputPayload?.date ?? args[1], flags);
|
|
1317
|
-
break;
|
|
1318
|
-
case "tarot":
|
|
1319
|
-
await cmdTarot(inputPayload?.count ?? args[1], flags);
|
|
1320
|
-
break;
|
|
1321
|
-
case "tarot:card":
|
|
1322
|
-
if (!args[1] && inputPayload?.query == null) {
|
|
1323
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah tarot:card <query>", flags);
|
|
1324
|
-
}
|
|
1325
|
-
cmdTarotCard((inputPayload?.query != null ? String(inputPayload.query) : void 0) ?? args.slice(1).join(" "), flags);
|
|
1326
|
-
break;
|
|
1327
|
-
case "tarot:spread": {
|
|
1328
|
-
const cardQueries = Array.isArray(inputPayload?.cards) ? inputPayload.cards.map(String) : args.slice(1);
|
|
1329
|
-
if (cardQueries.length === 0) {
|
|
1330
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah tarot:spread <card1> [card2] ...", flags);
|
|
1331
|
-
}
|
|
1332
|
-
cmdTarotSpread(cardQueries, flags);
|
|
1333
|
-
break;
|
|
1334
|
-
}
|
|
1335
|
-
case "ifa":
|
|
1336
|
-
if (!args[1] && !inputPayload?.date) {
|
|
1337
|
-
exitWithError("MISSING_ARGUMENT", "Usage: kaabalah ifa <YYYY-MM-DD>", flags);
|
|
1338
|
-
}
|
|
1339
|
-
cmdIfa(inputPayload?.date ?? args[1], flags);
|
|
1340
|
-
break;
|
|
1341
|
-
case "tree":
|
|
1342
|
-
cmdTree(flags);
|
|
1343
|
-
break;
|
|
1344
|
-
case "tree:node":
|
|
1345
|
-
if (!args[1] && !inputPayload?.id) {
|
|
1346
|
-
exitWithError("MISSING_ARGUMENT", 'Usage: kaabalah tree:node <id> (e.g. tree:node path:1, tree:node "tarotArkAnnu:The Magician")', flags);
|
|
1347
|
-
}
|
|
1348
|
-
cmdTreeNode(inputPayload?.id ?? args.slice(1).join(" "), flags);
|
|
1349
|
-
break;
|
|
1350
|
-
case "tree:types":
|
|
1351
|
-
cmdTreeTypes(flags);
|
|
1352
|
-
break;
|
|
1353
|
-
case "astrology":
|
|
1354
|
-
await cmdAstrology(args.slice(1), flags, inputPayload);
|
|
1355
|
-
break;
|
|
1356
|
-
case "astrology:synastry":
|
|
1357
|
-
await cmdAstrologySynastry(flags, inputPayload);
|
|
1358
|
-
break;
|
|
1359
|
-
case "astrology:composite":
|
|
1360
|
-
await cmdAstrologyComposite(flags, inputPayload);
|
|
1361
|
-
break;
|
|
1362
|
-
case "--version":
|
|
1363
|
-
if (isJsonMode(flags)) {
|
|
1364
|
-
outputJson({ version: VERSION }, flags);
|
|
1365
|
-
} else {
|
|
1366
|
-
console.log(`kaabalah v${VERSION}`);
|
|
1367
|
-
}
|
|
1368
|
-
break;
|
|
1369
|
-
default:
|
|
1370
|
-
exitWithError("UNKNOWN_COMMAND", `Unknown command: "${command}". Run "kaabalah help" for usage.`, flags);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
main().catch((err) => {
|
|
1374
|
-
const hasJson = process.argv.some((a) => a === "--json") || !process.stdout.isTTY;
|
|
1375
|
-
if (hasJson) {
|
|
1376
|
-
const out = JSON.stringify({
|
|
1377
|
-
error: true,
|
|
1378
|
-
code: "INTERNAL_ERROR",
|
|
1379
|
-
message: err instanceof Error ? err.message : String(err)
|
|
1380
|
-
});
|
|
1381
|
-
process.stdout.write(out + "\n");
|
|
1382
|
-
} else {
|
|
1383
|
-
console.error(err instanceof Error ? err.message : err);
|
|
1384
|
-
}
|
|
1385
|
-
process.exit(1);
|
|
1386
|
-
});
|
|
1387
|
-
//# sourceMappingURL=cli.mjs.map
|
|
1388
|
-
//# sourceMappingURL=cli.mjs.map
|