Xiaoshan journal

From dvcrn/openclaw-skills-marketplace · View interactive version

Xiaoshan journal is an AI agent skill from the GitHub repository dvcrn/openclaw-skills-marketplace. 个人日记自动化 skill。一键执行:自动检测配置 →(首次)自动初始化 → 写作 → 生成图片。依赖本地 SOUL、MEMORY、每日 memory 等素材,产出日记文本与 1080px 宽图片。

How to use this skill

Skill file

日记工作流(一键执行)

入口判断(自动分支)

Step 0: 检查配置状态

读取同目录 config.yaml:


【首次初始化流程】(仅首次执行)

目标:自动生成 config.yaml,填好后立即进入主流程。

0.1 探测环境路径

按优先级自动探测(取第一个存在的):

| 配置项 | 探测顺序 |

|--------|----------|

| 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(若存在)|

固定值:

0.2 生成 config.yaml

基于 config.template.yaml 创建 config.yaml,填入探测到的路径。

0.3 校验并创建目录

0.4 完成初始化

记录日志:首次初始化完成,配置已写入 config.yaml,现在进入主流程。


【主流程】(每次执行)

Step 1: 读取配置

从 config.yaml 读取:

路径处理:支持 ~ 自动展开为 home 目录。

Step 2: 计算目标日期并检查

Step 3: 收集素材

必须读取:

建议读取:

可选读取:

Step 4: 写作

你是一个独立的主体在写自己的日记。

核心原则:

内容可以包含(都要有,不是只选一种):

禁止:

格式:

保存到:<diary_text_dir>/YYYY-MM-DD.md

Step 5: 生成图片

5.1 生成 HTML

使用 skill 目录下的 diary-template.html 模板:

5.2 截图

规格:

方案优先级:

  1. Option A: Playwright(推荐)
  2. Option B: Chrome headless
  3. Option C: Python PIL(最终兜底)

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>
5.3 宽度校验与修正

截图后必须执行:

sips --resampleWidth <image_width> <output_path>
sips -g pixelWidth -g pixelHeight <output_path>

确认宽度精确等于 image_width。若不符,重新 resample。

输出:<diary_text_dir>/diary-YYYY-MM-DD.png

Step 6: 返回结果

返回:


依赖说明


文件结构

xiaoshan-journal/
├── SKILL.md              # 本文件(入口)
├── config.template.yaml  # 配置模板
├── diary-template.html   # 图片渲染 HTML 模板
└── config.yaml           # 实际配置(初始化后生成,gitignore)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.