@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,59 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-verify-before-complete
|
|
3
|
-
description:
|
|
3
|
+
description: `aiws ws-verify-before-complete` 的薄包装入口
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# ws-verify-before-complete
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- 在进入 `$ws-finish` / `$ws-handoff` 前,检查 review、validate stamp 和证据是否齐全
|
|
10
|
-
- 输出明确的 pass/fail 结论,避免“看起来完成了但 gate 没过”的伪完成
|
|
8
|
+
`aiws ws-verify-before-complete` 的薄包装入口。
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
必需输出:
|
|
22
|
-
- `证据(Evidence):` `changes/<change-id>/evidence/verify-before-complete.md` 或回退 `.agentdocs/tmp/review/verify-before-complete.md`
|
|
23
|
-
- `结论(Result):` pass / fail
|
|
24
|
-
- `缺失项(Missing):` 未满足的 gate
|
|
25
|
-
- `下一步(Next):` 进入 `$ws-finish` / `$ws-handoff`,或回退前置 gate
|
|
26
|
-
|
|
27
|
-
阻断条件:
|
|
28
|
-
- 缺少 spec review
|
|
29
|
-
- 缺少 quality review
|
|
30
|
-
- 缺少 validate stamp
|
|
31
|
-
- review 中仍有未关闭 blocker
|
|
32
|
-
- 无法写 verification 证据
|
|
33
|
-
|
|
34
|
-
完成判定:
|
|
35
|
-
- 已落盘 verify-before-complete 证据,并明确能否进入 `$ws-finish` / `$ws-handoff`。
|
|
36
|
-
|
|
37
|
-
步骤(建议):
|
|
38
|
-
1) 识别当前 `change/<change-id>`。
|
|
39
|
-
2) 检查以下最小 gate:
|
|
40
|
-
- `changes/<change-id>/review/spec-review.md`
|
|
41
|
-
- `changes/<change-id>/review/quality-review.md`
|
|
42
|
-
- `.agentdocs/tmp/aiws-validate/*.json`
|
|
43
|
-
3) 若存在 `changes/<change-id>/evidence/`,检查是否已经收敛 review / validate / collaboration summary。
|
|
44
|
-
4) 将结果落盘到:
|
|
45
|
-
- 默认:`changes/<change-id>/evidence/verify-before-complete.md`
|
|
46
|
-
- 回退:`.agentdocs/tmp/review/verify-before-complete.md`
|
|
47
|
-
5) 输出:
|
|
48
|
-
- `证据(Evidence):`
|
|
49
|
-
- `结论(Result): pass|fail`
|
|
50
|
-
- `缺失项(Missing):`
|
|
51
|
-
- `下一步(Next):`
|
|
52
|
-
|
|
53
|
-
重点:
|
|
54
|
-
- 这个 gate 不替代 `$ws-finish`;它只判断“是否具备进入 finish / handoff 的前置条件”。
|
|
55
|
-
- 若 fail,必须明确回退到哪个 gate:`$ws-spec-review`、`$ws-quality-review`、`aiws validate . --stamp` 或 `aiws change evidence <change-id>`。
|
|
56
|
-
|
|
57
|
-
安全:
|
|
58
|
-
- 不打印 secrets。
|
|
59
|
-
- 不执行破坏性命令。
|
|
10
|
+
```bash
|
|
11
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
12
|
+
./node_modules/.bin/aiws ws-verify-before-complete
|
|
13
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
14
|
+
aiws ws-verify-before-complete
|
|
15
|
+
else
|
|
16
|
+
npx @aipper/aiws ws-verify-before-complete
|
|
17
|
+
fi
|
|
18
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 自动 bootstrap:检查 update、确保 watchdog 已启动,并给出下一步
|
|
3
|
+
---
|
|
4
|
+
<!-- AIWS_MANAGED_BEGIN:opencode:ws-auto -->
|
|
5
|
+
# ws auto
|
|
6
|
+
|
|
7
|
+
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
8
|
+
|
|
9
|
+
目标:为当前 OpenCode 工作区执行一次显式 auto bootstrap,先补齐托管内容,再按条件启动 watchdog。
|
|
10
|
+
|
|
11
|
+
执行建议:
|
|
12
|
+
1) 先运行 `/ws-preflight`,确认 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md` 已读取。
|
|
13
|
+
2) 在项目根运行 `aiws opencode auto .`。
|
|
14
|
+
3) 输出:
|
|
15
|
+
- `Auto Bootstrap:`
|
|
16
|
+
- `Update:`
|
|
17
|
+
- `OpenCode mode:`
|
|
18
|
+
- `Watchdog:`
|
|
19
|
+
- `Next:`
|
|
20
|
+
4) 若输出 `watchdog:` 为已启动状态:
|
|
21
|
+
- 若当前任务意图明确:继续 `/using-aiws`、`/ws-plan`、`/ws-dev` 或 `/ws-review`
|
|
22
|
+
- 若当前只是要声明自主协作合同:继续 `/ws-autonomy`
|
|
23
|
+
5) 若输出 `watchdog: skipped (...)`:
|
|
24
|
+
- 明确写出原因
|
|
25
|
+
- 不要假装已经进入 autonomous 模式
|
|
26
|
+
|
|
27
|
+
边界:
|
|
28
|
+
- 允许通过 `aiws update .` 刷新 AIWS 托管内容。
|
|
29
|
+
- 不自动复制 `.opencode/oh-my-opencode.json.example` 成真实配置。
|
|
30
|
+
- 不自动批准 host permission,不自动执行 tmux rescue。
|
|
31
|
+
<!-- AIWS_MANAGED_END:opencode:ws-auto -->
|
|
32
|
+
|
|
33
|
+
可在下方追加本项目对 auto bootstrap 的额外说明(托管块外内容会被保留)。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 自主协作实验:声明 completion/retry/rescue 合同,并按需启用 tmux helper
|
|
3
|
+
---
|
|
4
|
+
<!-- AIWS_MANAGED_BEGIN:opencode:ws-autonomy -->
|
|
5
|
+
# ws autonomy
|
|
6
|
+
|
|
7
|
+
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
8
|
+
|
|
9
|
+
目标:声明当前 OpenCode/oMo 任务的 autonomous execution mode,并写清 completion/retry/rescue 合同。
|
|
10
|
+
|
|
11
|
+
执行建议:
|
|
12
|
+
1) 先运行 `/ws-preflight`,再读取 `packages/spec/docs/opencode-autonomous-swarm.md` 与 `packages/spec/docs/opencode-omo-adapter.md`。
|
|
13
|
+
2) 输出:
|
|
14
|
+
- `Execution Mode: single-agent / omo-native / omo-native + tmux-swarm`
|
|
15
|
+
- `Completion Contract:`
|
|
16
|
+
- `Retry Contract:`
|
|
17
|
+
- `Rescue Policy:`
|
|
18
|
+
- `Evidence:`
|
|
19
|
+
3) 若选择 `omo-native + tmux-swarm`:
|
|
20
|
+
- 先运行 `.opencode/helpers/tmux-swarm-scan.sh`
|
|
21
|
+
- 仅在需要安全白名单救援时运行 `.opencode/helpers/tmux-swarm-rescue.sh`
|
|
22
|
+
4) 明确这是实验层,不接管 runtime controller,不替代 `ws-plan` / `ws-dev` / `ws-review`。
|
|
23
|
+
<!-- AIWS_MANAGED_END:opencode:ws-autonomy -->
|
|
24
|
+
|
|
25
|
+
可在下方追加本项目对 autonomous swarm 的额外说明(托管块外内容会被保留)。
|
|
@@ -19,7 +19,11 @@ description: 评审:提交前审计改动并落盘证据
|
|
|
19
19
|
3) 将审计落盘到(目录不存在则创建):
|
|
20
20
|
- 默认:`changes/<change-id>/review/codex-review.md`
|
|
21
21
|
- 回退:`.agentdocs/tmp/review/codex-review.md`(仅在无法确定 `change-id` 时使用)
|
|
22
|
-
4)
|
|
22
|
+
4) 若当前任务已进入“准备提交/交付/finish”的语境,继续补齐 dual review gate:
|
|
23
|
+
- 运行/收敛 `/ws-spec-review`,落盘 `changes/<change-id>/review/spec-review.md`
|
|
24
|
+
- 运行/收敛 `/ws-quality-review`,落盘 `changes/<change-id>/review/quality-review.md`
|
|
25
|
+
- 不要把单个 `codex-review.md` 误当成 finish gate 已完成
|
|
26
|
+
5) 回复中输出:
|
|
23
27
|
- `证据(Evidence):` 证据文件路径
|
|
24
28
|
- `主要风险(Top risks):` 3–8 条(高→低)
|
|
25
29
|
- `下一步(Next):` 最小修复清单 + 最小验证命令
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 自动 bootstrap:检查 update、确保 watchdog 已启动,并给出下一步
|
|
3
|
+
---
|
|
4
|
+
<!-- AIWS_MANAGED_BEGIN:opencode:ws-auto -->
|
|
5
|
+
# ws auto
|
|
6
|
+
|
|
7
|
+
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
8
|
+
|
|
9
|
+
目标:为当前 OpenCode 工作区执行一次显式 auto bootstrap,先补齐托管内容,再按条件启动 watchdog。
|
|
10
|
+
|
|
11
|
+
执行建议:
|
|
12
|
+
1) 先运行 `/ws-preflight`,确认 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md` 已读取。
|
|
13
|
+
2) 在项目根运行 `aiws opencode auto .`。
|
|
14
|
+
3) 输出:
|
|
15
|
+
- `Auto Bootstrap:`
|
|
16
|
+
- `Update:`
|
|
17
|
+
- `OpenCode mode:`
|
|
18
|
+
- `Watchdog:`
|
|
19
|
+
- `Next:`
|
|
20
|
+
4) 若输出 `watchdog:` 为已启动状态:
|
|
21
|
+
- 若当前任务意图明确:继续 `/using-aiws`、`/ws-plan`、`/ws-dev` 或 `/ws-review`
|
|
22
|
+
- 若当前只是要声明自主协作合同:继续 `/ws-autonomy`
|
|
23
|
+
5) 若输出 `watchdog: skipped (...)`:
|
|
24
|
+
- 明确写出原因
|
|
25
|
+
- 不要假装已经进入 autonomous 模式
|
|
26
|
+
|
|
27
|
+
边界:
|
|
28
|
+
- 允许通过 `aiws update .` 刷新 AIWS 托管内容。
|
|
29
|
+
- 不自动复制 `.opencode/oh-my-opencode.json.example` 成真实配置。
|
|
30
|
+
- 不自动批准 host permission,不自动执行 tmux rescue。
|
|
31
|
+
<!-- AIWS_MANAGED_END:opencode:ws-auto -->
|
|
32
|
+
|
|
33
|
+
可在下方追加本项目对 auto bootstrap 的额外说明(托管块外内容会被保留)。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 自主协作实验:声明 completion/retry/rescue 合同,并按需启用 tmux helper
|
|
3
|
+
---
|
|
4
|
+
<!-- AIWS_MANAGED_BEGIN:opencode:ws-autonomy -->
|
|
5
|
+
# ws autonomy
|
|
6
|
+
|
|
7
|
+
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
8
|
+
|
|
9
|
+
目标:声明当前 OpenCode/oMo 任务的 autonomous execution mode,并写清 completion/retry/rescue 合同。
|
|
10
|
+
|
|
11
|
+
执行建议:
|
|
12
|
+
1) 先运行 `/ws-preflight`,再读取 `packages/spec/docs/opencode-autonomous-swarm.md` 与 `packages/spec/docs/opencode-omo-adapter.md`。
|
|
13
|
+
2) 输出:
|
|
14
|
+
- `Execution Mode: single-agent / omo-native / omo-native + tmux-swarm`
|
|
15
|
+
- `Completion Contract:`
|
|
16
|
+
- `Retry Contract:`
|
|
17
|
+
- `Rescue Policy:`
|
|
18
|
+
- `Evidence:`
|
|
19
|
+
3) 若选择 `omo-native + tmux-swarm`:
|
|
20
|
+
- 先运行 `.opencode/helpers/tmux-swarm-scan.sh`
|
|
21
|
+
- 仅在需要安全白名单救援时运行 `.opencode/helpers/tmux-swarm-rescue.sh`
|
|
22
|
+
4) 明确这是实验层,不接管 runtime controller,不替代 `ws-plan` / `ws-dev` / `ws-review`。
|
|
23
|
+
<!-- AIWS_MANAGED_END:opencode:ws-autonomy -->
|
|
24
|
+
|
|
25
|
+
可在下方追加本项目对 autonomous swarm 的额外说明(托管块外内容会被保留)。
|
|
@@ -4,67 +4,15 @@ description: 提交:门禁/审计后提交(submodule 感知)
|
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-commit -->
|
|
5
5
|
# ws commit
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws commit`.
|
|
8
8
|
|
|
9
|
-
目标:在**当前分支可直提**的前提下,先做审计与门禁,并在存在 submodule 时给出正确的提交顺序(先 submodule,再 superproject),最后执行 `git commit`。
|
|
10
|
-
补充:若你经常遇到 submodule detached,建议日常拉取优先使用 `/ws-pull`(尽量把 submodule “挂回分支”且不改变 gitlink commit)。
|
|
11
|
-
|
|
12
|
-
安全约束(强制):
|
|
13
|
-
- 不自动 `git add -A`;只在用户明确指示时才做 staging
|
|
14
|
-
- 不使用 `--no-verify` 绕过 hooks
|
|
15
|
-
- 不自动 push
|
|
16
|
-
- 不打印 secrets
|
|
17
|
-
- commit message 优先使用中文;若启用了 `.githooks/commit-msg`,默认仅提示,只有 strict 模式才会拒绝全英文首行(`Merge/Revert/fixup!/squash!` 例外)
|
|
18
|
-
|
|
19
|
-
步骤(建议):
|
|
20
|
-
1) 先运行 `/ws-preflight`。
|
|
21
|
-
2) 运行 `/ws-review`(优先落盘审计证据到 `changes/<change-id>/review/`)。
|
|
22
|
-
3) 运行门禁校验并写 stamp:
|
|
23
9
|
```bash
|
|
24
10
|
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
25
|
-
./node_modules/.bin/aiws
|
|
11
|
+
./node_modules/.bin/aiws commit -m "<message>"
|
|
26
12
|
elif command -v aiws >/dev/null 2>&1; then
|
|
27
|
-
aiws
|
|
13
|
+
aiws commit -m "<message>"
|
|
28
14
|
else
|
|
29
|
-
npx @aipper/aiws
|
|
30
|
-
fi
|
|
31
|
-
```
|
|
32
|
-
4) 输出提交上下文(必须输出给用户确认):
|
|
33
|
-
```bash
|
|
34
|
-
git branch --show-current
|
|
35
|
-
git status --porcelain
|
|
36
|
-
```
|
|
37
|
-
5) submodule 感知检查:
|
|
38
|
-
```bash
|
|
39
|
-
if [[ -f .gitmodules ]]; then
|
|
40
|
-
git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' || true
|
|
15
|
+
npx @aipper/aiws commit -m "<message>"
|
|
41
16
|
fi
|
|
42
|
-
while read -r _ sub_path; do
|
|
43
|
-
[[ -z "${sub_path:-}" ]] && continue
|
|
44
|
-
echo "== submodule: ${sub_path} =="
|
|
45
|
-
git -C "${sub_path}" rev-parse --abbrev-ref HEAD 2>/dev/null || true
|
|
46
|
-
git -C "${sub_path}" status --porcelain || true
|
|
47
|
-
done < <(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null || true)
|
|
48
17
|
```
|
|
49
|
-
判定规则(强制):
|
|
50
|
-
- 任一 submodule `git status --porcelain` 非空:停止提交 superproject;先在对应 submodule 完成 commit,再回到 superproject 更新并提交 gitlink。
|
|
51
|
-
- 若该 submodule 当前为 detached HEAD:先按 `.gitmodules` 的目标分支挂到 `aiws/pin/<target-branch>`;不要直接切 `change/<change-id>` / `main` / `master`。
|
|
52
|
-
6) 检查 staging(必须输出给用户确认):
|
|
53
|
-
```bash
|
|
54
|
-
git status --porcelain
|
|
55
|
-
git diff --staged --submodule=short
|
|
56
|
-
```
|
|
57
|
-
7) 若没有 staged changes:停止并提示用户先明确要提交哪些文件(例如 `git add -p` 或 `git add <path>`)。
|
|
58
|
-
8) 优先生成并确认中文 commit message(格式建议:`<类型>: <简述>`;若用户明确要求英文也可保留,但 strict 模式下会被 hook 拒绝)。
|
|
59
|
-
9) 执行提交(不带 `--no-verify`):
|
|
60
|
-
```bash
|
|
61
|
-
git commit -m "<message>"
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
输出必须包含:
|
|
65
|
-
- `证据(Evidence):` `changes/<change-id>/review/*`(无 change-id 时回退 `.agentdocs/tmp/review/*`) + `.agentdocs/tmp/aiws-validate/*`
|
|
66
|
-
- `上下文(Context):` 当前分支 + 是否检测到 submodule + 若阻断则给出阻断原因
|
|
67
|
-
- `下一步(Next):` 若存在 submodule 改动,先提示用户进入 submodule 提交
|
|
68
18
|
<!-- AIWS_MANAGED_END:opencode:ws-commit -->
|
|
69
|
-
|
|
70
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -4,55 +4,15 @@ description: 交付:submodules+superproject 分步提交并安全合并回 bas
|
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-deliver -->
|
|
5
5
|
# ws deliver
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws deliver`.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
建议流程(按顺序):
|
|
20
|
-
1) 先运行 `/ws-preflight`。
|
|
21
|
-
2) 如果存在 `.gitmodules` 但缺少 `submodule.<name>.branch`,先运行 `/ws-submodule-setup` 并提交 `.gitmodules`(否则 `aiws validate .` 会失败,且 submodule 工作流会产生人为差异)。
|
|
22
|
-
2.1) 若存在 submodule:必须准备 `changes/<change-id>/submodules.targets`,并覆盖所有 submodule path;这是本次交付的目标分支真值。
|
|
23
|
-
- 生成该文件时可先做默认预填:detached HEAD 默认建议取 `.gitmodules` 声明分支;已附着在本地分支时默认建议取当前分支。
|
|
24
|
-
- 上述都只是建议值;真正的 deliver/finish 只认 `submodules.targets`。
|
|
25
|
-
2) 发现 submodules:
|
|
26
|
-
- `git submodule status --recursive`
|
|
27
|
-
3) 逐个提交 submodules(按上一步顺序):
|
|
28
|
-
- `git -C "<sub_path>" status --porcelain`
|
|
29
|
-
- 先说明该 submodule 目标分支的来源:attached branch 默认建议取当前分支;detached HEAD 默认建议取 `.gitmodules`;若与 `submodules.targets` 已落盘值冲突,则以 `submodules.targets` 为准
|
|
30
|
-
- 若当前为 detached HEAD:不要直接切 `change/<change-id>` / `main` / `master`;先按 `submodules.targets`(若分支为 `.` 则展开为 `.ws-change.json` 的 `base_branch`)挂到 `aiws/pin/<target-branch>`
|
|
31
|
-
- `git -C "<sub_path>" add -p`
|
|
32
|
-
- `git -C "<sub_path>" diff --staged --stat`
|
|
33
|
-
- 生成并让用户确认该 submodule 的 commit message(每个 repo 单独确认)
|
|
34
|
-
- `git -C "<sub_path>" commit -m "<message>"`
|
|
35
|
-
4) 提交 superproject(gitlinks + 自身改动):
|
|
36
|
-
- `git diff --submodule`
|
|
37
|
-
- `git add <submodule-path-1> <submodule-path-2> ...`
|
|
38
|
-
- `git add -p`
|
|
39
|
-
- 生成并让用户确认 superproject 的 commit message
|
|
40
|
-
- `git commit -m "<message>"`
|
|
41
|
-
5) (推荐)门禁 + 证据:
|
|
42
|
-
- `aiws validate . --stamp`(未安装全局 aiws 时可用 `npx @aipper/aiws validate . --stamp`)
|
|
43
|
-
5.1) (强烈建议)生成持久证据并回填 `Evidence_Path`:
|
|
44
|
-
- `aiws change evidence <change-id>`(未安装全局 aiws 时可用 `npx @aipper/aiws change evidence <change-id>`)
|
|
45
|
-
5.2) (可选)生成状态快照(建议):
|
|
46
|
-
- `aiws change state <change-id> --write`
|
|
47
|
-
6) 安全合并回目标分支:
|
|
48
|
-
- 优先运行 `/ws-finish`(底层调用 `aiws change finish`,默认 `--ff-only`;push 成功后会清理对应 change worktree)
|
|
49
|
-
|
|
50
|
-
输出要求:
|
|
51
|
-
- `Submodules:` 每个 submodule 的 commit 摘要(repo/path → sha → message)
|
|
52
|
-
- `Superproject:` commit 摘要
|
|
53
|
-
- `Merge:` `/ws-finish` 输出(into/from)
|
|
54
|
-
- `Worktree cleanup:` 若存在独立 change worktree,输出清理结果(removed/skipped + reason)
|
|
55
|
-
- `Evidence:` `.agentdocs/tmp/aiws-validate/*.json`(若使用 --stamp)
|
|
9
|
+
```bash
|
|
10
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
11
|
+
./node_modules/.bin/aiws deliver -m "<message>"
|
|
12
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
13
|
+
aiws deliver -m "<message>"
|
|
14
|
+
else
|
|
15
|
+
npx @aipper/aiws deliver -m "<message>"
|
|
16
|
+
fi
|
|
17
|
+
```
|
|
56
18
|
<!-- AIWS_MANAGED_END:opencode:ws-deliver -->
|
|
57
|
-
|
|
58
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -1,75 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 收尾:fast-forward 合并并把 submodule 并回目标分支后顺序 push
|
|
2
|
+
description: 收尾:fast-forward 合并并把 submodule 并回目标分支后顺序 push。完成后标记 finish 阶段为 DONE
|
|
3
3
|
---
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-finish -->
|
|
5
5
|
# ws finish
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws finish`.
|
|
8
8
|
|
|
9
|
-
目标:安全把 `change/<change-id>` fast-forward 合并回目标分支,避免手输分支名导致的错误。
|
|
10
|
-
补充:若团队希望减少 submodule detached 的人为差异,建议在 `.gitmodules` 配置 `submodule.<name>.branch`,并在日常拉取时使用 `/ws-pull`。
|
|
11
|
-
|
|
12
|
-
前置(必须):
|
|
13
|
-
- 工作区干净:`git status --porcelain` 无输出(否则先 commit 或 stash)
|
|
14
|
-
- change 分支存在(`change/<change-id>`;也支持 `changes/`、`ws/`、`ws-change/`)
|
|
15
|
-
- 普通 finish 的 `validate/evidence/state` 应先在 `change/<change-id>` worktree 完成;真正执行 `aiws change finish` 时再切到目标分支所在 worktree
|
|
16
|
-
- 若 `aiws change status <change-id>` 输出 `governance_rule: finish_resume_required`:说明 merge 已发生,只需继续 push / archive / cleanup closeout;直接在提示的 worktree 运行 `aiws change finish <change-id> --push`
|
|
17
|
-
- 若存在 `.gitmodules`:必须为每个 submodule 配置 `submodule.<name>.branch`(否则先运行 `/ws-submodule-setup` 并提交 `.gitmodules`)
|
|
18
|
-
|
|
19
|
-
步骤(建议):
|
|
20
|
-
0) 若存在 `.gitmodules`,先检查 submodule branch 配置是否齐全(缺失则停止并提示 setup):
|
|
21
9
|
```bash
|
|
22
|
-
if [[ -
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
echo "error: missing .gitmodules submodule.${name}.branch (path=${sub_path})"
|
|
29
|
-
missing=1
|
|
30
|
-
fi
|
|
31
|
-
done < <(git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null || true)
|
|
32
|
-
if [[ "$missing" -ne 0 ]]; then
|
|
33
|
-
echo "hint: run /ws-submodule-setup (and commit .gitmodules), then retry"
|
|
34
|
-
exit 2
|
|
35
|
-
fi
|
|
10
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
11
|
+
./node_modules/.bin/aiws finish
|
|
12
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
13
|
+
aiws finish
|
|
14
|
+
else
|
|
15
|
+
npx @aipper/aiws finish
|
|
36
16
|
fi
|
|
37
17
|
```
|
|
38
|
-
1) 先运行 `/ws-preflight`(确保真值文件齐全)。
|
|
39
|
-
2) 先运行 `aiws change status <change-id>`,优先看稳定字段 `governance_rule:`。
|
|
40
|
-
- 若为 `finish_resume_required`:直接跳到步骤 3 执行 `aiws change finish <change-id> --push`
|
|
41
|
-
- 若不是该值:按普通 finish 继续;不要依赖自然语言提示句做分支判断
|
|
42
|
-
2.1) 普通 finish 时,`aiws validate . --stamp` / `aiws change evidence <change-id>` / `aiws change state <change-id> --write` 应在 `change/<change-id>` worktree 完成。
|
|
43
|
-
- 如果已经在目标分支 worktree,且 `governance_rule` 不是 `finish_resume_required`,不要在这里跑 `aiws validate . --stamp`;先回 `change/<change-id>` worktree,或先跑 `/ws-verify-before-complete`
|
|
44
|
-
3) 若不存在 `.gitmodules`,或 submodules 已按顺序处理完成,优先直接执行最小收尾闭环:
|
|
45
|
-
- `aiws change finish <change-id> --push`
|
|
46
|
-
- 若当前就在 `change/<change-id>` 分支上,也可省略 `<change-id>`
|
|
47
|
-
- 该命令会在 fast-forward 合并成功后 push 目标分支;默认优先使用 upstream 配置(`branch.<name>.remote` + `branch.<name>.merge`),只有在你明确知道要推向别的 remote 时才追加 `--remote <name>`
|
|
48
|
-
- 若 `change/<change-id>` 位于独立 worktree,且该 worktree 干净,则会在 push 成功后自动执行 `git worktree remove` + `git worktree prune`
|
|
49
|
-
- AI 入口执行前,应先向用户说明将要 push 的 remote/branch;显式传入 `--push` 即视为确认
|
|
50
|
-
4) 若提示无法 fast-forward:先在 change 分支(或对应 worktree)里 `git rebase <target-branch>`,再重试 `aiws change finish --push`。
|
|
51
|
-
5) 若需要先处理 submodules,则按顺序处理每个 submodule(减少 detached;再 push):
|
|
52
|
-
- 先显式解析 base branch,不要用当前分支名替代:
|
|
53
|
-
- `python3 - <<'PY'`
|
|
54
|
-
- `import json, pathlib; meta = pathlib.Path("changes") / "<change-id>" / ".ws-change.json"; print((json.loads(meta.read_text(encoding="utf-8")).get("base_branch") or "").strip())`
|
|
55
|
-
- `PY`
|
|
56
|
-
- 发现 submodules:`git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$'`
|
|
57
|
-
- 对每个 `<sub_path>`:
|
|
58
|
-
- 读取 superproject 当前 gitlink:`git rev-parse "HEAD:<sub_path>"`
|
|
59
|
-
- 目标分支真值:`changes/<change-id>/submodules.targets`;若条目里分支写 `.`,则展开为刚才解析出的 `base_branch`
|
|
60
|
-
- 生成/检查 `submodules.targets` 时,detached HEAD 默认建议取 `.gitmodules` 的 `submodule.<name>.branch`;已附着在本地分支时默认建议取当前分支;这些都只是预填建议,不是 finish/push 的运行时真值
|
|
61
|
-
- 不要直接切 `change/<change-id>` / `main` / `master` 来解 detached
|
|
62
|
-
- 用 pin 分支挂回(不改动现有 main/master 指针):`git -C "<sub_path>" checkout -B "aiws/pin/<target-branch>" <gitlink-sha>`
|
|
63
|
-
- 仅当 `<gitlink-sha>` 属于 `origin/<target-branch>` 历史时才允许 push;否则停止并人工处理分叉
|
|
64
|
-
- push(只允许 fast-forward):`git -C "<sub_path>" push origin "<gitlink-sha>:refs/heads/<target-branch>"`
|
|
65
|
-
6) 任一 submodule 不满足 fast-forward 条件时立即停止(不要继续 push 主仓库)。
|
|
66
|
-
7) submodules 全部成功后,再回到主仓库执行:
|
|
67
|
-
- `aiws change finish <change-id> --push`
|
|
68
|
-
8) `aiws change finish --push` 成功后会自动归档并生成 handoff;只有历史/异常场景才需要手工运行 `aiws change archive <change-id>`。
|
|
69
|
-
|
|
70
|
-
安全:
|
|
71
|
-
- push 前先输出状态并说明远端/分支。
|
|
72
|
-
- 不执行破坏性命令。
|
|
73
18
|
<!-- AIWS_MANAGED_END:opencode:ws-finish -->
|
|
74
|
-
|
|
75
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 交接:查看归档 change 的 handoff.md
|
|
2
|
+
description: 交接:查看归档 change 的 handoff.md
|
|
3
3
|
---
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-handoff -->
|
|
5
5
|
# ws handoff
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws handoff`.
|
|
8
8
|
|
|
9
|
-
目标:
|
|
10
|
-
- 交接与回放:通过 `handoff.md` 让已归档的 change 可被下一位/下一次会话快速接力。
|
|
11
|
-
- handoff 文件位置:`changes/archive/<date>-<change-id>/handoff.md`(默认由 `aiws change finish --push` 自动归档时生成)。
|
|
12
|
-
|
|
13
|
-
执行建议:
|
|
14
|
-
1) 先确认 change 已通过 `/ws-finish` 或 `aiws change finish --push` 完成自动归档。
|
|
15
|
-
2) 查看 handoff:
|
|
16
9
|
```bash
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
11
|
+
./node_modules/.bin/aiws handoff
|
|
12
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
13
|
+
aiws handoff
|
|
14
|
+
else
|
|
15
|
+
npx @aipper/aiws handoff
|
|
16
|
+
fi
|
|
20
17
|
```
|
|
21
|
-
3) 依赖提示:
|
|
22
|
-
- 若你在某个 change 的 `proposal.md` 声明了 `Depends_On`,`aiws change start` 会尝试读取依赖 change 的 `handoff.md` 并输出摘要(前提:依赖已归档且 handoff 存在)。
|
|
23
|
-
- 若是历史/异常场景尚未归档,再手工运行 `/p-aiws-change-archive`。
|
|
24
18
|
<!-- AIWS_MANAGED_END:opencode:ws-handoff -->
|
|
25
|
-
|
|
26
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -4,22 +4,15 @@ description: 迁移:把仓库对齐到 aiws workspace 模板
|
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-migrate -->
|
|
5
5
|
# ws migrate
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws migrate`.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- 恢复最近一次快照:`npx @aipper/aiws rollback . latest`
|
|
19
|
-
|
|
20
|
-
约束:
|
|
21
|
-
- 不写入任何 secrets。
|
|
22
|
-
- 不执行破坏性命令。
|
|
9
|
+
```bash
|
|
10
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
11
|
+
./node_modules/.bin/aiws migrate
|
|
12
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
13
|
+
aiws migrate
|
|
14
|
+
else
|
|
15
|
+
npx @aipper/aiws migrate
|
|
16
|
+
fi
|
|
17
|
+
```
|
|
23
18
|
<!-- AIWS_MANAGED_END:opencode:ws-migrate -->
|
|
24
|
-
|
|
25
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: 计划质检:执行前检查并给出最小修正项。通过后标记 plan 阶段为 DONE
|
|
3
3
|
---
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-plan-verify -->
|
|
5
5
|
# ws plan verify
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws plan-verify`.
|
|
8
8
|
|
|
9
|
-
目标:
|
|
10
|
-
- 执行前检查计划是否跑偏,并给出最小修正项。
|
|
11
|
-
|
|
12
|
-
执行建议:
|
|
13
|
-
1) 先运行 `/ws-preflight`。
|
|
14
|
-
2) 运行严格门禁:
|
|
15
9
|
```bash
|
|
16
10
|
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
17
|
-
./node_modules/.bin/aiws
|
|
11
|
+
./node_modules/.bin/aiws plan-verify
|
|
18
12
|
elif command -v aiws >/dev/null 2>&1; then
|
|
19
|
-
aiws
|
|
13
|
+
aiws plan-verify
|
|
20
14
|
else
|
|
21
|
-
npx @aipper/aiws
|
|
15
|
+
npx @aipper/aiws plan-verify
|
|
22
16
|
fi
|
|
23
17
|
```
|
|
24
|
-
3) 若失败:先修 `proposal.md` / `plan` 的绑定字段与验证命令,再复跑。
|
|
25
|
-
4) 通过后再进入 `/ws-dev`。
|
|
26
18
|
<!-- AIWS_MANAGED_END:opencode:ws-plan-verify -->
|
|
27
|
-
|
|
28
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -4,84 +4,15 @@ description: 拉取:fast-forward 拉取并对齐 submodules(尽量避免 det
|
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-pull -->
|
|
5
5
|
# ws pull
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Thin CLI wrapper. Delegates to `aiws pull`.
|
|
8
8
|
|
|
9
|
-
目标:安全拉取 superproject,并对齐 submodules,尽量把 submodule 从 detached HEAD “挂回”分支(仅当该分支包含 gitlink commit),减少人为操作差异。
|
|
10
|
-
|
|
11
|
-
安全约束(强制):
|
|
12
|
-
- 不执行破坏性命令;不自动提交/不自动 push
|
|
13
|
-
- 若工作区不干净:停止并要求用户先 commit 或 stash
|
|
14
|
-
- `git pull` 默认只允许 fast-forward(避免隐式 merge/rebase)
|
|
15
|
-
|
|
16
|
-
步骤(建议):
|
|
17
|
-
1) 输出上下文并检查工作区干净:
|
|
18
|
-
```bash
|
|
19
|
-
git rev-parse --show-toplevel
|
|
20
|
-
git branch --show-current
|
|
21
|
-
git status --porcelain
|
|
22
|
-
```
|
|
23
|
-
若 `git status --porcelain` 非空:停止。
|
|
24
|
-
|
|
25
|
-
2) 拉取 superproject(fast-forward only):
|
|
26
9
|
```bash
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
3) 更新 submodules 到 superproject 记录的 gitlink commit:
|
|
32
|
-
```bash
|
|
33
|
-
if [[ -f .gitmodules ]]; then
|
|
34
|
-
git submodule sync --recursive
|
|
35
|
-
git submodule update --init --recursive
|
|
10
|
+
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
11
|
+
./node_modules/.bin/aiws pull
|
|
12
|
+
elif command -v aiws >/dev/null 2>&1; then
|
|
13
|
+
aiws pull
|
|
36
14
|
else
|
|
37
|
-
|
|
38
|
-
fi
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
4) (可选但推荐)把 submodule 从 detached HEAD 尽量“挂回分支”(不改动 gitlink commit):
|
|
42
|
-
为避免 origin 多分支时“猜错分支”,本步骤只在 `.gitmodules` 明确配置了 `submodule.<name>.branch` 时才执行;否则保持 detached 并提示先运行 `/ws-submodule-setup` 对齐配置。
|
|
43
|
-
```bash
|
|
44
|
-
if [[ -f .gitmodules ]]; then
|
|
45
|
-
base_branch="$(git branch --show-current)"
|
|
46
|
-
git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$' 2>/dev/null \
|
|
47
|
-
| while read -r key sub_path; do
|
|
48
|
-
[[ -z "${sub_path:-}" ]] && continue
|
|
49
|
-
name="${key#submodule.}"; name="${name%.path}"
|
|
50
|
-
echo "== submodule: ${sub_path} (${name}) =="
|
|
51
|
-
sub_sha="$(git rev-parse "HEAD:${sub_path}" 2>/dev/null || true)"
|
|
52
|
-
[[ -z "${sub_sha:-}" ]] && { echo "[warn] no gitlink sha"; continue; }
|
|
53
|
-
|
|
54
|
-
cfg_branch="$(git config --file .gitmodules --get "submodule.${name}.branch" 2>/dev/null || true)"
|
|
55
|
-
if [[ "${cfg_branch:-}" == "." ]]; then cfg_branch="$base_branch"; fi
|
|
56
|
-
if [[ -z "${cfg_branch:-}" ]]; then
|
|
57
|
-
echo "[warn] ${sub_path}: missing .gitmodules submodule.${name}.branch; keep detached (run ws-submodule-setup)"
|
|
58
|
-
continue
|
|
59
|
-
fi
|
|
60
|
-
target_branch="${cfg_branch}"
|
|
61
|
-
pin_branch="aiws/pin/${target_branch}"
|
|
62
|
-
|
|
63
|
-
git -C "${sub_path}" fetch origin --prune || true
|
|
64
|
-
if git -C "${sub_path}" show-ref --verify --quiet "refs/remotes/origin/${target_branch}"; then
|
|
65
|
-
if git -C "${sub_path}" merge-base --is-ancestor "${sub_sha}" "origin/${target_branch}"; then
|
|
66
|
-
git -C "${sub_path}" checkout -B "${pin_branch}" "${sub_sha}"
|
|
67
|
-
git -C "${sub_path}" branch --set-upstream-to "origin/${target_branch}" "${pin_branch}" >/dev/null 2>&1 || true
|
|
68
|
-
echo "[ok] attached ${sub_path} to ${pin_branch} (upstream=origin/${target_branch}) at ${sub_sha}"
|
|
69
|
-
else
|
|
70
|
-
echo "[warn] ${sub_path}: ${sub_sha} is not in origin/${target_branch}; keep detached"
|
|
71
|
-
fi
|
|
72
|
-
else
|
|
73
|
-
echo "[warn] ${sub_path}: origin/${target_branch} not found; keep detached"
|
|
74
|
-
fi
|
|
75
|
-
done
|
|
15
|
+
npx @aipper/aiws pull
|
|
76
16
|
fi
|
|
77
17
|
```
|
|
78
|
-
|
|
79
|
-
可选(方案 2,一次性设置 submodule 跟踪分支,会改 `.gitmodules`,需提交):
|
|
80
|
-
```bash
|
|
81
|
-
git submodule set-branch --branch main <sub_path>
|
|
82
|
-
git add .gitmodules
|
|
83
|
-
git commit -m "chore(submodule): set tracking branch"
|
|
84
|
-
```
|
|
85
18
|
<!-- AIWS_MANAGED_END:opencode:ws-pull -->
|
|
86
|
-
|
|
87
|
-
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|