sillyspec 3.20.2 → 3.20.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 (133) hide show
  1. package/.claude/skills/sillyspec-archive/SKILL.md +21 -21
  2. package/.claude/skills/sillyspec-auto/SKILL.md +83 -83
  3. package/.claude/skills/sillyspec-brainstorm/SKILL.md +44 -44
  4. package/.claude/skills/sillyspec-commit/SKILL.md +106 -106
  5. package/.claude/skills/sillyspec-continue/SKILL.md +45 -45
  6. package/.claude/skills/sillyspec-doctor/SKILL.md +31 -31
  7. package/.claude/skills/sillyspec-execute/SKILL.md +30 -30
  8. package/.claude/skills/sillyspec-explore/SKILL.md +109 -109
  9. package/.claude/skills/sillyspec-knowledge/SKILL.md +269 -269
  10. package/.claude/skills/sillyspec-plan/SKILL.md +21 -21
  11. package/.claude/skills/sillyspec-propose/SKILL.md +21 -21
  12. package/.claude/skills/sillyspec-quick/SKILL.md +21 -21
  13. package/.claude/skills/sillyspec-resume/SKILL.md +68 -68
  14. package/.claude/skills/sillyspec-scan/SKILL.md +21 -21
  15. package/.claude/skills/sillyspec-state/SKILL.md +54 -54
  16. package/.claude/skills/sillyspec-status/SKILL.md +21 -21
  17. package/.claude/skills/sillyspec-verify/SKILL.md +21 -21
  18. package/.claude/skills/sillyspec-workspace/SKILL.md +157 -157
  19. package/.husky/pre-push +13 -13
  20. package/CLAUDE.md +18 -18
  21. package/README.md +198 -188
  22. package/SKILL.md +90 -91
  23. package/bin/sillyspec.js +2 -2
  24. package/docs/brainstorm-plan-contract.md +64 -64
  25. package/docs/plan-execute-contract.md +123 -123
  26. package/docs/platform-scan-protocol.md +298 -298
  27. package/docs/revision-mode.md +115 -115
  28. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +99 -99
  29. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +218 -218
  30. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +167 -167
  31. package/docs/sillyspec/file-lifecycle/storage-and-state.md +148 -148
  32. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +211 -193
  33. package/docs/sillyspec/file-lifecycle.md +125 -125
  34. package/docs/workflow-contract-regression.md +106 -106
  35. package/docs/worktree-isolation.md +252 -252
  36. package/package.json +40 -40
  37. package/packages/dashboard/dist/assets/index-Bq_Z2hne.js +7446 -7446
  38. package/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -1
  39. package/packages/dashboard/dist/index.html +16 -16
  40. package/packages/dashboard/index.html +15 -15
  41. package/packages/dashboard/package-lock.json +2384 -2384
  42. package/packages/dashboard/package.json +25 -25
  43. package/packages/dashboard/server/executor.js +86 -86
  44. package/packages/dashboard/server/index.js +588 -588
  45. package/packages/dashboard/server/parser.js +526 -526
  46. package/packages/dashboard/server/watcher.js +344 -344
  47. package/packages/dashboard/src/App.vue +558 -558
  48. package/packages/dashboard/src/components/ActionBar.vue +93 -93
  49. package/packages/dashboard/src/components/CommandPalette.vue +96 -96
  50. package/packages/dashboard/src/components/DetailPanel.vue +137 -137
  51. package/packages/dashboard/src/components/LogStream.vue +65 -65
  52. package/packages/dashboard/src/components/PipelineStage.vue +95 -95
  53. package/packages/dashboard/src/components/PipelineView.vue +156 -156
  54. package/packages/dashboard/src/components/ProjectList.vue +210 -210
  55. package/packages/dashboard/src/components/StageBadge.vue +67 -67
  56. package/packages/dashboard/src/components/StepCard.vue +94 -94
  57. package/packages/dashboard/src/components/detail/DocsDetail.vue +48 -48
  58. package/packages/dashboard/src/components/detail/GitDetail.vue +61 -61
  59. package/packages/dashboard/src/components/detail/TechDetail.vue +43 -43
  60. package/packages/dashboard/src/composables/useDashboard.js +170 -170
  61. package/packages/dashboard/src/composables/useKeyboard.js +119 -119
  62. package/packages/dashboard/src/composables/useWebSocket.js +129 -129
  63. package/packages/dashboard/src/main.js +8 -8
  64. package/packages/dashboard/src/style.css +132 -132
  65. package/packages/dashboard/vite.config.js +18 -18
  66. package/src/brainstorm-postcheck.js +158 -158
  67. package/src/change-list.js +52 -52
  68. package/src/change-risk-profile.js +352 -352
  69. package/src/classify-change.js +73 -73
  70. package/src/constants.js +70 -70
  71. package/src/contract-matrix.js +278 -278
  72. package/src/db.js +201 -201
  73. package/src/endpoint-extractor.js +315 -315
  74. package/src/hooks/claude-pre-tool-use.cjs +125 -125
  75. package/src/hooks/worktree-guard.js +653 -653
  76. package/src/index.js +922 -900
  77. package/src/init.js +431 -431
  78. package/src/knowledge-match.js +130 -130
  79. package/src/migrate.js +117 -117
  80. package/src/modules.js +482 -482
  81. package/src/progress.js +1734 -1734
  82. package/src/run.js +3465 -3358
  83. package/src/scan-postcheck.js +387 -383
  84. package/src/setup.js +398 -398
  85. package/src/stage-contract.js +700 -700
  86. package/src/stages/archive.js +160 -160
  87. package/src/stages/brainstorm-auto.js +229 -229
  88. package/src/stages/brainstorm.js +645 -645
  89. package/src/stages/doctor.js +365 -365
  90. package/src/stages/execute.js +625 -625
  91. package/src/stages/explore.js +34 -34
  92. package/src/stages/index.js +29 -29
  93. package/src/stages/knowledge.js +498 -498
  94. package/src/stages/plan-postcheck.js +511 -513
  95. package/src/stages/plan.js +582 -582
  96. package/src/stages/propose.js +174 -174
  97. package/src/stages/quick.js +82 -82
  98. package/src/stages/scan.js +558 -558
  99. package/src/stages/status.js +65 -65
  100. package/src/stages/verify.js +322 -322
  101. package/src/sync.js +497 -497
  102. package/src/task-review.js +346 -346
  103. package/src/workflow.js +785 -785
  104. package/src/worktree-apply.js +549 -549
  105. package/src/worktree-deps.js +185 -0
  106. package/src/worktree.js +982 -932
  107. package/templates/workflows/archive-impact.yaml +79 -79
  108. package/templates/workflows/scan-docs.yaml +132 -132
  109. package/test/brainstorm-plan-contract.test.mjs +273 -273
  110. package/test/check-syntax.mjs +26 -26
  111. package/test/contract-artifacts.test.mjs +323 -323
  112. package/test/decision-supersede.test.mjs +277 -277
  113. package/test/knowledge-match.test.mjs +231 -231
  114. package/test/plan-execute-contract.test.mjs +330 -330
  115. package/test/plan-optimization.test.mjs +572 -572
  116. package/test/platform-artifacts.test.mjs +166 -166
  117. package/test/platform-failure-samples.test.mjs +199 -199
  118. package/test/platform-recovery-chain.test.mjs +167 -167
  119. package/test/platform-recovery.test.mjs +136 -136
  120. package/test/platform-scan-p0.test.mjs +168 -168
  121. package/test/revision-v1.test.mjs +1145 -1145
  122. package/test/run-scan-project-parse.test.mjs +200 -200
  123. package/test/run-tests.mjs +48 -48
  124. package/test/scan-knowledge.test.mjs +175 -175
  125. package/test/scan-paths.test.mjs +68 -68
  126. package/test/scan-postcheck.test.mjs +197 -197
  127. package/test/spec-dir.test.mjs +206 -206
  128. package/test/stage-contract.test.mjs +299 -299
  129. package/test/stage-definitions.test.mjs +39 -39
  130. package/test/wait-gates.test.mjs +496 -496
  131. package/test/worktree-deps-provision.test.mjs +148 -0
  132. package/test/worktree-guard.test.mjs +71 -71
  133. package/test/worktree-native-overlay.test.mjs +188 -188
