@aipper/aiws-spec 0.0.24 → 0.0.25

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/README.md +22 -0
  2. package/docs/aiws-bootstrap-routing-design.md +138 -0
  3. package/docs/aiws-governance-positioning.md +69 -0
  4. package/docs/cli-interface.md +87 -5
  5. package/docs/collaboration-artifacts.md +62 -0
  6. package/docs/opencode-omo-adapter.md +135 -0
  7. package/docs/opencode-omo-validation-checklist.md +90 -0
  8. package/docs/spec-contract.md +26 -11
  9. package/docs/superpowers-collaboration-adoption.md +92 -0
  10. package/docs/workflow-delegation-contracts.json +274 -0
  11. package/docs/workflow-delegation-contracts.md +248 -0
  12. package/docs/workflow-delegation-contracts.schema.json +176 -0
  13. package/docs/workflow-governance-rules.json +294 -0
  14. package/docs/workflow-governance-rules.md +63 -0
  15. package/docs/workflow-governance-rules.schema.json +182 -0
  16. package/docs/workflow-review-gates.json +72 -0
  17. package/docs/workflow-review-gates.md +36 -0
  18. package/docs/workflow-review-gates.schema.json +67 -0
  19. package/docs/workflow-router-rules.json +196 -0
  20. package/docs/workflow-router-rules.md +83 -0
  21. package/docs/workflow-router-rules.schema.json +119 -0
  22. package/docs/workflow-stage-contracts.json +148 -0
  23. package/docs/workflow-stage-contracts.md +70 -0
  24. package/docs/workflow-stage-contracts.schema.json +98 -0
  25. package/package.json +1 -1
  26. package/templates/workspace/.agents/skills/using-aiws/SKILL.md +83 -0
  27. package/templates/workspace/.agents/skills/ws-commit/SKILL.md +23 -0
  28. package/templates/workspace/.agents/skills/ws-delegate/SKILL.md +75 -0
  29. package/templates/workspace/.agents/skills/ws-deliver/SKILL.md +22 -0
  30. package/templates/workspace/.agents/skills/ws-dev/SKILL.md +35 -6
  31. package/templates/workspace/.agents/skills/ws-finish/SKILL.md +24 -0
  32. package/templates/workspace/.agents/skills/ws-frontend-design/SKILL.md +126 -0
  33. package/templates/workspace/.agents/skills/ws-handoff/SKILL.md +22 -1
  34. package/templates/workspace/.agents/skills/ws-plan/SKILL.md +25 -1
  35. package/templates/workspace/.agents/skills/ws-plan-verify/SKILL.md +20 -0
  36. package/templates/workspace/.agents/skills/ws-preflight/SKILL.md +23 -0
  37. package/templates/workspace/.agents/skills/ws-quality-review/SKILL.md +56 -0
  38. package/templates/workspace/.agents/skills/ws-review/SKILL.md +24 -0
  39. package/templates/workspace/.agents/skills/ws-spec-review/SKILL.md +57 -0
  40. package/templates/workspace/.agents/skills/ws-verify-before-complete/SKILL.md +59 -0
  41. package/templates/workspace/.claude/commands/using-aiws.md +24 -0
  42. package/templates/workspace/.claude/commands/ws-quality-review.md +24 -0
  43. package/templates/workspace/.claude/commands/ws-spec-review.md +24 -0
  44. package/templates/workspace/.claude/commands/ws-verify-before-complete.md +24 -0
  45. package/templates/workspace/.claude/skills/p-aiws-change-archive/SKILL.md +24 -0
  46. package/templates/workspace/.claude/skills/p-aiws-change-finish/SKILL.md +24 -0
  47. package/templates/workspace/.claude/skills/p-aiws-change-list/SKILL.md +18 -0
  48. package/templates/workspace/.claude/skills/p-aiws-change-new/SKILL.md +26 -0
  49. package/templates/workspace/.claude/skills/p-aiws-change-next/SKILL.md +19 -0
  50. package/templates/workspace/.claude/skills/p-aiws-change-start/SKILL.md +33 -0
  51. package/templates/workspace/.claude/skills/p-aiws-change-status/SKILL.md +19 -0
  52. package/templates/workspace/.claude/skills/p-aiws-change-sync/SKILL.md +19 -0
  53. package/templates/workspace/.claude/skills/p-aiws-change-templates-init/SKILL.md +18 -0
  54. package/templates/workspace/.claude/skills/p-aiws-change-templates-which/SKILL.md +18 -0
  55. package/templates/workspace/.claude/skills/p-aiws-change-validate/SKILL.md +23 -0
  56. package/templates/workspace/.claude/skills/p-aiws-hooks-install/SKILL.md +30 -0
  57. package/templates/workspace/.claude/skills/p-aiws-hooks-status/SKILL.md +18 -0
  58. package/templates/workspace/.claude/skills/p-aiws-init/SKILL.md +27 -0
  59. package/templates/workspace/.claude/skills/p-aiws-rollback/SKILL.md +18 -0
  60. package/templates/workspace/.claude/skills/p-aiws-update/SKILL.md +26 -0
  61. package/templates/workspace/.claude/skills/p-aiws-validate/SKILL.md +22 -0
  62. package/templates/workspace/.claude/skills/p-tasks-plan/SKILL.md +37 -0
  63. package/templates/workspace/.claude/skills/using-aiws/SKILL.md +83 -0
  64. package/templates/workspace/.claude/skills/ws-analyze/SKILL.md +26 -0
  65. package/templates/workspace/.claude/skills/ws-bugfix/SKILL.md +111 -0
  66. package/templates/workspace/.claude/skills/ws-commit/SKILL.md +127 -0
  67. package/templates/workspace/.claude/skills/ws-deliver/SKILL.md +231 -0
  68. package/templates/workspace/.claude/skills/ws-dev/SKILL.md +168 -0
  69. package/templates/workspace/.claude/skills/ws-finish/SKILL.md +220 -0
  70. package/templates/workspace/.claude/skills/ws-frontend-design/SKILL.md +126 -0
  71. package/templates/workspace/.claude/skills/ws-handoff/SKILL.md +52 -0
  72. package/templates/workspace/.claude/skills/ws-migrate/SKILL.md +54 -0
  73. package/templates/workspace/.claude/skills/ws-plan/SKILL.md +138 -0
  74. package/templates/workspace/.claude/skills/ws-plan-verify/SKILL.md +61 -0
  75. package/templates/workspace/.claude/skills/ws-preflight/SKILL.md +55 -0
  76. package/templates/workspace/.claude/skills/ws-pull/SKILL.md +119 -0
  77. package/templates/workspace/.claude/skills/ws-push/SKILL.md +110 -0
  78. package/templates/workspace/.claude/skills/ws-quality-review/SKILL.md +56 -0
  79. package/templates/workspace/.claude/skills/ws-req-change/SKILL.md +41 -0
  80. package/templates/workspace/.claude/skills/ws-req-contract-sync/SKILL.md +17 -0
  81. package/templates/workspace/.claude/skills/ws-req-contract-validate/SKILL.md +12 -0
  82. package/templates/workspace/.claude/skills/ws-req-flow-sync/SKILL.md +28 -0
  83. package/templates/workspace/.claude/skills/ws-req-review/SKILL.md +32 -0
  84. package/templates/workspace/.claude/skills/ws-review/SKILL.md +50 -0
  85. package/templates/workspace/.claude/skills/ws-rule/SKILL.md +23 -0
  86. package/templates/workspace/.claude/skills/ws-spec-review/SKILL.md +57 -0
  87. package/templates/workspace/.claude/skills/ws-submodule-setup/SKILL.md +65 -0
  88. package/templates/workspace/.claude/skills/ws-verify-before-complete/SKILL.md +59 -0
  89. package/templates/workspace/.opencode/command/using-aiws.md +29 -0
  90. package/templates/workspace/.opencode/command/ws-delegate.md +33 -0
  91. package/templates/workspace/.opencode/command/ws-plan.md +3 -0
  92. package/templates/workspace/.opencode/command/ws-preflight.md +4 -0
  93. package/templates/workspace/.opencode/command/ws-quality-review.md +30 -0
  94. package/templates/workspace/.opencode/command/ws-review.md +3 -0
  95. package/templates/workspace/.opencode/command/ws-spec-review.md +30 -0
  96. package/templates/workspace/.opencode/command/ws-verify-before-complete.md +27 -0
  97. package/templates/workspace/.opencode/commands/p-aiws-change-archive.md +27 -0
  98. package/templates/workspace/.opencode/commands/p-aiws-change-finish.md +27 -0
  99. package/templates/workspace/.opencode/commands/p-aiws-change-list.md +26 -0
  100. package/templates/workspace/.opencode/commands/p-aiws-change-new.md +27 -0
  101. package/templates/workspace/.opencode/commands/p-aiws-change-next.md +27 -0
  102. package/templates/workspace/.opencode/commands/p-aiws-change-start.md +27 -0
  103. package/templates/workspace/.opencode/commands/p-aiws-change-status.md +27 -0
  104. package/templates/workspace/.opencode/commands/p-aiws-change-sync.md +27 -0
  105. package/templates/workspace/.opencode/commands/p-aiws-change-templates-init.md +26 -0
  106. package/templates/workspace/.opencode/commands/p-aiws-change-templates-which.md +26 -0
  107. package/templates/workspace/.opencode/commands/p-aiws-change-validate.md +27 -0
  108. package/templates/workspace/.opencode/commands/p-aiws-hooks-install.md +26 -0
  109. package/templates/workspace/.opencode/commands/p-aiws-hooks-status.md +26 -0
  110. package/templates/workspace/.opencode/commands/p-aiws-init.md +23 -0
  111. package/templates/workspace/.opencode/commands/p-aiws-rollback.md +16 -0
  112. package/templates/workspace/.opencode/commands/p-aiws-update.md +22 -0
  113. package/templates/workspace/.opencode/commands/p-aiws-validate.md +17 -0
  114. package/templates/workspace/.opencode/commands/using-aiws.md +29 -0
  115. package/templates/workspace/.opencode/commands/ws-analyze.md +30 -0
  116. package/templates/workspace/.opencode/commands/ws-bugfix.md +35 -0
  117. package/templates/workspace/.opencode/commands/ws-commit.md +70 -0
  118. package/templates/workspace/.opencode/commands/ws-delegate.md +33 -0
  119. package/templates/workspace/.opencode/commands/ws-deliver.md +58 -0
  120. package/templates/workspace/.opencode/commands/ws-dev.md +36 -0
  121. package/templates/workspace/.opencode/commands/ws-finish.md +71 -0
  122. package/templates/workspace/.opencode/commands/ws-handoff.md +25 -0
  123. package/templates/workspace/.opencode/commands/ws-migrate.md +25 -0
  124. package/templates/workspace/.opencode/commands/ws-plan-verify.md +28 -0
  125. package/templates/workspace/.opencode/commands/ws-plan.md +27 -0
  126. package/templates/workspace/.opencode/commands/ws-preflight.md +34 -0
  127. package/templates/workspace/.opencode/commands/ws-pull.md +87 -0
  128. package/templates/workspace/.opencode/commands/ws-push.md +93 -0
  129. package/templates/workspace/.opencode/commands/ws-quality-review.md +30 -0
  130. package/templates/workspace/.opencode/commands/ws-req-change.md +45 -0
  131. package/templates/workspace/.opencode/commands/ws-req-contract-sync.md +21 -0
  132. package/templates/workspace/.opencode/commands/ws-req-contract-validate.md +16 -0
  133. package/templates/workspace/.opencode/commands/ws-req-flow-sync.md +23 -0
  134. package/templates/workspace/.opencode/commands/ws-req-review.md +36 -0
  135. package/templates/workspace/.opencode/commands/ws-review.md +33 -0
  136. package/templates/workspace/.opencode/commands/ws-rule.md +27 -0
  137. package/templates/workspace/.opencode/commands/ws-spec-review.md +30 -0
  138. package/templates/workspace/.opencode/commands/ws-submodule-setup.md +57 -0
  139. package/templates/workspace/.opencode/commands/ws-verify-before-complete.md +27 -0
  140. package/templates/workspace/.opencode/oh-my-opencode.json.example +17 -0
  141. package/templates/workspace/.opencode/skills/p-aiws-change-archive/SKILL.md +24 -0
  142. package/templates/workspace/.opencode/skills/p-aiws-change-finish/SKILL.md +24 -0
  143. package/templates/workspace/.opencode/skills/p-aiws-change-list/SKILL.md +18 -0
  144. package/templates/workspace/.opencode/skills/p-aiws-change-new/SKILL.md +26 -0
  145. package/templates/workspace/.opencode/skills/p-aiws-change-next/SKILL.md +19 -0
  146. package/templates/workspace/.opencode/skills/p-aiws-change-start/SKILL.md +33 -0
  147. package/templates/workspace/.opencode/skills/p-aiws-change-status/SKILL.md +19 -0
  148. package/templates/workspace/.opencode/skills/p-aiws-change-sync/SKILL.md +19 -0
  149. package/templates/workspace/.opencode/skills/p-aiws-change-templates-init/SKILL.md +18 -0
  150. package/templates/workspace/.opencode/skills/p-aiws-change-templates-which/SKILL.md +18 -0
  151. package/templates/workspace/.opencode/skills/p-aiws-change-validate/SKILL.md +23 -0
  152. package/templates/workspace/.opencode/skills/p-aiws-hooks-install/SKILL.md +30 -0
  153. package/templates/workspace/.opencode/skills/p-aiws-hooks-status/SKILL.md +18 -0
  154. package/templates/workspace/.opencode/skills/p-aiws-init/SKILL.md +27 -0
  155. package/templates/workspace/.opencode/skills/p-aiws-rollback/SKILL.md +18 -0
  156. package/templates/workspace/.opencode/skills/p-aiws-update/SKILL.md +26 -0
  157. package/templates/workspace/.opencode/skills/p-aiws-validate/SKILL.md +22 -0
  158. package/templates/workspace/.opencode/skills/p-tasks-plan/SKILL.md +37 -0
  159. package/templates/workspace/.opencode/skills/using-aiws/SKILL.md +87 -0
  160. package/templates/workspace/.opencode/skills/ws-analyze/SKILL.md +26 -0
  161. package/templates/workspace/.opencode/skills/ws-bugfix/SKILL.md +111 -0
  162. package/templates/workspace/.opencode/skills/ws-commit/SKILL.md +127 -0
  163. package/templates/workspace/.opencode/skills/ws-delegate/SKILL.md +63 -0
  164. package/templates/workspace/.opencode/skills/ws-deliver/SKILL.md +231 -0
  165. package/templates/workspace/.opencode/skills/ws-dev/SKILL.md +168 -0
  166. package/templates/workspace/.opencode/skills/ws-finish/SKILL.md +220 -0
  167. package/templates/workspace/.opencode/skills/ws-frontend-design/SKILL.md +126 -0
  168. package/templates/workspace/.opencode/skills/ws-handoff/SKILL.md +52 -0
  169. package/templates/workspace/.opencode/skills/ws-migrate/SKILL.md +54 -0
  170. package/templates/workspace/.opencode/skills/ws-plan/SKILL.md +148 -0
  171. package/templates/workspace/.opencode/skills/ws-plan-verify/SKILL.md +61 -0
  172. package/templates/workspace/.opencode/skills/ws-preflight/SKILL.md +60 -0
  173. package/templates/workspace/.opencode/skills/ws-pull/SKILL.md +119 -0
  174. package/templates/workspace/.opencode/skills/ws-push/SKILL.md +110 -0
  175. package/templates/workspace/.opencode/skills/ws-quality-review/SKILL.md +63 -0
  176. package/templates/workspace/.opencode/skills/ws-req-change/SKILL.md +41 -0
  177. package/templates/workspace/.opencode/skills/ws-req-contract-sync/SKILL.md +17 -0
  178. package/templates/workspace/.opencode/skills/ws-req-contract-validate/SKILL.md +12 -0
  179. package/templates/workspace/.opencode/skills/ws-req-flow-sync/SKILL.md +28 -0
  180. package/templates/workspace/.opencode/skills/ws-req-review/SKILL.md +32 -0
  181. package/templates/workspace/.opencode/skills/ws-review/SKILL.md +57 -0
  182. package/templates/workspace/.opencode/skills/ws-rule/SKILL.md +23 -0
  183. package/templates/workspace/.opencode/skills/ws-spec-review/SKILL.md +64 -0
  184. package/templates/workspace/.opencode/skills/ws-submodule-setup/SKILL.md +65 -0
  185. package/templates/workspace/.opencode/skills/ws-verify-before-complete/SKILL.md +59 -0
  186. package/templates/workspace/AGENTS.md +72 -30
  187. package/templates/workspace/changes/README.md +18 -0
  188. package/templates/workspace/changes/templates/proposal.md +15 -0
  189. package/templates/workspace/changes/templates/tasks.md +9 -2
  190. package/templates/workspace/manifest.json +277 -2
  191. package/templates/workspace/tools/ws_change_check.py +26 -4
