clawt 3.9.13 → 3.10.1

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.
Files changed (106) hide show
  1. package/README.md +80 -1
  2. package/README.zh-CN.md +81 -0
  3. package/dist/index.js +1935 -592
  4. package/dist/postinstall.js +1626 -283
  5. package/docs/config-file.md +2 -0
  6. package/docs/config.md +2 -1
  7. package/docs/init.md +3 -2
  8. package/docs/project-config.md +10 -1
  9. package/docs/spec.md +69 -2
  10. package/package.json +1 -1
  11. package/src/commands/alias.ts +5 -4
  12. package/src/commands/completion.ts +2 -1
  13. package/src/commands/config.ts +25 -7
  14. package/src/commands/cover-validate.ts +3 -2
  15. package/src/commands/create.ts +8 -7
  16. package/src/commands/home.ts +2 -1
  17. package/src/commands/init.ts +13 -6
  18. package/src/commands/list.ts +6 -4
  19. package/src/commands/merge.ts +8 -7
  20. package/src/commands/projects.ts +5 -3
  21. package/src/commands/remove.ts +7 -6
  22. package/src/commands/reset.ts +3 -2
  23. package/src/commands/resume.ts +10 -7
  24. package/src/commands/run.ts +8 -7
  25. package/src/commands/status.ts +16 -11
  26. package/src/commands/sync.ts +4 -3
  27. package/src/commands/tasks.ts +8 -6
  28. package/src/commands/validate.ts +7 -6
  29. package/src/constants/ai-prompts.ts +11 -11
  30. package/src/constants/config.ts +30 -0
  31. package/src/constants/index.ts +3 -2
  32. package/src/constants/messages/alias.ts +44 -14
  33. package/src/constants/messages/cli-descriptions.ts +91 -0
  34. package/src/constants/messages/common.ts +221 -36
  35. package/src/constants/messages/completion.ts +43 -14
  36. package/src/constants/messages/config.ts +61 -18
  37. package/src/constants/messages/cover-validate.ts +43 -14
  38. package/src/constants/messages/create.ts +16 -5
  39. package/src/constants/messages/home.ts +19 -6
  40. package/src/constants/messages/index.ts +2 -0
  41. package/src/constants/messages/init.ts +45 -14
  42. package/src/constants/messages/interactive-panel.ts +183 -29
  43. package/src/constants/messages/merge.ts +140 -38
  44. package/src/constants/messages/post-create.ts +59 -19
  45. package/src/constants/messages/projects.ts +51 -14
  46. package/src/constants/messages/remove.ts +50 -15
  47. package/src/constants/messages/reset.ts +14 -4
  48. package/src/constants/messages/resume.ts +116 -19
  49. package/src/constants/messages/run.ts +165 -35
  50. package/src/constants/messages/status.ts +84 -23
  51. package/src/constants/messages/sync.ts +54 -17
  52. package/src/constants/messages/tasks.ts +21 -7
  53. package/src/constants/messages/update.ts +35 -11
  54. package/src/constants/messages/validate.ts +218 -57
  55. package/src/constants/progress.ts +17 -6
  56. package/src/constants/project-config.ts +17 -0
  57. package/src/constants/prompt.ts +18 -2
  58. package/src/constants/tasks-template.ts +56 -2
  59. package/src/hooks/post-create.ts +5 -2
  60. package/src/index.ts +6 -5
  61. package/src/types/config.ts +2 -0
  62. package/src/utils/alias.ts +2 -1
  63. package/src/utils/claude.ts +10 -9
  64. package/src/utils/config-strategy.ts +3 -3
  65. package/src/utils/dry-run.ts +2 -2
  66. package/src/utils/formatter.ts +18 -11
  67. package/src/utils/i18n.ts +63 -0
  68. package/src/utils/index.ts +2 -0
  69. package/src/utils/interactive-panel-render.ts +6 -3
  70. package/src/utils/progress-render.ts +11 -9
  71. package/src/utils/prompt.ts +2 -1
  72. package/src/utils/task-executor.ts +10 -7
  73. package/src/utils/task-file.ts +2 -1
  74. package/src/utils/terminal.ts +9 -9
  75. package/src/utils/ui-prompts.ts +4 -3
  76. package/src/utils/update-checker.ts +1 -1
  77. package/src/utils/validate-branch.ts +16 -9
  78. package/src/utils/validate-core.ts +2 -1
  79. package/src/utils/validate-runner.ts +2 -2
  80. package/src/utils/worktree-matcher.ts +9 -7
  81. package/tests/unit/commands/alias.test.ts +4 -0
  82. package/tests/unit/commands/completion.test.ts +14 -0
  83. package/tests/unit/commands/config.test.ts +61 -28
  84. package/tests/unit/commands/cover-validate.test.ts +13 -2
  85. package/tests/unit/commands/init.test.ts +6 -2
  86. package/tests/unit/commands/merge.test.ts +14 -0
  87. package/tests/unit/commands/run.test.ts +17 -0
  88. package/tests/unit/commands/tasks.test.ts +39 -9
  89. package/tests/unit/constants/config.test.ts +16 -1
  90. package/tests/unit/constants/messages-post-create.test.ts +93 -1
  91. package/tests/unit/constants/messages.test.ts +85 -1
  92. package/tests/unit/hooks/post-create.test.ts +32 -0
  93. package/tests/unit/utils/alias.test.ts +14 -0
  94. package/tests/unit/utils/claude.test.ts +24 -4
  95. package/tests/unit/utils/config-strategy.test.ts +21 -0
  96. package/tests/unit/utils/conflict-resolver.test.ts +24 -4
  97. package/tests/unit/utils/formatter.test.ts +21 -0
  98. package/tests/unit/utils/i18n.test.ts +91 -0
  99. package/tests/unit/utils/progress.test.ts +39 -18
  100. package/tests/unit/utils/prompt.test.ts +25 -2
  101. package/tests/unit/utils/task-file.test.ts +73 -10
  102. package/tests/unit/utils/terminal-cmux.test.ts +19 -4
  103. package/tests/unit/utils/update-checker.test.ts +2 -0
  104. package/tests/unit/utils/validate-branch.test.ts +26 -1
  105. package/tests/unit/utils/validation.test.ts +2 -2
  106. package/tests/unit/utils/worktree-matcher.test.ts +2 -0
