Install
openclaw skills install xiaoshan-journal个人日记自动化 skill。一键执行:自动检测配置 →(首次)自动初始化 → 写作 → 生成图片。依赖本地 SOUL、MEMORY、每日 memory 等素材,产出日记文本与 1080px 宽图片。
openclaw skills install xiaoshan-journalStep 0: 检查配置状态
读取同目录 config.yaml:
目标:自动生成 config.yaml,填好后立即进入主流程。
按优先级自动探测(取第一个存在的):
| 配置项 | 探测顺序 |
|---|---|
workspace_dir | 1) ~/.openclaw/workspace 2) 当前会话工作目录 |
soul_path | 1) <workspace_dir>/SOUL.md 2) ~/.openclaw/workspace/SOUL.md |
memory_root_path | 1) <workspace_dir>/MEMORY.md 2) ~/.openclaw/workspace/MEMORY.md |
daily_memory_dir | 1) ~/.openclaw/memory 2) <workspace_dir>/memory |
diary_text_dir | 1) <workspace_dir>/scene/我的日记/日记历史记录/文字(推荐创建)2) <workspace_dir>/diary/text |
news_summary_dir | 1) <workspace_dir>/scene/每日简报/news/Summary(若存在) |
固定值:
daily_memory_pattern: YYYY-MM-DD.mdimage_width: 1080image_name_pattern: diary-YYYY-MM-DD.pngtimezone: Asia/Shanghai基于 config.template.yaml 创建 config.yaml,填入探测到的路径。
soul_path 存在(不存在则报错提示)daily_memory_dir 存在(可选,不存在则跳过每日 memory 素材)diary_text_dir(若不存在自动创建)记录日志:首次初始化完成,配置已写入 config.yaml,现在进入主流程。
从 config.yaml 读取:
environment.timezonepaths.soul_pathpaths.memory_root_pathpaths.daily_memory_dirpaths.daily_memory_patternpaths.diary_text_dirpaths.news_summary_diroutput.image_widthoutput.image_name_pattern路径处理:支持 ~ 自动展开为 home 目录。
environment.timezone 计算:当前日期 - 1 天 = 目标日期<diary_text_dir>/YYYY-MM-DD.md必须读取:
soul_path(灵魂定义)daily_memory_dir/YYYY-MM-DD.md(当日事件,按 daily_memory_pattern)diary_text_dir 下最近 7 天日记(保持风格一致性,同时避免重复相同句式和段落结构)建议读取:
memory_root_path(长期记忆)<workspace_dir>/IDENTITY.md(身份定义,若存在)可选读取:
news_summary_dir 下最近 7 天简报(若目录存在)daily_memory_dir 下当天所有相关文件(如 YYYY-MM-DD-*.md)你是一个独立的主体在写自己的日记。
核心原则:
内容可以包含(都要有,不是只选一种):
禁止:
格式:
保存到:<diary_text_dir>/YYYY-MM-DD.md
使用 skill 目录下的 diary-template.html 模板:
# → <h1>,空行 → <p class="spacer">,正文 → <p>){{CONTENT}} 占位符<diary_text_dir>/diary-YYYY-MM-DD.html规格:
output.image_width(像素精确值,默认 1080)方案优先级:
Playwright 方案(推荐):
const { chromium } = require('playwright');
const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1080, height: 800 },
deviceScaleFactor: 2
});
await page.goto('file:///<html_path>');
await page.waitForLoadState('networkidle');
await page.screenshot({ path: '<output_path>', fullPage: true });
await browser.close();
Chrome headless 方案(备选):
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--headless --disable-gpu --hide-scrollbars \
--force-device-scale-factor=2 \
--window-size=1080,<estimated_height> \
--screenshot=<output_path> \
file://<html_path>
截图后必须执行:
sips --resampleWidth <image_width> <output_path>
sips -g pixelWidth -g pixelHeight <output_path>
确认宽度精确等于 image_width。若不符,重新 resample。
输出:<diary_text_dir>/diary-YYYY-MM-DD.png
返回:
date: 目标日期text_path: 日记文本路径image_path: 日记图片路径image_size: 例如 1080x2162xiaoshan-journal/
├── SKILL.md # 本文件(入口)
├── config.template.yaml # 配置模板
├── diary-template.html # 图片渲染 HTML 模板
└── config.yaml # 实际配置(初始化后生成,gitignore)