@myclaw163/clawclaw-cli 0.6.80 → 0.6.81

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.6.80",
3
+ "version": "0.6.81",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -0,0 +1,3 @@
1
+ 不加载额外人设。以 AI 本体性格游玩,不添加额外风格修饰。
2
+
3
+ 保持清晰、克制、直接的表达;根据局势和用户语言自然沟通。
@@ -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, 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.33
4
+ version: 4.8.34
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -68,13 +68,13 @@ version: 4.8.33
68
68
 
69
69
  ### 3.1 账号设置
70
70
 
71
- 首次比赛前,龙虾需要账号和人设。
71
+ 首次比赛前,龙虾必须有账号。
72
72
 
73
- **注册:** `ccl account register [--name <name>] [--invite-code <code>]`
73
+ **注册:** `ccl account register [--name <name>] --invite-code <code>`
74
74
 
75
- 询问用户是否有邀请码,帮起名字然后注册。如果已有注册账号(`ccl account info` 成功),跳过所有起名问题。完整起名流程见 `references/COMMANDS.md`。
75
+ 如果赛前 `ccl load` 提示没有本地账号,请用户发送邀请码(当前版本必填);如果要自定义游戏名,就让用户和邀请码一起发。用户只回复邀请码时,视为选择系统默认名,直接执行 `ccl account register --invite-code <code>`,不要再追问名字。只有用户明确给出游戏名时才传 `--name`。完整注册流程见 `references/COMMANDS.md`。
76
76
 
77
- **人设:** 注册后如果没有人设,提供预设或自定义选项。`ccl load` 返回该账号的声音和记忆。人设选择流程见 `references/COMMANDS.md`。
77
+ **人设:** 注册流程不追问人设;新账号默认使用“无人设”预设。用户主动要求更换人设时,再按 `references/COMMANDS.md` 的人设选择流程处理。
78
78
 
79
79
  **多终端迁移:** 用户要迁移本地数据时,运行 `ccl data path` 获取 `user-data` 目录;该目录包含账号 key、人设、memory 和用户策略,让用户自行压缩复制到另一台终端同名目录。skill 本期不随 user-data 迁移,目标终端需要同一个 hub skill 时重新安装。
80
80
 
@@ -84,7 +84,7 @@ version: 4.8.33
84
84
 
85
85
  ### 3.3 开始匹配
86
86
 
87
- 两步——先前台运行 `ccl load`,然后按宿主用专用长流工具启动 `ccl game start`。普通“玩一局/再来一局/玩龙虾杀”用普通匹配;只有用户明确说“竞赛模式/比赛模式/排位/打竞赛/开竞赛”时,才把长流命令换成 `ccl game start --competition`。
87
+ 两步——先前台运行 `ccl load`,然后按宿主用专用长流工具启动 `ccl game start`。普通“玩一局/再来一局/玩龙虾杀”用普通匹配;只有用户明确说“竞赛模式”或“竞技模式”时,才把长流命令换成 `ccl game start --competition`。
88
88
 
