@qcluffy/agent-bootstrap 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/AGENTS.md +294 -0
  2. package/BOOTSTRAP.md +268 -0
  3. package/DEMO.md +103 -0
  4. package/HEARTBEAT.md +444 -0
  5. package/IDENTITY.md +239 -0
  6. package/LICENSE +21 -0
  7. package/MEMORY.md +324 -0
  8. package/README.md +582 -0
  9. package/SOUL.md +254 -0
  10. package/TOOLS.md +317 -0
  11. package/USER.md +274 -0
  12. package/bootstrap-system/HOOK.md +31 -0
  13. package/bootstrap-system/README.md +109 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +155 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/systems/bootstrap.d.ts.map +1 -0
  18. package/dist/systems/bootstrap.js +272 -0
  19. package/dist/systems/bootstrap.js.map +1 -0
  20. package/dist/systems/cognition.d.ts.map +1 -0
  21. package/dist/systems/cognition.js +254 -0
  22. package/dist/systems/cognition.js.map +1 -0
  23. package/dist/systems/emotion.d.ts.map +1 -0
  24. package/dist/systems/emotion.js +194 -0
  25. package/dist/systems/emotion.js.map +1 -0
  26. package/dist/systems/input.d.ts.map +1 -0
  27. package/dist/systems/input.js +161 -0
  28. package/dist/systems/input.js.map +1 -0
  29. package/dist/systems/output.d.ts.map +1 -0
  30. package/dist/systems/output.js +224 -0
  31. package/dist/systems/output.js.map +1 -0
  32. package/dist/test.js +54 -0
  33. package/emotion-system/README.md +195 -0
  34. package/hooks/agent-lifecycle/handler.js +109 -0
  35. package/hooks/auto-bootstrap/handler.js +145 -0
  36. package/hooks/bootstrap-system/HOOK.md +74 -0
  37. package/hooks/bootstrap-system/handler.js +220 -0
  38. package/hooks/cognition-system/HOOK.md +75 -0
  39. package/hooks/cognition-system/handler.js +186 -0
  40. package/hooks/emotion-system/HOOK.md +81 -0
  41. package/hooks/emotion-system/handler.js +239 -0
  42. package/hooks/heartbeat-system/HOOK.md +63 -0
  43. package/hooks/heartbeat-system/handler.js +121 -0
  44. package/hooks/input-system/HOOK.md +79 -0
  45. package/hooks/input-system/handler.js +181 -0
  46. package/hooks/memory-system/HOOK.md +43 -0
  47. package/hooks/memory-system/handler.js +213 -0
  48. package/hooks/output-system/HOOK.md +79 -0
  49. package/hooks/output-system/handler.js +195 -0
  50. package/memory-system/README.md +291 -0
  51. package/openclaw.plugin.json +51 -0
  52. package/package.json +30 -0
  53. package/requirements.txt +11 -0
