sillyspec 3.22.3 → 3.22.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/worktree.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sillyspec",
3
- "version": "3.22.3",
3
+ "version": "3.22.4",
4
4
  "description": "SillySpec CLI — 流程状态机,让 AI 严格按步骤来",
5
5
  "icon": "logo.jpg",
6
6
  "homepage": "https://sillyspec.ppdmq.top/",
package/src/worktree.js CHANGED
@@ -244,9 +244,20 @@ export class WorktreeManager {
244
244
 
245
245
  // 2. 检查 worktree 是否已存在
246
246
  if (existsSync(worktreePath)) {
247
- // 目录在但 meta.json 不存在(幽灵状态),自动清理
247
+ // 目录在但 meta.json 不存在(幽灵状态)—— 删之前必须确认无未提交改动,
248
+ // 否则会丢失 execute 期间未 commit 的代码(不可恢复,3.22.4 修复)。
248
249
  if (!this.getMeta(name)) {
249
- console.log(`⚠️ 检测到幽灵 worktree 目录(无 meta.json),自动清理...`);
250
+ let uncommitted = '';
251
+ try { uncommitted = git(worktreePath, 'status --porcelain') } catch {}
252
+ if (uncommitted.trim()) {
253
+ throw new Error(
254
+ `检测到幽灵 worktree(无 meta.json)但含未提交改动,拒绝自动清理(防丢代码)。\n` +
255
+ ` 目录:${worktreePath}\n` +
256
+ ` 请先检查/commit/备份该目录,再手动清理:sillyspec worktree cleanup ${name} --force\n` +
257
+ ` (未提交文件数:${uncommitted.trim().split('\n').length})`
258
+ );
259
+ }
260
+ console.log(`⚠️ 检测到幽灵 worktree 目录(无 meta.json,无未提交改动),自动清理...`);
250
261
  try { rmSync(worktreePath, { recursive: true, force: true }); } catch {}
251
262
  // 同步清理 git worktree 注册 + 残留分支,否则目录虽删但 git 内部状态未清,
252
263
  // 后续 git worktree add 会因「worktree 已注册」或「分支已存在」失败