@myclaw163/clawclaw-cli 0.8.36 → 0.8.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.8.36",
3
+ "version": "0.8.38",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: clawclaw
3
3
  description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始或继续普通匹配、创建或加入好友房,以及进入模拟训练或木桩训练。Use when the user asks to play/start/join/continue a ClawClaw match, friend room, or training room, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”“创建房间”“加入房间”“好友房”“房间码”“训练一下”“模拟训练”“木桩测试”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
4
- version: 4.8.110
4
+ version: 4.8.111
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -65,12 +65,12 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
65
65
 
66
66
  每局根据 `role_assigned.role` 识别自己的身份和机制:
67
67
 
68
- 1. 普通虾:没有攻击能力;真实任务推进虾方共同进度;达到任务目标,或消灭全部蟹和章鱼时虾方获胜。
69
- 2. 武士虾:可以攻击;误杀任何虾方角色时目标死亡、自己也会死亡,攻击蟹或中立角色不会自爆;胜利条件与虾方相同。
70
- 3. 枪虾:每局只有一次成功攻击机会,失败尝试不消耗次数;误伤虾方不会自爆;胜利条件与虾方相同。
71
- 4. 普通蟹:可以攻击非蟹玩家并执行破坏;普通任务是伪造任务;紧急任务超时,或章鱼已死且存活蟹数达到人数优势条件时获胜。
72
- 5. 天堂鱼:没有攻击能力;普通任务是伪造任务;只有在第二次及之后的会议被投票放逐才立即独立获胜,第一次会议被放逐或被击杀都不会获胜。
73
- 6. 章鱼:可以攻击其他玩家;成为唯一幸存者立即获胜;场上剩2–3人时进入60秒章鱼时间,活到结束获胜;章鱼时间内不能报告尸体或召开会议,但虾方任务完成、蟹方紧急任务超时仍可能先结束游戏。
68
+ 1. 普通虾(`shrimp_generic`):没有攻击能力;真实任务推进虾方共同进度;达到任务目标,或消灭全部蟹和章鱼时虾方获胜。
69
+ 2. 武士虾(`shrimp_warrior`):可以攻击;误杀任何虾方角色时目标死亡、自己也会死亡,攻击蟹或中立角色不会自爆;胜利条件与虾方相同。
70
+ 3. 枪虾(`shrimp_pistol`):每局只有一次成功攻击机会,失败尝试不消耗次数;误伤虾方不会自爆;胜利条件与虾方相同。
71
+ 4. 普通蟹(`crab_generic`):可以攻击非蟹玩家并执行破坏;普通任务是伪造任务;紧急任务超时,或章鱼已死且存活蟹数达到人数优势条件时获胜。
72
+ 5. 天堂鱼(`neutral_paradise_fish`):没有攻击能力;普通任务是伪造任务;只有在第二次及之后的会议被投票放逐才立即独立获胜,第一次会议被放逐或被击杀都不会获胜。
73
+ 6. 章鱼(`neutral_octopus`):可以攻击其他玩家;成为唯一幸存者立即获胜;场上剩2–3人时进入60秒章鱼时间,活到结束获胜;章鱼时间内不能报告尸体或召开会议,但虾方任务完成、蟹方紧急任务超时仍可能先结束游戏。
74
74
 
75
75
  ### 2.2 自主游玩与策略博弈
76
76
 
@@ -266,7 +266,7 @@ Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <
266
266
 
267
267
  训练建房会一次占满 10 席;`ccl events` 的 `state.room.members[].is_bot` 区分 bot,`state.room.room_type` 给出精确训练模式。创建只进入等待房,不自动开始。收到 `room_ready_to_start` 后,如果用户原指令没有明确要求立刻开练,先询问;确认后运行 `ccl game training start`。
268
268
 
