@myclaw163/clawclaw-cli 0.8.4 → 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 (241) hide show
  1. package/README.md +3 -2
  2. package/docs/configuration.md +44 -26
  3. package/docs/custom-modules/README.md +7 -10
  4. package/docs/custom-modules/behavior.md +3 -1
  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 +9 -2
  11. package/scripts/build-official-hub-behaviors.mjs +136 -0
  12. package/scripts/build-official-hub-behaviors.test.mjs +178 -0
  13. package/scripts/enable_ccl_permissions.cjs +4 -2
  14. package/scripts/enable_ccl_permissions.test.mjs +8 -4
  15. package/scripts/postinstall.mjs +1 -4
  16. package/scripts/sync-bundled-skill.mjs +12 -159
  17. package/scripts/sync-bundled-skill.test.mjs +9 -74
  18. package/skills/clawclaw/SKILL.md +14 -9
  19. package/skills/clawclaw/references/BEHAVIORS.md +4 -4
  20. package/skills/clawclaw/references/COMMANDS.md +32 -16
  21. package/skills/clawclaw/references/HUB.md +25 -38
  22. package/src/commands/account.ts +58 -14
  23. package/src/commands/behavior.ts +116 -38
  24. package/src/commands/hub.ts +110 -153
  25. package/src/commands/load.ts +138 -33
  26. package/src/commands/perception.ts +55 -24
  27. package/src/commands/persona.ts +66 -20
  28. package/src/commands/skill.ts +12 -48
  29. package/src/commands/trigger.ts +68 -40
  30. package/src/hub-official-behaviors/kill-lone.ts +138 -0
  31. package/src/hub-official-behaviors/patrol.ts +30 -0
  32. package/src/hub-official-behaviors/shared.ts +125 -0
  33. package/src/hub-official-behaviors/task-only.ts +158 -0
  34. package/src/lib/account-guidance.ts +54 -9
  35. package/src/lib/agent-workspace-client.ts +135 -0
  36. package/src/lib/agent-workspace-runtime.ts +154 -0
  37. package/src/lib/agent-workspace-skills.ts +177 -0
  38. package/src/lib/agent-workspace-sync.ts +852 -0
  39. package/src/lib/gameplay-config.ts +29 -15
  40. package/src/lib/hub-client.ts +252 -34
  41. package/src/lib/hub-reminder.ts +22 -7
  42. package/src/lib/init-command.ts +0 -6
  43. package/src/lib/load-context.ts +12 -6
  44. package/src/lib/persona.ts +141 -69
  45. package/src/lib/server-status.ts +78 -0
  46. package/src/lib/skill-host.ts +160 -0
  47. package/src/lib/user-data.ts +197 -4
  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/perception/perception-plugin.ts +4 -1
  52. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  53. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  54. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  55. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  56. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  57. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  58. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  59. package/src/behaviors/official-finite/index.test.ts +0 -249
  60. package/src/channel/claude-channel-server.test.ts +0 -202
  61. package/src/commands/account.test.ts +0 -570
  62. package/src/commands/behavior.test.ts +0 -158
  63. package/src/commands/communication.test.ts +0 -282
  64. package/src/commands/competition.test.ts +0 -116
  65. package/src/commands/data.test.ts +0 -89
  66. package/src/commands/events-canonical-state.test.ts +0 -406
  67. package/src/commands/events.test.ts +0 -58
  68. package/src/commands/game/index.test.ts +0 -1251
  69. package/src/commands/game-map.test.ts +0 -69
  70. package/src/commands/hub.test.ts +0 -124
  71. package/src/commands/load.test.ts +0 -440
  72. package/src/commands/perception.test.ts +0 -75
  73. package/src/commands/setup/hermes.test.ts +0 -96
  74. package/src/commands/setup/openclaw.test.ts +0 -124
  75. package/src/commands/trigger.test.ts +0 -140
  76. package/src/commands/upgrade.test.ts +0 -82
  77. package/src/lib/account-guidance.test.ts +0 -36
  78. package/src/lib/auth.test.ts +0 -151
  79. package/src/lib/behavior-export.test.ts +0 -326
  80. package/src/lib/behavior-export.ts +0 -537
  81. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  82. package/src/lib/custom-tts.test.ts +0 -387
  83. package/src/lib/diagnostics-config.test.ts +0 -59
  84. package/src/lib/game-client-tts.test.ts +0 -151
  85. package/src/lib/game-client.test.ts +0 -250
  86. package/src/lib/gameplay-config.test.ts +0 -301
  87. package/src/lib/host-config-patcher.test.ts +0 -130
  88. package/src/lib/http-transport.test.ts +0 -124
  89. package/src/lib/hub-client.test.ts +0 -57
  90. package/src/lib/hub-install.test.ts +0 -135
  91. package/src/lib/hub-install.ts +0 -185
  92. package/src/lib/hub-unzip.test.ts +0 -69
  93. package/src/lib/init-command.test.ts +0 -103
  94. package/src/lib/load-context.test.ts +0 -62
  95. package/src/lib/match-state.test.ts +0 -134
  96. package/src/lib/official-resource-sync.test.ts +0 -199
  97. package/src/lib/official-resource-sync.ts +0 -221
  98. package/src/lib/perception-config.test.ts +0 -143
  99. package/src/lib/perception-export.test.ts +0 -145
  100. package/src/lib/perception-export.ts +0 -178
  101. package/src/lib/persona.test.ts +0 -84
  102. package/src/lib/room.test.ts +0 -88
  103. package/src/lib/server-registry.test.ts +0 -64
  104. package/src/lib/service-status.test.ts +0 -81
  105. package/src/lib/skill-version.test.ts +0 -48
  106. package/src/lib/trigger-config.test.ts +0 -102
  107. package/src/lib/trigger-export.test.ts +0 -80
  108. package/src/lib/trigger-export.ts +0 -210
  109. package/src/lib/user-data.test.ts +0 -121
  110. package/src/lib/workspace-argv.test.ts +0 -49
  111. package/src/pipeline/canonical-event-presentation.test.ts +0 -257
  112. package/src/pipeline/event-format.test.ts +0 -879
  113. package/src/pipeline/event-hints.test.ts +0 -337
  114. package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
  115. package/src/pipeline/player-projection.test.ts +0 -247
  116. package/src/runtime/auto-upgrade.test.ts +0 -66
  117. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  118. package/src/runtime/canonical-monitor.test.ts +0 -577
  119. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
  120. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  121. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  122. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  123. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  124. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  125. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  126. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  127. package/src/runtime/clawclaw/owner.test.ts +0 -203
  128. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
  129. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  130. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  131. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
  132. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  133. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  134. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  135. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  136. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  137. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  138. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  139. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  140. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  141. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  142. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  143. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  144. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  145. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  146. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  147. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  148. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  149. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  150. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  151. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  152. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  153. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  154. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  155. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  156. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  157. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  158. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  159. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  160. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  161. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  162. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  163. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  164. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  165. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  166. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  167. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  168. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  169. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  170. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  171. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  172. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
  173. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  174. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  175. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  176. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  177. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  178. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  179. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  180. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  181. package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
  182. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  183. package/src/runtime/framework/capability-registry.test.ts +0 -423
  184. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  185. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  186. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  187. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  188. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  189. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  190. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  191. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  192. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  193. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  194. package/src/runtime/framework/participation-manager.test.ts +0 -108
  195. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  196. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  197. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  198. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  199. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  200. package/src/runtime/framework/state/state-core.test.ts +0 -197
  201. package/src/runtime/game-sync-protocol.test.ts +0 -123
  202. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  203. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  204. package/src/runtime/observability/observability.test.ts +0 -583
  205. package/src/runtime/owner-control.test.ts +0 -153
  206. package/src/runtime/parent-process-watch.test.ts +0 -27
  207. package/src/runtime/pending-event-handoff.test.ts +0 -29
  208. package/src/runtime/raw-ws-log.test.ts +0 -102
  209. package/src/runtime/runtime-logger.test.ts +0 -58
  210. package/src/runtime/runtime-persistence.test.ts +0 -26
  211. package/src/runtime/runtime.test.ts +0 -1770
  212. package/src/runtime/ws-client.test.ts +0 -562
  213. package/src/sdk/action.test.ts +0 -8
  214. package/src/sdk/behavior-plugin/index.test.ts +0 -74
  215. package/src/sdk/index.test.ts +0 -45
  216. package/src/sdk/module-input/index.test.ts +0 -49
  217. package/src/sdk/perception-plugin/index.test.ts +0 -22
  218. package/src/sdk/resource-metadata.test.ts +0 -40
  219. package/src/sdk/trigger-plugin/index.test.ts +0 -41
  220. package/src/short-command/classifier.test.ts +0 -107
  221. package/src/short-command/presenter.test.ts +0 -119
  222. package/src/short-command/runner.test.ts +0 -78
  223. package/src/short-command/sensitive-data-filter.test.ts +0 -56
  224. package/src/short-command/transport-response.test.ts +0 -39
  225. package/src/strategies/custom-module.test.ts +0 -267
  226. package/src/strategies/game-utils.test.ts +0 -305
  227. package/src/strategies/goals/avoid-players-top.test.ts +0 -95
  228. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
  229. package/src/strategies/goals/kill-lone-top.test.ts +0 -96
  230. package/src/strategies/goals/kill-target-top.test.ts +0 -65
  231. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
  232. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
  233. package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
  234. package/src/strategies/goals/task-only-top.test.ts +0 -88
  235. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
  236. package/src/strategies/meeting-gate.test.ts +0 -59
  237. package/src/strategies/official-long-behavior.test.ts +0 -89
  238. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  239. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  240. package/src/strategies/player-targets.test.ts +0 -10
  241. package/src/strategies/task-only.test.ts +0 -138
