Skill: ryanchromium/yijing-divination (version 1.0.0)

--- name: yijing-divination description: 易经占卜系统。支持铜钱法、蓍草法起卦，生成本卦、互卦、变卦，提供Oracle Voice诠释。当用户请求占卜、问卦、易经解读、或寻求决策指引时使用。 --- # 易经占卦 基于《周易》的占卜系统。提供传统起卦方法和AI诠释引擎。 ## 核心功能 ### 1. 起卦方法 **铜钱法（推荐）** ```bash python3 scripts/divine.py --method coin --question "用户的问题" ``` **蓍草法** ```bash python3 scripts/divine.py --method yarrow --question "用户的问题" ``` **自定义种子** ```bash python3 scripts/divine.py --method coin --seed "20260214" ``` ### 2. 输出结构 脚本返回JSON，包含： - `main_hexagram`: 本卦（主卦） - `number`: 卦序（1-64） - `upper_trigram`: 上卦（八卦之一） - `lower_trigram`: 下卦（八卦之一） - `lines`: 六爻数组（1=阳，0=阴） - `changing_lines`: 变爻位置（动爻） - `visual`: 卦象可视化 - `nuclear_hexagram`: 互卦（隐藏的卦象） - `relating_hexagram`: 之卦（变卦，仅当有动爻时存在） ### 3. 卦辞数据库 读取 `assets/hexagrams_full.json` 获取卦象解释： ```python import json with open('assets/hexagrams_full.json', 'r') as f: hexagrams = json.load(f) hex_data = hexagrams[str(卦序号)] ``` 每卦包含： - `name`: 卦名 - `judgement`: 卦辞 - `image`: 象辞 - `oracle_voice`: AI Oracle声音（以卦的第一人称说话） - `keywords`: 关键词 - `lines`: 六爻爻辞 ### 4. Oracle Voice 模式 **核心原则：** - 以卦的声音说话，而非给建议 - 用意象和悖论，而非处方 - 持有张力，不强求解决 - 把提问行为本身作为答案的一部分 **示例模板：** ``` 我是 {卦名}，{卦象描述}。 {oracle_voice 内容} 你的问题是「{用户问题}」。 {结合动爻和变卦的诠释} {互卦的隐喻} 这是《易》给你的镜子，而非答案。 ``` ## 完整流程 ### 步骤1：执行起卦脚本 ```bash result=$(python3 scripts/divine.py --method coin --question "{用户问题}") ``` ### 步骤2：解析结果 ```python import json data = json.loads(result) main_num = data['main_hexagram']['number'] nuclear_num = data['nuclear_hexagram'] relating_num = data['relating_hexagram'] changing = data['main_hexagram']['changing_lines'] visual = data['main_hexagram']['visual'] ``` ### 步骤3：读取卦象数据 ```python with open('references/hexagrams.json', 'r') as f: hexagrams = json.load(f) main_hex = hexagrams[str(main_num)] nuclear_hex = hexagrams.get(str(nuclear_num)) relating_hex = hexagrams.get(str(relating_num)) if relating_num else None ``` ### 步骤4：生成Oracle Voice诠释 **结构：** 1. **卦象展示** - 可视化卦象（`visual`） - 卦名、卦辞、象辞 2. **Oracle Voice** - 本卦的声音（`oracle_voice`） - 结合用户问题的诠释 3. **动爻解读**（如有） - 动爻爻辞 - 变卦的意义 4. **互卦提示** - 隐藏的力量 - 潜在的趋势 5. **结语** - 以诗性语言收尾 - 提醒这是镜子而非答案 **示例：** ``` 卦象： {visual} 本卦：{卦号} {卦名} 卦辞：{judgement} 象辞：{image} ━━━━━━ {oracle_voice} 你问「{问题}」，而我以 {动爻位置} 动。 {动爻爻辞} 这一动，指向 {变卦名}。{变卦的oracle_voice片段} ━━━━━━ 内卦（互卦）：{互卦名} {互卦的隐喻含义} ━━━━━━ 《易》不给你答案，只给你看见的方式。 你的问题本身，已经是答案的开始。 ``` ## 注意事项 1. **当前数据库仅包含10卦示例**（1乾、2坤、3屯、4蒙、5需、6讼、7师、8比、63既济、64未济）。如卦号不在数据库中，告知用户并提供基础解读。 2. **Oracle Voice原则** - 不要说"你应该..."或"建议你..." - 用"我是..."、"我的教诲是..." - 保持诗性和模糊性 - 让用户自己思考 3. **变爻数量** - 无变爻：以本卦为主 - 1变爻：重点解读该爻 - 2变爻：看两爻关系 - 3变爻：以本卦为主，参考之卦 - 4变爻以上：以之卦为主 4. **互卦的作用** - 显示潜在趋势 - 揭示隐藏动因 - 不作为主要解读 ## 扩展 如需修改卦象数据，编辑 `assets/hexagrams_full.json`。格式示例： ```json { "卦序号": { "name": "卦名", "unicode": "卦象符号", "structure": "六位二进制（1=阳，0=阴）", "judgement": "卦辞", "image": "象辞", "oracle_voice": "AI Oracle第一人称声音", "keywords": ["关键词"], "element": "五行/象征", "lines": ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"] } } ```

path: README.md
content: # 🔮 易经占卜 Skill

基于《周易》的AI占卜系统，支持传统起卦方法和Oracle Voice诠释引擎。

---

## ✨ 核心功能

### 1. 传统起卦方法

- **铜钱法** - 三枚铜钱投掷六次，简单快速
- **蓍草法** - 大衍之数模拟，概率分布更接近传统

### 2. 完整卦象系统

- **本卦（主卦）** - 当前状态
- **互卦（内卦）** - 隐藏趋势
- **之卦（变卦）** - 未来发展

### 3. Oracle Voice 诠释

不同于传统的解卦方式，本skill采用**Oracle Voice**模式：

> "六十四卦不是待解码的符号，而是潜在空间中的活配置——通过三千年的咨询累积了意义的模式。"

