dsh-metaphysics 0.62.1 → 0.62.3

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +63 -1
  2. package/README.md +2 -2
  3. package/client.almanac.js +69 -65
  4. package/client.bazi.js +122 -118
  5. package/client.chenggu.js +69 -65
  6. package/client.convert.js +71 -67
  7. package/client.daliuren.js +119 -115
  8. package/client.fengshui.js +68 -64
  9. package/client.hepan.js +123 -119
  10. package/client.js +192 -192
  11. package/client.liuyao.js +121 -117
  12. package/client.mbti.js +69 -65
  13. package/client.name.js +69 -65
  14. package/client.numerology.js +68 -64
  15. package/client.qimen.js +124 -120
  16. package/client.star.js +69 -65
  17. package/client.tarot.js +120 -116
  18. package/client.trend.js +113 -109
  19. package/client.xiaoliuren.js +78 -74
  20. package/client.zeri.js +68 -64
  21. package/client.ziwei.js +123 -119
  22. package/docs/assets/verification-badge.svg +6 -6
  23. package/engine/almanac.js +10 -6
  24. package/engine/bazi.js +10 -6
  25. package/engine/bool.js +195 -0
  26. package/engine/calendar.js +10 -2
  27. package/engine/chenggu.js +2 -1
  28. package/engine/convert.js +2 -1
  29. package/engine/daliuren.js +2 -1
  30. package/engine/diff.js +5 -3
  31. package/engine/fengshui.js +33 -12
  32. package/engine/geju.js +16 -3
  33. package/engine/geo.js +2 -1
  34. package/engine/hepan.js +4 -3
  35. package/engine/index.js +202 -72
  36. package/engine/liuyao.js +24 -5
  37. package/engine/mbti.js +6 -1
  38. package/engine/meihua.js +21 -7
  39. package/engine/name.js +20 -12
  40. package/engine/random.js +17 -3
  41. package/engine/rectify.js +4 -3
  42. package/engine/tarot.js +22 -8
  43. package/engine/trace.js +2 -1
  44. package/engine/trend.js +7 -3
  45. package/engine/xiaoliuren.js +2 -1
  46. package/engine/ziwei.js +4 -3
  47. package/index.js +367 -42
  48. package/package.json +1 -1
  49. package//345/221/275/347/220/206/346/216/222/347/233/230.html +629 -160
