liuyao 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/index.d.mts +335 -0
  2. package/dist/index.mjs +2 -1778
  3. package/dist/index.mjs.map +1 -0
  4. package/liuyao-skill/SKILL.md +64 -8
  5. package/liuyao-skill/books//345/205/255/344/272/262/344/272/272/344/272/213/347/261/273.txt +131 -0
  6. package/liuyao-skill/books//345/207/272/350/241/214/350/241/214/344/272/272/347/261/273.txt +76 -0
  7. package/liuyao-skill/books//345/215/207/351/200/211/344/273/225/351/200/224/347/261/273.txt +182 -0
  8. package/liuyao-skill/books//345/244/251/346/227/266/345/215/240.txt +300 -0
  9. package/liuyao-skill/books//345/251/232/345/247/273/350/203/216/344/272/247/347/261/273.txt +100 -0
  10. package/liuyao-skill/books//345/255/246/344/270/232/345/212/237/345/220/215/347/261/273.txt +152 -0
  11. package/liuyao-skill/books//345/256/230/351/235/236/350/257/211/350/256/274/347/261/273.txt +9 -0
  12. package/liuyao-skill/books//345/256/266/345/256/205/350/220/245/351/200/240/347/261/273.txt +113 -0
  13. package/liuyao-skill/books//346/261/202/350/264/242/350/264/270/346/230/223/347/261/273.txt +171 -0
  14. package/liuyao-skill/books//347/226/276/347/227/205/345/214/273/347/226/227/347/261/273.txt +128 -0
  15. package/liuyao-skill/books//350/272/253/345/221/275/345/257/277/345/205/203/347/261/273.txt +331 -0
  16. package/liuyao-skill/books//351/201/223/347/220/206/347/257/207.txt +1912 -0
  17. package/liuyao-skill/books//351/243/216/346/260/264/350/214/224/350/221/254/347/261/273.txt +91 -0
  18. package/liuyao-skill/parser.skill.mjs +1 -0
  19. package/package.json +2 -5
  20. package/dist/SKILL.md +0 -10
  21. package/dist/index.d.ts +0 -330
  22. package/dist/parser.skill.js +0 -1
  23. package/liuyao-skill/parser.skill.js +0 -1
