@aipper/aiws-spec 0.0.3 → 0.0.5

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.
@@ -231,6 +231,7 @@
231
231
  - 若 `changes/<change-id>/` 不存在:等价执行 `aiws change new ...`。
232
232
  - 可选:`--hooks` 等价于 `aiws hooks install .`。
233
233
  - 可选:`--switch` 显式允许切换 superproject 分支(仅在存在 `.gitmodules` 时有意义;否则等价于默认行为)。
234
+ - 实现细节:当存在 `.gitmodules` 且使用 `--switch` 时,CLI 会尝试使用 `git switch/checkout --recurse-submodules` 让 submodules 工作区跟随 superproject 指针;若 git 不支持该选项,会降级为普通切分支并提示手工更新 submodules。
234
235
  - 可选:`--no-switch` 不切换当前分支(仅确保目标分支存在,并初始化变更工件);适用于 superproject + submodule 场景,避免意外切换 A 目录分支导致 submodule 状态混乱。
235
236
  - 可选:`--worktree` 使用 `git worktree` 创建一个独立工作区并在其中 checkout `change/<change-id>`,当前目录分支保持不变(推荐用于 superproject + submodule)。
236
237
  - 默认 worktree 目录:`../<repo-name>-<change-id>`(相对于 git root)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipper/aiws-spec",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "AIWS spec and templates (single source of truth).",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: ws-deliver
3
+ description: 交付(submodules + superproject 分步提交,并安全合并回目标分支)
4
+ ---
5
+
6
+ 用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
+
8
+ 目标:
9
+ - 适配 superproject + submodule(数量不固定)的交付收尾:
10
+ 1) 先逐个提交 submodule(每个 repo 单独确认 commit message)
11
+ 2) 再提交 superproject(包含 submodule gitlink 指针更新 + 变更工件/代码)
12
+ 3) 最后 fast-forward 合并回目标分支(复用 `aiws change finish`,减少手动 merge 出错)
13
+
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
+
30
+ ## A) 发现 submodules 清单(数量不固定)
31
+ 在 superproject 根目录执行:
32
+ ```bash
33
+ git submodule status --recursive
34
+ ```
35
+ 如果没有 submodule:跳到 C)。
36
+
37
+ ## B) 逐个提交 submodules(先 submodule,后 superproject)
38
+ 对每个 submodule path(可递归)重复以下步骤(建议按 `git submodule status --recursive` 顺序):
39
+ 1) 定位并检查状态:
40
+ ```bash
41
+ sub_path="<path>"
42
+ git -C "$sub_path" branch --show-current
43
+ git -C "$sub_path" status --porcelain
44
+ ```
45
+ 2) 若 submodule 处于 detached HEAD(`branch --show-current` 为空):
46
+ - 默认建议:在该 submodule 内创建并切到同名 change 分支(与 superproject 对齐),例如 `change/<change-id>`:
47
+ ```bash
48
+ git -C "$sub_path" switch -c "change/<change-id>"
49
+ ```
50
+ - 若用户明确不想建分支:停止,解释风险(提交可能不可追溯/难以推送)。
51
+ 3) 选择性 staging(默认用 `-p` 更安全):
52
+ ```bash
53
+ git -C "$sub_path" add -p
54
+ git -C "$sub_path" diff --staged --stat
55
+ git -C "$sub_path" diff --staged
56
+ ```
57
+ 4) AI 生成该 submodule 的 commit message(标题+可选 body),并让用户确认(每个 repo 单独确认)。
58
+ 5) 执行提交(不带 `--no-verify`):
59
+ ```bash
60
+ git -C "$sub_path" commit -m "<message>"
61
+ ```
62
+ 6) 若该 submodule 没有 staged changes:跳过(不要硬提交空 commit)。
63
+
64
+ ## C) 提交 superproject(更新 gitlinks + 自身改动 + changes 工件)
65
+ 1) 先检查 submodule 指针差异(gitlinks):
66
+ ```bash
67
+ git diff --submodule
68
+ ```
69
+ 2) 选择性 staging:
70
+ - 先 stage 发生指针变化的 submodule 路径(明确列出):
71
+ ```bash
72
+ git add <submodule-path-1> <submodule-path-2>
73
+ ```
74
+ - 再 stage superproject 自身改动(默认 `-p`):
75
+ ```bash
76
+ git add -p
77
+ git diff --staged --stat
78
+ git diff --staged
79
+ ```
80
+ 3) AI 生成 superproject 的 commit message(应包含 “bump submodule <name> -> <sha>” 等关键信息),并让用户确认。
81
+ 4) 提交:
82
+ ```bash
83
+ git commit -m "<message>"
84
+ ```
85
+
86
+ ## D) 门禁与证据(推荐)
87
+ ```bash
88
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
89
+ ./node_modules/.bin/aiws validate . --stamp
90
+ elif command -v aiws >/dev/null 2>&1; then
91
+ aiws validate . --stamp
92
+ else
93
+ npx @aipper/aiws validate . --stamp
94
+ fi
95
+ ```
96
+
97
+ ## E) 安全合并回目标分支(fast-forward)
98
+ 优先使用 `$ws-finish`(底层调用 `aiws change finish`)。
99
+
100
+ 若需要显式指定目标分支:
101
+ ```bash
102
+ aiws change finish <change-id> --into <base-branch>
103
+ ```
104
+
105
+ ## F) (可选)归档变更工件
106
+ ```bash
107
+ aiws change archive <change-id>
108
+ ```
109
+
110
+ 输出要求:
111
+ - `Submodules:` 每个 submodule 的分支/提交摘要(repo → commit sha → message)
112
+ - `Superproject:` 提交摘要
113
+ - `Merge:` `aiws change finish` 的输出(into/from)
114
+ - `Evidence:` `.agentdocs/tmp/aiws-validate/*.json`(若使用 --stamp)
@@ -13,6 +13,7 @@ description: 开发(按需求实现并验证;适用于任何需要修改代
13
13
  2) 建立变更归因(推荐):
14
14
  - 推荐一键:`aiws change start <change-id> --hooks`(切分支 + 初始化变更工件 + 启用 hooks)
15
15
  - superproject + submodule(推荐):`aiws change start <change-id> --hooks --worktree --submodules`(创建独立 worktree;当前目录分支保持不变)
16
+ - 若你明确要在 superproject 直接切分支:`aiws change start <change-id> --hooks --switch`(仅在存在 `.gitmodules` 时有意义;会尝试让 submodules 工作区跟随 superproject 指针)
16
17
  - 或手工:`git switch -c change/<change-id>`,并创建 `changes/<change-id>/proposal.md` 与 `changes/<change-id>/tasks.md`(参考 `changes/README.md`)
17
18
  3) 如涉及需求调整:先做需求评审(可用 `$ws-req-review`)→ 用户确认后再做需求落盘(可用 `$ws-req-change`)(避免需求漂移)。
18
19
  4) 实施最小改动:任何改动都要能归因到 `REQUIREMENTS.md`(验收)或 `issues/problem-issues.csv`(问题)。
@@ -126,6 +126,7 @@
126
126
  ".agents/skills/ws-analyze/SKILL.md",
127
127
  ".agents/skills/ws-commit/SKILL.md",
128
128
  ".agents/skills/ws-dev/SKILL.md",
129
+ ".agents/skills/ws-deliver/SKILL.md",
129
130
  ".agents/skills/ws-finish/SKILL.md",
130
131
  ".agents/skills/ws-migrate/SKILL.md",
131
132
  ".agents/skills/ws-plan/SKILL.md",