@aipper/aiws-spec 0.0.28 → 0.0.29
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/docs/cli-interface.md +10 -12
- package/docs/opencode-autonomous-swarm.md +178 -0
- package/docs/opencode-omo-adapter.md +123 -4
- package/docs/opencode-omo-validation-checklist.md +47 -0
- package/docs/opencode-subagent-first.md +187 -0
- package/docs/workflow-delegation-context-injection.md +217 -0
- package/docs/workflow-delegation-contracts.json +68 -1
- package/docs/workflow-delegation-contracts.md +3 -0
- package/docs/workflow-delegation-contracts.schema.json +95 -0
- package/docs/workflow-governance-rules.json +47 -6
- package/docs/workflow-governance-rules.md +7 -6
- package/docs/workflow-governance-rules.schema.json +39 -1
- package/docs/workflow-router-rules.json +36 -4
- package/docs/workflow-router-rules.md +8 -4
- package/docs/workflow-stage-contracts.json +2 -3
- package/docs/workflow-stage-contracts.md +2 -3
- package/package.json +1 -1
- package/templates/workspace/.agents/skills/using-aiws/SKILL.md +8 -6
- package/templates/workspace/.agents/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.agents/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.agents/skills/ws-dev/SKILL.md +52 -141
- package/templates/workspace/.agents/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.agents/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.agents/skills/ws-plan-verify/SKILL.md +6 -58
- package/templates/workspace/.agents/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.agents/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/.claude/commands/ws-review.md +5 -1
- package/templates/workspace/.claude/settings.json.example +26 -0
- package/templates/workspace/.claude/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.claude/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.claude/skills/ws-dev/SKILL.md +52 -141
- package/templates/workspace/.claude/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.claude/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.claude/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.claude/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.claude/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/.opencode/command/ws-auto.md +33 -0
- package/templates/workspace/.opencode/command/ws-autonomy.md +25 -0
- package/templates/workspace/.opencode/command/ws-review.md +5 -1
- package/templates/workspace/.opencode/commands/ws-auto.md +33 -0
- package/templates/workspace/.opencode/commands/ws-autonomy.md +25 -0
- package/templates/workspace/.opencode/commands/ws-commit.md +4 -56
- package/templates/workspace/.opencode/commands/ws-deliver.md +10 -50
- package/templates/workspace/.opencode/commands/ws-finish.md +8 -65
- package/templates/workspace/.opencode/commands/ws-handoff.md +9 -17
- package/templates/workspace/.opencode/commands/ws-migrate.md +10 -17
- package/templates/workspace/.opencode/commands/ws-plan-verify.md +5 -15
- package/templates/workspace/.opencode/commands/ws-pull.md +6 -75
- package/templates/workspace/.opencode/commands/ws-push.md +7 -82
- package/templates/workspace/.opencode/commands/ws-review.md +5 -1
- package/templates/workspace/.opencode/commands/ws-submodule-setup.md +8 -47
- package/templates/workspace/.opencode/commands/ws-verify-before-complete.md +10 -19
- package/templates/workspace/.opencode/helpers/approval-whitelist-check.sh +148 -0
- package/templates/workspace/.opencode/helpers/approval-whitelist-run.sh +82 -0
- package/templates/workspace/.opencode/helpers/approval-whitelist-watchdog.sh +144 -0
- package/templates/workspace/.opencode/helpers/tmux-swarm-rescue.sh +56 -0
- package/templates/workspace/.opencode/helpers/tmux-swarm-scan.sh +46 -0
- package/templates/workspace/.opencode/oh-my-opencode.json.example +64 -4
- package/templates/workspace/.opencode/skills/using-aiws/SKILL.md +93 -77
- package/templates/workspace/.opencode/skills/ws-analyze/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-auto/SKILL.md +46 -0
- package/templates/workspace/.opencode/skills/ws-autonomy/SKILL.md +62 -0
- package/templates/workspace/.opencode/skills/ws-bugfix/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.opencode/skills/ws-delegate/SKILL.md +93 -40
- package/templates/workspace/.opencode/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.opencode/skills/ws-dev/SKILL.md +53 -142
- package/templates/workspace/.opencode/skills/ws-dev-lite/SKILL.md +19 -6
- package/templates/workspace/.opencode/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.opencode/skills/ws-frontend-design/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.opencode/skills/ws-intake/SKILL.md +11 -2
- package/templates/workspace/.opencode/skills/ws-migrate/SKILL.md +6 -42
- package/templates/workspace/.opencode/skills/ws-plan/SKILL.md +4 -2
- package/templates/workspace/.opencode/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.opencode/skills/ws-preflight/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-pull/SKILL.md +8 -109
- package/templates/workspace/.opencode/skills/ws-push/SKILL.md +8 -100
- package/templates/workspace/.opencode/skills/ws-quality-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-change/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-contract-sync/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-contract-validate/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-flow-sync/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-review/SKILL.md +14 -3
- package/templates/workspace/.opencode/skills/ws-rule/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-spec-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-submodule-setup/SKILL.md +10 -57
- package/templates/workspace/.opencode/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/AGENTS.md +5 -2
- package/templates/workspace/AI_PROJECT.md +1 -1
- package/templates/workspace/changes/README.md +9 -12
- package/templates/workspace/manifest.json +265 -207
- package/templates/workspace/.agents/skills/ws-migrate/SKILL.md +0 -54
- package/templates/workspace/.agents/skills/ws-pull/SKILL.md +0 -119
- package/templates/workspace/.agents/skills/ws-push/SKILL.md +0 -110
- package/templates/workspace/.agents/skills/ws-submodule-setup/SKILL.md +0 -65
- package/templates/workspace/.claude/skills/ws-migrate/SKILL.md +0 -54
- package/templates/workspace/.claude/skills/ws-pull/SKILL.md +0 -119
- package/templates/workspace/.claude/skills/ws-push/SKILL.md +0 -110
- package/templates/workspace/.claude/skills/ws-submodule-setup/SKILL.md +0 -65
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "object",
|
|
3
|
-
"required": ["version", "description", "governanceRules", "guidanceRules"],
|
|
3
|
+
"required": ["version", "description", "workflowStateSuffix", "stateEnum", "governanceRules", "guidanceRules"],
|
|
4
4
|
"properties": {
|
|
5
5
|
"version": { "type": "integer" },
|
|
6
6
|
"description": { "type": "string", "minLength": 1 },
|
|
7
|
+
"workflowStateSuffix": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"required": ["description", "values", "stateSuffixMap"],
|
|
10
|
+
"properties": {
|
|
11
|
+
"description": { "type": "string", "minLength": 1 },
|
|
12
|
+
"values": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"minItems": 6,
|
|
15
|
+
"items": { "type": "string", "pattern": "^(intake|planning|dev|review|deliver|completed)$" }
|
|
16
|
+
},
|
|
17
|
+
"stateSuffixMap": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"minProperties": 6,
|
|
20
|
+
"additionalProperties": { "type": "string", "pattern": "^\\[workflow-state:session:[a-z]+\\]$" }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"additionalProperties": false
|
|
24
|
+
},
|
|
25
|
+
"stateEnum": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"required": ["values", "stageMapping"],
|
|
28
|
+
"properties": {
|
|
29
|
+
"values": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"minItems": 6,
|
|
32
|
+
"items": { "type": "string", "pattern": "^(intake|planning|dev|review|deliver|completed)$" }
|
|
33
|
+
},
|
|
34
|
+
"stageMapping": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"minProperties": 6,
|
|
37
|
+
"additionalProperties": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": { "type": "string" }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"additionalProperties": false
|
|
44
|
+
},
|
|
7
45
|
"governanceRules": {
|
|
8
46
|
"type": "array",
|
|
9
47
|
"minItems": 1,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"id": "finish_request",
|
|
94
94
|
"intent": "收尾/合并/推送/cleanup",
|
|
95
|
-
"match": "用户要求 finish、merge、push、收尾、交付完成、清理
|
|
95
|
+
"match": "用户要求 finish、merge、push、收尾、交付完成、清理 change 分支。",
|
|
96
96
|
"routeTo": "ws-finish",
|
|
97
97
|
"gate": "必须满足 finish gate,不能跳过 validate / push / cleanup。",
|
|
98
98
|
"rationale": "finish 是独立治理阶段,不能与普通实现混用。"
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
{
|
|
109
109
|
"id": "plan_first",
|
|
110
110
|
"intent": "中大型实现或需要建立 change 上下文",
|
|
111
|
-
"match": "任务是多步实现、跨文件、跨模块、需要方案、需要新建 change
|
|
111
|
+
"match": "任务是多步实现、跨文件、跨模块、需要方案、需要新建 change 分支,且需求已经冻结或已有可消费的 intake 草案。",
|
|
112
112
|
"routeTo": "ws-plan",
|
|
113
113
|
"gate": "plan 过 gate 前不进入 `ws-dev`。",
|
|
114
114
|
"rationale": "medium/complex 任务在需求冻结后必须先生成可落盘计划,避免 router 直接跳进实现。"
|
|
@@ -120,6 +120,22 @@
|
|
|
120
120
|
"routeTo": "ws-dev",
|
|
121
121
|
"gate": "若执行中发现复杂度升高,必须回退到 `ws-plan`。",
|
|
122
122
|
"rationale": "router 允许明确的小步任务直接实现,但必须保留回退计划阶段的门;若用户明确要走轻量入口,可在实现阶段显式使用 `ws-dev-lite` 作为 `ws-dev` 的 facade。"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "design_first",
|
|
126
|
+
"intent": "需要先出设计方案",
|
|
127
|
+
"match": "任务涉及新流程、新模块、新架构或对现有架构有显著影响的方向决策,需要先出设计方案再进入实现。",
|
|
128
|
+
"routeTo": "ws-design",
|
|
129
|
+
"gate": "design 未完成 review 前,不进入 `ws-plan`。",
|
|
130
|
+
"rationale": "复杂或高影响改动应先出设计方案,让设计过审后再投入实现,避免返工。"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": "spec_update",
|
|
134
|
+
"intent": "需要更新规范/文档/验收标准",
|
|
135
|
+
"match": "任务涉及更新 AI_PROJECT.md、REQUIREMENTS.md、AI_WORKSPACE.md 中的规范说明、验收标准或 contract 文档。",
|
|
136
|
+
"routeTo": "ws-spec-update",
|
|
137
|
+
"gate": "spec 更新必须先过 review,再同步到真值文件。",
|
|
138
|
+
"rationale": "规范更新与功能变更不同,router 应优先引导到 spec 维护链而非直接实现。"
|
|
123
139
|
}
|
|
124
140
|
],
|
|
125
141
|
"routeCases": [
|
|
@@ -166,7 +182,7 @@
|
|
|
166
182
|
{
|
|
167
183
|
"id": "case_finish_request",
|
|
168
184
|
"scenario": "用户要求合并、push、cleanup 或 finish 当前 change。",
|
|
169
|
-
"request": "把 demo-change finish 掉并 push,顺便 cleanup
|
|
185
|
+
"request": "把 demo-change finish 掉并 push,顺便 cleanup。",
|
|
170
186
|
"expectedRuleId": "finish_request",
|
|
171
187
|
"expectedRoute": "ws-finish",
|
|
172
188
|
"why": "finish 是独立治理阶段,必须先走 finish gate。"
|
|
@@ -181,7 +197,7 @@
|
|
|
181
197
|
},
|
|
182
198
|
{
|
|
183
199
|
"id": "case_plan_first",
|
|
184
|
-
"scenario": "任务是跨文件、多步实现,且需要先建立 change
|
|
200
|
+
"scenario": "任务是跨文件、多步实现,且需要先建立 change 分支或方案。",
|
|
185
201
|
"request": "实现 dashboard 的阶段治理视图并补测试,需要新建 change 和计划。",
|
|
186
202
|
"expectedRuleId": "plan_first",
|
|
187
203
|
"expectedRoute": "ws-plan",
|
|
@@ -194,6 +210,22 @@
|
|
|
194
210
|
"expectedRuleId": "direct_implementation",
|
|
195
211
|
"expectedRoute": "ws-dev",
|
|
196
212
|
"why": "小步明确实现允许直接进入 dev;若用户明确要轻量直修,可进一步显式使用 ws-dev-lite,但治理归属仍收敛到 ws-dev。"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"id": "case_design_first",
|
|
216
|
+
"scenario": "任务需要先出设计方案再进入实现。",
|
|
217
|
+
"request": "设计 dashboard 架构,出方案后再实现。",
|
|
218
|
+
"expectedRuleId": "design_first",
|
|
219
|
+
"expectedRoute": "ws-design",
|
|
220
|
+
"why": "高影响改动应先出设计方案,过审后再投入实现。"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"id": "case_spec_update",
|
|
224
|
+
"scenario": "任务涉及更新规范或验收标准文档。",
|
|
225
|
+
"request": "更新 AI_WORKSPACE.md 中的验证命令说明。",
|
|
226
|
+
"expectedRuleId": "spec_update",
|
|
227
|
+
"expectedRoute": "ws-spec-update",
|
|
228
|
+
"why": "规范更新应先走 spec 维护链,直接实现会绕过 review 门禁。"
|
|
197
229
|
}
|
|
198
230
|
],
|
|
199
231
|
"clarificationTriggers": [
|
|
@@ -45,10 +45,12 @@ router 在做任何 workflow 判断前,必须先读取:
|
|
|
45
45
|
| `needs_intake` | 需求存在多条待确认问题,尚未冻结 | 任务是新需求或中大型变更;目标方向大致明确,但存在多条待确认问题、需要逐条沟通,或用户明确要求先多轮澄清再进入计划。 | `ws-intake` | 先逐条澄清并冻结结论;未形成 intake 草案前不进入 `ws-plan`。 | `ws-intake` 负责把多轮需求沟通收敛为轻量草案,避免 `ws-plan` 同时承担反复澄清与正式计划落盘。 |
|
|
46
46
|
| `requirements_change` | 需求/验收/合同变更 | 任务涉及 `REQUIREMENTS.md`、requirements CSV、spec contract、验收标准或 workflow 真值变更。 | `ws-req-review` | 先做需求评审,再决定是否进入 `ws-plan` / `ws-dev`。 | 需求真值变更必须先过 review,不能直接编码。 |
|
|
47
47
|
| `review_request` | 审计/评审/找风险 | 用户明确要求 review、audit、评审、找 bug、识别风险或检查回归。 | `ws-review` | 先给 findings;除非用户另行要求,不先改代码。 | 评审任务与实现任务的输出契约不同,必须优先走 review。 |
|
|
48
|
-
| `finish_request` | 收尾/合并/推送/cleanup | 用户要求 finish、merge、push、收尾、交付完成、清理
|
|
48
|
+
| `finish_request` | 收尾/合并/推送/cleanup | 用户要求 finish、merge、push、收尾、交付完成、清理 change 分支。 | `ws-finish` | 必须满足 finish gate,不能跳过 validate / push / cleanup。 | finish 是独立治理阶段,不能与普通实现混用。 |
|
|
49
49
|
| `handoff_request` | 交接/归档总结 | 用户要求 handoff、交接说明、archive summary、会话总结或接力说明。 | `ws-handoff` | 先确认 change 已 finish 或 archive 上下文存在。 | handoff 依赖已有证据与归档上下文,不应在实现前触发。 |
|
|
50
|
-
| `plan_first` | 中大型实现或需要建立 change 上下文 | 任务是多步实现、跨文件、跨模块、需要方案、需要新建 change
|
|
50
|
+
| `plan_first` | 中大型实现或需要建立 change 上下文 | 任务是多步实现、跨文件、跨模块、需要方案、需要新建 change 分支,且需求已经冻结或已有可消费的 intake 草案。 | `ws-plan` | plan 过 gate 前不进入 `ws-dev`。 | medium/complex 任务在需求冻结后必须先生成可落盘计划,避免 router 直接跳进实现。 |
|
|
51
51
|
| `direct_implementation` | 小步实现/修复/配置调整 | 目标明确、归因清晰、验证入口明确,且无需先改 requirements 或单独评审。 | `ws-dev` | 若执行中发现复杂度升高,必须回退到 `ws-plan`。 | router 允许明确的小步任务直接实现,但必须保留回退计划阶段的门;若用户明确要走轻量入口,可在实现阶段显式使用 `ws-dev-lite` 作为 `ws-dev` 的 facade。 |
|
|
52
|
+
| `design_first` | 需要先出设计方案 | 任务涉及新流程、新模块、新架构或对现有架构有显著影响的方向决策,需要先出设计方案再进入实现。 | `ws-design` | design 未完成 review 前,不进入 `ws-plan`。 | 复杂或高影响改动应先出设计方案,让设计过审后再投入实现,避免返工。 |
|
|
53
|
+
| `spec_update` | 需要更新规范/文档/验收标准 | 任务涉及更新 AI_PROJECT.md、REQUIREMENTS.md、AI_WORKSPACE.md 中的规范说明、验收标准或 contract 文档。 | `ws-spec-update` | spec 更新必须先过 review,再同步到真值文件。 | 规范更新与功能变更不同,router 应优先引导到 spec 维护链而非直接实现。 |
|
|
52
54
|
|
|
53
55
|
## Route Cases
|
|
54
56
|
|
|
@@ -59,10 +61,12 @@ router 在做任何 workflow 判断前,必须先读取:
|
|
|
59
61
|
| `case_needs_intake` | 任务方向大致明确,但存在多条待确认问题,需要逐条沟通后再计划。 | 做一个新的 change intake 流程,我想先一条一条把需求和边界聊清楚,再进入正式计划。 | `needs_intake` | `ws-intake` | 这类需求不是完全不清晰,但还没有冻结,适合先走 intake。 |
|
|
60
62
|
| `case_requirements_change` | 任务要修改 REQUIREMENTS、requirements CSV 或 workflow 真值。 | 更新 REQUIREMENTS.md 和 requirements/requirements-issues.csv,补充验收标准。 | `requirements_change` | `ws-req-review` | 需求真值变更必须先做需求评审。 |
|
|
61
63
|
| `case_review_request` | 用户明确要求 review、审计、找风险或检查回归。 | review 这批改动,先给我风险和回归点,不要先改代码。 | `review_request` | `ws-review` | 评审任务的输出契约是 findings,不应直接进入实现。 |
|
|
62
|
-
| `case_finish_request` | 用户要求合并、push、cleanup 或 finish 当前 change。 | 把 demo-change finish 掉并 push,顺便 cleanup
|
|
64
|
+
| `case_finish_request` | 用户要求合并、push、cleanup 或 finish 当前 change。 | 把 demo-change finish 掉并 push,顺便 cleanup。 | `finish_request` | `ws-finish` | finish 是独立治理阶段,必须先走 finish gate。 |
|
|
63
65
|
| `case_handoff_request` | 用户要求 handoff、交接说明、archive summary 或接力文档。 | 给这个 change 写 handoff,并补 archive summary。 | `handoff_request` | `ws-handoff` | handoff 依赖已有 finish/archive 上下文,不能当成普通实现。 |
|
|
64
|
-
| `case_plan_first` | 任务是跨文件、多步实现,且需要先建立 change
|
|
66
|
+
| `case_plan_first` | 任务是跨文件、多步实现,且需要先建立 change 分支或方案。 | 实现 dashboard 的阶段治理视图并补测试,需要新建 change 和计划。 | `plan_first` | `ws-plan` | 中大型实现应先落盘计划,再进入 dev。 |
|
|
65
67
|
| `case_direct_implementation` | 任务是小步明确修复,归因和验证入口都已清楚。 | 修复 codex install-skills 的默认路径,并补一条可复现回归。 | `direct_implementation` | `ws-dev` | 小步明确实现允许直接进入 dev;若用户明确要轻量直修,可进一步显式使用 ws-dev-lite,但治理归属仍收敛到 ws-dev。 |
|
|
68
|
+
| `case_design_first` | 任务需要先出设计方案再进入实现。 | 设计 dashboard 架构,出方案后再实现。 | `design_first` | `ws-design` | 高影响改动应先出设计方案,过审后再投入实现。 |
|
|
69
|
+
| `case_spec_update` | 任务涉及更新规范或验收标准文档。 | 更新 AI_WORKSPACE.md 中的验证命令说明。 | `spec_update` | `ws-spec-update` | 规范更新应先走 spec 维护链,直接实现会绕过 review 门禁。 |
|
|
66
70
|
|
|
67
71
|
## 必须先澄清的情形
|
|
68
72
|
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"notes": [
|
|
22
22
|
"ws-deliver 用于多 repo / submodule 场景的顺序提交与交付准备。",
|
|
23
|
-
"ws-finish 用于 fast-forward 合并、push、
|
|
23
|
+
"ws-finish 用于 fast-forward 合并、push、change 分支清理,并在完整 finish 后自动归档 change。",
|
|
24
24
|
"ws-handoff 通常在 finish 自动归档后使用,用于查看/补充归档交接说明。",
|
|
25
|
-
"若存在独立 change worktree,治理信号应优先读取该 worktree;若 worktree metadata 已 stale,则降级为 warning 并回退到当前 worktree。"
|
|
26
25
|
],
|
|
27
26
|
"stages": [
|
|
28
27
|
{
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
"stage": "ws-finish",
|
|
94
93
|
"goal": "安全合并、push、cleanup,并自动归档",
|
|
95
94
|
"requiredInputs": "干净工作区;已提交的 change;push 目标;submodule 真值(若有)",
|
|
96
|
-
"requiredOutputs": "Merge;Push;
|
|
95
|
+
"requiredOutputs": "Merge;Push;Change 分支清理;Archive/Handoff;Evidence",
|
|
97
96
|
"blockers": "dirty 工作区;ff 失败;submodule 无法安全 push",
|
|
98
97
|
"next": "ws-handoff"
|
|
99
98
|
},
|
|
@@ -16,9 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
说明:
|
|
18
18
|
- ws-deliver 用于多 repo / submodule 场景的顺序提交与交付准备。
|
|
19
|
-
- ws-finish 用于 fast-forward 合并、push、
|
|
19
|
+
- ws-finish 用于 fast-forward 合并、push、change 分支清理,并在完整 finish 后自动归档 change。
|
|
20
20
|
- ws-handoff 通常在 finish 自动归档后使用,用于查看/补充归档交接说明。
|
|
21
|
-
- 若存在独立 change worktree,治理信号应优先读取该 worktree;若 worktree metadata 已 stale,则降级为 warning 并回退到当前 worktree。
|
|
22
21
|
|
|
23
22
|
## 阶段表
|
|
24
23
|
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
| `ws-review` | 审计规范、风险与验证完整性 | 当前 diff;验证结果;真值文件 | review 文件;Top risks;Next | 无改动可审;无法写审计证据 | ws-commit 或修复后重审 |
|
|
33
32
|
| `ws-commit` | 串联 review、validate、commit 确认 | staged diff;review 证据;validate stamp;用户确认的 message | Evidence;Context;Commit | 无 staged changes;submodule dirty;validate 失败;message 未确认 | ws-deliver / ws-finish |
|
|
34
33
|
| `ws-deliver` | 在 submodule 场景下完成顺序提交与证据收敛 | change 上下文;.gitmodules;submodules.targets;各 repo 状态 | submodule 提交摘要;superproject 提交摘要;Evidence | submodule 真值不完整;不在正确 change;commit 未确认 | ws-finish |
|
|
35
|
-
| `ws-finish` | 安全合并、push、cleanup,并自动归档 | 干净工作区;已提交的 change;push 目标;submodule 真值(若有) | Merge;Push;
|
|
34
|
+
| `ws-finish` | 安全合并、push、cleanup,并自动归档 | 干净工作区;已提交的 change;push 目标;submodule 真值(若有) | Merge;Push;Change 分支清理;Archive/Handoff;Evidence | dirty 工作区;ff 失败;submodule 无法安全 push | ws-handoff |
|
|
36
35
|
| `ws-handoff` | 查看/补充可接力的归档交接说明 | 已归档的 change | changes/archive/.../handoff.md;Next | 无法定位已归档 change;handoff 无法生成或读取 | 新 change 通过 Depends_On 接力 |
|
|
37
36
|
|
|
38
37
|
## 统一规则
|
package/package.json
CHANGED
|
@@ -50,12 +50,14 @@ description: 默认 workflow bootstrap/router:先读真值,再路由到正
|
|
|
50
50
|
- 输出下一步:先 `aiws init .`(或 `npx @aipper/aiws init .`),然后重新执行 `$using-aiws`
|
|
51
51
|
- 此时 route 视为 `$ws-preflight`
|
|
52
52
|
3) 根据 `packages/spec/docs/workflow-router-rules.json` 判定任务属于哪一类:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
- 需求/验收/合同变更:`$ws-req-review`
|
|
54
|
+
- 评审/审计/找风险:`$ws-review`
|
|
55
|
+
- finish / merge / push / cleanup:`$ws-finish`
|
|
56
|
+
- handoff / archive summary:`$ws-handoff`
|
|
57
|
+
- 新需求或中大型变更,且存在多条待确认问题 / 用户要求逐条多轮沟通:`$ws-intake`
|
|
58
|
+
- 需要先出设计方案(design 未过审前不进入实现):`$ws-design`
|
|
59
|
+
- 需要更新规范/验收标准(必须先过 review):`$ws-spec-update`
|
|
60
|
+
- 中大型实现、需要方案、需要 change/worktree,且需求已经冻结:`$ws-plan`
|
|
59
61
|
- 小步明确实现/修复/配置调整:`$ws-dev`(若是 simple/local 单点修复,且用户明确希望走轻量入口,可显式进入 `$ws-dev-lite`)
|
|
60
62
|
4) 若任务意图或归因不明确:
|
|
61
63
|
- 只问 1-3 个关键澄清问题
|
|
@@ -1,130 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-commit
|
|
3
|
-
description:
|
|
3
|
+
description: `aiws ws-commit` 的薄包装入口
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# ws-commit
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- 支持在**当前分支直接提交**(不要求必须先切 `change/<change-id>`)
|
|
10
|
-
- 提交前审计与证据落盘(`$ws-review`)
|
|
11
|
-
- 提交前门禁校验与证据落盘(`aiws validate . --stamp`)
|
|
12
|
-
- 最后执行 `git commit`(commit 前必须让用户确认 message;不使用 `--no-verify` 绕过 hooks)
|
|
13
|
-
- 若仓库含 submodule:提交前识别并提示正确顺序(先 submodule,再 superproject)
|
|
14
|
-
- 若你经常遇到 submodule detached:建议日常拉取使用 `$ws-pull`(尽量把 submodule “挂回分支”且不改变 gitlink commit)
|
|
8
|
+
`aiws ws-commit` 的薄包装入口。
|
|
15
9
|
|
|
16
|
-
安全约束(强制):
|
|
17
|
-
- 不自动 `git add -A`(避免误提交);只在用户明确指示时才执行 staging 命令
|
|
18
|
-
- 不自动 push
|
|
19
|
-
- 不写入任何 secrets
|
|
20
|
-
- 检测到 submodule 有未提交改动时,不允许直接提交 superproject(先处理 submodule)
|
|
21
|
-
- commit message 优先使用中文(命令/路径/代码标识符保持原样不翻译);格式建议:`<类型>: <简述>`(例如 `修复: 登录页空指针`、`功能: 新增 submodule targets 校验`、`重构: 提取共享脚本`)
|
|
22
|
-
- 若启用了 `.githooks/commit-msg`:默认按仓库角色区分
|
|
23
|
-
- superproject / root 仓库(存在 `.gitmodules`)默认允许自由 commit message
|
|
24
|
-
- submodule / 普通仓库默认提示优先中文
|
|
25
|
-
- 只有在 `git config aiws.commitMessagePolicy strict` 时才会拒绝全英文首行(`Merge/Revert/fixup!/squash!` 例外)
|
|
26
|
-
|
|
27
|
-
阶段定位:
|
|
28
|
-
- commit gate;负责在提交前收敛 review、validate 和 message 确认,不允许跳过 hooks。
|
|
29
|
-
|
|
30
|
-
必需输入:
|
|
31
|
-
- 当前分支与 staged diff
|
|
32
|
-
- `$ws-review` 生成的审计证据
|
|
33
|
-
- `aiws validate . --stamp` 生成的校验证据
|
|
34
|
-
- 用户确认后的 commit message
|
|
35
|
-
|
|
36
|
-
必需输出:
|
|
37
|
-
- `证据(Evidence):` review 文件路径 + validate stamp 路径
|
|
38
|
-
- `上下文(Context):` 当前分支、submodule 检测结果、阻断原因(若有)
|
|
39
|
-
- `提交信息(Commit):` 最终提交信息
|
|
40
|
-
|
|
41
|
-
阻断条件:
|
|
42
|
-
- 没有 staged changes
|
|
43
|
-
- submodule 工作区不干净或 detached 处理不完整
|
|
44
|
-
- 用户未确认 commit message
|
|
45
|
-
- validate 失败
|
|
46
|
-
|
|
47
|
-
完成判定:
|
|
48
|
-
- 提交已完成,证据路径明确,且没有通过 `--no-verify` 绕过门禁。
|
|
49
|
-
|
|
50
|
-
执行步骤(建议):
|
|
51
|
-
1) 运行 `$ws-preflight`(确保真值文件就绪)。
|
|
52
|
-
2) 运行 `$ws-review`(优先生成审计证据:`changes/<change-id>/review/codex-review.md`;无 `change-id` 时回退 `.agentdocs/tmp/review/codex-review.md`)。
|
|
53
|
-
3) 运行门禁校验并写 stamp:
|
|
54
10
|
```bash
|
|
55
11
|
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
56
|
-
./node_modules/.bin/aiws
|
|
12
|
+
./node_modules/.bin/aiws ws-commit
|
|
57
13
|
elif command -v aiws >/dev/null 2>&1; then
|
|
58
|
-
aiws
|
|
14
|
+
aiws ws-commit
|
|
59
15
|
else
|
|
60
|
-
npx @aipper/aiws
|
|
61
|
-
fi
|
|
62
|
-
```
|
|
63
|
-
4) 输出当前提交上下文(必须输出给用户确认):
|
|
64
|
-
```bash
|
|
65
|
-
git branch --show-current
|
|
66
|
-
git status --porcelain
|
|
67
|
-
```
|
|
68
|
-
5) 检测是否存在 submodule(有则进入 submodule 感知模式):
|
|
69
|
-
```bash
|
|
70
|
-
if [[ -f .gitmodules ]]; then
|
|
71
|
-
git config --file .gitmodules --get-regexp '^submodule\..*\.path$' || true
|
|
72
|
-
else
|
|
73
|
-
echo "[info] no .gitmodules"
|
|
74
|
-
fi
|
|
75
|
-
```
|
|
76
|
-
6) 若存在 submodule,逐个检查子仓库工作区是否干净:
|
|
77
|
-
```bash
|
|
78
|
-
while read -r _ sub_path; do
|
|
79
|
-
[[ -z "${sub_path:-}" ]] && continue
|
|
80
|
-
echo "== submodule: ${sub_path} =="
|
|
81
|
-
git -C "${sub_path}" rev-parse --abbrev-ref HEAD 2>/dev/null || true
|
|
82
|
-
git -C "${sub_path}" status --porcelain || true
|
|
83
|
-
done < <(git config --file .gitmodules --get-regexp '^submodule\..*\.path$' 2>/dev/null || true)
|
|
84
|
-
```
|
|
85
|
-
判定规则(强制):
|
|
86
|
-
- 任一 submodule `git status --porcelain` 非空:停止 superproject commit,先在对应 submodule 完成 commit,再回到 superproject 更新并提交 gitlink。
|
|
87
|
-
- 若该 submodule 当前为 detached HEAD:先按 `.gitmodules` 的目标分支挂到 `aiws/pin/<target_branch>`;不要直接切 `change/<change-id>` / `main` / `master` 来“解 detached”。
|
|
88
|
-
处理指引(detached submodule):
|
|
89
|
-
```bash
|
|
90
|
-
cur_branch="$(git branch --show-current)"
|
|
91
|
-
change_id="$(echo "${cur_branch}" | sed -n 's|^change/||p')"
|
|
92
|
-
targets="changes/${change_id}/submodules.targets"
|
|
93
|
-
|
|
94
|
-
source tools/ws_resolve_sub_target.sh
|
|
95
|
-
ws_resolve_sub_target "${sub_path}" "${sub_name}" "${targets}" "${cur_branch}" || exit 2
|
|
96
|
-
target_branch="${_resolved_branch}"
|
|
97
|
-
remote="${_resolved_remote}"
|
|
98
|
-
|
|
99
|
-
git -C "${sub_path}" fetch "${remote}" --prune
|
|
100
|
-
if ! git -C "${sub_path}" show-ref --verify --quiet "refs/remotes/${remote}/${target_branch}"; then
|
|
101
|
-
echo "error: missing ${remote}/${target_branch} for submodule path=${sub_path}"
|
|
102
|
-
exit 2
|
|
16
|
+
npx @aipper/aiws ws-commit
|
|
103
17
|
fi
|
|
104
|
-
git -C "${sub_path}" checkout -B "aiws/pin/${target_branch}" HEAD
|
|
105
|
-
git -C "${sub_path}" branch --set-upstream-to "${remote}/${target_branch}" "aiws/pin/${target_branch}" >/dev/null 2>&1 || true
|
|
106
18
|
```
|
|
107
|
-
7) 检查当前 staging 内容(必须输出给用户确认):
|
|
108
|
-
```bash
|
|
109
|
-
git status --porcelain
|
|
110
|
-
git diff --staged --submodule=short
|
|
111
|
-
```
|
|
112
|
-
8) 若没有 staged changes:停止并提示用户先明确要提交哪些文件(例如 `git add -p` 或 `git add <path>`)。
|
|
113
|
-
9) 生成中文 commit message 草案(格式:`<类型>: <简述>`),输出给用户确认后再执行。
|
|
114
|
-
- 类型参考:`功能` / `修复` / `重构` / `文档` / `测试` / `构建` / `杂项`
|
|
115
|
-
- 简述用一句话概括本次改动的"为什么"而非"改了什么"
|
|
116
|
-
- 命令/路径/代码标识符保持原样不翻译
|
|
117
|
-
- 若用户给出全英文 message:优先改写成中文;若用户明确要求保留英文,也可以提交(但 strict 模式下会被 hook 拒绝)
|
|
118
|
-
10) 执行提交(不带 `--no-verify`):
|
|
119
|
-
```bash
|
|
120
|
-
git commit -m "<message>"
|
|
121
|
-
```
|
|
122
|
-
11) 输出提交结果(可选):
|
|
123
|
-
```bash
|
|
124
|
-
git show --stat --oneline -1
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
输出要求:
|
|
128
|
-
- `证据(Evidence):` `changes/<change-id>/review/codex-review.md`(无 `change-id` 时回退 `.agentdocs/tmp/review/codex-review.md`) + `.agentdocs/tmp/aiws-validate/*.json`
|
|
129
|
-
- `上下文(Context):` 当前分支 + 是否检测到 submodule + 若阻断则给出阻断原因
|
|
130
|
-
- `提交信息(Commit):` 最终使用的 commit message(仅当用户确认后)
|
|
@@ -1,230 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-deliver
|
|
3
|
-
description:
|
|
3
|
+
description: `aiws ws-deliver` 的薄包装入口
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# ws-deliver
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- 适配 superproject + submodule(数量不固定)的交付收尾:
|
|
10
|
-
1) 先逐个提交 submodule(每个 repo 单独确认 commit message)
|
|
11
|
-
2) 再提交 superproject(包含 submodule gitlink 指针更新 + 变更工件/代码)
|
|
12
|
-
3) 最后 fast-forward 合并回目标分支(复用 `aiws change finish`,减少手动 merge 出错)
|
|
8
|
+
`aiws ws-deliver` 的薄包装入口。
|
|
13
9
|
|
|
14
|
-
非目标(强制):
|
|
15
|
-
- 不自动 `git add -A`(避免误提交)
|
|
16
|
-
- 不自动 push
|
|
17
|
-
- 不自动删除分支
|
|
18
|
-
|
|
19
|
-
前置(强制):
|
|
20
|
-
1) 先运行 `$ws-preflight`。
|
|
21
|
-
2) 确认当前处于 change 分支(推荐):`change/<change-id>`(也支持 `changes/`、`ws/`、`ws-change/`)。
|
|
22
|
-
- 若不在 change 分支:要求用户先切换到 `change/<change-id>`(或在命令里显式提供 `<change-id>`)。
|
|
23
|
-
3) 任何自动提交都必须在提交前输出:
|
|
24
|
-
- 该 repo 的 `git status --porcelain`
|
|
25
|
-
- 该 repo 的 `git diff --staged`
|
|
26
|
-
并让用户确认 commit message(每个 repo 单独确认)。
|
|
27
|
-
|
|
28
|
-
阶段定位:
|
|
29
|
-
- delivery 阶段;负责在多 repo / submodule 场景下完成顺序提交、证据收敛和最终合并前准备。
|
|
30
|
-
|
|
31
|
-
必需输入:
|
|
32
|
-
- 当前 `change/<change-id>` 上下文
|
|
33
|
-
- 若存在 submodule:`.gitmodules` + `changes/<change-id>/submodules.targets`
|
|
34
|
-
- 各 repo 当前状态与 staged diff
|
|
35
|
-
|
|
36
|
-
必需输出:
|
|
37
|
-
- `Submodules:` 每个 submodule 的提交摘要
|
|
38
|
-
- `Superproject:` 主仓库提交摘要
|
|
39
|
-
- `Evidence:` validate stamp 与持久证据路径
|
|
40
|
-
- `Next:` 进入 `$ws-finish` 或 `aiws change finish`
|
|
41
|
-
|
|
42
|
-
阻断条件:
|
|
43
|
-
- 不在正确的 change 上下文
|
|
44
|
-
- submodule branch / targets 真值不完整
|
|
45
|
-
- 任一 repo 未确认 commit message 或存在未处理冲突
|
|
46
|
-
|
|
47
|
-
完成判定:
|
|
48
|
-
- submodule 与 superproject 提交都已完成,证据已收敛,且可以安全进入 finish 阶段。
|
|
49
|
-
|
|
50
|
-
建议流程(按顺序):
|
|
51
|
-
|
|
52
|
-
## 0) submodule branch 真值检查(减少 detached 与人为差异)
|
|
53
|
-
如果存在 `.gitmodules` 但缺少 `submodule.<name>.branch`,先运行 `$ws-submodule-setup` 并提交 `.gitmodules`,否则后续 `aiws validate .` 会失败,且 `ws-pull/ws-finish` 无法确定性工作。
|
|
54
|
-
> 说明:若同一 superproject 分支内存在多渠道 submodule 目标分支的交付需求,可在 `changes/<change-id>/submodules.targets` 额外声明本次 change 的目标分支;交付时会优先使用该文件(不改变 `.gitmodules` 的团队默认真值)。
|
|
55
|
-
> 生成该文件时,可以按当前状态做默认预填,但必须显式说明来源并让用户确认:detached HEAD 默认建议取 `.gitmodules` 声明分支;已附着在某个本地分支时默认建议取当前分支;finish/push 最终只认 `submodules.targets`。
|
|
56
10
|
```bash
|
|
57
|
-
if [[ -f .gitmodules ]]; then
|
|
58
|
-
missing=0
|
|
59
|
-
while read -r key sub_path; do
|
|
60
|
-
name="${key#submodule.}"; name="${name%.path}"
|
|
61
|
-
b="$(git config --file .gitmodules --get "submodule.${name}.branch" 2>/dev/null || true)"
|
|
62
|
-
if [[ -z "${b:-}" ]]; then
|
|
63
|
-
echo "error: missing .gitmodules submodule.${name}.branch (path=${sub_path})"
|
|
64
|
-
missing=1
|
|
65
|
-
fi
|
|
66
|
-
done < <(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null || true)
|
|
67
|
-
if [[ "$missing" -ne 0 ]]; then
|
|
68
|
-
echo "hint: run $ws-submodule-setup (and commit .gitmodules), then retry"
|
|
69
|
-
exit 2
|
|
70
|
-
fi
|
|
71
|
-
|
|
72
|
-
# 强约束:当 .gitmodules 声明 submodules 时,要求本次 change 存在 submodules.targets 且覆盖所有 submodule path
|
|
73
|
-
if git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' >/dev/null 2>&1; then
|
|
74
|
-
change_id="$(git branch --show-current | sed -n 's|^change/||p')"
|
|
75
|
-
targets="changes/${change_id}/submodules.targets"
|
|
76
|
-
if [[ ! -f "${targets}" ]]; then
|
|
77
|
-
echo "error: missing ${targets} (required when .gitmodules declares submodules)"
|
|
78
|
-
exit 2
|
|
79
|
-
fi
|
|
80
|
-
t_missing=0
|
|
81
|
-
while read -r _ sub_path; do
|
|
82
|
-
[[ -z "${sub_path:-}" ]] && continue
|
|
83
|
-
if ! awk -v p="${sub_path}" '$1==p && $0 !~ /^[[:space:]]*#/ && $2!="" { found=1 } END { exit(found?0:1) }' "${targets}" 2>/dev/null; then
|
|
84
|
-
echo "error: ${targets} missing entry for submodule path=${sub_path}"
|
|
85
|
-
t_missing=1
|
|
86
|
-
fi
|
|
87
|
-
done < <(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null || true)
|
|
88
|
-
if [[ "${t_missing}" -ne 0 ]]; then
|
|
89
|
-
echo "hint: fill ${targets} as: <path> <target_branch> [remote]"
|
|
90
|
-
exit 2
|
|
91
|
-
fi
|
|
92
|
-
fi
|
|
93
|
-
fi
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## A) 发现 submodules 清单(数量不固定)
|
|
97
|
-
在 superproject 根目录执行:
|
|
98
|
-
```bash
|
|
99
|
-
git submodule status --recursive
|
|
100
|
-
```
|
|
101
|
-
如果没有 submodule:跳到 C)。
|
|
102
|
-
|
|
103
|
-
## B) 逐个提交 submodules(先 submodule,后 superproject)
|
|
104
|
-
对每个 submodule path(可递归)重复以下步骤(建议按 `git submodule status --recursive` 顺序):
|
|
105
|
-
1) 定位并检查状态:
|
|
106
|
-
```bash
|
|
107
|
-
sub_path="<path>"
|
|
108
|
-
git -C "$sub_path" branch --show-current
|
|
109
|
-
git -C "$sub_path" status --porcelain
|
|
110
|
-
```
|
|
111
|
-
2) 先确定该 submodule 的目标分支来源,并显式说明给用户:
|
|
112
|
-
- `branch --show-current` 非空:默认建议用当前分支
|
|
113
|
-
- `branch --show-current` 为空(detached HEAD):默认建议用 `.gitmodules` 的 `submodule.<name>.branch`
|
|
114
|
-
- 若建议值与 `changes/<change-id>/submodules.targets` 已落盘值不一致:以 `submodules.targets` 为准,并先提示差异
|
|
115
|
-
3) 若 submodule 处于 detached HEAD(`branch --show-current` 为空):
|
|
116
|
-
- 说明:这通常是因为 superproject 的 gitlink checkout(例如 `git submodule update`)导致 detached。
|
|
117
|
-
- 不要直接切 `change/<change-id>` / `main` / `master` 来解 detached。
|
|
118
|
-
- 若你要在该 submodule 里提交:先按目标分支挂到 pin 分支 `aiws/pin/<target-branch>`,再在其上提交:
|
|
119
|
-
- 目标分支真值优先级:`changes/<change-id>/submodules.targets`(若存在)> `.gitmodules submodule.<name>.branch`
|
|
120
|
-
```bash
|
|
121
|
-
change_id="<change-id>"
|
|
122
|
-
targets="changes/${change_id}/submodules.targets"
|
|
123
|
-
sub_name="$(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null | awk -v p="${sub_path}" '$2==p { name=$1; sub(/^submodule\\./,"",name); sub(/\\.path$/,"",name); print name; exit }')"
|
|
124
|
-
base_branch="$(python3 - <<'PY'
|
|
125
|
-
import json, pathlib
|
|
126
|
-
change_id = "<change-id>"
|
|
127
|
-
meta = pathlib.Path("changes") / change_id / ".ws-change.json"
|
|
128
|
-
data = json.loads(meta.read_text(encoding="utf-8"))
|
|
129
|
-
print((data.get("base_branch") or "").strip())
|
|
130
|
-
PY
|
|
131
|
-
)"
|
|
132
|
-
test -n "${sub_name}"
|
|
133
|
-
test -n "${base_branch}"
|
|
134
|
-
|
|
135
|
-
source tools/ws_resolve_sub_target.sh
|
|
136
|
-
ws_resolve_sub_target "${sub_path}" "${sub_name}" "${targets}" "${base_branch}" || exit 2
|
|
137
|
-
target_branch="${_resolved_branch}"
|
|
138
|
-
remote="${_resolved_remote}"
|
|
139
|
-
|
|
140
|
-
git -C "$sub_path" fetch "${remote}" --prune
|
|
141
|
-
if ! git -C "$sub_path" show-ref --verify --quiet "refs/remotes/${remote}/${target_branch}"; then
|
|
142
|
-
echo "error: missing ${remote}/${target_branch} for submodule path=${sub_path}"
|
|
143
|
-
exit 2
|
|
144
|
-
fi
|
|
145
|
-
git -C "$sub_path" checkout -B "aiws/pin/${target_branch}" HEAD
|
|
146
|
-
git -C "$sub_path" branch --set-upstream-to "${remote}/${target_branch}" "aiws/pin/${target_branch}" >/dev/null 2>&1 || true
|
|
147
|
-
```
|
|
148
|
-
- 若 `origin/<target-branch>` 不存在,或用户明确不想使用 pin 分支:停止,解释风险(提交可能不可追溯/难以推送)。
|
|
149
|
-
4) 选择性 staging(默认用 `-p` 更安全):
|
|
150
|
-
```bash
|
|
151
|
-
git -C "$sub_path" add -p
|
|
152
|
-
git -C "$sub_path" diff --staged --stat
|
|
153
|
-
git -C "$sub_path" diff --staged
|
|
154
|
-
```
|
|
155
|
-
5) AI 生成该 submodule 的 commit message(标题+可选 body),并让用户确认(每个 repo 单独确认)。
|
|
156
|
-
6) 执行提交(不带 `--no-verify`):
|
|
157
|
-
```bash
|
|
158
|
-
git -C "$sub_path" commit -m "<message>"
|
|
159
|
-
```
|
|
160
|
-
7) 若该 submodule 没有 staged changes:跳过(不要硬提交空 commit)。
|
|
161
|
-
|
|
162
|
-
## C) 提交 superproject(更新 gitlinks + 自身改动 + changes 工件)
|
|
163
|
-
1) 先检查 submodule 指针差异(gitlinks):
|
|
164
|
-
```bash
|
|
165
|
-
git diff --submodule
|
|
166
|
-
```
|
|
167
|
-
2) 选择性 staging:
|
|
168
|
-
- 先 stage 发生指针变化的 submodule 路径(明确列出):
|
|
169
|
-
```bash
|
|
170
|
-
git add <submodule-path-1> <submodule-path-2>
|
|
171
|
-
```
|
|
172
|
-
- 再 stage superproject 自身改动(默认 `-p`):
|
|
173
|
-
```bash
|
|
174
|
-
git add -p
|
|
175
|
-
git diff --staged --stat
|
|
176
|
-
git diff --staged
|
|
177
|
-
```
|
|
178
|
-
3) AI 生成 superproject 的 commit message(应包含 `bump submodule <name> -> <sha>` 等关键信息),并让用户确认。
|
|
179
|
-
4) 提交:
|
|
180
|
-
```bash
|
|
181
|
-
git commit -m "<message>"
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## D) 门禁与证据(推荐)
|
|
185
|
-
```bash
|
|
186
|
-
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
187
|
-
./node_modules/.bin/aiws validate . --stamp
|
|
188
|
-
elif command -v aiws >/dev/null 2>&1; then
|
|
189
|
-
aiws validate . --stamp
|
|
190
|
-
else
|
|
191
|
-
npx @aipper/aiws validate . --stamp
|
|
192
|
-
fi
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## D2) 生成持久证据并回填 Evidence_Path(强烈建议)
|
|
196
|
-
> 说明:`.agentdocs/tmp/...` 默认 gitignored;交付前建议把关键结果落到 `changes/<change-id>/evidence/...` 并回填 `proposal.md`/`plan` 的 `Evidence_Path`,避免后续评审/二次会话读不到证据。
|
|
197
|
-
```bash
|
|
198
|
-
change_id="<change-id>"
|
|
199
11
|
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
200
|
-
./node_modules/.bin/aiws
|
|
12
|
+
./node_modules/.bin/aiws ws-deliver
|
|
201
13
|
elif command -v aiws >/dev/null 2>&1; then
|
|
202
|
-
aiws
|
|
14
|
+
aiws ws-deliver
|
|
203
15
|
else
|
|
204
|
-
npx @aipper/aiws
|
|
16
|
+
npx @aipper/aiws ws-deliver
|
|
205
17
|
fi
|
|
206
18
|
```
|
|
207
|
-
|
|
208
|
-
## D3) 生成状态快照(可选,建议)
|
|
209
|
-
```bash
|
|
210
|
-
aiws change state "${change_id}" --write
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## E) 安全合并回目标分支(fast-forward)
|
|
214
|
-
优先使用 `$ws-finish`(底层调用 `aiws change finish`,并在 push 成功后清理对应 change worktree)。
|
|
215
|
-
|
|
216
|
-
若需要显式指定目标分支:
|
|
217
|
-
```bash
|
|
218
|
-
aiws change finish <change-id> --into <base-branch>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
## F) 归档说明
|
|
222
|
-
- 标准链路下不需要再单独执行 `aiws change archive <change-id>`。
|
|
223
|
-
- 进入 `$ws-finish` 并使用 `aiws change finish --push` 时,会自动完成 archive + handoff。
|
|
224
|
-
|
|
225
|
-
输出要求:
|
|
226
|
-
- `Submodules:` 每个 submodule 的分支/提交摘要(repo → commit sha → message)
|
|
227
|
-
- `Superproject:` 提交摘要
|
|
228
|
-
- `Merge:` `aiws change finish` 的输出(into/from)
|
|
229
|
-
- `Worktree cleanup:` 若存在独立 change worktree,输出清理结果(removed/skipped + reason)
|
|
230
|
-
- `Evidence:` `.agentdocs/tmp/aiws-validate/*.json`(若使用 --stamp)
|