dsh-metaphysics 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/engine/geju.js CHANGED
@@ -8,6 +8,7 @@
8
8
  // 调候由 tiaohou.js 独立判定,与扶抑冲突时显式裁决并写明理由,不静默取用。
9
9
 
10
10
  import { judgeClimate, arbitrate } from './tiaohou.js';
11
+ import { qtOf } from './qiongtong.js';
11
12
 
12
13
  const STEMS = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];
13
14
  const BRANCHES = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];
@@ -213,6 +214,8 @@ function yongshenOf(dayStem, monthBranch, strength, wuxing, branches = []) {
213
214
 
214
215
  // 先判气候,再决定要不要让调候压过扶抑
215
216
  const climate = judgeClimate({ monthBranch, dayStem, wuxing, branches });
217
+ // 《穷通宝鉴》120 格:同一「日主 + 月令」的取用顺序。只作展示与加权,不覆盖气候调候
218
+ const qt = qtOf(dayStem, monthBranch);
216
219
  const arb = arbitrate(climate, baseFavor, baseAvoid);
217
220
  if (climate.need && climate.priority === '调候优先') {
218
221
  const needEl = climate.need.element;
@@ -238,6 +241,7 @@ function yongshenOf(dayStem, monthBranch, strength, wuxing, branches = []) {
238
241
  ? `喜${roles.shi}(食伤)泄秀、${roles.cai}(财)耗、${roles.guan}(官杀)制;忌${me}(比劫)与${roles.inMe}(印)再助。`
239
242
  : '身中和,先取调候与通关,喜忌随大运流年动态变化。',
240
243
  `调候:${climate.label}(${(climate.evidence || []).join('、')})${climate.need ? `,取${climate.need.stem}${climate.need.element},忌${climate.avoidElement}` : ',气候平和'}。`,
244
+ qt ? `穷通宝鉴:${qt.month}${dayStem}${me},用神${qt.yong.join('、')}(首取${qt.primary})。` : '',
241
245
  arb.text,
242
246
  arb.clash ? '取舍:本盘按「调候优先、扶抑次之」取用;若你更认同扶抑派,可把调候当环境偏好,强弱判断不受影响。' : '',
243
247
  ].filter(Boolean).join('');
@@ -253,6 +257,7 @@ function yongshenOf(dayStem, monthBranch, strength, wuxing, branches = []) {
253
257
  avoidTenGods,
254
258
  tiaohou: { ...climate, ...arb, element: climate.need ? climate.need.element : null },
255
259
  climate,
260
+ qt,
256
261
  detail,
257
262
  };
258
263
  }
@@ -318,6 +323,18 @@ export function scoreLuck(ganzhi, frame) {
318
323
 
319
324
  const godStem = tenGod(frame.dayStem, stem);
320
325
  const bonus = ys.favorTenGods.includes(godStem) ? 0.3 : 0;
326
+ // 穷通宝鉴:天干正好是这一格的首取/次取时,再给一点「按书取用」的分
327
+ // 只在该干不属于忌神时加分——书里的取用与气候调候不同向时,以调候为先
328
+ const qt = ys.qt || null;
329
+ if (qt && qt.primary && !ys.avoid.includes(STEM_ELEMENT[qt.primary])) {
330
+ if (stem === qt.primary) {
331
+ score += 0.3;
332
+ reasons.push(`天干${stem}正是${qt.branch}月${qt.stem}日的首取(穷通宝鉴)`);
333
+ } else if (qt.yong.includes(stem) && !ys.avoid.includes(STEM_ELEMENT[stem])) {
334
+ score += 0.15;
335
+ reasons.push(`天干${stem}为穷通宝鉴次取`);
336
+ }
337
+ }
321
338
  let total = Math.round((score + bonus) * 10) / 10;
322
339
  total = Math.max(-4, Math.min(4, total));
323
340
 
package/engine/geo.js CHANGED
@@ -143,7 +143,7 @@ const DETAIL = /(区|县|镇|乡|村|小区|街道|路|号|巷|弄|组|队)/;
143
143
 
144
144
  /** OpenStreetMap Nominatim:免密钥、支持中文。失败返回 null。
145
145
  * UA 按 OSM 使用政策要求写明应用与联系方式(改版本时同步这里)。 */
146
- const USER_AGENT = 'dsh-metaphysics/0.20.0 (+https://github.com/xuanfu-web/dsh-metaphysics)';
146
+ const USER_AGENT = 'dsh-metaphysics/0.21.0 (+https://github.com/xuanfu-web/dsh-metaphysics)';
147
147
 
148
148
  async function onlineLookup(text, { timeoutMs = 2500 } = {}) {
149
149
  if (typeof fetch !== 'function') return null;
package/engine/index.js CHANGED
@@ -21,7 +21,7 @@ import { buildZeri } from './zeri.js';
21
21
  import { buildChenggu } from './chenggu.js';
22
22
  import { buildXiaoliuren } from './xiaoliuren.js';
23
23
  import { buildStar } from './star.js';
24
- import { buildNumerology } from './numerology.js';
24
+ import { buildNumerology } from './numerology.js';
25
25
  import { buildConvert } from './convert.js';
26
26
  import { buildTrend } from './trend.js';
27
27
  import { buildFengshui } from './fengshui.js';
@@ -110,7 +110,8 @@ function baziText(r) {
110
110
  `   ${r.frame.geju.map((g) => `${g.name}[${g.kind}]`).join(' ')}`,
111
111
  `用神:喜${r.frame.yongshen.favor.join('')}(${r.frame.yongshen.favorTenGods.join('、')}) 忌${r.frame.yongshen.avoid.join('')}(${r.frame.yongshen.avoidTenGods.join('、')}) ${r.frame.yongshen.method}`,
112
112
  `   ${r.frame.yongshen.detail}`,
113
- `寒暖:${r.climate ? `${r.climate.label}(${(r.climate.evidence || []).join('、')})${r.climate.need ? ` 调候取${r.climate.need.stem}${r.climate.need.element} 忌${r.climate.avoidElement}` : ''}` : '—'}`,
113
+ `寒暖:${r.climate ? `${r.climate.label}(${(r.climate.evidence || []).join('、')})${r.climate.need ? ` 调候取${r.climate.need.stem}${r.climate.need.element} 忌${r.climate.avoidElement}` : ''}` : '—'}` +
114
+ (r.frame.yongshen.qt ? ` 穷通:${r.frame.yongshen.qt.month}${r.frame.yongshen.qt.stem}取${r.frame.yongshen.qt.yong.join('、')}(首取${r.frame.yongshen.qt.primary})` : ''),
114
115
  `十神权重:${Object.entries(r.frame.godStats.groups).map(([k, v]) => `${k}${v}`).join(' ')}`,
115
116
  ] : [];
116
117
  return [
@@ -374,6 +374,11 @@ function baziInterpret(r) {
374
374
  ? `调候取${cli.need.stem}${cli.need.element},忌${cli.avoidElement};${cli.clash ? '与扶抑冲突,本盘以调候为先' : '与扶抑同向'}`
375
375
  : '气候平和,调候不作主取'}。`,
376
376
  }] : []),
377
+ ...(ys.qt ? [{
378
+ key: 'qiongtong', label: '穷通宝鉴',
379
+ text: `${ys.qt.label}:用神 ${ys.qt.yong.join('、')}(首取 ${ys.qt.primary})。原文:「${ys.qt.quote}」` +
380
+ `(《穷通宝鉴》第 ${ys.qt.chapter} 章${ys.qt.note ? ';' + ys.qt.note : ''})`,
381
+ }] : []),
377
382
  {
378
383
  key: 'geju', label: '格局依据',
379
384
  text: (Array.isArray(frame.geju) ? frame.geju : []).map((g) => `${g.name}(${g.kind}):${g.evidence}`).join(';') || '未取到格局',
@@ -384,7 +389,7 @@ function baziInterpret(r) {
384
389
  },
385
390
  {
386
391
  key: 'limits', label: '未纳入',
387
- text: '本盘没有计算:流月与流日、神煞的加权轻重、地支藏干的动态引化(合冲后再论)。取用按「调候优先、扶抑校验」;调候由月令与全局寒暖燥湿判定,未逐条录入穷通宝鉴 120 条,各派取法仍有分歧;真太阳时未含历史时区与夏令时。把这些补上会改变"强弱"的边际判断,所以这里只给方向,不下断语。',
392
+ text: '本盘没有计算:流月与流日、神煞的加权轻重、地支藏干的动态引化(合冲后再论)。取用按「调候优先、扶抑校验」;调候由月令与全局寒暖燥湿判定,并按《穷通宝鉴》120 格给出用神顺序(整理表口径,原文摘句照录,异文处已标 note);各派取法仍有分歧;真太阳时未含历史时区与夏令时。把这些补上会改变"强弱"的边际判断,所以这里只给方向,不下断语。',
388
393
  },
389
394
  ];
390
395