sillyspec 3.20.2 → 3.20.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/.claude/skills/sillyspec-archive/SKILL.md +1 -5
- package/.claude/skills/sillyspec-auto/SKILL.md +2 -8
- package/.claude/skills/sillyspec-brainstorm/SKILL.md +1 -28
- package/.claude/skills/sillyspec-commit/SKILL.md +3 -4
- package/.claude/skills/sillyspec-continue/SKILL.md +4 -5
- package/.claude/skills/sillyspec-doctor/SKILL.md +3 -12
- package/.claude/skills/sillyspec-execute/SKILL.md +2 -15
- package/.claude/skills/sillyspec-explore/SKILL.md +1 -14
- package/.claude/skills/sillyspec-plan/SKILL.md +36 -5
- package/.claude/skills/sillyspec-propose/SKILL.md +0 -4
- package/.claude/skills/sillyspec-quick/SKILL.md +1 -5
- package/.claude/skills/sillyspec-resume/SKILL.md +66 -23
- package/.claude/skills/sillyspec-scan/SKILL.md +1 -5
- package/.claude/skills/sillyspec-state/SKILL.md +8 -8
- package/.claude/skills/sillyspec-status/SKILL.md +1 -5
- package/.claude/skills/sillyspec-verify/SKILL.md +1 -5
- package/.claude/skills/sillyspec-workspace/SKILL.md +3 -11
- package/.sillyspec/changes/archive/2026-04-08-derive-state/design.md +97 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/plan.md +51 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/proposal.md +29 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/requirements.md +34 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/tasks.md +13 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/verify-result.md +43 -0
- package/.sillyspec/changes/auto-mode/design.md +50 -0
- package/.sillyspec/changes/auto-mode/proposal.md +19 -0
- package/.sillyspec/changes/auto-mode/requirements.md +21 -0
- package/.sillyspec/changes/auto-mode/tasks.md +7 -0
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-dashboard-design.md +206 -0
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-unified-docs-design.md +199 -0
- package/.sillyspec/changes/dashboard/design.md +219 -0
- package/.sillyspec/changes/dashboard/design.md.braindraft +206 -0
- package/.sillyspec/changes/run-command-design/design.md +1230 -0
- package/.sillyspec/changes/unified-docs-design/design.md +199 -0
- package/.sillyspec/docs/sillyspec/scan/.gitkeep +0 -0
- package/.sillyspec/knowledge/INDEX.md +8 -0
- package/.sillyspec/knowledge/uncategorized.md +3 -0
- package/.sillyspec/plans/2026-04-05-dashboard.md +737 -0
- package/.sillyspec/projects/sillyspec.yaml +3 -0
- package/README.md +11 -13
- package/SKILL.md +40 -44
- package/dist/steps/brainstorm/01-load-context.md +30 -0
- package/dist/steps/brainstorm/02-reuse-check.md +6 -0
- package/dist/steps/brainstorm/03-prototype-analysis.md +11 -0
- package/dist/steps/brainstorm/04-module-split.md +23 -0
- package/dist/steps/brainstorm/05-dialog-explore.md +8 -0
- package/dist/steps/brainstorm/06-propose-approaches.md +3 -0
- package/dist/steps/brainstorm/07-present-design.md +3 -0
- package/dist/steps/brainstorm/08-write-design.md +21 -0
- package/dist/steps/brainstorm/09-self-review.md +15 -0
- package/dist/steps/brainstorm/10-user-confirm.md +3 -0
- package/dist/steps/brainstorm/11-output-spec.md +7 -0
- package/dist/steps/brainstorm/manifest.yaml +26 -0
- package/dist/steps/execute/01-load-context.md +41 -0
- package/dist/steps/execute/02-scan-conventions.md +47 -0
- package/dist/steps/execute/03-skill-mcp.md +19 -0
- package/dist/steps/execute/04-assign-task.md +22 -0
- package/dist/steps/execute/04b-prompt-template.md +54 -0
- package/dist/steps/execute/05-write-test.md +7 -0
- package/dist/steps/execute/06-write-code.md +8 -0
- package/dist/steps/execute/07-run-test.md +26 -0
- package/dist/steps/execute/08-fix-issues.md +28 -0
- package/dist/steps/execute/09-next-task.md +33 -0
- package/dist/steps/execute/manifest.yaml +28 -0
- package/dist/steps/plan/01-load-context.md +22 -0
- package/dist/steps/plan/02-anchor-confirm.md +1 -0
- package/dist/steps/plan/03-expand-tasks.md +33 -0
- package/dist/steps/plan/04-mark-order.md +15 -0
- package/dist/steps/plan/05-e2e-planning.md +17 -0
- package/dist/steps/plan/06-self-check.md +16 -0
- package/dist/steps/plan/07-save.md +1 -0
- package/dist/steps/plan/manifest.yaml +18 -0
- package/dist/steps/scan/01-env-detect.md +51 -0
- package/dist/steps/scan/02-tech-stack.md +16 -0
- package/dist/steps/scan/03-conventions.md +16 -0
- package/dist/steps/scan/04-structure.md +19 -0
- package/dist/steps/scan/05-quality.md +18 -0
- package/dist/steps/scan/06-complete.md +49 -0
- package/dist/steps/scan/manifest.yaml +16 -0
- package/dist/steps/verify/01-load-specs.md +28 -0
- package/dist/steps/verify/02-check-tasks.md +1 -0
- package/dist/steps/verify/03-check-design.md +6 -0
- package/dist/steps/verify/04-run-tests.md +7 -0
- package/dist/steps/verify/05-e2e-tests.md +27 -0
- package/dist/steps/verify/05b-e2e-fix.md +33 -0
- package/dist/steps/verify/06-code-quality.md +25 -0
- package/dist/steps/verify/07-lint-check.md +27 -0
- package/dist/steps/verify/08-output-report.md +14 -0
- package/dist/steps/verify/manifest.yaml +22 -0
- package/package.json +1 -7
- package/packages/dashboard/dist/assets/{index-Bq_Z2hne.js → index-D1EVTLmc.js} +1264 -1264
- package/packages/dashboard/dist/assets/index-DGe8CqeP.css +1 -0
- package/packages/dashboard/dist/index.html +2 -2
- package/packages/dashboard/package-lock.json +6 -6
- package/packages/dashboard/server/executor.js +1 -1
- package/packages/dashboard/server/index.js +18 -98
- package/packages/dashboard/server/parser.js +71 -139
- package/packages/dashboard/server/watcher.js +6 -14
- package/packages/dashboard/src/App.vue +185 -418
- package/packages/dashboard/src/components/ActionBar.vue +1 -10
- package/packages/dashboard/src/components/CommandPalette.vue +1 -5
- package/packages/dashboard/src/components/DocPreview.vue +8 -105
- package/packages/dashboard/src/components/DocTree.vue +19 -75
- package/packages/dashboard/src/components/PipelineStage.vue +2 -22
- package/packages/dashboard/src/components/PipelineView.vue +5 -32
- package/packages/dashboard/src/components/ProjectOverview.vue +139 -113
- package/packages/dashboard/src/components/StageBadge.vue +3 -17
- package/packages/dashboard/src/components/StepCard.vue +2 -7
- package/packages/dashboard/src/composables/useDashboard.js +0 -28
- package/src/derive.js +147 -0
- package/src/index.js +40 -688
- package/src/init.js +63 -119
- package/src/migrate.js +7 -7
- package/src/progress.js +248 -1474
- package/src/run.js +302 -3008
- package/src/setup.js +64 -2
- package/src/stages/archive.js +17 -123
- package/src/stages/brainstorm.js +48 -454
- package/src/stages/doctor.js +46 -99
- package/src/stages/execute.js +59 -420
- package/src/stages/index.js +18 -12
- package/src/stages/plan.js +189 -492
- package/src/stages/propose.js +11 -70
- package/src/stages/quick.js +13 -52
- package/src/stages/scan.js +68 -485
- package/src/stages/status.js +1 -1
- package/src/stages/verify.js +16 -203
- package/src/step.js +543 -0
- package/.claude/skills/sillyspec-knowledge/SKILL.md +0 -270
- package/.husky/pre-push +0 -13
- package/CLAUDE.md +0 -18
- package/docs/brainstorm-plan-contract.md +0 -64
- package/docs/plan-execute-contract.md +0 -123
- package/docs/platform-scan-protocol.md +0 -298
- package/docs/revision-mode.md +0 -115
- package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +0 -99
- package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +0 -218
- package/docs/sillyspec/file-lifecycle/stage-artifacts.md +0 -167
- package/docs/sillyspec/file-lifecycle/storage-and-state.md +0 -148
- package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +0 -193
- package/docs/sillyspec/file-lifecycle.md +0 -125
- package/docs/workflow-contract-regression.md +0 -106
- package/docs/worktree-isolation.md +0 -252
- package/packages/dashboard/dist/assets/index-O2W5RV4z.css +0 -1
- package/packages/dashboard/dist/prototype-dashboard.html +0 -836
- package/packages/dashboard/dist/prototype-overview.html +0 -256
- package/packages/dashboard/public/prototype-dashboard.html +0 -836
- package/packages/dashboard/public/prototype-overview.html +0 -256
- package/packages/dashboard/src/components/HResizeHandle.vue +0 -48
- package/packages/dashboard/src/components/ProjectCard.vue +0 -187
- package/packages/dashboard/src/components/VResizeHandle.vue +0 -61
- package/packages/dashboard/src/composables/useLayout.js +0 -131
- package/src/brainstorm-postcheck.js +0 -158
- package/src/change-list.js +0 -52
- package/src/change-risk-profile.js +0 -352
- package/src/classify-change.js +0 -73
- package/src/constants.js +0 -70
- package/src/contract-matrix.js +0 -278
- package/src/db.js +0 -201
- package/src/endpoint-extractor.js +0 -315
- package/src/hooks/claude-pre-tool-use.cjs +0 -125
- package/src/hooks/worktree-guard.js +0 -761
- package/src/knowledge-match.js +0 -130
- package/src/modules.js +0 -482
- package/src/scan-postcheck.js +0 -383
- package/src/stage-contract.js +0 -700
- package/src/stages/brainstorm-auto.js +0 -229
- package/src/stages/explore.js +0 -34
- package/src/stages/knowledge.js +0 -498
- package/src/stages/plan-postcheck.js +0 -513
- package/src/sync.js +0 -497
- package/src/task-review.js +0 -346
- package/src/workflow.js +0 -785
- package/src/worktree-apply.js +0 -549
- package/src/worktree.js +0 -932
- package/templates/workflows/archive-impact.yaml +0 -79
- package/templates/workflows/scan-docs.yaml +0 -132
- package/test/brainstorm-plan-contract.test.mjs +0 -273
- package/test/check-syntax.mjs +0 -26
- package/test/cli-top-level-aliases.test.mjs +0 -174
- package/test/contract-artifacts.test.mjs +0 -323
- package/test/decision-supersede.test.mjs +0 -277
- package/test/knowledge-match.test.mjs +0 -231
- package/test/plan-execute-contract.test.mjs +0 -330
- package/test/plan-optimization.test.mjs +0 -572
- package/test/platform-artifacts.test.mjs +0 -190
- package/test/platform-failure-samples.test.mjs +0 -199
- package/test/platform-recovery-chain.test.mjs +0 -179
- package/test/platform-recovery.test.mjs +0 -167
- package/test/platform-scan-p0.test.mjs +0 -175
- package/test/revision-v1.test.mjs +0 -1145
- package/test/run-sanitize-project-name.test.mjs +0 -51
- package/test/run-scan-postcheck-fail.test.mjs +0 -64
- package/test/run-scan-project-parse.test.mjs +0 -200
- package/test/run-tests.mjs +0 -48
- package/test/scan-docs-yaml-placeholders.test.mjs +0 -84
- package/test/scan-knowledge.test.mjs +0 -175
- package/test/scan-paths.test.mjs +0 -68
- package/test/scan-postcheck-project-priority.test.mjs +0 -85
- package/test/scan-postcheck.test.mjs +0 -197
- package/test/scan-workflow-anyfailed-block.test.mjs +0 -52
- package/test/spec-dir.test.mjs +0 -206
- package/test/stage-contract-failed-post-check.test.mjs +0 -102
- package/test/stage-contract.test.mjs +0 -299
- package/test/stage-definitions.test.mjs +0 -39
- package/test/wait-gates.test.mjs +0 -501
- package/test/workflow-spec-base.test.mjs +0 -142
- package/test/worktree-guard.test.mjs +0 -136
- package/test/worktree-native-overlay.test.mjs +0 -188
|
@@ -1,193 +0,0 @@
|
|
|
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,125 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
author: qinyi
|
|
3
|
-
created_at: 2026-05-31 11:00:00
|
|
4
|
-
updated_at: 2026-06-19 15:00:00
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# SillySpec 文件生命周期
|
|
8
|
-
|
|
9
|
-
> 本文档按当前代码重写。它描述的是仓库里已经实现或运行时会暴露的行为,不描述期望设计。
|
|
10
|
-
|
|
11
|
-
## 文档拆分
|
|
12
|
-
|
|
13
|
-
| 文件 | 说明 |
|
|
14
|
-
|---|---|
|
|
15
|
-
| [storage-and-state.md](file-lifecycle/storage-and-state.md) | `.sillyspec/.runtime/`、SQLite、gate、artifact、history、local 配置口径 |
|
|
16
|
-
| [stage-artifacts.md](file-lifecycle/stage-artifacts.md) | 各阶段的运行时步骤、变更目录产物、归档和 quicklog |
|
|
17
|
-
| [worktree-and-guard.md](file-lifecycle/worktree-and-guard.md) | `sillyspec worktree`、`meta.json`、apply、cleanup、Claude hook 门禁 |
|
|
18
|
-
| [platform-workflows-sync.md](file-lifecycle/platform-workflows-sync.md) | 平台模式、workflow check、manifest、SillyHub sync |
|
|
19
|
-
| [known-implementation-gaps.md](file-lifecycle/known-implementation-gaps.md) | 当前代码与提示文案/旧文档不一致的地方 |
|
|
20
|
-
|
|
21
|
-
## 代码依据
|
|
22
|
-
|
|
23
|
-
本组文档主要对照以下实现:
|
|
24
|
-
|
|
25
|
-
- `src/init.js`
|
|
26
|
-
- `src/db.js`
|
|
27
|
-
- `src/scan-postcheck.js`
|
|
28
|
-
- `src/knowledge-match.js`
|
|
29
|
-
- `src/progress.js`
|
|
30
|
-
- `src/run.js`
|
|
31
|
-
- `src/stages/*.js`
|
|
32
|
-
- `src/worktree.js`
|
|
33
|
-
- `src/worktree-apply.js`
|
|
34
|
-
- `src/hooks/worktree-guard.js`
|
|
35
|
-
- `src/workflow.js`
|
|
36
|
-
- `src/sync.js`
|
|
37
|
-
- `src/modules.js`
|
|
38
|
-
- `src/index.js`
|
|
39
|
-
|
|
40
|
-
运行时阶段列表以导入 `src/stages/index.js` 后得到的对象为准。当前导入结果:
|
|
41
|
-
|
|
42
|
-
| 阶段 | 当前步骤数 | 备注 |
|
|
43
|
-
|---|---:|---|
|
|
44
|
-
| scan | 11 | 辅助阶段;step 2 后会按项目动态展开 `perProject` 步骤;第 10 步「Extract Project Knowledge」写入 `knowledge/` |
|
|
45
|
-
| brainstorm | 11 | 独立包含“写设计文档并自审”和“用户确认并生成规范文件” |
|
|
46
|
-
| propose | 7 | 包含“生成规范文件”与“自检门控”,四件套是该阶段预期产物 |
|
|
47
|
-
| plan | 动态 | 默认 8 步;`plan.md` 解析到任务后插入任务蓝图协调器 |
|
|
48
|
-
| execute | 动态 | 默认 12 步;Wave 来自 `plan.md`,解析失败时默认 3 个 Wave |
|
|
49
|
-
| verify | 7 | 只读校验 + 写 `verify-result.md` |
|
|
50
|
-
| archive | 5 | 辅助阶段;第 4 步必须带 `--confirm`,由 `run.js` 移动目录并注销 active change |
|
|
51
|
-
| quick | 3 | 辅助阶段;直接在主工作区实现,不创建 worktree |
|
|
52
|
-
| explore | 1 | 只读探索 |
|
|
53
|
-
| status | 3 | 状态展示 |
|
|
54
|
-
| doctor | 5 | 环境和项目自检 |
|
|
55
|
-
|
|
56
|
-
## 顶层目录口径
|
|
57
|
-
|
|
58
|
-
当前 `sillyspec init` 会创建或维护以下目录:
|
|
59
|
-
|
|
60
|
-
| 路径 | tracked | 创建/维护方 | 当前生命周期 |
|
|
61
|
-
|---|---|---|---|
|
|
62
|
-
| `.sillyspec/projects/` | 是 | `init.js`、scan prompt 人工确认后 | 项目注册表,`*.yaml` 描述项目名、路径、状态 |
|
|
63
|
-
| `.sillyspec/docs/<project>/scan/` | 是 | `init.js` 建目录;scan 阶段生成文档 | 代码扫描产物,workflow `scan-docs` 会检查 |
|
|
64
|
-
| `.sillyspec/docs/<project>/modules/` | 是 | scan 可选步骤、archive sync、`modules` 子命令 | 模块索引和模块卡片 |
|
|
65
|
-
| `.sillyspec/changes/<change>/` | 是 | `ProgressManager.initChange()` 确保目录;阶段 prompt 写入 | 单个变更包文档和验收产物 |
|
|
66
|
-
| `.sillyspec/changes/archive/` | 是 | archive `确认归档 --confirm` 分支 | 已归档变更目录 |
|
|
67
|
-
| `.sillyspec/knowledge/` | 是 | `init.js` 建目录;scan「Extract Project Knowledge」步骤产出 | `INDEX.md`、`uncategorized.md`,以及 scan 提取的 `conventions.md`/`patterns.md`/`known-issues.md` |
|
|
68
|
-
| `.sillyspec/workflows/` | 是 | `init.js` 从模板复制 | workflow check 定义 |
|
|
69
|
-
| `.sillyspec/quicklog/` | 是 | quick prompt | 无 `--change` quick 任务记录 |
|
|
70
|
-
| `.sillyspec/shared/` | 是 | `init.js` | 共享目录,当前无核心生命周期逻辑 |
|
|
71
|
-
| `.sillyspec/workspace/` | 是 | `init.js` | 工作区目录,当前无核心生命周期逻辑 |
|
|
72
|
-
| `.sillyspec/.runtime/` | 否 | `init.js`、`ProgressManager`、运行时命令 | DB、gate、artifacts、history、workflow-runs、worktrees、knowledge-hit-report.json、postcheck-result.json |
|
|
73
|
-
|
|
74
|
-
`init.js` 会把 `.sillyspec/.runtime/`、`.sillyspec/local.yaml`、`.sillyspec/codebase/SCAN-RAW.md` 追加到 `.gitignore`。
|
|
75
|
-
|
|
76
|
-
## 主要文件流
|
|
77
|
-
|
|
78
|
-
```text
|
|
79
|
-
sillyspec init
|
|
80
|
-
-> .sillyspec/projects/<project>.yaml
|
|
81
|
-
-> .sillyspec/docs/<project>/scan/.gitkeep
|
|
82
|
-
-> .sillyspec/workflows/*.yaml
|
|
83
|
-
-> .sillyspec/knowledge/{INDEX.md,uncategorized.md}
|
|
84
|
-
-> .sillyspec/.runtime/{sillyspec.db,user-inputs.md,artifacts,history,logs,templates}
|
|
85
|
-
|
|
86
|
-
sillyspec run scan
|
|
87
|
-
-> .sillyspec/docs/<project>/scan/*.md
|
|
88
|
-
-> .sillyspec/docs/<project>/modules/_module-map.yaml (optional prompt)
|
|
89
|
-
-> .sillyspec/docs/<project>/modules/<module>.md (optional prompt)
|
|
90
|
-
-> .sillyspec/knowledge/{conventions,patterns,known-issues}.md (Extract Project Knowledge)
|
|
91
|
-
-> .sillyspec/knowledge/INDEX.md (索引更新)
|
|
92
|
-
-> .sillyspec/.runtime/scan-projects.json (step expansion state)
|
|
93
|
-
-> .sillyspec/.runtime/postcheck-result.json (scan-postcheck 结构化结果)
|
|
94
|
-
|
|
95
|
-
brainstorm / propose / plan / execute / verify / archive
|
|
96
|
-
-> .sillyspec/changes/<change>/...
|
|
97
|
-
-> .sillyspec/.runtime/sillyspec.db
|
|
98
|
-
-> .sillyspec/.runtime/user-inputs.md
|
|
99
|
-
-> .sillyspec/.runtime/artifacts/*.txt (long step output)
|
|
100
|
-
|
|
101
|
-
execute
|
|
102
|
-
-> .sillyspec/.runtime/worktrees/<change>/meta.json
|
|
103
|
-
-> .sillyspec/.runtime/knowledge-hit-report.json (启动时按 taskContext 匹配 knowledge)
|
|
104
|
-
-> worktree branch sillyspec/<change>
|
|
105
|
-
-> apply patch back to main workspace, then cleanup
|
|
106
|
-
|
|
107
|
-
quick
|
|
108
|
-
-> .sillyspec/quicklog/QUICKLOG-<git-user>.md (without --change)
|
|
109
|
-
-> or append checkbox to .sillyspec/changes/<change>/tasks.md
|
|
110
|
-
-> code changes are made in the main workspace
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## 核心修正
|
|
114
|
-
|
|
115
|
-
这版文档相对旧版长文档做了几项关键修正:
|
|
116
|
-
|
|
117
|
-
- `quick` 不走 worktree 生命周期。hook 在 quick 阶段对写文件放行,只拦截危险 Bash 命令。
|
|
118
|
-
- `scan` 当前定义是 10 步,并且 step 2 后会动态展开项目级步骤,不是固定 12 步。
|
|
119
|
-
- `brainstorm` 和 `propose` 的重复 object key 已拆成独立步骤,运行时步骤数分别是 11 和 7。
|
|
120
|
-
- `.sillyspec/local.yaml` 是当前主配置口径;scan prompt 写这里,sync 读写这里,hook 优先读这里并兼容根目录 fallback。
|
|
121
|
-
- 平台模式的 `manifest.json` 已接入 scan 完成回调;`workflow-runs` 的 runtimeRoot 路径支持在 `workflow.js` 中存在,但 `run.js` 当前调用没有传入 `runtimeRoot`。
|
|
122
|
-
- `archive` 的目录移动已经由 `run.js` 在第 4 步 `--confirm` 时执行;未带 `--confirm` 会回退该步骤并提示补参。
|
|
123
|
-
- scan 第 10 步「Extract Project Knowledge」把长期有效的项目知识写入 `.sillyspec/knowledge/`(`conventions.md`/`patterns.md`/`known-issues.md` + 更新 `INDEX.md`);`scan-postcheck.js` 校验产物(INDEX.md 存在、引用文件真实存在)。
|
|
124
|
-
- execute 启动时由 `knowledge-match.js` 按 plan.md 的 task 关键词匹配知识库,命中报告注入 prompt 并写 `.runtime/knowledge-hit-report.json`。
|
|
125
|
-
- Revision v1:`stages` 表新增 `revision`/`reopened_from_step`/`reopened_at`/`stale_reason` 列;阶段新增 `revising`/`stale` 状态;`sillyspec run <stage> --reopen --from-step <n>` 重开已完成阶段、级联标记下游 stale;`.runtime/postcheck-result.json` 由 `scan-postcheck.js` 的 `writeStructuredResult` 落盘(本地写 `specDir/.runtime`,平台写 `runtimeRoot/scan-runs/<id>`)。
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# Workflow Contract Regression Audit
|
|
2
|
-
|
|
3
|
-
> 日期:2026-06-19
|
|
4
|
-
> 范围:16 commits (f52e670..977ad0a)
|
|
5
|
-
> 结论:**全绿,0 bug,274 个断言全部通过**
|
|
6
|
-
|
|
7
|
-
## 审计目标
|
|
8
|
-
|
|
9
|
-
确认今晚 16 个 commit 引入的 contract/revision/stale safety 改动没有误伤现有主链路。
|
|
10
|
-
|
|
11
|
-
## 审计范围
|
|
12
|
-
|
|
13
|
-
### 新增功能
|
|
14
|
-
1. **Revision v1** — 阶段重开 + 步骤级修订控制
|
|
15
|
-
2. **Revision v1.1** — 可观测性与状态自检
|
|
16
|
-
3. **Revision v1.2** — progress repair 安全修复状态元数据
|
|
17
|
-
4. **Execute stale safety v1** — 防止基于旧 plan 继续执行
|
|
18
|
-
5. **Verify/Archive stale safety** — 8 个测试固化安全链
|
|
19
|
-
6. **Plan→Execute contract v1** — 校验 + 文档 + 测试
|
|
20
|
-
7. **Plan postcheck contract v1** — plan 完成时校验 execute 契约
|
|
21
|
-
8. **Brainstorm→Plan contract v1** — design.md 输入校验
|
|
22
|
-
|
|
23
|
-
### 新增契约链
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
brainstorm → design.md → [Design Contract 校验] → plan → plan.md → [Plan Contract 校验] → execute
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
- **brainstorm → plan**: `validateDesignForPlan` — 3 error + 3 warning
|
|
30
|
-
- **plan → execute**: `validatePlanForExecute` — 5 error + 1 warning
|
|
31
|
-
- 双重校验:plan 完成时 + execute 启动时
|
|
32
|
-
|
|
33
|
-
### 新增 Stale Cascade 链
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
scan → brainstorm → plan → execute → verify → archive
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
- `checkConsistency` 基于 STAGE_ORDER 遍历上游,自动发现下游假完成
|
|
40
|
-
- `repair` cascade:execute stale → verify/archive stale → verify stale → archive stale
|
|
41
|
-
|
|
42
|
-
## 测试执行
|
|
43
|
-
|
|
44
|
-
### 命令
|
|
45
|
-
```bash
|
|
46
|
-
cd ~/Desktop/sillyspec && npm test
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 测试套件 (15 个,274 断言)
|
|
50
|
-
|
|
51
|
-
| 测试套件 | 断言数 | 状态 |
|
|
52
|
-
|---------|-------|------|
|
|
53
|
-
| brainstorm-plan-contract.test.mjs | 11 | ✅ |
|
|
54
|
-
| plan-execute-contract.test.mjs | 12 | ✅ |
|
|
55
|
-
| platform-artifacts.test.mjs | 31 | ✅ |
|
|
56
|
-
| platform-failure-samples.test.mjs | 20 | ✅ |
|
|
57
|
-
| platform-recovery-chain.test.mjs | 15 | ✅ |
|
|
58
|
-
| platform-recovery.test.mjs | 19 | ✅ |
|
|
59
|
-
| platform-scan-p0.test.mjs | 19 | ✅ |
|
|
60
|
-
| revision-v1.test.mjs | 12 | ✅ |
|
|
61
|
-
| scan-paths.test.mjs | 38 | ✅ |
|
|
62
|
-
| scan-postcheck.test.mjs | 38 | ✅ |
|
|
63
|
-
| spec-dir.test.mjs | 15 | ✅ |
|
|
64
|
-
| stage-contract.test.mjs | 19 | ✅ |
|
|
65
|
-
| stage-definitions.test.mjs | 29 | ✅ |
|
|
66
|
-
| wait-gates.test.mjs | 15 | ✅ |
|
|
67
|
-
| worktree-guard.test.mjs | (included) | ✅ |
|
|
68
|
-
|
|
69
|
-
**总计:15 套件,274 断言,0 失败。**
|
|
70
|
-
|
|
71
|
-
## 主链路验收
|
|
72
|
-
|
|
73
|
-
### 1. 完整主链路 (scan → brainstorm → plan → execute → verify)
|
|
74
|
-
- ✅ stage-contract.test.mjs 覆盖了各阶段的校验与转换
|
|
75
|
-
- ✅ stage-definitions.test.mjs 覆盖了所有阶段定义的步骤初始化
|
|
76
|
-
- ✅ 无 contract 误伤
|
|
77
|
-
|
|
78
|
-
### 2. Plan 级别验收 (none/light/full)
|
|
79
|
-
- ✅ plan-execute-contract.test.mjs 覆盖 none/light/full
|
|
80
|
-
- ✅ plan postcheck 在 plan completion path 执行
|
|
81
|
-
- ✅ execute startup 二次校验保留
|
|
82
|
-
|
|
83
|
-
### 3. Revision 链路
|
|
84
|
-
- ✅ revision-v1.test.mjs 覆盖 reopen/repair/checkConsistency
|
|
85
|
-
- ✅ verify/archive --reopen 清除旧 completed steps
|
|
86
|
-
- ✅ execute --reopen 重新解析最新 plan.md
|
|
87
|
-
- ✅ repair cascade execute → verify → archive
|
|
88
|
-
|
|
89
|
-
### 4. Progress check/repair
|
|
90
|
-
- ✅ 正常状态无误报
|
|
91
|
-
- ✅ 异常状态报告清晰(checkConsistency 输出 upstream/downstream 关系)
|
|
92
|
-
- ✅ repair 只修 progress 元数据,不改产物文件
|
|
93
|
-
|
|
94
|
-
## 发现
|
|
95
|
-
|
|
96
|
-
**0 bug。** 274 个断言全部通过,无回归。
|
|
97
|
-
|
|
98
|
-
### 设计确认
|
|
99
|
-
- checkConsistency 和 repair 基于 STAGE_ORDER 通用遍历,不针对特定 stage
|
|
100
|
-
- verify/archive 用静态 steps,不需要从文件重解析
|
|
101
|
-
- contract validator 只在阶段边界执行,不影响阶段内步骤流转
|
|
102
|
-
- repair cascade 是自然结果,不需要硬编码 stage 间关系
|
|
103
|
-
|
|
104
|
-
## 文件变更统计
|
|
105
|
-
|
|
106
|
-
16 commits, 28 files changed, +3675/-689 lines。
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
# Worktree 隔离
|
|
2
|
-
|
|
3
|
-
SillySpec 在 `execute` 和 `quick` 阶段使用 **git worktree** 隔离 AI 子代理的代码修改,确保主工作区始终干净。
|
|
4
|
-
|
|
5
|
-
## 概述
|
|
6
|
-
|
|
7
|
-
AI 子代理在执行任务时会在 worktree 中修改源码,而非直接在主工作区操作。任务完成后通过 `worktree apply` 将变更合入主工作区。这带来几个好处:
|
|
8
|
-
|
|
9
|
-
- **安全性** — 主工作区不受意外修改影响
|
|
10
|
-
- **可审计** — 变更集中在一个 diff 中,便于 review
|
|
11
|
-
- **可回退** — 不满意直接 cleanup,主工作区零影响
|
|
12
|
-
- **多 Agent 并行** — 多个子代理可以同时工作在不同的 worktree 中
|
|
13
|
-
|
|
14
|
-
### 架构示意
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
主工作区 worktree 隔离区
|
|
18
|
-
┌──────────────────────┐ ┌──────────────────────────┐
|
|
19
|
-
│ src/ │ │ .sillyspec/.runtime/ │
|
|
20
|
-
│ (hook 禁止写入) │ │ worktrees/ │
|
|
21
|
-
│ .sillyspec/ │ │ <change-name>/ │
|
|
22
|
-
│ changes/ │ │ src/ (完整副本) │
|
|
23
|
-
│ <change-name>/ │ │ node_modules/ │
|
|
24
|
-
│ design.md │ │ ... │
|
|
25
|
-
│ tasks.md │ │ │
|
|
26
|
-
│ .sillyspec/.runtime/ │ │ 分支: sillyspec/<name> │
|
|
27
|
-
│ gate-status.json │ └──────────────────────────┘
|
|
28
|
-
│ worktrees/ │ │
|
|
29
|
-
│ <change-name>/ │ │ sillyspec worktree apply
|
|
30
|
-
│ meta.json │────────────────────┘
|
|
31
|
-
└──────────────────────┘
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## 命令参考
|
|
35
|
-
|
|
36
|
-
### `sillyspec worktree create <change-name> [--base <branch>]`
|
|
37
|
-
|
|
38
|
-
创建一个隔离的 worktree。
|
|
39
|
-
|
|
40
|
-
- 基于 `--base` 分支(默认当前 HEAD)创建新分支 `sillyspec/<change-name>`
|
|
41
|
-
- worktree 目录位于 `.sillyspec/.runtime/worktrees/<change-name>/`
|
|
42
|
-
- 在目录内生成 `meta.json` 记录元数据(分支名、base hash、创建时间等)
|
|
43
|
-
- 如果 worktree 已存在则报错,提示先执行 cleanup
|
|
44
|
-
|
|
45
|
-
### `sillyspec worktree apply <change-name> [--check-only]`
|
|
46
|
-
|
|
47
|
-
将 worktree 中的变更合入主工作区。
|
|
48
|
-
|
|
49
|
-
- 读取 `meta.json` 中的 base hash,与主工作区比对
|
|
50
|
-
- 从 `design.md` 解析文件变更清单,校验变更范围
|
|
51
|
-
- `--check-only` 只输出检查结果,不实际 apply
|
|
52
|
-
- 校验通过后生成 patch 并 3-way apply 到主工作区
|
|
53
|
-
- apply 成功后自动清理 worktree
|
|
54
|
-
|
|
55
|
-
**文件变更清单解析:** 从 `.sillyspec/changes/<change-name>/design.md` 中的 `## 文件变更清单` 表格提取。
|
|
56
|
-
|
|
57
|
-
### `sillyspec worktree list`
|
|
58
|
-
|
|
59
|
-
列出所有活跃的 worktree。
|
|
60
|
-
|
|
61
|
-
输出表格包含变更名、分支名和创建时间。
|
|
62
|
-
|
|
63
|
-
### `sillyspec worktree cleanup <change-name>`
|
|
64
|
-
|
|
65
|
-
清理指定的 worktree。
|
|
66
|
-
|
|
67
|
-
- 强制移除 worktree 目录
|
|
68
|
-
- 删除 `sillyspec/<change-name>` 分支
|
|
69
|
-
- 删除 `meta.json`
|
|
70
|
-
|
|
71
|
-
> ⚠️ cleanup 会丢弃所有未 apply 的变更,请确认后再执行。
|
|
72
|
-
|
|
73
|
-
## Hook 拦截机制
|
|
74
|
-
|
|
75
|
-
SillySpec 通过 hook 在 AI 工具调用(Write/Edit/MultiEdit/Bash)前拦截非法写入。判断逻辑采用 **三重门禁**:
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
allowWrite = stageGate && locationGate && fileGate
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### 阶段门禁(stageGate)
|
|
82
|
-
|
|
83
|
-
- 读取 `.sillyspec/.runtime/gate-status.json`(由 CLI 维护)
|
|
84
|
-
- 只有 `execute` 和 `quick` 阶段允许源码写入
|
|
85
|
-
- 其他阶段(brainstorm/plan/verify/archive/explore)→ 禁止
|
|
86
|
-
- 无 `gate-status.json` → 禁止(默认安全)
|
|
87
|
-
|
|
88
|
-
### 位置门禁(locationGate)
|
|
89
|
-
|
|
90
|
-
- 目标路径必须在 `.sillyspec/.runtime/worktrees/` 下才允许源码写入
|
|
91
|
-
- 主工作区的源码目录一律禁止
|
|
92
|
-
|
|
93
|
-
### 文件门禁(fileGate)
|
|
94
|
-
|
|
95
|
-
文档类、配置类文件在所有阶段放行,不受阶段和位置限制:
|
|
96
|
-
|
|
97
|
-
- `.sillyspec/` 开头的路径
|
|
98
|
-
- `.md` 文件
|
|
99
|
-
- `package.json`、`tsconfig.json`、`local.yaml` 等配置文件
|
|
100
|
-
- `.git/` 下的文件
|
|
101
|
-
|
|
102
|
-
### Bash 命令拦截
|
|
103
|
-
|
|
104
|
-
| 类型 | 示例 |
|
|
105
|
-
|------|------|
|
|
106
|
-
| **只读放行** | `grep`、`cat`、`git diff`、`git status`、`ls`、`find`、`sillyspec worktree apply/create/list/cleanup` |
|
|
107
|
-
| **禁止** | `git add`、`git commit`、`git push`、`git checkout`、`rm -rf`、`sudo` 等 |
|
|
108
|
-
| **不确定** | 启发式判断,放行但警告 |
|
|
109
|
-
|
|
110
|
-
> 在 worktree 目录下执行 Bash 命令时全部放行,不做拦截。
|
|
111
|
-
|
|
112
|
-
## 降级方案和逃生开关
|
|
113
|
-
|
|
114
|
-
| 场景 | 处理方式 |
|
|
115
|
-
|------|---------|
|
|
116
|
-
| **git < 2.15** | 不支持 worktree,报错停止 |
|
|
117
|
-
| **`--no-worktree` 标志** | 跳过隔离创建,但 hook 仍然拦截源码写入 |
|
|
118
|
-
| **`SILLYSPEC_DISABLE_HOOKS=1`** | 紧急禁用所有 hook,全部放行 |
|
|
119
|
-
| **无 gate-status.json** | stageGate=false,默认禁止源码写入 |
|
|
120
|
-
| **worktree 创建失败** | 自动降级为 in-place + baseline protection(mode: in-place-fallback) |
|
|
121
|
-
| **已在 linked worktree** | 复用当前目录(mode: native-worktree) |
|
|
122
|
-
| **worktree 目录未 ignore** | 阻断创建,提示修复 |
|
|
123
|
-
|
|
124
|
-
> ⚠️ in-place 降级模式仍会记录 baseline(baselineFiles + baselineHash + baselineCommit),hook 拦截继续生效,不会无保护地直接写源码。
|
|
125
|
-
|
|
126
|
-
## 多 Agent 并行使用
|
|
127
|
-
|
|
128
|
-
不同的 AI 子代理可以同时创建各自的 worktree:
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
# Agent A 处理 task-01
|
|
132
|
-
sillyspec worktree create feature-auth
|
|
133
|
-
# worktree: .sillyspec/.runtime/worktrees/feature-auth/
|
|
134
|
-
|
|
135
|
-
# Agent B 处理 task-02
|
|
136
|
-
sillyspec worktree create feature-ui
|
|
137
|
-
# worktree: .sillyspec/.runtime/worktrees/feature-ui/
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
两个 Agent 在各自的 worktree 中独立工作,互不干扰。各自完成后分别 apply 合入主工作区。
|
|
141
|
-
|
|
142
|
-
> 💡 如果两个 Agent 修改了相同的文件,后 apply 的一方可能遇到冲突。建议在 `plan` 阶段通过 Wave 分组避免同一文件被多个 Agent 修改。
|
|
143
|
-
|
|
144
|
-
## 环境变量
|
|
145
|
-
|
|
146
|
-
| 变量 | 说明 |
|
|
147
|
-
|------|------|
|
|
148
|
-
| `SILLYSPEC_DISABLE_HOOKS` | 设为 `1` 时禁用所有 hook(紧急逃生) |
|
|
149
|
-
| `SILLYSPEC_WORKTREE_DIR` | 自定义 worktree 存储目录(默认 `.sillyspec/.runtime/worktrees/`) |
|
|
150
|
-
|
|
151
|
-
## 环境隔离检测
|
|
152
|
-
|
|
153
|
-
SillySpec 在创建 worktree 前会自动检测当前环境的隔离状态:
|
|
154
|
-
|
|
155
|
-
### submodule 防护
|
|
156
|
-
|
|
157
|
-
使用 `git rev-parse --git-dir` 和 `--git-common-dir` 判断是否在 linked worktree 中。
|
|
158
|
-
同时用 `--show-superproject-working-tree` 排除 git submodule 的误判:
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
if GIT_DIR != GIT_COMMON && 无 superproject:
|
|
162
|
-
→ 已在 linked worktree,复用当前隔离环境
|
|
163
|
-
if 无 superproject 为空:
|
|
164
|
-
→ 在 git submodule 内,阻断创建并提示
|
|
165
|
-
else:
|
|
166
|
-
→ 在主仓库中,正常创建 worktree
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### .gitignore 强制校验
|
|
170
|
-
|
|
171
|
-
worktree 存储目录 `.sillyspec/.runtime/worktrees/` 必须被 `.gitignore` 忽略:
|
|
172
|
-
|
|
173
|
-
- **init / doctor 阶段:** 预检查并提示修复
|
|
174
|
-
- **execute 阶段:** 未 ignore 则直接阻断 worktree 创建,抛出明确错误
|
|
175
|
-
- **不会自动修改 .gitignore:** 避免污染 baseline
|
|
176
|
-
|
|
177
|
-
修复方式:在项目 `.gitignore` 中添加:
|
|
178
|
-
```
|
|
179
|
-
.sillyspec/.runtime/worktrees/
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### isolation 状态
|
|
183
|
-
|
|
184
|
-
worktree create 后,isolation 状态写入 `sillyspec.db` 的 `changes` 表(权威状态源):
|
|
185
|
-
|
|
186
|
-
| 字段 | 说明 |
|
|
187
|
-
|------|------|
|
|
188
|
-
| `isolation_status` | pending / verified / degraded / blocked |
|
|
189
|
-
| `isolation_mode` | worktree / native-worktree / in-place-fallback / null |
|
|
190
|
-
| `isolation_reason` | blocked 或 degraded 时的原因说明 |
|
|
191
|
-
|
|
192
|
-
状态映射:
|
|
193
|
-
|
|
194
|
-
| status | mode | 触发条件 |
|
|
195
|
-
|--------|------|----------|
|
|
196
|
-
| verified | worktree | `git worktree add` 成功 |
|
|
197
|
-
| verified | native-worktree | 已在 linked worktree,复用 |
|
|
198
|
-
| degraded | in-place-fallback | `git worktree add` 失败,降级 in-place |
|
|
199
|
-
| blocked | null | submodule 内 / gitignore 未配置 |
|
|
200
|
-
| null | null | 尚未执行隔离检查 |
|
|
201
|
-
|
|
202
|
-
> ⚠️ isolation 的权威来源是 sillyspec.db。meta.json 中的 mode 仅作为 worktree 目录的运行时元信息。gate-status.json 不存储 isolation。
|
|
203
|
-
|
|
204
|
-
## 常见问题和故障排除
|
|
205
|
-
|
|
206
|
-
### worktree 残留无法清理
|
|
207
|
-
|
|
208
|
-
```bash
|
|
209
|
-
# 查看所有活跃 worktree
|
|
210
|
-
sillyspec worktree list
|
|
211
|
-
|
|
212
|
-
# 强制清理指定 worktree
|
|
213
|
-
sillyspec worktree cleanup <change-name>
|
|
214
|
-
|
|
215
|
-
# 如果 worktree 目录被手动删除但分支残留
|
|
216
|
-
git worktree prune
|
|
217
|
-
git branch -D sillyspec/<change-name>
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### apply 失败:base hash 不一致
|
|
221
|
-
|
|
222
|
-
说明主工作区在 worktree 创建后又被修改过。处理方式:
|
|
223
|
-
|
|
224
|
-
1. 检查主工作区的变更:`git diff`
|
|
225
|
-
2. 如果主工作区变更不重要 → `git stash` 后重试 apply
|
|
226
|
-
3. 如果重要 → 手动解决冲突
|
|
227
|
-
|
|
228
|
-
### apply 失败:文件清单校验不通过
|
|
229
|
-
|
|
230
|
-
说明 worktree 中修改了 `design.md` 清单之外的文件。处理方式:
|
|
231
|
-
|
|
232
|
-
1. 查看清单外文件:apply 的输出会列出
|
|
233
|
-
2. 确认是否是合理的新增(如测试文件)
|
|
234
|
-
3. 更新 `design.md` 中的文件变更清单后重试
|
|
235
|
-
4. 或用 `--check-only` 排查后再 apply
|
|
236
|
-
|
|
237
|
-
### Hook 误拦截了合法操作
|
|
238
|
-
|
|
239
|
-
- 临时方案:设置 `SILLYSPEC_DISABLE_HOOKS=1` 环境变量
|
|
240
|
-
- 检查目标文件是否应加入文件白名单(fileGate)
|
|
241
|
-
- 检查当前阶段是否正确(gate-status.json)
|
|
242
|
-
|
|
243
|
-
### worktree 内 node_modules 问题
|
|
244
|
-
|
|
245
|
-
worktree 创建后需要安装依赖:
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
cd .sillyspec/.runtime/worktrees/<change-name>/
|
|
249
|
-
npm install
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
如果项目使用 pnpm 且有 monorepo,可能需要额外配置。
|