relay-cc 2.0.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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +428 -0
  3. package/agents/relay-codebase-mapper.md +761 -0
  4. package/agents/relay-debugger.md +1203 -0
  5. package/agents/relay-estimator.md +257 -0
  6. package/agents/relay-executor.md +823 -0
  7. package/agents/relay-plan-checker.md +812 -0
  8. package/agents/relay-planner.md +1418 -0
  9. package/agents/relay-reviewer.md +279 -0
  10. package/agents/relay-ticket-researcher.md +287 -0
  11. package/agents/relay-verifier.md +778 -0
  12. package/bin/install.js +1667 -0
  13. package/commands/relay/add-todo.md +193 -0
  14. package/commands/relay/check-todos.md +200 -0
  15. package/commands/relay/debug.md +169 -0
  16. package/commands/relay/estimate.md +182 -0
  17. package/commands/relay/help.md +328 -0
  18. package/commands/relay/history.md +203 -0
  19. package/commands/relay/map-codebase.md +71 -0
  20. package/commands/relay/pause-work.md +128 -0
  21. package/commands/relay/pr.md +223 -0
  22. package/commands/relay/quick.md +307 -0
  23. package/commands/relay/resume-work.md +40 -0
  24. package/commands/relay/resume.md +181 -0
  25. package/commands/relay/review.md +322 -0
  26. package/commands/relay/rollback.md +248 -0
  27. package/commands/relay/set-profile.md +116 -0
  28. package/commands/relay/settings.md +165 -0
  29. package/commands/relay/setup.md +247 -0
  30. package/commands/relay/status.md +131 -0
  31. package/commands/relay/tickets.md +106 -0
  32. package/commands/relay/update.md +200 -0
  33. package/commands/relay/work.md +398 -0
  34. package/hooks/dist/relay-check-update.js +61 -0
  35. package/hooks/dist/relay-statusline.js +91 -0
  36. package/package.json +47 -0
  37. package/relay/references/checkpoints.md +1078 -0
  38. package/relay/references/continuation-format.md +249 -0
  39. package/relay/references/git-integration.md +209 -0
  40. package/relay/references/model-profiles.md +57 -0
  41. package/relay/references/planning-config.md +189 -0
  42. package/relay/references/questioning.md +141 -0
  43. package/relay/references/tdd.md +263 -0
  44. package/relay/references/ui-brand.md +162 -0
  45. package/relay/references/verification-patterns.md +612 -0
  46. package/relay/templates/DEBUG.md +159 -0
  47. package/relay/templates/UAT.md +247 -0
  48. package/relay/templates/analysis.md +101 -0
  49. package/relay/templates/codebase/architecture.md +255 -0
  50. package/relay/templates/codebase/concerns.md +310 -0
  51. package/relay/templates/codebase/conventions.md +307 -0
  52. package/relay/templates/codebase/integrations.md +280 -0
  53. package/relay/templates/codebase/stack.md +186 -0
  54. package/relay/templates/codebase/structure.md +285 -0
  55. package/relay/templates/codebase/testing.md +480 -0
  56. package/relay/templates/config.json +40 -0
  57. package/relay/templates/context.md +283 -0
  58. package/relay/templates/continue-here.md +78 -0
  59. package/relay/templates/debug-subagent-prompt.md +91 -0
  60. package/relay/templates/estimate.md +108 -0
  61. package/relay/templates/phase-prompt.md +567 -0
  62. package/relay/templates/planner-subagent-prompt.md +117 -0
  63. package/relay/templates/research.md +552 -0
  64. package/relay/templates/state.md +127 -0
  65. package/relay/templates/summary.md +246 -0
  66. package/relay/templates/verification-report.md +322 -0
  67. package/relay/workflows/analyze-ticket.md +42 -0
  68. package/relay/workflows/diagnose-issues.md +231 -0
  69. package/relay/workflows/execute-phase.md +700 -0
  70. package/relay/workflows/execute-plan.md +1851 -0
  71. package/relay/workflows/map-codebase.md +357 -0
  72. package/relay/workflows/resume-project.md +307 -0
  73. package/relay/workflows/sync-ticket.md +58 -0
  74. package/relay/workflows/verify-phase.md +628 -0
  75. package/relay/workflows/verify-ticket.md +596 -0
  76. package/scripts/build-hooks.js +42 -0
