@aipper/aiws-spec 0.0.7 → 0.0.9
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/package.json +1 -1
- package/templates/workspace/.agents/skills/ws-finish/SKILL.md +53 -3
- package/templates/workspace/.claude/commands/ws-finish.md +15 -2
- package/templates/workspace/.iflow/commands/ws-finish.toml +18 -5
- package/templates/workspace/.opencode/command/aiws-init.md +3 -1
- package/templates/workspace/.opencode/command/aiws-rollback.md +3 -1
- package/templates/workspace/.opencode/command/aiws-update.md +3 -1
- package/templates/workspace/.opencode/command/aiws-validate.md +3 -1
- package/templates/workspace/.opencode/command/ws-analyze.md +3 -0
- package/templates/workspace/.opencode/command/ws-deliver.md +3 -1
- package/templates/workspace/.opencode/command/ws-dev.md +3 -0
- package/templates/workspace/.opencode/command/ws-finish.md +18 -2
- package/templates/workspace/.opencode/command/ws-migrate.md +3 -0
- package/templates/workspace/.opencode/command/ws-preflight.md +3 -0
- package/templates/workspace/.opencode/command/ws-req-change.md +3 -0
- package/templates/workspace/.opencode/command/ws-req-contract-sync.md +3 -0
- package/templates/workspace/.opencode/command/ws-req-contract-validate.md +3 -0
- package/templates/workspace/.opencode/command/ws-req-flow-sync.md +3 -0
- package/templates/workspace/.opencode/command/ws-req-review.md +3 -0
- package/templates/workspace/.opencode/command/ws-review.md +3 -0
- package/templates/workspace/.opencode/command/ws-rule.md +3 -0
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ws-finish
|
|
3
|
-
description: 收尾(门禁 + 安全合并
|
|
3
|
+
description: 收尾(门禁 + 安全合并 + submodule→主仓库顺序 push)
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
7
7
|
|
|
8
8
|
目标:
|
|
9
9
|
- 在结束一次变更交付时,用 fast-forward 安全合并 `change/<change-id>` 回目标分支,减少手输分支名导致的错误
|
|
10
|
-
-
|
|
10
|
+
- 合并成功后,按 `submodule -> superproject` 顺序 push,避免遗漏导致其它仓库拉取异常
|
|
11
|
+
- 不自动删分支;push 前必须让用户确认
|
|
11
12
|
|
|
12
13
|
前置(必须):
|
|
13
14
|
- 工作区是干净的:`git status --porcelain` 无输出(若有未提交改动:先 commit 或 stash)
|
|
@@ -38,7 +39,56 @@ else
|
|
|
38
39
|
fi
|
|
39
40
|
```
|
|
40
41
|
3) 若 fast-forward 失败(提示需要 rebase):先在 change 分支(或对应 worktree)里 `git rebase <target-branch>`,再重试 `aiws change finish`。
|
|
41
|
-
4)
|
|
42
|
+
4) 合并成功后,先把每个 submodule 的 gitlink commit 合并回其目标分支(解决 detached HEAD),并按顺序 push:
|
|
43
|
+
```bash
|
|
44
|
+
# superproject 当前分支(finish 后通常是 base 分支)
|
|
45
|
+
base_branch="$(git branch --show-current)"
|
|
46
|
+
|
|
47
|
+
# 子模块清单(没有则跳过)
|
|
48
|
+
git config --file .gitmodules --get-regexp '^submodule\..*\.path$' 2>/dev/null || true
|
|
49
|
+
|
|
50
|
+
# 对每个 submodule.<name>.path <sub_path>:
|
|
51
|
+
# 1) 计算 superproject 当前 HEAD 记录的 gitlink commit
|
|
52
|
+
sub_sha="$(git rev-parse "HEAD:<sub_path>")"
|
|
53
|
+
# 2) 推断目标分支(优先:.gitmodules 的 submodule.<name>.branch;否则 origin/HEAD;否则 main/master)
|
|
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
|
+
origin_head="$(git -C "<sub_path>" symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##' || true)"
|
|
57
|
+
target_branch="${cfg_branch:-${origin_head:-}}"
|
|
58
|
+
if [[ -z "${target_branch:-}" ]]; then
|
|
59
|
+
if git -C "<sub_path>" show-ref --verify --quiet refs/heads/main || git -C "<sub_path>" show-ref --verify --quiet refs/remotes/origin/main; then
|
|
60
|
+
target_branch="main"
|
|
61
|
+
else
|
|
62
|
+
target_branch="master"
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# 3) 切到目标分支(若本地无分支则从 origin 跟踪创建)
|
|
67
|
+
git -C "<sub_path>" fetch origin
|
|
68
|
+
git -C "<sub_path>" switch "$target_branch" || git -C "<sub_path>" switch -c "$target_branch" --track "origin/$target_branch"
|
|
69
|
+
|
|
70
|
+
# 4) fast-forward 到 gitlink commit(非 ff 直接停止,避免错误合并)
|
|
71
|
+
git -C "<sub_path>" status -sb
|
|
72
|
+
if git -C "<sub_path>" merge-base --is-ancestor "$sub_sha" HEAD; then
|
|
73
|
+
echo "[skip] <sub_path> already contains $sub_sha"
|
|
74
|
+
else
|
|
75
|
+
git -C "<sub_path>" merge --ff-only "$sub_sha"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# 5) push(若无 upstream 则首次 -u)
|
|
79
|
+
git -C "<sub_path>" push || git -C "<sub_path>" push -u origin "$target_branch"
|
|
80
|
+
```
|
|
81
|
+
规则:
|
|
82
|
+
- 每个 submodule 必须先执行“切目标分支 + `merge --ff-only <gitlink-sha>`”,再 push;禁止在 detached HEAD 直接 push。
|
|
83
|
+
- 若任一 submodule 不能 fast-forward(`merge --ff-only` 失败),立即停止,先人工处理冲突/分叉,再继续。
|
|
84
|
+
|
|
85
|
+
5) 仅当 submodules 全部成功后,再 push superproject 当前分支:
|
|
86
|
+
```bash
|
|
87
|
+
git branch --show-current
|
|
88
|
+
git status -sb
|
|
89
|
+
git push
|
|
90
|
+
```
|
|
91
|
+
6) (可选)归档变更工件(完成交付后推荐):
|
|
42
92
|
```bash
|
|
43
93
|
change_id="<change-id>"
|
|
44
94
|
if [[ -x "./node_modules/.bin/aiws" ]]; then
|
|
@@ -16,10 +16,23 @@
|
|
|
16
16
|
- 若当前就在 `change/<change-id>` 分支上,可直接执行:`aiws change finish`
|
|
17
17
|
- 否则执行:`aiws change finish <change-id>`
|
|
18
18
|
4) 若提示无法 fast-forward:先在 change 分支(或对应 worktree)里 `git rebase <target-branch>`,再重试 `aiws change finish`。
|
|
19
|
-
5)
|
|
19
|
+
5) 合并成功后,按顺序处理每个 submodule(先“并回目标分支”,再 push):
|
|
20
|
+
- 发现 submodules:`git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$'`
|
|
21
|
+
- 对每个 `<sub_path>`:
|
|
22
|
+
- 读取 superproject 当前 gitlink:`git rev-parse "HEAD:<sub_path>"`
|
|
23
|
+
- 推断目标分支:优先 `.gitmodules` 的 `submodule.<name>.branch`(若为 `.` 则用当前主仓库分支),否则 `origin/HEAD`,再 fallback `main/master`
|
|
24
|
+
- 切到目标分支(必要时创建跟踪分支):`git -C "<sub_path>" switch <target-branch> || git -C "<sub_path>" switch -c <target-branch> --track origin/<target-branch>`
|
|
25
|
+
- 合并 gitlink commit:`git -C "<sub_path>" merge --ff-only <gitlink-sha>`
|
|
26
|
+
- push:`git -C "<sub_path>" push`(无 upstream 则 `git -C "<sub_path>" push -u origin <target-branch>`)
|
|
27
|
+
6) 任一 submodule `merge --ff-only` 失败时立即停止(不要继续 push 主仓库)。
|
|
28
|
+
7) submodules 全部成功后,再 push 主仓库当前分支:
|
|
29
|
+
- `git branch --show-current`
|
|
30
|
+
- `git status -sb`
|
|
31
|
+
- `git push`
|
|
32
|
+
8) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
|
|
20
33
|
|
|
21
34
|
安全:
|
|
22
|
-
-
|
|
35
|
+
- push 前先输出状态并请用户确认远端/分支。
|
|
23
36
|
- 不执行破坏性命令。
|
|
24
37
|
<!-- AIWS_MANAGED_END:claude:ws-finish -->
|
|
25
38
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Command: ws:finish
|
|
2
|
-
# Description: AI Workspace 安全收尾(门禁 + fast-forward 合并
|
|
2
|
+
# Description: AI Workspace 安全收尾(门禁 + fast-forward 合并 + submodule 并回分支后顺序 push)
|
|
3
3
|
# Category: workspace
|
|
4
4
|
# Version: 1
|
|
5
5
|
|
|
6
|
-
description = "AI Workspace 安全收尾(门禁 + fast-forward 合并
|
|
6
|
+
description = "AI Workspace 安全收尾(门禁 + fast-forward 合并 + submodule 并回分支后顺序 push)"
|
|
7
7
|
|
|
8
8
|
prompt = """
|
|
9
9
|
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
10
10
|
|
|
11
|
-
目标:安全把 `change/<change-id>` fast-forward
|
|
11
|
+
目标:安全把 `change/<change-id>` fast-forward 合并回目标分支,并按 `submodule -> superproject` 顺序 push,减少遗漏。
|
|
12
12
|
|
|
13
13
|
强制步骤:
|
|
14
14
|
1) 读取真值文件:`AI_PROJECT.md`、`REQUIREMENTS.md`、`AI_WORKSPACE.md`(缺失则先运行 `/aiws-init` 或 `aiws init .`)。
|
|
@@ -22,9 +22,22 @@ prompt = """
|
|
|
22
22
|
- 在 `change/<change-id>` 分支上:`aiws change finish`(会尝试读 `changes/<change-id>/.ws-change.json` 的 `base_branch` 并切回目标分支)
|
|
23
23
|
- 否则:`aiws change finish <change-id>`
|
|
24
24
|
7) 若提示无法 fast-forward:先在 change 分支(或对应 worktree)里执行 `git rebase <target-branch>`,再重试 `aiws change finish`。
|
|
25
|
-
8)
|
|
25
|
+
8) 合并成功后,按顺序处理每个 submodule(先“并回目标分支”,再 push):
|
|
26
|
+
- 发现 submodules:`git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$'`
|
|
27
|
+
- 对每个 `<sub_path>`:
|
|
28
|
+
- 读取 superproject 当前 gitlink:`git rev-parse "HEAD:<sub_path>"`
|
|
29
|
+
- 推断目标分支:优先 `.gitmodules` 的 `submodule.<name>.branch`(若为 `.` 则用当前主仓库分支),否则 `origin/HEAD`,再 fallback `main/master`
|
|
30
|
+
- 切到目标分支(必要时创建跟踪分支):`git -C "<sub_path>" switch <target-branch> || git -C "<sub_path>" switch -c <target-branch> --track origin/<target-branch>`
|
|
31
|
+
- 合并 gitlink commit:`git -C "<sub_path>" merge --ff-only <gitlink-sha>`
|
|
32
|
+
- push:`git -C "<sub_path>" push`(无 upstream 则 `git -C "<sub_path>" push -u origin <target-branch>`)
|
|
33
|
+
9) 任一 submodule `merge --ff-only` 失败时立即停止(不要继续 push 主仓库)。
|
|
34
|
+
10) submodules push 完成后,再 push 主仓库当前分支:
|
|
35
|
+
- `git branch --show-current`
|
|
36
|
+
- `git status -sb`
|
|
37
|
+
- `git push`
|
|
38
|
+
11) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
|
|
26
39
|
|
|
27
40
|
边界:
|
|
28
|
-
-
|
|
41
|
+
- push 前先输出状态并请用户确认远端/分支。
|
|
29
42
|
- 不执行破坏性命令。
|
|
30
43
|
"""
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 收尾:fast-forward 合并并把 submodule 并回目标分支后顺序 push
|
|
3
|
+
---
|
|
1
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-finish -->
|
|
2
5
|
# ws finish
|
|
3
6
|
|
|
@@ -16,10 +19,23 @@
|
|
|
16
19
|
- 若当前就在 `change/<change-id>` 分支上,可直接执行:`aiws change finish`
|
|
17
20
|
- 否则执行:`aiws change finish <change-id>`
|
|
18
21
|
4) 若提示无法 fast-forward:先在 change 分支(或对应 worktree)里 `git rebase <target-branch>`,再重试 `aiws change finish`。
|
|
19
|
-
5)
|
|
22
|
+
5) 合并成功后,按顺序处理每个 submodule(先“并回目标分支”,再 push):
|
|
23
|
+
- 发现 submodules:`git config --file .gitmodules --get-regexp '^submodule\\..*\\.path$'`
|
|
24
|
+
- 对每个 `<sub_path>`:
|
|
25
|
+
- 读取 superproject 当前 gitlink:`git rev-parse "HEAD:<sub_path>"`
|
|
26
|
+
- 推断目标分支:优先 `.gitmodules` 的 `submodule.<name>.branch`(若为 `.` 则用当前主仓库分支),否则 `origin/HEAD`,再 fallback `main/master`
|
|
27
|
+
- 切到目标分支(必要时创建跟踪分支):`git -C "<sub_path>" switch <target-branch> || git -C "<sub_path>" switch -c <target-branch> --track origin/<target-branch>`
|
|
28
|
+
- 合并 gitlink commit:`git -C "<sub_path>" merge --ff-only <gitlink-sha>`
|
|
29
|
+
- push:`git -C "<sub_path>" push`(无 upstream 则 `git -C "<sub_path>" push -u origin <target-branch>`)
|
|
30
|
+
6) 任一 submodule `merge --ff-only` 失败时立即停止(不要继续 push 主仓库)。
|
|
31
|
+
7) submodules 全部成功后,再 push 主仓库当前分支:
|
|
32
|
+
- `git branch --show-current`
|
|
33
|
+
- `git status -sb`
|
|
34
|
+
- `git push`
|
|
35
|
+
8) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
|
|
20
36
|
|
|
21
37
|
安全:
|
|
22
|
-
-
|
|
38
|
+
- push 前先输出状态并请用户确认远端/分支。
|
|
23
39
|
- 不执行破坏性命令。
|
|
24
40
|
<!-- AIWS_MANAGED_END:opencode:ws-finish -->
|
|
25
41
|
|