sillyspec 3.20.6 → 3.21.0

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 (80) hide show
  1. package/.claude/CLAUDE.md +23 -0
  2. package/.claude/skills/sillyspec-archive/SKILL.md +86 -21
  3. package/.claude/skills/sillyspec-auto/SKILL.md +98 -83
  4. package/.claude/skills/sillyspec-brainstorm/SKILL.md +78 -44
  5. package/.claude/skills/sillyspec-doctor/SKILL.md +61 -31
  6. package/.claude/skills/sillyspec-execute/SKILL.md +90 -30
  7. package/.claude/skills/sillyspec-explore/SKILL.md +96 -109
  8. package/.claude/skills/sillyspec-export/SKILL.md +4 -0
  9. package/.claude/skills/sillyspec-init/SKILL.md +7 -0
  10. package/.claude/skills/sillyspec-plan/SKILL.md +74 -21
  11. package/.claude/skills/sillyspec-propose/SKILL.md +61 -21
  12. package/.claude/skills/sillyspec-quick/SKILL.md +84 -21
  13. package/.claude/skills/sillyspec-scan/SKILL.md +74 -21
  14. package/.claude/skills/sillyspec-state/SKILL.md +11 -1
  15. package/.claude/skills/sillyspec-status/SKILL.md +55 -21
  16. package/.claude/skills/sillyspec-verify/SKILL.md +82 -21
  17. package/.claude/skills/sillyspec-workspace/SKILL.md +12 -0
  18. package/CLAUDE.md +4 -0
  19. package/package.json +2 -2
  20. package/src/change-list.js +51 -16
  21. package/src/contract-matrix.js +67 -0
  22. package/src/doctor-diagnostics.js +575 -0
  23. package/src/hooks/worktree-guard.js +111 -111
  24. package/src/index.js +154 -82
  25. package/src/progress.js +59 -9
  26. package/src/run.js +139 -38
  27. package/src/stage-contract.js +14 -2
  28. package/src/stages/execute.js +37 -18
  29. package/src/stages/plan-postcheck.js +234 -0
  30. package/src/stages/plan.js +13 -0
  31. package/src/sync.js +13 -3
  32. package/src/worktree.js +69 -28
  33. package/docs/brainstorm-plan-contract.md +0 -64
  34. package/docs/plan-execute-contract.md +0 -123
  35. package/docs/platform-scan-protocol.md +0 -298
  36. package/docs/revision-mode.md +0 -115
  37. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +0 -99
  38. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +0 -223
  39. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +0 -167
  40. package/docs/sillyspec/file-lifecycle/storage-and-state.md +0 -148
  41. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +0 -211
  42. package/docs/sillyspec/file-lifecycle.md +0 -132
  43. package/docs/workflow-contract-regression.md +0 -106
  44. package/docs/worktree-isolation.md +0 -252
  45. package/test/brainstorm-plan-contract.test.mjs +0 -273
  46. package/test/check-syntax.mjs +0 -26
  47. package/test/cli-top-level-aliases.test.mjs +0 -174
  48. package/test/contract-artifacts.test.mjs +0 -323
  49. package/test/decision-ref-version.mjs +0 -85
  50. package/test/decision-supersede.test.mjs +0 -277
  51. package/test/knowledge-match.test.mjs +0 -231
  52. package/test/plan-execute-contract.test.mjs +0 -357
  53. package/test/plan-optimization.test.mjs +0 -572
  54. package/test/platform-artifacts.test.mjs +0 -190
  55. package/test/platform-failure-samples.test.mjs +0 -199
  56. package/test/platform-recovery-chain.test.mjs +0 -179
  57. package/test/platform-recovery.test.mjs +0 -167
  58. package/test/platform-scan-p0.test.mjs +0 -186
  59. package/test/quick-recommend.test.mjs +0 -146
  60. package/test/revision-v1.test.mjs +0 -1145
  61. package/test/run-sanitize-project-name.test.mjs +0 -51
  62. package/test/run-scan-postcheck-fail.test.mjs +0 -64
  63. package/test/run-scan-project-parse.test.mjs +0 -200
  64. package/test/run-tests.mjs +0 -48
  65. package/test/runtime-cleanup-keeps-worktree.test.mjs +0 -107
  66. package/test/scan-docs-yaml-placeholders.test.mjs +0 -84
  67. package/test/scan-knowledge.test.mjs +0 -175
  68. package/test/scan-paths.test.mjs +0 -68
  69. package/test/scan-postcheck-project-priority.test.mjs +0 -85
  70. package/test/scan-postcheck.test.mjs +0 -197
  71. package/test/scan-workflow-anyfailed-block.test.mjs +0 -52
  72. package/test/spec-dir.test.mjs +0 -206
  73. package/test/stage-contract-failed-post-check.test.mjs +0 -102
  74. package/test/stage-contract.test.mjs +0 -301
  75. package/test/stage-definitions.test.mjs +0 -39
  76. package/test/wait-gates.test.mjs +0 -501
  77. package/test/workflow-spec-base.test.mjs +0 -142
  78. package/test/worktree-deps-provision.test.mjs +0 -148
  79. package/test/worktree-guard.test.mjs +0 -136
  80. package/test/worktree-native-overlay.test.mjs +0 -188