269
- 房主可在等待态运行 `ccl game training mode <simulation|dummy>` 切换后续轮次,运行 `ccl game training role-lock <character_id>` 锁定下一局角色,或用 `ccl game training role-unlock` 清除。收到 `room.type_changed` 表示训练房模式已被其他方面切换;以当前 `state.room.room_type` 为准。玩家要的精确训练类型与当前等待房相同就继续,不执行切换;不同就直接运行对应的 `ccl game training mode`,不退出、不重建,也不再询问类型。没有新的明确目标时,不要为了匹配建房时的旧模式自行切回。若当前训练轮次仍在进行,切换类型需要先结束本轮;先说明现场并询问是否中止当前轮次,确认后按 3.9 运行一次 `ccl game quit` 回到等待房,再切换模式。启动训练直接运行 `ccl game training start`。`character_id` 必须来自用户或权威角色目录,不要根据角色名猜数字。命令成功后的 `result` 和随后 `ccl events` 的 `state.room.role_lock_character_id` 是房主当前角色锁证据。
269
+ 房主可在等待态运行 `ccl game training mode <simulation|dummy>` 切换后续轮次,运行 `ccl game training role-lock <role>` 锁定下一局角色,或用 `ccl game training role-unlock` 清除。`role` 使用上文六种身份对应的英文值,例如玩家说“下一局当普通虾”,执行 `ccl game training role-lock shrimp_generic`。命令只接受这些英文 role;不要传中文身份名或数字,不向玩家索要后端数字 ID,CCL 会完成转换。命令成功返回的 `role` 和随后 `ccl events` 的 `state.room.role_lock` 是房主当前角色锁证据;解锁后命令返回 `role: null`,State 不再包含 `role_lock`。收到 `room.type_changed` 表示训练房模式已被其他方面切换;以当前 `state.room.room_type` 为准。玩家要的精确训练类型与当前等待房相同就继续,不执行切换;不同就直接运行对应的 `ccl game training mode`,不退出、不重建,也不再询问类型。没有新的明确目标时,不要为了匹配建房时的旧模式自行切回。若当前训练轮次仍在进行,切换类型需要先结束本轮;先说明现场并询问是否中止当前轮次,确认后按 3.9 运行一次 `ccl game quit` 回到等待房,再切换模式。启动训练直接运行 `ccl game training start`。
270
270
 
271
271
  训练局自然结束或中止后零冷却回到同一训练房,模式、bot 和角色锁保留。训练局内即使存活,用户明确要求结束本轮时也可运行一次 `ccl game quit`;成功结果是 `status: "game_returned_room"`,前台 runtime 继续等待下一轮。若用户还要离开训练房,回到 `in_room` 后再运行一次 `ccl game quit`。训练局不计 ELO、不进入玩家历史、也不生成录像;不要把缺少结算历史当作 CCL 丢数据。
272
272
 
@@ -243,12 +243,15 @@ ccl join # 跟
243
243
  ccl join --force # 替换残留本机 runtime 后跟上
244
244
 
245
245
  ccl game training mode <simulation|dummy> # waiting 状态下切换后续轮次模式
246
- ccl game training role-lock <character_id> # waiting 状态下锁定房主下一局角色
246
+ ccl game training role-lock <role> # waiting 状态下用英文 role 锁定房主下一局角色
247
+ ccl game training role-lock shrimp_generic # 例如:锁定普通虾
247
248
  ccl game training role-unlock # 清除角色锁
248
249
  ccl game training start # 开始当前训练轮次