@@ -1,60 +1,245 @@
1
- /** 通用/共享提示消息 */
2
- export const COMMON_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** 通用/共享提示消息(双语映射) */
4
+ const COMMON_MESSAGES_I18N = {
3
5
  /** 不在主 worktree 根目录 */
4
- NOT_MAIN_WORKTREE: '请在主 worktree 的根目录下执行 clawt',
6
+ NOT_MAIN_WORKTREE: {
7
+ en: 'Please run clawt in the root directory of the main worktree',
8
+ 'zh-CN': '请在主 worktree 的根目录下执行 clawt',
9
+ },
5
10
  /** 不在 git 仓库中 */
6
- NOT_GIT_REPO: '当前目录不是 git 仓库,请先执行 git init 并提交后,再执行 clawt init 初始化项目',
11
+ NOT_GIT_REPO: {
12
+ en: 'Current directory is not a git repository. Please run git init and make an initial commit, then run clawt init',
13
+ 'zh-CN': '当前目录不是 git 仓库,请先执行 git init 并提交后,再执行 clawt init 初始化项目',
14
+ },
7
15
  /** Git 未安装 */
8
- GIT_NOT_INSTALLED: 'Git 未安装或不在 PATH 中,请先安装 Git',
16
+ GIT_NOT_INSTALLED: {
17
+ en: 'Git is not installed or not in PATH. Please install Git first',
18
+ 'zh-CN': 'Git 未安装或不在 PATH 中,请先安装 Git',
19
+ },
9
20
  /** Claude Code CLI 未安装 */
10
- CLAUDE_NOT_INSTALLED: 'Claude Code CLI 未安装,请先安装:npm install -g @anthropic-ai/claude-code',
21
+ CLAUDE_NOT_INSTALLED: {
22
+ en: 'Claude Code CLI is not installed. Please install it: npm install -g @anthropic-ai/claude-code',
23
+ 'zh-CN': 'Claude Code CLI 未安装,请先安装:npm install -g @anthropic-ai/claude-code',
24
+ },
11
25
  /** HEAD 不存在(仓库无任何 commit) */
12
- HEAD_NOT_FOUND: '当前仓库尚未创建任何提交,请先执行 git commit 创建首次提交后再使用 clawt',
26
+ HEAD_NOT_FOUND: {
27
+ en: 'No commits exist in this repository. Please create an initial commit first',
28
+ 'zh-CN': '当前仓库尚未创建任何提交,请先执行 git commit 创建首次提交后再使用 clawt',
29
+ },
13
30
  /** 分支已存在 */
14
- BRANCH_EXISTS: (name: string) => `分支 ${name} 已存在,无法创建`,
31
+ BRANCH_EXISTS: {
32
+ en: (name: string) => `Branch ${name} already exists, cannot create`,
33
+ 'zh-CN': (name: string) => `分支 ${name} 已存在,无法创建`,
34
+ },
15
35
  /** 分支名清理后为空 */
16
- BRANCH_NAME_EMPTY: (original: string) =>
17
- `分支名 "${original}" 中不包含合法字符,无法创建分支`,
36
+ BRANCH_NAME_EMPTY: {
37
+ en: (original: string) =>
38
+ `Branch name "${original}" contains no valid characters, cannot create branch`,
39
+ 'zh-CN': (original: string) =>
40
+ `分支名 "${original}" 中不包含合法字符,无法创建分支`,
41
+ },
18
42
  /** 分支名被转换 */
19
- BRANCH_SANITIZED: (original: string, sanitized: string) =>
20
- `分支名已转换: ${original} ${sanitized}`,
43
+ BRANCH_SANITIZED: {
44
+ en: (original: string, sanitized: string) =>
45
+ `Branch name sanitized: ${original} → ${sanitized}`,
46
+ 'zh-CN': (original: string, sanitized: string) =>
47
+ `分支名已转换: ${original} → ${sanitized}`,
48
+ },
21
49
  /** worktree 创建成功 */
22
- WORKTREE_CREATED: (count: number) => `✓ 已创建 ${count} 个 worktree`,
50
+ WORKTREE_CREATED: {
51
+ en: (count: number) => `✓ Created ${count} worktree(s)`,
52
+ 'zh-CN': (count: number) => `✓ 已创建 ${count} 个 worktree`,
53
+ },
23
54
  /** worktree 移除成功 */
24
- WORKTREE_REMOVED: (path: string) => `✓ 已移除 worktree: ${path}`,
55
+ WORKTREE_REMOVED: {
56
+ en: (path: string) => `✓ Removed worktree: ${path}`,
57
+ 'zh-CN': (path: string) => `✓ 已移除 worktree: ${path}`,
58
+ },
25
59
  /** 没有 worktree */
26
- NO_WORKTREES: '(无 worktree)',
60
+ NO_WORKTREES: {
61
+ en: '(No worktrees)',
62
+ 'zh-CN': '(无 worktree)',
63
+ },
27
64
  /** 目标 worktree 不存在 */
28
- WORKTREE_NOT_FOUND: (name: string) => `worktree ${name} 不存在`,
65
+ WORKTREE_NOT_FOUND: {
66
+ en: (name: string) => `Worktree ${name} does not exist`,
67
+ 'zh-CN': (name: string) => `worktree ${name} 不存在`,
68
+ },
29
69
  /** 主 worktree 有未提交更改 */
30
- MAIN_WORKTREE_DIRTY: '主 worktree 有未提交的更改,请先处理',
70
+ MAIN_WORKTREE_DIRTY: {
71
+ en: 'Main worktree has uncommitted changes. Please resolve first',
72
+ 'zh-CN': '主 worktree 有未提交的更改,请先处理',
73
+ },
31
74
  /** 目标 worktree 无更改 */
32
- TARGET_WORKTREE_CLEAN: '该 worktree 的分支上没有任何更改,无需验证',
75
+ TARGET_WORKTREE_CLEAN: {
76
+ en: 'No changes on this worktree branch, nothing to validate',
77
+ 'zh-CN': '该 worktree 的分支上没有任何更改,无需验证',
78
+ },
33
79
  /** 用户取消破坏性操作 */
34
- DESTRUCTIVE_OP_CANCELLED: '已取消操作',
80
+ DESTRUCTIVE_OP_CANCELLED: {
81
+ en: 'Operation cancelled',
82
+ 'zh-CN': '已取消操作',
83
+ },
35
84
  /** 请提供提交信息 */
36
- COMMIT_MESSAGE_REQUIRED: '请提供提交信息(-m 参数)',
85
+ COMMIT_MESSAGE_REQUIRED: {
86
+ en: 'Please provide a commit message (-m option)',
87
+ 'zh-CN': '请提供提交信息(-m 参数)',
88
+ },
37
89
  /** 配置文件损坏,已重新生成默认配置 */
38
- CONFIG_CORRUPTED: '配置文件损坏或无法解析,已重新生成默认配置',
90
+ CONFIG_CORRUPTED: {
91
+ en: 'Config file corrupted or unparseable, regenerated default config',
92
+ 'zh-CN': '配置文件损坏或无法解析,已重新生成默认配置',
93
+ },
39
94
  /** worktree 状态获取失败 */
40
- WORKTREE_STATUS_UNAVAILABLE: '(状态不可用)',
95
+ WORKTREE_STATUS_UNAVAILABLE: {
96
+ en: '(Status unavailable)',
97
+ 'zh-CN': '(状态不可用)',
98
+ },
41
99
  /** 分隔线 */
42
- SEPARATOR: '────────────────────────────────────────',
100
+ SEPARATOR: {
101
+ en: '────────────────────────────────────────',
102
+ 'zh-CN': '────────────────────────────────────────',
103
+ },
43
104
  /** 粗分隔线 */
44
- DOUBLE_SEPARATOR: '════════════════════════════════════════',
105
+ DOUBLE_SEPARATOR: {
106
+ en: '════════════════════════════════════════',
107
+ 'zh-CN': '════════════════════════════════════════',
108
+ },
45
109
  /** 守卫检测:配置的主工作分支已不存在 */
46
- GUARD_BRANCH_NOT_EXISTS: (branchName: string) =>
47
- `配置的主工作分支 ${branchName} 已不存在,请执行 clawt init 重新设置主工作分支`,
110
+ GUARD_BRANCH_NOT_EXISTS: {
111
+ en: (branchName: string) =>
112
+ `Configured main work branch ${branchName} no longer exists. Please run clawt init to reset`,
113
+ 'zh-CN': (branchName: string) =>
114
+ `配置的主工作分支 ${branchName} 已不存在,请执行 clawt init 重新设置主工作分支`,
115
+ },
48
116
  /** 守卫检测:当前分支与配置的主工作分支不一致 */
49
- GUARD_BRANCH_MISMATCH: (configuredBranch: string, currentBranch: string) =>
50
- `当前分支 ${currentBranch} 与配置的主工作分支 ${configuredBranch} 不一致,如需更新请执行 clawt init`,
117
+ GUARD_BRANCH_MISMATCH: {
118
+ en: (configuredBranch: string, currentBranch: string) =>
119
+ `Current branch ${currentBranch} does not match configured main work branch ${configuredBranch}. Run clawt init to update`,
120
+ 'zh-CN': (configuredBranch: string, currentBranch: string) =>
121
+ `当前分支 ${currentBranch} 与配置的主工作分支 ${configuredBranch} 不一致,如需更新请执行 clawt init`,
122
+ },
51
123
  /** Git index 被锁定(index.lock 存在) */
52
- GIT_INDEX_LOCKED: (lockFilePath: string) =>
53
- `Git index 被锁定,无法执行操作\n` +
54
- ` 原因:锁文件已存在(可能是上次 git 操作异常中断残留)\n` +
55
- ` 锁文件路径:${lockFilePath}\n` +
56
- ` 修复方法:确认没有其他 git 操作在进行后,执行以下命令删除锁文件:\n` +
57
- ` rm ${lockFilePath}`,
124
+ GIT_INDEX_LOCKED: {
125
+ en: (lockFilePath: string) =>
126
+ `Git index is locked, cannot proceed\n` +
127
+ ` Cause: Lock file exists (possibly from an interrupted git operation)\n` +
128
+ ` Lock file path: ${lockFilePath}\n` +
129
+ ` Fix: Confirm no other git operations are running, then run:\n` +
130
+ ` rm ${lockFilePath}`,
131
+ 'zh-CN': (lockFilePath: string) =>
132
+ `Git index 被锁定,无法执行操作\n` +
133
+ ` 原因:锁文件已存在(可能是上次 git 操作异常中断残留)\n` +
134
+ ` 锁文件路径:${lockFilePath}\n` +
135
+ ` 修复方法:确认没有其他 git 操作在进行后,执行以下命令删除锁文件:\n` +
136
+ ` rm ${lockFilePath}`,
137
+ },
58
138
  /** Git index.lock 重试中(简短提示) */
59
- GIT_INDEX_LOCK_RETRYING: 'Git index 被锁定,正在重试...',
60
- } as const;
139
+ GIT_INDEX_LOCK_RETRYING: {
140
+ en: 'Git index is locked, retrying...',
141
+ 'zh-CN': 'Git index 被锁定,正在重试...',
142
+ },
143
+ // --- 从 formatter.ts 迁移 ---
144
+ /** 是否继续? */
145
+ CONFIRM_CONTINUE: {
146
+ en: 'Continue?',
147
+ 'zh-CN': '是否继续?',
148
+ },
149
+ /** 无变更 */
150
+ NO_CHANGES: {
151
+ en: 'No changes',
152
+ 'zh-CN': '无变更',
153
+ },
154
+ /** 未提交修改 */
155
+ UNCOMMITTED_CHANGES: {
156
+ en: '(uncommitted changes)',
157
+ 'zh-CN': '(未提交修改)',
158
+ },
159
+ /** 提交数 */
160
+ COMMIT_COUNT: {
161
+ en: (n: number) => `${n} commit(s)`,
162
+ 'zh-CN': (n: number) => `${n} 个提交`,
163
+ },
164
+ /** 刚刚 */
165
+ JUST_NOW: {
166
+ en: 'just now',
167
+ 'zh-CN': '刚刚',
168
+ },
169
+ /** N 分钟前 */
170
+ MINUTES_AGO: {
171
+ en: (n: number) => `${n} min ago`,
172
+ 'zh-CN': (n: number) => `${n} 分钟前`,
173
+ },
174
+ /** N 小时前 */
175
+ HOURS_AGO: {
176
+ en: (n: number) => `${n} hr ago`,
177
+ 'zh-CN': (n: number) => `${n} 小时前`,
178
+ },
179
+ /** N 天前 */
180
+ DAYS_AGO: {
181
+ en: (n: number) => `${n} day(s) ago`,
182
+ 'zh-CN': (n: number) => `${n} 天前`,
183
+ },
184
+ /** N 个月前 */
185
+ MONTHS_AGO: {
186
+ en: (n: number) => `${n} month(s) ago`,
187
+ 'zh-CN': (n: number) => `${n} 个月前`,
188
+ },
189
+ /** N 年前 */
190
+ YEARS_AGO: {
191
+ en: (n: number) => `${n} year(s) ago`,
192
+ 'zh-CN': (n: number) => `${n} 年前`,
193
+ },
194
+ /** 未知错误 */
195
+ UNKNOWN_ERROR: {
196
+ en: 'Unknown error',
197
+ 'zh-CN': '未知错误',
198
+ },
199
+ // --- 从 ui-prompts.ts 迁移 ---
200
+ /** 非交互模式下无法进行分支选择 */
201
+ NON_INTERACTIVE_BRANCH_SELECT: {
202
+ en: 'Cannot select branch in non-interactive mode. Please use -b to specify branch',
203
+ 'zh-CN': '非交互模式下无法进行分支选择,请使用 -b 指定分支',
204
+ },
205
+ /** 非交互模式下无法进行分支多选 */
206
+ NON_INTERACTIVE_MULTI_SELECT: {
207
+ en: 'Cannot multi-select branches in non-interactive mode',
208
+ 'zh-CN': '非交互模式下无法进行分支多选',
209
+ },
210
+ // --- 从 worktree-matcher.ts 迁移 ---
211
+ /** 今天 */
212
+ TODAY: {
213
+ en: 'Today',
214
+ 'zh-CN': '今天',
215
+ },
216
+ /** 昨天 */
217
+ YESTERDAY: {
218
+ en: 'Yesterday',
219
+ 'zh-CN': '昨天',
220
+ },
221
+ // --- 从 config-strategy.ts 迁移 ---
222
+ /** (未设置) */
223
+ NOT_SET: {
224
+ en: '(not set)',
225
+ 'zh-CN': '(未设置)',
226
+ },
227
+ /** 非交互模式下无法使用交互式配置编辑器 */
228
+ NON_INTERACTIVE_CONFIG_EDITOR: {
229
+ en: 'Cannot use interactive config editor in non-interactive mode. Please use: clawt config set <key> <value>',
230
+ 'zh-CN': '非交互模式下无法使用交互式配置编辑器,请使用 clawt config set <key> <value>',
231
+ },
232
+ /** 请输入有效的数字 */
233
+ INVALID_NUMBER_PROMPT: {
234
+ en: 'Please enter a valid number',
235
+ 'zh-CN': '请输入有效的数字',
236
+ },
237
+ // --- 从 commands/config.ts 迁移 ---
238
+ /** 当前配置将被覆盖为默认值 */
239
+ CONFIG_RESET_WARNING: {
240
+ en: 'Current configuration will be reset to defaults',
241
+ 'zh-CN': '当前配置将被覆盖为默认值',
242
+ },
243
+ };
244
+
245
+ export const COMMON_MESSAGES = createMessages(COMMON_MESSAGES_I18N);
@@ -1,23 +1,52 @@
1
- /**
2
- * 自动补全命令相关的提示消息常量
3
- */
4
- export const COMPLETION_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** 自动补全命令相关的提示消息常量(双语映射) */
4
+ const COMPLETION_MESSAGES_I18N = {
5
5
  /** completion 命令的主描述 */
6
- COMPLETION_COMMAND_DESC: '为终端提供 shell 自动补全功能(bash/zsh)',
6
+ COMPLETION_COMMAND_DESC: {
7
+ en: 'Provide shell auto-completion for terminal (bash/zsh)',
8
+ 'zh-CN': '为终端提供 shell 自动补全功能(bash/zsh)',
9
+ },
7
10
  /** bash 子命令描述 */
8
- COMPLETION_BASH_DESC: '输出 bash 自动补全脚本',
11
+ COMPLETION_BASH_DESC: {
12
+ en: 'Output bash auto-completion script',
13
+ 'zh-CN': '输出 bash 自动补全脚本',
14
+ },
9
15
  /** zsh 子命令描述 */
10
- COMPLETION_ZSH_DESC: '输出 zsh 自动补全脚本',
16
+ COMPLETION_ZSH_DESC: {
17
+ en: 'Output zsh auto-completion script',
18
+ 'zh-CN': '输出 zsh 自动补全脚本',
19
+ },
11
20
  /** install 子命令描述 */
12
- COMPLETION_INSTALL_DESC: '自动安装补全脚本到当前用户的 shell 配置文件',
21
+ COMPLETION_INSTALL_DESC: {
22
+ en: 'Auto-install completion script to current user shell config',
23
+ 'zh-CN': '自动安装补全脚本到当前用户的 shell 配置文件',
24
+ },
13
25
  /** 安装成功提示 */
14
- COMPLETION_INSTALL_SUCCESS: '自动补全配置已成功写入',
26
+ COMPLETION_INSTALL_SUCCESS: {
27
+ en: 'Auto-completion config written successfully',
28
+ 'zh-CN': '自动补全配置已成功写入',
29
+ },
15
30
  /** 安装失败或未知的 shell 提示 */
16
- COMPLETION_INSTALL_UNKNOWN_SHELL: '未知的 Shell 环境或无法自动安装,请手动配置。',
31
+ COMPLETION_INSTALL_UNKNOWN_SHELL: {
32
+ en: 'Unknown shell or unable to auto-install. Please configure manually.',
33
+ 'zh-CN': '未知的 Shell 环境或无法自动安装,请手动配置。',
34
+ },
17
35
  /** 补全配置已存在提示 */
18
- COMPLETION_INSTALL_EXISTS: '自动补全配置已存在于目标文件中',
36
+ COMPLETION_INSTALL_EXISTS: {
37
+ en: 'Auto-completion config already exists in target file',
38
+ 'zh-CN': '自动补全配置已存在于目标文件中',
39
+ },
19
40
  /** 提示用户重启生效 */
20
- COMPLETION_INSTALL_RESTART: (filePath: string) => `请重启终端或运行 \`source ${filePath}\` 以使补全生效。`,
41
+ COMPLETION_INSTALL_RESTART: {
42
+ en: (filePath: string) => `Please restart your terminal or run \`source ${filePath}\` for completion to take effect.`,
43
+ 'zh-CN': (filePath: string) => `请重启终端或运行 \`source ${filePath}\` 以使补全生效。`,
44
+ },
21
45
  /** 安装写入失败提示 */
22
- COMPLETION_INSTALL_WRITE_ERROR: (filePath: string) => `无法写入文件 ${filePath},请检查文件权限或手动配置。`,
23
- } as const;
46
+ COMPLETION_INSTALL_WRITE_ERROR: {
47
+ en: (filePath: string) => `Cannot write file ${filePath}, please check file permissions or configure manually.`,
48
+ 'zh-CN': (filePath: string) => `无法写入文件 ${filePath},请检查文件权限或手动配置。`,
49
+ },
50
+ };
51
+
52
+ export const COMPLETION_MESSAGES = createMessages(COMPLETION_MESSAGES_I18N);
@@ -1,30 +1,73 @@
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
1
3
  /** 对象类型配置项禁用提示(如 aliases 需通过专用命令管理) */