@@ -1,193 +1,211 @@
1
- ---
2
- author: qinyi
3
- created_at: 2026-06-04 16:25:42
4
- ---
5
-
6
- # Worktree 与 Hook 门禁
7
-
8
- ## 命令入口
9
-
10
- `src/index.js` 暴露:
11
-
12
- ```text
13
- sillyspec worktree create <change-name> [--base <branch>]
14
- sillyspec worktree apply <change-name> [--check-only]
15
- sillyspec worktree list
16
- sillyspec worktree cleanup <change-name>
17
- ```
18
-
19
- 实现分别调用:
20
-
21
- - `WorktreeManager.create()`
22
- - `applyWorktree()`
23
- - `WorktreeManager.list()`
24
- - `WorktreeManager.cleanup()`
25
-
26
- ## `create`
27
-
28
- 默认路径:
29
-
30
- ```text
31
- .sillyspec/.runtime/worktrees/<change-name>/
32
- ```
33
-
34
- 默认分支:
35
-
36
- ```text
37
- sillyspec/<change-name>
38
- ```
39
-
40
- 关键校验与分支:
41
-
42
- 1. `changeName` 不能为空,不能包含 `..`、`/`、`\`。
43
- 2. 如果当前目录是 git submodule,直接报错。
44
- 3. 如果当前目录已经是 linked worktree,创建 `native-worktree` meta,复用当前目录。
45
- 4. 普通主工作区必须先确认 `.sillyspec/.runtime/worktrees` `.gitignore` 忽略,否则报错。
46
- 5. 如果 worktree 目录存在但没有 `meta.json`,视为幽灵目录并自动删除。
47
- 6. 如果目标 branch 已存在,报错。
48
- 7. 默认 base 是当前 `HEAD`;传 `--base` 时使用指定 ref。
49
- 8. `git worktree add` 失败时:
50
- - 如果 git 版本低于 2.15 或不可用,报错。
51
- - 其他失败降级为 `in-place-fallback`,在主工作区记录 meta。
52
- 9. 创建普通 worktree 后,会 best-effort `fetch origin` 并尝试 fast-forward 到默认远端分支。
53
- 10. 主工作区已有 staged/unstaged/untracked 变更时,会 overlay worktree,并创建 baseline checkpoint commit。
54
-
55
- ## `meta.json`
56
-
57
- 普通 worktree 的 `meta.json` 位于 worktree 目录内:
58
-
59
- ```text
60
- .sillyspec/.runtime/worktrees/<change>/meta.json
61
- ```
62
-
63
- `native-worktree` 和 `in-place-fallback` 下,meta 仍写到 `.sillyspec/.runtime/worktrees/<change>/meta.json`,其中 `worktreePath` 可能指向当前工作目录。
64
-
65
- 主要字段:
66
-
67
- | 字段 | 说明 |
68
- |---|---|
69
- | `changeName` | 变更名 |
70
- | `branch` | worktree 分支 |
71
- | `baseBranch` | 基准分支或 ref |
72
- | `baseHash` | 创建时基准 commit |
73
- | `actualBaseHash` | worktree 当前 HEAD |
74
- | `createdAt` | 创建时间 |
75
- | `worktreePath` | 实际执行目录 |
76
- | `mode` | `worktree` / `native-worktree` / `in-place-fallback` |
77
- | `baselineFiles` | 从主工作区 overlay 的未提交文件 |
78
- | `baselineCommit` | baseline checkpoint commit |
79
- | `baselineHash` | execute 前主工作区 dirty baseline hash |
80
-
81
- ## `apply`
82
-
83
- `applyWorktree(changeName, { checkOnly })` 的真实流程:
84
-
85
- 1. 读取 `meta.json`。
86
- 2. diff base 使用 `baselineCommit || baseHash`。
87
- 3. 收集 tracked diff untracked 新文件。
88
- 4. 从 `.sillyspec/changes/<change>/design.md` 解析“文件变更清单”作为 allow list。
89
- 5. 如果 allow list 非空,要求 changed files 都在清单内。
90
- 6. 如果 meta 有 `baselineHash`,重新计算主工作区 dirty hash;不同则拒绝 apply。
91
- 7. 检查主工作区和 apply 文件有无未提交冲突。
92
- 8. 比较主工作区 `HEAD` 与 worktree `baseHash` 的目标文件 blob。
93
- 9. `--check-only` 到这里返回。
94
- 10. 生成临时 patch。
95
- 11. 在主工作区执行 `git apply --check`。
96
- 12. 执行 `git apply --3way`。
97
- 13. 成功后自动调用 `WorktreeManager.cleanup()`。
98
-
99
- 无变更时,如果不是 check-only,也会 cleanup。
100
-
101
- ## `cleanup`
102
-
103
- `cleanup(changeName, { force })`:
104
-
105
- | mode | 非 force 行为 |
106
- |---|---|
107
- | `worktree` | 尝试 `git worktree remove --force`,删除目录,删除分支,删除 meta 目录 |
108
- | `native-worktree` | 抛错,避免删除用户自己的 worktree |
109
- | `in-place-fallback` | 返回 `skipped` |
110
- | 无 meta 且目录不存在 | 返回 `skipped` |
111
-
112
- 如果 `git worktree remove` 失败但目录可删,结果是 `force-cleaned`。
113
-
114
- ## execute 阶段
115
-
116
- `execute.js` 的固定前缀第 3 步是“创建 worktree”,prompt 要求运行:
117
-
118
- ```text
119
- sillyspec worktree create <change-name>
120
- ```
121
-
122
- 后续 Wave prompt 要求把子代理 cwd 设置为 worktree 路径。完成确认 step 根据 mode 分别处理:
123
-
124
- - `worktree`:check-only,用户确认后 apply,再 cleanup。
125
- - `native-worktree`:可以 apply,但不要 cleanup。
126
- - `in-place-fallback`:跳过 apply/cleanup。
127
- - worktree:只展示 diff 摘要。
128
-
129
- 注意:`buildExecuteSteps()` 有 `noWorktree` 参数,但当前 `runCommand()` 没有解析 `--no-worktree` flag,CLI help 也没有列出该 flag。文档不要把 `--no-worktree` 写成已接通的公开流程。
130
-
131
- ## quick 阶段
132
-
133
- quick 当前不创建 worktree
134
-
135
- `quick.js` 2 步明确写的是“直接在主工作区实现任务”。`worktree-guard.js` stage 为 `quick` 时,对 Write/Edit/MultiEdit 直接放行;Bash 仅拦截危险命令。quick 作为辅助阶段完成后,`run.js` 会重置 quick 步骤并清空 `currentStage`,从而删除 gate 状态。
136
-
137
- 因此旧文档中“quick 创建 worktree/meta.json”的描述不符合当前代码。
138
-
139
- ## Hook 门禁
140
-
141
- 入口:`src/hooks/claude-pre-tool-use.cjs`
142
-
143
- 输入:Claude Code PreToolUse hook JSON。它只映射这些工具:
144
-
145
- - `Write`
146
- - `Edit`
147
- - `MultiEdit`
148
- - `Bash`
149
-
150
- 实际判断:`src/hooks/worktree-guard.js`
151
-
152
- ### 文件白名单
153
-
154
- 以下写入直接放行:
155
-
156
- - 路径中包含 `.sillyspec`,但 `.sillyspec/.runtime/worktrees/` 例外
157
- - 路径中包含 `.git`
158
- - 扩展名为 `.md`
159
- - 文件名为 `package.json`、`tsconfig.json`、`local.yaml`、`local.yml`
160
-
161
- `.sillyspec/.runtime/worktrees/` 下的写入不会仅因路径包含 `.sillyspec` 而放行;它必须命中当前 gate 中 active change 对应的 `meta.json.worktreePath`。
162
-
163
- ### 阶段门禁
164
-
165
- 阶段读取顺序:
166
-
167
- 1. `.sillyspec/.runtime/gate-status.json`
168
- 2. `sqlite3` CLI 查询 `.sillyspec/.runtime/sillyspec.db`
169
-
170
- 只有 `execute` 和 `quick` 被视为允许源码写入的阶段。
171
-
172
- ### execute 写入
173
-
174
- execute 阶段的源码写入必须位于已登记 worktree 内:
175
-
176
- 1. hook 读取 `.sillyspec/.runtime/gate-status.json` 或 SQLite,得到当前 active changes。
177
- 2. 对每个 active change 读取 `.sillyspec/.runtime/worktrees/<change>/meta.json`。
178
- 3. 只有目标路径位于 `meta.json.worktreePath` 内时才允许写入。
179
-
180
- 这意味着随便构造一个包含 `.sillyspec/.runtime/worktrees/` 字符串的路径不会被放行。主工作区写源码仍会被拦截。
181
-
182
- ### quick 写入
183
-
184
- quick 阶段写文件直接放行,不要求 worktree。
185
-
186
- ### Bash 命令
187
-
188
- - 已登记 worktree cwd:全部 Bash 放行。
189
- - 非 execute/quick:只读白名单放行。
190
- - quick:危险黑名单拦截,其余放行。
191
- - execute 主工作区:危险黑名单拦截;只读白名单放行;其他不确定命令当前放行。
192
-
193
- `worktree-guard.js` 的本地扩展白名单优先读取 `.sillyspec/local.yaml` / `.sillyspec/local.yml`,并兼容项目根 `local.yaml` / `local.yml`。
1
+ ---
2
+ author: qinyi
3
+ created_at: 2026-06-04 16:25:42
4
+ updated_at: 2026-06-28
5
+ ---
6
+
7
+ # Worktree 与 Hook 门禁
8
+
9
+ ## 命令入口
10
+
11
+ `src/index.js` 暴露:
12
+
13
+ ```text
14
+ sillyspec worktree create <change-name> [--base <branch>]
15
+ sillyspec worktree apply <change-name> [--check-only]
16
+ sillyspec worktree list
17
+ sillyspec worktree cleanup <change-name>
18
+ ```
19
+
20
+ 实现分别调用:
21
+
22
+ - `WorktreeManager.create()`
23
+ - `applyWorktree()`
24
+ - `WorktreeManager.list()`
25
+ - `WorktreeManager.cleanup()`
26
+
27
+ ## `create`
28
+
29
+ 默认路径:
30
+
31
+ ```text
32
+ .sillyspec/.runtime/worktrees/<change-name>/
33
+ ```
34
+
35
+ 默认分支:
36
+
37
+ ```text
38
+ sillyspec/<change-name>
39
+ ```
40
+
41
+ 关键校验与分支:
42
+
43
+ 1. `changeName` 不能为空,不能包含 `..`、`/`、`\`。
44
+ 2. 如果当前目录是 git submodule,直接报错。
45
+ 3. 如果当前目录已经是 linked worktree,创建 `native-worktree` meta,复用当前目录。
46
+ 4. 普通主工作区必须先确认 `.sillyspec/.runtime/worktrees` `.gitignore` 忽略,否则报错。
47
+ 5. 如果 worktree 目录存在但没有 `meta.json`,视为幽灵目录并自动删除。
48
+ 6. 如果目标 branch 已存在,报错。
49
+ 7. 默认 base 是当前 `HEAD`;传 `--base` 时使用指定 ref。
50
+ 8. `git worktree add` 失败时:
51
+ - 如果 git 版本低于 2.15 或不可用,报错。
52
+ - 其他失败降级为 `in-place-fallback`,在主工作区记录 meta。
53
+ 9. 创建普通 worktree 后,会 best-effort `fetch origin` 并尝试 fast-forward 到默认远端分支。
54
+ 10. 主工作区已有 staged/unstaged/untracked 变更时,会 overlay 到 worktree,并创建 baseline checkpoint commit。
55
+ 11. **依赖供给**(change `2026-06-28-worktree-deps-provision`):baseline overlay 后调用 `provisionDeps(worktreePath, mainCwd)`(`src/worktree-deps.js`)——lockfile 一致时 junction/symlink 主 checkout 的 `node_modules`(瞬时零网络),否则按 `local.yaml` 的 `project.type` + lockfile 推断并执行 install。结果写入 meta(`depsStatus` 等字段)。**供给失败不阻断 create**,只记 `depsStatus=failed`,交由 execute 验证硬门阻断。
56
+
57
+ ## `meta.json`
58
+
59
+ 普通 worktree 的 `meta.json` 位于 worktree 目录内:
60
+
61
+ ```text
62
+ .sillyspec/.runtime/worktrees/<change>/meta.json
63
+ ```
64
+
65
+ `native-worktree` 和 `in-place-fallback` 下,meta 仍写到 `.sillyspec/.runtime/worktrees/<change>/meta.json`,其中 `worktreePath` 可能指向当前工作目录。
66
+
67
+ 主要字段:
68
+
69
+ | 字段 | 说明 |
70
+ |---|---|
71
+ | `changeName` | 变更名 |
72
+ | `branch` | worktree 分支 |
73
+ | `baseBranch` | 基准分支或 ref |
74
+ | `baseHash` | 创建时基准 commit |
75
+ | `actualBaseHash` | worktree 当前 HEAD |
76
+ | `createdAt` | 创建时间 |
77
+ | `worktreePath` | 实际执行目录 |
78
+ | `mode` | `worktree` / `native-worktree` / `in-place-fallback` |
79
+ | `baselineFiles` | 从主工作区 overlay 的未提交文件 |
80
+ | `baselineCommit` | baseline checkpoint commit |
81
+ | `baselineHash` | execute 前主工作区 dirty baseline hash |
82
+ | `depsStatus` | 依赖供给状态:`linked` / `installed` / `n/a` / `failed` / `missing` / `stale`(provisionDeps 写入) |
83
+ | `depsMethod` | 供给机制:`junction` / `symlink` / `install` / `null` |
84
+ | `depsSource` | 依赖来源:`main-checkout` / `install` / `null` |
85
+ | `depsLockHash` | 供给时 lockfile/package.json 的 sha256 前 16 位 |
86
+ | `depsCheckedAt` | 上次供给时间(ISO8601) |
87
+ | `depsError` | `depsStatus=failed` 时填,install/junction 失败信息 |
88
+
89
+ ## `apply`
90
+
91
+ `applyWorktree(changeName, { checkOnly })` 的真实流程:
92
+
93
+ 1. 读取 `meta.json`。
94
+ 2. diff base 使用 `baselineCommit || baseHash`。
95
+ 3. 收集 tracked diff 和 untracked 新文件。
96
+ 4. `.sillyspec/changes/<change>/design.md` 解析“文件变更清单”作为 allow list。
97
+ 5. 如果 allow list 非空,要求 changed files 都在清单内。
98
+ 6. 如果 meta 有 `baselineHash`,重新计算主工作区 dirty hash;不同则拒绝 apply。
99
+ 7. 检查主工作区和 apply 文件有无未提交冲突。
100
+ 8. 比较主工作区 `HEAD` 与 worktree `baseHash` 的目标文件 blob。
101
+ 9. `--check-only` 到这里返回。
102
+ 10. 生成临时 patch。
103
+ 11. 在主工作区执行 `git apply --check`。
104
+ 12. 执行 `git apply --3way`。
105
+ 13. 成功后自动调用 `WorktreeManager.cleanup()`。
106
+
107
+ 无变更时,如果不是 check-only,也会 cleanup。
108
+
109
+ ## `cleanup`
110
+
111
+ `cleanup(changeName, { force })`:
112
+
113
+ | mode | 非 force 行为 |
114
+ |---|---|
115
+ | `worktree` | 尝试 `git worktree remove --force`,删除目录,删除分支,删除 meta 目录 |
116
+ | `native-worktree` | 抛错,避免删除用户自己的 worktree |
117
+ | `in-place-fallback` | 返回 `skipped` |
118
+ | 无 meta 且目录不存在 | 返回 `skipped` |
119
+
120
+ 如果 `git worktree remove` 失败但目录可删,结果是 `force-cleaned`。
121
+
122
+ ## execute 阶段
123
+
124
+ `execute.js` 的固定前缀第 3 步是“创建 worktree”,prompt 要求运行:
125
+
126
+ ```text
127
+ sillyspec worktree create <change-name>
128
+ ```
129
+
130
+ 后续 Wave prompt 要求把子代理 cwd 设置为 worktree 路径。完成确认 step 根据 mode 分别处理:
131
+
132
+ - `worktree`:check-only,用户确认后 apply,再 cleanup。
133
+ - `native-worktree`:可以 apply,但不要 cleanup
134
+ - `in-place-fallback`:跳过 apply/cleanup。
135
+ - worktree:只展示 diff 摘要。
136
+
137
+ 注意:`buildExecuteSteps()` `noWorktree` 参数,但当前 `runCommand()` 没有解析 `--no-worktree` flag,CLI help 也没有列出该 flag。文档不要把 `--no-worktree` 写成已接通的公开流程。
138
+
139
+ ### execute 依赖验证硬门(change `2026-06-28-worktree-deps-provision`)
140
+
141
+ `run.js completeStep` 在 execute 分支标记 step done **之前**调用 `enforceDepsGate()`:
142
+
143
+ 1. `meta.depsStatus`:∈ `{linked, installed, n/a}` 放行。
144
+ 2. 否则判断 wave 级 opt-out(`isCurrentWaveAllNoDepsVerify`):仅当前 wave(如 `Wave 2 执行`)内**全部** task 的 `tasks/task-NN.md` frontmatter `no_deps_verify: true` 才跳门。非 wave 步骤(确认执行范围/acceptance/suffix)恒过门。
145
+ 3. 不达标 → step 置 `blocked` + `process.exit(1)` 拒绝 `--done`,提示 `sillyspec worktree doctor --fix` 或手动 install。
146
+
147
+ execute **入口自检**:已存在 worktree(`create()` short-circuit 不供给)时,入口校验 `depsStatus` 缺失 / `node_modules` 丢失(missing)/ `lockfileHash` 变化(stale)→ 触发 `provisionDeps` 重供给并更新 meta,再交门判定。
148
+
149
+ ## quick 阶段
150
+
151
+ quick 当前不创建 worktree。
152
+
153
+ `quick.js` 第 2 步明确写的是“直接在主工作区实现任务”。`worktree-guard.js` 在 stage 为 `quick` 时,对 Write/Edit/MultiEdit 直接放行;Bash 仅拦截危险命令。quick 作为辅助阶段完成后,`run.js` 会重置 quick 步骤并清空 `currentStage`,从而删除 gate 状态。
154
+
155
+ 因此旧文档中“quick 创建 worktree/meta.json”的描述不符合当前代码。
156
+
157
+ ## Hook 门禁
158
+
159
+ 入口:`src/hooks/claude-pre-tool-use.cjs`
160
+
161
+ 输入:Claude Code PreToolUse hook JSON。它只映射这些工具:
162
+
163
+ - `Write`
164
+ - `Edit`
165
+ - `MultiEdit`
166
+ - `Bash`
167
+
168
+ 实际判断:`src/hooks/worktree-guard.js`
169
+
170
+ ### 文件白名单
171
+
172
+ 以下写入直接放行:
173
+
174
+ - 路径中包含 `.sillyspec`,但 `.sillyspec/.runtime/worktrees/` 例外
175
+ - 路径中包含 `.git`
176
+ - 扩展名为 `.md`
177
+ - 文件名为 `package.json`、`tsconfig.json`、`local.yaml`、`local.yml`
178
+
179
+ `.sillyspec/.runtime/worktrees/` 下的写入不会仅因路径包含 `.sillyspec` 而放行;它必须命中当前 gate 中 active change 对应的 `meta.json.worktreePath`。
180
+
181
+ ### 阶段门禁
182
+
183
+ 阶段读取顺序:
184
+
185
+ 1. `.sillyspec/.runtime/gate-status.json`
186
+ 2. `sqlite3` CLI 查询 `.sillyspec/.runtime/sillyspec.db`
187
+
188
+ 只有 `execute` `quick` 被视为允许源码写入的阶段。
189
+
190
+ ### execute 写入
191
+
192
+ execute 阶段的源码写入必须位于已登记 worktree 内:
193
+
194
+ 1. hook 读取 `.sillyspec/.runtime/gate-status.json` 或 SQLite,得到当前 active changes。
195
+ 2. 对每个 active change 读取 `.sillyspec/.runtime/worktrees/<change>/meta.json`。
196
+ 3. 只有目标路径位于 `meta.json.worktreePath` 内时才允许写入。
197
+
198
+ 这意味着随便构造一个包含 `.sillyspec/.runtime/worktrees/` 字符串的路径不会被放行。主工作区写源码仍会被拦截。
199
+
200
+ ### quick 写入
201
+
202
+ quick 阶段写文件直接放行,不要求 worktree。
203
+
204
+ ### Bash 命令
205
+
206
+ - 已登记 worktree 内 cwd:全部 Bash 放行。
207
+ - 非 execute/quick:只读白名单放行。
208
+ - quick:危险黑名单拦截,其余放行。
209
+ - execute 主工作区:危险黑名单拦截;只读白名单放行;其他不确定命令当前放行。
210
+
211
+ `worktree-guard.js` 的本地扩展白名单优先读取 `.sillyspec/local.yaml` / `.sillyspec/local.yml`,并兼容项目根 `local.yaml` / `local.yml`。