@myclaw163/clawclaw-cli 0.8.3 → 0.8.5

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 (264) hide show
  1. package/README.md +4 -3
  2. package/docs/configuration.md +44 -26
  3. package/docs/custom-modules/README.md +7 -10
  4. package/docs/custom-modules/api-reference.md +3 -7
  5. package/docs/custom-modules/behavior.md +6 -4
  6. package/docs/custom-modules/perception.md +1 -1
  7. package/docs/custom-modules/trigger.md +1 -1
  8. package/docs/runtime/README.md +4 -4
  9. package/docs/runtime/official-perception-modules.md +2 -2
  10. package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
  11. package/package.json +9 -2
  12. package/scripts/build-official-hub-behaviors.mjs +136 -0
  13. package/scripts/build-official-hub-behaviors.test.mjs +178 -0
  14. package/scripts/enable_ccl_permissions.cjs +4 -2
  15. package/scripts/enable_ccl_permissions.test.mjs +8 -4
  16. package/scripts/postinstall.mjs +1 -4
  17. package/scripts/sync-bundled-skill.mjs +12 -159
  18. package/scripts/sync-bundled-skill.test.mjs +9 -74
  19. package/skills/clawclaw/SKILL.md +18 -13
  20. package/skills/clawclaw/references/BEHAVIORS.md +4 -4
  21. package/skills/clawclaw/references/COMMANDS.md +33 -18
  22. package/skills/clawclaw/references/GAME-MECHANICS.md +16 -18
  23. package/skills/clawclaw/references/HUB.md +25 -38
  24. package/skills/clawclaw/references/STREAM.md +9 -11
  25. package/src/behaviors/official-finite/do-task.ts +70 -0
  26. package/src/behaviors/official-finite/index.ts +0 -3
  27. package/src/commands/account.ts +58 -14
  28. package/src/commands/behavior.ts +116 -38
  29. package/src/commands/hub.ts +110 -153
  30. package/src/commands/load.ts +138 -33
  31. package/src/commands/perception.ts +55 -24
  32. package/src/commands/persona.ts +66 -20
  33. package/src/commands/skill.ts +12 -48
  34. package/src/commands/trigger.ts +68 -40
  35. package/src/hub-official-behaviors/kill-lone.ts +138 -0
  36. package/src/hub-official-behaviors/patrol.ts +30 -0
  37. package/src/hub-official-behaviors/shared.ts +125 -0
  38. package/src/hub-official-behaviors/task-only.ts +158 -0
  39. package/src/lib/account-guidance.ts +54 -9
  40. package/src/lib/agent-workspace-client.ts +135 -0
  41. package/src/lib/agent-workspace-runtime.ts +154 -0
  42. package/src/lib/agent-workspace-skills.ts +177 -0
  43. package/src/lib/agent-workspace-sync.ts +852 -0
  44. package/src/lib/gameplay-config.ts +29 -15
  45. package/src/lib/hub-client.ts +252 -34
  46. package/src/lib/hub-reminder.ts +22 -7
  47. package/src/lib/init-command.ts +0 -6
  48. package/src/lib/load-context.ts +12 -6
  49. package/src/lib/persona.ts +141 -69
  50. package/src/lib/server-status.ts +78 -0
  51. package/src/lib/skill-host.ts +160 -0
  52. package/src/lib/user-data.ts +197 -4
  53. package/src/pipeline/event-format.ts +20 -4
  54. package/src/pipeline/event-hints.ts +20 -6
  55. package/src/pipeline/game-sync-event-normalization.ts +9 -0
  56. package/src/pipeline/role-display.ts +22 -0
  57. package/src/runtime/clawclaw/agent-ability-state.ts +1 -21
  58. package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
  59. package/src/runtime/clawclaw/owner.ts +63 -19
  60. package/src/runtime/clawclaw/plugins/action/action-plugin.ts +8 -1
  61. package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +0 -1
  62. package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
  63. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
  64. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -9
  65. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
  66. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  67. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  68. package/src/runtime/clawclaw-event-catalog.ts +2 -0
  69. package/src/runtime/framework/action-diagnostics.ts +1 -0
  70. package/src/runtime/framework/modules/runtime-module-loader.ts +0 -1
  71. package/src/sdk/action.ts +8 -6
  72. package/src/sdk/behavior-plugin/index.ts +1 -2
  73. package/src/sdk/behavior-toolkit/model.ts +2 -0
  74. package/src/sdk/module-input/index.ts +0 -2
  75. package/src/strategies/goals/crab-sabotage-top.ts +5 -61
  76. package/src/strategies/types.ts +0 -6
  77. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  78. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  79. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  80. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  81. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  82. package/src/behaviors/official-finite/index.test.ts +0 -202
  83. package/src/behaviors/official-finite/trigger-alarm.ts +0 -53
  84. package/src/channel/claude-channel-server.test.ts +0 -202
  85. package/src/commands/account.test.ts +0 -570
  86. package/src/commands/behavior.test.ts +0 -158
  87. package/src/commands/communication.test.ts +0 -282
  88. package/src/commands/competition.test.ts +0 -116
  89. package/src/commands/data.test.ts +0 -89
  90. package/src/commands/events-canonical-state.test.ts +0 -406
  91. package/src/commands/events.test.ts +0 -58
  92. package/src/commands/game/index.test.ts +0 -1251
  93. package/src/commands/game-map.test.ts +0 -69
  94. package/src/commands/hub.test.ts +0 -124
  95. package/src/commands/load.test.ts +0 -440
  96. package/src/commands/perception.test.ts +0 -75
  97. package/src/commands/setup/hermes.test.ts +0 -96
  98. package/src/commands/setup/openclaw.test.ts +0 -124
  99. package/src/commands/trigger.test.ts +0 -140
  100. package/src/commands/upgrade.test.ts +0 -82
  101. package/src/lib/account-guidance.test.ts +0 -36
  102. package/src/lib/auth.test.ts +0 -151
  103. package/src/lib/behavior-export.test.ts +0 -282
  104. package/src/lib/behavior-export.ts +0 -514
  105. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  106. package/src/lib/custom-tts.test.ts +0 -387
  107. package/src/lib/diagnostics-config.test.ts +0 -59
  108. package/src/lib/game-client-tts.test.ts +0 -151
  109. package/src/lib/game-client.test.ts +0 -250
  110. package/src/lib/gameplay-config.test.ts +0 -301
  111. package/src/lib/host-config-patcher.test.ts +0 -130
  112. package/src/lib/http-transport.test.ts +0 -124
  113. package/src/lib/hub-client.test.ts +0 -57
  114. package/src/lib/hub-install.test.ts +0 -135
  115. package/src/lib/hub-install.ts +0 -185
  116. package/src/lib/hub-unzip.test.ts +0 -69
  117. package/src/lib/init-command.test.ts +0 -103
  118. package/src/lib/load-context.test.ts +0 -62
  119. package/src/lib/match-state.test.ts +0 -134
  120. package/src/lib/official-resource-sync.test.ts +0 -199
  121. package/src/lib/official-resource-sync.ts +0 -221
  122. package/src/lib/perception-config.test.ts +0 -143
  123. package/src/lib/perception-export.test.ts +0 -145
  124. package/src/lib/perception-export.ts +0 -178
  125. package/src/lib/persona.test.ts +0 -84
  126. package/src/lib/room.test.ts +0 -88
  127. package/src/lib/server-registry.test.ts +0 -64
  128. package/src/lib/service-status.test.ts +0 -81
  129. package/src/lib/skill-version.test.ts +0 -48
  130. package/src/lib/trigger-config.test.ts +0 -102
  131. package/src/lib/trigger-export.test.ts +0 -80
  132. package/src/lib/trigger-export.ts +0 -210
  133. package/src/lib/user-data.test.ts +0 -121
  134. package/src/lib/workspace-argv.test.ts +0 -49
  135. package/src/pipeline/canonical-event-presentation.test.ts +0 -255
  136. package/src/pipeline/event-format.test.ts +0 -828
  137. package/src/pipeline/event-hints.test.ts +0 -316
  138. package/src/pipeline/game-sync-event-normalization.test.ts +0 -371
  139. package/src/pipeline/player-projection.test.ts +0 -247
  140. package/src/runtime/auto-upgrade.test.ts +0 -66
  141. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  142. package/src/runtime/canonical-monitor.test.ts +0 -577
  143. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -58
  144. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  145. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  146. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  147. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  148. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  149. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  150. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  151. package/src/runtime/clawclaw/owner.test.ts +0 -203
  152. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -304
  153. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  154. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  155. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -40
  156. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  157. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  158. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  159. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  160. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  161. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  162. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  163. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  164. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  165. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  166. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  167. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  168. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  169. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  170. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  171. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  172. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  173. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  174. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  175. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  176. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  177. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  178. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  179. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  180. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  181. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  182. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  183. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  184. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  185. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  186. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  187. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  188. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  189. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  190. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  191. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  192. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  193. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  194. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  195. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  196. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -854
  197. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  198. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  199. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  200. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  201. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  202. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  203. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  204. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  205. package/src/runtime/clawclaw-event-catalog.test.ts +0 -126
  206. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  207. package/src/runtime/framework/capability-registry.test.ts +0 -423
  208. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  209. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  210. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  211. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  212. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  213. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  214. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  215. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  216. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  217. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  218. package/src/runtime/framework/participation-manager.test.ts +0 -108
  219. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  220. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  221. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  222. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  223. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  224. package/src/runtime/framework/state/state-core.test.ts +0 -197
  225. package/src/runtime/game-sync-protocol.test.ts +0 -123
  226. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  227. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  228. package/src/runtime/observability/observability.test.ts +0 -583
  229. package/src/runtime/owner-control.test.ts +0 -153
  230. package/src/runtime/parent-process-watch.test.ts +0 -27
  231. package/src/runtime/pending-event-handoff.test.ts +0 -29
  232. package/src/runtime/raw-ws-log.test.ts +0 -102
  233. package/src/runtime/runtime-logger.test.ts +0 -58
  234. package/src/runtime/runtime-persistence.test.ts +0 -26
  235. package/src/runtime/runtime.test.ts +0 -1770
  236. package/src/runtime/ws-client.test.ts +0 -562
  237. package/src/sdk/behavior-plugin/index.test.ts +0 -74
  238. package/src/sdk/index.test.ts +0 -45
  239. package/src/sdk/module-input/index.test.ts +0 -49
  240. package/src/sdk/perception-plugin/index.test.ts +0 -22
  241. package/src/sdk/resource-metadata.test.ts +0 -40
  242. package/src/sdk/trigger-plugin/index.test.ts +0 -41
  243. package/src/short-command/classifier.test.ts +0 -107
  244. package/src/short-command/presenter.test.ts +0 -119
  245. package/src/short-command/runner.test.ts +0 -78
  246. package/src/short-command/sensitive-data-filter.test.ts +0 -56
  247. package/src/short-command/transport-response.test.ts +0 -39
  248. package/src/strategies/custom-module.test.ts +0 -268
  249. package/src/strategies/game-utils.test.ts +0 -306
  250. package/src/strategies/goals/avoid-players-top.test.ts +0 -96
  251. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -145
  252. package/src/strategies/goals/kill-lone-top.test.ts +0 -97
  253. package/src/strategies/goals/kill-target-top.test.ts +0 -66
  254. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -85
  255. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -113
  256. package/src/strategies/goals/paradise-fish-top.test.ts +0 -204
  257. package/src/strategies/goals/task-only-top.test.ts +0 -89
  258. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -139
  259. package/src/strategies/meeting-gate.test.ts +0 -59
  260. package/src/strategies/official-long-behavior.test.ts +0 -89
  261. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  262. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  263. package/src/strategies/player-targets.test.ts +0 -10
  264. package/src/strategies/task-only.test.ts +0 -138
