clawt 2.3.2 → 2.3.4

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 CHANGED
@@ -1037,8 +1037,16 @@ function migrateChangesViaPatch(targetWorktreePath, mainWorktreePath, branchName
1037
1037
  }
1038
1038
  } finally {
1039
1039
  if (didTempCommit) {
1040
- gitResetSoft(1, targetWorktreePath);
1041
- gitRestoreStaged(targetWorktreePath);
1040
+ try {
1041
+ gitResetSoft(1, targetWorktreePath);
1042
+ } catch (error) {
1043
+ logger.error(`\u64A4\u9500\u4E34\u65F6 commit \u5931\u8D25: ${error}`);
1044
+ }
1045
+ try {
1046
+ gitRestoreStaged(targetWorktreePath);
1047
+ } catch (error) {
1048
+ logger.error(`\u6062\u590D\u6682\u5B58\u533A\u5931\u8D25: ${error}`);
1049
+ }
1042
1050
  }
1043
1051
  }
1044
1052
  }
@@ -1258,6 +1266,7 @@ function formatConfigValue(value) {
1258
1266
 
1259
1267
  // src/commands/sync.ts
1260
1268
  import { existsSync as existsSync8 } from "fs";
1269
+ import { join as join6 } from "path";
1261
1270
  function registerSyncCommand(program2) {
1262
1271
  program2.command("sync").description("\u5C06\u4E3B\u5206\u652F\u6700\u65B0\u4EE3\u7801\u540C\u6B65\u5230\u76EE\u6807 worktree").requiredOption("-b, --branch <branchName>", "\u8981\u540C\u6B65\u7684\u5206\u652F\u540D").action(async (options) => {
1263
1272
  await handleSync(options);
@@ -1285,7 +1294,7 @@ async function handleSync(options) {
1285
1294
  const { branch } = options;
1286
1295
  logger.info(`sync \u547D\u4EE4\u6267\u884C\uFF0C\u5206\u652F: ${branch}`);
1287
1296
  const projectWorktreeDir = getProjectWorktreeDir();
1288
- const targetWorktreePath = `${projectWorktreeDir}/${branch}`;
1297
+ const targetWorktreePath = join6(projectWorktreeDir, branch);
1289
1298
  if (!existsSync8(targetWorktreePath)) {
1290
1299
  throw new ClawtError(MESSAGES.WORKTREE_NOT_FOUND(branch));
1291
1300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawt",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "本地并行执行多个Claude Code Agent任务,融合 Git Worktree 与 Claude Code CLI 的命令行工具",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,5 @@
1
1
  import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
2
3
  import type { Command } from 'commander';
3
4
  import { logger } from '../logger/index.js';
4
5
  import { ClawtError } from '../errors/index.js';
@@ -81,7 +82,7 @@ async function handleSync(options: SyncOptions): Promise<void> {
81
82
 
82
83
  // 检查目标 worktree 是否存在
83
84
  const projectWorktreeDir = getProjectWorktreeDir();
84
- const targetWorktreePath = `${projectWorktreeDir}/${branch}`;
85
+ const targetWorktreePath = join(projectWorktreeDir, branch);
85
86
 
86
87
  if (!existsSync(targetWorktreePath)) {
87
88
  throw new ClawtError(MESSAGES.WORKTREE_NOT_FOUND(branch));
@@ -127,9 +127,18 @@ function migrateChangesViaPatch(targetWorktreePath: string, mainWorktreePath: st
127
127
  }
128
128
  } finally {
129
129
  // 确保临时 commit 一定会被撤销,恢复目标 worktree 原状
130
+ // 每个操作独立 try-catch,避免前一个失败导致后续操作不执行
130
131
  if (didTempCommit) {
131
- gitResetSoft(1, targetWorktreePath);
132
- gitRestoreStaged(targetWorktreePath);
132
+ try {
133
+ gitResetSoft(1, targetWorktreePath);
134
+ } catch (error) {
135
+ logger.error(`撤销临时 commit 失败: ${error}`);
136
+ }
137
+ try {
138
+ gitRestoreStaged(targetWorktreePath);
139
+ } catch (error) {
140
+ logger.error(`恢复暂存区失败: ${error}`);
141
+ }
133
142
  }
134
143
  }
135
144
  }