@aipper/aiws-spec 0.0.42 → 0.0.43
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 +11 -6
- package/docs/run-behavior-guidelines.md +32 -0
- package/docs/workflow-delegation-context-injection.md +51 -0
- package/docs/workflow-delegation-contracts.json +46 -15
- package/docs/workflow-delegation-contracts.md +4 -8
- package/docs/workflow-delegation-contracts.schema.json +44 -12
- package/docs/workflow-router-rules.json +20 -3
- package/docs/ws-goal-contract.md +286 -30
- package/package.json +1 -1
- package/templates/workspace/.opencode/skills/using-aiws/SKILL.md +30 -65
- package/templates/workspace/.opencode/skills/ws-bugfix/SKILL.md +39 -63
- package/templates/workspace/.opencode/skills/ws-delegate/SKILL.md +40 -75
- package/templates/workspace/.opencode/skills/ws-dev/SKILL.md +36 -68
- package/templates/workspace/.opencode/skills/ws-dev-lite/SKILL.md +2 -0
- package/templates/workspace/.opencode/skills/ws-frontend-design/SKILL.md +74 -103
- package/templates/workspace/.opencode/skills/ws-intake/SKILL.md +45 -118
- package/templates/workspace/.opencode/skills/ws-plan/SKILL.md +4 -2
- package/templates/workspace/.opencode/skills/ws-quality-review/SKILL.md +12 -6
- package/templates/workspace/.opencode/skills/ws-review/SKILL.md +23 -17
- package/templates/workspace/.opencode/skills/ws-spec-review/SKILL.md +12 -6
package/docs/ws-goal-contract.md
CHANGED
|
@@ -629,14 +629,15 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
|
|
|
629
629
|
3. FOR each group in topological order:
|
|
630
630
|
a. Update group status → in_progress
|
|
631
631
|
b. Group PHASE 1 - PLAN:
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
632
|
+
i. Construct phase delegation prompt:
|
|
633
|
+
- Goal outcome, verification (group-level), constraints, boundaries
|
|
634
|
+
- Current group scope and verification
|
|
635
|
+
- target_base_branch from goal
|
|
636
|
+
- Dependency chain validation results (step 4)
|
|
637
|
+
- Workspace state analysis results (step 4.5)
|
|
638
|
+
- Phase scope: ONLY proposal.md + plan file + plan-verify
|
|
639
|
+
- Phase constraints: NOT dev, NOT review, NOT commit/finish
|
|
640
|
+
- output_manifest: proposal.md, plan file, plan-verify evidence
|
|
640
641
|
ii. Delegate to sub-agent:
|
|
641
642
|
- `task(category="unspecified-high", prompt="...")`
|
|
642
643
|
- Wait for completion
|
|
@@ -651,22 +652,39 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
|
|
|
651
652
|
iii. Verify design_context and internal_tasks non-empty
|
|
652
653
|
iv. If either empty: output warning (non-blocking), suggest filling
|
|
653
654
|
d. Group PHASE 2 - DEV:
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
655
|
+
i. Construct phase delegation prompt:
|
|
656
|
+
- Plan content, proposal links
|
|
657
|
+
- Phase scope: ONLY implement per plan + local verify
|
|
658
|
+
- Phase constraints: NOT modify proposal/plan, NOT commit
|
|
659
|
+
- output_manifest: list of promised output files (paths relative to repo root)
|
|
660
|
+
ii. Delegate to sub-agent:
|
|
661
|
+
- `task(category="deep", prompt="...")`
|
|
662
|
+
- Wait for completion
|
|
663
|
+
ii.a Output Verification Gate:
|
|
664
|
+
- Read back the output_manifest from sub-agent's final response
|
|
665
|
+
- Glob check each promised file exists
|
|
666
|
+
- Minimum content check: each file > 3 lines of non-whitespace content
|
|
667
|
+
- Exception:声明为配置/单行格式的文件(manifest 中标记 `"config": true` 或文件扩展名为 `.env`、`.json`、`.conf` 等配置格式),最小内容检查降为 ≥1 行非空白内容
|
|
668
|
+
- All pass → continue to step iii
|
|
669
|
+
- Fail → classify failure before retry:
|
|
670
|
+
a) Zero files produced → CLASS-A (prompt too complex, context overflow)
|
|
671
|
+
b) Partial files produced → CLASS-B (narrow scope; retry only missing files)
|
|
672
|
+
c) All files exist but content empty/wrong → CLASS-C (check diagnostics, retry with augmented context)
|
|
673
|
+
- Retry strategy per class:
|
|
674
|
+
- CLASS-A: split goal into smaller sub-goals or invoke degraded mode (see §6.8)
|
|
675
|
+
- CLASS-B: retry only missing files with narrowed prompt
|
|
676
|
+
- CLASS-C: retry with additional context (plan, related source files)
|
|
677
|
+
- Max 2 retries per class; after exhaustion → group paused, blocker recorded, STOP
|
|
678
|
+
iii. Main session verify:
|
|
679
|
+
- Diagnostics clean (lsp_diagnostics on changed files)
|
|
680
|
+
- Changes match plan scope
|
|
681
|
+
- Fail → group paused, blocker recorded, STOP
|
|
682
|
+
e. Group PHASE 3 - REVIEW:
|
|
683
|
+
i. Construct phase delegation prompt:
|
|
684
|
+
- Proposal + plan + changed files
|
|
685
|
+
- Phase scope: ONLY audit, produce review evidence
|
|
686
|
+
- Phase constraints: NOT modify code
|
|
687
|
+
- output_manifest: review evidence files
|
|
670
688
|
ii. Delegate to sub-agent:
|
|
671
689
|
- `task(category="unspecified-high", prompt="...")`
|
|
672
690
|
- Wait for completion
|
|
@@ -674,10 +692,11 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
|
|
|
674
692
|
- Review evidence files exist
|
|
675
693
|
- No HIGH blocker unresolved
|
|
676
694
|
- Fail → group paused, blocker recorded, STOP
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
695
|
+
f. Group PHASE 4 - FINISH:
|
|
696
|
+
i. Construct phase delegation prompt:
|
|
697
|
+
- Phase scope: ONLY commit + finish
|
|
698
|
+
- Phase constraints: NOT modify code
|
|
699
|
+
- output_manifest: commit SHA, merge confirmation
|
|
681
700
|
ii. Delegate to sub-agent:
|
|
682
701
|
- `task(category="quick", load_skills=["git-master"], prompt="...")`
|
|
683
702
|
- Wait for completion
|
|
@@ -723,8 +742,16 @@ Phase-Level Pipeline Dispatch 的审计分散在各 phase 的门禁验证中,
|
|
|
723
742
|
|
|
724
743
|
1. ws-goal 记录当前组停止位置到 Progress Notes
|
|
725
744
|
2. 标记 goal state=paused
|
|
726
|
-
3.
|
|
727
|
-
|
|
745
|
+
3. **Failure classification**:在重试前,按 Output Verification Gate(§6.4 step ii.a)的分类判断失败原因:
|
|
746
|
+
- CLASS-A(系统性缺陷:prompt 复杂度过高、context 溢出)→ **不盲重试**,拆分后再试或进入降级模式(§6.8)
|
|
747
|
+
- CLASS-B(局部缺失:部分文件未产出)→ 缩小范围重试缺失部分
|
|
748
|
+
- CLASS-C(质量缺陷:文件存在但内容错误)→ 补充上下文后重试
|
|
749
|
+
- 未触发 Output Verification Gate 的失败(如 phase 验证未通过)→ 归入 CLASS-C 处理
|
|
750
|
+
4. **默认重试**:下一 session 自动从失败 phase 根据分类策略重新委托(不询问 skip)
|
|
751
|
+
5. 重试耗尽(每种分类 2 次,总计最多 6 次)后自动暂停并 handoff,输出恢复上下文供手动处理
|
|
752
|
+
6. **Escalation to degraded mode**:若同一 group 在 2 种不同分类中各失败 1 次,主 session 可选择:
|
|
753
|
+
- 继续按当前分类重试
|
|
754
|
+
- 将该 group 切换为降级模式(§6.8)——main session 直接 batch-edit,post-hoc review 覆盖审计
|
|
728
755
|
|
|
729
756
|
### 6.7 Backward Compatibility
|
|
730
757
|
|
|
@@ -734,6 +761,118 @@ Phase-Level Pipeline Dispatch 的审计分散在各 phase 的门禁验证中,
|
|
|
734
761
|
| 含 groups 定义的 goal(新格式) | 进入 Phase-Level Sequential Dispatch 模式,每 group 按 4-phase 执行 |
|
|
735
762
|
| 已有 goal 工件(.md 文件) | 兼容。goal 文件格式不变,仅 delegation 执行方式变更 |
|
|
736
763
|
|
|
764
|
+
### 6.8 Degraded Mode Protocol
|
|
765
|
+
|
|
766
|
+
#### 6.8.1 Motivation
|
|
767
|
+
|
|
768
|
+
当 group scope 过大(CLASS-A 失败反复出现)或子 agent 反复失败(多种分类各消耗 1 次重试)时,完整 4-phase 委托的开销可能超过其收益。此时继续保持多轮委托只会加剧"退回直接编辑"的崩溃——main session 在重试 3 轮后放弃协议,直接改代码。
|
|
769
|
+
|
|
770
|
+
降级模式提供** sanctioned 的中间路径**:在 maintain auditability 的前提下,减少事前委托、增加事后审计。
|
|
771
|
+
|
|
772
|
+
#### 6.8.2 Entry Criteria
|
|
773
|
+
|
|
774
|
+
任一条件满足即可进入降级模式(由主 session 自主判定,**不阻断**):
|
|
775
|
+
|
|
776
|
+
| 条件 | 触发值 |
|
|
777
|
+
|---|---|
|
|
778
|
+
| CLASS-A 失败 ≥ 2 次(同一 group) | 当前 group 可降级 |
|
|
779
|
+
| 同一 group 的 2 种不同分类各失败 1 次 | 当前 group 可降级 |
|
|
780
|
+
| goal 含 > 10 个 group 且 ≥ 30% 失败 | 整个 goal 可降级 |
|
|
781
|
+
| 主 session 主动声明 `degraded: true` | 指定 group 可降级 |
|
|
782
|
+
|
|
783
|
+
#### 6.8.3 Degraded Mode Protocol
|
|
784
|
+
|
|
785
|
+
降级模式修改 §6.2.4 的 delegation model:
|
|
786
|
+
|
|
787
|
+
```
|
|
788
|
+
group execution (degraded):
|
|
789
|
+
PHASE 1 - PLAN: 正常 4-phase 委托(不变)
|
|
790
|
+
PHASE 2 - DEV: main session 直接 batch-edit(跳过低层级子 agent 委托)
|
|
791
|
+
→ output verification gate 由 main session 自行验证
|
|
792
|
+
→ 改动记录到 changes/<id>/patches/degraded-batch.md
|
|
793
|
+
PHASE 3 - REVIEW: 正常 review 委托(不变,reviewer 独立审查 batch-edit 产出)
|
|
794
|
+
PHASE 4 - FINISH: 正常 finish 委托(不变)
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
**变更内容**(Degraded DEV):
|
|
798
|
+
|
|
799
|
+
- DEV phase 不再委托给子 agent,改为 main session 直接使用 `edit` / `write` 工具批量修改文件
|
|
800
|
+
- main session 在开始 batch-edit 前,必须将预期改动写入 `changes/<id>/patches/degraded-batch.md`(格式见下)
|
|
801
|
+
- batch-edit 完成后,main session 自行运行验证:`lsp_diagnostics` + 测试命令
|
|
802
|
+
- 验证通过后,继续进入 REVIEW phase(独立 reviewer 审查 batch-edit 的改动)
|
|
803
|
+
- REVIEW phase 不变:独立 reviewer 仍然从需求 / 实现质量 / 回归风险角度审查
|
|
804
|
+
|
|
805
|
+
**关键约束**:
|
|
806
|
+
- **不能跳过 REVIEW phase**。降级模式只跳过低层级子 agent 委托,不跳过审查门禁
|
|
807
|
+
- **不能跳过 completion audit**。§6.5 的总体审计在降级模式下同样适用
|
|
808
|
+
- 降级只作用于当前 group,不强制影响其他 group
|
|
809
|
+
- REVIEW 发现 HIGH blocker 时,修复仍在降级模式下进行(main session 直接修复,不走子 agent 重试循环)
|
|
810
|
+
- 降级模式的 group 在 completion audit 中标记为 `degraded: true`,区分于正常委托 group
|
|
811
|
+
|
|
812
|
+
**嵌套失败边界**:
|
|
813
|
+
- 降级模式**不能嵌套**——已在降级模式下的 group 如果 REVIEW 或 FINISH 委托再次失败(CLASS-A/B/C),`"进入降级模式"`的升级路径替换为`"暂停 group 并 handoff"`。
|
|
814
|
+
- 原因:降级模式已经是 full delegation 的最后逃生通道;如果 sub-agent 在降级模式(REVIEW 或 FINISH)下仍然反复失败,说明问题不在 delegation 模式,而是目标本身或上下文不完整——此时重试无意义,应暂停并输出恢复上下文供手动处理。
|
|
815
|
+
|
|
816
|
+
#### 6.8.4 Degraded Batch Record 格式
|
|
817
|
+
|
|
818
|
+
```markdown
|
|
819
|
+
# Degraded Batch: <goal-id> / <group-id>
|
|
820
|
+
|
|
821
|
+
## Trigger
|
|
822
|
+
- <entry criteria>: <具体描述,如 "DEV phase CLASS-A 失败 2 次:context overflow">
|
|
823
|
+
|
|
824
|
+
## Expected Changes
|
|
825
|
+
| File | Operation | Summary |
|
|
826
|
+
|------|-----------|---------|
|
|
827
|
+
| src/a.ts | edit | Rename validate() to validateEmail() |
|
|
828
|
+
| src/b.ts | edit | Add null check before call |
|
|
829
|
+
| src/a.test.ts | write | Add edge case tests |
|
|
830
|
+
|
|
831
|
+
## Verification
|
|
832
|
+
- [ ] lsp_diagnostics clean
|
|
833
|
+
- [ ] Test command 1: npm test -- --filter ...
|
|
834
|
+
- [ ] Test command 2: ...
|
|
835
|
+
|
|
836
|
+
## Actual Outcome
|
|
837
|
+
- [ ] All changes applied
|
|
838
|
+
- [ ] Diagnostics clean
|
|
839
|
+
- [ ] All tests pass
|
|
840
|
+
- Notes: <any issues during batch-edit>
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
#### 6.8.5 全局降级模式
|
|
844
|
+
|
|
845
|
+
当整个 goal 进入降级模式(所有 group 降级),执行链路:
|
|
846
|
+
|
|
847
|
+
```
|
|
848
|
+
Goal (fully degraded):
|
|
849
|
+
INTAKE → PLAN (once, for all groups) → DEGRADED DEV (batch-all groups) → REVIEW (once, full goal) → FINISH
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
此时不拆分为逐 group 的 4-phase 循环,而是:
|
|
853
|
+
1. 一个 PLAN 子 agent 产出所有 group 的 proposal + plan
|
|
854
|
+
2. Main session 对所有 group 批量编辑(记录到同一份 degraded-batch.md)
|
|
855
|
+
3. 一个 REVIEW 子 agent 审查全部改动
|
|
856
|
+
4. 一个 FINISH 子 agent 完成提交
|
|
857
|
+
|
|
858
|
+
#### 6.8.6 降级证据记录
|
|
859
|
+
|
|
860
|
+
降级模式的 group 必须记录以下证据:
|
|
861
|
+
- `changes/<id>/patches/degraded-batch.md`:预期改动 + 验证结果(主 session 在 batch-edit 前写入)
|
|
862
|
+
- `changes/<id>/review/degraded-review.md`:reviewer 对 batch-edit 的审查结论(与正常 review 证据文件格式一致)
|
|
863
|
+
- `changes/<id>/evidence/degraded-evidence.md`:降级触发原因 + 涉及 group + 当前降级范围(主 session 在进入降级模式时写入)
|
|
864
|
+
- goal Progress Notes 记录降级原因 + 涉及 group 列表
|
|
865
|
+
|
|
866
|
+
三个文件共同构成降级模式的完整证据链:batch 记录(what changed)→ 审查结论(review 确认)→ 降级记录(why degraded)。
|
|
867
|
+
|
|
868
|
+
#### 6.8.7 退出降级
|
|
869
|
+
|
|
870
|
+
降级模式是 group 级别的选项。下一 group 可以:
|
|
871
|
+
- 保持降级(如果主 session 判定 delegation 仍然不可行)
|
|
872
|
+
- 恢复完整 4-phase 委托
|
|
873
|
+
|
|
874
|
+
退出条件:同一 goal 中后续 group 未出现 §6.8.2 的 entry criteria,主 session 可选择恢复。
|
|
875
|
+
|
|
737
876
|
## 7. Persistence & Resume
|
|
738
877
|
|
|
739
878
|
### 7.1 Motivation & Gap Analysis
|
|
@@ -836,6 +975,17 @@ Session 重启后 ws-goal step 0 检测流程:
|
|
|
836
975
|
|
|
837
976
|
> 设计原则:用户执行 ws-goal 即代表意图明确——继续未完成的工作。重复询问"是否要继续"增加摩擦、不增加价值。仅在无法自动决策时(如多个冲突 goal)才需要用户介入。
|
|
838
977
|
|
|
978
|
+
#### 7.4.1 Question Tool Interruption
|
|
979
|
+
|
|
980
|
+
`question` tool 调用会中断当前会话,下一个会话是新的 session 边界。Auto-Resume(§7.4)适用:
|
|
981
|
+
|
|
982
|
+
1. 执行者在调用 `question` tool **之前**,必须先写入 state.json 检查点(更新 `current_phase` 与当前 checkpoint `status=in_progress`)。
|
|
983
|
+
2. 写入完成后调用 `question` tool。会话可能在此后结束。
|
|
984
|
+
3. 下一个会话启动时,Auto-Resume 检测到 status=active 的 state.json,自动从当前 phase 恢复。
|
|
985
|
+
4. `question` 的上下文已在注入 §7.5 continuation context 时一并传递,不需要额外持久化。
|
|
986
|
+
|
|
987
|
+
> 例外:如果 `question` 在 PHASE 0(INTAKE)阶段调用,此时尚未创建 state.json。执行者应在 `question` 前记录 intake 草案到 `plan/<timestamp>-<slug>.intake.md`,下个会话通过询问用户后重新从 PHASE 0 开始。
|
|
988
|
+
|
|
839
989
|
### 7.5 Continuation Context Template
|
|
840
990
|
|
|
841
991
|
当 session 重启后检测到 paused goal 并 auto-resume 时,ws-goal 技能注入以下上下文:
|
|
@@ -871,3 +1021,109 @@ Instructions: Continue from the failed phase. Do NOT redo completed phases.
|
|
|
871
1021
|
- 如果用户手动删除或修改 state.json,ws-goal 降级为全量重跑(可重新生成)
|
|
872
1022
|
- 并行执行多个 goal 时,state.json 独立管理,互不依赖
|
|
873
1023
|
- state.json 不包含 secrets 或凭证信息
|
|
1024
|
+
|
|
1025
|
+
### 7.8 Pipeline Auto-Advance
|
|
1026
|
+
|
|
1027
|
+
#### 7.8.1 Motivation
|
|
1028
|
+
|
|
1029
|
+
§7.4 定义了 session 重启时的 auto-resume(向后恢复),但缺少**前向自动推进**——当当前 phase 完成后,自动读取 state.json 启动下一个 phase,而不是等待主 session 手动检查 checkpoint 并触发下一轮委托。
|
|
1030
|
+
|
|
1031
|
+
当前协议依赖主 session 在 phase 完成后手动判断"已完成 phase X,现在开始 phase Y"。这个判断是纯机械的,每次都重复一样逻辑。Auto-Advance 将此机械工作自动化,减少阶段转换摩擦。
|
|
1032
|
+
|
|
1033
|
+
#### 7.8.2 Mechanism
|
|
1034
|
+
|
|
1035
|
+
使用基于 **state.json checkpoint 文件产出**的自动推进,不依赖文本标记(如 `PHASE_DONE` 字符串):
|
|
1036
|
+
|
|
1037
|
+
```
|
|
1038
|
+
phase 完成 → checkpoint status=complete(写入 state.json)
|
|
1039
|
+
→ 读取 state.json,找到下一个 status=pending 的 checkpoint
|
|
1040
|
+
→ 若存在 → 自动启动该 phase(注入职责+上下文)
|
|
1041
|
+
→ 若不存在 → 全部完成,触发整体 completion audit(§6.5)
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
**不使用文本标记**的原因:
|
|
1045
|
+
- 依赖 agent 输出固定格式字符串是脆弱耦合(格式偏差即断链)
|
|
1046
|
+
- 文件状态(checkpoint written/last_phase.json 存在)是更可靠的信号
|
|
1047
|
+
- state.json 的 `status` 字段是机器可读、工具无关的检查点
|
|
1048
|
+
|
|
1049
|
+
#### 7.8.3 Phase Transition Protocol
|
|
1050
|
+
|
|
1051
|
+
```
|
|
1052
|
+
Current phase in_progress:
|
|
1053
|
+
1. Sub-agent completes current phase → main session 验证通过
|
|
1054
|
+
2. Main session 更新 checkpoint → status=complete + timestamp
|
|
1055
|
+
3. Main session 扫描 state.json checkpoints:
|
|
1056
|
+
a. 找到第一个 status=pending 且「所有依赖的 group phase 已 complete」的 checkpoint
|
|
1057
|
+
b. 若找到 → 设置 current_phase, current_group,checkpoint status=in_progress
|
|
1058
|
+
c. 若未找到 → 全部完成,进入整体 completion audit
|
|
1059
|
+
4. **Context offload**(phase 间上下文卸载):
|
|
1060
|
+
a. Main session 写入 phase summary 到 Progress Notes(goal .md 文件)
|
|
1061
|
+
b. Main session 写入当前 phase 的关键产出摘要到 state.json(extra 字段)
|
|
1062
|
+
c. Main session **释放**当前 phase 的原始上下文(raw output、sub-agent logs)——不再保留在活动窗口中
|
|
1063
|
+
d. 从 state.json 冷加载下一 phase:
|
|
1064
|
+
- 读取 goal objective、verification、boundaries
|
|
1065
|
+
- 读取下一 phase 的 checkpoint 状态
|
|
1066
|
+
- 读取上一 phase 的 summary(仅摘要,非原始输出)
|
|
1067
|
+
- 构造新 phase 的委托 prompt
|
|
1068
|
+
5. 启动下一 phase
|
|
1069
|
+
|
|
1070
|
+
Phase complete → 明确标记为 complete
|
|
1071
|
+
Phase failed → 标记为 failed,走 §6.6 Failure Recovery
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
#### 7.8.4 Context Offload
|
|
1075
|
+
|
|
1076
|
+
每个 phase 完成后的上下文卸载是 auto-advance 的关键机制,防止主 session 上下文累积导致性能下降或崩溃:
|
|
1077
|
+
|
|
1078
|
+
| 保留内容 | 卸载内容 |
|
|
1079
|
+
|---|---|
|
|
1080
|
+
| Phase 摘要(≤10 行结构化总结) | Sub-agent 完整输出 |
|
|
1081
|
+
| 关键产物的文件路径+checksum | 产物具体内容 |
|
|
1082
|
+
| 当前 phase 的 blocker/recovery 记录 | Sub-agent 中间错误栈 |
|
|
1083
|
+
| 下一 phase 需要的输入引用 | 上一 phase 的全文 prompt |
|
|
1084
|
+
| Goal objective & verification(持久引用) | 历史 phase 的委托结果原文 |
|
|
1085
|
+
|
|
1086
|
+
**卸载方法**:
|
|
1087
|
+
|
|
1088
|
+
```yaml
|
|
1089
|
+
# Progress Notes 中的 phase summary 格式
|
|
1090
|
+
PHASE <name> (<group-id>):
|
|
1091
|
+
status: complete | failed
|
|
1092
|
+
summary: "<10-line structured summary of what happened>"
|
|
1093
|
+
outputs:
|
|
1094
|
+
- file: <path> # 关键产出路径
|
|
1095
|
+
check: <checksum or "verified">
|
|
1096
|
+
blockers: <none or description>
|
|
1097
|
+
next_phase_input: <引用信息供下一 phase 使用>
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
#### 7.8.5 与 §7.4 Resume Protocol 的关系
|
|
1101
|
+
|
|
1102
|
+
| 协议 | 方向 | 触发条件 |
|
|
1103
|
+
|---|---|---|
|
|
1104
|
+
| Auto-Resume(§7.4) | 向后恢复 | Session 重启、检测到 paused/active state.json |
|
|
1105
|
+
| Auto-Advance(§7.8) | 前向推进 | 当前 phase complete、下一 phase pending |
|
|
1106
|
+
|
|
1107
|
+
两者互补:
|
|
1108
|
+
- Auto-Resume 从 state.json 恢复中断位置
|
|
1109
|
+
- Auto-Advance 在运行中沿 state.json 向前推进
|
|
1110
|
+
- 两者共享同一套 checkpoint 状态机
|
|
1111
|
+
|
|
1112
|
+
**重新进入 Auto-Advance**:Auto-Resume 恢复 phase 后,该 phase 完成时重新进入 Auto-Advance 循环(启动接下来的 phase),不需要额外状态。
|
|
1113
|
+
|
|
1114
|
+
#### 7.8.6 失败行为
|
|
1115
|
+
|
|
1116
|
+
- Phase 验证未通过 → 不推进,走 §6.6 Failure Recovery
|
|
1117
|
+
- state.json 不一致(多个 checkpoint 同时 in_progress)→ 阻断,输出诊断报告,要求手动修复
|
|
1118
|
+
- state.json 缺失(被手动删除)→ 降级为暂停,等待主 session 检查 goal .md 文件的 Progress Notes 手动判断下一步
|
|
1119
|
+
|
|
1120
|
+
#### 7.8.7 与 Degraded Mode 的交互
|
|
1121
|
+
|
|
1122
|
+
Auto-Advance 在降级模式下仍然适用,但推进逻辑调整:
|
|
1123
|
+
|
|
1124
|
+
- 降级模式 group 的 DEV phase 由 main session 直接 batch-edit(不经过子 agent 委托),但 main session 仍将 DEV checkpoint 写入 state.json(status=complete + `degraded: true`)
|
|
1125
|
+
- Auto-Advance 读取 state.json 时,`degraded: true` 标记的 checkpoint 视为 complete,正常推进到 REVIEW phase
|
|
1126
|
+
- REVIEW phase 仍然委托给子 agent,无论当前 group 的 DEV 是否处于降级模式
|
|
1127
|
+
- 全 goal 降级模式(§6.8.5)下,Auto-Advance 的 phase 序列变为:`intake → goal_def → dep_check → ws_analysis → plan → dev (degraded) → review → finish`
|
|
1128
|
+
|
|
1129
|
+
**即**:降级模式改变的是*执行方式*(batch-edit vs delegation),不改变 checkpoint 状态机。Auto-Advance 不关心执行方式,只关心 checkpoint 状态。
|
package/package.json
CHANGED
|
@@ -7,14 +7,14 @@ description: 使用时机:新会话开始、不确定下一步做什么时。
|
|
|
7
7
|
|
|
8
8
|
目标:默认入口,先读真值文件,判定当前任务 workflow,再进入具体 `ws-*` skill。若意图不明确:先澄清,不直接进入实现。
|
|
9
9
|
|
|
10
|
+
阶段定位:bootstrap/router 阶段;负责分流,不直接完成实现。
|
|
11
|
+
|
|
10
12
|
## 编排约束
|
|
11
13
|
|
|
12
|
-
-
|
|
13
|
-
- **上下文先于判决**:路由 `direct_implementation`
|
|
14
|
+
- **不直接实现**:只判 workflow、读真值、路由到对应 `ws-*`。主 session 不直接写代码。
|
|
15
|
+
- **上下文先于判决**:路由 `direct_implementation` 前必须收集项目上下文——`git status --porcelain`(改动文件数)、`git diff --stat`(改动行范围)、`AI_WORKSPACE.md` 验证入口。仅当 ≤3 文件、≤100 行改动、验证明确时,才可判 direct。
|
|
14
16
|
- **意图不明先澄清**:`routeTo=clarify` 时必须停止并问 1-3 个关键问题,不猜测。
|
|
15
17
|
|
|
16
|
-
阶段定位:bootstrap/router 阶段;负责分流,不直接完成实现。
|
|
17
|
-
|
|
18
18
|
## 必需输入
|
|
19
19
|
|
|
20
20
|
- 当前任务描述
|
|
@@ -27,40 +27,24 @@ description: 使用时机:新会话开始、不确定下一步做什么时。
|
|
|
27
27
|
|
|
28
28
|
## 阻断条件
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
- 缺失任一真值文件
|
|
32
|
-
- 无法明确当前任务意图
|
|
33
|
-
- 无法明确归因或验证入口,且不能安全推断
|
|
30
|
+
- 无法确定项目根目录、缺失任一真值文件、无法明确任务意图、无法归因且不能安全推断
|
|
34
31
|
|
|
35
32
|
## 执行步骤
|
|
36
33
|
|
|
37
34
|
### 1. Preflight
|
|
38
35
|
|
|
39
|
-
读取 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md
|
|
40
|
-
|
|
41
|
-
- 若检测到 `.opencode/oh-my-opencode.json`:输出 `oMo-enabled`
|
|
42
|
-
- 若未检测到:输出 `standard-opencode`
|
|
43
|
-
- 若缺失任一真值文件 → route = `$ws-preflight`,建议先 `aiws init .`
|
|
36
|
+
读取 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`。若检测到 `.opencode/oh-my-opencode.json` 输出 `oMo-enabled`,否则 `standard-opencode`。缺失真值文件则 route = `$ws-preflight`,建议 `aiws init .`
|
|
44
37
|
|
|
45
38
|
### 1.5 Per-turn Breadcrumb(必做)
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
目的:即使 context 被压缩,breadcrumb 也能让 AI 知道当前处于哪个阶段、上次做到哪一步。
|
|
50
|
-
|
|
51
|
-
格式:`[workflow-state:PHASE_NAME/N]`,其中 PHASE_NAME 取自 standardChain,N 为步骤序号。
|
|
40
|
+
每轮对话开始时读取当前 change 状态,输出 `[workflow-state:PHASE_NAME/N]` 标记。
|
|
52
41
|
|
|
53
42
|
### 2. 路由判定
|
|
54
43
|
|
|
55
|
-
根据 `packages/spec/docs/workflow-router-rules.json`
|
|
56
|
-
|
|
57
|
-
- 路由前先读上下文:判 direct_implementation 前,router 必须先收集项目上下文(git status、涉及文件范围),确认是真正的单文件修复,再决定 direct vs plan。
|
|
44
|
+
根据 `packages/spec/docs/workflow-router-rules.json` 判定。判 direct_implementation 前必须先收集上下文(git status、涉及文件范围):
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
- `git diff --stat` — 确认改动文件数量
|
|
62
|
-
- 改动涉及 ≤2 文件且均在已知路径 → 可判 direct
|
|
63
|
-
- 改动涉及 ≥3 文件或含未知路径 → 必须走 ws-plan
|
|
46
|
+
- ≤2 文件且均在已知路径 → direct
|
|
47
|
+
- ≥3 文件或含未知路径 → ws-plan
|
|
64
48
|
|
|
65
49
|
| 意图 | Route |
|
|
66
50
|
|------|-------|
|
|
@@ -75,53 +59,32 @@ description: 使用时机:新会话开始、不确定下一步做什么时。
|
|
|
75
59
|
| 极简修复 | `$ws-dev-lite` |
|
|
76
60
|
| Subagent 不可用 | 回退单 agent + 工件模式 |
|
|
77
61
|
|
|
78
|
-
注:`$ws-dev` 默认走 subagent-first
|
|
62
|
+
注:`$ws-dev` 默认走 subagent-first 策略。主 session 应优先通过 `$ws-delegate` 派发 `aiws-worker`,除非用户明确说"直接改"。
|
|
79
63
|
|
|
80
|
-
**Escape Hatch
|
|
81
|
-
1. 输出 `[escape-hatch: direct-implementation]` 标记
|
|
82
|
-
2. 仍须归因到 Req_ID / Problem_ID
|
|
83
|
-
3. 仍须有可复现验证入口
|
|
84
|
-
4. 仍须落盘 evidence 标记 escape-hatch 使用原因
|
|
64
|
+
**Escape Hatch**:用户明确说"跳过流程"时允许 direct_implementation,但须输出 `[escape-hatch]` 标记、归因到 Req_ID、有可复现验证入口、落盘 evidence 注明原因。
|
|
85
65
|
|
|
86
66
|
### 3. 意图不明确
|
|
87
67
|
|
|
88
|
-
只问 1-3
|
|
68
|
+
只问 1-3 个关键问题(意图、Req_ID/Problem_ID、verify、change),然后停止。
|
|
89
69
|
|
|
90
70
|
### 4. Continuation Routing(新 session 恢复)
|
|
91
71
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
续跑决策表(与 `aiws-context.js#getChangeState` 同步):
|
|
72
|
+
续跑决策:
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
│ │ 否则 worker 继续或 aiws-reviewer 审查 │
|
|
107
|
-
│ review │ evidence 齐 → ws-finish/ws-commit │
|
|
108
|
-
│ │ 否则补 evidence 再提交 │
|
|
109
|
-
│ finished │ ws-finish 收尾归档 │
|
|
110
|
-
│ unknown │ ws-preflight 重新评估 │
|
|
111
|
-
└──────────────────┴──────────────────────────────────────────────┘
|
|
112
|
-
```
|
|
74
|
+
| Phase | Next Action |
|
|
75
|
+
|-------|-------------|
|
|
76
|
+
| none(无 change) | ws-intake 或 ws-plan |
|
|
77
|
+
| intake | ws-intake 继续,或 ws-plan |
|
|
78
|
+
| planning | plan 存在→ws-plan-verify;否则 ws-plan |
|
|
79
|
+
| ready-for-dev | 派发 aiws-worker |
|
|
80
|
+
| in-progress | patches 存在→review;was DONE_WITH_CONCERNS→ws-quality-review;否则继续 |
|
|
81
|
+
| review | evidence 齐→ws-finish/ws-commit;否则补 evidence |
|
|
82
|
+
| finished | ws-finish 收尾归档 |
|
|
83
|
+
| unknown | ws-preflight |
|
|
113
84
|
|
|
114
|
-
Subagent
|
|
115
|
-
- ready-for-dev 无 subagent → 当前 agent 直接执行 ws-dev(走 inline escape hatch)
|
|
116
|
-
- in-progress 无 reviewer → 当前 agent 自审(走 evaluate-optimize 1 轮)
|
|
117
|
-
- review 无 oracle → 当前 agent 本地 review(不阻断流程)
|
|
85
|
+
Subagent 降级:无 subagent 时当前 agent 直接执行,evidence 中记录降级原因(`mode: single-agent`)。
|
|
118
86
|
|
|
119
|
-
|
|
120
|
-
- 上次 delegation 返回 `BLOCKED` → 先解决 blocker 再继续
|
|
121
|
-
- 上次 delegation 返回 `NEEDS_CONTEXT` → 补 context JSONL 后重新派发
|
|
122
|
-
- Subagent-first 默认:`ready-for-dev` / `in-progress` 默认派发 worker/reviewer
|
|
123
|
-
- Subagent 不可用时:降级为当前 agent 直接执行,但必须在 evidence 中记录降级原因
|
|
124
|
-
- Subagent 不可用时回退:单 agent 模式 + 显式维护 `.aiws/changes/<id>/` 工件(handoff-evidence.md, analysis/, patches/);不阻断流程,但须标注 `mode: single-agent`
|
|
87
|
+
特殊状态:`BLOCKED` 需解 blocker;`NEEDS_CONTEXT` 补 JSONL 后重试。
|
|
125
88
|
|
|
126
89
|
### 5. 输出路由
|
|
127
90
|
|
|
@@ -140,5 +103,7 @@ Next: <继续执行对应 skill,或提出澄清问题>
|
|
|
140
103
|
|
|
141
104
|
- Router 自己不实现代码;不给 route 前不直接改代码
|
|
142
105
|
- 一次只选一个主 route
|
|
143
|
-
-
|
|
144
|
-
-
|
|
106
|
+
- 复杂度升高:`$ws-dev` 回退 `$ws-plan`;`$ws-finish` 回退前置门禁
|
|
107
|
+
- subagent 不可用:单 agent 执行,但须维护等价工件结构
|
|
108
|
+
|
|
109
|
+
> 运行时行为约束:`packages/spec/docs/run-behavior-guidelines.md`
|