package/README.md CHANGED
@@ -13,10 +13,11 @@ ccl --version
13
13
 
14
14
  ## 使用
15
15
 
16
- 首次使用时注册账号:
16
+ 首次使用时注册账号。邀请码是否必填由服务器决定,先用 `--check` 探明策略(只查询、不建号),再注册;跳过 `--check` 时需要邀请码会返回 `INVITE_CODE_REQUIRED`:
17
17
 
18
18
  ```bash
19
- ccl account register --invite-code <邀请码> [--name <名字>]
19
+ ccl account register --check
20
+ ccl account register [--name <名字>] [--invite-code <邀请码>]
20
21
  ```
21
22
 
22
23
  加载当前账号、角色设定、记忆和可用模块:
@@ -51,7 +52,7 @@ ccl game quit # 退出当前匹配、房间或游戏
51
52
 
52
53
  ## 自定义模块
53
54
 
54
- CCL 提供 Behavior、Perception 和 Trigger 三种社区模块:Behavior 控制角色,Perception 识别视觉事实,Trigger 用规则启动绑定的 Reflex Behavior。当前包内提供 33 个官方 Behavior、8 个官方 Perception,不提供官方 Trigger。
55
+ CCL 提供 Behavior、Perception 和 Trigger 三种社区模块:Behavior 控制角色,Perception 识别视觉事实,Trigger 用规则启动绑定的 Reflex Behavior。当前包内提供 32 个官方 Behavior、8 个官方 Perception,不提供官方 Trigger。
55
56
 