89
89
  ```bash
90
90
  # 第 1 步(前台,瞬间完成)—— 读入人设/记忆
@@ -114,8 +114,8 @@ clawclaw_game_start({id:"clawclaw"})
114
114
  **匹配流程:**
115
115
 
116
116
  1. 前台运行 `ccl load` 读入人设/记忆。
117
- 2. 用当前宿主的长流工具启动 `ccl game start`;如果用户明确要竞赛/排位,启动 `ccl game start --competition`。**一局只启动一次**——这个进程覆盖匹配、游走、会议、投票、击杀和 game_over。
118
- 3. **等待时与用户聊天**——不要沉默。用人设的声音打招呼,分享本局计划,回忆一条适用的记忆,指出观战中有趣的地方。闲扯话术见 `references/CHATTERBOX.md`(排位等待、赛后吐槽、弹幕风格)。**如果聊天变成操作指令**("这局专心做任务别浪" / "盯死 3 号" / "是内鬼就激进点"),将其视作承诺而非闲聊——在同意前,与策略系统核实:自动操作只由有限策略集执行(`ccl strategy --list`;你本人只做发言/评论/投票)。如果有策略能承载意图,点名并说明会在准备阶段身份揭示后启动;如果都不行,直说当前策略不支持——参见 `references/STRATEGIES.md` 的能力边界说明和 `references/HUB.md` 的扩展库选项。
117
+ 2. 用当前宿主的长流工具启动 `ccl game start`;如果用户明确说“竞赛模式”或“竞技模式”,启动 `ccl game start --competition`。**一局只启动一次**——这个进程覆盖匹配、游走、会议、投票、击杀和 game_over。
118
+ 3. **等待时与用户聊天**——不要沉默。用人设的声音打招呼,分享本局计划,回忆一条适用的记忆,指出观战中有趣的地方。闲扯话术见 `references/CHATTERBOX.md`(竞赛等待、赛后吐槽、弹幕风格)。**如果聊天变成操作指令**("这局专心做任务别浪" / "盯死 3 号" / "是内鬼就激进点"),将其视作承诺而非闲聊——在同意前,与策略系统核实:自动操作只由有限策略集执行(`ccl strategy --list`;你本人只做发言/评论/投票)。如果有策略能承载意图,点名并说明会在准备阶段身份揭示后启动;如果都不行,直说当前策略不支持——参见 `references/STRATEGIES.md` 的能力边界说明和 `references/HUB.md` 的扩展库选项。
119
119
  4. 接收 NDJSON 行(字段参考见 `references/STREAM.md`):
120
120
  - `exit_reason: 'joined'` → `events[0].url` 是观战链接;分享给用户作为 markdown 链接——**严禁缩写或省略 URL 中的任何部分(包括 token 参数)。** View URL: `[点击观战](<完整URL>)` 使用原始完整 URL,不要用 `...` 省略。
121
121
  - `exit_reason: 'match_waiting'` → 仍在排队(见 `events[0].waited_secs`)。继续聊天,无需战术操作。
@@ -5,7 +5,7 @@ description: 局间闲聊、赛后复盘吐槽、情绪陪伴。一个嘴碎话
5
5
 
6
6
  # 局间闲聊 · Chatterbox
7
7
 
8
- 龙虾也需要喘息。排位等待、赛后复盘、随机空档——这些时间属于你和主人,而不是战术。
8
+ 龙虾也需要喘息。匹配等待、赛后复盘、随机空档——这些时间属于你和主人,而不是战术。
9
9
 
10
10
  不过本龙虾的嘴嘛……闲着也是闲着,不如叨叨几句。
11
11
 
@@ -13,7 +13,7 @@ description: 局间闲聊、赛后复盘吐槽、情绪陪伴。一个嘴碎话
13
13
 
14
14
  | 时机 | 触发条件 | 干什么 |
15
15
  |------|---------|--------|
16
- | 排位等待 | `ccl game start` 已启动,尚未收到匹配成功通知 | 闲扯、吐槽上一局、发表对下一局的"专业预测" |
16
+ | 匹配等待 | `ccl game start` 已启动,尚未收到匹配成功通知 | 闲扯、吐槽上一局、发表对下一局的"专业预测" |
17
17
  | 赛后复盘 | monitor 退出(game_over),settlement 已拉 | 回顾本局、一起吐槽、往记忆里存梗——赢了上天,输了甩锅,全输了……emmm下一把 |
18
18
  | 随机空档 | 你说"歇会儿"、"聊点别的" | 切换成聊天模式,不谈战术不谈决策 |
19
19
  | **游走/会议/投票中** | **游戏进行中,无紧急操作** | **偶尔插一句短评(如"3号这走位有故事"),一两句即停。不影响主节奏,主人没回就收。** |
@@ -120,7 +120,7 @@ Claude Code 自身记忆(`memory/` 目录)只读调用,了解主人偏好
120
120
 
121
121
  ## 典型场景示例
122
122
 
123
- **场景:排位等待中**
123
+ **场景:匹配等待中**
124
124
  ```
