@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.
- package/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/api-reference.md +3 -7
- package/docs/custom-modules/behavior.md +6 -4
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +9 -2
- package/scripts/build-official-hub-behaviors.mjs +136 -0
- package/scripts/build-official-hub-behaviors.test.mjs +178 -0
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/enable_ccl_permissions.test.mjs +8 -4
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/scripts/sync-bundled-skill.test.mjs +9 -74
- package/skills/clawclaw/SKILL.md +18 -13
- package/skills/clawclaw/references/BEHAVIORS.md +4 -4
- package/skills/clawclaw/references/COMMANDS.md +33 -18
- package/skills/clawclaw/references/GAME-MECHANICS.md +16 -18
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/STREAM.md +9 -11
- package/src/behaviors/official-finite/do-task.ts +70 -0
- package/src/behaviors/official-finite/index.ts +0 -3
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/hub-official-behaviors/kill-lone.ts +138 -0
- package/src/hub-official-behaviors/patrol.ts +30 -0
- package/src/hub-official-behaviors/shared.ts +125 -0
- package/src/hub-official-behaviors/task-only.ts +158 -0
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +22 -7
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/pipeline/event-format.ts +20 -4
- package/src/pipeline/event-hints.ts +20 -6
- package/src/pipeline/game-sync-event-normalization.ts +9 -0
- package/src/pipeline/role-display.ts +22 -0
- package/src/runtime/clawclaw/agent-ability-state.ts +1 -21
- package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +8 -1
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +0 -1
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -9
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/src/runtime/clawclaw-event-catalog.ts +2 -0
- package/src/runtime/framework/action-diagnostics.ts +1 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -1
- package/src/sdk/action.ts +8 -6
- package/src/sdk/behavior-plugin/index.ts +1 -2
- package/src/sdk/behavior-toolkit/model.ts +2 -0
- package/src/sdk/module-input/index.ts +0 -2
- package/src/strategies/goals/crab-sabotage-top.ts +5 -61
- package/src/strategies/types.ts +0 -6
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/src/behaviors/official-finite/index.test.ts +0 -202
- package/src/behaviors/official-finite/trigger-alarm.ts +0 -53
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -282
- package/src/lib/behavior-export.ts +0 -514
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -255
- package/src/pipeline/event-format.test.ts +0 -828
- package/src/pipeline/event-hints.test.ts +0 -316
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -371
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -58
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -40
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -854
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -126
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/custom-module.test.ts +0 -268
- package/src/strategies/game-utils.test.ts +0 -306
- package/src/strategies/goals/avoid-players-top.test.ts +0 -96
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -145
- package/src/strategies/goals/kill-lone-top.test.ts +0 -97
- package/src/strategies/goals/kill-target-top.test.ts +0 -66
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -85
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -113
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -204
- package/src/strategies/goals/task-only-top.test.ts +0 -89
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -139
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/task-only.test.ts +0 -138
package/src/commands/hub.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
// src/commands/hub.ts
|
|
2
1
|
import { Command } from 'commander';
|
|
3
|
-
import { spawnSync } from 'child_process';
|
|
4
|
-
import { existsSync, readdirSync, statSync } from 'fs';
|
|
5
|
-
import { join } from 'path';
|
|
6
|
-
import { createRequire } from 'module';
|
|
7
2
|
import { ApiError, formatApiError } from '../lib/http-transport.js';
|
|
8
3
|
import { HubClient, parseResourceRef } from '../lib/hub-client.js';
|
|
9
|
-
import type { ListOptions } from '../lib/hub-client.js';
|
|
10
|
-
import { installResource, uninstallResource, listInstalled, readLockfile } from '../lib/hub-install.js';
|
|
11
|
-
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
12
|
-
|
|
13
|
-
const require = createRequire(import.meta.url);
|
|
4
|
+
import type { ListOptions, ResourceType } from '../lib/hub-client.js';
|
|
14
5
|
|
|
15
6
|
export interface HubCommandDeps {
|
|
16
7
|
clientFactory?: () => HubClient;
|
|
@@ -32,57 +23,23 @@ function handleError(err: unknown): never {
|
|
|
32
23
|
fail({ error: 'hub_error', message: (err as any)?.message ?? String(err) });
|
|
33
24
|
}
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let entries: string[];
|
|
39
|
-
try { entries = readdirSync(absPath); } catch { return absPath; }
|
|
40
|
-
const dirs = entries.filter(e => {
|
|
41
|
-
try { return statSync(join(absPath, e)).isDirectory() && !e.startsWith('.'); } catch { return false; }
|
|
42
|
-
});
|
|
43
|
-
if (dirs.length === 1 && existsSync(join(absPath, dirs[0], 'SKILL.md'))) {
|
|
44
|
-
return join(absPath, dirs[0]);
|
|
45
|
-
}
|
|
46
|
-
return absPath;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Best-effort skill registration via the skills CLI. Returns true on success; false means manual ccl skill install is needed. */
|
|
50
|
-
async function registerSkill(absPath: string): Promise<boolean> {
|
|
51
|
-
try {
|
|
52
|
-
const root = findSkillRoot(absPath);
|
|
53
|
-
// Guard against a hub skill overwriting the built-in clawclaw skill.
|
|
54
|
-
const { readSkillName } = await import('./skill.js');
|
|
55
|
-
if (readSkillName(root) === 'clawclaw') {
|
|
56
|
-
console.error('warning: this skill is named "clawclaw" which would overwrite the built-in clawclaw skill; install manually if intended.');
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const bin = require.resolve('skills/bin/cli.mjs');
|
|
60
|
-
const result = spawnSync(process.execPath, [bin, 'add', root, '-y', '-g'], {
|
|
61
|
-
stdio: 'pipe',
|
|
62
|
-
timeout: 30_000,
|
|
63
|
-
});
|
|
64
|
-
// Forward CLI output to stderr so --json stdout stays clean.
|
|
65
|
-
if (result.stdout?.length) process.stderr.write(result.stdout);
|
|
66
|
-
if (result.stderr?.length) process.stderr.write(result.stderr);
|
|
67
|
-
return result.status === 0 && !result.error;
|
|
68
|
-
} catch {
|
|
69
|
-
return false;
|
|
26
|
+
function typeOption(value: string): ResourceType {
|
|
27
|
+
if (!['skill', 'strategy', 'persona', 'perception'].includes(value)) {
|
|
28
|
+
throw new Error('type must be skill, strategy, persona, or perception');
|
|
70
29
|
}
|
|
30
|
+
return value as ResourceType;
|
|
71
31
|
}
|
|
72
32
|
|
|
73
33
|
export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
74
|
-
const hub = new Command('hub')
|
|
75
|
-
|
|
76
|
-
'Legacy Hub strategy packages are not compatible with Behavior API v3. '
|
|
77
|
-
+ 'Install a reviewed Behavior module in user-data/behaviors/; Hub Behavior distribution is not available yet.';
|
|
34
|
+
const hub = new Command('hub')
|
|
35
|
+
.description('Browse Hub resources and manage the active account workspace');
|
|
78
36
|
|
|
79
|
-
// search
|
|
80
37
|
hub.command('search [query]')
|
|
81
|
-
.description('Search
|
|
82
|
-
.option('--type <type>', 'skill | strategy | persona')
|
|
83
|
-
.option('--sort <sort>', 'latest |
|
|
38
|
+
.description('Search or browse public Hub resources')
|
|
39
|
+
.option('--type <type>', 'skill | strategy | persona | perception', typeOption)
|
|
40
|
+
.option('--sort <sort>', 'latest | likes | comments', 'latest')
|
|
84
41
|
.option('--limit <n>', 'max results', '20')
|
|
85
|
-
.option('--
|
|
42
|
+
.option('--cursor <cursor>', 'cursor from the previous response')
|
|
86
43
|
.option('--json', 'machine-readable output')
|
|
87
44
|
.action(async (query: string | undefined, opts: any) => {
|
|
88
45
|
try {
|
|
@@ -91,142 +48,142 @@ export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
|
91
48
|
type: opts.type,
|
|
92
49
|
sort: opts.sort,
|
|
93
50
|
limit: Number(opts.limit),
|
|
94
|
-
|
|
51
|
+
cursor: opts.cursor,
|
|
95
52
|
};
|
|
96
|
-
const
|
|
53
|
+
const result = await getClient(deps).list(search);
|
|
97
54
|
if (opts.json) {
|
|
98
|
-
console.log(JSON.stringify(
|
|
55
|
+
console.log(JSON.stringify(result, null, 2));
|
|
99
56
|
return;
|
|
100
57
|
}
|
|
101
|
-
if (
|
|
102
|
-
console.log('No
|
|
58
|
+
if (result.items.length === 0) {
|
|
59
|
+
console.log('No Hub resources found.');
|
|
103
60
|
return;
|
|
104
61
|
}
|
|
105
|
-
for (const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
console.log(
|
|
109
|
-
console.log(
|
|
110
|
-
if (p.creatorDisplayName) console.log(' by ' + p.creatorDisplayName + ' (' + p.creator + ')');
|
|
62
|
+
for (const item of result.items) {
|
|
63
|
+
const installed = item.isInstalled ? ' installed' : '';
|
|
64
|
+
console.log(`${item.type}/${item.id} [${item.type}${installed}] installs:${item.stats.downloadCount} likes:${item.stats.starCount}`);
|
|
65
|
+
console.log(` ${item.title} — ${item.description}`);
|
|
66
|
+
if (item.creatorDisplayName) console.log(` by ${item.creatorDisplayName}`);
|
|
111
67
|
}
|
|
112
|
-
|
|
113
|
-
|
|
68
|
+
if (result.pagination.hasMore && result.pagination.nextCursor) {
|
|
69
|
+
console.log(`\nMore: --cursor ${result.pagination.nextCursor}`);
|
|
70
|
+
}
|
|
71
|
+
console.log('\nInstall to workspace: ccl hub install <type>/<id>');
|
|
72
|
+
} catch (err) {
|
|
73
|
+
handleError(err);
|
|
74
|
+
}
|
|
114
75
|
});
|
|
115
76
|
|
|
116
|
-
// info
|
|
117
77
|
hub.command('info <type/id>')
|
|
118
|
-
.description('Show
|
|
78
|
+
.description('Show one Hub resource')
|
|
119
79
|
.option('--json', 'machine-readable output')
|
|
120
80
|
.action(async (ref: string, opts: any) => {
|
|
121
81
|
try {
|
|
122
82
|
const { type, id } = parseResourceRef(ref);
|
|
123
|
-
const
|
|
83
|
+
const detail = await getClient(deps).getResource(type, id);
|
|
124
84
|
if (opts.json) {
|
|
125
|
-
console.log(JSON.stringify(
|
|
85
|
+
console.log(JSON.stringify(detail, null, 2));
|
|
126
86
|
return;
|
|
127
87
|
}
|
|
128
|
-
|
|
129
|
-
console.log(
|
|
130
|
-
console.log(
|
|
131
|
-
console.log(
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
} catch (err) { handleError(err); }
|
|
88
|
+
console.log(`${detail.type}/${detail.id} [${detail.type}] installs:${detail.stats.downloadCount} likes:${detail.stats.starCount}`);
|
|
89
|
+
console.log(detail.title);
|
|
90
|
+
console.log(detail.description);
|
|
91
|
+
if (detail.creatorDisplayName) console.log(`by ${detail.creatorDisplayName}`);
|
|
92
|
+
if (detail.fileName) console.log(`file: ${detail.fileName}`);
|
|
93
|
+
console.log(detail.isInstalled
|
|
94
|
+
? '\nAlready installed in this account workspace.'
|
|
95
|
+
: `\nInstall: ccl hub install ${detail.type}/${detail.id}`);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
handleError(err);
|
|
98
|
+
}
|
|
141
99
|
});
|
|
142
100
|
|
|
143
|
-
// install
|
|
144
101
|
hub.command('install <type/id>')
|
|
145
|
-
.description('
|
|
146
|
-
.option('--force', 'overwrite an existing untracked file/dir')
|
|
102
|
+
.description('Install a published Hub resource into the active account workspace')
|
|
147
103
|
.option('--json', 'machine-readable output')
|
|
148
104
|
.action(async (raw: string, opts: any) => {
|
|
149
105
|
try {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// For skills: auto-register with the agent via `ccl skill install`.
|
|
158
|
-
let skillRegistered = false;
|
|
159
|
-
if (res.type === 'skill') {
|
|
160
|
-
skillRegistered = await registerSkill(res.installedPath);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// For personas: extract the preset name (filename minus .md) for the ccl persona use hint.
|
|
164
|
-
let personaSlug: string | undefined;
|
|
165
|
-
if (res.type === 'persona') {
|
|
166
|
-
const m = res.installedPath.match(/(?:^|[\\/])personas[\\/]([^/\\]+)\.md$/);
|
|
167
|
-
personaSlug = m ? m[1] : undefined;
|
|
106
|
+
const ref = parseResourceRef(raw);
|
|
107
|
+
const result = await getClient(deps).installResource(ref.id);
|
|
108
|
+
const output = { ref: raw, ...result, message: 'Installed in workspace. Select it in the Hub loadout before ccl load applies it.' };
|
|
109
|
+
if (opts.json) {
|
|
110
|
+
console.log(JSON.stringify(output, null, 2));
|
|
111
|
+
return;
|
|
168
112
|
}
|
|
113
|
+
console.log(`${result.created ? 'Installed' : 'Already installed'} ${raw} in the active account workspace.`);
|
|
114
|
+
console.log('Select it in the Hub loadout; ccl load applies the selected revision before play.');
|
|
115
|
+
} catch (err) {
|
|
116
|
+
handleError(err);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
169
119
|
|
|
120
|
+
hub.command('installed')
|
|
121
|
+
.description('List resources in the active account workspace')
|
|
122
|
+
.option('--type <type>', 'skill | strategy | persona | perception', typeOption)
|
|
123
|
+
.option('--cursor <cursor>', 'cursor from the previous response')
|
|
124
|
+
.option('--json', 'machine-readable output')
|
|
125
|
+
.action(async (opts: any) => {
|
|
126
|
+
try {
|
|
127
|
+
const result = await getClient(deps).listWorkspace({
|
|
128
|
+
type: opts.type,
|
|
129
|
+
cursor: opts.cursor,
|
|
130
|
+
limit: 100,
|
|
131
|
+
});
|
|
170
132
|
if (opts.json) {
|
|
171
|
-
console.log(JSON.stringify(
|
|
133
|
+
console.log(JSON.stringify(result, null, 2));
|
|
172
134
|
return;
|
|
173
135
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log('Skill registered with agent.');
|
|
178
|
-
} else if (res.type === 'skill') {
|
|
179
|
-
console.log('Register manually: ccl skill install ' + res.installedPath);
|
|
136
|
+
if (result.items.length === 0) {
|
|
137
|
+
console.log('No Hub resources installed in the active account workspace.');
|
|
138
|
+
return;
|
|
180
139
|
}
|
|
181
|
-
|
|
182
|
-
console.log('
|
|
140
|
+
for (const item of result.items) {
|
|
141
|
+
console.log(`${item.resourceType}/${item.resourceId} "${item.title}"${item.equipped ? ' [equipped]' : ''}${item.hasUpdate ? ' [update available]' : ''}`);
|
|
183
142
|
}
|
|
184
|
-
} catch (err) {
|
|
143
|
+
} catch (err) {
|
|
144
|
+
handleError(err);
|
|
145
|
+
}
|
|
185
146
|
});
|
|
186
147
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
.
|
|
190
|
-
.action(async (
|
|
148
|
+
hub.command('sync <type/id>')
|
|
149
|
+
.description('Update one installed workspace item to the current published version')
|
|
150
|
+
.option('--json', 'machine-readable output')
|
|
151
|
+
.action(async (raw: string, opts: any) => {
|
|
191
152
|
try {
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const r2 = spawnSync(process.execPath, [bin, 'remove', name, '-y', '-g'], { timeout: 30_000 });
|
|
204
|
-
if (r2.status !== 0 || r2.error) {
|
|
205
|
-
console.error('warning: skills remove failed (status=' + (r2.status ?? 'error') + '); files will still be deleted');
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const r = uninstallResource(ref);
|
|
212
|
-
if (!r.removed) { console.log(ref + ' is not installed.'); return; }
|
|
213
|
-
console.log('Removed ' + ref + '\n → ' + r.path);
|
|
214
|
-
} catch (err) { handleError(err); }
|
|
153
|
+
const { type, id } = parseResourceRef(raw);
|
|
154
|
+
const client = getClient(deps);
|
|
155
|
+
const item = await client.findWorkspaceItem(type, id);
|
|
156
|
+
if (!item) throw new Error(`${raw} is not installed in the active account workspace`);
|
|
157
|
+
const result = await client.syncWorkspaceItem(item.workspaceItemId);
|
|
158
|
+
const output = { ref: raw, workspaceItemId: item.workspaceItemId, ...result };
|
|
159
|
+
if (opts.json) console.log(JSON.stringify(output, null, 2));
|
|
160
|
+
else console.log(result.updated ? `Updated ${raw}.` : `${raw} is already current.`);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
handleError(err);
|
|
163
|
+
}
|
|
215
164
|
});
|
|
216
165
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
.description('List locally installed hub packages')
|
|
220
|
-
.option('--type <type>', 'filter: skill | strategy | persona')
|
|
166
|
+
hub.command('uninstall <type/id>', { hidden: true })
|
|
167
|
+
.description('Remove an unequipped resource from the active account workspace')
|
|
221
168
|
.option('--json', 'machine-readable output')
|
|
222
|
-
.action(async (opts: any) => {
|
|
169
|
+
.action(async (raw: string, opts: any) => {
|
|
223
170
|
try {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
171
|
+
const { type, id } = parseResourceRef(raw);
|
|
172
|
+
const client = getClient(deps);
|
|
173
|
+
const item = await client.findWorkspaceItem(type, id);
|
|
174
|
+
if (!item) {
|
|
175
|
+
const output = { ref: raw, removed: false };
|
|
176
|
+
if (opts.json) console.log(JSON.stringify(output, null, 2));
|
|
177
|
+
else console.log(`${raw} is not installed.`);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
await client.deleteWorkspaceItem(item.workspaceItemId);
|
|
181
|
+
const output = { ref: raw, workspaceItemId: item.workspaceItemId, removed: true };
|
|
182
|
+
if (opts.json) console.log(JSON.stringify(output, null, 2));
|
|
183
|
+
else console.log(`Removed ${raw} from the active account workspace.`);
|
|
184
|
+
} catch (err) {
|
|
185
|
+
handleError(err);
|
|
186
|
+
}
|
|
230
187
|
});
|
|
231
188
|
|
|
232
189
|
return hub;
|
package/src/commands/load.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { loadContext } from '../lib/load-context.js';
|
|
3
|
+
import { AuthStore } from '../lib/auth.js';
|
|
3
4
|
import { noAccountMessage } from '../lib/account-guidance.js';
|
|
4
5
|
import { runAutoUpgradeOnLoad } from '../runtime/auto-upgrade.js';
|
|
5
6
|
import { CLAWCLAW_ROLE_IDS, readGameplayConfig } from '../lib/gameplay-config.js';
|
|
7
|
+
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
6
8
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
ensureAccountUserDataLayout,
|
|
10
|
+
getUserDataAccountBehaviorsDir,
|
|
11
|
+
getUserDataAccountPerceptionsDir,
|
|
12
|
+
getUserDataAccountTriggersDir,
|
|
13
|
+
} from '../lib/user-data.js';
|
|
14
|
+
import { listClawclawPerceptionSourcesInDirectory } from '../runtime/clawclaw/plugins/perception/perception-source.js';
|
|
11
15
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '../
|
|
15
|
-
import {
|
|
16
|
-
import { ensureUserDataLayout } from '../lib/user-data.js';
|
|
17
|
-
import { listClawclawPerceptionSources } from '../runtime/clawclaw/plugins/perception/index.js';
|
|
18
|
-
import { behaviorSourceCompatibilityError } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
16
|
+
behaviorSourceCompatibilityError,
|
|
17
|
+
listClawclawBehaviorSources,
|
|
18
|
+
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
19
|
+
import { listClawclawTriggerSources } from '../runtime/clawclaw/plugins/trigger/trigger-source.js';
|
|
19
20
|
import { GameClient } from '../lib/game-client.js';
|
|
20
21
|
import {
|
|
21
22
|
GAME_STATUS_SCHEMA,
|
|
@@ -26,9 +27,25 @@ import { BEHAVIOR_PLUGIN_API_VERSION } from '../sdk/behavior-plugin/index.js';
|
|
|
26
27
|
import { TRIGGER_PLUGIN_API_VERSION } from '../sdk/trigger-plugin/index.js';
|
|
27
28
|
import { PERCEPTION_PLUGIN_API_VERSION } from '../sdk/perception-plugin/index.js';
|
|
28
29
|
import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-version.js';
|
|
30
|
+
import {
|
|
31
|
+
readLocalAgentWorkspaceSnapshot,
|
|
32
|
+
resolveLocalAgentWorkspaceSnapshot,
|
|
33
|
+
syncAgentWorkspaceConfig,
|
|
34
|
+
type AgentWorkspaceSyncResult,
|
|
35
|
+
} from '../lib/agent-workspace-sync.js';
|
|
36
|
+
import { syncAgentWorkspaceSkills } from '../lib/agent-workspace-skills.js';
|
|
37
|
+
import {
|
|
38
|
+
listAgentWorkspaceBehaviorSources,
|
|
39
|
+
listAgentWorkspacePerceptionSources,
|
|
40
|
+
mergeAgentWorkspaceBehaviorSources,
|
|
41
|
+
mergeAgentWorkspacePerceptionSources,
|
|
42
|
+
} from '../lib/agent-workspace-runtime.js';
|
|
29
43
|
|
|
30
44
|
export interface LoadCommandDependencies {
|
|
31
45
|
clientFactory?: () => ParticipationStatusClient;
|
|
46
|
+
authStore?: AuthStore;
|
|
47
|
+
workspaceSync?: typeof syncAgentWorkspaceConfig;
|
|
48
|
+
skillSync?: typeof syncAgentWorkspaceSkills;
|
|
32
49
|
}
|
|
33
50
|
|
|
34
51
|
export function createLoadCommand(dependencies: LoadCommandDependencies = {}): Command {
|
|
@@ -36,24 +53,51 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
36
53
|
.description('Read active account context, configured gameplay resources, and backend participation')
|
|
37
54
|
.action(async () => {
|
|
38
55
|
runAutoUpgradeOnLoad({ notify: (message) => console.error(message) });
|
|
56
|
+
const workspaceDir = getWorkspaceDir();
|
|
57
|
+
const authStore = dependencies.authStore ?? new AuthStore();
|
|
58
|
+
const profile = authStore.getActive();
|
|
59
|
+
if (!profile) throw new Error(noAccountMessage('load'));
|
|
60
|
+
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
61
|
+
|
|
62
|
+
let workspaceResult: AgentWorkspaceSyncResult | undefined;
|
|
63
|
+
const storedWorkspace = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
64
|
+
let activeWorkspace = storedWorkspace
|
|
65
|
+
? resolveLocalAgentWorkspaceSnapshot(workspaceDir, profile, storedWorkspace)
|
|
66
|
+
: undefined;
|
|
67
|
+
let workspaceSyncStatus: 'updated' | 'unchanged' | 'local_overrides' | 'stale_fallback' | 'unavailable';
|
|
68
|
+
let workspaceSyncError: string | undefined;
|
|
69
|
+
try {
|
|
70
|
+
workspaceResult = await (dependencies.workspaceSync ?? syncAgentWorkspaceConfig)(workspaceDir, profile);
|
|
71
|
+
activeWorkspace = workspaceResult.snapshot;
|
|
72
|
+
workspaceSyncStatus = workspaceResult.status;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
workspaceSyncStatus = activeWorkspace ? 'stale_fallback' : 'unavailable';
|
|
75
|
+
workspaceSyncError = error instanceof Error ? error.message : String(error);
|
|
76
|
+
console.error(`[clawclaw-cli] Agent workspace sync unavailable: ${workspaceSyncError}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
39
79
|
let snapshot;
|
|
40
80
|
try {
|
|
41
|
-
snapshot = loadContext();
|
|
42
|
-
} catch (
|
|
43
|
-
if (
|
|
81
|
+
snapshot = loadContext(authStore);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof Error && error.message === 'Not logged in.') {
|
|
44
84
|
throw new Error(noAccountMessage('load'));
|
|
45
85
|
}
|
|
46
|
-
throw
|
|
86
|
+
throw error;
|
|
47
87
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
await syncOfficialPerceptions({ workspaceDir });
|
|
51
|
-
await syncOfficialTriggers({ workspaceDir });
|
|
52
|
-
ensureUserDataLayout(workspaceDir);
|
|
53
|
-
const gameplay = readGameplayConfig(workspaceDir);
|
|
88
|
+
|
|
89
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
54
90
|
const disabledBehaviors = new Set(gameplay.disabled_behaviors);
|
|
55
|
-
const
|
|
56
|
-
|
|
91
|
+
const hubBehaviors = activeWorkspace
|
|
92
|
+
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, activeWorkspace)
|
|
93
|
+
: [];
|
|
94
|
+
const localBehaviors = listClawclawBehaviorSources(
|
|
95
|
+
getUserDataAccountBehaviorsDir(workspaceDir, profile),
|
|
96
|
+
).filter(({ id }) => !disabledBehaviors.has(id));
|
|
97
|
+
const enabledBehaviors = mergeAgentWorkspaceBehaviorSources(
|
|
98
|
+
localBehaviors,
|
|
99
|
+
hubBehaviors,
|
|
100
|
+
);
|
|
57
101
|
const behaviorEntry = (source: typeof enabledBehaviors[number]) => {
|
|
58
102
|
const compatibilityError = behaviorSourceCompatibilityError(source);
|
|
59
103
|
const versionCompatible = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION;
|
|
@@ -70,30 +114,47 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
70
114
|
? compatibilityError
|
|
71
115
|
: `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`,
|
|
72
116
|
}),
|
|
73
|
-
source: source.
|
|
74
|
-
|
|
117
|
+
source: source.management.source,
|
|
118
|
+
managed_by: source.management.managedBy,
|
|
119
|
+
...(source.management.publisher ? { publisher: source.management.publisher } : {}),
|
|
120
|
+
...(source.management.resourceId ? { resource_id: source.management.resourceId } : {}),
|
|
121
|
+
...(source.management.versionId ? { version_id: source.management.versionId } : {}),
|
|
122
|
+
...(source.management.resolution ? { resolution: source.management.resolution } : {}),
|
|
75
123
|
};
|
|
76
124
|
};
|
|
77
125
|
const behaviorEntries = enabledBehaviors.map(behaviorEntry);
|
|
78
126
|
const behaviors = behaviorEntries.filter(({ loadable }) => loadable);
|
|
79
127
|
const incompatibleBehaviors = behaviorEntries.filter(({ loadable }) => !loadable);
|
|
128
|
+
const configurationWarnings: Array<Record<string, unknown>> = [];
|
|
80
129
|
for (const role of CLAWCLAW_ROLE_IDS) {
|
|
81
130
|
const fallback = gameplay.fallback_behaviors[role];
|
|
82
131
|
if (fallback === null) continue;
|
|
83
|
-
if (disabledBehaviors.has(fallback)) {
|
|
84
|
-
throw new Error(`Fallback Behavior '${fallback}' for role '${role}' is disabled.`);
|
|
85
|
-
}
|
|
86
132
|
if (!behaviors.some(({ id }) => id === fallback)) {
|
|
87
|
-
|
|
133
|
+
configurationWarnings.push({
|
|
134
|
+
code: 'DEFAULT_LONG_BEHAVIOR_UNAVAILABLE',
|
|
135
|
+
role,
|
|
136
|
+
behavior_id: fallback,
|
|
137
|
+
reason: disabledBehaviors.has(fallback) ? 'local_disabled_or_unselected' : 'not_loaded',
|
|
138
|
+
});
|
|
88
139
|
}
|
|
89
140
|
}
|
|
90
141
|
const disabledPerceptions = new Set(gameplay.disabled_perception_modules);
|
|
91
|
-
const
|
|
92
|
-
|
|
142
|
+
const hubPerceptions = activeWorkspace
|
|
143
|
+
? listAgentWorkspacePerceptionSources(workspaceDir, profile, activeWorkspace)
|
|
144
|
+
: [];
|
|
145
|
+
const hubPerceptionIds = new Set(hubPerceptions.map(({ id }) => id));
|
|
146
|
+
const localPerceptions = listClawclawPerceptionSourcesInDirectory(
|
|
147
|
+
getUserDataAccountPerceptionsDir(workspaceDir, profile),
|
|
148
|
+
).filter(({ id }) => !disabledPerceptions.has(id));
|
|
149
|
+
const enabledPerceptions = mergeAgentWorkspacePerceptionSources(
|
|
150
|
+
localPerceptions,
|
|
151
|
+
hubPerceptions,
|
|
152
|
+
);
|
|
93
153
|
const perceptionEntry = (source: typeof enabledPerceptions[number]) => ({
|
|
94
154
|
id: source.id,
|
|
95
155
|
name: source.name,
|
|
96
156
|
description: source.description,
|
|
157
|
+
source: hubPerceptionIds.has(source.id) ? 'hub' : 'workspace',
|
|
97
158
|
...pluginApiVersionStatus('perception', PERCEPTION_PLUGIN_API_VERSION, source.apiVersion),
|
|
98
159
|
});
|
|
99
160
|
const perceptions = enabledPerceptions
|
|
@@ -102,7 +163,9 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
102
163
|
const incompatiblePerceptions = enabledPerceptions
|
|
103
164
|
.filter(({ apiVersion }) => apiVersion !== PERCEPTION_PLUGIN_API_VERSION)
|
|
104
165
|
.map(perceptionEntry);
|
|
105
|
-
const triggerSources =
|
|
166
|
+
const triggerSources = listClawclawTriggerSources(
|
|
167
|
+
getUserDataAccountTriggersDir(workspaceDir, profile),
|
|
168
|
+
);
|
|
106
169
|
const enabledTriggers = triggerSources.filter((source) => (
|
|
107
170
|
gameplay.triggers[source.id]?.enabled === true
|
|
108
171
|
));
|
|
@@ -118,12 +181,22 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
118
181
|
...(loadable ? {} : {
|
|
119
182
|
compatibility_error: `trigger_api_version_unsupported:expected=${TRIGGER_PLUGIN_API_VERSION}:received=${source.apiVersion}`,
|
|
120
183
|
}),
|
|
121
|
-
source:
|
|
184
|
+
source: 'local',
|
|
122
185
|
};
|
|
123
186
|
};
|
|
124
187
|
const triggerEntries = enabledTriggers.map(triggerEntry);
|
|
125
188
|
const triggers = triggerEntries.filter(({ loadable }) => loadable);
|
|
126
189
|
const incompatibleTriggers = triggerEntries.filter(({ loadable }) => !loadable);
|
|
190
|
+
|
|
191
|
+
// Mutate Agent-facing Skill/Persona targets only after every non-Skill
|
|
192
|
+
// source has been parsed and Hub/local identity conflicts have passed.
|
|
193
|
+
const skillChanges = activeWorkspace
|
|
194
|
+
? (dependencies.skillSync ?? syncAgentWorkspaceSkills)(workspaceDir, profile, activeWorkspace)
|
|
195
|
+
: {
|
|
196
|
+
added: [], updated: [], removed: [], unchanged: [], failed: [],
|
|
197
|
+
preservedModified: [],
|
|
198
|
+
requiresUserConfirmation: false,
|
|
199
|
+
};
|
|
127
200
|
let participation;
|
|
128
201
|
try {
|
|
129
202
|
const client = (dependencies.clientFactory ?? (() => GameClient.fromAuth()))();
|
|
@@ -139,12 +212,44 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
139
212
|
}
|
|
140
213
|
console.log(JSON.stringify({
|
|
141
214
|
...snapshot,
|
|
215
|
+
workspace_config: {
|
|
216
|
+
sync: {
|
|
217
|
+
status: workspaceSyncStatus,
|
|
218
|
+
revision: activeWorkspace?.revision ?? null,
|
|
219
|
+
...(workspaceResult?.previous
|
|
220
|
+
? { previous_revision: workspaceResult.previous.revision }
|
|
221
|
+
: {}),
|
|
222
|
+
...(workspaceSyncError ? { error: workspaceSyncError } : {}),
|
|
223
|
+
},
|
|
224
|
+
items: activeWorkspace
|
|
225
|
+
? Object.fromEntries(Object.entries(activeWorkspace.items).map(([type, items]) => [
|
|
226
|
+
type,
|
|
227
|
+
items.map((item) => ({
|
|
228
|
+
resource_id: item.resourceId,
|
|
229
|
+
version_id: item.versionId,
|
|
230
|
+
content_digest: item.contentDigest,
|
|
231
|
+
resolution: item.resolution ?? 'hub',
|
|
232
|
+
...(item.localContentDigest ? { local_content_digest: item.localContentDigest } : {}),
|
|
233
|
+
})),
|
|
234
|
+
]))
|
|
235
|
+
: { skill: [], strategy: [], persona: [], perception: [] },
|
|
236
|
+
skill_changes: skillChanges,
|
|
237
|
+
persona: {
|
|
238
|
+
source: snapshot.persona.source ?? 'none',
|
|
239
|
+
path: snapshot.persona.path,
|
|
240
|
+
exists: snapshot.persona.exists,
|
|
241
|
+
...(snapshot.persona.id ? { id: snapshot.persona.id } : {}),
|
|
242
|
+
...(snapshot.persona.resource_id ? { resource_id: snapshot.persona.resource_id } : {}),
|
|
243
|
+
},
|
|
244
|
+
requires_user_confirmation: skillChanges.requiresUserConfirmation,
|
|
245
|
+
},
|
|
142
246
|
behaviors,
|
|
143
247
|
incompatible_behaviors: incompatibleBehaviors,
|
|
144
248
|
perceptions,
|
|
145
249
|
incompatible_perceptions: incompatiblePerceptions,
|
|
146
250
|
triggers,
|
|
147
251
|
incompatible_triggers: incompatibleTriggers,
|
|
252
|
+
configuration_warnings: configurationWarnings,
|
|
148
253
|
participation,
|
|
149
254
|
}, null, 2));
|
|
150
255
|
});
|