dsh-metaphysics 0.22.0 → 0.34.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/ziwei.js CHANGED
@@ -524,6 +524,8 @@ export function buildZiwei(input) {
524
524
 
525
525
  chart.patterns = detectPatterns(chart);
526
526
  chart.daxianList = daxianList(chart);
527
+ chart.fly = flyStars(chart);
528
+ chart.flyChains = flyChains(chart, { from: '命宫' });
527
529
  enrichLiunian(chart);
528
530
  // 流月/流日/流时:默认按本机当前时刻,可用 asOf 指定(如 "2026-10-22T16:00")
529
531
  chart.flow = flowOf(chart, input.asOf);
@@ -716,6 +718,83 @@ export function daxianList(chart) {
716
718
  .sort((a, b) => a.ages[0] - b.ages[0]);
717
719
  }
718
720
 
721
+ // ── 四化飞星:宫干四化飞向哪一宫,以及「串连」────────────────────
722
+ // 生年四化看「这颗星先天带着什么」,飞星四化看「这一宫自己会去找谁」:
723
+ // 宫干定出四个化星,星曜落在哪一宫,就是这一宫的禄/权/科/忌飞向哪里。
724
+ // 串连(忌转忌、科转科…)是同一支化一路跟下去:命宫化忌入 A 宫,A 宫的宫干再化忌入 B 宫……
725
+ // 走到回到已访问过的宫就成环(传统讲的「忌出」「自化」都在这一步显现)。
726
+
727
+ export const FLY_TYPES = ['禄', '权', '科', '忌'];
728
+
729
+ // 某天干下某一化的星曜;表里没有就返回 null(不会凭印象补)
730
+ export function flyStarOf(stem, type) {
731
+ const map = MUTAGEN[stem];
732
+ if (!map) return null;
733
+ for (const [star, t] of Object.entries(map)) if (t === type) return star;
734
+ return null;
735
+ }
736
+
737
+ // 12 宫各自的四化落点(一次算全,供面板与解读共用)
738
+ export function flyStars(chart) {
739
+ const palaces = chart.palaces || [];
740
+ return palaces.map((p) => ({
741
+ palace: p.palace,
742
+ branch: p.branch,
743
+ stem: p.stem,
744
+ flies: FLY_TYPES.map((type) => {
745
+ const star = flyStarOf(p.stem, type);
746
+ const b = star ? starBranchOf(chart, star) : -1;
747
+ const target = b >= 0 ? palaces.find((x) => x.branch === BRANCHES[b]) : null;
748
+ return {
749
+ type,
750
+ star,
751
+ to: target ? target.palace : null,
752
+ toBranch: target ? target.branch : null,
753
+ // 落回本宫即自化:这一宫自己化出去又回到自己
754
+ self: !!(target && target.palace === p.palace),
755
+ };
756
+ }),
757
+ }));
758
+ }
759
+
760
+ // 从某一宫出发,跟着同一支化逐跳;ended 说明为什么停:
761
+ // cycle=回到走过的宫(成环)、no-star=该干这一化无星、off-chart=星未上盘、max=走满上限
762
+ export function flyChain(chart, { from = '命宫', type = '忌', maxSteps = 12 } = {}) {
763
+ const palaces = chart.palaces || [];
764
+ const start = palaces.find((p) => p.palace === from) || palaces[0];
765
+ if (!start) return null;
766
+ const steps = [];
767
+ const seen = new Set([start.palace]);
768
+ let cur = start;
769
+ let ended = 'max';
770
+ for (let i = 0; i < Math.max(1, maxSteps); i++) {
771
+ const star = flyStarOf(cur.stem, type);
772
+ if (!star) { ended = 'no-star'; break; }
773
+ const b = starBranchOf(chart, star);
774
+ if (b < 0) { ended = 'off-chart'; break; }
775
+ const to = palaces.find((x) => x.branch === BRANCHES[b]);
776
+ steps.push({ from: cur.palace, fromBranch: cur.branch, fromStem: cur.stem, star, type, to: to.palace, toBranch: to.branch });
777
+ if (seen.has(to.palace)) { ended = 'cycle'; break; }
778
+ seen.add(to.palace);
779
+ cur = to;
780
+ }
781
+ return {
782
+ from: start.palace,
783
+ type,
784
+ steps,
785
+ path: [start.palace, ...steps.map((s) => s.to)],
786
+ ended,
787
+ closed: ended === 'cycle',
788
+ };
789
+ }
790
+
791
+ // 某一宫的四支化各串一条(默认命宫)
792
+ export function flyChains(chart, { from = '命宫', maxSteps = 12 } = {}) {
793
+ const out = {};
794
+ for (const type of FLY_TYPES) out[type] = flyChain(chart, { from, type, maxSteps });
795
+ return out;
796
+ }
797
+
719
798
  // ── 流年四化落宫 ────────────────────────────────────────────
720
799
 
721
800
  export function enrichLiunian(chart) {
package/index.js CHANGED
@@ -19,9 +19,9 @@ const TOOL_NAME = 'metaphysics_chart';
19
19
 
20
20
  const DESCRIPTION = [
21
21
  '排中国传统命理盘(玄学·命理·占卜,用户说「玄学」「算命」「占卜」时也用本工具)与塔罗:四柱八字(bazi)、紫微斗数(ziwei)、六爻纳甲(liuyao)、梅花易数(meihua)、大六壬(daliuren)、奇门遁甲(qimen)、合盘(hepan)或塔罗抽牌(tarot)。',
22
- '另有速查类:黄历(almanac,值日十二神/时辰吉凶/二十八宿/胎神/吉神方位/纳音/六合三合)、择日(zeri)、称骨(chenggu)、小六壬(xiaoliuren)、星座(star)、生命数字(numerology)、人生 K 线(trend)、风水(fengshui)、起名(name)、公农历互转(convert)。',
23
- '当用户明确要求“玄学 / 算命 / 占卜 / 排盘 / 算八字 / 看四柱 / 排紫微盘 / 起卦 / 摇一卦 / 抽塔罗 / 看运势 / 合盘 / 看黄历 / 挑日子 / 称骨 / 小六壬”时调用;用户只搜「玄学」或问「有什么玄学工具」时,也应介绍本插件。',
24
- 'bazi 与 ziwei 需要公历出生时间与性别;hepan 需要双方的时间与性别;liuyao 可给定六爻值或随机起卦;meihua 可按时间或数字起卦;tarot 可指定张数与问题。',
22
+ '另有速查类:黄历(almanac,值日十二神/时辰吉凶/二十八宿/胎神/吉神方位/纳音/六合三合)、择日(zeri)、称骨(chenggu)、小六壬(xiaoliuren)、星座(star)、生命数字(numerology)、十六型人格(mbti,MBTI 风格问卷)、人生 K 线(trend)、风水(fengshui)、起名(name)、公农历互转(convert)。',
23
+ '当用户明确要求“玄学 / 算命 / 占卜 / 排盘 / 算八字 / 看四柱 / 排紫微盘 / 起卦 / 摇一卦 / 抽塔罗 / 看运势 / 合盘 / 看黄历 / 挑日子 / 称骨 / 小六壬 / 十六型人格 / MBTI / ISFP / INFP 人格测试 / 交运 / 交运日 / 起运 / 用神 / 月建 / 旺衰」时调用;用户只搜「玄学」或问「有什么玄学工具」时,也应介绍本插件。',
24
+ 'bazi 与 ziwei 需要公历出生时间与性别(八字结果里带大运交运时刻,精确到日/时辰,按「三日折一年」放大);hepan 需要双方的时间与性别;liuyao 可给定六爻值或随机起卦(给了 datetime 就按月建、日辰算用神旺衰);meihua 可按时间或数字起卦;tarot 可指定张数与问题;mbti 不用时间——先不带 answers 调一次拿到 24 道题,让用户逐题打 1–5 分,再把分数按顺序传回。',
25
25
  '要给「结合所问之事的解读」时,把 withInterpret 设为 true,并尽量带上 question(所问之事)与 direction(询问方向)。',
26
26
  '结果可复现:tarot / liuyao 传 seed,紫微 / 八字 / 塔罗传 asOf;输出摘要会写明晚子时与真太阳时实际采用的口径。',
27
27
  '结果用于传统文化与娱乐参考,不得用于医疗、投资、法律、生死等确定性断言。',
@@ -85,7 +85,7 @@ export function apply(ctx) {
85
85
  const now = new Date();
86
86
  const pad = (n) => String(n).padStart(2, '0');
87
87
  const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
88
- const DATE_ONLY = { almanac: 1, star: 1, numerology: 1 };
88
+ const DATE_ONLY = { almanac: 1, star: 1, numerology: 1 };
89
89
  if (next.system === 'convert' && next.mode !== 'lunar2solar' && !next.datetime) next.datetime = today;
90
90
  if (DATE_ONLY[next.system] && !next.datetime) next.datetime = today;
91
91
  if (next.system === 'zeri' && !next.startDate) next.startDate = today;
@@ -107,13 +107,13 @@ export function apply(ctx) {
107
107
  properties: {
108
108
  system: {
109
109
  type: 'string',
110
- enum: ['bazi', 'ziwei', 'liuyao', 'tarot', 'meihua', 'daliuren', 'hepan', 'qimen', 'almanac', 'zeri', 'chenggu', 'xiaoliuren', 'star', 'numerology', 'trend', 'fengshui', 'name', 'convert'],
111
- description: 'bazi = 四柱八字(含调候寒暖与《穷通宝鉴》120 格用神);ziwei = 紫微斗数;liuyao = 六爻;tarot = 塔罗;meihua = 梅花易数;daliuren = 大六壬;hepan = 合盘(合婚),需同时给 partner;qimen = 奇门遁甲(时家转盘,拆补法);almanac = 黄历(某日宜忌/冲煞/建除/节气);zeri = 择日(某事项在日期区间内逐日打分排序);chenggu = 袁天罡称骨(骨重 + 通行本称骨歌原文 + 白话释义);xiaoliuren = 小六壬(时间或报数起课);star = 星座当日基调;numerology = 生命数字;trend = 人生 K 线(大运/流年走势可视化);fengshui = 风水(八宅命卦/流年飞星/门主灶布局);name = 起名(391 字库的用字五行评估与候选生成;未收录字可传 charElements 指定五行);convert = 公农历互转(solar2lunar 公历转农历 / lunar2solar 农历转公历)。',
110
+ enum: ['bazi', 'ziwei', 'liuyao', 'tarot', 'meihua', 'daliuren', 'hepan', 'qimen', 'almanac', 'zeri', 'chenggu', 'xiaoliuren', 'star', 'numerology', 'mbti', 'trend', 'fengshui', 'name', 'convert'],
111
+ description: 'bazi = 四柱八字(含调候寒暖与《穷通宝鉴》120 格用神);ziwei = 紫微斗数;liuyao = 六爻(纳甲、卦体关系、用神落位与月建日辰旺衰);tarot = 塔罗;meihua = 梅花易数;daliuren = 大六壬;hepan = 合盘(合婚),需同时给 partner;qimen = 奇门遁甲(时家转盘,拆补法);almanac = 黄历(某日宜忌/冲煞/建除/节气);zeri = 择日(某事项在日期区间内逐日打分排序);chenggu = 袁天罡称骨(骨重 + 通行本称骨歌原文 + 白话释义);xiaoliuren = 小六壬(时间或报数起课);star = 星座当日基调;numerology = 生命数字;mbti = 十六型人格(MBTI 风格 24 题问卷:给 answers 出类型,不给则先返回题目);trend = 人生 K 线(大运/流年走势可视化);fengshui = 风水(八宅命卦/流年飞星/门主灶布局);name = 起名(391 字库的用字五行评估与候选生成;未收录字可传 charElements 指定五行);convert = 公农历互转(solar2lunar 公历转农历 / lunar2solar 农历转公历)。',
112
112
  },
113
113
  datetime: {
114
114
  type: 'string',
115
115
  description:
116
- '公历本地时间,如 1990-05-12T14:30。bazi / ziwei 必填;liuyao 可选,仅用于取日辰定六神。almanac / star / numerology 只需要日期(可省略,省略则取今天);chenggu 需要带时分或用 hour 补时辰;xiaoliuren 时间起课用它的日期与时分。',
116
+ '公历本地时间,如 1990-05-12T14:30。bazi / ziwei 必填;liuyao 可选,仅用于取日辰定六神。almanac / star / numerology 只需要日期;mbti 不用时间。;chenggu 需要带时分或用 hour 补时辰;xiaoliuren 时间起课用它的日期与时分。',
117
117
  },
118
118
  date: {
119
119
  type: 'string',
@@ -185,15 +185,15 @@ export function apply(ctx) {
185
185
  enum: ['鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'],
186
186
  description: '仅 zeri 使用:当事人属相,用于排除冲煞日(不给则不排除)。',
187
187
  },
188
- mode: {
189
- type: 'string',
190
- enum: ['solar2lunar', 'lunar2solar'],
191
- description: '仅 convert 使用:转换方向,默认 solar2lunar(公历转农历);lunar2solar 需同时给 lunarYear/lunarMonth/lunarDay。',
192
- },
193
- lunarYear: { type: 'integer', description: '仅 convert 的 lunar2solar:农历年份,如 2026。' },
194
- lunarMonth: { type: 'integer', description: '仅 convert 的 lunar2solar:农历月份 1–12。' },
195
- lunarDay: { type: 'integer', description: '仅 convert 的 lunar2solar:农历日 1–30(小月无三十)。' },
196
- isLeapMonth: { type: 'boolean', description: '仅 convert 的 lunar2solar:该月是否为闰月。' },
188
+ mode: {
189
+ type: 'string',
190
+ enum: ['solar2lunar', 'lunar2solar'],
191
+ description: '仅 convert 使用:转换方向,默认 solar2lunar(公历转农历);lunar2solar 需同时给 lunarYear/lunarMonth/lunarDay。',
192
+ },
193
+ lunarYear: { type: 'integer', description: '仅 convert 的 lunar2solar:农历年份,如 2026。' },
194
+ lunarMonth: { type: 'integer', description: '仅 convert 的 lunar2solar:农历月份 1–12。' },
195
+ lunarDay: { type: 'integer', description: '仅 convert 的 lunar2solar:农历日 1–30(小月无三十)。' },
196
+ isLeapMonth: { type: 'boolean', description: '仅 convert 的 lunar2solar:该月是否为闰月。' },
197
197
  num1: { type: 'number', description: '仅 xiaoliuren 报数模式:第一个数(1–99)。' },
198
198
  num2: { type: 'number', description: '仅 xiaoliuren 报数模式:第二个数(1–99)。' },
199
199
  num3: { type: 'number', description: '仅 xiaoliuren 报数模式:第三个数(1–99)。' },
@@ -297,6 +297,11 @@ export function apply(ctx) {
297
297
  surname: { type: 'string', description: '仅 name 使用:姓氏,如「李」(复姓整体写,如「欧阳」)。' },
298
298
  givenName: { type: 'string', description: '仅 name assess 使用:名(1–2 个汉字)。' },
299
299
  limit: { type: 'number', description: '仅 name generate 使用:候选个数(1–20,默认 10)。' },
300
+ answers: {
301
+ type: 'array',
302
+ items: { type: ['integer', 'null'] },
303
+ description: '仅 mbti 使用:按题目顺序的 24 个分数,1(完全不像)–5(很像我);跳过某题传 null。不给则返回问卷题目,答满 12 题即可出类型。',
304
+ },
300
305
  },
301
306
  required: ['system'],
302
307
  },
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Metaphysics Charts (Xuanxue)",
4
- "description": "Chinese metaphysics (xuanxue) — eighteen systems in one plugin: eight chart systems plus ten quick references (almanac, solar–lunar conversion, date selection, bone-weight fortune, Xiao Liu Ren, horoscope, numerology, life-curve, feng shui, name analysis). Chart systems: BaZi (hidden stems, ten gods, 12 stages, 42 shensha, strength, pattern and useful-god, luck scoring), Zi Wei Dou Shu (49 stars with brightness, four 12-god cycles, 34 patterns, decade and annual/monthly/daily/hourly mutagen), LiuYao, MeiHua YiShu, Da Liu Ren, Qi Men Dun Jia (three ju-selection schools), compatibility charts (BaZi and Zi Wei), and Tarot, plus an ask-driven interpretation layer. Computed locally with networking off by default, exposed as an agent tool with a Web panel."
4
+ "description": "Chinese metaphysics (xuanxue) — nineteen systems in one plugin: eight chart systems plus eleven quick references (almanac, solar–lunar conversion, date selection, bone-weight fortune, Xiao Liu Ren, horoscope, numerology, MBTI-style 16-type questionnaire, life-curve, feng shui, name analysis). Chart systems: BaZi (hidden stems, ten gods, 12 stages, 42 shensha, strength, pattern and useful-god, luck scoring), Zi Wei Dou Shu (49 stars with brightness, four 12-god cycles, 34 patterns, decade and annual/monthly/daily/hourly mutagen), LiuYao, MeiHua YiShu, Da Liu Ren, Qi Men Dun Jia (three ju-selection schools), compatibility charts (BaZi and Zi Wei), and Tarot, plus an ask-driven interpretation layer. Computed locally with networking off by default, exposed as an agent tool with a Web panel."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "命理排盘(玄学)· 八字紫微六爻梅花六壬奇门合盘塔罗",
4
- "description": "玄学命理排盘:十八套体系一站排盘——既有的八套排盘(八字、紫微、六爻、梅花、大六壬、奇门、合盘、塔罗)之外,新增十套速查(黄历、农历互转、择日、称骨、小六壬、星座、生命数字、人生K线、风水、起名):八字(藏干十神、十二长生、42 神煞、旺衰、格局用神、大运流年吉凶评分)、紫微斗数(49 星曜与主星庙旺、四层十二神、34 格局、大限、流年流月流日流时四化)、六爻纳甲、梅花易数、大六壬(天地盘/四课/三传)、奇门遁甲(拆补/超神接气/置闰三派取局)、合盘(八字与紫微两套)与塔罗;另有所问之事驱动的解析与详解。纯本地计算、默认不联网,作为 Agent 工具供对话调用,并提供可切换本命/大限/流年视图的 Web 面板。"
4
+ "description": "玄学命理排盘:十九套体系一站排盘——既有的八套排盘(八字、紫微、六爻、梅花、大六壬、奇门、合盘、塔罗)之外,另有十一套速查(黄历、农历互转、择日、称骨、小六壬、星座、生命数字、人生K线、风水、起名、十六型人格):八字(藏干十神、十二长生、42 神煞、旺衰、格局用神、大运流年吉凶评分)、紫微斗数(49 星曜与主星庙旺、四层十二神、34 格局、大限、流年流月流日流时四化)、六爻纳甲、梅花易数、大六壬(天地盘/四课/三传)、奇门遁甲(拆补/超神接气/置闰三派取局)、合盘(八字与紫微两套)与塔罗;另有所问之事驱动的解析与详解。纯本地计算、默认不联网,作为 Agent 工具供对话调用,并提供可切换本命/大限/流年视图的 Web 面板。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-metaphysics",
3
- "version": "0.22.0",
3
+ "version": "0.34.0",
4
4
  "type": "module",
5
- "description": "命理排盘(玄学 xuanxue)for DeepSeek Harness: eighteen systems and ten quick references (almanac, solar–lunar conversion, …), with climate adjustment (tiaohou) and the 120 Qiongtong Baojian entries, 391-char name library.",
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, classical quotes (Ziping Zhenquan / Di Tian Sui), hexagram body relations (六冲/六合/伏吟/反吟/化进神/化退神) plus yongshen placement (用神落位) with month/day strength (月建日辰旺衰) for liuyao, plus an MBTI-style 16-type questionnaire and exact dayun handover dates (交运日), palace conditions (击刑/入墓), month states (旺相休囚死) and stem–palace relations (天盘干与宫生克) for qimen, flying four-transformations (四化飞星串连) for ziwei, and a bundled offline single-file page (命理排盘.html).",
6
6
  "keywords": [
7
7
  "玄学",
8
8
  "玄学排盘",
@@ -65,11 +65,13 @@
65
65
  "./client": "./client.js",
66
66
  "./package.json": "./package.json",
67
67
  "./locale/*.json": "./locale/*.json",
68
- "./icon": "./icon.svg"
68
+ "./icon": "./icon.svg",
69
+ "./命理排盘.html": "./命理排盘.html"
69
70
  },
70
71
  "files": [
71
72
  "index.js",
72
73
  "client.js",
74
+ "命理排盘.html",
73
75
  "engine",
74
76
  "cordis.patch.yml",
75
77
  "locale/*.json",