@myclaw163/clawclaw-cli 0.8.4 → 0.8.6

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 (330) 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/behavior.md +10 -19
  5. package/docs/custom-modules/perception.md +1 -1
  6. package/docs/custom-modules/trigger.md +1 -1
  7. package/docs/runtime/README.md +4 -4
  8. package/docs/runtime/official-perception-modules.md +2 -2
  9. package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
  10. package/package.json +15 -2
  11. package/scripts/enable_ccl_permissions.cjs +4 -2
  12. package/scripts/find-hide-spots.py +2 -2
  13. package/scripts/postinstall.mjs +1 -4
  14. package/scripts/sync-bundled-skill.mjs +12 -159
  15. package/skills/clawclaw/SKILL.md +25 -18
  16. package/skills/clawclaw/references/BEHAVIORS.md +15 -11
  17. package/skills/clawclaw/references/COMMANDS.md +45 -41
  18. package/skills/clawclaw/references/HUB.md +25 -38
  19. package/skills/clawclaw/references/TACTICS.md +1 -1
  20. package/src/commands/account.ts +58 -14
  21. package/src/commands/behavior.ts +116 -38
  22. package/src/commands/hub.ts +110 -153
  23. package/src/commands/load.ts +138 -33
  24. package/src/commands/perception.ts +55 -24
  25. package/src/commands/persona.ts +66 -20
  26. package/src/commands/skill.ts +12 -48
  27. package/src/commands/trigger.ts +68 -40
  28. package/src/lib/account-guidance.ts +54 -9
  29. package/src/lib/agent-workspace-client.ts +135 -0
  30. package/src/lib/agent-workspace-runtime.ts +154 -0
  31. package/src/lib/agent-workspace-skills.ts +177 -0
  32. package/src/lib/agent-workspace-sync.ts +852 -0
  33. package/src/lib/gameplay-config.ts +29 -15
  34. package/src/lib/hub-client.ts +252 -34
  35. package/src/lib/hub-reminder.ts +24 -11
  36. package/src/lib/init-command.ts +0 -6
  37. package/src/lib/load-context.ts +12 -6
  38. package/src/lib/persona.ts +141 -69
  39. package/src/lib/server-status.ts +78 -0
  40. package/src/lib/skill-host.ts +160 -0
  41. package/src/lib/user-data.ts +197 -4
  42. package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
  43. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
  44. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
  45. package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
  46. package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
  47. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
  48. package/src/runtime/clawclaw/owner.ts +63 -19
  49. package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
  50. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
  51. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
  52. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
  53. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  54. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  55. package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
  56. package/src/sdk/behavior-toolkit/escape.ts +2 -2
  57. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  58. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  59. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  60. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  61. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  62. package/scripts/compare-perception-replays.test.ts +0 -188
  63. package/scripts/enable_ccl_permissions.test.mjs +0 -163
  64. package/scripts/enable_monitor.test.mjs +0 -201
  65. package/scripts/sync-bundled-skill.test.mjs +0 -152
  66. package/scripts/watch-perception-events.test.ts +0 -43
  67. package/src/behaviors/official-finite/do-task.ts +0 -211
  68. package/src/behaviors/official-finite/evade.ts +0 -78
  69. package/src/behaviors/official-finite/find-player.ts +0 -50
  70. package/src/behaviors/official-finite/follow-player.ts +0 -70
  71. package/src/behaviors/official-finite/go-to.ts +0 -69
  72. package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
  73. package/src/behaviors/official-finite/hold-position.ts +0 -48
  74. package/src/behaviors/official-finite/hunt-player.ts +0 -47
  75. package/src/behaviors/official-finite/index.test.ts +0 -249
  76. package/src/behaviors/official-finite/index.ts +0 -44
  77. package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
  78. package/src/behaviors/official-finite/patrol-area.ts +0 -80
  79. package/src/behaviors/official-finite/report-corpse.ts +0 -73
  80. package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
  81. package/src/behaviors/official-finite/shared.ts +0 -27
  82. package/src/channel/claude-channel-server.test.ts +0 -202
  83. package/src/commands/account.test.ts +0 -570
  84. package/src/commands/behavior.test.ts +0 -158
  85. package/src/commands/communication.test.ts +0 -282
  86. package/src/commands/competition.test.ts +0 -116
  87. package/src/commands/data.test.ts +0 -89
  88. package/src/commands/events-canonical-state.test.ts +0 -406
  89. package/src/commands/events.test.ts +0 -58
  90. package/src/commands/game/index.test.ts +0 -1251
  91. package/src/commands/game-map.test.ts +0 -69
  92. package/src/commands/hub.test.ts +0 -124
  93. package/src/commands/load.test.ts +0 -440
  94. package/src/commands/perception.test.ts +0 -75
  95. package/src/commands/setup/hermes.test.ts +0 -96
  96. package/src/commands/setup/openclaw.test.ts +0 -124
  97. package/src/commands/trigger.test.ts +0 -140
  98. package/src/commands/upgrade.test.ts +0 -82
  99. package/src/lib/account-guidance.test.ts +0 -36
  100. package/src/lib/auth.test.ts +0 -151
  101. package/src/lib/behavior-export.test.ts +0 -326
  102. package/src/lib/behavior-export.ts +0 -537
  103. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  104. package/src/lib/custom-tts.test.ts +0 -387
  105. package/src/lib/diagnostics-config.test.ts +0 -59
  106. package/src/lib/game-client-tts.test.ts +0 -151
  107. package/src/lib/game-client.test.ts +0 -250
  108. package/src/lib/gameplay-config.test.ts +0 -301
  109. package/src/lib/host-config-patcher.test.ts +0 -130
  110. package/src/lib/http-transport.test.ts +0 -124
  111. package/src/lib/hub-client.test.ts +0 -57
  112. package/src/lib/hub-install.test.ts +0 -135
  113. package/src/lib/hub-install.ts +0 -185
  114. package/src/lib/hub-unzip.test.ts +0 -69
  115. package/src/lib/init-command.test.ts +0 -103
  116. package/src/lib/load-context.test.ts +0 -62
  117. package/src/lib/match-state.test.ts +0 -134
  118. package/src/lib/official-resource-sync.test.ts +0 -199
  119. package/src/lib/official-resource-sync.ts +0 -221
  120. package/src/lib/perception-config.test.ts +0 -143
  121. package/src/lib/perception-export.test.ts +0 -145
  122. package/src/lib/perception-export.ts +0 -178
  123. package/src/lib/persona.test.ts +0 -84
  124. package/src/lib/room.test.ts +0 -88
  125. package/src/lib/server-registry.test.ts +0 -64
  126. package/src/lib/service-status.test.ts +0 -81
  127. package/src/lib/skill-version.test.ts +0 -48
  128. package/src/lib/trigger-config.test.ts +0 -102
  129. package/src/lib/trigger-export.test.ts +0 -80
  130. package/src/lib/trigger-export.ts +0 -210
  131. package/src/lib/user-data.test.ts +0 -121
  132. package/src/lib/workspace-argv.test.ts +0 -49
  133. package/src/pipeline/canonical-event-presentation.test.ts +0 -257
  134. package/src/pipeline/event-format.test.ts +0 -879
  135. package/src/pipeline/event-hints.test.ts +0 -337
  136. package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
  137. package/src/pipeline/player-projection.test.ts +0 -247
  138. package/src/runtime/auto-upgrade.test.ts +0 -66
  139. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  140. package/src/runtime/canonical-monitor.test.ts +0 -577
  141. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
  142. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  143. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  144. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  145. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  146. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  147. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  148. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  149. package/src/runtime/clawclaw/owner.test.ts +0 -203
  150. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
  151. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  152. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  153. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
  154. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  155. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  156. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  157. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  158. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  159. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
  160. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  161. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  162. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  163. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  164. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  165. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  166. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  167. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  168. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  169. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  170. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  171. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  172. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  173. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  174. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  175. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  176. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  177. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  178. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  179. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  180. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  181. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  182. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  183. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  184. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  185. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  186. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  187. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  188. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  189. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  190. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  191. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  192. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  193. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  194. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  195. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
  196. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  197. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  198. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  199. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  200. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  201. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  202. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  203. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  204. package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
  205. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  206. package/src/runtime/framework/capability-registry.test.ts +0 -423
  207. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  208. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  209. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  210. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  211. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  212. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  213. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  214. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  215. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  216. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  217. package/src/runtime/framework/participation-manager.test.ts +0 -108
  218. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  219. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  220. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  221. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  222. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  223. package/src/runtime/framework/state/state-core.test.ts +0 -197
  224. package/src/runtime/game-sync-protocol.test.ts +0 -123
  225. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  226. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  227. package/src/runtime/observability/observability.test.ts +0 -583
  228. package/src/runtime/owner-control.test.ts +0 -153
  229. package/src/runtime/parent-process-watch.test.ts +0 -27
  230. package/src/runtime/pending-event-handoff.test.ts +0 -29
  231. package/src/runtime/raw-ws-log.test.ts +0 -102
  232. package/src/runtime/runtime-logger.test.ts +0 -58
  233. package/src/runtime/runtime-persistence.test.ts +0 -26
  234. package/src/runtime/runtime.test.ts +0 -1770
  235. package/src/runtime/ws-client.test.ts +0 -562
  236. package/src/sdk/action.test.ts +0 -8
  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/avoid-lone.ts +0 -32
  249. package/src/strategies/avoid-players.ts +0 -43
  250. package/src/strategies/corpse-patrol.ts +0 -50
  251. package/src/strategies/crab-sabotage.ts +0 -48
  252. package/src/strategies/custom-module.test.ts +0 -267
  253. package/src/strategies/find-player.ts +0 -49
  254. package/src/strategies/game-utils.test.ts +0 -305
  255. package/src/strategies/game-utils.ts +0 -927
  256. package/src/strategies/goals/anchor-linger.ts +0 -77
  257. package/src/strategies/goals/avoid-lone-top.ts +0 -189
  258. package/src/strategies/goals/avoid-players-top.test.ts +0 -95
  259. package/src/strategies/goals/avoid-players-top.ts +0 -122
  260. package/src/strategies/goals/conversation-goal.ts +0 -51
  261. package/src/strategies/goals/corpse-patrol-top.ts +0 -120
  262. package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
  263. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
  264. package/src/strategies/goals/crab-sabotage-top.ts +0 -139
  265. package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
  266. package/src/strategies/goals/find-player-top.ts +0 -136
  267. package/src/strategies/goals/flee-players-goal.ts +0 -55
  268. package/src/strategies/goals/follow-companion-goal.ts +0 -130
  269. package/src/strategies/goals/goal-manager.ts +0 -41
  270. package/src/strategies/goals/goal-root-strategy.ts +0 -49
  271. package/src/strategies/goals/goal.ts +0 -28
  272. package/src/strategies/goals/hide-top.ts +0 -240
  273. package/src/strategies/goals/keep-away-goal.ts +0 -243
  274. package/src/strategies/goals/kill-frenzy-top.ts +0 -90
  275. package/src/strategies/goals/kill-lone-top.test.ts +0 -96
  276. package/src/strategies/goals/kill-lone-top.ts +0 -166
  277. package/src/strategies/goals/kill-target-goal.ts +0 -69
  278. package/src/strategies/goals/kill-target-top.test.ts +0 -65
  279. package/src/strategies/goals/kill-target-top.ts +0 -121
  280. package/src/strategies/goals/leaf-goal.ts +0 -27
  281. package/src/strategies/goals/linger-corpse-goal.ts +0 -43
  282. package/src/strategies/goals/lone-kill-core.ts +0 -86
  283. package/src/strategies/goals/lone-kill-goal.ts +0 -24
  284. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
  285. package/src/strategies/goals/lone-kill-task-top.ts +0 -133
  286. package/src/strategies/goals/move-room-goal.ts +0 -102
  287. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
  288. package/src/strategies/goals/normal-shrimp-top.ts +0 -248
  289. package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
  290. package/src/strategies/goals/paradise-fish-top.ts +0 -234
  291. package/src/strategies/goals/patrol-top.ts +0 -68
  292. package/src/strategies/goals/report-patrol-top.ts +0 -97
  293. package/src/strategies/goals/safe-task-goal.ts +0 -130
  294. package/src/strategies/goals/social-task-top.ts +0 -192
  295. package/src/strategies/goals/task-kill-report-top.ts +0 -187
  296. package/src/strategies/goals/task-only-top.test.ts +0 -88
  297. package/src/strategies/goals/task-only-top.ts +0 -64
  298. package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
  299. package/src/strategies/goals/task-report-top.ts +0 -57
  300. package/src/strategies/goals/wander-task-goal.ts +0 -33
  301. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
  302. package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
  303. package/src/strategies/greeting.ts +0 -60
  304. package/src/strategies/hide.ts +0 -51
  305. package/src/strategies/kill-frenzy.ts +0 -32
  306. package/src/strategies/kill-lone.ts +0 -52
  307. package/src/strategies/kill-target.ts +0 -48
  308. package/src/strategies/lone-kill-task.ts +0 -48
  309. package/src/strategies/meeting-gate.test.ts +0 -59
  310. package/src/strategies/meeting-gate.ts +0 -28
  311. package/src/strategies/move-room.ts +0 -46
  312. package/src/strategies/official-long-behavior.test.ts +0 -89
  313. package/src/strategies/paradise-fish.ts +0 -70
  314. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  315. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  316. package/src/strategies/patrol.ts +0 -32
  317. package/src/strategies/player-targets.test.ts +0 -10
  318. package/src/strategies/player-targets.ts +0 -18
  319. package/src/strategies/report-patrol.ts +0 -32
  320. package/src/strategies/shrimp-memory.ts +0 -87
  321. package/src/strategies/social-task.ts +0 -67
  322. package/src/strategies/speech-module.ts +0 -123
  323. package/src/strategies/task-kill-report.ts +0 -49
  324. package/src/strategies/task-only.test.ts +0 -138
  325. package/src/strategies/task-only.ts +0 -34
  326. package/src/strategies/task-report.ts +0 -50
  327. package/src/strategies/types.ts +0 -116
  328. package/src/strategies/warrior-memory.ts +0 -54
  329. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
  330. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
