@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipper/aiws-spec",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "AIWS spec and templates (single source of truth).",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,13 +1,14 @@
1
1
  ---
2
2
  name: ws-finish
3
- description: 收尾(门禁 + 安全合并 change/<change-id> 回目标分支)
3
+ description: 收尾(门禁 + 安全合并 + submodule→主仓库顺序 push)
4
4
  ---
5
5
 
6
6
  用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
7
 
8
8
  目标:
9
9
  - 在结束一次变更交付时,用 fast-forward 安全合并 `change/<change-id>` 回目标分支,减少手输分支名导致的错误
10
- - 不自动 push;不自动删分支;必要时先让用户确认
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) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
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
- - 不自动 push。
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 合并 change/<change-id> 回目标分支)
2
+ # Description: AI Workspace 安全收尾(门禁 + fast-forward 合并 + submodule 并回分支后顺序 push)
3
3
  # Category: workspace
4
4
  # Version: 1
5
5
 
6
- description = "AI Workspace 安全收尾(门禁 + fast-forward 合并 change/<change-id> 回目标分支)"
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) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
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
- - 不自动 push。
41
+ - push 前先输出状态并请用户确认远端/分支。
29
42
  - 不执行破坏性命令。
30
43
  """
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 初始化:落盘 AIWS 真值与门禁文件
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:aiws-init -->
2
5
  # aiws init
3
6
 
@@ -16,4 +19,3 @@
16
19
  <!-- AIWS_MANAGED_END:opencode:aiws-init -->
17
20
 
18
21
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
19
-
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 回滚:从 .aiws/backups 恢复快照
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:aiws-rollback -->
2
5
  # aiws rollback
3
6
 
@@ -9,4 +12,3 @@
9
12
  <!-- AIWS_MANAGED_END:opencode:aiws-rollback -->
10
13
 
11
14
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
12
-
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 更新:刷新模板与 tool-native 文件(先备份)
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:aiws-update -->
2
5
  # aiws update
3
6
 
@@ -15,4 +18,3 @@
15
18
  <!-- AIWS_MANAGED_END:opencode:aiws-update -->
16
19
 
17
20
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
18
-
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 门禁:校验 required/托管块/漂移(可落盘 stamp)
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:aiws-validate -->
2
5
  # aiws validate
3
6
 
@@ -10,4 +13,3 @@
10
13
  <!-- AIWS_MANAGED_END:opencode:aiws-validate -->
11
14
 
12
15
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
13
-
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 分析:实现前技术分析并落盘证据
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-analyze -->
2
5
  # ws analyze
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 交付:submodules+superproject 分步提交并安全合并回 base
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-deliver -->
2
5
  # ws deliver
3
6
 
@@ -42,4 +45,3 @@
42
45
  <!-- AIWS_MANAGED_END:opencode:ws-deliver -->
43
46
 
44
47
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
45
-
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 开发:在 AIWS 约束下完成小步交付
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-dev -->
2
5
  # ws dev
3
6
 
@@ -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) (可选)交付完成后归档变更工件:`aiws change archive <change-id>`。
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
- - 不自动 push。
38
+ - push 前先输出状态并请用户确认远端/分支。
23
39
  - 不执行破坏性命令。
24
40
  <!-- AIWS_MANAGED_END:opencode:ws-finish -->
25
41
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 迁移:把仓库对齐到 aiws workspace 模板
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-migrate -->
2
5
  # ws migrate
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 预检:读取真值文件并输出约束摘要
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-preflight -->
2
5
  # ws preflight
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 需求变更:更新 REQUIREMENTS 并同步执行合同
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-req-change -->
2
5
  # ws req change
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 合同同步:把 REQUIREMENTS FlowSpec 同步到 requirements-issues.csv
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-req-contract-sync -->
2
5
  # ws req contract sync
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 合同校验:校验 requirements-issues.csv 字段完整性
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-req-contract-validate -->
2
5
  # ws req contract validate
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: Flow 同步:从 REQUIREMENTS 生成 api-flow 与场景执行合同
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-req-flow-sync -->
2
5
  # ws req flow sync
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 需求评审:对 REQUIREMENTS 做整体 QA(不改文件)
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-req-review -->
2
5
  # ws req review
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: Review:提交前审计改动并落盘证据
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-review -->
2
5
  # ws review
3
6
 
@@ -1,3 +1,6 @@
1
+ ---
2
+ description: 规则:把口述规则整理并写入 AI_PROJECT.md 托管段
3
+ ---
1
4
  <!-- AIWS_MANAGED_BEGIN:opencode:ws-rule -->
2
5
  # ws rule
3
6