2
- export const CONFIG_ALIAS_DISABLED_HINT = '(通过 clawt alias 命令管理)';
4
+ const CONFIG_ALIAS_DISABLED_HINT_I18N = {
5
+ en: '(Manage via clawt alias command)',
6
+ 'zh-CN': '(通过 clawt alias 命令管理)',
7
+ };
8
+
9
+ export const CONFIG_ALIAS_DISABLED_HINT = createMessages({ HINT: CONFIG_ALIAS_DISABLED_HINT_I18N }).HINT;
3
10
 
4
- /** config 命令专属提示消息 */
5
- export const CONFIG_CMD_MESSAGES = {
11
+ /** config 命令专属提示消息(双语映射) */
12
+ const CONFIG_CMD_MESSAGES_I18N = {
6
13
  /** 配置已恢复为默认值 */
7
- CONFIG_RESET_SUCCESS: '✓ 配置已恢复为默认值',
14
+ CONFIG_RESET_SUCCESS: {
15
+ en: '✓ Configuration reset to defaults',
16
+ 'zh-CN': '✓ 配置已恢复为默认值',
17
+ },
8
18
  /** 配置项设置成功 */
9
- CONFIG_SET_SUCCESS: (key: string, value: string) => `✓ ${key} 已设置为 ${value}`,
19
+ CONFIG_SET_SUCCESS: {
20
+ en: (key: string, value: string) => `✓ ${key} set to ${value}`,
21
+ 'zh-CN': (key: string, value: string) => `✓ ${key} 已设置为 ${value}`,
22
+ },
10
23
  /** 获取配置值显示 */
11
- CONFIG_GET_VALUE: (key: string, value: string) => `${key} = ${value}`,
24
+ CONFIG_GET_VALUE: {
25
+ en: (key: string, value: string) => `${key} = ${value}`,
26
+ 'zh-CN': (key: string, value: string) => `${key} = ${value}`,
27
+ },
12
28
  /** 无效配置项名称 */
13
- CONFIG_INVALID_KEY: (key: string, validKeys: string[]) =>
14
- `无效的配置项: ${key}\n可用的配置项: ${validKeys.join(', ')}`,
29
+ CONFIG_INVALID_KEY: {
30
+ en: (key: string, validKeys: string[]) =>
31
+ `Invalid config key: ${key}\nAvailable keys: ${validKeys.join(', ')}`,
32
+ 'zh-CN': (key: string, validKeys: string[]) =>
33
+ `无效的配置项: ${key}\n可用的配置项: ${validKeys.join(', ')}`,
34
+ },
15
35
  /** 布尔类型值无效 */
16
- CONFIG_INVALID_BOOLEAN: (key: string) =>
17
- `配置项 ${key} 为布尔类型,仅接受 true 或 false`,
36
+ CONFIG_INVALID_BOOLEAN: {
37
+ en: (key: string) =>
38
+ `Config key ${key} is boolean, only accepts true or false`,
39
+ 'zh-CN': (key: string) =>
40
+ `配置项 ${key} 为布尔类型,仅接受 true 或 false`,
41
+ },
18
42
  /** 数字类型值无效 */
19
- CONFIG_INVALID_NUMBER: (key: string) =>
20
- `配置项 ${key} 为数字类型,请输入有效的数字`,
43
+ CONFIG_INVALID_NUMBER: {
44
+ en: (key: string) =>
45
+ `Config key ${key} is numeric, please enter a valid number`,
46
+ 'zh-CN': (key: string) =>
47
+ `配置项 ${key} 为数字类型,请输入有效的数字`,
48
+ },
21
49
  /** 枚举类型配置项值无效(通用版) */
22
- CONFIG_INVALID_ENUM: (key: string, validValues: readonly string[]) =>
23
- `配置项 ${key} 仅接受以下值: ${validValues.join(', ')}`,
50
+ CONFIG_INVALID_ENUM: {
51
+ en: (key: string, validValues: readonly string[]) =>
52
+ `Config key ${key} only accepts: ${validValues.join(', ')}`,
53
+ 'zh-CN': (key: string, validValues: readonly string[]) =>
54
+ `配置项 ${key} 仅接受以下值: ${validValues.join(', ')}`,
55
+ },
24
56
  /** 交互式选择配置项提示 */
25
- CONFIG_SELECT_PROMPT: '选择要修改的配置项',
57
+ CONFIG_SELECT_PROMPT: {
58
+ en: 'Select a config key to modify',
59
+ 'zh-CN': '选择要修改的配置项',
60
+ },
26
61
  /** 交互式输入新值提示 */
27
- CONFIG_INPUT_PROMPT: (key: string) => `输入 ${key} 的新值`,
62
+ CONFIG_INPUT_PROMPT: {
63
+ en: (key: string) => `Enter new value for ${key}`,
64
+ 'zh-CN': (key: string) => `输入 ${key} 的新值`,
65
+ },
28
66
  /** 缺少 value 参数提示 */
29
- CONFIG_MISSING_VALUE: (key: string) => `缺少配置值,用法: clawt config set ${key} <value>`,
30
- } as const;
67
+ CONFIG_MISSING_VALUE: {
68
+ en: (key: string) => `Missing value, usage: clawt config set ${key} <value>`,
69
+ 'zh-CN': (key: string) => `缺少配置值,用法: clawt config set ${key} <value>`,
70
+ },
71
+ };
72
+
73
+ export const CONFIG_CMD_MESSAGES = createMessages(CONFIG_CMD_MESSAGES_I18N);
@@ -1,21 +1,50 @@
1
- /** cover-validate 命令专属提示消息 */
2
- export const COVER_VALIDATE_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** cover-validate 命令专属提示消息(双语映射) */
4
+ const COVER_VALIDATE_MESSAGES_I18N = {
3
5
  /** 当前不在验证分支上 */
4
- COVER_VALIDATE_NOT_ON_VALIDATE_BRANCH: '当前分支不是验证分支(需以 clawt-validate- 开头)\n 请先通过 clawt validate 切换到验证分支',
6
+ COVER_VALIDATE_NOT_ON_VALIDATE_BRANCH: {
7
+ en: 'Current branch is not a validate branch (must start with clawt-validate-)\n Please run clawt validate first to switch to a validate branch',
8
+ 'zh-CN': '当前分支不是验证分支(需以 clawt-validate- 开头)\n 请先通过 clawt validate 切换到验证分支',
9
+ },
5
10
  /** 无增量修改 */
6
- COVER_VALIDATE_NO_CHANGES: '验证分支上没有相对于快照的增量修改,无需覆盖',
11
+ COVER_VALIDATE_NO_CHANGES: {
12
+ en: 'No incremental changes on validate branch relative to snapshot, nothing to cover',
13
+ 'zh-CN': '验证分支上没有相对于快照的增量修改,无需覆盖',
14
+ },
7
15
  /** 目标 worktree 不存在 */
8
- COVER_VALIDATE_TARGET_NOT_FOUND: (branch: string) =>
9
- `未找到分支 ${branch} 对应的 worktree,请确认该 worktree 尚未被移除`,
16
+ COVER_VALIDATE_TARGET_NOT_FOUND: {
17
+ en: (branch: string) =>
18
+ `Worktree for branch ${branch} not found. Please confirm the worktree has not been removed`,
19
+ 'zh-CN': (branch: string) =>
20
+ `未找到分支 ${branch} 对应的 worktree,请确认该 worktree 尚未被移除`,
21
+ },
10
22
  /** 无快照,提示先执行 validate */
11
- COVER_VALIDATE_NO_SNAPSHOT: (branch: string) =>
12
- `未找到分支 ${branch} validate 快照\n 请先执行 clawt validate -b ${branch} 创建快照`,
23
+ COVER_VALIDATE_NO_SNAPSHOT: {
24
+ en: (branch: string) =>
25
+ `No validate snapshot found for branch ${branch}\n Please run clawt validate -b ${branch} to create a snapshot`,
26
+ 'zh-CN': (branch: string) =>
27
+ `未找到分支 ${branch} 的 validate 快照\n 请先执行 clawt validate -b ${branch} 创建快照`,
28
+ },
13
29
  /** 覆盖失败(tree checkout/clean 失败) */
14
- COVER_VALIDATE_COVER_FAILED: (branch: string) =>
15
- `覆盖变更到 worktree ${branch} 失败:tree checkout 或清理操作出错\n 请检查目标 worktree 状态后重试`,
30
+ COVER_VALIDATE_COVER_FAILED: {
31
+ en: (branch: string) =>
32
+ `Failed to cover changes to worktree ${branch}: tree checkout or cleanup error\n Please check the target worktree status and retry`,
33
+ 'zh-CN': (branch: string) =>
34
+ `覆盖变更到 worktree ${branch} 失败:tree checkout 或清理操作出错\n 请检查目标 worktree 状态后重试`,
35
+ },
16
36
  /** 工作区和暂存区无修改,可能为误操作 */
17
- COVER_VALIDATE_WORKING_DIR_CLEAN: '当前验证分支的工作区和暂存区没有任何修改,可能为误操作',
37
+ COVER_VALIDATE_WORKING_DIR_CLEAN: {
38
+ en: 'Working tree and staging area on current validate branch have no changes, possibly a mistaken operation',
39
+ 'zh-CN': '当前验证分支的工作区和暂存区没有任何修改,可能为误操作',
40
+ },
18
41
  /** 覆盖成功 */
19
- COVER_VALIDATE_SUCCESS: (branch: string) =>
20
- `✓ 已将验证分支上的修改覆盖到 worktree => ${branch}`,
21
- } as const;
42
+ COVER_VALIDATE_SUCCESS: {
43
+ en: (branch: string) =>
44
+ `✓ Changes on validate branch covered to worktree => ${branch}`,
45
+ 'zh-CN': (branch: string) =>
46
+ `✓ 已将验证分支上的修改覆盖到 worktree => ${branch}`,
47
+ },
48
+ };
49
+
50
+ export const COVER_VALIDATE_MESSAGES = createMessages(COVER_VALIDATE_MESSAGES_I18N);
@@ -1,8 +1,19 @@
1
- /** create 命令专属提示消息 */
2
- export const CREATE_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** create 命令专属提示消息(双语映射) */
4
+ const CREATE_MESSAGES_I18N = {
3
5
  /** 创建数量参数无效 */
4
- INVALID_COUNT: (value: string) => `无效的创建数量: "${value}",请输入正整数`,
6
+ INVALID_COUNT: {
7
+ en: (value: string) => `Invalid count: "${value}", please enter a positive integer`,
8
+ 'zh-CN': (value: string) => `无效的创建数量: "${value}",请输入正整数`,
9
+ },
5
10
  /** 当前不在主工作分支上的警告 */
6
- CREATE_WARN_NOT_ON_MAIN_BRANCH: (mainBranch: string, currentBranch: string) =>
7
- `当前不在主工作分支 ${mainBranch} 上(当前: ${currentBranch})`,
11
+ CREATE_WARN_NOT_ON_MAIN_BRANCH: {
12
+ en: (mainBranch: string, currentBranch: string) =>
13
+ `Not on main work branch ${mainBranch} (current: ${currentBranch})`,
14
+ 'zh-CN': (mainBranch: string, currentBranch: string) =>
15
+ `当前不在主工作分支 ${mainBranch} 上(当前: ${currentBranch})`,
16
+ },
8
17
  } as const;