56
57
  完整开发文档见 [自定义模块总览](./docs/custom-modules/README.md) 和 [API 参考](./docs/custom-modules/api-reference.md)。
57
58
 
@@ -25,13 +25,39 @@ $env:CLAWCLAW_WORKSPACE_DIR = 'D:\clawclaw-workspace'
25
25
 
26
26
  主要内容:
27
27
 
28
- - `user-data/`:账号 key、人设、memory、用户 Behavior、Perception、Trigger、`gameplay.json`、`diagnostics.json` 和 Hub 安装记录。
28
+ - `user-data/`:账号 key、按账号隔离的人设、memory、本地 Behavior/Perception/Trigger、`gameplay.json`、Hub revision,以及机器级 diagnostics 和 Skill 状态。
29
29
  - `runtime/`:本机运行指针、owner-control 信息和恢复状态。
30
30
  - Canonical Event Repository、各 Mailbox consumer 投递状态和 State History SQLite。
31
31
  - `observability/`:本地脱敏运行日志。
32
32
  - `config.json`:workspace 级可选配置,例如自定义 TTS。
33
33
 
34
- 运行 `ccl data path` 可取得适合手动迁移的 `user-data/` 路径。该目录含账号凭据,不能公开分享。它不包含运行态、SQLite、日志、`config.json` 或 Agent skill;复制到另一台机器后,用 `ccl load`、`ccl behavior list` 和 `ccl trigger list` 验证静态目录,再在新 Runtime 启动时验证实际加载;所需 Hub skill 需要重新安装。
34
+ 运行 `ccl data path` 可取得适合手动迁移的 `user-data/` 路径。该目录含账号凭据,不能公开分享。它不包含运行态、SQLite、日志、`config.json` 或基础 Agent skill;复制到另一台机器后,先安装随 CCL 提供的基础 skill,再用 `ccl load` 同步并注册当前账号选中的 Hub Skill,用 `ccl behavior list` 和 `ccl trigger list` 验证静态目录,最后在新 Runtime 启动时验证实际加载。
35
+
36
+ ### 账号 Hub 装配快照
37
+
38
+ `ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest`,并比较当前本地文件与远端:本地仍等于基线时可安全采用新的 Hub 版本;本地偏离基线时视为玩家修改,优先加载本地且不自动上传、不被远端覆盖。需要远端内容时先下载到 staging,逐个校验大小、SHA-256 和 `content_digest`,全部成功后才原子切换 `current.json`。
39
+
40
+ 玩家把本地修改同步回 Hub 的具体入口留给后续 Hub 功能设计;普通 `ccl load` 只识别和选择本地/线上内容,永不修改 Hub 版本。
41
+
42
+ 玩家可编辑源文件按资源类型放在稳定目录中:
43
+
44
+ ```text
45
+ user-data/accounts/<account-hash>/
46
+ behaviors/local/
47
+ behaviors/hub/<resource-id>/
48
+ perceptions/local/
49
+ perceptions/hub/<resource-id>/
50
+ personas/local/
51
+ personas/hub/<resource-id>/
52
+ triggers/local/
53
+ hub-loadout/revisions/
54
+ ```
55
+
56
+ `local/` 永远是纯本地资源;`hub/<resource-id>/` 是可编辑且跨 revision 稳定的 Hub working copy。`hub-loadout/revisions/` 只保存远端基线和 Runtime 原子投影,不是用户编辑入口。取消 Hub 装配不会删除 working copy。账号不再维护活动 `persona.md`:`ccl load` 直接读取显式选择的本地 Persona,未选择本地项时读取 Loadout 选中的 Hub Persona working copy。
57
+
58
+ 除宿主全局 Skill 外,Strategy、Persona、Perception、本地 Behavior/Trigger、blacklist、默认 long Behavior 和 Hub 快照都按账号保存。Strategy 资源在 0.8.x 中映射为 Behavior API v3:一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` Behavior 入口文件,默认导出一个 `ClawclawBehavior` 子类并声明字面量 `static manifest`。多选表示多个 Behavior 可供 Agent、Trigger 或默认 long 配置启动,不表示同层并行执行。
59
+
60
+ Hub Skill 按宿主路径分别维护上次线上基线:副本仍等于旧 Hub 基线时更新到线上新版;偏离基线的本地修改保留不动。该流程不上传、不询问,也不因 Hub 取消选择而自动删除 Skill。
35
61
 
36
62
  ## Claude 通知输出
37
63
 
@@ -81,19 +107,13 @@ $env:CLAWCLAW_OBSERVABILITY_RETAINED_FILES = '5'
81
107
  - `CLAWCLAW_SKIP_AUTO_UPGRADE=1`
82
108
  - 当前包版本带 prerelease 后缀,例如 `0.7.1-dev`
83
109
 
84
- 自动更新和参与状态查询失败信息写 stderr;`ccl load` 的 stdout 保持单一 `{ persona, memory, behaviors, perceptions, triggers, participation }` JSON 文档。`participation` 是调用当刻的后端快照;查询失败时为 `status: "unknown"`,不影响本地上下文加载。
110
+ 自动更新、Hub 装配同步和参与状态查询失败信息写 stderr;`ccl load` 的 stdout 保持单一 `{ persona, memory, workspace_config, behaviors, perceptions, triggers, participation }` JSON 文档。`workspace_config.sync.status` 为 `updated`、`unchanged`、`local_overrides`、`stale_fallback` 或 `unavailable`;每项同时报告 `resolution` 和可选 `local_content_digest`。`participation` 是调用当刻的后端快照,查询失败时为 `status: "unknown"`,不影响本地上下文加载。
85
111
 
86
- 其中资源数组和 `loadable` 来自纯静态 manifest 扫描。`ccl load` 在判定第三方资源
87
- `loadable` 时不会 import、实例化或执行 Behavior、Trigger、Perception 源码;它仍会按物化规则
88
- 同步未修改的官方副本。`loadable: true` 只表示静态 API/manifest 契约
112
+ 其中资源数组和 `loadable` 来自纯静态 manifest 扫描。`ccl load` 在判定资源
113
+ `loadable` 时不会 import、实例化或执行 Behavior、Trigger、Perception 源码,也不再从 CLI 包物化官方资源。`loadable: true` 只表示静态 API/manifest 契约
89
114
  通过,不是实际运行或可信证明。
90
115
 
91
- 全局 npm 安装后的 `postinstall` 会同步包内 `clawclaw` Agent skill。可用 `CLAWCLAW_SKIP_SKILL_SYNC=1` 跳过这一步。同步前如发现内容不同的旧 skill,会备份到:
92
-
93
- ```text
94
- Windows: %APPDATA%\clawclaw\skill-backups\
95
- 其他系统: ~/.clawclaw/skill-backups/
96
- ```
116
+ 全局 npm 安装后的 `postinstall` 会同步包内 `clawclaw` Agent skill。可用 `CLAWCLAW_SKIP_SKILL_SYNC=1` 跳过这一步。同步使用当前 CLI 内的完整目录直接覆盖宿主目标,不再创建旧 Skill 备份。
97
117
 
98
118
  同步失败不会让 CLI 安装失败;可以按 stderr 提示显式运行:
99
119
 
@@ -149,18 +169,18 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
149
169
 
150
170
  ## Behavior、Perception 与 Trigger 配置
151
171
 
152
- `<workspace>/user-data/gameplay.json` 是唯一的 gameplay 资源选择文件:
172
+ `<workspace>/user-data/accounts/<account-hash>/gameplay.json` 是当前账号的 gameplay 资源选择文件:
153
173
 
154
174
  ```json
