Skip to content
Back to search

qmenpowers

奇门遁甲 八门化气阵

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/skyfiredao--qmenpowers/badge.svg)](/listings/skyfiredao--qmenpowers)

HTML

<a href="/listings/skyfiredao--qmenpowers"><img src="/api/listings/skyfiredao--qmenpowers/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Run `install.sh` to symlink the project into your OpenCode skills directory and make the CLI executable:

bash install.sh

This creates a symlink for each `qmen_*` sub-skill in the OpenCode skills directory (e.g. `qmen_dunjia`, `qmen_event`, `qmen_caiguan`, `qmen_huaqizhen`, `qmen_hunlian`, `qmen_xingge`, `qmen_wanwu`, `qmen_yaoce`). Each skill sub-directory also contains relative symlinks (`bin`, `data`, `lib`) pointing to the project's tools directory, so AI agents can resolve the project root at runtime without hardcoded paths. Restart OpenCode to load the skills.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 948 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. **[中文版](README_zh.md)**
  2. > Establish the heart of heaven and earth,
  3. > Secure the livelihood of the people,
  4. > Continue the lost teachings of past sages,
  5. > Open an era of peace for all generations.
  6. >
  7. > — Zhang Zai, *Hengqu Four Maxims* (横渠四句)
  8. # Qi Men Dun Jia — Eight Gates Huaqi Array
  9. # 奇门遁甲 八门化气阵
  10. A pure-Bash Qi Men Dun Jia plate-setting engine with zero external dependencies.
  11. ## What Is Qi Men Dun Jia?
  12. Qi Men Dun Jia (奇门遁甲) is one of the "Three Styles" (三式) of classical Chinese cosmological forecasting, alongside Tai Yi (太乙) and Liu Ren (六壬). Dating back over two thousand years, it maps time and space onto a nine-palace grid derived from the Luoshu (洛书) magic square, then layers multiple symbol systems on top: heavenly stems, stars, gates, and deities. Each layer interacts through the five-phase (五行, wuxing) cycle of generation and overcoming, producing a rich symbolic picture of a given moment's energetic landscape.
  13. The system was historically used for military strategy, site selection, and timing decisions. Today it remains a living tradition in Chinese metaphysics, studied for both its cultural depth and its internal structural elegance.
  14. ## Design Choices
  15. **Zhi-Run intercalary method only.** Two major schools exist for handling the boundary between solar terms: Zhi-Run (置闰法) and Chai-Bu (拆补法). This project implements Zhi-Run exclusively. In Zhi-Run, when the current time falls between the Jieqi (节气) boundary and the start of a new Yuan (元), the previous Ju number is carried forward ("intercalated"). Chai-Bu instead splits and patches across both Ju numbers. Zhi-Run produces a single clean Ju per moment, which simplifies the computation pipeline and aligns with the dominant mainland Chinese tradition.
  16. **Hourly Qi Men with rotating plate.** This is Shi Jia Qi Men (时家奇门), the hourly variant, not the daily or monthly variants. The plate uses the rotating-plate (转盘) method, where stars and gates physically rotate around the nine palaces. The alternative flying-star (飞盘) method assigns symbols by flight path rather than rotation. Rotating plate preserves the spatial relationship between symbols and palaces, making it more intuitive for reading directional significance.
  17. **Tianqin palace assignment.** The star Tianqin (天禽, Heavenly Bird) sits in the center palace (5-palace), which has no gate and therefore needs a hosting palace. Three modes are available via `--tianqin=MODE`:
  18. - **`follow-tiannei`** (default): Tianqin follows wherever Tiannei (天内) goes. When the heaven plate rotates, Tiannei and Tianqin share the same palace. This preserves Tianqin's yin-earth affinity with Tiannei's yin-earth nature.
  19. - **`jikun`**: Tianqin lodges permanently in the Kun 2-palace (寄坤二宫), regardless of plate rotation. This is the most traditional convention.
  20. - **`follow-zhifu`**: Tianqin follows the Zhifu (值符) duty star to its rotated palace.
  21. In all modes, the hosting palace displays Tianqin with a `[寄]` (lodging) marker alongside the palace's own rotated star.
  22. **Pure Bash, no external tools.** The entire engine runs in Bash 3.2+ with no calls to Python, bc, awk, or any other external program. All arithmetic uses Bash integer math. Calendar calculations (Gregorian to Julian Day Number, Ganzhi cycle indexing) are implemented from scratch in shell arithmetic. This makes the tool portable to any system with a POSIX-compatible Bash, including stock macOS.
  23. **Script and data fully separated.** Every domain constant lives in `tools/data/*.dat` files, using a simple `key=value` format. The scripts contain zero hardcoded domain knowledge. You could, in theory, swap the data files to model a different Qi Men variant without touching a line of code.
  24. ## Architecture
  25. The engine is split into library files, CLI entry points, and a data directory.
  26. ```
  27. skill_qmenpowers/
  28. ├── skills/
  29. │ ├── qmen_dunjia/
  30. │ │ └── SKILL.md # Router skill: time-type triage + plate setting + sub-skill dispatch
  31. │ ├── qmen_event/
  32. │ │ └── SKILL.md # AI interpretation skill
  33. │ ├── qmen_caiguan/
  34. │ │ └── SKILL.md # Wealth & career diagnosis skill
  35. │ ├── qmen_huaqizhen/
  36. │ │ └── SKILL.md # Huaqizhen array placement skill
  37. │ ├── qmen_yishenhuanjiang/
  38. │ │ └── SKILL.md # Yishenhuanjiang (transformation resolution) skill
  39. │ ├── qmen_hunlian/
  40. │ │ └── SKILL.md # Hunlian (marriage/romance) analysis skill
  41. │ ├── qmen_wanwu/
  42. │ │ └── SKILL.md # Wanwu imagery portrait skill
  43. │ ├── qmen_xingge/
  44. │ │ └── SKILL.md # Personality analysis skill
  45. │ ├── qmen_xunshijieyun/
  46. │ │ └── SKILL.md # Xunshijieyun (寻时借运) skill
  47. │ ├── qmen_zhanduan/
  48. │ │ └── SKILL.md # Zhanduan (古籍占断) divination judgment skill
  49. │ └── qmen_yaoce/
  50. │ └── SKILL.md # Yaoce (cross-plate array-breaking) analysis skill
  51. ├── tools/
  52. │ ├── bin/
  53. │ │ ├── qimen_qiju.sh # Plate setting CLI
  54. │ │ ├── qimen_event.sh # Event analysis CLI
  55. │ │ ├── qimen_caiguan.sh # Caiguan (wealth/career) diagnosis CLI
  56. │ │ ├── qimen_huaqizhen.sh # Huaqizhen (array placement) CLI
  57. │ │ ├── qimen_yishenhuanjiang.sh # Yishenhuanjiang (transformation resolution) CLI
  58. │ │ ├── qimen_zhentaiyangshi.sh # True solar time calculator
  59. │ │ ├── qimen_hunlian.sh # Hunlian (marriage/romance) analysis CLI
  60. │ │ ├── qimen_wanwu.sh # Wanwu imagery extraction CLI
  61. │ │ ├── qimen_xingge.sh # Personality analysis CLI
  62. │ │ ├── qimen_xunshijieyun.sh # Xunshijieyun (寻时借运) CLI
  63. │ │ ├── qimen_show.sh # Plate JSON viewer (read & display)
  64. │ │ ├── qimen_luming.sh # Six-relation (六亲) destiny analysis
  65. │ │ ├── qimen_zhanduan.sh # Zhanduan (古籍占断) divination CLI
  66. │ │ └── qimen_yaoce.sh # Yaoce (cross-plate array-breaking) CLI
  67. │ ├── lib/
  68. │ │ ├── data_loader.sh # Generic data file loader
  69. │ │ ├── qimen_engine.sh # Core computation engine
  70. │ │ ├── qimen_output.sh # Output formatting (text + JSON)
  71. │ │ ├── qimen_json.sh # Shared JSON parsing and utility library
  72. │ │ ├── qimen_event.sh # Event analysis library
  73. │ │ ├── qimen_banmenhuaqizhen.sh # Core huaqizhen library
  74. │ │ ├── qimen_yishenhuanjiang.sh # Yishenhuanjiang (transformation resolution) library
  75. │ │ ├── qimen_caiguan.sh # Caiguan analysis library
  76. │ │ ├── qimen_hunlian.sh # Hunlian (marriage/romance) analysis library
  77. │ │ ├── qimen_xingge.sh # Personality analysis library
  78. │ │ ├── qimen_zhanduan.sh # Zhanduan (古籍占断) DSL evaluator library
  79. │ │ └── qimen_yaoce.sh # Yaoce (cross-plate array-breaking) library
  80. │ └── data/
  81. │ ├── tiangan_dizhi.dat # Engine: stems & branches
  82. │ ├── jieqi_table.dat # Engine: solar term timestamps
  83. │ ├── meta_jieqi.dat # Engine: solar term metadata
  84. │ ├── ju_map.dat # Engine: ju number mapping
  85. │ ├── nine_stars.dat # Engine: nine stars basics
  86. │ ├── eight_gates.dat # Engine: eight gates basics
  87. │ ├── eight_deities.dat # Engine: eight deities ordering
  88. │ ├── sanqi_liuyi.dat # Engine: three wonders & six yi
  89. │ ├── luoshu.dat # Engine: luoshu traversal order
  90. │ ├── meta_palace.dat # Engine: palace metadata
  91. │ ├── twelve_states.dat # Engine: twelve growth stages
  92. │ ├── wanwu_bagua.dat # Reference: eight trigrams correspondences
  93. │ ├── wanwu_tiangan.dat # Reference: heavenly stems correspondences
  94. │ ├── wanwu_dizhi.dat # Reference: earthly branches correspondences
  95. │ ├── wanwu_wuxing.dat # Reference: five phases correspondences
  96. │ ├── wanwu_nine_stars.dat # Reference: nine stars correspondences
  97. │ ├── wanwu_eight_gates.dat # Reference: eight gates correspondences
  98. │ ├── wanwu_eight_deities.dat # Reference: eight deities correspondences
  99. │ ├── engine_patterns.dat # Engine: 81 named pair pattern names (天干加地干_名称) — source of truth for engine
  100. │ ├── wanwu_geju.dat # Reference: pattern definitions & diagnostics
  101. │ ├── rules_yongshen.dat # Analysis: yongshen selection rules
  102. │ ├── wanwu_prefix_map.dat # Analysis: symbol-to-prefix mapping
  103. │ ├── meta_huaqizhen.dat # Huaqi: stem relationships, liuhai rules, yaohai definitions
  104. │ ├── hangye_quxiang.dat # Huaqi: industry-to-symbol mapping
  105. │ ├── rules_buzhen.dat # Buzhen: prohibition, suppression, miexiang rules
  106. │ ├── rules_yishenhuanjiang.dat # Yishenhuanjiang: transformation resolution rules, wuxing mappings, jinji, yindong
  107. │ ├── buzhen_xiangshu.dat # Buzhen: stem/branch imagery (colors, materials, animals)
  108. │ ├── rules_hunlian.dat # Hunlian: gan-he combinations, muyu positions, guchen/guasu groups, taohua deity/sanqi rules
  109. │ ├── rules_zhanduan.dat # Zhanduan: ancient divination judgment rules (DSL format)
  110. │ ├── rules_luming.dat # Luming: eight-gate/eight-deity verdicts, pozhi, pattern judgments
  111. │ ├── yigua_64.dat # Yigua: 64 hexagram names, palace→trigram, door→trigram
  112. │ └── wanwu_huaqizhen.dat # Huaqi: personality analysis correspondences
  113. ├── install.sh # Installation script
  114. ├── README.md
  115. └── README_zh.md
  116. ```
  117. **`tools/lib/data_loader.sh`** is a generic key=value file parser. It reads `.dat` files into shell variables and arrays. Comma-separated values become indexed arrays. Keys with CJK characters are stored via an internal key-value store (`dl_get`/`dl_set`) for Bash 3 compatibility, since older Bash lacks associative arrays with non-ASCII keys.
  118. **`tools/lib/qimen_engine.sh`** contains all computation logic: calendar math (Gregorian/JDN conversion, Ganzhi cycle calculation), solar term lookup, Yuan/Ju determination with intercalary handling, and the full plate-laying pipeline (earth plate, heaven plate rotation, gate rotation, deity placement, pattern detection).
  119. **`tools/lib/qimen_output.sh`** reads the global arrays populated by the engine and formats them for display. It supports two modes: human-readable text (palace-by-palace listing with a header block) and structured JSON.
  120. **`tools/lib/qimen_json.sh`** provides shared JSON parsing and utility functions: plate JSON parsing into the dl key-value store, day/hour stem palace location, stem extraction, and wanwu correspondence lookup. Used by all analysis CLI scripts.
  121. **`tools/lib/qimen_event.sh`** provides the event-specific analysis pipeline: yongshen (use god) selection by question type, yongshen palace marking, 81-combination lookups, pattern marker collection, and structured text/JSON output formatting. Used exclusively by `tools/bin/qimen_event.sh`.
  122. **`tools/bin/qimen_qiju.sh`** is the plate-setting CLI wrapper. It parses options, sources the library files, calls the engine, and dispatches to the appropriate output formatter.
  123. **`tools/bin/qimen_event.sh`** is the event analysis CLI. It reads a plate JSON produced by `qimen_qiju.sh`, runs the analysis pipeline, and outputs a structured analysis JSON. Used exclusively for event plates (问事局).
  124. **`tools/lib/qimen_banmenhuaqizhen.sh`** provides the core huaqizhen library: common helpers, palace finders, six-harm (六害) detection per palace with opposite-palace influence (玄武/庚/白虎 affect both host and opposite palace), monthly decree (月令) wuxing relationship computation with Chinese meaning labels (扩张/稳健/努力/损耗/大亏), controlled-wealth (干财) stem tracing with five-combination (天干五合) fallback and special missing-甲-find-zhifu rule (缺甲找值符), symbol location utilities, palace summary generation, yuegling relations, and the full buzhen (布阵) pipeline: protected stem identification (day/hour, birth year, family, yixiang concept stems, zhifu/zhishi), eight-palace six-harm scanning, miexiang (灭象) list generation with safe relocation targets, buzhen plan per palace (suppress jixing via combination, suppress rumu via clash, suppress menpo via combination, suppress geng/baihu via yi-stem, fill kongwang), jinji (禁忌) conflict detection, and physical object imagery mapping.
  125. **`tools/lib/qimen_yishenhuanjiang.sh`** provides the yishenhuanjiang (移神换将) transformation resolution library: detects six-harm problems across all palaces (jixing, rumu, menpo, kongwang, geng, baihu), computes transformation paths per problem type (灭象/暗合/地支合/泄化/冲墓/合出/补象/用乙), resolves physical object imagery via runtime wanwu data lookup, and outputs structured text/JSON with per-problem resolution paths, jinji (禁忌) warnings, and yindong (引动) activation methods. Uses `_yh_` prefix for all helper functions.
  126. **`tools/lib/qimen_caiguan.sh`** provides the caiguan-specific analysis pipeline: seven-hazard (七要害) yaohai analysis for both wealth and career dimensions with monthly decree Chinese meaning labels, gan_cai analysis with special missing-甲-find-zhifu rule (缺甲找值符宫干 instead of 己), industry symbol (hangye) lookup, fushi analysis, tiangan roles analysis, JSON output formatting, and the caiguan pipeline entry point.
  127. **`tools/lib/qimen_hunlian.sh`** provides the hunlian (marriage/romance) analysis pipeline: birth day stem palace location, gan-he (stem combination) partner, liuhe (six harmony), muyu (bathing position), sanqi (three wonders) proximity checks, taohua (peach blossom) detection across multiple indicators (xuanwu, taiyin, ren/gui, sanqi co-location), fuyin/fanyin palace scanning, kongwang impact on partner positions, gen/kun palace six-harm inspection, guchen/guasu (lonely star) computation with jiehua remedies, and special position tracking (tianpeng, shangmen, ding, gui).
  128. **`tools/lib/qimen_xingge.sh`** provides the personality analysis pipeline: birth day stem (inner personality) and hour stem (outer personality) palace location, personality correspondence extraction from huaqizhen-specific wanwu data (stem, star, gate, deity personality traits per palace), wuxing color mapping, and structured text/JSON output.
  129. **`tools/lib/qimen_yaoce.sh`** provides the yaoce (remote sensing) cross-plate analysis library: uses `qj_parse_plate_json` to parse both birth and event plate JSONs, extracts five stem types from the birth plate (day stem, hour stem, birth year stem, zhifu palace heaven stem, zhishi palace heaven stem), locates each on the event plate (heaven plate priority, earth plate fallback), collects palace environment info (stem/star/gate/deity/state/markers), detects six-harm (六害) per palace, extracts wanwu correspondences, and outputs structured text/JSON with per-stem analysis results. Supports optional yixiang (意象) concept stems passed via CLI. Self-contained helper functions (`_yc_` prefix) for stem wuxing, star jixi, and gate jixi lookups with no dependency on qimen_caiguan.sh.
  130. **`tools/lib/qimen_zhanduan.sh`** provides the ancient divination judgment (占断) DSL evaluator library. It reads `rules_zhanduan.dat` containing per-topic role definitions and judgment rules in a custom DSL. The evaluator parses condition expressions (wuxing relationships: `>` sheng, `<` ke, `=` equal, `!` overcome-by, `^` counter-ke; state queries (`?` prefix = unary "is role in this state?", applied to a single role): `?旺` `?囚` `?奇` `?吉门` `?凶门` `?吉格` `?凶格` `?空` `?墓` `?返` `?伏` `?内` `?外`; special: `庚格:年/月/日/时`), resolves role stems to palace positions on the event plate, evaluates all rules collecting matched conclusions, and outputs structured text/JSON. All-match semantics (not first-match). Uses `_zd_` prefix for all helper functions.
  131. **`tools/bin/qimen_caiguan.sh`** is the caiguan diagnosis CLI. It reads the birth plate (`./qmen_birth.json`) only. It auto-reads `./qmen_birth.json` for birth year stem, then outputs a structured caiguan analysis JSON with wealth and career hazard diagnostics.
  132. **`tools/bin/qimen_huaqizhen.sh`** is the huaqizhen buzhen CLI. It defaults to birth plate (`./qmen_birth.json`); use `--input` to specify an event plate for event-based analysis. It auto-reads `./qmen_birth.json` for birth year stem, takes optional family stems and yixiang concept stems, and outputs a structured buzhen JSON with miexiang list and per-palace placement plans.
  133. **`tools/bin/qimen_yishenhuanjiang.sh`** is the yishenhuanjiang (transformation resolution) CLI. It reads the birth plate (`./qmen_birth.json`) and outputs transformation resolution paths for all detected six-harm problems (击刑, 干墓, 门迫, 空亡, 庚, 白虎). For 击刑/干墓/庚, miexiang (灭象) is always the first path. Each problem includes multiple resolution methods with physical object imagery mapped from wanwu data. Problems in the same palace are grouped under a single palace header. Output includes jinji warnings and yindong activation methods. Writes to `./qmen_yishenhuanjiang.json`.
  134. **`tools/bin/qimen_hunlian.sh`** is the hunlian (marriage/romance) analysis CLI. It reads the birth plate (`./qmen_birth.json`) only. It auto-reads `./qmen_birth.json` for birth day stem, then outputs a structured hunlian analysis JSON with partner detection, taohua indicators, guchen/guasu assessment, and palace-level relationship diagnostics.
  135. **`tools/bin/qimen_xingge.sh`** is the personality analysis CLI. It reads the birth plate (`./qmen_birth.json`) only. It reads the birth day stem and hour stem, locates them on the plate, extracts personality trait correspondences from the star, gate, and deity at each stem's palace, and outputs structured personality analysis JSON.
  136. **`tools/bin/qimen_xunshijieyun.sh`** is the xunshijieyun (寻时借运) CLI. It reads a plate JSON (default `./qmen_birth.json`), generates 60 variant plates by cycling the time pillar through all 60 甲子 while keeping the 局数 fixed, ranks them by total 六害 count on protected stems, and outputs sortable JSON files to `./60ke/`. Protected stems include day stem, hour stem, birth year stem, optional yixiang concept stems, and per-course zhifu/zhishi palace stems.
  137. **`tools/bin/qimen_show.sh`** is a plate JSON viewer. It reads any plate JSON file and displays the full text-format plate (identical to `qimen_qiju.sh` output). Optionally copies the JSON to a specified output path via `--output=PATH`. Used by xunshijieyun to display selected courses from `./60ke/`.
  138. **`tools/bin/qimen_luming.sh`** is the six-relation (六亲禄命) analysis CLI. It reads the birth plate (`./qmen_birth.json`), determines the reference stem (year stem by default, day stem optional via `--reference=day`), locates the benming palace (本命宫), assigns six relations (父母/兄弟/子孙/官禄/妻财/疾厄) to each palace based on wuxing relationships, and outputs verdict texts from `rules_luming.dat`. Writes to `./qmen_luming.json`.
  139. **`tools/bin/qimen_zhanduan.sh`** is the zhanduan (古籍占断) divination CLI. It reads an event plate JSON (`./qmen_event.json`) and optionally `./qmen_birth.json` for the birth year stem. Given a topic via `--topic=X`, it applies judgment rules from `rules_zhanduan.dat` and outputs structured text/JSON with all matched conclusions. Without `--topic`, it displays help and the full topic list. Writes to `./qmen_zhanduan.json`.
  140. **`tools/bin/qimen_wanwu.sh`** is the wanwu imagery extraction CLI. It supports two modes: palace mode (`--palace=N`) extracts all wanwu correspondences for a given palace from a plate JSON, and manual mode (`--stem/--star/--gate/--deity/--state`) accepts any combination of symbols directly. Each symbol is optional; at least one is required. Outputs structured text and JSON with full wanwu correspondences per symbol.
  141. **`tools/bin/qimen_yaoce.sh`** is the yaoce (remote sensing) cross-plate analysis CLI. It reads both the birth plate (`./qmen_birth.json`) and event plate (`./qmen_event.json`), extracts five stem types from the birth plate (day stem, hour stem, birth year stem, zhifu palace heaven stem, zhishi palace heaven stem), locates each on the event plate, detects six-harm and collects wanwu correspondences per palace, and outputs structured cross-plate analysis JSON to `./qmen_yaoce.json`. Supports `--yixiang=CONCEPT` to add an optional yixiang concept stem (e.g. `--yixiang=财富` maps to 戊; direct stem characters like `--yixiang=甲` are also accepted).
  142. ## Data Files
  143. Data files fall into two categories: **engine data** (11 files consumed by the computation pipeline) and **reference data** (8 `wanwu_*` files providing comprehensive correspondence tables for interpretation). All live under `tools/data/`, use `key=value` format with `#` comments.
  144. ### Engine Data
  145. | File | Contents |
  146. |------|----------|
  147. | `tiangan_dizhi.dat` | Heavenly Stems (天干) and Earthly Branches (地支): the 10+12 cyclical characters forming the sexagenary system |
  148. | `jieqi_table.dat` | Solar term timestamps from 1899 to 2100, stored as Unix-epoch seconds for each of the 24 Jieqi per year |
  149. | `meta_jieqi.dat` | Solar term metadata: Jie (节) vs. Qi (气) classification, Yin/Yang Dun assignment, Yuan cycle info |
  150. | `ju_map.dat` | Ju number mapping: for each solar term and Yuan (upper/middle/lower), the Ju number (1–9) |
  151. | `nine_stars.dat` | Nine Stars (九星): name, wuxing, auspiciousness, default palace |
  152. | `eight_gates.dat` | Eight Gates (八门): name, wuxing, auspiciousness, default palace |
  153. | `eight_deities.dat` | Eight Deities (八神): Yang-sequence and Yin-sequence ordering |
  154. | `sanqi_liuyi.dat` | Three Wonders and Six Yi (三奇六仪): the nine instruments and their stem assignments |
  155. | `luoshu.dat` | Luoshu magic square (洛书) palace traversal order |
  156. | `meta_palace.dat` | Palace metadata: name, wuxing, direction, Earthly Branches, tail numbers, Xiantian/Houtian numbers |
  157. | `twelve_states.dat` | Twelve Growth Stages (十二长生): lifecycle states used in palace vitality assessment |
  158. | `engine_patterns.dat` | 81 named pair patterns (`天干加地干_名称=name`). Engine-only source of truth for pattern detection. wanwu_geju.dat keeps `_含义/_吉凶` interpretation data; both files must stay in sync. |
  159. ### Reference Data (万物类象)
  160. Comprehensive correspondence tables for Qi Men interpretation. These files are not consumed by the engine but serve as a structured knowledge base for reading and analysis.
  161. | File | Contents |
  162. |------|----------|
  163. | `wanwu_bagua.dat` | Eight Trigrams (八卦): imagery, body, family, animal, direction, season, organ, emotion, and more per trigram |
  164. | `wanwu_tiangan.dat` | Heavenly Stems (天干): wuxing, color, direction, body part, personality, season, number per stem |
  165. | `wanwu_dizhi.dat` | Earthly Branches (地支): wuxing, direction, season, body, personality per branch; plus San-He, Liu-He, Liu-Chong, and punishment relationship tables |
  166. | `wanwu_wuxing.dat` | Five Phases (五行): direction, season, organ, taste, color, emotion, number, sheng-ke cycles; includes Hetu numbers and seasonal vitality states |
  167. | `wanwu_nine_stars.dat` | Nine Stars (九星): wuxing, auspiciousness, color, body/disease, personality, weather, objects, places, career, divination suitability per star |
  168. | `wanwu_eight_gates.dat` | Eight Gates (八门): wuxing, auspiciousness, color, body/disease, personality, places, career, divination suitability; three-auspicious / three-inauspicious classification |
  169. | `wanwu_eight_deities.dat` | Eight Deities (八神): wuxing, imagery, personality, body, events, objects per deity; Yang/Yin sequence notes |
  170. | `wanwu_geju.dat` | Pattern Definitions (格局大全): Geng patterns, all 81 stem-on-stem combinations, auspicious/inauspicious pattern catalog, Men-Po conditions, Fan-Yin/Fu-Yin tables, tomb tables, Liu-Yi Ji-Xing, Kong-Wang, Yi-Ma rules. Note: pattern names duplicated to `engine_patterns.dat` (engine source); this file is reference-only for 含义/吉凶. |
  171. ### Analysis Data
  172. | File | Contents |
  173. |------|----------|
  174. | `rules_yongshen.dat` | Yongshen (use god) selection rules: 9 question types, each with prioritized star/gate/deity/stem selections |
  175. | `wanwu_prefix_map.dat` | Symbol name to wanwu file prefix mapping: maps Chinese names to data file key prefixes |
  176. | `rules_yishenhuanjiang.dat` | Yishenhuanjiang: per-problem-type resolution paths, wuxing sheng/xie/ke mappings, mu (tomb) branches, chong/he pairs, jinji prohibitions, yindong activation methods, override examples |
  177. | `rules_zhanduan.dat` | Zhanduan (古籍占断): per-topic divination rules in custom DSL format; role definitions (stem assignments), condition expressions (wuxing relationships + state queries), conclusions as original ancient text |
  178. | `rules_luming.dat` | Luming (禄命): eight-gate destiny verdicts per liuqin, eight-deity personality/destiny, deity palace preferences, ten-stem suppression rules, pattern auspiciousness judgments |
  179. | `yigua_64.dat` | Yigua (演卦): 64 hexagram name lookup (upper+lower trigram → name), palace-to-trigram mapping, door-to-trigram mapping |
  180. ### Huaqi Data
  181. | File | Contents |
  182. |------|----------|
  183. | `meta_huaqizhen.dat` | Tiangan five-combinations (天干五合), stem-conquers (天干所克) tables, wuxing relationships, dizhi wuxing, six-harm marker definitions, wealth seven-hazard and career seven-hazard element definitions, yixiang concept-to-stem mappings (财富→戊, 暴力→庚, etc.), opposite-palace (对宫) mappings |
  184. | `hangye_quxiang.dat` | Industry-to-symbol mapping: maps job names to their corresponding Qi Men symbols (gates, stars, deities, stems) |
  185. | `wanwu_huaqizhen.dat` | Huaqi-specific correspondences: ten stems (personality + imagery), eight gates (personality + imagery), nine stars (personality + industry + imagery), eight deities (personality + imagery) traits for character analysis; wuxing colors; palace name/wuxing mapping |
  186. ### Buzhen Data
  187. | File | Contents |
  188. |------|----------|
  189. | `rules_buzhen.dat` | Prohibition rules (jinji): which stems cannot be placed in which palaces (sanqi-rumu, liuyi-jixing); suppression methods (jixing→combination, rumu→clash, menpo→combination, geng/baihu→yi-stem, kongwang→fill); miexiang methods; safe palace definitions; protect priority |
  190. | `rules_yishenhuanjiang.dat` | Yishenhuanjiang: per-problem-type resolution paths, wuxing sheng/xie/ke mappings, mu (tomb) branches, chong/he pairs, jinji prohibitions, yindong activation methods, override examples |
  191. | `buzhen_xiangshu.dat` | Physical imagery for array placement: each heavenly stem mapped to colors and materials; each earthly branch mapped to zodiac animals and substitute objects; position rules for object placement |
  192. ### Hunlian Data
  193. | File | Contents |
  194. |------|----------|
  195. | `rules_hunlian.dat` | Hunlian: gan-he combinations, muyu positions, guchen/guasu groups, taohua deity/sanqi rules |
  196. ## Computation Pipeline
  197. The engine function `qm_compute_plate` executes the following steps in order:
  198. 1. **Four Pillars (四柱干支).** Compute the year, month, day, and hour pillars. Each pillar is a Tiangan-Dizhi pair drawn from the sexagenary cycle, derived from calendar math.
  199. 2. **Ju Determination (局数).** Identify the current solar term, then determine which Yuan (上元/中元/下元, upper/middle/lower) the current day falls within. Look up the Ju number from the mapping table. If the date falls in an intercalary gap (between the Jie boundary and the next Yuan start), apply Zhi-Run: carry forward the previous Ju number.
  200. 3. **Earth Plate (地盘).** Lay the nine instruments (三奇六仪) onto the nine palaces according to the Ju number and Yin/Yang Dun (阴遁/阳遁) direction.
  201. 4. **Zhifu and Zhishi (值符值使).** Identify the duty star (Zhifu, 值符) and duty gate (Zhishi, 值使) from the hour pillar's position on the earth plate.
  202. 5. **Heaven Plate Rotation (天盘).** Rotate the nine stars from their default palaces by an offset derived from the hour pillar, placing each star into its new palace position.
  203. 6. **Human Plate Rotation (人盘).** Rotate the eight gates using the Earthly Branch step method, shifting gates from their default palaces based on the hour branch offset.
  204. 7. **Deity Plate (神盘).** Place the eight deities starting from the Zhifu star's palace, following the Yang or Yin sequence depending on Dun direction.
  205. 8. **Twelve Growth Stages (十二长生).** Compute the lifecycle state (birth, growth, peak, decline, grave, etc.) for each palace based on the day stem's wuxing.
  206. 9. **Liuyi Jixing (六仪击刑).** Check whether any of the six Yi instruments land in a palace that carries a punishment (刑) relationship with their associated Earthly Branch.
  207. 10. **Kongwang (空亡).** Determine the two void/empty Branches from the hour pillar's position within its sexagenary decade, then map those Branches to palaces.
  208. 11. **Yima (驿马).** Derive the courier horse Branch from the hour Branch using the traditional formula, then map it to a palace.
  209. 12. **Pattern Markers (格局).** Scan each palace for significant configurations:
  210. | Marker | Chinese | Meaning |
  211. |--------|---------|---------|
  212. | `[庚]` | 天盘庚 | Geng on the heaven plate (inauspicious metal energy) |
  213. | `[干墓]` | 干入墓 | Heaven stem enters its grave palace |
  214. | `[星墓]` | 星入墓 | Star enters its grave palace |
  215. | `[门墓]` | 门入墓 | Gate enters its grave palace |
  216. | `[门迫]` | 门迫 | Gate oppresses palace (gate's wuxing overcomes palace's wuxing) |
  217. | `[星反吟]` | 星反吟 | Star sits in the palace opposite its home (reversal) |
  218. | `[门反吟]` | 门反吟 | Gate sits in the palace opposite its home (reversal) |
  219. | `[星伏吟]` | 星伏吟 | Star sits in its own home palace (stagnation) |
  220. | `[门伏吟]` | 门伏吟 | Gate sits in its own home palace (stagnation) |
  221. | `[击刑]` | 六仪击刑 | Six-instrument punishment |
  222. | `[空亡]` | 空亡 | Void/empty |
  223. | `[驿马]` | 驿马 | Courier horse (mobility indicator) |
  224. | `[迫制]` | 十干迫制 | Heaven stem's wuxing overcomes earth stem's wuxing (suppression) |
  225. | `全盘伏吟` | (composite) | All 8 stars in their home palaces — total stagnation |
  226. | `全盘反吟` | (composite) | All 8 stars in their opposite palaces — total reversal |
  227. | `乙奇升殿` | 乙在巽4 | Yi-stem in Xun-4 palace (auspicious) |
  228. | `丙奇升殿` | 丙在离9 | Bing-stem in Li-9 palace (auspicious) |
  229. | `丁奇升殿` | 丁在兑7 | Ding-stem in Dui-7 palace (auspicious) |
  230. **演卦 (Yigua)** convention: 值符宫 → 内卦 (lower trigram), 值使宫 → 外卦 (upper trigram). Sourced from kentang/kinqimen tradition. Per-palace 门方演卦 also emitted (door bagua → upper, palace bagua → lower).
  231. ## Output
  232. Two output modes are available.
  233. **Text mode** (default) prints a header block followed by a palace-by-palace listing:
  234. ```
  235. 奇门遁甲起局
  236. 时间: 1973-04-24 19:30
  237. 四柱: 癸丑 丙辰 庚寅 丙戌
  238. 局 : 阳遁8局 (下元)
  239. 值符: 天蓬
  240. 值使: 休门
  241. 空亡: 午(9宫) 未(2宫)
  242. 驿马: 申(2宫)
  243. 天马: 午(9宫)
  244. 丁马: 亥(6宫)
  245. 旺衰: 木旺,火相,水休,金囚,土死
  246. 演卦: 雷天大壮(外震内乾)
  247. 格局: 值符飞宫(坎1宫)
  248. 格局: 青龙逃走(坤2宫)
  249. [ 巽4宫|东南|木 ]
  250. 地支: 辰巳
  251. 天盘: 己(土)
  252. 地盘: 癸(水)
  253. 神 : 白虎
  254. 星 : 天英(凶)
  255. 门 : 生门(吉)
  256. 状态: 衰
  257. 格局: [干墓] [门墓]
  258. 先天数: 5 后天数: 4 尾数: 3,8
  259. [ 震3宫|东|木 ]
  260. 地支: 卯
  261. 天盘: 癸(水)
  262. 地盘: 壬(水)
  263. 神 : 六合
  264. 星 : 天辅(吉)
  265. 门 : 休门(吉)
  266. 状态: 长生
  267. 先天数: 4 后天数: 3 尾数: 3,8
  268. [ 艮8宫|东北|土 ]
  269. 地支: 丑寅
  270. 天盘: 壬(水)
  271. 地盘: 戊(土)
  272. 神 : 太阴
  273. 星 : 天冲(吉)
  274. 门 : 开门(吉)
  275. 状态: 衰
  276. 格局: [门墓]
  277. 先天数: 7 后天数: 8 尾数: 5,0
  278. ```
  279. **JSON mode** is always-on: every run writes a structured JSON file (based on `--type`) containing all header fields and an array of palace objects, each with every computed field. The text output is displayed on the terminal simultaneously.
  280. Each plate JSON includes a top-level `schema_version: 2` field. Increment this when adding/removing top-level fields to enable downstream version detection.
  281. **special_patterns** are emitted as `[{"name": "XX", "palaces": [N]}]` objects (not strings), allowing future cross-palace patterns to use multi-palace arrays.
  282. ## Analysis Script
  283. The event analysis script `qimen_event.sh` reads a plate JSON (produced by `qimen_qiju.sh`), enriches it with wanwu correspondence data, marks yongshen (use god) palaces based on the question type, and outputs a structured analysis JSON.
  284. ### Pipeline
  285. ```bash
  286. # Step 1: Generate birth plate
  287. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  288. # Creates ./qmen_birth.json
  289. # Step 2: Generate event plate
  290. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  291. # Creates ./qmen_event.json
  292. # Step 3: Run analysis
  293. tools/bin/qimen_event.sh --question=事业
  294. # Reads ./qmen_event.json, writes ./qmen_event_analysis.json
  295. ```
  296. ### Question Types
  297. | Type | Meaning | Primary Yongshen |
  298. |------|---------|-----------------|
  299. | 事业 | Career / official prospects | 开门 (Open Gate), 天心 (Tianxin Star) |
  300. | 求财 | Wealth / financial matters | 生门 (Life Gate), 六合 (Liuhe Deity) |
  301. | 婚姻感情 | Marriage / relationships | 六合 (Liuhe), 景门 (View Gate), 乙 (Yi Stem) |
  302. | 疾病健康 | Health / illness | 天内 (Tiannei Star), 死门 (Death Gate) |
  303. | 出行 | Travel / movement | 开门 (Open Gate), 九天 (Jiutian Deity) |
  304. | 官司诉讼 | Lawsuits / legal disputes | 伤门 (Harm Gate), 天英 (Tianying Star) |
  305. | 寻人寻物 | Finding people / lost items | 六合 (Liuhe), 杜门 (Block Gate) |
  306. | 天气 | Weather | 景门 (View Gate), 天英 (Tianying Star) |
  307. | 家宅风水 | Home / feng shui | 生门 (Life Gate), 天任 (Tianren Star) |
  308. ### Analysis Output
  309. The analysis JSON includes:
  310. - Day stem and hour stem palace positions
  311. - Yongshen (use god) markings with palace locations
  312. - Wanwu correspondences for each palace (star, gate, deity, stems)
  313. - 81-combination lookups for key palaces
  314. - Pattern markers (kongwang, yima, geng, rumu, menpo, fanyin, fuyin, jixing)
  315. ### CLI Reference
  316. ```
  317. Usage: qimen_event.sh [OPTIONS]
  318. Options:
  319. --input=PATH Input plate JSON (default: ./qmen_event.json)
  320. --question=TYPE Question type (required)
  321. --verbose Full wanwu extraction (default: concise)
  322. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  323. -h, --help Show this help
  324. ```
  325. ## Caiguan Script (财官诊断)
  326. The caiguan script `qimen_caiguan.sh` reads the birth plate (`./qmen_birth.json`) only. It performs wealth/career deep analysis. It locates seven hazard elements (七要害) for both wealth and career dimensions, detects six-harm (六害: punishment, tomb, Geng, White Tiger, gate oppression, void) at each palace, computes monthly decree wuxing relationships with Chinese meaning labels (扩张/稳健/努力/损耗/大亏), traces controlled-wealth stems (干财) with five-combination fallback (missing 甲 uses zhifu palace stem instead of 己), and auto-derives industry symbols from the plate. The birth year stem is auto-read from `./qmen_birth.json`.
  327. ### Pipeline
  328. ```bash
  329. # Default usage (birth plate analysis)
  330. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  331. # Creates ./qmen_birth.json
  332. tools/bin/qimen_caiguan.sh
  333. # Reads ./qmen_birth.json by default
  334. ```
  335. ### CLI Reference
  336. ```
  337. Usage: qimen_caiguan.sh [OPTIONS]
  338. Options:
  339. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  340. -h, --help Show this help
  341. Requires: ./qmen_birth.json (for birth year stem)
  342. ```
  343. ## Buzhen Script (布阵)
  344. The buzhen script `qimen_huaqizhen.sh` defaults to birth plate (`./qmen_birth.json`); use `--input` to specify an event plate for event-based analysis. It reads a huaqi analysis JSON and generates array placement plans. It identifies protected stems (day/hour stem, birth year stem, family stems, yixiang concept stems, zhifu/zhishi stems), scans all eight palaces for six-harm threats against protected stems (including opposite-palace influence from 玄武/庚/白虎), generates miexiang (灭象) lists with safe relocation targets, and produces per-palace buzhen plans (suppress jixing via combination, suppress rumu via clash, suppress menpo via combination, neutralize geng/baihu via yi-stem, fill kongwang gaps) with physical object imagery mapping. The birth year stem is auto-read from `./qmen_birth.json`.
  345. ### Pipeline
  346. ```bash
  347. # Default usage (birth plate analysis)
  348. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  349. # Creates ./qmen_birth.json
  350. tools/bin/qimen_huaqizhen.sh
  351. # Reads ./qmen_birth.json by default
  352. # With event plate (optional, only when targeting a specific event)
  353. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  354. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  355. tools/bin/qimen_huaqizhen.sh --input=./qmen_event.json
  356. ```
  357. ### CLI Reference
  358. ```
  359. Usage: qimen_huaqizhen.sh [OPTIONS]
  360. Options:
  361. --input=PATH Input plate JSON (default: ./qmen_birth.json)
  362. --family-stems=S1,S2 Family members' birth year stems (optional)
  363. --yixiang=C1,C2 Concepts to protect: 财富,暴力,权威,突破,表现,情欲 (optional)
  364. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  365. -h, --help Show this help
  366. Requires: ./qmen_birth.json (for birth year stem)
  367. ```
  368. ## Yishenhuanjiang Script (移神换将化解)
  369. The yishenhuanjiang script `qimen_yishenhuanjiang.sh` reads the birth plate (`./qmen_birth.json`) and performs transformation-based resolution analysis. Unlike the buzhen script which uses pressure/suppression (灭象+布阵), yishenhuanjiang uses removal (灭象), combination (合), drainage (泄), clash (冲), and supplement (补) to transform harmful energy. It scans all palaces for six-harm problems (击刑, 干墓, 门迫, 空亡, 庚, 白虎), computes per-problem resolution paths with physical object imagery (灭象 as mandatory first path for 击刑/干墓/庚), groups problems by palace, and includes jinji (禁忌) warnings and yindong (引动) activation methods.
  370. ### Pipeline
  371. ```bash
  372. # Default usage (birth plate analysis)
  373. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  374. # Creates ./qmen_birth.json
  375. tools/bin/qimen_yishenhuanjiang.sh
  376. # Reads ./qmen_birth.json, writes ./qmen_yishenhuanjiang.json
  377. ```
  378. ### CLI Reference
  379. ```
  380. Usage: qimen_yishenhuanjiang.sh [OPTIONS]
  381. Options:
  382. --input=PATH Input plate JSON (default: ./qmen_birth.json)
  383. --output=PATH Output JSON path (default: ./qmen_yishenhuanjiang.json)
  384. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  385. -h, --help Show this help
  386. Requires: ./qmen_birth.json (generated by qimen_qiju.sh --type=birth)
  387. ```
  388. ## True Solar Time Calculator (真太阳时)
  389. The `qimen_zhentaiyangshi.sh` utility converts between standard clock time and true solar time. Two modes: **forward** (clock time → true solar time + shichen) and **reverse** (shichen → clock time window). True solar time is required for accurate shichen (时辰) determination in Qi Men practice, especially when the practitioner is far from the standard meridian of their timezone. The tool applies longitude correction (4 minutes per degree of longitude difference) and the Equation of Time (seasonal correction for Earth's elliptical orbit).
  390. `--longitude` and `--timezone` are mutually exclusive: provide one to auto-derive the other. Default: UTC+8 at 120°E.
  391. ### Pipeline
  392. ```bash
  393. # Forward: Beijing (116.4°E, longitude positioning) — clock time → true solar time
  394. tools/bin/qimen_zhentaiyangshi.sh --longitude=116.4 "2026-04-30 14:30"
  395. # Forward: New York (UTC-5, timezone positioning)
  396. tools/bin/qimen_zhentaiyangshi.sh --timezone=-5 "2026-04-30 14:30"
  397. # Reverse: what clock time is 申时 in Urumqi (longitude positioning)?
  398. tools/bin/qimen_zhentaiyangshi.sh --shichen=申时 --longitude=87.6 "2026-04-30"
  399. # Reverse: what clock time is 子时 in New York (timezone positioning)?
  400. tools/bin/qimen_zhentaiyangshi.sh --shichen=子 --timezone=-5 "2026-04-30"
  401. ```
  402. ### CLI Reference
  403. ```
  404. Usage: qimen_zhentaiyangshi.sh [OPTIONS] "YYYY-MM-DD HH:MM"
  405. qimen_zhentaiyangshi.sh --shichen=X [OPTIONS] "YYYY-MM-DD"
  406. Modes:
  407. Forward (default) Clock time → true solar time + shichen
  408. Reverse (--shichen) Shichen + date → clock time window
  409. Options:
  410. --longitude=N Local longitude (east positive, west negative; timezone auto-derived)
  411. --timezone=N Timezone offset (longitude defaults to standard meridian)
  412. Mutually exclusive; omit both for default UTC+8 at 120°E
  413. --shichen=X Reverse query: input shichen, output clock time window
  414. Accepts: 子/丑/寅/卯/辰/巳/午/未/申/酉/戌/亥 (with or without 时)
  415. --output=PATH Output JSON path (default: ./qmen_zhentaiyangshi.json)
  416. -h, --help Show this help
  417. ```
  418. ## Hunlian Script (婚恋分析)
  419. The hunlian script `qimen_hunlian.sh` reads the birth plate (`./qmen_birth.json`) only. It performs marriage/romance analysis. It locates the birth day stem palace, identifies the gan-he (stem combination) partner, checks liuhe (six harmony) and muyu (bathing position), detects taohua (peach blossom) indicators across multiple dimensions (xuanwu, taiyin, ren/gui, sanqi co-location), scans fuyin/fanyin palaces, evaluates kongwang impact on partner positions, inspects gen/kun palace six-harm, computes guchen/guasu (lonely star) with jiehua remedies, and tracks special positions (tianpeng, shangmen, ding, gui). The birth day stem is auto-read from `./qmen_birth.json`.
  420. ### Pipeline
  421. ```bash
  422. # Default usage (birth plate analysis)
  423. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  424. # Creates ./qmen_birth.json
  425. tools/bin/qimen_hunlian.sh
  426. # Reads ./qmen_birth.json by default
  427. ```
  428. ### CLI Reference
  429. ```
  430. Usage: qimen_hunlian.sh [OPTIONS]
  431. Options:
  432. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  433. -h, --help Show this help
  434. Requires: ./qmen_birth.json (for birth day stem)
  435. ```
  436. ## Xingge Script (性格分析)
  437. The xingge script `qimen_xingge.sh` defaults to birth plate (`./qmen_birth.json`). It performs personality analysis. It reads the birth day stem (inner personality) and hour stem (outer personality), locates each on the plate, extracts personality trait correspondences from the star, gate, and deity at each stem's palace using huaqizhen-specific wanwu data, maps wuxing colors, and outputs structured personality analysis JSON.
  438. ### Pipeline
  439. ```bash
  440. # Default usage (birth plate analysis)
  441. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  442. # Creates ./qmen_birth.json
  443. tools/bin/qimen_xingge.sh
  444. # Reads ./qmen_birth.json by default
  445. ```
  446. ### CLI Reference
  447. ```
  448. Usage: qimen_xingge.sh [OPTIONS]
  449. Options:
  450. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  451. -h, --help Show this help
  452. Requires: ./qmen_birth.json (for birth day stem and hour stem)
  453. ```
  454. ## Xunshijieyun Script (寻时借运)
  455. The xunshijieyun script `qimen_xunshijieyun.sh` reads a plate JSON and generates 60 variant plates by cycling through all 60 甲子 time pillars with fixed 局数. It ranks each variant by total 六害 (six harms) on protected stems and outputs sortable JSON files. The first file in `ls 60ke/` is always the optimal course.
  456. ### Pipeline
  457. ```bash
  458. # Default usage (birth plate)
  459. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  460. tools/bin/qimen_xunshijieyun.sh
  461. # Produces 60 JSON files in ./60ke/
  462. # With yixiang concept protection
  463. tools/bin/qimen_xunshijieyun.sh --yixiang=财富
  464. # Custom input and output
  465. tools/bin/qimen_xunshijieyun.sh --input=./qmen_event.json --output-dir=./results/
  466. ```
  467. ### CLI Reference
  468. ```
  469. Usage: qimen_xunshijieyun.sh [OPTIONS]
  470. Options:
  471. --input=PATH Input plate JSON (default: ./qmen_birth.json)
  472. --yixiang=X1,X2 Concept protection (财富,暴力,权威,突破,表现,情欲 or direct stem)
  473. --output-dir=PATH Output directory for 60 JSONs (default: ./60ke/)
  474. -h, --help Show this help
  475. Requires: ./qmen_birth.json (generated by qimen_qiju.sh --type=birth)
  476. ```
  477. ## Show Script (盘面查看)
  478. The show script `qimen_show.sh` reads any plate JSON and displays the full text-format plate (identical to `qimen_qiju.sh` output). Optionally copies the JSON to a specified output path.
  479. ### Pipeline
  480. ```bash
  481. # Display a plate from 60ke
  482. tools/bin/qimen_show.sh ./60ke/001_甲子_liuhai2.json
  483. # Display and copy to a target path
  484. tools/bin/qimen_show.sh ./60ke/001_甲子_liuhai2.json --output=./qmen_selected.json
  485. ```
  486. ### CLI Reference
  487. ```
  488. Usage: qimen_show.sh INPUT [--output=PATH]
  489. Arguments:
  490. INPUT Input plate JSON (required)
  491. Options:
  492. --output=PATH Copy JSON to specified path (optional)
  493. -h, --help Show this help
  494. ```
  495. ## Zhanduan Script (古籍占断)
  496. The zhanduan script `qimen_zhanduan.sh` applies divination judgment rules from "Qi Men Zhi Gui" (《奇门旨归》) volumes 6-13 to an event plate. It reads `rules_zhanduan.dat` which encodes ancient text judgment criteria in a custom DSL, resolves role stems (日干, 时干, 年干, 用神, custom named roles) to their palace positions on the plate, evaluates wuxing relationship and state conditions between roles, and collects all matched conclusions. AI then explains the conclusions in plain language.
  497. ### Pipeline
  498. ```bash
  499. # Generate event plate
  500. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  501. # Run divination judgment
  502. tools/bin/qimen_zhanduan.sh --topic=婚姻
  503. # List all available topics (run without --topic)
  504. tools/bin/qimen_zhanduan.sh
  505. ```
  506. ### CLI Reference
  507. ```
  508. Usage: qimen_zhanduan.sh [OPTIONS]
  509. Options:
  510. --input=PATH Input event plate JSON (default: ./qmen_event.json)
  511. --topic=TOPIC Divination topic (e.g. 婚姻, 官司, 行人归期)
  512. -h, --help Show this help
  513. Without --topic: displays help and full topic list.
  514. Requires: ./qmen_event.json (generated by qimen_qiju.sh --type=event)
  515. Optional: ./qmen_birth.json (auto-reads birth year stem if present)
  516. ```
  517. ## Wanwu Script (万物类象提取)
  518. The wanwu script `qimen_wanwu.sh` extracts full wanwu (万物类象) correspondences for a set of Qi Men symbols. Two input modes: palace mode reads symbols from a plate JSON, manual mode accepts symbols directly. At least one symbol is required in manual mode. Outputs structured text and JSON with all correspondence fields per symbol.
  519. ### Pipeline
  520. ```bash
  521. # Palace mode: extract from birth plate
  522. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  523. tools/bin/qimen_wanwu.sh --palace=3
  524. # Manual mode: specify symbols directly (any combination, at least one)
  525. tools/bin/qimen_wanwu.sh --stem=丙 --star=天冲 --gate=伤门 --deity=九天 --state=帝旺
  526. # Manual mode: single symbol
  527. tools/bin/qimen_wanwu.sh --gate=开门
  528. ```
  529. ### CLI Reference
  530. ```
  531. Usage: qimen_wanwu.sh [OPTIONS]
  532. Palace mode:
  533. --input=PATH Input plate JSON (default: ./qmen_birth.json)
  534. --palace=N Palace number (1-9)
  535. Manual mode:
  536. --stem=X Heavenly stem (e.g. 丙)
  537. --star=X Nine star (e.g. 天冲)
  538. --gate=X Eight gate (e.g. 伤门)
  539. --deity=X Eight deity (e.g. 九天)
  540. --state=X Twelve growth state (e.g. 帝旺)
  541. Common:
  542. --output=PATH Output JSON (default: ./qmen_wanwu.json)
  543. -h, --help Show this help
  544. ```
  545. ## Yaoce Script (遥测 / Array-Breaking)
  546. The yaoce script `qimen_yaoce.sh` performs cross-plate remote sensing, the diagnostic phase of array-breaking (破阵). The event plate represents a "natural array" (天然阵): a time-space configuration that has already formed and is exerting influence on the subject. Yaoce reads this array by placing the subject's protected stems from the birth plate onto the event plate, then assessing what harm the array inflicts on each stem.
  547. It reads both the birth plate (`./qmen_birth.json`) and the event plate (`./qmen_event.json`), extracts five stem types from the birth plate: day stem (日干), hour stem (时干), birth year stem (生年干), zhifu palace heaven stem (值符宫干), and zhishi palace heaven stem (值使宫干). It then locates each on the event plate (heaven plate priority, earth plate fallback). For each stem's landing palace, it collects the full palace environment (heaven/earth stems, star, gate, deity, state, markers), detects six-harm (六害: punishment, tomb, Geng, White Tiger, gate oppression, void), and extracts wanwu correspondences. An optional yixiang (意象) concept stem can be added via `--yixiang`, either as a concept name (e.g. `财富` → maps to 戊) or as a direct stem character (e.g. `甲`). The output feeds into two follow-up actions: miexiang (灭象, urgent removal of harmful symbols) and full re-layout via `qimen_huaqizhen.sh` (布阵, systematic counter-array placement).
  548. ### Pipeline
  549. ```bash
  550. # Step 1: Generate birth plate
  551. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  552. # Creates ./qmen_birth.json
  553. # Step 2: Generate event plate
  554. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  555. # Creates ./qmen_event.json
  556. # Step 3: Run yaoce (cross-plate) analysis
  557. tools/bin/qimen_yaoce.sh
  558. # Reads ./qmen_birth.json + ./qmen_event.json, writes ./qmen_yaoce.json
  559. # Step 3b: With yixiang concept stem (optional, after interactive inquiry)
  560. tools/bin/qimen_yaoce.sh --yixiang=财富
  561. # Adds yixiang stem (戊) to the analysis
  562. ```
  563. ### CLI Reference
  564. ```
  565. Usage: qimen_yaoce.sh [OPTIONS]
  566. Options:
  567. --event=PATH Event plate JSON (default: ./qmen_event.json)
  568. --yixiang=CONCEPT Yixiang concept or stem (e.g. 财富, 暴力, or direct stem 甲)
  569. --wanwu Show wanwu (万物类象) in text output (JSON always includes wanwu)
  570. -h, --help Show this help
  571. Requires: ./qmen_birth.json (for day stem, hour stem, birth year stem, zhifu/zhishi stems)
  572. ./qmen_event.json (event plate to analyze stems against)
  573. ```
  574. `SKILL.md` files in the `skills/` directory define OpenCode AI skills for conversational interpretation.
  575. **`qmen_dunjia`** is the unified router skill. When the user says "Qi Men Dun Jia" without a clear analysis direction, this skill takes over to (1) force a triage between event time vs. birth time, (2) perform the entry blessing ritual, (3) call `qimen_qiju.sh` to generate the appropriate plate JSON, and (4) hand off to the right sub-skill. Sub-skills detect the existing plate JSON and skip their own plate-setting step. The router never performs analysis itself. When user intent is ambiguous after a birth plate is generated, the router presents a 3-choice menu (全局总览 / 财运事业 / 性格分析) rather than silently defaulting to the heaviest skill.
  576. **`qmen_event`** drives event plate reading (问事局): run analysis → narrative reading → follow-up. Maps free-text questions to 9 standard question types. Can only be invoked via `qmen_dunjia` router (which handles ritual and plate generation). Used exclusively for event plates; birth plate analysis uses the huaqizhen skill family (caiguan, hunlian, xingge, huaqizhen).
  577. **`qmen_caiguan`** (财官诊断) drives wealth/career diagnosis: generate birth plate → run caiguan analysis → diagnose seven hazards for wealth and career → "step on one, lift the other" advice. Birth year stem is auto-read from `qmen_birth.json`. Uses birth plate only.
  578. **`qmen_huaqizhen`** (化气阵布阵) drives array placement: generate birth plate (event plate optional, only when targeting a specific event) → generate buzhen → miexiang + physical object recommendations.
  579. **`qmen_yishenhuanjiang`** (移神换将化解) drives transformation-based resolution: generate birth plate → run yishenhuanjiang analysis → AI interprets per-problem resolution paths with physical object recommendations and activation methods. Unlike huaqizhen (pressure/suppression), yishenhuanjiang uses 灭象 (removal), 合 (combination), 泄 (drainage), 冲 (clash), and 补 (supplement) to transform harmful energy rather than suppress it.
  580. **`qmen_hunlian`** (婚恋分析) drives marriage/romance interpretation: generate birth plate → run hunlian analysis → interpret across 5 modules (tuodan, sishou, cui_taohua, zhan_taohua, qingqu) plus 4 common modules. Uses birth plate only.
  581. **`qmen_xingge`** (性格分析) drives personality interpretation: generate birth plate → run personality analysis → AI synthesizes inner (day stem) and outer (hour stem) personality profiles from the combined stem/star/gate/deity traits at each palace.
  582. **`qmen_xunshijieyun`** (寻时借运) drives the 幻化六十课 mechanism — the third resolution method (换局) independent of miexiang and buzhen: generates 60 variant plates → ranks by liuhai on protected stems → presents optimal course(s) → guides user to recreate the favorable time-space layout by arranging physical objects per palace's wanwu correspondences. For event plates, interacts with user to determine yixiang concept stem. For birth plates, runs directly. Handles tie-breaking when multiple courses share the lowest liuhai count.
  583. **`qmen_zhanduan`** (古籍占断) executes divination judgments based on ancient text rules from "Qi Men Zhi Gui" (《奇门旨归》volumes 6-13). The script evaluates DSL-encoded rules against the event plate: resolves role stems (日干/时干/年干/用神/custom) to palace positions, evaluates wuxing relationships and state conditions between roles, and collects all matched conclusions. AI then explains the conclusions in plain language.
  584. **`qmen_luming`** (禄命总览 / Full Life Overview) provides a complete six-relation life reading with 3 perspective modes. It calls `qimen_luming.sh` for deterministic six-relation computation (with correct 六甲遁干 substitution per year branch) plus deity verdicts (神性情 / 神论命 / 神喜忌), then AI interprets across six life domains (parents, siblings, children, career, spouse/wealth, health). Three perspective modes: 奇门大师 (comprehensive), 军师 (strategy-focused), 法术奇门 (ritual-focused). For 问事 (event-divination) intent, the router redirects to `qmen_event` instead (correct plate type).
  585. **`qmen_wanwu`** (万物类象画像) generates creative imagery portraits from Qi Men symbol combinations. Three modes: scene (environment/atmosphere), object (shape/color/material/function), and person (appearance/temperament/behavior). Symbols are flexibly mapped to dimensions (each symbol used once), with twelve growth stages as lowest-priority modifier. Supports iterative refinement (style, domain, era adjustments) within wanwu data bounds.
  586. **`qmen_yaoce`** (遥测 / 破阵) drives cross-plate array-breaking analysis in an 8-step flow. The event plate is treated as a natural array (天然阵) that has already formed and is affecting the subject; yaoce diagnoses this array, measures its harm on the subject's protected stems, then plans counter-measures. Flow: collects birth time and event time → ritual reminder → generates both plates → **diagnoses natural array** (AI reads event plate: six-harm distribution, array pattern, overall assessment) → **locates native** (runs yaoce script: places 5 protected stem types on event plate, namely day stem, hour stem, birth year stem, zhifu palace stem, zhishi palace stem; detects six-harm, extracts wanwu) → **assesses harm** (AI interprets each stem's palace via 6-module framework: day+hour contrast, birth year root, zhifu/zhishi authority, scene reconstruction, yixiang concept, re-layout plan) → interactive inquiry to refine yixiang concept stem (optional re-run with `--yixiang`) → **re-layout** (step 1: miexiang urgent removal of harmful symbols identified during diagnosis; step 2: guides user to `qmen_huaqizhen` for systematic counter-array placement).
  587. ## Usage
  588. ```bash
  589. # Current time
  590. tools/bin/qimen_qiju.sh
  591. # Specific datetime (auto-detected as birth plate)
  592. tools/bin/qimen_qiju.sh "2026-04-18 10:00"
  593. # Birth plate (explicit)
  594. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  595. # Tianqin lodges in Kun 2-palace (traditional, instead of default follow-tiannei)
  596. tools/bin/qimen_qiju.sh --tianqin=jikun "2024-02-04 11:00"
  597. # Tianqin follows Zhifu star
  598. tools/bin/qimen_qiju.sh --tianqin=follow-zhifu "2024-02-04 11:00"
  599. # Custom JSON output path
  600. tools/bin/qimen_qiju.sh --output=/tmp/plate.json "2026-04-18 10:00"
  601. # Full pipeline: birth plate + event plate + analysis
  602. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  603. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  604. tools/bin/qimen_event.sh --question=事业
  605. # Run analysis with custom paths
  606. tools/bin/qimen_event.sh --input=/tmp/plate.json --question=求财
  607. # Verbose analysis (all wanwu fields)
  608. tools/bin/qimen_event.sh --question=婚姻感情 --verbose
  609. # Caiguan (auto-reads birth year from qmen_birth.json)
  610. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  611. tools/bin/qimen_caiguan.sh
  612. # Buzhen (array placement)
  613. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  614. tools/bin/qimen_huaqizhen.sh
  615. # Buzhen with event plate
  616. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  617. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  618. tools/bin/qimen_huaqizhen.sh --input=./qmen_event.json
  619. # Buzhen with family protection
  620. tools/bin/qimen_huaqizhen.sh --family-stems=甲,丙
  621. # Buzhen with yixiang concept protection
  622. tools/bin/qimen_huaqizhen.sh --yixiang=财富,权威
  623. # Yishenhuanjiang (transformation resolution)
  624. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  625. tools/bin/qimen_yishenhuanjiang.sh
  626. # Hunlian (marriage/romance analysis)
  627. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  628. tools/bin/qimen_hunlian.sh
  629. # Xingge (personality analysis)
  630. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  631. tools/bin/qimen_xingge.sh
  632. # Wanwu (imagery extraction, palace mode)
  633. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  634. tools/bin/qimen_wanwu.sh --palace=3
  635. # Wanwu (imagery extraction, manual mode)
  636. tools/bin/qimen_wanwu.sh --stem=丙 --star=天冲 --gate=伤门
  637. # Yaogce (cross-plate analysis: birth + event)
  638. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  639. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  640. tools/bin/qimen_yaoce.sh
  641. # Yaogce with yixiang concept stem (optional, after interactive inquiry)
  642. tools/bin/qimen_yaoce.sh --yixiang=财富
  643. # Xunshijieyun (寻时借运, 60-course ranking)
  644. tools/bin/qimen_qiju.sh --type=birth "1973-04-24 19:30"
  645. tools/bin/qimen_xunshijieyun.sh
  646. # Xunshijieyun with yixiang concept protection
  647. tools/bin/qimen_xunshijieyun.sh --yixiang=财富
  648. # Zhanduan (ancient text divination judgment)
  649. tools/bin/qimen_qiju.sh --type=event "2026-04-18 10:00"
  650. tools/bin/qimen_zhanduan.sh --topic=婚姻
  651. # Zhanduan: list all available topics (run without --topic)
  652. tools/bin/qimen_zhanduan.sh
  653. ```
  654. Full CLI reference:
  655. ```
  656. Usage: qimen_qiju.sh [OPTIONS] [DATETIME]
  657. 奇门遁甲起局 (Qi Men Dun Jia Plate Setting)
  658. 时家奇门 置闰法
  659. DATETIME format: "YYYY-MM-DD HH:MM" (default: current time)
  660. Options:
  661. --type=TYPE Plate type: "event" or "birth"
  662. Auto-selects: specified time → birth, current time → event
  663. event → ./qmen_event.json, birth → ./qmen_birth.json
  664. --output=PATH JSON file output path (default: based on --type)
  665. --tianqin=MODE 天禽 handling: "follow-tiannei" (default, follows Tiannei), "jikun", or "follow-zhifu"
  666. -h, --help Show this help
  667. ```
  668. ## Installation
  669. Run `install.sh` to symlink the project into your OpenCode skills directory and make the CLI executable:
  670. ```bash
  671. bash install.sh
  672. ```
  673. This creates a symlink for each `qmen_*` sub-skill in the OpenCode skills directory (e.g. `qmen_dunjia`, `qmen_event`, `qmen_caiguan`, `qmen_huaqizhen`, `qmen_hunlian`, `qmen_xingge`, `qmen_wanwu`, `qmen_yaoce`). Each skill sub-directory also contains relative symlinks (`bin`, `data`, `lib`) pointing to the project's tools directory, so AI agents can resolve the project root at runtime without hardcoded paths. Restart OpenCode to load the skills.
  674. ## Requirements
  675. **Shell:** Bash 3.2 or later. No external dependencies: no Python, no bc, no awk, no GNU coreutils extensions.
  676. **OS:** Linux (recommended), macOS, Windows WSL. Native Windows is not supported.
  677. **AI Coding Agent:** [OpenCode](https://github.com/anomalyco/opencode) (recommended), [Openclaw](https://github.com/openclaw/openclaw), [Hermes](https://github.com/NousResearch/hermes-agent). Other tools have not been tested.
  678. **Tested Models (ranked):**
  679. | Rank | Model |
  680. |------|-------|
  681. | 1 | Claude Opus 4.6 |
  682. | 2 | Deepseek v4 Pro / Flash |
  683. | 3 | XiaoMi MiMo v2.5 Pro |
  684. | 4 | MiniMax M2.7 |
  685. ## Acknowledgments
  686. What is implemented here represents roughly thirty percent of the author's lifetime study. With gratitude to Master Xun Shuang (荀爽) for his teaching.
  687. ## License
  688. GPL-3.0

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.