@aipper/aiws-spec 0.0.33 → 0.0.36
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/aiws-bootstrap-routing-design.md +5 -50
- package/docs/aiws-governance-positioning.md +1 -1
- package/docs/cli-interface.md +13 -73
- package/docs/collaboration-artifacts.md +2 -2
- package/docs/opencode-autonomous-swarm.md +0 -2
- package/docs/opencode-omo-adapter.md +0 -2
- package/docs/opencode-omo-validation-checklist.md +0 -1
- package/docs/spec-contract.md +10 -36
- package/docs/workflow-router-rules.json +2 -2
- package/docs/workflow-router-rules.md +2 -2
- package/docs/ws-goal-contract.md +153 -33
- package/package.json +1 -1
- package/templates/workspace/.aiws/continuation/CONTINUATION_PROTOCOL.md +101 -0
- package/templates/workspace/.aiws/manifest.json +2 -10
- package/templates/workspace/.opencode/command/ws-finish.md +4 -0
- package/templates/workspace/.opencode/command/ws-goal.md +132 -20
- package/templates/workspace/.opencode/commands/ws-finish.md +4 -0
- package/templates/workspace/.opencode/skills/ws-goal/SKILL.md +32 -0
- package/templates/workspace/AGENTS.md +1 -3
- package/templates/workspace/AI_PROJECT.md +6 -1
- package/templates/workspace/AI_WORKSPACE.md +1 -1
- package/templates/workspace/manifest.json +179 -446
- package/templates/workspace/.agents/skills/p-aiws-change-archive/SKILL.md +0 -24
- package/templates/workspace/.agents/skills/p-aiws-change-finish/SKILL.md +0 -24
- package/templates/workspace/.agents/skills/p-aiws-change-list/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/p-aiws-change-new/SKILL.md +0 -26
- package/templates/workspace/.agents/skills/p-aiws-change-next/SKILL.md +0 -19
- package/templates/workspace/.agents/skills/p-aiws-change-start/SKILL.md +0 -33
- package/templates/workspace/.agents/skills/p-aiws-change-status/SKILL.md +0 -19
- package/templates/workspace/.agents/skills/p-aiws-change-sync/SKILL.md +0 -19
- package/templates/workspace/.agents/skills/p-aiws-change-templates-init/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/p-aiws-change-templates-which/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/p-aiws-change-validate/SKILL.md +0 -23
- package/templates/workspace/.agents/skills/p-aiws-hooks-install/SKILL.md +0 -30
- package/templates/workspace/.agents/skills/p-aiws-hooks-status/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/p-aiws-init/SKILL.md +0 -27
- package/templates/workspace/.agents/skills/p-aiws-rollback/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/p-aiws-update/SKILL.md +0 -26
- package/templates/workspace/.agents/skills/p-aiws-validate/SKILL.md +0 -22
- package/templates/workspace/.agents/skills/p-tasks-plan/SKILL.md +0 -37
- package/templates/workspace/.agents/skills/using-aiws/SKILL.md +0 -112
- package/templates/workspace/.agents/skills/ws-analyze/SKILL.md +0 -26
- package/templates/workspace/.agents/skills/ws-bugfix/SKILL.md +0 -111
- package/templates/workspace/.agents/skills/ws-commit/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-delegate/SKILL.md +0 -75
- package/templates/workspace/.agents/skills/ws-deliver/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-dev/SKILL.md +0 -109
- package/templates/workspace/.agents/skills/ws-dev-lite/SKILL.md +0 -58
- package/templates/workspace/.agents/skills/ws-finish/SKILL.md +0 -22
- package/templates/workspace/.agents/skills/ws-frontend-design/SKILL.md +0 -126
- package/templates/workspace/.agents/skills/ws-goal/SKILL.md +0 -89
- package/templates/workspace/.agents/skills/ws-handoff/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-intake/SKILL.md +0 -106
- package/templates/workspace/.agents/skills/ws-migrate/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-plan/SKILL.md +0 -144
- package/templates/workspace/.agents/skills/ws-plan-verify/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-preflight/SKILL.md +0 -56
- package/templates/workspace/.agents/skills/ws-pull/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-push/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-quality-review/SKILL.md +0 -56
- package/templates/workspace/.agents/skills/ws-req-change/SKILL.md +0 -41
- package/templates/workspace/.agents/skills/ws-req-contract-sync/SKILL.md +0 -17
- package/templates/workspace/.agents/skills/ws-req-contract-validate/SKILL.md +0 -12
- package/templates/workspace/.agents/skills/ws-req-flow-sync/SKILL.md +0 -28
- package/templates/workspace/.agents/skills/ws-req-review/SKILL.md +0 -32
- package/templates/workspace/.agents/skills/ws-research/SKILL.md +0 -56
- package/templates/workspace/.agents/skills/ws-review/SKILL.md +0 -55
- package/templates/workspace/.agents/skills/ws-rule/SKILL.md +0 -23
- package/templates/workspace/.agents/skills/ws-spec-review/SKILL.md +0 -57
- package/templates/workspace/.agents/skills/ws-submodule-setup/SKILL.md +0 -18
- package/templates/workspace/.agents/skills/ws-verify-before-complete/SKILL.md +0 -18
- package/templates/workspace/.claude/commands/p-aiws-change-archive.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-finish.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-list.md +0 -23
- package/templates/workspace/.claude/commands/p-aiws-change-new.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-next.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-start.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-status.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-sync.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-change-templates-init.md +0 -23
- package/templates/workspace/.claude/commands/p-aiws-change-templates-which.md +0 -23
- package/templates/workspace/.claude/commands/p-aiws-change-validate.md +0 -24
- package/templates/workspace/.claude/commands/p-aiws-hooks-install.md +0 -23
- package/templates/workspace/.claude/commands/p-aiws-hooks-status.md +0 -23
- package/templates/workspace/.claude/commands/p-aiws-init.md +0 -20
- package/templates/workspace/.claude/commands/p-aiws-rollback.md +0 -13
- package/templates/workspace/.claude/commands/p-aiws-update.md +0 -19
- package/templates/workspace/.claude/commands/p-aiws-validate.md +0 -14
- package/templates/workspace/.claude/commands/using-aiws.md +0 -25
- package/templates/workspace/.claude/commands/ws-analyze.md +0 -27
- package/templates/workspace/.claude/commands/ws-bugfix.md +0 -32
- package/templates/workspace/.claude/commands/ws-commit.md +0 -67
- package/templates/workspace/.claude/commands/ws-deliver.md +0 -55
- package/templates/workspace/.claude/commands/ws-dev-lite.md +0 -31
- package/templates/workspace/.claude/commands/ws-dev.md +0 -33
- package/templates/workspace/.claude/commands/ws-finish.md +0 -72
- package/templates/workspace/.claude/commands/ws-goal.md +0 -34
- package/templates/workspace/.claude/commands/ws-handoff.md +0 -23
- package/templates/workspace/.claude/commands/ws-intake.md +0 -19
- package/templates/workspace/.claude/commands/ws-migrate.md +0 -22
- package/templates/workspace/.claude/commands/ws-plan-verify.md +0 -25
- package/templates/workspace/.claude/commands/ws-plan.md +0 -21
- package/templates/workspace/.claude/commands/ws-preflight.md +0 -27
- package/templates/workspace/.claude/commands/ws-pull.md +0 -84
- package/templates/workspace/.claude/commands/ws-push.md +0 -90
- package/templates/workspace/.claude/commands/ws-quality-review.md +0 -24
- package/templates/workspace/.claude/commands/ws-req-change.md +0 -42
- package/templates/workspace/.claude/commands/ws-req-contract-sync.md +0 -18
- package/templates/workspace/.claude/commands/ws-req-contract-validate.md +0 -13
- package/templates/workspace/.claude/commands/ws-req-flow-sync.md +0 -20
- package/templates/workspace/.claude/commands/ws-req-review.md +0 -33
- package/templates/workspace/.claude/commands/ws-review.md +0 -31
- package/templates/workspace/.claude/commands/ws-rule.md +0 -24
- package/templates/workspace/.claude/commands/ws-spec-review.md +0 -24
- package/templates/workspace/.claude/commands/ws-submodule-setup.md +0 -54
- package/templates/workspace/.claude/commands/ws-verify-before-complete.md +0 -24
- package/templates/workspace/.claude/settings.json.example +0 -26
- package/templates/workspace/.claude/skills/p-aiws-change-archive/SKILL.md +0 -24
- package/templates/workspace/.claude/skills/p-aiws-change-finish/SKILL.md +0 -24
- package/templates/workspace/.claude/skills/p-aiws-change-list/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/p-aiws-change-new/SKILL.md +0 -26
- package/templates/workspace/.claude/skills/p-aiws-change-next/SKILL.md +0 -19
- package/templates/workspace/.claude/skills/p-aiws-change-start/SKILL.md +0 -33
- package/templates/workspace/.claude/skills/p-aiws-change-status/SKILL.md +0 -19
- package/templates/workspace/.claude/skills/p-aiws-change-sync/SKILL.md +0 -19
- package/templates/workspace/.claude/skills/p-aiws-change-templates-init/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/p-aiws-change-templates-which/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/p-aiws-change-validate/SKILL.md +0 -23
- package/templates/workspace/.claude/skills/p-aiws-hooks-install/SKILL.md +0 -30
- package/templates/workspace/.claude/skills/p-aiws-hooks-status/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/p-aiws-init/SKILL.md +0 -27
- package/templates/workspace/.claude/skills/p-aiws-rollback/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/p-aiws-update/SKILL.md +0 -26
- package/templates/workspace/.claude/skills/p-aiws-validate/SKILL.md +0 -22
- package/templates/workspace/.claude/skills/p-tasks-plan/SKILL.md +0 -37
- package/templates/workspace/.claude/skills/using-aiws/SKILL.md +0 -87
- package/templates/workspace/.claude/skills/ws-analyze/SKILL.md +0 -26
- package/templates/workspace/.claude/skills/ws-bugfix/SKILL.md +0 -111
- package/templates/workspace/.claude/skills/ws-commit/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-deliver/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-dev/SKILL.md +0 -79
- package/templates/workspace/.claude/skills/ws-dev-lite/SKILL.md +0 -58
- package/templates/workspace/.claude/skills/ws-finish/SKILL.md +0 -22
- package/templates/workspace/.claude/skills/ws-frontend-design/SKILL.md +0 -126
- package/templates/workspace/.claude/skills/ws-handoff/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-intake/SKILL.md +0 -53
- package/templates/workspace/.claude/skills/ws-migrate/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-plan/SKILL.md +0 -138
- package/templates/workspace/.claude/skills/ws-plan-verify/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-preflight/SKILL.md +0 -55
- package/templates/workspace/.claude/skills/ws-pull/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-push/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-quality-review/SKILL.md +0 -56
- package/templates/workspace/.claude/skills/ws-req-change/SKILL.md +0 -41
- package/templates/workspace/.claude/skills/ws-req-contract-sync/SKILL.md +0 -17
- package/templates/workspace/.claude/skills/ws-req-contract-validate/SKILL.md +0 -12
- package/templates/workspace/.claude/skills/ws-req-flow-sync/SKILL.md +0 -28
- package/templates/workspace/.claude/skills/ws-req-review/SKILL.md +0 -32
- package/templates/workspace/.claude/skills/ws-review/SKILL.md +0 -55
- package/templates/workspace/.claude/skills/ws-rule/SKILL.md +0 -23
- package/templates/workspace/.claude/skills/ws-spec-review/SKILL.md +0 -57
- package/templates/workspace/.claude/skills/ws-submodule-setup/SKILL.md +0 -18
- package/templates/workspace/.claude/skills/ws-verify-before-complete/SKILL.md +0 -18
- package/templates/workspace/.codex/prompts/aiws-init.md +0 -23
- package/templates/workspace/.codex/prompts/aiws-rollback.md +0 -16
- package/templates/workspace/.codex/prompts/aiws-update.md +0 -22
- package/templates/workspace/.codex/prompts/aiws-validate.md +0 -17
- package/templates/workspace/.codex/prompts/ws-analyze.md +0 -32
- package/templates/workspace/.codex/prompts/ws-dev.md +0 -36
- package/templates/workspace/.codex/prompts/ws-migrate.md +0 -27
- package/templates/workspace/.codex/prompts/ws-preflight.md +0 -32
- package/templates/workspace/.codex/prompts/ws-req-change.md +0 -39
- package/templates/workspace/.codex/prompts/ws-req-contract-sync.md +0 -23
- package/templates/workspace/.codex/prompts/ws-req-contract-validate.md +0 -18
- package/templates/workspace/.codex/prompts/ws-req-flow-sync.md +0 -25
- package/templates/workspace/.codex/prompts/ws-req-review.md +0 -38
- package/templates/workspace/.codex/prompts/ws-review.md +0 -32
- package/templates/workspace/.codex/prompts/ws-rule.md +0 -29
package/docs/ws-goal-contract.md
CHANGED
|
@@ -6,9 +6,9 @@ ws-goal 协议层规范:目标定义、完成审计、预算约束与工具适
|
|
|
6
6
|
|
|
7
7
|
## 1. Background & Motivation
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### /goal 类指令的五层架构
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
一些工具引入了 `/goal` 类指令。它的实现分五层:
|
|
12
12
|
|
|
13
13
|
| 层 | 实现 | 职责 |
|
|
14
14
|
|---|---|---|
|
|
@@ -32,9 +32,18 @@ aiws 当前没有等价协议。OpenCode + oh-my-opencode 已经提供了 3 层
|
|
|
32
32
|
|
|
33
33
|
### 方案:ws-goal 作为协议层
|
|
34
34
|
|
|
35
|
-
ws-goal 定义为**协议层**(prompt-template + artifact spec
|
|
35
|
+
ws-goal 定义为**协议层**(prompt-template + artifact spec),不是运行时引擎。**它做四件事:录入目标、依赖链预检、管道委托、完成审计。**
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
| 步骤 | 做什么 | 不做什么 |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| 录入目标 | 按模板写 `.aiws/goals/<id>.md` | 不创建 change/plan |
|
|
40
|
+
| 依赖链预检 | 追溯上游 change 健康度 + target_base_branch 一致性 | 不修改上游工件 |
|
|
41
|
+
| 管道委托 | 预检通过后,将 goal 委托给子 agent 执行完整 pipeline(ws-plan → ws-dev → ws-review → ws-commit → ws-finish → 审计) | ws-goal 自己不执行任何实现步骤 |
|
|
42
|
+
| 完成审计 | Verification 对照 outcome 逐条验证 | 不替代 review 门禁 |
|
|
43
|
+
|
|
44
|
+
第四步(管道委托)是 ws-goal 的**编排出口**:依赖链预检通过后,ws-goal 构造一个包含 goal 文件完整内容 + 真值文件路径 + 强制 pipeline 步骤的委托 prompt,交由平台支持的子 agent 执行。子 agent 执行完成后,ws-goal 执行最终的完成审计并更新 goal status。
|
|
45
|
+
|
|
46
|
+
这样做的好处是:ws-goal 保持轻量协议层,不重复造 runtime,但通过委托机制提供了从 goal 到 complete 的自动化路径。
|
|
38
47
|
|
|
39
48
|
---
|
|
40
49
|
|
|
@@ -51,7 +60,8 @@ ws-goal 定义为**协议层**(prompt-template + artifact spec),不是运
|
|
|
51
60
|
| **constraints** | object | 预算限制:token_budget(token 上限)、time_budget(wall clock 上限)、max_iterations(turn 次数上限) |
|
|
52
61
|
| **boundaries** | string[] | 显式的非目标、范围限制。什么不在本次 goal 内 |
|
|
53
62
|
| **iteration_policy** | object | max_attempts(重试次数)、reaudit_frequency(每几次迭代重新审计一次) |
|
|
54
|
-
| **blocked_stop** | boolean | 遇到 blocker 时是否暂停并报告。true =
|
|
63
|
+
| **blocked_stop** | boolean/object | 遇到 blocker 时是否暂停并报告。true = 报告并等待,不能静默失败。可扩展为 `{ enabled: true, extends_to_upstream: true }`,将阻断语义延伸到上游依赖链不健康的情况(见 2.4) |
|
|
64
|
+
| **target_base_branch** | string | 目标交付的目标分支(如 `main`、`release/v2`)。agent 在 ws-plan 创建 change 时必须以此为 base_branch,不得自由选择。默认 `main`。若使用的 base_branch 与 `target_base_branch` 不一致,阻断并提示。 |
|
|
55
65
|
|
|
56
66
|
### 2.2 Goal State Machine
|
|
57
67
|
|
|
@@ -60,14 +70,14 @@ active → paused (optional) → complete | budget_limited → archived
|
|
|
60
70
|
```
|
|
61
71
|
|
|
62
72
|
- **active**:目标正在执行中。可能有多个 iteration
|
|
63
|
-
- **paused
|
|
73
|
+
- **paused**(可选):目标被暂停。运行时能力取决于平台。
|
|
64
74
|
- **complete**:完成审计通过,目标已被证明达成
|
|
65
75
|
- **budget_limited**:预算耗尽,目标未完成但无法继续。产生进度报告和 TODO 列表供继续
|
|
66
76
|
- **archived**:最终状态。goal artifact 归档到 evidence 目录
|
|
67
77
|
|
|
68
78
|
### 2.3 Completion Audit Protocol
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
8 步完成审计方法:
|
|
71
81
|
|
|
72
82
|
1. **Derive requirements**:从 objective 推导出具体的、可验证的需求列表。不是重复 objective 原文,而是分解为可逐个检查的原子项
|
|
73
83
|
2. **Preserve scope**:保持原始目标范围。不要将"已经做了什么"重新定义为目标——audit 评判的是原始目标是否达成
|
|
@@ -78,6 +88,98 @@ active → paused (optional) → complete | budget_limited → archived
|
|
|
78
88
|
7. **Uncertain = NOT achieved**:不确定的、间接的、推论性的证据不能作为完成依据。audit 需要确定的证明
|
|
79
89
|
8. **Prove, not disprove**:audit 必须正面证明完成,而不是反面证明"没找到未完成的工作"。找不出 bug 不等于代码正确
|
|
80
90
|
|
|
91
|
+
### 2.4 Dependency Chain Validation
|
|
92
|
+
|
|
93
|
+
引入 change 流水线之前(由 ws-plan/ws-dev 负责),必须先对其上游依赖链做健康检查——这是 ws-goal 作为预检门的职责。防止"死 change 阻塞下游"或"base_branch 选错导致 chaining 混乱"。
|
|
94
|
+
|
|
95
|
+
#### 2.4.1 依赖链定义
|
|
96
|
+
|
|
97
|
+
依赖链是从当前 goal 的目标分支追溯到 main 的完整 change 列表:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
main → change/A → change/B → change/C (当前)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
每个环节称为一个 **link**。每个 link 有独立健康状态。
|
|
104
|
+
|
|
105
|
+
#### 2.4.2 Link 健康判定
|
|
106
|
+
|
|
107
|
+
| 维度 | 健康 (HEALTHY) | 不健康 (UNHEALTHY) | 过时 (STALE) |
|
|
108
|
+
|---|---|---|---|
|
|
109
|
+
| **Artifacts 完整性** | proposal/tasks/design 都存在 | 缺失任意一项 | — |
|
|
110
|
+
| **Task 完成率** | ≤30% WS:TODO,有实际进展 | >50% WS:TODO,无进展迹象 | — |
|
|
111
|
+
| **Review** | review 已通过或无 blocking 项 | review 存在 HIGH blocker | — |
|
|
112
|
+
| **活跃度** | 最近 14 天内有更新 | — | >14 天无任何更新 |
|
|
113
|
+
| **Truth drift** | `aiws validate .` 通过 | `aiws validate .` 失败 | — |
|
|
114
|
+
|
|
115
|
+
整体判定规则:
|
|
116
|
+
- 任意维度 UNHEALTHY → link 标记 **UNHEALTHY**
|
|
117
|
+
- 所有维度 HEALTHY 但任一维度 STALE → link 标记 **STALE**
|
|
118
|
+
- 全部 HEALTHY 且无 STALE → link 标记 **HEALTHY**
|
|
119
|
+
|
|
120
|
+
#### 2.4.3 阻断与确认规则
|
|
121
|
+
|
|
122
|
+
| 上游状态 | 当前 goal 行为 |
|
|
123
|
+
|---|---|
|
|
124
|
+
| 全部 HEALTHY | 放行,无需确认 |
|
|
125
|
+
| 存在 STALE | 输出警告,允许继续 |
|
|
126
|
+
| 存在 UNHEALTHY | 输出完整 chain 拓扑 + 健康报告,**必须用户显式确认**才能继续 |
|
|
127
|
+
| 父 change 不存在(孤儿分支)| 阻断,提示选择已知 base |
|
|
128
|
+
| **实际 base_branch ≠ goal target_base_branch** | **阻断**。输出 "goal 声明 target_base_branch = X,但当前 base_branch = Y",必须用户修正或显式确认才能继续。此检查优先于链健康检查——如果 base_branch 本身就选错了,不需要继续追溯 |
|
|
129
|
+
|
|
130
|
+
#### 2.4.4 Dependency Chain 证据记录
|
|
131
|
+
|
|
132
|
+
验证结果必须写入 goal artifact 的 `Dependency Chain` 字段(见 3.1 模板),包括:
|
|
133
|
+
- 完整 chain 拓扑(从 main 到当前)
|
|
134
|
+
- 每个 link 的健康状态与判定理由
|
|
135
|
+
- 用户确认记录(若 UNHEALTHY 被显式放行)
|
|
136
|
+
|
|
137
|
+
### 2.5 Workspace State Analysis
|
|
138
|
+
|
|
139
|
+
ws-goal 在执行 pipeline delegation(管道委托,见 1.§ 第四步)之前,必须先对当前工作区做全面的状态分析。目的是防止委托子 agent 时因为 workspace 的 dirty 状态、子模块未提交、旧 change 残留等问题导致执行失败或产生意外副作用。
|
|
140
|
+
|
|
141
|
+
#### 2.5.1 分析维度
|
|
142
|
+
|
|
143
|
+
| 维度 | 检查项 | 工具 |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| **Dirty 状态** | staged changes、unstaged changes、untracked files | `git diff --cached --stat` / `git diff --stat` / `git status --porcelain` |
|
|
146
|
+
| **Submodule 状态** | dirty submodules、detached HEAD、unpushed commits | `git submodule status` / `git -C <path> symbolic-ref HEAD` / `git -C <path> log @{u}..HEAD --oneline` |
|
|
147
|
+
| **Change artifacts** | 已有 change 分支、未完成的 change、旧残留 | `git branch --list 'change/*'` / 检查 WS:TODO 比例 |
|
|
148
|
+
| **Git 状态** | unpushed commits、stash | `git log @{u}..HEAD --oneline` / `git stash list` |
|
|
149
|
+
| **Goal 冲突** | 同名 goal、相同 scope 的 active goal | 扫描 `.aiws/goals/*.md` 的 status 与 outcome |
|
|
150
|
+
|
|
151
|
+
#### 2.5.2 影响评估
|
|
152
|
+
|
|
153
|
+
每个发现项必须归属影响等级:
|
|
154
|
+
|
|
155
|
+
| 等级 | 含义 | 示例 |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| **HIGH** | 阻碍 goal 执行,必须处理 | 子模块 dirty 且与 goal 同一目录 |
|
|
158
|
+
| **MED** | 可能干扰或产生误报 | 旧 change 残留导致依赖链误判 |
|
|
159
|
+
| **LOW** | 无影响,仅提示 | untracked 日志文件 |
|
|
160
|
+
| **NONE** | 完全无关 | `.DS_Store` 之类的系统文件 |
|
|
161
|
+
|
|
162
|
+
#### 2.5.3 报告格式
|
|
163
|
+
|
|
164
|
+
分析结果必须用结构化文本块输出,便于用户快速扫描:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
═══ 工作区状态报告 ═══
|
|
168
|
+
[HIGH] <发现项描述> — <影响说明>
|
|
169
|
+
[MED] <发现项描述> — <影响说明>
|
|
170
|
+
[LOW] <发现项描述> — <影响说明>
|
|
171
|
+
═══════════════════════
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### 2.5.4 确认门禁
|
|
175
|
+
|
|
176
|
+
报告输出后,必须等待用户确认:
|
|
177
|
+
- **继续** → 进入 pipeline delegation
|
|
178
|
+
- **暂停** → goal status=paused,报告写入 Audit Trail
|
|
179
|
+
- **先清理** → goal status=paused,输出清理建议步骤
|
|
180
|
+
|
|
181
|
+
用户未确认,不得进入 delegation。
|
|
182
|
+
|
|
81
183
|
---
|
|
82
184
|
|
|
83
185
|
## 3. Protocol Specification
|
|
@@ -87,8 +189,8 @@ active → paused (optional) → complete | budget_limited → archived
|
|
|
87
189
|
```markdown
|
|
88
190
|
---
|
|
89
191
|
ws_goal:
|
|
90
|
-
version:
|
|
91
|
-
state: active
|
|
192
|
+
version: 2 # ↑ bumped to 2 for dependency chain support
|
|
193
|
+
state: active # active | paused | complete | budget_limited | archived
|
|
92
194
|
created_at: <ISO 8601>
|
|
93
195
|
updated_at: <ISO 8601>
|
|
94
196
|
iteration: 1
|
|
@@ -123,10 +225,24 @@ ws_goal:
|
|
|
123
225
|
- max_attempts: <number>
|
|
124
226
|
- reaudit_frequency: <number> # 每 N 次 iteration 重新做一次完成审计
|
|
125
227
|
|
|
126
|
-
##
|
|
228
|
+
## Target Base Branch
|
|
229
|
+
|
|
230
|
+
- target_base_branch: main | change/<id> | release/<name> # 强制。agent 创建 change 时必须以此为 base
|
|
231
|
+
- base_branch_mismatch_action: block | warn # base_branch 不匹配时的行为。默认 block
|
|
232
|
+
|
|
233
|
+
## Dependency Chain
|
|
234
|
+
|
|
235
|
+
- base_branch: main | change/<id>
|
|
236
|
+
- chain:
|
|
237
|
+
- <link-1>: HEALTHY
|
|
238
|
+
- <link-2>: HEALTHY
|
|
239
|
+
- <link-3>: UNHEALTHY (reason: ...)
|
|
240
|
+
- chain_verified_at: <ISO 8601>
|
|
241
|
+
- user_confirmed_unhealthy: true | false | null # UNHEALTHY 时是否显式确认放行
|
|
242
|
+
|
|
243
|
+
## Audit Trail
|
|
127
244
|
|
|
128
|
-
|
|
129
|
-
- report_to: user | log
|
|
245
|
+
<确认记录、约束传递记录、关键变更等>
|
|
130
246
|
|
|
131
247
|
## Progress Notes
|
|
132
248
|
|
|
@@ -164,6 +280,7 @@ token_budget 依赖平台的 token 计数器。aiws 不提供独立的 token 监
|
|
|
164
280
|
| `changes/<id>/tasks.md` | tasks.md 中的每个 item 可携带 `ws_goal_id: <id>` 引用,表示该 task 通过 goal 自动执行。`update_plan` 的 progress tracking 反映 goal iteration 进度 |
|
|
165
281
|
| `.aiws/plan/...` proposal | proposal 中的 `Plan_File` 可以指向 goal objective markdown,表示该 change 使用 goal-driven 执行模式 |
|
|
166
282
|
| `aiws validate` + evidence | validate 的门禁检查可以包含对 goal 的完成审计证据的校验。goal 的 evidence 应落盘到 `changes/<id>/evidence/`,与其他 change 工件统一 |
|
|
283
|
+
| `changes/<id>/.ws-change.json` | `base_branch` 字段作为 dependency chain 验证的起点。ws-goal 在依赖链预检中读取 `.ws-change.json` 的 `base_branch` 追溯上游链 |
|
|
167
284
|
|
|
168
285
|
---
|
|
169
286
|
|
|
@@ -171,16 +288,13 @@ token_budget 依赖平台的 token 计数器。aiws 不提供独立的 token 监
|
|
|
171
288
|
|
|
172
289
|
| Tool | Continuation Engine | Goal Persistence | Budget Tracking | Audit Method |
|
|
173
290
|
|---|---|---|---|---|
|
|
174
|
-
| **Codex** | `/goal` auto-continuation(Rust runtime,内置 turn 调度) | `thread_goals` DB(Rust 状态表,pursuing/paused/achieved/budget_limited) | 内置 token counter + `budget_limit.md` 软停止 | 模型自检 + continuation.md 8 步审计(prompt 内) |
|
|
175
291
|
| **OpenCode** | Ralph Loop L2(`/ralph-loop` 自引循环) / Ultrawork L3(Ralph Loop + Oracle 审计) | `.opencode/ralph-loop.local.md`(YAML frontmatter,active/iteration 状态) | max_iterations 硬限制(L2),无 token/time budget | L2: `<promise>DONE</promise>` 语义声明;L3: Oracle 独立审计 + `<promise>VERIFIED</promise>` |
|
|
176
|
-
| **
|
|
177
|
-
| **aiws ws-goal protocol** | 不提供。依赖各平台已有 continuation 引擎 | `.aiws/goals/<goal-id>.md`(标准模板工件)+ `changes/<id>/evidence/` 审计证据 | 定义协议但依赖平台 token 计数器。aiws 只做格式规范和软停止信号定义 | 8 步完成审计(协议层规范,平台层执行) |
|
|
292
|
+
| **aiws ws-goal protocol** | 不提供。依赖各平台已有 continuation 引擎 | `.aiws/goals/<goal-id>.md`(标准模板工件)+ `changes/<id>/evidence/` 审计证据 | 定义协议但依赖平台能力 | 8 步完成审计(协议层规范,平台层执行) |
|
|
178
293
|
|
|
179
294
|
### 关键说明
|
|
180
295
|
|
|
181
296
|
- **OpenCode L2 vs L3**:L2 只有自检声明(DONE),可信度较低;L3 引入独立审计者(Oracle),可信度较高但成本也高。ws-goal 协议推荐的审计模式是 L3,但允许 L2 作为轻度使用的降级
|
|
182
|
-
-
|
|
183
|
-
- **Claude Code 的局限性**:Claude Code 没有等效的 Ralph Loop 或 /goal 运行时。ws-goal 在 Claude Code 上的能力受限于平台本身的续跑机制
|
|
297
|
+
- ws-goal 协议可以投影到各平台时绑定其 continuation 能力,只需补充完成审计的规范约束
|
|
184
298
|
|
|
185
299
|
---
|
|
186
300
|
|
|
@@ -191,18 +305,14 @@ token_budget 依赖平台的 token 计数器。aiws 不提供独立的 token 监
|
|
|
191
305
|
ws-goal 协议层不实现任何 continuation/scheduling/pause/resume 机制。这些能力完全依赖于各平台:
|
|
192
306
|
|
|
193
307
|
- OpenCode:依赖 Ralph Loop(文件状态轮询 + prompt 注入)
|
|
194
|
-
- Codex:依赖 /goal 的 Rust runtime(turn 调度 + 数据库)
|
|
195
|
-
- Claude Code:依赖用户手动管理
|
|
196
308
|
|
|
197
|
-
这意味着跨工具的"暂停/恢复"行为会不一致。
|
|
309
|
+
这意味着跨工具的"暂停/恢复"行为会不一致。
|
|
198
310
|
|
|
199
311
|
### 5.2 Budget Tracking 依赖平台能力
|
|
200
312
|
|
|
201
313
|
token_budget 和 time_budget 的监控需要平台提供接口。当前:
|
|
202
314
|
|
|
203
|
-
- Codex:内置 token counter,支持软停止
|
|
204
315
|
- OpenCode(oh-my-opencode):无 token 计数,只有 max_iterations
|
|
205
|
-
- Claude Code:无任何 budget tracking
|
|
206
316
|
|
|
207
317
|
aiws 只定义"预算耗尽时应该做什么"的协议,不提供跨平台的统一计费层。在缺少平台支持的维度上,goal 应标记为 unsupported 而不是假装能工作。
|
|
208
318
|
|
|
@@ -210,27 +320,37 @@ aiws 只定义"预算耗尽时应该做什么"的协议,不提供跨平台的
|
|
|
210
320
|
|
|
211
321
|
不同工具使用不同的持久化机制:
|
|
212
322
|
|
|
213
|
-
- Codex:服务端 `thread_goals` 数据库(跨客户端同步)
|
|
214
323
|
- OpenCode(Ralph Loop):文件 `.opencode/ralph-loop.local.md`(会话级)
|
|
215
|
-
- Claude Code:无内置持久化
|
|
216
324
|
|
|
217
|
-
|
|
325
|
+
没有共享数据库。如果一个目标在一个工具开始,无法在另一个工具中恢复。goal objective markdown 文件 `.aiws/goals/<goal-id>.md` 可以作为人类可读的参考,但状态同步不保证。
|
|
218
326
|
|
|
219
327
|
### 5.4 State Machine 的工具依赖
|
|
220
328
|
|
|
221
329
|
完整状态机 `active → paused → complete | budget_limited → archived` 中各状态的支持情况:
|
|
222
330
|
|
|
223
|
-
| 状态转换 |
|
|
224
|
-
|
|
225
|
-
| active → paused |
|
|
226
|
-
| paused → active |
|
|
227
|
-
| active → complete |
|
|
228
|
-
| active → budget_limited |
|
|
229
|
-
| complete → archived |
|
|
331
|
+
| 状态转换 | OpenCode (Ralph Loop) |
|
|
332
|
+
|---|---|---|
|
|
333
|
+
| active → paused | 不支持(只能 cancel) |
|
|
334
|
+
| paused → active | 不支持 |
|
|
335
|
+
| active → complete | 支持(DONE 声明 + oracle 验证) |
|
|
336
|
+
| active → budget_limited | 不支持 |
|
|
337
|
+
| complete → archived | 手动 |
|
|
230
338
|
|
|
231
339
|
aiws 协议层定义了完整的语义状态,但各平台只能实现其中一部分。goal 创建时应注意平台的能力边界。
|
|
232
340
|
|
|
233
|
-
### 5.5
|
|
341
|
+
### 5.5 Dependency Chain Validation 依赖仓库上下文
|
|
342
|
+
|
|
343
|
+
Dependency chain 验证(2.4)需要:
|
|
344
|
+
- 当前仓库的 git 历史完整(能追溯到 main)
|
|
345
|
+
- `.ws-change.json` 或 proposal.md 记录了 `base_branch`
|
|
346
|
+
- 对链上每个 change 的 artifacts 有读权限(同一工作区)
|
|
347
|
+
|
|
348
|
+
如果当前不在 git 仓库、或无法访问上游 change 的工件(例如跨仓库依赖),则 chain 验证降级为:
|
|
349
|
+
- 报 UNKNOWN 状态
|
|
350
|
+
- 输出警告"无法验证上游依赖链"
|
|
351
|
+
- 不阻断,但要求用户确认已知风险
|
|
352
|
+
|
|
353
|
+
### 5.6 Completion Audit 的执行成本
|
|
234
354
|
|
|
235
355
|
8 步完成审计方法在完整执行时需要独立审计者(在 OpenCode L3 中需要额外模型调用)。对于小目标(比如"修复一个 lint 错误"),完整审计的 overhead 可能超过实际工作的成本。建议根据目标复杂度选择审计级别:
|
|
236
356
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# ws-* Pipeline Continuation Protocol
|
|
2
|
+
|
|
3
|
+
## 问题
|
|
4
|
+
|
|
5
|
+
每个 ws-* skill 完成当前 phase 后输出 `Next:` 文本建议,然后停下。用户需要手动输入下一 phase 的 slash 命令。本协议定义了一套标准化机制,让所有 ws-* skill 在完成后自动推进到下一 phase。
|
|
6
|
+
|
|
7
|
+
## 核心机制
|
|
8
|
+
|
|
9
|
+
### 1. Pipeline 状态文件
|
|
10
|
+
|
|
11
|
+
`.aiws/continuation/pipeline.json` — 共享状态文件,记录当前流水线所有 phase 的状态。
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"pipeline_id": "<pipeline-id>",
|
|
16
|
+
"goal_id": "<goal-id>",
|
|
17
|
+
"change_id": "<change-id>",
|
|
18
|
+
"created_at": "<UTC timestamp>",
|
|
19
|
+
"updated_at": "<UTC timestamp>",
|
|
20
|
+
"phases": [
|
|
21
|
+
{"name": "preflight", "status": "completed", "evidence": ""},
|
|
22
|
+
{"name": "ws-goal", "status": "completed", "evidence": ".aiws/goals/<goal-id>.md"},
|
|
23
|
+
{"name": "ws-plan", "status": "in_progress", "evidence": ""},
|
|
24
|
+
{"name": "ws-plan-verify","status": "pending", "evidence": ""},
|
|
25
|
+
{"name": "ws-dev", "status": "pending", "evidence": ""},
|
|
26
|
+
{"name": "ws-review", "status": "pending", "evidence": ""},
|
|
27
|
+
{"name": "ws-commit", "status": "pending", "evidence": ""},
|
|
28
|
+
{"name": "ws-finish", "status": "pending", "evidence": ""}
|
|
29
|
+
],
|
|
30
|
+
"current_phase_index": 2,
|
|
31
|
+
"blockers": []
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
状态值: `pending` | `in_progress` | `completed` | `blocked`
|
|
36
|
+
|
|
37
|
+
### 2. Phase Completion Protocol(所有 ws-* skill 共享)
|
|
38
|
+
|
|
39
|
+
每个 ws-* skill 完成后执行(替代原有 `Next:` 输出 + 结束):
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
1. 更新 pipeline.json:
|
|
43
|
+
- 当前 phase → status: "completed", evidence: <路径>
|
|
44
|
+
- 下一 phase → status: "in_progress"
|
|
45
|
+
- current_phase_index → 下一 phase 索引号
|
|
46
|
+
- updated_at → 当前时间
|
|
47
|
+
|
|
48
|
+
2. 更新 todo:
|
|
49
|
+
- 当前 phase 的 todo → completed
|
|
50
|
+
- 下一 phase 的 todo → in_progress(若还不存在则创建)
|
|
51
|
+
|
|
52
|
+
3. 若还有下一 phase:
|
|
53
|
+
- 输出 "→ Auto-continuing to <next_phase>"
|
|
54
|
+
- 立即开始执行下一 phase 的逻辑(不输出"是否继续"等待文本)
|
|
55
|
+
|
|
56
|
+
4. 若已是最后一个 phase:
|
|
57
|
+
- 输出 pipeline 完成摘要
|
|
58
|
+
- 标记 goal 为 complete
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Continuation Detection(所有 ws-* skill 共享)
|
|
62
|
+
|
|
63
|
+
当 skill 被调用时(包括 slash command 直接调用 和 Boulder/Ralph Loop continuation):
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
检查 .aiws/continuation/pipeline.json:
|
|
67
|
+
- 若存在且有 in_progress phase:
|
|
68
|
+
a) 如果 in_progress phase 名称 == 当前 skill 名称 → 正常执行当前 skill
|
|
69
|
+
b) 如果 in_progress phase 名称 ≠ 当前 skill 名称 → 跳到该 phase 的执行逻辑
|
|
70
|
+
c) 如果所有 phase completed → 输出 pipeline 完成摘要,不再执行新工作
|
|
71
|
+
- 若不存在 → 正常执行当前 skill(独立模式)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 4. Skill Entry 改造
|
|
75
|
+
|
|
76
|
+
每个 ws-* SKILL.md 顶部增加 Pipeline Continuation Detection 段。
|
|
77
|
+
|
|
78
|
+
### 5. Skill Ending 改造
|
|
79
|
+
|
|
80
|
+
每个 ws-* SKILL.md 的 `输出要求` / `Next:` 段替换为 Phase Completion Protocol。
|
|
81
|
+
|
|
82
|
+
### 6. ws-goal 作为 Pipeline 启动器
|
|
83
|
+
|
|
84
|
+
ws-goal 在复杂度评估后:
|
|
85
|
+
- 创建 pipeline.json(预填所有 phase)
|
|
86
|
+
- 创建所有 phase 对应的 todo
|
|
87
|
+
- 直接执行第一个 phase 的逻辑(不停下)
|
|
88
|
+
|
|
89
|
+
## 默认 Pipeline 链路
|
|
90
|
+
|
|
91
|
+
preflight → ws-goal → ws-plan → ws-plan-verify → ws-dev → ws-review → ws-commit → ws-finish
|
|
92
|
+
|
|
93
|
+
根据复杂度评估选择包含哪些 phase:
|
|
94
|
+
- 简单路径: ws-goal → dev → commit → finish
|
|
95
|
+
- 标准路径: ws-goal → plan → plan-verify → dev → review → commit → finish
|
|
96
|
+
- 复杂路径: 标准路径 + intake + deliver + handoff
|
|
97
|
+
|
|
98
|
+
## 文件位置
|
|
99
|
+
|
|
100
|
+
- 状态文件: `.aiws/continuation/pipeline.json`
|
|
101
|
+
- 协议文档: `.aiws/continuation/CONTINUATION_PROTOCOL.md`
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"aiws_version": "0.0.0",
|
|
6
6
|
"installed_at": "1970-01-01T00:00:00Z",
|
|
7
7
|
"updated_at": "1970-01-01T00:00:00Z",
|
|
8
|
-
"tools": ["
|
|
8
|
+
"tools": ["opencode"],
|
|
9
9
|
"managed": [
|
|
10
10
|
{ "path": ".githooks/pre-commit", "mode": "replace_file", "sha256": "<sha256>" },
|
|
11
11
|
{ "path": ".githooks/pre-push", "mode": "replace_file", "sha256": "<sha256>" },
|
|
@@ -16,17 +16,9 @@
|
|
|
16
16
|
{ "path": "AI_WORKSPACE.md", "mode": "managed_blocks", "blocks": { "ai-workspace:core": "<sha256>" } },
|
|
17
17
|
{ "path": "REQUIREMENTS.md", "mode": "managed_blocks", "blocks": { "requirements:contract": "<sha256>" } },
|
|
18
18
|
{ "path": ".gitignore", "mode": "managed_blocks", "blocks": { "gitignore": "<sha256>" } },
|
|
19
|
-
{ "path": ".claude/commands/aiws-init.md", "mode": "managed_blocks", "blocks": { "claude:aiws-init": "<sha256>" } },
|
|
20
|
-
{ "path": ".claude/commands/aiws-update.md", "mode": "managed_blocks", "blocks": { "claude:aiws-update": "<sha256>" } },
|
|
21
|
-
{ "path": ".claude/commands/aiws-validate.md", "mode": "managed_blocks", "blocks": { "claude:aiws-validate": "<sha256>" } },
|
|
22
|
-
{ "path": ".claude/commands/aiws-rollback.md", "mode": "managed_blocks", "blocks": { "claude:aiws-rollback": "<sha256>" } },
|
|
23
19
|
{ "path": ".opencode/command/aiws-init.md", "mode": "managed_blocks", "blocks": { "opencode:aiws-init": "<sha256>" } },
|
|
24
20
|
{ "path": ".opencode/command/aiws-update.md", "mode": "managed_blocks", "blocks": { "opencode:aiws-update": "<sha256>" } },
|
|
25
21
|
{ "path": ".opencode/command/aiws-validate.md", "mode": "managed_blocks", "blocks": { "opencode:aiws-validate": "<sha256>" } },
|
|
26
|
-
{ "path": ".opencode/command/aiws-rollback.md", "mode": "managed_blocks", "blocks": { "opencode:aiws-rollback": "<sha256>" } }
|
|
27
|
-
{ "path": ".codex/prompts/aiws-init.md", "mode": "managed_blocks", "blocks": { "codex:aiws-init": "<sha256>" } },
|
|
28
|
-
{ "path": ".codex/prompts/aiws-update.md", "mode": "managed_blocks", "blocks": { "codex:aiws-update": "<sha256>" } },
|
|
29
|
-
{ "path": ".codex/prompts/aiws-validate.md", "mode": "managed_blocks", "blocks": { "codex:aiws-validate": "<sha256>" } },
|
|
30
|
-
{ "path": ".codex/prompts/aiws-rollback.md", "mode": "managed_blocks", "blocks": { "codex:aiws-rollback": "<sha256>" } }
|
|
22
|
+
{ "path": ".opencode/command/aiws-rollback.md", "mode": "managed_blocks", "blocks": { "opencode:aiws-rollback": "<sha256>" } }
|
|
31
23
|
]
|
|
32
24
|
}
|
|
@@ -66,6 +66,10 @@ fi
|
|
|
66
66
|
7) submodules 全部成功后,再回到主仓库执行:
|
|
67
67
|
- `aiws change finish <change-id> --push`
|
|
68
68
|
8) `aiws change finish --push` 成功后会自动归档并生成 handoff;只有历史/异常场景才需要手工运行 `aiws change archive <change-id>`。
|
|
69
|
+
9) 输出本轮 change 的中文工作摘要,包含:
|
|
70
|
+
- 目标:解决了什么问题
|
|
71
|
+
- 改动范围:改了哪些文件/模块(可引用 handoff 或 evidence)
|
|
72
|
+
- 验证结果:构建/测试/LSP/validate 等关键门禁的结果
|
|
69
73
|
|
|
70
74
|
安全:
|
|
71
75
|
- push 前先输出状态并说明远端/分支。
|
|
@@ -1,39 +1,151 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 目标协议:设定可审计的 goal
|
|
2
|
+
description: 目标协议:设定可审计的 goal 目标;依赖链预检;完成审计
|
|
3
3
|
---
|
|
4
4
|
<!-- AIWS_MANAGED_BEGIN:opencode:ws-goal -->
|
|
5
5
|
# ws goal
|
|
6
6
|
|
|
7
7
|
用中文输出(命令/路径/代码标识符保持原样不翻译)。
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
## 职责边界
|
|
10
|
+
|
|
11
|
+
ws-goal 只做三件事,不做更多:
|
|
12
|
+
|
|
13
|
+
| 做 | 不做 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 录入目标(写 `.aiws/goals/<id>.md`) | 创建/驱动 change(那是 ws-plan/ws-dev) |
|
|
16
|
+
| 依赖链预检(上游死 change → 阻断) | 评估复杂度、路由执行路径 |
|
|
17
|
+
| 完成审计(claim done 时验证 outcome) | git add/commit/push、finish |
|
|
18
|
+
| 记录 target_base_branch 约束 | auto-chain 到下一个 goal |
|
|
19
|
+
|
|
20
|
+
超出以上范围的需求,路由到对应 ws-* 技能,ws-goal 不碰。
|
|
21
|
+
|
|
22
|
+
## 前置条件
|
|
11
23
|
|
|
12
|
-
前置条件:
|
|
13
24
|
1) 先运行 `/ws-preflight`(对齐 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`)。
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
## 执行流程
|
|
27
|
+
|
|
16
28
|
0) 检查 `.aiws/goals/` 目录:
|
|
17
29
|
a) 若用户仅查询状态(无明确目标),列出所有 goal 文件及其 status 字段,然后结束。
|
|
18
30
|
b) 若存在 status=active 或 status=paused 的 goal 文件,优先读取并恢复执行,不再新建 goal。
|
|
31
|
+
|
|
19
32
|
1) 读取真值文件(`AI_PROJECT.md`、`REQUIREMENTS.md`、`AI_WORKSPACE.md`),确认项目规则与边界。
|
|
33
|
+
|
|
20
34
|
2) 接受用户输入的 goal objective,明确目标范围与验收标准。
|
|
35
|
+
|
|
21
36
|
3) 按 ws-goal-contract.md 的目标模板生成目标文件,写入 `.aiws/goals/<goal-id>.md`。
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
b)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
a) 生成时填入 `Target Base Branch` 字段:
|
|
38
|
+
- `target_base_branch`:从当前分支追踪或用户声明确定。默认 `main`
|
|
39
|
+
- `base_branch_mismatch_action`:默认 `block`
|
|
40
|
+
b) 生成时填入初始 `Dependency Chain` 字段:
|
|
41
|
+
- `base_branch`:当前检出分支或用户指定的基分支
|
|
42
|
+
- `chain`:追溯完整的 change 链到 main
|
|
43
|
+
- `chain_verified_at`:当前时间
|
|
44
|
+
- `user_confirmed_unhealthy`:初始为 null
|
|
45
|
+
|
|
46
|
+
4) **Dependency Chain Validation**:上游依赖链健康检查(不创建任何 change/plan/commit)。
|
|
47
|
+
a) 确定 base_branch:
|
|
48
|
+
- 若当前已存在 change 分支,读取 `.ws-change.json` 或 proposal.md 的 `base_branch`
|
|
49
|
+
- 若用户显式指定 base_branch,以用户指定为准
|
|
50
|
+
- 否则默认 main
|
|
51
|
+
a1) **target_base_branch 一致性检查**(Rule C):
|
|
52
|
+
- 读取 goal 文件的 `Target Base Branch.target_base_branch`
|
|
53
|
+
- 若 `base_branch != target_base_branch`:
|
|
54
|
+
- 输出 "goal 声明 target_base_branch = X,但当前 base_branch = Y"
|
|
55
|
+
- 若 `base_branch_mismatch_action` 为 `block`(默认):**强制 blocker**,必须用户修正 base_branch 或显式确认 mismatch 才能继续
|
|
56
|
+
- 若为 `warn`:输出警告并允许继续
|
|
57
|
+
- 将 mismatch 记录到 goal 文件的 Audit Trail
|
|
58
|
+
- 若一致:继续 step b
|
|
59
|
+
b) 追溯 chain:从 base_branch 逐级向上追溯到 main
|
|
60
|
+
- 每级检查 `.ws-change.json` 的 `base_branch` 或 git 分支关系
|
|
61
|
+
- 若无法追溯(孤儿分支),标记 UNKNOWN 并输出警告
|
|
62
|
+
c) 对 chain 中每个 link 做健康检查(按 ws-goal-contract.md 2.4.2 标准):
|
|
63
|
+
- artifacts 完整性:proposal/tasks/design 是否存在
|
|
64
|
+
- task 完成率:WS:TODO 占比
|
|
65
|
+
- review 状态:是否有 HIGH blocker
|
|
66
|
+
- 活跃度:最后更新时间
|
|
67
|
+
- truth drift:`aiws validate .` 是否通过
|
|
68
|
+
d) 结果:
|
|
69
|
+
- ALL HEALTHY → 输出 "依赖链健康" 并继续
|
|
70
|
+
- 存在 STALE → 输出链拓扑 + 警告,允许继续
|
|
71
|
+
- 存在 UNHEALTHY → 输出完整 chain 拓扑 + 每级健康报告,**强制 blocker**,必须用户显式确认才能继续
|
|
72
|
+
- UNKNOWN(无法追溯)→ 输出警告"无法验证上游依赖链",不阻断但要求用户确认
|
|
73
|
+
e) 将验证结果写入 goal 文件的 `Dependency Chain` 字段:
|
|
74
|
+
- 更新 `chain` 中每个 link 的健康状态与判定理由
|
|
75
|
+
- 若用户放行 UNHEALTHY:设置 `user_confirmed_unhealthy: true` 并记录到 `Audit Trail`
|
|
76
|
+
- 若用户未放行:设置 goal status=paused 并结束
|
|
77
|
+
|
|
78
|
+
4.5) **Workspace State Analysis**:依赖链预检通过后、delegation 前,分析工作区状态并输出报告。
|
|
79
|
+
必须用户确认后才能进入 step 5。
|
|
80
|
+
a) 检查 dirty 状态:
|
|
81
|
+
- staged changes(`git diff --cached --stat`)
|
|
82
|
+
- unstaged changes(`git diff --stat`)
|
|
83
|
+
- untracked files(`git status --porcelain` 中 `??` 开头项)
|
|
84
|
+
b) 检查 submodule 状态:
|
|
85
|
+
- 每个 submodule 的 dirty 状态(`git submodule status`)
|
|
86
|
+
- detached HEAD(`git -C <path> symbolic-ref HEAD` 失败)
|
|
87
|
+
- unpushed 提交(`git -C <path> log @{u}..HEAD --oneline`)
|
|
88
|
+
c) 检查 change artifacts:
|
|
89
|
+
- 存在哪些 change 分支(`git branch --list 'change/*'`)
|
|
90
|
+
- 是否有未完成的 change(proposal/tasks 仍含 WS:TODO)
|
|
91
|
+
- 是否与当前 goal 冲突(同名、同域)
|
|
92
|
+
d) 检查 git 状态:
|
|
93
|
+
- 是否有 unpushed 提交(`git log @{u}..HEAD --oneline`)
|
|
94
|
+
- 是否有 stash(`git stash list`)
|
|
95
|
+
e) 评估影响:逐项判断与当前 goal 的关联度:
|
|
96
|
+
- HIGH:阻碍 goal 执行,必须处理
|
|
97
|
+
- MED:可能干扰或产生误报
|
|
98
|
+
- LOW:无影响,仅提示
|
|
99
|
+
- NONE:完全无关,忽略
|
|
100
|
+
f) 输出结构化分析报告:
|
|
101
|
+
用格式化的文本块输出,每行标注影响等级:
|
|
102
|
+
```
|
|
103
|
+
═══ 工作区状态报告 ═══
|
|
104
|
+
[HIGH] 子模块 web/ dirty(7 文件)— 与 goal 同一目录,可能干扰
|
|
105
|
+
[MED] 旧 change contract-ai-rag 残留 — 可能干扰依赖链判断
|
|
106
|
+
[LOW] .aiws/journal/ 日志文件 — 无影响
|
|
107
|
+
════════════════════════
|
|
108
|
+
```
|
|
109
|
+
g) 展示报告后要求用户选择:
|
|
110
|
+
- **继续** → 进入 step 5
|
|
111
|
+
- **暂停** → goal status=paused,报告写入 Audit Trail,结束
|
|
112
|
+
- **先清理** → goal status=paused,输出清理建议步骤,结束
|
|
113
|
+
用户未确认前,不得进入 step 5。
|
|
114
|
+
|
|
115
|
+
5) **Pipeline Delegation**:依赖链预检 + workspace 分析通过后,将 goal 完整执行委托给管道 agent。
|
|
116
|
+
前置条件:step 4 必须通过(ALL HEALTHY 或 UNHEALTHY 已显式放行)。若 step 4 阻断,则不允许 delegation。
|
|
117
|
+
a) 读取 goal 文件,评估复杂度:
|
|
118
|
+
- 简单(配置/doc/规范,≤5 文件,低风险)→ delegate 到 ws-dev-lite
|
|
119
|
+
- 复杂(代码改动 >5 文件,多模块,架构/迁移风险)→ delegate 到完整 pipeline
|
|
120
|
+
b) 构造 delegation prompt,包含:
|
|
121
|
+
- goal 文件完整路径与内容(含 target_base_branch、dependency chain 验证结果)
|
|
122
|
+
- 真值文件路径(AI_PROJECT.md / REQUIREMENTS.md / AI_WORKSPACE.md)
|
|
123
|
+
- 强制 pipeline 步骤(见下方 c)
|
|
124
|
+
- 完成条件:goal 文件的 Verification 字段全部通过
|
|
125
|
+
c) 强制 pipeline 步骤(子 agent 必须依次执行,不得跳过):
|
|
126
|
+
1. 如果 change 不存在:`aiws change start <goal-id> --allow-dirty`,base_branch 必须用 goal 的 target_base_branch
|
|
127
|
+
2. 写 proposal.md:绑定 goal 的 outcome 到 Req_ID,plan_file 指向即将生成的 plan
|
|
128
|
+
3. 写 plan 文件:`plan/<timestamp>-<goal-id>.md`,含验证命令与预期
|
|
129
|
+
4. 运行 plan-verify:`aiws plan-verify <plan-file>` 或等效检查
|
|
130
|
+
5. 实现代码改动(ws-dev):按 plan 实施,边改边验证
|
|
131
|
+
6. review 检查:lint/typecheck/code review 按 ws-review 标准
|
|
132
|
+
7. 提交:`ws-commit`(或等效 git add + commit)
|
|
133
|
+
8. 收尾:`ws-finish`(fast-forward 合并 + 推送)
|
|
134
|
+
9. 更新 goal status=complete:修改 goal 文件中的 state 字段
|
|
135
|
+
「not applicable」步骤可跳过,但必须说明理由
|
|
136
|
+
d) 使用 task 委托:
|
|
137
|
+
- 简单 → `task(category="quick", load_skills=[], ...)`
|
|
138
|
+
- 复杂 → `task(category="deep", load_skills=[], ...)` 或 `task(subagent_type="general", ...)`
|
|
139
|
+
e) 委托任务执行完成后:
|
|
140
|
+
- 收集子 agent 的输出,逐项对照 goal 文件的 Verification 字段做完成审计
|
|
141
|
+
- 全部通过 → 更新 goal state=complete,输出 "Goal <goal-id> complete"
|
|
142
|
+
- 有未通过 → 更新 goal state=paused,记录 blocker 到 Audit Trail,输出 "Goal <goal-id> paused: <reason>"
|
|
143
|
+
- 若子 agent 返回了未完成的 pipeline 状态(只有部分步骤完成),在 goal 文件的 Progress Notes 中记录进展,标记 goal state=paused 并输出当前进度
|
|
144
|
+
f) 判断平台是否支持 task 委托:
|
|
145
|
+
- 调用 `task(category="quick", load_skills=[], description="probe", prompt="probe", run_in_background=true)`
|
|
146
|
+
- 若返回有效的 task_id/session_id → 支持委托,走 e)
|
|
147
|
+
- 若返回错误或无 session_id → 不支持委托
|
|
148
|
+
- 不支持时:在本会话中亲自执行 c) 的 pipeline 步骤,全部完成后更新 goal status=complete
|
|
37
149
|
<!-- AIWS_MANAGED_END:opencode:ws-goal -->
|
|
38
150
|
|
|
39
151
|
可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
|
|
@@ -66,6 +66,10 @@ fi
|
|
|
66
66
|
7) submodules 全部成功后,再回到主仓库执行:
|
|
67
67
|
- `aiws change finish <change-id> --push`
|
|
68
68
|
8) `aiws change finish --push` 成功后会自动归档并生成 handoff;只有历史/异常场景才需要手工运行 `aiws change archive <change-id>`。
|
|
69
|
+
9) 输出本轮 change 的中文工作摘要,包含:
|
|
70
|
+
- 目标:解决了什么问题
|
|
71
|
+
- 改动范围:改了哪些文件/模块(可引用 handoff 或 evidence)
|
|
72
|
+
- 验证结果:构建/测试/LSP/validate 等关键门禁的结果
|
|
69
73
|
|
|
70
74
|
安全:
|
|
71
75
|
- push 前先输出状态并说明远端/分支。
|