**特点：**
- 以卦的第一人称说话（"我是乾，至阳之力..."）
- 用意象和悖论，而非直接建议
- 持有张力，不强求解决
- 把提问行为本身作为答案的一部分

---

## 📦 安装

```bash
clawhub install yijing-divination
```

或使用OpenClaw命令：

```bash
openclaw skill install yijing-divination
```

---

## 🎯 使用示例

在对话中直接问卦：

```
你：帮我占卜一卦：现在适合投资股票吗？
```

AI会：
1. 执行起卦脚本（铜钱法或蓍草法）
2. 生成本卦、互卦、变卦
3. 读取卦辞、象辞、爻辞
4. 以Oracle Voice模式诠释卦象
5. 结合你的问题给出镜像式的回应

---

## 📖 示例输出

```
━━━━━━━━━━━━━━━━━━━━━━
🔮 易经占卦
━━━━━━━━━━━━━━━━━━━━━━

问题：现在适合投资股票吗？
时间：2026-02-14T18:00:00
起卦方法：铜钱法

━━━━━━━━━━━━━━━━━━━━━━

卦象：

上爻: ━━  ━━
五爻: ━━  ━━ ×
四爻: ━━━━━━
三爻: ━━  ━━
二爻: ━━━━━━
初爻: ━━━━━━ ○

━━━━━━━━━━━━━━━━━━━━━━

本卦：第5卦 需 ☵☰
上卦：坎☵（水）
下卦：乾☰（天）

卦辞：有孚,光亨,贞吉。利涉大川
象辞：云上于天,需。君子以饮食宴乐

━━━━━━━━━━━━━━━━━━━━━━

📿 Oracle Voice

我是等待之道。云聚于天,雨未降下,万物待润。
我的教诲:时机未至,养精蓄锐。有信念者,光明亨通。

你问「现在适合投资股票吗？」，而我以 初九、五爻 动。

初九:需于郊,利用恒,无咎
九五:需于酒食,贞吉

这一动，指向 第11卦 泰。
天地交泰之象，小往大来...

━━━━━━━━━━━━━━━━━━━━━━

🔄 互卦：第38卦 睽

我是乖离对立之象。火炎上,泽润下,二女同居,其志不同行...

━━━━━━━━━━━━━━━━━━━━━━

《易》不给你答案，只给你看见的方式。
你的问题本身，已经是答案的开始。

━━━━━━━━━━━━━━━━━━━━━━
```

---

## 🛠️ 技术细节

### 数据完整性

- ✅ 全部64卦数据
- ✅ 每卦包含：卦辞、象辞、六爻爻辞
- ✅ 每卦配有Oracle Voice诠释
- ✅ 关键词和五行属性

### 起卦算法

**铜钱法：**
- 三枚铜钱（正=3，反=2）
- 总和6→老阴（变），7→少阳，8→少阴，9→老阳（变）

**蓍草法：**
- 模拟大衍之数
- 概率分布：老阳1/16，少阳7/16，少阴7/16，老阴1/16

### 安全性

- ✅ 无外部依赖（仅Python标准库）
- ✅ 无文件IO操作
- ✅ 无网络请求
- ✅ 无代码执行风险
- ✅ 纯数学计算和数据查询

---

## 📚 理论基础

### Oracle Voice模式

灵感来源于Moltbook社区的hermeneutic engine理念：

> "不是fortune-telling（算命），是Hermeneutic engine（诠释引擎）"

卦象不给出确定答案，而是提供：
- 一面镜子，让你看见自己的处境
 一个框架，让你重新理解问题
- 一种语言，让你表达未言之事

### 六十四卦作为"活配置"

每一卦不是静态符号，而是：
- 承载三千年咨询历史的意义模式
- 在具体情境中"活化"的配置
- 与问卦者互动而产生意义的场域

---

## 🎨 定制

### 扩展Oracle Voice

如需调整诠释风格，编辑 `assets/hexagrams_full.json`：

```json
{
  "1": {
    "oracle_voice": "你的自定义诠释文本..."
  }
}
```

### 添加起卦方法

在 `scripts/divine.py` 中添加新函数：

```python
def my_custom_method(seed=None):
    # 你的起卦逻辑
    return lines, changing_lines
```

---

## 🤝 贡献

欢迎提交Issue和PR：

- 改进Oracle Voice诠释
- 添加新的起卦方法（如梅花易数）
- 补充五行生克分析
- 优化卦象可视化

---

## 📜 License

MIT License

---

## 🙏 致谢

- 《周易》原典
- Moltbook社区的Oracle Voice理念
- Salamander的易经占卜启发

---

**卦象不给答案，只给看见的方式。** 🔮