18
+
19
+ export const CREATE_MESSAGES = createMessages(CREATE_MESSAGES_I18N);
@@ -1,9 +1,22 @@
1
- /** home 命令专属提示消息 */
2
- export const HOME_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** home 命令专属提示消息(双语映射) */
4
+ const HOME_MESSAGES_I18N = {
3
5
  /** 已在主工作分支上 */
4
- HOME_ALREADY_ON_MAIN: (branch: string) => `已在主工作分支 ${branch} 上,无需切换`,
6
+ HOME_ALREADY_ON_MAIN: {
7
+ en: (branch: string) => `Already on main work branch ${branch}, no switch needed`,
8
+ 'zh-CN': (branch: string) => `已在主工作分支 ${branch} 上,无需切换`,
9
+ },
5
10
  /** 切换成功 */
6
- HOME_SWITCH_SUCCESS: (from: string, to: string) => `✓ 已从 ${from} 切换到主工作分支 ${to}`,
11
+ HOME_SWITCH_SUCCESS: {
12
+ en: (from: string, to: string) => `✓ Switched from ${from} to main work branch ${to}`,
13
+ 'zh-CN': (from: string, to: string) => `✓ 已从 ${from} 切换到主工作分支 ${to}`,
14
+ },
7
15
  /** 当前在子 worktree,提示用户手动 cd 到主 worktree */
8
- HOME_NOT_IN_MAIN_WORKTREE: (mainPath: string) => `当前不在主 worktree,请先切换到主 worktree:\n\n cd ${mainPath}`,
9
- } as const;
16
+ HOME_NOT_IN_MAIN_WORKTREE: {
17
+ en: (mainPath: string) => `Not in main worktree. Please switch to main worktree:\n\n cd ${mainPath}`,
18
+ 'zh-CN': (mainPath: string) => `当前不在主 worktree,请先切换到主 worktree:\n\n cd ${mainPath}`,
19
+ },
20
+ };
21
+
22
+ export const HOME_MESSAGES = createMessages(HOME_MESSAGES_I18N);
@@ -19,10 +19,12 @@ import { HOME_MESSAGES } from './home.js';
19
19
  import { TASKS_CMD_MESSAGES } from './tasks.js';
