opencastle 1.6.3 → 1.6.4

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 (155) hide show
  1. package/README.md +9 -9
  2. package/bin/cli.mjs +6 -4
  3. package/dist/cli/adapters/adapter-contract.test.js +1 -1
  4. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  5. package/dist/cli/adapters/single-file-base.js +2 -12
  6. package/dist/cli/adapters/single-file-base.js.map +1 -1
  7. package/dist/cli/bootstrap.js +1 -1
  8. package/dist/cli/bootstrap.js.map +1 -1
  9. package/dist/cli/command-namespace.test.js +4 -21
  10. package/dist/cli/command-namespace.test.js.map +1 -1
  11. package/dist/cli/convoy/engine.js +2 -2
  12. package/dist/cli/convoy/engine.js.map +1 -1
  13. package/dist/cli/convoy/read-model.d.ts +8 -15
  14. package/dist/cli/convoy/read-model.d.ts.map +1 -1
  15. package/dist/cli/convoy/read-model.js +9 -68
  16. package/dist/cli/convoy/read-model.js.map +1 -1
  17. package/dist/cli/convoy/read-model.test.js +6 -25
  18. package/dist/cli/convoy/read-model.test.js.map +1 -1
  19. package/dist/cli/convoy/spec-builder.d.ts +2 -2
  20. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  21. package/dist/cli/convoy/spec-builder.js +1 -1
  22. package/dist/cli/dashboard.js +1 -1
  23. package/dist/cli/dashboard.test.js +10 -2
  24. package/dist/cli/dashboard.test.js.map +1 -1
  25. package/dist/cli/dispatcher.test.js +5 -2
  26. package/dist/cli/dispatcher.test.js.map +1 -1
  27. package/dist/cli/docs-accuracy.test.js +5 -1
  28. package/dist/cli/docs-accuracy.test.js.map +1 -1
  29. package/dist/cli/doctor.d.ts.map +1 -1
  30. package/dist/cli/doctor.js +0 -25
  31. package/dist/cli/doctor.js.map +1 -1
  32. package/dist/cli/pipeline.d.ts +1 -1
  33. package/dist/cli/pipeline.flow.test.js +77 -77
  34. package/dist/cli/pipeline.flow.test.js.map +1 -1
  35. package/dist/cli/pipeline.js +24 -24
  36. package/dist/cli/pipeline.js.map +1 -1
  37. package/dist/cli/plan.d.ts +8 -2
  38. package/dist/cli/plan.d.ts.map +1 -1
  39. package/dist/cli/plan.js +18 -12
  40. package/dist/cli/plan.js.map +1 -1
  41. package/dist/cli/plan.test.js +17 -19
  42. package/dist/cli/plan.test.js.map +1 -1
  43. package/dist/cli/update.d.ts.map +1 -1
  44. package/dist/cli/update.js +1 -58
  45. package/dist/cli/update.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/cli/adapters/adapter-contract.test.ts +1 -1
  48. package/src/cli/adapters/single-file-base.ts +2 -11
  49. package/src/cli/bootstrap.ts +1 -1
  50. package/src/cli/command-namespace.test.ts +5 -22
  51. package/src/cli/convoy/engine.ts +2 -2
  52. package/src/{orchestrator/prompts/assess-complexity.prompt.md → cli/convoy/prompts/convoy-assess.prompt.md} +0 -3
  53. package/src/{orchestrator/prompts/fix-convoy.prompt.md → cli/convoy/prompts/convoy-plan-fix.prompt.md} +0 -3
  54. package/src/{orchestrator/prompts/validate-convoy.prompt.md → cli/convoy/prompts/convoy-plan-review.prompt.md} +0 -3
  55. package/src/{orchestrator/prompts/generate-convoy.prompt.md → cli/convoy/prompts/convoy-plan.prompt.md} +0 -2
  56. package/src/{orchestrator/prompts/fix-prd.prompt.md → cli/convoy/prompts/convoy-prd-fix.prompt.md} +0 -3
  57. package/src/{orchestrator/prompts/validate-prd.prompt.md → cli/convoy/prompts/convoy-prd-review.prompt.md} +0 -3
  58. package/src/{orchestrator/prompts/generate-prd.prompt.md → cli/convoy/prompts/convoy-prd.prompt.md} +0 -3
  59. package/src/cli/convoy/read-model.test.ts +5 -29
  60. package/src/cli/convoy/read-model.ts +11 -71
  61. package/src/cli/convoy/spec-builder.ts +2 -2
  62. package/src/cli/dashboard/dashboard.js +2 -4
  63. package/src/cli/dashboard.test.ts +10 -2
  64. package/src/cli/dashboard.ts +1 -1
  65. package/src/cli/dispatcher.test.ts +6 -2
  66. package/src/cli/docs-accuracy.test.ts +5 -1
  67. package/src/cli/doctor.ts +0 -26
  68. package/src/cli/pipeline.flow.test.ts +78 -78
  69. package/src/cli/pipeline.ts +25 -25
  70. package/src/cli/plan.test.ts +18 -20
  71. package/src/cli/plan.ts +18 -12
  72. package/src/cli/update.ts +1 -66
  73. package/src/orchestrator/agent-workflows/README.md +10 -18
  74. package/src/orchestrator/agent-workflows/data-pipeline.md +7 -140
  75. package/src/orchestrator/agent-workflows/database-migration.md +7 -153
  76. package/src/orchestrator/agent-workflows/performance-optimization.md +6 -119
  77. package/src/orchestrator/agent-workflows/refactoring.md +8 -137
  78. package/src/orchestrator/agent-workflows/schema-changes.md +8 -159
  79. package/src/orchestrator/agent-workflows/security-audit.md +7 -142
  80. package/src/orchestrator/agent-workflows/shared-delivery-phase.md +8 -25
  81. package/src/orchestrator/agents/architect.agent.md +2 -14
  82. package/src/orchestrator/agents/content-engineer.agent.md +8 -10
  83. package/src/orchestrator/agents/data-engineer.agent.md +8 -8
  84. package/src/orchestrator/agents/developer.agent.md +3 -10
  85. package/src/orchestrator/agents/devops-expert.agent.md +0 -3
  86. package/src/orchestrator/agents/performance-expert.agent.md +2 -3
  87. package/src/orchestrator/agents/security-expert.agent.md +10 -12
  88. package/src/orchestrator/agents/team-lead.agent.md +31 -75
  89. package/src/orchestrator/agents/testing-expert.agent.md +3 -6
  90. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -4
  91. package/src/orchestrator/agents/writer.agent.md +0 -3
  92. package/src/orchestrator/customizations/README.md +3 -4
  93. package/src/orchestrator/customizations/agents/agent-registry.md +3 -3
  94. package/src/orchestrator/customizations/agents/skill-matrix.json +6 -42
  95. package/src/orchestrator/instructions/general.instructions.md +10 -37
  96. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -6
  97. package/src/orchestrator/prompts/brainstorm.prompt.md +7 -12
  98. package/src/orchestrator/prompts/bug-fix.prompt.md +19 -100
  99. package/src/orchestrator/prompts/convoy.prompt.md +20 -0
  100. package/src/orchestrator/prompts/create-skill.prompt.md +1 -5
  101. package/src/orchestrator/prompts/implement-feature.prompt.md +22 -93
  102. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +1 -5
  103. package/src/orchestrator/skills/api-patterns/SKILL.md +21 -18
  104. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
  105. package/src/orchestrator/skills/fast-review/SKILL.md +28 -65
  106. package/src/orchestrator/skills/frontend-design/REFERENCE.md +0 -1
  107. package/src/orchestrator/skills/frontend-design/SKILL.md +3 -1
  108. package/src/orchestrator/skills/git-workflow/SKILL.md +18 -34
  109. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +16 -46
  110. package/src/orchestrator/skills/security-hardening/SKILL.md +20 -19
  111. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +2 -2
  112. package/src/orchestrator/skills/self-improvement/SKILL.md +21 -46
  113. package/src/orchestrator/skills/technical-writing/SKILL.md +3 -1
  114. package/src/orchestrator/skills/technical-writing/TEMPLATES.md +23 -0
  115. package/src/orchestrator/skills/testing-workflow/SKILL.md +21 -23
  116. package/src/orchestrator/skills/validation-gates/REFERENCE.md +2 -14
  117. package/src/orchestrator/skills/validation-gates/SKILL.md +10 -88
  118. package/dist/cli/log.d.ts +0 -44
  119. package/dist/cli/log.d.ts.map +0 -1
  120. package/dist/cli/log.js +0 -336
  121. package/dist/cli/log.js.map +0 -1
  122. package/dist/cli/log.test.d.ts +0 -2
  123. package/dist/cli/log.test.d.ts.map +0 -1
  124. package/dist/cli/log.test.js +0 -208
  125. package/dist/cli/log.test.js.map +0 -1
  126. package/src/cli/log.test.ts +0 -228
  127. package/src/cli/log.ts +0 -374
  128. package/src/orchestrator/agent-workflows/bug-fix.md +0 -130
  129. package/src/orchestrator/agent-workflows/feature-implementation.md +0 -232
  130. package/src/orchestrator/instructions/ai-optimization.instructions.md +0 -17
  131. package/src/orchestrator/prompts/quick-refinement.prompt.md +0 -110
  132. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +0 -44
  133. package/src/orchestrator/skills/agent-hooks/SKILL.md +0 -80
  134. package/src/orchestrator/skills/agent-memory/KNOWLEDGE-GRAPH.md +0 -49
  135. package/src/orchestrator/skills/agent-memory/SKILL.md +0 -50
  136. package/src/orchestrator/skills/code-commenting/SKILL.md +0 -18
  137. package/src/orchestrator/skills/context-map/REFERENCE.md +0 -67
  138. package/src/orchestrator/skills/context-map/SKILL.md +0 -71
  139. package/src/orchestrator/skills/decomposition/SKILL.md +0 -103
  140. package/src/orchestrator/skills/documentation-standards/SKILL.md +0 -33
  141. package/src/orchestrator/skills/fast-review/REFERENCE.md +0 -28
  142. package/src/orchestrator/skills/memory-merger/SKILL.md +0 -77
  143. package/src/orchestrator/skills/observability-logging/LOG-SCHEMA.md +0 -238
  144. package/src/orchestrator/skills/observability-logging/SKILL.md +0 -73
  145. package/src/orchestrator/skills/orchestration-protocols/REFERENCE.md +0 -38
  146. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +0 -120
  147. package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +0 -49
  148. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +0 -38
  149. package/src/orchestrator/skills/performance-optimization/SKILL.md +0 -23
  150. package/src/orchestrator/skills/project-consistency/SKILL.md +0 -80
  151. package/src/orchestrator/skills/project-consistency/TEMPLATES.md +0 -35
  152. package/src/orchestrator/skills/react-development/SKILL.md +0 -24
  153. package/src/orchestrator/skills/session-checkpoints/CHECKPOINT-TEMPLATE.md +0 -56
  154. package/src/orchestrator/skills/session-checkpoints/SKILL.md +0 -40
  155. package/src/orchestrator/skills/team-lead-reference/SKILL.md +0 -126