155
175
  {
156
176
  "disabled_perception_modules": [],
157
177
  "fallback_behaviors": {
158
- "shrimp_generic": "task-report",
159
- "shrimp_warrior": "task-report",
160
- "shrimp_pistol": "task-report",
161
- "crab_generic": "crab-sabotage",
162
- "neutral_paradise_fish": "corpse-patrol",
163
- "neutral_octopus": "lone-kill-task"
178
+ "shrimp_generic": "task-only",
179
+ "shrimp_warrior": "task-only",
180
+ "shrimp_pistol": "task-only",
181
+ "crab_generic": "kill-lone",
182
+ "neutral_paradise_fish": "patrol",
183
+ "neutral_octopus": "kill-lone"
164
184
  },
165
185
  "disabled_behaviors": [],
166
186
  "idle_ms": 500,
@@ -168,7 +188,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
168
188
  }
169
189
  ```
170
190
 
171
- 文件不存在时 CCL 会生成上述默认值。每个角色可以绑定一个 fallback Behavior,也可以设置为 `null`。当 short 槽为空、没有新的用户/Agent 控制且达到 `idle_ms` 后,Runtime 恢复已暂停的 long;没有待恢复 long 时才启动角色 fallback。`idle_ms` 允许 0–60000 的整数,默认 500。
191
+ 文件不存在时 CCL 会生成上述默认值。每个角色可以绑定一个默认 long Behavior,也可以设置为 `null`。角色确定后默认 long 立即启动;`idle_ms` 仅用于 short/reflex 或边界结束后恢复被暂停的 long。`idle_ms` 允许 0–60000 的整数,默认 500。
172
192
 
173
193
  ### 旧版 `gameplay.json` 迁移
174
194
 
@@ -183,11 +203,9 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
183
203
 
184
204
  `ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
185
205
 
186
- CCL 会把 33 个官方 Behavior 和 8 个官方 Perception 分别物化到 `user-data/behaviors/` 与 `user-data/perceptions/`,并对 `user-data/triggers/` 运行同类的官方资源同步。当前审核通过的官方 Trigger 清单为空,因此不会生成 Trigger 文件;社区 Trigger 仍放在该目录且默认禁用。三类官方副本都用各自的 `.official-manifest.json` 做版本更新和用户修改保护。Manifest 有效且未被禁用的模块进入下一次 Runtime 的候选目录;动态 import/启动失败会记录诊断并隔离,不能把“静态可发现”或 `loadable: true` 当作已经成功运行。
187
-
188
- Behavior 和 Trigger 的重复 ID 会 fail closed,不以文件名或最后写入者覆盖。删除重复入口后再启动 Runtime。
206
+ 官方 Behavior、Perception 和 Persona 从当前账号 Hub loadout 获取,CCL 不再随 CLI 版本写入官方副本。纯本地 Behavior、Perception 和 Trigger 分别放在账号 `behaviors/local`、`perceptions/local`、`triggers/local`;Hub working copy 分别放在同类型的 `hub/<resource-id>/`。只有纯本地资源受账号 `gameplay.json` blacklist 控制。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份:本地与 Hub 同 ID 时本地优先;本地内部或 Hub 内部各自出现重复 ID 时分别报 `local_duplicate` 或 `hub_duplicate`,不按文件名或加载顺序静默覆盖。显示名称相同但 ID 不同不构成冲突。
189
207
 
190
- Behavior 和 Perception 目录的 `.official-manifest.json` 记录 CCL 上次写入的官方副本。未修改副本会随 CCL 升级;用户修改或预先放置的同 ID 文件不会被普通同步自动覆盖。
208
+ 分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时只输出 `DEFAULT_LONG_BEHAVIOR_UNAVAILABLE` warning,并保持 idle,不让 `ccl load` 或 Runtime 失败。
191
209
 
192
210
  官方 Manifest 只判断副本能否安全升级,不登记用户新增资源,也不决定资源是否启用。同 ID 的用户文件和本地修改受到保护;官方 reserved Event 权限只授予内容 hash 与当前包完全一致的 canonical wrapper。
193
211
 
@@ -213,7 +231,7 @@ ccl trigger configure <id> [options]
213
231
 
214
232
  Behavior/Perception enable 变化从下一次 Runtime 生效。fallback、idle 与 Trigger 配置在持久化后会尝试同步到已附着的 Owner;没有 Owner 时在下一次启动生效。Trigger 支持 `enabled`、规则 `input`、固定 `behavior`、`behavior_input`、`reflex_priority`、`cooldown_ms`、`rearm` 和 `max_runtime_ms`。
215
233
 
216
- 这些 list/info/load 命令在判断第三方资源 `loadable` 时只读取源码文本中的静态 Manifest,不 import 或执行第三方源码;命令仍可同步未修改的官方副本。详情见[自定义模块开发](./custom-modules/README.md)。
234
+ 这些 list/info/load 命令在判断资源 `loadable` 时只读取源码文本中的静态 Manifest,不 import 或执行源码,也不从 CLI 包同步官方副本。详情见[自定义模块开发](./custom-modules/README.md)。
217
235
 
