dsh-metaphysics 0.46.5 → 0.50.5

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/liuyao.js CHANGED
@@ -66,6 +66,7 @@ const LIUSHEN_START = { 甲: 0, 乙: 0, 丙: 1, 丁: 1, 戊: 2, 己: 3, 庚: 4,
66
66
  const ZHI_CHONG_PAIRS = [['子', '午'], ['丑', '未'], ['寅', '申'], ['卯', '酉'], ['辰', '戌'], ['巳', '亥']];
67
67
  const ZHI_HE_PAIRS = [['子', '丑'], ['寅', '亥'], ['卯', '戌'], ['辰', '酉'], ['巳', '申'], ['午', '未']];
68
68
  const CHONG_OF = Object.fromEntries(ZHI_CHONG_PAIRS.flatMap(([a, b]) => [[a, b], [b, a]]));
69
+ const HE_OF = Object.fromEntries(ZHI_HE_PAIRS.flatMap(([a, b]) => [[a, b], [b, a]]));
69
70
  const TRIGRAM_OPPOSITE = { 乾: '巽', 巽: '乾', 坎: '离', 离: '坎', 艮: '坤', 坤: '艮', 震: '兑', 兑: '震' };
70
71
 
71
72
  // ── 化进神 / 化退神 ────────────────────────────────────────────────
@@ -930,3 +931,102 @@ export function jinTuiPower(result, opts = {}) {
930
931
  note: '进退只说这一爻往哪边走;力重是把它放回月建日辰,看有没有托着——得令则进得动、退得慢,失令则进得虚、退得实,月破压过一切。仍不直接定吉凶:用神化进为喜,忌神化进反而是忌。',
931
932
  };
932
933
  }