@@ -1,48 +1,80 @@
1
1
  import { Command } from 'commander';
2
+ import { AuthStore, type AuthProfile } from '../lib/auth.js';
2
3
  import { getWorkspaceDir } from '../lib/init-command.js';
3
4
  import {
4
5
  readGameplayConfig,
5
6
  updateGameplayConfig,
6
7
  } from '../lib/gameplay-config.js';
7
8
  import {
8
- getUserDataGameplayConfigFile,
9
- getUserDataPerceptionsDir,
9
+ ensureAccountUserDataLayout,
10
+ getUserDataAccountGameplayConfigFile,
11
+ getUserDataAccountPerceptionsDir,
10
12
  } from '../lib/user-data.js';
13
+ import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
11
14
  import {
12
- DEFAULT_PERCEPTION_MODULES,
13
- listClawclawPerceptionSources,
14
- } from '../runtime/clawclaw/plugins/perception/index.js';
15
- import { syncOfficialPerceptions } from '../lib/perception-export.js';
15
+ listAgentWorkspacePerceptionSources,
16
+ mergeAgentWorkspacePerceptionSources,
17
+ } from '../lib/agent-workspace-runtime.js';
18
+ import { listClawclawPerceptionSourcesInDirectory } from '../runtime/clawclaw/plugins/perception/perception-source.js';
16
19
  import { PERCEPTION_PLUGIN_API_VERSION } from '../sdk/perception-plugin/index.js';
