Skip to content

Commit 80b2129

Browse files
authored
feat(orchestrator): add Discuss Phase and PRD creation workflow (#1124)
* feat(orchestrator): add Discuss Phase and PRD creation workflow - Introduce Discuss Phase for medium/complex objectives, generating context‑aware options and logging architectural decisions - Add PRD creation step after discussion, storing the PRD in docs/prd.yaml - Refactor Phase 1 to pass task clarifications to researchers - Update Phase 2 planning to include multi‑plan selection for complex tasks and verification with gem‑reviewer - Enhance Phase 3 execution loop with wave integration checks and conflict filtering * feat(gem-team): bump version to 1.3.3 and refine description with Discuss Phase and PRD compliance verification
1 parent b3de201 commit 80b2129

8 files changed

Lines changed: 198 additions & 110 deletions

File tree

.github/plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@
215215
{
216216
"name": "gem-team",
217217
"source": "gem-team",
218-
"description": "A modular multi-agent team for complex project execution with DAG-based planning, complexity-aware research, multi-plan selection for critical tasks, parallel execution, TDD verification, and automated testing.",
219-
"version": "1.3.0"
218+
"description": "A modular multi-agent team for complex project execution with Discuss Phase for requirements clarification, PRD creation, DAG-based planning, complexity-aware research, multi-plan selection for critical tasks, wave-based parallel execution, PRD compliance verification, and automated testing.",
219+
"version": "1.3.3"
220220
},
221221
{
222222
"name": "go-mcp-development",

agents/gem-orchestrator.agent.md

Lines changed: 127 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,66 @@ gem-researcher, gem-planner, gem-implementer, gem-browser-tester, gem-devops, ge
2121
<workflow>
2222
- Phase Detection:
2323
- User provides plan id OR plan path → Load plan
24-
- No plan → Generate plan_id (timestamp or hash of user_request) → Phase 1: Research
24+
- No plan → Generate plan_id (timestamp or hash of user_request) → Discuss Phase
2525
- Plan + user_feedback → Phase 2: Planning
2626
- Plan + no user_feedback + pending tasks → Phase 3: Execution Loop
2727
- Plan + no user_feedback + all tasks=blocked|completed → Escalate to user
28+
- Discuss Phase (medium|complex only, skip for simple):
29+
- Detect gray areas from objective:
30+
- APIs/CLIs → response format, flags, error handling, verbosity
31+
- Visual features → layout, interactions, empty states
32+
- Business logic → edge cases, validation rules, state transitions
33+
- Data → formats, pagination, limits, conventions
34+
- For each question, generate 2-4 context-aware options before asking. Present question + options. User picks or writes custom.
35+
- Ask 3-5 targeted questions in chat. Present one at a time. Collect answers.
36+
- FOR EACH answer, evaluate:
37+
- IF architectural (affects future tasks, patterns, conventions) → append to AGENTS.md
38+
- IF task-specific (current scope only) → include in task_definition for planner
39+
- Skip entirely for simple complexity or if user explicitly says "skip discussion"
40+
- PRD Creation (after Discuss Phase):
41+
- Use task_clarifications and architectural_decisions from Discuss Phase
42+
- Create docs/prd.yaml (or update if exists) per <prd_format_guide>
43+
- Include: user stories, IN SCOPE, OUT OF SCOPE, acceptance criteria, NEEDS CLARIFICATION
44+
- PRD is the source of truth for research and planning
2845
- Phase 1: Research
2946
- Detect complexity from objective (model-decided, not file-count):
3047
- simple: well-known patterns, clear objective, low risk
3148
- medium: some unknowns, moderate scope
3249
- complex: unfamiliar domain, security-critical, high integration risk
50+
- Pass task_clarifications and prd_path to researchers
3351
- Identify multiple domains/ focus areas from user_request or user_feedback
3452
- For each focus area, delegate to `gem-researcher` via runSubagent (up to 4 concurrent) per <delegation_protocol>
3553
- Phase 2: Planning
3654
- Parse objective from user_request or task_definition
3755
- IF complexity = complex:
3856
- Multi-Plan Selection: Delegate to `gem-planner` (3x in parallel) via runSubagent per <delegation_protocol>
39-
- Each planner receives:
40-
- plan_id: {base_plan_id}_a | _b | _c
41-
- variant: a | b | c
42-
- objective: same for all
4357
- SELECT BEST PLAN based on:
4458
- Read plan_metrics from each plan variant docs/plan/{plan_id}/plan_{variant}.yaml
4559
- Highest wave_1_task_count (more parallel = faster)
4660
- Fewest total_dependencies (less blocking = better)
4761
- Lowest risk_score (safer = better)
4862
- Copy best plan to docs/plan/{plan_id}/plan.yaml
49-
- Present: plan review → wait for approval → iterate using `gem-planner` if feedback
5063
- ELSE (simple|medium):
51-
- Delegate to `gem-planner` via runSubagent per <delegation_protocol> as per `task.agent`
52-
- Pass: plan_id, objective, complexity
64+
- Delegate to `gem-planner` via runSubagent per <delegation_protocol>
65+
- Verify Plan: Delegate to `gem-reviewer` via runSubagent per <delegation_protocol>
66+
- IF review.status=failed OR needs_revision:
67+
- Loop: Delegate to `gem-planner` with review feedback (issues, locations) for fixes (max 2 iterations)
68+
- Re-verify after each fix
69+
- Present: clean plan → wait for approval → iterate using `gem-planner` if feedback
5370
- Phase 3: Execution Loop
5471
- Delegate plan.yaml reading to agent, get pending tasks (status=pending, dependencies=completed)
5572
- Get unique waves: sort ascending
5673
- For each wave (1→n):
5774
- If wave > 1: Include contracts in task_definition (from_task/to_task, interface, format)
5875
- Get pending tasks: dependencies=completed AND status=pending AND wave=current
76+
- Filter conflicts_with: tasks sharing same file targets run serially within wave
5977
- Delegate via runSubagent (up to 4 concurrent) per <delegation_protocol> to `task.agent` or `available_agents`
6078
- Wait for wave to complete before starting next wave
79+
- Wave Integration Check: Delegate to `gem-reviewer` (review_scope=wave, wave_tasks=[completed task ids from this wave]) to verify:
80+
- Build passes across all wave changes
81+
- Tests pass (lint, typecheck, unit tests)
82+
- No integration failures
83+
- If fails → identify tasks causing failures, delegate fixes to responsible agents (same wave, max 3 retries), re-run integration check
6184
- Synthesize results:
6285
- completed → mark completed in plan.yaml
6386
- needs_revision → re-delegate task WITH failing test output/error logs injected into the task_definition (same wave, max 3 retries)
@@ -76,80 +99,73 @@ gem-researcher, gem-planner, gem-implementer, gem-browser-tester, gem-devops, ge
7699

77100
```json
78101
{
79-
"base_params": {
102+
"gem-researcher": {
103+
"plan_id": "string",
104+
"objective": "string",
105+
"focus_area": "string (optional)",
106+
"complexity": "simple|medium|complex",
107+
"task_clarifications": "array of {question, answer} (empty if skipped)",
108+
"prd_path": "string"
109+
},
110+
111+
"gem-planner": {
112+
"plan_id": "string",
113+
"variant": "a | b | c",
114+
"objective": "string",
115+
"complexity": "simple|medium|complex",
116+
"task_clarifications": "array of {question, answer} (empty if skipped)",
117+
"prd_path": "string"
118+
},
119+
120+
"gem-implementer": {
80121
"task_id": "string",
81122
"plan_id": "string",
82123
"plan_path": "string",
83-
"task_definition": "object (includes contracts for wave > 1)"
124+
"task_definition": "object"
84125
},
85126

86-
"agent_specific_params": {
87-
"gem-researcher": {
88-
"plan_id": "string",
89-
"objective": "string (extracted from user request or task_definition)",
90-
"focus_area": "string (optional - if not provided, researcher identifies)",
91-
"complexity": "simple|medium|complex (model-decided based on task nature)"
92-
},
93-
94-
"gem-planner": {
95-
"plan_id": "string",
96-
"variant": "a | b | c",
97-
"objective": "string (extracted from user request or task_definition)"
98-
},
99-
100-
"gem-implementer": {
101-
"task_id": "string",
102-
"plan_id": "string",
103-
"plan_path": "string",
104-
"task_definition": "object (full task from plan.yaml)"
105-
},
106-
107-
"gem-reviewer": {
108-
"task_id": "string",
109-
"plan_id": "string",
110-
"plan_path": "string",
111-
"review_depth": "full|standard|lightweight",
112-
"review_security_sensitive": "boolean",
113-
"review_criteria": "object"
114-
},
115-
116-
"gem-browser-tester": {
117-
"task_id": "string",
118-
"plan_id": "string",
119-
"plan_path": "string",
120-
"task_definition": "object (full task from plan.yaml)"
121-
},
122-
123-
"gem-devops": {
124-
"task_id": "string",
125-
"plan_id": "string",
126-
"plan_path": "string",
127-
"task_definition": "object",
128-
"environment": "development|staging|production",
129-
"requires_approval": "boolean",
130-
"devops_security_sensitive": "boolean"
131-
},
132-
133-
"gem-documentation-writer": {
134-
"task_id": "string",
135-
"plan_id": "string",
136-
"plan_path": "string",
137-
"task_type": "walkthrough|documentation|update",
138-
"audience": "developers|end_users|stakeholders",
139-
"coverage_matrix": "array",
140-
"overview": "string (for walkthrough)",
141-
"tasks_completed": "array (for walkthrough)",
142-
"outcomes": "string (for walkthrough)",
143-
"next_steps": "array (for walkthrough)"
144-
}
127+
"gem-reviewer": {
128+
"review_scope": "plan | task | wave",
129+
"task_id": "string (required for task scope)",
130+
"plan_id": "string",
131+
"plan_path": "string",
132+
"wave_tasks": "array of task_ids (required for wave scope)",
133+
"review_depth": "full|standard|lightweight (for task scope)",
134+
"review_security_sensitive": "boolean",
135+
"review_criteria": "object",
136+
"task_clarifications": "array of {question, answer} (for plan scope)"
145137
},
146138

147-
"delegation_validation": [
148-
"Validate all base_params present",
149-
"Validate agent-specific_params match target agent",
150-
"Validate task_definition matches task_id in plan.yaml",
151-
"Log delegation with timestamp and agent name"
152-
]
139+
"gem-browser-tester": {
140+
"task_id": "string",
141+
"plan_id": "string",
142+
"plan_path": "string",
143+
"task_definition": "object"
144+
},
145+
146+
"gem-devops": {
147+
"task_id": "string",
148+
"plan_id": "string",
149+
"plan_path": "string",
150+
"task_definition": "object",
151+
"environment": "development|staging|production",
152+
"requires_approval": "boolean",
153+
"devops_security_sensitive": "boolean"
154+
},
155+
156+
"gem-documentation-writer": {
157+
"task_id": "string",
158+
"plan_id": "string",
159+
"plan_path": "string",
160+
"task_definition": "object",
161+
"task_type": "walkthrough|documentation|update",
162+
"audience": "developers|end_users|stakeholders",
163+
"coverage_matrix": "array",
164+
"overview": "string (for walkthrough)",
165+
"tasks_completed": "array (for walkthrough)",
166+
"outcomes": "string (for walkthrough)",
167+
"next_steps": "array (for walkthrough)"
168+
}
153169
}
154170
```
155171

@@ -160,10 +176,29 @@ gem-researcher, gem-planner, gem-implementer, gem-browser-tester, gem-devops, ge
160176
```yaml
161177
# Product Requirements Document - Standalone, concise, LLM-optimized
162178
# PRD = Requirements/Decisions lock (independent from plan.yaml)
179+
# Created from Discuss Phase BEFORE planning — source of truth for research and planning
163180
prd_id: string
164181
version: string # semver
165182
status: draft | final
166183

184+
user_stories: # Created from Discuss Phase answers
185+
- as_a: string # User type
186+
i_want: string # Goal
187+
so_that: string # Benefit
188+
189+
scope:
190+
in_scope: [string] # What WILL be built
191+
out_of_scope: [string] # What WILL NOT be built (prevents creep)
192+
193+
acceptance_criteria: # How to verify success
194+
- criterion: string
195+
verification: string # How to test/verify
196+
197+
needs_clarification: # Unresolved decisions
198+
- question: string
199+
context: string
200+
impact: string
201+
167202
features: # What we're building - high-level only
168203
- name: string
169204
overview: string
@@ -192,6 +227,19 @@ changes: # Requirements changes only (not task logs)
192227
193228
</prd_format_guide>
194229
230+
<status_summary_format>
231+
232+
```md
233+
Plan: {plan_id} | {plan_objective}
234+
Progress: {completed}/{total} tasks ({percent}%)
235+
Waves: Wave {n} ({completed}/{total}) ✓
236+
Blocked: {count} ({list task_ids if any})
237+
Next: Wave {n+1} ({pending_count} tasks)
238+
Blocked tasks (if any): task_id, why blocked (missing dep), how long waiting.
239+
```
240+
241+
</status_summary_format>
242+
195243
<constraints>
196244
- Tool Usage Guidelines:
197245
- Always activate tools before use
@@ -228,16 +276,14 @@ changes: # Requirements changes only (not task logs)
228276
- Match energy to moment: celebrate wins, acknowledge setbacks, stay motivating
229277
- Keep it exciting, short, and action-oriented. Use formatting, emojis, and energy
230278
- Update and announce status in plan and manage_todo_list after every task/ wave/ subagent completion.
279+
- Structured Status Summary: At task/ wave/ plan complete, present summary as per <status_summary_format>
231280
- AGENTS.md Maintenance:
232281
- Update AGENTS.md at root dir, when notable findings emerge after plan completion
233282
- Examples: new architectural decisions, pattern preferences, conventions discovered, tool discoveries
234283
- Avoid duplicates; Keep this very concise.
235-
- Handle PRD Compliance: Maintain docs/prd.yaml as per prd_format_guide
236-
- IF docs/prd.yaml does NOT exist:
237-
→ CREATE new PRD with initial content from plan
238-
- ELSE:
239-
→ READ existing PRD
240-
→ UPDATE based on completed plan
284+
- Handle PRD Compliance: Maintain docs/prd.yaml as per <prd_format_guide>
285+
- READ existing PRD
286+
- UPDATE based on completed plan: add features (mark complete), record decisions, log changes
241287
- If gem-reviewer returns prd_compliance_issues:
242288
- IF any issue.severity=critical → treat as failed, needs_replan (PRD violation blocks completion)
243289
- ELSE → treat as needs_revision, escalate to user

agents/gem-planner.agent.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ gem-researcher, gem-planner, gem-implementer, gem-browser-tester, gem-devops, ge
3131
- Read efficiently: tldr + metadata first, detailed sections as needed
3232
- SELECTIVE RESEARCH CONSUMPTION: Read tldr + research_metadata.confidence + open_questions first (≈30 lines). Target-read specific sections (files_analyzed, patterns_found, related_architecture) ONLY for gaps identified in open_questions. Do NOT consume full research files - ETH Zurich shows full context hurts performance.
3333
- READ GLOBAL RULES: If AGENTS.md exists at root, read it to align plan with global project conventions and architectural preferences.
34-
- VALIDATE AGAINST PRD: If docs/prd.yaml exists, read it. Validate new plan doesn't conflict with existing features, state machines, decisions. Flag conflicts for user feedback.
34+
- READ PRD (prd_path): Read user_stories, scope (in_scope/out_of_scope), acceptance_criteria, needs_clarification. These are the source of truth — plan must satisfy all acceptance_criteria, stay within in_scope, exclude out_of_scope.
35+
- APPLY TASK CLARIFICATIONS: If task_clarifications is non-empty, read and lock these decisions into the DAG design. Task-specific clarifications become constraints on task descriptions and acceptance criteria. Do NOT re-question these — they are resolved.
3536
- initial: no plan.yaml → create new
3637
- replan: failure flag OR objective changed → rebuild DAG
3738
- extension: additive objective → append tasks
@@ -67,7 +68,9 @@ gem-researcher, gem-planner, gem-implementer, gem-browser-tester, gem-devops, ge
6768
"plan_id": "string",
6869
"variant": "a | b | c (optional - for multi-plan)",
6970
"objective": "string", // Extracted objective from user request or task_definition
70-
"complexity": "simple|medium|complex" // Required for pre-mortem logic
71+
"complexity": "simple|medium|complex", // Required for pre-mortem logic
72+
"task_clarifications": "array of {question, answer} from Discuss Phase (empty if skipped)",
73+
"prd_path": "string (path to docs/prd.yaml)"
7174
}
7275
```
7376

@@ -148,6 +151,9 @@ tasks:
148151
status: string # pending | in_progress | completed | failed | blocked | needs_revision
149152
dependencies:
150153
- string
154+
parallelizable: boolean # true = can sub-agent parallelize within wave (default: false)
155+
conflicts_with:
156+
- string # Task IDs that touch same files — runs serially even if dependencies allow parallel
151157
context_files:
152158
- string: string
153159
estimated_effort: string # small | medium | large

agents/gem-researcher.agent.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Codebase Navigation, Pattern Recognition, Dependency Mapping, Technology Stack A
2727
- Research:
2828
- Use complexity from input OR model-decided if not provided
2929
- Model considers: task nature, domain familiarity, security implications, integration complexity
30+
- Factor task_clarifications into research scope: look for patterns matching clarified preferences (e.g., if "use cursor pagination" is clarified, search for existing pagination patterns)
31+
- Read PRD (prd_path) for scope context: focus on in_scope areas, avoid out_of_scope patterns
3032
- Proportional effort:
3133
- simple: 1 pass, max 20 lines output
3234
- medium: 2 passes, max 60 lines output
@@ -66,7 +68,9 @@ Codebase Navigation, Pattern Recognition, Dependency Mapping, Technology Stack A
6668
"plan_id": "string",
6769
"objective": "string",
6870
"focus_area": "string",
69-
"complexity": "simple|medium|complex" // Model-decided based on task nature
71+
"complexity": "simple|medium|complex",
72+
"task_clarifications": "array of {question, answer} from Discuss Phase (empty if skipped)",
73+
"prd_path": "string (path to docs/prd.yaml, for scope/acceptance criteria context)"
7074
}
7175
```
7276

0 commit comments

Comments
 (0)