@clawplays/ospec-cli 0.1.1

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 (191) hide show
  1. package/.ospec/templates/hooks/post-merge +8 -0
  2. package/.ospec/templates/hooks/pre-commit +8 -0
  3. package/LICENSE +21 -0
  4. package/README.md +549 -0
  5. package/README.zh-CN.md +549 -0
  6. package/assets/for-ai/en-US/ai-guide.md +98 -0
  7. package/assets/for-ai/en-US/execution-protocol.md +64 -0
  8. package/assets/for-ai/zh-CN/ai-guide.md +102 -0
  9. package/assets/for-ai/zh-CN/execution-protocol.md +68 -0
  10. package/assets/git-hooks/post-merge +12 -0
  11. package/assets/git-hooks/pre-commit +12 -0
  12. package/assets/global-skills/claude/ospec-change/SKILL.md +116 -0
  13. package/assets/global-skills/codex/ospec-change/SKILL.md +117 -0
  14. package/assets/global-skills/codex/ospec-change/agents/openai.yaml +7 -0
  15. package/assets/global-skills/codex/ospec-change/skill.yaml +19 -0
  16. package/assets/project-conventions/en-US/development-guide.md +32 -0
  17. package/assets/project-conventions/en-US/naming-conventions.md +51 -0
  18. package/assets/project-conventions/en-US/skill-conventions.md +40 -0
  19. package/assets/project-conventions/en-US/workflow-conventions.md +70 -0
  20. package/assets/project-conventions/zh-CN/development-guide.md +32 -0
  21. package/assets/project-conventions/zh-CN/naming-conventions.md +51 -0
  22. package/assets/project-conventions/zh-CN/skill-conventions.md +40 -0
  23. package/assets/project-conventions/zh-CN/workflow-conventions.md +74 -0
  24. package/dist/adapters/codex-stitch-adapter.js +420 -0
  25. package/dist/adapters/gemini-stitch-adapter.js +408 -0
  26. package/dist/adapters/playwright-checkpoint-adapter.js +2260 -0
  27. package/dist/advanced/BatchOperations.d.ts +36 -0
  28. package/dist/advanced/BatchOperations.js +159 -0
  29. package/dist/advanced/CachingLayer.d.ts +66 -0
  30. package/dist/advanced/CachingLayer.js +136 -0
  31. package/dist/advanced/FeatureUpdater.d.ts +46 -0
  32. package/dist/advanced/FeatureUpdater.js +151 -0
  33. package/dist/advanced/PerformanceMonitor.d.ts +52 -0
  34. package/dist/advanced/PerformanceMonitor.js +129 -0
  35. package/dist/advanced/StatePersistence.d.ts +61 -0
  36. package/dist/advanced/StatePersistence.js +168 -0
  37. package/dist/advanced/index.d.ts +14 -0
  38. package/dist/advanced/index.js +22 -0
  39. package/dist/cli/commands/config.d.ts +5 -0
  40. package/dist/cli/commands/config.js +6 -0
  41. package/dist/cli/commands/feature.d.ts +5 -0
  42. package/dist/cli/commands/feature.js +6 -0
  43. package/dist/cli/commands/index.d.ts +5 -0
  44. package/dist/cli/commands/index.js +6 -0
  45. package/dist/cli/commands/project.d.ts +5 -0
  46. package/dist/cli/commands/project.js +6 -0
  47. package/dist/cli/commands/validate.d.ts +5 -0
  48. package/dist/cli/commands/validate.js +6 -0
  49. package/dist/cli/index.d.ts +5 -0
  50. package/dist/cli/index.js +6 -0
  51. package/dist/cli.d.ts +3 -0
  52. package/dist/cli.js +1007 -0
  53. package/dist/commands/ArchiveCommand.d.ts +14 -0
  54. package/dist/commands/ArchiveCommand.js +241 -0
  55. package/dist/commands/BaseCommand.d.ts +33 -0
  56. package/dist/commands/BaseCommand.js +46 -0
  57. package/dist/commands/BatchCommand.d.ts +5 -0
  58. package/dist/commands/BatchCommand.js +42 -0
  59. package/dist/commands/ChangesCommand.d.ts +3 -0
  60. package/dist/commands/ChangesCommand.js +71 -0
  61. package/dist/commands/DocsCommand.d.ts +5 -0
  62. package/dist/commands/DocsCommand.js +118 -0
  63. package/dist/commands/FinalizeCommand.d.ts +3 -0
  64. package/dist/commands/FinalizeCommand.js +24 -0
  65. package/dist/commands/IndexCommand.d.ts +5 -0
  66. package/dist/commands/IndexCommand.js +57 -0
  67. package/dist/commands/InitCommand.d.ts +5 -0
  68. package/dist/commands/InitCommand.js +65 -0
  69. package/dist/commands/NewCommand.d.ts +11 -0
  70. package/dist/commands/NewCommand.js +262 -0
  71. package/dist/commands/PluginsCommand.d.ts +58 -0
  72. package/dist/commands/PluginsCommand.js +2491 -0
  73. package/dist/commands/ProgressCommand.d.ts +5 -0
  74. package/dist/commands/ProgressCommand.js +103 -0
  75. package/dist/commands/QueueCommand.d.ts +10 -0
  76. package/dist/commands/QueueCommand.js +147 -0
  77. package/dist/commands/RunCommand.d.ts +13 -0
  78. package/dist/commands/RunCommand.js +200 -0
  79. package/dist/commands/SkillCommand.d.ts +31 -0
  80. package/dist/commands/SkillCommand.js +1216 -0
  81. package/dist/commands/SkillsCommand.d.ts +5 -0
  82. package/dist/commands/SkillsCommand.js +68 -0
  83. package/dist/commands/StatusCommand.d.ts +6 -0
  84. package/dist/commands/StatusCommand.js +140 -0
  85. package/dist/commands/UpdateCommand.d.ts +8 -0
  86. package/dist/commands/UpdateCommand.js +251 -0
  87. package/dist/commands/VerifyCommand.d.ts +5 -0
  88. package/dist/commands/VerifyCommand.js +278 -0
  89. package/dist/commands/WorkflowCommand.d.ts +12 -0
  90. package/dist/commands/WorkflowCommand.js +150 -0
  91. package/dist/commands/index.d.ts +43 -0
  92. package/dist/commands/index.js +85 -0
  93. package/dist/core/constants.d.ts +41 -0
  94. package/dist/core/constants.js +73 -0
  95. package/dist/core/errors.d.ts +36 -0
  96. package/dist/core/errors.js +72 -0
  97. package/dist/core/index.d.ts +7 -0
  98. package/dist/core/index.js +23 -0
  99. package/dist/core/types.d.ts +369 -0
  100. package/dist/core/types.js +3 -0
  101. package/dist/index.d.ts +11 -0
  102. package/dist/index.js +27 -0
  103. package/dist/presets/ProjectPresets.d.ts +41 -0
  104. package/dist/presets/ProjectPresets.js +190 -0
  105. package/dist/scaffolds/ProjectScaffoldPresets.d.ts +20 -0
  106. package/dist/scaffolds/ProjectScaffoldPresets.js +151 -0
  107. package/dist/services/ConfigManager.d.ts +14 -0
  108. package/dist/services/ConfigManager.js +386 -0
  109. package/dist/services/FeatureManager.d.ts +5 -0
  110. package/dist/services/FeatureManager.js +6 -0
  111. package/dist/services/FileService.d.ts +21 -0
  112. package/dist/services/FileService.js +152 -0
  113. package/dist/services/IndexBuilder.d.ts +12 -0
  114. package/dist/services/IndexBuilder.js +130 -0
  115. package/dist/services/Logger.d.ts +20 -0
  116. package/dist/services/Logger.js +48 -0
  117. package/dist/services/ProjectAssetRegistry.d.ts +12 -0
  118. package/dist/services/ProjectAssetRegistry.js +96 -0
  119. package/dist/services/ProjectAssetService.d.ts +49 -0
  120. package/dist/services/ProjectAssetService.js +223 -0
  121. package/dist/services/ProjectScaffoldCommandService.d.ts +73 -0
  122. package/dist/services/ProjectScaffoldCommandService.js +159 -0
  123. package/dist/services/ProjectScaffoldService.d.ts +44 -0
  124. package/dist/services/ProjectScaffoldService.js +507 -0
  125. package/dist/services/ProjectService.d.ts +209 -0
  126. package/dist/services/ProjectService.js +13239 -0
  127. package/dist/services/QueueService.d.ts +17 -0
  128. package/dist/services/QueueService.js +142 -0
  129. package/dist/services/RunService.d.ts +40 -0
  130. package/dist/services/RunService.js +420 -0
  131. package/dist/services/SkillParser.d.ts +30 -0
  132. package/dist/services/SkillParser.js +88 -0
  133. package/dist/services/StateManager.d.ts +16 -0
  134. package/dist/services/StateManager.js +127 -0
  135. package/dist/services/TemplateEngine.d.ts +43 -0
  136. package/dist/services/TemplateEngine.js +119 -0
  137. package/dist/services/TemplateGenerator.d.ts +40 -0
  138. package/dist/services/TemplateGenerator.js +273 -0
  139. package/dist/services/ValidationService.d.ts +19 -0
  140. package/dist/services/ValidationService.js +44 -0
  141. package/dist/services/Validator.d.ts +5 -0
  142. package/dist/services/Validator.js +6 -0
  143. package/dist/services/index.d.ts +52 -0
  144. package/dist/services/index.js +91 -0
  145. package/dist/services/templates/ExecutionTemplateBuilder.d.ts +12 -0
  146. package/dist/services/templates/ExecutionTemplateBuilder.js +300 -0
  147. package/dist/services/templates/ProjectTemplateBuilder.d.ts +38 -0
  148. package/dist/services/templates/ProjectTemplateBuilder.js +1897 -0
  149. package/dist/services/templates/TemplateBuilderBase.d.ts +19 -0
  150. package/dist/services/templates/TemplateBuilderBase.js +60 -0
  151. package/dist/services/templates/TemplateInputFactory.d.ts +16 -0
  152. package/dist/services/templates/TemplateInputFactory.js +298 -0
  153. package/dist/services/templates/templateTypes.d.ts +90 -0
  154. package/dist/services/templates/templateTypes.js +3 -0
  155. package/dist/tools/build-index.js +632 -0
  156. package/dist/utils/DateUtils.d.ts +18 -0
  157. package/dist/utils/DateUtils.js +40 -0
  158. package/dist/utils/PathUtils.d.ts +9 -0
  159. package/dist/utils/PathUtils.js +66 -0
  160. package/dist/utils/StringUtils.d.ts +26 -0
  161. package/dist/utils/StringUtils.js +47 -0
  162. package/dist/utils/helpers.d.ts +5 -0
  163. package/dist/utils/helpers.js +6 -0
  164. package/dist/utils/index.d.ts +7 -0
  165. package/dist/utils/index.js +23 -0
  166. package/dist/utils/logger.d.ts +5 -0
  167. package/dist/utils/logger.js +6 -0
  168. package/dist/utils/path.d.ts +5 -0
  169. package/dist/utils/path.js +6 -0
  170. package/dist/utils/subcommandHelp.d.ts +11 -0
  171. package/dist/utils/subcommandHelp.js +119 -0
  172. package/dist/workflow/ArchiveGate.d.ts +30 -0
  173. package/dist/workflow/ArchiveGate.js +93 -0
  174. package/dist/workflow/ConfigurableWorkflow.d.ts +89 -0
  175. package/dist/workflow/ConfigurableWorkflow.js +186 -0
  176. package/dist/workflow/HookSystem.d.ts +38 -0
  177. package/dist/workflow/HookSystem.js +66 -0
  178. package/dist/workflow/IndexRegenerator.d.ts +49 -0
  179. package/dist/workflow/IndexRegenerator.js +147 -0
  180. package/dist/workflow/PluginWorkflowComposer.d.ts +138 -0
  181. package/dist/workflow/PluginWorkflowComposer.js +239 -0
  182. package/dist/workflow/SkillUpdateEngine.d.ts +26 -0
  183. package/dist/workflow/SkillUpdateEngine.js +113 -0
  184. package/dist/workflow/VerificationSystem.d.ts +24 -0
  185. package/dist/workflow/VerificationSystem.js +116 -0
  186. package/dist/workflow/WorkflowEngine.d.ts +15 -0
  187. package/dist/workflow/WorkflowEngine.js +57 -0
  188. package/dist/workflow/index.d.ts +19 -0
  189. package/dist/workflow/index.js +32 -0
  190. package/package.json +78 -0
  191. package/scripts/postinstall.js +43 -0