934
+
935
+ // ── 应期线索:只列「该留意哪一支」,不给日期 ─────────────────────────
936
+ // 知识卡 liuyao-yingqi 的承诺是「只作时间窗口的提示」:传统取用神逢值、
937
+ // 逢冲、逢合之期,旬空另等出空、冲空。这里只把这些地支列出来,再按月建给
938
+ // 一个快慢方向;不换算成日期、不排先后、不判忌神受制,也不叠动变连环。
939
+ export const YINGQI_TEMPO = ['偏速', '偏缓', '待解', '未定'];
940
+ const TEMPO_SAY = {
941
+ 偏速: '用神得月令之气,应期偏近',
942
+ 偏缓: '用神失月令之气,应期偏远',
943
+ 待解: '有月破或旬空的用神,先等条件解除',
944
+ 未定: '快慢不定(缺月建,或用神两现而旺衰不一)',
945
+ };
946
+ const TRIGGER_ORDER = ['逢值', '逢冲', '逢合', '出空填实', '冲空'];
947
+
948
+ /**
949
+ * 应期线索:用神逢值、逢冲、逢合,旬空另标出空与冲空。
950
+ * @param {object} result buildLiuyao 的结果
951
+ * @param {object} useGod yongshenOf 的结果
952
+ * @param {{monthBranch?: string}} opts
953
+ */
954
+ export function yingqiWindow(result, useGod, opts = {}) {
955
+ if (!useGod || !useGod.liuqin) return null;
956
+ const found = Array.isArray(useGod.found) ? useGod.found : [];
957
+ const fushen = Array.isArray(useGod.fushen) ? useGod.fushen : [];
958
+ const viaFushen = !found.length && fushen.length > 0;
959
+ const source = found.length ? found : fushen;
960
+ if (!source.length) return null;
961
+ const monthBranch = opts.monthBranch || null;
962
+ const monthElement = monthBranch ? zhiElementOf(monthBranch) : null;
963
+ const kong = Array.isArray(result && result.xunKong)
964
+ ? result.xunKong
965
+ : (result && typeof result.xunKong === 'string' ? result.xunKong.split('') : []);
966
+
967
+ const items = source.map((l) => {
968
+ const branch = l.branch;
969
+ const element = l.element || zhiElementOf(branch);
970
+ const monthState = monthStateOf(element, monthElement);
971
+ const isEmpty = kong.includes(branch);
972
+ const monthChong = !!(monthBranch && CHONG_OF[branch] === monthBranch);
973
+ const tempo = monthChong ? '待解'
974
+ : isEmpty ? '待解'
975
+ : monthState === 'unknown' ? '未定'
976
+ : (monthState === '旺' || monthState === '相') ? '偏速' : '偏缓';
977
+ const tempoSay = monthChong ? `遭${monthBranch}冲(月破),先待出月或填实`
978
+ : isEmpty ? '用神旬空,先待出空填实'
979
+ : monthState === 'unknown' ? '缺月建,快慢不定'
980
+ : `月建${monthState},${tempo === '偏速' ? '应期偏近' : '应期偏远'}`;
981
+ const triggers = [
982
+ { branch, labels: ['逢值'] },
983
+ { branch: CHONG_OF[branch] || null, labels: ['逢冲'] },
984
+ { branch: HE_OF[branch] || null, labels: ['逢合'] },
985
+ ];
986
+ if (isEmpty) {
987
+ triggers[0].labels.push('出空填实');
988
+ triggers[1].labels.push('冲空');
989
+ }
990
+ return {
991
+ position: l.position,
992
+ branch,
993
+ element,
994
+ monthState,
995
+ monthChong,
996
+ kong: isEmpty,
997
+ tempo,
998
+ tempoSay,
999
+ triggers,
1000
+ };
1001
+ });
1002
+
1003
+ // 用神两现时各爻的支可能不同:按支归并标签,不替谁选主用
1004
+ const merged = new Map();
1005
+ for (const it of items) {
1006
+ for (const t of it.triggers) {
1007
+ if (!t.branch) continue;
1008
+ const cur = merged.get(t.branch) || { branch: t.branch, labels: [] };
1009
+ for (const lb of t.labels) if (!cur.labels.includes(lb)) cur.labels.push(lb);
1010
+ merged.set(t.branch, cur);
1011
+ }
1012
+ }
1013
+ const triggers = [...merged.values()].map((t) => ({
1014
+ branch: t.branch,
1015
+ labels: [...t.labels].sort((a, b) => TRIGGER_ORDER.indexOf(a) - TRIGGER_ORDER.indexOf(b)),
1016
+ }));
1017
+ const tempos = items.map((x) => x.tempo);
1018
+ const tempo = tempos.includes('待解') ? '待解'
1019
+ : tempos.every((t) => t === '偏速') ? '偏速'
1020
+ : tempos.every((t) => t === '偏缓') ? '偏缓' : '未定';
1021
+
1022
+ return {
1023
+ month: monthBranch ? { branch: monthBranch, element: monthElement } : null,
1024
+ viaFushen,
1025
+ tempo,
1026
+ tempoSay: TEMPO_SAY[tempo],
1027
+ items,
1028
+ triggers,
1029
+ labels: [`应期${tempo}`, ...triggers.map((t) => `${t.labels.join('/')}${t.branch}`)],
1030
+ note: '应期只给「该留意哪一支」与快慢方向:用神逢值、逢冲、逢合,旬空另标出空与冲空。不换算成日期、不排先后、不判忌神受制;近事以日计、远事以月计,用哪把尺由事情远近决定,本插件不代选。',
1031
+ };
1032
+ }
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Host 半:把排盘引擎注册成一个模型可调用的工具。
3
3
  * 纯计算;唯一的网络行为是按需把地址解析成经度(失败即退回内置坐标表)。
4
4
  */
5
- import { compute, renderText, geocodeAddress } from './engine/index.js';
5
+ import { compute, renderText, geocodeAddress, caliberCompare } from './engine/index.js';
6
6
  import { createLru } from './engine/lru.js';
7
7
  import { cacheMetrics } from './engine/calendar.js';
8
8
 
@@ -98,7 +98,13 @@ export function apply(ctx) {
98
98
  && next.fortuneYear === undefined) {
99
99
  next.fortuneYear = now.getFullYear();
100
100
  }
101
- return compute(next);
101
+ const out = compute(next);
102
+ // 显式要求时才做口径对照:每次要额外排 2–3 张盘,默认不付这笔开销
103
+ if (next.diff === true) {
104
+ const cmp = caliberCompare(next);
105
+ if (cmp.switches.length) out.caliber = cmp;
106
+ }
107
+ return out;
102
108
  }