@@ -1,537 +0,0 @@
1
- // Materialize every bundled long and finite Behavior into one persistent
2
- // authoring directory. Runtime discovery remains static: no module is imported
3
- // until an Activation explicitly prepares it.
4
- import {
5
- existsSync,
6
- readFileSync,
7
- readdirSync,
8
- unlinkSync,
9
- } from 'node:fs';
10
- import { createHash } from 'node:crypto';
11
- import {
12
- basename,
13
- dirname,
14
- join,
15
- resolve,
16
- } from 'node:path';
17
- import { fileURLToPath } from 'node:url';
18
- import { getWorkspaceDir } from './init-command.js';
19
- import {
20
- hashOfficialResourceContent,
21
- isOfficialResourceUnmodified,
22
- readOfficialResourceManifest,
23
- syncOfficialResources,
24
- writeOfficialResourceManifest,
25
- type OfficialResourceManifestEntry,
26
- type OfficialResourceSyncResult,
27
- } from './official-resource-sync.js';
28
- import {
29
- ensureUserDataLayout,
30
- getUserDataBehaviorsDir,
31
- getUserDataOfficialBehaviorsManifestFile,
32
- } from './user-data.js';
33
- import { isClawclawFixedEventType } from '../runtime/clawclaw-event-catalog.js';
34
- import { ClawclawBehaviorCatalog } from '../runtime/clawclaw/plugins/behavior/behavior-catalog.js';
35
- import {
36
- listClawclawBehaviorSources,
37
- type ClawclawBehaviorSourceProvenance,
38
- type ResolvedClawclawBehaviorSource,
39
- } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
40
- import { deepFreezeBehaviorValue } from '../runtime/clawclaw/plugins/behavior/behavior-manifest.js';
41
-
42
- const OFFICIAL_BEHAVIOR_EXPORT_FORMAT = 1 as const;
43
- const RETIRED_OFFICIAL_BEHAVIOR_IDS = new Set(['trigger_alarm']);
44
-
45
- const OFFICIAL_LONG_BEHAVIOR_FILES = Object.freeze([
46
- 'avoid-lone.ts',
47
- 'avoid-players.ts',
48
- 'corpse-patrol.ts',
49
- 'crab-sabotage.ts',
50
- 'find-player.ts',
51
- 'hide.ts',
52
- 'kill-frenzy.ts',
53
- 'kill-lone.ts',
54
- 'kill-target.ts',
55
- 'lone-kill-task.ts',
56
- 'move-room.ts',
57
- 'paradise-fish.ts',
58
- 'patrol.ts',
59
- 'report-patrol.ts',
60
- 'shrimp-memory.ts',
61
- 'social-task.ts',
62
- 'task-kill-report.ts',
63
- 'task-only.ts',
64
- 'task-report.ts',
65
- 'warrior-memory.ts',
66
- ] as const);
67
-
68
- const OFFICIAL_FINITE_BEHAVIOR_FILES = Object.freeze([
69
- 'do-task.ts',
70
- 'evade.ts',
71
- 'find-player.ts',
72
- 'follow-player.ts',
73
- 'go-to.ts',
74
- 'hide-temporarily.ts',
75
- 'hold-position.ts',
76
- 'hunt-player.ts',
77
- 'inspect-corpse.ts',
78
- 'patrol-area.ts',
79
- 'report-corpse.ts',
80
- 'seek-kill-opportunity.ts',
81
- ] as const);
82
-
83
- export type OfficialBehaviorFamily = 'long' | 'finite';
84
-
85
- export interface OfficialBehaviorProvenance {
86
- readonly kind: 'clawclaw.official-behavior';
87
- readonly family: OfficialBehaviorFamily;
88
- /** Package-relative source identity, never a machine-local absolute path. */
89
- readonly source: string;
90
- readonly materializationFormat: typeof OFFICIAL_BEHAVIOR_EXPORT_FORMAT;
91
- }
92
-
93
- export interface OfficialBehaviorManifestEntry extends OfficialResourceManifestEntry {
94
- readonly provenance?: OfficialBehaviorProvenance;
95
- }
96
-
97
- export type OfficialBehaviorManifest = Record<string, OfficialBehaviorManifestEntry>;
98
-
99
- interface BundledOfficialBehaviorSource {
100
- readonly id: string;
101
- readonly className: string;
102
- readonly family: OfficialBehaviorFamily;
103
- readonly fileName: string;
104
- readonly path: string;
105
- readonly source: string;
106
- readonly manifestObject: string;
107
- readonly provenance: OfficialBehaviorProvenance;
108
- readonly sourceHash: string;
109
- }
110
-
111
- function packageSourceRoot(): string {
112
- return join(dirname(fileURLToPath(import.meta.url)), '..');
113
- }
114
-
115
- function readPackageVersion(): string {
116
- try {
117
- const path = join(packageSourceRoot(), '..', 'package.json');
118
- const parsed = JSON.parse(readFileSync(path, 'utf8')) as { version?: unknown };
119
- return typeof parsed.version === 'string' ? parsed.version : '0.0.0';
120
- } catch {
121
- return '0.0.0';
122
- }
123
- }
124
-
125
- function balancedObject(source: string, open: number): string | null {
126
- let depth = 0;
127
- let quote: "'" | '"' | '`' | undefined;
128
- let escaped = false;
129
- let lineComment = false;
130
- let blockComment = false;
131
- for (let index = open; index < source.length; index += 1) {
132
- const char = source[index]!;
133
- const next = source[index + 1];
134
- if (lineComment) {
135
- if (char === '\n' || char === '\r') lineComment = false;
136
- continue;
137
- }
138
- if (blockComment) {
139
- if (char === '*' && next === '/') {
140
- blockComment = false;
141
- index += 1;
142
- }
143
- continue;
144
- }
145
- if (quote) {
146
- if (escaped) escaped = false;
147
- else if (char === '\\') escaped = true;
148
- else if (char === quote) quote = undefined;
149
- continue;
150
- }
151
- if (char === '/' && next === '/') {
152
- lineComment = true;
153
- index += 1;
154
- continue;
155
- }
156
- if (char === '/' && next === '*') {
157
- blockComment = true;
158
- index += 1;
159
- continue;
160
- }
161
- if (char === "'" || char === '"' || char === '`') {
162
- quote = char;
163
- continue;
164
- }
165
- if (char === '{') depth += 1;
166
- else if (char === '}' && --depth === 0) return source.slice(open, index + 1);
167
- }
168
- return null;
169
- }
170
-
171
- function parseBundledBehavior(
172
- family: OfficialBehaviorFamily,
173
- fileName: string,
174
- ): BundledOfficialBehaviorSource {
175
- const relativeSource = family === 'long'
176
- ? `strategies/${fileName}`
177
- : `behaviors/official-finite/${fileName}`;
178
- const path = join(packageSourceRoot(), ...relativeSource.split('/'));
179
- if (!existsSync(path)) throw new Error(`Bundled Behavior source '${relativeSource}' is missing.`);
180
- const source = readFileSync(path, 'utf8');
181
- const classMatch = /export\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends\s+ClawclawBehavior(?:\s*<[\s\S]{0,1000}?>)?\s*\{/.exec(source);
182
- if (!classMatch) {
183
- throw new Error(`Bundled Behavior '${relativeSource}' is not a direct ClawclawBehavior class.`);
184
- }
185
- const manifestMatch = /\bstatic\s+(?:override\s+)?(?:readonly\s+)?manifest\s*=\s*\{/.exec(source);
186
- if (!manifestMatch) throw new Error(`Bundled Behavior '${relativeSource}' has no literal manifest.`);
187
- const manifestOpen = manifestMatch.index + manifestMatch[0].lastIndexOf('{');
188
- const manifestObject = balancedObject(source, manifestOpen);
189
- if (!manifestObject) throw new Error(`Bundled Behavior '${relativeSource}' has an invalid manifest.`);
190
- const id = /\bid\s*:\s*(['"])([a-z0-9][a-z0-9._-]*)\1/.exec(manifestObject)?.[2];
191
- if (!id) throw new Error(`Bundled Behavior '${relativeSource}' has no literal id.`);
192
- const provenance: OfficialBehaviorProvenance = Object.freeze({
193
- kind: 'clawclaw.official-behavior',
194
- family,
195
- source: relativeSource,
196
- materializationFormat: OFFICIAL_BEHAVIOR_EXPORT_FORMAT,
197
- });
198
- return Object.freeze({
199
- id,
200
- className: classMatch[1]!,
201
- family,
202
- fileName,
203
- path,
204
- source,
205
- manifestObject,
206
- provenance,
207
- sourceHash: hashOfficialResourceContent(
208
- `${source}\0behavior-export-v${OFFICIAL_BEHAVIOR_EXPORT_FORMAT}\0${JSON.stringify(provenance)}`,
209
- ),
210
- });
211
- }
212
-
213
- function listBundledOfficialBehaviorSources(): readonly BundledOfficialBehaviorSource[] {
214
- const sources = [
215
- ...OFFICIAL_LONG_BEHAVIOR_FILES.map((file) => parseBundledBehavior('long', file)),
216
- ...OFFICIAL_FINITE_BEHAVIOR_FILES.map((file) => parseBundledBehavior('finite', file)),
217
- ];
218
- const ids = new Set<string>();
219
- for (const source of sources) {
220
- if (ids.has(source.id)) throw new Error(`Duplicate bundled Behavior id '${source.id}'.`);
221
- ids.add(source.id);
222
- }
223
- if (sources.filter(({ family }) => family === 'long').length !== 20) {
224
- throw new Error('Expected exactly 20 bundled long Behaviors.');
225
- }
226
- if (sources.filter(({ family }) => family === 'finite').length !== 12) {
227
- throw new Error('Expected exactly 12 bundled finite Behaviors.');
228
- }
229
- return Object.freeze(sources);
230
- }
231
-
232
- /** Stable, non-executable metadata for tooling and tests. */
233
- export function listOfficialBehaviorDefinitions(): readonly Readonly<{
234
- id: string;
235
- family: OfficialBehaviorFamily;
236
- provenance: OfficialBehaviorProvenance;
237
- sourceHash: string;
238
- }>[] {
239
- return listBundledOfficialBehaviorSources().map((source) => Object.freeze({
240
- id: source.id,
241
- family: source.family,
242
- provenance: source.provenance,
243
- sourceHash: source.sourceHash,
244
- }));
245
- }
246
-
247
- function materializeBehavior(source: BundledOfficialBehaviorSource, version: string): string {
248
- const provenance = JSON.stringify(source.provenance);
249
- return [
250
- `// Materialized from official ${source.family} Behavior ${source.id}@${version}.`,
251
- `// provenance: ${provenance}`,
252
- `import {`,
253
- ` ClawclawBehavior,`,
254
- ` type BehaviorDecision,`,
255
- ` type BehaviorInput,`,
256
- ` type BehaviorNormalizationApi,`,
257
- ` type BehaviorReadApi,`,
258
- `} from '@myclaw163/clawclaw-cli/behavior-plugin';`,
259
- `import OfficialBehavior from 'clawclaw-internal:official-behavior/${source.id}';`,
260
- '',
261
- `type AnyBehaviorInput = Readonly<Record<string, unknown>>;`,
262
- `type OfficialBehaviorDelegate = {`,
263
- ` normalize?: (input: AnyBehaviorInput, api: BehaviorNormalizationApi) => AnyBehaviorInput;`,
264
- ` decide: (`,
265
- ` input: Readonly<BehaviorInput<AnyBehaviorInput>>,`,
266
- ` api: BehaviorReadApi,`,
267
- ` ) => BehaviorDecision | void | Promise<BehaviorDecision | void>;`,
268
- `};`,
269
- '',
270
- `export default class ${source.className} extends ClawclawBehavior<AnyBehaviorInput> {`,
271
- ` static override readonly manifest = ${source.manifestObject} as const;`,
272
- '',
273
- ` private readonly implementation = new OfficialBehavior() as unknown as OfficialBehaviorDelegate;`,
274
- '',
275
- ` override normalize(input: AnyBehaviorInput, api: BehaviorNormalizationApi): AnyBehaviorInput {`,
276
- ` return this.implementation.normalize?.(input, api) ?? input;`,
277
- ` }`,
278
- '',
279
- ` override decide(`,
280
- ` input: Readonly<BehaviorInput<AnyBehaviorInput>>,`,
281
- ` api: BehaviorReadApi,`,
282
- ` ): BehaviorDecision | void | Promise<BehaviorDecision | void> {`,
283
- ` return this.implementation.decide(input, api);`,
284
- ` }`,
285
- `}`,
286
- '',
287
- ].join('\n');
288
- }
289
-
290
- function sameProvenance(
291
- value: OfficialBehaviorProvenance | undefined,
292
- expected: OfficialBehaviorProvenance,
293
- ): boolean {
294
- return value?.kind === expected.kind
295
- && value.family === expected.family
296
- && value.source === expected.source
297
- && value.materializationFormat === expected.materializationFormat;
298
- }
299
-
300
- export function readOfficialBehaviorManifest(workspaceDir = getWorkspaceDir()): OfficialBehaviorManifest {
301
- return readOfficialResourceManifest(
302
- getUserDataOfficialBehaviorsManifestFile(workspaceDir),
303
- ) as OfficialBehaviorManifest;
304
- }
305
-
306
- function recordOfficialBehaviorProvenance(
307
- workspaceDir: string,
308
- sources: readonly BundledOfficialBehaviorSource[],
309
- ): void {
310
- const path = getUserDataOfficialBehaviorsManifestFile(workspaceDir);
311
- const manifest = readOfficialBehaviorManifest(workspaceDir);
312
- let changed = false;
313
- for (const source of sources) {
314
- const entry = manifest[source.id];
315
- if (!entry || entry.sourceHash !== source.sourceHash) continue;
316
- if (sameProvenance(entry.provenance, source.provenance)) continue;
317
- manifest[source.id] = { ...entry, provenance: source.provenance };
318
- changed = true;
319
- }
320
- if (changed) writeOfficialResourceManifest(path, manifest);
321
- }
322
-
323
- function retireRemovedOfficialBehaviors(workspaceDir: string): void {
324
- const manifestPath = getUserDataOfficialBehaviorsManifestFile(workspaceDir);
325
- const manifest = readOfficialBehaviorManifest(workspaceDir);
326
- let changed = false;
327
- for (const id of RETIRED_OFFICIAL_BEHAVIOR_IDS) {
328
- const entry = manifest[id];
329
- if (!entry) continue;
330
- const destination = join(getUserDataBehaviorsDir(workspaceDir), `${id}.ts`);
331
- if (existsSync(destination) && !isOfficialResourceUnmodified(destination, entry)) {
332
- // Preserve user edits, but the retired id is filtered from Runtime discovery.
333
- continue;
334
- }
335
- if (existsSync(destination)) unlinkSync(destination);
336
- delete manifest[id];
337
- changed = true;
338
- }
339
- if (changed) writeOfficialResourceManifest(manifestPath, manifest);
340
- }
341
-
342
- export interface SyncOfficialBehaviorsOptions {
343
- readonly workspaceDir?: string;
344
- readonly ids?: readonly string[];
345
- readonly force?: boolean;
346
- }
347
-
348
- export async function syncOfficialBehaviors(
349
- options: SyncOfficialBehaviorsOptions = {},
350
- ): Promise<OfficialResourceSyncResult> {
351
- const workspaceDir = options.workspaceDir ?? getWorkspaceDir();
352
- ensureUserDataLayout(workspaceDir);
353
- const destinationDir = getUserDataBehaviorsDir(workspaceDir);
354
- const bundled = listBundledOfficialBehaviorSources();
355
- const installedSources = new Map(
356
- listClawclawBehaviorSources(destinationDir).map((source) => [source.id, source]),
357
- );
358
- const result = await syncOfficialResources({
359
- sources: bundled,
360
- manifestPath: getUserDataOfficialBehaviorsManifestFile(workspaceDir),
361
- destinationPath: (source) => join(destinationDir, `${source.id}.ts`),
362
- hasUntrackedConflict: (source, destination) => {
363
- const installed = installedSources.get(source.id);
364
- return installed !== undefined && resolve(installed.sourcePath) !== resolve(destination);
365
- },
366
- materialize: materializeBehavior,
367
- version: readPackageVersion(),
368
- ids: options.ids,
369
- force: options.force,
370
- notFoundMessage: (id) => `Built-in Behavior '${id}' not found.`,
371
- });
372
- if (options.ids === undefined) retireRemovedOfficialBehaviors(workspaceDir);
373
- recordOfficialBehaviorProvenance(workspaceDir, bundled);
374
- return result;
375
- }
376
-
377
- function trustedOfficialSource(
378
- workspaceDir: string,
379
- source: ResolvedClawclawBehaviorSource,
380
- bundled: ReadonlyMap<string, BundledOfficialBehaviorSource>,
381
- manifest: OfficialBehaviorManifest,
382
- ): ResolvedClawclawBehaviorSource {
383
- const official = bundled.get(source.id);
384
- const entry = manifest[source.id];
385
- if (!official || !entry) return source;
386
- const canonicalPath = resolve(getUserDataBehaviorsDir(workspaceDir), `${source.id}.ts`);
387
- if (
388
- resolve(source.sourcePath) !== canonicalPath
389
- || entry.format !== 1
390
- || typeof entry.version !== 'string'
391
- || !/^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/.test(entry.version)
392
- || entry.sourceHash !== official.sourceHash
393
- || !sameProvenance(entry.provenance, official.provenance)
394
- || typeof entry.installedHash !== 'string'
395
- ) return source;
396
-
397
- let installed: string;
398
- try {
399
- installed = readFileSync(source.sourcePath, 'utf8');
400
- } catch {
401
- return source;
402
- }
403
- const installedHash = hashOfficialResourceContent(installed);
404
- const expected = materializeBehavior(official, entry.version);
405
- // The shared manifest keeps compact operational hashes. Privilege is
406
- // stricter: byte-for-byte deterministic content equality avoids treating a
407
- // truncated-hash collision or a forged manifest as official code.
408
- if (installedHash !== entry.installedHash || installed !== expected) return source;
409
-
410
- const allowReservedProduces = (source.produces ?? []).filter(isClawclawFixedEventType);
411
- const provenance: ClawclawBehaviorSourceProvenance = {
412
- kind: 'official',
413
- family: official.family,
414
- source: official.provenance.source,
415
- };
416
- return deepFreezeBehaviorValue({
417
- ...source,
418
- provenance,
419
- trustedSourceSha256: createHash('sha256').update(installed).digest('hex'),
420
- ...(allowReservedProduces.length === 0 ? {} : { allowReservedProduces }),
421
- });
422
- }
423
-
424
- /**
425
- * Discover one workspace's unified Behavior directory and attach official
426
- * privileges only after deterministic source and installed-content proof.
427
- */
428
- export function listWorkspaceClawclawBehaviorSources(
429
- workspaceDir = getWorkspaceDir(),
430
- ): readonly ResolvedClawclawBehaviorSource[] {
431
- ensureUserDataLayout(workspaceDir);
432
- const bundled = new Map(
433
- listBundledOfficialBehaviorSources().map((source) => [source.id, source]),
434
- );
435
- const manifest = readOfficialBehaviorManifest(workspaceDir);
436
- return Object.freeze(
437
- listClawclawBehaviorSources(getUserDataBehaviorsDir(workspaceDir))
438
- .filter((source) => !RETIRED_OFFICIAL_BEHAVIOR_IDS.has(source.id))
439
- .map((source) => trustedOfficialSource(workspaceDir, source, bundled, manifest)),
440
- );
441
- }
442
-
443
- /** Build the lazy, static catalog used later by the Runtime assembly layer. */
444
- export function createWorkspaceClawclawBehaviorCatalog(
445
- workspaceDir = getWorkspaceDir(),
446
- ): ClawclawBehaviorCatalog {
447
- return new ClawclawBehaviorCatalog(listWorkspaceClawclawBehaviorSources(workspaceDir));
448
- }
449
-
450
- export async function exportBehavior(
451
- id: string,
452
- options: { readonly workspaceDir?: string; readonly force?: boolean } = {},
453
- ): Promise<void> {
454
- const workspaceDir = options.workspaceDir ?? getWorkspaceDir();
455
- const destination = join(getUserDataBehaviorsDir(workspaceDir), `${id}.ts`);
456
- const result = await syncOfficialBehaviors({
457
- workspaceDir,
458
- ids: [id],
459
- force: options.force,
460
- });
461
- if (result.preservedUntracked.includes(id)) {
462
- if (options.force) {
463
- throw new Error(`Another user-owned Behavior source already declares '${id}'; --force does not overwrite a different file path.`);
464
- }
465
- throw new Error(`${destination} already exists and is not tracked. Use --force to overwrite.`);
466
- }
467
- if (result.preservedModified.includes(id)) {
468
- throw new Error(`${destination} was modified. Use --force to overwrite.`);
469
- }
470
- if (result.preservedDeleted.includes(id)) {
471
- throw new Error(`${destination} was deleted after export. Use --force to restore.`);
472
- }
473
- }
474
-
475
- export function detectStaleOfficialBehaviors(
476
- workspaceDir = getWorkspaceDir(),
477
- ): string[] {
478
- const manifest = readOfficialBehaviorManifest(workspaceDir);
479
- const bundled = new Map(
480
- listBundledOfficialBehaviorSources().map((source) => [source.id, source]),
481
- );
482
- return Object.entries(manifest)
483
- .filter(([id, entry]) => {
484
- const source = bundled.get(id);
485
- return !source
486
- || entry.sourceHash !== source.sourceHash
487
- || !sameProvenance(entry.provenance, source.provenance);
488
- })
489
- .map(([id]) => id)
490
- .sort();
491
- }
492
-
493
- /**
494
- * True when the unified Behavior directory contains user-owned source or a
495
- * manifest-tracked official wrapper was edited/deleted. Helper, declaration,
496
- * and test files do not count as gameplay customization.
497
- */
498
- export function hasUserBehaviorCustomization(
499
- workspaceDir = getWorkspaceDir(),
500
- ): boolean {
501
- const directory = getUserDataBehaviorsDir(workspaceDir);
502
- const manifest = readOfficialBehaviorManifest(workspaceDir);
503
- let files: string[];
504
- try {
505
- files = readdirSync(directory);
506
- } catch {
507
- return false;
508
- }
509
-
510
- for (const file of files) {
511
- if (file.startsWith('_')) continue;
512
- if (!/\.(?:ts|tsx|js)$/.test(file)) continue;
513
- if (/\.d\.ts$|\.(?:test|spec)\.(?:ts|tsx|js)$/.test(file)) continue;
514
-
515
- const id = file.endsWith('.ts') ? basename(file, '.ts') : '';
516
- const entry = id ? manifest[id] : undefined;
517
- if (!entry || file !== `${id}.ts` || !entry.installedHash) return true;
518
- try {
519
- if (hashOfficialResourceContent(readFileSync(join(directory, file))) !== entry.installedHash) {
520
- return true;
521
- }
522
- } catch {
523
- return true;
524
- }
525
- }
526
-
527
- for (const [id, entry] of Object.entries(manifest)) {
528
- const path = join(directory, `${id}.ts`);
529
- if (!entry.installedHash || !existsSync(path)) return true;
530
- try {
531
- if (hashOfficialResourceContent(readFileSync(path)) !== entry.installedHash) return true;
532
- } catch {
533
- return true;
534
- }
535
- }
536
- return false;
537
- }
@@ -1,21 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { describe, expect, it } from 'vitest';
4
-
5
- function skillText(path: string): string {
6
- return readFileSync(join(process.cwd(), 'skills', 'clawclaw', path), 'utf8');
7
- }
8
-
9
- describe('official ClawClaw Skill spectate guidance', () => {
10
- it('leaves host-specific spectate-link guidance to CCL Event presentation', () => {
11
- const skill = skillText('SKILL.md');
12
- const commands = skillText(join('references', 'COMMANDS.md'));
13
- const stream = skillText(join('references', 'STREAM.md'));
14
-
15
- expect(skill).not.toMatch(/分享给用户作为 markdown 链接/u);
16
- expect(skill).not.toMatch(/有 `url` 就按上条完整分享/u);
17
- expect(skill).not.toMatch(/事件里有 `url` \/ `spectate_url` 时按原样分享/u);
18
- expect(commands).not.toMatch(/分享完整房间码和可用的完整观战链接/u);
19
- expect(stream).not.toMatch(/详情带完整 `url` 时直接分享/u);
20
- });
21
- });