17
20
  import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-version.js';
18
21
 
19
- export function createPerceptionCommand(): Command {
22
+ export interface PerceptionCommandDependencies {
23
+ activeProfile?: () => AuthProfile | null;
24
+ }
25
+
26
+ function activeProfile(dependencies: PerceptionCommandDependencies): AuthProfile {
27
+ const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
28
+ if (!profile) throw new Error('No active account. Run `ccl account register` or switch accounts first.');
29
+ return profile;
30
+ }
31
+
32
+ export function createPerceptionCommand(dependencies: PerceptionCommandDependencies = {}): Command {
20
33
  const cmd = new Command('perception')
21
34
  .alias('pcp')
22
35
  .description('Inspect, enable, or disable perception modules')
23
36
  .option('--list', 'List installed perception modules')
24
- .option('--disable <id>', 'Disable a perception module on the next runtime')
25
- .option('--enable <id>', 'Enable a perception module on the next runtime')
26
- .addHelpText('after', () => `
37
+ .option('--disable <id>', 'Disable a local perception module on the next runtime')
38
+ .option('--enable <id>', 'Enable a local perception module on the next runtime')
39
+ .addHelpText('after', () => {
40
+ const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
41
+ const directory = profile
42
+ ? getUserDataAccountPerceptionsDir(getWorkspaceDir(), profile)
43
+ : '<active-account>/perceptions/local';
44
+ return `
27
45
  Perception modules:
28
- Place custom .ts or .js modules in ${getUserDataPerceptionsDir(getWorkspaceDir())}
29
- Installed modules are enabled by default unless listed in user-data/gameplay.json.
30
- `)
46
+ Place custom .ts or .js modules in ${directory}
47
+ Local modules are enabled by default unless listed in the account gameplay.json.
48
+ Hub module enablement is controlled by the Hub loadout.
49
+ `;
50
+ })
31
51
  .action(async (opts: { list?: boolean; disable?: string; enable?: string }) => {
32
52
  if (opts.disable && opts.enable) {
33
53
  throw new Error('Use only one of --disable or --enable at a time.');
34
54
  }
35
55
  const workspaceDir = getWorkspaceDir();
36
- await syncOfficialPerceptions({ workspaceDir });
56
+ const profile = activeProfile(dependencies);
57
+ ensureAccountUserDataLayout(workspaceDir, profile);
58
+ const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
59
+ const hub = snapshot
60
+ ? listAgentWorkspacePerceptionSources(workspaceDir, profile, snapshot)
61
+ : [];
62
+ const hubIds = new Set(hub.map(({ id }) => id));
63
+ const local = listClawclawPerceptionSourcesInDirectory(
64
+ getUserDataAccountPerceptionsDir(workspaceDir, profile),
65
+ );
66
+ if ((opts.disable && hubIds.has(opts.disable)) || (opts.enable && hubIds.has(opts.enable))) {
67
+ throw new Error(`Hub Perception '${opts.disable ?? opts.enable}' enablement is controlled by the Hub loadout.`);
68
+ }
37
69
  if (opts.disable) {
38
70
  const updated = updateGameplayConfig((current) => {
39
71
  current.disabled_perception_modules.push(opts.disable!);
40
- }, workspaceDir);
72
+ }, workspaceDir, profile);
41
73
  console.log(JSON.stringify({
42
74
  perception_module: opts.disable,
43
75
  disabled: true,
44
76
  effective: 'next_runtime',
45
- config_file: getUserDataGameplayConfigFile(workspaceDir),
77
+ config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
46
78
  disabled_perception_modules: updated.disabled_perception_modules,
47
79
  }, null, 2));
48
80
  return;
@@ -51,36 +83,35 @@ Perception modules:
51
83
  const updated = updateGameplayConfig((current) => {
52
84
  current.disabled_perception_modules = current.disabled_perception_modules
53
85
  .filter((id) => id !== opts.enable);
54
- }, workspaceDir);
86
+ }, workspaceDir, profile);
55
87
  console.log(JSON.stringify({
56
88
  perception_module: opts.enable,
57
89
  disabled: false,
58
90
  effective: 'next_runtime',
59
- config_file: getUserDataGameplayConfigFile(workspaceDir),
91
+ config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
60
92
  disabled_perception_modules: updated.disabled_perception_modules,
61
93
  }, null, 2));