103
109
 
104
110
  const definition = {
@@ -208,6 +214,10 @@ export function apply(ctx) {
208
214
  type: 'boolean',
209
215
  description: '八字 / 紫微专用:为同一份出生信息再排另一套盘,返回「八字 × 紫微 交叉验证」(同向 / 有张力 / 互补),不合并数值。',
210
216
  },
217
+ diff: {
218
+ type: 'boolean',
219
+ description: '口径对照(bazi / ziwei / qimen):同一组输入分别按当前口径与另一档各排一次,列出根因字段(如日柱、命宫、局数)与连带变化数。只列差异,不判哪套口径更准,也不改盘面。',
220
+ },
211
221
  verifyPast: {
212
222
  type: 'number',
213
223
  description: '验前事(仅八字):传年数(如 6),返回过去 N 年的流年信号行,供用户勾选「准/不准」并算贴合度;只读,不改盘。',
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-metaphysics",
3
- "version": "0.46.5",
3
+ "version": "0.50.5",
4
4
  "type": "module",
5
- "description": "命理排盘(玄学 xuanxue)for DeepSeek Harness: nineteen systems and eleven quick references (almanac, solar–lunar conversion, …), with climate adjustment (tiaohou), the 120 Qiongtong Baojian entries, 391-char name library with per-character pinyin, Kangxi stroke counts, five-grid (五格/三才) analysis and mechanical phonetics checks, classical quotes (Ziping Zhenquan / Di Tian Sui / San Ming Tong Hui), hexagram body relations (六冲/六合/伏吟/反吟/化进神/化退神) plus yongshen placement (用神落位) with month/day strength (月建日辰旺衰) and whole-hexagram per-line strength (全卦逐爻旺衰) for liuyao, plus an MBTI-style 16-type questionnaire and exact dayun handover dates (交运日) with annual suiyun hints (岁运并临/伏吟反吟), palace conditions (击刑/入墓), month states (旺相休囚死) and stem–palace relations (天盘干与宫生克) for qimen, flying four-transformations with chained flights (四化飞星串连), three-way-four-corner composite flights (三方四正复合飞化), switchable leap-month policy (闰月按日切分/整月归次月/整月归本月) and nine school switches (亮度/庚干四化/天马/天空/截空旬空/魁钺/天伤天使/长生/晚子时) for ziwei, and a bundled offline single-file page (命理排盘.html), and a panel-to-chat handoff that asks the Harness about a finished chart.",
5
+ "description": "命理排盘(玄学 xuanxue)for DeepSeek Harness: nineteen systems and eleven quick references (almanac, solar–lunar conversion, …), with climate adjustment (tiaohou), the 120 Qiongtong Baojian entries, 391-char name library with per-character pinyin, Kangxi stroke counts, five-grid (五格/三才) analysis and mechanical phonetics checks, classical quotes (Ziping Zhenquan / Di Tian Sui / San Ming Tong Hui), hexagram body relations (六冲/六合/伏吟/反吟/化进神/化退神) plus yongshen placement (用神落位) with month/day strength (月建日辰旺衰) and whole-hexagram per-line strength (全卦逐爻旺衰) and response-time clues (应期线索:逢值/逢冲/逢合 + 月建五态快慢) for liuyao, plus an MBTI-style 16-type questionnaire and exact dayun handover dates (交运日) with annual suiyun hints (岁运并临/伏吟反吟), palace conditions (击刑/入墓), month states (旺相休囚死) and stem–palace relations (天盘干与宫生克) for qimen, flying four-transformations with chained flights (四化飞星串连), three-way-four-corner composite flights (三方四正复合飞化), switchable leap-month policy (闰月按日切分/整月归次月/整月归本月) nine school switches (亮度/庚干四化/天马/天空/截空旬空/魁钺/天伤天使/长生/晚子时) for ziwei, caliber diffs for bazi/ziwei/qimen (same inputs, one switch, root-field changes), and a bundled offline single-file page (命理排盘.html), and a panel-to-chat handoff that asks the Harness about a finished chart.",
6
6
  "keywords": [
7
7
  "玄学",
8
8
  "玄学排盘",