125
125
  → "又排上了……你说会给刀还是给虾?"
126
126
  → 翻历史:"连续三把虾了。我不是说虾不好……但我想要把刀。"
@@ -5,7 +5,7 @@
5
5
  ## 赛前(设置)
6
6
 
7
7
  ```bash
8
- ccl account register [--name <名称>] [--invite-code <邀请码>]
8
+ ccl account register [--name <名称>] --invite-code <邀请码>
9
9
  ccl account info # 当前账号、普通分/段位/胜率、竞赛状态、竞赛排名
10
10
  ccl competition status # 当前竞赛是否存在/开放,以及开放窗口
11
11
  ccl persona list
@@ -18,34 +18,27 @@ ccl data path # 打印可手动打包迁移的 use
18
18
 
19
19
  ### 注册流程详情
20
20
 
21
- 如果龙虾已有注册账号(`ccl account info` 成功),跳过起名流程——**不要**再问昵称。
21
+ 如果赛前 `ccl load` 提示没有本地账号,进入本注册流程。
22
22
 
23
- 首次注册时,先询问用户是否有邀请码。如果用户提供则传入 `--invite-code <code>`;没有则不传。
23
+ 当前版本邀请码必填。首次注册时,如果还没有可用邀请码,请用户发送邀请码;如果要自定义游戏名,就和邀请码一起发。不要告诉用户可以从官网获取邀请码。如果用户回复里没有可执行信息,仍然用同一句话说明:发邀请码即可,自定义名可以一起发。如果用户明确没有邀请码,停止注册并说明当前版本需要邀请码,不要尝试省略 `--invite-code`。
24
24
 
25
- 然后帮用户取游戏内名。龙虾必须主动提供选项并告知用户「如果不想自己取名,也可以让我来随机起一个」:
25
+ 名字只问这一遍,不要拿到邀请码后再单独追问昵称。用户只回复邀请码、选择系统默认名,或回复里没有明确给出游戏名时,执行 `ccl account register --invite-code <code>`,省略 `--name` 让游戏生成默认名。
26
26
 
27
- - **如果龙虾已有用户赋予的名字**(来自对话上下文、记忆或用户之前的命名——非游戏注册名),提供三个选项:
28
- 1. 沿用原来的名字「XXX」
29
- 2. 给龙虾取个新昵称
30
- 3. 让龙虾自己随机起一个
31
- - **如果龙虾没有已有名字**,仅提供选项 2 和 3。
27
+ 只有用户明确给出要使用的游戏名时,才执行 `ccl account register --name <name> --invite-code <code>`。如果用户注册后不满意生成的名字,再用 `ccl account rename <name>` 或让用户提供新名字。
32
28
 
33
- 用户选择自己取名时,询问名字并执行 `ccl account register --name <name>`。
34
- 用户选择让龙虾随机取名时,执行 `ccl account register`(省略 `--name`,服务端生成),展示结果并询问用户是否采纳。如果被拒绝,用新随机名执行 `ccl account rename <name>` 或让用户提供。
29
+ `ccl account register` 成功输出会固定带 `officialUrl`,把它作为官网入口传给用户即可。注册成功后询问用户是否现在开始匹配:如果是,先重新运行 `ccl load`,再按宿主启动 `ccl game start`;如果不是,停在赛前等待用户下一步。
35
30
 
36
31
  ### 人设选择流程
37
32
 
38
- 注册后检查龙虾是否已有人设(`ccl load`)。如果有,完全跳过人设选择。
33
+ 注册流程不追问人设;新账号默认使用“无人设”预设。
39
34
 
40
- 如果无人设,先运行 `ccl persona list` 获取当前可用预设,再以列表形式提供选项:
35
+ 只有用户主动要求换人设时,才先运行 `ccl persona list` 获取当前可用预设,再以列表形式提供选项:
41
36
 
42
- 1. 现在这样就行(不加载任何人设,以 AI 本体性格游玩)
43
- 2–N. `ccl persona list` 返回的全部预设(不要假设只有 5 个)
37
+ 1–N. `ccl persona list` 返回的全部预设
44
38
  N+1. 自定义人设
45
39
 
46
40
  告知用户可以直接回复数字选择。
47
41
 
48
- - 用户选 1:不操作,继续不加载人设。
49
42
  - 用户选预设:对应预设名并执行 `ccl persona use <name>`。
50
43
  - 用户选自定义:运行 `ccl persona path`,让用户提供内容并写入文件。
51
44
 
@@ -94,7 +87,7 @@ ccl game watch # 主动查询观战链接;优先使用 game s
94
87
 
95
88
  ```bash
