@metago-ai/engine 2.1.3 → 2.1.4
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.
- package/BOUNDARIES.md +109 -0
- package/CHANGES.md +4 -4
- package/CONSTITUTION/AXIOMS.md +75 -113
- package/CORE/ATOMS.md +611 -0
- package/CORE/ATTRIBUTES.md +74 -105
- package/CORE/PROTOCOLS.md +134 -116
- package/ENGINE.md +115 -115
- package/ENGINES/engine-runtime.cjs +318 -0
- package/ENGINES/final-engines-runtime.cjs +683 -0
- package/ENGINES/governance-runtime.cjs +582 -0
- package/ENGINES/math-capability-runtime.cjs +451 -0
- package/ENGINES/philosophy-runtime.cjs +427 -0
- package/ENGINES/yili/data/yaoci-1.js +24 -0
- package/ENGINES/yili/data/yaoci-2.js +21 -0
- package/ENGINES/yili/data/yaoci-3.js +21 -0
- package/ENGINES/yili/data/yaoci-4.js +21 -0
- package/ENGINES/yili/data/yaoci.js +17 -0
- package/ENGINES/yili/lib/almanac.js +416 -0
- package/ENGINES/yili/lib/bazi.js +127 -0
- package/ENGINES/yili/lib/diagnose.js +71 -0
- package/ENGINES/yili/lib/hetu-luoshu.js +123 -0
- package/ENGINES/yili/lib/index.js +23 -0
- package/ENGINES/yili/lib/liuyao.js +226 -0
- package/ENGINES/yili/lib/qimen.js +167 -0
- package/ENGINES/yili/lib/shushu-calculus.js +85 -0
- package/ENGINES/yili/lib/taiyi.js +83 -0
- package/ENGINES/yili/lib/vendor/shouxing-core.js +627 -0
- package/ENGINES/yili/lib/wuxing.js +106 -0
- package/ENGINES/yili/lib/yijing.js +226 -0
- package/ENGINES/yili/lib/zeri.js +80 -0
- package/ENGINES/yili/lib/ziwei.js +145 -0
- package/ENGINES/yili/package.json +1 -0
- package/EXECUTORS.md +85 -0
- package/GENOME.json +11 -10
- package/INDEX/ENGINES.md +168 -0
- package/INDEX/engines.json +2 -2
- package/INDEX/knowledge.json +87 -87
- package/INDEX/skills.json +227 -203
- package/PATENTS.md +1 -1
- package/PROTOCOLS/closure-runtime.cjs +288 -0
- package/PROTOCOLS/covenant-runtime.cjs +409 -0
- package/PROTOCOLS/final-runtime.cjs +680 -0
- package/PROTOCOLS/formula-runtime.cjs +399 -0
- package/PROTOCOLS/proactive-runtime.cjs +368 -0
- package/PROTOCOLS/rule-runtime.cjs +448 -0
- package/PROTOCOLS/runtime.cjs +441 -0
- package/README.md +5 -5
- package/RUNTIME/dist/kmwi-memory.d.ts.map +1 -1
- package/RUNTIME/dist/kmwi-memory.js +14 -2
- package/RUNTIME/dist/kmwi-memory.js.map +1 -1
- package/RUNTIME/dist/validators.js +11 -2
- package/atoms/approx.cjs +293 -0
- package/atoms/atom-factory.cjs +550 -0
- package/atoms/atoms-cosmic-bio.cjs +340 -0
- package/atoms/atoms-crypto-emotion.cjs +215 -0
- package/atoms/atoms_engines.json +5821 -0
- package/atoms/blueprint-atoms-2.cjs +583 -0
- package/atoms/blueprint-atoms.cjs +975 -0
- package/atoms/constraints.cjs +257 -0
- package/atoms/contract-validator.cjs +213 -0
- package/atoms/engine.cjs +849 -0
- package/atoms/specialized.cjs +530 -0
- package/atoms/verify.cjs +94 -0
- package/package.json +12 -6
- package/scripts/verify-dist.cjs +80 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* P6-B3 · 哲学族引擎运行时(第1部分 V9 的 02–18,共 18 条)
|
|
4
|
+
*
|
|
5
|
+
* 诚实分层(依卷首条款「唯一允许的例外」):
|
|
6
|
+
* compute : 有明确公式或可从真实输入确定性计算的 → 真实实现
|
|
7
|
+
* external : 蓝本明确要求训练模型的(多模态 Transformer / 物种识别 CNN / seq2seq 翻译 / 脑电解码)
|
|
8
|
+
* → 返回 EXTERNAL_REQUIRED,写明缺什么、为什么纯软件不可实现
|
|
9
|
+
* hardware : 需物理传感器接口的(引力波/宇宙射线/地磁/量子传感器)
|
|
10
|
+
* → 返回 HARDWARE_REQUIRED,可用调用方提供的实测值代入计算
|
|
11
|
+
*
|
|
12
|
+
* 共用结构:28 维环境/万物状态向量 = 物理8 + 生物6 + 量子4 + 宇宙6 + 融合4
|
|
13
|
+
*/
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
let __seq = 0;
|
|
17
|
+
const newTraceId = () => {
|
|
18
|
+
const d = new Date(), p = (n, w = 2) => String(n).padStart(w, '0');
|
|
19
|
+
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}-P${p((++__seq) % 10000, 4)}`;
|
|
20
|
+
};
|
|
21
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, Number(x) || 0));
|
|
22
|
+
const mean = (a) => (a.length ? a.reduce((s, x) => s + (Number(x) || 0), 0) / a.length : 0);
|
|
23
|
+
const round = (x, n = 4) => Math.round((Number(x) || 0) * 10 ** n) / 10 ** n;
|
|
24
|
+
|
|
25
|
+
/* ══════════ 共用计算原语(全部真实实现) ══════════ */
|
|
26
|
+
|
|
27
|
+
/** Shannon 熵:S = -Σ p_i log p_i(蓝本 ALG_ENV_ENTROPY_610 公式) */
|
|
28
|
+
function shannonEntropy(values) {
|
|
29
|
+
const v = values.map(Number).filter((x) => isFinite(x) && x >= 0);
|
|
30
|
+
const s = v.reduce((a, b) => a + b, 0);
|
|
31
|
+
if (!s) return 0;
|
|
32
|
+
const p = v.map((x) => x / s);
|
|
33
|
+
return round(-p.reduce((a, x) => a + (x > 0 ? x * Math.log(x) : 0), 0));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 公平指数:F = w1·F_access + w2·F_distribution + w3·F_opportunity(蓝本 ALG_ENV_FAIR_608) */
|
|
37
|
+
function fairnessIndex(input) {
|
|
38
|
+
const { access = 0.8, distribution = 0.7, opportunity = 0.75 } = input || {};
|
|
39
|
+
const w = [0.4, 0.3, 0.3]; // 蓝本权重
|
|
40
|
+
const F = w[0] * clamp01(access) + w[1] * clamp01(distribution) + w[2] * clamp01(opportunity);
|
|
41
|
+
return { F: round(F), components: { access: clamp01(access), distribution: clamp01(distribution), opportunity: clamp01(opportunity) }, weights: w };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 温度舒适度(蓝本量程 -40~85℃,精度±0.1℃;舒适区间取 18–26℃) */
|
|
45
|
+
function tempComfort(t) {
|
|
46
|
+
const x = Number(t);
|
|
47
|
+
if (!isFinite(x)) return null;
|
|
48
|
+
if (x >= 18 && x <= 26) return 1;
|
|
49
|
+
if (x < 18) return clamp01(1 - (18 - x) / 58); // -40 时为 0
|
|
50
|
+
return clamp01(1 - (x - 26) / 59); // 85 时为 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 光照适宜度(0–100000 lux;室内舒适 300–1500 lux) */
|
|
54
|
+
function lightComfort(lux) {
|
|
55
|
+
const x = Number(lux);
|
|
56
|
+
if (!isFinite(x)) return null;
|
|
57
|
+
if (x >= 300 && x <= 1500) return 1;
|
|
58
|
+
if (x < 300) return clamp01(x / 300);
|
|
59
|
+
return clamp01(1 - (x - 1500) / 98500);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 声环境质量(20–20000Hz、120dB 动态范围;55dB 以下为优) */
|
|
63
|
+
function soundQuality(db) {
|
|
64
|
+
const x = Number(db);
|
|
65
|
+
if (!isFinite(x)) return null;
|
|
66
|
+
if (x <= 55) return 1;
|
|
67
|
+
return clamp01(1 - (x - 55) / 65); // 120dB 时为 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 空气质量(PM2.5,0–500;≤35 优) */
|
|
71
|
+
function airQuality(pm25) {
|
|
72
|
+
const x = Number(pm25);
|
|
73
|
+
if (!isFinite(x)) return null;
|
|
74
|
+
if (x <= 35) return 1;
|
|
75
|
+
return clamp01(1 - (x - 35) / 465);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 28 维向量聚合:物理8 + 生物6 + 量子4 + 宇宙6 + 融合4 */
|
|
79
|
+
function build28(cfg) {
|
|
80
|
+
const phy = cfg.physical || {};
|
|
81
|
+
const bio = cfg.biological || {};
|
|
82
|
+
const q = cfg.quantum || {};
|
|
83
|
+
const cos = cfg.cosmic || {};
|
|
84
|
+
const dims = [];
|
|
85
|
+
const push = (group, name, val) => dims.push({ group, name, value: val === null || val === undefined ? null : round(clamp01(val)) });
|
|
86
|
+
|
|
87
|
+
/* 物理 8 */
|
|
88
|
+
push('物理', '温度舒适度', tempComfort(phy.temperature));
|
|
89
|
+
push('物理', '空气质量指数', airQuality(phy.pm25));
|
|
90
|
+
push('物理', '光照适宜度', lightComfort(phy.lux));
|
|
91
|
+
push('物理', '声环境质量', soundQuality(phy.db));
|
|
92
|
+
push('物理', '湿度适宜度', phy.humidity === undefined ? null : clamp01(1 - Math.abs(Number(phy.humidity) - 50) / 50));
|
|
93
|
+
push('物理', '气压稳定度', phy.pressure === undefined ? null : clamp01(1 - Math.abs(Number(phy.pressure) - 1013) / 713));
|
|
94
|
+
push('物理', '振动安全度', phy.vibration === undefined ? null : clamp01(1 - Math.abs(Number(phy.vibration)) / 16));
|
|
95
|
+
push('物理', '辐射安全度', phy.radiation === undefined ? null : clamp01(1 - Number(phy.radiation)));
|
|
96
|
+
/* 生物 6 */
|
|
97
|
+
push('生物', '生物多样性', bio.biodiversity);
|
|
98
|
+
push('生物', '生态健康度', bio.ecosystemHealth);
|
|
99
|
+
push('生物', '人境和谐度', bio.humanHarmony);
|
|
100
|
+
push('生物', '人群密度适宜度', bio.crowdDensity === undefined ? null : clamp01(1 - Math.abs(Number(bio.crowdDensity) - 30) / 100));
|
|
101
|
+
push('生物', '植物状态指数', bio.plantHealth);
|
|
102
|
+
push('生物', '微生物活性', bio.microbialActivity);
|
|
103
|
+
/* 量子 4 */
|
|
104
|
+
push('量子', '量子稳定度', q.stability);
|
|
105
|
+
push('量子', '纠缠可用性', q.entanglement);
|
|
106
|
+
push('量子', '退相干风险(反向)', q.decoherence === undefined ? null : clamp01(1 - Number(q.decoherence)));
|
|
107
|
+
push('量子', '量子噪声(反向)', q.noise === undefined ? null : clamp01(1 - Number(q.noise)));
|
|
108
|
+
/* 宇宙 6 */
|
|
109
|
+
push('宇宙', '宇宙事件影响度(反向)', cos.eventImpact === undefined ? null : clamp01(1 - Number(cos.eventImpact)));
|
|
110
|
+
push('宇宙', '辐射安全度', cos.radiationSafety);
|
|
111
|
+
push('宇宙', '星际连接度', cos.interstellarLink);
|
|
112
|
+
push('宇宙', '地磁稳定度', cos.geomagnetic);
|
|
113
|
+
push('宇宙', '太阳活动影响(反向)', cos.solarActivity === undefined ? null : clamp01(1 - Number(cos.solarActivity)));
|
|
114
|
+
push('宇宙', '宇宙射线安全度', cos.cosmicRaySafety);
|
|
115
|
+
/* 融合 4 */
|
|
116
|
+
const avail = dims.filter((d) => d.value !== null).map((d) => d.value);
|
|
117
|
+
const fiveFold = avail.length ? mean(avail) : null;
|
|
118
|
+
push('融合', '五元融合度', fiveFold);
|
|
119
|
+
push('融合', '环境负熵率', fiveFold === null ? null : clamp01(fiveFold ** 2));
|
|
120
|
+
push('融合', '演化势能', fiveFold === null ? null : clamp01(fiveFold * (1 - fiveFold) * 4));
|
|
121
|
+
push('融合', '综合和谐度', fiveFold);
|
|
122
|
+
|
|
123
|
+
const known = dims.filter((d) => d.value !== null);
|
|
124
|
+
return {
|
|
125
|
+
vector: dims,
|
|
126
|
+
dims: dims.length, // 恒为 28
|
|
127
|
+
knownDims: known.length,
|
|
128
|
+
missingDims: dims.length - known.length,
|
|
129
|
+
byGroup: ['物理', '生物', '量子', '宇宙', '融合'].reduce((acc, g) => {
|
|
130
|
+
const xs = dims.filter((d) => d.group === g && d.value !== null).map((d) => d.value);
|
|
131
|
+
acc[g] = xs.length ? round(mean(xs)) : null;
|
|
132
|
+
return acc;
|
|
133
|
+
}, {}),
|
|
134
|
+
overall: known.length ? round(mean(known.map((d) => d.value))) : null,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** 耦生度矩阵:C_ij = f(相似度, 互信息)(蓝本 ALG_ALLBIO_COUPLING_617) */
|
|
139
|
+
function couplingMatrix(states) {
|
|
140
|
+
const n = states.length;
|
|
141
|
+
if (!n) return { n: 0, matrix: [] };
|
|
142
|
+
const cos = (a, b) => {
|
|
143
|
+
const dot = a.reduce((s, x, i) => s + x * (b[i] || 0), 0);
|
|
144
|
+
const na = Math.sqrt(a.reduce((s, x) => s + x * x, 0));
|
|
145
|
+
const nb = Math.sqrt(b.reduce((s, x) => s + x * x, 0));
|
|
146
|
+
return na && nb ? dot / (na * nb) : 0;
|
|
147
|
+
};
|
|
148
|
+
const m = [];
|
|
149
|
+
for (let i = 0; i < n; i++) {
|
|
150
|
+
m.push([]);
|
|
151
|
+
for (let j = 0; j < n; j++) m[i].push(i === j ? 1 : round(cos(states[i], states[j])));
|
|
152
|
+
}
|
|
153
|
+
return { n, matrix: m };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** 互信息熵(离散化后):用于生物-硅基融合判据 互信息熵 > 0.7(蓝本 ALG_ALLBIO_FUSION_622) */
|
|
157
|
+
function mutualInformationEntropy(a, b, bins = 8) {
|
|
158
|
+
const n = Math.min(a.length, b.length);
|
|
159
|
+
if (!n) return 0;
|
|
160
|
+
const disc = (v, lo, hi) => Math.min(bins - 1, Math.max(0, Math.floor(((v - lo) / (hi - lo || 1)) * bins)));
|
|
161
|
+
const lo = (v) => Math.min(...v), hi = (v) => Math.max(...v);
|
|
162
|
+
const la = lo(a.slice(0, n)), ha = hi(a.slice(0, n)), lb = lo(b.slice(0, n)), hb = hi(b.slice(0, n));
|
|
163
|
+
const joint = {}, ma = {}, mb = {};
|
|
164
|
+
for (let i = 0; i < n; i++) {
|
|
165
|
+
const x = disc(a[i], la, ha), y = disc(b[i], lb, hb);
|
|
166
|
+
joint[`${x},${y}`] = (joint[`${x},${y}`] || 0) + 1;
|
|
167
|
+
ma[x] = (ma[x] || 0) + 1; mb[y] = (mb[y] || 0) + 1;
|
|
168
|
+
}
|
|
169
|
+
let mi = 0;
|
|
170
|
+
for (const [k, c] of Object.entries(joint)) {
|
|
171
|
+
const [x, y] = k.split(',').map(Number);
|
|
172
|
+
const pxy = c / n, px = ma[x] / n, py = mb[y] / n;
|
|
173
|
+
mi += pxy * Math.log(pxy / (px * py));
|
|
174
|
+
}
|
|
175
|
+
return round(Math.max(0, mi));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* ══════════ 18 条引擎定义 ══════════ */
|
|
179
|
+
const NG = '蓝本要求训练模型 → 纯软件不可实现(无权重、无训练数据)';
|
|
180
|
+
const HW = '需物理传感器接口 → 本机无该硬件';
|
|
181
|
+
|
|
182
|
+
const ENGINES = [
|
|
183
|
+
{ id: 'ENGINE_CIRCUMSTANCE_02', name: '境遇引擎', kind: 'compute', spec: '4921 字符',
|
|
184
|
+
implements: ['ALG_ENV_FAIR_608 公平指数 F=w1·F_access+w2·F_distribution+w3·F_opportunity (0.4/0.3/0.3)', 'ALG_ENV_ENTROPY_610 熵 S=-Σp_i·log p_i + dS/dt 预警(0.1黄/0.2红)', '28 维状态向量聚合(物理8+生物6+量子4+宇宙6+融合4)'],
|
|
185
|
+
external: { alg: 'ALG_ENV_SENSE_607 五元环境感知融合', why: '多模态融合 Transformer,420M 参数,需 10 亿+传感器读数训练', ext: NG },
|
|
186
|
+
async exec(inp, tid) {
|
|
187
|
+
const v = build28(inp || {});
|
|
188
|
+
const fair = fairnessIndex((inp && inp.fairness) || {});
|
|
189
|
+
const history = (inp && inp.entropySeries) || null;
|
|
190
|
+
const S = history ? shannonEntropy(history) : null;
|
|
191
|
+
let alert = null;
|
|
192
|
+
if (history && history.length >= 2) {
|
|
193
|
+
const dSdt = round((history[history.length - 1] - history[0]) / (history.length - 1));
|
|
194
|
+
alert = dSdt > 0.2 ? 'RED' : dSdt > 0.1 ? 'YELLOW' : 'GREEN';
|
|
195
|
+
var dS = dSdt;
|
|
196
|
+
}
|
|
197
|
+
return { success: true, kind: 'compute', output: {
|
|
198
|
+
state28: v, fairness: fair, entropy: S === null ? { note: '需提供 entropySeries 才可计算' } : { S, dSdt: dS, alert, formula: 'S=-Σp_i·log p_i;dS/dt>0.1 黄 / >0.2 红' },
|
|
199
|
+
externalRequired: [{ alg: 'ALG_ENV_SENSE_607', reason: NG }],
|
|
200
|
+
}, provenance: [`[${tid}] circumstance: 28维聚合(${v.knownDims}/${v.dims}) + 公平指数 ${fair.F} + 熵 ${S}`] };
|
|
201
|
+
} },
|
|
202
|
+
|
|
203
|
+
{ id: 'ENGINE_ALLBEINGS_03', name: '万物耦生引擎', kind: 'compute', spec: '4063 字符',
|
|
204
|
+
implements: ['ALG_ALLBIO_COUPLING_617 耦生度矩阵 C_ij=cos(状态向量)', 'ALG_ALLBIO_ECOSYSTEM_618 生态健康指数(多样性/稳定性/生产力/恢复力 等权)', 'ALG_ALLBIO_FUSION_622 生物-硅基融合判据 互信息熵>0.7'],
|
|
205
|
+
external: { alg: 'ALG_ALLBIO_SENSE_615 / TRANSLATE_616', why: '物种识别 CNN(动物1000+/植物10000+)+ seq2seq 跨物种翻译,需百万级标注对', ext: NG },
|
|
206
|
+
async exec(inp, tid) {
|
|
207
|
+
const states = (inp && inp.speciesStates) || [[0.8,0.6,0.7],[0.5,0.9,0.4],[0.7,0.3,0.8]];
|
|
208
|
+
const cm = couplingMatrix(states);
|
|
209
|
+
const eco = (inp && inp.ecosystem) || { diversity: 0.75, stability: 0.68, productivity: 0.72, resilience: 0.61 };
|
|
210
|
+
const health = round(mean([eco.diversity, eco.stability, eco.productivity, eco.resilience]));
|
|
211
|
+
const bio = (inp && inp.bioSignal) || [0.5,0.6,0.7,0.8,0.9,0.4];
|
|
212
|
+
const si = (inp && inp.siliconSignal) || [0.52,0.58,0.71,0.79,0.88,0.42];
|
|
213
|
+
const mi = mutualInformationEntropy(bio, si);
|
|
214
|
+
return { success: true, kind: 'compute', output: {
|
|
215
|
+
couplingMatrix: cm, ecosystemHealth: { index: health, dims: eco, standard: '多样性/稳定性/生产力/恢复力 等权' },
|
|
216
|
+
fusion: { mutualInformation: mi, threshold: 0.7, fused: mi > 0.7, rule: '互信息熵 > 0.7 判为边界消融' },
|
|
217
|
+
externalRequired: [{ alg: 'ALG_ALLBIO_SENSE_615 + TRANSLATE_616', reason: NG }],
|
|
218
|
+
}, provenance: [`[${tid}] allbeings: 耦生矩阵 ${cm.n}×${cm.n} + 生态健康 ${health} + 互信息 ${mi}`] };
|
|
219
|
+
} },
|
|
220
|
+
|
|
221
|
+
{ id: 'ENGINE_METAMIRROR_04', name: '元镜引擎', kind: 'pipeline', spec: '1539 字符',
|
|
222
|
+
implements: ['自我审视四步:能力清单 → 已考虑维度 → 未考虑维度声明 → 审查标记'],
|
|
223
|
+
async exec(inp, tid) {
|
|
224
|
+
const st = (inp && inp.self) || {};
|
|
225
|
+
const fams = ['认知能力族','治理能力族','资产能力族','保障能力族','执行能力族','权限能力族','工业互联族','元进化族'];
|
|
226
|
+
const covered = (st.covered || []).filter((x) => fams.includes(x));
|
|
227
|
+
const missing = fams.filter((f) => !covered.includes(f));
|
|
228
|
+
const unconsidered = Array.isArray(st.unconsidered) ? st.unconsidered : null;
|
|
229
|
+
const pass = covered.length > 0 && unconsidered !== null;
|
|
230
|
+
return { success: pass, kind: 'pipeline',
|
|
231
|
+
output: { families: fams, covered, missing, unconsidered, mark: pass ? '战略思考审查通过' : '未经战略思考审查' },
|
|
232
|
+
error: pass ? undefined : '未声明未考虑维度(unconsidered 必须显式给出,可为空数组)',
|
|
233
|
+
reason: pass ? undefined : 'PRECONDITION_FAILED',
|
|
234
|
+
provenance: [`[${tid}] metamirror: 覆盖 ${covered.length}/8 族 + 未考虑声明 ${unconsidered === null ? '缺失' : unconsidered.length}`] };
|
|
235
|
+
} },
|
|
236
|
+
|
|
237
|
+
{ id: 'ENGINE_MEANING_05', name: '意义引擎', kind: 'compute', spec: '2301 字符',
|
|
238
|
+
implements: ['意义五维评分:时间/空间/因果/价值/意义(易霄溯源论五原理)→ 加权意义度'],
|
|
239
|
+
async exec(inp, tid) {
|
|
240
|
+
const d = (inp && inp.dims) || { temporal: 0.7, spatial: 0.6, causal: 0.8, value: 0.75, meaning: 0.65 };
|
|
241
|
+
const w = { temporal: 0.15, spatial: 0.15, causal: 0.25, value: 0.25, meaning: 0.20 };
|
|
242
|
+
const score = round(Object.keys(w).reduce((s, k) => s + w[k] * clamp01(d[k]), 0));
|
|
243
|
+
return { success: true, kind: 'compute', output: { dims: d, weights: w, meaningScore: score, level: score >= 0.8 ? '强意义' : score >= 0.6 ? '有意义' : '意义待补' },
|
|
244
|
+
provenance: [`[${tid}] meaning: 五维加权 = ${score}`] };
|
|
245
|
+
} },
|
|
246
|
+
|
|
247
|
+
{ id: 'ENGINE_STRATEGY_06', name: '战略推演引擎', kind: 'compute', spec: '1071 字符',
|
|
248
|
+
implements: ['四维对齐:技术可行性/经济合理性/制度兼容性/政策导向性 → 加权战略适配度'],
|
|
249
|
+
async exec(inp, tid) {
|
|
250
|
+
const d = (inp && inp.dims) || { tech: 0.8, economy: 0.7, institution: 0.75, policy: 0.85 };
|
|
251
|
+
const w = { tech: 0.25, economy: 0.25, institution: 0.25, policy: 0.25 };
|
|
252
|
+
const score = round(Object.keys(w).reduce((s, k) => s + w[k] * clamp01(d[k]), 0));
|
|
253
|
+
return { success: true, kind: 'compute', output: { dims: d, weights: w, alignment: score, verdict: score >= 0.75 ? '可推' : score >= 0.6 ? '谨慎推' : '不宜推' },
|
|
254
|
+
provenance: [`[${tid}] strategy: 四维对齐 = ${score}`] };
|
|
255
|
+
} },
|
|
256
|
+
|
|
257
|
+
{ id: 'ENGINE_TIMESPACE_06', name: '时空耦生引擎', kind: 'compute', spec: '1080 字符',
|
|
258
|
+
implements: ['时-空耦生度:时间密度 × 空间密度 → 耦生度 + 分层(环境/基础/主体/不可控)'],
|
|
259
|
+
async exec(inp, tid) {
|
|
260
|
+
const t = clamp01((inp && inp.timeDensity) ?? 0.7);
|
|
261
|
+
const s = clamp01((inp && inp.spaceDensity) ?? 0.6);
|
|
262
|
+
const coupling = round(Math.sqrt(t * s));
|
|
263
|
+
const layers = ['环境层','基础层','主体层','不可控层'];
|
|
264
|
+
return { success: true, kind: 'compute', output: { timeDensity: t, spaceDensity: s, coupling, layers, dominant: layers[Math.min(3, Math.floor((1 - coupling) * 4))] },
|
|
265
|
+
provenance: [`[${tid}] timespace: 时${t}×空${s} → 耦生 ${coupling}`] };
|
|
266
|
+
} },
|
|
267
|
+
|
|
268
|
+
{ id: 'ENGINE_TAO_07', name: '道源引擎', kind: 'compute', spec: '2286 字符',
|
|
269
|
+
implements: ['归根复命:从现象层回溯本源层(5 层深度),输出本源度与回归路径'],
|
|
270
|
+
async exec(inp, tid) {
|
|
271
|
+
const depth = Math.max(1, Math.min(5, Number((inp && inp.depth) ?? 3)));
|
|
272
|
+
const layers = ['现象层','机制层','规律层','法则层','本源层'].slice(0, depth);
|
|
273
|
+
const sourceDegree = round(depth / 5);
|
|
274
|
+
return { success: true, kind: 'compute', output: { depth, layers, sourceDegree, path: layers.map((l, i) => ({ level: i + 1, layer: l })) },
|
|
275
|
+
provenance: [`[${tid}] tao: 溯源深度 ${depth}/5 → 本源度 ${sourceDegree}`] };
|
|
276
|
+
} },
|
|
277
|
+
|
|
278
|
+
{ id: 'ENGINE_DAILYTAO_08', name: '道在日常引擎', kind: 'compute', spec: '2034 字符',
|
|
279
|
+
implements: ['场景 → 经典映射(仅映射不预测,如实标注)'],
|
|
280
|
+
external: { alg: '经典语义匹配', why: '需经典文本语义模型才能泛化到任意场景;当前为规则表映射', ext: '可用规则表覆盖常见场景,泛化需语义模型' },
|
|
281
|
+
async exec(inp, tid) {
|
|
282
|
+
const scene = (inp && inp.scene) || '日常';
|
|
283
|
+
const TABLE = { 决策: '知止而后有定', 协作: '和而不同', 变化: '穷则变,变则通', 积累: '合抱之木生于毫末', 日常: '道在日常' };
|
|
284
|
+
const hit = Object.keys(TABLE).find((k) => scene.includes(k)) || '日常';
|
|
285
|
+
return { success: true, kind: 'compute', output: { scene, mapping: TABLE[hit], rule: '仅映射不预测(蓝本约束)', note: '泛化到任意场景需经典语义模型' },
|
|
286
|
+
provenance: [`[${tid}] dailytao: 场景「${scene}」→ 「${TABLE[hit]}」`] };
|
|
287
|
+
} },
|
|
288
|
+
|
|
289
|
+
{ id: 'ENGINE_OPPONENT_09', name: '反者引擎', kind: 'compute', spec: '255 字符',
|
|
290
|
+
implements: ['反者道之动:对命题取反并给出反向证据权重(对偶分析)'],
|
|
291
|
+
async exec(inp, tid) {
|
|
292
|
+
const p = (inp && inp.proposition) || '方案可行';
|
|
293
|
+
const w = clamp01((inp && inp.weight) ?? 0.6);
|
|
294
|
+
return { success: true, kind: 'compute', output: { proposition: p, opposite: '非(' + p + ')', oppositeWeight: round(1 - w), originalWeight: round(w), rule: '反者道之动:反向权重 = 1 - 正向权重' },
|
|
295
|
+
provenance: [`[${tid}] opponent: 「${p}」对偶权重 ${round(1 - w)}`] };
|
|
296
|
+
} },
|
|
297
|
+
|
|
298
|
+
{ id: 'ENGINE_METAEVO_10', name: '元进化引擎', kind: 'pipeline', spec: '1313 字符',
|
|
299
|
+
implements: ['五阶段:边界感知→差距分析→自生成→验证→递归(与 PROTOCOL_META_EVOLUTION_V1 同构)'],
|
|
300
|
+
async exec(inp, tid) {
|
|
301
|
+
const need = ['boundary','gap','newCapability','verification','selfReflection'];
|
|
302
|
+
const miss = need.filter((k) => !(inp && inp[k]));
|
|
303
|
+
const steps = need.map((k, i) => ({ stage: i + 1, key: k, present: !!(inp && inp[k]) }));
|
|
304
|
+
return { success: miss.length === 0, kind: 'pipeline', steps,
|
|
305
|
+
output: { stages: steps, complete: miss.length === 0, missing: miss },
|
|
306
|
+
error: miss.length ? '缺阶段输入:' + miss.join(',') : undefined,
|
|
307
|
+
reason: miss.length ? 'PRECONDITION_FAILED' : undefined,
|
|
308
|
+
provenance: [`[${tid}] metaevo: ${steps.filter((s) => s.present).length}/5 阶段齐备`] };
|
|
309
|
+
} },
|
|
310
|
+
|
|
311
|
+
{ id: 'ENGINE_QUANTUM_11', name: '量子叠加引擎', kind: 'compute', spec: '2227 字符',
|
|
312
|
+
implements: ['态叠加与测量:归一化振幅 → Born 规则概率 → 一次测量坍缩'],
|
|
313
|
+
external: { alg: '真实量子硬件执行', why: '需物理量子处理器;当前为经典模拟(数学等价,非量子加速)', ext: HW },
|
|
314
|
+
async exec(inp, tid) {
|
|
315
|
+
const amps = (inp && inp.amplitudes) || [0.6, 0.8];
|
|
316
|
+
const norm = Math.sqrt(amps.reduce((s, a) => s + a * a, 0)) || 1;
|
|
317
|
+
const p = amps.map((a) => round((a * a) / (norm * norm)));
|
|
318
|
+
const sum = round(p.reduce((a, b) => a + b, 0));
|
|
319
|
+
return { success: true, kind: 'compute', output: { amplitudes: amps, normalizedProb: p, probSum: sum, rule: 'Born 规则 P=|a|²/Σ|a|²', note: '经典模拟,非量子硬件' },
|
|
320
|
+
provenance: [`[${tid}] quantum: ${amps.length} 态叠加 → 概率 ${p.join('/')}(和 ${sum})`] };
|
|
321
|
+
} },
|
|
322
|
+
|
|
323
|
+
{ id: 'ENGINE_BIO_12', name: '生物融合引擎', kind: 'compute', spec: '2547 字符',
|
|
324
|
+
implements: ['HRV 时域(RMSSD/pNN50) + 频域(LF/HF) + 唤醒度代理(与 ATOM_PEOPLE_BIO_006 同源)'],
|
|
325
|
+
external: { alg: '生理信号采集', why: '需可穿戴设备的原始 RR 间期;调用方可直接传入 rr 数组', ext: HW },
|
|
326
|
+
async exec(inp, tid) {
|
|
327
|
+
const rr = (inp && inp.rr) || [800,810,795,805,820,790,800,815,805,795];
|
|
328
|
+
const diffs = rr.slice(1).map((x, i) => x - rr[i]);
|
|
329
|
+
const rmssd = round(Math.sqrt(mean(diffs.map((d) => d * d))));
|
|
330
|
+
const pnn50 = round(diffs.filter((d) => Math.abs(d) > 50).length / Math.max(1, diffs.length));
|
|
331
|
+
const hrv = round(Math.sqrt(mean(rr.map((x) => (x - mean(rr)) ** 2))));
|
|
332
|
+
const arousal = round(clamp01(1 - hrv / 200));
|
|
333
|
+
return { success: true, kind: 'compute', output: { beats: rr.length, rmssd, pnn50, sdnn: hrv, arousal, note: 'RR 间期需硬件采集;算法本身确定性' },
|
|
334
|
+
provenance: [`[${tid}] bio: ${rr.length} 拍 → RMSSD ${rmssd} / pNN50 ${pnn50} / 唤醒 ${arousal}`] };
|
|
335
|
+
} },
|
|
336
|
+
|
|
337
|
+
{ id: 'ENGINE_COSMIC_13', name: '宇宙网络引擎', kind: 'compute', spec: '2477 字符',
|
|
338
|
+
implements: ['星际连接度 = 节点数 × 平均链路质量 → 网络连通度;宇宙事件影响度加权'],
|
|
339
|
+
external: { alg: '引力波/宇宙射线/地磁实数据', why: '需 LIGO/Virgo、NOAA、空间站数据接口', ext: HW },
|
|
340
|
+
async exec(inp, tid) {
|
|
341
|
+
const nodes = Number((inp && inp.nodes) ?? 8);
|
|
342
|
+
const linkQ = clamp01((inp && inp.avgLinkQuality) ?? 0.7);
|
|
343
|
+
const connectivity = round(nodes > 1 ? (Math.log(nodes) / Math.log(100)) * linkQ : 0);
|
|
344
|
+
const impact = clamp01((inp && inp.eventImpact) ?? 0.2);
|
|
345
|
+
return { success: true, kind: 'compute', output: { nodes, avgLinkQuality: linkQ, connectivity, eventImpact: impact, safety: round(1 - impact), note: '真实引力波/射线数据需外部接口' },
|
|
346
|
+
provenance: [`[${tid}] cosmic: ${nodes} 节点 × 链路 ${linkQ} → 连通度 ${connectivity}`] };
|
|
347
|
+
} },
|
|
348
|
+
|
|
349
|
+
{ id: 'ENGINE_SLEEP_14', name: '睡眠引擎', kind: 'compute', spec: '1913 字符',
|
|
350
|
+
implements: ['睡眠周期分期(N1/N2/N3/REM)+ 睡眠效率 + 恢复度'],
|
|
351
|
+
external: { alg: '睡眠多导睡眠图', why: '需 EEG/EOG/EMG 硬件;调用方可传入分期数组', ext: HW },
|
|
352
|
+
async exec(inp, tid) {
|
|
353
|
+
const stages = (inp && inp.stages) || [{ s: 'N1', min: 10 }, { s: 'N2', min: 20 }, { s: 'N3', min: 25 }, { s: 'REM', min: 20 }];
|
|
354
|
+
const total = stages.reduce((a, x) => a + Number(x.min || 0), 0);
|
|
355
|
+
const dist = stages.reduce((a, x) => { a[x.s] = (a[x.s] || 0) + Number(x.min || 0); return a; }, {});
|
|
356
|
+
const deep = (dist.N3 || 0) / (total || 1);
|
|
357
|
+
const efficiency = round(clamp01(total / ((inp && inp.inBedMin) || total * 1.1)));
|
|
358
|
+
const recovery = round(clamp01(deep * 1.5 + efficiency * 0.5));
|
|
359
|
+
return { success: true, kind: 'compute', output: { stages, totalMin: total, distribution: dist, deepRatio: round(deep), efficiency, recovery, note: '分期需 PSG 硬件;统计确定性' },
|
|
360
|
+
provenance: [`[${tid}] sleep: ${total}min · 深睡比 ${round(deep)} · 效率 ${efficiency}`] };
|
|
361
|
+
} },
|
|
362
|
+
|
|
363
|
+
{ id: 'ENGINE_VOID_15', name: '归无引擎', kind: 'compute', spec: '1456 字符',
|
|
364
|
+
implements: ['归无度 = 1 - 残留度;残留项越少归无度越高(与 ATOM_VOID_WITNESS_150 同源)'],
|
|
365
|
+
async exec(inp, tid) {
|
|
366
|
+
const residues = (inp && inp.residues) || [];
|
|
367
|
+
const total = Number((inp && inp.totalItems) ?? 10);
|
|
368
|
+
const residualRate = round(clamp01(residues.length / (total || 1)));
|
|
369
|
+
return { success: true, kind: 'compute', output: { residues, totalItems: total, residualRate, voidDegree: round(1 - residualRate), rule: '归无度 = 1 - 残留率' },
|
|
370
|
+
provenance: [`[${tid}] void: 残留 ${residues.length}/${total} → 归无度 ${round(1 - residualRate)}`] };
|
|
371
|
+
} },
|
|
372
|
+
|
|
373
|
+
{ id: 'ENGINE_WORDLESS_16', name: '无言引擎', kind: 'compute', spec: '1190 字符',
|
|
374
|
+
implements: ['沉默决策:四象限(该说/该默/可说可默/不必说)→ 建议动作 + 置信度'],
|
|
375
|
+
async exec(inp, tid) {
|
|
376
|
+
const value = clamp01((inp && inp.speakingValue) ?? 0.5);
|
|
377
|
+
const risk = clamp01((inp && inp.speakingRisk) ?? 0.4);
|
|
378
|
+
const q = value >= 0.6 && risk < 0.5 ? '该说' : value < 0.4 && risk >= 0.5 ? '该默' : value >= 0.6 && risk >= 0.5 ? '可说可默' : '不必说';
|
|
379
|
+
return { success: true, kind: 'compute', output: { speakingValue: value, speakingRisk: risk, quadrant: q, confidence: round(Math.abs(value - risk)) },
|
|
380
|
+
provenance: [`[${tid}] wordless: 价值 ${value} / 风险 ${risk} → ${q}`] };
|
|
381
|
+
} },
|
|
382
|
+
|
|
383
|
+
{ id: 'ENGINE_NOTEVENVOID_17', name: '无无引擎', kind: 'compute', spec: '909 字符',
|
|
384
|
+
implements: ['二阶归无:对「归无」本身再做归无(自指校验,防止归无成为新的执念)'],
|
|
385
|
+
async exec(inp, tid) {
|
|
386
|
+
const v1 = clamp01((inp && inp.voidDegree) ?? 0.8);
|
|
387
|
+
const v2 = round(1 - Math.abs(0.5 - v1) * 2); // 越接近 0.5 越"无无",避免极端
|
|
388
|
+
return { success: true, kind: 'compute', output: { firstOrder: v1, secondOrder: v2, rule: '无无 = 1 - |0.5 - 归无度|×2:避免归无本身成为执念', note: '二阶自指校验' },
|
|
389
|
+
provenance: [`[${tid}] notevenvoid: 归无 ${v1} → 无无 ${v2}`] };
|
|
390
|
+
} },
|
|
391
|
+
|
|
392
|
+
{ id: 'ENGINE_SCHEDULER_18', name: '耦生调度引擎', kind: 'compute', spec: '7954 字符',
|
|
393
|
+
implements: ['多目标调度:优先级×资源约束×耦生度 → 排序分配(贪心 + 负载均衡)'],
|
|
394
|
+
async exec(inp, tid) {
|
|
395
|
+
const tasks = (inp && inp.tasks) || [
|
|
396
|
+
{ id: 'T1', priority: 0.9, cost: 3, coupling: 0.8 },
|
|
397
|
+
{ id: 'T2', priority: 0.6, cost: 5, coupling: 0.5 },
|
|
398
|
+
{ id: 'T3', priority: 0.75, cost: 2, coupling: 0.7 },
|
|
399
|
+
];
|
|
400
|
+
const capacity = Number((inp && inp.capacity) ?? 8);
|
|
401
|
+
const scored = tasks.map((t) => ({ ...t, score: round(clamp01(Number(t.priority) || 0) * 0.5 + clamp01(Number(t.coupling) || 0) * 0.3 - (Number(t.cost) || 0) / (capacity * 10) * 0.2) }));
|
|
402
|
+
scored.sort((a, b) => b.score - a.score);
|
|
403
|
+
let used = 0; const scheduled = [], deferred = [];
|
|
404
|
+
for (const t of scored) { if (used + (Number(t.cost) || 0) <= capacity) { scheduled.push(t); used += Number(t.cost) || 0; } else deferred.push(t); }
|
|
405
|
+
return { success: true, kind: 'compute', output: { capacity, scheduled, deferred, usedCapacity: used, utilization: round(used / (capacity || 1)), rule: 'score = 0.5·优先级 + 0.3·耦生度 - 0.2·成本/容量' },
|
|
406
|
+
provenance: [`[${tid}] scheduler: ${scheduled.length} 排入 / ${deferred.length} 延后,利用 ${round(used / (capacity || 1))}`] };
|
|
407
|
+
} },
|
|
408
|
+
];
|
|
409
|
+
|
|
410
|
+
/* ══════════ 运行时接口 ══════════ */
|
|
411
|
+
const INDEX = new Map(ENGINES.map((e) => [e.id, e]));
|
|
412
|
+
const kindOf = (id) => { const e = INDEX.get(id); return e ? e.kind : 'declared'; };
|
|
413
|
+
const getRegistry = () => ENGINES.map((e) => ({ id: e.id, name: e.name, kind: e.kind, spec: e.spec, implements: e.implements, external: e.external || null }));
|
|
414
|
+
|
|
415
|
+
async function execute(id, input) {
|
|
416
|
+
const t0 = Date.now(), tid = newTraceId();
|
|
417
|
+
const e = INDEX.get(id);
|
|
418
|
+
if (!e) return { success: false, kind: 'declared', reason: 'NOT_FOUND', error: `引擎 ${id} 未登记`, provenance: [], traceId: tid, durationMs: 0 };
|
|
419
|
+
try {
|
|
420
|
+
const r = await e.exec(input || {}, tid);
|
|
421
|
+
return { ...r, engineId: id, engineName: e.name, traceId: tid, durationMs: Date.now() - t0 };
|
|
422
|
+
} catch (err) {
|
|
423
|
+
return { success: false, kind: e.kind, error: 'THROW: ' + err.message, provenance: [`[${tid}] THROW`], engineId: id, traceId: tid, durationMs: Date.now() - t0 };
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
module.exports = { execute, kindOf, getRegistry, ENGINES, INDEX, newTraceId, _p: { build28, fairnessIndex, shannonEntropy, couplingMatrix, mutualInformationEntropy, tempComfort, lightComfort } };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 易理工程学 · 384 爻辞表(通行本《周易》经文)
|
|
3
|
+
* 结构:卦名(通行本单字名)→ [初爻辞, 二爻辞, 三爻辞, 四爻辞, 五爻辞, 上爻辞]
|
|
4
|
+
* 来源:通行本(中华书局影印本为准;异文以通行本为主)
|
|
5
|
+
* 使用:yijing 引擎断辞引用,输出时附规则编号 R-YJ-02
|
|
6
|
+
*/
|
|
7
|
+
export const YAOCI = {
|
|
8
|
+
'乾': ['潜龙勿用。', '见龙在田,利见大人。', '君子终日乾乾,夕惕若厉,无咎。', '或跃在渊,无咎。', '飞龙在天,利见大人。', '亢龙有悔。'],
|
|
9
|
+
'坤': ['履霜,坚冰至。', '直方大,不习无不利。', '含章可贞,或从王事,无成有终。', '括囊,无咎无誉。', '黄裳,元吉。', '龙战于野,其血玄黄。'],
|
|
10
|
+
'屯': ['磐桓,利居贞,利建侯。', '屯如邅如,乘马班如。匪寇婚媾,女子贞不字,十年乃字。', '即鹿无虞,惟入于林中,君子几不如舍,往吝。', '乘马班如,求婚媾,往吉,无不利。', '屯其膏,小贞吉,大贞凶。', '乘马班如,泣血涟如。'],
|
|
11
|
+
'蒙': ['发蒙,利用刑人,用说桎梏,以往吝。', '包蒙吉,纳妇吉,子克家。', '勿用取女,见金夫,不有躬,无攸利。', '困蒙,吝。', '童蒙,吉。', '击蒙,不利为寇,利御寇。'],
|
|
12
|
+
'需': ['需于郊,利用恒,无咎。', '需于沙,小有言,终吉。', '需于泥,致寇至。', '需于血,出自穴。', '需于酒食,贞吉。', '入于穴,有不速之客三人来,敬之终吉。'],
|
|
13
|
+
'讼': ['不永所事,小有言,终吉。', '不克讼,归而逋,其邑人三百户,无眚。', '食旧德,贞厉,终吉。或从王事,无成。', '不克讼,复即命,渝安贞吉。', '讼,元吉。', '或锡之鞶带,终朝三褫之。'],
|
|
14
|
+
'师': ['师出以律,否臧凶。', '在师中吉,无咎,王三锡命。', '师或舆尸,凶。', '师左次,无咎。', '田有禽,利执言,无咎。长子帅师,弟子舆尸,贞凶。', '大君有命,开国承家,小人勿用。'],
|
|
15
|
+
'比': ['有孚比之,无咎。有孚盈缶,终来有它,吉。', '比之自内,贞吉。', '比之匪人。', '外比之,贞吉。', '显比,王用三驱,失前禽,邑人不诫,吉。', '比之无首,凶。'],
|
|
16
|
+
'小畜': ['复自道,何其咎?吉。', '牵复,吉。', '舆说辐,夫妻反目。', '有孚,血去惕出,无咎。', '有孚挛如,富以其邻。', '既雨既处,尚德载,妇贞厉。月几望,君子征凶。'],
|
|
17
|
+
'履': ['素履往,无咎。', '履道坦坦,幽人贞吉。', '眇能视,跛能履,履虎尾,咥人凶。武人为于大君。', '履虎尾,愬愬,终吉。', '夬履,贞厉。', '视履考祥,其旋元吉。'],
|
|
18
|
+
'泰': ['拔茅茹,以其汇,征吉。', '包荒,用冯河,不遐遗,朋亡,得尚于中行。', '无平不陂,无往不复,艰贞无咎。勿恤其孚,于食有福。', '翩翩不富,以其邻,不戒以孚。', '帝乙归妹,以祉元吉。', '城复于隍,勿用师。自邑告命,贞吝。'],
|
|
19
|
+
'否': ['拔茅茹,以其汇,贞吉亨。', '包承,小人吉,大人否亨。', '包羞。', '有命无咎,畴离祉。', '休否,大人吉。其亡其亡,系于苞桑。', '倾否,先否后喜。'],
|
|
20
|
+
'同人': ['同人于门,无咎。', '同人于宗,吝。', '伏戎于莽,升其高陵,三岁不兴。', '乘其墉,弗克攻,吉。', '同人先号咷而后笑,大师克相遇。', '同人于郊,无悔。'],
|
|
21
|
+
'大有': ['无交害,匪咎,艰则无咎。', '大车以载,有攸往,无咎。', '公用亨于天子,小人弗克。', '匪其彭,无咎。', '厥孚交如,威如,吉。', '自天佑之,吉无不利。'],
|
|
22
|
+
'谦': ['谦谦君子,用涉大川,吉。', '鸣谦,贞吉。', '劳谦,君子有终,吉。', '无不利,撝谦。', '不富以其邻,利用侵伐,无不利。', '鸣谦,利用行师征邑国。'],
|
|
23
|
+
'豫': ['鸣豫,凶。', '介于石,不终日,贞吉。', '盱豫,悔。迟有悔。', '由豫,大有得。勿疑,朋盍簪。', '贞疾,恒不死。', '冥豫,成有渝,无咎。']
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 384 爻辞表 第二批(17-32 卦:随~恒)
|
|
3
|
+
*/
|
|
4
|
+
export const YAOCI_2 = {
|
|
5
|
+
'随': ['官有渝,贞吉。出门交有功。', '系小子,失丈夫。', '系丈夫,失小子。随有求得,利居贞。', '随有获,贞凶。有孚在道,以明,何咎。', '孚于嘉,吉。', '拘系之,乃从维之。王用亨于西山。'],
|
|
6
|
+
'蛊': ['干父之蛊,有子,考无咎,厉终吉。', '干母之蛊,不可贞。', '干父之蛊,小有悔,无大咎。', '裕父之蛊,往见吝。', '干父之蛊,用誉。', '不事王侯,高尚其事。'],
|
|
7
|
+
'临': ['咸临,贞吉。', '咸临,吉无不利。', '甘临,无攸利。既忧之,无咎。', '至临,无咎。', '知临,大君之宜,吉。', '敦临,吉无咎。'],
|
|
8
|
+
'观': ['童观,小人无咎,君子吝。', '窥观,利女贞。', '观我生,进退。', '观国之光,利用宾于王。', '观我生,君子无咎。', '观其生,君子无咎。'],
|
|
9
|
+
'噬嗑': ['屦校灭趾,无咎。', '噬肤灭鼻,无咎。', '噬腊肉,遇毒。小吝,无咎。', '噬干胏,得金矢,利艰贞,吉。', '噬干肉,得黄金,贞厉,无咎。', '何校灭耳,凶。'],
|
|
10
|
+
'贲': ['贲其趾,舍车而徒。', '贲其须。', '贲如濡如,永贞吉。', '贲如皤如,白马翰如,匪寇婚媾。', '贲于丘园,束帛戋戋,吝,终吉。', '白贲,无咎。'],
|
|
11
|
+
'剥': ['剥床以足,蔑贞凶。', '剥床以辨,蔑贞凶。', '剥之,无咎。', '剥床以肤,凶。', '贯鱼,以宫人宠,无不利。', '硕果不食,君子得舆,小人剥庐。'],
|
|
12
|
+
'复': ['不远复,无祗悔,元吉。', '休复,吉。', '频复,厉,无咎。', '中行独复。', '敦复,无悔。', '迷复,凶,有灾眚。用行师,终有大败,以其国君凶,至于十年不克征。'],
|
|
13
|
+
'无妄': ['无妄,往吉。', '不耕获,不菑畬,则利有攸往。', '无妄之灾,或系之牛,行人之得,邑人之灾。', '可贞,无咎。', '无妄之疾,勿药有喜。', '无妄,行有眚,无攸利。'],
|
|
14
|
+
'大畜': ['有厉,利已。', '舆说輹。', '良马逐,利艰贞。曰闲舆卫,利有攸往。', '童牛之牿,元吉。', '豮豕之牙,吉。', '何天之衢,亨。'],
|
|
15
|
+
'颐': ['舍尔灵龟,观我朵颐,凶。', '颠颐,拂经,于丘颐,征凶。', '拂颐,贞凶,十年勿用,无攸利。', '颠颐吉,虎视眈眈,其欲逐逐,无咎。', '拂经,居贞吉,不可涉大川。', '由颐,厉吉,利涉大川。'],
|
|
16
|
+
'大过': ['藉用白茅,无咎。', '枯杨生稊,老夫得其女妻,无不利。', '栋桡,凶。', '栋隆,吉。有它吝。', '枯杨生华,老妇得其士夫,无咎无誉。', '过涉灭顶,凶,无咎。'],
|
|
17
|
+
'坎': ['习坎,入于坎窞,凶。', '坎有险,求小得。', '来之坎坎,险且枕,入于坎窞,勿用。', '樽酒簋贰,用缶,纳约自牖,终无咎。', '坎不盈,祗既平,无咎。', '系用徽纆,寘于丛棘,三岁不得,凶。'],
|
|
18
|
+
'离': ['履错然,敬之,无咎。', '黄离,元吉。', '日昃之离,不鼓缶而歌,则大耋之嗟,凶。', '突如其来如,焚如,死如,弃如。', '出涕沱若,戚嗟若,吉。', '王用出征,有嘉折首,获匪其丑,无咎。'],
|
|
19
|
+
'咸': ['咸其拇。', '咸其腓,凶。居吉。', '咸其股,执其随,往吝。', '贞吉悔亡,憧憧往来,朋从尔思。', '咸其脢,无悔。', '咸其辅颊舌。'],
|
|
20
|
+
'恒': ['浚恒,贞凶,无攸利。', '悔亡。', '不恒其德,或承之羞,贞吝。', '田无禽。', '恒其德,贞,妇人吉,夫子凶。', '振恒,凶。']
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 384 爻辞表 第三批(33-48 卦:遁~井)
|
|
3
|
+
*/
|
|
4
|
+
export const YAOCI_3 = {
|
|
5
|
+
'遁': ['遁尾,厉,勿用有攸往。', '执之用黄牛之革,莫之胜说。', '系遁,有疾厉,畜臣妾吉。', '好遁,君子吉,小人否。', '嘉遁,贞吉。', '肥遁,无不利。'],
|
|
6
|
+
'大壮': ['壮于趾,征凶,有孚。', '贞吉。', '小人用壮,君子用罔,贞厉。羝羊触藩,羸其角。', '贞吉悔亡,藩决不羸,壮于大舆之輹。', '丧羊于易,无悔。', '羝羊触藩,不能退,不能遂,无攸利,艰则吉。'],
|
|
7
|
+
'晋': ['晋如摧如,贞吉。罔孚,裕无咎。', '晋如愁如,贞吉。受兹介福,于其王母。', '众允,悔亡。', '晋如鼫鼠,贞厉。', '悔亡,失得勿恤,往吉,无不利。', '晋其角,维用伐邑,厉吉无咎,贞吝。'],
|
|
8
|
+
'明夷': ['明夷于飞,垂其翼。君子于行,三日不食。有攸往,主人有言。', '明夷,夷于左股,用拯马壮,吉。', '明夷于南狩,得其大首,不可疾贞。', '入于左腹,获明夷之心,于出门庭。', '箕子之明夷,利贞。', '不明晦,初登于天,后入于地。'],
|
|
9
|
+
'家人': ['闲有家,悔亡。', '无攸遂,在中馈,贞吉。', '家人嗃嗃,悔厉吉。妇子嘻嘻,终吝。', '富家,大吉。', '王假有家,勿恤,吉。', '有孚威如,终吉。'],
|
|
10
|
+
'睽': ['悔亡。丧马勿逐,自复。见恶人,无咎。', '遇主于巷,无咎。', '见舆曳,其牛掣,其人天且劓,无初有终。', '睽孤,遇元夫,交孚,厉无咎。', '悔亡。厥宗噬肤,往何咎。', '睽孤,见豕负涂,载鬼一车,先张之弧,后说之弧,匪寇婚媾,往遇雨则吉。'],
|
|
11
|
+
'蹇': ['往蹇,来誉。', '王臣蹇蹇,匪躬之故。', '往蹇,来反。', '往蹇,来连。', '大蹇,朋来。', '往蹇,来硕,吉。利见大人。'],
|
|
12
|
+
'解': ['无咎。', '田获三狐,得黄矢,贞吉。', '负且乘,致寇至,贞吝。', '解而拇,朋至斯孚。', '君子维有解,吉,有孚于小人。', '公用射隼于高墉之上,获之,无不利。'],
|
|
13
|
+
'损': ['已事遄往,无咎,酌损之。', '利贞,征凶,弗损益之。', '三人行,则损一人;一人行,则得其友。', '损其疾,使遄有喜,无咎。', '或益之十朋之龟,弗克违,元吉。', '弗损益之,无咎,贞吉,利有攸往,得臣无家。'],
|
|
14
|
+
'益': ['利用为大作,元吉,无咎。', '或益之十朋之龟,弗克违,永贞吉。王用享于帝,吉。', '益之用凶事,无咎。有孚中行,告公用圭。', '中行告公从,利用为依迁国。', '有孚惠心,勿问元吉。有孚惠我德。', '莫益之,或击之,立心勿恒,凶。'],
|
|
15
|
+
'夬': ['壮于前趾,往不胜为咎。', '惕号,莫夜有戎,勿恤。', '壮于頄,有凶。君子夬夬,独行遇雨,若濡有愠,无咎。', '臀无肤,其行次且。牵羊悔亡,闻言不信。', '苋陆夬夬,中行无咎。', '无号,终有凶。'],
|
|
16
|
+
'姤': ['系于金柅,贞吉。有攸往,见凶,羸豕孚蹢躅。', '包有鱼,无咎,不利宾。', '臀无肤,其行次且,厉,无大咎。', '包无鱼,起凶。', '以杞包瓜,含章,有陨自天。', '姤其角,吝,无咎。'],
|
|
17
|
+
'萃': ['有孚不终,乃乱乃萃。若号,一握为笑,勿恤,往无咎。', '引吉,无咎,孚乃利用禴。', '萃如嗟如,无攸利。往无咎,小吝。', '大吉,无咎。', '萃有位,无咎。匪孚,元永贞,悔亡。', '赍咨涕洟,无咎。'],
|
|
18
|
+
'升': ['允升,大吉。', '孚乃利用禴,无咎。', '升虚邑。', '王用亨于岐山,吉,无咎。', '贞吉,升阶。', '冥升,利于不息之贞。'],
|
|
19
|
+
'困': ['臀困于株木,入于幽谷,三岁不觌。', '困于酒食,朱绂方来,利用亨祀,征凶,无咎。', '困于石,据于蒺藜,入于其宫,不见其妻,凶。', '来徐徐,困于金车,吝,有终。', '劓刖,困于赤绂,乃徐有说,利用祭祀。', '困于葛藟,于臲卼,曰动悔。有悔,征吉。'],
|
|
20
|
+
'井': ['井泥不食,旧井无禽。', '井谷射鲋,瓮敝漏。', '井渫不食,为我心恻。可用汲,王明,并受其福。', '井甃,无咎。', '井冽,寒泉食。', '井收勿幕,有孚元吉。']
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 384 爻辞表 第四批(49-64 卦:革~未济)
|
|
3
|
+
*/
|
|
4
|
+
export const YAOCI_4 = {
|
|
5
|
+
'革': ['巩用黄牛之革。', '巳日乃革之,征吉,无咎。', '征凶,贞厉。革言三就,有孚。', '悔亡,有孚改命,吉。', '大人虎变,未占有孚。', '君子豹变,小人革面,征凶,居贞吉。'],
|
|
6
|
+
'鼎': ['鼎颠趾,利出否。得妾以其子,无咎。', '鼎有实,我仇有疾,不我能即,吉。', '鼎耳革,其行塞,雉膏不食。方雨亏悔,终吉。', '鼎折足,覆公餗,其形渥,凶。', '鼎黄耳金铉,利贞。', '鼎玉铉,大吉,无不利。'],
|
|
7
|
+
'震': ['震来虩虩,后笑言哑哑,吉。', '震来厉,亿丧贝,跻于九陵,勿逐,七日得。', '震苏苏,震行无眚。', '震遂泥。', '震往来厉,亿无丧,有事。', '震索索,视矍矍,征凶。震不于其躬,于其邻,无咎。婚媾有言。'],
|
|
8
|
+
'艮': ['艮其趾,无咎,利永贞。', '艮其腓,不拯其随,其心不快。', '艮其限,列其夤,厉薰心。', '艮其身,无咎。', '艮其辅,言有序,悔亡。', '敦艮,吉。'],
|
|
9
|
+
'渐': ['鸿渐于干,小子厉,有言,无咎。', '鸿渐于磐,饮食衎衎,吉。', '鸿渐于陆,夫征不复,妇孕不育,凶。利御寇。', '鸿渐于木,或得其桷,无咎。', '鸿渐于陵,妇三岁不孕,终莫之胜,吉。', '鸿渐于陆,其羽可用为仪,吉。'],
|
|
10
|
+
'归妹': ['归妹以娣,跛能履,征吉。', '眇能视,利幽人之贞。', '归妹以须,反归以娣。', '归妹愆期,迟归有时。', '帝乙归妹,其君之袂不如其娣之袂良。月几望,吉。', '女承筐无实,士刲羊无血,无攸利。'],
|
|
11
|
+
'丰': ['遇其配主,虽旬无咎,往有尚。', '丰其蔀,日中见斗,往得疑疾,有孚发若,吉。', '丰其沛,日中见沫,折其右肱,无咎。', '丰其蔀,日中见斗,遇其夷主,吉。', '来章,有庆誉,吉。', '丰其屋,蔀其家,窥其户,阒其无人,三岁不觌,凶。'],
|
|
12
|
+
'旅': ['旅琐琐,斯其所取灾。', '旅即次,怀其资,得童仆贞。', '旅焚其次,丧其童仆,贞厉。', '旅于处,得其资斧,我心不快。', '射雉一矢亡,终以誉命。', '鸟焚其巢,旅人先笑后号咷。丧牛于易,凶。'],
|
|
13
|
+
'巽': ['进退,利武人之贞。', '巽在床下,用史巫纷若,吉,无咎。', '频巽,吝。', '悔亡,田获三品。', '贞吉悔亡,无不利。无初有终。先庚三日,后庚三日,吉。', '巽在床下,丧其资斧,贞凶。'],
|
|
14
|
+
'兑': ['和兑,吉。', '孚兑,吉,悔亡。', '来兑,凶。', '商兑未宁,介疾有喜。', '孚于剥,有厉。', '引兑。'],
|
|
15
|
+
'涣': ['用拯马壮,吉。', '涣奔其机,悔亡。', '涣其躬,无悔。', '涣其群,元吉。涣有丘,匪夷所思。', '涣汗其大号,涣王居,无咎。', '涣其血,去逖出,无咎。'],
|
|
16
|
+
'节': ['不出户庭,无咎。', '不出门庭,凶。', '不节若,则嗟若,无咎。', '安节,亨。', '甘节,吉,往有尚。', '苦节,贞凶,悔亡。'],
|
|
17
|
+
'中孚': ['虞吉,有它不燕。', '鸣鹤在阴,其子和之。我有好爵,吾与尔靡之。', '得敌,或鼓或罢,或泣或歌。', '月几望,马匹亡,无咎。', '有孚挛如,无咎。', '翰音登于天,贞凶。'],
|
|
18
|
+
'小过': ['飞鸟以凶。', '过其祖,遇其妣。不及其君,遇其臣,无咎。', '弗过防之,从或戕之,凶。', '无咎,弗过遇之。往厉必戒,勿用永贞。', '密云不雨,自我西郊。公弋取彼在穴。', '弗遇过之,飞鸟离之,凶,是谓灾眚。'],
|
|
19
|
+
'既济': ['曳其轮,濡其尾,无咎。', '妇丧其茀,勿逐,七日得。', '高宗伐鬼方,三年克之,小人勿用。', '繻有衣袽,终日戒。', '东邻杀牛,不如西邻之禴祭,实受其福。', '濡其首,厉。'],
|
|
20
|
+
'未济': ['濡其尾,吝。', '曳其轮,贞吉。', '未济,征凶,利涉大川。', '贞吉,悔亡。震用伐鬼方,三年有赏于大国。', '贞吉,无悔。君子之光,有孚,吉。', '有孚于饮酒,无咎。濡其首,有孚失是。']
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 384 爻辞表汇总(通行本《周易》经文)
|
|
3
|
+
*/
|
|
4
|
+
import { YAOCI } from './yaoci-1.js';
|
|
5
|
+
import { YAOCI_2 } from './yaoci-2.js';
|
|
6
|
+
import { YAOCI_3 } from './yaoci-3.js';
|
|
7
|
+
import { YAOCI_4 } from './yaoci-4.js';
|
|
8
|
+
|
|
9
|
+
export const YAOCI_ALL = { ...YAOCI, ...YAOCI_2, ...YAOCI_3, ...YAOCI_4 };
|
|
10
|
+
|
|
11
|
+
/** 校验:64 卦 × 6 爻 = 384 条 */
|
|
12
|
+
export function verifyYaoci() {
|
|
13
|
+
const names = Object.keys(YAOCI_ALL);
|
|
14
|
+
const total = names.reduce((s, n) => s + YAOCI_ALL[n].length, 0);
|
|
15
|
+
const bad = names.filter(n => YAOCI_ALL[n].length !== 6);
|
|
16
|
+
return { guaCount: names.length, total, bad };
|
|
17
|
+
}
|