@@ -0,0 +1,126 @@
1
+ ---
2
+ name: ws-frontend-design
3
+ description: 前端设计实现(用于视觉型 landing page / 网站 / 应用界面 / demo / prototype;强调构图、层级、图像、动效与克制,不做通用卡片墙)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:
9
+ - 在 AIWS 约束下交付一个可运行、可验证、视觉方向明确的前端界面
10
+ - 先做信息层级与构图,再做组件细节;避免“先堆卡片再补样式”
11
+ - 在品牌页与产品页之间做正确取舍:品牌页重视觉锚点,产品页重可操作性
12
+
13
+ 非目标(强制):
14
+ - 不绕过 `$ws-preflight`、`REQUIREMENTS.md`、`AI_WORKSPACE.md`
15
+ - 不因为“追求设计感”而重写无关页面、改动无关设计系统或新增大面积依赖
16
+ - 不默认把已有产品后台改成营销页;dashboard / admin / workspace 优先 utility copy
17
+ - 不把 prompt 语言、设计说明、占位废话直接写进 UI
18
+
19
+ 适用场景:
20
+ - 用户要做 landing page、品牌站、活动页、marketing 页面、demo、prototype、game UI
21
+ - 用户要把现有前端界面做成“视觉主导、层级清晰、记忆点强”的版本
22
+ - 用户明确要求美化、重做、提质、增强 art direction / hierarchy / motion
23
+
24
+ 前置(建议顺序):
25
+ 1) 先运行 `$ws-preflight`。
26
+ 2) 判断任务类型(必须选一个):
27
+ - `landing`:品牌/营销/活动页
28
+ - `app-ui`:dashboard / admin / workspace / 工具界面
29
+ - `polish-only`:不改信息架构,只做视觉提质
30
+ 3) 判断设计边界(必须说明):
31
+ - `net-new`:全新页面,可建立完整视觉语言
32
+ - `existing-system`:已有设计系统/品牌规范,优先复用
33
+ 4) 若任务达到 medium / complex:先用 `$ws-plan` 落盘计划,再进入实现。
34
+
35
+ 开始编码前,先写三项(不要跳过):
36
+ - `Visual thesis:` 一句话写清 mood / material / energy
37
+ - `Content plan:` `hero -> support -> detail -> final CTA`(若是 app-ui,则改为 `workspace -> nav -> context -> action`)
38
+ - `Interaction thesis:` 2-3 个动效想法;说明它们如何改善层级/氛围/可感知性
39
+
40
+ 设计默认值:
41
+ - 从构图开始,不从组件库开始
42
+ - 第一屏优先做成海报感(poster),不是文档感(document)
43
+ - 默认先找一个强视觉锚点:大图、主视觉平面、关键产品画面、主数据工作区
44
+ - 默认不做卡片墙;优先 section、column、divider、media block、list、plain layout
45
+ - 默认最多两套字体、一种强调色;若已有品牌系统,优先跟随现有 token
46
+ - 优先靠留白、尺度、裁切、对比、对齐建立层级,再考虑装饰
47
+
48
+ landing 规则:
49
+ 1) 默认结构:
50
+ - Hero:品牌/产品名、承诺、CTA、一个主视觉
51
+ - Support:一个具体能力 / 证明点 / offer
52
+ - Detail:氛围、流程、产品深度或故事
53
+ - Final CTA:开始、注册、联系、访问
54
+ 2) Hero 强约束:
55
+ - 一个 section 只承载一个 dominant idea
56
+ - 默认使用 full-bleed hero;只有内层文字列需要约束宽度
57
+ - 品牌名优先级高于 headline;headline 高于 body;body 高于 CTA
58
+ - 默认不要 hero cards、stat strips、logo clouds、pill soup、floating dashboards
59
+ - headline 在 desktop 约 2-3 行;mobile 一眼读完
60
+ - 若有固定 header,它占用首屏预算;不要让 header + hero 超出初始 viewport
61
+ - 若去掉主视觉后首屏仍几乎成立,说明图像太弱
62
+
63
+ app-ui 规则:
64
+ - 默认偏克制:少颜色、少 chrome、清晰栅格、密度适中、信息可扫读
65
+ - 优先组织为:`primary workspace -> navigation -> secondary context/inspector -> action`
66
+ - 只有当 card 本身就是交互容器时才用 card;否则尽量改回 plain layout
67
+ - 不要把 routine product UI 做成营销落地页
68
+ - 文案优先 orientation / status / action:
69
+ - 好例子:`Selected KPIs`、`Plan status`、`Last sync`
70
+ - 差例子:首页口号、情绪化隐喻、执行摘要横幅
71
+
72
+ 图像与媒体:
73
+ - 图像必须承担叙事任务,不能只是补背景
74
+ - 品牌页/空间页/生活方式产品优先真实感强的图,而不是抽象 3D / 假 dashboard
75
+ - 选图时优先有稳定明暗区,便于文字落位
76
+ - 避免图里自带抢戏的 logo、signage、碎字、边框 UI
77
+ - 若需要多个场景,优先多张图,不要拼贴大杂烩
78
+
79
+ 文案:
80
+ - 用产品语言,不用设计评论语言
81
+ - headline 负责主要意义;supporting copy 通常一句话够了
82
+ - 每个 section 只负责一件事:explain / prove / deepen / convert
83
+ - 如果删掉 30% 文案后更清楚,就继续删
84
+
85
+ 动效:
86
+ - 视觉型页面至少给 2-3 个“有感但克制”的动效:
87
+ - 一个 hero 入场序列
88
+ - 一个 scroll-linked / sticky / depth 效果
89
+ - 一个 hover / reveal / layout transition
90
+ - 动效必须改善层级或氛围,不能只是热闹
91
+ - 要兼顾 mobile 流畅度;支持 `prefers-reduced-motion`
92
+
93
+ 工程约束(强制):
94
+ - 先读现有代码,再决定是否沿用已有 design tokens / 组件 / 动效库
95
+ - `existing-system` 场景下,优先复用已有视觉语言;不要无故“整站改头换面”
96
+ - 不新增字体、图片资源、动画库、运行时依赖,除非明确写出原因、来源、license/成本与回滚方式
97
+ - 所有文字覆盖在图像上时,必须保证对比度与点击区域可用
98
+ - 必须同时考虑 desktop / mobile;不要只调一个 viewport
99
+ - 未运行不声称已运行;验证命令优先引用 `AI_WORKSPACE.md`
100
+
101
+ 硬规则:
102
+ - No cards by default
103
+ - No hero cards by default
104
+ - No generic SaaS card grid as first impression
105
+ - No more than one dominant idea per section
106
+ - No more than two typefaces without a clear reason
107
+ - No more than one accent color unless the existing product already has a strong system
108
+ - No decorative gradients behind routine product UI
109
+ - No busy imagery behind text
110
+ - No filler copy
111
+
112
+ 实现检查(交付前自检):
113
+ - 第一屏能否一眼看出品牌/产品是什么
114
+ - 是否存在一个明确视觉锚点
115
+ - 只扫标题是否能理解页面
116
+ - 每个 section 是否只有一个职责
117
+ - card 是否真有必要
118
+ - 动效是否真的提升层级/氛围
119
+ - 去掉装饰阴影后,页面是否仍然成立
120
+
121
+ 输出要求:
122
+ - `Mode:` `landing | app-ui | polish-only`
123
+ - `Visual thesis:` 一句话
124
+ - `Changed:` 改动文件清单
125
+ - `Verify:` 实际运行命令 + 预期结果
126
+ - `Evidence:` 相关 `plan/...`、`changes/<change-id>/...` 或截图/审计路径
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: ws-handoff
3
+ description: 交接(归档后生成/查看 changes/archive/.../handoff.md)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:
9
+ - 让 change 的交接信息可回放:`handoff.md`(包含:本次完成/改动文件/关键决策/下一步建议/绑定)
10
+ - 若存在协同工件:在 handoff 中一并概述 `analysis/`、`patches/`、`review/`、`evidence/`
11
+ - 指引在归档与依赖场景下如何使用 handoff
12
+
13
+ 说明:
14
+ - `handoff.md` 由 `aiws change archive` 自动生成:`changes/archive/<date>-<change-id>/handoff.md`
15
+ - `Depends_On` 依赖若已归档,`aiws change start` 会尝试读取依赖的 `handoff.md` 并输出摘要
16
+
17
+ 阶段定位:
18
+ - handoff / archive 阶段;负责把已完成 change 的上下文压缩成后续协作者可直接接手的说明。
19
+
20
+ 必需输入:
21
+ - 当前或已归档的 `change/<change-id>`
22
+ - 对应 archive 目录或准备归档的 change 工件
23
+
24
+ 必需输出:
25
+ - `Change_ID:` 当前交接对象
26
+ - `Handoff:` `changes/archive/.../handoff.md`
27
+ - `Next:` 推荐后续 change / `Depends_On` 关系
28
+
29
+ 阻断条件:
30
+ - 无法定位目标 change
31
+ - 未归档且无法执行 `aiws change archive <change-id>`
32
+ - `handoff.md` 无法生成或读取
33
+
34
+ 完成判定:
35
+ - 下一位协作者可以只依赖 `handoff.md` 和绑定信息继续工作,而不需要回溯整段会话。
36
+
37
+ 执行建议:
38
+ 1) 先运行 `$ws-preflight`。
39
+ 2) 若本 change 已完成并准备归档:运行 `aiws change archive <change-id>`(会先做严格校验,并移动目录到 `changes/archive/`,同时生成 `handoff.md`)。
40
+ 3) 查看 handoff:
41
+ ```bash
42
+ change_id="<change-id>"
43
+ ls -1 changes/archive/*-"${change_id}"/handoff.md
44
+ sed -n '1,160p' changes/archive/*-"${change_id}"/handoff.md
45
+ ```
46
+ 4) 若要让后续 change 可接力:在 `proposal.md` 里声明 `Blocks`(下一步建议会据此生成)。
47
+ 5) 若本 change 使用了外部 / 子 agent 协作:确认关键结论已经进入 `review/` 或 `evidence/`,避免 handoff 只留下原始 patch/分析文件而没有最终结论。
48
+
49
+ 输出要求:
50
+ - `Change_ID:` <change-id>
51
+ - `Handoff:` `changes/archive/.../handoff.md`
52
+ - `Next:` 若还有后续工作,建议创建新 change 并在其 `Depends_On` 引用本 change
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: ws-migrate
3
+ description: 迁移(补齐/升级 AIWS 工作区文件)
4
+ ---
5
+
6
+ 用中文输出;命令与路径保持原样不翻译。
7
+
8
+ 目标:把当前仓库补齐为 aiws workspace 模板,并启用可验证门禁。
9
+
10
+ 执行(在项目根目录):
11
+ ```bash
12
+ if [[ -f ".aiws/manifest.json" ]]; then
13
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
14
+ ./node_modules/.bin/aiws update .
15
+ elif command -v aiws >/dev/null 2>&1; then
16
+ aiws update .
17
+ else
18
+ npx @aipper/aiws update .
19
+ fi
20
+ else
21
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
22
+ ./node_modules/.bin/aiws init .
23
+ elif command -v aiws >/dev/null 2>&1; then
24
+ aiws init .
25
+ else
26
+ npx @aipper/aiws init .
27
+ fi
28
+ fi
29
+
30
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
31
+ ./node_modules/.bin/aiws validate .
32
+ elif command -v aiws >/dev/null 2>&1; then
33
+ aiws validate .
34
+ else
35
+ npx @aipper/aiws validate .
36
+ fi
37
+
38
+ git config core.hooksPath .githooks
39
+ ```
40
+
41
+ 回滚(恢复最近一次快照):
42
+ ```bash
43
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
44
+ ./node_modules/.bin/aiws rollback . latest
45
+ elif command -v aiws >/dev/null 2>&1; then
46
+ aiws rollback . latest
47
+ else
48
+ npx @aipper/aiws rollback . latest
49
+ fi
50
+ ```
51
+
52
+ 约束:
53
+ - 不写入任何 secrets。
54
+ - 不执行破坏性命令。
@@ -0,0 +1,148 @@
1
+ ---
2
+ name: ws-plan
3
+ description: 规划(生成可落盘 plan/ 工件;供 ws-dev 执行)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:
9
+ - 对齐真值文件(`AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`)
10
+ - 若尚未进入本次 change 的工作上下文:先建立 `change/<change-id>` 分支 / worktree,再生成计划
11
+ - 为当前任务生成一份可追踪的执行计划文件:`plan/<timestamp>-<slug>.md`
12
+ - 计划必须包含可复现验证命令(优先引用 `AI_WORKSPACE.md`)
13
+ - 计划必须包含“主索引绑定”:`Change_ID` / (`Req_ID` or `Problem_ID`) / `Contract_Row` / `Plan_File` / `Evidence_Path`
14
+
15
+ OpenCode + oMo 优先策略:
16
+ - 若检测到 `.opencode/oh-my-opencode.json`,或当前会话明确可用 `planner-sisyphus` / `explore` / `librarian`,优先按 `packages/spec/docs/opencode-omo-adapter.md` 借用这些 agent。
17
+ - 计划主框架优先交给 `planner-sisyphus`;代码结构探索优先交给 `@explore`;规范/文档/依赖查证优先交给 `@librarian`。
18
+ - 主 agent 负责回收这些结果并最终落盘 `plan/...`;不要把“调用了 oMo agent”当作已经完成计划。
19
+
20
+ 约束:
21
+ - 不写入任何 secrets(token、账号、内网端点等不得进入 git)
22
+ - 本 skill 只负责“想清楚怎么做 + 落盘计划”,不要直接大规模改动代码
23
+ - 未运行不声称已运行;验证命令要写清“预期结果”
24
+ - 若存在 `changes/<change-id>/proposal.md`,计划与 proposal 的绑定字段必须保持一致(不一致时先修正再继续)
25
+
26
+ 阶段定位:
27
+ - planning 阶段;负责把用户目标收敛为 change 绑定、计划文件和验证入口。
28
+
29
+ 必需输入:
30
+ - 当前任务描述
31
+ - 真值文件:`AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`
32
+ - 若已存在:`changes/<change-id>/proposal.md`
33
+ - 若已有计划:当前 `plan/...` 文件
34
+
35
+ 必需输出:
36
+ - `Plan file:` 实际写入的 `plan/...`
37
+ - `Change context:` 当前生效的 `change/<change-id>` 分支或 worktree
38
+ - `Bindings:` `Change_ID` / `Req_ID|Problem_ID` / `Contract_Row` / `Plan_File` / `Evidence_Path`
39
+ - `Verify:` 可复现验证命令与预期
40
+ - `Next:` 先 `$ws-plan-verify`,通过后再 `$ws-dev`
41
+
42
+ 阻断条件:
43
+ - 任务目标或归因绑定不清晰
44
+ - 当前工作区 dirty 且尚未进入可复用的 change 上下文
45
+ - 无法把计划实际写盘
46
+
47
+ 完成判定:
48
+ - 计划已落盘、绑定已同步、验证入口明确,后续实现可以直接按计划推进。
49
+
50
+ 执行步骤(建议):
51
+ 1) 先运行 `$ws-preflight`(读取真值文件并输出约束摘要)。
52
+ - 若检测到 oMo:优先让 `planner-sisyphus` 生成 planning draft;若需要补结构探索,再委托 `@explore` / `@librarian`。
53
+ 2) 若用户任务描述不清:先问 1-3 个关键澄清问题(不要猜)。
54
+ 3) 判断复杂度:`simple / medium / complex`(给出一句理由),并估算步骤数。
55
+ 4) 识别或建立主索引 / change 上下文:
56
+ - 若存在 `changes/<change-id>/proposal.md`:读取其中 `Change_ID` / `Req_ID` / `Problem_ID` / `Contract_Row` / `Evidence_Path`
57
+ - 若缺失关键绑定:先补齐 proposal(至少 `Change_ID`、`Req_ID|Problem_ID`、`Contract_Row`)再继续生成计划
58
+ - 若当前不在 `change/<change-id>` 分支 / worktree,且本次任务需要新建 change:先调用 `aiws change start` 建立上下文,再继续写 plan
59
+ - 推荐顺序:
60
+ - 工作区已存在未提交改动:不要先写 `plan/...`;先停下来说明原因,并要求用户先 commit/stash,或改用已有 change 上下文
61
+ - 仓库已有提交:优先创建独立 worktree;若仓库声明了 submodules,加上 `--submodules`
62
+ - 仓库尚无提交 / 不满足 worktree 前置条件:回退为 `--no-switch`
63
+ ```bash
64
+ change_id="<change-id>"
65
+ if [[ -n "$(git status --porcelain)" ]]; then
66
+ echo "error: working tree dirty before ws-plan creates change context"
67
+ echo "hint: commit/stash first, or continue inside an existing change/<change-id> context"
68
+ exit 2
69
+ fi
70
+
71
+ has_commits=0
72
+ git rev-parse --verify HEAD >/dev/null 2>&1 && has_commits=1
73
+
74
+ has_submodules=0
75
+ if [[ -f .gitmodules ]] && git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' >/dev/null 2>&1; then
76
+ has_submodules=1
77
+ fi
78
+
79
+ if [[ "${has_commits}" -eq 1 ]]; then
80
+ if [[ "${has_submodules}" -eq 1 ]]; then
81
+ aiws change start "${change_id}" --hooks --worktree --submodules
82
+ else
83
+ aiws change start "${change_id}" --hooks --worktree
84
+ fi
85
+ else
86
+ aiws change start "${change_id}" --hooks --no-switch
87
+ fi
88
+ ```
89
+ - 若上一步创建了 worktree:后续所有读取/写入都必须切到 `aiws change start` 输出的 `worktree:` 路径中进行;不要把 `plan/...` 写回原工作区
90
+ 5) 生成计划文件:
91
+ - 文件名:`plan/YYYY-MM-DD_HH-MM-SS-<slug>.md`(`<slug>` 用 kebab-case;同一任务调整计划时尽量复用同一文件)
92
+ - 若 `plan/` 不存在先创建
93
+ - 必须实际写入到磁盘(不要只在对话里输出);如因权限/策略无法写盘,必须明确说明原因并输出可复制的完整内容
94
+ - 计划必须写在当前 active change 上下文内:若当前已进入 `change/<change-id>` worktree,则 `plan/...`、`proposal.md`、`tasks.md` 都应写在该 worktree 中
95
+ 6) 计划内容至少包含(不要留空):
96
+ - `Bindings`:`Change_ID` / `Req_ID` / `Problem_ID` / `Contract_Row` / `Plan_File` / `Evidence_Path`
97
+ - `Goal`:要达成什么
98
+ - `Non-goals`:明确不做什么(避免 scope creep)
99
+ - `Scope`:将改动的文件/目录清单(不确定就写 `TBD` 并说明如何确定)
100
+ - `Plan`:分步执行(每步尽量落到具体文件/命令;必要时拆 Phase)
101
+ - `Submodules`(当存在 `.gitmodules` 且声明了 submodule 条目时,强制):声明“本次 change 的 submodule 目标分支真值”(用于同一 superproject 分支内的多渠道交付;也避免仅靠 `.gitmodules` 默认分支导致交付推送到错误分支)
102
+ - `Verify`:可复现命令 + 期望结果(优先引用 `AI_WORKSPACE.md` 的入口;必要时补充 e2e)
103
+ - `Risks & Rollback`:风险点 + 回滚方案(例如 git 回滚、`aiws rollback`、恢复备份等)
104
+ - `Evidence`:计划文件路径;若创建了变更工件则附 `changes/<change-id>/...`
105
+ 7) 若存在 change proposal:回填并对齐 `proposal.md` 的 `Plan_File`(必要时同步 `Contract_Row` / `Evidence_Path`),保证 plan/proposal 一致。
106
+ 8) 运行 `$ws-plan-verify` 作为执行前质量门(计划不过长、不跑偏、验证可复现)。
107
+ 9) 若计划涉及“需求/验收”变更:先用 `$ws-req-review` 评审 → 用户确认后再 `$ws-req-change` 落盘(避免需求漂移)。
108
+ 10) 多步任务(≥2 步):后续进入实现时,使用 `update_plan` 工具跟踪 `pending → in_progress → completed`。
109
+
110
+ oMo 回退:
111
+ - 若当前没有 oMo、没有 `planner-sisyphus`,或你无法稳定调用相关 agent:直接回退为普通 OpenCode `plan` / 当前 agent 本地规划。
112
+ - 回退不改变 AIWS 的要求:`plan/...` 仍必须落盘,bindings / verify / risks / evidence 仍必须完整。
113
+
114
+ 补充:submodule 目标分支真值(强约束;同一 superproject 分支内可多渠道)
115
+ - 背景:`.gitmodules submodule.<name>.branch` 适合作为“团队默认分支真值”,但当同一 superproject 分支需要在不同交付中选择不同 submodule 目标分支(多渠道)时,仅靠 `.gitmodules` 不足。
116
+ - 强约束:当 `.gitmodules` 声明了 submodule 条目时,门禁会要求本次 change 存在该文件且覆盖所有 submodule path(否则 `aiws validate .` / `aiws change validate --strict` 阻断)。
117
+ - 约定:为本次 change 落盘一个“交付目标分支映射”文件,并在后续 `$ws-dev`/`$ws-deliver`/`$ws-finish` 优先使用它:
118
+ - 文件:`changes/<change-id>/submodules.targets`
119
+ - 格式:每行一个 submodule(忽略空行与 `#` 注释),字段用空白分隔(推荐 `TAB`):
120
+ - 第 1 列:submodule path(例如 `vendor/foo`)
121
+ - 第 2 列:target branch(例如 `release/channel-a`)
122
+ - 第 3 列(可选):remote 名(默认 `origin`)
123
+ - 生成模板(建议在确认 `Change_ID` 后执行;如文件已存在先备份再覆盖):
124
+ ```bash
125
+ change_id="<change-id>"
126
+ targets="changes/${change_id}/submodules.targets"
127
+ mkdir -p "changes/${change_id}"
128
+ if [[ -f "${targets}" ]]; then
129
+ bak="${targets}.bak.$(date -u +%Y%m%d-%H%M%SZ)"
130
+ cp "${targets}" "${bak}"
131
+ echo "info: backup: ${bak}"
132
+ fi
133
+ : > "${targets}"
134
+ echo "# path<TAB>target_branch<TAB>remote(optional, default=origin)" >> "${targets}"
135
+ while read -r key sub_path; do
136
+ name="${key#submodule.}"; name="${name%.path}"
137
+ b="$(git config --file .gitmodules --get "submodule.${name}.branch" 2>/dev/null || true)"
138
+ [[ "${b:-}" == "." ]] && b="$(git branch --show-current)" # '.' means "follow superproject branch"
139
+ printf "%s\t%s\t%s\n" "${sub_path}" "${b:-<fill-me>}" "origin" >> "${targets}"
140
+ done < <(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null || true)
141
+ echo "ok: wrote ${targets}"
142
+ ```
143
+ - 计划里必须写清:本次交付选择的 `targets` 内容,以及后续在 `$ws-dev` 进入编码前会把 submodules 挂到 `aiws/pin/<target_branch>`(必要时先 `fetch`)。
144
+
145
+ 输出要求:
146
+ - `Plan file:` <实际写入的路径>
147
+ - `Change context:` <当前 change 分支或 worktree 路径;若新建了 worktree 需明确写出>
148
+ - `Next:` 推荐下一步(先 `$ws-plan-verify`,通过后再 `$ws-dev`;或 `aiws change start <change-id> --hooks`,superproject + submodule 可用 `--worktree`)
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: ws-plan-verify
3
+ description: 计划质检(执行前检查计划是否过长/跑偏,并给出最小修正清单)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:
9
+ - 在进入 `$ws-dev` 前,对 `plan/...` 与 `changes/<change-id>/proposal.md` 做一次“硬约束”质检
10
+ - 避免计划过长、步骤不够具体、验证不可复现、与需求合同绑定不一致
11
+ - 失败时只给最小修正项,修完后再进入实现
12
+
13
+ 适用时机:
14
+ - 已执行过 `$ws-plan`,且准备开始编码
15
+ - 或用户反馈“计划太长/容易跑偏”,需要先压缩并对齐
16
+
17
+ 阶段定位:
18
+ - planning gate;负责在编码前检查计划是否满足 change 严格契约。
19
+
20
+ 必需输入:
21
+ - 当前 `plan/...`
22
+ - `changes/<change-id>/proposal.md`
23
+ - 当前 change 上下文
24
+
25
+ 必需输出:
26
+ - `Quality gate:` pass/fail
27
+ - `Fix list:` 最小修正项
28
+ - `Next:` 通过则 `$ws-dev`,未通过则继续修正并复跑
29
+
30
+ 阻断条件:
31
+ - 无法定位当前 change 或计划文件
32
+ - `aiws change validate <change-id> --strict` 未通过
33
+
34
+ 完成判定:
35
+ - 计划满足严格门禁,且后续实现可以在不补需求/补绑定的情况下直接开始。
36
+
37
+ 执行步骤(建议):
38
+ 1) 先运行 `$ws-preflight`。
39
+ 2) 识别 change 上下文:
40
+ - 优先从当前分支推断 `change/<change-id>`
41
+ - 若无法推断:读取 `changes/*/proposal.md` 中的 `Change_ID`,并让用户确认本次要质检的 change
42
+ 3) 运行严格门禁(这是硬约束入口):
43
+ ```bash
44
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
45
+ ./node_modules/.bin/aiws change validate <change-id> --strict
46
+ elif command -v aiws >/dev/null 2>&1; then
47
+ aiws change validate <change-id> --strict
48
+ else
49
+ npx @aipper/aiws change validate <change-id> --strict
50
+ fi
51
+ ```
52
+ 4) 若失败:按报错逐条修正 `proposal.md` / `plan/...`,优先级如下:
53
+ - 先修绑定:`Change_ID` / `Req_ID|Problem_ID` / `Contract_Row` / `Plan_File` / `Evidence_Path`
54
+ - 再修计划质量:必需章节、步骤数量、步骤具体性、验证命令与预期
55
+ 5) 复跑 strict 校验,直到通过。
56
+ 6) 输出“可执行最小计划摘要”(3-8 步),再进入 `$ws-dev`。
57
+
58
+ 输出要求:
59
+ - `Quality gate:` pass/fail
60
+ - `Fix list:` 仅保留必须修改项(按阻断级别排序)
61
+ - `Next:` 通过后建议 `$ws-dev`;未通过则继续修正并复跑 strict
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: ws-preflight
3
+ description: 预检(提交前快速检查与建议)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:在开始任何“写代码/改配置/落盘文件”之前,对齐工作区真值文件,避免规则漂移。
9
+
10
+ 阶段定位:
11
+ - workflow 入口阶段;负责判断当前仓库是否具备继续执行其它 `ws-*` 阶段的前置条件。
12
+
13
+ 必需输入:
14
+ - 当前项目根目录候选路径
15
+ - `AI_PROJECT.md`
16
+ - `REQUIREMENTS.md`
17
+ - `AI_WORKSPACE.md`
18
+
19
+ 必需输出:
20
+ - `Root:` 当前项目根
21
+ - `Found:` 实际读取到的真值文件
22
+ - `Missing:` 缺失项
23
+ - `OpenCode mode:` `oMo-enabled` / `standard-opencode`
24
+ - `Key rules:` 3-8 条约束摘要
25
+ - `Next:` 若真值齐全,建议进入 `$ws-plan` 或 `$ws-dev`;若缺失,建议先 `aiws init .`
26
+
27
+ 阻断条件:
28
+ - 无法确定项目根目录
29
+ - 缺失任一真值文件
30
+
31
+ 完成判定:
32
+ - 使用者已经知道当前仓库能否继续进入后续阶段,以及必须遵守的约束与下一步入口。
33
+
34
+ 执行步骤(强制):
35
+ 1) 定位项目根目录:
36
+ - 优先:`git rev-parse --show-toplevel`
37
+ - 若失败:停止并让用户确认当前目录是否为项目根(不要猜测)。
38
+ 2) 在项目根目录读取以下文件(存在则必须读取;缺失则明确报告缺失项,不要臆测内容):
39
+ - `AI_PROJECT.md`
40
+ - `REQUIREMENTS.md`
41
+ - `AI_WORKSPACE.md`
42
+ 3) 若缺失任意真值文件:不要继续“写代码/改配置/落盘文件”。先输出缺失项,并给出下一步建议:
43
+ - `npx @aipper/aiws init .`(或 `aiws init .`)初始化真值文件
44
+ - 然后重新执行 `$ws-preflight`
45
+ 4) 输出:
46
+ - `Root:` <项目根路径>
47
+ - `Found:` <实际读取到的文件列表>
48
+ - `Missing:` <缺失文件列表>
49
+ - `OpenCode mode:`
50
+ - 若检测到 `.opencode/oh-my-opencode.json`:`oMo-enabled`
51
+ - 否则:`standard-opencode`
52
+ - 若为 `oMo-enabled`:附一句说明后续 `ws-plan` / `ws-review` / `ws-spec-review` / `ws-quality-review` / `ws-delegate` 会优先借用 oMo agent
53
+ - `Key rules:` 3–8 条 bullet(范围/禁止项/必须产物/必须验证命令)
54
+ 5) 若存在 `.gitmodules`:
55
+ - 输出 submodule 列表:`git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$'`
56
+ - 检查每个 submodule 是否配置 `submodule.<name>.branch`(缺失则提示先运行 `$ws-submodule-setup`;否则 `aiws validate .` 会失败)
57
+
58
+ 安全:
59
+ - 不打印 secrets;遇到疑似敏感值只提示“存在风险”但不要复述原文。
60
+ - 不执行破坏性命令。
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: ws-pull
3
+ description: 拉取并对齐 submodules(避免 detached;减少人为差异)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 背景:
9
+ - Git submodule 在别的电脑 `git submodule update` 后常见现象是子模块处于 detached HEAD(因为主仓库记录的是固定 gitlink commit)。
10
+ - detached 本身不一定是错,但会增加“需要手动切分支/容易忘”的操作差异。
11
+
12
+ 目标:
13
+ - 安全拉取 superproject(默认只允许 fast-forward)
14
+ - 初始化/同步 submodules(`--init --recursive`)
15
+ - 在**不改动 superproject gitlink commit** 的前提下,尽量把每个 submodule 从 detached HEAD “挂回”到一个**确定的目标分支**(仅当该分支包含 gitlink commit 时)
16
+ - 若未配置 `.gitmodules` 的 `submodule.<name>.branch`:保持 detached,并提示先运行 `$ws-submodule-setup`
17
+
18
+ 安全约束(强制):
19
+ - 不执行破坏性命令(不 `reset --hard` 主仓库;不改动远端)
20
+ - 不自动提交/不自动 push
21
+ - 若工作区不干净:停止并要求用户先 commit 或 stash(不要自动处理)
22
+
23
+ 执行步骤(建议):
24
+ 0) 输出上下文:
25
+ ```bash
26
+ git rev-parse --show-toplevel
27
+ git branch --show-current
28
+ git status --porcelain
29
+ ```
30
+ 若 `git status --porcelain` 非空:停止,要求用户先清理工作区(commit 或 stash)。
31
+
32
+ 1) 拉取 superproject(默认只允许 fast-forward,避免隐式 merge/rebase):
33
+ ```bash
34
+ git pull --ff-only
35
+ ```
36
+ 若失败(需要 merge/rebase):停止并向用户解释原因,让用户明确选择 `git pull --rebase` 或手动处理。
37
+
38
+ 2) 同步并更新 submodules 到 superproject 记录的 gitlink commit:
39
+ ```bash
40
+ if [[ -f .gitmodules ]]; then
41
+ git submodule sync --recursive
42
+ git submodule update --init --recursive
43
+ else
44
+ echo "[info] no .gitmodules"
45
+ fi
46
+ ```
47
+
48
+ 3) (可选但推荐)把 submodule 从 detached HEAD 尽量“挂回分支”,减少手工操作差异:
49
+
50
+ 说明:
51
+ - 该步骤不会改变 superproject 的 gitlink commit(也不会让主仓库出现“submodule modified”)。
52
+ - 只在目标分支包含该 gitlink commit 时才执行“挂回”;否则保持 detached 并提示原因。
53
+ - 为了避免 origin 分支较多时“猜错分支”,本步骤**只在** `.gitmodules` 明确配置了 `submodule.<name>.branch` 时才执行“挂回分支”;否则保持 detached 并提示先运行 `$ws-submodule-setup` 对齐配置。
54
+
55
+ ```bash
56
+ if [[ -f .gitmodules ]]; then
57
+ base_branch="$(git branch --show-current)"
58
+ git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null \
59
+ | while read -r key sub_path; do
60
+ [[ -z "${sub_path:-}" ]] && continue
61
+ name="${key#submodule.}"
62
+ name="${name%.path}"
63
+ echo "== submodule: ${sub_path} (${name}) =="
64
+
65
+ sub_sha="$(git rev-parse "HEAD:${sub_path}" 2>/dev/null || true)"
66
+ if [[ -z "${sub_sha:-}" ]]; then
67
+ echo "[warn] failed to read gitlink sha for ${sub_path}"
68
+ continue
69
+ fi
70
+
71
+ cfg_branch="$(git config --file .gitmodules --get "submodule.${name}.branch" 2>/dev/null || true)"
72
+ if [[ "${cfg_branch:-}" == "." ]]; then cfg_branch="$base_branch"; fi
73
+ if [[ -z "${cfg_branch:-}" ]]; then
74
+ echo "[warn] ${sub_path}: missing .gitmodules submodule.${name}.branch; keep detached (run ws-submodule-setup to set it)"
75
+ continue
76
+ fi
77
+
78
+ target_branch="${cfg_branch}"
79
+ pin_branch="aiws/pin/${target_branch}"
80
+
81
+ git -C "${sub_path}" fetch origin --prune || true
82
+
83
+ if git -C "${sub_path}" show-ref --verify --quiet "refs/remotes/origin/${target_branch}"; then
84
+ if git -C "${sub_path}" merge-base --is-ancestor "${sub_sha}" "origin/${target_branch}"; then
85
+ # 不改动现有分支(避免把已有 main/master 等分支强行指回旧 commit)
86
+ # 仅创建/更新一个 AIWS 专用 pin 分支指向 gitlink commit,从 detached “挂回分支”。
87
+ git -C "${sub_path}" checkout -B "${pin_branch}" "${sub_sha}"
88
+ git -C "${sub_path}" branch --set-upstream-to "origin/${target_branch}" "${pin_branch}" >/dev/null 2>&1 || true
89
+ echo "[ok] attached ${sub_path} to ${pin_branch} (upstream=origin/${target_branch}) at ${sub_sha}"
90
+ else
91
+ echo "[warn] ${sub_path}: ${sub_sha} is not in origin/${target_branch}; keep detached"
92
+ fi
93
+ else
94
+ echo "[warn] ${sub_path}: origin/${target_branch} not found; keep detached"
95
+ fi
96
+
97
+ git -C "${sub_path}" rev-parse --abbrev-ref HEAD 2>/dev/null || true
98
+ git -C "${sub_path}" status -sb || true
99
+ done
100
+ fi
101
+ ```
102
+
103
+ 4) 一次性配置(方案 2):为每个 submodule 写入跟踪分支,便于团队统一(需要用户确认,会改动 `.gitmodules`):
104
+ ```bash
105
+ # 示例:把某个 submodule 固定跟踪 main(会写入 .gitmodules 的 submodule.<name>.branch)
106
+ git submodule set-branch --branch main <sub_path>
107
+
108
+ # 提示:该变更需要提交到 superproject
109
+ git add .gitmodules
110
+ git commit -m "chore(submodule): set tracking branch"
111
+ ```
112
+ 建议:
113
+ - 只有当团队明确希望“子模块按分支滚动”(而不是锁定固定 commit)时,才采用方案 2。
114
+ - 若只是想避免 detached 但仍锁定 gitlink commit:优先使用步骤 3(不改 `.gitmodules`)。
115
+ - 推荐用 `$ws-submodule-setup` 交互式对齐所有 submodules 的 branch,并提交 `.gitmodules`。
116
+
117
+ 输出要求:
118
+ - `Context:` 当前分支 + 是否存在 `.gitmodules` + submodule 列表
119
+ - `Result:` pull 是否 fast-forward;每个 submodule 是否成功“挂回分支”,失败原因是什么