clawt 2.3.7 → 2.3.9
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 +24 -4
- package/package.json +1 -1
- package/src/commands/remove.ts +9 -0
- package/src/commands/resume.ts +3 -3
- package/src/commands/run.ts +1 -1
- package/src/constants/messages.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -100,7 +100,8 @@ var MESSAGES = {
|
|
|
100
100
|
/** sync 冲突 */
|
|
101
101
|
SYNC_CONFLICT: (worktreePath) => `\u5408\u5E76\u5B58\u5728\u51B2\u7A81\uFF0C\u8BF7\u8FDB\u5165\u76EE\u6807 worktree \u624B\u52A8\u89E3\u51B3\uFF1A
|
|
102
102
|
cd ${worktreePath}
|
|
103
|
-
\u89E3\u51B3\u51B2\u7A81\u540E\u6267\u884C git add . && git merge --continue
|
|
103
|
+
\u89E3\u51B3\u51B2\u7A81\u540E\u6267\u884C git add . && git merge --continue
|
|
104
|
+
clawt validate -b <branch> \u9A8C\u8BC1\u53D8\u66F4`,
|
|
104
105
|
/** validate patch apply 失败,提示用户同步主分支 */
|
|
105
106
|
VALIDATE_PATCH_APPLY_FAILED: (branch) => `\u53D8\u66F4\u8FC1\u79FB\u5931\u8D25\uFF1A\u76EE\u6807\u5206\u652F\u4E0E\u4E3B\u5206\u652F\u5DEE\u5F02\u8FC7\u5927
|
|
106
107
|
\u8BF7\u5148\u6267\u884C clawt sync -b ${branch} \u540C\u6B65\u4E3B\u5206\u652F\u540E\u91CD\u8BD5`,
|
|
@@ -666,6 +667,21 @@ function removeSnapshot(projectName, branchName) {
|
|
|
666
667
|
logger.info(`\u5DF2\u5220\u9664 validate \u5FEB\u7167: ${snapshotPath}`);
|
|
667
668
|
}
|
|
668
669
|
}
|
|
670
|
+
function removeProjectSnapshots(projectName) {
|
|
671
|
+
const projectDir = join3(VALIDATE_SNAPSHOTS_DIR, projectName);
|
|
672
|
+
if (!existsSync5(projectDir)) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const files = readdirSync3(projectDir);
|
|
676
|
+
for (const file of files) {
|
|
677
|
+
unlinkSync(join3(projectDir, file));
|
|
678
|
+
}
|
|
679
|
+
try {
|
|
680
|
+
rmdirSync2(projectDir);
|
|
681
|
+
} catch {
|
|
682
|
+
}
|
|
683
|
+
logger.info(`\u5DF2\u5220\u9664\u9879\u76EE ${projectName} \u7684\u6240\u6709 validate \u5FEB\u7167`);
|
|
684
|
+
}
|
|
669
685
|
|
|
670
686
|
// src/commands/list.ts
|
|
671
687
|
import chalk2 from "chalk";
|
|
@@ -773,6 +789,7 @@ async function handleRemove(options) {
|
|
|
773
789
|
if (shouldDeleteBranch) {
|
|
774
790
|
deleteBranch(wt.branch);
|
|
775
791
|
}
|
|
792
|
+
removeSnapshot(projectName, wt.branch);
|
|
776
793
|
printSuccess(MESSAGES.WORKTREE_REMOVED(wt.path));
|
|
777
794
|
} catch (error) {
|
|
778
795
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -780,6 +797,9 @@ async function handleRemove(options) {
|
|
|
780
797
|
failures.push({ path: wt.path, error: errorMessage });
|
|
781
798
|
}
|
|
782
799
|
}
|
|
800
|
+
if (options.all) {
|
|
801
|
+
removeProjectSnapshots(projectName);
|
|
802
|
+
}
|
|
783
803
|
gitWorktreePrune();
|
|
784
804
|
const projectDir = getProjectWorktreeDir();
|
|
785
805
|
removeEmptyDir(projectDir);
|
|
@@ -959,8 +979,8 @@ async function handleRun(options) {
|
|
|
959
979
|
|
|
960
980
|
// src/commands/resume.ts
|
|
961
981
|
function registerResumeCommand(program2) {
|
|
962
|
-
program2.command("resume").description("\u5728\u5DF2\u6709 worktree \u4E2D\u6062\u590D Claude Code \u4EA4\u4E92\u5F0F\u4F1A\u8BDD").requiredOption("-b, --branch <branchName>", "\u8981\u6062\u590D\u7684\u5206\u652F\u540D").action(
|
|
963
|
-
|
|
982
|
+
program2.command("resume").description("\u5728\u5DF2\u6709 worktree \u4E2D\u6062\u590D Claude Code \u4EA4\u4E92\u5F0F\u4F1A\u8BDD").requiredOption("-b, --branch <branchName>", "\u8981\u6062\u590D\u7684\u5206\u652F\u540D").action((options) => {
|
|
983
|
+
handleResume(options);
|
|
964
984
|
});
|
|
965
985
|
}
|
|
966
986
|
function findWorktreeByBranch(branchName) {
|
|
@@ -971,7 +991,7 @@ function findWorktreeByBranch(branchName) {
|
|
|
971
991
|
}
|
|
972
992
|
return matched;
|
|
973
993
|
}
|
|
974
|
-
|
|
994
|
+
function handleResume(options) {
|
|
975
995
|
validateMainWorktree();
|
|
976
996
|
validateClaudeCodeInstalled();
|
|
977
997
|
logger.info(`resume \u547D\u4EE4\u6267\u884C\uFF0C\u5206\u652F: ${options.branch}`);
|
package/package.json
CHANGED
package/src/commands/remove.ts
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
printSuccess,
|
|
18
18
|
printError,
|
|
19
19
|
confirmAction,
|
|
20
|
+
removeSnapshot,
|
|
21
|
+
removeProjectSnapshots,
|
|
20
22
|
} from '../utils/index.js';
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -100,6 +102,8 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
100
102
|
if (shouldDeleteBranch) {
|
|
101
103
|
deleteBranch(wt.branch);
|
|
102
104
|
}
|
|
105
|
+
// 清理该分支对应的 validate 快照
|
|
106
|
+
removeSnapshot(projectName, wt.branch);
|
|
103
107
|
printSuccess(MESSAGES.WORKTREE_REMOVED(wt.path));
|
|
104
108
|
} catch (error) {
|
|
105
109
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -108,6 +112,11 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|
|
115
|
+
// --all 模式下清理整个项目的 validate 快照目录
|
|
116
|
+
if (options.all) {
|
|
117
|
+
removeProjectSnapshots(projectName);
|
|
118
|
+
}
|
|
119
|
+
|
|
111
120
|
// 清理 worktree 并清除空目录
|
|
112
121
|
gitWorktreePrune();
|
|
113
122
|
const projectDir = getProjectWorktreeDir();
|
package/src/commands/resume.ts
CHANGED
|
@@ -19,8 +19,8 @@ export function registerResumeCommand(program: Command): void {
|
|
|
19
19
|
.command('resume')
|
|
20
20
|
.description('在已有 worktree 中恢复 Claude Code 交互式会话')
|
|
21
21
|
.requiredOption('-b, --branch <branchName>', '要恢复的分支名')
|
|
22
|
-
.action(
|
|
23
|
-
|
|
22
|
+
.action((options: ResumeOptions) => {
|
|
23
|
+
handleResume(options);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -46,7 +46,7 @@ function findWorktreeByBranch(branchName: string): WorktreeInfo {
|
|
|
46
46
|
* 查找已有 worktree 并恢复 Claude Code 会话
|
|
47
47
|
* @param {ResumeOptions} options - 命令选项
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
function handleResume(options: ResumeOptions): void {
|
|
50
50
|
validateMainWorktree();
|
|
51
51
|
validateClaudeCodeInstalled();
|
|
52
52
|
|
package/src/commands/run.ts
CHANGED
|
@@ -46,7 +46,7 @@ interface ClaudeTaskHandle {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* 在指定 worktree 中执行 Claude Code
|
|
49
|
+
* 在指定 worktree 中执行 Claude Code 任务,由于是--output-format json形式,所以这里固定claude code cli的启动命令
|
|
50
50
|
* @param {WorktreeInfo} worktree - worktree 信息
|
|
51
51
|
* @param {string} task - 任务描述
|
|
52
52
|
* @returns {ClaudeTaskHandle} 包含子进程引用和结果 Promise
|
|
@@ -86,7 +86,7 @@ export const MESSAGES = {
|
|
|
86
86
|
`✓ 已将 ${mainBranch} 的最新代码同步到 ${targetBranch}`,
|
|
87
87
|
/** sync 冲突 */
|
|
88
88
|
SYNC_CONFLICT: (worktreePath: string) =>
|
|
89
|
-
`合并存在冲突,请进入目标 worktree 手动解决:\n cd ${worktreePath}\n 解决冲突后执行 git add . && git merge --continue
|
|
89
|
+
`合并存在冲突,请进入目标 worktree 手动解决:\n cd ${worktreePath}\n 解决冲突后执行 git add . && git merge --continue\n clawt validate -b <branch> 验证变更`,
|
|
90
90
|
/** validate patch apply 失败,提示用户同步主分支 */
|
|
91
91
|
VALIDATE_PATCH_APPLY_FAILED: (branch: string) =>
|
|
92
92
|
`变更迁移失败:目标分支与主分支差异过大\n 请先执行 clawt sync -b ${branch} 同步主分支后重试`,
|