opencastle 1.4.1 → 1.4.3
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/dist/cli/adapters/adapter-contract.test.js +85 -2
- package/dist/cli/adapters/adapter-contract.test.js.map +1 -1
- package/dist/cli/adapters/antigravity.d.ts +5 -4
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/antigravity.js +5 -4
- package/dist/cli/adapters/antigravity.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +25 -19
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +10 -7
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +11 -5
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/workflows.d.ts +33 -0
- package/dist/cli/adapters/workflows.d.ts.map +1 -0
- package/dist/cli/adapters/workflows.js +58 -0
- package/dist/cli/adapters/workflows.js.map +1 -0
- package/dist/cli/adapters/workflows.test.d.ts +2 -0
- package/dist/cli/adapters/workflows.test.d.ts.map +1 -0
- package/dist/cli/adapters/workflows.test.js +62 -0
- package/dist/cli/adapters/workflows.test.js.map +1 -0
- package/dist/cli/convoy/spec-types.d.ts +15 -0
- package/dist/cli/convoy/spec-types.d.ts.map +1 -1
- package/dist/cli/docs-accuracy.test.js +3 -3
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +3 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.flow.test.js +134 -27
- package/dist/cli/pipeline.flow.test.js.map +1 -1
- package/dist/cli/pipeline.js +113 -34
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/plan.d.ts +22 -0
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +43 -6
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/run/adapters/claude.d.ts +13 -0
- package/dist/cli/run/adapters/claude.d.ts.map +1 -1
- package/dist/cli/run/adapters/claude.js +30 -1
- package/dist/cli/run/adapters/claude.js.map +1 -1
- package/dist/cli/run/adapters/claude.test.js +34 -1
- package/dist/cli/run/adapters/claude.test.js.map +1 -1
- package/dist/cli/run/adapters/codex.d.ts.map +1 -1
- package/dist/cli/run/adapters/codex.js +4 -0
- package/dist/cli/run/adapters/codex.js.map +1 -1
- package/dist/cli/run/adapters/codex.test.js +8 -0
- package/dist/cli/run/adapters/codex.test.js.map +1 -1
- package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
- package/dist/cli/run/adapters/copilot.js +4 -1
- package/dist/cli/run/adapters/copilot.js.map +1 -1
- package/dist/cli/run/adapters/copilot.test.js +9 -0
- package/dist/cli/run/adapters/copilot.test.js.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +2 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.js +16 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -1
- package/dist/cli/run/platform.d.ts +12 -0
- package/dist/cli/run/platform.d.ts.map +1 -1
- package/dist/cli/run/platform.js +49 -0
- package/dist/cli/run/platform.js.map +1 -1
- package/dist/cli/run/platform.test.js +21 -1
- package/dist/cli/run/platform.test.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/adapters/adapter-contract.test.ts +89 -2
- package/src/cli/adapters/antigravity.ts +5 -4
- package/src/cli/adapters/rules-dir-base.ts +30 -19
- package/src/cli/adapters/single-file-base.ts +10 -6
- package/src/cli/adapters/vscode.ts +11 -4
- package/src/cli/adapters/workflows.test.ts +70 -0
- package/src/cli/adapters/workflows.ts +62 -0
- package/src/cli/convoy/spec-types.ts +15 -0
- package/src/cli/docs-accuracy.test.ts +3 -3
- package/src/cli/explain.ts +3 -1
- package/src/cli/pipeline.flow.test.ts +143 -28
- package/src/cli/pipeline.ts +141 -34
- package/src/cli/plan.ts +51 -6
- package/src/cli/run/adapters/claude.test.ts +39 -1
- package/src/cli/run/adapters/claude.ts +27 -1
- package/src/cli/run/adapters/codex.test.ts +9 -0
- package/src/cli/run/adapters/codex.ts +3 -0
- package/src/cli/run/adapters/copilot.test.ts +11 -0
- package/src/cli/run/adapters/copilot.ts +3 -1
- package/src/cli/run/adapters/stub-cli.test-helper.ts +16 -1
- package/src/cli/run/platform.test.ts +23 -1
- package/src/cli/run/platform.ts +50 -0
- package/src/orchestrator/agent-workflows/README.md +2 -0
- package/src/orchestrator/agent-workflows/bug-fix.md +3 -3
- package/src/orchestrator/agent-workflows/data-pipeline.md +2 -2
- package/src/orchestrator/agent-workflows/database-migration.md +2 -2
- package/src/orchestrator/agent-workflows/feature-implementation.md +2 -2
- package/src/orchestrator/agent-workflows/performance-optimization.md +3 -3
- package/src/orchestrator/agent-workflows/refactoring.md +2 -2
- package/src/orchestrator/agent-workflows/schema-changes.md +2 -2
- package/src/orchestrator/agent-workflows/security-audit.md +2 -2
- package/src/orchestrator/agents/architect.agent.md +1 -1
- package/src/orchestrator/agents/content-engineer.agent.md +1 -1
- package/src/orchestrator/agents/data-engineer.agent.md +1 -1
- package/src/orchestrator/agents/developer.agent.md +1 -1
- package/src/orchestrator/agents/devops-expert.agent.md +1 -1
- package/src/orchestrator/agents/performance-expert.agent.md +1 -1
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/agents/security-expert.agent.md +1 -1
- package/src/orchestrator/agents/team-lead.agent.md +3 -4
- package/src/orchestrator/agents/testing-expert.agent.md +1 -1
- package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -1
- package/src/orchestrator/agents/writer.agent.md +1 -1
- package/src/orchestrator/instructions/general.instructions.md +2 -2
- package/src/orchestrator/plugins/chrome-devtools/skills/browser-testing/SKILL.md +1 -1
- package/src/orchestrator/plugins/nx/skills/nx-workspace/SKILL.md +1 -1
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/bug-fix.prompt.md +3 -3
- package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
- package/src/orchestrator/prompts/quick-refinement.prompt.md +2 -2
- package/src/orchestrator/skills/api-patterns/SKILL.md +1 -1
- package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
- package/src/orchestrator/skills/team-lead-reference/SKILL.md +11 -11
- package/src/orchestrator/skills/validation-gates/SKILL.md +1 -1
|
@@ -95,10 +95,17 @@ interface Call {
|
|
|
95
95
|
permissionMode?: string
|
|
96
96
|
cwd?: string
|
|
97
97
|
prompt: string
|
|
98
|
+
effort?: string
|
|
99
|
+
lean?: boolean
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
/** An answer that never comes: the session runs until it is stopped. */
|
|
103
|
+
const never = (): Promise<string> => new Promise(() => {})
|
|
104
|
+
|
|
105
|
+
function stubAdapter(answers: Record<string, Answer> = {}): { adapter: AgentAdapter; calls: Call[]; killed: string[] } {
|
|
101
106
|
const calls: Call[] = []
|
|
107
|
+
const killed: string[] = []
|
|
108
|
+
const stoppers = new Map<string, Array<() => void>>()
|
|
102
109
|
const seen = new Map<string, number>()
|
|
103
110
|
const defaults: Record<string, Answer> = {
|
|
104
111
|
'generate-prd': PRD,
|
|
@@ -113,15 +120,30 @@ function stubAdapter(answers: Record<string, Answer> = {}): { adapter: AgentAdap
|
|
|
113
120
|
name: 'stub',
|
|
114
121
|
isAvailable: async () => true,
|
|
115
122
|
async execute(task: Task, options?: ExecuteOptions) {
|
|
116
|
-
calls.push({
|
|
123
|
+
calls.push({
|
|
124
|
+
template: task.id,
|
|
125
|
+
permissionMode: options?.permissionMode,
|
|
126
|
+
cwd: options?.cwd,
|
|
127
|
+
prompt: task.prompt,
|
|
128
|
+
effort: options?.effort,
|
|
129
|
+
lean: options?.lean,
|
|
130
|
+
})
|
|
117
131
|
const nth = (seen.get(task.id) ?? 0) + 1
|
|
118
132
|
seen.set(task.id, nth)
|
|
119
133
|
const answer = answers[task.id] ?? defaults[task.id]
|
|
120
|
-
|
|
134
|
+
// Stopped like a real runtime: the process ends and reports a failure.
|
|
135
|
+
const stopped = new Promise<null>((r) => stoppers.set(task.id, [...(stoppers.get(task.id) ?? []), () => r(null)]))
|
|
136
|
+
const output = await Promise.race([typeof answer === 'function' ? answer(task.prompt, nth) : answer, stopped])
|
|
137
|
+
if (output === null) return { success: false, output: 'stopped', exitCode: 143 }
|
|
121
138
|
return { success: true, output, exitCode: 0 }
|
|
122
139
|
},
|
|
140
|
+
kill(task: Task) {
|
|
141
|
+
killed.push(task.id)
|
|
142
|
+
for (const stop of stoppers.get(task.id) ?? []) stop()
|
|
143
|
+
stoppers.delete(task.id)
|
|
144
|
+
},
|
|
123
145
|
}
|
|
124
|
-
return { adapter, calls }
|
|
146
|
+
return { adapter, calls, killed }
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
const templates = (calls: Call[]): string[] => calls.map((c) => c.template)
|
|
@@ -157,10 +179,14 @@ function plan(adapter: AgentAdapter, extra: Partial<Parameters<typeof planConvoy
|
|
|
157
179
|
// ── Sessions ────────────────────────────────────────────────────────────────
|
|
158
180
|
|
|
159
181
|
describe('planConvoy: sessions', () => {
|
|
160
|
-
it('
|
|
182
|
+
it('starts five sessions when every answer is good, with no semantic review of the plan', async () => {
|
|
161
183
|
const { adapter, calls } = stubAdapter()
|
|
162
184
|
const outcome = await plan(adapter)
|
|
163
|
-
|
|
185
|
+
// The plan from the request is dropped once the size says a PRD is needed;
|
|
186
|
+
// the plan from the PRD is the one kept.
|
|
187
|
+
expect([...templates(calls)].sort()).toEqual([
|
|
188
|
+
'assess-complexity', 'generate-convoy', 'generate-convoy', 'generate-prd', 'validate-prd',
|
|
189
|
+
])
|
|
164
190
|
expect(outcome.problems).toEqual([])
|
|
165
191
|
})
|
|
166
192
|
|
|
@@ -177,26 +203,96 @@ describe('planConvoy: sessions', () => {
|
|
|
177
203
|
it('sends the PRD to generate-convoy once', async () => {
|
|
178
204
|
const { adapter, calls } = stubAdapter()
|
|
179
205
|
await plan(adapter)
|
|
180
|
-
const
|
|
181
|
-
expect(
|
|
182
|
-
expect(prompt).
|
|
206
|
+
const fromPrd = calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('PRD-MARKER'))
|
|
207
|
+
expect(fromPrd).toHaveLength(1)
|
|
208
|
+
expect(fromPrd[0].prompt.match(/PRD-MARKER/g)).toHaveLength(1)
|
|
209
|
+
expect(fromPrd[0].prompt).not.toMatch(/\{\{(goal|context)\}\}/)
|
|
183
210
|
})
|
|
184
211
|
|
|
185
212
|
it('plans a small change straight from the request, with no PRD', async () => {
|
|
186
213
|
const { adapter, calls } = stubAdapter({ 'assess-complexity': fence({ ...SINGLE, complexity: 'low' }) })
|
|
187
214
|
const outcome = await plan(adapter)
|
|
188
|
-
|
|
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'])
|
|
189
217
|
expect(outcome.prdPath).toBeNull()
|
|
190
218
|
expect(existsSync(join(root, '.opencastle', 'prds'))).toBe(false)
|
|
191
|
-
expect(calls
|
|
219
|
+
expect(calls.find((c) => c.template === 'generate-convoy')!.prompt).toContain('There is no PRD: this is a small change')
|
|
192
220
|
expect(outcome.problems).toEqual([])
|
|
193
221
|
})
|
|
194
222
|
|
|
223
|
+
it('sizes a request and plans it at the same time', async () => {
|
|
224
|
+
let inFlight = 0
|
|
225
|
+
let most = 0
|
|
226
|
+
const overlap = (answer: string) => async () => {
|
|
227
|
+
inFlight++
|
|
228
|
+
most = Math.max(most, inFlight)
|
|
229
|
+
await new Promise((r) => setTimeout(r, 20))
|
|
230
|
+
inFlight--
|
|
231
|
+
return answer
|
|
232
|
+
}
|
|
233
|
+
const { adapter } = stubAdapter({
|
|
234
|
+
'assess-complexity': overlap(fence({ ...SINGLE, complexity: 'low' })),
|
|
235
|
+
'generate-convoy': overlap(fence(PLAN)),
|
|
236
|
+
})
|
|
237
|
+
await plan(adapter)
|
|
238
|
+
expect(most).toBe(2)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it('stops the PRD as soon as the size says the change is small', async () => {
|
|
242
|
+
const { adapter, killed } = stubAdapter({
|
|
243
|
+
'assess-complexity': fence({ ...SINGLE, complexity: 'low' }),
|
|
244
|
+
'generate-prd': never,
|
|
245
|
+
})
|
|
246
|
+
const outcome = await plan(adapter)
|
|
247
|
+
expect(killed).toEqual(['generate-prd'])
|
|
248
|
+
expect(outcome.prdPath).toBeNull()
|
|
249
|
+
expect(outcome.plan.name).toBe('Dark mode')
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
it('stops the plan from the request as soon as the size says a PRD is needed', async () => {
|
|
253
|
+
const { adapter, calls, killed } = stubAdapter({
|
|
254
|
+
'generate-convoy': (prompt) => (prompt.includes('PRD-MARKER') ? fence(PLAN) : never()),
|
|
255
|
+
})
|
|
256
|
+
const outcome = await plan(adapter)
|
|
257
|
+
expect(killed).toEqual(['generate-convoy'])
|
|
258
|
+
expect(outcome.prdPath).not.toBeNull()
|
|
259
|
+
expect(outcome.plan.name).toBe('Dark mode')
|
|
260
|
+
// A stopped session counts, and makes the cost a lower bound.
|
|
261
|
+
expect(outcome.planning?.sessions).toBe(calls.length)
|
|
262
|
+
expect(outcome.planning?.costComplete).toBe(false)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('plans from the PRD beside its review, and again from the fixed PRD when the review fails', async () => {
|
|
266
|
+
const fixedPrd = PRD.replace('PRD-MARKER', 'FIXED-MARKER')
|
|
267
|
+
const { adapter, calls, killed } = stubAdapter({
|
|
268
|
+
'validate-prd': (_p, n) => fence({ valid: n > 1, issues: ['US-1: unclear'] }),
|
|
269
|
+
'fix-prd': fixedPrd,
|
|
270
|
+
// The plan from the request ends at once; the one from the draft PRD
|
|
271
|
+
// runs until it is stopped.
|
|
272
|
+
'generate-convoy': (prompt) => (prompt.includes('PRD-MARKER') ? never() : fence(PLAN)),
|
|
273
|
+
})
|
|
274
|
+
const outcome = await plan(adapter)
|
|
275
|
+
expect(killed).toEqual(['generate-convoy'])
|
|
276
|
+
const last = calls.filter((c) => c.template === 'generate-convoy').at(-1)!
|
|
277
|
+
expect(last.prompt).toContain('FIXED-MARKER')
|
|
278
|
+
expect(outcome.problems).toEqual([])
|
|
279
|
+
})
|
|
280
|
+
|
|
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'] }) })
|
|
283
|
+
await plan(adapter, { critic: true })
|
|
284
|
+
expect(new Set(calls.map((c) => c.template)).size).toBeGreaterThanOrEqual(6)
|
|
285
|
+
for (const call of calls) {
|
|
286
|
+
expect(call.effort, call.template).toBe(call.template === 'generate-convoy' ? 'medium' : 'low')
|
|
287
|
+
expect(call.lean, call.template).toBe(true)
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
|
|
195
291
|
it('sizes a larger request once, and does not size its PRD again', async () => {
|
|
196
292
|
const { adapter, calls } = stubAdapter()
|
|
197
293
|
await plan(adapter)
|
|
198
294
|
expect(count(calls, 'assess-complexity')).toBe(1)
|
|
199
|
-
expect(templates(calls)
|
|
295
|
+
expect(templates(calls).slice(0, 3).sort()).toEqual(['assess-complexity', 'generate-convoy', 'generate-prd'])
|
|
200
296
|
})
|
|
201
297
|
|
|
202
298
|
it('fixes an invalid PRD at most twice, then plans from it anyway', async () => {
|
|
@@ -204,7 +300,10 @@ describe('planConvoy: sessions', () => {
|
|
|
204
300
|
const outcome = await plan(adapter)
|
|
205
301
|
expect(count(calls, 'fix-prd')).toBe(2)
|
|
206
302
|
expect(count(calls, 'validate-prd')).toBe(3)
|
|
207
|
-
|
|
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)
|
|
305
|
+
expect(calls).toHaveLength(10)
|
|
306
|
+
expect(templates(calls).at(-1)).toBe('generate-convoy')
|
|
208
307
|
expect(outcome.problems).toEqual([])
|
|
209
308
|
})
|
|
210
309
|
|
|
@@ -212,7 +311,7 @@ describe('planConvoy: sessions', () => {
|
|
|
212
311
|
const { adapter, calls } = stubAdapter({ 'validate-prd': (_p, n) => fence({ valid: n > 1, issues: ['x'] }) })
|
|
213
312
|
await plan(adapter)
|
|
214
313
|
expect(count(calls, 'fix-prd')).toBe(1)
|
|
215
|
-
expect(calls).toHaveLength(
|
|
314
|
+
expect(calls).toHaveLength(8)
|
|
216
315
|
})
|
|
217
316
|
|
|
218
317
|
it('asks fix-convoy only when the checks fail, and never validate-convoy', async () => {
|
|
@@ -224,14 +323,21 @@ describe('planConvoy: sessions', () => {
|
|
|
224
323
|
const outcome = await plan(adapter)
|
|
225
324
|
expect(count(calls, 'fix-convoy')).toBe(1)
|
|
226
325
|
expect(count(calls, 'validate-convoy')).toBe(0)
|
|
227
|
-
expect(calls).toHaveLength(
|
|
326
|
+
expect(calls).toHaveLength(6)
|
|
228
327
|
expect(outcome.problems).toEqual([])
|
|
229
328
|
})
|
|
230
329
|
|
|
231
330
|
it('retries an unreadable plan once', async () => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
331
|
+
// The plan that is kept, from the PRD; the one from the request is dropped
|
|
332
|
+
// as soon as the size is known, whether or not it got to its own retry.
|
|
333
|
+
let fromPrd = 0
|
|
334
|
+
const { adapter, calls } = stubAdapter({
|
|
335
|
+
'generate-convoy': (prompt) =>
|
|
336
|
+
prompt.includes('PRD-MARKER') && fromPrd++ === 0 ? 'Sorry, here you go: {' : fence(PLAN),
|
|
337
|
+
})
|
|
338
|
+
const outcome = await plan(adapter)
|
|
339
|
+
expect(calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('PRD-MARKER'))).toHaveLength(2)
|
|
340
|
+
expect(outcome.plan.name).toBe('Dark mode')
|
|
235
341
|
})
|
|
236
342
|
|
|
237
343
|
it('keeps the unreadable answer for inspection when the retry fails too', async () => {
|
|
@@ -242,14 +348,21 @@ describe('planConvoy: sessions', () => {
|
|
|
242
348
|
|
|
243
349
|
it('is bounded in the worst case, and reports what is left', async () => {
|
|
244
350
|
const bad = { ...PLAN, tasks: [PLAN.tasks[0], { ...PLAN.tasks[1], timeout: 'soon' }] }
|
|
351
|
+
let fromFixed = 0
|
|
245
352
|
const { adapter, calls } = stubAdapter({
|
|
246
353
|
'validate-prd': fence({ valid: false, issues: ['x'] }),
|
|
247
|
-
|
|
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
|
|
357
|
+
? '```json\n{ "name": "x", "tasks": [\n```'
|
|
358
|
+
: fence(bad),
|
|
248
359
|
'fix-convoy': fence([{ task_id: 'toggle', field: 'timeout', value: 'later' }]),
|
|
249
360
|
})
|
|
250
361
|
const outcome = await plan(adapter, { critic: true })
|
|
251
|
-
//
|
|
252
|
-
|
|
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.
|
|
365
|
+
expect(calls).toHaveLength(13)
|
|
253
366
|
expect(count(calls, 'validate-convoy')).toBe(0) // no review of a plan that cannot run
|
|
254
367
|
expect(outcome.problems.join('\n')).toContain('timeout')
|
|
255
368
|
})
|
|
@@ -276,7 +389,7 @@ describe('planConvoy: sessions', () => {
|
|
|
276
389
|
})
|
|
277
390
|
const outcome = await plan(adapter, { critic: true })
|
|
278
391
|
expect(templates(calls).slice(-2)).toEqual(['validate-convoy', 'fix-convoy'])
|
|
279
|
-
expect(calls).toHaveLength(
|
|
392
|
+
expect(calls).toHaveLength(7)
|
|
280
393
|
expect(outcome.plan.tasks[1].prompt).toBe('Add the toggle; read docs first.')
|
|
281
394
|
|
|
282
395
|
const broken = stubAdapter({
|
|
@@ -342,9 +455,10 @@ describe('planConvoy: groups', () => {
|
|
|
342
455
|
const { adapter, calls } = stubAdapter({ 'assess-complexity': fence(CHAIN), 'generate-convoy': groups.answer })
|
|
343
456
|
await plan(adapter)
|
|
344
457
|
expect(groups.most()).toBe(3)
|
|
345
|
-
expect(
|
|
346
|
-
// The request is sized, then the PRD again:
|
|
347
|
-
|
|
458
|
+
expect(calls.filter((c) => c.template === 'generate-convoy' && c.prompt.includes('**Group name:**'))).toHaveLength(3)
|
|
459
|
+
// The request is sized (beside its dropped plan), then the PRD again:
|
|
460
|
+
// groups name the PRD's phases.
|
|
461
|
+
expect(calls).toHaveLength(8)
|
|
348
462
|
const docs = calls.find((c) => c.template === 'generate-convoy' && c.prompt.includes('**Group name:** docs'))!
|
|
349
463
|
expect(docs.prompt).not.toContain('Phase 1 — Theme')
|
|
350
464
|
})
|
|
@@ -528,7 +642,7 @@ describe('convoy "<task>": show the plan, ask once', () => {
|
|
|
528
642
|
await planTask({ args: [], pkgRoot }, 'add dark mode')
|
|
529
643
|
expect(adapters.resolveAdapter).toHaveBeenCalledTimes(1)
|
|
530
644
|
expect(adapters.resolveAdapter).toHaveBeenCalledWith({ projectRoot: root, explicit: null })
|
|
531
|
-
expect(stub.calls.length).toBe(
|
|
645
|
+
expect(stub.calls.length).toBe(5)
|
|
532
646
|
})
|
|
533
647
|
|
|
534
648
|
it('stops before planning when no runtime can be found', async () => {
|
|
@@ -600,8 +714,9 @@ describe('the plan says what planning spent', () => {
|
|
|
600
714
|
})
|
|
601
715
|
|
|
602
716
|
it('counts the sessions planConvoy ran', async () => {
|
|
603
|
-
const { adapter } = stubAdapter()
|
|
717
|
+
const { adapter, calls } = stubAdapter()
|
|
604
718
|
const outcome = await plan(adapter)
|
|
605
|
-
expect(outcome.planning?.sessions).toBe(
|
|
719
|
+
expect(outcome.planning?.sessions).toBe(5)
|
|
720
|
+
expect(calls).toHaveLength(5)
|
|
606
721
|
})
|
|
607
722
|
})
|
package/src/cli/pipeline.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
|
1
|
+
import { readFile, writeFile, mkdir, rm, rmdir } from 'node:fs/promises'
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import { createHash } from 'node:crypto'
|
|
4
|
-
import { resolve, relative, basename } from 'node:path'
|
|
4
|
+
import { resolve, relative, basename, dirname } from 'node:path'
|
|
5
5
|
import { c, confirm, closePrompts } from './prompt.js'
|
|
6
|
-
import { runPromptStep, freePath } from './plan.js'
|
|
6
|
+
import { runPromptStep, freePath, StepCancelled } from './plan.js'
|
|
7
7
|
import type { PromptStepOptions, PromptStepResult } from './plan.js'
|
|
8
8
|
import { resolveAdapter, cleanupAdapters, type ResolvedAdapter } from './run/adapters/index.js'
|
|
9
9
|
import { findProjectRoot } from './convoy/read-model.js'
|
|
@@ -416,11 +416,19 @@ async function settleAll<T>(work: Array<Promise<T>>): Promise<T[]> {
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
/** generate-convoy, with the one retry an unreadable answer gets. */
|
|
419
|
-
async function generatePlan(
|
|
419
|
+
async function generatePlan(
|
|
420
|
+
step: StepRunner,
|
|
421
|
+
goal: string,
|
|
422
|
+
context: string,
|
|
423
|
+
label: string,
|
|
424
|
+
convoyDir: string,
|
|
425
|
+
signal?: AbortSignal,
|
|
426
|
+
onStart?: () => void,
|
|
427
|
+
): Promise<TaskPlan> {
|
|
420
428
|
let raw = ''
|
|
421
429
|
let reason = ''
|
|
422
430
|
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
423
|
-
raw = (await step('generate-convoy', { goalText: goal, contextText: context })).rawOutput
|
|
431
|
+
raw = (await step('generate-convoy', { goalText: goal, contextText: context, signal, onStart })).rawOutput
|
|
424
432
|
const parsed = parseTaskPlanWithReason(raw)
|
|
425
433
|
if (parsed.plan) return parsed.plan
|
|
426
434
|
reason = parsed.reason ?? 'unreadable'
|
|
@@ -443,13 +451,55 @@ async function fixPlan(step: StepRunner, plan: TaskPlan, problems: string): Prom
|
|
|
443
451
|
return normalizePlanFiles(applyPatches(plan, patches)).plan
|
|
444
452
|
}
|
|
445
453
|
|
|
454
|
+
/**
|
|
455
|
+
* A step started before the planner knows it will use it.
|
|
456
|
+
*
|
|
457
|
+
* Planning was a chain of sessions, each waiting for the one before, and every
|
|
458
|
+
* session costs its start-up and its answer however short the question. Where
|
|
459
|
+
* the next step does not depend on the answer it waits for, it starts at the
|
|
460
|
+
* same time, and is stopped if that answer says it is not needed.
|
|
461
|
+
*/
|
|
462
|
+
interface Speculation<T> {
|
|
463
|
+
value: Promise<T>
|
|
464
|
+
/**
|
|
465
|
+
* Settles once its session has started, or once the step has failed without
|
|
466
|
+
* one. The planner waits for it before starting the step that decides, so
|
|
467
|
+
* the same answers always lead to the same sessions.
|
|
468
|
+
*/
|
|
469
|
+
started: Promise<void>
|
|
470
|
+
/** Stop the session and wait until it has stopped: its answer, if it finished first. */
|
|
471
|
+
drop(): Promise<T | undefined>
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function speculate<T>(start: (signal: AbortSignal, onStart: () => void) => Promise<T>): Speculation<T> {
|
|
475
|
+
const control = new AbortController()
|
|
476
|
+
let began!: () => void
|
|
477
|
+
const sessionStarted = new Promise<void>((r) => (began = r))
|
|
478
|
+
const value = start(control.signal, began)
|
|
479
|
+
// Settled whether or not anyone awaits it, so a dropped step is not an
|
|
480
|
+
// unhandled rejection.
|
|
481
|
+
const settled = value.then((v) => v, () => undefined)
|
|
482
|
+
return {
|
|
483
|
+
value,
|
|
484
|
+
started: Promise.race([sessionStarted, settled.then(() => undefined)]),
|
|
485
|
+
drop: async () => {
|
|
486
|
+
control.abort()
|
|
487
|
+
return settled
|
|
488
|
+
},
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
446
492
|
/**
|
|
447
493
|
* From a request (or an edited PRD) to a checked spec on disk.
|
|
448
494
|
*
|
|
449
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,
|
|
497
|
+
* which is kept when the change is small and stopped when it is not;
|
|
450
498
|
* - generate-prd, unless a PRD was given;
|
|
451
|
-
* - validate-prd beside
|
|
452
|
-
*
|
|
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;
|
|
453
503
|
* - generate-convoy, once, or once per group at the same time for a large
|
|
454
504
|
* feature; one retry when an answer cannot be read;
|
|
455
505
|
* - fix-convoy only when the code's checks fail, at most twice;
|
|
@@ -459,6 +509,15 @@ async function fixPlan(step: StepRunner, plan: TaskPlan, problems: string): Prom
|
|
|
459
509
|
* checks it was there for are done in code, and a person reads the plan
|
|
460
510
|
* before it runs.
|
|
461
511
|
*/
|
|
512
|
+
function tasksPlanned(plan: TaskPlan): string {
|
|
513
|
+
return `${plan.tasks.length} task${plan.tasks.length === 1 ? '' : 's'}`
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** Whether an assessment asks for the work to be planned as groups, side by side. */
|
|
517
|
+
function inGroups(c: ComplexityAssessment): boolean {
|
|
518
|
+
return c.recommended_strategy === 'chain' && c.convoy_groups.length > 1
|
|
519
|
+
}
|
|
520
|
+
|
|
462
521
|
/** Where a PRD would go, for a change small enough to plan from the request alone. */
|
|
463
522
|
const NO_PRD = 'There is no PRD: this is a small change, planned straight from the request. Read the code it touches before you plan.'
|
|
464
523
|
|
|
@@ -469,7 +528,18 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
469
528
|
const started = Date.now()
|
|
470
529
|
const spend: PlanningSpend = { sessions: 0, ms: 0, tokens: 0, costUsd: 0, costComplete: true }
|
|
471
530
|
const step: StepRunner = async (template, inputs) => {
|
|
472
|
-
|
|
531
|
+
let r: PromptStepResult
|
|
532
|
+
try {
|
|
533
|
+
r = await runPromptStep({ template, adapter: req.adapter, pkgRoot: req.pkgRoot, cwd: root, verbose: req.verbose, ...inputs })
|
|
534
|
+
} catch (err) {
|
|
535
|
+
// A stopped session ran, and spent what it never got to report.
|
|
536
|
+
if (err instanceof StepCancelled) {
|
|
537
|
+
spend.sessions++
|
|
538
|
+
spend.costComplete = false
|
|
539
|
+
spend.ms = Date.now() - started
|
|
540
|
+
}
|
|
541
|
+
throw err
|
|
542
|
+
}
|
|
473
543
|
spend.sessions++
|
|
474
544
|
spend.tokens += r.tokens ?? 0
|
|
475
545
|
if (r.costUsd === undefined) spend.costComplete = false
|
|
@@ -479,21 +549,37 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
479
549
|
}
|
|
480
550
|
|
|
481
551
|
// ── A small change: no PRD ────────────────────────────────────────────────
|
|
482
|
-
//
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
//
|
|
552
|
+
// When the request is small, the plan is written straight from it: a PRD,
|
|
553
|
+
// its review and its fixes were four or five sessions and most of the
|
|
554
|
+
// planning time — 7m 25s in a real run — for a change the request already
|
|
555
|
+
// described. Neither the plan from the request nor the PRD depends on the
|
|
556
|
+
// size, so all three start together, and the size decides which of the two
|
|
557
|
+
// is kept: the other is stopped. Waiting for the size first added its whole
|
|
558
|
+
// session, about 20s, to every plan.
|
|
486
559
|
let prdPath: string | null = null
|
|
487
560
|
let plan: TaskPlan | null = null
|
|
488
561
|
let quick: ComplexityAssessment | null = null
|
|
562
|
+
let drafting: Speculation<PromptStepResult> | null = null
|
|
489
563
|
if (!req.prdPath && req.task) {
|
|
490
|
-
|
|
564
|
+
const task = req.task
|
|
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 }))
|
|
567
|
+
await Promise.all([direct.started, drafting.started])
|
|
568
|
+
quick = await step('assess-complexity', { goalText: task, contextText: task })
|
|
491
569
|
.then((r) => parseComplexityAssessment(r.rawOutput))
|
|
492
570
|
.catch(() => null)
|
|
493
571
|
if (quick?.complexity === 'low' && quick.recommended_strategy !== 'chain') {
|
|
494
572
|
done('Sized', 'low — planned straight from the request, without a PRD')
|
|
495
|
-
|
|
496
|
-
|
|
573
|
+
// A PRD that finished first is not left behind for a change that has none.
|
|
574
|
+
const unneeded = await drafting.drop()
|
|
575
|
+
if (unneeded?.outputPath) {
|
|
576
|
+
await rm(unneeded.outputPath, { force: true })
|
|
577
|
+
await rmdir(dirname(unneeded.outputPath)).catch(() => {})
|
|
578
|
+
}
|
|
579
|
+
plan = await direct.value
|
|
580
|
+
done(`${tasksPlanned(plan)} planned`)
|
|
581
|
+
} else {
|
|
582
|
+
await direct.drop()
|
|
497
583
|
}
|
|
498
584
|
}
|
|
499
585
|
|
|
@@ -503,7 +589,7 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
503
589
|
prdPath = resolve(root, req.prdPath)
|
|
504
590
|
done('PRD', relPath(prdPath))
|
|
505
591
|
} else {
|
|
506
|
-
const written = await step('generate-prd', { goalText: req.task ?? '' })
|
|
592
|
+
const written = drafting ? await drafting.value : await step('generate-prd', { goalText: req.task ?? '' })
|
|
507
593
|
prdPath = written.outputPath!
|
|
508
594
|
done('PRD written', relPath(prdPath))
|
|
509
595
|
}
|
|
@@ -514,25 +600,45 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
514
600
|
// it is cached under this draft's text, which is the text it describes.
|
|
515
601
|
const cached = await readCachedComplexity(prdPath, prd)
|
|
516
602
|
const assessedFrom = prd
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
603
|
+
// The request was sized already. Only groups need sizing against the PRD,
|
|
604
|
+
// whose phases they name.
|
|
605
|
+
const known = cached ?? (quick && quick.recommended_strategy !== 'chain' ? quick : null)
|
|
606
|
+
const goalFor = (c: ComplexityAssessment | null): string => req.task ?? c?.original_prompt ?? 'Implement the PRD.'
|
|
607
|
+
// When how to plan it is known already, the plan starts beside the review:
|
|
608
|
+
// most PRDs pass, and a plan from one that does not is written again from
|
|
609
|
+
// the fixed text.
|
|
610
|
+
const draft = prd
|
|
611
|
+
let early = known && !inGroups(known)
|
|
612
|
+
? speculate((signal, onStart) =>
|
|
613
|
+
generatePlan(step, goalFor(known), appendTaskComplexity(draft, known.task_complexity), 'task', convoyDir, signal, onStart))
|
|
614
|
+
: null
|
|
615
|
+
await early?.started
|
|
616
|
+
let verdict: PromptStepResult
|
|
617
|
+
let complexity: ComplexityAssessment | null
|
|
618
|
+
try {
|
|
619
|
+
;[verdict, complexity] = await settleAll<PromptStepResult | ComplexityAssessment | null>([
|
|
620
|
+
step('validate-prd', { goalText: `<!-- validation-pass: 1 -->\n${prd}` }),
|
|
621
|
+
known
|
|
622
|
+
? Promise.resolve(known)
|
|
623
|
+
: step('assess-complexity', { goalText: prd, contextText: req.task ?? '' })
|
|
624
|
+
.then((r) => parseComplexityAssessment(r.rawOutput))
|
|
625
|
+
.catch((err: unknown) => {
|
|
626
|
+
warn(`Could not size the work (${message(err)}) — planning it as one`)
|
|
627
|
+
return null
|
|
628
|
+
}),
|
|
629
|
+
]) as [PromptStepResult, ComplexityAssessment | null]
|
|
630
|
+
} catch (err) {
|
|
631
|
+
await early?.drop()
|
|
632
|
+
throw err
|
|
633
|
+
}
|
|
530
634
|
|
|
531
635
|
if (complexity && !cached && complexity !== quick) await writeCachedComplexity(prdPath, assessedFrom, complexity)
|
|
532
636
|
|
|
533
637
|
if (verdict.isValid) {
|
|
534
638
|
done('PRD checked')
|
|
535
639
|
} else {
|
|
640
|
+
await early?.drop()
|
|
641
|
+
early = null
|
|
536
642
|
let issues = verdict.errors || verdict.rawOutput
|
|
537
643
|
let fixed = false
|
|
538
644
|
for (let round = 1; round <= MAX_FIX_ROUNDS && !fixed; round++) {
|
|
@@ -554,7 +660,7 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
554
660
|
|
|
555
661
|
// ── The tasks ─────────────────────────────────────────────────────────────
|
|
556
662
|
let groups: ConvoyGroup[] | null = null
|
|
557
|
-
if (complexity
|
|
663
|
+
if (complexity && inGroups(complexity)) {
|
|
558
664
|
const check = validateComplexityGroups(complexity)
|
|
559
665
|
if (check.valid) groups = topologicalSortGroups(complexity.convoy_groups)
|
|
560
666
|
else warn(`Ignoring the suggested groups (${check.reason}) — planning it as one`)
|
|
@@ -592,11 +698,12 @@ export async function planConvoy(req: PlanRequest): Promise<PlanOutcome> {
|
|
|
592
698
|
featureName,
|
|
593
699
|
all.map((g, i) => ({ name: g.name, depends_on: g.depends_on, plan: plans[i] })),
|
|
594
700
|
)
|
|
595
|
-
done(`${plan
|
|
701
|
+
done(`${tasksPlanned(plan)} planned`, `${all.length} groups, planned side by side`)
|
|
596
702
|
} else {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
703
|
+
plan = early
|
|
704
|
+
? await early.value
|
|
705
|
+
: await generatePlan(step, goalFor(complexity), appendTaskComplexity(prd, complexity?.task_complexity), 'task', convoyDir)
|
|
706
|
+
done(`${tasksPlanned(plan)} planned`)
|
|
600
707
|
}
|
|
601
708
|
}
|
|
602
709
|
|
package/src/cli/plan.ts
CHANGED
|
@@ -37,6 +37,22 @@ export interface PromptStepOptions {
|
|
|
37
37
|
verbose?: boolean
|
|
38
38
|
/** How long one session may run before it is stopped. Defaults to 10 minutes. */
|
|
39
39
|
timeoutMs?: number
|
|
40
|
+
/**
|
|
41
|
+
* Stops the session when aborted, and the step fails with a `StepCancelled`.
|
|
42
|
+
* The planner starts some steps before it knows it needs them, and stops the
|
|
43
|
+
* ones it turns out not to.
|
|
44
|
+
*/
|
|
45
|
+
signal?: AbortSignal
|
|
46
|
+
/** Called once the session has started, before its answer. */
|
|
47
|
+
onStart?: () => void
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A step stopped through its `signal`, not one that failed. */
|
|
51
|
+
export class StepCancelled extends Error {
|
|
52
|
+
constructor(template: string) {
|
|
53
|
+
super(`${template} was stopped: its answer is no longer needed`)
|
|
54
|
+
this.name = 'StepCancelled'
|
|
55
|
+
}
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
export interface PromptStepResult {
|
|
@@ -265,6 +281,19 @@ function modelFor(adapter: AgentAdapter, template: string): string | undefined {
|
|
|
265
281
|
return adapter.tierModels?.[tier]
|
|
266
282
|
}
|
|
267
283
|
|
|
284
|
+
/**
|
|
285
|
+
* How much each step reasons before it answers.
|
|
286
|
+
*
|
|
287
|
+
* Planning sessions spent most of their time thinking, not reading: on a small
|
|
288
|
+
* project a PRD took 129s at Claude Code's default effort and 36s at `low`, with
|
|
289
|
+
* every section, and a plan 55s against 30s at `medium`. The plan gets
|
|
290
|
+
* `medium` because its task prompts are the only instructions the workers see;
|
|
291
|
+
* sizing, the PRD, the checks and the fixes get `low`.
|
|
292
|
+
*/
|
|
293
|
+
export function effortFor(template: string): 'low' | 'medium' {
|
|
294
|
+
return template === 'generate-convoy' ? 'medium' : 'low'
|
|
295
|
+
}
|
|
296
|
+
|
|
268
297
|
/**
|
|
269
298
|
* Run one planning template through the caller's adapter.
|
|
270
299
|
*
|
|
@@ -297,28 +326,44 @@ export async function runPromptStep(opts: PromptStepOptions): Promise<PromptStep
|
|
|
297
326
|
console.log(c.dim(` ${opts.template} · ${opts.adapter.name} · read-only · ${prompt.length} chars`))
|
|
298
327
|
}
|
|
299
328
|
|
|
329
|
+
if (opts.signal?.aborted) throw new StepCancelled(opts.template)
|
|
300
330
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_STEP_TIMEOUT_MS
|
|
301
331
|
const stop = opts.verbose ? null : startProgress(opts.template)
|
|
302
332
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
333
|
+
let onAbort: (() => void) | undefined
|
|
303
334
|
let execResult
|
|
304
335
|
try {
|
|
336
|
+
const running = opts.adapter.execute(task, {
|
|
337
|
+
verbose: opts.verbose ?? false,
|
|
338
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
339
|
+
permissionMode: 'plan',
|
|
340
|
+
// Everything a planning step needs is in its prompt or in the files it
|
|
341
|
+
// reads: no MCP servers, skills or web searches.
|
|
342
|
+
lean: true,
|
|
343
|
+
effort: effortFor(opts.template),
|
|
344
|
+
...(modelFor(opts.adapter, opts.template) ? { model: modelFor(opts.adapter, opts.template) } : {}),
|
|
345
|
+
})
|
|
346
|
+
opts.onStart?.()
|
|
305
347
|
execResult = await Promise.race([
|
|
306
|
-
|
|
307
|
-
verbose: opts.verbose ?? false,
|
|
308
|
-
cwd: opts.cwd ?? process.cwd(),
|
|
309
|
-
permissionMode: 'plan',
|
|
310
|
-
...(modelFor(opts.adapter, opts.template) ? { model: modelFor(opts.adapter, opts.template) } : {}),
|
|
311
|
-
}),
|
|
348
|
+
running,
|
|
312
349
|
new Promise<never>((_, reject) => {
|
|
313
350
|
timer = setTimeout(() => {
|
|
314
351
|
// A hung session would otherwise hold the whole plan open forever.
|
|
315
352
|
opts.adapter.kill?.(task)
|
|
316
353
|
reject(new Error(`${opts.template} ran longer than ${Math.round(timeoutMs / 60_000)}m and was stopped`))
|
|
317
354
|
}, timeoutMs)
|
|
355
|
+
// Stopped by id. The planner only cancels a step while it is the one
|
|
356
|
+
// session of its template, so no other session shares the id.
|
|
357
|
+
onAbort = () => {
|
|
358
|
+
opts.adapter.kill?.(task)
|
|
359
|
+
reject(new StepCancelled(opts.template))
|
|
360
|
+
}
|
|
361
|
+
opts.signal?.addEventListener('abort', onAbort, { once: true })
|
|
318
362
|
}),
|
|
319
363
|
])
|
|
320
364
|
} finally {
|
|
321
365
|
if (timer) clearTimeout(timer)
|
|
366
|
+
if (onAbort) opts.signal?.removeEventListener('abort', onAbort)
|
|
322
367
|
stop?.()
|
|
323
368
|
}
|
|
324
369
|
|