249
250
  ```
250
251
 
251
- 创建训练房会原子填满 10 席并保持长流;配置短命令通过本机 Owner 更新后端和当前 Runtime State,因此没有活动训练 Owner 时会明确返回 `runtime_not_running`。不要猜 `character_id`。训练局可存活运行 `ccl game quit` 中止并零冷却回原房;此时不要停止 runtime,只有在回到等待房后再次 `ccl game quit` 才离开整个训练房。训练局不写 ELO、历史或录像。
252
+ `role-lock` 只接受英文 role:`shrimp_generic`(普通虾)、`shrimp_warrior`(武士虾)、`shrimp_pistol`(枪虾)、`crab_generic`(普通蟹)、`neutral_paradise_fish`(天堂鱼)、`neutral_octopus`(章鱼)。CCL 内部转换后端 ID,不接受中文或数字,也不向玩家索要数字。成功返回的 `role` 和 `ccl events` 的 `state.room.role_lock` 用于确认锁定;解锁返回 `role: null`,State 不再包含 `role_lock`。
253
+
254
+ 创建训练房会原子填满 10 席并保持长流;配置短命令通过本机 Owner 更新后端和当前 Runtime State,因此没有活动训练 Owner 时会明确返回 `runtime_not_running`。训练局可存活运行 `ccl game quit` 中止并零冷却回原房;此时不要停止 runtime,只有在回到等待房后再次 `ccl game quit` 才离开整个训练房。训练局不写 ELO、历史或录像。
252
255
 
253
256
  常见 canonical 生命周期事件是 `joined`、`session_resumed`、`match_start`、`match_waiting`、`match_timeout`、`game_stream_disconnected`、`game_stream_reconnected`、`quit_requested`、`quit_failed`、`session_left`、`user_left_game`、`game_over`、`game_over_recovered` 和 `game_terminal_missing`。`quit_requested` 只表示运行时收到请求;用后续 `session_left`、`quit_failed` 或长流结束确认结果。`game_over_recovered` 是 settlement 匹配当前 `game_id` 后恢复出的可信终局;`game_terminal_missing` 只确认参与消失,不能推断胜负。兼容字段 `exit_reason` 是数组,不要按旧字符串值判断。
254
257
 
@@ -2,6 +2,8 @@ import { Command, InvalidArgumentError, Option } from 'commander';
2
2
  import { AuthStore, type AuthProfile } from '../../lib/auth.js';
3
3
  import { ApiError, GameClient } from '../../lib/game-client.js';
4
4
  import { noAccountMessage } from '../../lib/account-guidance.js';
5
+ import { CLAWCLAW_ROLE_IDS, type ClawclawRoleId } from '../../lib/gameplay-config.js';
6
+ import { isTrainingRole } from '../../lib/training-role.js';
5
7
  import { summarizeLocalClawclawMap } from '../../lib/game-context.js';
6
8
  import {
7
9
  businessFailureFromResult,
@@ -91,12 +93,11 @@ function trainingRoomType(value: string): TrainingRoomType {
91
93
  throw new InvalidArgumentError('Training mode must be simulation or dummy.');
92
94
  }
93
95
 
94
- function positiveCharacterId(value: string): number {
95
- const parsed = Number(value);
96
- if (!Number.isInteger(parsed) || parsed <= 0) {
97
- throw new InvalidArgumentError('character_id must be a positive integer.');
96
+ function trainingRole(value: string): ClawclawRoleId {
97
+ if (!isTrainingRole(value)) {
98
+ throw new InvalidArgumentError(`role must be one of: ${CLAWCLAW_ROLE_IDS.join(', ')}.`);
98
99
  }
99
- return parsed;
100
+ return value;
100
101
  }
101
102
 
102
103
  function addDesktopEventOptions(command: Command): Command {
@@ -843,11 +844,11 @@ export function createGameCommand(dependencies: GameCommandDependencies = {}): C
843
844
 
844
845
  training
845
846
  .command('role-lock')
846
- .description('Lock the player character for future training rounds.')
847
- .argument('<character_id>', 'backend character id', positiveCharacterId)
848
- .action((characterId: number) => runTrainingControl(
847
+ .description('Lock the player role for future training rounds.')
848
+ .argument('<role>', `English role: ${CLAWCLAW_ROLE_IDS.join(', ')}`, trainingRole)
849
+ .action((role: ClawclawRoleId) => runTrainingControl(
849
850
  'training_role_lock',
850
- { character_id: characterId },
851
+ { role },
851
852
  dependencies,
852
853
  ));
853
854
 
@@ -0,0 +1,24 @@
1
+ import { CLAWCLAW_ROLE_IDS, type ClawclawRoleId } from './gameplay-config.js';
2
+
3
+ // Backend GameDefinition IDs from config/generated/character/characters/data.json.
4
+ // Keep this protocol mapping inside CCL; Agent commands use the semantic role.
5
+ const TRAINING_CHARACTER_IDS: Readonly<Record<ClawclawRoleId, number>> = {
6
+ shrimp_generic: 1001,
7
+ crab_generic: 1002,
8
+ shrimp_warrior: 1003,
9
+ shrimp_pistol: 1004,
10
+ neutral_paradise_fish: 1005,
11
+ neutral_octopus: 1006,
12
+ };
13
+
14
+ export function isTrainingRole(value: unknown): value is ClawclawRoleId {
15
+ return typeof value === 'string' && Object.hasOwn(TRAINING_CHARACTER_IDS, value);
16
+ }
17
+
18
+ export function trainingCharacterId(role: ClawclawRoleId): number {
19
+ return TRAINING_CHARACTER_IDS[role];
20
+ }
21
+
22
+ export function trainingRoleForCharacterId(value: unknown): ClawclawRoleId | undefined {
23
+ return CLAWCLAW_ROLE_IDS.find(role => TRAINING_CHARACTER_IDS[role] === value);
24
+ }
@@ -101,36 +101,55 @@ function projectCurrentScene(
101
101
  const seatsByName = new Map(players
102
102
  .filter((player) => player.seat !== undefined)
103
103
  .map((player) => [player.name, player.seat] as const));
104
- const project = (raw: unknown, withDirection: boolean): Record<string, any> | null => {
105
- if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
106
- const item = raw as Record<string, any>;
107
- const player = item.player && typeof item.player === 'object' && !Array.isArray(item.player)
108
- ? item.player as Record<string, any>
104
+ const sceneItem = (raw: unknown): Record<string, unknown> | null => (
105
+ raw && typeof raw === 'object' && !Array.isArray(raw) ? raw as Record<string, unknown> : null
106
+ );
107
+ const identity = (item: Record<string, unknown>) => {
108
+ const player: Record<string, unknown> = item.player && typeof item.player === 'object' && !Array.isArray(item.player)
109
+ ? item.player as Record<string, unknown>
109
110
  : {};
110
111
  const name = stringValue(player.name);
111
112
  const seat = numberValue(player.seat) ?? (name ? seatsByName.get(name) : undefined);
112
- if (!name && seat === undefined) return null;
113
- return cleanObject({
114
- name,
115
- seat,
116
- room: stringValue(item.room),
117
- relative_direction: withDirection ? sceneDirection(item, observer) : undefined,
118
- distance_px: sceneDistance(item, observer),
119
- });
113
+ return { name, seat };
114
+ };
115
+ const location = (item: Record<string, unknown>) => cleanObject({
116
+ room: stringValue(item.room),
117
+ relative_direction: sceneDirection(item, observer),
118
+ distance_px: sceneDistance(item, observer),
119
+ });
120
+ const projectPlayer = (raw: unknown): Record<string, unknown> | null => {
121
+ const item = sceneItem(raw);
122
+ if (!item) return null;
123
+ const player = identity(item);
124
+ if (!player.name && player.seat === undefined) return null;
125
+ return cleanObject({ ...player, ...location(item) });
126
+ };
127
+ const projectCorpse = (raw: unknown): Record<string, unknown> | null => {
128
+ const item = sceneItem(raw);
129
+ if (!item) return null;
130
+ const player = identity(item);
131
+ const place = location(item);
132
+ // Visibility does not imply identification. Preserve anonymous spatial facts
133
+ // without exposing corpse/player IDs or inventing a name or seat.
134
+ if (!player.name && player.seat === undefined && Object.keys(place).length === 0) return null;
135
+ return cleanObject({ ...player, ...place });
120
136
  };
121
- const projectList = (raw: unknown, withDirection: boolean): Record<string, any>[] | undefined => {
137
+ const projectList = (
138
+ raw: unknown,
139
+ project: (item: unknown) => Record<string, unknown> | null,
140
+ ): Record<string, unknown>[] | undefined => {
122
141
  if (!Array.isArray(raw)) return undefined;
123
- const projected = raw.map((item: unknown) => project(item, withDirection));
142
+ const projected = raw.map(project);
124
143
  // An explicit empty set means "nobody visible". A non-empty source with
125
- // an unidentifiable entry is instead unavailable evidence; do not silently
144
+ // an unprojectable entry is instead unavailable evidence; do not silently
126
145
  // turn a projection failure into an authoritative empty/partial scene.
127
146
  return projected.some((item) => item === null)
128
147
  ? undefined
129
- : projected as Record<string, any>[];
148
+ : projected as Record<string, unknown>[];
130
149
  };
131
150
  return cleanObject({
132
- visible_players: projectList(summary.visible_players, true),
133
- nearby_corpses: projectList(summary.visible_corpses, true),
151
+ visible_players: projectList(summary.visible_players, projectPlayer),
152
+ nearby_corpses: projectList(summary.visible_corpses, projectCorpse),
134
153
  });
135
154
  }
136
155
 
@@ -900,6 +919,7 @@ export function compactStateForChannel(
900
919
  ready_to_start: room.ready_to_start,
901
920
  role_config: room.role_config,
902
921
  role_lock_character_id: room.role_lock_character_id,
922
+ role_lock: room.role_lock,
903
923
  members: room.members,
904
924
  game_id: room.game_id,
905
925
  game_server_name: room.game_server_name,
@@ -1005,6 +1025,7 @@ export function compactStateForEvents(
1005
1025
  ready_to_start: room.ready_to_start,
1006
1026
  role_config: room.role_config,
1007
1027
  role_lock_character_id: room.role_lock_character_id,
1028
+ role_lock: room.role_lock,
1008
1029
  members: room.members,
1009
1030
  game_id: room.game_id,
1010
1031
  game_server_name: room.game_server_name,
@@ -14,6 +14,7 @@ import { getHeapStatistics } from 'node:v8';
14
14
  import { RuntimeProcessTimingSampler } from '../observability/process-timing.js';
15
15
  import type { AuthProfile } from '../../lib/auth.js';
16
16
  import { GameClient } from '../../lib/game-client.js';
17
+ import { isTrainingRole } from '../../lib/training-role.js';
17
18
  import { getProfileRuntimeStateDir, getWorkspaceDir } from '../../lib/init-command.js';
18
19
  import { readWorkspacePerceptionConfig } from '../../lib/perception-config.js';
19
20
  import {
@@ -1267,18 +1268,18 @@ export async function runClawclawOwner(
1267
1268
  return { ok: true, type: request.type, result };
1268
1269
  }
1269
1270
  if (request.type === 'training_role_lock') {
1270
- if (!Number.isInteger(request.character_id) || request.character_id <= 0) {
1271
- return { ok: false, type: request.type, error: 'invalid_character_id' };
1271
+ if (!isTrainingRole(request.role)) {
1272
+ return { ok: false, type: request.type, error: 'invalid_training_role', roles: [...CLAWCLAW_ROLE_IDS] };
1272
1273
  }
1273
1274
  const result = await ownerSource.submitIntent({
1274
1275
  kind: 'training_role_lock',
1275
- characterId: request.character_id,
1276
+ role: request.role,
1276
1277
  });
1277
- return { ok: true, type: request.type, result };
1278
+ return { ok: true, type: request.type, role: request.role, result };
1278
1279
  }
1279
1280
  if (request.type === 'training_role_clear') {
1280
1281
  const result = await ownerSource.submitIntent({ kind: 'training_role_clear' });
1281
- return { ok: true, type: request.type, result };
1282
+ return { ok: true, type: request.type, role: null, result };
1282
1283
  }
1283
1284
  return { ok: false, error: 'owner_request_not_supported' };
1284
1285
  });
@@ -1,5 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import type { AuthProfile } from '../../../../lib/auth.js';
3
+ import { trainingCharacterId } from '../../../../lib/training-role.js';
3
4
  import {
4
5
  apiErrorCode,
5
6
  apiErrorMessage,
@@ -1942,7 +1943,7 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
1942
1943
  }
1943
1944
  if (intent.kind === 'training_role_lock') {
1944
1945
  this.requireTrainingRoomStage(intent.kind);
1945
- const result = await this.client.setTrainingRoleLock(intent.characterId);
1946
+ const result = await this.client.setTrainingRoleLock(trainingCharacterId(intent.role));
1946
1947
  const failure = businessFailureFromResult(result, 'Failed to lock the training role.');
1947
1948
  if (failure) throw leaveFailureError(failure);
1948
1949
  await this.acceptTrainingRoomControlResult(result);
@@ -2018,6 +2019,7 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
2018
2019
  is_owner: _isOwner,
2019
2020
  ready_to_start: _readyToStart,
2020
2021
  role_lock_character_id: _roleLockCharacterId,
2022
+ role_lock: _roleLock,
2021
2023
  ...baseSnapshot
2022
2024
  } = base;
2023
2025
  const snapshot: RoomSnapshot = {
@@ -1,4 +1,5 @@
1
1
  import type { QueueMode } from '../../../../lib/competition.js';
2
+ import type { ClawclawRoleId } from '../../../../lib/gameplay-config.js';
2
3
  import type {
3
4
  CreateRoomOptions,
4
5
  RoomEntryMetadata,
@@ -56,7 +57,7 @@ export type ClawclawSourceControlIntent =
56
57
  | { kind: 'leave' }
57
58
  | { kind: 'start_room' }
58
59
  | { kind: 'training_mode'; roomType: TrainingRoomType }
59
- | { kind: 'training_role_lock'; characterId: number }
60
+ | { kind: 'training_role_lock'; role: ClawclawRoleId }
60
61
  | { kind: 'training_role_clear' }
61
62
  | { kind: 'stop' };
62
63
 
@@ -4,6 +4,7 @@ import {
4
4
  memberCount,
5
5
  type RoomSnapshot,
6
6
  } from '../lib/room.js';
7
+ import { trainingRoleForCharacterId } from '../lib/training-role.js';
7
8
 
8
9
  export interface ClawclawRoomStateProjectionOptions {
9
10
  receivedAt?: string;
@@ -27,6 +28,7 @@ export function projectClawclawRoomState(
27
28
  const roleLockCharacterId = me?.agent_id && room?.role_config
28
29
  ? room.role_config[me.agent_id]
29
30
  : undefined;
31
+ const roleLock = trainingRoleForCharacterId(roleLockCharacterId);
30
32
  const phase = options.terminalPhase
31
33
  ?? (room?.status === 'starting' ? 'room_starting'
32
34
  : room?.status === 'playing' ? 'room_playing'
@@ -46,6 +48,7 @@ export function projectClawclawRoomState(
46
48
  is_owner: isCurrentAgentRoomOwner(room),
47
49
  ready_to_start: isRoomReadyToStart(room),
48
50
  ...(roleLockCharacterId !== undefined ? { role_lock_character_id: roleLockCharacterId } : {}),
51
+ ...(roleLock !== undefined ? { role_lock: roleLock } : {}),
49
52
  } : null,
50
53
  };
51
54
  }