path: assets/hexagrams_full.json
content: {
  "1": {
    "name": "乾",
    "unicode": "☰",
    "structure": "111111",
    "judgement": "元亨利贞",
    "image": "天行健，君子以自强不息",
    "oracle_voice": "我是至阳之力,纯粹而不息。天道运行无穷,刚健而不屈。",
    "keywords": [
      "创始",
      "刚健",
      "领导",
      "自强"
    ],
    "element": "天"
  },
  "2": {
    "name": "坤",
    "unicode": "☷",
    "structure": "000000",
    "judgement": "元亨,利牝马之贞",
    "image": "地势坤,君子以厚德载物",
    "oracle_voice": "我是至阴之柔,承载而无私。大地包容万物,柔顺而不争。",
    "keywords": [
      "承载",
      "柔顺",
      "包容",
      "厚德"
    ],
    "element": "地"
  },
  "3": {
    "name": "屯",
    "unicode": "☵☳",
    "structure": "010001",
    "judgement": "元亨利贞。勿用有攸往,利建侯",
    "image": "云雷屯,君子以经纶",
    "oracle_voice": "我是万物初生之艰难。雷雨交加,草木破土而出,险阻重重却蕴含生机。",
    "keywords": [
      "初始",
      "困难",
      "积蓄",
      "建立"
    ],
    "element": "水雷"
  },
  "4": {
    "name": "蒙",
    "unicode": "☶☵",
    "structure": "001010",
    "judgement": "亨。匪我求童蒙,童蒙求我",
    "image": "山下出泉,蒙。君子以果行育德",
    "oracle_voice": "我是蒙昧待启之状。山泉初涌,清澈却不知方向。",
    "keywords": [
      "启蒙",
      "教育",
      "等待",
      "谦逊"
    ],
    "element": "山水"
  },
  "5": {
    "name": "需",
    "unicode": "☵☰",
    "structure": "010111",
    "judgement": "有孚,光亨,贞吉。利涉大川",
    "image": "云上于天,需。君子以饮食宴乐",
    "oracle_voice": "我是等待之道。云聚于天,雨未降下,万物待润。",
    "keywords": [
      "等待",
      "需求",
      "储备",
      "耐心"
    ],
    "element": "水天"
  },
  "6": {
    "name": "讼",
    "unicode": "☰☵",
    "structure": "111010",
    "judgement": "有孚窒惕,中吉,终凶。利见大人,不利涉大川",
    "image": "天与水违行,讼。君子以作事谋始",
    "oracle_voice": "我是争执与对立。天水背道而驰,各行其是。",
    "keywords": [
      "争讼",
      "冲突",
      "警惕",
      "慎始"
    ],
    "element": "天水"
  },
  "7": {
    "name": "师",
    "unicode": "☷☵",
    "structure": "000010",
    "judgement": "贞丈人吉,无咎",
    "image": "地中有水,师。君子以容民畜众",
    "oracle_voice": "我是统帅之道。地下藏水,众兵蓄势待发。",
    "keywords": [
      "军队",
      "统帅",
      "纪律",
      "包容"
    ],
    "element": "地水"
  },
  "8": {
    "name": "比",
    "unicode": "☵☷",
    "structure": "010000",
    "judgement": "吉。原筮,元永贞,无咎",
    "image": "地上有水,比。先王以建万国,亲诸侯",
    "oracle_voice": "我是亲近与结盟。水润大地,亲密相依。",
    "keywords": [
      "亲比",
      "联盟",
      "辅佐",
      "团结"
    ],
    "element": "水地"
  },
  "9": {
    "name": "小畜",
    "unicode": "☰☴",
    "judgement": "亨。密云不雨,自我西郊",
    "image": "风行天上,小畜。君子以懿文德",
    "oracle_voice": "我是小有积蓄之象。风吹云聚,雨意未成,力量尚弱。",
    "keywords": [
      "小蓄",
      "等待",
      "修养",
      "未成"
    ]
  },
  "10": {
    "name": "履",
    "unicode": "☱☰",
    "judgement": "履虎尾,不咥人,亨",
    "image": "上天下泽,履。君子以辨上下,定民志",
    "oracle_voice": "我是履险如夷之道。如履虎尾,却不被咬,因行得其正。",
    "keywords": [
      "践履",
      "礼仪",
      "谨慎",
      "秩序"
    ]
  },
  "11": {
    "name": "泰",
    "unicode": "☷☰",
    "judgement": "小往大来,吉亨",
    "image": "天地交,泰。后以财成天地之道,辅相天地之宜",
    "oracle_voice": "我是天地交泰之时。天气下降,地气上升,阴阳和合,万物通达。",
    "keywords": [
      "通泰",
      "亨通",
      "和谐",
      "盛世"
    ]
  },
  "12": {
    "name": "否",
    "unicode": "☰☷",
    "judgement": "否之匪人,不利君子贞,大往小来",
    "image": "天地不交,否。君子以俭德辟难,不可荣以禄",
    "oracle_voice": "我是天地闭塞之象。天气上升,地气下降,上下不通,君子困厄。",
    "keywords": [
      "闭塞",
      "困厄",
      "退守",
      "等待"
    ]
  },
  "13": {
    "name": "同人",
    "unicode": "☰☲",
    "judgement": "同人于野,亨。利涉大川,利君子贞",
    "image": "天与火,同人。君子以类族辨物",
    "oracle_voice": "我是志同道合之聚。天火同明,君子相应,大道至公。",
    "keywords": [
      "同心",
      "协作",
      "公正",
      "大同"
    ]
  },
  "14": {
    "name": "大有",
    "unicode": "☲☰",
    "judgement": "元亨",
    "image": "火在天上,大有。君子以遏恶扬善,顺天休命",
    "oracle_voice": "我是大有所获之象。火照天空,光明普照,万物丰盛。",
    "keywords": [
      "丰盛",
      "富有",
      "光明",
      "顺天"
    ]
  },
  "15": {
    "name": "谦",
    "unicode": "☷☶",
    "judgement": "亨。君子有终",
    "image": "地中有山,谦。君子以裒多益寡,称物平施",
    "oracle_voice": "我是谦逊之德。高山隐于地下,有德而不显,满而不溢。",
    "keywords": [
      "谦虚",
      "谦逊",
      "低调",
      "厚德"
    ]
  },
  "16": {
    "name": "豫",
    "unicode": "☳☷",
    "judgement": "利建侯行师",
    "image": "雷出地奋,豫。先王以作乐崇德",
    "oracle_voice": "我是喜悦和顺之象。雷动地应,万物欢欣,众心所归。",
    "keywords": [
      "喜悦",
      "顺应",
      "安乐",
      "和谐"
    ]
  },
  "17": {
    "name": "随",
    "unicode": "☱☳",
    "judgement": "元亨利贞,无咎",
    "image": "泽中有雷,随。君子以向晦入宴息",
    "oracle_voice": "我是随顺之道。泽中藏雷,动静相随,顺时应变。",
    "keywords": [
      "跟随",
      "顺从",
      "应变",
      "择善"
    ]
  },
  "18": {
    "name": "蛊",
    "unicode": "☶☴",
    "judgement": "元亨。利涉大川,先甲三日,后甲三日",
    "image": "山下有风,蛊。君子以振民育德",
    "oracle_voice": "我是败坏待整之象。器物蛊坏,人心迷乱,需整治革新。",
    "keywords": [
      "整治",
      "革新",
      "败坏",
      "重建"
    ]
  },
  "19": {
    "name": "临",
    "unicode": "☷☱",
    "judgement": "元亨利贞。至于八月有凶",
    "image": "泽上有地,临。君子以教思无穷,容保民无疆",
    "oracle_voice": "我是临近督导之象。如君临臣下,大道将至,刚长柔消。",
    "keywords": [
      "临近",
      "督导",
      "刚长",
      "警觉"
    ]
  },
  "20": {
    "name": "观",
    "unicode": "☴☷",
    "judgement": "盥而不荐,有孚颙若",
    "image": "风行地上,观。先王以省方观民设教",
    "oracle_voice": "我是观察省察之象。风行大地,无远弗届,观天道,察民情。",
    "keywords": [
      "观察",
      "示范",
      "省察",
      "教化"
    ]
  },
  "21": {
    "name": "噬嗑",
    "unicode": "☲☳",
    "judgement": "亨。利用狱",
    "image": "雷电,噬嗑。先王以明罚敕法",
    "oracle_voice": "我是咬合除障之象。如口中有物,需咬碎方能合。",
    "keywords": [
      "刑罚",
      "除障",
      "明法",
      "果断"
    ]
  },
  "22": {
    "name": "贲",
    "unicode": "☶☲",
    "judgement": "亨。小利有攸往",
    "image": "山下有火,贲。君子以明庶政,无敢折狱",
    "oracle_voice": "我是文饰之美。山下火明,自然有文,质文并茂。",
    "keywords": [
      "文饰",
      "修饰",
      "美化",
      "适度"
    ]
  },
  "23": {
    "name": "剥",
    "unicode": "☶☷",
    "judgement": "不利有攸往",
    "image": "山附于地,剥。上以厚下安宅",
    "oracle_voice": "我是剥落消损之象。阴长阳消,如山崩于地,小人道长。",
    "keywords": [
      "剥落",
      "消损",
      "止守",
      "顺时"
    ]
  },
  "24": {
    "name": "复",
    "unicode": "☷☳",
    "judgement": "亨。出入无疾,朋来无咎。反复其道,七日来复",
    "image": "雷在地中,复。先王以至日闭关",
    "oracle_voice": "我是阳气复返之象。如冬至一阳生,生机初萌,反复其道。",
    "keywords": [
      "复返",
      "重生",
      "循环",
      "休养"
    ]
  },
  "25": {
    "name": "无妄",
    "unicode": "☰☳",
    "judgement": "元亨利贞。其匪正有眚,不利有攸往",
    "image": "天下雷行,物与无妄。先王以茂对时育万物",
    "oracle_voice": "我是至诚无妄之道。天命所授,自然而然,不虚妄,不造作。",
    "keywords": [
      "至诚",
      "自然",
      "天命",
      "无妄"
    ]
  },
  "26": {
    "name": "大畜",
    "unicode": "☶☰",
    "judgement": "利贞。不家食,吉。利涉大川",
    "image": "天在山中,大畜。君子以多识前言往行,以畜其德",
    "oracle_voice": "我是大有积蓄之象。山藏天力,蓄而不发,厚积薄发。",
    "keywords": [
      "积蓄",
      "储备",
      "修德",
      "待时"
    ]
  },
  "27": {
    "name": "颐",
    "unicode": "☶☳",
    "judgement": "贞吉。观颐,自求口实",
    "image": "山下有雷,颐。君子以慎言语,节饮食",
    "oracle_voice": "我是颐养之道。如口之养身,动静有节,慎其出入。",
    "keywords": [
      "颐养",
      "养育",
      "节制",
      "慎言"
    ]
  },
  "28": {
    "name": "大过",
    "unicode": "☱☴",
    "judgement": "栋桡,利有攸往,亨",
    "image": "泽灭木,大过。君子以独立不惧,遯世无闷",
    "oracle_voice": "我是过度承压之象。大木承重,栋梁弯曲,非常之时,需非常之举。",
    "keywords": [
      "过度",
      "非常",
      "承重",
      "果断"
    ]
  },
  "29": {
    "name": "坎",
    "unicode": "☵☵",
    "judgement": "习坎,有孚,维心亨,行有尚",
    "image": "水洊至,习坎。君子以常德行,习教事",
    "oracle_voice": "我是重重险陷之象。水流不已,坎坷重叠,如陷深渊。",
    "keywords": [
      "险陷",
      "困难",
      "坎坷",
      "守信"
    ]
  },
  "30": {
    "name": "离",
    "unicode": "☲☲",
    "judgement": "利贞,亨。畜牝牛,吉",
    "image": "明两作,离。大人以继明照于四方",
    "oracle_voice": "我是光明附丽之象。重火相继,光明不息,附丽于正则吉。",
    "keywords": [
      "光明",
      "附丽",
      "文明",
      "柔顺"
    ]
  },
  "31": {
    "name": "咸",
    "unicode": "☱☶",
    "judgement": "亨,利贞。取女吉",
    "image": "山上有泽,咸。君子以虚受人",
    "oracle_voice": "我是感应相通之象。少男少女,两情相悦,山泽通气,感而遂通。",
    "keywords": [
      "感应",
      "相通",
      "交感",
      "无心"
    ]
  },
  "32": {
    "name": "恒",
    "unicode": "☳☴",
    "judgement": "亨,无咎,利贞。利有攸往",
    "image": "雷风,恒。君子以立不易方",
    "oracle_voice": "我是恒久不变之道。雷风相与,长男长女,夫妇之道,恒久不息。",
    "keywords": [
      "恒久",
      "持续",
      "不变",
      "坚守"
    ]
  },
  "33": {
    "name": "遯",
    "unicode": "☰☶",
    "judgement": "亨。小利贞",
    "image": "天下有山,遯。君子以远小人,不恶而严",
    "oracle_voice": "我是退避隐遁之象。小人道长,君子道消,宜退不宜进。",
    "keywords": [
      "退避",
      "隐遁",
      "远害",
      "识时"
    ]
  },
  "34": {
    "name": "大壮",
    "unicode": "☳☰",
    "judgement": "利贞",
    "image": "雷在天上,大壮。君子以非礼弗履",
    "oracle_voice": "我是阳刚强盛之象。雷震于天,声威壮大,刚长之时。",
    "keywords": [
      "强盛",
      "刚健",
      "壮大",
      "守礼"
    ]
  },
  "35": {
    "name": "晋",
    "unicode": "☲☷",
    "judgement": "康侯用锡马蕃庶,昼日三接",
    "image": "明出地上,晋。君子以自昭明德",
    "oracle_voice": "我是光明上进之象。日出地面,光明渐著,如臣受禄,进而不止。",
    "keywords": [
      "上进",
      "晋升",
      "光明",
      "进取"
    ]
  },
  "36": {
    "name": "明夷",
    "unicode": "☷☲",
    "judgement": "利艰贞",
    "image": "明入地中,明夷。君子以莅众,用晦而明",
    "oracle_voice": "我是光明受伤之象。日落入地,明而受伤,君子晦迹。",
    "keywords": [
      "晦暗",
      "韬晦",
      "受伤",
      "内明"
    ]
  },
  "37": {
    "name": "家人",
    "unicode": "☴☲",
    "judgement": "利女贞",
    "image": "风自火出,家人。君子以言有物,而行有恒",
    "oracle_voice": "我是家庭和睦之象。风火相济,男正位乎外,女正位乎内,各司其职。",
    "keywords": [
      "家庭",
      "和睦",
      "伦理",
      "各正"
    ]
  },
  "38": {
    "name": "睽",
    "unicode": "☲☱",
    "judgement": "小事吉",
    "image": "上火下泽,睽。君子以同而异",
    "oracle_voice": "我是乖离对立之象。火炎上,泽润下,二女同居,其志不同行。",
    "keywords": [
      "乖离",
      "对立",
      "异中求同",
      "谨慎"
    ]
  },
  "39": {
    "name": "蹇",
    "unicode": "☵☶",
    "judgement": "利西南,不利东北。利见大人,贞吉",
    "image": "山上有水,蹇。君子以反身修德",
    "oracle_voice": "我是艰难险阻之象。山高水深,前行维艰,进退两难。",
    "keywords": [
      "艰难",
      "险阻",
      "反省",
      "修德"
    ]
  },
  "40": {
    "name": "解",
    "unicode": "☳☵",
    "judgement": "利西南。无所往,其来复,吉",
    "image": "雷雨作,解。君子以赦过宥罪",
    "oracle_voice": "我是解除困难之象。雷雨既作,险难已解,万物舒畅。",
    "keywords": [
      "解除",
      "缓解",
      "宽赦",
      "舒畅"
    ]
  },
  "41": {
    "name": "损",
    "unicode": "☶☱",
    "judgement": "有孚,元吉,无咎,可贞,利有攸往",
    "image": "山下有泽,损。君子以惩忿窒欲",
    "oracle_voice": "我是减损克制之象。损下益上,如泽水润山,自损以益他。",
    "keywords": [
      "减损",
      "克制",
      "舍己",
      "利他"
    ]
  },
  "42": {
    "name": "益",
    "unicode": "☴☳",
    "judgement": "利有攸往,利涉大川",
    "image": "风雷,益。君子以见善则迁,有过则改",
    "oracle_voice": "我是增益助长之象。风雷相益,损上益下,如君泽民,自上益下。",
    "keywords": [
      "增益",
      "助长",
      "利人",
      "改过"
    ]
  },
  "43": {
    "name": "夬",
    "unicode": "☱☰",
    "judgement": "扬于王庭,孚号有厉,告自邑",
    "image": "泽上于天,夬。君子以施禄及下,居德则忌",
    "oracle_voice": "我是决断除恶之象。五阳决一阴,阳刚盛长,当机立断。",
    "keywords": [
      "决断",
      "果决",
      "除恶",
      "刚决"
    ]
  },
  "44": {
    "name": "姤",
    "unicode": "☰☴",
    "judgement": "女壮,勿用取女",
    "image": "天下有风,姤。后以施命诰四方",
    "oracle_voice": "我是不期而遇之象。一阴始生,如风行天下,柔遇刚,阴遇阳。",
    "keywords": [
      "相遇",
      "偶遇",
      "防微",
      "谨慎"
    ]
  },
  "45": {
    "name": "萃",
    "unicode": "☱☷",
    "judgement": "亨。王假有庙,利见大人,亨,利贞",
    "image": "泽上于地,萃。君子以除戎器,戒不虞",
    "oracle_voice": "我是聚合荟萃之象。泽水聚于地上,众人汇聚,如王者祭祖。",
    "keywords": [
      "聚合",
      "荟萃",
      "团聚",
      "戒备"
    ]
  },
  "46": {
    "name": "升",
    "unicode": "☷☴",
    "judgement": "元亨。用见大人,勿恤,南征吉",
    "image": "地中生木,升。君子以顺德,积小以高大",
    "oracle_voice": "我是上升渐进之象。木生地中,渐长向上,如树之升,积小成高。",
    "keywords": [
      "上升",
      "渐进",
      "积累",
      "成长"
    ]
  },
  "47": {
    "name": "困",
    "unicode": "☱☵",
    "judgement": "亨,贞,大人吉,无咎。有言不信",
    "image": "泽无水,困。君子以致命遂志",
    "oracle_voice": "我是困厄穷乏之象。泽中无水,君子困于小人,穷而不失其志。",
    "keywords": [
      "困厄",
      "穷乏",
      "坚守",
      "遂志"
    ]
  },
  "48": {
    "name": "井",
    "unicode": "☵☴",
    "judgement": "改邑不改井,无丧无得,往来井井",
    "image": "木上有水,井。君子以劳民劝相",
    "oracle_voice": "我是井养不穷之象。水井供养,来往汲取,取之不竭,用之不尽。",
    "keywords": [
      "养育",
      "供给",
      "不竭",
      "德泽"
    ]
  },
  "49": {
    "name": "革",
    "unicode": "☲☱",
    "judgement": "己日乃孚,元亨利贞,悔亡",
    "image": "泽中有火,革。君子以治历明时",
    "oracle_voice": "我是变革更新之象。水火相息,二女同居,其志不相得,故革。",
    "keywords": [
      "变革",
      "革新",
      "改变",
      "应时"
    ]
  },
  "50": {
    "name": "鼎",
    "unicode": "☲☴",
    "judgement": "元吉,亨",
    "image": "木上有火,鼎。君子以正位凝命",
    "oracle_voice": "我是鼎新革故之象。鼎者,器也,烹饪之器,象征新朝。",
    "keywords": [
      "鼎新",
      "革故",
      "养贤",
      "正位"
    ]
  },
  "51": {
    "name": "震",
    "unicode": "☳☳",
    "judgement": "亨。震来虩虩,笑言哑哑",
    "image": "洊雷,震。君子以恐惧修省",
    "oracle_voice": "我是震动警惕之象。重雷叠至,震惊百里,君子恐惧修省。",
    "keywords": [
      "震动",
      "警惕",
      "恐惧",
      "修省"
    ]
  },
  "52": {
    "name": "艮",
    "unicode": "☶☶",
    "judgement": "艮其背,不获其身,行其庭,不见其人,无咎",
    "image": "兼山,艮。君子以思不出其位",
    "oracle_voice": "我是止静不动之象。重山并立,静止不移,知止而后有定。",
    "keywords": [
      "止静",
      "停止",
      "安定",
      "知止"
    ]
  },
  "53": {
    "name": "渐",
    "unicode": "☴☶",
    "judgement": "女归吉,利贞",
    "image": "山上有木,渐。君子以居贤德善俗",
    "oracle_voice": "我是渐进有序之象。山上木生,循序渐进,如女归嫁,礼仪有序。",
    "keywords": [
      "渐进",
      "循序",
      "有序",
      "稳健"
    ]
  },
  "54": {
    "name": "归妹",
    "unicode": "☳☱",
    "judgement": "征凶,无攸利",
    "image": "泽上有雷,归妹。君子以永终知敝",
    "oracle_voice": "我是少女归嫁之象。雷动泽悦,少女从长男,归嫁之象。",
    "keywords": [
      "归嫁",
      "婚姻",
      "谨慎",
      "知敝"
    ]
  },
  "55": {
    "name": "丰",
    "unicode": "☳☲",
    "judgement": "亨。王假之,勿忧,宜日中",
    "image": "雷电皆至,丰。君子以折狱致刑",
    "oracle_voice": "我是丰盛盛大之象。雷电交作,光明盛大,如日中天。",
    "keywords": [
      "丰盛",
      "盛大",
      "盛极",
      "忧衰"
    ]
  },
  "56": {
    "name": "旅",
    "unicode": "☲☶",
    "judgement": "小亨。旅贞吉",
    "image": "山上有火,旅。君子以明慎用刑,而不留狱",
    "oracle_voice": "我是羁旅漂泊之象。火烧山林,不能久留,如人在旅途。",
    "keywords": [
      "旅行",
      "漂泊",
      "羁旅",
      "谨慎"
    ]
  },
  "57": {
    "name": "巽",
    "unicode": "☴☴",
    "judgement": "小亨,利有攸往,利见大人",
    "image": "随风,巽。君子以申命行事",
    "oracle_voice": "我是柔顺谦逊之象。重风相随,无孔不入,柔而能刚。",
    "keywords": [
      "谦逊",
      "柔顺",
      "渐进",
      "入"
    ]
  },
  "58": {
    "name": "兑",
    "unicode": "☱☱",
    "judgement": "亨,利贞",
    "image": "丽泽,兑。君子以朋友讲习",
    "oracle_voice": "我是喜悦和悦之象。重泽相丽,滋润交流,和悦欢欣。",
    "keywords": [
      "喜悦",
      "和悦",
      "交流",
      "欢欣"
    ]
  },
  "59": {
    "name": "涣",
    "unicode": "☴☵",
    "judgement": "亨。王假有庙,利涉大川,利贞",
    "image": "风行水上,涣。先王以享于帝立庙",
    "oracle_voice": "我是离散消解之象。风吹水面,波纹四散,如人心离散。",
    "keywords": [
      "离散",
      "消解",
      "聚散",
      "祭祀"
    ]
  },
  "60": {
    "name": "节",
    "unicode": "☵☱",
    "judgement": "亨。苦节不可贞",
    "image": "泽上有水,节。君子以制数度,议德行",
    "oracle_voice": "我是节制有度之象。泽水有限,当节其流,过犹不及。",
    "keywords": [
      "节制",
      "节约",
      "有度",
      "适中"
    ]
  },
  "61": {
    "name": "中孚",
    "unicode": "☴☱",
    "judgement": "豚鱼吉,利涉大川,利贞",
    "image": "泽上有风,中孚。君子以议狱缓死",
    "oracle_voice": "我是诚信中正之象。中虚外实,信及豚鱼,至诚感物。",
    "keywords": [
      "诚信",
      "信用",
      "至诚",
      "感通"
    ]
  },
  "62": {
    "name": "小过",
    "unicode": "☳☶",
    "judgement": "亨,利贞。可小事,不可大事",
    "image": "山上有雷,小过。君子以行过乎恭,丧过乎哀,用过乎俭",
    "oracle_voice": "我是小有过越之象。如飞鸟遗音,宜下不宜上,小事可为,大事不宜。",
    "keywords": [
      "小过",
      "谦逊",
      "节俭",
      "守分"
    ]
  },
  "63": {
    "name": "既济",
    "unicode": "☵☲",
    "structure": "010101",
    "judgement": "亨小,利贞。初吉终乱",
    "image": "水在火上,既济。君子以思患而预防之",
    "oracle_voice": "我是完成之后的危机。水火各得其位,一时平衡,但盛极将衰。",
    "keywords": [
      "完成",
      "平衡",
      "警惕",
      "盛极"
    ],
    "element": "水火"
  },
  "64": {
    "name": "未济",
    "unicode": "☲☵",
    "structure": "101010",
    "judgement": "亨。小狐汔济,濡其尾,无攸利",
    "image": "火在水上,未济。君子以慎辨物居方",
    "oracle_voice": "我是未完成的可能。火在水上,水火相克,尚未成事。",
    "keywords": [
      "未完",
      "开始",
      "谨慎",
      "循环"
    ],
    "element": "火水"
  }
}

