clawt 2.7.2 → 2.7.3
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/README.md +1 -1
- package/dist/index.js +6 -1
- package/docs/spec.md +2 -0
- package/package.json +1 -1
- package/src/commands/list.ts +8 -2
- package/src/utils/formatter.ts +12 -0
- package/src/utils/index.ts +2 -2
package/README.md
CHANGED
|
@@ -246,7 +246,7 @@ clawt list [--json]
|
|
|
246
246
|
| ---- | ---- | ---- |
|
|
247
247
|
| `--json` | 否 | 以 JSON 格式输出(仅包含 path 和 branch) |
|
|
248
248
|
|
|
249
|
-
列出当前项目在 `~/.clawt/worktrees/` 下的所有 worktree
|
|
249
|
+
列出当前项目在 `~/.clawt/worktrees/` 下的所有 worktree 及对应分支。文本模式下,如果某个 worktree 处于空闲状态(0 个提交、无变更、无未提交修改),其路径会以橙色高亮显示,方便快速识别可能需要清理或还未开始工作的 worktree。指定 `--json` 时以 JSON 格式输出,便于脚本解析。
|
|
250
250
|
|
|
251
251
|
```bash
|
|
252
252
|
# 文本格式输出(默认)
|
package/dist/index.js
CHANGED
|
@@ -499,6 +499,9 @@ function confirmDestructiveAction(dangerousCommand, description) {
|
|
|
499
499
|
printWarning(`\u5373\u5C06\u6267\u884C ${chalk.red.bold(dangerousCommand)}\uFF0C${description}`);
|
|
500
500
|
return confirmAction("\u662F\u5426\u7EE7\u7EED\uFF1F");
|
|
501
501
|
}
|
|
502
|
+
function isWorktreeIdle(status) {
|
|
503
|
+
return status.commitCount === 0 && status.insertions === 0 && status.deletions === 0 && !status.hasDirtyFiles;
|
|
504
|
+
}
|
|
502
505
|
function formatWorktreeStatus(status) {
|
|
503
506
|
const parts = [];
|
|
504
507
|
parts.push(chalk.yellow(`${status.commitCount} \u4E2A\u63D0\u4EA4`));
|
|
@@ -854,8 +857,10 @@ function printListAsText(projectName, worktrees) {
|
|
|
854
857
|
printInfo(` ${MESSAGES.NO_WORKTREES}`);
|
|
855
858
|
} else {
|
|
856
859
|
for (const wt of worktrees) {
|
|
857
|
-
printInfo(` ${wt.path} [${wt.branch}]`);
|
|
858
860
|
const status = getWorktreeStatus(wt);
|
|
861
|
+
const isIdle = status ? isWorktreeIdle(status) : false;
|
|
862
|
+
const pathDisplay = isIdle ? chalk2.hex("#FF8C00")(wt.path) : wt.path;
|
|
863
|
+
printInfo(` ${pathDisplay} [${wt.branch}]`);
|
|
859
864
|
if (status) {
|
|
860
865
|
printInfo(` ${formatWorktreeStatus(status)}`);
|
|
861
866
|
} else {
|
package/docs/spec.md
CHANGED
package/package.json
CHANGED
package/src/commands/list.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getProjectWorktrees,
|
|
10
10
|
getWorktreeStatus,
|
|
11
11
|
formatWorktreeStatus,
|
|
12
|
+
isWorktreeIdle,
|
|
12
13
|
printInfo,
|
|
13
14
|
} from '../utils/index.js';
|
|
14
15
|
// getWorktreeStatus 和 formatWorktreeStatus 仅在文本模式下使用
|
|
@@ -77,10 +78,15 @@ function printListAsText(projectName: string, worktrees: import('../types/index.
|
|
|
77
78
|
printInfo(` ${MESSAGES.NO_WORKTREES}`);
|
|
78
79
|
} else {
|
|
79
80
|
for (const wt of worktrees) {
|
|
80
|
-
printInfo(` ${wt.path} [${wt.branch}]`);
|
|
81
|
-
|
|
82
81
|
// 获取并展示 worktree 变更状态
|
|
83
82
|
const status = getWorktreeStatus(wt);
|
|
83
|
+
|
|
84
|
+
// 空闲状态的 worktree 路径用橙色高亮,提示用户关注
|
|
85
|
+
const isIdle = status ? isWorktreeIdle(status) : false;
|
|
86
|
+
const pathDisplay = isIdle ? chalk.hex('#FF8C00')(wt.path) : wt.path;
|
|
87
|
+
|
|
88
|
+
printInfo(` ${pathDisplay} [${wt.branch}]`);
|
|
89
|
+
|
|
84
90
|
if (status) {
|
|
85
91
|
printInfo(` ${formatWorktreeStatus(status)}`);
|
|
86
92
|
} else {
|
package/src/utils/formatter.ts
CHANGED
|
@@ -78,6 +78,18 @@ export function confirmDestructiveAction(dangerousCommand: string, description:
|
|
|
78
78
|
return confirmAction('是否继续?');
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* 判断 worktree 是否处于空闲状态(0 个提交、无变更、无未提交修改)
|
|
83
|
+
* @param {WorktreeStatus} status - worktree 变更统计信息
|
|
84
|
+
* @returns {boolean} 是否空闲
|
|
85
|
+
*/
|
|
86
|
+
export function isWorktreeIdle(status: WorktreeStatus): boolean {
|
|
87
|
+
return status.commitCount === 0
|
|
88
|
+
&& status.insertions === 0
|
|
89
|
+
&& status.deletions === 0
|
|
90
|
+
&& !status.hasDirtyFiles;
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
/**
|
|
82
94
|
* 将 WorktreeStatus 格式化为带颜色的字符串
|
|
83
95
|
* @param {WorktreeStatus} status - worktree 变更统计信息
|
package/src/utils/index.ts
CHANGED
|
@@ -47,8 +47,8 @@ export {
|
|
|
47
47
|
export { sanitizeBranchName, generateBranchNames, validateBranchesNotExist } from './branch.js';
|
|
48
48
|
export { validateMainWorktree, validateGitInstalled, validateClaudeCodeInstalled } from './validation.js';
|
|
49
49
|
export { createWorktrees, getProjectWorktrees, getProjectWorktreeDir, cleanupWorktrees, getWorktreeStatus } from './worktree.js';
|
|
50
|
-
export { loadConfig, getConfigValue, ensureClawtDirs
|
|
51
|
-
export { printSuccess, printError, printWarning, printInfo, printSeparator, printDoubleSeparator, confirmAction, confirmDestructiveAction, formatWorktreeStatus } from './formatter.js';
|
|
50
|
+
export { loadConfig, writeDefaultConfig, getConfigValue, ensureClawtDirs } from './config.js';
|
|
51
|
+
export { printSuccess, printError, printWarning, printInfo, printSeparator, printDoubleSeparator, confirmAction, confirmDestructiveAction, formatWorktreeStatus, isWorktreeIdle } from './formatter.js';
|
|
52
52
|
export { ensureDir, removeEmptyDir } from './fs.js';
|
|
53
53
|
export { multilineInput } from './prompt.js';
|
|
54
54
|
export { launchInteractiveClaude } from './claude.js';
|