A local-first TypeScript engine for turning outputs from multiple traditional divination systems into explicit, auditable signals and conservative consensus decisions.
Experimental research software. It models calculation rules and combines caller-supplied interpretations; it does not establish predictive accuracy or scientific validity. Do not use it as medical, legal, financial, or other professional advice. Never commit real personal birth data.
- Local calculation engines for Bazi, Ziwei, Qimen, Daliuren, Taiyi, Meihua, Liuren (六壬), Liuyao (六爻), and Jinkoujue (金口诀).
- A common
PredictionSignalcontract for caller-supplied interpretation rules. - Per-system aggregation so multiple rules from one system do not silently become multiple independent votes.
- Explicit core and secondary system tiers; the five core voting systems are Qimen, Daliuren, Taiyi, Ziwei, and Bazi.
- Abstention on ties, weak support, or unresolved internal disagreement.
- Evidence, warnings, participating systems, and calculation metadata in the result.
- A prospective shadow-sample log with a SHA-256 hash chain for recording locked readings before outcomes are observed.
The calculation engines do not ship with a hidden interpretation model. Rules are passed in by the caller so that each conclusion remains inspectable and testable.
Requires Node.js 22 or newer.
npm ci
npm test
npm run typecheckThe public repository ships the engine and its tests; two local-only tests that depend on the internal
scripts/classicstoolchain are intentionally not included, so the publicnpm testcount (601) is slightly lower than the full local suite (609).
The public API is re-exported from src/index.ts:
import { ConsensusEngine, type PredictionSignal } from "./src/index.ts";
const signals: PredictionSignal[] = [
{
system: "bazi",
domain: "career",
direction: "positive",
intensity: 0.8,
confidence: 0.7,
evidence: ["example rule"],
},
{
system: "ziwei",
domain: "career",
direction: "positive",
intensity: 0.7,
confidence: 0.6,
evidence: ["another example rule"],
},
];
const [decision] = new ConsensusEngine().decide(signals);
console.log(decision.direction, decision.evidence);Use BaziEngine, ZiweiEngine, QimenEngine, DaliurenEngine, TaiyiEngine, or MeihuaEngine to calculate a chart. To produce prediction signals, pass explicit rules implementing the corresponding *Rule interface. PredictionSession can run registered engines and separate core votes from supplementary evidence.
For a single-question pipeline, buildFullReading(questionText, options) runs the five core engines at a common time anchor and returns structured readings, dimension signals, consensus, and a plain-language verdict.
src/
bazi.ts Bazi adapter and chart normalization
ziwei.ts Ziwei adapter and chart normalization
qimen.ts Qimen board adapter and normalization
meihua.ts Meihua number-to-hexagram calculator
consensus.ts auditable signal aggregation and abstention
session.ts multi-engine orchestration
systems.ts core/secondary system registry
full-reading.ts single-question five-engine pipeline
index.ts public export surface
test/ deterministic unit and integration tests
.github/ continuous integration workflow
The core tier names Qimen, Daliuren, Taiyi, Ziwei, and Bazi. Naming a tier does not imply that an adapter or interpretation rule is implemented.
The engine accepts normalized dates, times, gender, and optional location information. Tests use fixed, synthetic examples only. Runtime calculation is local after dependencies are installed; the project does not send chart inputs to a service.
Third-party runtime dependencies are listed in package.json and are MIT-licensed at the versions used by this project. Their own repositories and licenses remain authoritative.