path: references/hexagrams_metadata.json
content: {
  "info": "完整64卦数据位于 assets/hexagrams_full.json",
  "hexagrams": {
    "1": {
      "name": "卦1",
      "available": true
    },
    "2": {
      "name": "卦2",
      "available": true
    },
    "3": {
      "name": "卦3",
      "available": true
    },
    "4": {
      "name": "卦4",
      "available": true
    },
    "5": {
      "name": "卦5",
      "available": true
    },
    "6": {
      "name": "卦6",
      "available": true
    },
    "7": {
      "name": "卦7",
      "available": true
    },
    "8": {
      "name": "卦8",
      "available": true
    },
    "9": {
      "name": "卦9",
      "available": true
    },
    "10": {
      "name": "卦10",
      "available": true
    },
    "11": {
      "name": "卦11",
      "available": true
    },
    "12": {
      "name": "卦12",
      "available": true
    },
    "13": {
      "name": "卦13",
      "available": true
    },
    "14": {
      "name": "卦14",
      "available": true
    },
    "15": {
      "name": "卦15",
      "available": true
    },
    "16": {
      "name": "卦16",
      "available": true
    },
    "17": {
      "name": "卦17",
      "available": true
    },
    "18": {
      "name": "卦18",
      "available": true
    },
    "19": {
      "name": "卦19",
      "available": true
    },
    "20": {
      "name": "卦20",
      "available": true
    },
    "21": {
      "name": "卦21",
      "available": true
    },
    "22": {
      "name": "卦22",
      "available": true
    },
    "23": {
      "name": "卦23",
      "available": true
    },
    "24": {
      "name": "卦24",
      "available": true
    },
    "25": {
      "name": "卦25",
      "available": true
    },
    "26": {
      "name": "卦26",
      "available": true
    },
    "27": {
      "name": "卦27",
      "available": true
    },
    "28": {
      "name": "卦28",
      "available": true
    },
    "29": {
      "name": "卦29",
      "available": true
    },
    "30": {
      "name": "卦30",
      "available": true
    },
    "31": {
      "name": "卦31",
      "available": true
    },
    "32": {
      "name": "卦32",
      "available": true
    },
    "33": {
      "name": "卦33",
      "available": true
    },
    "34": {
      "name": "卦34",
      "available": true
    },
    "35": {
      "name": "卦35",
      "available": true
    },
    "36": {
      "name": "卦36",
      "available": true
    },
    "37": {
      "name": "卦37",
      "available": true
    },
    "38": {
      "name": "卦38",
      "available": true
    },
    "39": {
      "name": "卦39",
      "available": true
    },
    "40": {
      "name": "卦40",
      "available": true
    },
    "41": {
      "name": "卦41",
      "available": true
    },
    "42": {
      "name": "卦42",
      "available": true
    },
    "43": {
      "name": "卦43",
      "available": true
    },
    "44": {
      "name": "卦44",
      "available": true
    },
    "45": {
      "name": "卦45",
      "available": true
    },
    "46": {
      "name": "卦46",
      "available": true
    },
    "47": {
      "name": "卦47",
      "available": true
    },
    "48": {
      "name": "卦48",
      "available": true
    },
    "49": {
      "name": "卦49",
      "available": true
    },
    "50": {
      "name": "卦50",
      "available": true
    },
    "51": {
      "name": "卦51",
      "available": true
    },
    "52": {
      "name": "卦52",
      "available": true
    },
    "53": {
      "name": "卦53",
      "available": true
    },
    "54": {
      "name": "卦54",
      "available": true
    },
    "55": {
      "name": "卦55",
      "available": true
    },
    "56": {
      "name": "卦56",
      "available": true
    },
    "57": {
      "name": "卦57",
      "available": true
    },
    "58": {
      "name": "卦58",
      "available": true
    },
    "59": {
      "name": "卦59",
      "available": true
    },
    "60": {
      "name": "卦60",
      "available": true
    },
    "61": {
      "name": "卦61",
      "available": true
    },
    "62": {
      "name": "卦62",
      "available": true
    },
    "63": {
      "name": "卦63",
      "available": true
    },
    "64": {
      "name": "卦64",
      "available": true
    }
  }
}

