八字 + 紫微斗数 AI 排盘与综合分析。当用户提供生辰(阳历/农历日期、时辰、性别)询问八字、紫微、命理、命盘、流年大运相关问题时使用。基于 Yiqi 算法库 + enrichBazi 补全层精准排盘(杜绝 LLM 自行排盘出错),支持按需独立分析八字 / 独立分析紫微 / 两盘交叉印证。
$npx -y skills add dzcmemory-web/bazi-ziwei-skill --skill bazi-ziwei-skillInstalls into the current project.
Run `npx skills use "https://github.com/dzcmemory-web/bazi-ziwei-skill" --skill "dzcmemory-web/bazi-ziwei-skill"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.
Use the skills in "https://github.com/dzcmemory-web/bazi-ziwei-skill" that are relevant to the current task. Run `npx skills add "https://github.com/dzcmemory-web/bazi-ziwei-skill"` and select the relevant skills, then follow their instructions.
| 1 | <div align="center"> |
| 2 | |
| 3 | # bazi-ziwei-skill |
| 4 | |
| 5 | **AI 八字 + 紫微斗数排盘与综合印证 Skill** |
| 6 | |
| 7 | 精准排盘(不靠 LLM 猜)· 三种分析模式 · 一键生成水墨风 HTML 命盘海报 |
| 8 | |
| 9 | [](./LICENSE) |
| 10 | [](#-安装) |
| 11 | |
| 12 | 简体中文 | [English](./README.en.md) |
| 13 | |
| 14 | <br> |
| 15 | |
| 16 | <img src="./docs/jietu.png" alt="综合印证海报示例" width="680"> |
| 17 | |
| 18 | <sub>综合印证海报示例(合成命主,仅供展示)</sub> |
| 19 | |
| 20 | </div> |
| 21 | |
| 22 | --- |
| 23 | |
| 24 | ## 这是什么 |
| 25 | |
| 26 | 一个遵循 [SKILL.md 开放标准](https://code.claude.com/docs/en/skills) 的命理分析 Skill,可装入 Claude Code / Claude Desktop / Codex / Cursor / Hermes / OpenClaw 等支持该标准的 AI Agent。 |
| 27 | |
| 28 | 它做三件大模型单独做不好的事: |
| 29 | |
| 30 | 1. **精准排盘**:八字四柱、紫微十二宫、大运流年由内置算法库计算,**不让 LLM 自己排**——纯 LLM 排盘常把日柱、日主、格局算错,一步错则全盘失真。 |
| 31 | 2. **格局补层**:在排盘之上补一层"格局 / 旺衰 / 调候 / 刑冲合害 / 盖头截脚"算法,喂给 LLM 做有依据的分析。 |
| 32 | 3. **综合印证**:把八字与紫微两套独立体系的结论做交叉对账——主轴是否一致、人生窗口是否对齐、冲突时听谁。这是本 Skill 区别于"任意 LLM + 任意排盘工具"的核心增量。 |
| 33 | |
| 34 | --- |
| 35 | |
| 36 | ## ✨ 特性 |
| 37 | |
| 38 | - 🎯 **算法精准**:排盘核心源自开源项目 Yiqi(MIT),经实测对齐;补层算法经 7 组案例多维度回归验证 |
| 39 | - 🧭 **三种分析模式**:八字独立 / 紫微独立 / 八字+紫微综合印证 |
| 40 | - 📜 **两种呈现形态**:Markdown 长文深度版 + 🎴 单文件 HTML 海报版(综合印证专属) |
| 41 | - 🎴 **水墨风命盘海报**:现代极简 × 中式水墨,含紫微 12 宫盘 + 八字四柱盘 + 六维交叉对账,可截图分享 |
| 42 | - 🔌 **跨 Agent**:一份 SKILL.md,多个主流 Agent 通用 |
| 43 | - 🔒 **隐私优先**:所有排盘在本地完成,无需联网;运行产物默认 gitignore |
| 44 | |
| 45 | --- |
| 46 | |
| 47 | ## 🚀 安装 |
| 48 | |
| 49 | ### 1. 克隆仓库 |
| 50 | |
| 51 | ```bash |
| 52 | git clone https://github.com/dzcmemory-web/bazi-ziwei-skill.git |
| 53 | ``` |
| 54 | |
| 55 | ### 2. 安装算法层依赖 |
| 56 | |
| 57 | ```bash |
| 58 | cd bazi-ziwei-skill/calculator |
| 59 | npm install |
| 60 | ``` |
| 61 | > 需要 Node.js >= 18。算法层依赖仅一个:`lunar-typescript`(MIT)。 |
| 62 | |
| 63 | ### 3. 注册到你的 Agent |
| 64 | |
| 65 | 把整个 `bazi-ziwei-skill/` 文件夹放进 Agent 的 skills 目录: |
| 66 | |
| 67 | | Agent | skills 目录 | |
| 68 | |---|---| |
| 69 | | Claude Code / Claude Desktop | `~/.claude/skills/bazi-ziwei/` | |
| 70 | | Codex | `~/.codex/skills/bazi-ziwei/` 或项目内 AGENTS.md 引用 | |
| 71 | | Cursor | 项目 `.cursor/` 规则引用 | |
| 72 | | Hermes Agent | `~/.hermes/skills/bazi-ziwei/` | |
| 73 | | OpenClaw | 其 skills 目录 / ClawHub 本地安装 | |
| 74 | |
| 75 | Agent 会自动读取 `SKILL.md` 并按需调用。 |
| 76 | |
| 77 | --- |
| 78 | |
| 79 | ## 📖 使用 |
| 80 | |
| 81 | 装好后,直接对 Agent 说出生时间即可: |
| 82 | |
| 83 | ``` |
| 84 | 我是 2000 年 1 月 1 日中午 12 点出生的男生,帮我看下命盘。 |
| 85 | ``` |
| 86 | |
| 87 | Agent 会: |
| 88 | 1. 问你要哪种分析(八字 / 紫微 / 综合印证) |
| 89 | 2. 综合印证时再问要长文还是 HTML 海报 |
| 90 | 3. 调用算法层排盘 → 加载对应提示词 → 输出分析或渲染海报 |
| 91 | |
| 92 | 详细流程见 [`SKILL.md`](./SKILL.md),测试方法见 [`TEST-GUIDE.md`](./TEST-GUIDE.md)。 |
| 93 | |
| 94 | ### 命令行直接排盘(不经 Agent) |
| 95 | |
| 96 | ```bash |
| 97 | cd calculator |
| 98 | # 排盘 → JSON |
| 99 | node dist/run-chart.js --year=2000 --month=1 --day=1 --hour=12 --minute=0 --gender=male > chart.json |
| 100 | # JSON → 可读文本盘 |
| 101 | node dist/dump-text.js --input=chart.json --output=chart.txt |
| 102 | # JSON + 分析 JSON + 模板 → HTML 海报 |
| 103 | node dist/render.js --chart=chart.json --analysis=analysis.json \ |
| 104 | --template=../templates/report-zonghe-poster.html --output=report.html --currentYear=2026 |
| 105 | ``` |
| 106 | |
| 107 | 仓库自带一份合成示例(2000-01-01 男,非真人): |
| 108 | - `examples/sample-chart.json` — 算法层排盘输出 |
| 109 | - `examples/sample-chart.txt` — 文墨天机风文本盘 |
| 110 | - `examples/sample-analysis.json` — 综合印证分析(示例) |
| 111 | - `examples/sample-report.html` — **综合印证海报成品,下载后用浏览器打开即可预览效果** |
| 112 | |
| 113 | --- |
| 114 | |
| 115 | ## 📁 目录结构 |
| 116 | |
| 117 | ``` |
| 118 | bazi-ziwei-skill/ |
| 119 | ├── SKILL.md Skill 主入口(Agent 读这个) |
| 120 | ├── TEST-GUIDE.md 测试指南(5 条用户路径) |
| 121 | ├── calculator/ |
| 122 | │ ├── run-chart.ts 排盘入口:生辰 → JSON |
| 123 | │ ├── dump-text.ts JSON → 文墨天机风文本盘 |
| 124 | │ ├── render.ts JSON + 分析 + 模板 → 单文件 HTML |
| 125 | │ ├── yiqi-core/ 排盘核心算法(vendored from Yiqi, MIT) |
| 126 | │ └── bazi-enrich/ 格局/旺衰/调候/刑冲合害 补层算法 |
| 127 | ├── prompts/ |
| 128 | │ ├── bazi-prompt.md 八字独立分析(长文) |
| 129 | │ ├── ziwei-prompt.md 紫微独立分析(长文) |
| 130 | │ ├── zonghe-yinzheng-prompt.md 综合印证(长文) |
| 131 | │ └── zonghe-poster.md 综合印证(海报 JSON 输出) |
| 132 | ├── templates/ |
| 133 | │ └── report-zonghe-poster.html 综合印证海报模板(占位符) |
| 134 | └── examples/ |
| 135 | ├── sample-chart.json 合成示例排盘 |
| 136 | └── sample-chart.txt 合成示例文本盘 |
| 137 | ``` |
| 138 | |
| 139 | --- |
| 140 | |
| 141 | ## 🏗️ 工作原理 |
| 142 | |
| 143 | ``` |
| 144 | 生辰 ──> run-chart.ts ──> chart.json ──> dump-text.ts ──> chart.txt |
| 145 | (算法层精准排盘) (LLM 友好文本) |
| 146 | │ |
| 147 | ┌───────────────────────────┤ |
| 148 | ▼ ▼ |
| 149 | 长文提示词 海报提示词 |
| 150 | (Markdown 散文) (严格 JSON 输出) |