20
20
  import { POST_CREATE_MESSAGES } from './post-create.js';
21
21
  import { PANEL_FOOTER_SHORTCUTS, PANEL_FOOTER_COUNTDOWN, PANEL_OVERFLOW_DOWN_HINT, PANEL_OVERFLOW_UP_HINT, PANEL_SNAPSHOT_SUMMARY, PANEL_NO_WORKTREES as PANEL_NO_WORKTREES_MSG, PANEL_PRESS_ENTER_TO_RETURN, PANEL_NOT_TTY, PANEL_TITLE, PANEL_CONFIGURED_BRANCH, PANEL_CONFIGURED_BRANCH_DELETED, PANEL_CONFIGURED_BRANCH_MISMATCH, PANEL_NOT_INITIALIZED, PANEL_UNKNOWN_DATE, PANEL_SYNCED_WITH_MAIN, PANEL_COMMITS_AHEAD, PANEL_COMMITS_BEHIND } from './interactive-panel.js';
22
+ import { CLI_DESCRIPTIONS } from './cli-descriptions.js';
22
23
 
23
24
  export { CONFIG_ALIAS_DISABLED_HINT };
24
25
  export { UPDATE_MESSAGES, UPDATE_COMMANDS };
25
26
  export { PANEL_FOOTER_SHORTCUTS, PANEL_FOOTER_COUNTDOWN, PANEL_OVERFLOW_DOWN_HINT, PANEL_OVERFLOW_UP_HINT, PANEL_SNAPSHOT_SUMMARY, PANEL_NO_WORKTREES_MSG, PANEL_PRESS_ENTER_TO_RETURN, PANEL_NOT_TTY, PANEL_TITLE, PANEL_CONFIGURED_BRANCH, PANEL_CONFIGURED_BRANCH_DELETED, PANEL_CONFIGURED_BRANCH_MISMATCH, PANEL_NOT_INITIALIZED, PANEL_UNKNOWN_DATE, PANEL_SYNCED_WITH_MAIN, PANEL_COMMITS_AHEAD, PANEL_COMMITS_BEHIND };