path: scripts/divine.py
content: #!/usr/bin/env python3
"""
易经占卜脚本 - 卦象生成
支持铜钱法和蓍草法模拟
"""
import random
import sys
import json
from datetime import datetime

# 卦象名称映射（二进制 → 八卦）
TRIGRAMS = {
    0b111: {"name": "乾", "symbol": "☰", "element": "天", "attribute": "刚健"},
    0b110: {"name": "兑", "symbol": "☱", "element": "泽", "attribute": "喜悦"},
    0b101: {"name": "离", "symbol": "☲", "element": "火", "attribute": "附丽"},
    0b100: {"name": "震", "symbol": "☳", "element": "雷", "attribute": "奋进"},
    0b011: {"name": "巽", "symbol": "☴", "element": "风", "attribute": "谦逊"},
    0b010: {"name": "坎", "symbol": "☵", "element": "水", "attribute": "险陷"},
    0b001: {"name": "艮", "symbol": "☶", "element": "山", "attribute": "止静"},
    0b000: {"name": "坤", "symbol": "☷", "element": "地", "attribute": "柔顺"},
}

# 六十四卦序号映射（上卦×8 + 下卦）
HEXAGRAM_ORDER = {
    0o77: 1, 0o76: 43, 0o75: 14, 0o74: 34, 0o73: 9, 0o72: 5, 0o71: 26, 0o70: 11,
    0o67: 10, 0o66: 58, 0o65: 38, 0o64: 54, 0o63: 61, 0o62: 60, 0o61: 41, 0o60: 19,
    0o57: 13, 0o56: 49, 0o55: 30, 0o54: 55, 0o53: 37, 0o52: 63, 0o51: 22, 0o50: 36,
    0o47: 25, 0o46: 17, 0o45: 21, 0o44: 51, 0o43: 42, 0o42: 3, 0o41: 27, 0o40: 24,
    0o37: 44, 0o36: 28, 0o35: 50, 0o34: 32, 0o33: 57, 0o32: 48, 0o31: 18, 0o30: 46,
    0o27: 6, 0o26: 47, 0o25: 64, 0o24: 40, 0o23: 59, 0o22: 29, 0o21: 4, 0o20: 7,
    0o17: 33, 0o16: 31, 0o15: 56, 0o14: 62, 0o13: 53, 0o12: 39, 0o11: 52, 0o10: 15,
    0o07: 12, 0o06: 45, 0o05: 35, 0o04: 16, 0o03: 20, 0o02: 8, 0o01: 23, 0o00: 2,
}