@@ -108,13 +108,13 @@ function stubAdapter(answers: Record<string, Answer> = {}): { adapter: AgentAdap
108
108
  const stoppers = new Map<string, Array<() => void>>()
109
109
  const seen = new Map<string, number>()
110
110
  const defaults: Record<string, Answer> = {
111
- 'generate-prd': PRD,
112
- 'fix-prd': PRD,
113
- 'validate-prd': fence({ valid: true }),
114
- 'assess-complexity': fence(SINGLE),
115
- 'generate-convoy': fence(PLAN),
116
- 'validate-convoy': fence({ valid: true }),
117
- 'fix-convoy': fence([]),
111
+ 'convoy-prd': PRD,
112
+ 'convoy-prd-fix': PRD,
113
+ 'convoy-prd-review': fence({ valid: true }),
114
+ 'convoy-assess': fence(SINGLE),
115
+ 'convoy-plan': fence(PLAN),
116
+ 'convoy-plan-review': fence({ valid: true }),
117
+ 'convoy-plan-fix': fence([]),
118
118
  }
119
119
  const adapter: AgentAdapter = {
120
120
  name: 'stub',
@@ -185,13 +185,13 @@ describe('planConvoy: sessions', () => {
185
185
  // The plan from the request is dropped once the size says a PRD is needed;
186
186
  // the plan from the PRD is the one kept.
187
187
  expect([...templates(calls)].sort()).toEqual([
188
- 'assess-complexity', 'generate-convoy', 'generate-convoy', 'generate-prd', 'validate-prd',
188
+ 'convoy-assess', 'convoy-plan', 'convoy-plan', 'convoy-prd', 'convoy-prd-review',
189
189
  ])
190
190
  expect(outcome.problems).toEqual([])
191
191
  })
192
192
 
193
193
  it('runs every planning session read-only, in the project', async () => {
194
- const { adapter, calls } = stubAdapter({ 'validate-prd': (_p, n) => fence(n === 1 ? { valid: false, issues: ['x'] } : { valid: true }) })
194
+ const { adapter, calls } = stubAdapter({ 'convoy-prd-review': (_p, n) => fence(n === 1 ? { valid: false, issues: ['x'] } : { valid: true }) })
195
195
  await plan(adapter, { critic: true })
196
196
  expect(calls.length).toBeGreaterThan(4)
197
197
  for (const call of calls) {
@@ -200,23 +200,23 @@ describe('planConvoy: sessions', () => {
200
200
  }
201
201
  })
202
202
 
203
- it('sends the PRD to generate-convoy once', async () => {
203
+ it('sends the PRD to convoy-plan once', async () => {
204
204
  const { adapter, calls } = stubAdapter()
205
205
  await plan(adapter)
206
- const fromPrd = calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('PRD-MARKER'))
206
+ const fromPrd = calls.filter((c) => c.template === 'convoy-plan' && c.prompt.includes('PRD-MARKER'))
207
207
  expect(fromPrd).toHaveLength(1)
208
208
  expect(fromPrd[0].prompt.match(/PRD-MARKER/g)).toHaveLength(1)
209
209
  expect(fromPrd[0].prompt).not.toMatch(/\{\{(goal|context)\}\}/)
210
210
  })
211
211
 
212
212
  it('plans a small change straight from the request, with no PRD', async () => {
213
- const { adapter, calls } = stubAdapter({ 'assess-complexity': fence({ ...SINGLE, complexity: 'low' }) })
213
+ const { adapter, calls } = stubAdapter({ 'convoy-assess': fence({ ...SINGLE, complexity: 'low' }) })
214
214
  const outcome = await plan(adapter)
215
215
  // The PRD starts beside the size too; here it finished first, and is not kept.
216
- expect([...templates(calls)].sort()).toEqual(['assess-complexity', 'generate-convoy', 'generate-prd'])
216
+ expect([...templates(calls)].sort()).toEqual(['convoy-assess', 'convoy-plan', 'convoy-prd'])
217
217
  expect(outcome.prdPath).toBeNull()
218
218
  expect(existsSync(join(root, '.opencastle', 'prds'))).toBe(false)
219
- expect(calls.find((c) => c.template === 'generate-convoy')!.prompt).toContain('There is no PRD: this is a small change')
219
+ expect(calls.find((c) => c.template === 'convoy-plan')!.prompt).toContain('There is no PRD: this is a small change')
220
220
  expect(outcome.problems).toEqual([])
221
221
  })
222
222
 
@@ -231,8 +231,8 @@ describe('planConvoy: sessions', () => {
231
231
  return answer
232
232
  }
233
233
  const { adapter } = stubAdapter({
234
- 'assess-complexity': overlap(fence({ ...SINGLE, complexity: 'low' })),
235
- 'generate-convoy': overlap(fence(PLAN)),
234
+ 'convoy-assess': overlap(fence({ ...SINGLE, complexity: 'low' })),
235
+ 'convoy-plan': overlap(fence(PLAN)),
236
236
  })
237
237
  await plan(adapter)
238
238
  expect(most).toBe(2)
@@ -240,21 +240,21 @@ describe('planConvoy: sessions', () => {
240
240
 
241
241
  it('stops the PRD as soon as the size says the change is small', async () => {
242
242
  const { adapter, killed } = stubAdapter({
243
- 'assess-complexity': fence({ ...SINGLE, complexity: 'low' }),
244
- 'generate-prd': never,
243
+ 'convoy-assess': fence({ ...SINGLE, complexity: 'low' }),
244
+ 'convoy-prd': never,
245
245
  })
246
246
  const outcome = await plan(adapter)
247
- expect(killed).toEqual(['generate-prd'])
247
+ expect(killed).toEqual(['convoy-prd'])
248
248
  expect(outcome.prdPath).toBeNull()
249
249
  expect(outcome.plan.name).toBe('Dark mode')
250
250
  })
251
251
 
252
252
  it('stops the plan from the request as soon as the size says a PRD is needed', async () => {
253
253
  const { adapter, calls, killed } = stubAdapter({
254
- 'generate-convoy': (prompt) => (prompt.includes('PRD-MARKER') ? fence(PLAN) : never()),
254
+ 'convoy-plan': (prompt) => (prompt.includes('PRD-MARKER') ? fence(PLAN) : never()),
255
255
  })
256
256
  const outcome = await plan(adapter)
257
- expect(killed).toEqual(['generate-convoy'])
257
+ expect(killed).toEqual(['convoy-plan'])
258
258
  expect(outcome.prdPath).not.toBeNull()
259
259
  expect(outcome.plan.name).toBe('Dark mode')
260
260
  // A stopped session counts, and makes the cost a lower bound.
@@ -265,25 +265,25 @@ describe('planConvoy: sessions', () => {
265
265
  it('plans from the PRD beside its review, and again from the fixed PRD when the review fails', async () => {
266
266
  const fixedPrd = PRD.replace('PRD-MARKER', 'FIXED-MARKER')
267
267
  const { adapter, calls, killed } = stubAdapter({
268
- 'validate-prd': (_p, n) => fence({ valid: n > 1, issues: ['US-1: unclear'] }),
269
- 'fix-prd': fixedPrd,
268
+ 'convoy-prd-review': (_p, n) => fence({ valid: n > 1, issues: ['US-1: unclear'] }),
269
+ 'convoy-prd-fix': fixedPrd,
270
270
  // The plan from the request ends at once; the one from the draft PRD
271
271
  // runs until it is stopped.
272
- 'generate-convoy': (prompt) => (prompt.includes('PRD-MARKER') ? never() : fence(PLAN)),
272
+ 'convoy-plan': (prompt) => (prompt.includes('PRD-MARKER') ? never() : fence(PLAN)),
273
273
  })
274
274
  const outcome = await plan(adapter)
275
- expect(killed).toEqual(['generate-convoy'])
276
- const last = calls.filter((c) => c.template === 'generate-convoy').at(-1)!
275
+ expect(killed).toEqual(['convoy-plan'])
276
+ const last = calls.filter((c) => c.template === 'convoy-plan').at(-1)!
277
277
  expect(last.prompt).toContain('FIXED-MARKER')
278
278
  expect(outcome.problems).toEqual([])
279
279
  })
280
280
 
281
281
  it('asks for medium effort for the plan and low for every other step, all lean', async () => {
282
- const { adapter, calls } = stubAdapter({ 'validate-prd': (_p, n) => fence({ valid: n > 1, issues: ['x'] }) })
282
+ const { adapter, calls } = stubAdapter({ 'convoy-prd-review': (_p, n) => fence({ valid: n > 1, issues: ['x'] }) })
283
283
  await plan(adapter, { critic: true })
284
284
  expect(new Set(calls.map((c) => c.template)).size).toBeGreaterThanOrEqual(6)
285
285
  for (const call of calls) {
286
- expect(call.effort, call.template).toBe(call.template === 'generate-convoy' ? 'medium' : 'low')
286
+ expect(call.effort, call.template).toBe(call.template === 'convoy-plan' ? 'medium' : 'low')
287
287
  expect(call.lean, call.template).toBe(true)
288
288
  }
289
289
  })
@@ -291,38 +291,38 @@ describe('planConvoy: sessions', () => {
291
291
  it('sizes a larger request once, and does not size its PRD again', async () => {
292
292
  const { adapter, calls } = stubAdapter()
293
293
  await plan(adapter)
294
- expect(count(calls, 'assess-complexity')).toBe(1)
295
- expect(templates(calls).slice(0, 3).sort()).toEqual(['assess-complexity', 'generate-convoy', 'generate-prd'])
294
+ expect(count(calls, 'convoy-assess')).toBe(1)
295
+ expect(templates(calls).slice(0, 3).sort()).toEqual(['convoy-assess', 'convoy-plan', 'convoy-prd'])
296
296
  })
297
297
 
298
298
  it('fixes an invalid PRD at most twice, then plans from it anyway', async () => {
299
- const { adapter, calls } = stubAdapter({ 'validate-prd': fence({ valid: false, issues: ['Overview: thin'] }) })
299
+ const { adapter, calls } = stubAdapter({ 'convoy-prd-review': fence({ valid: false, issues: ['Overview: thin'] }) })
300
300
  const outcome = await plan(adapter)
301
- expect(count(calls, 'fix-prd')).toBe(2)
302
- expect(count(calls, 'validate-prd')).toBe(3)
301
+ expect(count(calls, 'convoy-prd-fix')).toBe(2)
302
+ expect(count(calls, 'convoy-prd-review')).toBe(3)
303
303
  // Planned from the request, from the draft beside its review, and from the PRD as fixed.
304
- expect(count(calls, 'generate-convoy')).toBe(3)
304
+ expect(count(calls, 'convoy-plan')).toBe(3)
305
305
  expect(calls).toHaveLength(10)
306
- expect(templates(calls).at(-1)).toBe('generate-convoy')
306
+ expect(templates(calls).at(-1)).toBe('convoy-plan')
307
307
  expect(outcome.problems).toEqual([])
308
308
  })
309
309
 
310
310
  it('stops fixing the PRD as soon as it passes', async () => {
311
- const { adapter, calls } = stubAdapter({ 'validate-prd': (_p, n) => fence({ valid: n > 1, issues: ['x'] }) })
311
+ const { adapter, calls } = stubAdapter({ 'convoy-prd-review': (_p, n) => fence({ valid: n > 1, issues: ['x'] }) })
312
312
  await plan(adapter)
313
- expect(count(calls, 'fix-prd')).toBe(1)
313
+ expect(count(calls, 'convoy-prd-fix')).toBe(1)
314
314
  expect(calls).toHaveLength(8)
315
315
  })
316
316
 
317
- it('asks fix-convoy only when the checks fail, and never validate-convoy', async () => {
317
+ it('asks convoy-plan-fix only when the checks fail, and never convoy-plan-review', async () => {
318
318
  const bad = { ...PLAN, tasks: [PLAN.tasks[0], { ...PLAN.tasks[1], timeout: 'soon' }] }
319
319
  const { adapter, calls } = stubAdapter({
320
- 'generate-convoy': fence(bad),
321
- 'fix-convoy': fence([{ task_id: 'toggle', field: 'timeout', value: '10m' }]),
320
+ 'convoy-plan': fence(bad),
321
+ 'convoy-plan-fix': fence([{ task_id: 'toggle', field: 'timeout', value: '10m' }]),
322
322
  })
323
323
  const outcome = await plan(adapter)
324
- expect(count(calls, 'fix-convoy')).toBe(1)
325
- expect(count(calls, 'validate-convoy')).toBe(0)
324
+ expect(count(calls, 'convoy-plan-fix')).toBe(1)
325
+ expect(count(calls, 'convoy-plan-review')).toBe(0)
326
326
  expect(calls).toHaveLength(6)
327
327
  expect(outcome.problems).toEqual([])
328
328
  })
@@ -332,16 +332,16 @@ describe('planConvoy: sessions', () => {
332
332
  // as soon as the size is known, whether or not it got to its own retry.
333
333
  let fromPrd = 0
334
334
  const { adapter, calls } = stubAdapter({
335
- 'generate-convoy': (prompt) =>
335
+ 'convoy-plan': (prompt) =>
336
336
  prompt.includes('PRD-MARKER') && fromPrd++ === 0 ? 'Sorry, here you go: {' : fence(PLAN),
337
337
  })
338
338
  const outcome = await plan(adapter)
339
- expect(calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('PRD-MARKER'))).toHaveLength(2)
339
+ expect(calls.filter((c) => c.template === 'convoy-plan' && c.prompt.includes('PRD-MARKER'))).toHaveLength(2)
340
340
  expect(outcome.plan.name).toBe('Dark mode')
341
341
  })
342
342
 
343
343
  it('keeps the unreadable answer for inspection when the retry fails too', async () => {
344
- const { adapter } = stubAdapter({ 'generate-convoy': 'not a plan' })
344
+ const { adapter } = stubAdapter({ 'convoy-plan': 'not a plan' })
345
345
  await expect(plan(adapter)).rejects.toThrow(/could not be read after a retry/)
346
346
  expect(readdirSync(join(root, '.opencastle', 'convoys')).some((f) => f.endsWith('.task-plan.json'))).toBe(true)
347
347
  })
@@ -350,20 +350,20 @@ describe('planConvoy: sessions', () => {
350
350
  const bad = { ...PLAN, tasks: [PLAN.tasks[0], { ...PLAN.tasks[1], timeout: 'soon' }] }
351
351
  let fromFixed = 0
352
352
  const { adapter, calls } = stubAdapter({
353
- 'validate-prd': fence({ valid: false, issues: ['x'] }),
353
+ 'convoy-prd-review': fence({ valid: false, issues: ['x'] }),
354
354
  // Only the plan that is kept, from the PRD as fixed, is unreadable once.
355
- 'generate-convoy': (prompt) =>
356
- prompt.includes('PRD-MARKER') && calls.some((c) => c.template === 'fix-prd') && fromFixed++ === 0
355
+ 'convoy-plan': (prompt) =>
356
+ prompt.includes('PRD-MARKER') && calls.some((c) => c.template === 'convoy-prd-fix') && fromFixed++ === 0
357
357
  ? '```json\n{ "name": "x", "tasks": [\n```'
358
358
  : fence(bad),
359
- 'fix-convoy': fence([{ task_id: 'toggle', field: 'timeout', value: 'later' }]),
359
+ 'convoy-plan-fix': fence([{ task_id: 'toggle', field: 'timeout', value: 'later' }]),
360
360
  })
361
361
  const outcome = await plan(adapter, { critic: true })
362
- // assess ‖ the plan from the request, generate-prd, validate-prd ‖ the plan
363
- // from the draft, 2 × (fix-prd + validate-prd), 2 × generate-convoy (one
364
- // unreadable), 2 × fix-convoy.
362
+ // assess ‖ the plan from the request, convoy-prd, convoy-prd-review ‖ the plan
363
+ // from the draft, 2 × (convoy-prd-fix + convoy-prd-review), 2 × convoy-plan (one
364
+ // unreadable), 2 × convoy-plan-fix.
365
365
  expect(calls).toHaveLength(13)
366
- expect(count(calls, 'validate-convoy')).toBe(0) // no review of a plan that cannot run
366
+ expect(count(calls, 'convoy-plan-review')).toBe(0) // no review of a plan that cannot run
367
367
  expect(outcome.problems.join('\n')).toContain('timeout')
368
368
  })
369
369
 
@@ -375,26 +375,26 @@ describe('planConvoy: sessions', () => {
375
375
  { id: 'b', prompt: 'b', files: ['src/components/Hero.tsx'] },
376
376
  ],
377
377
  }
378
- const { adapter, calls } = stubAdapter({ 'generate-convoy': fence(clash) })
378
+ const { adapter, calls } = stubAdapter({ 'convoy-plan': fence(clash) })
379
379
  const outcome = await plan(adapter)
380
- expect(count(calls, 'fix-convoy')).toBe(2)
380
+ expect(count(calls, 'convoy-plan-fix')).toBe(2)
381
381
  expect(outcome.problems).toEqual([])
382
382
  expect(outcome.plan.tasks[1].depends_on).toEqual(['a'])
383
383
  })
384
384
 
385
385
  it('reviews the plan only for --yes, and keeps a revision only if it still passes', async () => {
386
386
  const { adapter, calls } = stubAdapter({
387
- 'validate-convoy': fence({ valid: false, issues: ['toggle: needs the theme docs'] }),
388
- 'fix-convoy': fence([{ task_id: 'toggle', field: 'prompt', value: 'Add the toggle; read docs first.' }]),
387
+ 'convoy-plan-review': fence({ valid: false, issues: ['toggle: needs the theme docs'] }),
388
+ 'convoy-plan-fix': fence([{ task_id: 'toggle', field: 'prompt', value: 'Add the toggle; read docs first.' }]),
389
389
  })
390
390
  const outcome = await plan(adapter, { critic: true })
391
- expect(templates(calls).slice(-2)).toEqual(['validate-convoy', 'fix-convoy'])
391
+ expect(templates(calls).slice(-2)).toEqual(['convoy-plan-review', 'convoy-plan-fix'])
392
392
  expect(calls).toHaveLength(7)
393
393
  expect(outcome.plan.tasks[1].prompt).toBe('Add the toggle; read docs first.')
394
394
 
395
395
  const broken = stubAdapter({
396
- 'validate-convoy': fence({ valid: false, issues: ['x'] }),
397
- 'fix-convoy': fence([{ task_id: 'toggle', field: 'depends_on', value: ['ghost'] }]),
396
+ 'convoy-plan-review': fence({ valid: false, issues: ['x'] }),
397
+ 'convoy-plan-fix': fence([{ task_id: 'toggle', field: 'depends_on', value: ['ghost'] }]),
398
398
  })
399
399
  const kept = await plan(broken.adapter, { critic: true })
400
400
  expect(kept.plan.tasks[1].depends_on).toEqual(['theme'])
@@ -405,7 +405,7 @@ describe('planConvoy: sessions', () => {
405
405
  // ── Chain groups ────────────────────────────────────────────────────────────
406
406
 
407
407
  describe('planConvoy: groups', () => {
408
- /** generate-convoy for a group waits until every group's session has started. */
408
+ /** convoy-plan for a group waits until every group's session has started. */
409
409
  function groupAnswers() {
410
410
  let started = 0
411
411
  let most = 0
@@ -442,9 +442,9 @@ describe('planConvoy: groups', () => {
442
442
  }
443
443
  const groups = groupAnswers()
444
444
  const { adapter } = stubAdapter({
445
- 'validate-prd': slow(fence({ valid: true })),
446
- 'assess-complexity': slow(fence(CHAIN)),
447
- 'generate-convoy': groups.answer,
445
+ 'convoy-prd-review': slow(fence({ valid: true })),
446
+ 'convoy-assess': slow(fence(CHAIN)),
447
+ 'convoy-plan': groups.answer,
448
448
  })
449
449
  await plan(adapter)
450
450
  expect(most).toBe(2)
@@ -452,20 +452,20 @@ describe('planConvoy: groups', () => {
452
452
 
453
453
  it('plans every group at the same time, from its own part of the PRD', async () => {
454
454
  const groups = groupAnswers()
455
- const { adapter, calls } = stubAdapter({ 'assess-complexity': fence(CHAIN), 'generate-convoy': groups.answer })
455
+ const { adapter, calls } = stubAdapter({ 'convoy-assess': fence(CHAIN), 'convoy-plan': groups.answer })
456
456
  await plan(adapter)
457
457
  expect(groups.most()).toBe(3)
458
- expect(calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('**Group name:**'))).toHaveLength(3)
458
+ expect(calls.filter((c) => c.template === 'convoy-plan' && c.prompt.includes('**Group name:**'))).toHaveLength(3)
459
459
  // The request is sized (beside its dropped plan), then the PRD again:
460
460
  // groups name the PRD's phases.
461
461
  expect(calls).toHaveLength(8)
462
- const docs = calls.find((c) => c.template === 'generate-convoy' && c.prompt.includes('**Group name:** docs'))!
462
+ const docs = calls.find((c) => c.template === 'convoy-plan' && c.prompt.includes('**Group name:** docs'))!
463
463
  expect(docs.prompt).not.toContain('Phase 1 — Theme')
464
464
  })
465
465
 
466
466
  it('joins the groups into one spec that keeps their dependencies', async () => {
467
467
  const groups = groupAnswers()
468
- const { adapter } = stubAdapter({ 'assess-complexity': fence(CHAIN), 'generate-convoy': groups.answer })
468
+ const { adapter } = stubAdapter({ 'convoy-assess': fence(CHAIN), 'convoy-plan': groups.answer })
469
469
  const outcome = await plan(adapter)
470
470
  expect(readdirSync(join(root, '.opencastle', 'convoys')).filter((f) => f.endsWith('.convoy.yml'))).toHaveLength(1)
471
471
  const spec = yamlParse(readFileSync(outcome.specPath, 'utf8'))
@@ -497,7 +497,7 @@ describe('planConvoy: the spec', () => {
497
497
 
498
498
  it('reduces a glob the planner wrote to a directory', async () => {
499
499
  const globbed = { ...PLAN, tasks: [{ ...PLAN.tasks[0], files: ['src/theme/**/*.ts'] }, PLAN.tasks[1]] }
500
- const { adapter } = stubAdapter({ 'generate-convoy': fence(globbed) })
500
+ const { adapter } = stubAdapter({ 'convoy-plan': fence(globbed) })
501
501
  const outcome = await plan(adapter)
502
502
  expect(outcome.plan.tasks[0].files).toEqual(['src/theme/'])
503
503
  })
@@ -526,17 +526,17 @@ describe('planConvoy: the complexity cache', () => {
526
526
  const prdPath = writePrd(PRD)
527
527
  const first = stubAdapter()
528
528
  await plan(first.adapter, { task: undefined, prdPath })
529
- expect(count(first.calls, 'assess-complexity')).toBe(1)
530
- expect(count(first.calls, 'generate-prd')).toBe(0)
529
+ expect(count(first.calls, 'convoy-assess')).toBe(1)
530
+ expect(count(first.calls, 'convoy-prd')).toBe(0)
531
531
 
532
532
  const second = stubAdapter()
533
533
  await plan(second.adapter, { task: undefined, prdPath })
534
- expect(count(second.calls, 'assess-complexity')).toBe(0)
534
+ expect(count(second.calls, 'convoy-assess')).toBe(0)
535
535
 
536
536
  writePrd(PRD + '\nOne more line.\n')
537
537
  const third = stubAdapter()
538
538
  await plan(third.adapter, { task: undefined, prdPath })
539
- expect(count(third.calls, 'assess-complexity')).toBe(1)
539
+ expect(count(third.calls, 'convoy-assess')).toBe(1)
540
540
  })
541
541
 
542
542
  it('ignores an assessment of different text at the same path', async () => {
@@ -545,7 +545,7 @@ describe('planConvoy: the complexity cache', () => {
545
545
  writeFileSync(deriveComplexityPath(prdPath), JSON.stringify(stale))
546
546
  const { adapter, calls } = stubAdapter()
547
547
  await plan(adapter, { task: undefined, prdPath })
548
- expect(count(calls, 'assess-complexity')).toBe(1)
548
+ expect(count(calls, 'convoy-assess')).toBe(1)
549
549
  const cached = JSON.parse(readFileSync(deriveComplexityPath(prdPath), 'utf8'))
550
550
  expect(cached.prd_sha256).toBe(hashPrd(PRD))
551
551
  expect(cached.recommended_strategy).toBe('single')
@@ -605,7 +605,7 @@ describe('convoy "<task>": show the plan, ask once', () => {
605
605
  await planTask({ args: ['--yes'], pkgRoot }, 'add dark mode')
606
606
  expect(promptModule.confirm).not.toHaveBeenCalled()
607
607
  expect(runModule.runSpec).toHaveBeenCalledWith(runArgs(), { runtime: resolved(stub.adapter) })
608
- expect(count(stub.calls, 'validate-convoy')).toBe(1)
608
+ expect(count(stub.calls, 'convoy-plan-review')).toBe(1)
609
609
  })
610
610
 
611
611
  it('carries --concurrency through to the run', async () => {
@@ -633,7 +633,7 @@ describe('convoy "<task>": show the plan, ask once', () => {
633
633
  expect(text()).toMatch(/TASK\s+AGENT/)
634
634
  expect(promptModule.confirm).not.toHaveBeenCalled()
635
635
  expect(runModule.runSpec).not.toHaveBeenCalled()
636
- expect(count(stub.calls, 'validate-convoy')).toBe(0)
636
+ expect(count(stub.calls, 'convoy-plan-review')).toBe(0)
637
637
  expect(text()).toContain('opencastle convoy run .opencastle/convoys/dark-mode.convoy.yml')
638
638
  })
639
639
 
@@ -660,13 +660,13 @@ describe('convoy "<task>": show the plan, ask once', () => {
660
660
  writeFileSync(prd, PRD)
661
661
  vi.mocked(promptModule.confirm).mockResolvedValue(false)
662
662
  await pipeline({ args: ['--prd', 'my.prd.md'], pkgRoot })
663
- expect(count(stub.calls, 'generate-prd')).toBe(0)
663
+ expect(count(stub.calls, 'convoy-prd')).toBe(0)
664
664
  expect(existsSync(specFile())).toBe(true)
665
665
  })
666
666
 
667
667
  it('does not offer to run a plan that fails its checks', async () => {
668
668
  const bad = { ...PLAN, tasks: [PLAN.tasks[0], { ...PLAN.tasks[1], timeout: 'soon' }] }
669
- stub = stubAdapter({ 'generate-convoy': fence(bad) })
669
+ stub = stubAdapter({ 'convoy-plan': fence(bad) })
670
670
  vi.mocked(adapters.resolveAdapter).mockResolvedValue(resolved(stub.adapter))
671
671
  const exit = vi.spyOn(process, 'exit').mockImplementation(((code?: number) => {
672
672
  throw new Error(`exit ${code}`)
@@ -335,7 +335,7 @@ async function writeCachedComplexity(prdPath: string, prdContent: string, assess
335
335
 
336
336
  // ── Planning ────────────────────────────────────────────────────────────────
337
337
 
338
- /** Rounds of fix-prd, and of fix-convoy, before the planner stops asking. */
338
+ /** Rounds of convoy-prd-fix, and of convoy-plan-fix, before the planner stops asking. */
339
339
  const MAX_FIX_ROUNDS = 2
340
340
 
341
341
  export interface PlanRequest {
@@ -352,7 +352,7 @@ export interface PlanRequest {
352
352
  projectRoot?: string
353
353
  verbose?: boolean
354
354
  /**
355
- * Have validate-convoy review the plan. Only when nobody will read it before
355
+ * Have convoy-plan-review review the plan. Only when nobody will read it before
356
356
  * it runs (`--yes`): a person looking at the plan is the better reviewer,
357
357
  * and the session is skipped for them.
358
358
  */
@@ -415,7 +415,7 @@ async function settleAll<T>(work: Array<Promise<T>>): Promise<T[]> {
415
415
  return settled.map((s) => (s as PromiseFulfilledResult<T>).value)
416
416
  }
417
417
 
418
- /** generate-convoy, with the one retry an unreadable answer gets. */
418
+ /** convoy-plan, with the one retry an unreadable answer gets. */
419
419
  async function generatePlan(
420
420
  step: StepRunner,
421
421
  goal: string,
@@ -428,7 +428,7 @@ async function generatePlan(
428
428
  let raw = ''
429
429
  let reason = ''
430
430
  for (let attempt = 1; attempt <= 2; attempt++) {
431
- raw = (await step('generate-convoy', { goalText: goal, contextText: context, signal, onStart })).rawOutput
431
+ raw = (await step('convoy-plan', { goalText: goal, contextText: context, signal, onStart })).rawOutput
432
432
  const parsed = parseTaskPlanWithReason(raw)
433
433
  if (parsed.plan) return parsed.plan
434
434
  reason = parsed.reason ?? 'unreadable'
@@ -440,9 +440,9 @@ async function generatePlan(
440
440
  throw new Error(`The ${label} plan could not be read after a retry: ${reason}. The answer is in ${relPath(kept)}.`)
441
441
  }
442
442
 
443
- /** One fix-convoy round: patches applied to the plan, globs reduced again. */
443
+ /** One convoy-plan-fix round: patches applied to the plan, globs reduced again. */
444
444
  async function fixPlan(step: StepRunner, plan: TaskPlan, problems: string): Promise<TaskPlan> {
445
- const answer = await step('fix-convoy', { goalText: JSON.stringify(plan, null, 2), contextText: problems })
445
+ const answer = await step('convoy-plan-fix', { goalText: JSON.stringify(plan, null, 2), contextText: problems })
446
446
  const patches = parsePatches(answer.rawOutput)
447
447
  if (!patches?.length) {
448
448
  warn('No usable patches came back')
@@ -493,19 +493,19 @@ function speculate<T>(start: (signal: AbortSignal, onStart: () => void) => Promi
493
493
  * From a request (or an edited PRD) to a checked spec on disk.
494
494
  *
495
495
  * Sessions, all read-only, on the one adapter the caller resolved:
496
- * - assess-complexity on the request, beside a plan written straight from it,
496
+ * - convoy-assess on the request, beside a plan written straight from it,
497
497
  * which is kept when the change is small and stopped when it is not;
498
- * - generate-prd, unless a PRD was given;
499
- * - validate-prd beside the plan from the PRD when how to plan it is already
500
- * known, or beside assess-complexity on the PRD when it is not, which is
501
- * skipped when this exact PRD was assessed before; up to two fix-prd +
502
- * validate-prd rounds, and the plan is written again from the fixed PRD;
503
- * - generate-convoy, once, or once per group at the same time for a large
498
+ * - convoy-prd, unless a PRD was given;
499
+ * - convoy-prd-review beside the plan from the PRD when how to plan it is already
500
+ * known, or beside convoy-assess on the PRD when it is not, which is
501
+ * skipped when this exact PRD was assessed before; up to two convoy-prd-fix +
502
+ * convoy-prd-review rounds, and the plan is written again from the fixed PRD;
503
+ * - convoy-plan, once, or once per group at the same time for a large
504
504
  * feature; one retry when an answer cannot be read;
505
- * - fix-convoy only when the code's checks fail, at most twice;
506
- * - validate-convoy only as the reviewer for `--yes`.
505
+ * - convoy-plan-fix only when the code's checks fail, at most twice;
506
+ * - convoy-plan-review only as the reviewer for `--yes`.
507
507
  *
508
- * The semantic validate-convoy pass that followed every plan is gone: the
508
+ * The semantic convoy-plan-review pass that followed every plan is gone: the
509
509
  * checks it was there for are done in code, and a person reads the plan
510
510
  * before it runs.
511
511
  */
@@ -563,9 +563,9 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
563
563
  if (!req.prdPath && req.task) {
564
564
  const task = req.task
565
565
  const direct = speculate((signal, onStart) => generatePlan(step, task, NO_PRD, 'task', convoyDir, signal, onStart))
566
- drafting = speculate((signal, onStart) => step('generate-prd', { goalText: task, signal, onStart }))
566
+ drafting = speculate((signal, onStart) => step('convoy-prd', { goalText: task, signal, onStart }))
567
567
  await Promise.all([direct.started, drafting.started])
568
- quick = await step('assess-complexity', { goalText: task, contextText: task })
568
+ quick = await step('convoy-assess', { goalText: task, contextText: task })
569
569
  .then((r) => parseComplexityAssessment(r.rawOutput))
570
570
  .catch(() => null)
571
571
  if (quick?.complexity === 'low' && quick.recommended_strategy !== 'chain') {
@@ -589,13 +589,13 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
589
589
  prdPath = resolve(root, req.prdPath)
590
590
  done('PRD', relPath(prdPath))
591
591
  } else {
592
- const written = drafting ? await drafting.value : await step('generate-prd', { goalText: req.task ?? '' })
592
+ const written = drafting ? await drafting.value : await step('convoy-prd', { goalText: req.task ?? '' })
593
593
  prdPath = written.outputPath!
594
594
  done('PRD written', relPath(prdPath))
595
595
  }
596
596
  let prd = await readFile(prdPath!, 'utf8')
597
597
 
598
- // Both only read the PRD, so they run side by side. fix-prd is told to keep
598
+ // Both only read the PRD, so they run side by side. convoy-prd-fix is told to keep
599
599
  // the PRD's phases, so the assessment of this draft still fits a fixed one;
600
600
  // it is cached under this draft's text, which is the text it describes.
601
601
  const cached = await readCachedComplexity(prdPath, prd)
@@ -617,10 +617,10 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
617
617
  let complexity: ComplexityAssessment | null
618
618
  try {
619
619
  ;[verdict, complexity] = await settleAll<PromptStepResult | ComplexityAssessment | null>([
620
- step('validate-prd', { goalText: `<!-- validation-pass: 1 -->\n${prd}` }),
620
+ step('convoy-prd-review', { goalText: `<!-- validation-pass: 1 -->\n${prd}` }),
621
621
  known
622
622
  ? Promise.resolve(known)
623
- : step('assess-complexity', { goalText: prd, contextText: req.task ?? '' })
623
+ : step('convoy-assess', { goalText: prd, contextText: req.task ?? '' })
624
624
  .then((r) => parseComplexityAssessment(r.rawOutput))
625
625
  .catch((err: unknown) => {
626
626
  warn(`Could not size the work (${message(err)}) — planning it as one`)
@@ -644,9 +644,9 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
644
644
  for (let round = 1; round <= MAX_FIX_ROUNDS && !fixed; round++) {
645
645
  warn(`The PRD has issues — fixing (${round}/${MAX_FIX_ROUNDS})`)
646
646
  console.log(indented(issues))
647
- await step('fix-prd', { goalText: prd, contextText: issues, outputPath: prdPath })
647
+ await step('convoy-prd-fix', { goalText: prd, contextText: issues, outputPath: prdPath })
648
648
  prd = await readFile(prdPath, 'utf8')
649
- const again = await step('validate-prd', { goalText: `<!-- validation-pass: ${round + 1} -->\n${prd}` })
649
+ const again = await step('convoy-prd-review', { goalText: `<!-- validation-pass: ${round + 1} -->\n${prd}` })
650
650
  fixed = again.isValid === true
651
651
  if (!fixed) issues = again.errors || again.rawOutput
652
652
  }
@@ -743,7 +743,7 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
743
743
  if (problems.length === 0) done('Plan checked')
744
744
 
745
745
  if (req.critic && problems.length === 0) {
746
- const review = await step('validate-convoy', { goalText: buildConvoyYaml(plan, settings) })
746
+ const review = await step('convoy-plan-review', { goalText: buildConvoyYaml(plan, settings) })
747
747
  if (review.isValid) {
748
748
  done('Plan reviewed')
749
749
  } else {
@@ -30,23 +30,21 @@ describe('fillTemplate', () => {
30
30
  })
31
31
  })
32
32
 
33
- // `pipeline`: only the CLI runs it. generate-convoy is the exception, as the
34
- // Team Lead also plans in the editor by its rules.
35
33
  const PLANNER = {
36
- 'generate-prd': { output: 'prd', context: false, pipeline: true },
37
- 'validate-prd': { output: 'validation', context: false, pipeline: true },
38
- 'fix-prd': { output: 'prd', context: true, pipeline: true },
39
- 'assess-complexity': { output: 'json', context: true, pipeline: true },
40
- 'generate-convoy': { output: 'json', context: true, pipeline: false },
41
- 'validate-convoy': { output: 'validation', context: false, pipeline: true },
42
- 'fix-convoy': { output: 'json', context: true, pipeline: true },
34
+ 'convoy-prd': { output: 'prd', context: false },
35
+ 'convoy-prd-review': { output: 'validation', context: false },
36
+ 'convoy-prd-fix': { output: 'prd', context: true },
37
+ 'convoy-assess': { output: 'json', context: true },
38
+ 'convoy-plan': { output: 'json', context: true },
39
+ 'convoy-plan-review': { output: 'validation', context: false },
40
+ 'convoy-plan-fix': { output: 'json', context: true },
43
41
  } as const
44
42
 
45
43
  describe('the planner templates', () => {
46
44
  it.each(Object.entries(PLANNER))('%s keeps its frontmatter and fills each input once', (name, expected) => {
47
45
  const text = readFileSync(templatePath(pkgRoot, name), 'utf8')
48
46
  const fm = parseFrontmatter(text)
49
- expect(Object.keys(fm).sort()).toEqual(['agent', 'description', 'output', ...(expected.pipeline ? ['pipeline'] : [])])
47
+ expect(Object.keys(fm).sort()).toEqual(['agent', 'description', 'output'])
50
48
  expect(fm.output).toBe(expected.output)
51
49
 
52
50
  // Exactly one slot per input, and no other mention that a fill could reach.
@@ -140,7 +138,7 @@ describe('runPromptStep', () => {
140
138
 
141
139
  it('runs read-only, in the project, as the template agent', async () => {
142
140
  const { adapter, seen } = adapterAnswering('```json\n{"valid": true}\n```')
143
- const result = await runPromptStep({ template: 'validate-prd', goalText: '# PRD', adapter, pkgRoot, cwd })
141
+ const result = await runPromptStep({ template: 'convoy-prd-review', goalText: '# PRD', adapter, pkgRoot, cwd })
144
142
  expect(result.isValid).toBe(true)
145
143
  expect(seen[0].options).toMatchObject({ permissionMode: 'plan', cwd })
146
144
  expect(seen[0].task.agent).toBe('reviewer')
@@ -150,45 +148,45 @@ describe('runPromptStep', () => {
150
148
  it('writes the plan on the standard tier and checks it on economy, when the runtime has tier models', async () => {
151
149
  const { adapter, seen } = adapterAnswering('```json\n{"valid": true}\n```')
152
150
  adapter.tierModels = { premium: 'opus', standard: 'sonnet', economy: 'haiku' }
153
- await runPromptStep({ template: 'validate-prd', goalText: '# PRD', adapter, pkgRoot, cwd })
154
- await runPromptStep({ template: 'generate-prd', goalText: 'add tags', adapter, pkgRoot, cwd })
151
+ await runPromptStep({ template: 'convoy-prd-review', goalText: '# PRD', adapter, pkgRoot, cwd })
152
+ await runPromptStep({ template: 'convoy-prd', goalText: 'add tags', adapter, pkgRoot, cwd })
155
153
  expect(seen[0].options?.model).toBe('haiku')
156
154
  expect(seen[1].options?.model).toBe('sonnet')
157
155
  })
158
156
 
159
157
  it('passes no model when the runtime has none for its tiers', async () => {
160
158
  const { adapter, seen } = adapterAnswering('```json\n{"valid": true}\n```')
161
- await runPromptStep({ template: 'validate-prd', goalText: '# PRD', adapter, pkgRoot, cwd })
159
+ await runPromptStep({ template: 'convoy-prd-review', goalText: '# PRD', adapter, pkgRoot, cwd })
162
160
  expect(seen[0].options).not.toHaveProperty('model')
163
161
  })
164
162
 
165
163
  it('names a Team Lead step by its slug', async () => {
166
164
  const { adapter, seen } = adapterAnswering('```json\n[]\n```')
167
- await runPromptStep({ template: 'fix-convoy', goalText: '{}', contextText: '- x', adapter, pkgRoot, cwd })
165
+ await runPromptStep({ template: 'convoy-plan-fix', goalText: '{}', contextText: '- x', adapter, pkgRoot, cwd })
168
166
  expect(seen[0].task.agent).toBe('team-lead')
169
167
  })
170
168
 
171
169
  it('writes a PRD to a new file under .opencastle/prds', async () => {
172
170
  const { adapter } = adapterAnswering('Sure!\n# Dark Mode — PRD\n\n## Overview\n\nText.')
173
- const first = await runPromptStep({ template: 'generate-prd', goalText: 'dark mode', adapter, pkgRoot, cwd })
171
+ const first = await runPromptStep({ template: 'convoy-prd', goalText: 'dark mode', adapter, pkgRoot, cwd })
174
172
  expect(first.outputPath).toBe(join(cwd, '.opencastle', 'prds', 'dark-mode.prd.md'))
175
173
  expect(readFileSync(first.outputPath!, 'utf8')).toBe('# Dark Mode — PRD\n\n## Overview\n\nText.\n')
176
- const second = await runPromptStep({ template: 'generate-prd', goalText: 'dark mode', adapter, pkgRoot, cwd })
174
+ const second = await runPromptStep({ template: 'convoy-prd', goalText: 'dark mode', adapter, pkgRoot, cwd })
177
175
  expect(second.outputPath).toBe(join(cwd, '.opencastle', 'prds', 'dark-mode-2.prd.md'))
178
176
  expect(existsSync(first.outputPath!)).toBe(true)
179
177
  })
180
178
 
181
179
  it('reports an adapter failure with its output', async () => {
182
180
  const { adapter } = adapterAnswering('auth expired', false)
183
- await expect(runPromptStep({ template: 'validate-prd', goalText: 'x', adapter, pkgRoot, cwd })).rejects.toThrow(
184
- /stub failed on validate-prd \(exit code 2\)[\s\S]*auth expired/,
181
+ await expect(runPromptStep({ template: 'convoy-prd-review', goalText: 'x', adapter, pkgRoot, cwd })).rejects.toThrow(
182
+ /stub failed on convoy-prd-review \(exit code 2\)[\s\S]*auth expired/,
185
183
  )
186
184
  })
187
185
 
188
186
  it('stops a session that runs too long', async () => {
189
187
  const { adapter, kill } = adapterAnswering(() => new Promise<never>(() => {}))
190
188
  await expect(
191
- runPromptStep({ template: 'validate-prd', goalText: 'x', adapter, pkgRoot, cwd, timeoutMs: 20 }),
189
+ runPromptStep({ template: 'convoy-prd-review', goalText: 'x', adapter, pkgRoot, cwd, timeoutMs: 20 }),
192
190
  ).rejects.toThrow(/ran longer than/)
193
191
  expect(kill).toHaveBeenCalledTimes(1)
194
192
  })