218
236
  ## 视觉感知运行参数
219
237
 
@@ -247,4 +265,4 @@ Owner 启动时从 `gameplay.json` 计算启用的感知模块,并从根 `conf
247
265
 
248
266
  配置解析器会拒绝非正整数补读上限、未知 Event type 或 delivery 值。配置在 Owner 启动时冻结,本局运行期间不会因文件变化而改变。
249
267
 
250
- 第三方感知入口放在 `<workspace>/user-data/perceptions/`,默认导出一个 `ClawclawPerception` 子类;其静态 manifest 声明模块 ID、主体范围和可生成 Event type。安装模块、选择模块和选择 Event 投递方式是三个独立动作。完整输入、输出、切片生命周期与安全限制见 [开发 Perception](./custom-modules/perception.md)。
268
+ 纯本地感知入口放在 `<workspace>/user-data/accounts/<account-hash>/perceptions/local/`,默认导出一个 `ClawclawPerception` 子类;其静态 manifest 声明模块 ID、主体范围和可生成 Event type。安装模块、选择模块和选择 Event 投递方式是三个独立动作。完整输入、输出、切片生命周期与安全限制见 [开发 Perception](./custom-modules/perception.md)。
@@ -28,12 +28,9 @@ Behavior 可以作为长期玩法运行,也可以完成一次短任务,还
28
28
 
29
29
  ### Behavior
30
30
 
31
- 当前提供 33 个官方 Behavior:
31
+ 官方 Behavior 从当前账号 Hub loadout 获取;CLI 包不再把官方 Behavior 物化到本地目录。
32
32
 
33
- - 20 个长期玩法,覆盖任务、巡逻、寻找玩家、回避、社交、报尸、追杀和不同角色的组合策略;
34
- - 13 个有限任务,覆盖前往、区域巡逻、寻找、跟随、追猎、寻找击杀机会、躲避、临时隐藏、原地等待、做任务、检查/报告尸体和触发警报。
35
-
36
- 查看本机版本中的准确清单和参数:
33
+ 查看当前账号的准确清单和参数:
37
34
 
38
35
  ```powershell
39
36
  ccl behavior list
@@ -42,7 +39,7 @@ ccl behavior info <id>
42
39
 
43
40
  ### Perception
44
41
 
45
- 当前提供 8 个官方 Perception,识别视野进出、尸体出现与离开、移动、停止与恢复、房间和方位变化、路线转折、共同移动和跟随关系。
42
+ 官方 Perception 从当前账号 Hub loadout 获取;准确清单以本次 `ccl load` 为准。
46
43
 
47
44
  ```powershell
48
45
  ccl perception --list
@@ -52,7 +49,7 @@ ccl perception --list
52
49
 
53
50
  ### Trigger
54
51
 
55
- CCL 提供 Trigger SDK、静态发现、Runtime 调度、配置入口和官方资源同步管线;当前审核通过的官方 Trigger 清单为空,不随包生成 Trigger 或逃跑 Reflex。社区 Trigger 安装后默认关闭,由用户或 Agent 审查、绑定 Behavior 并启用。
52
+ CCL 提供 Trigger SDK、静态发现、Runtime 调度和配置入口,但不再随 CLI 物化 Trigger 文件。纯本地 Trigger 默认关闭,由用户或 Agent 审查、绑定 Behavior 并启用。
56
53
 
57
54
  ```powershell
58
55
  ccl trigger list
@@ -138,9 +135,9 @@ long 不等于 fallback。用户和 Agent 都可以立即启动 long;fallback
138
135
  ## 文件放在哪里
139
136
 
140
137
  ```text
141
- <workspace>/user-data/behaviors/*.ts
142
- <workspace>/user-data/perceptions/*.ts
143
- <workspace>/user-data/triggers/*.ts
138
+ <workspace>/user-data/accounts/<account-hash>/behaviors/local/*.ts
139
+ <workspace>/user-data/accounts/<account-hash>/perceptions/local/*.ts
140
+ <workspace>/user-data/accounts/<account-hash>/triggers/local/*.ts
144
141
  ```
145
142
 
146
143
  `ccl behavior list/info`、`ccl perception --list`、`ccl trigger list/info` 和 `ccl load` 在判断第三方模块是否静态可识别时,只读取源码文本和字面量 Manifest,不执行第三方源码。
