opencastle 1.4.2 → 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/convoy/spec-types.d.ts +15 -0
- package/dist/cli/convoy/spec-types.d.ts.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/convoy/spec-types.ts +15 -0
- 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
|
@@ -2,7 +2,7 @@ import { mkdtempSync, writeFileSync, chmodSync, rmSync, existsSync } from 'node:
|
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { describe, it, expect, afterEach } from 'vitest';
|
|
5
|
-
import { resolveCommand, commandExists, quoteForCmd, runShell, spawnCommand, killTree } from './platform.js';
|
|
5
|
+
import { resolveCommand, commandExists, quoteForCmd, runShell, spawnCommand, killTree, helpText, forgetHelpText } from './platform.js';
|
|
6
6
|
const posix = process.platform !== 'win32';
|
|
7
7
|
describe('finding a command without `which`', () => {
|
|
8
8
|
const dirs = [];
|
|
@@ -23,6 +23,26 @@ describe('finding a command without `which`', () => {
|
|
|
23
23
|
expect(await commandExists('nowhere-to-be-found', env)).toBe(false);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
+
describe('reading a CLI\'s --help', () => {
|
|
27
|
+
afterEach(() => forgetHelpText());
|
|
28
|
+
it('is empty for a command that is not there, and asks only once', async () => {
|
|
29
|
+
const missing = 'opencastle-no-such-cli-' + process.pid;
|
|
30
|
+
expect(await helpText(missing)).toBe('');
|
|
31
|
+
expect(helpText(missing)).toBe(helpText(missing));
|
|
32
|
+
});
|
|
33
|
+
it.skipIf(!posix)('reads what the command prints', async () => {
|
|
34
|
+
const dir = mkdtempSync(join(tmpdir(), 'oc-help-'));
|
|
35
|
+
const cli = join(dir, 'fake-cli');
|
|
36
|
+
writeFileSync(cli, '#!/bin/sh\necho " --effort <level> Effort"\n');
|
|
37
|
+
chmodSync(cli, 0o755);
|
|
38
|
+
try {
|
|
39
|
+
expect(await helpText(cli)).toContain('--effort <level>');
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
rmSync(dir, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
26
46
|
describe('quoting for cmd.exe', () => {
|
|
27
47
|
// The same output cross-spawn produces for these inputs.
|
|
28
48
|
it('quotes and caret-escapes metacharacters', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.test.js","sourceRoot":"","sources":["../../../src/cli/run/platform.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"platform.test.js","sourceRoot":"","sources":["../../../src/cli/run/platform.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAA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 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencastle",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write your AI config once, for every assistant and every teammate: compiles instructions, agents, skills, commands and MCP servers for Claude Code, Copilot, Cursor, Windsurf, OpenCode, Codex and Antigravity, shared across your team's repositories.",
|
|
6
6
|
"bin": {
|
|
@@ -176,6 +176,21 @@ export interface ExecuteOptions {
|
|
|
176
176
|
permissionMode?: PermissionMode;
|
|
177
177
|
/** A model name the runtime understands; omitted means the runtime's own default. */
|
|
178
178
|
model?: string;
|
|
179
|
+
/**
|
|
180
|
+
* How much the model reasons before it answers, where the runtime lets a
|
|
181
|
+
* caller choose; omitted means the runtime's own default. Planning asks for
|
|
182
|
+
* less: measured on Claude Code, a PRD took 129s at the default and 36s at
|
|
183
|
+
* `low`, with the same sections, because most of the session was thinking.
|
|
184
|
+
*/
|
|
185
|
+
effort?: 'low' | 'medium' | 'high';
|
|
186
|
+
/**
|
|
187
|
+
* A self-contained, read-only session: everything it needs is in its prompt
|
|
188
|
+
* or in the files it reads. It starts no MCP server, loads no skill or
|
|
189
|
+
* command, and has only the tools that read files — so it cannot spend its
|
|
190
|
+
* time on a web search or a sub-agent. Runtimes that cannot narrow a session
|
|
191
|
+
* this way run it as usual.
|
|
192
|
+
*/
|
|
193
|
+
lean?: boolean;
|
|
179
194
|
/**
|
|
180
195
|
* @deprecated Ignored. Agents read the project's own MCP config, which
|
|
181
196
|
* `opencastle sync` compiles for every assistant; writing a second copy
|
|
@@ -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
|
})
|