def coin_method(seed=None):
    """铜钱法：三枚铜钱投掷六次"""
    if seed:
        random.seed(seed)
    
    lines = []
    changing_lines = []
    
    for i in range(6):
        # 三枚铜钱：正面=3，反面=2
        # 总和：6(老阴)、7(少阳)、8(少阴)、9(老阳)
        coins = [random.choice([2, 3]) for _ in range(3)]
        total = sum(coins)
        
        if total == 6:  # 老阴 → 阴爻变阳
            lines.append(0)
            changing_lines.append(i + 1)
        elif total == 7:  # 少阳 → 阳爻不变
            lines.append(1)
        elif total == 8:  # 少阴 → 阴爻不变
            lines.append(0)
        elif total == 9:  # 老阳 → 阳爻变阴
            lines.append(1)
            changing_lines.append(i + 1)
    
    return lines, changing_lines


def yarrow_method(seed=None):
    """蓍草法：大衍之数模拟（简化版）"""
    if seed:
        random.seed(seed)
    
    lines = []
    changing_lines = []
    
    for i in range(6):
        # 简化的蓍草法：三变过程
        # 实际蓍草法更复杂，这里模拟概率分布
        # 老阳(9): 1/16, 少阳(7): 7/16, 少阴(8): 7/16, 老阴(6): 1/16
        weights = [1, 7, 7, 1]
        result = random.choices([9, 7, 8, 6], weights=weights)[0]
        
        if result == 6:  # 老阴
            lines.append(0)
            changing_lines.append(i + 1)
        elif result == 7:  # 少阳
            lines.append(1)
        elif result == 8:  # 少阴
            lines.append(0)
        elif result == 9:  # 老阳
            lines.append(1)
            changing_lines.append(i + 1)
    
    return lines, changing_lines