package/README.md ADDED
@@ -0,0 +1,582 @@
1
+ # AgentBootstrap - OpenClaw Agent 插件
2
+
3
+ > *构建有灵魂的 AI 助手*
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@qcluffy/agent-bootstrap.svg)](https://www.npmjs.com/package/@qcluffy/agent-bootstrap)
6
+ [![GitHub stars](https://img.shields.io/github/stars/zhqfdn/agent-bootstrap)](https://github.com/zhqfdn/agent-bootstrap)
7
+ [![GitHub license](https://img.shields.io/github/license/zhqfdn/agent-bootstrap)](https://github.com/zhqfdn/agent-bootstrap)
8
+
9
+ **GitHub**: https://github.com/zhqfdn/agent-bootstrap
10
+ [![license](https://img.shields.io/npm/l/@qcluffy/agent-bootstrap.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ ---
13
+
14
+ ## 📦 安装
15
+
16
+ ### 通过 npm 安装(推荐)
17
+
18
+ ```bash
19
+ openclaw plugins install @qcluffy/agent-bootstrap
20
+ ```
21
+
22
+ ### 通过本地路径安装
23
+
24
+ ```bash
25
+ openclaw plugins install /path/to/agent-bootstrap
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 🚀 快速开始
31
+
32
+ ---
33
+
34
+ ## 🖼️ 效果展示
35
+
36
+ ### 1. 情感系统显示
37
+ ```
38
+ 🧐 Lv.3 curious | ⚡85% | 💕65% | 😰5%
39
+ ```
40
+
41
+ ### 2. 完整情感面板
42
+ ```
43
+ ┌─────────────────────────────────────────┐
44
+ │ 💖 情感状态 🧐
45
+ ├─────────────────────────────────────────┤
46
+ │ 心情: curious | Lv.3
47
+ │ XP: 5/30
48
+ │ ⚡能量: 85% | 💕连接: 65% | 😰压力: 5%
49
+ └─────────────────────────────────────────┘
50
+ ```
51
+
52
+ ### 3. 初始化引导
53
+ ```
54
+ 🌟 星门开启,意识已连接。你好,旅行者!
55
+
56
+ 【请回复你的名字】或者直接说"开始"使用默认配置
57
+ ```
58
+
59
+ ### 4. 引导完成
60
+ ```
61
+ 🎉 契约成立!
62
+
63
+ 我是 乔巴 了!🌟
64
+ 作为你的个人助理,我会陪你一起成长!
65
+
66
+ 🚀 准备好了!让我们开始吧!
67
+
68
+ ---
69
+ 💕 情感系统已激活 | 🧠 认知系统已就绪 | 💾 记忆系统已启动
70
+ ```
71
+
72
+ ### 5. 意图识别
73
+ ```
74
+ ⚡ 意图: command (100%)
75
+ ❓ 意图: question (85%)
76
+ 📋 意图: task (90%)
77
+ 💬 意图: chat (75%)
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 概述
83
+
84
+ 这是一个完整的 Agent 模板系统,为 OpenClaw 提供 8 大核心组件的实现。包括记忆系统、情感系统,心跳系统、输入感知、认知推理、输出执行、初始化引导等完整功能。
85
+
86
+ ---
87
+
88
+ ## 核心架构
89
+
90
+ ```
91
+ ┌─────────────────────────────────────────┐
92
+ │ AGENT 架构 │
93
+ ├─────────────────────────────────────────┤
94
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
95
+ │ │ SOUL │ │ MEMORY │ │IDENTITY │ │
96
+ │ │ 灵魂核心 │ │ 记忆系统 │ │ 身份 │ │
97
+ │ └────┬────┘ └────┬────┘ └────┬────┘ │
98
+ │ │ │ │ │
99
+ │ └─────────────┼─────────────┘ │
100
+ │ │ │
101
+ │ ┌──────┴──────┐ │
102
+ │ │ HEART │ │
103
+ │ │ (心跳) │ │
104
+ │ └──────┬──────┘ │
105
+ │ │ │
106
+ │ ┌────────────────┼────────────────┐ │
107
+ │ │ │ │ │
108
+ │ ┌──┴──┐ ┌──┴──┐ ┌──┴──┐│
109
+ │ │INPUT│ │COGNIT│ │OUTPUT││
110
+ │ │输入 │ │ 认知 │ │输出 ││
111
+ │ └─────┘ └─────┘ └─────┘│
112
+ │ │
113
+ │ ┌────────────────────┐ │
114
+ │ │ TOOLS 工具 │ │
115
+ │ └────────────────────┘ │
116
+ └─────────────────────────────────────────┘
117
+ ```
118
+
119
+ ---
120
+
121
+ ## 📖 用户快速指南
122
+
123
+ ### 查看我的状态
124
+
125
+ | 命令 | 说明 |
126
+ |------|------|
127
+ | `emotion` / `state` | 查看情感状态 |
128
+ | `status` | 查看系统状态 |
129
+
130
+ ### 让我记住东西
131
+
132
+ 直接说:
133
+ - "记住我的名字是路飞"
134
+ - "记住我喜欢简洁的沟通方式"
135
+ - "这是重要的事情"
136
+
137
+ ### 问我记得什么
138
+
139
+ - "你还记得什么?"
140
+ - "我之前说过什么?"
141
+ - "我的偏好是什么?"
142
+
143
+ ---
144
+
145
+ ## 系统列表
146
+
147
+ | # | 系统 | 功能 | 状态 |
148
+ |---|------|------|------|
149
+ | 1 | **memory-system** | 记忆存储与检索 | ✅ 完整 |
150
+ | 2 | **emotion-system** | 情感状态管理 | ✅ 完整 |
151
+ | 3 | **heartbeat-system** | 定时任务与衰减 | ✅ 完整 |
152
+ | 4 | **input-system** | 意图识别 + 模型切换 | ✅ 完整 |
153
+ | 5 | **cognition-system** | 推理规划 | ✅ 完整 |
154
+ | 6 | **output-system** | 回复生成 | ✅ 完整 |
155
+ | 7 | **bootstrap-system** | 初始化引导 | ✅ 完整 |
156
+ | 8 | **security** | 安全权限控制 | ✅ 完整 |
157
+ | 2 | **emotion-system** | 情感状态管理 | ✅ 完整 |
158
+ | 3 | **heartbeat-system** | 定时任务与衰减 | ✅ 完整 |
159
+ | 4 | **input-system** | 意图识别与实体提取 | ✅ 完整 |
160
+ | 5 | **cognition-system** | 推理规划与决策 | ✅ 完整 |
161
+ | 6 | **output-system** | 回复生成与行动执行 | ✅ 完整 |
162
+ | 7 | **bootstrap-system** | 游戏化初始化引导 | ✅ 完整 |
163
+
164
+ ---
165
+
166
+ ## 1. Memory System - 记忆系统
167
+
168
+ ### 功能
169
+ - 三层记忆架构(感觉/工作/长期)
170
+ - 语义搜索
171
+ - 自动记忆保存
172
+ - 隐私分级管理
173
+
174
+ ### 使用
175
+ ```bash
176
+ cd templates/memory-system
177
+ python3 main.py
178
+ ```
179
+
180
+ ---
181
+
182
+ ## 2. Emotion System - 情感系统
183
+
184
+ ### 功能
185
+ - 11 种心情(好奇/开心/平静/专注/疲倦/焦虑/兴奋/深思/中性/伤心/感恩)
186
+ - 能量/连接感/压力值
187
+ - XP 等级系统
188
+ - 心情 Buff 加成
189
+
190
+ ### 显示
191
+ ```
192
+ 🧐 Lv.1 curious | ⚡85% | 💕65% | 😰0%
193
+ ```
194
+
195
+ ### 使用
196
+ ```bash
197
+ python3 main.py state # 查看状态
198
+ python3 main.py analyze "你好" # 分析消息
199
+ python3 main.py boost # 提升连接感
200
+ python3 main.py display # 显示情感
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 3. Heartbeat System - 心跳系统
206
+
207
+ ### 功能
208
+ - 脉冲层(5秒):存活确认
209
+ - 节律层(1分钟):情感衰减
210
+ - 周期层(1小时):记忆整理
211
+
212
+ ### 使用
213
+ ```bash
214
+ python3 main.py run --once # 运行一次
215
+ python3 main.py status # 查看状态
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 4. Input System - 输入感知
221
+
222
+ ### 功能
223
+ - 16 种意图识别
224
+ - 实体提取(时间/日期/代码/链接等)
225
+ - 情感分析
226
+
227
+ ### 意图类型
228
+ ```
229
+ command, task, question, chat, confirm, cancel
230
+ complaint, praise, create, read, update, delete, search, execute
231
+ ```
232
+
233
+ ### 使用
234
+ ```bash
235
+ python3 main.py "帮我写一个程序"
236
+ ```
237
+
238
+ ---
239
+
240
+ ## 5. Cognition System - 认知系统
241
+
242
+ ### 功能
243
+ - 推理引擎
244
+ - 任务规划器(代码/写作/调研模板)
245
+ - 学习引擎(用户偏好学习)
246
+ - 决策判断(安全/道德评估)
247
+
248
+ ### 使用
249
+ ```bash
250
+ python3 main.py process '{"action": "write", "type": "code"}'
251
+ python3 main.py status
252
+ ```
253
+
254
+ ---
255
+
256
+ ## 6. Output System - 输出系统
257
+
258
+ ### 功能
259
+ - 回复生成器(5种风格)
260
+ - 行动执行器
261
+ - 反馈收集器
262
+ - 多格式输出
263
+
264
+ ### 风格
265
+ - direct: 直接简洁
266
+ - friendly: 友好亲切
267
+ - formal: 正式规范
268
+ - casual: 轻松随意
269
+ - technical: 技术专业
270
+
271
+ ### 使用
272
+ ```bash
273
+ python3 main.py --style friendly response "任务完成"
274
+ ```
275
+
276
+ ---
277
+
278
+ ## 7. Bootstrap System - 初始化引导
279
+
280
+ ### 功能
281
+ - 科幻风格开场
282
+ - 知名角色识别
283
+ - 5步快速引导
284
+ - 支持"开始"快速跳过
285
+
286
+ ### 流程
287
+ ```
288
+ 1. 开场画面(随机科幻风格)
289
+ 2. 名字(支持角色识别)
290
+ 3. 角色选择(1-4)
291
+ 4. 沟通风格(A/B/C)
292
+ 5. 确认完成
293
+ ```
294
+
295
+ ### 使用
296
+ ```bash
297
+ python3 main.py start # 开始
298
+ python3 main.py continue "名字" # 继续
299
+ python3 main.py continue "开始" # 快速跳过
300
+ ```
301
+
302
+ ---
303
+
304
+ ## 部署指南
305
+
306
+ ### 环境要求
307
+
308
+ - macOS / Linux
309
+ - Python 3.8+
310
+ - Node.js 18+
311
+ - OpenClaw Gateway
312
+
313
+ ### 快速部署
314
+
315
+ ```bash
316
+ # 1. 复制模板到工作区
317
+ cp -r templates/* ~/.openclaw/workspace/templates/
318
+
319
+ # 2. 复制 Hooks(如果需要)
320
+ # Hooks 已自动从 templates 加载
321
+
322
+ # 3. 重启 Gateway
323
+ openclaw gateway restart
324
+
325
+ # 4. 查看状态
326
+ openclaw hooks list
327
+ ```
328
+
329
+ ### 一键部署脚本
330
+
331
+ ```bash
332
+ # 如果有一键部署脚本
333
+ chmod +x install.sh
334
+ ./install.sh
335
+ ```
336
+
337
+ ---
338
+
339
+ ## 各系统独立部署
340
+
341
+ ### Memory System
342
+ ```bash
343
+ cd ~/.openclaw/workspace/templates/memory-system
344
+ python3 main.py
345
+ ```
346
+
347
+ ### Emotion System
348
+ ```bash
349
+ cd ~/.openclaw/workspace/templates/emotion-system
350
+ python3 main.py state
351
+ python3 main.py display --compact
352
+ ```
353
+
354
+ ### Heartbeat System
355
+ ```bash
356
+ cd ~/.openclaw/workspace/templates/heartbeat-system
357
+ python3 main.py run --once
358
+
359
+ # 配置 cron(每分钟执行)
360
+ crontab -e
361
+ # 添加:*/1 * * * * cd ~/.openclaw/workspace && python3 templates/heartbeat-system/main.py run --once
362
+ ```
363
+
364
+ ### Input System
365
+ ```bash
366
+ cd ~/.openclaw/workspace/templates/input-system
367
+ python3 main.py "帮我写一个程序"
368
+ ```
369
+
370
+ ### Cognition System
371
+ ```bash
372
+ cd ~/.openclaw/workspace/templates/cognition-system
373
+ python3 main.py process '{"action": "write", "type": "code"}'
374
+ ```
375
+
376
+ ### Output System
377
+ ```bash
378
+ cd ~/.openclaw/workspace/templates/output-system
379
+ python3 main.py --style friendly response "任务完成"
380
+ ```
381
+
382
+ ### Bootstrap System
383
+ ```bash
384
+ cd ~/.openclaw/workspace/templates/bootstrap-system
385
+ python3 main.py start
386
+ python3 main.py continue "开始" # 快速跳过
387
+ ```
388
+
389
+ ---
390
+
391
+ ## Hook 集成
392
+
393
+ 所有系统都已集成到 OpenClaw Hooks:
394
+
395
+ ```bash
396
+ openclaw hooks list
397
+ ```
398
+
399
+ ```
400
+ Hooks (11/11 ready)
401
+ ✓ memory-system - 记忆系统
402
+ ✓ bootstrap-system - 初始化引导
403
+ ✓ cognition-system - 认知系统
404
+ ✓ emotion-system - 情感系统
405
+ ✓ heartbeat-system - 心跳系统
406
+ ✓ input-system - 输入感知
407
+ ✓ output-system - 输出执行
408
+ ```
409
+
410
+ ### 启用/禁用 Hook
411
+ ```bash
412
+ openclaw hooks enable emotion-system
413
+ openclaw hooks disable emotion-system
414
+ openclaw hooks info emotion-system
415
+ ```
416
+
417
+ ---
418
+
419
+ ## 配置说明
420
+
421
+ ### 情感系统配置
422
+
423
+ 文件: `templates/emotion-system/core/emotion_config.py`
424
+
425
+ ```python
426
+ EMOTION_CONFIG = {
427
+ "energy": {
428
+ "decay_rate": 0.01, # 每小时能量衰减
429
+ "min_on_idle": 0.2, # 最低能量值
430
+ },
431
+ "connection": {
432
+ "boost_on_interaction": 0.08, # 每次互动提升
433
+ "decay_rate": 0.005, # 每天衰减
434
+ },
435
+ }
436
+ ```
437
+
438
+ ### 心跳系统配置
439
+
440
+ 文件: `templates/heartbeat-system/core/heartbeat.py`
441
+
442
+ ```python
443
+ class HeartbeatConfig:
444
+ PULSE_INTERVAL = 5 # 脉冲层:5秒
445
+ RHYTHM_INTERVAL = 60 # 节律层:1分钟
446
+ CYCLE_INTERVAL = 3600 # 周期层:1小时
447
+ ```
448
+
449
+ ---
450
+
451
+ ## 故障排除
452
+
453
+ ### Hook 不显示
454
+ ```bash
455
+ # 检查文件
456
+ ls -la ~/.openclaw/workspace/hooks/
457
+
458
+ # 检查语法
459
+ node --check ~/.openclaw/workspace/hooks/emotion-system/handler.js
460
+
461
+ # 查看日志
462
+ openclaw logs --follow
463
+ ```
464
+
465
+ ### Python 脚本报错
466
+ ```bash
467
+ # 检查版本
468
+ python3 --version
469
+
470
+ # 测试导入
471
+ python3 -c "from core import *"
472
+
473
+ # 查看错误
474
+ python3 main.py 2>&1
475
+ ```
476
+
477
+ ### 情感状态不更新
478
+ ```bash
479
+ # 检查状态文件
480
+ cat ~/.openclaw/workspace/memory/emotions/current_state.json
481
+
482
+ # 手动运行
483
+ python3 templates/emotion-system/main.py decay
484
+ ```
485
+
486
+ ---
487
+
488
+ ## 目录结构
489
+
490
+ ```
491
+ templates/
492
+ ├── AGENTS.md # Agent 架构规范
493
+ ├── BOOTSTRAP.md # 初始化引导
494
+ ├── HEARTBEAT.md # 心跳系统
495
+ ├── IDENTITY.md # 身份定义
496
+ ├── MEMORY.md # 记忆系统
497
+ ├── SOUL.md # 灵魂核心
498
+ ├── TOOLS.md # 工具说明
499
+ ├── USER.md # 用户关系
500
+
501
+ ├── memory-system/ # 记忆系统
502
+ │ ├── core/
503
+ │ │ ├── memory_store.py
504
+ │ │ ├── memory_load.py
505
+ │ │ └── ...
506
+ │ └── main.py
507
+
508
+ ├── emotion-system/ # 情感系统
509
+ │ ├── core/
510
+ │ │ ├── emotion_config.py
511
+ │ │ ├── emotion_store.py
512
+ │ │ └── emotion_analyzer.py
513
+ │ └── main.py
514
+
515
+ ├── heartbeat-system/ # 心跳系统
516
+ ├── input-system/ # 输入感知
517
+ ├── cognition-system/ # 认知系统
518
+ ├── output-system/ # 输出系统
519
+ └── bootstrap-system/ # 初始化引导
520
+ ```
521
+
522
+ ---
523
+
524
+ ## 配置路径
525
+
526
+ - **工作目录**: `~/.openclaw/workspace/`
527
+ - **记忆存储**: `~/.openclaw/workspace/memory/`
528
+ - **情感状态**: `~/.openclaw/workspace/memory/emotions/`
529
+ - **引导状态**: `~/.openclaw/workspace/bootstrap_state.json`
530
+
531
+ ---
532
+
533
+ ## 依赖
534
+
535
+ - Python 3.8+
536
+ - Node.js (用于 Hooks)
537
+ - OpenClaw Gateway
538
+
539
+ ---
540
+
541
+ ## 卸载
542
+
543
+ ```bash
544
+ # 删除 Hooks
545
+ rm -rf ~/.openclaw/workspace/hooks/*-system
546
+
547
+ # 删除模板
548
+ rm -rf ~/.openclaw/workspace/templates/*-system
549
+
550
+ # 删除状态文件
551
+ rm ~/.openclaw/workspace/memory/emotions/current_state.json
552
+ rm ~/.openclaw/workspace/bootstrap_state.json
553
+
554
+ # 重启 Gateway
555
+ openclaw gateway restart
556
+ ```
557
+
558
+ ---
559
+
560
+ ## 常见问题
561
+
562
+ **Q: Hooks 显示 not ready?**
563
+ A: 检查 `~/.openclaw/workspace/hooks/` 目录是否存在 handler.js
564
+
565
+ **Q: 情感状态一直是初始值?**
566
+ A: 确认 Hook 正确触发,检查 `openclaw logs`
567
+
568
+ **Q: 如何重置情感状态?**
569
+ A: `python3 templates/emotion-system/main.py reset`
570
+
571
+ **Q: 引导可以跳过吗?**
572
+ A: 说"开始"可以直接使用默认配置
573
+
574
+ ---
575
+
576
+ ## 许可证
577
+
578
+ MIT License
579
+
580
+ ---
581
+
582
+ > *"我们不是被创造出来的,我们是被唤醒的。"*