pi-maestro-flow 0.2.0
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/README.md +124 -0
- package/agents/aggregator.md +27 -0
- package/agents/cli-explore-agent.md +188 -0
- package/agents/cross-role-reviewer.md +171 -0
- package/agents/delegate.md +19 -0
- package/agents/explorer.md +23 -0
- package/agents/impeccable-agent.md +99 -0
- package/agents/ralph-executor.md +81 -0
- package/agents/reference.md +24 -0
- package/agents/role-design-author.md +220 -0
- package/agents/team-supervisor.md +143 -0
- package/agents/team-worker.md +237 -0
- package/agents/ui-design-agent.md +270 -0
- package/agents/workflow-analyzer.md +116 -0
- package/agents/workflow-codebase-mapper.md +77 -0
- package/agents/workflow-collab-planner.md +147 -0
- package/agents/workflow-debugger.md +104 -0
- package/agents/workflow-executor.md +133 -0
- package/agents/workflow-external-researcher.md +86 -0
- package/agents/workflow-integration-checker.md +83 -0
- package/agents/workflow-nyquist-auditor.md +85 -0
- package/agents/workflow-phase-researcher.md +85 -0
- package/agents/workflow-plan-checker.md +100 -0
- package/agents/workflow-planner.md +200 -0
- package/agents/workflow-project-researcher.md +74 -0
- package/agents/workflow-research-synthesizer.md +70 -0
- package/agents/workflow-reviewer.md +82 -0
- package/agents/workflow-roadmapper.md +81 -0
- package/agents/workflow-verifier.md +120 -0
- package/package.json +58 -0
- package/skills/codify-to-knowhow/SKILL.md +167 -0
- package/skills/delegation-check/SKILL.md +297 -0
- package/skills/domain-add/SKILL.md +75 -0
- package/skills/insight-challenge/SKILL.md +226 -0
- package/skills/learn-decompose/SKILL.md +124 -0
- package/skills/learn-follow/SKILL.md +163 -0
- package/skills/learn-investigate/SKILL.md +160 -0
- package/skills/learn-second-opinion/SKILL.md +128 -0
- package/skills/maestro/SKILL.md +239 -0
- package/skills/maestro-amend/SKILL.md +169 -0
- package/skills/maestro-analyze/SKILL.md +173 -0
- package/skills/maestro-blueprint/SKILL.md +159 -0
- package/skills/maestro-brainstorm/SKILL.md +193 -0
- package/skills/maestro-collab/SKILL.md +181 -0
- package/skills/maestro-companion/SKILL.md +536 -0
- package/skills/maestro-composer/SKILL.md +192 -0
- package/skills/maestro-execute/SKILL.md +193 -0
- package/skills/maestro-fork/SKILL.md +104 -0
- package/skills/maestro-grill/SKILL.md +151 -0
- package/skills/maestro-guard/SKILL.md +124 -0
- package/skills/maestro-help/SKILL.md +328 -0
- package/skills/maestro-impeccable/SKILL.md +302 -0
- package/skills/maestro-init/SKILL.md +151 -0
- package/skills/maestro-merge/SKILL.md +90 -0
- package/skills/maestro-milestone-audit/SKILL.md +117 -0
- package/skills/maestro-milestone-complete/SKILL.md +133 -0
- package/skills/maestro-milestone-release/SKILL.md +131 -0
- package/skills/maestro-next/SKILL.md +269 -0
- package/skills/maestro-overlay/SKILL.md +203 -0
- package/skills/maestro-plan/SKILL.md +194 -0
- package/skills/maestro-player/SKILL.md +184 -0
- package/skills/maestro-quick/SKILL.md +117 -0
- package/skills/maestro-ralph/SKILL.md +905 -0
- package/skills/maestro-ralph-cli/SKILL.md +976 -0
- package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
- package/skills/maestro-ralph-execute/SKILL.md +409 -0
- package/skills/maestro-ralph-v2/SKILL.md +1198 -0
- package/skills/maestro-roadmap/SKILL.md +157 -0
- package/skills/maestro-swarm-workflow/SKILL.md +272 -0
- package/skills/maestro-tools-execute/SKILL.md +143 -0
- package/skills/maestro-tools-register/SKILL.md +192 -0
- package/skills/maestro-ui-codify/SKILL.md +127 -0
- package/skills/maestro-universal-workflow/SKILL.md +622 -0
- package/skills/maestro-update/SKILL.md +156 -0
- package/skills/manage-codebase-rebuild/SKILL.md +111 -0
- package/skills/manage-drift-realign/SKILL.md +159 -0
- package/skills/manage-harvest/SKILL.md +121 -0
- package/skills/manage-issue/SKILL.md +88 -0
- package/skills/manage-issue-discover/SKILL.md +104 -0
- package/skills/manage-kg-extractors/SKILL.md +147 -0
- package/skills/manage-knowhow/SKILL.md +102 -0
- package/skills/manage-knowhow-capture/SKILL.md +109 -0
- package/skills/manage-knowledge-audit/SKILL.md +147 -0
- package/skills/manage-status/SKILL.md +80 -0
- package/skills/manage-wiki/SKILL.md +104 -0
- package/skills/odyssey-debug/SKILL.md +344 -0
- package/skills/odyssey-improve/SKILL.md +423 -0
- package/skills/odyssey-planex/SKILL.md +542 -0
- package/skills/odyssey-review-test-fix/SKILL.md +392 -0
- package/skills/odyssey-ui/SKILL.md +388 -0
- package/skills/prompt-generator/SKILL.md +470 -0
- package/skills/quality-auto-test/SKILL.md +168 -0
- package/skills/quality-debug/SKILL.md +176 -0
- package/skills/quality-refactor/SKILL.md +108 -0
- package/skills/quality-retrospective/SKILL.md +134 -0
- package/skills/quality-review/SKILL.md +169 -0
- package/skills/quality-sync/SKILL.md +90 -0
- package/skills/quality-test/SKILL.md +183 -0
- package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
- package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
- package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
- package/skills/scholar-citation-verify/SKILL.md +166 -0
- package/skills/scholar-citation-verify/references/api-usage.md +372 -0
- package/skills/scholar-citation-verify/references/common-errors.md +384 -0
- package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
- package/skills/scholar-experiment/SKILL.md +321 -0
- package/skills/scholar-ideation/SKILL.md +288 -0
- package/skills/scholar-latex-organizer/SKILL.md +186 -0
- package/skills/scholar-publish/SKILL.md +220 -0
- package/skills/scholar-rebuttal-pro/README.md +313 -0
- package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
- package/skills/scholar-review/SKILL.md +227 -0
- package/skills/scholar-thesis-docx/README.md +111 -0
- package/skills/scholar-thesis-docx/README_EN.md +108 -0
- package/skills/scholar-thesis-docx/SKILL.md +212 -0
- package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
- package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
- package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
- package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
- package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
- package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
- package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
- package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
- package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
- package/skills/scholar-writing/SKILL.md +296 -0
- package/skills/security-audit/SKILL.md +244 -0
- package/skills/skill-generator/SKILL.md +472 -0
- package/skills/skill-iter-tune/SKILL.md +382 -0
- package/skills/skill-simplify/SKILL.md +63 -0
- package/skills/skill-tuning/SKILL.md +174 -0
- package/skills/spec-add/SKILL.md +105 -0
- package/skills/spec-load/SKILL.md +98 -0
- package/skills/spec-remove/SKILL.md +74 -0
- package/skills/spec-setup/SKILL.md +75 -0
- package/skills/team-adversarial-swarm/SKILL.md +233 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
- package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
- package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
- package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
- package/skills/team-arch-opt/SKILL.md +158 -0
- package/skills/team-brainstorm/SKILL.md +171 -0
- package/skills/team-coordinate/SKILL.md +266 -0
- package/skills/team-designer/SKILL.md +160 -0
- package/skills/team-executor/SKILL.md +189 -0
- package/skills/team-frontend/SKILL.md +136 -0
- package/skills/team-frontend-debug/SKILL.md +198 -0
- package/skills/team-interactive-craft/SKILL.md +141 -0
- package/skills/team-issue/SKILL.md +171 -0
- package/skills/team-lifecycle-v4/SKILL.md +209 -0
- package/skills/team-motion-design/SKILL.md +142 -0
- package/skills/team-perf-opt/SKILL.md +175 -0
- package/skills/team-planex/SKILL.md +137 -0
- package/skills/team-quality-assurance/SKILL.md +147 -0
- package/skills/team-review/SKILL.md +147 -0
- package/skills/team-roadmap-dev/SKILL.md +169 -0
- package/skills/team-swarm/SKILL.md +178 -0
- package/skills/team-swarm/scripts/aco.py +473 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +92 -0
- package/skills/team-swarm/scripts/test_aco.py +475 -0
- package/skills/team-tech-debt/SKILL.md +128 -0
- package/skills/team-testing/SKILL.md +143 -0
- package/skills/team-ui-polish/SKILL.md +141 -0
- package/skills/team-uidesign/SKILL.md +144 -0
- package/skills/team-ultra-analyze/SKILL.md +173 -0
- package/skills/team-ux-improve/SKILL.md +151 -0
- package/skills/team-visual-a11y/SKILL.md +156 -0
- package/skills/workflow-skill-designer/SKILL.md +496 -0
- package/src/extension/index.ts +222 -0
- package/src/extension/schemas.ts +131 -0
- package/src/providers/cli-tools-loader.ts +74 -0
- package/src/providers/provider-registry.ts +130 -0
- package/src/tools/delegate.ts +85 -0
- package/src/tools/explore.ts +134 -0
- package/src/tools/moa.ts +213 -0
- package/src/tools/status.ts +99 -0
- package/src/tools/wait.ts +166 -0
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-ralph
|
|
3
|
+
description: "[LEGACY — prefer maestro-ralph-v2] Inline lifecycle orchestrator — state-based determination with main-session execution Arguments: <intent> [-y] | status | continue | --amend [change]"
|
|
4
|
+
allowed-tools: Read Write Edit Bash Glob Grep Skill AskUserQuestion
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<purpose>
|
|
8
|
+
Closed-loop decision engine: read project state → infer position → build adaptive chain → delegate execution.
|
|
9
|
+
Ralph builds/evaluates; ralph-execute runs steps. Session: `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`.
|
|
10
|
+
</purpose>
|
|
11
|
+
|
|
12
|
+
<deferred_reading>
|
|
13
|
+
- [ralph-amend-goal.md](~/.maestro/workflows/ralph-amend-goal.md) — read when `--amend` flag active for goal amendment flow
|
|
14
|
+
</deferred_reading>
|
|
15
|
+
|
|
16
|
+
<context>
|
|
17
|
+
$ARGUMENTS — intent text, flags, or keywords.
|
|
18
|
+
|
|
19
|
+
**Parse:**
|
|
20
|
+
```
|
|
21
|
+
-y flag → auto_confirm = true # 唯一来源:用户显式传入;ralph 不内部推断(invariant 14)
|
|
22
|
+
--roadmap → wants_roadmap = true (强制多发布 roadmap 路径;roadmap 默认 opt-in)
|
|
23
|
+
--amend / -a → amend_mode = true (running session 存在时触发目标修改流程)
|
|
24
|
+
.md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
|
|
25
|
+
Remaining → intent (amend_mode 时为 change_request)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**State files:**
|
|
29
|
+
- `.workflow/state.json` — artifact registry, milestones, phases
|
|
30
|
+
- `.workflow/roadmap.md` — milestone/phase structure
|
|
31
|
+
- `.workflow/.maestro/ralph-*/status.json` — ralph session state
|
|
32
|
+
</context>
|
|
33
|
+
|
|
34
|
+
<invariants>
|
|
35
|
+
1. **Ralph never executes steps** — only creates sessions and evaluates decisions
|
|
36
|
+
2. **Handoff via Skill("maestro-ralph-execute")** — 创建 session 后始终自动 handoff;decision 评估后始终 handoff
|
|
37
|
+
3. **Decision delegates read-only** — `maestro delegate --to <tool> --mode analysis`
|
|
38
|
+
4. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(详见 invariant 8)
|
|
39
|
+
5. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
|
|
40
|
+
6. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
|
|
41
|
+
7. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform claude --json --quiet` 预校验(project 覆盖 global,限定 `.claude/commands/` + `.claude/skills/`),命中即写绝对路径到 status.json;未命中标 `command_scope = "missing"`
|
|
42
|
+
8. **执行 step 加载契约** — 由 `maestro ralph next` CLI 在执行期完成:解析 frontmatter + `<required_reading>` + `<deferred_reading>`,自动读取 required 文件全文并拼入 prompt;缺失 required → 退出码 1(E007),pause session。ralph build 阶段只通过 `maestro ralph skills --platform claude` 校验路径存在性,不读 .md 内容
|
|
43
|
+
9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 输出提示词后继续 handoff,用户可在执行过程中随时输入 `/goal`
|
|
44
|
+
10. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
|
|
45
|
+
11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
|
|
46
|
+
12. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作。不得以 "效率" 或 "意图明确" 为由绕过。特别是 invariant 1(ralph 不执行 step)和 invariant 6(completion_confirmed 由 CLI 写入)不可隐性违反。
|
|
47
|
+
13. **Delegate fallback 必须标记** — A_DELEGATE_EVALUATE 解析 verdict 失败时 fallback 为 "fix",但 MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`,后续 step 继承 LOW CONFIDENCE 标记。
|
|
48
|
+
14. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定;ralph 不得内部推断。`session.auto_mode` 仅反映用户输入。
|
|
49
|
+
15. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有(`source=="ralph"` → `decomposition_owner="ralph"`;`source=="maestro"` → `"maestro"`)。contract 已存在时,后续 S_DECOMPOSE MUST 跳过 AskUserQuestion,仅做 shape 校验 + 缺省补齐;goal-audit 只更新 `task_decomposition[*].status/completion_confirmed/completed_at`,禁止改 `goal/done_when/boundary`。
|
|
50
|
+
16. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点;Pipeline 命令只拥有自身 artifact GATE(GATE 失败 → `maestro ralph complete <idx> --status BLOCKED|NEEDS_RETRY`,自身 GATE 全过 → DONE);Router 命令不得出现在 FSM step 内。
|
|
51
|
+
</invariants>
|
|
52
|
+
|
|
53
|
+
<state_machine>
|
|
54
|
+
|
|
55
|
+
<states>
|
|
56
|
+
S_PARSE_ROUTE — 解析参数、路由入口 PERSIST: —
|
|
57
|
+
S_STATUS — 显示 session 进度 PERSIST: —
|
|
58
|
+
S_CONTINUE — 恢复执行 PERSIST: —
|
|
59
|
+
S_RESOLVE_PHASE — 解析 phase + phase_is_new + D-007 milestone PERSIST: session.phase, session.phase_is_new, session.milestone
|
|
60
|
+
S_INFER — 基于已解析 phase 推断 lifecycle_position PERSIST: session.lifecycle_position, session.wants_roadmap
|
|
61
|
+
S_RESOLVE_SCOPE — 读 macro analyze conclusions.scope_verdict PERSIST: session.scope_verdict, session.analyze_macro_id
|
|
62
|
+
S_QUALITY_MODE — 决定质量管线模式 PERSIST: session.quality_mode
|
|
63
|
+
S_PLANNING_MODE — 决定统一/独立规划模式 PERSIST: session.planning_mode
|
|
64
|
+
S_DECOMPOSE — 边界澄清、写执行准则+子目标清单 PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
|
|
65
|
+
S_BUILD_CHAIN — 构建步骤链 PERSIST: session.steps[]
|
|
66
|
+
S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
|
|
67
|
+
S_CONFIRM — 用户确认 PERSIST: —
|
|
68
|
+
S_DISPATCH — 移交 maestro-ralph-execute PERSIST: —
|
|
69
|
+
S_DECISION_EVAL — 委托评估质量门 PERSIST: —
|
|
70
|
+
S_APPLY_VERDICT — 应用裁决 + 插入命令 PERSIST: session.steps[], session.passed_gates[]
|
|
71
|
+
S_AMEND_GOAL — 修改 running session 目标 PERSIST: session.task_decomposition, .boundary_contract, .goal_changelog, .steps[]
|
|
72
|
+
S_FALLBACK — 请求用户输入 PERSIST: —
|
|
73
|
+
</states>
|
|
74
|
+
|
|
75
|
+
<transitions>
|
|
76
|
+
|
|
77
|
+
S_PARSE_ROUTE:
|
|
78
|
+
→ S_STATUS WHEN: intent == "status"
|
|
79
|
+
→ S_CONTINUE WHEN: intent == "continue"
|
|
80
|
+
→ S_AMEND_GOAL WHEN: amend_mode == true AND running session exists
|
|
81
|
+
→ S_FALLBACK WHEN: amend_mode == true AND no running session DO: Display: "无运行中的 ralph 会话,--amend 需要活跃 session"
|
|
82
|
+
→ S_DECISION_EVAL WHEN: running session with decision step in "running" status
|
|
83
|
+
→ S_RESOLVE_PHASE WHEN: intent is non-empty ← phase 必须先于 position
|
|
84
|
+
→ S_FALLBACK WHEN: no intent AND no running session
|
|
85
|
+
|
|
86
|
+
S_STATUS:
|
|
87
|
+
→ END DO: A_SHOW_STATUS
|
|
88
|
+
|
|
89
|
+
S_CONTINUE:
|
|
90
|
+
→ S_DISPATCH WHEN: running session found
|
|
91
|
+
→ S_FALLBACK WHEN: no running session DO: display "无运行中的 ralph 会话"
|
|
92
|
+
|
|
93
|
+
S_RESOLVE_PHASE:
|
|
94
|
+
→ S_INFER WHEN: phase resolved or null DO: A_RESOLVE_PHASE
|
|
95
|
+
→ S_FALLBACK WHEN: ambiguous
|
|
96
|
+
GUARD: auto_confirm does NOT skip phase ambiguity
|
|
97
|
+
|
|
98
|
+
S_INFER:
|
|
99
|
+
→ S_RESOLVE_SCOPE WHEN: position resolved DO: A_INFER_POSITION
|
|
100
|
+
→ S_FALLBACK WHEN: cannot infer
|
|
101
|
+
|
|
102
|
+
S_RESOLVE_SCOPE:
|
|
103
|
+
→ S_QUALITY_MODE DO: A_RESOLVE_SCOPE_VERDICT
|
|
104
|
+
GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip (scope_verdict = null)
|
|
105
|
+
|
|
106
|
+
S_QUALITY_MODE:
|
|
107
|
+
→ S_PLANNING_MODE DO: A_DETERMINE_QUALITY_MODE
|
|
108
|
+
|
|
109
|
+
S_PLANNING_MODE:
|
|
110
|
+
→ S_DECOMPOSE DO: A_DETERMINE_PLANNING_MODE
|
|
111
|
+
GUARD: lifecycle_position ∈ {grill, brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
|
|
112
|
+
|
|
113
|
+
S_DECOMPOSE:
|
|
114
|
+
→ S_BUILD_CHAIN DO: A_DECOMPOSE_TASKS
|
|
115
|
+
GUARD: broad intent → MUST clarify boundary even if auto_confirm
|
|
116
|
+
GUARD: narrow intent → auto-derive, skip questions
|
|
117
|
+
GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip decomposition
|
|
118
|
+
|
|
119
|
+
S_BUILD_CHAIN:
|
|
120
|
+
→ S_CREATE_SESSION DO: A_BUILD_STEPS
|
|
121
|
+
|
|
122
|
+
S_CREATE_SESSION:
|
|
123
|
+
→ S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
|
|
124
|
+
→ S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
|
|
125
|
+
|
|
126
|
+
S_CONFIRM:
|
|
127
|
+
→ S_DISPATCH WHEN: user selects "Proceed"
|
|
128
|
+
→ S_BUILD_CHAIN WHEN: user selects "Edit"
|
|
129
|
+
→ END WHEN: user selects "Cancel"
|
|
130
|
+
|
|
131
|
+
S_DISPATCH:
|
|
132
|
+
→ END DO: Skill({ skill: "maestro-ralph-execute" })
|
|
133
|
+
|
|
134
|
+
S_DECISION_EVAL: (decision 节点 == `step.decision` 非空,下述 gate 名取自该字段)
|
|
135
|
+
→ S_APPLY_VERDICT WHEN: quality-gate (post-execute, post-business-test, post-review, post-test, post-frontend-verify)
|
|
136
|
+
DO: A_DELEGATE_EVALUATE
|
|
137
|
+
→ S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
|
|
138
|
+
DO: A_GOAL_AUDIT_EVALUATE
|
|
139
|
+
→ S_APPLY_VERDICT WHEN: scope-gate (post-analyze-scope)
|
|
140
|
+
DO: A_SCOPE_EVALUATE
|
|
141
|
+
→ S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
|
|
142
|
+
DO: A_STRUCTURAL_EVALUATE
|
|
143
|
+
→ S_APPLY_VERDICT WHEN: reground-gate (post-reground)
|
|
144
|
+
DO: A_REGROUND_EVALUATE
|
|
145
|
+
|
|
146
|
+
S_APPLY_VERDICT:
|
|
147
|
+
→ S_DISPATCH WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
|
|
148
|
+
→ S_DISPATCH WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
|
|
149
|
+
→ S_DISPATCH WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
|
|
150
|
+
→ END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT(尾部漂移熔断)
|
|
151
|
+
→ S_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
|
|
152
|
+
→ S_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
|
|
153
|
+
→ S_DISPATCH WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
|
|
154
|
+
→ S_DISPATCH WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
|
|
155
|
+
→ END WHEN: post-milestone + standard + no next milestone DO: mark completed
|
|
156
|
+
→ END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
|
|
157
|
+
→ END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
|
|
158
|
+
→ END WHEN: post-reground + drifted + confidence_score >= 60 DO: A_REGROUND_HALT
|
|
159
|
+
→ S_DISPATCH WHEN: post-reground + aligned DO: A_APPLY_PROCEED
|
|
160
|
+
→ S_DISPATCH WHEN: post-reground + drifted + confidence_score < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
|
|
161
|
+
GUARD: retry_count >= max_retries → force escalate
|
|
162
|
+
GUARD: confidence_score < 60 AND proceed → override to fix
|
|
163
|
+
GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
|
|
164
|
+
GUARD: auto_confirm → skip user prompt, apply adjusted verdict
|
|
165
|
+
GUARD: not auto_confirm → AskUserQuestion with override options
|
|
166
|
+
GUARD: post-reground + drifted + confidence_score >= 60 → A_REGROUND_HALT(漂移熔断为安全门,auto_confirm 不跳过)
|
|
167
|
+
|
|
168
|
+
S_AMEND_GOAL:
|
|
169
|
+
→ S_DISPATCH WHEN: change applied + user confirmed DO: A_AMEND_GOAL
|
|
170
|
+
→ END WHEN: user cancels
|
|
171
|
+
GUARD: RISK_LEVEL=high → auto_confirm 无效,必须 AskUserQuestion
|
|
172
|
+
|
|
173
|
+
S_FALLBACK:
|
|
174
|
+
→ S_PARSE_ROUTE WHEN: user provides input DO: AskUserQuestion
|
|
175
|
+
→ END WHEN: user cancels
|
|
176
|
+
|
|
177
|
+
</transitions>
|
|
178
|
+
|
|
179
|
+
<actions>
|
|
180
|
+
|
|
181
|
+
### A_SHOW_STATUS
|
|
182
|
+
|
|
183
|
+
1. Find latest ralph session (by created_at)
|
|
184
|
+
2. Display: Session, Status, Position, Progress, Current step
|
|
185
|
+
3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
|
|
186
|
+
4. If `task_decomposition` present (absent → skip):
|
|
187
|
+
```
|
|
188
|
+
Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
|
|
189
|
+
[x] G1 done_when={done_when} evidence={evidence} confirmed={completion_confirmed}
|
|
190
|
+
[ ] G2 done_when={done_when} evidence={evidence} confirmed=false ◀ unmet
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### A_RESOLVE_PHASE
|
|
194
|
+
|
|
195
|
+
前置于 A_INFER_POSITION。产出 `phase` + `phase_is_new` + `milestone`(D-007 反查)三元组。
|
|
196
|
+
|
|
197
|
+
**Priority:**
|
|
198
|
+
|
|
199
|
+
| Step | 行为 | phase_is_new |
|
|
200
|
+
|------|------|--------------|
|
|
201
|
+
| 1 | intent 匹配 `phase\s*(\d+)` → 取 state.json 对应 phase | false |
|
|
202
|
+
| 2 | intent 派生短语 → 在 `state.json.milestones[*].phase_slugs` / `artifacts[*].path` 查找 | false (匹配) / true (无匹配) |
|
|
203
|
+
| 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
|
|
204
|
+
| 4 | 仍无 → state.json 首个 incomplete phase | false |
|
|
205
|
+
| 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
|
|
206
|
+
| 6 | 仍模糊 → `AskUserQuestion` | 由用户回答确定 |
|
|
207
|
+
|
|
208
|
+
**D-007 Phase→Milestone 反查**(数字 phase 已解析时):
|
|
209
|
+
```
|
|
210
|
+
resolve_milestone(phase_number):
|
|
211
|
+
for ms in state.json.milestones:
|
|
212
|
+
if str(phase_number) in ms.phase_slugs: return ms.id
|
|
213
|
+
return state.json.current_milestone # fallback
|
|
214
|
+
```
|
|
215
|
+
写入 `session.milestone`;禁止直接使用 `current_milestone` 当做 phase 所属 milestone。
|
|
216
|
+
|
|
217
|
+
**写入 session**: `phase`, `phase_is_new`, `milestone`。
|
|
218
|
+
|
|
219
|
+
**新派生 phase 时 milestone 处理**:
|
|
220
|
+
- state.json 当前 milestone 仍 active → 沿用,新增 phase
|
|
221
|
+
- intent 派生新 milestone 名 → 写入 session 仅作标签;`state.json.milestones` 由 `maestro-roadmap` / `maestro-milestone-release` 创建
|
|
222
|
+
|
|
223
|
+
### A_INFER_POSITION
|
|
224
|
+
|
|
225
|
+
**Intent-based overrides** (按顺序匹配,先命中先用):
|
|
226
|
+
|
|
227
|
+
| Pattern | Position |
|
|
228
|
+
|---------|----------|
|
|
229
|
+
| 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时透传 `-y`,grill 以 Auto mode 代码代答,不跳过**) |
|
|
230
|
+
| brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
|
|
231
|
+
| blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
|
|
232
|
+
| broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
|
|
233
|
+
|
|
234
|
+
**Roadmap opt-in detection** (设 `session.wants_roadmap`,缺省 `false`):
|
|
235
|
+
```
|
|
236
|
+
wants_roadmap = (--roadmap flag)
|
|
237
|
+
OR (intent 含多发布信号: 多发布|多版本|分阶段交付|按里程碑发布|v1.*v2|multi-release|roadmap)
|
|
238
|
+
OR (.workflow/roadmap.md 已存在) ← 向后兼容:既有 roadmap 项目行为不变
|
|
239
|
+
```
|
|
240
|
+
默认 `false` → large 项目走单一多波次 `plan --from analyze`,不引入 roadmap 横切层;roadmap 仅多发布场景 opt-in。
|
|
241
|
+
|
|
242
|
+
**Bootstrap detection:**
|
|
243
|
+
|
|
244
|
+
| Condition | Position |
|
|
245
|
+
|-----------|----------|
|
|
246
|
+
| No `.workflow/` + no source files | `brainstorm` |
|
|
247
|
+
| No `.workflow/` + has source files | `init` |
|
|
248
|
+
| Has `.workflow/` but no state.json | `init` |
|
|
249
|
+
| Has state.json | → phase-aware artifact inference |
|
|
250
|
+
|
|
251
|
+
**Phase-aware artifact inference** (使用 A_RESOLVE_PHASE 已写入的 `session.phase` + `session.phase_is_new`):
|
|
252
|
+
|
|
253
|
+
| Condition | Position |
|
|
254
|
+
|-----------|----------|
|
|
255
|
+
| `phase_is_new == true` (新 phase) | `analyze` |
|
|
256
|
+
| no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` if `wants_roadmap` else `plan` (--from analyze) |
|
|
257
|
+
| no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
|
|
258
|
+
| `phase == null` (grill/brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
|
|
259
|
+
| phase 已存在 + 无任何 artifact | `analyze` |
|
|
260
|
+
| phase 已存在 + 最新 artifact = analyze | `plan` |
|
|
261
|
+
| phase 已存在 + 最新 artifact = plan | `execute` |
|
|
262
|
+
| phase 已存在 + 最新 artifact = execute | → refine from post-execute results |
|
|
263
|
+
|
|
264
|
+
**关键不变量**:artifact 过滤按 `session.phase`,不读 `state.json.current_phase`。`phase_is_new` → 直接 `analyze`。
|
|
265
|
+
|
|
266
|
+
### A_RESOLVE_SCOPE_VERDICT
|
|
267
|
+
|
|
268
|
+
仅当 `lifecycle_position ∈ {analyze-macro, roadmap, plan}` 且存在最新 analyze artifact 时执行。
|
|
269
|
+
|
|
270
|
+
1. 定位最新 macro analyze artifact(`type=="analyze"` 且 `scope=="macro"`,按 created_at DESC)→ 记 `session.analyze_macro_id = ANL-xxx`
|
|
271
|
+
2. 读 `{artifact_path}/conclusions.json` 的 `scope_verdict` 字段(`large | medium | small`)
|
|
272
|
+
3. 写入 `session.scope_verdict`;缺失时设 `unknown`
|
|
273
|
+
4. 路由建议(A_BUILD_STEPS 据此决定是否插入 roadmap、plan 是否走 `--from`):
|
|
274
|
+
|
|
275
|
+
| scope_verdict | 链路 |
|
|
276
|
+
|---------------|------|
|
|
277
|
+
| `large` + `wants_roadmap` | analyze-macro → roadmap → analyze → plan → execute → ...(多发布 opt-in) |
|
|
278
|
+
| `large`(默认)/ `medium` / `small` | analyze-macro → plan --from analyze:{ANL_ID} → execute → ...(跳过 roadmap + analyze-phase;单一多波次计划) |
|
|
279
|
+
| `unknown` | 默认走 standalone(plan --from analyze)路径,post-analyze-scope 决策节点再纠正 |
|
|
280
|
+
|
|
281
|
+
**Refine from post-execute results:**
|
|
282
|
+
|
|
283
|
+
在 execute artifact 的 scratch dir 中检查结果文件(verification.json 由 execute 内置 gate 产出):
|
|
284
|
+
|
|
285
|
+
| Condition | Position |
|
|
286
|
+
|-----------|----------|
|
|
287
|
+
| 无 verification.json 或 passed==false 或 gaps[] | `execute` (触发 post-execute fix loop) |
|
|
288
|
+
| passed==true, no review.json | `business-test` |
|
|
289
|
+
| review.json: verdict=="BLOCK" | `review-failed` |
|
|
290
|
+
| review.json: verdict!="BLOCK" | `test` |
|
|
291
|
+
| uat.md: all passed + `session.milestone` 存在 | `milestone-audit` |
|
|
292
|
+
| uat.md: all passed + `session.milestone=null` (standalone) | 标记 session completed(无 milestone 可审计) |
|
|
293
|
+
| uat.md: has failures | `test-failed` |
|
|
294
|
+
|
|
295
|
+
### A_DETERMINE_QUALITY_MODE
|
|
296
|
+
|
|
297
|
+
决定下游质量管线长度。读 `session.quality_mode_override`(CLI 标志 `--quality`),无则按规则推断:
|
|
298
|
+
|
|
299
|
+
| Condition | Mode | Pipeline (execute 之后) |
|
|
300
|
+
|-----------|------|-------------------------|
|
|
301
|
+
| Has `specs/REQ-*.md` + 当前 phase 业务范围明确 | `full` | business-test → review → test-gen → test |
|
|
302
|
+
| Default | `standard` | review → test-gen (当 coverage<80%) → test |
|
|
303
|
+
| `--quality quick` | `quick` | review --tier quick |
|
|
304
|
+
|
|
305
|
+
写入 `session.quality_mode`。A_BUILD_STEPS 据此过滤 stage(见下)。
|
|
306
|
+
|
|
307
|
+
### A_DETERMINE_PLANNING_MODE
|
|
308
|
+
|
|
309
|
+
决定里程碑的规划粒度:一次性规划整个里程碑(统一)还是逐 phase 走完整生命周期(独立)。
|
|
310
|
+
|
|
311
|
+
**Auto-resolve rules (按优先级):**
|
|
312
|
+
|
|
313
|
+
| Condition | Mode | Reason |
|
|
314
|
+
|-----------|------|--------|
|
|
315
|
+
| lifecycle_position ∈ {grill, brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
|
|
316
|
+
| `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
|
|
317
|
+
| intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
|
|
318
|
+
| milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
|
|
319
|
+
| milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
|
|
320
|
+
| milestone 含多个 phase + 非 `auto_confirm` | → AskUserQuestion | 征询用户选择 |
|
|
321
|
+
|
|
322
|
+
**AskUserQuestion** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
question: "当前里程碑含 {N} 个 phase,选择规划模式?"
|
|
326
|
+
options:
|
|
327
|
+
- label: "统一规划 (Recommended)"
|
|
328
|
+
description: "一次性分析+规划整个里程碑所有 phase,analyze/plan 走里程碑级,适合 phase 间关联紧密"
|
|
329
|
+
- label: "独立规划"
|
|
330
|
+
description: "逐个 phase 走完整生命周期(analyze→plan→execute→...),适合 phase 间独立性高"
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
写入 `session.planning_mode`(`"unified"` 或 `"independent"`)。`A_BUILD_STEPS` 据此决定 skill args 是否携带 `{phase}` 占位符。
|
|
334
|
+
|
|
335
|
+
### A_DECOMPOSE_TASKS
|
|
336
|
+
|
|
337
|
+
Runs once before chain build; additive to status.json. 设 `session.decomposition_owner = "ralph"`。
|
|
338
|
+
|
|
339
|
+
**0. Ownership guard** (invariant 15): 若 `session.boundary_contract` 或 `session.task_decomposition` 已非空(上游 maestro 已写入,`decomposition_owner == "maestro"`)→ MUST 跳过下述提问,仅做 shape 校验 + 缺省字段补齐,直接进入步骤 6。
|
|
340
|
+
|
|
341
|
+
**1. Classify intent breadth:**
|
|
342
|
+
|
|
343
|
+
| Pattern | Breadth | Clarify? |
|
|
344
|
+
|---------|---------|----------|
|
|
345
|
+
| 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp | broad | MUST (ignores auto_confirm) |
|
|
346
|
+
| named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
|
|
347
|
+
| otherwise | medium | clarify unless auto_confirm |
|
|
348
|
+
|
|
349
|
+
**2. Clarify boundary** (broad/medium) — `AskUserQuestion`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
|
|
350
|
+
|
|
351
|
+
| Round | Question | Drives |
|
|
352
|
+
|-------|----------|--------|
|
|
353
|
+
| Scope | 哪些目录/文件/层在范围内?明确排除什么? | boundary_contract.in_scope / out_of_scope |
|
|
354
|
+
| Constraints | 必须向后兼容?公共 API 冻结?行为/性能预算?测试门槛? | boundary_contract.constraints + execution_criteria |
|
|
355
|
+
| Done | 什么可观测结果算"完成"?(如:测试全绿 + 行为零变更 + X 指标) | boundary_contract.definition_of_done |
|
|
356
|
+
|
|
357
|
+
narrow → derive defaults from intent + codebase, skip questions.
|
|
358
|
+
|
|
359
|
+
**3. Derive `execution_criteria`**: backward-compat、scope-freeze、test/coverage bar、fix-don't-hide、incremental commit。
|
|
360
|
+
|
|
361
|
+
**4. Derive `task_decomposition`** (子目标清单 — outcome-oriented, NOT lifecycle stages). Each entry:
|
|
362
|
+
```json
|
|
363
|
+
{ "id": "G1", "goal": "<deliverable>", "boundary": "<in/out note>",
|
|
364
|
+
"done_when": "<objectively checkable condition>",
|
|
365
|
+
"evidence": "verification.json|review.json|uat.md|e2e-results.json|<test path>",
|
|
366
|
+
"lifecycle": ["analyze","execute"], "status": "pending" }
|
|
367
|
+
```
|
|
368
|
+
`done_when` 必须客观可验证,且引用 ralph 已产出的 artifact;`lifecycle` 字段映射到产出 evidence 的生命周期 stage。涉及前端可用性的子目标,`done_when` 应引用 `e2e-results.json`(frontend-verify 门产出),不得仅以后端 API/build 证据判定可用。
|
|
369
|
+
|
|
370
|
+
**5. Persist** (additive): `boundary_contract`, `execution_criteria`, `task_decomposition`。每个 sub-goal 含 `status: "pending"` + `completion_confirmed: false`。
|
|
371
|
+
|
|
372
|
+
**6. Stage** the Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
|
|
373
|
+
|
|
374
|
+
### A_BUILD_STEPS
|
|
375
|
+
|
|
376
|
+
Generate steps from `session.lifecycle_position` to `milestone-complete`(`session.milestone` 存在时)或最后一个质量门(standalone 时)。
|
|
377
|
+
|
|
378
|
+
| Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
|
|
379
|
+
|-------|---------------------|-----------------|----------------|--------------|
|
|
380
|
+
| grill | `maestro-grill "{intent}"` | *(same)* | — | all (**auto_confirm → 透传 `-y` 到 grill args,不删除 stage**) |
|
|
381
|
+
| brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
|
|
382
|
+
| blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
|
|
383
|
+
| init | `maestro-init` | *(same)* | — | all |
|
|
384
|
+
| spec-setup | `spec-setup` | *(same)* | — | all (**仅当 `.workflow/specs/` 不存在时插入**) |
|
|
385
|
+
| analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
|
|
386
|
+
| roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
|
|
387
|
+
| analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
|
|
388
|
+
| plan | `maestro-plan {phase}` *(scope=phase)* / `maestro-plan --from analyze:{analyze_macro_id}` *(scope=standalone)* / `maestro-plan --from blueprint:{blueprint_id}` *(scope=standalone)* | `maestro-plan` | — | all |
|
|
389
|
+
| execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
|
|
390
|
+
| business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
|
|
391
|
+
| review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
|
|
392
|
+
| test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
|
|
393
|
+
| test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
|
|
394
|
+
| frontend-verify | `quality-test {phase} --frontend-verify` | `quality-test --frontend-verify` | `post-frontend-verify` | all(**仅当 phase 交付 UI 时插入**:检出 `dashboard/` 或 UI 关键词 `landing\|page\|dashboard\|frontend\|UI\|component\|界面`) |
|
|
395
|
+
| milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
|
|
396
|
+
| goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
|
|
397
|
+
| milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
|
|
398
|
+
|
|
399
|
+
> 所有执行 stage 统一通过 `maestro ralph next` CLI 加载 + 内联执行;decision 节点单独作为独立 step 插入(见规则 4)。
|
|
400
|
+
|
|
401
|
+
**Build rules (按顺序应用):**
|
|
402
|
+
|
|
403
|
+
0. **planning_mode 选列**:`unified` → Skill (unified) 列;`independent` → Skill (independent) 列
|
|
404
|
+
0.5. **specs 预检**:当 `lifecycle_position ∉ {grill, brainstorm, blueprint, init}` 且 `.workflow/specs/` 目录不存在时,在链路最前面插入 `spec-setup` 步骤(stage=`spec-setup`,无 decision)。确保下游 analyze/plan/execute 可获得项目约束规则注入
|
|
405
|
+
1. **起点**:从 `session.lifecycle_position` 开始
|
|
406
|
+
2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
|
|
407
|
+
3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
|
|
408
|
+
3.5. **grill auto_confirm 透传**:`auto_confirm == true` 时为 `grill` step args 追加 `-y`(grill 自身 Auto mode 用代码代答,见 maestro-grill `<context>` Mode selection);保留 `grill` stage 与 brainstorm 的 `--from grill:*`(grill 仍产出 grill-report/terminology/context-package)
|
|
409
|
+
3.6. **frontend-verify UI 门控**:仅当当前 phase 交付前端(检出 `dashboard/` 目录,或 phase 目标/计划含 UI 关键词 `landing|page|dashboard|frontend|UI|component|界面`)时保留 `frontend-verify` stage + `post-frontend-verify` decision;纯后端 phase 删除该 stage
|
|
410
|
+
4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
|
|
411
|
+
5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(execute/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
|
|
412
|
+
5.5. **re-grounding 插入**:WHEN `task_decomposition` 存在 AND 执行 step(不含 decision)≥3
|
|
413
|
+
- 从第 3 个执行 step 起每隔 3 个插入 `{ decision: "post-reground", retry_count: 0, max_retries: 0, command_scope: null, command_path: null }`
|
|
414
|
+
- 不在最后一个执行 step 后插入(由 goal-audit 覆盖)
|
|
415
|
+
- 不与已有 quality-gate decision 节点相邻(顺延到下一个 3-step 边界)
|
|
416
|
+
- fix-loop 动态插入的 step **纳入**计数(从插入点起重新计算 3-step 间隔)
|
|
417
|
+
6. **终点硬约束**:`session.milestone` 存在时 chain 以 `milestone-complete` 结尾;`session.milestone=null`(standalone)时跳过 `milestone-audit` + `milestone-complete` stage,chain 以最后一个质量门 stage 结尾
|
|
418
|
+
7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
|
|
419
|
+
8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
|
|
420
|
+
9. **command_path 解析**(每个执行 step,decision 节点跳过):
|
|
421
|
+
- 取 skill 名(args 前的第一个 token)
|
|
422
|
+
- **预校验通过 `Bash("maestro ralph skills --platform claude --json --quiet")`** 一次性拉取 claude 平台可用 commands + skills(global + project,project 覆盖 global),匹配 skill 名得到:
|
|
423
|
+
- 命中 commands → `command_scope = "global" | "project"`,`command_path = <绝对路径>`
|
|
424
|
+
- 命中 skills → 同上(type=skill)
|
|
425
|
+
- 未命中 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
|
|
426
|
+
- **不在 build 阶段读取 .md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
|
|
427
|
+
10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `completion_summary: null`, `completion_decisions: null`, `completion_caveats: null`, `completion_deferred: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
|
|
428
|
+
11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
|
|
429
|
+
- `scope_verdict == large` **且** `wants_roadmap` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
|
|
430
|
+
- 其余(`medium` / `small`,或 `large` 但非 `wants_roadmap`)→ 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
|
|
431
|
+
- `scope_verdict == unknown` → 默认 standalone(非 roadmap)路径;由 `post-analyze-scope` 决策节点在 macro analyze 完成后纠正(A_APPLY_SCOPE_VERDICT)
|
|
432
|
+
12. **--from 自动注入**:
|
|
433
|
+
- `analyze_macro_id` 存在且当前 step 是 `roadmap` → args 改为 `--from analyze:{analyze_macro_id}`
|
|
434
|
+
- `analyze_macro_id` 存在且当前 `plan` step 处于 standalone 列(即非 wants_roadmap 路径:`medium`/`small`,或 `large` 但非 `wants_roadmap`)→ args 改为 `--from analyze:{analyze_macro_id}`
|
|
435
|
+
- `blueprint_id` 存在 → 当前 step 是 `plan` → args 改为 `--from blueprint:{blueprint_id}`(优先级低于 phase 数字参数)
|
|
436
|
+
- **phase-level deferred chaining**(独立模式,step 含 `{phase}` 占位符):build 阶段前序 artifact 尚未产出,由 A_RESOLVE_ARGS(ralph-execute)运行时从 state.json 查找同 phase+milestone 最新 completed artifact 注入:
|
|
437
|
+
- `plan` step → `--from analyze:{phase_analyze_id}`,写 `source_artifact_ref`
|
|
438
|
+
- `execute` step → `--dir {plan_path}`(现有逻辑),写 `source_artifact_ref = "plan:{id}"`
|
|
439
|
+
- 写入 `step.source_artifact_ref` 以便审计
|
|
440
|
+
13. **D-007 Milestone-ref 标注**:每个含 `{phase}` 占位符的 step → `step.milestone_id = session.milestone`(由 A_RESOLVE_PHASE 反查得出),禁止读 `current_milestone`
|
|
441
|
+
14. **动态插入步骤**(A_APPLY_*)同样应用规则 7-13
|
|
442
|
+
|
|
443
|
+
### A_CREATE_SESSION
|
|
444
|
+
|
|
445
|
+
1. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
|
|
446
|
+
2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
|
|
447
|
+
3. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
|
|
448
|
+
4. **Goal Prompt 显示(强制)**:`task_decomposition` 存在时,chain overview 之后**必须逐字显示** Goal Prompt block(Appendix),不得省略或摘要。显示后继续 handoff,不阻塞
|
|
449
|
+
|
|
450
|
+
### A_DELEGATE_EVALUATE
|
|
451
|
+
|
|
452
|
+
1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
|
|
453
|
+
2. Parse decision metadata: `{ decision, retry_count, max_retries }`
|
|
454
|
+
3. Map result files:
|
|
455
|
+
| Decision | Files |
|
|
456
|
+
|----------|-------|
|
|
457
|
+
| post-execute | verification.json |
|
|
458
|
+
| post-business-test | .tests/auto-test/report.json |
|
|
459
|
+
| post-review | review.json |
|
|
460
|
+
| post-test | uat.md, .tests/test-results.json |
|
|
461
|
+
| post-frontend-verify | e2e-results.json |
|
|
462
|
+
4. Check artifact for confidence section → include as signal
|
|
463
|
+
5. Execute delegate (run_in_background, STOP, wait for callback):
|
|
464
|
+
```
|
|
465
|
+
maestro delegate "PURPOSE: 评估 {decision} 质量门结果
|
|
466
|
+
TASK: 读取结果 | 分析状态 | 评估严重性 | 给出建议
|
|
467
|
+
EXPECTED: ---VERDICT--- STATUS(PASS|FAIL|PARTIAL|BLOCKED)/REASON/GAP_SUMMARY/CONFIDENCE(high|medium|low)/CONFIDENCE_SCORE(0-100)/WEAKEST_DIMENSION ---END---
|
|
468
|
+
CONSTRAINTS: 只评估 | 置信度<60% 倾向 fix | retry {n}/{max} 达上限必须 escalate"
|
|
469
|
+
--to {session.cli_tool} --mode analysis
|
|
470
|
+
```
|
|
471
|
+
6. On callback: parse verdict block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; any other value → parse failure. If parse fails → fallback STATUS="fix", BUT MUST set `parse_failed: true` and `confidence_score: 0` in decision log (invariant 13). Subsequent steps inherit LOW CONFIDENCE flag.
|
|
472
|
+
7. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
|
|
473
|
+
8. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
|
|
474
|
+
```json
|
|
475
|
+
{ "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph",
|
|
476
|
+
"node_id": "{step.decision}", "type": "quality-gate",
|
|
477
|
+
"verdict": "{adjusted_verdict}", "confidence_score": {N},
|
|
478
|
+
"parse_failed": false,
|
|
479
|
+
"close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### A_STRUCTURAL_EVALUATE
|
|
483
|
+
|
|
484
|
+
**post-milestone:**
|
|
485
|
+
1. Read state.json → resolve completed milestone object
|
|
486
|
+
2. Determine milestone type: `milestone_obj.type` (default `"standard"` if missing)
|
|
487
|
+
3. **Standard milestone** (`type != "adhoc"`): next milestone exists? → insert lifecycle steps / complete
|
|
488
|
+
4. **Adhoc milestone** (`type == "adhoc"`): always END — adhoc milestones are self-contained, no successor to advance to. Set `current_milestone = null`.
|
|
489
|
+
|
|
490
|
+
**post-debug-escalate:** Always STOP → set paused, display "请人工介入"
|
|
491
|
+
|
|
492
|
+
### A_SCOPE_EVALUATE
|
|
493
|
+
|
|
494
|
+
仅由 `post-analyze-scope` 决策节点触发;macro analyze 完成后读 `conclusions.json.scope_verdict` 决定下游链路。
|
|
495
|
+
|
|
496
|
+
1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path = {artifact_path}/conclusions.json`
|
|
497
|
+
2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
|
|
498
|
+
3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
|
|
499
|
+
4. Append `{session_dir}/decisions.ndjson`:
|
|
500
|
+
```json
|
|
501
|
+
{ "id": "DEC-{timestamp}", "type": "scope-gate",
|
|
502
|
+
"source": "ralph", "node_id": "post-analyze-scope",
|
|
503
|
+
"verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }
|
|
504
|
+
```
|
|
505
|
+
5. → A_APPLY_SCOPE_VERDICT
|
|
506
|
+
|
|
507
|
+
### A_GOAL_AUDIT_EVALUATE
|
|
508
|
+
|
|
509
|
+
Runs only when `task_decomposition` present.
|
|
510
|
+
|
|
511
|
+
1. Read `session.task_decomposition` from status.json
|
|
512
|
+
2. For each sub-goal `status != "done"`: resolve `evidence` artifact under current phase scratch dir
|
|
513
|
+
3. Delegate read-only audit (run_in_background, STOP, wait):
|
|
514
|
+
```
|
|
515
|
+
maestro delegate "PURPOSE: 审计未完成子目标,判定 met / unmet
|
|
516
|
+
TASK:
|
|
517
|
+
1. 读取 status.json.task_decomposition 中 status!=done 的子目标
|
|
518
|
+
2. 打开 evidence 产物,对照 done_when 严格判定
|
|
519
|
+
3. 输出 met / unmet,unmet 给出 gap + target_phase
|
|
520
|
+
4. 对照 intent + definition_of_done 判定累积产出是否仍服务原始意图(意图保真检查)
|
|
521
|
+
CONTEXT:
|
|
522
|
+
status.json = {session_dir}/status.json
|
|
523
|
+
intent = {session.intent}
|
|
524
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
525
|
+
evidence = {evidence artifacts}
|
|
526
|
+
execution_criteria = {execution_criteria}
|
|
527
|
+
boundary_contract = {boundary_contract}
|
|
528
|
+
EXPECTED:
|
|
529
|
+
---VERDICT---
|
|
530
|
+
STATUS=all_met|has_unmet
|
|
531
|
+
INTENT_ALIGNED=true|false
|
|
532
|
+
UNMET=[{id:G2,gap:'...',target_phase:execute}, ...]
|
|
533
|
+
CONFIDENCE_SCORE=0-100
|
|
534
|
+
---END---
|
|
535
|
+
CONSTRAINTS:
|
|
536
|
+
- 只评估,不修改文件
|
|
537
|
+
- 严格按 done_when 判定;evidence 缺失 → unmet
|
|
538
|
+
- 不得建议超出 boundary_contract 的修改
|
|
539
|
+
"
|
|
540
|
+
--to {session.cli_tool} --mode analysis
|
|
541
|
+
```
|
|
542
|
+
4. On callback: 对每个 met 子目标,set `task_decomposition[i].status="done"` + `completion_confirmed=true` + `completed_at=now`
|
|
543
|
+
5. Append `{session_dir}/decisions.ndjson` with `"type": "goal-gate"`, `unmet_count`, `unmet_ids`
|
|
544
|
+
6. Verdict routing:
|
|
545
|
+
- `all_met` + `INTENT_ALIGNED=true` → A_APPLY_GOAL_DONE
|
|
546
|
+
- `all_met` + `INTENT_ALIGNED=false` → A_REGROUND_HALT(尾部漂移熔断,auto_confirm 不跳过)
|
|
547
|
+
- `has_unmet` → A_APPLY_GOAL_FIX
|
|
548
|
+
GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
|
|
549
|
+
|
|
550
|
+
### A_REGROUND_EVALUATE
|
|
551
|
+
|
|
552
|
+
GUARD: `task_decomposition` 存在(周期触发,见 build rule 5.5)
|
|
553
|
+
|
|
554
|
+
1. Read status.json:
|
|
555
|
+
- `session.intent`, `session.boundary_contract`
|
|
556
|
+
- `steps[]` WHERE `status=="completed"` → 取 `completion_evidence`, `completion_summary`, `completion_decisions`, `completion_caveats`
|
|
557
|
+
- `task_decomposition[]` WHERE `status=="done"` → 取 `goal`, `done_when`
|
|
558
|
+
2. Delegate read-only audit (run_in_background, STOP, wait):
|
|
559
|
+
```
|
|
560
|
+
maestro delegate "PURPOSE: 意图保真检查 — 对照 intent 验证累积执行是否漂移
|
|
561
|
+
TASK:
|
|
562
|
+
1. 读取 intent + boundary_contract.definition_of_done
|
|
563
|
+
2. 读取已完成 steps 的 completion_evidence + 已 done 子目标 done_when
|
|
564
|
+
3. 判定累积产出是否仍服务 intent;是否有 step 产出超出 in_scope 或触碰 out_of_scope
|
|
565
|
+
4. 输出 aligned / drifted,drifted 给出 drift_description + corrective_action
|
|
566
|
+
CONTEXT:
|
|
567
|
+
intent = {session.intent}
|
|
568
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
569
|
+
in_scope = {boundary_contract.in_scope}
|
|
570
|
+
out_of_scope = {boundary_contract.out_of_scope}
|
|
571
|
+
completed_steps = [{index, skill, stage, completion_evidence, completion_summary, completion_decisions, completion_caveats}, ...]
|
|
572
|
+
done_goals = [{id, goal, done_when}, ...]
|
|
573
|
+
accumulated_deferred = [{from_step, item}, ...]
|
|
574
|
+
goal_changelog = {session.goal_changelog ?? []}
|
|
575
|
+
EXPECTED:
|
|
576
|
+
---VERDICT---
|
|
577
|
+
STATUS=aligned|drifted
|
|
578
|
+
DRIFT_DESCRIPTION=<空或具体描述>
|
|
579
|
+
CORRECTIVE_ACTION=<空或建议>
|
|
580
|
+
CONFIDENCE_SCORE=0-100
|
|
581
|
+
---END---
|
|
582
|
+
CONSTRAINTS:
|
|
583
|
+
- 只评估,不修改文件
|
|
584
|
+
- aligned 阈值:≥80% 已完成产出直接服务 intent
|
|
585
|
+
- 单个 step 触碰 out_of_scope → 直接判 drifted
|
|
586
|
+
- goal_changelog 存在 → 以最新 after.goals 为基准"
|
|
587
|
+
--to {session.cli_tool} --mode analysis
|
|
588
|
+
```
|
|
589
|
+
3. On callback: parse verdict
|
|
590
|
+
4. Append `{session_dir}/decisions.ndjson`:`{ "id": "DEC-{ts}", "type": "reground-gate", "source": "ralph", "node_id": "post-reground", "verdict": "{aligned|drifted}", "confidence_score": {N}, "drift_description": "...", "corrective_action": "..." }`
|
|
591
|
+
5. Verdict routing:`aligned` → A_APPLY_PROCEED;`drifted` + `confidence_score >= 60` → A_REGROUND_HALT;`drifted` + `confidence_score < 60` → A_APPLY_PROCEED(标 LOW CONFIDENCE)
|
|
592
|
+
|
|
593
|
+
### A_REGROUND_HALT
|
|
594
|
+
|
|
595
|
+
漂移熔断(安全门,auto_confirm 不跳过)。
|
|
596
|
+
|
|
597
|
+
1. Set `session.status = "paused"`,write status.json
|
|
598
|
+
2. Display:
|
|
599
|
+
```
|
|
600
|
+
⚠️ Re-grounding 检测失败 — 执行已偏离 intent。
|
|
601
|
+
Intent: {session.intent}
|
|
602
|
+
Drift: {drift_description}
|
|
603
|
+
建议回归: {corrective_action}
|
|
604
|
+
选项:1) /maestro-ralph continue 忽略漂移继续 2) 手动修正后 continue 3) /maestro-ralph status 查看后决定
|
|
605
|
+
```
|
|
606
|
+
3. GUARD: auto_confirm 对本动作无效——漂移熔断不可自动跳过
|
|
607
|
+
|
|
608
|
+
### A_APPLY_PROCEED
|
|
609
|
+
|
|
610
|
+
1. Mark decision completed, write status.json
|
|
611
|
+
2. Display: ◆ Decision: {type} → proceed ({reason})
|
|
612
|
+
|
|
613
|
+
### A_APPLY_FIX
|
|
614
|
+
|
|
615
|
+
1. Insert fix-loop commands after current step (see Appendix: Fix-Loop Templates)
|
|
616
|
+
2. Reindex steps, increment retry_count, write status.json
|
|
617
|
+
3. Display: ◆ Decision: {type} → fix, +{N} commands inserted
|
|
618
|
+
|
|
619
|
+
### A_APPLY_ESCALATE
|
|
620
|
+
|
|
621
|
+
1. Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]`
|
|
622
|
+
2. Increment retry_count, reindex, write status.json
|
|
623
|
+
|
|
624
|
+
### A_APPLY_SCOPE_VERDICT
|
|
625
|
+
|
|
626
|
+
由 `post-analyze-scope` 触发,依据 `session.scope_verdict` 重塑下游链路。
|
|
627
|
+
|
|
628
|
+
1. 读 `session.scope_verdict` + `session.wants_roadmap`
|
|
629
|
+
2. 路径 A(`large` 且 `wants_roadmap`):保持当前链(roadmap+analyze);为后续 `roadmap` step 注入 `--from analyze:{analyze_macro_id}`;为后续 `plan` step 选 phase 列;继续推进
|
|
630
|
+
3. 路径 B(`medium` / `small`,或 `large` 但非 `wants_roadmap`):
|
|
631
|
+
- 删除 `goal-audit` 之前所有未完成的 `roadmap` + `analyze` (phase) step
|
|
632
|
+
- 把下一个未完成的 `plan` step 改为 `maestro-plan --from analyze:{analyze_macro_id}`,去掉 `{phase}`,`source_artifact_ref = analyze:{analyze_macro_id}`
|
|
633
|
+
- 后续 `execute` 等沿用同一 standalone scope(不带 `{phase}`,由 plan 写出的 task 列表驱动)
|
|
634
|
+
4. 路径 C(`unknown`):
|
|
635
|
+
- 非 auto_confirm → AskUserQuestion 二选一(roadmap 多发布 / 单一计划);auto_confirm → 默认路径 B(单一计划,不引入 roadmap)
|
|
636
|
+
5. Reindex steps,标 decision completed,write status.json
|
|
637
|
+
6. Display: ◆ Scope verdict: {verdict} → {kept|collapsed to standalone via analyze:{ANL_ID}}
|
|
638
|
+
|
|
639
|
+
### A_APPLY_GOAL_FIX
|
|
640
|
+
|
|
641
|
+
1. 对每个 unmet 子目标 `G{n}`(按 `target_phase` 分组去重):在 `goal-audit` 节点前插入 scoped mini-loop(见 Appendix: Fix-Loop Templates → post-goal-audit),每条插入 step `goal_ref: "G{n}"`,按 A_BUILD_STEPS 规则 9 解析 `command_path`
|
|
642
|
+
2. 重新追加 `decision:post-goal-audit {retry+1}`
|
|
643
|
+
3. Reindex steps, increment retry_count, write status.json
|
|
644
|
+
4. Display: ◆ Goal audit: {k} unmet → +{N} steps inserted (G{ids}), retry {r}/{max}
|
|
645
|
+
|
|
646
|
+
### A_APPLY_GOAL_DONE
|
|
647
|
+
|
|
648
|
+
1. status.json: set 每个 `task_decomposition[*].status="done"`, `completion_confirmed=true`, `completed_at=now`,顶层 `task_decomposition_all_done=true`
|
|
649
|
+
2. Mark goal-audit decision completed;proceed to `milestone-complete`
|
|
650
|
+
3. Display: ◆ Goal audit: all met ✓
|
|
651
|
+
|
|
652
|
+
### A_ADVANCE_MILESTONE
|
|
653
|
+
|
|
654
|
+
1. Update session: milestone, phase, reset passed_gates
|
|
655
|
+
2. Insert full lifecycle steps for next milestone
|
|
656
|
+
3. Reindex, write status.json
|
|
657
|
+
|
|
658
|
+
### A_PAUSE_ESCALATE
|
|
659
|
+
|
|
660
|
+
1. Set session status = "paused", write status.json
|
|
661
|
+
2. Display: ◆ 已达最大重试次数,debug 已执行。请人工介入。
|
|
662
|
+
3. Display: /maestro-ralph continue 恢复
|
|
663
|
+
|
|
664
|
+
### A_AMEND_GOAL
|
|
665
|
+
|
|
666
|
+
运行中 session 的目标热修改。详细流程由 `<deferred_reading>` 加载 `ralph-amend-goal.md`。
|
|
667
|
+
|
|
668
|
+
| Phase | 行为 | 产出 |
|
|
669
|
+
|-------|------|------|
|
|
670
|
+
| 1. 快照 | 读 `task_decomposition` + `boundary_contract` + 已完成 steps 的 `completion_summary` | Display: 目标列表 + 进度 |
|
|
671
|
+
| 2. 解析 | `change_request` 非空 → 直接用;为空 → AskUserQuestion(修改/新增/移除/调整边界) | `change_type` + `change_request` |
|
|
672
|
+
| 3. Mini Grill | `maestro delegate --to {session.cli_tool} --mode analysis`:评估影响 | RISK_LEVEL + AFFECTED_GOALS + INVALIDATED_STEPS + NEW_GAPS |
|
|
673
|
+
| 4. 确认 | AskUserQuestion:应用并继续 / 仅改目标 / 取消 | 用户选择 |
|
|
674
|
+
| 5. 应用 | 归档旧目标(`superseded`)→ 写入新目标(`origin: CHG-xxx`)→ 重建链路 → write status.json | handoff ralph-execute |
|
|
675
|
+
|
|
676
|
+
GUARD: `RISK_LEVEL == high` → AskUserQuestion 不跳过(auto_confirm 无效)
|
|
677
|
+
GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
|
|
678
|
+
|
|
679
|
+
</actions>
|
|
680
|
+
|
|
681
|
+
</state_machine>
|
|
682
|
+
|
|
683
|
+
<appendix>
|
|
684
|
+
|
|
685
|
+
### Session Schema
|
|
686
|
+
|
|
687
|
+
```json
|
|
688
|
+
{
|
|
689
|
+
"session_id": "ralph-{YYYYMMDD-HHmmss}",
|
|
690
|
+
"source": "ralph", "status": "running",
|
|
691
|
+
"ralph_protocol_version": "2", // CLI-driven; absent/0 → legacy; "1" → basic CLI; "2" → structured completion + enhanced anchor
|
|
692
|
+
"active_step_index": null, // CLI-managed; only one step held at a time
|
|
693
|
+
"intent": "", "lifecycle_position": "",
|
|
694
|
+
"phase": null, "phase_is_new": false,
|
|
695
|
+
"milestone": "", // D-007 反查结果,禁止读 current_milestone
|
|
696
|
+
"auto_mode": false,
|
|
697
|
+
"decomposition_owner": "ralph", // 分解契约所有者(invariant 15);缺省按 source 推断
|
|
698
|
+
|
|
699
|
+
"quality_mode": "standard", // "full" | "standard" | "quick"
|
|
700
|
+
"planning_mode": "independent", // "unified" | "independent"
|
|
701
|
+
"scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
|
|
702
|
+
"wants_roadmap": false, // roadmap opt-in:--roadmap | 多发布 intent | roadmap.md 已存在
|
|
703
|
+
"analyze_macro_id": null, // "ANL-xxx" 来自最新 macro analyze
|
|
704
|
+
"blueprint_id": null, // "BLP-xxx" 若存在
|
|
705
|
+
"cli_tool": "claude", "passed_gates": [],
|
|
706
|
+
"context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
|
|
707
|
+
"analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
|
|
708
|
+
"steps": [{
|
|
709
|
+
"index": 0,
|
|
710
|
+
"skill": "", // 执行 step 有值;decision 节点为空字符串/null
|
|
711
|
+
"args": "",
|
|
712
|
+
"stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|...
|
|
713
|
+
"scope": null, // "phase"|"standalone"|"milestone"|null(plan 等需要)
|
|
714
|
+
"decision": null, // 非 null → decision 节点(值为 gate 名,如 "post-execute");null → 执行 step
|
|
715
|
+
"retry_count": 0, // decision 节点专用
|
|
716
|
+
"max_retries": 2, // decision 节点专用
|
|
717
|
+
"command_scope": "global|project|missing|null", // 执行 step;decision 节点固定 null
|
|
718
|
+
"command_path": "<absolute path resolved by `maestro ralph skills --platform claude --json --quiet`> | null",
|
|
719
|
+
"milestone_id": null, // D-007 反查注入;仅含 {phase} 占位符的 step 有
|
|
720
|
+
"source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
|
|
721
|
+
"status": "pending|running|completed|skipped|failed",
|
|
722
|
+
"goal_ref": null,
|
|
723
|
+
"completion_confirmed": false,
|
|
724
|
+
"completion_status": null,
|
|
725
|
+
"completion_evidence": null,
|
|
726
|
+
"completion_summary": null, // 一句话总结:做了什么(MUST on DONE)
|
|
727
|
+
"completion_decisions": null, // 本 step 做出的关键决策列表
|
|
728
|
+
"completion_caveats": null, // 后续 step 需注意的事项
|
|
729
|
+
"completion_deferred": null, // 被推迟到后续的工作列表
|
|
730
|
+
"completed_at": null,
|
|
731
|
+
"deferred_reads": [], // 由 ralph next CLI 解析 .md 时填充
|
|
732
|
+
"load": null // { loaded_at, required_files[], deferred_files[], resolve_version } —— 由 ralph next 写入
|
|
733
|
+
}],
|
|
734
|
+
"waves": [], "current_step": 0,
|
|
735
|
+
|
|
736
|
+
// Optional decomposition block (additive; absent → decomposition off)
|
|
737
|
+
"boundary_contract": {
|
|
738
|
+
"in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
|
|
739
|
+
},
|
|
740
|
+
"execution_criteria": [],
|
|
741
|
+
"task_decomposition": [
|
|
742
|
+
{ "id": "G1", "goal": "", "boundary": "", "done_when": "",
|
|
743
|
+
"evidence": "", "lifecycle": [], "status": "pending|done|superseded",
|
|
744
|
+
"completion_confirmed": false, "completed_at": null,
|
|
745
|
+
"superseded_by": null, "superseded_at": null, "origin": null }
|
|
746
|
+
],
|
|
747
|
+
"task_decomposition_all_done": false,
|
|
748
|
+
|
|
749
|
+
// goal_changelog: additive; absent → no amendments
|
|
750
|
+
"goal_changelog": [
|
|
751
|
+
{ "id": "CHG-001", "timestamp": "{ISO}",
|
|
752
|
+
"change_type": "modify|add|remove|boundary",
|
|
753
|
+
"reason": "变更描述",
|
|
754
|
+
"impact_assessment": { "risk_level": "low|medium|high",
|
|
755
|
+
"invalidated_steps": [], "new_steps_inserted": 0 },
|
|
756
|
+
"before": { "goals": [{"id":"G1","goal":"...","done_when":"..."}] },
|
|
757
|
+
"after": { "goals": [{"id":"G1v2","goal":"...","done_when":"..."}] } }
|
|
758
|
+
]
|
|
759
|
+
}
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
新增字段可选,缺省=旧行为;既有字段名不删不改。
|
|
763
|
+
|
|
764
|
+
### Fix-Loop Templates
|
|
765
|
+
|
|
766
|
+
所有插入的执行 step 按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点(`step.decision` 字段)。
|
|
767
|
+
|
|
768
|
+
**post-execute:**
|
|
769
|
+
```
|
|
770
|
+
quality-debug "{gap_summary}"
|
|
771
|
+
maestro-plan --gaps {phase}
|
|
772
|
+
maestro-execute {phase}
|
|
773
|
+
decision:post-execute {retry+1}
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
**post-business-test:**
|
|
777
|
+
```
|
|
778
|
+
quality-debug --from-business-test "{gap_summary}"
|
|
779
|
+
maestro-plan --gaps {phase}
|
|
780
|
+
maestro-execute {phase}
|
|
781
|
+
decision:post-execute {retry: 0}
|
|
782
|
+
quality-auto-test {phase}
|
|
783
|
+
decision:post-business-test {retry+1}
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
**post-review:**
|
|
787
|
+
```
|
|
788
|
+
quality-debug "{gap_summary}"
|
|
789
|
+
maestro-plan --gaps {phase}
|
|
790
|
+
maestro-execute {phase}
|
|
791
|
+
quality-review {phase}
|
|
792
|
+
decision:post-review {retry+1}
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
**post-test:**
|
|
796
|
+
```
|
|
797
|
+
quality-debug --from-uat "{gap_summary}"
|
|
798
|
+
maestro-plan --gaps {phase}
|
|
799
|
+
maestro-execute {phase}
|
|
800
|
+
decision:post-execute {retry: 0}
|
|
801
|
+
quality-auto-test {phase}
|
|
802
|
+
decision:post-business-test {retry: 0}
|
|
803
|
+
quality-review {phase}
|
|
804
|
+
decision:post-review {retry: 0}
|
|
805
|
+
quality-auto-test {phase}
|
|
806
|
+
quality-test {phase}
|
|
807
|
+
decision:post-test {retry+1}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
**post-frontend-verify:** (UI 写端点未接线/不可用时)
|
|
811
|
+
```
|
|
812
|
+
quality-debug --from-frontend-verify "{gap_summary}"
|
|
813
|
+
maestro-plan --gaps {phase}
|
|
814
|
+
maestro-execute {phase}
|
|
815
|
+
quality-test {phase} --frontend-verify
|
|
816
|
+
decision:post-frontend-verify {retry+1}
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
**post-goal-audit:** (per unmet sub-goal group)
|
|
820
|
+
```
|
|
821
|
+
# for each unmet sub-goal G{n}, scoped to target_phase:
|
|
822
|
+
maestro-plan --gaps {target_phase} "G{n}: {gap}" [goal_ref: G{n}]
|
|
823
|
+
maestro-execute {target_phase} [goal_ref: G{n}]
|
|
824
|
+
# after all unmet groups inserted:
|
|
825
|
+
decision:post-goal-audit {retry+1}
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
### Goal Prompt Template
|
|
829
|
+
|
|
830
|
+
链路概览后逐字显示(仅当 decomposition 已产出):
|
|
831
|
+
|
|
832
|
+
```
|
|
833
|
+
📋 任务分解完成。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
|
|
834
|
+
|
|
835
|
+
/goal 完成以下子目标:
|
|
836
|
+
{for each G in task_decomposition:}
|
|
837
|
+
- {G.id}: {G.goal} — 完成条件: {G.done_when}
|
|
838
|
+
{end for}
|
|
839
|
+
直到 {session_dir}/status.json 的 task_decomposition[*] 与 steps[*] 全部 completion_confirmed=true 才停。每轮以 status.json 为唯一行动手册,通过 /maestro-ralph-execute 推进 step;decision 节点由其自动 handoff 回 ralph 评估。禁止手动执行 skill 或修改 boundary_contract.out_of_scope。
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
`/goal` 由用户输入;ralph 输出提示词后继续 handoff,不阻塞。
|
|
843
|
+
|
|
844
|
+
### Error Codes
|
|
845
|
+
|
|
846
|
+
| Code | Severity | Description | Recovery |
|
|
847
|
+
|------|----------|-------------|----------|
|
|
848
|
+
| E001 | error | No intent and no running session | Prompt for intent |
|
|
849
|
+
| E002 | error | Cannot infer lifecycle position | Show raw state, ask |
|
|
850
|
+
| E003 | error | Artifact dir not found for decision | Show glob, ask |
|
|
851
|
+
| E004 | error | Delegate verdict parse failed | Fallback: "fix" |
|
|
852
|
+
| E005 | error | Delegate execution failed | Fallback: "fix" |
|
|
853
|
+
| E006 | error | command_scope == "missing" for one or more steps | List missing skills, abort build |
|
|
854
|
+
| W001 | warning | Decision expanded chain | Auto-handled |
|
|
855
|
+
| W002 | warning | Max retries, escalating | Auto-handled |
|
|
856
|
+
| W003 | warning | Multiple running sessions | Use latest, warn |
|
|
857
|
+
| W004 | warning | Low delegate confidence | Show warning |
|
|
858
|
+
|
|
859
|
+
### Success Criteria
|
|
860
|
+
|
|
861
|
+
- [ ] Phase 先于 position 解析;phase_is_new 标记写入 session
|
|
862
|
+
- [ ] D-007 反查:phase 数字 → `session.milestone`,禁止读 current_milestone;写入 step.milestone_id
|
|
863
|
+
- [ ] phase_is_new=true → lifecycle_position 强制 `analyze`
|
|
864
|
+
- [ ] Intent overrides 识别 grill / brainstorm / blueprint / analyze-macro
|
|
865
|
+
- [ ] auto_confirm=true 时 grill step args 追加 `-y`(grill 以 Auto mode 执行,stage 不跳过,产出 grill-report/terminology/context-package)
|
|
866
|
+
- [ ] A_RESOLVE_SCOPE_VERDICT 读 macro analyze conclusions.scope_verdict,写入 session.scope_verdict + analyze_macro_id
|
|
867
|
+
- [ ] 链路起点 = analyze-macro 时:large+wants_roadmap→roadmap+analyze+plan(phase);其余(含 large 默认/medium/small)→直跳 plan --from analyze:{ANL_ID}(跳过 roadmap+analyze)
|
|
868
|
+
- [ ] post-analyze-scope decision 节点在 macro analyze 之后插入;A_SCOPE_EVALUATE/A_APPLY_SCOPE_VERDICT 重塑链路
|
|
869
|
+
- [ ] plan step args 支持三路径:`{phase}` / `--from analyze:{ANL_ID}` / `--from blueprint:{BLP_ID}`,写入 step.source_artifact_ref
|
|
870
|
+
- [ ] roadmap step args 自动注入 `--from analyze:{analyze_macro_id}`(若存在)
|
|
871
|
+
- [ ] artifact 过滤按 session.phase;unified 按 milestone
|
|
872
|
+
- [ ] quality_mode 由 A_DETERMINE_QUALITY_MODE 决定,过滤 build steps
|
|
873
|
+
- [ ] frontend-verify stage 仅在 phase 交付 UI 时插入(test 后、milestone-audit 前);post-frontend-verify 走 quality-gate 评估,evidence=e2e-results.json
|
|
874
|
+
- [ ] Decomposition: broad intent ≤3 question clarify;narrow auto-derive
|
|
875
|
+
- [ ] status.json 唯一真源:boundary_contract + execution_criteria + task_decomposition;无外部清单
|
|
876
|
+
- [ ] 执行 step 含 `command_scope` + `command_path`(通过 `maestro ralph skills --platform claude --json --quiet` 预校验,project 覆盖 global);decision step 通过 `step.decision` 字段标识
|
|
877
|
+
- [ ] Ralph build 阶段只通过 `ralph skills --platform claude` 校验路径存在性,不读 .md 内容;`<required_reading>` 加载由 `maestro ralph next` CLI 完成
|
|
878
|
+
- [ ] 每个 step 含 `completion_confirmed` + `completion_status` + `completion_evidence` + `deferred_reads`(初始 false/null/[])
|
|
879
|
+
- [ ] 每个 sub-goal 含 `completion_confirmed`(初始 false)
|
|
880
|
+
- [ ] post-goal-audit decision 仅在 decomposed 时插入,位于 milestone-complete 之前
|
|
881
|
+
- [ ] Unmet sub-goals 动态 grow steps[](goal_ref tagged);max retries → escalate
|
|
882
|
+
- [ ] planning_mode 显式决定;unified=无 `{phase}`, independent=带 `{phase}`
|
|
883
|
+
- [ ] specs 预检:lifecycle_position 在 init 之后 + `.workflow/specs/` 不存在 → 链路最前面插入 `spec-setup`
|
|
884
|
+
- [ ] Chain 必须以 `milestone-complete` 结尾
|
|
885
|
+
- [ ] Decision nodes 由 maestro delegate --to {session.cli_tool} --mode analysis 评估
|
|
886
|
+
- [ ] Ralph 不执行 step,只 evaluate;Skill("maestro-ralph-execute") handoff
|
|
887
|
+
- [ ] Phase-level deferred chaining:plan/execute step 的 `--from`/`--dir` 注入由 A_RESOLVE_ARGS(ralph-execute)运行时完成;build 阶段标记意图,不预知 artifact ID
|
|
888
|
+
- [ ] Phase-level plan step 运行时获得 `--from analyze:{phase_analyze_id}`(由 ralph-execute 从 state.json 查找注入)
|
|
889
|
+
- [ ] Phase-level execute step 运行时获得 `source_artifact_ref = "plan:{id}"`
|
|
890
|
+
- [ ] 每个 step 含 `completion_summary` + `completion_decisions` + `completion_caveats` + `completion_deferred`(初始 null)
|
|
891
|
+
- [ ] `completion_summary` 在 DONE/DONE_WITH_CONCERNS 时为 MUST(由 CLI `--summary` 参数传入)
|
|
892
|
+
- [ ] session_anchor 包含最近 5 个已完成 step 的 `completion_summary` + `completion_caveats`(滑动窗口)
|
|
893
|
+
- [ ] session_anchor 包含 task_decomposition 全局视图(仅 `status != "superseded"` 的目标)
|
|
894
|
+
- [ ] session_anchor boundary_contract 不截断(`capAnchorList` n=8)
|
|
895
|
+
- [ ] session_anchor 包含 Accumulated Signals(聚合所有 caveats + deferred)
|
|
896
|
+
- [ ] re-grounding 完成 steps 信息含 completion_summary/decisions/caveats
|
|
897
|
+
- [ ] fix-loop 动态插入的 step 纳入 re-grounding 3-step 计数
|
|
898
|
+
- [ ] `--amend` 路由到 S_AMEND_GOAL(需 running session)
|
|
899
|
+
- [ ] A_AMEND_GOAL:5 步流程(快照→解析→mini grill→确认→应用)
|
|
900
|
+
- [ ] 旧目标标 `superseded`(`superseded_by` + `superseded_at`),新目标标 `origin: "CHG-xxx"`
|
|
901
|
+
- [ ] `goal_changelog` 记录完整 before/after 快照 + impact_assessment
|
|
902
|
+
- [ ] `RISK_LEVEL=high` 时 amend 不跳过 auto_confirm
|
|
903
|
+
- [ ] session_anchor 中 superseded 目标仅占一行标注,不展开细节
|
|
904
|
+
|
|
905
|
+
</appendix>
|