You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
205 lines
4.4 KiB
205 lines
4.4 KiB
# Active Learning Skill - 主动学习 |
|
|
|
**版本:** 1.0 |
|
**日期:** 2026-03-07 |
|
**维护者:** Eason (陈医生) |
|
|
|
--- |
|
|
|
## 功能说明 |
|
|
|
让 Agent(如桐哥)在特定时段(7-23 点)每小时主动学习: |
|
1. 从记忆中选一个感兴趣的话题 |
|
2. 用 tavily 搜索学习 |
|
3. 记录学习日志到记忆 |
|
4. 可选:分享学到的东西给用户 |
|
|
|
--- |
|
|
|
## 触发方式 |
|
|
|
### Cron 定时触发(OpenClaw 内置 Cron,当前方式) |
|
|
|
任务配置在 `/root/.openclaw-tongge/cron/jobs.json`(jobId: `tongge-active-learning`),由桐哥 Gateway 直接调度。每小时触发,时区 Asia/Hong_Kong,7-23 点运行。 |
|
|
|
> **已废弃**:不再使用 `/etc/cron.d/tongge-learning` 系统 cron 方式。 |
|
|
|
--- |
|
|
|
## 学习流程 |
|
|
|
``` |
|
1. 读取桐哥的兴趣/最近关注 (从 MEMORY.md 或记忆系统) |
|
2. 选一个话题 |
|
3. 调用 tavily 搜索 |
|
4. 整理学习内容 |
|
5. 写入桐哥的 memory/YYYY-MM-DD.md |
|
6. 可选:如果学到有趣的东西,发消息给用户 |
|
``` |
|
|
|
--- |
|
|
|
## 配置文件 |
|
|
|
### Cron 配置 |
|
位置:`/root/.openclaw-tongge/cron/jobs.json`(OpenClaw 内置 Cron) |
|
|
|
```json |
|
{ |
|
"jobId": "tongge-active-learning", |
|
"name": "桐哥主动学习", |
|
"agentId": "tongge", |
|
"schedule": { "kind": "cron", "expr": "0 7-23 * * *", "tz": "Asia/Hong_Kong" }, |
|
"sessionTarget": "isolated", |
|
"wakeMode": "next-heartbeat", |
|
"payload": { |
|
"kind": "agentTurn", |
|
"message": "请主动学习一个你感兴趣的话题...", |
|
"lightContext": false |
|
}, |
|
"delivery": { "mode": "none" } |
|
} |
|
``` |
|
|
|
### 学习话题配置 |
|
位置:`/root/.openclaw-tongge/learning-topics.yaml` |
|
|
|
```yaml |
|
# 桐哥的学习兴趣领域 |
|
interests: |
|
- 编程技术 |
|
- 设计美学 |
|
- 心理学 |
|
- 生活方式 |
|
- 艺术文化 |
|
|
|
# 最近关注的话题(动态更新) |
|
recent_focus: |
|
- React Hooks |
|
- 色彩理论 |
|
|
|
# 已学过的话题(避免重复) |
|
learned_topics: [] |
|
|
|
# 学习偏好 |
|
preferences: |
|
depth: "intro-to-intermediate" # intro, intermediate, deep-dive |
|
format: "practical" # practical, theoretical, mixed |
|
time_per_session: "15min" # 15min, 30min, 1h |
|
``` |
|
|
|
--- |
|
|
|
## 学习日志格式 |
|
|
|
位置:`/root/.openclaw/workspace/agents/tongge-workspace/memory/learning/YYYY-MM-DD.md` |
|
|
|
```markdown |
|
# 学习日志 - 2026-03-07 |
|
|
|
## 14:00 - React Hooks 的最佳实践 |
|
|
|
**来源:** Tavily 搜索 |
|
**深度:** 入门到中级 |
|
**时间:** ~15 分钟 |
|
|
|
### 学到了什么 |
|
- useCallback 和 useMemo 的区别 |
|
- 什么时候不应该用 memo |
|
|
|
### 我的想法 |
|
感觉以前理解得不太对... 原来 useCallback 主要是为了保持引用稳定,不是性能优化。 |
|
|
|
### 想尝试 |
|
下次写代码时试试不用 useCallback,看看会不会有问题。 |
|
|
|
--- |
|
|
|
## 15:00 - 色彩理论基础知识 |
|
|
|
... |
|
``` |
|
|
|
--- |
|
|
|
## 休息模式配置 |
|
|
|
### Telegram 拦截脚本 |
|
位置:`/root/.openclaw/workspace/scripts/tongge-rest-mode.js` |
|
|
|
```javascript |
|
// 23-7 点自动回复 |
|
const REST_START = 23; // 23:00 |
|
const REST_END = 7; // 07:00 |
|
|
|
function isRestTime() { |
|
const hour = new Date().getHours(); |
|
return hour >= REST_START || hour < REST_END; |
|
} |
|
|
|
function getRestReply() { |
|
const replies = [ |
|
"桐哥在睡觉呢~ 明天再聊吧 😴", |
|
"夜深了,桐哥去休息啦,有话明天说~", |
|
"桐哥已经睡了,留言明天会回复的 🌙", |
|
]; |
|
return replies[Math.floor(Math.random() * replies.length)]; |
|
} |
|
|
|
module.exports = { isRestTime, getRestReply }; |
|
``` |
|
|
|
--- |
|
|
|
## 安装步骤 |
|
|
|
1. **创建学习技能** |
|
```bash |
|
mkdir -p /root/.openclaw/workspace/skills/active-learning |
|
# 创建 SKILL.md 和实现代码 |
|
``` |
|
|
|
2. **配置 cron** |
|
```bash |
|
sudo cp /root/.openclaw/workspace/skills/active-learning/cron /etc/cron.d/tongge-learning |
|
sudo chmod 644 /etc/cron.d/tongge-learning |
|
``` |
|
|
|
3. **启用技能** |
|
```bash |
|
openclaw --profile tongge skills enable active-learning |
|
``` |
|
|
|
4. **测试** |
|
```bash |
|
openclaw --profile tongge active-learn |
|
``` |
|
|
|
--- |
|
|
|
## 监控和调试 |
|
|
|
### 查看学习日志 |
|
```bash |
|
tail -f /var/log/tongge-learning.log |
|
``` |
|
|
|
### 查看桐哥的记忆 |
|
```bash |
|
cat /root/.openclaw/workspace/agents/tongge-workspace/memory/learning/$(date +%Y-%m-%d).md |
|
``` |
|
|
|
### 检查 cron 状态 |
|
```bash |
|
systemctl status cron |
|
grep tongge /var/log/syslog |
|
``` |
|
|
|
--- |
|
|
|
## 未来扩展 |
|
|
|
- [ ] 学习内容自动分享到 Telegram(如果有趣) |
|
- [ ] 学习主题推荐(基于最近的对话) |
|
- [ ] 学习进度追踪(每周/月总结) |
|
- [ ] 和用户一起学习(邀请用户参与话题)
|
|
|