@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.
- package/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/behavior.md +10 -19
- 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 +15 -2
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/find-hide-spots.py +2 -2
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/skills/clawclaw/SKILL.md +25 -18
- package/skills/clawclaw/references/BEHAVIORS.md +15 -11
- package/skills/clawclaw/references/COMMANDS.md +45 -41
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/TACTICS.md +1 -1
- 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/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 +24 -11
- 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/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +63 -19
- 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/game-query/game-query-plugin.ts +1 -1
- 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/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- 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/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -163
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -152
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.test.ts +0 -249
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- 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 -326
- package/src/lib/behavior-export.ts +0 -537
- 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 -257
- package/src/pipeline/event-format.test.ts +0 -879
- package/src/pipeline/event-hints.test.ts +0 -337
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
- 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 -60
- 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 -328
- 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 -43
- 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/official-goal-behavior.ts +0 -757
- 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 -853
- 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 -128
- 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/action.test.ts +0 -8
- 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/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/custom-module.test.ts +0 -267
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.test.ts +0 -305
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.test.ts +0 -95
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.test.ts +0 -96
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.test.ts +0 -65
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.test.ts +0 -88
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.test.ts +0 -138
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { tmpdir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
import { createPerceptionCommand } from './perception.js';
|
|
6
|
-
|
|
7
|
-
let workspaceDir: string;
|
|
8
|
-
let logs: string[];
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
workspaceDir = mkdtempSync(join(tmpdir(), 'ccl-perception-command-'));
|
|
12
|
-
process.env.CLAWCLAW_WORKSPACE_DIR = workspaceDir;
|
|
13
|
-
logs = [];
|
|
14
|
-
vi.spyOn(console, 'log').mockImplementation((...args) => logs.push(args.join(' ')));
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
delete process.env.CLAWCLAW_WORKSPACE_DIR;
|
|
19
|
-
vi.restoreAllMocks();
|
|
20
|
-
rmSync(workspaceDir, { recursive: true, force: true });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
async function run(args: string[]): Promise<void> {
|
|
24
|
-
await createPerceptionCommand().parseAsync(['node', 'ccl', ...args]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
describe('perception command', () => {
|
|
28
|
-
it('lists installed modules and their enabled state', async () => {
|
|
29
|
-
await run(['--list']);
|
|
30
|
-
const output = JSON.parse(logs[0]);
|
|
31
|
-
expect(output.perception_modules.map((module: any) => module.id))
|
|
32
|
-
.toContain('visual.visibility');
|
|
33
|
-
expect(output.perception_modules.every((module: any) => module.disabled === false)).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('keeps missing disabled module ids without reporting an error', async () => {
|
|
37
|
-
await run(['--disable', 'visual.removed']);
|
|
38
|
-
const config = JSON.parse(
|
|
39
|
-
readFileSync(join(workspaceDir, 'user-data', 'gameplay.json'), 'utf8'),
|
|
40
|
-
);
|
|
41
|
-
expect(config.disabled_perception_modules).toEqual(['visual.removed']);
|
|
42
|
-
|
|
43
|
-
await run(['--list']);
|
|
44
|
-
expect(JSON.parse(logs.at(-1)!).ignored_disabled_ids).toEqual(['visual.removed']);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('marks an incompatible source non-loadable with an exact version diagnostic', async () => {
|
|
48
|
-
await run(['--list']);
|
|
49
|
-
writeFileSync(join(workspaceDir, 'user-data', 'perceptions', 'visual.legacy.ts'), `
|
|
50
|
-
import { ClawclawPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
51
|
-
export default class LegacyPerception extends ClawclawPerception {
|
|
52
|
-
static manifest = {
|
|
53
|
-
apiVersion: 1,
|
|
54
|
-
id: 'visual.legacy',
|
|
55
|
-
name: 'Legacy perception',
|
|
56
|
-
description: 'Legacy Perception API fixture.',
|
|
57
|
-
subjectScope: 'others',
|
|
58
|
-
produces: ['visual.legacy'],
|
|
59
|
-
};
|
|
60
|
-
update() {}
|
|
61
|
-
}
|
|
62
|
-
`, 'utf8');
|
|
63
|
-
|
|
64
|
-
await run(['--list']);
|
|
65
|
-
|
|
66
|
-
const legacy = JSON.parse(logs.at(-1)!).perception_modules
|
|
67
|
-
.find(({ id }: any) => id === 'visual.legacy');
|
|
68
|
-
expect(legacy).toMatchObject({
|
|
69
|
-
api_version: 1,
|
|
70
|
-
expected_api_version: 2,
|
|
71
|
-
loadable: false,
|
|
72
|
-
compatibility_error: 'perception_api_version_unsupported:expected=2:received=1',
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { runHermesSetup } from './hermes.js';
|
|
3
|
-
import { spawnSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
vi.mock('child_process', () => ({
|
|
6
|
-
spawnSync: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
const mockedSpawnSync = vi.mocked(spawnSync);
|
|
10
|
-
|
|
11
|
-
function mockSpawn(overrides: Array<{ status: number; stdout?: string; stderr?: string }>) {
|
|
12
|
-
mockedSpawnSync.mockImplementation((_cmd: any, _args?: any, _opts?: any): any => {
|
|
13
|
-
const next = overrides.shift();
|
|
14
|
-
if (!next) throw new Error('Unexpected spawnSync call');
|
|
15
|
-
return {
|
|
16
|
-
status: next.status,
|
|
17
|
-
stdout: next.stdout ?? '',
|
|
18
|
-
stderr: next.stderr ?? '',
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
vi.clearAllMocks();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('runHermesSetup', () => {
|
|
28
|
-
it('returns error when hermes CLI is not found', () => {
|
|
29
|
-
mockSpawn([{ status: 1, stderr: 'command not found' }]);
|
|
30
|
-
const r = runHermesSetup({});
|
|
31
|
-
expect(r.exitCode).toBe(1);
|
|
32
|
-
expect(r.output.some((l) => l.includes('not found'))).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('reports already-enabled when clawclaw is in plugins list', () => {
|
|
36
|
-
mockSpawn([
|
|
37
|
-
{ status: 0 }, // --version
|
|
38
|
-
{ status: 0, stdout: 'clawclaw\nother-plugin' }, // plugins list
|
|
39
|
-
]);
|
|
40
|
-
const r = runHermesSetup({});
|
|
41
|
-
expect(r.exitCode).toBe(0);
|
|
42
|
-
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('dry-run shows pending message when not enabled', () => {
|
|
46
|
-
mockSpawn([
|
|
47
|
-
{ status: 0 }, // --version
|
|
48
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
49
|
-
]);
|
|
50
|
-
const r = runHermesSetup({});
|
|
51
|
-
expect(r.exitCode).toBe(2);
|
|
52
|
-
expect(r.output.some((l) => l.includes('Dry-run'))).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('--print shows the command that would run', () => {
|
|
56
|
-
mockSpawn([
|
|
57
|
-
{ status: 0 }, // --version
|
|
58
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
59
|
-
]);
|
|
60
|
-
const r = runHermesSetup({ print: true });
|
|
61
|
-
expect(r.exitCode).toBe(0);
|
|
62
|
-
expect(r.output.some((l) => l.includes('hermes plugins enable clawclaw'))).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('-y runs hermes plugins enable and succeeds', () => {
|
|
66
|
-
mockSpawn([
|
|
67
|
-
{ status: 0 }, // --version
|
|
68
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
69
|
-
{ status: 0, stdout: 'plugin enabled' }, // plugins enable
|
|
70
|
-
]);
|
|
71
|
-
const r = runHermesSetup({ yes: true });
|
|
72
|
-
expect(r.exitCode).toBe(0);
|
|
73
|
-
expect(r.output.some((l) => l.includes('enabled'))).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('-y handles hermes plugins enable failure', () => {
|
|
77
|
-
mockSpawn([
|
|
78
|
-
{ status: 0 }, // --version
|
|
79
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
80
|
-
{ status: 1, stderr: 'permission denied' }, // plugins enable
|
|
81
|
-
]);
|
|
82
|
-
const r = runHermesSetup({ yes: true });
|
|
83
|
-
expect(r.exitCode).toBe(1);
|
|
84
|
-
expect(r.output.some((l) => l.includes('Failed'))).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('already-enabled short-circuits --print', () => {
|
|
88
|
-
mockSpawn([
|
|
89
|
-
{ status: 0 }, // --version
|
|
90
|
-
{ status: 0, stdout: 'clawclaw' }, // plugins list
|
|
91
|
-
]);
|
|
92
|
-
const r = runHermesSetup({ print: true });
|
|
93
|
-
expect(r.exitCode).toBe(0);
|
|
94
|
-
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { computeOpenclawPatch, resolveOpenclawConfigPath } from './openclaw.js';
|
|
3
|
-
|
|
4
|
-
describe('computeOpenclawPatch', () => {
|
|
5
|
-
it('on empty config creates entries.enabled and tools.alsoAllow, but does NOT create plugins.allow', () => {
|
|
6
|
-
const r = computeOpenclawPatch({}, {});
|
|
7
|
-
expect(r.warnings).toEqual([]);
|
|
8
|
-
expect(r.next).toEqual({
|
|
9
|
-
plugins: { entries: { clawclaw: { enabled: true } } },
|
|
10
|
-
tools: { alsoAllow: ['clawclaw', 'clawclaw:*'] },
|
|
11
|
-
});
|
|
12
|
-
expect(r.changes).toHaveLength(3);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('null/non-object current is treated as empty', () => {
|
|
16
|
-
const r1 = computeOpenclawPatch(null, {});
|
|
17
|
-
expect(r1.warnings).toEqual([]);
|
|
18
|
-
expect((r1.next as any).plugins.allow).toBeUndefined();
|
|
19
|
-
expect((r1.next as any).plugins.entries.clawclaw.enabled).toBe(true);
|
|
20
|
-
const r2 = computeOpenclawPatch(['unexpected'], {});
|
|
21
|
-
expect(r2.warnings).toEqual([]);
|
|
22
|
-
expect((r2.next as any).plugins.allow).toBeUndefined();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('no-op when everything already present', () => {
|
|
26
|
-
const current = {
|
|
27
|
-
plugins: { allow: ['clawclaw'], entries: { clawclaw: { enabled: true } } },
|
|
28
|
-
tools: { profile: 'coding', alsoAllow: ['clawclaw', 'clawclaw:*'] },
|
|
29
|
-
};
|
|
30
|
-
const r = computeOpenclawPatch(current, {});
|
|
31
|
-
expect(r.changes).toEqual([]);
|
|
32
|
-
expect(r.warnings).toEqual([]);
|
|
33
|
-
expect(r.next).toEqual(current);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('appends to existing plugins.allow without dupes', () => {
|
|
37
|
-
const r = computeOpenclawPatch({ plugins: { allow: ['other'] } }, {});
|
|
38
|
-
expect((r.next as any).plugins.allow).toEqual(['other', 'clawclaw']);
|
|
39
|
-
expect(r.changes).toContain('add "clawclaw" to plugins.allow');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('does not create plugins.allow when it does not exist', () => {
|
|
43
|
-
const r = computeOpenclawPatch({ plugins: { entries: { browser: { enabled: true } } } }, {});
|
|
44
|
-
expect((r.next as any).plugins.allow).toBeUndefined();
|
|
45
|
-
expect((r.next as any).plugins.entries.clawclaw.enabled).toBe(true);
|
|
46
|
-
// browser entry preserved
|
|
47
|
-
expect((r.next as any).plugins.entries.browser).toEqual({ enabled: true });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('Set union into existing tools.alsoAllow without dupes', () => {
|
|
51
|
-
const r = computeOpenclawPatch({ tools: { profile: 'coding', alsoAllow: ['somethingElse'] } }, {});
|
|
52
|
-
expect((r.next as any).tools.alsoAllow).toEqual(['somethingElse', 'clawclaw', 'clawclaw:*']);
|
|
53
|
-
expect(r.changes).toContain('add "clawclaw" to tools.alsoAllow');
|
|
54
|
-
expect(r.changes).toContain('add "clawclaw:*" to tools.alsoAllow');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('does not touch tools.profile, even when not coding', () => {
|
|
58
|
-
const r = computeOpenclawPatch({ tools: { profile: 'full' } }, {});
|
|
59
|
-
expect((r.next as any).tools.profile).toBe('full');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('does not touch tools.profile when missing (no opinion-setting)', () => {
|
|
63
|
-
const r = computeOpenclawPatch({}, {});
|
|
64
|
-
expect((r.next as any).tools.profile).toBeUndefined();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('warns and skips when plugins.allow is not an array', () => {
|
|
68
|
-
const r = computeOpenclawPatch({ plugins: { allow: 'oops' } }, {});
|
|
69
|
-
expect(r.warnings.some((w) => w.includes('plugins.allow'))).toBe(true);
|
|
70
|
-
// unchanged value
|
|
71
|
-
expect((r.next as any).plugins.allow).toBe('oops');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('warns and skips when tools.alsoAllow is not an array', () => {
|
|
75
|
-
const r = computeOpenclawPatch({ tools: { alsoAllow: 'oops' } }, {});
|
|
76
|
-
expect(r.warnings.some((w) => w.includes('tools.alsoAllow'))).toBe(true);
|
|
77
|
-
expect((r.next as any).tools.alsoAllow).toBe('oops');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('respects explicit enabled:false on entries.clawclaw', () => {
|
|
81
|
-
const r = computeOpenclawPatch(
|
|
82
|
-
{ plugins: { entries: { clawclaw: { enabled: false } } } },
|
|
83
|
-
{},
|
|
84
|
-
);
|
|
85
|
-
expect((r.next as any).plugins.entries.clawclaw.enabled).toBe(false);
|
|
86
|
-
expect(r.warnings.some((w) => w.includes('explicitly false'))).toBe(true);
|
|
87
|
-
// and we did not mark a change for it
|
|
88
|
-
expect(r.changes.some((c) => c.includes('enabled = true'))).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('--skip-plugins-allow leaves plugins untouched, still patches tools', () => {
|
|
92
|
-
const r = computeOpenclawPatch({}, { skipPluginsAllow: true });
|
|
93
|
-
expect((r.next as any).plugins).toBeUndefined();
|
|
94
|
-
expect((r.next as any).tools.alsoAllow).toEqual(['clawclaw', 'clawclaw:*']);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('--skip-tools-allow leaves tools untouched, still patches plugins', () => {
|
|
98
|
-
const r = computeOpenclawPatch({}, { skipToolsAllow: true });
|
|
99
|
-
expect((r.next as any).tools).toBeUndefined();
|
|
100
|
-
expect((r.next as any).plugins.entries.clawclaw.enabled).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('preserves unrelated top-level keys', () => {
|
|
104
|
-
const r = computeOpenclawPatch(
|
|
105
|
-
{ models: { mode: 'replace' }, channels: { telegram: { enabled: true } } },
|
|
106
|
-
{},
|
|
107
|
-
);
|
|
108
|
-
expect((r.next as any).models).toEqual({ mode: 'replace' });
|
|
109
|
-
expect((r.next as any).channels).toEqual({ telegram: { enabled: true } });
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('resolveOpenclawConfigPath', () => {
|
|
114
|
-
it('uses OPENCLAW_HOME when set', () => {
|
|
115
|
-
const p = resolveOpenclawConfigPath({ OPENCLAW_HOME: '/tmp/oc' });
|
|
116
|
-
expect(p.replace(/\\/g, '/')).toBe('/tmp/oc/openclaw.json');
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('falls back to ~/.openclaw/openclaw.json', () => {
|
|
120
|
-
const p = resolveOpenclawConfigPath({});
|
|
121
|
-
expect(p.endsWith('openclaw.json')).toBe(true);
|
|
122
|
-
expect(p.includes('.openclaw')).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
-
import { readGameplayConfig } from '../lib/gameplay-config.js';
|
|
7
|
-
import { ensureUserDataLayout, getUserDataTriggersDir } from '../lib/user-data.js';
|
|
8
|
-
import { createTriggerCommand, type TriggerCommandDependencies } from './trigger.js';
|
|
9
|
-
|
|
10
|
-
describe('trigger command', () => {
|
|
11
|
-
let workspaceDir: string;
|
|
12
|
-
let previousWorkspace: string | undefined;
|
|
13
|
-
let logs: string[];
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
workspaceDir = mkdtempSync(join(tmpdir(), 'ccl-trigger-command-'));
|
|
17
|
-
previousWorkspace = process.env.CLAWCLAW_WORKSPACE_DIR;
|
|
18
|
-
process.env.CLAWCLAW_WORKSPACE_DIR = workspaceDir;
|
|
19
|
-
ensureUserDataLayout(workspaceDir);
|
|
20
|
-
logs = [];
|
|
21
|
-
vi.spyOn(console, 'log').mockImplementation((...args) => logs.push(args.join(' ')));
|
|
22
|
-
writeFileSync(join(getUserDataTriggersDir(workspaceDir), 'tailing.ts'), `
|
|
23
|
-
import { ClawclawTrigger } from '@myclaw163/clawclaw-cli/trigger-plugin';
|
|
24
|
-
throw new Error('trigger discovery executed player code');
|
|
25
|
-
export default class TailingTrigger extends ClawclawTrigger {
|
|
26
|
-
static manifest = {
|
|
27
|
-
apiVersion: 4,
|
|
28
|
-
id: 'tailing',
|
|
29
|
-
name: 'Tailing',
|
|
30
|
-
description: 'Detects persistent followers.',
|
|
31
|
-
inputs: [],
|
|
32
|
-
consumes: ['player_moved'],
|
|
33
|
-
defaultBehavior: 'evade',
|
|
34
|
-
defaultBehaviorInput: {},
|
|
35
|
-
defaultReflexPriority: 50,
|
|
36
|
-
defaultCooldownMs: 1000,
|
|
37
|
-
defaultRearm: 'after_clear',
|
|
38
|
-
defaultMaxRuntimeMs: 5000,
|
|
39
|
-
};
|
|
40
|
-
evaluate() {}
|
|
41
|
-
}
|
|
42
|
-
`, 'utf8');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
afterEach(() => {
|
|
46
|
-
if (previousWorkspace === undefined) delete process.env.CLAWCLAW_WORKSPACE_DIR;
|
|
47
|
-
else process.env.CLAWCLAW_WORKSPACE_DIR = previousWorkspace;
|
|
48
|
-
vi.restoreAllMocks();
|
|
49
|
-
rmSync(workspaceDir, { recursive: true, force: true });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
async function run(args: string[], dependencies: TriggerCommandDependencies = {}): Promise<void> {
|
|
53
|
-
const program = new Command().name('ccl');
|
|
54
|
-
program.addCommand(createTriggerCommand(dependencies));
|
|
55
|
-
await program.parseAsync(['node', 'ccl', 'trigger', ...args], { from: 'node' });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
it('discovers community Trigger manifests statically and keeps them disabled by default', async () => {
|
|
59
|
-
await run(['list']);
|
|
60
|
-
|
|
61
|
-
const output = JSON.parse(logs.at(-1)!);
|
|
62
|
-
expect(output.triggers).toEqual([
|
|
63
|
-
expect.objectContaining({
|
|
64
|
-
id: 'tailing',
|
|
65
|
-
loadable: true,
|
|
66
|
-
source: 'community',
|
|
67
|
-
effective: expect.objectContaining({
|
|
68
|
-
enabled: false,
|
|
69
|
-
behavior: 'evade',
|
|
70
|
-
reflex_priority: 50,
|
|
71
|
-
}),
|
|
72
|
-
}),
|
|
73
|
-
]);
|
|
74
|
-
expect(readGameplayConfig(workspaceDir).triggers).toEqual({});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('persists enablement and synchronizes the complete snake_case override to Owner', async () => {
|
|
78
|
-
const send = vi.fn(async (_profile: unknown, type: string) => (
|
|
79
|
-
type === 'snapshot'
|
|
80
|
-
? { ok: true, scope: { sessionId: 'session-1', segmentId: 'game-1' } }
|
|
81
|
-
: { ok: true, type }
|
|
82
|
-
));
|
|
83
|
-
const dependencies = {
|
|
84
|
-
activeProfile: () => ({ apiKey: 'key', runtimeAccountId: 'account-1' }) as any,
|
|
85
|
-
sendOwnerControlRequest: send as any,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
await run(['enable', 'tailing'], dependencies);
|
|
89
|
-
await run([
|
|
90
|
-
'configure',
|
|
91
|
-
'tailing',
|
|
92
|
-
'--behavior',
|
|
93
|
-
'evade',
|
|
94
|
-
'--behavior-input',
|
|
95
|
-
'{"player_seats":[4]}',
|
|
96
|
-
'--reflex-priority',
|
|
97
|
-
'90',
|
|
98
|
-
'--cooldown-ms',
|
|
99
|
-
'2500',
|
|
100
|
-
'--rearm',
|
|
101
|
-
'after_cooldown',
|
|
102
|
-
'--max-runtime-ms',
|
|
103
|
-
'9000',
|
|
104
|
-
], dependencies);
|
|
105
|
-
|
|
106
|
-
expect(readGameplayConfig(workspaceDir).triggers.tailing).toEqual({
|
|
107
|
-
enabled: true,
|
|
108
|
-
behavior: 'evade',
|
|
109
|
-
behavior_input: { player_seats: [4] },
|
|
110
|
-
reflex_priority: 90,
|
|
111
|
-
cooldown_ms: 2500,
|
|
112
|
-
rearm: 'after_cooldown',
|
|
113
|
-
max_runtime_ms: 9000,
|
|
114
|
-
});
|
|
115
|
-
expect(send).toHaveBeenLastCalledWith(
|
|
116
|
-
expect.objectContaining({ runtimeAccountId: 'account-1' }),
|
|
117
|
-
'trigger_configure',
|
|
118
|
-
{
|
|
119
|
-
expected_scope: { sessionId: 'session-1', segmentId: 'game-1' },
|
|
120
|
-
trigger: 'tailing',
|
|
121
|
-
config: {
|
|
122
|
-
enabled: true,
|
|
123
|
-
behavior: 'evade',
|
|
124
|
-
behavior_input: { player_seats: [4] },
|
|
125
|
-
reflex_priority: 90,
|
|
126
|
-
cooldown_ms: 2500,
|
|
127
|
-
rearm: 'after_cooldown',
|
|
128
|
-
max_runtime_ms: 9000,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
30_000,
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('rejects unknown Trigger modules instead of pre-authorizing a future installation', async () => {
|
|
136
|
-
await expect(run(['enable', 'future-trigger']))
|
|
137
|
-
.rejects.toThrow("Unknown or ambiguous trigger module 'future-trigger'.");
|
|
138
|
-
expect(readGameplayConfig(workspaceDir).triggers).toEqual({});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, mkdtempSync, writeFileSync } from 'fs';
|
|
2
|
-
import { tmpdir } from 'os';
|
|
3
|
-
import { join, resolve } from 'path';
|
|
4
|
-
import { describe, expect, it } from 'vitest';
|
|
5
|
-
import { installLatestFromNpm, runUpgrade, syncSkillFromInstalledPackage } from './upgrade.js';
|
|
6
|
-
|
|
7
|
-
describe('runUpgrade', () => {
|
|
8
|
-
it('installs and returns the installed cli version without syncing skill again', () => {
|
|
9
|
-
let installed = false;
|
|
10
|
-
const result = runUpgrade({
|
|
11
|
-
installLatest: () => { installed = true; },
|
|
12
|
-
readInstalledCliVersion: () => '0.4.7',
|
|
13
|
-
});
|
|
14
|
-
expect(installed).toBe(true);
|
|
15
|
-
expect(result).toEqual({ version: '0.4.7' });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('reports error when npm install fails', () => {
|
|
19
|
-
const result = runUpgrade({
|
|
20
|
-
installLatest: () => { throw new Error('EACCES'); },
|
|
21
|
-
readInstalledCliVersion: () => '0.3.4',
|
|
22
|
-
});
|
|
23
|
-
expect(result.version).toBeUndefined();
|
|
24
|
-
expect(result.error).toMatch(/npm install failed/);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('installs latest from npm without registry flag', () => {
|
|
28
|
-
const calls: Array<{ file: string; args: string[]; options: Record<string, unknown> }> = [];
|
|
29
|
-
installLatestFromNpm('clawclaw-cli', (file, args, options) => {
|
|
30
|
-
calls.push({ file, args, options });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
expect(calls).toHaveLength(1);
|
|
34
|
-
if (process.platform === 'win32') {
|
|
35
|
-
expect(calls[0].file).toBe('cmd.exe');
|
|
36
|
-
expect(calls[0].args).toEqual([
|
|
37
|
-
'/d',
|
|
38
|
-
'/c',
|
|
39
|
-
'npm.cmd install -g clawclaw-cli@latest --foreground-scripts --loglevel=error',
|
|
40
|
-
]);
|
|
41
|
-
} else {
|
|
42
|
-
expect(calls[0].args).toEqual([
|
|
43
|
-
'install',
|
|
44
|
-
'-g',
|
|
45
|
-
'clawclaw-cli@latest',
|
|
46
|
-
'--foreground-scripts',
|
|
47
|
-
'--loglevel=error',
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
expect(calls[0].options.stdio).toEqual(['ignore', 'ignore', 'inherit']);
|
|
51
|
-
expect(calls[0].options.shell).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('runs bundled skill sync script for explicit skill update', () => {
|
|
55
|
-
const root = mkdtempSync(join(tmpdir(), 'upgrade-skill-'));
|
|
56
|
-
const installDir = join(root, 'clawclaw-cli');
|
|
57
|
-
const scriptPath = join(installDir, 'scripts', 'sync-bundled-skill.mjs');
|
|
58
|
-
mkdirSync(join(installDir, 'scripts'), { recursive: true });
|
|
59
|
-
writeFileSync(scriptPath, '');
|
|
60
|
-
|
|
61
|
-
const calls: Array<{ file: string; args: string[]; options: Record<string, unknown> }> = [];
|
|
62
|
-
syncSkillFromInstalledPackage('clawclaw-cli', (file, args, options) => {
|
|
63
|
-
calls.push({ file, args, options });
|
|
64
|
-
if (args[0] === 'root' || args.at(-1)?.includes('root -g')) return root;
|
|
65
|
-
return '';
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
expect(calls).toHaveLength(2);
|
|
69
|
-
expect(calls[1].file).toBe(process.execPath);
|
|
70
|
-
expect(calls[1].args).toEqual([resolve(scriptPath)]);
|
|
71
|
-
expect(calls[1].options.stdio).toBe('inherit');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('reports error when reading installed version fails', () => {
|
|
75
|
-
const result = runUpgrade({
|
|
76
|
-
installLatest: () => {},
|
|
77
|
-
readInstalledCliVersion: () => { throw new Error('missing package'); },
|
|
78
|
-
});
|
|
79
|
-
expect(result.version).toBeUndefined();
|
|
80
|
-
expect(result.error).toMatch(/read installed cli version failed/);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_NAME_REGISTER_COMMAND,
|
|
4
|
-
NAMED_REGISTER_COMMAND,
|
|
5
|
-
OFFICIAL_URL,
|
|
6
|
-
POST_REGISTRATION_NEXT_STEP,
|
|
7
|
-
noAccountMessage,
|
|
8
|
-
registrationSuccessOutput,
|
|
9
|
-
} from './account-guidance.js';
|
|
10
|
-
|
|
11
|
-
describe('account guidance', () => {
|
|
12
|
-
it('adds the fixed official URL and next step to registration success output', () => {
|
|
13
|
-
const output = registrationSuccessOutput({ ok: true, officialUrl: 'https://example.com/' }, 'lobster-1');
|
|
14
|
-
|
|
15
|
-
expect(output).toMatchObject({
|
|
16
|
-
ok: true,
|
|
17
|
-
message: 'Registered and saved as profile "lobster-1"',
|
|
18
|
-
officialUrl: OFFICIAL_URL,
|
|
19
|
-
next_step: POST_REGISTRATION_NEXT_STEP,
|
|
20
|
-
});
|
|
21
|
-
expect(output.next_step).toContain('`ccl load`');
|
|
22
|
-
expect(output.next_step).toContain('`ccl start match`');
|
|
23
|
-
expect(output.next_step).toContain('`ccl join`');
|
|
24
|
-
expect(output.next_step).not.toContain('`ccl game start`');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('keeps the official URL out of no-account setup guidance', () => {
|
|
28
|
-
const message = noAccountMessage('load');
|
|
29
|
-
|
|
30
|
-
expect(message).toContain('Cannot load persona/memory: no local ClawClaw account is configured.');
|
|
31
|
-
expect(message).toContain('If the player replies with only an invite code');
|
|
32
|
-
expect(message).toContain(DEFAULT_NAME_REGISTER_COMMAND);
|
|
33
|
-
expect(message).toContain(NAMED_REGISTER_COMMAND);
|
|
34
|
-
expect(message).not.toContain(OFFICIAL_URL);
|
|
35
|
-
});
|
|
36
|
-
});
|