27
+ export { CLI_DESCRIPTIONS };
26
28
 
27
29
  /**
28
30
  * 提示消息模板
@@ -1,22 +1,53 @@
1
- /** init 命令专属提示消息 */
2
- export const INIT_MESSAGES = {
1
+ import { createMessages } from '../../utils/i18n.js';
2
+
3
+ /** init 命令专属提示消息(双语映射) */
4
+ const INIT_MESSAGES_I18N = {
3
5
  /** init 成功 */
4
- INIT_SUCCESS: (branch: string) =>
5
- `✓ 项目初始化成功,主工作分支设置为: ${branch}`,
6
+ INIT_SUCCESS: {
7
+ en: (branch: string) =>
8
+ `✓ Project initialized, main work branch set to: ${branch}`,
9
+ 'zh-CN': (branch: string) =>
10
+ `✓ 项目初始化成功,主工作分支设置为: ${branch}`,
11
+ },
6
12
  /** init 更新 */
7
- INIT_UPDATED: (oldBranch: string, newBranch: string) =>
8
- `✓ 已将主工作分支从 ${oldBranch} 更新为 ${newBranch}`,
13
+ INIT_UPDATED: {
14
+ en: (oldBranch: string, newBranch: string) =>
15
+ `✓ Main work branch updated from ${oldBranch} to ${newBranch}`,
16
+ 'zh-CN': (oldBranch: string, newBranch: string) =>
17
+ `✓ 已将主工作分支从 ${oldBranch} 更新为 ${newBranch}`,
18
+ },
9
19
  /** init show 查看当前项目完整配置(JSON 格式) */
10
- INIT_SHOW: (configJson: string) =>
11
- `${configJson}`,
20
+ INIT_SHOW: {
21
+ en: (configJson: string) =>
22
+ `${configJson}`,
23
+ 'zh-CN': (configJson: string) =>
24
+ `${configJson}`,
25
+ },
12
26
  /** init 未初始化 */
13
- INIT_NOT_INITIALIZED: '项目尚未初始化,请先执行 clawt init 设置主工作分支',
27
+ INIT_NOT_INITIALIZED: {
28
+ en: 'Project not initialized. Please run clawt init to set the main work branch',
29
+ 'zh-CN': '项目尚未初始化,请先执行 clawt init 设置主工作分支',
30
+ },
14
31
  /** 项目未初始化(requireProjectConfig 使用) */
15
- PROJECT_NOT_INITIALIZED: '项目尚未初始化,请先执行 clawt init 设置主工作分支',
32
+ PROJECT_NOT_INITIALIZED: {
33
+ en: 'Project not initialized. Please run clawt init to set the main work branch',
34
+ 'zh-CN': '项目尚未初始化,请先执行 clawt init 设置主工作分支',
35
+ },
16
36
  /** 项目配置缺少 clawtMainWorkBranch 字段 */
17
- PROJECT_CONFIG_MISSING_BRANCH: '项目配置缺少主工作分支信息,请重新执行 clawt init 设置主工作分支',
37
+ PROJECT_CONFIG_MISSING_BRANCH: {
38
+ en: 'Project config missing main work branch info. Please run clawt init to set the main work branch',
39
+ 'zh-CN': '项目配置缺少主工作分支信息,请重新执行 clawt init 设置主工作分支',
40
+ },
18
41
  /** init show 交互式面板选择配置项提示 */
19
- INIT_SELECT_PROMPT: '选择要修改的项目配置项',
42
+ INIT_SELECT_PROMPT: {
43
+ en: 'Select project config item to modify',
44
+ 'zh-CN': '选择要修改的项目配置项',
45
+ },
20
46
  /** init show 交互式面板配置项修改成功 */
21
- INIT_SET_SUCCESS: (key: string, value: string) => `✓ 项目配置 ${key} 已设置为 ${value}`,
22
- } as const;
47
+ INIT_SET_SUCCESS: {
48
+ en: (key: string, value: string) => `✓ Project config ${key} set to ${value}`,
49
+ 'zh-CN': (key: string, value: string) => `✓ 项目配置 ${key} 已设置为 ${value}`,
50
+ },
51
+ };
52
+
53
+ export const INIT_MESSAGES = createMessages(INIT_MESSAGES_I18N);