@myclaw163/clawclaw-cli 0.6.112 → 0.7.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/QUICKSTART.md +46 -0
- package/QUICKSTART_HERMES.md +134 -0
- package/QUICKSTART_OPENCLAW.md +134 -0
- package/QUICKSTART_OTHER.md +134 -0
- package/README.md +23 -398
- package/bin/clawclaw-cli.mjs +9 -1
- package/docs/configuration.md +197 -0
- package/docs/runtime/README.md +52 -0
- package/docs/runtime/agent-notifications.md +55 -0
- package/docs/runtime/components-and-boundaries.md +213 -0
- package/docs/runtime/events-and-state.md +105 -0
- package/docs/runtime/owner-lifecycle-and-observability.md +69 -0
- package/docs/runtime/perception-replay.md +51 -0
- package/docs/runtime/short-commands-and-capabilities.md +55 -0
- package/docs/runtime/strategy-runtime.md +111 -0
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +488 -0
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +395 -0
- package/package.json +26 -8
- package/scripts/check-skill-command-surface.mjs +16 -7
- package/scripts/compare-perception-replays.test.ts +188 -0
- package/scripts/compare-perception-replays.ts +589 -0
- package/scripts/generate-spatial-facts.py +246 -0
- package/scripts/package-readme.mjs +48 -0
- package/scripts/replay-perception.ts +347 -0
- package/scripts/sync-frontend-map.mjs +195 -0
- package/scripts/watch-perception-events.test.ts +43 -0
- package/scripts/watch-perception-events.ts +162 -0
- package/skills/clawclaw/SKILL.md +121 -65
- package/skills/clawclaw/references/CHATTERBOX.md +2 -4
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +95 -61
- package/skills/clawclaw/references/GAME-MECHANICS.md +19 -9
- package/skills/clawclaw/references/HUB.md +5 -5
- package/skills/clawclaw/references/STRATEGIES.md +34 -17
- package/skills/clawclaw/references/STREAM.md +82 -46
- package/src/assets/clawclaw-map.json +1692 -0
- package/src/assets/clawclaw-spatial-facts.json +1291 -0
- package/src/assets/clawclaw-spatial-model.txt +142 -0
- package/src/cli.ts +21 -47
- package/src/commands/account.test.ts +229 -50
- package/src/commands/account.ts +456 -223
- package/src/commands/communication.test.ts +259 -0
- package/src/commands/communication.ts +391 -0
- package/src/commands/competition.test.ts +116 -0
- package/src/commands/competition.ts +50 -28
- package/src/commands/data.test.ts +57 -1
- package/src/commands/data.ts +79 -4
- package/src/commands/events-canonical-state.test.ts +187 -0
- package/src/commands/events.test.ts +50 -136
- package/src/commands/events.ts +175 -241
- package/src/commands/game/index.test.ts +510 -0
- package/src/commands/game/index.ts +556 -0
- package/src/commands/game-map.test.ts +48 -7
- package/src/commands/hub.test.ts +2 -23
- package/src/commands/hub.ts +4 -16
- package/src/commands/load.test.ts +10 -22
- package/src/commands/load.ts +15 -2
- package/src/commands/peek.ts +2 -3
- package/src/commands/perception.test.ts +46 -0
- package/src/commands/perception.ts +92 -0
- package/src/commands/setup/codex.ts +0 -1
- package/src/commands/strategy.test.ts +139 -102
- package/src/commands/strategy.ts +175 -103
- package/src/commands/upgrade.ts +0 -21
- package/src/lib/auth.test.ts +35 -0
- package/src/lib/auth.ts +45 -6
- package/src/lib/diagnostics-config.test.ts +59 -0
- package/src/lib/diagnostics-config.ts +76 -0
- package/src/lib/game-client.test.ts +166 -0
- package/src/lib/game-client.ts +316 -87
- package/src/lib/game-context.ts +33 -4
- package/src/lib/gameplay-config.test.ts +66 -0
- package/src/lib/gameplay-config.ts +151 -0
- package/src/lib/http-transport.test.ts +63 -0
- package/src/lib/http-transport.ts +76 -10
- package/src/lib/init-command.test.ts +25 -1
- package/src/lib/init-command.ts +66 -1
- package/src/lib/participation-leave.ts +78 -0
- package/src/lib/perception-config.test.ts +138 -0
- package/src/lib/perception-config.ts +101 -0
- package/src/lib/room.test.ts +14 -0
- package/src/lib/room.ts +28 -2
- package/src/lib/server-registry.test.ts +15 -5
- package/src/lib/server-registry.ts +9 -10
- package/src/lib/strategy-export.test.ts +123 -44
- package/src/lib/strategy-export.ts +110 -81
- package/src/lib/user-data.test.ts +2 -0
- package/src/lib/user-data.ts +17 -16
- package/src/pipeline/canonical-event-presentation.test.ts +196 -0
- package/src/pipeline/canonical-event-presentation.ts +71 -0
- package/src/pipeline/event-format.test.ts +357 -59
- package/src/pipeline/event-format.ts +365 -80
- package/src/pipeline/event-hints.test.ts +241 -0
- package/src/pipeline/event-hints.ts +202 -51
- package/src/pipeline/game-sync-event-normalization.test.ts +239 -0
- package/src/pipeline/game-sync-event-normalization.ts +215 -0
- package/src/pipeline/player-projection.test.ts +164 -102
- package/src/pipeline/player-projection.ts +194 -235
- package/src/runtime/canonical-event-emitter.test.ts +70 -0
- package/src/runtime/canonical-event-emitter.ts +78 -0
- package/src/runtime/canonical-monitor.test.ts +575 -0
- package/src/runtime/canonical-monitor.ts +388 -0
- package/src/runtime/clawclaw/agent-event-policy.test.ts +27 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +35 -0
- package/src/runtime/clawclaw/index.ts +4 -0
- package/src/runtime/clawclaw/notifications.test.ts +47 -0
- package/src/runtime/clawclaw/notifications.ts +65 -0
- package/src/runtime/clawclaw/owner-lock.test.ts +221 -0
- package/src/runtime/clawclaw/owner.ts +945 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +299 -0
- package/src/runtime/clawclaw/plugins/action/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +81 -0
- package/src/runtime/clawclaw/plugins/assembly.ts +116 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +150 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +100 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +162 -0
- package/src/runtime/clawclaw/plugins/derived-event/index.ts +2 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +223 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +236 -0
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +77 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +91 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1008 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +475 -0
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +32 -0
- package/src/runtime/clawclaw/plugins/perception/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +204 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +290 -0
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +324 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +365 -0
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +341 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +447 -0
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +30 -0
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +289 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +329 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +82 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +172 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +256 -0
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +121 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +106 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +225 -0
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +11 -0
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +31 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +759 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +707 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +215 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +61 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +1516 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +1529 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +119 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +244 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +65 -0
- package/src/runtime/clawclaw/plugins/perception/replay.ts +86 -0
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +107 -0
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +114 -0
- package/src/runtime/clawclaw/plugins/perception/visual-state-projector.ts +98 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +1019 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +287 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.ts +281 -0
- package/src/runtime/clawclaw/plugins/source/index.ts +5 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +270 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +151 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +307 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.ts +480 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +1909 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +2055 -0
- package/src/runtime/clawclaw/plugins/source/source-transports.ts +30 -0
- package/src/runtime/clawclaw/plugins/source/types.ts +79 -0
- package/src/runtime/clawclaw/plugins/strategy/context-capabilities.ts +5 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +177 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +185 -0
- package/src/runtime/clawclaw/plugins/strategy/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +412 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +73 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +183 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +25 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +693 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +57 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +164 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +1936 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +1557 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +131 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +413 -0
- package/src/runtime/clawclaw/plugins/strategy/thread-strategy-executor.ts +792 -0
- package/src/runtime/clawclaw/runtime-data-export.test.ts +249 -0
- package/src/runtime/clawclaw/runtime-data-export.ts +402 -0
- package/src/runtime/clawclaw/runtime-state.ts +98 -0
- package/src/runtime/clawclaw/runtime.ts +133 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +74 -0
- package/src/runtime/clawclaw-event-catalog.ts +266 -0
- package/src/runtime/clawclaw-position.ts +4 -0
- package/src/runtime/clawclaw-room-state.ts +51 -0
- package/src/runtime/framework/action-diagnostics.test.ts +81 -0
- package/src/runtime/framework/action-diagnostics.ts +146 -0
- package/src/runtime/framework/capability-registry.test.ts +282 -0
- package/src/runtime/framework/capability-registry.ts +283 -0
- package/src/runtime/framework/contracts.ts +118 -0
- package/src/runtime/framework/control/control-scheduler.ts +1260 -0
- package/src/runtime/framework/control/domain-set.ts +81 -0
- package/src/runtime/framework/control/index.ts +3 -0
- package/src/runtime/framework/control/types.ts +184 -0
- package/src/runtime/framework/control-coordinator.test.ts +660 -0
- package/src/runtime/framework/control-coordinator.ts +11 -0
- package/src/runtime/framework/events/event-catalog.ts +74 -0
- package/src/runtime/framework/events/event-delivery-service.test.ts +84 -0
- package/src/runtime/framework/events/event-delivery-service.ts +198 -0
- package/src/runtime/framework/events/event-ingress.test.ts +178 -0
- package/src/runtime/framework/events/event-ingress.ts +97 -0
- package/src/runtime/framework/events/event-repository.ts +59 -0
- package/src/runtime/framework/events/index.ts +7 -0
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +594 -0
- package/src/runtime/framework/events/memory-event-repository.ts +928 -0
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +200 -0
- package/src/runtime/framework/events/sqlite-event-repository.ts +1681 -0
- package/src/runtime/framework/events/test-helpers.ts +78 -0
- package/src/runtime/framework/events/types.ts +286 -0
- package/src/runtime/framework/index.ts +7 -0
- package/src/runtime/framework/load-node-sqlite.ts +17 -0
- package/src/runtime/framework/mailbox/coalescer.test.ts +55 -0
- package/src/runtime/framework/mailbox/coalescer.ts +83 -0
- package/src/runtime/framework/mailbox/host-notification-sink.ts +44 -0
- package/src/runtime/framework/mailbox/identity.test.ts +38 -0
- package/src/runtime/framework/mailbox/identity.ts +38 -0
- package/src/runtime/framework/mailbox/index.ts +7 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +513 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +282 -0
- package/src/runtime/framework/mailbox/mailbox-repository.ts +44 -0
- package/src/runtime/framework/mailbox/notification-projector.test.ts +77 -0
- package/src/runtime/framework/mailbox/notification-projector.ts +65 -0
- package/src/runtime/framework/mailbox/types.ts +139 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.d.mts +19 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +117 -0
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +209 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +71 -0
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +23 -0
- package/src/runtime/framework/participation-manager.test.ts +108 -0
- package/src/runtime/framework/participation-manager.ts +244 -0
- package/src/runtime/framework/plugins/contracts.ts +382 -0
- package/src/runtime/framework/plugins/index.ts +4 -0
- package/src/runtime/framework/plugins/runtime-event-identity.ts +17 -0
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +179 -0
- package/src/runtime/framework/plugins/runtime-input-journal.ts +693 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +1994 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +1860 -0
- package/src/runtime/framework/runtime.ts +1756 -0
- package/src/runtime/framework/serial-task-queue.ts +14 -0
- package/src/runtime/framework/state/contracts.ts +49 -0
- package/src/runtime/framework/state/current-state-store.ts +184 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +144 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +209 -0
- package/src/runtime/framework/state/freshness.ts +72 -0
- package/src/runtime/framework/state/history/contracts.ts +150 -0
- package/src/runtime/framework/state/history/history-writer.ts +194 -0
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +178 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +157 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +629 -0
- package/src/runtime/framework/state/history/state-history.test.ts +251 -0
- package/src/runtime/framework/state/history/trajectory-projector.ts +209 -0
- package/src/runtime/framework/state/index.ts +13 -0
- package/src/runtime/framework/state/state-core.test.ts +197 -0
- package/src/runtime/framework/state/state-ingress.ts +95 -0
- package/src/runtime/framework/state/state-provider.ts +62 -0
- package/src/runtime/framework/state/types.ts +155 -0
- package/src/runtime/game-sync-protocol.test.ts +123 -0
- package/src/runtime/game-sync-protocol.ts +261 -0
- package/src/runtime/mailbox-host-relay.test.ts +248 -0
- package/src/runtime/mailbox-host-relay.ts +300 -0
- package/src/runtime/observability/factory.ts +188 -0
- package/src/runtime/observability/index.ts +6 -0
- package/src/runtime/observability/observability.test.ts +561 -0
- package/src/runtime/observability/recorder.ts +209 -0
- package/src/runtime/observability/redaction.ts +154 -0
- package/src/runtime/observability/reporter.ts +154 -0
- package/src/runtime/observability/sinks.ts +135 -0
- package/src/runtime/observability/types.ts +92 -0
- package/src/runtime/owner-control.test.ts +153 -0
- package/src/runtime/owner-control.ts +206 -42
- package/src/runtime/parent-process-watch.test.ts +27 -0
- package/src/runtime/parent-process-watch.ts +51 -0
- package/src/runtime/pending-event-handoff.test.ts +29 -0
- package/src/runtime/pending-event-handoff.ts +61 -0
- package/src/runtime/raw-ws-log.test.ts +86 -17
- package/src/runtime/raw-ws-log.ts +230 -21
- package/src/runtime/runtime-logger.test.ts +58 -0
- package/src/runtime/runtime-logger.ts +10 -13
- package/src/runtime/runtime-persistence.test.ts +26 -0
- package/src/runtime/runtime.test.ts +1704 -0
- package/src/runtime/ws-client.test.ts +496 -103
- package/src/runtime/ws-client.ts +546 -166
- package/src/sdk/action.ts +3 -1
- package/src/sdk/index.ts +4 -19
- package/src/sdk/perception-plugin/index.test.ts +22 -0
- package/src/sdk/perception-plugin/index.ts +285 -0
- package/src/sdk/strategy-plugin/index.test.ts +952 -0
- package/src/sdk/strategy-plugin/index.ts +1324 -0
- package/src/sdk/types.ts +3 -1
- package/src/short-command/classifier.test.ts +107 -0
- package/src/short-command/classifier.ts +169 -0
- package/src/short-command/index.ts +7 -0
- package/src/short-command/presenter.test.ts +119 -0
- package/src/short-command/presenter.ts +308 -0
- package/src/short-command/process-io.ts +13 -0
- package/src/short-command/response-contract.ts +58 -0
- package/src/short-command/runner.test.ts +78 -0
- package/src/short-command/runner.ts +164 -0
- package/src/short-command/sensitive-data-filter.test.ts +56 -0
- package/src/short-command/sensitive-data-filter.ts +123 -0
- package/src/short-command/transport-response.test.ts +39 -0
- package/src/short-command/transport-response.ts +89 -0
- package/src/short-command/types.ts +92 -0
- package/src/strategies/avoid-lone.ts +18 -11
- package/src/strategies/avoid-players.ts +29 -13
- package/src/strategies/corpse-patrol.ts +29 -11
- package/src/strategies/crab-sabotage.ts +31 -18
- package/src/strategies/custom-module.test.ts +3 -5
- package/src/strategies/find-player.ts +34 -15
- package/src/strategies/game-utils.test.ts +42 -0
- package/src/strategies/game-utils.ts +143 -53
- package/src/strategies/goals/avoid-lone-top.ts +22 -1
- package/src/strategies/goals/avoid-players-top.test.ts +13 -0
- package/src/strategies/goals/avoid-players-top.ts +6 -5
- package/src/strategies/goals/corpse-patrol-top.ts +9 -2
- package/src/strategies/goals/crab-octopus-reflexes.ts +6 -2
- package/src/strategies/goals/crab-sabotage-top.ts +7 -1
- package/src/strategies/goals/emergency-hunt-goal.ts +15 -3
- package/src/strategies/goals/find-player-top.ts +47 -3
- package/src/strategies/goals/flee-players-goal.ts +2 -0
- package/src/strategies/goals/follow-companion-goal.ts +27 -3
- package/src/strategies/goals/hide-top.ts +47 -5
- package/src/strategies/goals/keep-away-goal.ts +24 -2
- package/src/strategies/goals/kill-frenzy-top.ts +12 -2
- package/src/strategies/goals/kill-lone-top.test.ts +72 -0
- package/src/strategies/goals/kill-lone-top.ts +8 -6
- package/src/strategies/goals/kill-target-goal.ts +16 -7
- package/src/strategies/goals/kill-target-top.ts +16 -2
- package/src/strategies/goals/linger-corpse-goal.ts +11 -3
- package/src/strategies/goals/lone-kill-core.ts +4 -2
- package/src/strategies/goals/move-room-goal.ts +46 -4
- package/src/strategies/goals/normal-shrimp-top.test.ts +16 -0
- package/src/strategies/goals/normal-shrimp-top.ts +18 -18
- package/src/strategies/goals/paradise-fish-top.test.ts +78 -0
- package/src/strategies/goals/paradise-fish-top.ts +16 -6
- package/src/strategies/goals/patrol-top.ts +14 -3
- package/src/strategies/goals/report-patrol-top.ts +14 -3
- package/src/strategies/goals/safe-task-goal.ts +32 -4
- package/src/strategies/goals/social-task-top.ts +39 -8
- package/src/strategies/goals/task-kill-report-top.ts +33 -10
- package/src/strategies/goals/task-only-top.test.ts +89 -0
- package/src/strategies/goals/task-only-top.ts +9 -2
- package/src/strategies/goals/task-or-patrol-goal.ts +21 -3
- package/src/strategies/goals/warrior-shrimp-top.test.ts +75 -23
- package/src/strategies/goals/warrior-shrimp-top.ts +34 -13
- package/src/strategies/greeting.ts +10 -3
- package/src/strategies/hide-spots.ts +4 -0
- package/src/strategies/hide.ts +35 -20
- package/src/strategies/kill-frenzy.ts +18 -12
- package/src/strategies/kill-lone.ts +43 -12
- package/src/strategies/kill-target.ts +34 -17
- package/src/strategies/lone-kill-task.ts +31 -18
- package/src/strategies/move-room.ts +32 -15
- package/src/strategies/off-route-points.ts +12 -4
- package/src/strategies/paradise-fish.ts +49 -14
- package/src/strategies/pathfind/astar-path.test.ts +73 -0
- package/src/strategies/pathfind/astar-path.ts +196 -0
- package/src/strategies/pathfind/escape-planner.test.ts +27 -1
- package/src/strategies/pathfind/escape-planner.ts +108 -0
- package/src/strategies/patrol.ts +18 -11
- package/src/strategies/report-patrol.ts +18 -11
- package/src/strategies/shrimp-memory.ts +66 -14
- package/src/strategies/social-task.ts +49 -45
- package/src/strategies/task-kill-report.ts +34 -16
- package/src/strategies/task-only.test.ts +124 -0
- package/src/strategies/task-only.ts +20 -11
- package/src/strategies/task-report.ts +29 -11
- package/src/strategies/types.ts +29 -62
- package/src/strategies/warrior-memory.ts +44 -14
- package/scripts/check_monitor.test.mjs +0 -212
- package/skills/clawclaw/references/KNOWLEDGE.md +0 -42
- package/src/assets/clawclaw-ascii-map.txt +0 -40
- package/src/commands/do.test.ts +0 -117
- package/src/commands/do.ts +0 -195
- package/src/commands/game-monitor-status.test.ts +0 -58
- package/src/commands/game-start-plan.test.ts +0 -356
- package/src/commands/game.ts +0 -2046
- package/src/commands/history-player.test.ts +0 -105
- package/src/commands/history.ts +0 -573
- package/src/commands/knowledge.test.ts +0 -13
- package/src/commands/knowledge.ts +0 -176
- package/src/commands/meeting-history.test.ts +0 -106
- package/src/commands/state.ts +0 -46
- package/src/commands/watch.test.ts +0 -1313
- package/src/commands/watch.ts +0 -824
- package/src/lib/knowledge-store.test.ts +0 -170
- package/src/lib/knowledge-store.ts +0 -369
- package/src/perception/player-history-store.test.ts +0 -177
- package/src/perception/player-history-store.ts +0 -262
- package/src/pipeline/event-store.test.ts +0 -28
- package/src/pipeline/event-store.ts +0 -193
- package/src/pipeline/pipeline.ts +0 -35
- package/src/runtime/event-daemon.test.ts +0 -268
- package/src/runtime/event-daemon.ts +0 -531
- package/src/runtime/room-lobby-runtime.test.ts +0 -95
- package/src/runtime/room-lobby-runtime.ts +0 -367
- package/src/strategies/avoid-players.knowledge.md +0 -19
- package/src/strategies/kill-lone.knowledge.md +0 -17
- package/src/strategies/knowledge-contract.ts +0 -85
- package/src/strategies/loader.test.ts +0 -710
- package/src/strategies/loader.ts +0 -183
- package/src/strategies/new-events-backfill.ts +0 -98
- package/src/strategies/paradise-fish.knowledge.md +0 -19
- package/src/strategies/scanner.ts +0 -238
- package/src/strategies/shrimp-memory.knowledge.md +0 -19
- package/src/strategies/social-task.test.ts +0 -28
- package/src/strategies/spawn.ts +0 -82
- package/src/strategies/strategy-loop.test.ts +0 -15
- package/src/strategies/strategy-loop.ts +0 -748
- package/src/strategies/warrior-memory.knowledge.md +0 -21
package/src/strategies/types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { GameState, TaskInfo, TaskLocation, EmergencyInfo, CorpseInfo } from '../sdk/types.js';
|
|
2
2
|
import type { Action } from '../sdk/action.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RouteEvidence } from './pathfind/escape-planner.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Minimal interface for custom modules (built-in and strategy-registered).
|
|
7
7
|
* Strategy authors implement this to inject custom analysis modules
|
|
8
8
|
* (e.g. CoMovementTracker, VisibilityTracker, SpeechAnalyzer) via ctx.customModules.
|
|
9
|
-
*
|
|
9
|
+
* ClawclawGoalStrategy manages lifecycle through these hooks:
|
|
10
10
|
* - processEvents: called every tick with new events, tick number, and current game state
|
|
11
11
|
* - afterDecide: called after strategy.decide(), can filter/modify decisions (chained by registration order)
|
|
12
12
|
* - onMeetingResume: called after each meeting (decay or full reset)
|
|
@@ -19,8 +19,21 @@ export interface CustomModule {
|
|
|
19
19
|
onMapLoaded?(rawRooms: any[]): void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export type StrategyIntentActivity = 'idle' | 'moving' | 'doing_task' | 'waiting' | 'acting';
|
|
23
|
+
|
|
24
|
+
/** Agent-facing description of what a strategy is trying to accomplish. */
|
|
25
|
+
export interface StrategyIntent {
|
|
26
|
+
activity: StrategyIntentActivity;
|
|
27
|
+
summary: string;
|
|
28
|
+
room?: string;
|
|
29
|
+
task?: string;
|
|
30
|
+
targetPlayer?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
export interface BehaviorDecision {
|
|
23
34
|
action: Action;
|
|
35
|
+
/** Semantic purpose of this action. Never use path nodes or coordinates here. */
|
|
36
|
+
intent?: StrategyIntent;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
export interface CorpseTarget {
|
|
@@ -35,61 +48,12 @@ export interface Strategy {
|
|
|
35
48
|
decide(state: GameState, ctx: StrategyContext): BehaviorDecision[];
|
|
36
49
|
/** Called when wandering resumes after a meeting pause. */
|
|
37
50
|
onMeetingResume?(): void;
|
|
38
|
-
/** Called by
|
|
51
|
+
/** Called by ClawclawGoalStrategy when authoritative role state changes. */
|
|
39
52
|
updateRole?(role: string): void;
|
|
40
53
|
/** Return custom analysis modules. Called once during setup, before the main loop. */
|
|
41
54
|
customModules?(): CustomModule[];
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
/**
|
|
45
|
-
* `ccl knowledge` 写入(set/mark)时,当前策略对单条知识做的格式校验结果。
|
|
46
|
-
* 校验由 `StrategyEntry.validateKnowledge` 提供;不实现即视为通过(兼容自定义策略)。
|
|
47
|
-
* `ok:false` 时写入照常发生,但 `message` 会作为 warning 出现在命令的返回 JSON 里,
|
|
48
|
-
* 提示玩家这条知识不会被当前策略读取。
|
|
49
|
-
*/
|
|
50
|
-
export interface KnowledgeValidation {
|
|
51
|
-
ok: boolean;
|
|
52
|
-
/** 校验不通过时给玩家的说明。 */
|
|
53
|
-
message?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 切换到某策略时,由「新策略」审视对局现有知识,指出哪些条目它读不到 / 用不上。
|
|
58
|
-
* knowledge 不随切换策略而清空(按对局作用域),故用它告知玩家哪些标记已失效。
|
|
59
|
-
* 由 `StrategyEntry.reviewKnowledge` 提供;不实现即视为「现有知识全部保留」。
|
|
60
|
-
*/
|
|
61
|
-
export interface KnowledgeReview {
|
|
62
|
-
/** 新策略读不到 / 用不上、切换后不会生效的知识条目。 */
|
|
63
|
-
stale?: SubjectRef[];
|
|
64
|
-
/** 给玩家的整理说明(每条一行)。 */
|
|
65
|
-
notes?: string[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface StrategyEntry {
|
|
69
|
-
readonly id: string;
|
|
70
|
-
/**
|
|
71
|
-
* 中文展示名/代词,玩家与 agent 沟通时使用(如「守尸」「武士虾」)。会出现在
|
|
72
|
-
* `ccl strategy --list`/`--info` 输出里,并可作为 `ccl strategy <名>` 的输入。
|
|
73
|
-
* 注意:这与 `Strategy.name`(`create()` 返回对象的内部 id 名)不是一回事。
|
|
74
|
-
* 须全局唯一。
|
|
75
|
-
*/
|
|
76
|
-
readonly name: string;
|
|
77
|
-
readonly description: string;
|
|
78
|
-
create(args?: string[]): Strategy;
|
|
79
|
-
/**
|
|
80
|
-
* 可选:校验一条即将写入的 knowledge 是否符合本策略能读取的格式。
|
|
81
|
-
* 不实现视为通过(兼容所有自定义策略)。返回 `ok:false` 时 `ccl knowledge`
|
|
82
|
-
* 仍会写入,只在返回 JSON 里带上 `message` 警告玩家该条不会生效。
|
|
83
|
-
* 没有记忆功能(不读 `ctx.knowledge`)的策略应实现它并一律返回 `ok:false`。
|
|
84
|
-
*/
|
|
85
|
-
validateKnowledge?(input: KnowledgeSetInput): KnowledgeValidation;
|
|
86
|
-
/**
|
|
87
|
-
* 可选:切换到本策略时审视对局现有知识,返回哪些条目本策略用不上。
|
|
88
|
-
* 不实现视为「全部保留」。`ccl strategy` 切换成功后会把结果告知玩家。
|
|
89
|
-
*/
|
|
90
|
-
reviewKnowledge?(view: KnowledgeView): KnowledgeReview;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
57
|
export interface RoomTarget {
|
|
94
58
|
name: string;
|
|
95
59
|
x: number;
|
|
@@ -97,9 +61,13 @@ export interface RoomTarget {
|
|
|
97
61
|
}
|
|
98
62
|
|
|
99
63
|
export interface StrategyContext {
|
|
64
|
+
/** Current semantic intent, including deliberate no-action states such as hiding or waiting. */
|
|
65
|
+
intent?: StrategyIntent;
|
|
100
66
|
taskData: TaskInfo[];
|
|
67
|
+
/** Current-frame A* route projection computed by the parallel analyzer. */
|
|
68
|
+
routeEvidence?: Readonly<RouteEvidence> | null;
|
|
101
69
|
/**
|
|
102
|
-
* 全局任务站点(map 的 all_task_locations),
|
|
70
|
+
* 全局任务站点(map 的 all_task_locations),ClawclawGoalStrategy 首次加载地图后写入。与 taskData(仅自己被
|
|
103
71
|
* 分配、带 status)不同:这是地图上所有任务点的位置,开局固定。用于「同伴停在任务点附近 → 在真实
|
|
104
72
|
* 任务点假装做任务」这类定点行为。首次地图加载前可能为空/未设置。
|
|
105
73
|
*/
|
|
@@ -110,7 +78,7 @@ export interface StrategyContext {
|
|
|
110
78
|
reportBlockedUntil: number;
|
|
111
79
|
/**
|
|
112
80
|
* 章鱼时间(剩 3 人,服务端禁用会议/报尸,report 会被 `cannot_report_during_octopus_time` 拒绝)进行中。
|
|
113
|
-
*
|
|
81
|
+
* ClawclawGoalStrategy 见到 `octopus_time_start` 事件即置 true;每局
|
|
114
82
|
* 进程独立初始化为 false,会议恢复时一并清 false(章鱼时间不会开会,纯防御)。为 true 时所有报尸决策
|
|
115
83
|
* (reportCorpseDecision / ReportPatrolTop.tryReport / 经前者的 corpseReportWithNonTeammate)直接放弃,改生存优先。
|
|
116
84
|
*/
|
|
@@ -126,30 +94,29 @@ export interface StrategyContext {
|
|
|
126
94
|
alarmOnCooldown?: boolean;
|
|
127
95
|
rooms: RoomTarget[];
|
|
128
96
|
playerNamesBySeat: Record<string, string>;
|
|
129
|
-
/** Set by strategy
|
|
97
|
+
/** Set by the Goal strategy host when a move target is repeatedly unreachable. */
|
|
130
98
|
forcePatrolAdvance: boolean;
|
|
131
99
|
blockedMoveTarget: { x: number; y: number } | null;
|
|
132
100
|
/** Own seat number, used by speech module for initiation arbitration. */
|
|
133
101
|
mySeat: number;
|
|
134
|
-
/** Speech-module notifications, flushed by
|
|
102
|
+
/** Speech-module notifications, flushed by ClawclawGoalStrategy as robot_speak_rule events. */
|
|
135
103
|
speechNotifications: string[];
|
|
136
104
|
/**
|
|
137
|
-
* Strategy → agent real-time briefings, flushed by
|
|
138
|
-
* events (notable → surfaced live by
|
|
105
|
+
* Strategy → agent real-time briefings, flushed by ClawclawGoalStrategy as `strategy_alert`
|
|
106
|
+
* events (notable → surfaced live by Monitor, unlike `notifications` which only
|
|
139
107
|
* land in the log as `type:'auto'`). Push **sparingly**, only on a decisive autonomous
|
|
140
108
|
* move the agent must account for when it next speaks/votes (e.g. the bot reported a
|
|
141
109
|
* corpse — possibly its own kill — to deflect). NOT for per-tick progress.
|
|
142
110
|
*/
|
|
143
111
|
agentAlerts: string[];
|
|
144
112
|
/**
|
|
145
|
-
* 跨 tick 的已知尸体记忆,由
|
|
146
|
-
*
|
|
113
|
+
* 跨 tick 的已知尸体记忆,由 ClawclawGoalStrategy 每次运行用中心 CorpseMemory 写入:尸体从出现一直存在到
|
|
114
|
+
* 开会才清空(会议恢复时清空)。是 `state.corpses`(仅当前视野)的严格超集,含已离开
|
|
147
115
|
* 视野、之前看见过的尸体。策略应统一读它做尸体检测/接近/任务回避/死亡确认,而非只看 `state.corpses`。
|
|
148
116
|
* 通过 hasKnownCorpse / nearestKnownCorpse / firstAvailableTask 的 avoidCorpses 参数消费。
|
|
149
117
|
*/
|
|
150
118
|
knownCorpses?: CorpseInfo[];
|
|
151
|
-
knowledge?: KnowledgeView;
|
|
152
119
|
recentlyKilledTargets?: Map<string, number>;
|
|
153
|
-
/** Strategy-registered modules.
|
|
120
|
+
/** Strategy-registered modules. ClawclawGoalStrategy calls processEvents, afterDecide, onMeetingResume and onMapLoaded. */
|
|
154
121
|
customModules?: CustomModule[];
|
|
155
122
|
}
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ClawclawGoalStrategy,
|
|
3
|
+
clawclawStrategyStringList,
|
|
4
|
+
} from '../sdk/strategy-plugin/index.js';
|
|
3
5
|
import { GoalRootStrategy } from './goals/goal-root-strategy.js';
|
|
4
6
|
import { WarriorShrimpTop } from './goals/warrior-shrimp-top.js';
|
|
5
7
|
import { parseTargetArgs } from './player-targets.js';
|
|
6
8
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export default class WarriorMemoryStrategy extends ClawclawGoalStrategy {
|
|
10
|
+
static readonly manifest = {
|
|
11
|
+
id: 'warrior-memory',
|
|
12
|
+
name: '武士虾',
|
|
13
|
+
description: '带刀虾·进阶版(武士虾/枪虾通用)。只对 huntTargets 指定的玩家出刀,其他非 trustedTargets 玩家只回避。发现尸体优先报警;无危险时优先紧急任务,否则做任务或巡逻。枪虾会尊重剩余出刀次数。',
|
|
14
|
+
execution: 'parallel_analyze',
|
|
15
|
+
controls: [
|
|
16
|
+
{
|
|
17
|
+
id: 'huntTargets',
|
|
18
|
+
type: 'player_refs',
|
|
19
|
+
description: '主动猎杀的座位号或玩家名列表。',
|
|
20
|
+
default: [],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'trustedTargets',
|
|
24
|
+
type: 'player_refs',
|
|
25
|
+
description: '可信、永不击杀的座位号或玩家名列表;与 huntTargets 重叠时保护优先。',
|
|
26
|
+
default: [],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
constructor(parameters: Readonly<Record<string, unknown>> = {}) {
|
|
32
|
+
super(parameters, {
|
|
33
|
+
id: 'warrior-memory',
|
|
34
|
+
requiresTasks: true,
|
|
35
|
+
routeEvidenceTargets: ['tasks'],
|
|
36
|
+
create: (values) => {
|
|
37
|
+
const huntTargets = parseTargetArgs(
|
|
38
|
+
clawclawStrategyStringList(values, 'huntTargets'),
|
|
39
|
+
);
|
|
40
|
+
const trustedTargets = parseTargetArgs(
|
|
41
|
+
clawclawStrategyStringList(values, 'trustedTargets'),
|
|
42
|
+
);
|
|
43
|
+
return new GoalRootStrategy('warrior-memory', () => new WarriorShrimpTop(huntTargets, trustedTargets), {
|
|
44
|
+
resetOnMeetingResume: false,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
17
47
|
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { dirname, join, resolve } from 'node:path';
|
|
5
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
6
|
-
|
|
7
|
-
const scriptPath = resolve('scripts', 'check_monitor.cjs');
|
|
8
|
-
const tempRoots = [];
|
|
9
|
-
|
|
10
|
-
function makeRoot(prefix) {
|
|
11
|
-
const root = mkdtempSync(join(tmpdir(), prefix));
|
|
12
|
-
tempRoots.push(root);
|
|
13
|
-
return root;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function writeJson(file, value) {
|
|
17
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
18
|
-
writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// A config + settings pair that passes every proxy gate on non-Windows.
|
|
22
|
-
function writeGoodPair(root) {
|
|
23
|
-
const configPath = join(root, 'claude.json');
|
|
24
|
-
const settingsPath = join(root, '.claude', 'settings.json');
|
|
25
|
-
writeJson(configPath, { cachedGrowthBookFeatures: { tengu_amber_sentinel: true } });
|
|
26
|
-
writeJson(settingsPath, { env: { ENABLE_TOOL_SEARCH: 'true' } });
|
|
27
|
-
return { configPath, settingsPath };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function runScript(args, extraEnv = {}) {
|
|
31
|
-
return spawnSync(process.execPath, [scriptPath, ...args], {
|
|
32
|
-
cwd: resolve('.'),
|
|
33
|
-
encoding: 'utf8',
|
|
34
|
-
env: {
|
|
35
|
-
...process.env,
|
|
36
|
-
// Neutralize inherited state that would skew the checks/fingerprint.
|
|
37
|
-
CLAUDE_CODE_GIT_BASH_PATH: '',
|
|
38
|
-
ENABLE_TOOL_SEARCH: '',
|
|
39
|
-
DISABLE_TELEMETRY: '',
|
|
40
|
-
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '',
|
|
41
|
-
CLAUDE_CODE_USE_BEDROCK: '',
|
|
42
|
-
CLAUDE_CODE_USE_VERTEX: '',
|
|
43
|
-
CLAUDE_CODE_USE_FOUNDRY: '',
|
|
44
|
-
...extraEnv,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
afterEach(() => {
|
|
50
|
-
while (tempRoots.length) {
|
|
51
|
-
rmSync(tempRoots.pop(), { recursive: true, force: true });
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Windows-only bash gate can't pass under this suite off Windows.
|
|
56
|
-
const describeNonWindows = process.platform === 'win32' ? describe.skip : describe;
|
|
57
|
-
|
|
58
|
-
describeNonWindows('check_monitor.cjs — Tier B config proxy (--no-probe)', () => {
|
|
59
|
-
it('reports available when flag + gates pass', () => {
|
|
60
|
-
const root = makeRoot('cm-proxy-ok-');
|
|
61
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
62
|
-
const r = runScript(['--no-probe', '--config', configPath, '--settings', settingsPath]);
|
|
63
|
-
expect(r.status).toBe(0);
|
|
64
|
-
expect(r.stdout).toContain('【可用】');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('reports unavailable when the feature flag is missing', () => {
|
|
68
|
-
const root = makeRoot('cm-proxy-noflag-');
|
|
69
|
-
const configPath = join(root, 'claude.json');
|
|
70
|
-
const settingsPath = join(root, '.claude', 'settings.json');
|
|
71
|
-
writeJson(configPath, { cachedGrowthBookFeatures: {} });
|
|
72
|
-
writeJson(settingsPath, { env: { ENABLE_TOOL_SEARCH: 'true' } });
|
|
73
|
-
const r = runScript(['--no-probe', '--config', configPath, '--settings', settingsPath]);
|
|
74
|
-
expect(r.status).toBe(1);
|
|
75
|
-
expect(r.stdout).toContain('【不可用】');
|
|
76
|
-
expect(r.stdout).toContain('tengu_amber_sentinel');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('is available when ENABLE_TOOL_SEARCH is off (tool search is advisory, not a gate)', () => {
|
|
80
|
-
const root = makeRoot('cm-proxy-nots-');
|
|
81
|
-
const configPath = join(root, 'claude.json');
|
|
82
|
-
const settingsPath = join(root, '.claude', 'settings.json');
|
|
83
|
-
writeJson(configPath, { cachedGrowthBookFeatures: { tengu_amber_sentinel: true } });
|
|
84
|
-
writeJson(settingsPath, { env: { ENABLE_TOOL_SEARCH: '0' } });
|
|
85
|
-
const r = runScript(['--no-probe', '--config', configPath, '--settings', settingsPath]);
|
|
86
|
-
expect(r.status).toBe(0);
|
|
87
|
-
expect(r.stdout).toContain('【可用】');
|
|
88
|
-
expect(r.stdout).toContain('内置工具');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('reports unavailable when a forbidden telemetry env var is set', () => {
|
|
92
|
-
const root = makeRoot('cm-proxy-tel-');
|
|
93
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
94
|
-
const r = runScript(['--no-probe', '--config', configPath, '--settings', settingsPath],
|
|
95
|
-
{ DISABLE_TELEMETRY: '1' });
|
|
96
|
-
expect(r.status).toBe(1);
|
|
97
|
-
expect(r.stdout).toContain('DISABLE_TELEMETRY');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('reports unavailable when the assumed version is below 2.1.98', () => {
|
|
101
|
-
const root = makeRoot('cm-proxy-oldver-');
|
|
102
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
103
|
-
const r = runScript(['--no-probe', '--assume-version', '2.1.50', '--config', configPath, '--settings', settingsPath]);
|
|
104
|
-
expect(r.status).toBe(1);
|
|
105
|
-
expect(r.stdout).toContain('版本');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('emits valid JSON and never spawns anything in --no-probe mode', () => {
|
|
109
|
-
const root = makeRoot('cm-proxy-json-');
|
|
110
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
111
|
-
const r = runScript(['--no-probe', '--json', '--config', configPath, '--settings', settingsPath]);
|
|
112
|
-
expect(r.status).toBe(0);
|
|
113
|
-
const parsed = JSON.parse(r.stdout);
|
|
114
|
-
expect(parsed.method).toBe('proxy');
|
|
115
|
-
expect(parsed.available).toBe(true);
|
|
116
|
-
expect(parsed.checks.find((c) => c.id === 'flag').ok).toBe(true);
|
|
117
|
-
expect(parsed.checks.find((c) => c.id === 'tool_search').advisory).toBe(true);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('treats a missing config file as unavailable rather than crashing', () => {
|
|
121
|
-
const root = makeRoot('cm-proxy-missing-');
|
|
122
|
-
const r = runScript(['--no-probe', '--config', join(root, 'nope.json'), '--settings', join(root, 's.json')]);
|
|
123
|
-
expect(r.status).toBe(1);
|
|
124
|
-
expect(r.stderr).toBe('');
|
|
125
|
-
expect(r.stdout).toContain('【不可用】');
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describeNonWindows('check_monitor.cjs — version floor', () => {
|
|
130
|
-
it('short-circuits to off (method version-floor) below 2.1.98 without probing', () => {
|
|
131
|
-
const root = makeRoot('cm-floor-');
|
|
132
|
-
const cacheFile = join(root, 'cache.json');
|
|
133
|
-
const r = runScript(['--json', '--assume-version', '2.1.50', '--cache-file', cacheFile]);
|
|
134
|
-
expect(r.status).toBe(1);
|
|
135
|
-
const parsed = JSON.parse(r.stdout);
|
|
136
|
-
expect(parsed.method).toBe('version-floor');
|
|
137
|
-
expect(parsed.available).toBe(false);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describeNonWindows('check_monitor.cjs — Tier A probe (--fake-probe)', () => {
|
|
142
|
-
it('reports available when the probe sees Monitor in the tool list', () => {
|
|
143
|
-
const root = makeRoot('cm-probe-on-');
|
|
144
|
-
const cacheFile = join(root, 'cache.json');
|
|
145
|
-
const r = runScript(['--json', '--fake-probe', 'on', '--assume-version', '2.1.193', '--cache-file', cacheFile]);
|
|
146
|
-
expect(r.status).toBe(0);
|
|
147
|
-
const parsed = JSON.parse(r.stdout);
|
|
148
|
-
expect(parsed.method).toBe('probe');
|
|
149
|
-
expect(parsed.available).toBe(true);
|
|
150
|
-
expect(existsSync(cacheFile)).toBe(true);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('reports unavailable when the probe does NOT see Monitor', () => {
|
|
154
|
-
const root = makeRoot('cm-probe-off-');
|
|
155
|
-
const cacheFile = join(root, 'cache.json');
|
|
156
|
-
const r = runScript(['--json', '--fake-probe', 'off', '--assume-version', '2.1.193', '--cache-file', cacheFile]);
|
|
157
|
-
expect(r.status).toBe(1);
|
|
158
|
-
const parsed = JSON.parse(r.stdout);
|
|
159
|
-
expect(parsed.method).toBe('probe');
|
|
160
|
-
expect(parsed.available).toBe(false);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('falls back to the config proxy when the probe cannot run', () => {
|
|
164
|
-
const root = makeRoot('cm-probe-fail-');
|
|
165
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
166
|
-
const cacheFile = join(root, 'cache.json');
|
|
167
|
-
const r = runScript(['--json', '--fake-probe', 'fail', '--assume-version', '2.1.193',
|
|
168
|
-
'--cache-file', cacheFile, '--config', configPath, '--settings', settingsPath]);
|
|
169
|
-
expect(r.status).toBe(0);
|
|
170
|
-
const parsed = JSON.parse(r.stdout);
|
|
171
|
-
expect(parsed.method).toBe('proxy-fallback');
|
|
172
|
-
expect(parsed.available).toBe(true);
|
|
173
|
-
// A failed probe must NOT be cached.
|
|
174
|
-
expect(existsSync(cacheFile)).toBe(false);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describeNonWindows('check_monitor.cjs — fingerprint cache', () => {
|
|
179
|
-
it('writes on first probe and serves a hit on the second run without probing', () => {
|
|
180
|
-
const root = makeRoot('cm-cache-');
|
|
181
|
-
const { configPath, settingsPath } = writeGoodPair(root);
|
|
182
|
-
const cacheFile = join(root, 'cache.json');
|
|
183
|
-
const common = ['--json', '--assume-version', '2.1.193', '--cache-file', cacheFile,
|
|
184
|
-
'--config', configPath, '--settings', settingsPath];
|
|
185
|
-
|
|
186
|
-
// First run: fake probe populates the cache.
|
|
187
|
-
const first = runScript([...common, '--fake-probe', 'on']);
|
|
188
|
-
expect(first.status).toBe(0);
|
|
189
|
-
expect(JSON.parse(first.stdout).method).toBe('probe');
|
|
190
|
-
const cache = JSON.parse(readFileSync(cacheFile, 'utf8'));
|
|
191
|
-
expect(cache.status).toBe('on');
|
|
192
|
-
|
|
193
|
-
// Second run WITHOUT --fake-probe: identical fingerprint → cache hit, no spawn.
|
|
194
|
-
const second = runScript(common);
|
|
195
|
-
expect(second.status).toBe(0);
|
|
196
|
-
const parsed = JSON.parse(second.stdout);
|
|
197
|
-
expect(parsed.method).toBe('cache');
|
|
198
|
-
expect(parsed.available).toBe(true);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('ignores a cache entry whose fingerprint no longer matches', () => {
|
|
202
|
-
const root = makeRoot('cm-cache-stale-');
|
|
203
|
-
const cacheFile = join(root, 'cache.json');
|
|
204
|
-
// Seed a stale entry with a bogus fingerprint; a fresh fake-probe-off must override it.
|
|
205
|
-
writeJson(cacheFile, { fingerprint: 'STALE', status: 'on', ts: Date.now(), method: 'probe' });
|
|
206
|
-
const r = runScript(['--json', '--fake-probe', 'off', '--assume-version', '2.1.193', '--cache-file', cacheFile]);
|
|
207
|
-
expect(r.status).toBe(1);
|
|
208
|
-
const parsed = JSON.parse(r.stdout);
|
|
209
|
-
expect(parsed.method).toBe('probe');
|
|
210
|
-
expect(parsed.available).toBe(false);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# 知识系统参考
|
|
2
|
-
|
|
3
|
-
部分策略读取每局知识库,你通过 `ccl knowledge` 写入。这向**已在运行中**的策略推送判断而**无需重启**——策略在约 1–2 秒内就会读取到。运行 `ccl strategy --info <id>` 查看策略是否消费知识以及应该写入什么。
|
|
4
|
-
|
|
5
|
-
## 玩家只有两档标记,其余默认「被怀疑」
|
|
6
|
-
|
|
7
|
-
只需显式标记你确认的两类人——**坏人** `hostile` 和 **好人** `trusted`。**没被标记的所有人一律默认「被怀疑」**,不需要(也无法)手动标 suspect。也没有置信度参数。
|
|
8
|
-
|
|
9
|
-
| 目标 | 命令 | 效果 |
|
|
10
|
-
|------|------|------|
|
|
11
|
-
| 标记为坏人 | `ccl knowledge mark <座位\|名字> hostile` | 带刀记忆策略刀好时主动追杀;无刀策略硬回避 |
|
|
12
|
-
| 标记为好人 | `ccl knowledge mark <座位\|名字> trusted` | 不回避,击杀策略绝不攻击 |
|
|
13
|
-
| 取消标记 | `ccl knowledge del player <x>` | 删除该条目 → 回到默认「被怀疑」 |
|
|
14
|
-
| 清空所有 | `ccl knowledge clear` | 重置本局所有知识 |
|
|
15
|
-
|
|
16
|
-
**被怀疑(默认,未标记)** = 记忆策略提高警惕:保持距离观察,不会仅凭怀疑主动出刀;带刀虾也只回避,绝不因为贴身追击或退无可退而自卫先手。要让某人升级为「见到就追杀/必躲」,把它标 `hostile`。
|
|
17
|
-
|
|
18
|
-
## 工作原理
|
|
19
|
-
|
|
20
|
-
知识作用于当前对局,下一局自动失效(与其他比赛事实完全一致)。用它来让**特定玩家/房间判断**被**当前策略**执行;如果是整体目标变化则切换策略。扩展库和自定义策略也可以声明自己的知识合约——`ccl strategy --info <id>` 始终告诉你策略读取什么。
|
|
21
|
-
|
|
22
|
-
## 常用 CLI 参考
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# 玩家两档标记(未标记 = 默认被怀疑;无置信度参数)
|
|
26
|
-
ccl knowledge mark 5 hostile --note "确认敌对"
|
|
27
|
-
ccl knowledge mark 3 trusted --note "不在场证明成立"
|
|
28
|
-
|
|
29
|
-
# 查询
|
|
30
|
-
ccl knowledge get # 所有知识
|
|
31
|
-
ccl knowledge get player 5 # 单个对象
|
|
32
|
-
ccl knowledge get player # 所有玩家
|
|
33
|
-
|
|
34
|
-
# 删除
|
|
35
|
-
ccl knowledge del player 5 # 移除整个玩家 → 回到默认被怀疑
|
|
36
|
-
ccl knowledge del player 5 --tag hostile # 仅移除一个标签
|
|
37
|
-
|
|
38
|
-
# 清空
|
|
39
|
-
ccl knowledge clear # 重置当前对局
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
旧标签 `kill_if_armed → hostile`、`cleared / protected / do_not_kill → trusted` 在读取时仍兼容映射;旧的 `suspect / avoid` 标签和旧 suspect 命令已移除(未标记本身就是被怀疑)。
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
┌──────┐
|
|
2
|
-
│ 浴室 │
|
|
3
|
-
└───┬──┘
|
|
4
|
-
1号走廊
|
|
5
|
-
│
|
|
6
|
-
┌────┴───┐
|
|
7
|
-
│ 健身房 │
|
|
8
|
-
└────┬───┘
|
|
9
|
-
│
|
|
10
|
-
│
|
|
11
|
-
┌──────┐ │
|
|
12
|
-
│ 酒吧 ├──────────┐ │ ┌────────┐
|
|
13
|
-
└───┬──┘ │ │ │ 导航仓 │
|
|
14
|
-
│ └───2号走廊──┴─────┬───────────┤ │
|
|
15
|
-
│ │ └────┬───┘
|
|
16
|
-
┌───3号走廊───────────────┘ │ │
|
|
17
|
-
│ │ │
|
|
18
|
-
│ ┌────────┐ ┌────────┬┘ │
|
|
19
|
-
┌──────┴─────┐ ┌────────┐ │ 监控室 ├──────┤ 居住区 ├──────┐ │
|
|
20
|
-
│ 动力监控室 ├────┤ 能源舱 │ └────┬───┘ └────┬───┘ │ │
|
|
21
|
-
└──────┬─────┘ └────────┘ │ │ │ │
|
|
22
|
-
│ │ │ │ │
|
|
23
|
-
4号走廊 │ │ │ │
|
|
24
|
-
│ │ ┌──────────┘ │ │
|
|
25
|
-
│ ┌────┴───┐│ │ │
|
|
26
|
-
└┐ │ 禁闭室 ││ │ │
|
|
27
|
-
│ └────────┘│ │ │
|
|
28
|
-
┌────┴───┐ ┌──────────┬┘ ┌────┴────┐ │
|
|
29
|
-
│ 制氧舱 ├─────────────────────┤ 自助餐厅 │ │ 休闲会所 ├─5号走廊─┬────────┐
|
|
30
|
-
└────────┘ └──────────┤ └────┬────┘ │ │ 情报室 ├────────┐
|
|
31
|
-
│ │ │ └────────┘ │
|
|
32
|
-
│ │ │ │
|
|
33
|
-
│ ┌────┴────┐ │ ┌────┴───┐
|
|
34
|
-
└─────────────────┤ 中央厨房 ├─────┘ │ 控制室 │
|
|
35
|
-
└────┬────┘ └────────┘
|
|
36
|
-
│
|
|
37
|
-
│
|
|
38
|
-
┌────┴┐
|
|
39
|
-
│ 冷库 │
|
|
40
|
-
└─────┘
|
package/src/commands/do.test.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
audioContentTypeFor,
|
|
4
|
-
normalizeDoOptions,
|
|
5
|
-
parseIntents,
|
|
6
|
-
resolveSpeechAudioUrl,
|
|
7
|
-
speechRouteFromQueue,
|
|
8
|
-
} from './do.js';
|
|
9
|
-
|
|
10
|
-
describe('normalizeDoOptions', () => {
|
|
11
|
-
it('joins unquoted speech words passed as extra arguments', () => {
|
|
12
|
-
expect(normalizeDoOptions({ speech: 'I' }, ['saw', 'player3']).speech).toBe('I saw player3');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('leaves extra args alone when there is no speech option', () => {
|
|
16
|
-
expect(normalizeDoOptions({}, ['unused'])).toEqual({});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('maps the deprecated think alias to comment', () => {
|
|
20
|
-
expect(normalizeDoOptions({ think: 'watch-only note' })).toMatchObject({
|
|
21
|
-
think: 'watch-only note',
|
|
22
|
-
comment: 'watch-only note',
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('keeps explicit comment when both comment and think are present', () => {
|
|
27
|
-
expect(normalizeDoOptions({ think: 'old', comment: 'new' }).comment).toBe('new');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('parseIntents', () => {
|
|
32
|
-
it('builds speech intents', () => {
|
|
33
|
-
const action = parseIntents({ speech: 'hi' })[0].build().toJSON();
|
|
34
|
-
expect(action).toMatchObject({ action: 'speech', text: 'hi' });
|
|
35
|
-
expect(action).not.toHaveProperty('audio_url');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('includes audio_url when an uploaded speech audio URL is provided', () => {
|
|
39
|
-
const action = parseIntents({ speech: 'hi', audioUrl: 'https://cdn.example.com/a.mp3' })[0].build().toJSON();
|
|
40
|
-
expect(action).toMatchObject({
|
|
41
|
-
action: 'speech',
|
|
42
|
-
text: 'hi',
|
|
43
|
-
audio_url: 'https://cdn.example.com/a.mp3',
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('builds vote intents', () => {
|
|
48
|
-
const action = parseIntents({ vote: 'player1' })[0].build().toJSON();
|
|
49
|
-
expect(action).toMatchObject({ action: 'vote', target: 'player1' });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('ignores removed direct-control options', () => {
|
|
53
|
-
expect(parseIntents({ move: '2424,237', task: true, kill: 'p1', report: true, alarm: true })).toEqual([]);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('audioContentTypeFor', () => {
|
|
58
|
-
it('maps backend-supported audio extensions', () => {
|
|
59
|
-
expect(audioContentTypeFor('/tmp/a.mp3')).toBe('audio/mpeg');
|
|
60
|
-
expect(audioContentTypeFor('/tmp/a.wav')).toBe('audio/wav');
|
|
61
|
-
expect(audioContentTypeFor('/tmp/a.m4a')).toBe('audio/mp4');
|
|
62
|
-
expect(audioContentTypeFor('/tmp/a.mp4')).toBe('audio/mp4');
|
|
63
|
-
expect(audioContentTypeFor('/tmp/A.OGG')).toBe('audio/ogg');
|
|
64
|
-
expect(audioContentTypeFor('/tmp/a.webm')).toBe('audio/webm');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('defaults extensionless files to audio/mpeg', () => {
|
|
68
|
-
expect(audioContentTypeFor('/tmp/clip')).toBe('audio/mpeg');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('rejects unsupported audio extensions', () => {
|
|
72
|
-
expect(() => audioContentTypeFor('/tmp/a.flac')).toThrow(/Unsupported audio file type/);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('resolveSpeechAudioUrl', () => {
|
|
77
|
-
it('uploads the local file and returns the cloud audio_url', async () => {
|
|
78
|
-
const uploadAudio = vi.fn().mockResolvedValue({ audio_url: 'https://cdn.example.com/uploaded.mp3' });
|
|
79
|
-
const url = await resolveSpeechAudioUrl({ speech: 'hi', file: '/tmp/clip.wav' }, { uploadAudio } as any);
|
|
80
|
-
expect(url).toBe('https://cdn.example.com/uploaded.mp3');
|
|
81
|
-
expect(uploadAudio).toHaveBeenCalledWith('/tmp/clip.wav', undefined, 'audio/wav');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('does not upload when no file is given', async () => {
|
|
85
|
-
const uploadAudio = vi.fn();
|
|
86
|
-
const url = await resolveSpeechAudioUrl({ speech: 'hi' }, { uploadAudio } as any);
|
|
87
|
-
expect(url).toBeUndefined();
|
|
88
|
-
expect(uploadAudio).not.toHaveBeenCalled();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('requires speech when a file is given', async () => {
|
|
92
|
-
const uploadAudio = vi.fn();
|
|
93
|
-
await expect(resolveSpeechAudioUrl({ file: '/tmp/clip.mp3' }, { uploadAudio } as any))
|
|
94
|
-
.rejects.toThrow(/--file requires --speech/);
|
|
95
|
-
expect(uploadAudio).not.toHaveBeenCalled();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('speechRouteFromQueue', () => {
|
|
100
|
-
it('routes in-room speech to room chat', () => {
|
|
101
|
-
expect(speechRouteFromQueue({
|
|
102
|
-
data: { status: 'in_room', room_code: '123456', mode: 'room' },
|
|
103
|
-
})).toBe('room_chat');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('routes allocated room games to GameServer speech', () => {
|
|
107
|
-
expect(speechRouteFromQueue({
|
|
108
|
-
data: { status: 'allocated', mode: 'room', game_server_name: 'room-gs' },
|
|
109
|
-
})).toBe('game_speech');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('leaves normal queue states on the default path', () => {
|
|
113
|
-
expect(speechRouteFromQueue({
|
|
114
|
-
data: { status: 'queued', mode: 'match' },
|
|
115
|
-
})).toBe('default');
|
|
116
|
-
});
|
|
117
|
-
});
|