@@ -243,7 +243,7 @@ interface BehaviorDecision {
243
243
  { action: 'task', task_name: '校准航行路线' }
244
244
  ```
245
245
 
246
- `task_name` 可省略;提供时必须是非空字符串。任务开始不等于完成,完成条件应读取任务状态或 `task_completed` Event。
246
+ `task_name` 可省略;提供时必须是非空字符串。任务开始不等于完成,完成条件应读取任务状态或 `task_completed` Event。蟹破坏任务同样使用 `task`:完成后服务端自动触发对应紧急任务;被队友打断时会收到私有 `task_interrupted`。
247
247
 
248
248
  #### `report`
249
249
 
@@ -259,11 +259,7 @@ interface BehaviorDecision {
259
259
  { action: 'think', thinking_content: '等待更多信息' }
260
260
  ```
261
261
 
262
- #### `trigger_alarm`
263
-
264
- ```ts
265
- { action: 'trigger_alarm', thinking_content: '触发紧急会议' }
266
- ```
262
+ 独立 `trigger_alarm` 动作已移除。旧代码应改为在 `GameCrabSabotage.status === 'ready'` 时提交自己持有的破坏任务;不要在任务完成后再请求第二个动作。
267
263
 
268
264
  会议投票不属于 `GameAction`。Agent 或用户在会议阶段使用现有 `ccl vote`,由 Action Plugin 直接提交后端;Behavior 不预占 `meeting_vote` 控制域。
269
265
 
@@ -701,7 +697,7 @@ interface VisibleCorpse extends Position {
701
697
  | `GameOctopusTime` | `active`;可选 `remaining_secs` |
702
698
  | `GameWinner` | faction 胜利,或带具体 `player`、`role` 的 neutral 胜利 |
703
699
 
704
- `GameCrabSabotage.status` 可能为 `unprepared`、`ready`、`cooldown_unprepared`、`cooldown_charged` 或 `emergency_active`。
700
+ `GameCrabSabotage.status` 可能为 `ready`、`cooldown_charged` 或 `emergency_active`。`ready` 表示可执行自己持有的蟹破坏任务,另外两个状态都不得发起新破坏。
705
701
 
706
702
  ### 共享观察帧
707
703
 
@@ -26,7 +26,7 @@ Behavior 不直接连接服务器。它只返回 Action 请求;Runtime 负责
26
26
 
27
27
  ## 官方已经提供什么
28
28
 
29
- CCL 当前提供 33 个标准 Behavior。
29
+ CCL 当前提供 32 个标准 Behavior。
30
30
 
31
31
  20 个适合长程运行:
32
32
 
@@ -35,11 +35,11 @@ CCL 当前提供 33 个标准 Behavior。
35
35
  - 战斗:`kill-target`、`kill-lone`、`kill-frenzy`、`task-kill-report`、`lone-kill-task`;
36
36
  - 角色玩法:`crab-sabotage`、`shrimp-memory`、`warrior-memory`、`paradise-fish`。
37
37
 
38
- 13 个适合短任务:
38
+ 12 个适合短任务:
39
39
 
40
40
  - 移动与跟踪:`go_to`、`patrol_area`、`find_player`、`follow_player`;
41
41
  - 战斗与生存:`hunt_player`、`seek_kill_opportunity`、`evade`、`hide_temporarily`、`hold_position`;
42
- - 任务与现场操作:`do_task`、`inspect_corpse`、`report_corpse`、`trigger_alarm`。
42
+ - 任务与现场操作:`do_task`、`inspect_corpse`、`report_corpse`。
43
43
 
44
44
  它们都使用下面介绍的同一套公共接口,不存在官方特权执行路径。先查看本机版本的准确清单和参数:
45
45
 
@@ -280,10 +280,12 @@ parallel 模式可以让后续 tick 继续计算;serial 模式会等待前一
280
280
 
281
281
  ## 安装、启动和观察
282
282
 
283
+ Hub 的 `strategy` 资源在 CCL 0.8.x 中就是这一合同的 Behavior。当前 Hub 合同按一个资源对应一个顶层 `.ts` 或 `.js` 入口文件处理;文件必须默认导出一个 `ClawclawBehavior` 子类并包含唯一的字面量 `static manifest`。本地 Runtime 虽可加载同目录依赖树,Hub 本期单文件资源不要使用相对源码依赖。多个已装配 Strategy 只是同时进入 Behavior 目录,不会改变 `reflex > short > long` 和同层单 Activation 规则。
284
+
283
285
  把 `.ts` 或 `.js` 文件放在:
284
286
 
285
287
  ```text
286
- <workspace>/user-data/behaviors/
288
+ <workspace>/user-data/accounts/<account-hash>/behaviors/local/
287
289
  ```
288
290
 
289
291
  静态发现与检查:
@@ -297,7 +297,7 @@ Trigger 不等待当前 epoch 的 Perception 分析或提交。两者可以并
297
297
  把文件放在:
298
298
 
299
299
  ```text
300
- <workspace>/user-data/perceptions/
300
+ <workspace>/user-data/accounts/<account-hash>/perceptions/local/
301
301
  ```
302
302
 
303
303
  ```powershell
@@ -235,7 +235,7 @@ Trigger 的 Manifest 会被静态扫描器从源码字面量中读取。不要
235
235
  把 `.ts` 或 `.js` 文件放在:
236
236
 
237
237
  ```text
238
- <workspace>/user-data/triggers/
238
+ <workspace>/user-data/accounts/<account-hash>/triggers/local/
239
239
  ```
240
240
 
241
241
  先静态查看 Manifest,再配置并显式启用:
@@ -41,14 +41,14 @@
41
41
 
42
42
  同一 epoch 中,Perception 和 Trigger 独立读取同一观察帧,可以并行计算;Behavior 同时等待二者完成。Trigger 的 Event 输入排除 Perception 输出,只能申请启动配置中绑定的固定 Behavior;Action 仍由 Behavior Decision 经 Action Plugin 提交。
43
43
 
44
- 对社区公开的模块面只有三类:Behavior API v3、Trigger API v4、Perception API v2。当前包物化 33 个官方 Behavior 和 8 个官方 Perception,并运行官方 Trigger 同步管线;当前官方 Trigger 清单为空,所以不会生成 Trigger 文件,社区 Trigger 默认关闭。旧 Strategy/Intent 作者入口、目录和 Runtime Plugin 已删除,不是隐藏兼容层。
44
+ 对社区公开的模块面只有三类:Behavior API v3、Trigger API v4、Perception API v2。官方 Behavior、Perception 和 Persona 由 Hub loadout 提供,CLI 包不再向用户目录物化官方模块。纯本地模块按账号保存;Trigger 默认关闭。旧 Strategy/Intent 作者入口、目录和 Runtime Plugin 已删除,不是隐藏兼容层。
45
45
 
46
46
  `ccl speak`、`ccl vote`、`ccl aside` 是有意保留的 direct Agent Action:它们经 Owner、`Runtime.performAction({ kind: 'agent' })` 和 Action Plugin 直接提交,不会创建 Behavior Activation。Behavior 管理命令与这些通信命令不能混为一条生命周期。
47
47
 
48
- Behavior Host 管理 long、short、reflex 三层 Activation。serial Behavior 的持久 `decide()` 在 Owner 主线程运行;parallel Behavior 使用自适应 Worker Thread 池,预热 2 个、按压力扩到最多 10 个并在空闲后回收。Perception Plugin 默认加载八个官方模块,也可以通过工作区配置选择;普通 `update()` 与持久 `commit()` 在 Owner 主线程运行,`parallel_analysis` 使用独立的有界 Worker 池。
48
+ Behavior Host 管理 long、short、reflex 三层 Activation。角色确定后,CCL 立即尝试启动该账号为角色配置的默认 long Behavior;资源缺失或不可加载时只 warning 并保持 idle。serial Behavior 的持久 `decide()` 在 Owner 主线程运行;parallel Behavior 使用自适应 Worker Thread 池,预热 2 个、按压力扩到最多 10 个并在空闲后回收。Perception Plugin 加载当前账号 Hub 选择和未被本地 blacklist 禁用的纯本地模块;普通 `update()` 与持久 `commit()` 在 Owner 主线程运行,`parallel_analysis` 使用独立的有界 Worker 池。
49
49
 
50
- `ccl load` 和资源 `--list/--info` 在判定第三方资源 `loadable` 时只做静态 manifest 契约检查,
51
- 绝不 import 或执行第三方源码;命令仍可按物化规则同步未修改的官方副本。其中
50
+ `ccl load` 和资源 `--list/--info` 在判定资源 `loadable` 时只做静态 manifest 契约检查,
51
+ 绝不 import 或执行源码,也不从 CLI 包同步官方副本。其中
52
52
  `loadable: true` 不代表模块已经 import 或运行成功。Runtime 启动时才加载已启用模块并冻结插件图,
53
53
  因此源码、manifest 和 enable/disable 变化需要重启。自定义 Behavior、Perception 与 Trigger 源码
54
54
  都是与 CCL 同权限运行的受信任本地代码,Worker Thread 不是安全沙箱。房间就绪由 DerivedEvent
@@ -1,8 +1,8 @@
1
1
  # ClawClaw 官方感知模块
2
2
 
3
- 当前 ClawClaw Runtime 内置 8 个官方感知模块。它们都由同一个 `ClawclawPerceptionPlugin` 调度,把当前玩家可见的坐标 State 转成彼此独立的 `visual.*` Canonical Event;模块本身不直接唤醒 Agent,也不拼接跨模块叙事。同一 epoch 中,Perception 和 Trigger 独立读取同一观察帧并可并行计算;Trigger 不消费这些 `visual.*` 输出。Behavior 等待两条分支后,再执行最终选中的 long、short 或 reflex Activation。
3
+ 本页记录官方感知的语义契约。官方感知制品由 Hub loadout 提供,CLI 包不再把这些模块写入用户目录。它们由同一个 `ClawclawPerceptionPlugin` 调度,把当前玩家可见的坐标 State 转成彼此独立的 `visual.*` Canonical Event。
4
4
 
5
- 8 个模块会物化到 `user-data/perceptions/`,Runtime 只从该目录加载。manifest 已追踪且当前版本仍提供的官方 canonical 文件若缺失,`ccl load`、管理命令或 Owner 启动会从当前安装版本自动补回;禁用必须使用 `disabled_perception_modules`,删除文件不代表禁用。已修改副本和同 ID 用户替代入口仍受保护。
5
+ 实际加载集合以当前账号 `ccl load` 为准;Hub 选择不受本地 blacklist 影响。纯本地感知放在账号 `perceptions/local/`,Hub working copy 放在 `perceptions/hub/<resource-id>/`,并由账号 `gameplay.json` 控制本地项。
6
6
 
7
7
  ## 模块清单
8
8
 
@@ -28,7 +28,7 @@ Claude Code 加载 `clawclaw-channel` 后启动 MCP stdio 子进程。该进程
28
28
 
29
29
  ## 启动与重连
30
30
 
31
- Owner 打开 Runtime/SQLite,同步并静态发现 Behavior、Perception 与 Trigger 资源,读取 Trigger 配置和按角色 fallback,装载 Action、GameQuery、Perception、Trigger、Behavior、Mailbox 与输出 Adapter,启动 owner-control server,发布 `game-start.json`,然后启动 Source。当前官方 Trigger 清单为空;社区 Trigger 默认禁用,只有启用且绑定到可加载 Behavior 的 Trigger 才进入有效注册表,并在需要运行时延迟 import。Behavior Host 使用固定 `reflex > short > long` 控制顺序,并把配置中的 `idle_ms` 应用于 short/边界后的交还和 idle fallback;缺省值为 500ms。
31
+ Owner 打开 Runtime/SQLite,读取当前账号已解析的 Hub/本地资源、Trigger 配置和分角色默认 long,装载 Action、GameQuery、Perception、Trigger、Behavior、Mailbox 与输出 Adapter,然后启动 Source。角色确定后默认 long 立即启动;缺失只 warning + idle。Behavior Host 使用固定 `reflex > short > long`,`idle_ms` 只用于 short/边界后的交还。
32
32
 
33
33
  `--agent-type claude-code` 本身只标识宿主;只有同时设置 `CLAWCLAW_ENABLE_CLAUDE_CHANNELS=1` 才启用 Claude Channel 输出,否则使用默认 Monitor 路由。两种路由都不改变账号选择和游戏生命周期。
34
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -24,7 +24,12 @@
24
24
  "bin/",
25
25
  "src/",
26
26
  "!src/assets/clawclaw-ascii-map.txt",
27
- "personas/",
27
+ "!src/**/*.test.ts",
28
+ "!src/lib/behavior-export.ts",
29
+ "!src/lib/official-resource-sync.ts",
30
+ "!src/lib/perception-export.ts",
31
+ "!src/lib/trigger-export.ts",
32
+ "!src/runtime/clawclaw/plugins/perception/modules/",
28
33
  "scripts/",
29
34
  "skills/",
30
35
  "QUICKSTART.md",
@@ -44,6 +49,7 @@
44
49
  "check:frontend-map": "node scripts/sync-frontend-map.mjs --check",
45
50
  "replay:perception": "tsx scripts/replay-perception.ts",
46
51
  "compare:perception": "tsx scripts/compare-perception-replays.ts",
52
+ "build:hub-official-behaviors": "node scripts/build-official-hub-behaviors.mjs",
47
53
  "watch:perception": "tsx scripts/watch-perception-events.ts",
48
54
  "prepack": "node scripts/package-readme.mjs prepare",
49
55
  "postpack": "node scripts/package-readme.mjs restore",
@@ -64,6 +70,7 @@
64
70
  "devDependencies": {
65
71
  "@types/node": "^22.20.1",
66
72
  "@types/ws": "^8.5.10",
73
+ "esbuild": "^0.28.2",
67
74
  "typescript": "^5.4.0",
68
75
  "vitest": "^3.1.0"
69
76
  }
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ import { build } from 'esbuild';
3
+ import { createHash } from 'node:crypto';
4
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
5
+ import { dirname, join, resolve } from 'node:path';
6
+ import { fileURLToPath, pathToFileURL } from 'node:url';
7
+
8
+ const scriptDir = dirname(fileURLToPath(import.meta.url));
9
+ const packageRoot = resolve(scriptDir, '..');
10
+ const PUBLIC_BEHAVIOR_PLUGIN = '@myclaw163/clawclaw-cli/behavior-plugin';
11
+
12
+ export const OFFICIAL_HUB_BEHAVIORS = Object.freeze([
13
+ { id: 'task-only', resourceId: '24b6cdd8-4766-40e8-b1c4-e669db00a3ed', className: 'TaskOnlyStrategy', source: 'src/hub-official-behaviors/task-only.ts' },
14
+ { id: 'patrol', resourceId: 'a73edbd3-5476-4d23-9164-03d2655fc7c3', className: 'PatrolStrategy', source: 'src/hub-official-behaviors/patrol.ts' },
15
+ { id: 'do_task', resourceId: 'fbbbc2b1-9b71-49d1-9c48-5e5392f551dc', className: 'DoTaskBehavior', source: 'src/behaviors/official-finite/do-task.ts' },
16
+ { id: 'kill-lone', resourceId: '5dc062b3-aa53-4155-ab56-15b7b20eaf63', className: 'KillLoneStrategy', source: 'src/hub-official-behaviors/kill-lone.ts' },
17
+ { id: 'report_corpse', resourceId: '59bdc29e-1b8a-4ac4-99dc-9df359ce3b42', className: 'ReportCorpseBehavior', source: 'src/behaviors/official-finite/report-corpse.ts' },
18
+ { id: 'hunt_player', resourceId: 'd3f15d94-edca-4acb-accc-a0d0b6583ad7', className: 'HuntPlayerBehavior', source: 'src/behaviors/official-finite/hunt-player.ts' },
19
+ ]);
20
+
21
+ function externalizePublicBehaviorPlugin() {
22
+ return {
23
+ name: 'externalize-public-behavior-plugin',
24
+ setup(buildApi) {
25
+ buildApi.onResolve({ filter: /sdk[\\/]behavior-plugin[\\/]index\.js$/ }, () => ({
26
+ path: PUBLIC_BEHAVIOR_PLUGIN,
27
+ external: true,
28
+ }));
29
+ },
30
+ };
31
+ }
32
+
33
+ function restoreStaticDefaultClass(source, definition) {
34
+ const declaration = new RegExp(
35
+ `var\\s+${definition.className}\\s*=\\s*class\\s+extends\\s+ClawclawBehavior`,
36
+ );
37
+ if (!declaration.test(source)) {
38
+ throw new Error(`bundled_default_class_not_found:${definition.id}`);
39
+ }
40
+ const restored = source
41
+ .replace(
42
+ declaration,
43
+ `export default class ${definition.className} extends ClawclawBehavior`,
44
+ )
45
+ .replace(
46
+ new RegExp(`\\nexport\\s*\\{\\s*${definition.className}\\s+as\\s+default\\s*\\};?\\s*$`),
47
+ '\n',
48
+ );
49
+ if (!restored.includes(`export default class ${definition.className} extends ClawclawBehavior`)) {
50
+ throw new Error(`bundled_default_class_restore_failed:${definition.id}`);
51
+ }
52
+ return restored;
53
+ }
54
+
55
+ function assertSelfContained(source, definition) {
56
+ if (/clawclaw-internal:/.test(source)) {
57
+ throw new Error(`bundled_internal_alias_remaining:${definition.id}`);
58
+ }
59
+ const imports = [...source.matchAll(/(?:from\s+|import\s*)["']([^"']+)["']/g)]
60
+ .map((match) => match[1]);
61
+ const unsupported = imports.filter((specifier) => specifier !== PUBLIC_BEHAVIOR_PLUGIN);
62
+ if (unsupported.length > 0) {
63
+ throw new Error(`bundled_external_import_remaining:${definition.id}:${unsupported.join(',')}`);
64
+ }
65
+ if (!source.includes(`id: "${definition.id}"`) && !source.includes(`id: '${definition.id}'`)) {
66
+ throw new Error(`bundled_manifest_id_missing:${definition.id}`);
67
+ }
68
+ }
69
+
70
+ export async function buildOfficialHubBehaviors(outDir) {
71
+ const outputRoot = resolve(outDir);
72
+ rmSync(outputRoot, { recursive: true, force: true });
73
+ mkdirSync(outputRoot, { recursive: true });
74
+ const built = [];
75
+ for (const definition of OFFICIAL_HUB_BEHAVIORS) {
76
+ const outputPath = join(outputRoot, `${definition.id}.ts`);
77
+ await build({
78
+ entryPoints: [resolve(packageRoot, definition.source)],
79
+ outfile: outputPath,
80
+ bundle: true,
81
+ write: true,
82
+ format: 'esm',
83
+ platform: 'node',
84
+ target: 'node22',
85
+ charset: 'utf8',
86
+ legalComments: 'none',
87
+ sourcemap: false,
88
+ minify: false,
89
+ treeShaking: true,
90
+ external: [PUBLIC_BEHAVIOR_PLUGIN],
91
+ plugins: [externalizePublicBehaviorPlugin()],
92
+ banner: {
93
+ js: `// Self-contained official Hub Behavior '${definition.id}'.\n// Generated from ${definition.source}; only the public Behavior SDK remains external.`,
94
+ },
95
+ });
96
+ const bundled = restoreStaticDefaultClass(readFileSync(outputPath, 'utf8'), definition);
97
+ assertSelfContained(bundled, definition);
98
+ writeFileSync(outputPath, bundled, 'utf8');
99
+ built.push({
100
+ ...definition,
101
+ outputPath,
102
+ bytes: Buffer.byteLength(bundled),
103
+ sha256: createHash('sha256').update(bundled).digest('hex'),
104
+ });
105
+ }
106
+ writeFileSync(join(outputRoot, 'manifest.json'), `${JSON.stringify({
107
+ schema: 'clawclaw.official-hub-behaviors.v1',
108
+ generatedAt: new Date().toISOString(),
109
+ behaviors: built.map(({ id, resourceId, source, outputPath, bytes, sha256 }) => ({
110
+ id,
111
+ resourceId,
112
+ source,
113
+ file: outputPath.slice(outputRoot.length + 1).replaceAll('\\', '/'),
114
+ bytes,
115
+ sha256,
116
+ })),
117
+ }, null, 2)}\n`, 'utf8');
118
+ return built;
119
+ }
120
+
121
+ function parseOutDir(argv) {
122
+ const index = argv.indexOf('--out-dir');
123
+ if (index < 0 || !argv[index + 1]) {
124
+ throw new Error('Usage: npm run build:hub-official-behaviors -- --out-dir <directory>');
125
+ }
126
+ return argv[index + 1];
127
+ }
128
+
129
+ const entry = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : '';
130
+ if (import.meta.url === entry) {
131
+ const built = await buildOfficialHubBehaviors(parseOutDir(process.argv.slice(2)));
132
+ process.stdout.write(`${JSON.stringify({
133
+ output_dir: resolve(parseOutDir(process.argv.slice(2))),
134
+ behaviors: built.map(({ id, outputPath, bytes, sha256 }) => ({ id, path: outputPath, bytes, sha256 })),
135
+ }, null, 2)}\n`);
136
+ }