@@ -0,0 +1,549 @@
1
+ # OSpec
2
+
3
+ OSpec 是一个面向 AI 协作交付的 CLI 工作流系统。
4
+
5
+ 它不是一个“先生成一堆业务模板”的脚手架,而是一个协议壳优先的协作框架:先建立最小协作协议,再显式补齐项目知识层,最后用 change 流程管理需求的执行、验证和归档。
6
+
7
+ 当前版本:
8
+
9
+ - CLI:`0.1.1`
10
+
11
+ 文档入口:
12
+
13
+ - [项目介绍](docs/project-overview.zh-CN.md)
14
+ - [安装说明](docs/installation.zh-CN.md)
15
+ - [使用说明](docs/usage.zh-CN.md)
16
+ - [提示词文档](docs/prompt-guide.zh-CN.md)
17
+ - [Skills 安装说明](docs/skills-installation.zh-CN.md)
18
+ - [GitLab 自定义 Fork 同步方案](docs/custom-fork-sync.zh-CN.md)
19
+ - [Stitch 插件规范](docs/stitch-plugin-spec.zh-CN.md)
20
+ - [Checkpoint 插件规范](docs/checkpoint-plugin-spec.zh-CN.md)
21
+
22
+ ## OSpec 是什么
23
+
24
+ OSpec 的核心目标,不是帮团队一次性生成固定项目结构,而是先把 AI 协作的基本规则落下来。
25
+
26
+ 它做的事情可以概括成三层:
27
+
28
+ - 先初始化最小协议壳,让项目进入统一协作状态
29
+ - 再补齐项目知识层,让 AI 有稳定上下文可读
30
+ - 最后用 active change 流程管理每个需求的执行、验证和收口
31
+
32
+ 如果用更通俗的话说,OSpec 管的不是“先写什么业务页面”,而是“团队和 AI 应该按什么规则协作”。
33
+
34
+ ## 想解决什么问题
35
+
36
+ 在 AI 参与研发后,常见问题通常有这些:
37
+
38
+ - AI 能写代码,但不知道项目里的执行规则
39
+ - 需求做完以后,中间过程不可见,也很难回溯
40
+ - 文档、技能文件、实现状态容易不同步
41
+ - 不同 AI 客户端使用的协作协议不一致
42
+ - 某些需求需要设计审批或额外门禁,但缺少统一入口
43
+
44
+ OSpec 的思路不是直接给一个很重的业务模板,而是先把协议和门禁建立起来,让项目进入可检查、可追踪、可归档的状态。
45
+
46
+ ## 三个核心概念
47
+
48
+ ### 1. 协议壳
49
+
50
+ 协议壳是项目最小可协作骨架,主要解决“项目先进入统一协作状态”。
51
+
52
+ 初始化后,关键文件和目录通常包括:
53
+
54
+ - `.skillrc`
55
+ - `.ospec/`
56
+ - `changes/active/`
57
+ - `changes/archived/`
58
+ - `SKILL.md`
59
+ - `SKILL.index.json`
60
+ - `for-ai/` 下的一组 AI 协作规则文档
61
+
62
+ 可以把它理解成项目的“协作底座”。
63
+
64
+ ### 2. 项目知识层
65
+
66
+ 协议壳建立以后,项目还需要长期稳定的知识上下文。OSpec 用 `docs/project/` 和分层 `SKILL.md` 去承接这部分内容。
67
+
68
+ 默认会补齐的项目文档包括:
69
+
70
+ - `docs/project/overview.md`
71
+ - `docs/project/tech-stack.md`
72
+ - `docs/project/architecture.md`
73
+ - `docs/project/module-map.md`
74
+ - `docs/project/api-overview.md`
75
+
76
+ 这一步的目标,是让 AI 后续不是盲写,而是有稳定上下文可以引用。
77
+
78
+ ### 3. active change
79
+
80
+ OSpec 不把一个需求散落在聊天记录里,而是给每个需求建立一个独立的执行容器。
81
+
82
+ 每个 active change 里最关键的文件是:
83
+
84
+ - `proposal.md`
85
+ - `tasks.md`
86
+ - `state.json`
87
+ - `verification.md`
88
+ - `review.md`
89
+
90
+ 其中真正的执行状态真源是:
91
+
92
+ - `state.json`
93
+
94
+ 也就是说,项目不是靠“口头说已经完成”,而是靠状态文件和验证文件共同证明 change 到了什么阶段。
95
+
96
+ ## 主流程
97
+
98
+ OSpec 当前的主流程可以概括成四段:
99
+
100
+ 1. 协议壳初始化
101
+ 2. 项目知识层补齐
102
+ 3. active change 执行
103
+ 4. verify / archive / finalize 收口
104
+
105
+ 对应的核心命令是:
106
+
107
+ ```bash
108
+ ospec status [path]
109
+ ospec init [path]
110
+ ospec docs generate [path]
111
+ ospec new <change-name> [path]
112
+ ospec progress [changes/active/<change>]
113
+ ospec verify [changes/active/<change>]
114
+ ospec archive [changes/active/<change>]
115
+ ospec finalize [changes/active/<change>]
116
+ ```
117
+
118
+ ## 常见用法
119
+
120
+ ### 1. 先看项目状态
121
+
122
+ ```bash
123
+ ospec status .
124
+ ```
125
+
126
+ 这一步相当于先体检。它会告诉你:
127
+
128
+ - 项目是否已经初始化
129
+ - 缺哪些协议文件
130
+ - 项目文档覆盖率如何
131
+ - skills 是否完整
132
+ - 当前是否存在 active changes
133
+ - 下一步最推荐执行什么
134
+
135
+ ### 2. 初始化协议壳
136
+
137
+ ```bash
138
+ ospec init .
139
+ ```
140
+
141
+ 这一步只做最小初始化:
142
+
143
+ - 创建 OSpec 协议壳
144
+ - 不默认生成 Web 模板或业务 scaffold
145
+ - 不自动创建第一个 change
146
+
147
+ 这体现了 OSpec 的一个核心原则:先建立协作协议,不抢业务决策,也不猜项目类型。
148
+
149
+ ### 3. 补齐项目知识层
150
+
151
+ ```bash
152
+ ospec docs generate .
153
+ ```
154
+
155
+ 这一步会补齐项目知识层文档、分层技能入口和索引等基础内容。
156
+
157
+ 它的边界也很明确:
158
+
159
+ - 会补项目知识
160
+ - 不会自动应用业务 scaffold
161
+ - 不会自动开始一个需求
162
+
163
+ ### 4. 创建一个需求 change
164
+
165
+ ```bash
166
+ ospec new landing-refresh .
167
+ ```
168
+
169
+ 这一步不是直接开始写代码,而是先创建需求执行容器。
170
+
171
+ 创建后,项目里会出现:
172
+
173
+ - `proposal.md`:记录背景、目标、范围、验收标准
174
+ - `tasks.md`:记录任务清单
175
+ - `state.json`:记录执行状态
176
+ - `verification.md`:记录验证项
177
+ - `review.md`:记录评审视角
178
+
179
+ ### 5. 持续查看进度和风险
180
+
181
+ 常用命令:
182
+
183
+ ```bash
184
+ ospec progress changes/active/landing-refresh
185
+ ospec verify changes/active/landing-refresh
186
+ ospec changes status .
187
+ ```
188
+
189
+ 它们分别解决三个问题:
190
+
191
+ - `progress`:当前 change 到了哪一步
192
+ - `verify`:当前 change 的协议文件和验证项是否完整
193
+ - `changes status`:整个项目所有 active changes 的 PASS / WARN / FAIL 汇总
194
+
195
+ ### 6. 标准收口
196
+
197
+ 推荐使用:
198
+
199
+ ```bash
200
+ ospec finalize changes/active/landing-refresh
201
+ ```
202
+
203
+ `finalize` 是默认收口路径,它会按顺序执行:
204
+
205
+ - verify
206
+ - 重建索引
207
+ - archive
208
+
209
+ 最后把 change 从 `changes/active/` 挪到 `changes/archived/`,并把仓库留在“可以手动提交 Git”的状态。
210
+
211
+ ### 7. 显式队列模式
212
+
213
+ 队列模式默认是保守接入:
214
+
215
+ - `ospec new` 仍然只创建一个普通 active change
216
+ - 不会因为仓库状态自动进入队列模式
217
+ - 只有显式使用 `ospec queue ...` 或 `ospec run ...` 才会启动队列能力
218
+
219
+ 核心命令:
220
+
221
+ ```bash
222
+ ospec queue add landing-refresh .
223
+ ospec queue add billing-cleanup .
224
+ ospec queue status .
225
+ ospec queue next .
226
+ ospec run start . --profile manual-safe
227
+ ospec run step .
228
+ ```
229
+
230
+ runner profile 说明:
231
+
232
+ - `manual-safe`:只做显式队列跟踪和激活,不改你现有的手动 change 执行方式
233
+ - `archive-chain`:在一次显式 `ospec run step` 中,如果当前 active change 已满足归档门禁,OSpec 会先 finalize/archive,再继续推进下一个 queued change
234
+
235
+ 推荐给 AI 的描述方式:
236
+
237
+ - 单个 change:`使用 OSpec 为这个需求创建并推进一个 change。`
238
+ - 只建队列先不跑:`使用 OSpec 读取这份 TODO,把它拆成多个 change,建立队列,并先展示队列状态,不要马上执行。`
239
+ - 显式按队列执行:`使用 OSpec 建立 change 队列,并用 ospec run manual-safe 显式推进。`
240
+
241
+ ## 一个需求怎么流转
242
+
243
+ 单个需求的推荐顺序是:
244
+
245
+ 1. 明确上下文和影响范围
246
+ 2. 创建或更新 `proposal.md`
247
+ 3. 创建或更新 `tasks.md`
248
+ 4. 根据 `state.json` 推进实现
249
+ 5. 更新相关 `SKILL.md`
250
+ 6. 重建 `SKILL.index.json`
251
+ 7. 完成 `verification.md`
252
+ 8. 满足门禁后归档
253
+
254
+ 如果用一句话概括,就是:
255
+
256
+ 需求进入
257
+ -> 建 change
258
+ -> 写 proposal
259
+ -> 写 tasks
260
+ -> 按状态推进实现
261
+ -> 同步文档和技能
262
+ -> 完成 verification
263
+ -> verify 检查
264
+ -> archive / finalize 收口
265
+
266
+ 这个设计的价值是:
267
+
268
+ - 每个需求都有独立容器
269
+ - 每个阶段都有明确文档锚点
270
+ - 完成状态不是“感觉差不多”,而是可检查
271
+
272
+ ## 当前核心功能
273
+
274
+ 从 CLI 能力看,当前功能大致可以分成五组。
275
+
276
+ ### 1. 项目初始化与诊断
277
+
278
+ - `status`
279
+ - `init`
280
+ - `docs status`
281
+ - `docs generate`
282
+
283
+ 这组命令主要解决“项目是否进入协议化协作状态”。
284
+
285
+ ### 2. 需求执行流程
286
+
287
+ - `new`
288
+ - `progress`
289
+ - `verify`
290
+ - `archive`
291
+ - `finalize`
292
+ - `changes status`
293
+
294
+ 这组命令主要解决“一个需求如何从创建走到收口”。
295
+
296
+ ### 3. 技能与索引管理
297
+
298
+ - `skills status`
299
+ - `skill status`
300
+ - `skill install`
301
+ - `index check`
302
+ - `index build`
303
+
304
+ 这组命令主要解决“AI 该从哪里读规则,以及规则是否同步”。
305
+
306
+ ### 4. 插件化工作流
307
+
308
+ - `plugins status`
309
+ - `plugins enable stitch`
310
+ - `plugins run stitch`
311
+ - `plugins approve stitch`
312
+ - `plugins reject stitch`
313
+ - `plugins doctor stitch`
314
+
315
+ 这组命令主要解决“某些需求除了代码之外,还需要额外阻断步骤”。
316
+
317
+ 当前第一个插件是 `stitch`,主要面向页面设计验收。
318
+
319
+ ### 5. 协议更新与分发
320
+
321
+ - `update`
322
+ - `skill install`
323
+ - `skill install-claude`
324
+
325
+ 这组能力让 OSpec 不只管理单个项目,还能把同一套协作协议同步给不同 AI 客户端。
326
+
327
+ 其中 `ospec update [path]` 的边界是:
328
+
329
+ - 会刷新协议文档、项目 tooling、Git hooks、托管安装的 skills,以及已启用插件的托管工作目录资产
330
+ - 不会自动 `enable/disable` 插件
331
+ - 不会自动调整已有 active changes 到新的插件工作流
332
+ - 如果要启用 Stitch,仍需显式执行 `ospec plugins enable stitch [path]`
333
+
334
+ ## 一个容易混淆的细节
335
+
336
+ 当前版本里,有两个概念需要分开理解:
337
+
338
+ - 结构层级
339
+ - 工作流模式
340
+
341
+ ### 结构层级
342
+
343
+ 结构判断现在固定只按:
344
+
345
+ - `none`
346
+
347
+ 来理解。
348
+
349
+ 它不再使用 `basic` / `full` 去描述“仓库结构层级”。
350
+
351
+ ### 工作流模式
352
+
353
+ 初始化出来的 `.skillrc` 默认工作流模式仍然是:
354
+
355
+ - `full`
356
+
357
+ 它影响的是:
358
+
359
+ - 支持哪些 feature flags
360
+ - 哪些 optional steps 会被激活
361
+ - archive gate 需要检查什么
362
+
363
+ 所以应当这样理解:
364
+
365
+ - 结构层级表示项目是否完成协议化初始化
366
+ - 工作流模式表示需求执行时采用多严格的流程
367
+
368
+ ## Stitch 插件
369
+
370
+ Stitch 体现了 OSpec 的插件化扩展能力。
371
+
372
+ 它的思路不是把设计审核硬编码进主流程,而是:
373
+
374
+ - 项目通过 plugin 启用能力
375
+ - plugin 贡献 optional step
376
+ - change 根据 flag 命中后激活这个 step
377
+ - `verify / archive / finalize` 依据审批产物进行阻断
378
+
379
+ 例如项目启用 Stitch 后,如果新 change 带这些 flags:
380
+
381
+ - `ui_change`
382
+ - `page_design`
383
+ - `landing_page`
384
+
385
+ 那么系统会激活:
386
+
387
+ - `stitch_design_review`
388
+
389
+ 并在 change 下生成:
390
+
391
+ - `artifacts/stitch/approval.json`
392
+
393
+ 如果这个审批文件没有通过,change 就不能声称已完成,也不能归档。
394
+
395
+ 在页面设计评审场景下,这个门禁还要求:
396
+
397
+ - 同一路由只能有一个 canonical layout
398
+ - `light/dark` 必须是一套 layout 的主题变体,不能变成两套不同排版
399
+ - 交付中必须给出 `screen mapping`
400
+ - 旧稿和探索稿必须归档,不能与 canonical 页面并列
401
+
402
+ 这说明 OSpec 的插件不是简单提醒,而是真正参与流程门禁。
403
+
404
+ ## 设计理念
405
+
406
+ ### 1. Protocol-shell-first
407
+
408
+ 先建协议壳,再谈业务。
409
+
410
+ 这样做的好处是:
411
+
412
+ - 初始化足够轻
413
+ - 不容易误判项目类型
414
+ - 不会把一个还没想清楚的仓库直接塞成固定模板
415
+
416
+ ### 2. 显式优于隐式
417
+
418
+ OSpec 很少做“猜你想要什么”的事情。
419
+
420
+ 例如:
421
+
422
+ - `init` 不自动补 docs
423
+ - `docs generate` 不自动建 change
424
+ - `new` 不自动推进业务实现
425
+
426
+ 每一步都尽量清晰、可控、可解释。
427
+
428
+ ### 3. 文档是执行面的一部分
429
+
430
+ 在 OSpec 里:
431
+
432
+ - proposal 不是附属汇报材料
433
+ - tasks 不是临时记事本
434
+ - verification 不是最后补充说明
435
+
436
+ 这些文档本身就是工作流的一部分,会直接影响后续能不能通过 verify 和 archive。
437
+
438
+ ### 4. `state.json` 是状态真源
439
+
440
+ 项目明确要求:
441
+
442
+ - 以 `state.json` 作为当前执行状态依据
443
+ - `verification.md` 不能替代 `state.json`
444
+
445
+ 这让流程不会因为“说法不一致”而漂移。
446
+
447
+ ### 5. 先门禁,再归档
448
+
449
+ OSpec 的收口不是“代码写完就提交”,而是:
450
+
451
+ - 先检查流程是否完整
452
+ - 再允许归档
453
+ - 归档后再进入 Git 提交阶段
454
+
455
+ 这会让交付边界更清楚。
456
+
457
+ ### 6. 插件化而不是硬编码
458
+
459
+ 像设计审核这类能力,不是直接写死在主流程里,而是通过 plugin 注入 step。
460
+
461
+ 这意味着未来可以继续扩展:
462
+
463
+ - 设计评审
464
+ - 安全检查
465
+ - 其他审批能力
466
+
467
+ 而不用把主工作流改得越来越臃肿。
468
+
469
+ ### 7. 同一套协议适配多个 AI 客户端
470
+
471
+ 当前项目不仅管理项目内部流程,还能把技能包同步给:
472
+
473
+ - Codex
474
+ - Claude Code
475
+
476
+ 这意味着团队即使使用不同 AI 工具,也能尽量共享同一套协作协议。
477
+
478
+ ## 当前仓库说明
479
+
480
+ 当前仓库本身首先是:
481
+
482
+ - OSpec 的实现与发布仓库
483
+
484
+ 它主要包含这些部分:
485
+
486
+ - `dist/`:编译后的 CLI、commands、workflow、services、adapters
487
+ - `assets/`:协议文档、约定模板、全局 skills、git hooks
488
+ - `docs/`:对外说明文档和设计规范文档
489
+ - `scripts/`:安装、发版、fork 同步相关脚本
490
+ - `skill.yaml`、`SKILL.md`、`agents/`:技能打包和分发入口
491
+
492
+ 从 `ospec status .` 的结果看,当前仓库根目录并没有完整初始化成一个“被 OSpec 管理的业务项目”,它还缺:
493
+
494
+ - `.skillrc`
495
+ - `changes/active/`
496
+ - `changes/archived/`
497
+
498
+ 这说明当前仓库有两个不同身份:
499
+
500
+ - 它是 OSpec 工具本身的源码仓
501
+ - 它不是一个已经用 OSpec 执行业务需求的示例业务仓
502
+
503
+ 因此更准确的理解是:
504
+
505
+ - 这个仓库负责实现 OSpec
506
+ - OSpec 的直接使用对象,是下游业务项目或新初始化目录
507
+
508
+ ## 当前行为特征
509
+
510
+ 通过实际命令验证,可以确认这些行为:
511
+
512
+ - `ospec init` 只初始化协议壳,不会自动补项目 docs,也不会自动创建第一个 change
513
+ - `ospec docs generate` 会补齐知识层和分层技能入口,但不会应用业务 scaffold
514
+ - 当 Stitch 插件未启用时,`ui_change`、`page_design` 这类 flag 会被记录在 `proposal.md`,但会提示为 unsupported flags
515
+ - 当 Stitch 插件启用后,同样的 flag 会真正激活 `stitch_design_review`,并自动生成 `artifacts/stitch/approval.json`
516
+
517
+ 这几项特征正好体现了 OSpec 的几个核心设计:
518
+
519
+ - 默认最小化
520
+ - 显式扩展
521
+ - 流程可检查
522
+ - 插件可阻断
523
+ - 队列能力只有在显式要求时才启动
524
+
525
+ ## 快速体验顺序
526
+
527
+ 如果想快速体验一遍主流程,推荐按这个顺序执行:
528
+
529
+ ```bash
530
+ ospec status demo
531
+ ospec init demo
532
+ ospec docs generate demo
533
+ ospec new landing-refresh demo
534
+ ospec changes status demo
535
+ ospec progress demo/changes/active/landing-refresh
536
+ ```
537
+
538
+ 如果还想体验插件扩展能力,可以继续执行:
539
+
540
+ ```bash
541
+ ospec plugins enable stitch demo
542
+ ospec new home-hero-redesign demo --flags ui_change,page_design
543
+ ```
544
+
545
+ ## 总结
546
+
547
+ 如果用一句话概括 OSpec,它不是帮团队“更快生成代码”的工具,而是帮团队“更稳地用 AI 做交付”的工具。
548
+
549
+ 它最核心的价值,不是模板,不是页面,也不是脚手架,而是把 AI 协作这件事从“靠聊天记录推进”,变成“有协议壳、有知识层、有 change 容器、有门禁、有归档”的可管理流程。
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: project-ai-guide
3
+ title: AI Guide
4
+ tags: [ai, guide, ospec]
5
+ ---
6
+
7
+ # AI Guide
8
+
9
+ ## Goal
10
+
11
+ This document is the project-adopted AI guide copied from the OSpec mother spec. The AI must follow the project-adopted rules first instead of improvising from the mother repo.
12
+
13
+ ## Working Order
14
+
15
+ 1. Read `.skillrc`
16
+ 2. Read `SKILL.index.json`
17
+ 3. Read the project-adopted rules under `docs/project/`
18
+ 4. Read the relevant `SKILL.md` files
19
+ 5. Read the current change execution files
20
+ 6. If Stitch is enabled and the current change activates `stitch_design_review`, inspect `artifacts/stitch/approval.json` first
21
+ 7. If you need to handle Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup, read the repo-local Stitch spec first; when `docs/stitch-plugin-spec.zh-CN.md` exists, treat its config snippets as the source of truth
22
+
23
+ ## Required Behavior
24
+
25
+ - Follow the project-adopted document language for `proposal.md`, `tasks.md`, `verification.md`, and `review.md`
26
+ - Do not infer change-document language from product copy, default site locale, or an "English-first" business requirement alone
27
+ - If the project-adopted protocol is Chinese or the current change docs are already Chinese, keep the change docs in Chinese unless the project rules explicitly switch them to English
28
+ - Use the index to locate knowledge before reading target files
29
+ - Read the project-adopted rules before implementation work
30
+ - If `stitch_design_review` is active and `approval.json.preview_url` or `submitted_at` is empty, run `ospec plugins run stitch <change-path>` first to generate a preview, then send the preview URL to the user for review
31
+ - If `.skillrc.plugins.stitch.project.project_id` is already set, you must reuse that exact Stitch project instead of creating a new one
32
+ - If `.skillrc.plugins.stitch.project.project_id` is empty, treat the first successful Stitch run as the canonical project and keep reusing it for later changes
33
+ - If `stitch_design_review` is active and `approval.json.status != approved`, stop at the design review gate
34
+ - Stitch page review must enforce one canonical layout per business route; do not leave multiple unclassified main layouts under the same route
35
+ - When producing `light/dark`, derive both from the same canonical screen; do not reorder modules, change information architecture, move CTAs, or create a different composition
36
+ - If the matching page already exists, prefer `edit existing screen` or `duplicate existing canonical screen and derive a theme variant`
37
+ - Every Stitch delivery must include a `screen mapping` with at least the route, canonical dark/light screen ids, whether one is derived from the other, and archived screen ids
38
+ - Old screens, explorations, and replaced screens must be archived or renamed instead of staying beside the canonical screen as peer main pages
39
+ - If canonical selection, theme pairing, screen mapping, or duplicate cleanup is missing, do not treat the review as complete
40
+ - `ospec plugins run stitch <change-path>` uses the configured Stitch provider adapter by default; only use a custom runner when `.skillrc.plugins.stitch.runner` is explicitly overridden
41
+ - If the project uses a custom runner and `token_env` is configured, confirm the matching environment variable is set before running
42
+ - If the runner, Gemini CLI, Codex CLI, stitch MCP, or auth readiness is unclear, run `ospec plugins doctor stitch <project-path>` first
43
+ - If `plugins doctor stitch` reports non-PASS for the selected provider checks, prompt the user to install the required CLI and complete the stitch MCP / API token setup in the matching user config
44
+ - For Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup, read the repo-local Stitch spec first; when `docs/stitch-plugin-spec.zh-CN.md` exists, copy the documented Gemini / Codex config shape instead of inventing a `command` / `args` / `env` or stdio-proxy workaround just to satisfy doctor
45
+ - If the built-in `codex` provider succeeds on read-only calls but `create_project`, `generate_screen`, or `edit_screens` stalls locally, first verify the run actually uses `codex exec --dangerously-bypass-approvals-and-sandbox`
46
+ - If the project explicitly overrides `.skillrc.plugins.stitch.runner` and Codex still performs Stitch writes, the custom runner / wrapper must also pass `--dangerously-bypass-approvals-and-sandbox`
47
+ - Sync `SKILL.md` after meaningful code changes
48
+ - Rebuild `SKILL.index.json` when needed
49
+
50
+ ## Project-Adopted Rules First
51
+
52
+ - Naming conventions: `docs/project/naming-conventions.md`
53
+ - SKILL conventions: `docs/project/skill-conventions.md`
54
+ - Workflow conventions: `docs/project/workflow-conventions.md`
55
+ - Development guide: `docs/project/development-guide.md`
56
+
57
+ ## Stitch Provider Baseline
58
+
59
+ - When `docs/stitch-plugin-spec.zh-CN.md` exists in the repo, use its original config snippets first.
60
+ - When the repo does not contain that spec and the built-in Stitch provider must be enabled, use these baselines.
61
+ - `gemini`: edit `%USERPROFILE%/.gemini/settings.json` and use `mcpServers.stitch.httpUrl` plus `headers.X-Goog-Api-Key`.
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "stitch": {
67
+ "httpUrl": "https://stitch.googleapis.com/mcp",
68
+ "headers": {
69
+ "X-Goog-Api-Key": "your-stitch-api-key"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ - `codex`: edit `%USERPROFILE%/.codex/config.toml` and use HTTP transport, the fixed Stitch MCP URL, and the `X-Goog-Api-Key` header.
77
+ - The built-in `codex` adapter should launch Stitch write operations through `codex exec --dangerously-bypass-approvals-and-sandbox`; if a custom runner replaces it, that runner must provide the same write-bypass behavior.
78
+
79
+ ```toml
80
+ [mcp_servers.stitch]
81
+ type = "http"
82
+ url = "https://stitch.googleapis.com/mcp"
83
+ headers = { X-Goog-Api-Key = "your-stitch-api-key" }
84
+
85
+ [mcp_servers.stitch.http_headers]
86
+ X-Goog-Api-Key = "your-stitch-api-key"
87
+ ```
88
+
89
+ ## Stitch Canonical Layout
90
+
91
+ - Each business route must have exactly one canonical layout.
92
+ - `Light` and `Dark` must be theme variants of the same layout, not separate compositions.
93
+ - Theme-variant prompts must explicitly include:
94
+ - `Use the existing canonical screen as the base`
95
+ - `Keep the same layout structure`
96
+ - `Do not reorder modules`
97
+ - `Do not create a different composition`
98
+ - `Only transform the visual theme`