@@ -362,7 +362,7 @@ h3::after{content:"";flex:1;height:1px;background:linear-gradient(90deg,var(--li
362
362
  <div class="wrap">
363
363
  <header>
364
364
  <div class="brand-row">
365
- <div class="brand"><span class="seal" aria-hidden="true">命</span><span class="brand-txt">命理排盘<span class="ver">v0.62.1</span><small>八字 · 紫微 · 六爻 · 梅花 · 六壬 · 奇门 · 合盘 · 塔罗 全部在本机计算</small></span></div>
365
+ <div class="brand"><span class="seal" aria-hidden="true">命</span><span class="brand-txt">命理排盘<span class="ver">v0.62.3</span><small>八字 · 紫微 · 六爻 · 梅花 · 六壬 · 奇门 · 合盘 · 塔罗 全部在本机计算</small></span></div>
366
366
  <div class="view-switch">
367
367
  <span class="hint">熟练了可以换回平铺</span>
368
368
  <span class="seg" role="group" aria-label="首屏样式">
@@ -653,7 +653,7 @@ h3::after{content:"";flex:1;height:1px;background:linear-gradient(90deg,var(--li
653
653
  <h3>对拍:把典籍当期望值</h3>
654
654
  <ul><li>六爻:京房八宫卦序与世应,64 卦全表;旬空六旬表</li><li>六壬:日干寄宫、中气换将;紫微:纳音定五行局、紫微天府相照</li><li>卦例:《增删卜易》9 条 +《卜筮正宗》128 条(93 成对 + 35 静卦),核本变卦 / 动爻数 / 卦宫 / 缺爻 / 旬空</li><li>奇门:20 个时辰 × 9 宫,核四柱 / 局数 / 值符 / 值使 / 星门神 / 天盘干</li></ul>
655
655
  <h3>工程验证</h3>
656
- <ul><li>测试:154 个测试文件 / 7894 条断言;七道闸(回归 · 断言基线 · 测试可失败自检 · HTML 注入面 · 工程约定 · 产物宿主形态 · 随机扫射)</li><li>可复现:seed / asOf 显式;同一输入同一输出</li><li>口径:晚子时、真太阳时、奇门三流派、闰月归月都可切换,并有字段级差异对照</li></ul>
656
+ <ul><li>测试:155 个测试文件 / 8218 条断言;七道闸(回归 · 断言基线 · 测试可失败自检 · HTML 注入面 · 工程约定 · 产物宿主形态 · 随机扫射)</li><li>可复现:seed / asOf 显式;同一输入同一输出</li><li>口径:晚子时、真太阳时、奇门三流派、闰月归月都可切换,并有字段级差异对照</li></ul>
657
657
 
658
658
  <h3>已知边界(不猜)</h3>
659
659
  <ul><li>六爻应期(具体哪天应验)不做;卦例只录动爻个数,不录爻位</li><li>财富/健康只给结构判断与档位,不给金额区间、不作诊断</li><li>紫微飞星已做「单一支化逐宫追到成环」与「三方四正 16 条按落宫归堆」,但都未叠大限流年四化、不折吉凶;八字交运日已能算到日/时,但未与第三方排盘案例批量对拍</li></ul>
@@ -683,6 +683,206 @@ const fail = (code, message) => {
683
683
  return { fail };
684
684
  })();
685
685
 
686
+ __mods.bool = (function () {
687
+ /**
688
+ * 读参数里的布尔值只走这里。
689
+ *
690
+ * 本文件是引擎入口的「参数口径归一」:布尔(bool / canonicalFlags)与
691
+ * 数字(canonicalNumbers)各一道,盘面读的、句柄编码的、指纹比的是同一份值。
692
+ *
693
+ * 直接写 `args.cross === true` 会把字符串 "true" 与数字 1 都当成 false——
694
+ * 模型经 JSON 传参时这三种写法都出现过,界面层归一后仍可能有旧句柄或直接调用
695
+ * 引擎的路径。defaultValue 决定「没给值」时的口径(如 lateZi 默认 true)。
696
+ */
697
+ function bool(value, defaultValue = false) {
698
+ if (value === undefined || value === null || value === '') return defaultValue;
699
+ if (value === true || value === 1 || value === 'true' || value === '1') return true;
700
+ if (value === false || value === 0 || value === 'false' || value === '0') return false;
701
+ return defaultValue;
702
+ }
703
+
704
+ /**
705
+ * 引擎入口的开关归一表:键 → 未给值时的默认口径。
706
+ * 只收 schema 里声明为 boolean 的参数;盘面读值与句柄编码必须看到同一份值。
707
+ */
708
+ const FLAG_DEFAULTS = {
709
+ lateZi: true, trueSolar: true, dst: true,
710
+ isLeapMonth: false, leapAsNext: false,
711
+ cross: false, hourUnknown: false, diff: false, shadow: false,
712
+ trace: false, rectify: false, withInterpret: false,
713
+ };
714
+
715
+ /** 合盘对方 / 第三方对象里的同名开关(见 hepan、shadowPerson):键 → 未给值时的默认口径。
716
+ * hourUnknown 的缺省是 false(合盘遇到 true 会拦),不能跟着 lateZi 等默认开。 */
717
+ const PARTNER_FLAGS = {
718
+ lateZi: true,
719
+ trueSolar: true,
720
+ dst: true,
721
+ hourUnknown: false,
722
+ };
723
+
724
+ function canonicalInto(source, defaults) {
725
+ let out = source;
726
+ const put = (key, value) => {
727
+ if (Object.is(source[key], value)) return;
728
+ if (out === source) out = { ...source };
729
+ out[key] = value;
730
+ };
731
+ const drop = (key) => {
732
+ if (out === source) out = { ...source };
733
+ delete out[key];
734
+ };
735
+ for (const [key, fallback] of Object.entries(defaults)) {
736
+ // 没给这个键就一个键都不加:凭空补 true 会改掉所有旧句柄的身份
737
+ if (source[key] === undefined) continue;
738
+ // 空串 / 空白串按「没给」处理(宿主 normalizeArgs 也是这么收的):
739
+ // 各体系的缺省并不相同——奇门 lateZi 缺省 same-day、紫微 lateZishi 缺省 current-day,
740
+ // 若把 "" 折成全局缺省 true,同一次输入走工具层和直调引擎会排出两张盘。
741
+ if (typeof source[key] === 'string' && source[key].trim() === '') { drop(key); continue; }
742
+ put(key, bool(source[key], fallback));
743
+ }
744
+ return out;
745
+ }
746
+
747
+ function canonicalPartner(person) {
748
+ if (!person || typeof person !== 'object' || Array.isArray(person)) return person;
749
+ let out = person;
750
+ for (const [key, fallback] of Object.entries(PARTNER_FLAGS)) {
751
+ if (person[key] === undefined) continue;
752
+ if (typeof person[key] === 'string' && person[key].trim() === '') {
753
+ if (out === person) out = { ...person };
754
+ delete out[key];
755
+ continue;
756
+ }
757
+ const v = bool(person[key], fallback);
758
+ if (Object.is(person[key], v)) continue;
759
+ if (out === person) out = { ...person };
760
+ out[key] = v;
761
+ }
762
+ return out;
763
+ }
764
+
765
+ /**
766
+ * 把 args 里的字符串布尔 / 数字布尔统一成真布尔,返回**新对象**(无改动时返回原对象)。
767
+ *
768
+ * 为什么要在入口做一次:0.62.x 的盘面读开关用 `!== false`(只认字面 false),
769
+ * 句柄却直接编码传进来的原文。于是 `trueSolar:"false"` 排出「开真太阳时」的盘,
770
+ * 句柄里却写着 false——同一张盘两个身份,影子盘对拍、深链回放、跨版本 diff 全跟着错。
771
+ * 现在读值已统一走 `bool()`,这道归一仍要在入口做:它保证句柄与指纹拿到的
772
+ * 也是同一份真布尔,而不只是「读的时候碰巧算出同一个结果」。
773
+ */
774
+ function canonicalFlags(args) {
775
+ if (!args || typeof args !== 'object') return args;
776
+ let out = canonicalInto(args, FLAG_DEFAULTS);
777
+ for (const key of ['partner', 'partner2']) {
778
+ const person = out[key];
779
+ const fixed = canonicalPartner(person);
780
+ if (fixed !== person) {
781
+ if (out === args) out = { ...args };
782
+ out[key] = fixed;
783
+ }
784
+ }
785
+ return out;
786
+ }
787
+
788
+ // ── 数字归一 ────────────────────────────────────────────────
789
+ // 只把「整串就是一个数」的字符串转成数字:count:"3" → 3、period:"9" → 9。
790
+ // "9运" / "十" / 空串原样留着,让各体系原有的范围校验报 E_INPUT,
791
+ // 而不是先变成 NaN 再以「没给」的身份混过去。
792
+
793
+ /** schema 里 type 为 number / integer 的顶层键(options 由工具层摊平到顶层) */
794
+ const NUMERIC_KEYS = [
795
+ 'hour', 'minute', 'longitude', 'verifyPast', 'seed',
796
+ 'days', 'lunarYear', 'lunarMonth', 'lunarDay',
797
+ 'num1', 'num2', 'num3', 'upper', 'lower', 'changing',
798
+ 'count', 'toAge', 'fortuneYear', 'period', 'limit',
799
+ 'sittingOffset', 'sittingDegree', 'facingOffset', 'facingDegree',
800
+ 'year', 'month', 'day',
801
+ ];
802
+
803
+ /** 数值数组:逐项转,任一项不是数字就整组不动,交给原有校验报错 */
804
+ const NUMERIC_ARRAY_KEYS = ['lines', 'rectifyHours', 'answers'];
805
+
806
+ /** 字形 → 笔画的映射:值也是数字(起名的 strokeOverrides / surnameStrokes) */
807
+ const NUMERIC_MAP_KEYS = ['strokeOverrides', 'surnameStrokes'];
808
+
809
+ // 与宿主 normalizeArgs 同一把尺:指数写法(1e3)与尾点(5.)都算「整串是一个数」。
810
+ // 收窄成十进制会把 seed:"1e3" 留在字符串态——randomOf 照样按 1000 出牌,句柄却记着
811
+ // "1e3",同一张盘两个身份,正是这刀要消掉的东西。
812
+ const NUMERIC_RE = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
813
+
814
+ function numericOf(value) {
815
+ if (typeof value !== 'string') return value;
816
+ const s = value.trim();
817
+ if (!NUMERIC_RE.test(s)) return value;
818
+ const n = Number(s);
819
+ return Number.isFinite(n) ? n : value;
820
+ }
821
+
822
+ function canonicalMap(obj) {
823
+ let changed = false;
824
+ const next = {};
825
+ for (const [k, v] of Object.entries(obj)) {
826
+ const n = v === null ? null : numericOf(v);
827
+ if (!Object.is(n, v)) changed = true;
828
+ next[k] = n;
829
+ }
830
+ return changed ? next : obj;
831
+ }
832
+
833
+ /**
834
+ * 把数字串统一成数字,返回**新对象**(无改动时返回原对象)。
835
+ *
836
+ * 为什么也要在入口做一刀:句柄直接编码参数原文,`count:"3"` 与 `count:3`
837
+ * 抽出同一副牌、却拿到两个句柄——影子盘对拍、深链回放会认成两张盘。
838
+ * 另有两处不只影响身份,是实打实的算错:
839
+ * * 风水 `period:"9"` 被 1–9 校验拒掉,报错里还写着「收到「9」」,看着像误报;
840
+ * * 起名 `strokeOverrides:{"秋":"9"}` 被 overridesOf 静默丢掉,五格退回字库笔画,
841
+ * 用户给的笔画根本没参与计算。
842
+ */
843
+ function canonicalNumbers(args) {
844
+ if (!args || typeof args !== 'object') return args;
845
+ let out = args;
846
+ const put = (key, value) => {
847
+ if (Object.is(args[key], value)) return;
848
+ if (out === args) out = { ...args };
849
+ out[key] = value;
850
+ };
851
+ for (const key of NUMERIC_KEYS) {
852
+ if (args[key] === undefined) continue;
853
+ // 空串 / 空白串按「没给」处理(与宿主 normalizeArgs 一致)。留着会变成另一条路:
854
+ // 梅花数字起卦 Number("") = 0、风水 period 直接报「收到「」」——同一份输入两种结果。
855
+ if (typeof args[key] === 'string' && args[key].trim() === '') {
856
+ if (out === args) out = { ...args };
857
+ delete out[key];
858
+ continue;
859
+ }
860
+ put(key, numericOf(args[key]));
861
+ }
862
+ for (const key of NUMERIC_ARRAY_KEYS) {
863
+ const v = args[key];
864
+ if (!Array.isArray(v)) continue;
865
+ let changed = false;
866
+ const next = v.map((x) => {
867
+ if (x === null) return null;
868
+ if (typeof x === 'string' && x.trim() === '') { changed = true; return undefined; }
869
+ const n = numericOf(x);
870
+ if (!Object.is(n, x)) changed = true;
871
+ return n;
872
+ });
873
+ if (changed) put(key, next);
874
+ }
875
+ for (const key of NUMERIC_MAP_KEYS) {
876
+ const v = args[key];
877
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue;
878
+ put(key, canonicalMap(v));
879
+ }
880
+ return out;
881
+ }
882
+
883
+ return { bool, FLAG_DEFAULTS, canonicalFlags, NUMERIC_KEYS, NUMERIC_ARRAY_KEYS, NUMERIC_MAP_KEYS, canonicalNumbers };
884
+ })();
885
+
686
886
  __mods.diff = (function () {
687
887
  // 口径差异:同一组参数在不同流派口径下排出的盘,逐字段比对
688
888
  //
@@ -692,6 +892,8 @@ __mods.diff = (function () {
692
892
  //
693
893
  // 只做结构化比对,不改动任何引擎的输出。
694
894
 
895
+ const { bool } = (__mods.bool || {});
896
+
695
897
  /** 比对时忽略的字段:文案、时间戳、口径回显、内部儒略日数字 */
696
898
  const IGNORE_KEYS = new Set([
697
899
  'summary', 'interpret', 'castAt', 'asOf', 'precision', 'disclaimer', 'note',
@@ -962,7 +1164,7 @@ const CALIBER_SWITCHES = {
962
1164
  key: 'lateZi',
963
1165
  title: '晚子时:23:00 后是否换日',
964
1166
  short: '晚子时',
965
- read: (a) => a.lateZi !== false,
1167
+ read: (a) => bool(a.lateZi, true),
966
1168
  alt: (v) => !v,
967
1169
  label: (v) => (v ? '换日' : '不换日'),
968
1170
  },
@@ -970,7 +1172,7 @@ const CALIBER_SWITCHES = {
970
1172
  key: 'trueSolar',
971
1173
  title: '真太阳时:是否按出生地经度修正',
972
1174
  short: '真太阳时',
973
- read: (a) => a.trueSolar !== false,
1175
+ read: (a) => bool(a.trueSolar, true),
974
1176
  alt: (v) => !v,
975
1177
  label: (v) => (v ? '修正' : '不修正'),
976
1178
  },
@@ -988,7 +1190,7 @@ const CALIBER_SWITCHES = {
988
1190
  key: 'trueSolar',
989
1191
  title: '真太阳时:是否按出生地经度修正',
990
1192
  short: '真太阳时',
991
- read: (a) => a.trueSolar !== false,
1193
+ read: (a) => bool(a.trueSolar, true),
992
1194
  alt: (v) => !v,
993
1195
  label: (v) => (v ? '修正' : '不修正'),
994
1196
  },
@@ -1536,6 +1738,7 @@ return { earthL };
1536
1738
  __mods.calendar = (function () {
1537
1739
  const { earthL } = (__mods['vsop-earth'] || {});
1538
1740
  const { createLru } = (__mods.lru || {});
1741
+ const { bool } = (__mods.bool || {});
1539
1742
  // 历法底座:儒略日、干支、二十四节气、真太阳时
1540
1743
  // 全部为纯函数,不依赖 DOM / Node API,Host 与 Client 可共用。
1541
1744
 
@@ -1682,7 +1885,14 @@ function deltaTSeconds(year) {
1682
1885
  return v0 + ((v1 - v0) * (year - y0)) / (y1 - y0);
1683
1886
  }
1684
1887
  }
1685
- return knots[knots.length - 1][1];
1888
+ // 2100 年后用 Morrison & Stephenson (2004) 抛物线外推:ΔT ≈ 32 × ((y − 1820)/100)² 秒。
1889
+ // 注意单位:括号里是「世纪」,不是年——写成 32×(y−1820)² 会在 2400 年给出 1076 万秒(约 124 天),
1890
+ // 把节气、朔望整体推后好几个月。这里以 2100 端点(110s)接续抛物线增长率,保证 2100→2101 连续:
1891
+ // 2101 约 111.8s、2200 约 321s、2400 约 936s。
1892
+ const [yLast, vLast] = knots[knots.length - 1];
1893
+ const uLast = (yLast - 1820) / 100;
1894
+ const u = (year - 1820) / 100;
1895
+ return vLast + 32 * (u * u - uLast * uLast);
1686
1896
  }
1687
1897
 
1688
1898
  // 1929 年元旦之前,中国历书按「北京地方平时」(116.4°E,UTC+7.7611)推算朔与中气;
@@ -1825,7 +2035,7 @@ function termYearList(year, jieOnly) {
1825
2035
  * @param {{jieOnly?: boolean}} [opts] jieOnly=true 时只返回十二节(default:false,含气)
1826
2036
  */
1827
2037
  function termWindow(year, opts = {}) {
1828
- const jieOnly = opts.jieOnly === true;
2038
+ const jieOnly = bool(opts.jieOnly);
1829
2039
  const cacheKey = jieOnly ? `${year}|jie` : year;
1830
2040
  const cached = TERM_WINDOW_CACHE.get(cacheKey);
1831
2041
  if (cached) return cached;
@@ -2059,6 +2269,7 @@ __mods.geo = (function () {
2059
2269
  // 坐标为近似值(±0.2°≈0.8 分钟时差),足够真太阳时使用。
2060
2270
  // 联网(Nominatim)是显式可选项:只有调用方传 online: true 才会把地址原文发出去,
2061
2271
  // 默认走内置表,不上传任何数据。
2272
+ const { bool } = (__mods.bool || {});
2062
2273
  const RAW = `
2063
2274
  北京 116.41 39.90;上海 121.47 31.23;天津 117.20 39.13;重庆 106.55 29.56
2064
2275
  广州 113.26 23.13;深圳 114.06 22.55;珠海 113.58 22.27;东莞 113.75 23.02;佛山 113.12 23.02
@@ -2286,7 +2497,7 @@ async function geocodeAddress(input, opts = {}) {
2286
2497
  const text = String(input || '').trim();
2287
2498
  if (!text) return local;
2288
2499
  // 默认离线:联网必须显式开启(会把出生地原文发给第三方)
2289
- const wantOnline = opts.online === true;
2500
+ const wantOnline = bool(opts.online);
2290
2501
  if (!wantOnline) return local;
2291
2502
  if (local && typeof local.lon === 'number' && !DETAIL.test(text)) return local;
2292
2503
  const remote = await onlineLookup(text, opts);
@@ -2328,22 +2539,36 @@ function mulberry32(seed) {
2328
2539
  };
2329
2540
  }
2330
2541
 
2542
+ // 与宿主 / bool.js 同一把尺:只认十进制(可带指数、尾点)。Number() 会把
2543
+ // "0x10"、false、[] 也变成有效数字,于是直接调引擎能排出盘、走工具层却被拒——
2544
+ // 同一份输入两种命运,正是句柄与复现最容易分叉的地方。
2545
+ const NUMERIC_TEXT = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
2546
+
2547
+ const seedNumber = (seed) => {
2548
+ if (typeof seed === 'number') return Number.isFinite(seed) ? seed : NaN;
2549
+ if (typeof seed === 'string') {
2550
+ const s = seed.trim();
2551
+ if (s !== '' && NUMERIC_TEXT.test(s)) return Number(s);
2552
+ }
2553
+ return NaN;
2554
+ };
2555
+
2331
2556
  /**
2332
2557
  * 从参数里取随机源:
2333
2558
  * - 没给 seed:沿用 Math.random(保持"真随机"的手感)
2334
- * - 给了数字或数字字符串:mulberry32(seed),可复现
2559
+ * - 给了数字或十进制数字串:mulberry32(seed),可复现
2335
2560
  * - 给了别的东西:调用方应当先报错,这里兜底回 Math.random
2336
2561
  */
2337
2562
  function randomOf(seed) {
2338
2563
  if (seed === undefined || seed === null || seed === '') return Math.random;
2339
- const n = Number(seed);
2564
+ const n = seedNumber(seed);
2340
2565
  return Number.isFinite(n) ? mulberry32(n) : Math.random;
2341
2566
  }
2342
2567
 
2343
2568
  /** 是否是一个可以接受的 seed */
2344
2569
  function isSeed(v) {
2345
2570
  if (v === undefined || v === null || v === '') return true;
2346
- return Number.isFinite(Number(v));
2571
+ return Number.isFinite(seedNumber(v));
2347
2572
  }
2348
2573
 
2349
2574
  return { mulberry32, randomOf, isSeed };
@@ -4786,7 +5011,7 @@ const GENERATES = { 木: '火', 火: '土', 土: '金', 金: '水', 水: '木' }
4786
5011
  const OVERCOMES = { 木: '土', 土: '水', 水: '火', 火: '金', 金: '木' };
4787
5012
  const HIDDEN = {
4788
5013
  子: ['癸'], 丑: ['己', '癸', '辛'], 寅: ['甲', '丙', '戊'], 卯: ['乙'],
4789
- 辰: ['戊', '乙', '癸'], 巳: ['丙', '戊', '庚'], 午: ['丁', '己'], 未: ['己', '丁', '乙'],
5014
+ 辰: ['戊', '乙', '癸'], 巳: ['丙', '庚', '戊'], 午: ['丁', '己'], 未: ['己', '丁', '乙'],
4790
5015
  申: ['庚', '壬', '戊'], 酉: ['辛'], 戌: ['戊', '辛', '丁'], 亥: ['壬', '甲'],
4791
5016
  };
4792
5017
  const HIDDEN_W = [1, 0.5, 0.3];
@@ -4877,10 +5102,23 @@ function monthPattern(pillars, dayStem, monthBranch) {
4877
5102
  w: HIDDEN_W[i] ?? 0.1,
4878
5103
  }));
4879
5104
  const others = ['year', 'month', 'hour'];
4880
- const exposedKey = others.find((k) => cands.some((c) => c.stem === pillars[k].stem));
4881
5105
  const base = cands[0];
5106
+ // 取格按「藏干位阶」定先后:本气透则取本气,本气不透再取中气、余气(子平通例)。
5107
+ // 不能按柱位「先遇上谁就用谁」——那样月干透出的中气会输给年干透出的余气,
5108
+ // 实测约 13% 的盘有两处以上不同藏干并透,其中七成以上会因此取错格局名。
5109
+ // 同一藏干多柱并透时,「月」优先报出(离月令最近)。
5110
+ let exposedKey = null;
5111
+ let use = null;
5112
+ for (const c of cands) {
5113
+ const hits = others.filter((k) => pillars[k].stem === c.stem);
5114
+ if (hits.length) {
5115
+ use = c;
5116
+ exposedKey = hits.includes('month') ? 'month' : hits[0];
5117
+ break;
5118
+ }
5119
+ }
4882
5120
  const hui = exposedKey ? null : huiCandidate(pillars, monthBranch, cands);
4883
- const use = exposedKey ? cands.find((c) => c.stem === pillars[exposedKey].stem) : (hui || base);
5121
+ if (!use) use = hui || base;
4884
5122
  const usedBy = exposedKey ? '透干' : (hui ? '会支' : '本气');
4885
5123
  const exposedPos = exposedKey ? { year: '年', month: '月', hour: '时' }[exposedKey] : null;
4886
5124
 
@@ -5317,18 +5555,22 @@ const { resolveAddress } = (__mods.geo || {});
5317
5555
  const { computeBaziShensha } = (__mods.shensha || {});
5318
5556
  const { assertCivil, assertShifted, daysInMonth } = (__mods.validate || {});
5319
5557
  const { applyDst } = (__mods.dst || {});
5558
+ const { bool } = (__mods.bool || {});
5320
5559
  const { nayinOf } = (__mods.nayin || {});
5321
5560
  const { SANHE } = (__mods.sanhe || {});
5322
5561
  const { analyzeBaziFrame, scoreLuck } = (__mods.geju || {});
5323
5562
 
5324
5563
  // 地支藏干(本气 / 中气 / 余气)
5564
+ // 巳的顺序是「丙庚戊」而不是「丙戊庚」:庚长生于巳,是中气;戊是辰月余气,排末位。
5565
+ // 本表与下面 RENYUAN_TABLE(巳月:戊 5 日 → 庚 9 日 → 丙 16 日)互为倒序,
5566
+ // 也与寅(甲丙戊)、申(庚壬戊)、亥(壬甲)的「长生=中气」写法一致。
5325
5567
  const HIDDEN_STEMS = {
5326
5568
  子: ['癸'],
5327
5569
  丑: ['己', '癸', '辛'],
5328
5570
  寅: ['甲', '丙', '戊'],
5329
5571
  卯: ['乙'],
5330
5572
  辰: ['戊', '乙', '癸'],
5331
- 巳: ['丙', '戊', '庚'],
5573
+ 巳: ['丙', '庚', '戊'],
5332
5574
  午: ['丁', '己'],
5333
5575
  未: ['己', '丁', '乙'],
5334
5576
  申: ['庚', '壬', '戊'],
@@ -5642,13 +5884,13 @@ function buildBazi(input) {
5642
5884
  let { year, month, day, hour = 0, minute = 0, gender = 'male' } = input;
5643
5885
  // 时辰未知:内部仍按「正午」跑完整条管线(大运、旺衰都要有个基准才能算),
5644
5886
  // 但对外一律不承认这个钟点——时柱置空、文本不出现具体时刻、精度降为按日。
5645
- const hourUnknown = input.hourUnknown === true;
5887
+ const hourUnknown = bool(input.hourUnknown);
5646
5888
  if (hourUnknown) { hour = 12; minute = 0; }
5647
- const lateZi = input.lateZi !== false;
5648
- const useTrueSolar = input.trueSolar !== false;
5889
+ const lateZi = bool(input.lateZi, true);
5890
+ const useTrueSolar = bool(input.trueSolar, true);
5649
5891
  // 1986–1991 中国夏令时:出生证钟面时间普遍是「拨快 1 小时」的钟面时间,
5650
5892
  // 不校正会让时柱(乃至跨 23:00 的日柱)整档偏;显式传 dst:false 可关闭。
5651
- const dst = input.dst === false ? { applied: false, note: null } : applyDst({ year, month, day, hour, minute });
5893
+ const dst = bool(input.dst, true) ? applyDst({ year, month, day, hour, minute }) : { applied: false, note: null };
5652
5894
  if (dst.applied) {
5653
5895
  year = dst.year; month = dst.month; day = dst.day; hour = dst.hour; minute = dst.minute;
5654
5896
  }
@@ -5752,7 +5994,7 @@ function buildBazi(input) {
5752
5994
 
5753
5995
  // 流年(默认从「今年」起排 10 年;传 input.nowYear 可钉死基准年,用于复现历史结论;
5754
5996
  // input.liunianTo 可把窗口延到指定年,生时校正要拿几十年前的事件逐年对账)
5755
- const thisYear = Number(input.nowYear) || new Date().getFullYear();
5997
+ const thisYear = Number(input.nowYear) || new Date().getFullYear(); // allow-clock: 未传 nowYear 时取本机年份;工具层 asOf 可钉死
5756
5998
  const liunianTo = Math.max(thisYear, Number(input.liunianTo) || thisYear + 9);
5757
5999
  const liunian = [];
5758
6000
  for (let y = thisYear; y <= liunianTo; y++) {
@@ -6931,6 +7173,7 @@ const { STEMS, BRANCHES, toJDN, ganzhiName, dayGanzhiIndex, sexagenaryIndex, xun
6931
7173
  const { jingText } = (__mods['yijing-text'] || {});
6932
7174
  const { fail } = (__mods.fail || {});
6933
7175
  const { assertObject } = (__mods.validate || {});
7176
+ const { randomOf, isSeed } = (__mods.random || {});
6934
7177
 
6935
7178
  // 八卦三位(自下而上,1 = 阳)
6936
7179
  const TRIGRAM_BITS = {
@@ -7263,10 +7506,8 @@ const sideOf = (position) => (position <= 3 ? 'inner' : 'outer');
7263
7506
  * @param {{direction?:string, gender?:string}} [opts]
7264
7507
  */
7265
7508
  function yongshenOf(result, opts = {}) {
7266
- // opts 允许省略或传 null(都按默认口径),但显式给了别的东西就必须是对象:
7509
+ opts = liuyaoOpts(opts, 'yongshenOf 的 opts', '{ direction?, gender? }');
7267
7510
  // 以前 yongshenOf(r, null) 会一路走到读 opts.direction,抛裸 TypeError
7268
- if (opts === null || opts === undefined) opts = {};
7269
- assertObject(opts, 'yongshenOf 的 opts', '{ direction?, gender? };省略或 null 按默认口径');
7270
7511
  const r = result && typeof result === 'object' ? result : {};
7271
7512
  const ben = r.ben && typeof r.ben === 'object' ? r.ben : {};
7272
7513
  const lines = Array.isArray(ben.lines) ? ben.lines : [];
@@ -7418,6 +7659,14 @@ function isMoving(v) {
7418
7659
  */
7419
7660
  function buildLiuyao(input = {}) {
7420
7661
  if (!input || typeof input !== 'object') throw fail('E_INPUT', '六爻起卦参数不能为空:至少给 lines 或 seed');
7662
+ // seed 以前只写在文档里:直接 buildLiuyao({ seed }) 仍走 Math.random,
7663
+ // 同一个 seed 摇不出同一卦,句柄却按 seed 算了身份。这里与工具层同一把尺。
7664
+ if (input.seed !== undefined && input.seed !== null && input.seed !== '' && !isSeed(input.seed)) {
7665
+ throw fail('E_INPUT', `seed 必须是数字,收到「${String(input.seed).slice(0, 24)}」`);
7666
+ }
7667
+ if (input.random !== undefined && input.random !== null && typeof input.random !== 'function') {
7668
+ throw fail('E_INPUT', `random 必须是函数,收到 ${typeof input.random}`);
7669
+ }
7421
7670
  // lines 给了但不是数组("7,8,9,6,7,8" / 789678 / {…})以前等同于「没给」:
7422
7671
  // 用户以为摇的是自己记下的那一卦,实际拿到一张随机盘,而且看不出来。
7423
7672
  if (input.lines !== undefined && input.lines !== null && !Array.isArray(input.lines)) {
@@ -7429,7 +7678,8 @@ function buildLiuyao(input = {}) {
7429
7678
  if (given && given.length !== 6) {
7430
7679
  throw fail('E_LINES', `lines 必须是 6 个爻值(自下而上),收到 ${given.length} 个`);
7431
7680
  }
7432
- const rawLines = given ? given.slice() : tossLines(input.random);
7681
+ const rand = typeof input.random === 'function' ? input.random : randomOf(input.seed);
7682
+ const rawLines = given ? given.slice() : tossLines(rand);
7433
7683
 
7434
7684
  const invalid = rawLines.filter((v) => ![6, 7, 8, 9].includes(v));
7435
7685
  if (invalid.length) throw fail('E_LINES', `爻值只能是 6/7/8/9,收到 ${JSON.stringify(rawLines)}`);
@@ -7441,7 +7691,7 @@ function buildLiuyao(input = {}) {
7441
7691
  const bian = bianBits ? hexagramFromBits(bianBits) : null;
7442
7692
 
7443
7693
  const dayGanZhi = input.dayGanZhi ?? (() => {
7444
- const now = new Date();
7694
+ const now = new Date(); // allow-clock: 未传日辰时按起卦当天取日干起六神;asOf 可钉死
7445
7695
  const jdn = toJDN(now.getFullYear(), now.getMonth() + 1, now.getDate());
7446
7696
  const g = ganzhiName(dayGanzhiIndex(jdn));
7447
7697
  return { stem: g.stem, branch: g.branch, name: g.name };
@@ -7590,6 +7840,12 @@ function dayRelationOf(element, dayElement) {
7590
7840
  return 'unknown';
7591
7841
  }
7592
7842
 
7843
+ /** opts 省略或传 null 都按默认口径;显式给了别的类型则当场报 E_INPUT。 */
7844
+ function liuyaoOpts(opts, who, shape) {
7845
+ if (opts === null || opts === undefined) return {};
7846
+ return assertObject(opts, who, `${shape};省略或 null 按默认口径`);
7847
+ }
7848
+
7593
7849
  /**
7594
7850
  * 用神旺衰:把月建、日辰两股外部力量落到用神那几爻上。
7595
7851
  * 月建按月支、日辰按日支,各出自己的五行,再与本爻五行论生克;
@@ -7599,6 +7855,7 @@ function dayRelationOf(element, dayElement) {
7599
7855
  * @param {{monthBranch?: string, dayBranch?: string}} opts
7600
7856
  */
7601
7857
  function yongshenStrength(result, useGod, opts = {}) {
7858
+ opts = liuyaoOpts(opts, 'yongshenStrength 的 opts', '{ monthBranch?, dayBranch? }');
7602
7859
  if (!useGod || !Array.isArray(useGod.found) || !useGod.found.length) return null;
7603
7860
  const monthBranch = opts.monthBranch || null;
7604
7861
  const dayBranch = opts.dayBranch || (result && result.dayGanZhi ? result.dayGanZhi.branch : null);
@@ -7675,6 +7932,7 @@ const FUSHEN_VERDICTS = ['可出', '有助有压', '受压难出', '未得助'];
7675
7932
  * @param {{monthBranch?: string, dayBranch?: string}} opts
7676
7933
  */
7677
7934
  function fushenAccess(result, useGod, opts = {}) {
7935
+ opts = liuyaoOpts(opts, 'fushenAccess 的 opts', '{ monthBranch?, dayBranch? }');
7678
7936
  if (!useGod || !Array.isArray(useGod.fushen) || !useGod.fushen.length) return null;
7679
7937
  const monthBranch = opts.monthBranch || null;
7680
7938
  const dayBranch = opts.dayBranch || (result && result.dayGanZhi ? result.dayGanZhi.branch : null);
@@ -7750,6 +8008,7 @@ function fushenAccess(result, useGod, opts = {}) {
7750
8008
  // 与用神旺衰同一套判定(月令五态、日辰五关系、三种冲法),区别只在不挑用神:
7751
8009
  // 六爻每一爻都给一次,世应、动爻、旬空另标,看得出整张卦的气压在哪一头。
7752
8010
  function hexagramStrength(result, opts = {}) {
8011
+ opts = liuyaoOpts(opts, 'hexagramStrength 的 opts', '{ monthBranch?, dayBranch? }');
7753
8012
  const rows = (result && result.ben && Array.isArray(result.ben.lines))
7754
8013
  ? result.ben.lines
7755
8014
  : (result && Array.isArray(result.lines) ? result.lines : []);
@@ -7838,6 +8097,7 @@ const TUI_VERDICT = { 旺: '退得缓', 相: '退得缓', 休: '退得实', 囚:
7838
8097
  * @param {{monthBranch?: string, dayBranch?: string}} opts
7839
8098
  */
7840
8099
  function jinTuiPower(result, opts = {}) {
8100
+ opts = liuyaoOpts(opts, 'jinTuiPower 的 opts', '{ monthBranch?, dayBranch? }');
7841
8101
  const items = result && result.body && Array.isArray(result.body.jinTui) ? result.body.jinTui : [];
7842
8102
  if (!items.length) return null;
7843
8103
  const rows = result && result.ben && Array.isArray(result.ben.lines) ? result.ben.lines : [];
@@ -7911,6 +8171,7 @@ const TRIGGER_ORDER = ['逢值', '逢冲', '逢合', '出空填实', '冲空'];
7911
8171
  * @param {{monthBranch?: string}} opts
7912
8172
  */
7913
8173
  function yingqiWindow(result, useGod, opts = {}) {
8174
+ opts = liuyaoOpts(opts, 'yingqiWindow 的 opts', '{ monthBranch? }');
7914
8175
  if (!useGod || !useGod.liuqin) return null;
7915
8176
  const found = Array.isArray(useGod.found) ? useGod.found : [];
7916
8177
  const fushen = Array.isArray(useGod.fushen) ? useGod.fushen : [];
@@ -8573,6 +8834,7 @@ const { nayinOf } = (__mods.nayin || {});
8573
8834
  const { resolveAddress } = (__mods.geo || {});
8574
8835
  const { placeZuoyao, zuoyaoVerseBlock, ZUOYAO_SKIPPED } = (__mods['ziwei-zuoyao'] || {});
8575
8836
  const { SHA_STAR } = (__mods['ziwei-words'] || {});
8837
+ const { bool } = (__mods.bool || {});
8576
8838
 
8577
8839
  const fix = (i) => ((i % 12) + 12) % 12;
8578
8840
 
@@ -8962,7 +9224,7 @@ function buildZiwei(input) {
8962
9224
  assertCivil(input);
8963
9225
  const schools = ziweiSchoolsOf(input);
8964
9226
  const { year: cy, month: cm, day: cd, hour: ch = 0, minute: cmin = 0, gender = 'male' } = input;
8965
- const useTrueSolar = input.trueSolar !== false;
9227
+ const useTrueSolar = bool(input.trueSolar, true);
8966
9228
  const geo = input.geo || (input.address ? resolveAddress(input.address) : null);
8967
9229
  const longitude = typeof input.longitude === 'number'
8968
9230
  ? input.longitude
@@ -9236,7 +9498,7 @@ function buildZiwei(input) {
9236
9498
  // 直接读挂钟的话,同一组参数(同一个句柄)跨年会排出不同的流年表,
9237
9499
  // 「同参数同盘」的承诺就只在当年成立。
9238
9500
  const asOfForLiunian = asOfParts(input.asOf);
9239
- const thisYear = (asOfForLiunian && asOfForLiunian.year) || new Date().getFullYear();
9501
+ const thisYear = (asOfForLiunian && asOfForLiunian.year) || new Date().getFullYear(); // allow-clock: 未传 asOf 时按本机年份起流年;工具层 asOf 可钉死
9240
9502
  const liunian = [];
9241
9503
  for (let y = thisYear; y < thisYear + 12; y++) {
9242
9504
  const gz = ganzhiName((((y - 4) % 60) + 60) % 60);
@@ -9888,7 +10150,7 @@ function asOfParts(v) {
9888
10150
  }
9889
10151
 
9890
10152
  function flowOf(chart, asOf) {
9891
- const now = new Date();
10153
+ const now = new Date(); // allow-clock: 流日/流时按调用时刻;显式 asOf 会覆盖
9892
10154
  const a = asOfParts(asOf) || {};
9893
10155
  const Y = a.year || now.getFullYear();
9894
10156
  const M = a.month || now.getMonth() + 1;
@@ -10387,12 +10649,17 @@ function tarotDeck() {
10387
10649
  // 名称 → 牌面数据(解读时按名字回查,保证确定性、且不依赖调用方是否带全字段)
10388
10650
  const BY_NAME = new Map(tarotDeck().map((c) => [c.name, c]));
10389
10651
 
10652
+ // 外部手输/旧数据常见的另一种译名。只做显式别名,不做模糊匹配:
10653
+ // 拼错的牌名不能被猜成另一张,否则解读会披着别的牌义,错得看不出来。
10654
+ const CARD_ALIASES = { 愚人: '愚者' };
10655
+ const cardMeta = (name) => BY_NAME.get(CARD_ALIASES[name] || name) || null;
10656
+
10390
10657
  const splitKeywords = (s) => String(s || '').split(/\s+/).filter(Boolean);
10391
10658
 
10392
10659
  /** 抽牌时刻(只做记录,不影响牌面) */
10393
10660
  function stamp(at) {
10394
10661
  if (typeof at === 'string' && at.trim()) return at.trim().replace('T', ' ').slice(0, 16);
10395
- const d = new Date();
10662
+ const d = new Date(); // allow-clock: 未传 asOf 时记录抽牌时刻;牌面由 seed 固定
10396
10663
  const p = (x) => String(x).padStart(2, '0');
10397
10664
  return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
10398
10665
  }
@@ -10416,12 +10683,17 @@ function tarotReading(input = {}) {
10416
10683
  if (!n) return ['没有抽到牌面,无法解读。'];
10417
10684
 
10418
10685
  const names = list.map((c) => c.name).join(' / ');
10686
+ // 牌库外的牌名不能悄悄读成「空牌义」:开场点名是哪几张,逐张处退回正/逆位泛义。
10687
+ const unknown = list.map((c) => c.name).filter((name) => !cardMeta(name));
10688
+ const unknownNote = unknown.length
10689
+ ? `其中「${unknown.join('」「')}」不在韦特 78 张牌库里,这几张只按你给的位置与正逆位泛读,不补牌面、元素与占星对应。`
10690
+ : '';
10419
10691
  const paras = [];
10420
10692
 
10421
10693
  // ① 开场:所问 + 象征系统声明
10422
10694
  paras.push(q
10423
- ? `你问的是「${q}」,抽到的是 ${n} 张牌阵(${names})。塔罗是一套象征系统而不是判决:不同流派对牌义、编号与逆位的取舍略有差异,这里按 RWS(韦特)牌名与黄金黎明的元素对应来读,请把下面的话当作镜子,对照自己的处境取用。`
10424
- : `这次没有具体提问,那就先看牌面本身在说什么。牌阵 ${n} 张(${names})。塔罗是象征系统,牌义随流派略有差异,这里按 RWS(韦特)与黄金黎明的常见对应来读,读到合用的部分就好。`);
10695
+ ? `你问的是「${q}」,抽到的是 ${n} 张牌阵(${names})。塔罗是一套象征系统而不是判决:不同流派对牌义、编号与逆位的取舍略有差异,这里按 RWS(韦特)牌名与黄金黎明的元素对应来读,请把下面的话当作镜子,对照自己的处境取用。${unknownNote}`
10696
+ : `这次没有具体提问,那就先看牌面本身在说什么。牌阵 ${n} 张(${names})。塔罗是象征系统,牌义随流派略有差异,这里按 RWS(韦特)与黄金黎明的常见对应来读,读到合用的部分就好。${unknownNote}`);
10425
10697
 
10426
10698
  // ② 逐张:位义 + 牌名/正逆 + 关键词 + 一句与位义结合的解读
10427
10699
  // 1-3 张时每张一段;4 张以上按前后两段分组(前段取 ceil(n/2) 张),
@@ -10431,8 +10703,10 @@ function tarotReading(input = {}) {
10431
10703
  for (const group of groups) {
10432
10704
  const lines = group.map((i) => {
10433
10705
  const c = list[i];
10434
- const meta = BY_NAME.get(c.name) || {};
10435
- const kws = (c.keywords && c.keywords.length ? c.keywords : splitKeywords(c.upright ? meta.up : meta.down)).join('、');
10706
+ const meta = cardMeta(c.name) || {};
10707
+ // 牌库外又没有关键词时,退回正/逆位的泛义,别留下「正位:。」的空句
10708
+ const kws = (c.keywords && c.keywords.length ? c.keywords : splitKeywords(c.upright ? meta.up : meta.down)).join('、')
10709
+ || (c.upright === false ? '逆位泛义(阻滞、内转或用力过头)' : '正位泛义(推进、显化、顺势)');
10436
10710
  const ori = c.upright === false ? '逆位' : '正位';
10437
10711
  const oriNote = c.upright === false
10438
10712
  ? '逆位并不等于凶,更像这股力量还没顺过来,或用力过了头'
@@ -10457,7 +10731,7 @@ function tarotReading(input = {}) {
10457
10731
  const upCount = n - revCount;
10458
10732
  const elementCount = {};
10459
10733
  for (const c of list) {
10460
- const e = (BY_NAME.get(c.name) || {}).element || c.element;
10734
+ const e = (cardMeta(c.name) || {}).element || c.element;
10461
10735
  if (e) elementCount[e] = (elementCount[e] || 0) + 1;
10462
10736
  }
10463
10737
  const present = ELEMENT_ORDER.filter((e) => elementCount[e]);
@@ -10486,7 +10760,7 @@ function tarotReading(input = {}) {
10486
10760
  const majorCard = list.find((c) => c.arcana === '大阿卡纳');
10487
10761
  const revCard = list.find((c) => c.upright === false);
10488
10762
  const key = majorCard || revCard || list[0];
10489
- const keyMeta = BY_NAME.get(key.name) || {};
10763
+ const keyMeta = cardMeta(key.name) || {};
10490
10764
  const keyReason = majorCard
10491
10765
  ? '它出现的地方,往往就是这件事真正被牵动的层级'
10492
10766
  : revCard
@@ -10559,7 +10833,9 @@ function drawTarot(input = {}) {
10559
10833
  keywords: splitKeywords(upright ? c.up : c.down),
10560
10834
  };
10561
10835
  });
10562
- const q = (question || '').trim();
10836
+ // 直接调引擎时 question 可能是数字(工具层 schema 的 string 不做强转),
10837
+ // 以前 (123 || '').trim() 会抛裸 TypeError,整张牌只剩一句内部错误。
10838
+ const q = String(question == null ? '' : question).trim();
10563
10839
  return {
10564
10840
  system: 'tarot',
10565
10841
  question: q || null,
@@ -10581,6 +10857,7 @@ __mods.meihua = (function () {
10581
10857
  const { BRANCHES, fromJDN, toJDN } = (__mods.calendar || {});
10582
10858
  const { solarToLunar } = (__mods.lunar || {});
10583
10859
  const { fail } = (__mods.fail || {});
10860
+ const { bool } = (__mods.bool || {});
10584
10861
  const { parseDateTime } = (__mods.datetime || {});
10585
10862
  const { assertShifted } = (__mods.validate || {});
10586
10863
  const { hexagramFromBits } = (__mods.liuyao || {});
@@ -10634,16 +10911,29 @@ function buildMeihua(input = {}) {
10634
10911
  let source;
10635
10912
 
10636
10913
  if (mode === 'number') {
10637
- const a = Number(input.upper);
10638
- const b = Number(input.lower);
10639
- if (!Number.isFinite(a) || !Number.isFinite(b)) throw fail('E_INPUT', '数字起卦需要两个数字(upper / lower),例如 upper=3、lower=5');
10914
+ // 只认真正的数字:Number(null) / Number(false) / Number([]) 都是 0,
10915
+ // 以前缺参或传错类型会静默起成「坤为地」,盘面看着正常却完全不是用户给的字数。
10916
+ const a = input.upper;
10917
+ const b = input.lower;
10918
+ // 小数以前只过 Number.isFinite,mod8(3.5) 得到 4.5,bitsOf 查不到卦再在深处抛
10919
+ // 「bitsOf is not a function」——参数错却报成内部错误。数字起卦只认整数。
10920
+ if (typeof a !== 'number' || typeof b !== 'number' || !Number.isInteger(a) || !Number.isInteger(b)) {
10921
+ throw fail('E_INPUT', '数字起卦需要两个整数(upper / lower),例如 upper=3、lower=5');
10922
+ }
10640
10923
  upperNum = mod8(a);
10641
10924
  lowerNum = mod8(b);
10642
10925
  if (input.changing !== undefined && input.changing !== null && input.changing !== '') {
10643
- // 以前 99 会被 mod 6 折成 3:用户指定动爻却得到另一爻,结果里看不出来
10644
- const ch = Number(input.changing);
10926
+ // 以前 99 会被 mod 6 折成 3:用户指定动爻却得到另一爻,结果里看不出来。
10927
+ // Number(true)=1、Number([3])=3 也会静默通过,故只收数字或十进制数字串。
10928
+ const raw = input.changing;
10929
+ const ch = typeof raw === 'number'
10930
+ ? raw
10931
+ : typeof raw === 'string' && /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/.test(raw.trim())
10932
+ ? Number(raw.trim())
10933
+ : NaN;
10645
10934
  if (!Number.isInteger(ch) || ch < 1 || ch > 6) {
10646
- throw fail('E_INPUT', `动爻 changing 必须是 1–6 的整数,收到「${input.changing}」`);
10935
+ const shown = typeof raw === 'string' ? raw : JSON.stringify(raw);
10936
+ throw fail('E_INPUT', `动爻 changing 必须是 1–6 的整数,收到「${shown}」`);
10647
10937
  }
10648
10938
  moving = ch;
10649
10939
  } else {
@@ -10653,7 +10943,7 @@ function buildMeihua(input = {}) {
10653
10943
  } else {
10654
10944
  const dt = parseDateTime(input.datetime);
10655
10945
  // 晚子时换日与八字/六壬/奇门同口径:23:00–23:59 归次日,年月日电数才落在同一子时
10656
- const lateZi = input.lateZi !== false;
10946
+ const lateZi = bool(input.lateZi, true);
10657
10947
  let sy = dt.year;
10658
10948
  let sm = dt.month;
10659
10949
  let sd = dt.day;
@@ -10739,6 +11029,7 @@ __mods.daliuren = (function () {
10739
11029
  const { toJDN, dayGanzhiIndex, ganzhiName, termWindow, formatJd, jdToParts, xunKongOf } = (__mods.calendar || {});
10740
11030
  const { assertCivil, assertShifted } = (__mods.validate || {});
10741
11031
  const { SANHE_ELEMENT } = (__mods.sanhe || {});
11032
+ const { bool } = (__mods.bool || {});
10742
11033
 
10743
11034
  const GAN = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];
10744
11035
  const ZHI = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];
@@ -11043,7 +11334,7 @@ function fanYin(ke, dayGan, dayZhi, stats, isFB) {
11043
11334
  function buildDaliuren(input) {
11044
11335
  assertCivil(input);
11045
11336
  const { year, month, day, hour = 0, minute = 0 } = input;
11046
- const lateZi = input.lateZi !== false;
11337
+ const lateZi = bool(input.lateZi, true);
11047
11338
  const jdnBase = toJDN(year, month, day);
11048
11339
  const jdn = lateZi && hour >= 23 ? jdnBase + 1 : jdnBase;
11049
11340
  const dayIdx = dayGanzhiIndex(jdn);
@@ -11153,6 +11444,7 @@ const { buildBazi, tenGod } = (__mods.bazi || {});
11153
11444
  const { STEMS, BRANCHES } = (__mods.calendar || {});
11154
11445
  const { assertCivil } = (__mods.validate || {});
11155
11446
  const { SANHE_GROUPS } = (__mods.sanhe || {});
11447
+ const { bool } = (__mods.bool || {});
11156
11448
 
11157
11449
  const WX_GAN = { 甲: '木', 乙: '木', 丙: '火', 丁: '火', 戊: '土', 己: '土', 庚: '金', 辛: '金', 壬: '水', 癸: '水' };
11158
11450
  const WX_ZHI = { 子: '水', 丑: '土', 寅: '木', 卯: '木', 辰: '土', 巳: '火', 午: '火', 未: '土', 申: '金', 酉: '金', 戌: '土', 亥: '水' };
@@ -11365,7 +11657,7 @@ function buildHepan(input) {
11365
11657
  tenGodToA: godB,
11366
11658
  text: he5
11367
11659
  ? `日干五合(${aStem}${bStem}),传统称「天干五合」,主彼此吸引强,也容易黏在一起分不开。`
11368
- : `日干无五合:你在对方盘里是「${godA}」,对方在你盘里是「${godB}」。`,
11660
+ : `日干无五合:对方在你盘里是「${godA}」,你在对方盘里是「${godB}」。`,
11369
11661
  },
11370
11662
  crossBranches: uniqCross.slice(0, 8),
11371
11663
  nayin: { a: nyA, b: nyB, label: nayinRel.name, text: nayinRel.text },
@@ -11387,7 +11679,7 @@ function buildHepan(input) {
11387
11679
  wuxing: wxA,
11388
11680
  // 真太阳时口径要能被看到:合盘与单盘用同一套修正,否则同一个人会出现两套四柱
11389
11681
  longitude: A.input.longitude ?? null,
11390
- trueSolar: A.input.trueSolar !== false,
11682
+ trueSolar: bool(A.input.trueSolar, true),
11391
11683
  solarNote: A.solarTime ? A.solarTime.note : '',
11392
11684
  summary: A.summary,
11393
11685
  },
@@ -11400,7 +11692,7 @@ function buildHepan(input) {
11400
11692
  favor: favorB.join(''),
11401
11693
  wuxing: wxB,
11402
11694
  longitude: B.input.longitude ?? null,
11403
- trueSolar: B.input.trueSolar !== false,
11695
+ trueSolar: bool(B.input.trueSolar, true),
11404
11696
  solarNote: B.solarTime ? B.solarTime.note : '',
11405
11697
  summary: B.summary,
11406
11698
  },
@@ -11428,6 +11720,7 @@ __mods.trend = (function () {
11428
11720
  // 口径:这是一套**简化启发式**——十神计分表固定、正负号随日主旺衰方向翻转,
11429
11721
  // 只用于看形态与相对起伏;分高不等于真实吉凶,旺衰落在换档边界时连排序都不给。
11430
11722
  const { buildBazi, HIDDEN_STEMS, tenGod } = (__mods.bazi || {});
11723
+ const { bool } = (__mods.bool || {});
11431
11724
  const { ganzhiName, sexagenaryIndex, STEMS, BRANCHES } = (__mods.calendar || {});
11432
11725
  const { fail } = (__mods.fail || {});
11433
11726
 
@@ -11531,10 +11824,13 @@ function buildTrend(input) {
11531
11824
  day: input.day,
11532
11825
  hour: Number.isInteger(input.hour) ? input.hour : 12,
11533
11826
  minute: Number.isInteger(input.minute) ? input.minute : 0,
11827
+ // 时辰未知必须一路传到 buildBazi:它在内部统一按正午占位并收回时柱。
11828
+ // 少了这一个键,摘要写着「按正午暂算」,旺衰却按 00:00 算成了另一档。
11829
+ hourUnknown: bool(input.hourUnknown),
11534
11830
  gender,
11535
- lateZi: input.lateZi !== false,
11536
- trueSolar: input.trueSolar !== false,
11537
- dst: input.dst !== false,
11831
+ lateZi: bool(input.lateZi, true),
11832
+ trueSolar: bool(input.trueSolar, true),
11833
+ dst: bool(input.dst, true),
11538
11834
  address: typeof input.address === 'string' ? input.address : undefined,
11539
11835
  longitude: typeof input.longitude === 'number' ? input.longitude : undefined,
11540
11836
  geo: input.geo && typeof input.geo === 'object' ? input.geo : undefined,
@@ -11650,6 +11946,8 @@ __mods.fengshui = (function () {
11650
11946
  const { partsToJd, termInstantJd, toJDN, dayGanzhiIndex, ganzhiName, termWindow, previousJie, BRANCHES } = (__mods.calendar || {});
11651
11947
  const { applyDst } = (__mods.dst || {});
11652
11948
  const { fail } = (__mods.fail || {});
11949
+ const { bool } = (__mods.bool || {});
11950
+ const { assertCivil, MIN_YEAR, MAX_YEAR } = (__mods.validate || {});
11653
11951
 
11654
11952
  /** 九星名称表:数 → {name, color, element, star(北斗名), lucky}。 */
11655
11953
  const NINE_STARS = {
@@ -11738,7 +12036,10 @@ const GUA_BY_NUM = ['坎', '坤', '震', '巽', '中', '乾', '兑', '艮', '离
11738
12036
  */
11739
12037
  function mingGua(birthYear, gender) {
11740
12038
  const tail = ((birthYear % 100) + 100) % 100;
11741
- const century = birthYear >= 2000 ? { male: 99, female: 3 } : { male: 100, female: 4 };
12039
+ // 世纪常数每个世纪减 1:1900s 男 100 / 女 4,2000s 99 / 3,2100s 98 / 2……
12040
+ // 以前只在「>=2000」时切一次 99/3,2100 年以后(引擎支持到 2400)会整档算错。
12041
+ const shift = Math.floor(birthYear / 100) - 19;
12042
+ const century = { male: 100 - shift, female: 4 - shift };
11742
12043
  const mod9 = (n) => { const r = ((n % 9) + 9) % 9; return r === 0 ? 9 : r; };
11743
12044
  let num = gender === 'male' ? mod9(century.male - tail) : mod9(tail - century.female);
11744
12045
  if (num === 5) num = gender === 'male' ? 2 : 8;
@@ -11758,10 +12059,11 @@ function eightStars(gua) {
11758
12059
  return result;
11759
12060
  }
11760
12061
 
11761
- /** 立春界节气年:生日在当年立春前 → 上一年(按正午判,与黄历一致)。 */
12062
+ /** 立春界节气年:生日在当年立春前 → 上一年。
12063
+ * 按「日」判(立春当日即算新年),与黄历同一口径;本函数只收年月日,不看当天交节时刻——
12064
+ * 命卦本来就只按出生年取,同一天出生的人不因生在 16:27 前后换卦。 */
11762
12065
  function guaYearOf(year, month, day) {
11763
- const birthJd = partsToJd({ year, month, day, hour: 12, minute: 0 });
11764
- return birthJd < termInstantJd(year, 2) ? year - 1 : year;
12066
+ return Math.floor(termInstantJd(year, 2) + 0.5) <= toJDN(year, month, day) ? year : year - 1;
11765
12067
  }
11766
12068
 
11767
12069
  /**
@@ -11858,13 +12160,20 @@ function timeFlyingOf(at) {
11858
12160
  const hour = Number.isInteger(at.hour) ? at.hour : 12;
11859
12161
  const minute = Number.isInteger(at.minute) ? at.minute : 0;
11860
12162
  const jd = partsToJd({ year, month, day, hour, minute });
12163
+ // 交节的判定基准:给了时刻就按精确时刻(14:30 出生、当天 17:03 才立春,仍在上一月);
12164
+ // 只给日期则按「日」——当天交节即算新节。旧实现一律用正午,交节在午后的那半天会算成上个月,
12165
+ // 与同一页黄历的月柱(已按日判)自相矛盾。
12166
+ const hasHour = Number.isInteger(at.hour);
12167
+ const jdTerm = hasHour ? jd : toJDN(year, month, day) + 0.5 - 1e-6;
11861
12168
  const terms = termWindow(year);
11862
- const guaYear = guaYearOf(year, month, day);
12169
+ // 年紫白同样以立春为界,且与上面月/日/时用同一个基准:给时刻按时刻,只给日期按日。
12170
+ // 若这里改回只看日期的 guaYearOf,立春当天的「年」会是新年、「月」还是上一月,同盘自相矛盾。
12171
+ const guaYear = jdTerm >= termInstantJd(year, 2) ? year : year - 1;
11863
12172
  const yearBranch = yearBranchOf(guaYear);
11864
12173
  const yearGroup = branchGroupOf(yearBranch);
11865
- const prevJie = previousJie(terms, jd);
12174
+ const prevJie = previousJie(terms, jdTerm);
11866
12175
  const monthNum = JIE_MONTH_NUM[prevJie ? prevJie.name : '立春'] || 1;
11867
- const half = zibaiHalfAt(terms, jd);
12176
+ const half = zibaiHalfAt(terms, jdTerm);
11868
12177
  const jdn = toJDN(year, month, day) + (hour >= 23 ? 1 : 0);
11869
12178
  const dayIdx = dayGanzhiIndex(jdn);
11870
12179
  const dayName = ganzhiName(dayIdx).name;
@@ -12084,9 +12393,10 @@ function xuankongChart(period, sitting, facing, opts = {}) {
12084
12393
 
12085
12394
  /** DST 校正出生日期(1986–1991),返回校正后的年月日。 */
12086
12395
  function civilDate(input) {
12087
- const dst = input.dst === false
12088
- ? { year: input.year, month: input.month, day: input.day, hour: 0, minute: 0, applied: false, note: null }
12089
- : applyDst({ year: input.year, month: input.month, day: input.day, hour: 0, minute: 0 });
12396
+ // 开启 DST 校正(默认开)才走 applyDst;显式关闭时不动日期
12397
+ const dst = bool(input.dst, true)
12398
+ ? applyDst({ year: input.year, month: input.month, day: input.day, hour: 0, minute: 0 })
12399
+ : { year: input.year, month: input.month, day: input.day, hour: 0, minute: 0, applied: false, note: null };
12090
12400
  return { year: dst.year, month: dst.month, day: dst.day, dst };
12091
12401
  }
12092
12402
 
@@ -12115,6 +12425,10 @@ function buildFengshui(input) {
12115
12425
  if (input.fortuneYear !== undefined && input.fortuneYear !== null && input.fortuneYear !== '') {
12116
12426
  const fy = Number(input.fortuneYear);
12117
12427
  if (!Number.isInteger(fy)) throw fail('E_INPUT', `fortuneYear 必须是整数年份,收到「${input.fortuneYear}」`);
12428
+ // 只校验「是整数」会放过 0 / 负数:年紫白照样按公式给出一颗星,看着像算过。
12429
+ if (fy < MIN_YEAR || fy > MAX_YEAR) {
12430
+ throw fail('E_INPUT', `fortuneYear 超出支持范围 ${MIN_YEAR}–${MAX_YEAR}(收到 ${fy})`);
12431
+ }
12118
12432
  input = { ...input, fortuneYear: fy };
12119
12433
  }
12120
12434
  const action = input.action;
@@ -12130,6 +12444,9 @@ function buildFengshui(input) {
12130
12444
  if (!Number.isInteger(input.year) || !Number.isInteger(input.month) || !Number.isInteger(input.day)) {
12131
12445
  throw fail('E_INPUT', '风水命卦需要完整出生年月日(公历)——只知道年份不够:命卦按立春界划分出生年');
12132
12446
  }
12447
+ // 与其它体系同一把尺:2 月 30 日、13 月、越界年份必须在入口报错,
12448
+ // 否则会被 Date 静默滚到下个月,命卦按另一天算出来却没人知道。
12449
+ assertCivil(input, '风水命卦');
12133
12450
  const civil = civilDate(input);
12134
12451
  const guaYear = guaYearOf(civil.year, civil.month, civil.day);
12135
12452
  const { num, gua, direction } = mingGua(guaYear, gender);
@@ -12292,7 +12609,7 @@ function parseFortuneAt(input) {
12292
12609
  }
12293
12610
  const [hour, minute] = rawTime.split(':').map(Number);
12294
12611
  if (hour > 23 || minute > 59) throw fail('E_INPUT', `fortuneTime 超出范围(HH:MM):「${rawTime}」`);
12295
- const dst = input.dst === false ? null : applyDst({ year, month, day, hour, minute });
12612
+ const dst = bool(input.dst, true) ? applyDst({ year, month, day, hour, minute }) : null;
12296
12613
  const at = dst ? { year: dst.year, month: dst.month, day: dst.day, hour: dst.hour, minute: dst.minute } : { year, month, day, hour, minute };
12297
12614
  return { at, dst };
12298
12615
  }
@@ -12350,7 +12667,7 @@ function buildXuankong(input) {
12350
12667
  action: 'xuankong',
12351
12668
  period,
12352
12669
  periodLabel: yearInfo ? yearInfo.label : `${period}运`,
12353
- ...(yearInfo ? { year: input.fortuneYear || (fortune && fortune.at.year), periodStart: yearInfo.start, periodEnd: yearInfo.end } : {}),
12670
+ ...(yearInfo ? { year: input.fortuneYear ?? (fortune && fortune.at.year), periodStart: yearInfo.start, periodEnd: yearInfo.end } : {}),
12354
12671
  sitting: `${sitting.m}山(罗盘 ${sitting.deg}°)`,
12355
12672
  facing: `${facing.m}山(罗盘 ${facing.deg}°)`,
12356
12673
  sittingGua: sitting.gua,
@@ -13241,6 +13558,7 @@ __mods.name = (function () {
13241
13558
  // 五格按康熙字典繁体笔画计(见 name-data.js 的口径说明),81 数理取通行本;
13242
13559
  // 音韵只做机械检查(同调、相邻同声母/同韵母、叠字),不做语义谐音判断。
13243
13560
  const { buildBazi } = (__mods.bazi || {});
13561
+ const { bool } = (__mods.bool || {});
13244
13562
  const { assertCivil, assertObject } = (__mods.validate || {});
13245
13563
  const { fail } = (__mods.fail || {});
13246
13564
  const { READING, SURNAME_STROKES, SURNAME_READING, SURNAME_ALT_READING, DOUBLE_SURNAMES, SHULI_81 } = (__mods['name-data'] || {});
@@ -13502,19 +13820,23 @@ const WX_REL = (a, b) => (a === b ? '同' : SHENG[a] === b ? '生' : KE[a] === b
13502
13820
 
13503
13821
  /** 数理超过 81 按传统「减 80 循环」取(如 104 → 24)。 */
13504
13822
  function shuliOf(n) {
13505
- let x = n;
13506
- while (x > 81) x -= 80;
13823
+ // 用取模代替 while 递减:strokeOverrides 允许用户给任意正整数,
13824
+ // 以前给 1e12 会在这里空转一百多亿次,整次排盘卡死。
13825
+ const x = n > 81 ? ((n - 1) % 80) + 1 : n;
13507
13826
  if (!(x >= 1)) return null;
13508
13827
  const row = SHULI_81[x];
13509
13828
  return row ? { num: x, level: row[0], name: row[1] } : null;
13510
13829
  }
13511
13830
 
13512
- /** 合并两处笔画覆盖:surnameStrokes(按姓给的)+ strokeOverrides(逐字覆盖),后者优先。 */
13831
+ /** 合并两处笔画覆盖:surnameStrokes(按姓给的)+ strokeOverrides(逐字覆盖),后者优先。
13832
+ * 笔画值允许数字串(`{"秋":"9"}`):模型经 JSON 传参时常见,只在入口归一还不够——
13833
+ * 这里再兜一层,免得「用户给了笔画却被静默按字库算」这种错法又冒出来。 */
13513
13834
  function overridesOf(input) {
13514
13835
  const out = {};
13515
13836
  for (const src of [input && input.surnameStrokes, input && input.strokeOverrides]) {
13516
13837
  if (!src || typeof src !== 'object') continue;
13517
- for (const [k, v] of Object.entries(src)) {
13838
+ for (const [k, raw] of Object.entries(src)) {
13839
+ const v = typeof raw === 'string' ? Number(raw.trim()) : raw;
13518
13840
  if (Number.isInteger(v) && v > 0) out[k] = v;
13519
13841
  }
13520
13842
  }
@@ -13742,12 +14064,14 @@ function assessName(input) {
13742
14064
  assertCivil(input, 'birth');
13743
14065
  const r = buildBazi({
13744
14066
  year: input.year, month: input.month, day: input.day,
13745
- hour: Number.isInteger(input.hour) ? input.hour : 12,
14067
+ // 只给日期时与 datetime:'YYYY-MM-DD' 同一口径(00:00 占位);引擎摘要会标明缺时刻,
14068
+ // 以前这里悄悄补 12:00,同一个生日走 datetime 和 year/month/day 会得到两档旺衰。
14069
+ hour: Number.isInteger(input.hour) ? input.hour : 0,
13746
14070
  minute: Number.isInteger(input.minute) ? input.minute : 0,
13747
14071
  gender: input.gender || 'male',
13748
- lateZi: input.lateZi !== false,
13749
- trueSolar: input.trueSolar !== false,
13750
- dst: input.dst !== false,
14072
+ lateZi: bool(input.lateZi, true),
14073
+ trueSolar: bool(input.trueSolar, true),
14074
+ dst: bool(input.dst, true),
13751
14075
  longitude: input.longitude, address: input.address, geo: input.geo,
13752
14076
  });
13753
14077
  strength = { level: r.strength.level, score: r.strength.score, dayElement: r.pillars.day.stemElement };
@@ -13843,12 +14167,13 @@ function generateNames(input) {
13843
14167
  const limit = Math.max(1, Math.min(20, Number.isInteger(input.limit) ? input.limit : 10));
13844
14168
  const r = buildBazi({
13845
14169
  year: input.year, month: input.month, day: input.day,
13846
- hour: Number.isInteger(input.hour) ? input.hour : 12,
14170
+ // 与 assessName 同一口径:缺时刻按 00:00 占位,由引擎摘要统一提示
14171
+ hour: Number.isInteger(input.hour) ? input.hour : 0,
13847
14172
  minute: Number.isInteger(input.minute) ? input.minute : 0,
13848
14173
  gender,
13849
- lateZi: input.lateZi !== false,
13850
- trueSolar: input.trueSolar !== false,
13851
- dst: input.dst !== false,
14174
+ lateZi: bool(input.lateZi, true),
14175
+ trueSolar: bool(input.trueSolar, true),
14176
+ dst: bool(input.dst, true),
13852
14177
  longitude: input.longitude, address: input.address, geo: input.geo,
13853
14178
  });
13854
14179
  const strength = { level: r.strength.level, score: r.strength.score, dayElement: r.pillars.day.stemElement };
@@ -15386,7 +15711,7 @@ __mods.almanac = (function () {
15386
15711
  // 不是逐日全量黄历。
15387
15712
  const { solarToLunar } = (__mods.lunar || {});
15388
15713
  const { nayinOf } = (__mods.nayin || {});
15389
- const { toJDN, fromJDN, dayGanzhiIndex, ganzhiName, termWindow, termInstantJd, partsToJd, STEMS, BRANCHES, TERM_NAMES } = (__mods.calendar || {});
15714
+ const { toJDN, fromJDN, dayGanzhiIndex, ganzhiName, termWindow, termInstantJd, STEMS, BRANCHES, TERM_NAMES } = (__mods.calendar || {});
15390
15715
  const { HEX64 } = (__mods['interpret-data'] || {});
15391
15716
  const { sanheGroupOf } = (__mods.sanhe || {});
15392
15717
  const { assertCivil, daysInMonth } = (__mods.validate || {});
@@ -15571,13 +15896,18 @@ function buildAlmanac(input) {
15571
15896
  if (day > daysInMonth(year, month)) {
15572
15897
  throw new Error(`非法日期:${year} 年 ${month} 月没有 ${day} 日`);
15573
15898
  }
15574
- const jdNoon = partsToJd({ year, month, day, hour: 12, minute: 0 });
15575
15899
  const lunar = solarToLunar(year, month, day);
15576
15900
  const jdn = toJDN(year, month, day);
15577
15901
 
15902
+ // 黄历是「按日」出版的:交节当天即算新节(通书本子口径),所以节气一律比「日序」,
15903
+ // 不比当天正午的时刻。用正午比时刻时,交节落在午后的那半年,整天还挂在上个月——
15904
+ // 每年 12 个「节」约一半在午后,等于每年约 6 天的月柱、建除、值日神全错。
15905
+ // 八字侧仍按精确到分的交节时刻判月柱(见 bazi.js),两者不共用这一层。
15906
+ const termDayIndex = (jd) => Math.floor(jd + 0.5);
15907
+
15578
15908
  // 年柱:立春界;同时给出春节界口径
15579
15909
  const lichunJd = termInstantJd(year, 2);
15580
- const ganzhiYear = jdNoon < lichunJd ? year - 1 : year;
15910
+ const ganzhiYear = termDayIndex(lichunJd) <= jdn ? year : year - 1;
15581
15911
  const yearIdx = (((ganzhiYear - 4) % 60) + 60) % 60;
15582
15912
  const yearGz = ganzhiName(yearIdx);
15583
15913
  const springYear = lunar.lunarYear;
@@ -15586,9 +15916,8 @@ function buildAlmanac(input) {
15586
15916
  // 月柱:以「节」为界
15587
15917
  const jieTerms = termWindow(year, { jieOnly: true });
15588
15918
  let prevJie = null;
15589
- let nextJie = null;
15590
15919
  for (const t of jieTerms) {
15591
- if (t.jd <= jdNoon) prevJie = t; else { if (!nextJie) nextJie = t; }
15920
+ if (termDayIndex(t.jd) <= jdn) prevJie = t;
15592
15921
  }
15593
15922
  const monthBranchIdx = ((2 + (prevJie.index - 2) / 2) % 12 + 12) % 12;
15594
15923
  const yinMonthStem = ((STEMS.indexOf(yearGz.stem) % 5) * 2 + 2) % 10;
@@ -15606,7 +15935,7 @@ function buildAlmanac(input) {
15606
15935
  let prevTerm = null;
15607
15936
  let nextTerm = null;
15608
15937
  for (const t of allTerms) {
15609
- if (t.jd <= jdNoon) prevTerm = t; else { if (!nextTerm) nextTerm = t; }
15938
+ if (termDayIndex(t.jd) <= jdn) prevTerm = t; else { if (!nextTerm) nextTerm = t; }
15610
15939
  }
15611
15940
  const fmtJdDate = (jd) => {
15612
15941
  const p = fromJDN(Math.floor(jd + 0.5));
@@ -16269,8 +16598,11 @@ function buildMbti(input = {}) {
16269
16598
  picked,
16270
16599
  strength: strengthOf(pct, answered),
16271
16600
  tie: sum === 0,
16601
+ unanswered: answered === 0,
16272
16602
  };
16273
16603
  });
16604
+ // 整维未答时 letter 只是 tie 占位;把它单独列出来,摘要与面板才不会当成「测出来了」
16605
+ const unanswered = dims.filter((d) => d.unanswered).map((d) => d.key);
16274
16606
  const type = dims.map((d) => d.picked).join('');
16275
16607
  const profile = TYPES[type];
16276
16608
  if (!profile) throw fail('E_SYSTEM', `内部错误:类型 ${type} 没有对应文案`);
@@ -16297,7 +16629,9 @@ function buildMbti(input = {}) {
16297
16629
  answered: answeredAll,
16298
16630
  skipped: QUESTIONS.length - answeredAll,
16299
16631
  total: QUESTIONS.length,
16300
- note: '四维各 6 题、李克特 1–5 计分,按维度净分取字母(平手时取 I / N / F / P 一侧并标「临界」)。这是 MBTI 风格的问卷测算,不是官方量表;类型只作自我参照,不是能力评价,也不用它给人下结论。',
16632
+ unanswered,
16633
+ note: '四维各 6 题、李克特 1–5 计分,按维度净分取字母(平手时取 I / N / F / P 一侧并标「临界」)。这是 MBTI 风格的问卷测算,不是官方量表;类型只作自我参照,不是能力评价,也不用它给人下结论。'
16634
+ + (unanswered.length ? ` 本轮 ${unanswered.join('、')} 维度一题未答,该维按平手取字母,只作占位,参考价值有限。` : ''),
16301
16635
  };
16302
16636
  }
16303
16637
 
@@ -16312,6 +16646,7 @@ const { ganzhiName, toJDN, fromJDN, dayGanzhiIndex } = (__mods.calendar || {});
16312
16646
  const { assertCivil, assertShifted } = (__mods.validate || {});
16313
16647
  const { hourToBranch } = (__mods.almanac || {});
16314
16648
  const { fail } = (__mods.fail || {});
16649
+ const { bool } = (__mods.bool || {});
16315
16650
 
16316
16651
  /** 六十甲子年骨重(单位:钱;索引 = (农历年 - 4) mod 60,0 = 甲子)。 */
16317
16652
  const YEAR_WEIGHT = [
@@ -16454,7 +16789,7 @@ function buildChenggu(input) {
16454
16789
  }
16455
16790
  // 晚子时换日与八字/六壬/奇门同口径:23:00–23:59 按次日取农历日与日柱,
16456
16791
  // 否则同一子时的前后两个钟点会差一天的日重
16457
- const lateZi = input.lateZi !== false;
16792
+ const lateZi = bool(input.lateZi, true);
16458
16793
  let sy = year;
16459
16794
  let sm = month;
16460
16795
  let sd = day;
@@ -16523,6 +16858,7 @@ __mods.xiaoliuren = (function () {
16523
16858
  // 小六壬(诸葛马前课):月/日/时(或报三个数)掐指落宫,六宫循环。
16524
16859
  // 口径:通行掌诀;断语为白话提炼(非原文照录)。轻量快占,属民俗参考。
16525
16860
  const { solarToLunar } = (__mods.lunar || {});
16861
+ const { bool } = (__mods.bool || {});
16526
16862
  const { hourToBranch } = (__mods.almanac || {});
16527
16863
  const { BRANCHES, fromJDN, toJDN } = (__mods.calendar || {});
16528
16864
  const { parseYmd } = (__mods.datetime || {});
@@ -16571,7 +16907,7 @@ function buildXiaoliuren(input) {
16571
16907
  let y = mt.year;
16572
16908
  let mo = mt.month;
16573
16909
  let dy = mt.day;
16574
- const lateZi = input.lateZi !== false;
16910
+ const lateZi = bool(input.lateZi, true);
16575
16911
  if (lateZi && input.hour >= 23) {
16576
16912
  const next = assertShifted(fromJDN(toJDN(y, mo, dy) + 1), '小六壬时间起课');
16577
16913
  y = next.year;
@@ -17929,6 +18265,7 @@ __mods.convert = (function () {
17929
18265
  const { solarToLunar } = (__mods.lunar || {});
17930
18266
  const { fromJDN, toJDN } = (__mods.calendar || {});
17931
18267
  const { buildAlmanac } = (__mods.almanac || {});
18268
+ const { bool } = (__mods.bool || {});
17932
18269
  const { assertCivil, assertObject, daysInMonth } = (__mods.validate || {});
17933
18270
  const { fail } = (__mods.fail || {});
17934
18271
 
@@ -18010,7 +18347,7 @@ function buildConvert(input) {
18010
18347
  if (m < 1 || m > 12) throw fail('E_INPUT', '农历月份须在 1–12');
18011
18348
  const months = lunarMonths(y);
18012
18349
  if (!months.length) throw fail('E_INPUT', `农历 ${y} 年无法定位正月,请核对年份(1600–2400)`);
18013
- const isLeap = input.isLeapMonth === true;
18350
+ const isLeap = bool(input.isLeapMonth);
18014
18351
  const hit = months.find((x) => x.month === m && x.isLeap === isLeap);
18015
18352
  if (!hit) {
18016
18353
  const leapMonths = months.filter((x) => x.isLeap).map((x) => `闰${MONTH_TEXT[x.month - 1]}月`);
@@ -22505,6 +22842,7 @@ __mods.rectify = (function () {
22505
22842
  // 2. 只有时柱(以及跨 23:00 时的日柱)会变,年/月柱通常不变,所以候选之间的差异集中在晚运、子女、事业后半段;
22506
22843
  // 3. 打分规则是显式、固定的(见 matchEvent),不是拟合;换一套规则排序可能变。
22507
22844
  const { buildBazi } = (__mods.bazi || {});
22845
+ const { bool } = (__mods.bool || {});
22508
22846
 
22509
22847
  const KINDS = ['career', 'wealth', 'love', 'move', 'health', 'other'];
22510
22848
  const HOURS = [0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 23];
@@ -22619,9 +22957,9 @@ function rectifyBirth(opts) {
22619
22957
  hour,
22620
22958
  minute: 0,
22621
22959
  gender,
22622
- lateZi: opts.lateZi !== false,
22623
- trueSolar: opts.trueSolar !== false,
22624
- dst: opts.dst !== false,
22960
+ lateZi: bool(opts.lateZi, true),
22961
+ trueSolar: bool(opts.trueSolar, true),
22962
+ dst: bool(opts.dst, true),
22625
22963
  address: typeof opts.address === 'string' ? opts.address : undefined,
22626
22964
  longitude: typeof opts.longitude === 'number' ? opts.longitude : undefined,
22627
22965
  geo: opts.geo && typeof opts.geo === 'object' ? opts.geo : undefined,
@@ -22706,6 +23044,7 @@ const { PATTERN_TONE } = (__mods.ziwei || {});
22706
23044
  const { yongshenOf, yongshenStrength, fushenAccess } = (__mods.liuyao || {});
22707
23045
  const { qimenYongshen } = (__mods['qimen-interpret'] || {});
22708
23046
  const { GAN_JI_GONG } = (__mods.daliuren || {});
23047
+ const { bool } = (__mods.bool || {});
22709
23048
 
22710
23049
  const SYSTEM_LABEL = { liuyao: '六爻', bazi: '八字', ziwei: '紫微', qimen: '奇门', daliuren: '大六壬' };
22711
23050
 
@@ -23126,7 +23465,7 @@ function buildTrace(result, opts = {}) {
23126
23465
  if (result.system === 'liuyao') {
23127
23466
  let view = result;
23128
23467
  // 面板改了「询问方向」但不想重摇一卦:只按新方向重算用神相关三层
23129
- if (opts.refresh === true) {
23468
+ if (bool(opts.refresh)) {
23130
23469
  try {
23131
23470
  const ug = yongshenOf(result, { direction: opts.direction, gender: opts.gender });
23132
23471
  const monthBranch = (result.hexStrength && result.hexStrength.month && result.hexStrength.month.branch)
@@ -25016,6 +25355,7 @@ const { buildZiweiHepan } = (__mods['ziwei-hepan'] || {});
25016
25355
  const { buildQimen, buildSnapshot } = (__mods.qimen || {});
25017
25356
  const { geocodeAddress, resolveAddress } = (__mods.geo || {});
25018
25357
  const { toJDN, ganzhiName, dayGanzhiIndex } = (__mods.calendar || {});
25358
+ const { bool, canonicalFlags, canonicalNumbers } = (__mods.bool || {});
25019
25359
  const { randomOf, isSeed } = (__mods.random || {});
25020
25360
  const { encodeHandle, decodeHandle, resolveHandle, pruneForeignKeys, ownedKeys } = (__mods.handle || {});
25021
25361
  const { askLink, parseAskLink, formOf, restNote, askPackages } = (__mods.bridge || {});
@@ -25041,7 +25381,7 @@ const { buildFengshui } = (__mods.fengshui || {});
25041
25381
  const { buildName } = (__mods.name || {});
25042
25382
  const { buildTrace, traceMarkdown, SYSTEM_LABEL } = (__mods.trace || {});
25043
25383
  const { fail } = (__mods.fail || {});
25044
- const { assertCivil } = (__mods.validate || {});
25384
+ const { assertCivil, MIN_YEAR, MAX_YEAR } = (__mods.validate || {});
25045
25385
  const { parseDateTime, daysInMonth } = (__mods.datetime || {});
25046
25386
 
25047
25387
 
@@ -25051,6 +25391,25 @@ const pad = (n) => String(n).padStart(2, '0');
25051
25391
 
25052
25392
  const GENDERS = ['male', 'female'];
25053
25393
 
25394
+ /**
25395
+ * 时刻会改变盘面、且允许只给日期的体系:那时按 00:00 排,必须当场说清。
25396
+ * 黄历 / 择日 / 公农历转换只以「日」为输入,缺时刻是正常用法;
25397
+ * 六爻取日辰与月建定六神、旬空,不看钟点;梅花数字起卦也不看时间——都在名单外。
25398
+ * 称骨与小六壬缺时辰直接报错(时辰不可代填),同样不需要这句提示。
25399
+ */
25400
+ const HOUR_MATTERS = new Set(['bazi', 'ziwei', 'hepan', 'trend', 'meihua', 'daliuren', 'qimen', 'name']);
25401
+ /** 缺时刻时那句提示里要说清的「按什么排」,以及该怎么补(hourUnknown 只对八字/趋势有定义) */
25402
+ const NO_TIME_NOTE = {
25403
+ bazi: { what: '时柱', advice: '知道大概几点就补上,不知道就传 hourUnknown:true(只排三柱)' },
25404
+ ziwei: { what: '命宫与生时星曜', advice: '紫微排不出三柱,必须补上出生时刻' },
25405
+ hepan: { what: '两侧时柱', advice: '两侧都要出生时刻,合盘才有意义' },
25406
+ trend: { what: '时柱与起运', advice: '知道大概几点就补上,不知道就传 hourUnknown:true(按日估算)' },
25407
+ meihua: { what: '起卦时刻', advice: '时间起卦要用真实起念时刻,请补 HH:mm' },
25408
+ daliuren: { what: '起课时辰(月将与贵人)', advice: '请补起课时刻 HH:mm' },
25409
+ qimen: { what: '起局时辰(旬首与局数)', advice: '请补起局时刻 HH:mm' },
25410
+ name: { what: '时柱', advice: '请补出生时刻 HH:mm' },
25411
+ };
25412
+
25054
25413
  /**
25055
25414
  * 性别是必填项:它决定大运/大限的顺逆,缺省按某一方排等于给出一张错盘。
25056
25415
  * 之前用 `=== 'female' ? 'female' : 'male'` 兜底,静默把未填性别的人按男命排。
@@ -25518,14 +25877,14 @@ function shadowPerson(person = {}) {
25518
25877
  if (person.gender) out.gender = String(person.gender).toLowerCase();
25519
25878
  if (person.longitude !== undefined) out.longitude = num6(person.longitude);
25520
25879
  else if (person.address) out.address = String(person.address).trim();
25521
- if (person.lateZi !== undefined) out.lateZi = person.lateZi !== false;
25522
- if (person.trueSolar !== undefined) out.trueSolar = person.trueSolar !== false;
25523
- if (person.dst !== undefined) out.dst = person.dst !== false;
25880
+ if (person.lateZi !== undefined) out.lateZi = bool(person.lateZi, true);
25881
+ if (person.trueSolar !== undefined) out.trueSolar = bool(person.trueSolar, true);
25882
+ if (person.dst !== undefined) out.dst = bool(person.dst, true);
25524
25883
  return out;
25525
25884
  }
25526
25885
 
25527
25886
  function qimenLateMode(args) {
25528
- if (args.lateZiHourMode === 'next-day' || args.lateZi === true) return 'next-day';
25887
+ if (args.lateZiHourMode === 'next-day' || bool(args.lateZi)) return 'next-day';
25529
25888
  return 'same-day';
25530
25889
  }
25531
25890
 
@@ -25537,8 +25896,8 @@ function shadowParams(args, result) {
25537
25896
  civil: input.civil,
25538
25897
  gender: input.gender,
25539
25898
  longitude: num6(input.longitude),
25540
- lateZi: input.lateZi !== false,
25541
- trueSolar: input.trueSolar !== false,
25899
+ lateZi: bool(input.lateZi, true),
25900
+ trueSolar: bool(input.trueSolar, true),
25542
25901
  dst: !!(input.dst && input.dst.applied),
25543
25902
  };
25544
25903
  }
@@ -25548,9 +25907,9 @@ function shadowParams(args, result) {
25548
25907
  gender: input.gender,
25549
25908
  longitude: num6(input.longitude),
25550
25909
  leapMonth: input.leapMonth || 'split',
25551
- leapAsNext: input.leapAsNext === true,
25910
+ leapAsNext: bool(input.leapAsNext),
25552
25911
  schools: input.schools || ZIWEI_SCHOOL_DEFAULTS,
25553
- trueSolar: input.trueSolar !== false,
25912
+ trueSolar: bool(input.trueSolar, true),
25554
25913
  dst: !!(input.dst && input.dst.applied),
25555
25914
  };
25556
25915
  }
@@ -25636,7 +25995,10 @@ function normalizeAsOf(value) {
25636
25995
  const parts = asOfParts(s);
25637
25996
  if (!parts) return s; // 非法值留给 checkAsOf 报错,指纹不抢答
25638
25997
  const p2 = (n) => String(n).padStart(2, '0');
25639
- return `${parts.year}-${p2(parts.month)}-${p2(parts.day)}T${p2(parts.hour)}:${p2(parts.minute)}`;
25998
+ // 年份也要补到 4 位:asOfParts 的正则只认四位年份,0000 原样拼成 '0-01-01T12:00'
25999
+ // 会在 checkAsOf 里被当成格式错误,报出「无法解析 asOf:「0-01-01T12:00」」这种看不懂的话。
26000
+ const y4 = String(parts.year).padStart(4, '0');
26001
+ return `${y4}-${p2(parts.month)}-${p2(parts.day)}T${p2(parts.hour)}:${p2(parts.minute)}`;
25640
26002
  }
25641
26003
 
25642
26004
  /**
@@ -25753,6 +26115,14 @@ function compute(input = {}) {
25753
26115
  // 称骨句柄里的 hour 会跟到八字盘上,被工具层当成误传报错。
25754
26116
  args = pruneForeignKeys(args, ownedKeys(input, rev.patch));
25755
26117
  }
26118
+ // 开关归一:排盘读的、句柄记的、指纹比的是同一份真布尔。
26119
+ // 少了这一刀,`trueSolar:"false"` 会排出「开真太阳时」的盘而句柄写 false——
26120
+ // 同一张盘两个身份,影子盘对拍与深链回放都会错过。
26121
+ args = canonicalFlags(args);
26122
+ // 数字归一:`count:"3"` 与 `count:3` 是同一张盘,句柄与指纹也只能有一个身份。
26123
+ // 放在开关之后、asOf / 经度 / verifyPast 整形之前:后面几处校验读到的是真数字,
26124
+ // 「收到「9」」这种字面看着没错的报错也就不会再出现。
26125
+ args = canonicalNumbers(args);
25756
26126
  // asOf 在入口就归一成 canonical 串(去首尾空格、只给日期补 12:00):
25757
26127
  // 排盘、句柄、影子盘指纹读同一份。以前只有指纹 trim,句柄照抄原文,
25758
26128
  // '2030-01-01' 与 '2030-01-01T12:00' 出的明明是同一张盘,却各得一个 handle、一个 baseId。
@@ -25827,6 +26197,36 @@ ${r.summary}`;
25827
26197
  r.summary = `时柱暂缺:起运与大运按日估算,仅供参考
25828
26198
  ${r.summary}`;
25829
26199
  }
26200
+ // 只给日期、没给时刻:parseDateTime 会把时分补成 00:00,于是照常排出完整四柱/起好局,
26201
+ // 而调用方以为「日期就够了」。这类静默默认正是最该说出来的一种:盘面上看不出任何异常。
26202
+ // 梅花数字起卦只读 upper/lower,datetime 不参与取卦,不该被这句提示打扰。
26203
+ const ignoresClock = r && r.system === 'meihua' && args.mode === 'number';
26204
+ const datetimeDateOnly = typeof args.datetime === 'string' && args.datetime.trim() !== ''
26205
+ && !/[T\s]\d{1,2}:\d{1,2}/.test(args.datetime.trim());
26206
+ // name 还支持 year/month/day(+hour/minute) 分开给生辰:只给年月日时,
26207
+ // buildName 内部同样按 00:00 占位,不能因为没走 datetime 就绕过这句提示。
26208
+ const nameDateOnly = r && r.system === 'name' && !(typeof args.datetime === 'string' && args.datetime.trim())
26209
+ && Number.isInteger(args.year) && Number.isInteger(args.month) && Number.isInteger(args.day)
26210
+ && !Number.isInteger(args.hour);
26211
+ if (r && !ignoresClock && !r.hourUnknown && !r.timeMissing && HOUR_MATTERS.has(r.system)
26212
+ && (datetimeDateOnly || nameDateOnly) && r.summary) {
26213
+ r.timeMissing = true;
26214
+ const note = NO_TIME_NOTE[r.system] || { what: '时刻', advice: '请补上时刻 HH:mm' };
26215
+ r.summary = `⚠ 只给了日期、没有时刻:${note.what}按 00:00 暂算,与真实结果可能整档不同;${note.advice}\n${r.summary}`;
26216
+ }
26217
+ // 合盘的另一方同样是「只给日期」的静默 00:00,主方有提示、对方没有就等于只报了一半
26218
+ if (r && r.system === 'hepan' && r.summary) {
26219
+ const missing = [];
26220
+ for (const [who, label] of [['partner', '对方'], ['partner2', '第三方']]) {
26221
+ const person = args[who];
26222
+ const when = person && typeof person === 'object' ? person.datetime : undefined;
26223
+ if (typeof when === 'string' && !/[T\s]\d{1,2}:\d{1,2}/.test(when.trim())) missing.push(label);
26224
+ }
26225
+ if (missing.length) {
26226
+ r.timeMissing = true;
26227
+ r.summary = `⚠ 只给了日期、没有时刻:${missing.join('、')}的时柱按 00:00 暂算,与真实结果可能整档不同;请补出生时刻 HH:mm\n${r.summary}`;
26228
+ }
26229
+ }
25830
26230
  // 显式要求时才附加解析模块,避免默认输出过长;「所问之事」与「询问方向」一并传进去
25831
26231
  const tier = detailOf(args.detail);
25832
26232
  if (args.withInterpret) {
@@ -25836,13 +26236,14 @@ ${r.summary}`;
25836
26236
  });
25837
26237
  // 档位只改「回给模型的文本」,不改解析对象:面板拿到的仍是完整的 interpret。
25838
26238
  // 键名不用 detail / tier:合盘结果里 r.detail 是详批对象、流年行里 r.tier 是档位,都会撞。
25839
- if (tier === 'lean') r.interpretTier = 'lean';
26239
+ // 有些体系没有解析模块(interpret 为 null),此时不该留下一个没有正文的档位键。
26240
+ if (r.interpret && tier !== 'full') r.interpretTier = tier;
25840
26241
  }
25841
26242
  // 八字 × 紫微交叉验证:同一份出生信息再排另一套盘,并列两边对同一件事的说法
25842
26243
  // 交叉验证要再排另一套盘:时辰未知时紫微排不出来,这条支路直接跳过,
25843
26244
  // 不能拿正午排一张紫微盘来「交叉」,那是两张都不可信的盘互证。
25844
- if (args.cross === true && args.hourUnknown === true) r.crossSkipped = 'HOUR_UNKNOWN';
25845
- if (args.cross === true && args.hourUnknown !== true && (r.system === 'bazi' || r.system === 'ziwei')) {
26245
+ if (bool(args.cross) && bool(args.hourUnknown)) r.crossSkipped = 'HOUR_UNKNOWN';
26246
+ if (bool(args.cross) && !bool(args.hourUnknown) && (r.system === 'bazi' || r.system === 'ziwei')) {
25846
26247
  const cdt = parseDateTime(args.datetime);
25847
26248
  const common = {
25848
26249
  ...cdt,
@@ -25850,13 +26251,28 @@ ${r.summary}`;
25850
26251
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
25851
26252
  address: typeof args.address === 'string' ? args.address : undefined,
25852
26253
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
25853
- trueSolar: args.trueSolar !== false,
25854
- dst: args.dst !== false,
26254
+ trueSolar: bool(args.trueSolar, true),
26255
+ dst: bool(args.dst, true),
25855
26256
  };
25856
26257
  const asOf = checkAsOf(args.asOf);
26258
+ // 八字显式写了 lateZi 时,交叉的紫微盘必须同口径:23:00 后一边按次日、一边按当日,
26259
+ // 等于拿两个生日互证。没写时仍按紫微自己的 current-day 缺省,不改既有交叉结果;
26260
+ // 显式 lateZishi(紫微历史参数名)优先。
26261
+ const crossLateZishi = args.lateZishi !== undefined
26262
+ ? args.lateZishi
26263
+ : args.lateZi === undefined || args.lateZi === null || args.lateZi === ''
26264
+ ? undefined
26265
+ : bool(args.lateZi, true) ? 'next-day' : 'current-day';
25857
26266
  const other = r.system === 'bazi'
25858
- ? buildZiwei({ ...common, leapMonth: args.leapMonth, leapAsNext: args.leapAsNext === true, ...ziweiSchoolArgs(args), asOf })
25859
- : buildBazi({ ...common, lateZi: args.lateZi !== false, nowYear: asOf ? asOf.year : undefined });
26267
+ ? buildZiwei({
26268
+ ...common,
26269
+ leapMonth: args.leapMonth,
26270
+ leapAsNext: bool(args.leapAsNext),
26271
+ ...ziweiSchoolArgs(args),
26272
+ ...(crossLateZishi !== undefined ? { lateZishi: crossLateZishi } : {}),
26273
+ asOf,
26274
+ })
26275
+ : buildBazi({ ...common, lateZi: bool(args.lateZi, true), nowYear: asOf ? asOf.year : undefined });
25860
26276
  r.cross = crossCheck(r.system === 'bazi' ? r : other, r.system === 'ziwei' ? r : other);
25861
26277
  if (r.interpret) {
25862
26278
  r.interpret.sections.push(crossSection(r.cross));
@@ -25870,14 +26286,14 @@ ${r.summary}`;
25870
26286
  ...parseDateTime(args.datetime),
25871
26287
  // 与主盘同口径:主盘 hourUnknown 时内部按正午占位,过去盘若还用 00:00,
25872
26288
  // 流年信号就来自子夜的盘,与用户看到的不是同一张
25873
- hourUnknown: args.hourUnknown === true,
26289
+ hourUnknown: bool(args.hourUnknown),
25874
26290
  gender: requireGender(args.gender),
25875
- lateZi: args.lateZi !== false,
25876
- trueSolar: args.trueSolar !== false,
26291
+ lateZi: bool(args.lateZi, true),
26292
+ trueSolar: bool(args.trueSolar, true),
25877
26293
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
25878
26294
  address: typeof args.address === 'string' ? args.address : undefined,
25879
26295
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
25880
- dst: args.dst !== false,
26296
+ dst: bool(args.dst, true),
25881
26297
  nowYear: from,
25882
26298
  });
25883
26299
  r.past = {
@@ -25887,16 +26303,16 @@ ${r.summary}`;
25887
26303
  };
25888
26304
  }
25889
26305
  // 生时校正:候选时辰 × 过去事件,按固定规则打分(仅八字)
25890
- if (args.rectify === true && r.system === 'bazi') {
26306
+ if (bool(args.rectify) && r.system === 'bazi') {
25891
26307
  const base = parseDateTime(args.datetime);
25892
26308
  r.rectify = rectifyBirth({
25893
26309
  base: { year: base.year, month: base.month, day: base.day, minute: base.minute },
25894
26310
  gender: requireGender(args.gender),
25895
26311
  events: Array.isArray(args.events) ? args.events : [],
25896
26312
  hours: Array.isArray(args.rectifyHours) ? args.rectifyHours : undefined,
25897
- lateZi: args.lateZi !== false,
25898
- trueSolar: args.trueSolar !== false,
25899
- dst: args.dst !== false,
26313
+ lateZi: bool(args.lateZi, true),
26314
+ trueSolar: bool(args.trueSolar, true),
26315
+ dst: bool(args.dst, true),
25900
26316
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
25901
26317
  address: typeof args.address === 'string' ? args.address : undefined,
25902
26318
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
@@ -25905,7 +26321,7 @@ ${r.summary}`;
25905
26321
  // 追问:围绕已算好的盘回答「某一年 / 某方面」的具体问题
25906
26322
  if (typeof args.ask === 'string' && args.ask.trim()) r.followup = followup(r, args.ask);
25907
26323
  // 推导链:只读结果、不重算;生成失败不影响盘面,单独留一条错误信息
25908
- if (args.trace === true) {
26324
+ if (bool(args.trace)) {
25909
26325
  try {
25910
26326
  const layers = buildTrace(r, { direction: args.direction, gender: args.gender });
25911
26327
  if (layers) {
@@ -25918,7 +26334,7 @@ ${r.summary}`;
25918
26334
  }
25919
26335
  }
25920
26336
  // 影子盘 ID:同一组归一化参数 + 同一版本 → 同一个短 ID;显式要时才挂,避免默认输出变长
25921
- if (args.shadow === true) {
26337
+ if (bool(args.shadow)) {
25922
26338
  try {
25923
26339
  r.shadow = chartFingerprint(args, { result: r, version: args.shadowVersion });
25924
26340
  } catch (e) {
@@ -25936,11 +26352,17 @@ ${r.summary}`;
25936
26352
  }
25937
26353
 
25938
26354
  /** 解析与详解的紧凑文本(给模型看,不塞整块 JSON)
25939
- * detail:'full'(默认,与历史输出逐字一致)或 'lean'(只给结论、你问的那条与三张表,
25940
- * 长论述与「规则·出处」折成一行指针)。省的是回给模型的文本,不改盘面、不改解析对象本身。 */
26355
+ * detail:'full'(默认全文)/ 'lean'(只给结论、所问方向与三张表,长论述与规则出处折成指针)/
26356
+ * 'brief'(在 lean 上再限表行;工具层在 withInterpret 且未指定档位时用这一档)。
26357
+ * 省的是回给模型的文本,不改盘面、不改解析对象本身。
26358
+ * **不设体积上限**:brief 只做「少给哪些维度、表最多几行」这类结构性收敛,
26359
+ * 超长就让它超长——按字节截断会把结论、依据、边界一起腰斩,省下的体积不值这个代价。 */
25941
26360
  function interpretText(i, detail) {
25942
26361
  if (!i) return '';
26362
+ const brief = detail === 'brief';
25943
26363
  const lean = detail === 'lean';
26364
+ const compact = brief || lean;
26365
+ const BRIEF_TABLE_ROWS = 8;
25944
26366
  const LONG_SECTION = 300;
25945
26367
  const out = [`【${i.title || '解析与详解'}】${i.ask && i.ask.echo ? i.ask.echo : ''}`];
25946
26368
  // 直答放在最前:先回答「你问的事」,再说依据,避免读者读到最后才知道结论;
@@ -25956,12 +26378,12 @@ function interpretText(i, detail) {
25956
26378
  if (i.error) out.push(`⚠ 解析生成失败:${i.error}(上方盘面数据本身可用)`);
25957
26379
  const allDims = i.dimensions || [];
25958
26380
  // 问了方向就只给那一条:其余四条在 full 档里,模型要展开随时可以再排一次
25959
- const dims = lean && allDims.some((d) => d && d.focused) ? allDims.filter((d) => d && d.focused) : allDims;
26381
+ const dims = compact && allDims.some((d) => d && d.focused) ? allDims.filter((d) => d && d.focused) : allDims;
25960
26382
  for (const d of dims) {
25961
26383
  const evidence = Array.isArray(d.evidence) && d.evidence.length ? `\n 依据:${d.evidence.join(';')}${d.confidence ? ` 置信度:${d.confidence}` : ''}` : '';
25962
26384
  const plain = d.plain ? `(${d.plain})` : '';
25963
26385
  // 知识条目:「为什么这样断」+出处+可信度标注,是结论与依据之外的第三层
25964
- const know = lean
26386
+ const know = compact
25965
26387
  ? ((d.knowledge || []).length ? `\n 规则 ${d.knowledge.length} 条未展开(detail:"full" 给出原文与出处)` : '')
25966
26388
  : (d.knowledge || [])
25967
26389
  .map((k) => `\n 规则·${k.gist}〔${k.statusLabel}〕${k.detail} 出处:${k.source}${k.note ? ` 注:${k.note}` : ''}`)
@@ -25969,31 +26391,41 @@ function interpretText(i, detail) {
25969
26391
  out.push(`${d.label}:${plain}${d.text}${d.advice ? ` 建议:${d.advice}` : ''}${evidence}${know}`);
25970
26392
  }
25971
26393
  const secs = i.sections || [];
25972
- const longSecs = lean ? secs.filter((s) => String(s.text || '').length > LONG_SECTION) : [];
26394
+ const longSecs = compact ? secs.filter((s) => String(s.text || '').length > LONG_SECTION) : [];
25973
26395
  for (const s of secs) {
25974
- if (lean && String(s.text || '').length > LONG_SECTION) continue;
26396
+ if (compact && String(s.text || '').length > LONG_SECTION) continue;
25975
26397
  out.push(`${s.label}:${s.text}`);
25976
26398
  }
25977
26399
  if (longSecs.length) out.push(`(另有 ${longSecs.length} 节长论述未展开:${longSecs.map((s) => s.label).join('、')}。需要原文与出处时传 detail:"full")`);
25978
26400
  // 三张表:大运 / 流年 / 触发事件(纯文本对齐,工具输出也能直接读)
25979
26401
  for (const t of i.tables || []) {
25980
26402
  if (!Array.isArray(t.rows) || !t.rows.length) continue;
26403
+ let rows = t.rows;
25981
26404
  out.push(`【${t.title}】`);
25982
- out.push([t.columns.join(' | '), ...t.rows.map((r) => r.join(' | '))].join('\n'));
26405
+ if (brief && rows.length > BRIEF_TABLE_ROWS) {
26406
+ rows = rows.slice(0, BRIEF_TABLE_ROWS);
26407
+ out.push(`(共 ${t.rows.length} 行,仅列前 ${BRIEF_TABLE_ROWS} 行;全表传 detail:"lean")`);
26408
+ }
26409
+ out.push([t.columns.join(' | '), ...rows.map((r) => r.join(' | '))].join('\n'));
25983
26410
  }
25984
26411
  if (Array.isArray(i.followups) && i.followups.length) {
25985
26412
  out.push('还可以这样追问:' + i.followups.map((q) => `「${q}」`).join(' '));
25986
26413
  }
25987
- if (Array.isArray(i.glossary) && i.glossary.length) {
26414
+ if (!brief && Array.isArray(i.glossary) && i.glossary.length) {
25988
26415
  out.push('名词解释:' + i.glossary.map((g) => `${g.term}=${g.plain}`).join(' '));
25989
26416
  }
25990
26417
  // 能力边界:这段是给调用方(模型)看的上下文,不是给用户直接念的。
25991
26418
  // 写全比只写标题有用——模型知道「为什么不答」,才不会自己补一个答案出来。
26419
+ let text = '';
25992
26420
  if (Array.isArray(i.limits) && i.limits.length) {
25993
- out.push('【本插件不回答什么】' + i.limits.map((l) => `${l.title}——${l.text}`).join('\n'));
26421
+ text += `【本插件不回答什么】${i.limits.map((l) => `${l.title}——${l.text}`).join('\n')}\n`;
25994
26422
  }
25995
- if (i.disclaimer) out.push(i.disclaimer);
25996
- return out.join('\n');
26423
+ if (i.disclaimer) text += i.disclaimer;
26424
+ // 不按体积截断:这里只把「边界与免责声明」放在末尾,
26425
+ // 正文一个字都不砍——brief 已经用「少给维度、表限行数」控过长度了,
26426
+ // 再按字节腰斩只会把结论、依据和必要交代一起截掉,反而让模型读到半句话。
26427
+ const head = out.join('\n');
26428
+ return text ? `${head}\n${text}` : head;
25997
26429
  }
25998
26430
 
25999
26431
  /** 对照时不参与计算的参数:它们只影响解析/附加模块,不影响盘面 */
@@ -26113,12 +26545,12 @@ function normalizeLongitudes(args) {
26113
26545
  return out;
26114
26546
  }
26115
26547
 
26116
- /** 输出档位:缺省与 'full' 都是历史全文;'lean' 只回结论与你问的那一条,省模型上下文。
26117
- * 其它值以前会被当成「缺省」静默放过,写了 detail:'brief' 的人以为自己省了钱,其实没有。 */
26548
+ /** 输出档位:缺省 'full'(面板与直接调用保持历史全文);'lean' 去掉长论述与规则出处,
26549
+ * 'brief' 在 lean 上再限表行(不设体积上限)。工具层在 withInterpret 且未指定时传 brief。 */
26118
26550
  function detailOf(value) {
26119
- if (value === undefined || value === null || value === '' || value === 'full') return 'full';
26120
- if (value === 'lean') return 'lean';
26121
- throw fail('E_INPUT', `detail 只能是 'full' 或 'lean':收到「${String(value).slice(0, 24)}」`);
26551
+ if (value === undefined || value === null || value === '') return 'full';
26552
+ if (value === 'full' || value === 'lean' || value === 'brief') return value;
26553
+ throw fail('E_INPUT', `detail 只能是 'full' / 'lean' / 'brief':收到「${String(value).slice(0, 24)}」`);
26122
26554
  }
26123
26555
 
26124
26556
  /** asOf 只接受能解析成真实日期的字符串;非法值以前会静默回退到「此刻」 */
@@ -26129,6 +26561,11 @@ function checkAsOf(asOf) {
26129
26561
  const parts = asOfParts(asOf);
26130
26562
  if (!parts) throw fail('E_ASOF', `无法解析 asOf:「${asOf}」,请用 2026-10-22T16:00 这种格式`);
26131
26563
  const { year, month, day, hour, minute } = parts;
26564
+ // 与 parseDateTime / assertCivil 同一把年份尺:asOf 只校验月日时,1500 / 2500 / 9999
26565
+ // 会一路排进紫微流月流日,农历表却只覆盖 1600–2400,出来的是一张外推盘。
26566
+ if (year < MIN_YEAR || year > MAX_YEAR) {
26567
+ throw fail('E_ASOF', `asOf 的年份超出可计算范围(${MIN_YEAR}–${MAX_YEAR}):${asOf}`);
26568
+ }
26132
26569
  if (!(month >= 1 && month <= 12) || !(day >= 1 && day <= daysInMonth(year, month))) {
26133
26570
  throw fail('E_ASOF', `asOf 指向的日期不存在:${asOf}`);
26134
26571
  }
@@ -26158,6 +26595,17 @@ function computeRaw(args = {}) {
26158
26595
  throw fail('E_INPUT', `${system} 的 mode 只能是 ${allowed.join(' / ')},收到「${String(args.mode).slice(0, 24)}」`);
26159
26596
  }
26160
26597
  }
26598
+ // gender / direction 的枚举写在 schema 里,引擎直调也得守同一份契约:
26599
+ // 六爻曾把「女」静默当 male 出用神,direction 拼错则静默按 general——
26600
+ // 换一个用神、换一套断法,盘面却看不出任何异常。
26601
+ if (args.gender !== undefined && args.gender !== null && args.gender !== ''
26602
+ && args.gender !== 'male' && args.gender !== 'female') {
26603
+ throw fail('E_INPUT', `gender 只能是 male / female,收到「${String(args.gender).slice(0, 24)}」`);
26604
+ }
26605
+ if (args.direction !== undefined && args.direction !== null && args.direction !== ''
26606
+ && !['general', 'wealth', 'career', 'love', 'health', 'study', 'travel'].includes(args.direction)) {
26607
+ throw fail('E_INPUT', `direction 只能是 general / wealth / career / love / health / study / travel,收到「${String(args.direction).slice(0, 24)}」`);
26608
+ }
26161
26609
  // 风水 fortuneYear 以前只认整数:2026.5 被静默当成「没给」,整块年飞星消失。
26162
26610
  if (args.fortuneYear !== undefined && args.fortuneYear !== null && args.fortuneYear !== '') {
26163
26611
  const n = Number(args.fortuneYear);
@@ -26175,25 +26623,25 @@ function computeRaw(args = {}) {
26175
26623
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
26176
26624
  address: typeof args.address === 'string' ? args.address : undefined,
26177
26625
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
26178
- lateZi: args.lateZi !== false,
26179
- trueSolar: args.trueSolar !== false,
26180
- dst: args.dst !== false,
26626
+ lateZi: bool(args.lateZi, true),
26627
+ trueSolar: bool(args.trueSolar, true),
26628
+ dst: bool(args.dst, true),
26181
26629
  // 流年表默认从「今年」起排;要复现历史结论就把基准年钉死
26182
26630
  nowYear: asOf ? asOf.year : undefined,
26183
26631
  // 时辰未知:三柱模式(时柱不排、精度降到日、摘要首行固定提示)
26184
- hourUnknown: args.hourUnknown === true,
26632
+ hourUnknown: bool(args.hourUnknown),
26185
26633
  });
26186
26634
  return { ...result, ...(asOf ? { asOf } : {}), precision: dt.precision, summary: baziText(result) };
26187
26635
  }
26188
26636
  if (system === 'ziwei') {
26189
26637
  // 命宫由「生月 + 生时支」定:时支未知则整盘无处落脚,没有「大概的紫微盘」这种东西
26190
- if (args.hourUnknown === true) {
26638
+ if (bool(args.hourUnknown)) {
26191
26639
  throw fail('HOUR_UNKNOWN', '紫微必须有出生时刻:命宫由生月与生时支定,时支未知则整盘不成立。请补上出生时刻,或改用八字三柱模式只看年/月/日。');
26192
26640
  }
26193
26641
  // 与奇门同一个别名口径:lateZi 是八字/六壬的参数名,紫微的历史参数名是 lateZishi。
26194
26642
  // 不归一的话 revise「晚子时算次日」会照常回执已应用,盘却按默认 current-day 排。
26195
26643
  if (args.lateZi !== undefined && args.lateZishi === undefined) {
26196
- args = { ...args, lateZishi: args.lateZi === false ? 'current-day' : 'next-day' };
26644
+ args = { ...args, lateZishi: bool(args.lateZi, true) ? 'next-day' : 'current-day' };
26197
26645
  }
26198
26646
  const dt = parseDateTime(args.datetime);
26199
26647
  const asOf = checkAsOf(args.asOf);
@@ -26201,13 +26649,13 @@ function computeRaw(args = {}) {
26201
26649
  ...dt,
26202
26650
  gender: requireGender(args.gender),
26203
26651
  leapMonth: args.leapMonth,
26204
- leapAsNext: args.leapAsNext === true,
26652
+ leapAsNext: bool(args.leapAsNext),
26205
26653
  ...ziweiSchoolArgs(args),
26206
26654
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
26207
26655
  address: typeof args.address === 'string' ? args.address : undefined,
26208
26656
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
26209
- trueSolar: args.trueSolar,
26210
- dst: args.dst !== false,
26657
+ trueSolar: bool(args.trueSolar, true),
26658
+ dst: bool(args.dst, true),
26211
26659
  // 流月/流日/流时的基准时刻:默认本机此刻,可用 asOf 指定以便复现
26212
26660
  asOf,
26213
26661
  });
@@ -26227,7 +26675,7 @@ function computeRaw(args = {}) {
26227
26675
  }
26228
26676
  if (system === 'daliuren') {
26229
26677
  const dt = parseDateTime(args.datetime);
26230
- const lateZi = args.lateZi !== false;
26678
+ const lateZi = bool(args.lateZi, true);
26231
26679
  const result = buildDaliuren({ ...dt, lateZi });
26232
26680
  result.lateZi = lateZi;
26233
26681
  return { ...result, precision: dt.precision, summary: daliurenText(result) };
@@ -26241,7 +26689,7 @@ function computeRaw(args = {}) {
26241
26689
  // lateZiHourMode 是奇门的历史参数名,lateZi 是八字/六壬的;两者互为别名。
26242
26690
  const mode = args.lateZiHourMode !== undefined
26243
26691
  ? args.lateZiHourMode
26244
- : args.lateZi === true ? 'next-day' : args.lateZi === false ? 'same-day' : undefined;
26692
+ : args.lateZi === undefined || args.lateZi === null ? undefined : bool(args.lateZi) ? 'next-day' : 'same-day';
26245
26693
  if (mode !== undefined && !LATE_ZI_MODES.includes(mode)) {
26246
26694
  throw fail('E_INPUT', `lateZiHourMode 只能是 same-day / next-day,收到「${mode}」`);
26247
26695
  }
@@ -26251,9 +26699,14 @@ function computeRaw(args = {}) {
26251
26699
  return { ...result, summary: qimenText(result) };
26252
26700
  }
26253
26701
  if (system === 'hepan') {
26254
- // 双方夫妻宫、大运都依赖时支:任一方时辰未知就不出盘,免得「差不多」的合盘误导决定
26255
- if (args.hourUnknown === true || (args.partner && args.partner.hourUnknown === true)) {
26256
- throw fail('HOUR_UNKNOWN', '合盘需要双方都有出生时刻:夫妻宫与大运都依赖时支。请补齐时刻后再看,或用八字三柱模式各自看年/月/日。');
26702
+ // 双方(以及可选的第三方)夫妻宫、大运都依赖时支:任一方时辰未知就不出盘,
26703
+ // 免得「差不多」的合盘误导决定。第三方只在给了 partner2 时才参与校验,
26704
+ // 但一旦参与,口径必须和主方、对方一致——不能主方缺时柱就拦、第三方缺时柱却照排。
26705
+ const unknownSide = bool(args.hourUnknown)
26706
+ || (args.partner && bool(args.partner.hourUnknown))
26707
+ || (args.partner2 && bool(args.partner2.hourUnknown));
26708
+ if (unknownSide) {
26709
+ throw fail('HOUR_UNKNOWN', '合盘需要每一方都有出生时刻:夫妻宫与大运都依赖时支。请补齐时刻后再看,或用八字三柱模式各自看年/月/日。');
26257
26710
  }
26258
26711
  const partner = args.partner;
26259
26712
  if (!partner || typeof partner !== 'object') {
@@ -26275,12 +26728,23 @@ function computeRaw(args = {}) {
26275
26728
  // 性别决定双方大运/大限顺逆,两边都不能用默认值
26276
26729
  const sideOf = (src, who) => {
26277
26730
  const dt = parseDateTime(src.datetime);
26731
+ // 紫微读的是历史参数名 lateZishi,合盘这一层若不转写,`chart:'ziwei', lateZi:false`
26732
+ // 会排出与 true 完全相同的盘(八字合盘同一开关却生效)。
26733
+ const lateZishi = src.lateZishi !== undefined
26734
+ ? src.lateZishi
26735
+ : src.lateZi === undefined || src.lateZi === null || src.lateZi === ''
26736
+ ? undefined
26737
+ : bool(src.lateZi, true) ? 'next-day' : 'current-day';
26278
26738
  return {
26279
26739
  ...dt,
26280
26740
  gender: requireGender(src.gender, who),
26281
26741
  trueSolar: src.trueSolar,
26282
26742
  lateZi: src.lateZi,
26283
- dst: src.dst !== false,
26743
+ ...(lateZishi !== undefined ? { lateZishi } : {}),
26744
+ // 紫微的闰月口径同属「读盘时才算」的参数,漏传会让合盘与单盘在闰月出生时差一个月
26745
+ ...(src.leapMonth !== undefined ? { leapMonth: src.leapMonth } : {}),
26746
+ ...(src.leapAsNext !== undefined ? { leapAsNext: bool(src.leapAsNext) } : {}),
26747
+ dst: bool(src.dst, true),
26284
26748
  address: typeof src.address === 'string' ? src.address : undefined,
26285
26749
  longitude: typeof src.longitude === 'number' ? src.longitude : undefined,
26286
26750
  geo: src.geo && typeof src.geo === 'object' ? src.geo : undefined,
@@ -26434,7 +26898,7 @@ function computeRaw(args = {}) {
26434
26898
  lunarYear: Number(args.lunarYear),
26435
26899
  lunarMonth: Number(args.lunarMonth),
26436
26900
  lunarDay: Number(args.lunarDay),
26437
- isLeapMonth: args.isLeapMonth === true,
26901
+ isLeapMonth: bool(args.isLeapMonth),
26438
26902
  });
26439
26903
  } else {
26440
26904
  const dt = parseDateTime(args.datetime);
@@ -26485,18 +26949,18 @@ function computeRaw(args = {}) {
26485
26949
  nowYear: nowParts ? nowParts.year : undefined,
26486
26950
  gender: requireGender(args.gender),
26487
26951
  toAge: args.toAge,
26488
- lateZi: args.lateZi !== false,
26489
- trueSolar: args.trueSolar !== false,
26490
- dst: args.dst !== false,
26952
+ lateZi: bool(args.lateZi, true),
26953
+ trueSolar: bool(args.trueSolar, true),
26954
+ dst: bool(args.dst, true),
26491
26955
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
26492
26956
  address: typeof args.address === 'string' ? args.address : undefined,
26493
26957
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
26494
- hourUnknown: args.hourUnknown === true,
26958
+ hourUnknown: bool(args.hourUnknown),
26495
26959
  });
26496
26960
  // 趋势没有独立的 dayun 字段(大运在 buildTrend 内部用),所以精度标记挂在结果顶层
26497
26961
  return {
26498
26962
  ...result,
26499
- ...(args.hourUnknown === true ? { hourUnknown: true, hourPrecision: 'day' } : {}),
26963
+ ...(bool(args.hourUnknown) ? { hourUnknown: true, hourPrecision: 'day' } : {}),
26500
26964
  precision: dt.precision,
26501
26965
  summary: trendText(result),
26502
26966
  };
@@ -26519,7 +26983,7 @@ function computeRaw(args = {}) {
26519
26983
  ...(typeof args.facingDegree === 'number' ? { facingDegree: args.facingDegree } : {}),
26520
26984
  ...(typeof args.fortuneDate === 'string' ? { fortuneDate: args.fortuneDate } : {}),
26521
26985
  ...(typeof args.fortuneTime === 'string' ? { fortuneTime: args.fortuneTime } : {}),
26522
- dst: args.dst !== false,
26986
+ dst: bool(args.dst, true),
26523
26987
  });
26524
26988
  return { ...result, summary: fengshuiText(result) };
26525
26989
  }
@@ -26530,7 +26994,7 @@ function computeRaw(args = {}) {
26530
26994
  facing: args.facing,
26531
26995
  ...(args.datetime ? parseDateTime(args.datetime) : {}),
26532
26996
  ...(args.gender === 'male' || args.gender === 'female' ? { gender: args.gender } : {}),
26533
- dst: args.dst !== false,
26997
+ dst: bool(args.dst, true),
26534
26998
  });
26535
26999
  return { ...result, summary: fengshuiText(result) };
26536
27000
  }
@@ -26540,7 +27004,7 @@ function computeRaw(args = {}) {
26540
27004
  year: dt.year, month: dt.month, day: dt.day,
26541
27005
  gender: requireGender(args.gender),
26542
27006
  fortuneYear: args.fortuneYear,
26543
- dst: args.dst !== false,
27007
+ dst: bool(args.dst, true),
26544
27008
  });
26545
27009
  return { ...result, summary: fengshuiText(result) };
26546
27010
  }
@@ -26569,9 +27033,9 @@ function computeRaw(args = {}) {
26569
27033
  ...birth,
26570
27034
  ...(args.gender === 'male' || args.gender === 'female' ? { gender: args.gender } : {}),
26571
27035
  ...(args.datetime ? {
26572
- lateZi: args.lateZi !== false,
26573
- trueSolar: args.trueSolar !== false,
26574
- dst: args.dst !== false,
27036
+ lateZi: bool(args.lateZi, true),
27037
+ trueSolar: bool(args.trueSolar, true),
27038
+ dst: bool(args.dst, true),
26575
27039
  longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
26576
27040
  address: typeof args.address === 'string' ? args.address : undefined,
26577
27041
  geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
@@ -26717,8 +27181,11 @@ function mbtiText(r) {
26717
27181
  const stack = Array.isArray(p.stack) && p.stack.length
26718
27182
  ? p.stack.map((f, i) => `${i === 0 ? '主导 ' : ''}${f.code}`).join(' → ') + `\n ${p.stack.map((f) => `${f.code}:${f.say}`).join('\n ')}`
26719
27183
  : '';
27184
+ const missing = Array.isArray(r.unanswered) && r.unanswered.length
27185
+ ? ` 未答维度:${r.unanswered.join('、')}(该维按平手占位)`
27186
+ : '';
26720
27187
  return [
26721
- `【十六型人格】${r.type}(${p.title})· ${p.keywords} 已答 ${r.answered}/${r.total} 题`,
27188
+ `【十六型人格】${r.type}(${p.title})· ${p.keywords} 已答 ${r.answered}/${r.total} 题${missing}`,
26722
27189
  `一句:${p.oneLine}`,
26723
27190
  '【四维】',
26724
27191
  ...dims,
@@ -26892,6 +27359,8 @@ function renderText(result) {
26892
27359
  parts.push(`【推导链】${SYSTEM_LABEL[result.system] || result.system} · ${result.trace.length} 层\n`
26893
27360
  + result.trace.map((t, i) => `${i + 1}. ${t.field}|${t.result}\n 规则:${t.rule} 出处:${t.source}`).join('\n'));
26894
27361
  }
27362
+ // 解析段按档位渲染。brief 只做结构性收敛(少给维度、表限行数),不压体积:
27363
+ // 盘面、句柄、解析全都不裁,这段有多长就多长。
26895
27364
  if (result.interpret) {
26896
27365
  const extra = interpretText(result.interpret, result.interpretTier);
26897
27366
  if (extra) parts.push(extra);
@@ -26962,7 +27431,7 @@ return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, parseDate
26962
27431
  })();
26963
27432
 
26964
27433
  window.Engine = __mods.index;
26965
- window.__MP_VER = "0.62.1";
27434
+ window.__MP_VER = "0.62.3";
26966
27435
  </script>
26967
27436
  <script>
26968
27437
  // 两个 UI 共用的表单规则:宿主面板(src/app.js)与独立页(src/web-ui.js)。