@aipper/aiws-spec 0.0.28 → 0.0.30
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 +108 -2
- package/docs/workflow-delegation-contracts.md +13 -0
- package/docs/workflow-delegation-contracts.schema.json +152 -0
- package/docs/workflow-governance-rules.json +47 -6
- package/docs/workflow-governance-rules.md +8 -7
- package/docs/workflow-governance-rules.schema.json +39 -1
- package/docs/workflow-review-gates.json +6 -0
- package/docs/workflow-review-gates.md +14 -5
- package/docs/workflow-review-gates.schema.json +4 -0
- package/docs/workflow-router-rules.json +72 -8
- package/docs/workflow-router-rules.md +21 -14
- package/docs/workflow-router-rules.schema.json +4 -0
- package/docs/workflow-stage-contracts.json +24 -5
- package/docs/workflow-stage-contracts.md +16 -15
- package/docs/workflow-stage-contracts.schema.json +12 -1
- package/package.json +1 -1
- package/templates/workspace/.agents/skills/using-aiws/SKILL.md +16 -10
- 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 +82 -141
- package/templates/workspace/.agents/skills/ws-finish/SKILL.md +9 -204
- package/templates/workspace/.agents/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.agents/skills/ws-migrate/SKILL.md +6 -42
- package/templates/workspace/.agents/skills/ws-plan-verify/SKILL.md +6 -58
- package/templates/workspace/.agents/skills/ws-pull/SKILL.md +8 -109
- package/templates/workspace/.agents/skills/ws-push/SKILL.md +8 -100
- package/templates/workspace/.agents/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.agents/skills/ws-submodule-setup/SKILL.md +10 -57
- package/templates/workspace/.agents/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/{changes → .aiws/changes}/README.md +20 -23
- package/templates/workspace/{changes → .aiws/changes}/templates/proposal.md +12 -12
- package/templates/workspace/{changes → .aiws/changes}/templates/tasks.md +8 -8
- package/templates/workspace/{issues → .aiws/issues}/problem-issues.csv +1 -1
- package/templates/workspace/.aiws/journal/.gitkeep +1 -0
- package/templates/workspace/{requirements → .aiws/requirements}/requirements-issues.csv +1 -1
- package/templates/workspace/.aiws/tmp/.gitkeep +0 -0
- package/templates/workspace/{tools → .aiws/tools}/requirements_contract.py +2 -2
- package/templates/workspace/{tools → .aiws/tools}/requirements_contract_sync.py +2 -2
- package/templates/workspace/{tools → .aiws/tools}/requirements_flow_gen.py +1 -1
- package/templates/workspace/{tools → .aiws/tools}/server_test_runner.py +10 -10
- package/templates/workspace/{tools → .aiws/tools}/ws_change_check.py +23 -23
- package/templates/workspace/{tools → .aiws/tools}/ws_resolve_sub_target.sh +2 -2
- package/templates/workspace/{tools → .aiws/tools}/ws_tasks_plan.py +3 -3
- 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 +9 -204
- package/templates/workspace/.claude/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.claude/skills/ws-migrate/SKILL.md +6 -42
- package/templates/workspace/.claude/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.claude/skills/ws-pull/SKILL.md +8 -109
- package/templates/workspace/.claude/skills/ws-push/SKILL.md +8 -100
- package/templates/workspace/.claude/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.claude/skills/ws-submodule-setup/SKILL.md +10 -57
- package/templates/workspace/.claude/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/.githooks/pre-commit +13 -0
- package/templates/workspace/.githooks/pre-push +7 -0
- 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 +11 -3
- 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/lib/aiws-context.js +953 -0
- package/templates/workspace/.opencode/oh-my-opencode.json.example +64 -4
- package/templates/workspace/.opencode/plugins/aiws-inject-context.js +201 -0
- package/templates/workspace/.opencode/plugins/aiws-session-start.js +86 -0
- package/templates/workspace/.opencode/plugins/aiws-workflow-state.js +116 -0
- package/templates/workspace/.opencode/scripts/ws-plan-gen-submodule-targets.sh +27 -0
- package/templates/workspace/.opencode/scripts/ws-plan-setup-worktree.sh +31 -0
- package/templates/workspace/.opencode/skills/using-aiws/SKILL.md +130 -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 +115 -40
- package/templates/workspace/.opencode/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.opencode/skills/ws-dev/SKILL.md +105 -146
- package/templates/workspace/.opencode/skills/ws-dev-lite/SKILL.md +23 -7
- package/templates/workspace/.opencode/skills/ws-finish/SKILL.md +9 -204
- 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 +43 -4
- package/templates/workspace/.opencode/skills/ws-migrate/SKILL.md +6 -42
- package/templates/workspace/.opencode/skills/ws-plan/SKILL.md +15 -55
- 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 +7 -2
- 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 +35 -4
- 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 +45 -55
- package/templates/workspace/AGENTS.md +32 -84
- package/templates/workspace/AI_PROJECT.md +5 -5
- package/templates/workspace/AI_WORKSPACE.md +1 -1
- package/templates/workspace/REQUIREMENTS.md +1 -1
- package/templates/workspace/gitignore +1 -1
- package/templates/workspace/manifest.json +215 -395
- /package/templates/workspace/{changes → .aiws/changes}/templates/design.md +0 -0
- /package/templates/workspace/{memory-bank → .aiws/memory-bank}/README.md +0 -0
- /package/templates/workspace/{memory-bank → .aiws/memory-bank}/architecture.md +0 -0
- /package/templates/workspace/{memory-bank → .aiws/memory-bank}/implementation-plan.md +0 -0
- /package/templates/workspace/{memory-bank → .aiws/memory-bank}/progress.md +0 -0
- /package/templates/workspace/{memory-bank → .aiws/memory-bank}/tech-stack.md +0 -0
- /package/templates/workspace/{requirements → .aiws/requirements}/CHANGELOG.md +0 -0
- /package/templates/workspace/{secrets → .aiws/secrets}/test-accounts.example.json +0 -0
|
@@ -1,63 +1,138 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-delegate
|
|
3
|
-
description:
|
|
3
|
+
description: 使用时机:需要拆分子任务、委托给子 agent 时。触发词:委托、子 agent、拆分、并行、sub-agent。注意:简单任务不需委托。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
7
7
|
|
|
8
8
|
目标:在 OpenCode 中,优先借用 `oh-my-opencode` 的现有 agent 做任务拆分;若 oMo 不可用,再回退为普通 OpenCode delegation / 单 agent 执行。
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## 核心约束
|
|
11
|
+
|
|
12
|
+
- **Subagent-First**:主 session 只做编排与收敛,不直接写实现代码。所有产出必须由 subagent 完成并可追溯到具体 worker。
|
|
13
|
+
- **Handoff 证据**:每轮委托完成后,worker 必须产出结构化 handoff 到 `changes/<id>/handoff-evidence.md`(完成项、未完成项、残余风险),供主 session 收敛判断。handoff 文件缺失等同于委托未完成。
|
|
14
|
+
|
|
15
|
+
## 必需输入
|
|
16
|
+
|
|
11
17
|
- 真值文件:`AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`
|
|
12
18
|
- delegation contract:`packages/spec/docs/workflow-delegation-contracts.md`
|
|
19
|
+
- 上下文策展规范:`packages/spec/docs/workflow-delegation-context-injection.md`
|
|
13
20
|
- OpenCode + oMo 适配说明:`packages/spec/docs/opencode-omo-adapter.md`
|
|
21
|
+
- 连续执行循环:`packages/spec/docs/opencode-subagent-first.md`
|
|
14
22
|
- 当前任务已绑定 `Req_ID` / change / Verify
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
## 必需输出
|
|
25
|
+
|
|
26
|
+
- `Delegation Plan:` role / preferred agent / readScope / writeScope / artifactTargets / fallback
|
|
27
|
+
- `Context Curation:` 上下文策展详情
|
|
18
28
|
- `Execution Mode:` `omo-native` / `opencode-native` / `single-agent`
|
|
19
29
|
- `Evidence:` 产物路径
|
|
20
30
|
- `Next:` 回到 `ws-dev` / `ws-review` / `ws-commit` / `ws-finish`
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
## 执行要求
|
|
33
|
+
|
|
34
|
+
- 主 session 不直接改代码:所有实现与验证产物必须由 subagent 产出并向 handoff 记录可追溯
|
|
35
|
+
- handoff 证据:手交材料中须含 delegate round number、产出文件路径、已知未关闭项
|
|
36
|
+
|
|
37
|
+
## 阻断条件
|
|
38
|
+
|
|
23
39
|
- 任务未绑定
|
|
24
40
|
- 没有写清委托边界
|
|
41
|
+
- 上下文策展未执行(未生成 JSONL 或未在 prompt 中引用)
|
|
25
42
|
- 无法判断当前是否可用 oMo,又不能接受回退
|
|
43
|
+
- handoff 文件 `changes/<id>/handoff-evidence.md` 缺失或为空(委托返回后必须检查)
|
|
44
|
+
|
|
45
|
+
## 角色映射
|
|
46
|
+
|
|
47
|
+
| aiws 角色 | oMo Agent |
|
|
48
|
+
|-----------|-----------|
|
|
49
|
+
| `planner` | `planner-sisyphus` |
|
|
50
|
+
| `explorer` | `@explore` / `@librarian` |
|
|
51
|
+
| `reviewer` | `@oracle` |
|
|
52
|
+
| `integrator` | 当前主 agent |
|
|
53
|
+
|
|
54
|
+
**推荐标准角色**(source: `workflow-delegation-contracts.json` standardRoles):
|
|
55
|
+
|
|
56
|
+
| 角色 | 职责 | 读取范围 | 写入范围 |
|
|
57
|
+
|------|------|----------|----------|
|
|
58
|
+
| `implementer` | 代码+测试实现 | 真值文件+change上下文 | 代码文件+测试文件+evidence/ |
|
|
59
|
+
| `reviewer` | 独立审查 | 真值文件+diff+evidence | review/*.md |
|
|
60
|
+
| `researcher` | 分析探索 | 真值文件+外部文档 | analysis/*.md |
|
|
61
|
+
|
|
62
|
+
这些角色为建议非强制;委托时优先参考但允许根据任务需要调整。
|
|
63
|
+
|
|
64
|
+
## 连续执行循环(Worker → Reviewer → Fix)
|
|
65
|
+
|
|
66
|
+
默认闭环(详见 `packages/spec/docs/opencode-subagent-first.md`):
|
|
67
|
+
|
|
68
|
+
1. 主 session 策展上下文 JSONL → dispatch `aiws-worker`
|
|
69
|
+
2. 检查 worker 返回状态(DONE / DONE_WITH_CONCERNS / NEEDS_CONTEXT / BLOCKED)
|
|
70
|
+
3. DONE → dispatch `aiws-reviewer`
|
|
71
|
+
4. Reviewer pass → 收敛 evidence;fail → 返回 worker 修复(最多 3 次)
|
|
72
|
+
5. DONE_WITH_CONCERNS → 先 `ws-quality-review`
|
|
73
|
+
6. NEEDS_CONTEXT → 补充上下文重试(最多 2 次)
|
|
74
|
+
7. BLOCKED → 输出 blocker 详情,不继续
|
|
75
|
+
|
|
76
|
+
## 上下文策展
|
|
77
|
+
|
|
78
|
+
详细规范见 `packages/spec/docs/workflow-delegation-context-injection.md`。
|
|
79
|
+
|
|
80
|
+
策展步骤:
|
|
81
|
+
1. 读取合同基线(`delegation-contracts.json` 中对应角色的 `contextFiles`)
|
|
82
|
+
2. 展开 glob 为实际路径(替换 `<id>`)
|
|
83
|
+
3. 委托者调整:添加/删除/调整 priority/sections
|
|
84
|
+
4. 预算检查:high+medium ≤ 5 文件,总行数 ≤ 4000
|
|
85
|
+
5. 写入 `changes/<id>/analysis/<role>-context.jsonl`
|
|
86
|
+
|
|
87
|
+
OpenCode 插件 `aiws-inject-context` 会自动注入 JSONL 上下文——只需在 `task()` 中指定 `role: <role>`。
|
|
88
|
+
|
|
89
|
+
## 子 agent 返回协议
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
**Status:** DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
|
|
93
|
+
**Completed:** 实现内容
|
|
94
|
+
**Files Changed:** 文件路径
|
|
95
|
+
**Verification:** 命令 + 结果
|
|
96
|
+
**Artifacts:** analysis|patches|review|evidence 下的路径
|
|
97
|
+
**Concerns:** 疑虑或未完成项
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 状态处理
|
|
101
|
+
|
|
102
|
+
- **DONE**: 进入 ws-review;若已过 review 则准备 ws-finish
|
|
103
|
+
- **DONE_WITH_CONCERNS**: 先 ws-quality-review,根据风险决定是否阻断
|
|
104
|
+
- **NEEDS_CONTEXT**: 补上下文重试(最多 2 次);仍失败则回退单 agent
|
|
105
|
+
- **BLOCKED**: 停止委托;解 blocker 后重试;永不到达则升级给用户
|
|
106
|
+
|
|
107
|
+
## Delegation Plan 格式
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
**Delegation Plan:**
|
|
111
|
+
- role: worker
|
|
112
|
+
- preferred agent: aiws-worker
|
|
113
|
+
- task: <描述>
|
|
114
|
+
- readScope: <文件/目录>
|
|
115
|
+
- writeScope: <文件/目录>
|
|
116
|
+
- artifactTargets: changes/<id>/patches/, changes/<id>/evidence/
|
|
117
|
+
- fallback: single-agent
|
|
118
|
+
Context Curation: changes/<id>/analysis/worker-context.jsonl
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 委托者检查清单
|
|
122
|
+
|
|
123
|
+
派遣前:
|
|
124
|
+
- [ ] 子 agent prompt 包含上下文引用
|
|
125
|
+
- [ ] JSONL 已写入 `changes/<id>/analysis/<role>-context.jsonl`
|
|
126
|
+
- [ ] 预算检查通过
|
|
127
|
+
- [ ] readScope / writeScope / artifactTargets 已声明
|
|
26
128
|
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
- `
|
|
32
|
-
|
|
33
|
-
执行步骤(建议):
|
|
34
|
-
1) 先读真值文件、delegation contract 和 `opencode-omo-adapter.md`。
|
|
35
|
-
2) 判断当前项目是否启用了 oMo:
|
|
36
|
-
- 优先检查 `.opencode/oh-my-opencode.json`
|
|
37
|
-
- 或当前会话是否明确可用 `planner-sisyphus` / `librarian` / `explore` / `oracle`
|
|
38
|
-
3) 先写 `Delegation Plan:`:
|
|
39
|
-
- `role`
|
|
40
|
-
- `preferred agent`
|
|
41
|
-
- `task`
|
|
42
|
-
- `readScope`
|
|
43
|
-
- `writeScope`
|
|
44
|
-
- `artifactTargets`
|
|
45
|
-
- `fallback`
|
|
46
|
-
4) 若 oMo 可用:
|
|
47
|
-
- planning 优先 `planner-sisyphus`
|
|
48
|
-
- 文档/知识检索优先 `@librarian`
|
|
49
|
-
- 代码导航与结构探索优先 `@explore`
|
|
50
|
-
- 独立审查优先 `@oracle`
|
|
51
|
-
5) 主 agent 统一收敛结果,并把产物回收到:
|
|
52
|
-
- `changes/<id>/analysis/`
|
|
53
|
-
- `changes/<id>/patches/`
|
|
54
|
-
- `changes/<id>/review/`
|
|
55
|
-
- `changes/<id>/evidence/`
|
|
56
|
-
6) 若 oMo 不可用:
|
|
57
|
-
- 输出 `Execution Mode: opencode-native` 或 `Execution Mode: single-agent`
|
|
58
|
-
- 不阻断工作流,继续按 AIWS 委托合同执行
|
|
129
|
+
返回后:
|
|
130
|
+
- [ ] 解析 Status 行
|
|
131
|
+
- [ ] 非 DONE → 按状态处理规则行动
|
|
132
|
+
- [ ] 非 DONE → 记录决策到 `delegation-decisions.md`
|
|
133
|
+
- [ ] handoff 文件 `changes/<id>/handoff-evidence.md` 已存在且非空
|
|
59
134
|
|
|
60
135
|
安全:
|
|
61
|
-
- 不让 `ws-delegate` 变成第二套 orchestrator
|
|
62
|
-
-
|
|
63
|
-
-
|
|
136
|
+
- 不让 `ws-delegate` 变成第二套 orchestrator
|
|
137
|
+
- 不让 delegated agent 越权写未授权文件
|
|
138
|
+
- 不跳过 submodule drift check(若 `.gitmodules` 存在)
|
|
@@ -1,230 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-deliver
|
|
3
|
-
description:
|
|
3
|
+
description: Thin wrapper for `aiws 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
|
+
Thin skill wrapper. Delegates to `aiws deliver`. See `aiws deliver --help` for details.
|
|
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 deliver
|
|
201
13
|
elif command -v aiws >/dev/null 2>&1; then
|
|
202
|
-
aiws
|
|
14
|
+
aiws deliver
|
|
203
15
|
else
|
|
204
|
-
npx @aipper/aiws
|
|
16
|
+
npx @aipper/aiws 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)
|