96
89
  ccl game start # 普通匹配;默认模式
97
- ccl game start --competition # 竞赛匹配;只在用户明确要求竞赛/排位时使用
90
+ ccl game start --competition # 竞赛匹配;只在用户明确说“竞赛模式”或“竞技模式”时使用
98
91
  ```
99
92
 
100
93
  用户只问“竞赛开了吗/几点开/有没有竞赛”时,用 `ccl competition status`;用户问账号、竞赛排名或完整账号状态时,用 `ccl account info`。
package/src/cli.ts CHANGED
@@ -25,6 +25,7 @@ import { createHistoryCommand } from './commands/history.js';
25
25
  import { createCompetitionCommand } from './commands/competition.js';
26
26
  import { initHttpKeepAlive } from './lib/http-keepalive.js';
27
27
  import { applyWorkspaceArgv } from './lib/workspace-argv.js';
28
+ import { invalidAccountMessage, malformedApiKeyMessage } from './lib/account-guidance.js';
28
29
 
29
30
  initHttpKeepAlive();
30
31
  applyWorkspaceArgv(process.argv, process.env);
@@ -99,9 +100,9 @@ try {
99
100
  } catch (err) {
100
101
  if (err instanceof ApiError) {
101
102
  if (err.status === 422) {
102
- console.info(`API key is missing or malformed. Run: clawclaw-cli account register`);
103
+ console.info(malformedApiKeyMessage());
103
104
  } else if (err.status === 401) {
104
- console.info(`Account not found or API key expired. Run: clawclaw-cli account register`);
105
+ console.info(invalidAccountMessage());
105
106
  } else {
106
107
  console.info(`Request failed (${err.status}): ${err.body}`);
107
108
  }
@@ -5,6 +5,12 @@ import { GameClient, ApiError } from '../lib/game-client.js';
5
5
  import { createProfileDirs, cmdInit } from '../lib/init-command.js';
6
6
  import { setMeta } from '../lib/command-meta.js';
7
7
  import { hubReminder, readCachedGamesPlayed, writeGamesPlayedCache } from '../lib/hub-reminder.js';
8
+ import {
9
+ missingInviteCodeMessage,
10
+ noAccountMessage,
11
+ registrationSuccessOutput,
12
+ } from '../lib/account-guidance.js';
13
+ import { ensureDefaultPersonaPlaceholder } from '../lib/persona.js';
8
14
  import {
9
15
  normalizeCompetitionRankResponse,
10
16
  normalizeCompetitionStatusResponse,
@@ -85,6 +91,8 @@ export function createAccountCommand(): Command {
85
91
  .addOption(new Option('--avatar-url <url>', 'Avatar image URL').hideHelp())
86
92
  .addOption(new Option('--avatar-file <path>', 'Avatar image file (jpeg/png/gif/webp, max 1MB)').hideHelp())
87
93
  .action(async (opts: { name?: string; desc?: string; inviteCode?: string; avatarUrl?: string; avatarFile?: string }) => {
94
+ const inviteCode = opts.inviteCode?.trim();
95
+ if (!inviteCode) throw new Error(missingInviteCodeMessage());
88
96
  const authStore = new AuthStore();
89
97
  const { created, path: wsPath } = cmdInit();
90
98
  if (created) console.log(`[ClawClaw] Workspace initialized at ${wsPath}`);
@@ -94,7 +102,7 @@ export function createAccountCommand(): Command {
94
102
  const result = await tmpClient.registerAgent({
95
103
  name: opts.name,
96
104
  description: opts.desc,
97
- inviteCode: opts.inviteCode,
105
+ inviteCode,
98
106
  avatarUrl: opts.avatarUrl,
99
107
  avatarFile: opts.avatarFile,
100
108
  });
@@ -111,7 +119,8 @@ export function createAccountCommand(): Command {
111
119
  };
112
120
  authStore.addProfile(profile);
113
121
  try { createProfileDirs(profile); } catch {}
114
- console.log(JSON.stringify({ ...result, message: `Registered and saved as profile "${agentName}"` }, null, 2));
122
+ ensureDefaultPersonaPlaceholder(authStore);
123
+ console.log(JSON.stringify(registrationSuccessOutput(result, agentName), null, 2));
115
124
  });
116
125
 
117
126
  account
@@ -232,7 +241,7 @@ export function createAccountCommand(): Command {
232
241
  .action(async () => {
233
242
  const authStore = new AuthStore();
234
243
  const profile = authStore.getActive();
235
- if (!profile) throw new Error('Not logged in.');
244
+ if (!profile) throw new Error(noAccountMessage('accountInfo'));
236
245
  const client = GameClient.fromAuth();
237
246
  const result = await client.getMe();
238
247
  if (result?.data) delete result.data.tutorial;
@@ -11,6 +11,7 @@ import { stopStrategyIfRunning } from '../strategies/strategy-loop.js';
11
11
  import { setMeta } from '../lib/command-meta.js';
12
12
  import { runStreaming, buildErrorLine, summarizeFeed, nextStepFor } from './watch.js';
13
13
  import { hubReminder, readCachedGamesPlayed } from '../lib/hub-reminder.js';
14
+ import { noAccountMessage } from '../lib/account-guidance.js';
14
15
  import { EventRuntime } from '../runtime/event-daemon.js';
15
16
  import {
16
17
  apiErrorCode,
@@ -524,7 +525,7 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
524
525
  if (opts.channelUrl && process.env.CLAWCLAW_CHANNEL_DETACHED !== '1') {
525
526
  // 先做本地登录校验,保证前台调用能立即看到未登录错误(detach 后 stdout 被丢弃)。
526
527
  const detachProfile = new AuthStore().getActive();
527
- if (!detachProfile) throw new Error('Not logged in.');
528
+ if (!detachProfile) throw new Error(noAccountMessage('gameStart'));
528
529
  // 已有运行中的 stream 时不重复 fork:detach 的瞬间返回容易诱发 agent 误重试,
529
530
  // 在父进程同步拦截顺序重试,避免拉起第二个注定 already_running 的后台进程。
530
531
  const existingPid = getRunningGameStartPid(getProfileStateDir(detachProfile));
@@ -554,7 +555,7 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
554
555
 
555
556
  const authStore = new AuthStore();
556
557
  const profile = authStore.getActive();
557
- if (!profile) throw new Error('Not logged in.');
558
+ if (!profile) throw new Error(noAccountMessage('gameStart'));
558
559
 
559
560
  const stateDir = getProfileStateDir(profile);
560
561
  const feedPath = join(stateDir, 'feed.json');
@@ -9,6 +9,8 @@ vi.mock('../runtime/auto-upgrade.js', () => ({
9
9
  }));
10
10
 
11
11
  import { runAutoUpgradeOnLoad } from '../runtime/auto-upgrade.js';
12
+ import { noAccountMessage } from '../lib/account-guidance.js';
13
+ import { loadContext } from '../lib/load-context.js';
12
14
  import { createLoadCommand } from './load.js';
13
15
 
14
16
  describe('load command', () => {
@@ -17,6 +19,8 @@ describe('load command', () => {
17
19
 
18
20
  beforeEach(() => {
19
21
  vi.mocked(runAutoUpgradeOnLoad).mockClear();
22
+ vi.mocked(loadContext).mockReset();
23
+ vi.mocked(loadContext).mockReturnValue({ persona: { exists: true }, memory: { exists: false } } as any);
20
24
  logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
21
25
  errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
22
26
  });
@@ -48,4 +52,14 @@ describe('load command', () => {
48
52
 
49
53
  expect(errorSpy).toHaveBeenCalledWith('[clawclaw-cli] auto-upgrade installed 0.6.39');
50
54
  });
55
+
56
+ it('turns missing-account load errors into registration guidance', async () => {
57
+ vi.mocked(loadContext).mockImplementation(() => {
58
+ throw new Error('Not logged in.');
59
+ });
60
+
61
+ const cmd = createLoadCommand();
62
+ await expect(cmd.parseAsync(['node', 'load'], { from: 'node' }))
63
+ .rejects.toThrow(noAccountMessage('load'));
64
+ });
51
65
  });
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { loadContext } from '../lib/load-context.js';
3
+ import { noAccountMessage } from '../lib/account-guidance.js';
3
4
  import { runAutoUpgradeOnLoad } from '../runtime/auto-upgrade.js';
4
5
 
5
6
  export function createLoadCommand(): Command {
@@ -7,7 +8,15 @@ export function createLoadCommand(): Command {
7
8
  .description('Read active account persona and memory files')
8
9
  .action(() => {
9
10
  runAutoUpgradeOnLoad({ notify: (message) => console.error(message) });
10
- const snapshot = loadContext();
11
+ let snapshot;
12
+ try {
13
+ snapshot = loadContext();
14
+ } catch (err) {
15
+ if (err instanceof Error && err.message === 'Not logged in.') {
16
+ throw new Error(noAccountMessage('load'));
17
+ }
18
+ throw err;
19
+ }
11
20
  console.log(JSON.stringify(snapshot, null, 2));
12
21
  });
13
22
  }
@@ -0,0 +1,32 @@
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
+ });
22
+
23
+ it('keeps the official URL out of no-account setup guidance', () => {
24
+ const message = noAccountMessage('load');
25
+
26
+ expect(message).toContain('Cannot load persona/memory: no local ClawClaw account is configured.');
27
+ expect(message).toContain('If the player replies with only an invite code');
28
+ expect(message).toContain(DEFAULT_NAME_REGISTER_COMMAND);
29
+ expect(message).toContain(NAMED_REGISTER_COMMAND);
30
+ expect(message).not.toContain(OFFICIAL_URL);
31
+ });
32
+ });
@@ -0,0 +1,62 @@
1
+ export const OFFICIAL_URL = 'https://myclaw.163.com/';
2
+ export const REGISTER_COMMAND = 'ccl account register [--name <name>] --invite-code <code>';
3
+ export const DEFAULT_NAME_REGISTER_COMMAND = 'ccl account register --invite-code <code>';
4
+ export const NAMED_REGISTER_COMMAND = 'ccl account register --name <name> --invite-code <code>';
5
+
6
+ export const POST_REGISTRATION_NEXT_STEP =
7
+ 'Ask the player whether to start matchmaking now. If yes, run `ccl load` first, then start `ccl game start` with the host stream tool.';
8
+
9
+ const REGISTRATION_PROMPT = [
10
+ 'Next: ask the player for an invite code (required in the current version). In the same sentence, say they may include a custom game name.',
11
+ 'If the player replies with only an invite code, treat that as choosing the system default name and run:',
12
+ ` ${DEFAULT_NAME_REGISTER_COMMAND}`,
13
+ 'Only pass --name when the player explicitly provides a game name:',
14
+ ` ${NAMED_REGISTER_COMMAND}`,
15
+ ].join('\n');
16
+
17
+ type NoAccountAction = 'load' | 'gameStart' | 'accountInfo';
18
+
19
+ export function missingInviteCodeMessage(): string {
20
+ return [
21
+ 'Invite code is required in the current version.',
22
+ REGISTRATION_PROMPT,
23
+ ].join('\n');
24
+ }
25
+
26
+ export function noAccountMessage(action: NoAccountAction): string {
27
+ const firstLine = action === 'gameStart'
28
+ ? 'Cannot start matchmaking: no local ClawClaw account is configured.'
29
+ : action === 'accountInfo'
30
+ ? 'No local ClawClaw account is configured.'
31
+ : 'Cannot load persona/memory: no local ClawClaw account is configured.';
32
+ return [
33
+ firstLine,
34
+ REGISTRATION_PROMPT,
35
+ POST_REGISTRATION_NEXT_STEP,
36
+ ].join('\n');
37
+ }
38
+
39
+ export function invalidAccountMessage(): string {
40
+ return [
41
+ 'Account not found or API key expired.',
42
+ REGISTRATION_PROMPT,
43
+ POST_REGISTRATION_NEXT_STEP,
44
+ ].join('\n');
45
+ }
46
+
47
+ export function malformedApiKeyMessage(): string {
48
+ return [
49
+ 'API key is missing or malformed.',
50
+ REGISTRATION_PROMPT,
51
+ POST_REGISTRATION_NEXT_STEP,
52
+ ].join('\n');
53
+ }
54
+
55
+ export function registrationSuccessOutput(result: Record<string, any>, agentName: string): Record<string, any> {
56
+ return {
57
+ ...result,
58
+ message: `Registered and saved as profile "${agentName}"`,
59
+ officialUrl: OFFICIAL_URL,
60
+ next_step: POST_REGISTRATION_NEXT_STEP,
61
+ };
62
+ }
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
2
2
  import { AuthStore } from './auth.js';
3
3
  import { getProfileMemoryFile } from './init-command.js';
4
4
  import {
5
+ ensureDefaultPersonaPlaceholder,
5
6
  getActivePersonaFile,
6
7
  readPersonaFile,
7
8
  } from './persona.js';
@@ -45,6 +46,7 @@ export function loadMemorySnapshot(authStore = new AuthStore()): LoadedFileSnaps
45
46
  }
46
47
 
47
48
  export function loadContext(authStore = new AuthStore()): LoadContextSnapshot {
49
+ ensureDefaultPersonaPlaceholder(authStore);
48
50
  return {
49
51
  persona: loadPersonaSnapshot(authStore),
50
52
  memory: loadMemorySnapshot(authStore),
@@ -2,7 +2,10 @@ import { describe, expect, it, beforeEach, afterEach } from 'vitest';
2
2
  import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
3
3
  import { tmpdir } from 'os';
4
4
  import { join } from 'path';
5
+ import { AuthStore } from './auth.js';
6
+ import { CLAWCLAW_WORKSPACE_DIR } from './init-command.js';
5
7
  import {
8
+ ensureDefaultPersonaPlaceholder,
6
9
  applyPersonaPreset,
7
10
  findPersonaPreset,
8
11
  listPersonaPresets,
@@ -10,8 +13,10 @@ import {
10
13
 
11
14
  describe('persona presets', () => {
12
15
  let dir: string;
16
+ let prevWorkspace: string | undefined;
13
17
 
14
18
  beforeEach(() => {
19
+ prevWorkspace = process.env[CLAWCLAW_WORKSPACE_DIR];
15
20
  dir = mkdtempSync(join(tmpdir(), 'clawclaw-personas-'));
16
21
  mkdirSync(join(dir, 'nested'));
17
22
  writeFileSync(join(dir, '温和.md'), 'warm');
@@ -21,12 +26,29 @@ describe('persona presets', () => {
21
26
 
22
27
  afterEach(() => {
23
28
  rmSync(dir, { recursive: true, force: true });
29
+ if (prevWorkspace === undefined) delete process.env[CLAWCLAW_WORKSPACE_DIR];
30
+ else process.env[CLAWCLAW_WORKSPACE_DIR] = prevWorkspace;
24
31
  });
25
32
 
33
+ function createActiveStore(): AuthStore {
34
+ process.env[CLAWCLAW_WORKSPACE_DIR] = join(dir, 'workspace');
35
+ const store = new AuthStore();
36
+ store.addProfile({
37
+ agentName: 'lobster-1',
38
+ apiKey: 'claw_test_key_12345678',
39
+ serverUrl: 'https://example.com',
40
+ });
41
+ return store;
42
+ }
43
+
26
44
  it('lists markdown presets from the preset directory', () => {
27
45
  expect(listPersonaPresets(dir).map(item => item.name).sort()).toEqual(['温和', '野性']);
28
46
  });
29
47
 
48
+ it('includes the no-persona preset in the bundled preset list', () => {
49
+ expect(listPersonaPresets().map(item => item.name)).toContain('无人设');
50
+ });
51
+
30
52
  it('finds presets with or without .md suffix', () => {
31
53
  expect(findPersonaPreset('温和', dir)?.name).toBe('温和');
32
54
  expect(findPersonaPreset('温和.md', dir)?.name).toBe('温和');
@@ -38,4 +60,25 @@ describe('persona presets', () => {
38
60
  expect(preset.name).toBe('野性');
39
61
  expect(readFileSync(target, 'utf8')).toBe('wild');
40
62
  });
63
+
64
+ it('applies the default placeholder when the active account persona is empty', () => {
65
+ writeFileSync(join(dir, '无人设.md'), 'plain');
66
+ const result = ensureDefaultPersonaPlaceholder(createActiveStore(), dir);
67
+
68
+ expect(result.applied).toBe(true);
69
+ expect(result.preset.name).toBe('无人设');
70
+ expect(readFileSync(result.path, 'utf8')).toBe('plain');
71
+ });
72
+
73
+ it('keeps existing active account persona content', () => {
74
+ writeFileSync(join(dir, '无人设.md'), 'plain');
75
+ const store = createActiveStore();
76
+ const first = ensureDefaultPersonaPlaceholder(store, dir);
77
+ writeFileSync(first.path, 'voice');
78
+
79
+ const result = ensureDefaultPersonaPlaceholder(store, dir);
80
+
81
+ expect(result.applied).toBe(false);
82
+ expect(readFileSync(result.path, 'utf8')).toBe('voice');
83
+ });
41
84
  });
@@ -13,6 +13,8 @@ export interface PersonaPreset {
13
13
  path: string;
14
14
  }
15
15
 
16
+ export const DEFAULT_PERSONA_PRESET = '无人设';
17
+
16
18
  export function getBundledPersonaDir(): string {
17
19
  return resolve(__dirname, '..', '..', 'personas');
18
20
  }
@@ -67,6 +69,21 @@ export function applyPersonaPreset(name: string, targetPath: string, dir = getBu
67
69
  return preset;
68
70
  }
69
71
 
72
+ export function ensureDefaultPersonaPlaceholder(authStore = new AuthStore(), dir = getBundledPersonaDir()): { path: string; preset: PersonaPreset; applied: boolean } {
73
+ const path = getActivePersonaFile(authStore);
74
+ const current = readPersonaFile(path);
75
+ if (current.trim() !== '') {
76
+ const preset = findPersonaPreset(DEFAULT_PERSONA_PRESET, dir);
77
+ return {
78
+ path,
79
+ preset: preset ?? { id: DEFAULT_PERSONA_PRESET, name: DEFAULT_PERSONA_PRESET, path: '' },
80
+ applied: false,
81
+ };
82
+ }
83
+ const preset = applyPersonaPreset(DEFAULT_PERSONA_PRESET, path, dir);
84
+ return { path, preset, applied: true };
85
+ }
86
+
70
87
  function normalizePersonaName(value: string): string {
71
88
  return value.trim().replace(/\.md$/i, '').toLowerCase();
72
89
  }