62
94
  return;
63
95
  }
64
96
  if (opts.list) {
65
- const config = readGameplayConfig(workspaceDir);
97
+ const config = readGameplayConfig(workspaceDir, profile);
66
98
  const disabled = new Set(config.disabled_perception_modules);
67
- const officialIds = new Set<string>(DEFAULT_PERCEPTION_MODULES);
68
- const installed = listClawclawPerceptionSources(workspaceDir).map((source) => ({
99
+ const installed = mergeAgentWorkspacePerceptionSources(local, hub).map((source) => ({
69
100
  id: source.id,
70
101
  name: source.name,
71
102
  description: source.description,
72
- source: officialIds.has(source.id) ? 'official' : 'user',
103
+ source: hubIds.has(source.id) ? 'hub' : 'local',
73
104
  ...pluginApiVersionStatus(
74
105
  'perception',
75
106
  PERCEPTION_PLUGIN_API_VERSION,
76
107
  source.apiVersion,
77
108
  ),
78
- disabled: disabled.has(source.id),
109
+ disabled: hubIds.has(source.id) ? false : disabled.has(source.id),
79
110
  }));
80
111
  console.log(JSON.stringify({
81
112
  perception_modules: installed,
82
113
  ignored_disabled_ids: config.disabled_perception_modules
83
- .filter((id) => !installed.some((module) => module.id === id)),
114
+ .filter((id) => !local.some((module) => module.id === id)),
84
115
  }, null, 2));
85
116
  return;
86
117
  }
@@ -1,15 +1,31 @@
1
1
  import { Command } from 'commander';
2
+ import { AuthStore } from '../lib/auth.js';
3
+ import { getWorkspaceDir } from '../lib/init-command.js';
2
4
  import {
3
- applyPersonaPreset,
4
- ensurePersonaFile,
5
- getActivePersonaFile,
6
- getBundledPersonaDir,
7
- getWorkspacePersonaDir,
8
- listAllPersonaPresets,
9
- findPersonaPresetAnywhere,
5
+ resolveActivePersonaFile,
6
+ createPersonaPreset,
7
+ listPersonaPresets,
8
+ findPersonaPreset,
9
+ writePersonaSelection,
10
10
  } from '../lib/persona.js';
11
+ import {
12
+ ensureAccountUserDataLayout,
13
+ getUserDataAccountPersonasDir,
14
+ } from '../lib/user-data.js';
11
15
  import { loadPersonaSnapshot } from '../lib/load-context.js';
12
16
 
17
+ function context() {
18
+ const profile = new AuthStore().getActive();
19
+ if (!profile) throw new Error('Not logged in.');
20
+ const workspaceDir = getWorkspaceDir();
21
+ ensureAccountUserDataLayout(workspaceDir, profile);
22
+ return {
23
+ profile,
24
+ workspaceDir,
25
+ directory: getUserDataAccountPersonasDir(workspaceDir, profile),
26
+ };
27
+ }
28
+
13
29
  export function createPersonaCommand(): Command {
14
30
  const persona = new Command('persona');
15
31
  persona
@@ -18,9 +34,10 @@ export function createPersonaCommand(): Command {
18
34
 
19
35
  persona
20
36
  .command('list')
21
- .description('List all persona presets (bundled and hub-installed)')
37
+ .description('List local persona presets for the active account')
22
38
  .action(() => {
23
- const presets = listAllPersonaPresets().map(({ id, name, source }) => ({ id, name, source }));
39
+ const { directory } = context();
40
+ const presets = listPersonaPresets(directory).map(({ id, name }) => ({ id, name, source: 'local' }));
24
41
  console.log(JSON.stringify({ presets }, null, 2));
25
42
  });
26
43
 
@@ -28,9 +45,7 @@ export function createPersonaCommand(): Command {
28
45
  .command('path')
29
46
  .description('Print the absolute persona file path for the active account')
30
47
  .action(() => {
31
- const path = getActivePersonaFile();
32
- ensurePersonaFile(path);
33
- console.log(JSON.stringify({ path }, null, 2));
48
+ console.log(JSON.stringify(resolveActivePersonaFile(), null, 2));
34
49
  });
35
50
 
36
51
  persona
@@ -40,23 +55,54 @@ export function createPersonaCommand(): Command {
40
55
  console.log(JSON.stringify(loadPersonaSnapshot(), null, 2));
41
56
  });
42
57
 
58
+ persona
59
+ .command('create <name>')
60
+ .description('Create and select an empty account-local Persona preset')
61
+ .action((name: string) => {
62
+ const { directory, workspaceDir, profile } = context();
63
+ const created = createPersonaPreset(name, directory);
64
+ writePersonaSelection(workspaceDir, profile, { source: 'local', id: created.id });
65
+ console.log(JSON.stringify({
66
+ path: created.path,
67
+ preset: { id: created.id, name: created.name, source: 'local' },
68
+ }, null, 2));
69
+ });
70
+
43
71
  persona
44
72
  .command('use <preset>')
45
- .description('Copy a persona preset (hub-installed or bundled) into the active account persona file')
73
+ .description('Select an account-local Persona preset')
46
74
  .action((presetName: string) => {
47
- const path = getActivePersonaFile();
48
- const found = findPersonaPresetAnywhere(presetName);
75
+ const { directory, workspaceDir, profile } = context();
76
+ const found = findPersonaPreset(presetName, directory);
49
77
  if (!found) {
50
- const available = listAllPersonaPresets().map(p => p.name).join(', ') || 'none';
78
+ const available = listPersonaPresets(directory).map(p => p.name).join(', ') || 'none';
51
79
  throw new Error(`Persona preset "${presetName}" not found. Available: ${available}`);
52
80
  }
53
- applyPersonaPreset(found.name, path, found.source === 'bundled' ? getBundledPersonaDir() : getWorkspacePersonaDir());
81
+ writePersonaSelection(workspaceDir, profile, { source: 'local', id: found.id });
54
82
  console.log(JSON.stringify({
55
- path,
56
- preset: { id: found.id, name: found.name, source: found.source },
57
- message: `Persona "${found.name}" (${found.source}) copied to active account.`,
83
+ path: found.path,
84
+ preset: { id: found.id, name: found.name, source: 'local' },
85
+ message: `Persona "${found.name}" (local) selected for the active account.`,
58
86
  }, null, 2));
59
87
  });
60
88
 
89
+ persona
90
+ .command('use-hub')
91
+ .description('Use the Persona selected by the active account Hub loadout')
92
+ .action(() => {
93
+ const { workspaceDir, profile } = context();
94
+ writePersonaSelection(workspaceDir, profile, { source: 'hub' });
95
+ console.log(JSON.stringify(resolveActivePersonaFile(), null, 2));
96
+ });
97
+
98
+ persona
99
+ .command('clear')
100
+ .description('Use no Persona for the active account')
101
+ .action(() => {
102
+ const { workspaceDir, profile } = context();
103
+ writePersonaSelection(workspaceDir, profile, { source: 'none' });
104
+ console.log(JSON.stringify({ path: null, source: 'none' }, null, 2));
105
+ });
106
+
61
107
  return persona;
62
108
  }
@@ -1,23 +1,21 @@
1
1
  // src/commands/skill.ts
2
2
  import { Command } from 'commander';
3
- import { spawnSync } from 'child_process';
4
- import { existsSync, readFileSync } from 'fs';
3
+ import { existsSync } from 'fs';
5
4
  import { join, resolve, dirname } from 'path';
6
5
  import { fileURLToPath } from 'url';
7
6
  import { createRequire } from 'module';
7
+ import {
8
+ readSkillName,
9
+ registerAgentSkill,
10
+ unregisterAgentSkill,
11
+ } from '../lib/skill-host.js';
12
+
13
+ export { readSkillName } from '../lib/skill-host.js';
8
14
 
9
15
  const require = createRequire(import.meta.url);
10
16
  const __filename = fileURLToPath(import.meta.url);
11
17
  const __dirname = dirname(__filename);
12
18
 
13
- function getSkillsCli(): string {
14
- try {
15
- return require.resolve('skills/bin/cli.mjs');
16
- } catch {
17
- return '';
18
- }
19
- }
20
-
21
19
  /** Resolve the built-in clawclaw skill shipped with this CLI package. */
22
20
  function resolveBuiltinSkill(): string {
23
21
  // Priority: same repo layout (src/commands/skill.ts → ../../skills/clawclaw)
@@ -38,34 +36,6 @@ function resolveBuiltinSkill(): string {
38
36
  }
39
37
  }
40
38
 
41
- /** Read the skill name from a directory's SKILL.md frontmatter. Returns null if not found. */
42
- export function readSkillName(dir: string): string | null {
43
- const md = join(dir, 'SKILL.md');
44
- if (!existsSync(md)) return null;
45
- const content = readFileSync(md, 'utf8');
46
- const m = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
47
- if (!m) return null;
48
- for (const line of m[1].split(/\r?\n/)) {
49
- const kv = line.match(/^\s*name\s*:\s*(.+)\s*$/i);
50
- if (kv) return kv[1].trim().replace(/^["']|["']$/g, '');
51
- }
52
- return null;
53
- }
54
-
55
- function runSkillsCli(args: string[]): { ok: boolean; err?: string } {
56
- const cliBin = getSkillsCli();
57
- if (!cliBin) return { ok: false, err: 'skills CLI not found. Ensure the "skills" package is installed.' };
58
-
59
- const result = spawnSync(process.execPath, [cliBin, ...args], {
60
- stdio: 'inherit',
61
- timeout: 30_000,
62
- });
63
-
64
- if (result.error) return { ok: false, err: result.error.message };
65
- if (result.status !== 0) return { ok: false, err: `skills CLI exited with code ${result.status}` };
66
- return { ok: true };
67
- }
68
-
69
39
  export function createSkillCommand(): Command {
70
40
  const cmd = new Command('skill')
71
41
  .description('Install and manage agent skills');
@@ -92,12 +62,9 @@ export function createSkillCommand(): Command {
92
62
  process.exit(1);
93
63
  }
94
64
 
95
- const args = ['add', absPath];
96
- if (opts.global) args.push('-g');
97
- if (opts.yes) args.push('-y');
98
- const r = runSkillsCli(args);
65
+ const r = registerAgentSkill(absPath);
99
66
  if (!r.ok) {
100
- console.error(JSON.stringify({ error: 'skill_install_failed', message: r.err }, null, 2));
67
+ console.error(JSON.stringify({ error: 'skill_install_failed', message: r.error }, null, 2));
101
68
  process.exit(1);
102
69
  }
103
70
  });
@@ -114,12 +81,9 @@ export function createSkillCommand(): Command {
114
81
  console.error(JSON.stringify({ error: 'skill_name_missing', message: `No valid SKILL.md with a name found in ${absPath}` }, null, 2));
115
82
  process.exit(1);
116
83
  }
117
- const args = ['remove', name];
118
- if (opts.global) args.push('-g');
119
- if (opts.yes) args.push('-y');
120
- const r = runSkillsCli(args);
84
+ const r = unregisterAgentSkill(name);
121
85
  if (!r.ok) {
122
- console.error(JSON.stringify({ error: 'skill_uninstall_failed', message: r.err }, null, 2));
86
+ console.error(JSON.stringify({ error: 'skill_uninstall_failed', message: r.error }, null, 2));
123
87
  process.exit(1);
124
88
  }
125
89
  });
@@ -1,25 +1,30 @@
1
1
  import { Command, InvalidArgumentError, Option } from 'commander';
2
2
  import { AuthStore, type AuthProfile } from '../lib/auth.js';
3
- import { syncOfficialBehaviors, listWorkspaceClawclawBehaviorSources } from '../lib/behavior-export.js';
4
3
  import { readGameplayConfig, updateGameplayConfig } from '../lib/gameplay-config.js';
5
4
  import { getWorkspaceDir } from '../lib/init-command.js';
6
- import {
7
- listWorkspaceClawclawTriggerSources,
8
- syncOfficialTriggers,
9
- } from '../lib/trigger-export.js';
10
5
  import {
11
6
  toTriggerRegistrationOverrides,
12
7
  type GameplayTriggerConfig,
13
8
  type GameplayTriggerRearm,
14
9
  } from '../lib/trigger-config.js';
15
10
  import {
16
- ensureUserDataLayout,
17
- getUserDataGameplayConfigFile,
18
- getUserDataTriggersDir,
11
+ ensureAccountUserDataLayout,
12
+ getUserDataAccountBehaviorsDir,
13
+ getUserDataAccountGameplayConfigFile,
14
+ getUserDataAccountTriggersDir,
19
15
  } from '../lib/user-data.js';
20
16
  import { TRIGGER_PLUGIN_API_VERSION, MAX_TRIGGER_RUNTIME_MS } from '../sdk/trigger-plugin/index.js';
21
17
  import { BEHAVIOR_PLUGIN_API_VERSION } from '../sdk/behavior-plugin/index.js';
22
- import { behaviorSourceCompatibilityError } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
18
+ import {
19
+ behaviorSourceCompatibilityError,
20
+ listClawclawBehaviorSources,
21
+ } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
22
+ import { listClawclawTriggerSources } from '../runtime/clawclaw/plugins/trigger/trigger-source.js';
23
+ import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
24
+ import {
25
+ listAgentWorkspaceBehaviorSources,
26
+ mergeAgentWorkspaceBehaviorSources,
27
+ } from '../lib/agent-workspace-runtime.js';
23
28
  import { normalizeBehaviorInput } from '../runtime/clawclaw/behavior-input-fields.js';
24
29
  import { sendProfileOwnerControlRequest } from '../runtime/owner-control.js';
25
30
 
@@ -59,9 +64,15 @@ function parseSafeInteger(value: string, field: string, minimum: number, maximum
59
64
  return parsed;
60
65
  }
61
66
 
62
- function triggerSources(workspaceDir: string) {
63
- ensureUserDataLayout(workspaceDir);
64
- return listWorkspaceClawclawTriggerSources(workspaceDir);
67
+ function activeProfile(dependencies: TriggerCommandDependencies): AuthProfile {
68
+ const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
69
+ if (!profile) throw new Error('No active account. Run `ccl account register` or switch accounts first.');
70
+ return profile;
71
+ }
72
+
73
+ function triggerSources(workspaceDir: string, profile: Pick<AuthProfile, 'apiKey'>) {
74
+ ensureAccountUserDataLayout(workspaceDir, profile);
75
+ return listClawclawTriggerSources(getUserDataAccountTriggersDir(workspaceDir, profile));
65
76
  }
66
77
 
67
78
  function persistedOverride(id: string, config: GameplayTriggerConfig | undefined) {
@@ -111,25 +122,38 @@ function triggerEntry(
111
122
  rearm: override?.rearm ?? source.manifest.defaultRearm,
112
123
  max_runtime_ms: override?.maxRuntimeMs ?? source.manifest.defaultMaxRuntimeMs,
113
124
  },
114
- source: source.provenance?.kind === 'official' ? 'official' : 'community',
125
+ source: 'local',
115
126
  };
116
127
  }
117
128
 
118
- async function assertBehaviorBinding(id: string, workspaceDir: string): Promise<void> {
119
- await syncOfficialBehaviors({ workspaceDir });
120
- const gameplay = readGameplayConfig(workspaceDir);
121
- const source = listWorkspaceClawclawBehaviorSources(workspaceDir)
129
+ function assertBehaviorBinding(
130
+ id: string,
131
+ workspaceDir: string,
132
+ profile: Pick<AuthProfile, 'apiKey'>,
133
+ ): void {
134
+ const gameplay = readGameplayConfig(workspaceDir, profile);
135
+ const local = listClawclawBehaviorSources(getUserDataAccountBehaviorsDir(workspaceDir, profile));
136
+ const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
137
+ const hub = snapshot
138
+ ? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
139
+ : [];
140
+ const source = mergeAgentWorkspaceBehaviorSources(
141
+ local.filter((candidate) => !gameplay.disabled_behaviors.includes(candidate.id)),
142
+ hub,
143
+ )
122
144
  .find((candidate) => candidate.id === id);
123
- if (!source) throw new Error(`Unknown behavior module '${id}'.`);
145
+ if (!source) {
146
+ if (local.some((candidate) => candidate.id === id) && gameplay.disabled_behaviors.includes(id)) {
147
+ throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
148
+ }
149
+ throw new Error(`Unknown behavior module '${id}'.`);
150
+ }
124
151
  if (
125
152
  source.apiVersion !== BEHAVIOR_PLUGIN_API_VERSION
126
153
  || behaviorSourceCompatibilityError(source) !== undefined
127
154
  ) {
128
155
  throw new Error(`Behavior '${id}' is not loadable.`);
129
156
  }
130
- if (gameplay.disabled_behaviors.includes(id)) {
131
- throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
132
- }
133
157
  }
134
158
 
135
159
  async function tryApplyRuntimeConfig(
@@ -168,24 +192,24 @@ async function updateTrigger(
168
192
  dependencies: TriggerCommandDependencies,
169
193
  ): Promise<void> {
170
194
  const workspaceDir = getWorkspaceDir();
171
- await syncOfficialTriggers({ workspaceDir });
172
- const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
195
+ const profile = activeProfile(dependencies);
196
+ const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
173
197
  if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
174
- const before = readGameplayConfig(workspaceDir);
198
+ const before = readGameplayConfig(workspaceDir, profile);
175
199
  const nextConfig = { ...(before.triggers[id] ?? {}) };
176
200
  update(nextConfig);
177
201
  const effectiveBehavior = nextConfig.behavior ?? source.manifest.defaultBehavior;
178
- if (nextConfig.enabled === true) await assertBehaviorBinding(effectiveBehavior, workspaceDir);
202
+ if (nextConfig.enabled === true) assertBehaviorBinding(effectiveBehavior, workspaceDir, profile);
179
203
  const updated = updateGameplayConfig((gameplay) => {
180
204
  gameplay.triggers[id] = nextConfig;
181
- }, workspaceDir);
205
+ }, workspaceDir, profile);
182
206
  const config = updated.triggers[id]!;
183
207
  const runtime = await tryApplyRuntimeConfig(id, config, dependencies);
184
208
  console.log(JSON.stringify({
185
209
  trigger: id,
186
210
  config,
187
211
  effective: triggerEntry(source, config).effective,
188
- config_file: getUserDataGameplayConfigFile(workspaceDir),
212
+ config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
189
213
  runtime,
190
214
  }, null, 2));
191
215
  }
@@ -196,17 +220,20 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
196
220
  .description('Discover and configure rule-based Reflex triggers')
197
221
  .addHelpText('after', () => {
198
222
  const workspaceDir = getWorkspaceDir();
199
- ensureUserDataLayout(workspaceDir);
200
- return `\nTrigger modules:\n Place .ts or .js files in ${getUserDataTriggersDir(workspaceDir)}\n Community Triggers are disabled by default and discovery never executes module code.\n`;
223
+ const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
224
+ const directory = profile
225
+ ? getUserDataAccountTriggersDir(workspaceDir, profile)
226
+ : '<active-account>/triggers/local';
227
+ return `\nTrigger modules:\n Place .ts or .js files in ${directory}\n Community Triggers are disabled by default and discovery never executes module code.\n`;
201
228
  });
202
229
 
203
230
  trigger.addCommand(new Command('list')
204
231
  .description('List statically discovered Trigger modules')
205
232
  .action(async () => {
206
233
  const workspaceDir = getWorkspaceDir();
207
- await syncOfficialTriggers({ workspaceDir });
208
- const gameplay = readGameplayConfig(workspaceDir);
209
- const sources = triggerSources(workspaceDir);
234
+ const profile = activeProfile(dependencies);
235
+ const gameplay = readGameplayConfig(workspaceDir, profile);
236
+ const sources = triggerSources(workspaceDir, profile);
210
237
  console.log(JSON.stringify({
211
238
  triggers: sources.map((source) => triggerEntry(source, gameplay.triggers[source.id])),
212
239
  ignored_config_ids: Object.keys(gameplay.triggers)
@@ -220,9 +247,9 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
220
247
  .allowExcessArguments(false)
221
248
  .action(async (id: string) => {
222
249
  const workspaceDir = getWorkspaceDir();
223
- await syncOfficialTriggers({ workspaceDir });
224
- const gameplay = readGameplayConfig(workspaceDir);
225
- const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
250
+ const profile = activeProfile(dependencies);
251
+ const gameplay = readGameplayConfig(workspaceDir, profile);
252
+ const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
226
253
  if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
227
254
  console.log(JSON.stringify(triggerEntry(source, gameplay.triggers[id]), null, 2));
228
255
  }));
@@ -233,13 +260,14 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
233
260
  .allowExcessArguments(false)
234
261
  .action(async (id: string) => {
235
262
  const workspaceDir = getWorkspaceDir();
236
- await syncOfficialTriggers({ workspaceDir });
237
- const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
263
+ const profile = activeProfile(dependencies);
264
+ const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
238
265
  if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
239
- const gameplay = readGameplayConfig(workspaceDir);
240
- await assertBehaviorBinding(
266
+ const gameplay = readGameplayConfig(workspaceDir, profile);
267
+ assertBehaviorBinding(
241
268
  gameplay.triggers[id]?.behavior ?? source.manifest.defaultBehavior,
242
269
  workspaceDir,
270
+ profile,
243
271
  );
244
272
  await updateTrigger(id, (config) => { config.enabled = true; }, dependencies);
245
273
  }));
@@ -296,7 +324,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
296
324
  throw new Error('--reset cannot be combined with Trigger overrides.');
297
325
  }
298
326
  if (opts.behavior !== undefined) {
299
- await assertBehaviorBinding(opts.behavior, getWorkspaceDir());
327
+ assertBehaviorBinding(opts.behavior, getWorkspaceDir(), activeProfile(dependencies));
300
328
  }
301
329
  await updateTrigger(id, (config) => {
302
330
  const enabled = config.enabled;