@@ -0,0 +1,357 @@
1
+ <purpose>
2
+ Orchestrate parallel codebase mapper agents to analyze codebase and produce structured documents in .relay/codebase/
3
+
4
+ Each agent has fresh context, explores a specific focus area, and **writes documents directly**. The orchestrator only receives confirmation + line counts, then writes a summary.
5
+
6
+ Output: .relay/codebase/ folder with 7 structured documents about the codebase state.
7
+ </purpose>
8
+
9
+ <philosophy>
10
+ **Why dedicated mapper agents:**
11
+ - Fresh context per domain (no token contamination)
12
+ - Agents write documents directly (no context transfer back to orchestrator)
13
+ - Orchestrator only summarizes what was created (minimal context usage)
14
+ - Faster execution (agents run simultaneously)
15
+
16
+ **Document quality over length:**
17
+ Include enough detail to be useful as reference. Prioritize practical examples (especially code patterns) over arbitrary brevity.
18
+
19
+ **Always include file paths:**
20
+ Documents are reference material for Claude when planning/executing. Always include actual file paths formatted with backticks: `src/services/user.ts`.
21
+ </philosophy>
22
+
23
+ <process>
24
+
25
+ <step name="resolve_model_profile" priority="first">
26
+ Read model profile for agent spawning:
27
+
28
+ ```bash
29
+ MODEL_PROFILE=$(cat .relay/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
30
+ ```
31
+
32
+ Default to "balanced" if not set.
33
+
34
+ **Model lookup table:**
35
+
36
+ | Agent | quality | balanced | budget |
37
+ |-------|---------|----------|--------|
38
+ | relay-codebase-mapper | sonnet | haiku | haiku |
39
+
40
+ Store resolved model for use in Task calls below.
41
+ </step>
42
+
43
+ <step name="check_existing">
44
+ Check if .relay/codebase/ already exists:
45
+
46
+ ```bash
47
+ ls -la .relay/codebase/ 2>/dev/null
48
+ ```
49
+
50
+ **If exists:**
51
+
52
+ ```
53
+ .relay/codebase/ already exists with these documents:
54
+ [List files found]
55
+
56
+ What's next?
57
+ 1. Refresh - Delete existing and remap codebase
58
+ 2. Update - Keep existing, only update specific documents
59
+ 3. Skip - Use existing codebase map as-is
60
+ ```
61
+
62
+ Wait for user response.
63
+
64
+ If "Refresh": Delete .relay/codebase/, continue to create_structure
65
+ If "Update": Ask which documents to update, continue to spawn_agents (filtered)
66
+ If "Skip": Exit workflow
67
+
68
+ **If doesn't exist:**
69
+ Continue to create_structure.
70
+ </step>
71
+
72
+ <step name="create_structure">
73
+ Create .relay/codebase/ directory:
74
+
75
+ ```bash
76
+ mkdir -p .relay/codebase
77
+ ```
78
+
79
+ **Expected output files:**
80
+ - STACK.md (from tech mapper)
81
+ - INTEGRATIONS.md (from tech mapper)
82
+ - ARCHITECTURE.md (from arch mapper)
83
+ - STRUCTURE.md (from arch mapper)
84
+ - CONVENTIONS.md (from quality mapper)
85
+ - TESTING.md (from quality mapper)
86
+ - CONCERNS.md (from concerns mapper)
87
+
88
+ Continue to spawn_agents.
89
+ </step>
90
+
91
+ <step name="spawn_agents">
92
+ Spawn 4 parallel relay-codebase-mapper agents.
93
+
94
+ Use Task tool with `subagent_type="relay-codebase-mapper"`, `model="{mapper_model}"`, and `run_in_background=true` for parallel execution.
95
+
96
+ **CRITICAL:** Use the dedicated `relay-codebase-mapper` agent, NOT `Explore`. The mapper agent writes documents directly.
97
+
98
+ **Agent 1: Tech Focus**
99
+
100
+ Task tool parameters:
101
+ ```
102
+ subagent_type: "relay-codebase-mapper"
103
+ model: "{mapper_model}"
104
+ run_in_background: true
105
+ description: "Map codebase tech stack"
106
+ ```
107
+
108
+ Prompt:
109
+ ```
110
+ Focus: tech
111
+
112
+ Analyze this codebase for technology stack and external integrations.
113
+
114
+ Write these documents to .relay/codebase/:
115
+ - STACK.md - Languages, runtime, frameworks, dependencies, configuration
116
+ - INTEGRATIONS.md - External APIs, databases, auth providers, webhooks
117
+
118
+ Explore thoroughly. Write documents directly using templates. Return confirmation only.
119
+ ```
120
+
121
+ **Agent 2: Architecture Focus**
122
+
123
+ Task tool parameters:
124
+ ```
125
+ subagent_type: "relay-codebase-mapper"
126
+ model: "{mapper_model}"
127
+ run_in_background: true
128
+ description: "Map codebase architecture"
129
+ ```
130
+
131
+ Prompt:
132
+ ```
133
+ Focus: arch
134
+
135
+ Analyze this codebase architecture and directory structure.
136
+
137
+ Write these documents to .relay/codebase/:
138
+ - ARCHITECTURE.md - Pattern, layers, data flow, abstractions, entry points
139
+ - STRUCTURE.md - Directory layout, key locations, naming conventions
140
+
141
+ Explore thoroughly. Write documents directly using templates. Return confirmation only.
142
+ ```
143
+
144
+ **Agent 3: Quality Focus**
145
+
146
+ Task tool parameters:
147
+ ```
148
+ subagent_type: "relay-codebase-mapper"
149
+ model: "{mapper_model}"
150
+ run_in_background: true
151
+ description: "Map codebase conventions"
152
+ ```
153
+
154
+ Prompt:
155
+ ```
156
+ Focus: quality
157
+
158
+ Analyze this codebase for coding conventions and testing patterns.
159
+
160
+ Write these documents to .relay/codebase/:
161
+ - CONVENTIONS.md - Code style, naming, patterns, error handling
162
+ - TESTING.md - Framework, structure, mocking, coverage
163
+
164
+ Explore thoroughly. Write documents directly using templates. Return confirmation only.
165
+ ```
166
+
167
+ **Agent 4: Concerns Focus**
168
+
169
+ Task tool parameters:
170
+ ```
171
+ subagent_type: "relay-codebase-mapper"
172
+ model: "{mapper_model}"
173
+ run_in_background: true
174
+ description: "Map codebase concerns"
175
+ ```
176
+
177
+ Prompt:
178
+ ```
179
+ Focus: concerns
180
+
181
+ Analyze this codebase for technical debt, known issues, and areas of concern.
182
+
183
+ Write this document to .relay/codebase/:
184
+ - CONCERNS.md - Tech debt, bugs, security, performance, fragile areas
185
+
186
+ Explore thoroughly. Write document directly using template. Return confirmation only.
187
+ ```
188
+
189
+ Continue to collect_confirmations.
190
+ </step>
191
+
192
+ <step name="collect_confirmations">
193
+ Wait for all 4 agents to complete.
194
+
195
+ Read each agent's output file to collect confirmations.
196
+
197
+ **Expected confirmation format from each agent:**
198
+ ```
199
+ ## Mapping Complete
200
+
201
+ **Focus:** {focus}
202
+ **Documents written:**
203
+ - `.relay/codebase/{DOC1}.md` ({N} lines)
204
+ - `.relay/codebase/{DOC2}.md` ({N} lines)
205
+
206
+ Ready for orchestrator summary.
207
+ ```
208
+
209
+ **What you receive:** Just file paths and line counts. NOT document contents.
210
+
211
+ If any agent failed, note the failure and continue with successful documents.
212
+
213
+ Continue to verify_output.
214
+ </step>
215
+
216
+ <step name="verify_output">
217
+ Verify all documents created successfully:
218
+
219
+ ```bash
220
+ ls -la .relay/codebase/
221
+ wc -l .relay/codebase/*.md
222
+ ```
223
+
224
+ **Verification checklist:**
225
+ - All 7 documents exist
226
+ - No empty documents (each should have >20 lines)
227
+
228
+ If any documents missing or empty, note which agents may have failed.
229
+
230
+ Continue to scan_for_secrets.
231
+ </step>
232
+
233
+ <step name="scan_for_secrets">
234
+ **CRITICAL SECURITY CHECK:** Scan output files for accidentally leaked secrets before committing.
235
+
236
+ Run secret pattern detection:
237
+
238
+ ```bash
239
+ # Check for common API key patterns in generated docs
240
+ grep -E '(sk-[a-zA-Z0-9]{20,}|sk_live_[a-zA-Z0-9]+|sk_test_[a-zA-Z0-9]+|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|glpat-[a-zA-Z0-9_-]+|AKIA[A-Z0-9]{16}|xox[baprs]-[a-zA-Z0-9-]+|-----BEGIN.*PRIVATE KEY|eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.)' .relay/codebase/*.md 2>/dev/null && SECRETS_FOUND=true || SECRETS_FOUND=false
241
+ ```
242
+
243
+ **If SECRETS_FOUND=true:**
244
+
245
+ ```
246
+ ⚠️ SECURITY ALERT: Potential secrets detected in codebase documents!
247
+
248
+ Found patterns that look like API keys or tokens in:
249
+ [show grep output]
250
+
251
+ This would expose credentials if committed.
252
+
253
+ **Action required:**
254
+ 1. Review the flagged content above
255
+ 2. If these are real secrets, they must be removed before committing
256
+ 3. Consider adding sensitive files to Claude Code "Deny" permissions
257
+
258
+ Pausing before commit. Reply "safe to proceed" if the flagged content is not actually sensitive, or edit the files first.
259
+ ```
260
+
261
+ Wait for user confirmation before continuing to commit_codebase_map.
262
+
263
+ **If SECRETS_FOUND=false:**
264
+
265
+ Continue to commit_codebase_map.
266
+ </step>
267
+
268
+ <step name="commit_codebase_map">
269
+ Commit the codebase map:
270
+
271
+ **Check planning config:**
272
+
273
+ ```bash
274
+ COMMIT_PLANNING_DOCS=$(cat .relay/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
275
+ git check-ignore -q .relay 2>/dev/null && COMMIT_PLANNING_DOCS=false
276
+ ```
277
+
278
+ **If `COMMIT_PLANNING_DOCS=false`:** Skip git operations
279
+
280
+ **If `COMMIT_PLANNING_DOCS=true` (default):**
281
+
282
+ ```bash
283
+ git add .relay/codebase/*.md
284
+ git commit -m "$(cat <<'EOF'
285
+ docs: map existing codebase
286
+
287
+ - STACK.md - Technologies and dependencies
288
+ - ARCHITECTURE.md - System design and patterns
289
+ - STRUCTURE.md - Directory layout
290
+ - CONVENTIONS.md - Code style and patterns
291
+ - TESTING.md - Test structure
292
+ - INTEGRATIONS.md - External services
293
+ - CONCERNS.md - Technical debt and issues
294
+ EOF
295
+ )"
296
+ ```
297
+
298
+ Continue to offer_next.
299
+ </step>
300
+
301
+ <step name="offer_next">
302
+ Present completion summary and next steps.
303
+
304
+ **Get line counts:**
305
+ ```bash
306
+ wc -l .relay/codebase/*.md
307
+ ```
308
+
309
+ **Output format:**
310
+
311
+ ```
312
+ Codebase mapping complete.
313
+
314
+ Created .relay/codebase/:
315
+ - STACK.md ([N] lines) - Technologies and dependencies
316
+ - ARCHITECTURE.md ([N] lines) - System design and patterns
317
+ - STRUCTURE.md ([N] lines) - Directory layout and organization
318
+ - CONVENTIONS.md ([N] lines) - Code style and patterns
319
+ - TESTING.md ([N] lines) - Test structure and practices
320
+ - INTEGRATIONS.md ([N] lines) - External services and APIs
321
+ - CONCERNS.md ([N] lines) - Technical debt and issues
322
+
323
+
324
+ ---
325
+
326
+ ## ▶ Next Up
327
+
328
+ **Initialize project** — use codebase context for planning
329
+
330
+ `/relay:new-project`
331
+
332
+ <sub>`/clear` first → fresh context window</sub>
333
+
334
+ ---
335
+
336
+ **Also available:**
337
+ - Re-run mapping: `/relay:map-codebase`
338
+ - Review specific file: `cat .relay/codebase/STACK.md`
339
+ - Edit any document before proceeding
340
+
341
+ ---
342
+ ```
343
+
344
+ End workflow.
345
+ </step>
346
+
347
+ </process>
348
+
349
+ <success_criteria>
350
+ - .relay/codebase/ directory created
351
+ - 4 parallel relay-codebase-mapper agents spawned with run_in_background=true
352
+ - Agents write documents directly (orchestrator doesn't receive document contents)
353
+ - Read agent output files to collect confirmations
354
+ - All 7 codebase documents exist
355
+ - Clear completion summary with line counts
356
+ - User offered clear next steps in Relay style
357
+ </success_criteria>
@@ -0,0 +1,307 @@
1
+ <trigger>
2
+ Use this workflow when:
3
+ - Starting a new session on an existing project
4
+ - User says "continue", "what's next", "where were we", "resume"
5
+ - Any planning operation when .relay/ already exists
6
+ - User returns after time away from project
7
+ </trigger>
8
+
9
+ <purpose>
10
+ Instantly restore full project context so "Where were we?" has an immediate, complete answer.
11
+ </purpose>
12
+
13
+ <required_reading>
14
+ @~/.claude/relay/references/continuation-format.md
15
+ </required_reading>
16
+
17
+ <process>
18
+
19
+ <step name="detect_existing_project">
20
+ Check if this is an existing project:
21
+
22
+ ```bash
23
+ ls .relay/STATE.md 2>/dev/null && echo "Project exists"
24
+ ls .relay/ROADMAP.md 2>/dev/null && echo "Roadmap exists"
25
+ ls .relay/PROJECT.md 2>/dev/null && echo "Project file exists"
26
+ ```
27
+
28
+ **If STATE.md exists:** Proceed to load_state
29
+ **If only ROADMAP.md/PROJECT.md exist:** Offer to reconstruct STATE.md
30
+ **If .relay/ doesn't exist:** This is a new project - route to /relay:new-project
31
+ </step>
32
+
33
+ <step name="load_state">
34
+
35
+ Read and parse STATE.md, then PROJECT.md:
36
+
37
+ ```bash
38
+ cat .relay/STATE.md
39
+ cat .relay/PROJECT.md
40
+ ```
41
+
42
+ **From STATE.md extract:**
43
+
44
+ - **Project Reference**: Core value and current focus
45
+ - **Current Position**: Phase X of Y, Plan A of B, Status
46
+ - **Progress**: Visual progress bar
47
+ - **Recent Decisions**: Key decisions affecting current work
48
+ - **Pending Todos**: Ideas captured during sessions
49
+ - **Blockers/Concerns**: Issues carried forward
50
+ - **Session Continuity**: Where we left off, any resume files
51
+
52
+ **From PROJECT.md extract:**
53
+
54
+ - **What This Is**: Current accurate description
55
+ - **Requirements**: Validated, Active, Out of Scope
56
+ - **Key Decisions**: Full decision log with outcomes
57
+ - **Constraints**: Hard limits on implementation
58
+
59
+ </step>
60
+
61
+ <step name="check_incomplete_work">
62
+ Look for incomplete work that needs attention:
63
+
64
+ ```bash
65
+ # Check for continue-here files (mid-plan resumption)
66
+ ls .relay/tickets/*/.continue-here*.md 2>/dev/null
67
+
68
+ # Check for plans without summaries (incomplete execution)
69
+ for plan in .relay/tickets/*/*-PLAN.md; do
70
+ summary="${plan/PLAN/SUMMARY}"
71
+ [ ! -f "$summary" ] && echo "Incomplete: $plan"
72
+ done 2>/dev/null
73
+
74
+ # Check for interrupted agents
75
+ if [ -f .relay/current-agent-id.txt ] && [ -s .relay/current-agent-id.txt ]; then
76
+ AGENT_ID=$(cat .relay/current-agent-id.txt | tr -d '\n')
77
+ echo "Interrupted agent: $AGENT_ID"
78
+ fi
79
+ ```
80
+
81
+ **If .continue-here file exists:**
82
+
83
+ - This is a mid-plan resumption point
84
+ - Read the file for specific resumption context
85
+ - Flag: "Found mid-plan checkpoint"
86
+
87
+ **If PLAN without SUMMARY exists:**
88
+
89
+ - Execution was started but not completed
90
+ - Flag: "Found incomplete plan execution"
91
+
92
+ **If interrupted agent found:**
93
+
94
+ - Subagent was spawned but session ended before completion
95
+ - Read agent-history.json for task details
96
+ - Flag: "Found interrupted agent"
97
+ </step>
98
+
99
+ <step name="present_status">
100
+ Present complete project status to user:
101
+
102
+ ```
103
+ ╔══════════════════════════════════════════════════════════════╗
104
+ ║ PROJECT STATUS ║
105
+ ╠══════════════════════════════════════════════════════════════╣
106
+ ║ Building: [one-liner from PROJECT.md "What This Is"] ║
107
+ ║ ║
108
+ ║ Phase: [X] of [Y] - [Phase name] ║
109
+ ║ Plan: [A] of [B] - [Status] ║
110
+ ║ Progress: [██████░░░░] XX% ║
111
+ ║ ║
112
+ ║ Last activity: [date] - [what happened] ║
113
+ ╚══════════════════════════════════════════════════════════════╝
114
+
115
+ [If incomplete work found:]
116
+ ⚠️ Incomplete work detected:
117
+ - [.continue-here file or incomplete plan]
118
+
119
+ [If interrupted agent found:]
120
+ ⚠️ Interrupted agent detected:
121
+ Agent ID: [id]
122
+ Task: [task description from agent-history.json]
123
+ Interrupted: [timestamp]
124
+
125
+ Resume with: Task tool (resume parameter with agent ID)
126
+
127
+ [If pending todos exist:]
128
+ 📋 [N] pending todos — /relay:check-todos to review
129
+
130
+ [If blockers exist:]
131
+ ⚠️ Carried concerns:
132
+ - [blocker 1]
133
+ - [blocker 2]
134
+
135
+ [If alignment is not ✓:]
136
+ ⚠️ Brief alignment: [status] - [assessment]
137
+ ```
138
+
139
+ </step>
140
+
141
+ <step name="determine_next_action">
142
+ Based on project state, determine the most logical next action:
143
+
144
+ **If interrupted agent exists:**
145
+ → Primary: Resume interrupted agent (Task tool with resume parameter)
146
+ → Option: Start fresh (abandon agent work)
147
+
148
+ **If .continue-here file exists:**
149
+ → Primary: Resume from checkpoint
150
+ → Option: Start fresh on current plan
151
+
152
+ **If incomplete plan (PLAN without SUMMARY):**
153
+ → Primary: Complete the incomplete plan
154
+ → Option: Abandon and move on
155
+
156
+ **If phase in progress, all plans complete:**
157
+ → Primary: Transition to next phase
158
+ → Option: Review completed work
159
+
160
+ **If phase ready to plan:**
161
+ → Check if CONTEXT.md exists for this phase:
162
+
163
+ - If CONTEXT.md missing:
164
+ → Primary: Discuss phase vision (how user imagines it working)
165
+ → Secondary: Plan directly (skip context gathering)
166
+ - If CONTEXT.md exists:
167
+ → Primary: Plan the phase
168
+ → Option: Review roadmap
169
+
170
+ **If phase ready to execute:**
171
+ → Primary: Execute next plan
172
+ → Option: Review the plan first
173
+ </step>
174
+
175
+ <step name="offer_options">
176
+ Present contextual options based on project state:
177
+
178
+ ```
179
+ What would you like to do?
180
+
181
+ [Primary action based on state - e.g.:]
182
+ 1. Resume interrupted agent [if interrupted agent found]
183
+ OR
184
+ 1. Execute phase (/relay:execute-phase {phase})
185
+ OR
186
+ 1. Discuss Phase 3 context (/relay:discuss-phase 3) [if CONTEXT.md missing]
187
+ OR
188
+ 1. Plan Phase 3 (/relay:plan-phase 3) [if CONTEXT.md exists or discuss option declined]
189
+
190
+ [Secondary options:]
191
+ 2. Review current phase status
192
+ 3. Check pending todos ([N] pending)
193
+ 4. Review brief alignment
194
+ 5. Something else
195
+ ```
196
+
197
+ **Note:** When offering phase planning, check for CONTEXT.md existence first:
198
+
199
+ ```bash
200
+ ls .relay/tickets/XX-name/*-CONTEXT.md 2>/dev/null
201
+ ```
202
+
203
+ If missing, suggest discuss-phase before plan. If exists, offer plan directly.
204
+
205
+ Wait for user selection.
206
+ </step>
207
+
208
+ <step name="route_to_workflow">
209
+ Based on user selection, route to appropriate workflow:
210
+
211
+ - **Execute plan** → Show command for user to run after clearing:
212
+ ```
213
+ ---
214
+
215
+ ## ▶ Next Up
216
+
217
+ **{phase}-{plan}: [Plan Name]** — [objective from PLAN.md]
218
+
219
+ `/relay:execute-phase {phase}`
220
+
221
+ <sub>`/clear` first → fresh context window</sub>
222
+
223
+ ---
224
+ ```
225
+ - **Plan phase** → Show command for user to run after clearing:
226
+ ```
227
+ ---
228
+
229
+ ## ▶ Next Up
230
+
231
+ **Phase [N]: [Name]** — [Goal from ROADMAP.md]
232
+
233
+ `/relay:plan-phase [phase-number]`
234
+
235
+ <sub>`/clear` first → fresh context window</sub>
236
+
237
+ ---
238
+
239
+ **Also available:**
240
+ - `/relay:discuss-phase [N]` — gather context first
241
+ - `/relay:research-phase [N]` — investigate unknowns
242
+
243
+ ---
244
+ ```
245
+ - **Transition** → ./transition.md
246
+ - **Check todos** → Read .relay/todos/pending/, present summary
247
+ - **Review alignment** → Read PROJECT.md, compare to current state
248
+ - **Something else** → Ask what they need
249
+ </step>
250
+
251
+ <step name="update_session">
252
+ Before proceeding to routed workflow, update session continuity:
253
+
254
+ Update STATE.md:
255
+
256
+ ```markdown
257
+ ## Session Continuity
258
+
259
+ Last session: [now]
260
+ Stopped at: Session resumed, proceeding to [action]
261
+ Resume file: [updated if applicable]
262
+ ```
263
+
264
+ This ensures if session ends unexpectedly, next resume knows the state.
265
+ </step>
266
+
267
+ </process>
268
+
269
+ <reconstruction>
270
+ If STATE.md is missing but other artifacts exist:
271
+
272
+ "STATE.md missing. Reconstructing from artifacts..."
273
+
274
+ 1. Read PROJECT.md → Extract "What This Is" and Core Value
275
+ 2. Read ROADMAP.md → Determine phases, find current position
276
+ 3. Scan \*-SUMMARY.md files → Extract decisions, concerns
277
+ 4. Count pending todos in .relay/todos/pending/
278
+ 5. Check for .continue-here files → Session continuity
279
+
280
+ Reconstruct and write STATE.md, then proceed normally.
281
+
282
+ This handles cases where:
283
+
284
+ - Project predates STATE.md introduction
285
+ - File was accidentally deleted
286
+ - Cloning repo without full .relay/ state
287
+ </reconstruction>
288
+
289
+ <quick_resume>
290
+ If user says "continue" or "go":
291
+ - Load state silently
292
+ - Determine primary action
293
+ - Execute immediately without presenting options
294
+
295
+ "Continuing from [state]... [action]"
296
+ </quick_resume>
297
+
298
+ <success_criteria>
299
+ Resume is complete when:
300
+
301
+ - [ ] STATE.md loaded (or reconstructed)
302
+ - [ ] Incomplete work detected and flagged
303
+ - [ ] Clear status presented to user
304
+ - [ ] Contextual next actions offered
305
+ - [ ] User knows exactly where project stands
306
+ - [ ] Session continuity updated
307
+ </success_criteria>