@@ -0,0 +1,335 @@
1
+ //#region src/core/setup-gram.d.ts
2
+ /**
3
+ * Kins and their corresponding earthly branches in the Liu Yao divination system, along with the type of relation (世 or 应).
4
+ * This information is crucial for interpreting the hexagrams and their changing lines in the context of a divination reading.
5
+ */
6
+ interface SetupGramInfo {
7
+ /**
8
+ * There are 5 kins in total.
9
+ *
10
+ * - 兄弟 (Brothers): Representing peers, friends, or competitors.
11
+ * - 妻财 (Wife/Wealth): Representing spouse, wealth, or resources.
12
+ * - 子孙 (Children/Descendants): Representing offspring, students, or followers.
13
+ * - 官鬼 (Officials/Ghosts): Representing authority figures, adversaries, or hidden factors.
14
+ * - 父母 (Parents): Representing parents, mentors, or foundational influences.
15
+ *
16
+ * Each kin is associated with one of the twelve earthly branches (地支), which adds another layer of meaning to the hexagram lines.
17
+ */
18
+ kin: '兄弟丑土' | '兄弟亥水' | '兄弟午火' | '兄弟卯木' | '兄弟子水' | '兄弟寅木' | '兄弟巳火' | '兄弟戌土' | '兄弟未土' | '兄弟申金' | '兄弟辰土' | '兄弟酉金' | '妻财丑土' | '妻财亥水' | '妻财午火' | '妻财卯木' | '妻财子水' | '妻财寅木' | '妻财巳火' | '妻财戌土' | '妻财未土' | '妻财申金' | '妻财辰土' | '妻财酉金' | '子孙丑土' | '子孙亥水' | '子孙午火' | '子孙卯木' | '子孙子水' | '子孙寅木' | '子孙巳火' | '子孙戌土' | '子孙未土' | '子孙申金' | '子孙辰土' | '子孙酉金' | '官鬼丑土' | '官鬼亥水' | '官鬼午火' | '官鬼卯木' | '官鬼子水' | '官鬼寅木' | '官鬼巳火' | '官鬼戌土' | '官鬼未土' | '官鬼申金' | '官鬼辰土' | '官鬼酉金' | '父母丑土' | '父母亥水' | '父母午火' | '父母卯木' | '父母子水' | '父母寅木' | '父母巳火' | '父母戌土' | '父母未土' | '父母申金' | '父母辰土' | '父母酉金';
19
+ /**
20
+ * Host(世)is the augur and Guest(应) is the person or things which to ask about.
21
+ *
22
+ * Indexes of Host and Guest satisfies this formula:
23
+ * ```js
24
+ * index_guest = (index_host + 3) % 6
25
+ * ```
26
+ */
27
+ hostGuest?: '世' | '应';
28
+ }
29
+ //#endregion
30
+ //#region src/core/common.d.ts
31
+ interface PalaceOrderName {
32
+ name: string;
33
+ nameEn: string;
34
+ }
35
+ declare const PalaceOrderTable: PalaceOrderName[];
36
+ interface HexagramInfo {
37
+ /**
38
+ * Binary representation of the hexagram, where 0 represents a yin line and 1 represents a yang line. The lines are ordered from the bottom (first line) to the top (sixth line).
39
+ */
40
+ binary: `${0 | 1}${0 | 1}${0 | 1}${0 | 1}${0 | 1}${0 | 1}`;
41
+ /**
42
+ * Binary to YangCounts.
43
+ * e.g. `'000000'` 坤为地 -> `[2, 2, 2, 2, 2, 2]`, 2 means Shao Yin.
44
+ */
45
+ yangCounts: number[];
46
+ /**
47
+ * Name of the hexagram, which includes the names of the upper and lower trigrams.
48
+ *
49
+ * For example, "坤为地", "地雷复", "地水师", etc.
50
+ */
51
+ id: string;
52
+ /**
53
+ * 64 hexagrams correspond to Unicode characters.
54
+ * For example, "䷁" (U+4DC1) represents the hexagram "坤为地".
55
+ */
56
+ sign: string;
57
+ /**
58
+ * Five Phases (五行) associated with the hexagram, which can be one of "金" (Metal), "木" (Wood), "水" (Water), "火" (Fire), or "土" (Earth).
59
+ * It indicates the development and state of things.
60
+ */
61
+ phase: '金' | '木' | '水' | '火' | '土';
62
+ /**
63
+ * Eight Palaces (八宫) to which the hexagram belongs.
64
+ * 'Palace' is not a physical palace, but rather a category or family of hexagrams.
65
+ */
66
+ palace: '乾' | '兑' | '离' | '震' | '巽' | '坎' | '艮' | '坤';
67
+ /**
68
+ * Index of the hexagram within its palace, ranging from 0 to 7. This index helps to identify the specific hexagram within the context of its palace.
69
+ *
70
+ * - 本宫卦 Original Palace
71
+ * - 一世卦 First Generation, 1st yao is changed
72
+ * - 二世卦 Second Generation, 1st and 2nd yao is changed
73
+ * - 三世卦 Third Generation, 1st, 2nd and 3rd yao is changed
74
+ * - 四世卦 Fourth Generation, 1st, 2nd, 3rd and 4th yao is changed
75
+ * - 五世卦 Fifth Generation, 1st, 2nd, 3rd, 4th and 5th yao is changed
76
+ * - 游魂卦 Wandering Soul, restores 4th yao of Fifth Generation
77
+ * - 归魂卦 Returning Soul, restores lower 3 yaos of Fifth Generation
78
+ */
79
+ palaceIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
80
+ /**
81
+ * Setup information of the hexagram. Includes Host-Guest(世应) and Six Kins (六亲) for each of the six lines. This information is crucial for interpreting the hexagrams and their changing lines in the context of a divination reading.
82
+ *
83
+ * Host(世)is the augur and Guest(应) is the person or things which to ask about.
84
+ */
85
+ setupInfo: [SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo];
86
+ }
87
+ declare const HexagramInfoTable: readonly HexagramInfo[];
88
+ interface TrigramInfo {
89
+ /**
90
+ * Presents the trigram as a 3-digit binary string. 1 represents a Yang line and 0 represents a Yin line.
91
+ *
92
+ * For example, "111" for 乾, "100" for 震, etc.
93
+ */
94
+ binary: `${0 | 1}${0 | 1}${0 | 1}`;
95
+ /**
96
+ * How many Yang Yaos are in the trigram, such as 0 for 坤, 1 for 震, 2 for 兑, etc.
97
+ */
98
+ yangCount: 0 | 1 | 2 | 3;
99
+ /**
100
+ * Name of the trigram in Chinese, such as "乾", "坤", "震", etc.
101
+ */
102
+ id: string;
103
+ /**
104
+ * Name of the trigram in English, such as "Qian", "Kun", "Zhen", etc.
105
+ */
106
+ nameEn: string;
107
+ /**
108
+ * What the trigram represents in Chinese, such as "天", "地", "水", etc.
109
+ */
110
+ represents: string;
111
+ /**
112
+ * What the trigram represents in English, such as "heaven", "earth", "water", etc.
113
+ */
114
+ representsEn: string;
115
+ /**
116
+ * Unicode character representing the trigram, such as "☰" for 乾, "☷" for 坤, etc.
117
+ */
118
+ sign: string;
119
+ }
120
+ /**
121
+ * List of all trigrams in the I Ching, with their binary representation, number of yang lines, name, what they represent, and their corresponding sign.
122
+ */
123
+ declare const TrigramInfoTable: readonly TrigramInfo[];
124
+ //#endregion
125
+ //#region src/core/six-gods.d.ts
126
+ type SixGod = '玄武' | '白虎' | '螣蛇' | '勾陈' | '朱雀' | '青龙';
127
+ interface SixGodInfo {
128
+ /**
129
+ * The Heavenly Stem associated with the Six Gods in this order.
130
+ * They are '甲乙丙丁戊己庚辛壬癸' in sequence.
131
+ * Different Heavenly Stems correspond to different orders of Six Gods.
132
+ */
133
+ heavenlyStem: string;
134
+ /**
135
+ * Six Gods contains '青龙', '朱雀', '勾陈', '螣蛇', '白虎', '玄武'.
136
+ * Different Heavenly Stems correspond to different orders of Six Gods.
137
+ *
138
+ * Six Gods are all auspicious symbols and protectors.
139
+ * - 青龙: Azure Loong, the God in the East worshipped by the Taoists.
140
+ * - 朱雀: Vermilion Bird, its body is covered with eternal fire.
141
+ * - 白虎: White Tiger, as white as snow. If the emperor is not cruel and tyrannical, the White Tiger will appear.
142
+ * - 玄武:Black Tortoise, a spiritual creature formed by the combination of a tortoise and a snake.
143
+ * - 螣蛇: Flying Serpent, a limbless divine serpent that can summon clouds and mist and roam within them.
144
+ * - 勾陈: Gouchen, Also considered as 麒麟 Kylin. It has a body like a musk deer, a tail like that of a dragon, dragon scales, and a single horn.
145
+ */
146
+ gods: SixGod[];
147
+ }
148
+ /**
149
+ * @see 《增删卜易·六神章》
150
+ */
151
+ declare const SixGodTable: readonly SixGodInfo[];
152
+ //#endregion
153
+ //#region src/classes/yao.d.ts
154
+ declare class Yao {
155
+ static getName(yangCount: number): "老阴" | "少阳" | "少阴" | "老阳";
156
+ /**
157
+ * Support creating a Yao from various types of input:
158
+ * - A symbol representing the Yao (e.g. '交', '单', '拆', '重')
159
+ * - A name representing the Yao (e.g. '老阴', '少阳', '少阴', '老阳')
160
+ * - A digit representing the count of yang (e.g. '0', '1', '2', '3')
161
+ * - Symbols in ancient books representing a Yao ()
162
+ * - A field of a TrigramInfo object (e.g. id, binary, nameEn, represents, representsEn, sign)
163
+ * If the input matches any of these, a corresponding Yao will be created.
164
+ * Otherwise, null will be returned.
165
+ */
166
+ /**
167
+ * Creating a Yao from symbol.
168
+ * @param symbol e.g. '×' for 0, '’' for 1, '”' for 2, '○' for 3.
169
+ */
170
+ static fromSymbol(symbol: string): Yao | null;
171
+ /**
172
+ * Creating a Yao from symbolName.
173
+ * @param symbolName e.g. '交' for 0, '单' for 1, '拆' for 2, '重' for 3.
174
+ */
175
+ static fromSymbolName(symbolName: string): Yao | null;
176
+ /**
177
+ * Creating a Yao from name.
178
+ * @param name e.g. '老阴', '少阳', '少阴', '老阳'.
179
+ */
180
+ static fromName(name: string): Yao | null;
181
+ /**
182
+ * Create a Yao from a digit string representing the count of yang.
183
+ */
184
+ static fromDigitString(digit: string): Yao | null;
185
+ /**
186
+ * Create a Yao from any Trigram field value.
187
+ * @param value `{id: '坤', binary: '000', yangCount: 0}`, so `'坤'`, `'000'` and `0` can all be used.
188
+ */
189
+ static fromTrigramField(value: string | number): Yao | null;
190
+ private _yangCount;
191
+ /**
192
+ * How many faces of character of 3 coins in this Yao.
193
+ * It can only be 0, 1, 2 or 3, which corresponds to 老阴、少阳、少阴、老阳 respectively.
194
+ * - 0: 老阴 (all three coins are Yin)
195
+ * - 1: 少阳 (one coin is Yang, two coins are Yin)
196
+ * - 2: 少阴 (two coins are Yang, one coin is Yin)
197
+ * - 3: 老阳 (all three coins are Yang)
198
+ */
199
+ get yangCount(): 0 | 1 | 2 | 3;
200
+ /**
201
+ * Two Polars.
202
+ * - 0 represents Yin 阴
203
+ * - 1 represents Yang 阳
204
+ */
205
+ get polar(): 0 | 1;
206
+ /**
207
+ * If this Yao is dynamic, which means it can change to another Yao. In LiuYao, only 老阴 and 老阳 are dynamic.
208
+ * - 老阴 (0) can change to 少阳 (1)
209
+ * - 老阳 (3) can change to 少阴 (2)
210
+ * - 少阳 (1) and 少阴 (2) cannot change, so they are static.
211
+ */
212
+ get isDynamic(): boolean;
213
+ /**
214
+ * Whether this Yao has already changed to another Yao. Once a Yao is changed, it cannot change again.
215
+ */
216
+ readonly isChanged: boolean;
217
+ /**
218
+ * @returns The symbol representing this Yao, which is one of '×', '’', '”', '○'.
219
+ */
220
+ get symbol(): string;
221
+ get symbolName(): string;
222
+ get name(): "老阴" | "少阳" | "少阴" | "老阳";
223
+ constructor(yangCount: number, isChanged?: boolean);
224
+ /**
225
+ * Change `this.yangCount`
226
+ */
227
+ set(yangCount: number): void;
228
+ clone(): Yao;
229
+ toChanged(): Yao;
230
+ }
231
+ //#endregion
232
+ //#region src/classes/hexagram.d.ts
233
+ type LiuYao = [Yao, Yao, Yao, Yao, Yao, Yao];
234
+ declare const HexagramYaoOrder: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
235
+ /**
236
+ * Hexagram class represents a hexagram, which consists of 6 Yao.
237
+ * - Each Yao can be either yin or yang, and can be changing or not.
238
+ * - The hexagram can be constructed from an array of Yao or an array of counts of yang.
239
+ * - Creates “乾为天” by default.
240
+ */
241
+ declare class Hexagram {
242
+ /**
243
+ * Use tokens like `'012132'` to create a Hexagram, where each digit represents the count of Yang in the corresponding Yao (0 for 老阴, 1 for 少阳, 2 for 少阴, 3 for 老阳). The first digit represents the first Yao (初爻) and the last digit represents the sixth Yao (上爻).
244
+ */
245
+ static fromQuaternary(quaternary: string): Hexagram | null;
246
+ /**
247
+ * Use tokens like `'单单拆拆重重'` to create a Hexagram.
248
+ *
249
+ * Since 交 is 0, 单 is 1, 拆 is 2, and 重 is 3, the above token is equivalent to '112233'.
250
+ * Which returns '风泽中孚' with its 5th and 6th Yao being dynamic.
251
+ */
252
+ static fromSymbolName(symbolNames: string): Hexagram | null;
253
+ /**
254
+ * Try to create a Hexagram from an array of counts of Yang. If the input is invalid, null will be returned.
255
+ */
256
+ static fromYangCounts(counts: number[]): Hexagram | null;
257
+ /**
258
+ * Create a Hexagram from its id, which is the name of the hexagram without the palace name.
259
+ * @param id "坤为地", "地雷复", "地水师"
260
+ */
261
+ static fromId(id: string): Hexagram | null;
262
+ /**
263
+ * Find Original Palace Hexagram by the palace name, which is the last character of the hexagram id. For example, '天' for '乾为天', '地' for '坤为地', etc.
264
+ */
265
+ static fromPalace(palace: string): Hexagram | null;
266
+ /**
267
+ * 6 Yao positions, indexed from bottom to top.
268
+ * Index from 0 to 5, where 0 is the first Yao (初爻) and 5 is the sixth Yao (上爻).
269
+ */
270
+ readonly yaos: LiuYao;
271
+ /**
272
+ * HexagramInfo of this hexagram, which can be used to get more information about this hexagram, such as its name, sign, phase, palace, etc.
273
+ */
274
+ get info(): HexagramInfo;
275
+ get palace(): string;
276
+ /**
277
+ * Whether the 6 Yaos of this hexagram contain any dynamic Yao.
278
+ */
279
+ get isDynamic(): boolean;
280
+ /**
281
+ * Whether this hexagram has already changed to another hexagram. Once a hexagram is changed, it cannot change again.
282
+ */
283
+ get isChanged(): boolean;
284
+ /**
285
+ * Outer trigram of this hexagram, which consists of the last three yao (四爻、五爻、上爻).
286
+ * @returns A trigram if the outer trigram is dynamic.
287
+ */
288
+ get dynamicOuter(): boolean;
289
+ /**
290
+ * Inner trigram of this hexagram, which consists of the first three yao (初爻、二爻、三爻).
291
+ * @returns A trigram if the inner trigram is dynamic.
292
+ */
293
+ get dynamicInner(): boolean;
294
+ /**
295
+ * Create a Hexagram from an array of Yao with length 6.
296
+ */
297
+ constructor(yaos: Yao[]);
298
+ setYao(index: number, yangCount: number): void;
299
+ toChanged(): Hexagram | null;
300
+ /**
301
+ * Describe this hexagram in a human-readable way, including the original hexagram, the changed hexagram (if any), and the dynamic yao (if any).
302
+ * - e.g.:“本卦乾为天,变卦坤为地,动爻:初爻、三爻”
303
+ */
304
+ toDescription(): string;
305
+ /**
306
+ * This output is meant for AI skills.
307
+ */
308
+ toAIReadable(): {
309
+ 本卦: HexagramAIReadable;
310
+ 变卦: HexagramAIReadable | '无';
311
+ 世应变化: string;
312
+ };
313
+ clone(): Hexagram;
314
+ toString(): string;
315
+ [Symbol.toPrimitive](): string;
316
+ }
317
+ interface YaoInfo {
318
+ 爻: string;
319
+ 类型?: '世' | '应';
320
+ 六亲: string;
321
+ }
322
+ interface HexagramAIReadable {
323
+ 初爻: YaoInfo;
324
+ 二爻: YaoInfo;
325
+ 三爻: YaoInfo;
326
+ 四爻: YaoInfo;
327
+ 五爻: YaoInfo;
328
+ 上爻: YaoInfo;
329
+ 卦名: string;
330
+ 宫: string;
331
+ 变爻?: string[];
332
+ }
333
+ //#endregion
334
+ export { Hexagram, type HexagramInfo, HexagramInfoTable, HexagramYaoOrder, PalaceOrderTable as PalaceIndexTable, type SetupGramInfo, type SixGod, type SixGodInfo, SixGodTable, type TrigramInfo, TrigramInfoTable, Yao };
335
+ //# sourceMappingURL=index.d.mts.map