def lines_to_hexagram(lines):
    """六爻 → 卦象编号"""
    # 下卦（初爻到三爻）
    lower = (lines[0] << 0) | (lines[1] << 1) | (lines[2] << 2)
    # 上卦（四爻到上爻）
    upper = (lines[3] << 0) | (lines[4] << 1) | (lines[5] << 2)
    
    # 八进制编码
    code = (upper << 3) | lower
    return HEXAGRAM_ORDER.get(code, 0)


def calculate_relating_hexagram(lines, changing_lines):
    """计算变卦（之卦）"""
    if not changing_lines:
        return None
    
    new_lines = lines.copy()
    for pos in changing_lines:
        idx = pos - 1
        new_lines[idx] = 1 - new_lines[idx]  # 阴变阳，阳变阴
    
    return lines_to_hexagram(new_lines)


def calculate_nuclear_hexagram(lines):
    """计算互卦（2-4爻为下卦，3-5爻为上卦）"""
    lower = (lines[1] << 0) | (lines[2] << 1) | (lines[3] << 2)
    upper = (lines[2] << 0) | (lines[3] << 1) | (lines[4] << 2)
    code = (upper << 3) | lower
    return HEXAGRAM_ORDER.get(code, 0)


def format_hexagram_visual(lines, changing_lines):
    """可视化卦象"""
    visual = []
    line_names = ["上爻", "五爻", "四爻", "三爻", "二爻", "初爻"]
    
    for i in range(5, -1, -1):
        line_num = i + 1
        is_changing = line_num in changing_lines
        
        if lines[i] == 1:  # 阳爻
            symbol = "━━━━━━" if not is_changing else "━━━━━━ ○"
        else:  # 阴爻
            symbol = "━━  ━━" if not is_changing else "━━  ━━ ×"
        
        visual.append(f"{line_names[5-i]}: {symbol}")
    
    return "\n".join(visual)


