clawt 2.3.4 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -0
- package/package.json +1 -1
- package/src/commands/run.ts +1 -2
- package/src/constants/messages.ts +3 -0
- package/src/utils/branch.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -28,6 +28,8 @@ var MESSAGES = {
|
|
|
28
28
|
CLAUDE_NOT_INSTALLED: "Claude Code CLI \u672A\u5B89\u88C5\uFF0C\u8BF7\u5148\u5B89\u88C5\uFF1Anpm install -g @anthropic-ai/claude-code",
|
|
29
29
|
/** 分支已存在 */
|
|
30
30
|
BRANCH_EXISTS: (name) => `\u5206\u652F ${name} \u5DF2\u5B58\u5728\uFF0C\u65E0\u6CD5\u521B\u5EFA`,
|
|
31
|
+
/** 分支名清理后为空 */
|
|
32
|
+
BRANCH_NAME_EMPTY: (original) => `\u5206\u652F\u540D "${original}" \u4E2D\u4E0D\u5305\u542B\u5408\u6CD5\u5B57\u7B26\uFF0C\u65E0\u6CD5\u521B\u5EFA\u5206\u652F`,
|
|
31
33
|
/** 分支名被转换 */
|
|
32
34
|
BRANCH_SANITIZED: (original, sanitized) => `\u5206\u652F\u540D\u5DF2\u8F6C\u6362: ${original} \u2192 ${sanitized}`,
|
|
33
35
|
/** worktree 创建成功 */
|
|
@@ -438,6 +440,9 @@ function formatWorktreeStatus(status) {
|
|
|
438
440
|
// src/utils/branch.ts
|
|
439
441
|
function sanitizeBranchName(branchName) {
|
|
440
442
|
const sanitized = branchName.replace(INVALID_BRANCH_CHARS, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
|
|
443
|
+
if (!sanitized) {
|
|
444
|
+
throw new ClawtError(MESSAGES.BRANCH_NAME_EMPTY(branchName));
|
|
445
|
+
}
|
|
441
446
|
if (sanitized !== branchName) {
|
|
442
447
|
logger.warn(MESSAGES.BRANCH_SANITIZED(branchName, sanitized));
|
|
443
448
|
printWarning(MESSAGES.BRANCH_SANITIZED(branchName, sanitized));
|
package/package.json
CHANGED
package/src/commands/run.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ChildProcess } from 'node:child_process';
|
|
|
3
3
|
import { logger } from '../logger/index.js';
|
|
4
4
|
import { ClawtError } from '../errors/index.js';
|
|
5
5
|
import { MESSAGES } from '../constants/index.js';
|
|
6
|
-
import type { RunOptions, ClaudeCodeResult, TaskResult, TaskSummary } from '../types/index.js';
|
|
6
|
+
import type { RunOptions, ClaudeCodeResult, TaskResult, TaskSummary, WorktreeInfo } from '../types/index.js';
|
|
7
7
|
import {
|
|
8
8
|
validateMainWorktree,
|
|
9
9
|
validateClaudeCodeInstalled,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
confirmAction,
|
|
22
22
|
launchInteractiveClaude,
|
|
23
23
|
} from '../utils/index.js';
|
|
24
|
-
import type { WorktreeInfo } from '../types/index.js';
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* 注册 run 命令:批量创建 worktree 并执行 Claude Code 任务
|
|
@@ -8,6 +8,9 @@ export const MESSAGES = {
|
|
|
8
8
|
CLAUDE_NOT_INSTALLED: 'Claude Code CLI 未安装,请先安装:npm install -g @anthropic-ai/claude-code',
|
|
9
9
|
/** 分支已存在 */
|
|
10
10
|
BRANCH_EXISTS: (name: string) => `分支 ${name} 已存在,无法创建`,
|
|
11
|
+
/** 分支名清理后为空 */
|
|
12
|
+
BRANCH_NAME_EMPTY: (original: string) =>
|
|
13
|
+
`分支名 "${original}" 中不包含合法字符,无法创建分支`,
|
|
11
14
|
/** 分支名被转换 */
|
|
12
15
|
BRANCH_SANITIZED: (original: string, sanitized: string) =>
|
|
13
16
|
`分支名已转换: ${original} → ${sanitized}`,
|
package/src/utils/branch.ts
CHANGED
|
@@ -15,6 +15,10 @@ export function sanitizeBranchName(branchName: string): string {
|
|
|
15
15
|
.replace(/-{2,}/g, '-')
|
|
16
16
|
.replace(/^-|-$/g, '');
|
|
17
17
|
|
|
18
|
+
if (!sanitized) {
|
|
19
|
+
throw new ClawtError(MESSAGES.BRANCH_NAME_EMPTY(branchName));
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
if (sanitized !== branchName) {
|
|
19
23
|
logger.warn(MESSAGES.BRANCH_SANITIZED(branchName, sanitized));
|
|
20
24
|
printWarning(MESSAGES.BRANCH_SANITIZED(branchName, sanitized));
|