Files
ZiPingEightChar/scripts/render/markdown.py
T
moxiaonian 618bf8dcab v3.4:童限小运、全量流年与节气边界提示;解释输出契约 v3.0 直答先行
排盘输出 schema 1.1→1.2:
- ## 流年 改为出生年至今+10 年全量,逐年标注所属区间(童限/某运/交运年)
- 新增 ## 小运(童限各虚岁干支,自时柱起、一位一岁、顺逆同大运)
- 生于交节前后 12 小时内出 ⚠️ 节气边界提示(月令敏感性)
- 神煞改由脚本按查法直接计算并列锚点;新增 scripts/query_shensha.py 查岁运神煞

规则库 380→541(16→20 文件,版本 3.4):
- 新增 89_旺衰扶抑 / 91_何知事类 / 92_调候 / 93_性情(滴天髓、穷通宝鉴参看层)
- 90_行运.md 新增 §10 童限(R-运-36~39,蒸馏《命理探源》《三命通会》小运诸法)
- R-运-33 改写为核对前置:intake 一问定场景,可核对走锚点、不可核对直推,输出只出现一次
- R-运-32 增前提挑战、直答收敛(一个主答案+置信度)、同机制证伪降权
- R-运-34 增救应回查(合绊解冲折减引动并回写排序);R-运-10 补「缓急非早晚」之辨
- 94 神煞扩展 19 条(三命通会书证);规则编号记录移调试层
- sources 按书归档五书全文;黄金集扩至 291 例(真诠 92 + 滴天髓 199)

SKILL.md 输出契约 v2.1→v3.0:
- 骨架改为 排盘口径→直答→现实对应→分析推理→存疑与边界→免责
- 说人话段改现实对应段(问题域优先);编号默认不进用户面输出
- Intake 增场景判定一问(命主本人/替人看/能否核对)

测试:新增 test_luck.py 9 项,全套 65 项通过
2026-10-08 13:07:23 +08:00

141 lines
4.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# scripts/render/markdown.py
"""ChartData → 自包含 Markdown(输出格式契约 v1.0)。
纯文本、无代码块、无表格嵌套;审计信息放末尾;字段名用中文;
不包含任何命理判断(P1)。
"""
def render(chart) -> str:
L = []
L.append(f"# 命盘:{chart.name}")
L.append("")
L.append(f"- 性别:{chart.gender}")
L.append(f"- 出生地:{chart.birthplace}")
L.append(f"- 输入时间:{chart.birth_clock}")
L.append(f"- 真太阳时:{chart.true_solar_time}")
if chart.is_late_zi:
L.append(
"- ⚠️ 晚子时:本造落于真太阳时 23:00–24:00,"
"已按「子初换日」归入次日。另存「子正换日」一派,"
"日柱与时柱将不同,结论需谨慎。"
)
if chart.jie_gap_warning:
L.append(f"- {chart.jie_gap_warning}")
L.append("")
L.append("## 四柱")
L.append("")
for key, label, p in (("year", "年柱", chart.year),
("month", "月柱", chart.month),
("day", "日柱", chart.day),
("hour", "时柱", chart.hour)):
god = p.gan_ten_god or ("日主" if key == "day" else "")
line = f"- {label}:{p.gan}{p.zhi}"
if god:
line += f"({god})"
changsheng = chart.terrain.get(key)
if changsheng:
line += f" · {changsheng}"
L.append(line)
L.append("")
L.append("## 地支藏干")
L.append("")
for label, p in (("年支", chart.year), ("月支", chart.month),
("日支", chart.day), ("时支", chart.hour)):
if p.hidden_stems:
pairs = "、".join(f"{s}({g})"
for s, g in zip(p.hidden_stems, p.hidden_ten_gods))
L.append(f"- {label} {p.zhi}:{pairs}")
L.append("")
L.append("## 四柱空亡")
L.append("")
L.append(f"- 日柱空亡:{chart.void['day']};时柱空亡:{chart.void['hour']}")
L.append("")
L.append("## 纳音")
L.append("")
for label, p in (("年柱", chart.year), ("月柱", chart.month),
("日柱", chart.day), ("时柱", chart.hour)):
if p.na_yin:
L.append(f"- {label}:{p.na_yin}")
L.append("")
L.append("## 神煞")
L.append("")
for key, label in (("year", "年柱"), ("month", "月柱"),
("day", "日柱"), ("hour", "时柱")):
L.append(f"### {label}神煞")
entries = chart.shen_sha.get(key) or []
if entries:
for s in entries:
L.append(f"- {s}")
else:
L.append("- (无)")
L.append("")
L.append("### 四柱组合")
combo = chart.shen_sha.get("combo") or []
if combo:
for s in combo:
L.append(f"- {s}")
else:
L.append("- (无)")
L.append("")
L.append("## 节令")
L.append("")
L.append(f"- 月令:{chart.month_ling}")
L.append(f"- 生于 {chart.solar_term_before} 之后、{chart.solar_term_after} 之前")
L.append(f"- 胎元:{chart.tai_yuan} 命宫:{chart.ming_gong}")
L.append("")
L.append("## 大运")
L.append("")
direction = "顺行" if chart.luck_is_forward else "逆行"
if chart.luck_pillars:
L.append(f"- 排法:{direction};起运:{chart.start_age_text}"
f"({chart.luck_pillars[0].start_age:.2f} 岁)")
else:
L.append(f"- 排法:{direction};起运:{chart.start_age_text}")
for lp in chart.luck_pillars:
L.append(f"- 第 {lp.index} 步:{lp.gan}{lp.zhi}"
f"({lp.start_age:.2f} 岁起,{lp.start_year} 年)")
L.append("")
L.append("## 小运")
L.append("")
if chart.childhood_luck:
L.append("- 自时柱起,一位一岁;童限(未交大运)参用")
for age, year, gz in chart.childhood_luck:
L.append(f"- {age} 岁({year} 年):{gz}")
else:
L.append("- (无:起运不足一岁)")
L.append("")
L.append("## 流年")
L.append("")
for year, gz, label in chart.flow_years:
L.append(f"- {year} {gz}({label})")
L.append("")
L.append("## 流月")
L.append("")
for label, gz in chart.flow_months:
L.append(f"- {label}:{gz}")
L.append("")
L.append("---")
L.append("## 排盘审计")
L.append("")
L.append(f"- 时区:{chart.tz_used}(夏令时:{'是' if chart.is_dst else '否'})")
L.append(f"- 经度修正:{chart.lon_correction_min:+.2f} 分 / "
f"均时差:{chart.eot_minutes:+.2f} 分 / "
f"合计修正:{chart.lon_correction_min + chart.eot_minutes:+.2f} 分")
L.append("- 日界规则:子初换日(真太阳时 23:00)")
L.append(f"- 历法库:tyme4py {chart.library_version}")
L.append(f"- 输出 schema:{chart.schema_version}")
return "\n".join(L)