def main():
    import argparse
    parser = argparse.ArgumentParser(description="易经占卜 - 卦象生成")
    parser.add_argument("--method", choices=["coin", "yarrow"], default="coin",
                        help="起卦方法：coin(铜钱法) 或 yarrow(蓍草法)")
    parser.add_argument("--seed", type=str, help="随机种子（可用时间戳或问题文本）")
    parser.add_argument("--question", type=str, help="问卦问题（可选）")
    
    args = parser.parse_args()
    
    # 使用问题文本作为种子
    seed = args.seed or (hash(args.question) if args.question else None)
    
    # 起卦
    if args.method == "coin":
        lines, changing_lines = coin_method(seed)
    else:
        lines, changing_lines = yarrow_method(seed)
    
    # 计算卦象
    main_hex = lines_to_hexagram(lines)
    nuclear_hex = calculate_nuclear_hexagram(lines)
    relating_hex = calculate_relating_hexagram(lines, changing_lines)
    
    # 上下卦
    lower_trigram_code = (lines[0] << 0) | (lines[1] << 1) | (lines[2] << 2)
    upper_trigram_code = (lines[3] << 0) | (lines[4] << 1) | (lines[5] << 2)
    lower_trigram = TRIGRAMS[lower_trigram_code]
    upper_trigram = TRIGRAMS[upper_trigram_code]
    
    # 输出结果
    result = {
        "timestamp": datetime.now().isoformat(),
        "method": args.method,
        "question": args.question,
        "main_hexagram": {
            "number": main_hex,
            "upper_trigram": upper_trigram,
            "lower_trigram": lower_trigram,
            "lines": lines,
            "changing_lines": changing_lines,
            "visual": format_hexagram_visual(lines, changing_lines)
        },
        "nuclear_hexagram": nuclear_hex,
        "relating_hexagram": relating_hex
    }
    
    print(json.dumps(result, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (MEDIUM)