kaabalah 6.12.0 → 6.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -20376,6 +20376,14 @@ var init_core = __esm({
20376
20376
  });
20377
20377
 
20378
20378
  // src/visual/tree.ts
20379
+ function getUnsupportedTreeSvgSystemMessage(system) {
20380
+ return `tree:svg is only supported for the Melkitzedeki system ('${TREE_SVG_SUPPORTED_SYSTEM}'); received '${system}'.`;
20381
+ }
20382
+ function assertTreeSvgSupportedSystem(system) {
20383
+ if (system !== TREE_SVG_SUPPORTED_SYSTEM) {
20384
+ throw new Error(getUnsupportedTreeSvgSystemMessage(system));
20385
+ }
20386
+ }
20379
20387
  function iridescentColorAt(t) {
20380
20388
  const frac = (t % 1 + 1) % 1;
20381
20389
  return interpolateColorStops(IRIDESCENT_STOPS, frac);
@@ -20574,6 +20582,7 @@ function getTreeRenderModel(options = {}) {
20574
20582
  }
20575
20583
  function generateTreeSvg(options = {}) {
20576
20584
  const system = options.system ?? "kaabalah";
20585
+ assertTreeSvgSupportedSystem(system);
20577
20586
  const daathLayer = options.daathLayer ?? "front";
20578
20587
  const tree = createTree({ system, parts: ["colors"] });
20579
20588
  const viewBox = normalizeViewBox3(options.viewBox);
@@ -21330,11 +21339,12 @@ function resolveDualToneFill(fill) {
21330
21339
  function escapeAttr3(value) {
21331
21340
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
21332
21341
  }
21333
- var TREE_SVG_DEFAULT_VIEWBOX, TREE_SPHERE_NAMES, CANONICAL_X_PERCENTAGES, CANONICAL_ROW_Y_PERCENTAGES, DEFAULT_SPHERE_RADIUS, DEFAULT_PATH_EDGE_WIDTH, DEFAULT_PATH_MAIN_WIDTH, DEFAULT_PATH_HIGHLIGHT_WIDTH, DEFAULT_SPHERE_HIT_RADIUS, DEFAULT_PATH_HIT_STROKE_WIDTH, MUTED_TARGET_COLOR, INNER_BORDER_SPHERE_NAMES, NAZAR_NACRE, NAZAR_IRIS, NAZAR_PUPIL, sphereId, pathId, SPLIT_GRADIENT_PATH_IDS, SPLIT_GRADIENT_BLEND, SPECIAL_SPHERE_PATH_COLORS, CHOKHMAH_SWEEP_SPAN, CHOKHMAH_SWEEP_SAMPLES, TREE_SPHERE_IDS, TREE_PATH_IDS, CANONICAL_SPHERE_PERCENTAGES, IRIDESCENT_STOPS, NACRE_STOPS;
21342
+ var TREE_SVG_SUPPORTED_SYSTEM, TREE_SVG_DEFAULT_VIEWBOX, TREE_SPHERE_NAMES, CANONICAL_X_PERCENTAGES, CANONICAL_ROW_Y_PERCENTAGES, DEFAULT_SPHERE_RADIUS, DEFAULT_PATH_EDGE_WIDTH, DEFAULT_PATH_MAIN_WIDTH, DEFAULT_PATH_HIGHLIGHT_WIDTH, DEFAULT_SPHERE_HIT_RADIUS, DEFAULT_PATH_HIT_STROKE_WIDTH, MUTED_TARGET_COLOR, INNER_BORDER_SPHERE_NAMES, NAZAR_NACRE, NAZAR_IRIS, NAZAR_PUPIL, sphereId, pathId, SPLIT_GRADIENT_PATH_IDS, SPLIT_GRADIENT_BLEND, SPECIAL_SPHERE_PATH_COLORS, CHOKHMAH_SWEEP_SPAN, CHOKHMAH_SWEEP_SAMPLES, TREE_SPHERE_IDS, TREE_PATH_IDS, CANONICAL_SPHERE_PERCENTAGES, IRIDESCENT_STOPS, NACRE_STOPS;
21334
21343
  var init_tree = __esm({
21335
21344
  "src/visual/tree.ts"() {
21336
21345
  "use strict";
21337
21346
  init_core();
21347
+ TREE_SVG_SUPPORTED_SYSTEM = "kaabalah";
21338
21348
  TREE_SVG_DEFAULT_VIEWBOX = {
21339
21349
  minX: 0,
21340
21350
  minY: 0,
@@ -21449,6 +21459,7 @@ __export(visual_exports, {
21449
21459
  TREE_SPHERE_IDS: () => TREE_SPHERE_IDS,
21450
21460
  TREE_SPHERE_NAMES: () => TREE_SPHERE_NAMES,
21451
21461
  TREE_SVG_DEFAULT_VIEWBOX: () => TREE_SVG_DEFAULT_VIEWBOX,
21462
+ TREE_SVG_SUPPORTED_SYSTEM: () => TREE_SVG_SUPPORTED_SYSTEM,
21452
21463
  ZODIAC_GLYPHS: () => ZODIAC_GLYPHS,
21453
21464
  ZODIAC_GLYPH_PRIMITIVES: () => ZODIAC_GLYPH_PRIMITIVES,
21454
21465
  generateArcheometerSvg: () => generateArcheometerSvg,
@@ -21461,6 +21472,7 @@ __export(visual_exports, {
21461
21472
  getRouteActivations: () => getRouteActivations,
21462
21473
  getTreeLayout: () => getTreeLayout,
21463
21474
  getTreeRenderModel: () => getTreeRenderModel,
21475
+ getUnsupportedTreeSvgSystemMessage: () => getUnsupportedTreeSvgSystemMessage,
21464
21476
  listAstroGlyphs: () => listAstroGlyphs
21465
21477
  });
21466
21478
  var init_visual = __esm({
@@ -23547,6 +23559,19 @@ function drawDefaultTarotSpread(spread, includeInverted, rng) {
23547
23559
  }
23548
23560
  return drawnCards;
23549
23561
  }
23562
+ function buildResolvedConsciousCard(slot, card, index, poolSize, includeInverted, rng) {
23563
+ const drawnCard = withSpreadCardOrientation(card, includeInverted, rng);
23564
+ return {
23565
+ slotKey: slot.slotKey,
23566
+ cardNumber: drawnCard.number,
23567
+ isInverted: drawnCard.isInverted ?? false,
23568
+ slot,
23569
+ card: drawnCard,
23570
+ index,
23571
+ poolSize,
23572
+ pos: `${index} of ${poolSize}`
23573
+ };
23574
+ }
23550
23575
  function drawEventReadingSpread(spread, includeInverted, rng, context) {
23551
23576
  const inquirerRule = spread.specialRules?.inquirerCard;
23552
23577
  if (!inquirerRule || !context?.inquirerGender) {
@@ -23776,11 +23801,81 @@ function drawTarotSpread(options) {
23776
23801
  cards: sortResolvedTarotSpreadCards(drawnCards)
23777
23802
  };
23778
23803
  }
23779
- var TAROT_SPREAD_MINOR_RANKS, EVENT_INNER_SLOT_KEYS, TAROT_CARD_BY_NUMBER, TAROT_SPREADS, TAROT_SPREAD_BY_ID;
23804
+ function drawConsciousTarotSpread(options) {
23805
+ const spread = TAROT_SPREAD_BY_ID.get(options.spreadId);
23806
+ if (!spread) {
23807
+ throw new Error(`Unknown tarot spread: ${options.spreadId}.`);
23808
+ }
23809
+ const slots = spread.slots.slice().sort((left, right) => left.order - right.order);
23810
+ if (options.indices.length !== slots.length) {
23811
+ throw new Error(
23812
+ `${spread.label} requires ${slots.length} conscious indices; received ${options.indices.length}.`
23813
+ );
23814
+ }
23815
+ const rng = options.rng ?? Math.random;
23816
+ const includeInverted = options.includeInverted ?? false;
23817
+ const drawnCards = slots.map((slot, slotIndex) => {
23818
+ const index = options.indices[slotIndex];
23819
+ const drawRule = getTarotSpreadRuleForDraw(slot);
23820
+ const pool = options.shuffledDeck.filter(
23821
+ (card) => matchesTarotSpreadConstraint(card, drawRule)
23822
+ );
23823
+ if (!Number.isInteger(index) || index < 1) {
23824
+ throw new Error(
23825
+ `${slot.label} conscious index must be a positive integer; received ${index}.`
23826
+ );
23827
+ }
23828
+ if (index > pool.length) {
23829
+ throw new TarotSpreadIndexOutOfPoolError(slot, index, pool.length);
23830
+ }
23831
+ return buildResolvedConsciousCard(
23832
+ slot,
23833
+ pool[index - 1],
23834
+ index,
23835
+ pool.length,
23836
+ includeInverted,
23837
+ rng
23838
+ );
23839
+ });
23840
+ const validation = validateTarotSpreadSelection({
23841
+ spreadId: spread.spreadId,
23842
+ cards: drawnCards.map((card) => ({
23843
+ slotKey: card.slotKey,
23844
+ cardNumber: card.cardNumber,
23845
+ isInverted: card.isInverted
23846
+ })),
23847
+ context: options.context
23848
+ });
23849
+ if (!validation.ok) {
23850
+ throw new Error(
23851
+ `Generated an invalid conscious tarot spread selection for ${spread.label}: ${validation.errors.map((error) => error.message).join(" ")}`
23852
+ );
23853
+ }
23854
+ return {
23855
+ spread: cloneSpreadDefinition(spread),
23856
+ deckId: options.deckId ?? "rider-waite",
23857
+ method: "conscious",
23858
+ context: options.context,
23859
+ cards: sortResolvedTarotSpreadCards(drawnCards)
23860
+ };
23861
+ }
23862
+ var TarotSpreadIndexOutOfPoolError, TAROT_SPREAD_MINOR_RANKS, EVENT_INNER_SLOT_KEYS, TAROT_CARD_BY_NUMBER, TAROT_SPREADS, TAROT_SPREAD_BY_ID;
23780
23863
  var init_spreads = __esm({
23781
23864
  "src/tarot/spreads.ts"() {
23782
23865
  "use strict";
23783
23866
  init_arkannus();
23867
+ TarotSpreadIndexOutOfPoolError = class extends Error {
23868
+ constructor(slot, index, poolSize) {
23869
+ super(
23870
+ `${slot.label} index ${index} exceeds the matching tarot pool size (${poolSize}).`
23871
+ );
23872
+ this.code = "INDEX_OUT_OF_POOL";
23873
+ this.name = "TarotSpreadIndexOutOfPoolError";
23874
+ this.slotKey = slot.slotKey;
23875
+ this.index = index;
23876
+ this.poolSize = poolSize;
23877
+ }
23878
+ };
23784
23879
  TAROT_SPREAD_MINOR_RANKS = [
23785
23880
  "ace",
23786
23881
  "2",
@@ -27053,7 +27148,7 @@ var import_config3 = require("dotenv/config");
27053
27148
  // package.json
27054
27149
  var package_default = {
27055
27150
  name: "kaabalah",
27056
- version: "6.12.0",
27151
+ version: "6.12.1",
27057
27152
  description: "The de-facto library for any esoteric calculations and tooling",
27058
27153
  engines: {
27059
27154
  node: ">=18.18.0"
@@ -27191,6 +27286,8 @@ var GLOBAL_FLAGS = [
27191
27286
  { name: "compact", type: "boolean", default: false, description: "Minified JSON output (no indentation)" },
27192
27287
  { name: "fields", type: "string", description: "Comma-separated dot-paths to filter JSON output (e.g. --fields=a.b,c.d)" },
27193
27288
  { name: "input-json", type: "string", description: "JSON string, or - to read a JSON object from stdin" },
27289
+ { name: "quiet", type: "boolean", default: false, description: "Suppress stderr diagnostics and notices" },
27290
+ { name: "silent", type: "boolean", default: false, description: "Alias for --quiet" },
27194
27291
  { name: "debug", type: "boolean", default: false, description: "Emit debug logs to stderr (same effect as DEBUG=kaabalah:*)" },
27195
27292
  { name: "trace", type: "boolean", default: false, description: "Print stack traces for unexpected fatal errors in human-readable mode" }
27196
27293
  ];
@@ -27270,7 +27367,9 @@ var COMMANDS = [
27270
27367
  args: [{ name: "count", type: "number", required: false, description: "Number of cards to draw (1-78, default: 3)" }],
27271
27368
  flags: [
27272
27369
  { name: "inverted", type: "boolean", default: false, description: "Include inverted cards" },
27273
- { name: "shuffle-count", type: "number", default: 7, description: "Number of times to shuffle the deck" }
27370
+ { name: "shuffle-count", type: "number", default: 7, description: "Number of times to shuffle the deck" },
27371
+ { name: "deck", type: "string", description: "Deck for image/description: papus_pt, papus, mythic, egyptian, rider-waite" },
27372
+ { name: "include-fields", type: "string", description: "Comma-separated legacy card fields to include with --deck (papus, egyptian)" }
27274
27373
  ],
27275
27374
  examples: ["kaabalah tarot 5 --inverted", "kaabalah tarot --json"]
27276
27375
  },
@@ -27280,7 +27379,8 @@ var COMMANDS = [
27280
27379
  args: [{ name: "query", type: "string", required: true, description: "Card number (1-78) or name (e.g. 'The Chariot', 'Two of Cups')" }],
27281
27380
  flags: [
27282
27381
  { name: "deck", type: "string", description: "Deck for image/description: papus_pt, papus, mythic, egyptian, rider-waite" },
27283
- { name: "decks", type: "boolean", description: "List available decks" }
27382
+ { name: "decks", type: "boolean", description: "List available decks" },
27383
+ { name: "include-fields", type: "string", description: "Comma-separated legacy card fields to include with --deck (papus, egyptian)" }
27284
27384
  ],
27285
27385
  examples: [
27286
27386
  "kaabalah tarot:card 7",
@@ -27295,7 +27395,14 @@ var COMMANDS = [
27295
27395
  args: [{ name: "cards", type: "string", required: false, description: "Card names or numbers, space-separated (quote multi-word names)" }],
27296
27396
  flags: [
27297
27397
  { name: "list", type: "boolean", default: false, description: "List built-in spread IDs and requirements" },
27398
+ { name: "verbose", type: "boolean", default: false, description: "Include full spread slot definitions with --list" },
27399
+ { name: "describe", type: "boolean", default: false, description: "Describe a spread schema without drawing cards" },
27298
27400
  { name: "spread-id", type: "string", description: "Draw a built-in spread by ID (e.g. quick-insight, celtic-cross, event-reading)" },
27401
+ { name: "method", type: "string", description: "Spread draw method: random or conscious" },
27402
+ { name: "indices", type: "string", description: "Comma-separated 1-based pool indices for --method=conscious" },
27403
+ { name: "deck", type: "string", description: "Deck for image/description: papus_pt, papus, mythic, egyptian, rider-waite" },
27404
+ { name: "shuffle-count", type: "number", default: 7, description: "Number of times to shuffle the deck for conscious spreads" },
27405
+ { name: "include-fields", type: "string", description: "Comma-separated legacy card fields to include with --deck (papus, egyptian)" },
27299
27406
  { name: "inverted", type: "boolean", default: false, description: "Include inverted cards when drawing a named spread" },
27300
27407
  { name: "inquirer-gender", type: "string", description: 'Required by event-reading; must be "man" or "woman"' }
27301
27408
  ],
@@ -27804,6 +27911,25 @@ function debugLog(namespace, message, details) {
27804
27911
  );
27805
27912
  }
27806
27913
 
27914
+ // src/cli/runtime/quiet.ts
27915
+ var originalStderrWrite = null;
27916
+ function isQuietMode(flags) {
27917
+ return flags.quiet === true || flags.silent === true;
27918
+ }
27919
+ function configureQuietRuntime(flags = {}) {
27920
+ if (isQuietMode(flags)) {
27921
+ if (!originalStderrWrite) {
27922
+ originalStderrWrite = process.stderr.write.bind(process.stderr);
27923
+ process.stderr.write = () => true;
27924
+ }
27925
+ return;
27926
+ }
27927
+ if (originalStderrWrite) {
27928
+ process.stderr.write = originalStderrWrite;
27929
+ originalStderrWrite = null;
27930
+ }
27931
+ }
27932
+
27807
27933
  // src/cli/runtime/args.ts
27808
27934
  var CliParseError = class extends Error {
27809
27935
  constructor(message, flags) {
@@ -27904,6 +28030,14 @@ function getFallbackFlags(argv) {
27904
28030
  flags.debug = true;
27905
28031
  continue;
27906
28032
  }
28033
+ if (arg === "--quiet") {
28034
+ flags.quiet = true;
28035
+ continue;
28036
+ }
28037
+ if (arg === "--silent") {
28038
+ flags.silent = true;
28039
+ continue;
28040
+ }
27907
28041
  if (arg === "--trace") {
27908
28042
  flags.trace = true;
27909
28043
  continue;
@@ -27948,6 +28082,7 @@ function parseArgs(argv) {
27948
28082
  const flags = applyJsonDefaults({ ...parsed.values });
27949
28083
  const args = parsed.positionals;
27950
28084
  const usedOptions = parsed.tokens.filter((token) => token.kind === "option").map((token) => token.name);
28085
+ configureQuietRuntime(flags);
27951
28086
  configureDebugRuntime(flags);
27952
28087
  debugLog("parser", "Parsed CLI arguments.", {
27953
28088
  argv: describeArgvForDebug(argv),
@@ -27967,6 +28102,7 @@ function parseArgs(argv) {
27967
28102
  throw err;
27968
28103
  }
27969
28104
  const fallbackFlags = getFallbackFlags(argv);
28105
+ configureQuietRuntime(fallbackFlags);
27970
28106
  configureDebugRuntime(fallbackFlags);
27971
28107
  debugLog("parser", "Argument parsing failed.", {
27972
28108
  argv: describeArgvForDebug(argv),
@@ -28371,6 +28507,7 @@ function exitWithError(code, message, flags) {
28371
28507
  }
28372
28508
  function handleFatalError(err, argv) {
28373
28509
  const flags = getFallbackFlags(argv);
28510
+ configureQuietRuntime(flags);
28374
28511
  configureDebugRuntime(flags);
28375
28512
  if (isCliSignalError(err)) {
28376
28513
  debugLog("signals", `Exiting after ${err.signalName}.`);
@@ -30545,6 +30682,25 @@ function summarizeTarotSpreads() {
30545
30682
  contextRequirements: spread.contextRequirements ?? []
30546
30683
  }));
30547
30684
  }
30685
+ function describeTarotSpread(spread) {
30686
+ return {
30687
+ spreadId: spread.spreadId,
30688
+ label: spread.label,
30689
+ description: spread.description,
30690
+ contextRequirements: spread.contextRequirements ?? [],
30691
+ slots: spread.slots.slice().sort((left, right) => left.order - right.order).map((slot) => ({
30692
+ slotKey: slot.slotKey,
30693
+ label: slot.label,
30694
+ order: slot.order,
30695
+ minCards: slot.minCards,
30696
+ maxCards: slot.maxCards,
30697
+ validationRules: slot.validationRules,
30698
+ manualSelectionRules: slot.manualSelectionRules,
30699
+ drawRules: slot.drawRules,
30700
+ metadata: slot.metadata
30701
+ }))
30702
+ };
30703
+ }
30548
30704
  function findCardsByQuery(query) {
30549
30705
  const num = Number.parseInt(query, 10);
30550
30706
  if (!Number.isNaN(num)) {
@@ -30610,7 +30766,28 @@ function getRequestedDeckId(flags) {
30610
30766
  }
30611
30767
  return deckId;
30612
30768
  }
30613
- function enrichCardWithDeck(card, deckId, flags) {
30769
+ function getRequestedLegacyFields(flags) {
30770
+ const raw = getFlagString(flags, "include-fields");
30771
+ const fields = /* @__PURE__ */ new Set();
30772
+ if (!raw) {
30773
+ return fields;
30774
+ }
30775
+ for (const field of raw.split(",").map((value) => value.trim()).filter(Boolean)) {
30776
+ if (field !== "papus" && field !== "egyptian") {
30777
+ exitWithError(
30778
+ "INVALID_ARGUMENT",
30779
+ `Unknown tarot include field "${field}". Valid: papus, egyptian.`,
30780
+ flags
30781
+ );
30782
+ }
30783
+ fields.add(field);
30784
+ }
30785
+ return fields;
30786
+ }
30787
+ function serializeTarotCard(card, deckId, flags) {
30788
+ if (!deckId) {
30789
+ return card;
30790
+ }
30614
30791
  const profile = getTarotCardProfile({ tarotCardName: card.tarotCard });
30615
30792
  if (!profile) {
30616
30793
  exitWithError(
@@ -30620,12 +30797,52 @@ function enrichCardWithDeck(card, deckId, flags) {
30620
30797
  );
30621
30798
  }
30622
30799
  const representation = profile.availableDeckIds.includes(deckId) ? getTarotRepresentation({ tarotCardName: card.tarotCard }, deckId) : void 0;
30623
- return {
30624
- ...card,
30800
+ const legacyFields = getRequestedLegacyFields(flags);
30801
+ const serialized = {
30802
+ number: card.number,
30803
+ tarotCard: card.tarotCard,
30804
+ tarotCardFilename: card.tarotCardFilename,
30805
+ meaning: card.meaning,
30806
+ type: card.type,
30807
+ deck: deckId,
30808
+ suit: card.suit,
30809
+ isInverted: card.isInverted,
30625
30810
  deckId,
30626
30811
  imageUrl: representation?.imageUrl ?? null,
30627
30812
  description: profile.descriptionsByDeck[deckId]
30628
30813
  };
30814
+ if (legacyFields.has("egyptian") && card.egyptianCardName) {
30815
+ serialized.egyptianCardName = card.egyptianCardName;
30816
+ }
30817
+ if (legacyFields.has("papus") && card.papusMeaning) {
30818
+ serialized.papusMeaning = card.papusMeaning;
30819
+ }
30820
+ return serialized;
30821
+ }
30822
+ function serializeSpreadCard(spreadCard, deckId, flags) {
30823
+ return {
30824
+ ...spreadCard,
30825
+ card: serializeTarotCard(spreadCard.card, deckId, flags)
30826
+ };
30827
+ }
30828
+ function parseConsciousIndices(flags) {
30829
+ const raw = getFlagString(flags, "indices");
30830
+ if (!raw) {
30831
+ exitWithError(
30832
+ "MISSING_ARGUMENT",
30833
+ "--method=conscious requires --indices=<n1,n2,...>.",
30834
+ flags
30835
+ );
30836
+ }
30837
+ const indices = raw.split(",").map((value) => Number.parseInt(value.trim(), 10));
30838
+ if (indices.some((index) => !Number.isInteger(index) || index < 1)) {
30839
+ exitWithError(
30840
+ "INVALID_ARGUMENT",
30841
+ "--indices must contain positive 1-based integers.",
30842
+ flags
30843
+ );
30844
+ }
30845
+ return indices;
30629
30846
  }
30630
30847
  async function cmdTarot(countStr, flags) {
30631
30848
  const count = countStr ? Number.parseInt(countStr, 10) : 3;
@@ -30634,6 +30851,7 @@ async function cmdTarot(countStr, flags) {
30634
30851
  }
30635
30852
  const shuffleCount = getFlagNumber(flags, "shuffle-count") ?? 7;
30636
30853
  const shuffleDelay = isJsonMode(flags) ? 0 : 300;
30854
+ const deckId = getRequestedDeckId(flags);
30637
30855
  const deck = await shuffleTarotDeck(
30638
30856
  ARKANNUS,
30639
30857
  getFlagBool(flags, "inverted"),
@@ -30641,8 +30859,9 @@ async function cmdTarot(countStr, flags) {
30641
30859
  shuffleDelay
30642
30860
  );
30643
30861
  const drawn = deck.slice(0, count);
30862
+ const outputCards = deckId ? drawn.map((card) => serializeTarotCard(card, deckId, flags)) : drawn;
30644
30863
  if (isJsonMode(flags)) {
30645
- outputJson(drawn, flags);
30864
+ outputJson(outputCards, flags);
30646
30865
  return;
30647
30866
  }
30648
30867
  console.log(`
@@ -30671,7 +30890,7 @@ function cmdTarotCard(query, flags) {
30671
30890
  exitWithError("CARD_NOT_FOUND", `No card found for "${query}". Use a number (1-78) or card name.`, flags);
30672
30891
  }
30673
30892
  const deckId = getRequestedDeckId(flags);
30674
- const outputCards = deckId ? cards.map((card) => enrichCardWithDeck(card, deckId, flags)) : cards;
30893
+ const outputCards = deckId ? cards.map((card) => serializeTarotCard(card, deckId, flags)) : cards;
30675
30894
  if (isJsonMode(flags)) {
30676
30895
  outputJson(outputCards.length === 1 ? outputCards[0] : outputCards, flags);
30677
30896
  return;
@@ -30715,7 +30934,7 @@ ${result.spread.label}`);
30715
30934
  }
30716
30935
  console.log();
30717
30936
  }
30718
- function cmdTarotNamedSpread(spreadId, flags, options) {
30937
+ async function cmdTarotNamedSpread(spreadId, flags, options) {
30719
30938
  const spread = getTarotSpread(spreadId);
30720
30939
  if (!spread) {
30721
30940
  exitWithError("INVALID_ARGUMENT", `Unknown tarot spread: ${spreadId}.`, flags);
@@ -30729,32 +30948,59 @@ function cmdTarotNamedSpread(spreadId, flags, options) {
30729
30948
  flags
30730
30949
  );
30731
30950
  }
30951
+ const deckId = getRequestedDeckId(flags);
30952
+ const method = getFlagString(flags, "method") ?? "random";
30953
+ if (method !== "random" && method !== "conscious") {
30954
+ exitWithError("INVALID_ARGUMENT", 'Tarot spread method must be "random" or "conscious".', flags);
30955
+ }
30732
30956
  try {
30733
- const result = drawTarotSpread({
30957
+ const shuffledDeck = method === "conscious" ? await shuffleTarotDeck(
30958
+ ARKANNUS,
30959
+ false,
30960
+ getFlagNumber(flags, "shuffle-count") ?? 7,
30961
+ isJsonMode(flags) ? 0 : 300
30962
+ ) : void 0;
30963
+ const result = method === "conscious" ? drawConsciousTarotSpread({
30734
30964
  spreadId: spread.spreadId,
30965
+ shuffledDeck: shuffledDeck ?? ARKANNUS,
30966
+ indices: parseConsciousIndices(flags),
30967
+ deckId,
30968
+ includeInverted: getFlagBool(flags, "inverted"),
30969
+ context
30970
+ }) : drawTarotSpread({
30971
+ spreadId: spread.spreadId,
30972
+ deckId,
30735
30973
  includeInverted: getFlagBool(flags, "inverted"),
30736
30974
  context
30737
30975
  });
30976
+ const outputResult = deckId ? {
30977
+ ...result,
30978
+ cards: result.cards.map((card) => serializeSpreadCard(card, deckId, flags))
30979
+ } : result;
30738
30980
  if (isJsonMode(flags)) {
30739
- outputJson(result, flags);
30981
+ outputJson(outputResult, flags);
30740
30982
  return;
30741
30983
  }
30742
30984
  printSpreadDraw(result);
30743
30985
  } catch (err) {
30986
+ if (err instanceof TarotSpreadIndexOutOfPoolError) {
30987
+ exitWithError("INDEX_OUT_OF_POOL", err.message, flags);
30988
+ }
30744
30989
  exitWithError("INVALID_ARGUMENT", err instanceof Error ? err.message : String(err), flags);
30745
30990
  }
30746
30991
  }
30747
- function cmdTarotSpread(cardQueries, flags, options = {}) {
30992
+ async function cmdTarotSpread(cardQueries, flags, options = {}) {
30748
30993
  if (getFlagBool(flags, "list")) {
30749
- const spreads = summarizeTarotSpreads();
30994
+ const spreads = getFlagBool(flags, "verbose") ? listTarotSpreads().map(describeTarotSpread) : summarizeTarotSpreads();
30750
30995
  if (isJsonMode(flags)) {
30751
30996
  outputJson(spreads, flags);
30752
30997
  return;
30753
30998
  }
30754
30999
  console.log("\nTarot spreads\n");
30755
31000
  for (const spread of spreads) {
31001
+ const slotCount = Array.isArray(spread.slots) ? spread.slots.length : spread.slots;
30756
31002
  const requirements = spread.contextRequirements.length > 0 ? ` | requires: ${spread.contextRequirements.join(", ")}` : "";
30757
- console.log(` ${spread.spreadId.padEnd(22)} ${spread.label} (${spread.slots} slots)${requirements}`);
31003
+ console.log(` ${spread.spreadId.padEnd(22)} ${spread.label} (${slotCount} slots)${requirements}`);
30758
31004
  if (spread.description) {
30759
31005
  console.log(` ${spread.description}`);
30760
31006
  }
@@ -30762,9 +31008,30 @@ function cmdTarotSpread(cardQueries, flags, options = {}) {
30762
31008
  console.log();
30763
31009
  return;
30764
31010
  }
31011
+ const describedSpreadId = getFlagBool(flags, "describe") ? cardQueries[0] ?? getFlagString(flags, "spread-id") ?? options.spreadId : void 0;
31012
+ if (describedSpreadId) {
31013
+ const spread = getTarotSpread(describedSpreadId);
31014
+ if (!spread) {
31015
+ exitWithError("INVALID_ARGUMENT", `Unknown tarot spread: ${describedSpreadId}.`, flags);
31016
+ }
31017
+ const describedSpread = describeTarotSpread(spread);
31018
+ if (isJsonMode(flags)) {
31019
+ outputJson(describedSpread, flags);
31020
+ return;
31021
+ }
31022
+ console.log(`
31023
+ ${describedSpread.label}`);
31024
+ console.log(`Spread: ${describedSpread.spreadId}`);
31025
+ for (const slot of describedSpread.slots) {
31026
+ const allowedTypes = slot.validationRules?.allowedTypes?.join(", ") ?? "any";
31027
+ console.log(` ${slot.order}. ${slot.label} (${slot.minCards}-${slot.maxCards}) | allowed: ${allowedTypes}`);
31028
+ }
31029
+ console.log();
31030
+ return;
31031
+ }
30765
31032
  const spreadId = getFlagString(flags, "spread-id") ?? options.spreadId;
30766
31033
  if (spreadId) {
30767
- cmdTarotNamedSpread(spreadId, flags, options);
31034
+ await cmdTarotNamedSpread(spreadId, flags, options);
30768
31035
  return;
30769
31036
  }
30770
31037
  const results = [];
@@ -31126,6 +31393,10 @@ function readActivations(flags) {
31126
31393
  return payload.map((entry, index) => validateActivationEntry(entry, index, flags));
31127
31394
  }
31128
31395
  function buildSvgOptions(flags) {
31396
+ const system = resolveSystem(flags);
31397
+ if (system !== TREE_SVG_SUPPORTED_SYSTEM) {
31398
+ exitWithError("UNSUPPORTED_SYSTEM", getUnsupportedTreeSvgSystemMessage(system), flags);
31399
+ }
31129
31400
  const palette = getFlagString(flags, "palette");
31130
31401
  if (palette && palette !== "color" && palette !== "monochrome") {
31131
31402
  exitWithError(
@@ -31143,7 +31414,7 @@ function buildSvgOptions(flags) {
31143
31414
  );
31144
31415
  }
31145
31416
  return {
31146
- system: resolveSystem(flags),
31417
+ system,
31147
31418
  width: getFlagString(flags, "width"),
31148
31419
  height: getFlagString(flags, "height"),
31149
31420
  background: getFlagString(flags, "background") ?? void 0,
@@ -31665,9 +31936,11 @@ async function runCli(argv) {
31665
31936
  if (isCliParseError(err)) {
31666
31937
  try {
31667
31938
  const resolved = resolveRuntimeConfig(err.flags);
31939
+ configureQuietRuntime(resolved.flags);
31668
31940
  exitWithError("INVALID_ARGUMENT", err.message, resolved.flags);
31669
31941
  } catch (configErr) {
31670
31942
  if (isCliConfigError(configErr)) {
31943
+ configureQuietRuntime(err.flags);
31671
31944
  exitWithError(configErr.code, configErr.message, err.flags);
31672
31945
  }
31673
31946
  throw configErr;
@@ -31679,8 +31952,10 @@ async function runCli(argv) {
31679
31952
  let flags = parsedArgs.flags;
31680
31953
  try {
31681
31954
  flags = resolveRuntimeConfig(flags).flags;
31955
+ configureQuietRuntime(flags);
31682
31956
  } catch (err) {
31683
31957
  if (isCliConfigError(err)) {
31958
+ configureQuietRuntime(flags);
31684
31959
  exitWithError(err.code, err.message, flags);
31685
31960
  }
31686
31961
  throw err;
@@ -31769,7 +32044,7 @@ async function runCli(argv) {
31769
32044
  if (cardQueries.length === 0 && !hasSpreadIdFlag && !spreadId && !shouldListSpreads) {
31770
32045
  exitWithError("MISSING_ARGUMENT", "Usage: kaabalah tarot:spread <card1> [card2] ...", flags);
31771
32046
  }
31772
- cmdTarotSpread(cardQueries, flags, {
32047
+ await cmdTarotSpread(cardQueries, flags, {
31773
32048
  spreadId,
31774
32049
  context: inputPayload?.context
31775
32050
  });