docs: 修复备份任务记录 + 精简 TOOLS.md

This commit is contained in:
2026-03-24 10:15:57 -07:00
parent df7cdffc13
commit 8d416abfa0
3 changed files with 97 additions and 4 deletions

View File

@@ -62,14 +62,22 @@ _这份文件记录持续性项目和重要状态跨会话保留。_
### 2. 工作区自动备份
**状态**: 运行中
**创建**: 2026-03-06
**更新**: 2026-03-12移除脚本改用直接 git 命令
**更新**: 2026-03-24修复agentTurn → systemEvent
**配置**:
- Cron: 每天 00:00PST
- 命令: `git add -A && git commit -m "auto: $(date)" && git push`
- Cron ID: `53c0b2a6-e3b3-4a1d-b2a8-66e216fad753`
- Schedule: 每天 00:00PST
- Target: `main` session通过 heartbeat 触发)
- Payload: `systemEvent` 直接执行 shell
- 远程: `ssh://git@luyanxin.com:8103/lyx/youlu-openclaw-workspace.git`
**关键修复** (2026-03-24):
- **问题**: 原配置使用 `agentTurn`,把 shell 命令发给 kimi-k2.5LLM 只是"理解"了命令意思并编造了"备份完成"回复,**没有真正执行 git**
- **解决**: 改为 `systemEvent` + `exec:` 前缀,直接执行不经过 LLM
- **语法**: `exec:cd ... && git add -A && git diff --cached --quiet || (git commit -m "Daily backup $(date +"%Y-%m-%d %H:%M:%S")" && git push)`
- **注意日期转义**: 外层单引号 + 内层双引号保护 `+` 符号
**功能**:
- 自动提交所有变更到 git
- 自动提交所有变更到 git(包括未追踪文件)
- 自动推送到 origin/main**无需确认**
- 无变更时静默(无通知)
- 仅出错时报告

View File

@@ -155,6 +155,23 @@ khal list today 7d
**同步**: 发送/回复/待办变更后自动 `vdirsyncer sync`,心跳也会定期同步
**注意**: 发送日历邀请属于对外邮件,需先确认
### OpenClaw Cron 定时任务
**规则**: 确定性 shell 任务用 `systemEvent`,需要 LLM 判断的用 `agentTurn`
```bash
# systemEvent 直接执行(不走 LLM
openclaw cron edit <id> --session main \
--system-event 'exec:cd /path && command'
# 查看/测试
openclaw cron list
openclaw cron runs --id <id>
openclaw cron run <id> # 立即触发
```
**注意**: kimi-k2.5 工具使用弱,`agentTurn` 容易产生"已完成"幻觉。详见 MEMORY.md 2026-03-24 备份修复记录。
---
Add whatever helps you do your job. This is your cheat sheet.

68
memory/2026-03-24.md Normal file
View File

@@ -0,0 +1,68 @@
# 2026-03-24 — 修复工作区备份 Cron 任务
## 问题发现
小鹿问"昨天晚上的工作区备份执行了吗",检查发现:
- Cron 日志显示"执行成功"
- 但 git log 最后一次备份是 3月23日 10:02
- 工作区有未提交的变更calendars/*.ics, memory/*.md
## 根本原因
备份任务配置为 `agentTurn` 类型:
```json
{
"kind": "agentTurn",
"message": "cd ... && git add -A && git commit ...",
"lightContext": true
}
```
这意味着 shell 命令被当作**文本提示**发给 kimi-k2.5LLM 只是"理解"了命令的含义,然后编造了"备份完成"的回复,**根本没有调用工具执行 git**。
对比邮件处理器 digest 任务(工作正常):
```json
{
"kind": "systemEvent",
"text": "exec:cd ... && ./email-processor.sh digest"
}
```
## 修复过程
### 1. 切换到 systemEvent
```bash
openclaw cron edit 53c0b2a6-e3b3-4a1d-b2a8-66e216fad753 \
--session main \
--system-event 'exec:cd /home/lyx/.openclaw/workspace && git add -A && git diff --cached --quiet || (git commit -m "Daily backup $(date +"%Y-%m-%d %H:%M:%S")" && git push origin main)'
```
关键改动:
- `agentTurn``systemEvent`(直接执行,不走 LLM
- `isolated``main`(在主会话通过 heartbeat 执行)
- `exec:` 前缀确保 shell 直接执行
### 2. 日期转义问题
最初尝试时 `$(date +%Y-%m-%d %H:%M:%S)` 报错,因为 `%` 被 shell 特殊处理。
解决方案:外层单引号 + 内层双引号:
```
'... "$(date +"%Y-%m-%d %H:%M:%S")" ...'
```
### 3. 验证成功
手动触发测试后git log 显示:
```
33f0dac Daily backup
...(后续提交)
df7cdff Daily backup 2026-03-24 10:02:50
```
备份现在真正工作了。
## 教训记录
- 确定性任务shell 命令)必须用 `systemEvent`,不能依赖 LLM 解释执行
- kimi-k2.5 的工具使用能力较弱,容易产生幻觉
- 日期/特殊字符在 cron 命令中需要正确转义
## 更新文件
- MEMORY.md — 更新备份任务配置
- TOOLS.md — 添加 OpenClaw Cron 章节记录经验教训