@@ -1,211 +0,0 @@
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`。
@@ -1,132 +0,0 @@
1
- ---
2
- author: qinyi
3
- created_at: 2026-05-31 11:00:00
4
- updated_at: 2026-07-02 11: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 | 每次 quick 任务记录(始终写入;关联变更另在各 change tasks.md 勾选) |
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
- > **平台模式残留清理边界**(`init.js` `cleanupRuntimeResidue`,由 `run.js` 启动时首次执行一次):
77
- > 当 `specRoot` 指向外部、源码目录的 `.sillyspec/` 含真实资产(`changes/`/`projects/`/`sillyspec.db`)时,只清理运行时残留,**不整删 `.runtime/`**。清理白名单保留权威状态:`worktrees/`、`sillyspec.db`、`global.json`、`gate-status.json`、`contract-artifacts/`、`execute-runs/`;其余子项(`artifacts/`、`scan-runs/`、`scan-projects.json`、`user-inputs.md`、`postcheck-result.json` 等可重建缓存)逐项删除,`local.yaml`、`codebase/` 整删。未知子项默认保留(安全侧倾斜)。
78
- > 该清理在 `run.js` 启动时**仅执行一次**:首次处理后写 cwd 根的 `.sillyspec-platform-cleaned` 标记文件,后续每次 `run` 直接跳过。旧版每次启动都打印 `❌ 拒绝删除` 红叉属误导性噪声(清理既不阻塞流程也不动真实资产),已降为 `ℹ️` 一次性提示。
79
-
80
- ## 主要文件流
81
-
82
- ```text
83
- sillyspec init
84
- -> .sillyspec/projects/<project>.yaml
85
- -> .sillyspec/docs/<project>/scan/.gitkeep
86
- -> .sillyspec/workflows/*.yaml
87
- -> .sillyspec/knowledge/{INDEX.md,uncategorized.md}
88
- -> .sillyspec/.runtime/{sillyspec.db,user-inputs.md,artifacts,history,logs,templates}
89
-
90
- sillyspec run scan
91
- -> .sillyspec/docs/<project>/scan/*.md
92
- -> .sillyspec/docs/<project>/modules/_module-map.yaml (optional prompt)
93
- -> .sillyspec/docs/<project>/modules/<module>.md (optional prompt)
94
- -> .sillyspec/knowledge/{conventions,patterns,known-issues}.md (Extract Project Knowledge)
95
- -> .sillyspec/knowledge/INDEX.md (索引更新)
96
- -> .sillyspec/.runtime/scan-projects.json (step expansion state)
97
- -> .sillyspec/.runtime/postcheck-result.json (scan-postcheck 结构化结果)
98
-
99
- brainstorm / propose / plan / execute / verify / archive
100
- -> .sillyspec/changes/<change>/...
101
- -> .sillyspec/.runtime/sillyspec.db
102
- -> .sillyspec/.runtime/user-inputs.md
103
- -> .sillyspec/.runtime/artifacts/*.txt (long step output)
104
-
105
- execute
106
- -> .sillyspec/.runtime/worktrees/<change>/meta.json
107
- -> .sillyspec/.runtime/knowledge-hit-report.json (启动时按 taskContext 匹配 knowledge)
108
- -> worktree branch sillyspec/<change>
109
- -> apply patch back to main workspace, then cleanup
110
-
111
- quick
112
- -> .sillyspec/quicklog/QUICKLOG-<git-user>.md (without --change)
113
- -> or append checkbox to .sillyspec/changes/<change>/tasks.md
114
- -> code changes are made in the main workspace
115
- ```
116
-
117
- ## 核心修正
118
-
119
- 这版文档相对旧版长文档做了几项关键修正:
120
-
121
- - `quick` 不走 worktree 生命周期。hook 在 quick 阶段对写文件放行,只拦截危险 Bash 命令。
122
- - `scan` 当前定义是 10 步,并且 step 2 后会动态展开项目级步骤,不是固定 12 步。
123
- - `brainstorm` 和 `propose` 的重复 object key 已拆成独立步骤,运行时步骤数分别是 11 和 7。
124
- - `.sillyspec/local.yaml` 是当前主配置口径;scan prompt 写这里,sync 读写这里,hook 优先读这里并兼容根目录 fallback。
125
- - 平台模式的 `manifest.json` 已接入 scan 完成回调;`workflow-runs` 的 runtimeRoot 路径支持在 `workflow.js` 中存在,但 `run.js` 当前调用没有传入 `runtimeRoot`。
126
- - `archive` 的目录移动已经由 `run.js` 在第 4 步 `--confirm` 时执行;未带 `--confirm` 会回退该步骤并提示补参。
127
- - scan 第 10 步「Extract Project Knowledge」把长期有效的项目知识写入 `.sillyspec/knowledge/`(`conventions.md`/`patterns.md`/`known-issues.md` + 更新 `INDEX.md`);`scan-postcheck.js` 校验产物(INDEX.md 存在、引用文件真实存在)。
128
- - execute 启动时由 `knowledge-match.js` 按 plan.md 的 task 关键词匹配知识库,命中报告注入 prompt 并写 `.runtime/knowledge-hit-report.json`。
129
- - 平台模式残留清理只删缓存、保留权威状态(`worktrees/`、`sillyspec.db`、`global.json`、`gate-status.json`、`contract-artifacts/`、`execute-runs/`),不再整删 `.runtime/`——否则 worktree meta 被清掉会导致 `depsStatus` 恒为 unknown、`branch already exists` 死循环、`worktree doctor` orphan 误判。
130
- - plan→execute Contract 校验(`parseWavesFromPlan`)只解析 `## Wave N` 段内的 `- [ ] task-XX:` 行;遇到非 Wave 标题行(`## 自检` 等)即退出当前 Wave 段,避免自检 `- [x]` checkbox 被误当 task 定义。
131
- - `executePlanPostcheck` 的 `resolveChangeDir` 复用 `run.js` 模块内本地函数,不从 `./modules.js` 导入(该模块未导出此函数)。
132
- - 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。