Install
openclaw skills install bazi-pillars-from-datetimeUse when a task involves deriving bazi chart data from Gregorian datetime and timezone, or generating a grounded user-language analysis from an existing chart JSON plus the local knowledge files.
openclaw skills install bazi-pillars-from-datetime这个 skill 现在包含两个明确模式,必须先判断当前任务属于哪一种:
chart 模式:把公历日期时间转换成可复现的八字排盘结果。analysis 模式:基于已有盘面 JSON、用户问题和本地知识文件生成适配用户语言的分析。不要把两种模式混用。排盘负责事实,分析负责表达与建议。
chart 模式analysis 模式chart 盘面 JSON,用户要求分析事业、婚恋、健康、整体趋势或指定年份。knowledge.md 的解释素材,并遵循 prompt.md 的输出结构。chart,再把结果传给 analysis。chart,不要重复排盘。main.py 为准。chart输出一个确定性、可复现、可被程序消费的八字 JSON 合同。该模式不生成用户面向的自然语言分析。
输入为 JSON,对应 main.py 从标准输入读取的 payload:
{
"datetime": "YYYY-MM-DDTHH:MM:SS",
"timezone": "IANA/Timezone",
"location": {
"name": "City/Region",
"longitude": 0.0,
"latitude": 0.0,
"lookup_mode": "auto|local|online",
"lookup_provider": "nominatim|amap|tencent",
"lookup_key": "optional-api-key",
"lookup_path": "/path/to/cities.json",
"cache_path": "/path/to/city_cache.json",
"lookup_timeout": 6
},
"gender": "female|male|other",
"rules": {
"year_boundary": "lichun",
"month_rule": "solar_terms",
"day_boundary": "00:00",
"time_correction": "mean_solar_time",
"require_dayun": false
},
"flows": {
"datetime": "YYYY-MM-DDTHH:MM:SS",
"timezone": "IANA/Timezone"
},
"mode": "strict"
}
datetime:本地日期时间字符串,不带 offset。timezone:IANA 时区,例如 Asia/Shanghai。location:当 time_correction 为 mean_solar_time 或 true_solar_time 时必填。gender:当需要计算大运且 require_dayun=true 时必填。flows.datetime:只有请求流年/流月/流日时才需要。rules.year_boundary 默认 lichunrules.month_rule 默认 solar_termsrules.day_boundary 默认 00:00rules.time_correction 默认 mean_solar_timerules.require_dayun 默认 falsemode 默认 strictlocation.lookup_provider 默认 nominatimlocation.lookup_path 默认 ./cities.jsonlocation.cache_path 默认 ./city_cache.jsonlocation.lookup_timeout 默认 6longitude 和 latitude。name 时,按 lookup_mode 解析:
local:仅查本地映射。online:仅查在线地理编码。auto:先本地,后在线。amap 和 tencent 需要 lookup_key,也可走环境变量 BAZI_GEOCODE_KEY。BAZI_CITY_MAP_PATHBAZI_CITY_CACHE_PATHBAZI_GEOCODE_PROVIDERBAZI_GEOCODE_KEYBAZI_GEOCODE_TIMEOUT立春00:00mean_solar_time:只做经度修正true_solar_time:经度修正 + 均时差require_dayun:默认 false1984-02-02 为 丙寅日strict 模式下,缺少关键时间信息应直接报错datetime 与 timezonerules 决定是否做平太阳时或真太阳时修正flows{
"ok": true,
"bazi": {
"year": { "tg": "...", "dz": "..." },
"month": { "tg": "...", "dz": "..." },
"day": { "tg": "...", "dz": "..." },
"hour": { "tg": "...", "dz": "..." }
},
"dayun": {
"direction": "forward|backward",
"start_age_years": 0.0,
"start_age_months": 0.0,
"start_datetime": "YYYY-MM-DDTHH:MM:SS",
"cycles": [
{
"index": 1,
"tg": "...",
"dz": "...",
"gz": "...",
"start_age_years": 0.0,
"start_datetime": "YYYY-MM-DDTHH:MM:SS",
"end_datetime": "YYYY-MM-DDTHH:MM:SS"
}
]
},
"flows": {
"datetime": "YYYY-MM-DDTHH:MM:SS",
"year": { "tg": "...", "dz": "...", "gz": "..." },
"month": { "tg": "...", "dz": "...", "gz": "..." },
"day": { "tg": "...", "dz": "...", "gz": "..." }
},
"solar_terms": {
"prev": { "name": "...", "datetime": "..." },
"next": { "name": "...", "datetime": "..." }
},
"meta": {
"timezone": "IANA/Timezone",
"rules_used": {
"year_boundary": "lichun",
"month_rule": "solar_terms",
"day_boundary": "00:00",
"time_correction": "mean_solar_time",
"require_dayun": false
},
"true_solar_time": {
"method": "mean_solar_time|true_solar_time",
"datetime": "...",
"delta_minutes": 0.0,
"equation_of_time_minutes": 0.0,
"longitude_correction_minutes": 0.0
},
"location": {
"name": "...",
"longitude": 0.0,
"latitude": 0.0
},
"confidence": "high|medium|low",
"notes": []
}
}
{
"ok": false,
"error": {
"code": "INVALID_DATETIME|INVALID_TIMEZONE|INVALID_LOCATION|MISSING_DATE|MISSING_TIMEZONE|MISSING_LOCATION|MISSING_GENDER",
"missing": ["date|time|timezone|location|gender"],
"message": "Human-readable error for agent use"
}
}
MISSING_DATE:缺少 datetimeINVALID_DATETIME:日期时间格式不合法MISSING_TIMEZONE:缺少 timezoneINVALID_TIMEZONE:时区无效MISSING_LOCATION:需要地点但无法解析MISSING_GENDER:请求大运时缺少性别00:00 日界入口文件:main.py
echo '{"datetime":"1998-08-12T15:30:00","timezone":"Asia/Shanghai","location":{"name":"广州"},"rules":{"time_correction":"true_solar_time"}}' | python3 main.py
analysis基于盘面事实与本地知识库,生成可对话展示、语言跟随用户的分析报告。该模式不重新计算排盘,只消费已有 chart 数据。
user_query:用户当前问题,可为简体中文或其他语言。chart:由 main.py 产生的排盘 JSON。knowledge:解释和建议素材,来源于 knowledge.md。语言选择优先级如下:
user_query 的主要语言补充约束:
chartknowledge.md当知识库与盘面事实冲突时,以 chart 为准,并明确说明不确定性。
chart 是否包含 dayun、flows、meta.confidence 等关键字段。输出使用 Markdown,并固定以下标题顺序:
盘面摘要本次问题结论时间轴(仅在用户询问年份或趋势时使用)建议依据与补充可信度与缺失信息chart.flows.year.gz 可用时展示,否则写“流年未指定”。user_query,不要泛泛而谈。knowledge.md 的条目或章节。chart.meta.confidence。chart 事实做判断。prompt.mdknowledge.mdchart,再基于 chart 输出分析。chart 关键字段缺失,只说明限制,不在分析阶段偷偷补算。chartanalysischart 然后 analysis