kaabalah 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -161,6 +161,28 @@ var COMMANDS = [
161
161
  "kaabalah astrology 1990-01-15 --lat=40.7128 --lon=-74.006 --json"
162
162
  ]
163
163
  },
164
+ {
165
+ name: "astrology:synastry",
166
+ description: "Calculate synastry (cross-chart aspects) between two birth charts",
167
+ args: [],
168
+ flags: [
169
+ { name: "house-system", type: "string", default: "placidus", description: "House system for both charts" }
170
+ ],
171
+ examples: [
172
+ `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`
173
+ ]
174
+ },
175
+ {
176
+ name: "astrology:composite",
177
+ description: "Calculate midpoint composite chart from two birth charts",
178
+ args: [],
179
+ flags: [
180
+ { name: "house-system", type: "string", default: "placidus", description: "House system for both charts" }
181
+ ],
182
+ examples: [
183
+ `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`
184
+ ]
185
+ },
164
186
  {
165
187
  name: "help",
166
188
  description: "Show help message",
@@ -905,6 +927,187 @@ Node types (${Object.keys(counts).length}):
905
927
  }
906
928
  console.log();
907
929
  }
930
+ function parseChartInput(input, label, flags) {
931
+ const dateStr = input.date;
932
+ if (!dateStr) {
933
+ exitWithError("MISSING_ARGUMENT", `${label}: "date" is required (YYYY-MM-DD).`, flags);
934
+ }
935
+ parseDate(dateStr, flags);
936
+ const timeStr = input.time ?? "12:00";
937
+ const timeMatch = timeStr.match(/^(\d{1,2}):(\d{2})$/);
938
+ if (!timeMatch) {
939
+ exitWithError("INVALID_ARGUMENT", `${label}: Invalid time format "${timeStr}". Use HH:MM.`, flags);
940
+ }
941
+ const hour = parseInt(timeMatch[1], 10);
942
+ const minute = parseInt(timeMatch[2], 10);
943
+ if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
944
+ exitWithError("INVALID_ARGUMENT", `${label}: Invalid time "${timeStr}". Hours 0-23, minutes 0-59.`, flags);
945
+ }
946
+ const latitude = input.lat != null ? Number(input.lat) : void 0;
947
+ const longitude = input.lon != null ? Number(input.lon) : void 0;
948
+ if (latitude == null || longitude == null) {
949
+ exitWithError("MISSING_ARGUMENT", `${label}: "lat" and "lon" are required.`, flags);
950
+ }
951
+ if (latitude < -90 || latitude > 90) {
952
+ exitWithError("INVALID_ARGUMENT", `${label}: Latitude must be between -90 and 90, got ${latitude}.`, flags);
953
+ }
954
+ if (longitude < -180 || longitude > 180) {
955
+ exitWithError("INVALID_ARGUMENT", `${label}: Longitude must be between -180 and 180, got ${longitude}.`, flags);
956
+ }
957
+ const houseSystem = input.houseSystem ?? "placidus";
958
+ const houseSystemCode = HOUSE_SYSTEM_MAP[houseSystem.toLowerCase()];
959
+ if (!houseSystemCode) {
960
+ exitWithError("INVALID_ARGUMENT", `${label}: Unknown house system "${houseSystem}". Valid: ${Object.keys(HOUSE_SYSTEM_MAP).join(", ")}`, flags);
961
+ }
962
+ const timezoneStr = input.timezone;
963
+ const timeZoneSettings = {};
964
+ if (timezoneStr) {
965
+ timeZoneSettings.timeZone = timezoneStr;
966
+ } else {
967
+ timeZoneSettings.autoTimeZone = true;
968
+ }
969
+ const dateParts = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
970
+ const birthDate = new Date(
971
+ parseInt(dateParts[1], 10),
972
+ parseInt(dateParts[2], 10) - 1,
973
+ parseInt(dateParts[3], 10),
974
+ hour,
975
+ minute,
976
+ 0
977
+ );
978
+ return { birthDate, latitude, longitude, houseSystem, houseSystemCode, timeZoneSettings, dateStr, timeStr };
979
+ }
980
+ async function initWasm() {
981
+ const path = chunkFM7WUVZV_js.__require("path");
982
+ const wasmPath = path.resolve(__dirname, "../wasm/build/swisseph.node.wasm");
983
+ const ephePath = path.resolve(__dirname, "../ephe");
984
+ const { getSwissEph } = await import('./astrology/index.js');
985
+ await getSwissEph({ wasmPath, ephePath });
986
+ }
987
+ async function cmdAstrologySynastry(flags, inputPayload) {
988
+ if (!inputPayload?.chartA || !inputPayload?.chartB) {
989
+ exitWithError("MISSING_ARGUMENT", `Usage: kaabalah astrology:synastry --input-json='{"chartA":{...},"chartB":{...}}'`, flags);
990
+ }
991
+ const chartAInput = parseChartInput(inputPayload.chartA, "chartA", flags);
992
+ const chartBInput = parseChartInput(inputPayload.chartB, "chartB", flags);
993
+ const { getSynastryChart, closeSwissEph, HouseSystem } = await import('./astrology/index.js');
994
+ try {
995
+ await initWasm();
996
+ } catch (err) {
997
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
998
+ }
999
+ try {
1000
+ const result = await getSynastryChart({
1001
+ chartA: {
1002
+ date: chartAInput.birthDate,
1003
+ latitude: chartAInput.latitude,
1004
+ longitude: chartAInput.longitude,
1005
+ houseSystem: chartAInput.houseSystemCode,
1006
+ timeZoneSettings: chartAInput.timeZoneSettings
1007
+ },
1008
+ chartB: {
1009
+ date: chartBInput.birthDate,
1010
+ latitude: chartBInput.latitude,
1011
+ longitude: chartBInput.longitude,
1012
+ houseSystem: chartBInput.houseSystemCode,
1013
+ timeZoneSettings: chartBInput.timeZoneSettings
1014
+ },
1015
+ aspectSpecs: inputPayload.aspectSpecs
1016
+ });
1017
+ if (isJsonMode(flags)) {
1018
+ outputJson({
1019
+ ...result,
1020
+ input: {
1021
+ chartA: { date: chartAInput.dateStr, time: chartAInput.timeStr, lat: chartAInput.latitude, lon: chartAInput.longitude, houseSystem: chartAInput.houseSystem },
1022
+ chartB: { date: chartBInput.dateStr, time: chartBInput.timeStr, lat: chartBInput.latitude, lon: chartBInput.longitude, houseSystem: chartBInput.houseSystem }
1023
+ }
1024
+ }, flags);
1025
+ } else {
1026
+ console.log(`
1027
+ Synastry Chart
1028
+ `);
1029
+ console.log(` Chart A: ${chartAInput.dateStr} ${chartAInput.timeStr} (${chartAInput.latitude}, ${chartAInput.longitude})`);
1030
+ console.log(` Chart B: ${chartBInput.dateStr} ${chartBInput.timeStr} (${chartBInput.latitude}, ${chartBInput.longitude})`);
1031
+ console.log(`
1032
+ Cross-chart Aspects (${result.aspects.length}):
1033
+ `);
1034
+ for (const a of result.aspects) {
1035
+ console.log(` ${a.planetA.padEnd(14)} ${a.aspect.padEnd(12)} ${a.planetB.padEnd(14)} orb ${a.orb.toFixed(2)}\xB0`);
1036
+ }
1037
+ console.log();
1038
+ }
1039
+ } finally {
1040
+ closeSwissEph();
1041
+ }
1042
+ }
1043
+ async function cmdAstrologyComposite(flags, inputPayload) {
1044
+ if (!inputPayload?.chartA || !inputPayload?.chartB) {
1045
+ exitWithError("MISSING_ARGUMENT", `Usage: kaabalah astrology:composite --input-json='{"chartA":{...},"chartB":{...}}'`, flags);
1046
+ }
1047
+ const chartAInput = parseChartInput(inputPayload.chartA, "chartA", flags);
1048
+ const chartBInput = parseChartInput(inputPayload.chartB, "chartB", flags);
1049
+ const { getCompositeChart, closeSwissEph, HouseSystem } = await import('./astrology/index.js');
1050
+ try {
1051
+ await initWasm();
1052
+ } catch (err) {
1053
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
1054
+ }
1055
+ try {
1056
+ const result = await getCompositeChart({
1057
+ chartA: {
1058
+ date: chartAInput.birthDate,
1059
+ latitude: chartAInput.latitude,
1060
+ longitude: chartAInput.longitude,
1061
+ houseSystem: chartAInput.houseSystemCode,
1062
+ timeZoneSettings: chartAInput.timeZoneSettings
1063
+ },
1064
+ chartB: {
1065
+ date: chartBInput.birthDate,
1066
+ latitude: chartBInput.latitude,
1067
+ longitude: chartBInput.longitude,
1068
+ houseSystem: chartBInput.houseSystemCode,
1069
+ timeZoneSettings: chartBInput.timeZoneSettings
1070
+ },
1071
+ aspectSpecs: inputPayload.aspectSpecs
1072
+ });
1073
+ if (isJsonMode(flags)) {
1074
+ outputJson({
1075
+ ...result,
1076
+ input: {
1077
+ chartA: { date: chartAInput.dateStr, time: chartAInput.timeStr, lat: chartAInput.latitude, lon: chartAInput.longitude, houseSystem: chartAInput.houseSystem },
1078
+ chartB: { date: chartBInput.dateStr, time: chartBInput.timeStr, lat: chartBInput.latitude, lon: chartBInput.longitude, houseSystem: chartBInput.houseSystem }
1079
+ }
1080
+ }, flags);
1081
+ } else {
1082
+ console.log(`
1083
+ Composite Chart (Midpoint Method)
1084
+ `);
1085
+ console.log(` Chart A: ${chartAInput.dateStr} ${chartAInput.timeStr} (${chartAInput.latitude}, ${chartAInput.longitude})`);
1086
+ console.log(` Chart B: ${chartBInput.dateStr} ${chartBInput.timeStr} (${chartBInput.latitude}, ${chartBInput.longitude})`);
1087
+ console.log(`
1088
+ Composite Planets:`);
1089
+ for (const [name, planet] of Object.entries(result.compositePlanets)) {
1090
+ const zp = planet.zodiacPosition;
1091
+ console.log(` ${name.padEnd(14)} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} House ${zp.house}`);
1092
+ }
1093
+ console.log(`
1094
+ Composite House Cusps:`);
1095
+ for (let i = 0; i < result.compositeHouses.length; i++) {
1096
+ const h = result.compositeHouses[i];
1097
+ console.log(` House ${String(i + 1).padStart(2)}: ${h.sign.padEnd(12)} ${h.traditionalFormat}`);
1098
+ }
1099
+ console.log(`
1100
+ Composite Aspects (${result.aspects.length}):
1101
+ `);
1102
+ for (const a of result.aspects) {
1103
+ console.log(` ${a.planetA.padEnd(14)} ${a.aspect.padEnd(12)} ${a.planetB.padEnd(14)} orb ${a.orb.toFixed(2)}\xB0`);
1104
+ }
1105
+ console.log();
1106
+ }
1107
+ } finally {
1108
+ closeSwissEph();
1109
+ }
1110
+ }
908
1111
  async function cmdAstrology(args, flags, inputPayload) {
909
1112
  const dateStr = inputPayload?.date ?? args[0];
910
1113
  if (!dateStr) {
@@ -1153,6 +1356,12 @@ async function main() {
1153
1356
  case "astrology":
1154
1357
  await cmdAstrology(args.slice(1), flags, inputPayload);
1155
1358
  break;
1359
+ case "astrology:synastry":
1360
+ await cmdAstrologySynastry(flags, inputPayload);
1361
+ break;
1362
+ case "astrology:composite":
1363
+ await cmdAstrologyComposite(flags, inputPayload);
1364
+ break;
1156
1365
  case "--version":
1157
1366
  if (isJsonMode(flags)) {
1158
1367
  outputJson({ version: VERSION }, flags);