@markjaquith/agency 3.2.13 → 3.2.15
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/package.json +7 -2
- package/src/workbase/schemas.ts +12 -0
- package/fixtures/protocol/orchestration-recipes.json +0 -53
- package/pi-extensions/agency.test.ts +0 -117
- package/src/check-commits.test.ts +0 -58
- package/src/cli-parser.test.ts +0 -945
- package/src/cli.test.ts +0 -1889
- package/src/commands/act.test.ts +0 -418
- package/src/commands/archive.test.ts +0 -236
- package/src/commands/context.test.ts +0 -665
- package/src/commands/description.test.ts +0 -103
- package/src/commands/doctor.test.ts +0 -185
- package/src/commands/epic.test.ts +0 -196
- package/src/commands/init.test.ts +0 -117
- package/src/commands/integration.test.ts +0 -165
- package/src/commands/pr.test.ts +0 -248
- package/src/commands/push.test.ts +0 -56
- package/src/commands/read-only.test.ts +0 -161
- package/src/commands/repo.test.ts +0 -199
- package/src/commands/restore.test.ts +0 -106
- package/src/commands/status.test.ts +0 -113
- package/src/commands/sync.test.ts +0 -200
- package/src/commands/task-phase.test.ts +0 -410
- package/src/commands/task.test.ts +0 -281
- package/src/commands/validate.test.ts +0 -186
- package/src/commands/work.test.ts +0 -1375
- package/src/commands/workbase.test.ts +0 -170
- package/src/graph-schema.test.ts +0 -124
- package/src/protocol.test.ts +0 -163
- package/src/readiness.test.ts +0 -105
- package/src/services/ArchiveBulkService.test.ts +0 -384
- package/src/services/ArchiveService.test.ts +0 -1092
- package/src/services/EpicService.test.ts +0 -74
- package/src/services/FileSystemService.test.ts +0 -81
- package/src/services/GraphMutationService.test.ts +0 -486
- package/src/services/GraphService.test.ts +0 -494
- package/src/services/IntegrationService.test.ts +0 -1091
- package/src/services/LifecycleTransaction.test.ts +0 -145
- package/src/services/PullRequestService.test.ts +0 -716
- package/src/services/PushService.test.ts +0 -408
- package/src/services/ReadinessService.test.ts +0 -290
- package/src/services/RepositoryService.test.ts +0 -789
- package/src/services/ReviewService.test.ts +0 -408
- package/src/services/SyncService.test.ts +0 -1377
- package/src/services/TaskPhaseService.test.ts +0 -852
- package/src/services/VersionControlService.test.ts +0 -62
- package/src/services/WorkbaseService.test.ts +0 -910
- package/src/services/WorktreeLock.test.ts +0 -205
- package/src/services/WorktreePerformance.test.ts +0 -71
- package/src/services/WorktreeService.test.ts +0 -2292
- package/src/test-utils.ts +0 -110
- package/src/usage-log.test.ts +0 -188
- package/src/utils/chooser.test.ts +0 -192
- package/src/utils/effect.test.ts +0 -30
- package/src/utils/interactive.pty.test.ts +0 -128
- package/src/utils/interactive.test.tsx +0 -860
- package/src/utils/process.test.ts +0 -132
- package/src/utils/progress.test.ts +0 -37
- package/src/work-view.test.ts +0 -151
- package/src/workbase/agent-command.test.ts +0 -128
- package/src/workbase/checkout-command.test.ts +0 -62
- package/src/workbase/delivery-command.test.ts +0 -180
- package/src/workbase/dependency-graph.test.ts +0 -50
- package/src/workbase/execution-contract.test.ts +0 -161
- package/src/workbase/frontmatter.test.ts +0 -67
- package/src/workbase/repository-reference.test.ts +0 -25
- package/src/workbase/schemas.test.ts +0 -543
- package/src/workbase/work-target.test.ts +0 -108
- package/src/workbase/worktree-command.test.ts +0 -61
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { mkdir } from "node:fs/promises"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
-
import { Effect, Layer } from "effect"
|
|
5
|
-
import {
|
|
6
|
-
captureLogs,
|
|
7
|
-
cleanupTempDir,
|
|
8
|
-
createTempDir,
|
|
9
|
-
runTestEffect,
|
|
10
|
-
} from "../test-utils"
|
|
11
|
-
import { phase } from "./phase"
|
|
12
|
-
import { task } from "./task"
|
|
13
|
-
import { FileSystemService } from "../services/FileSystemService"
|
|
14
|
-
import { PhaseService } from "../services/PhaseService"
|
|
15
|
-
import { TaskService } from "../services/TaskService"
|
|
16
|
-
import { WorkbaseService } from "../services/WorkbaseService"
|
|
17
|
-
|
|
18
|
-
describe("task and phase command JSON output", () => {
|
|
19
|
-
let root: string
|
|
20
|
-
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
root = await createTempDir()
|
|
23
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
24
|
-
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
25
|
-
await runTestEffect(
|
|
26
|
-
task({
|
|
27
|
-
subcommand: "create",
|
|
28
|
-
args: ["multi"],
|
|
29
|
-
ticketUrl: "https://example.com/task",
|
|
30
|
-
multiPhase: true,
|
|
31
|
-
cwd: root,
|
|
32
|
-
silent: true,
|
|
33
|
-
}),
|
|
34
|
-
)
|
|
35
|
-
await runTestEffect(
|
|
36
|
-
phase({
|
|
37
|
-
subcommand: "create",
|
|
38
|
-
args: ["multi", "first"],
|
|
39
|
-
repo: "agency",
|
|
40
|
-
branch: "task/first",
|
|
41
|
-
base: "main",
|
|
42
|
-
cwd: root,
|
|
43
|
-
silent: true,
|
|
44
|
-
}),
|
|
45
|
-
)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
afterEach(async () => cleanupTempDir(root))
|
|
49
|
-
|
|
50
|
-
test("lists and shows task metadata without Markdown content", async () => {
|
|
51
|
-
const listLogs = await captureLogs(() =>
|
|
52
|
-
runTestEffect(
|
|
53
|
-
task({ subcommand: "list", args: [], cwd: root, json: true }),
|
|
54
|
-
),
|
|
55
|
-
)
|
|
56
|
-
const listed = JSON.parse(listLogs[0]!)
|
|
57
|
-
expect(listed[0].revision).toMatch(/^[a-f0-9]{64}$/)
|
|
58
|
-
expect(listed).toEqual([
|
|
59
|
-
{
|
|
60
|
-
id: "multi",
|
|
61
|
-
path: join(root, "tasks/multi/TASK.md"),
|
|
62
|
-
revision: listed[0].revision,
|
|
63
|
-
data: {
|
|
64
|
-
ticketUrl: "https://example.com/task",
|
|
65
|
-
phases: [{ id: "first" }],
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
])
|
|
69
|
-
|
|
70
|
-
const showLogs = await captureLogs(() =>
|
|
71
|
-
runTestEffect(
|
|
72
|
-
task({
|
|
73
|
-
subcommand: "show",
|
|
74
|
-
args: ["multi"],
|
|
75
|
-
cwd: root,
|
|
76
|
-
json: true,
|
|
77
|
-
}),
|
|
78
|
-
),
|
|
79
|
-
)
|
|
80
|
-
const shown = JSON.parse(showLogs[0]!)
|
|
81
|
-
expect(shown.revision).toBe(listed[0].revision)
|
|
82
|
-
expect(shown).toEqual({
|
|
83
|
-
id: "multi",
|
|
84
|
-
path: join(root, "tasks/multi/TASK.md"),
|
|
85
|
-
revision: shown.revision,
|
|
86
|
-
data: {
|
|
87
|
-
ticketUrl: "https://example.com/task",
|
|
88
|
-
phases: [{ id: "first" }],
|
|
89
|
-
},
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
test("returns complete handoff JSON without preparing work", async () => {
|
|
94
|
-
await runTestEffect(
|
|
95
|
-
task({
|
|
96
|
-
subcommand: "create",
|
|
97
|
-
args: ["investigate"],
|
|
98
|
-
repo: "agency",
|
|
99
|
-
purpose: "investigation",
|
|
100
|
-
cwd: root,
|
|
101
|
-
silent: true,
|
|
102
|
-
}),
|
|
103
|
-
)
|
|
104
|
-
const logs = await captureLogs(() =>
|
|
105
|
-
runTestEffect(
|
|
106
|
-
task({
|
|
107
|
-
subcommand: "handoff",
|
|
108
|
-
args: ["investigate", "implement"],
|
|
109
|
-
repo: "agency",
|
|
110
|
-
cwd: root,
|
|
111
|
-
json: true,
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
114
|
-
)
|
|
115
|
-
const output = JSON.parse(logs[0]!)
|
|
116
|
-
expect(output).toMatchObject({
|
|
117
|
-
task: {
|
|
118
|
-
id: "implement",
|
|
119
|
-
selector: "task/implement",
|
|
120
|
-
directory: join(root, "tasks/implement"),
|
|
121
|
-
documentPath: join(root, "tasks/implement/TASK.md"),
|
|
122
|
-
branch: "task/implement",
|
|
123
|
-
base: "main",
|
|
124
|
-
},
|
|
125
|
-
source: {
|
|
126
|
-
selector: "task/investigate",
|
|
127
|
-
documentPath: join(root, "tasks/investigate/TASK.md"),
|
|
128
|
-
},
|
|
129
|
-
validation: { valid: true },
|
|
130
|
-
worktreePrepare: {
|
|
131
|
-
target: "task/implement",
|
|
132
|
-
command: ["agency", "worktree", "prepare", "implement"],
|
|
133
|
-
},
|
|
134
|
-
})
|
|
135
|
-
expect(output.task.revision).toMatch(/^[a-f0-9]{64}$/)
|
|
136
|
-
expect(output.source.revision).toMatch(/^[a-f0-9]{64}$/)
|
|
137
|
-
expect(await Bun.file(join(root, "tasks/implement/code")).exists()).toBe(
|
|
138
|
-
false,
|
|
139
|
-
)
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test("lists and shows phase metadata without Markdown content", async () => {
|
|
143
|
-
const listLogs = await captureLogs(() =>
|
|
144
|
-
runTestEffect(
|
|
145
|
-
phase({ subcommand: "list", args: ["multi"], cwd: root, json: true }),
|
|
146
|
-
),
|
|
147
|
-
)
|
|
148
|
-
const listed = JSON.parse(listLogs[0]!)
|
|
149
|
-
expect(listed[0].revision).toMatch(/^[a-f0-9]{64}$/)
|
|
150
|
-
expect(listed).toEqual([
|
|
151
|
-
{
|
|
152
|
-
taskId: "multi",
|
|
153
|
-
id: "first",
|
|
154
|
-
path: join(root, "tasks/multi/phases/first/PHASE.md"),
|
|
155
|
-
revision: listed[0].revision,
|
|
156
|
-
data: {
|
|
157
|
-
repo: "agency",
|
|
158
|
-
branch: "task/first",
|
|
159
|
-
base: "main",
|
|
160
|
-
pr: null,
|
|
161
|
-
status: "open",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
])
|
|
165
|
-
|
|
166
|
-
const showLogs = await captureLogs(() =>
|
|
167
|
-
runTestEffect(
|
|
168
|
-
phase({
|
|
169
|
-
subcommand: "show",
|
|
170
|
-
args: ["multi", "first"],
|
|
171
|
-
cwd: root,
|
|
172
|
-
json: true,
|
|
173
|
-
}),
|
|
174
|
-
),
|
|
175
|
-
)
|
|
176
|
-
const shown = JSON.parse(showLogs[0]!)
|
|
177
|
-
expect(shown.revision).toBe(listed[0].revision)
|
|
178
|
-
expect(shown).toEqual({
|
|
179
|
-
taskId: "multi",
|
|
180
|
-
id: "first",
|
|
181
|
-
path: join(root, "tasks/multi/phases/first/PHASE.md"),
|
|
182
|
-
revision: shown.revision,
|
|
183
|
-
data: {
|
|
184
|
-
repo: "agency",
|
|
185
|
-
branch: "task/first",
|
|
186
|
-
base: "main",
|
|
187
|
-
pr: null,
|
|
188
|
-
status: "open",
|
|
189
|
-
},
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
test("shows one phase without reading sibling phase documents", async () => {
|
|
194
|
-
await runTestEffect(
|
|
195
|
-
phase({
|
|
196
|
-
subcommand: "create",
|
|
197
|
-
args: ["multi", "second"],
|
|
198
|
-
repo: "agency",
|
|
199
|
-
branch: "task/second",
|
|
200
|
-
base: "main",
|
|
201
|
-
cwd: root,
|
|
202
|
-
silent: true,
|
|
203
|
-
}),
|
|
204
|
-
)
|
|
205
|
-
const fs = await Effect.runPromise(
|
|
206
|
-
FileSystemService.pipe(Effect.provide(FileSystemService.Default)),
|
|
207
|
-
)
|
|
208
|
-
const readPaths: string[] = []
|
|
209
|
-
const countingFs = {
|
|
210
|
-
...fs,
|
|
211
|
-
readFile: (path: string) => {
|
|
212
|
-
readPaths.push(path)
|
|
213
|
-
return fs.readFile(path)
|
|
214
|
-
},
|
|
215
|
-
}
|
|
216
|
-
const program = PhaseService.pipe(
|
|
217
|
-
Effect.flatMap((service) => service.show("multi", "second", root)),
|
|
218
|
-
Effect.provide(PhaseService.Default),
|
|
219
|
-
Effect.provide(TaskService.Default),
|
|
220
|
-
Effect.provide(WorkbaseService.Default),
|
|
221
|
-
Effect.provide(Layer.succeed(FileSystemService, countingFs)),
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
const record = await Effect.runPromise(program)
|
|
225
|
-
|
|
226
|
-
expect(record.id).toBe("second")
|
|
227
|
-
expect(readPaths.filter((path) => path.endsWith("PHASE.md"))).toEqual([
|
|
228
|
-
join(root, "tasks/multi/phases/second/PHASE.md"),
|
|
229
|
-
])
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
test("renders task and phase operational tables", async () => {
|
|
233
|
-
const taskLogs = await captureLogs(() =>
|
|
234
|
-
runTestEffect(task({ subcommand: "list", args: [], cwd: root })),
|
|
235
|
-
)
|
|
236
|
-
expect(taskLogs[0]).toContain(
|
|
237
|
-
"TASK PARENT STATUS READINESS REPOSITORIES BRANCH",
|
|
238
|
-
)
|
|
239
|
-
expect(taskLogs[0]).toContain("multi - open ready")
|
|
240
|
-
|
|
241
|
-
const phaseLogs = await captureLogs(() =>
|
|
242
|
-
runTestEffect(phase({ subcommand: "list", args: ["multi"], cwd: root })),
|
|
243
|
-
)
|
|
244
|
-
expect(phaseLogs[0]).toContain(
|
|
245
|
-
"PHASE PARENT STATUS READINESS REPOSITORIES BRANCH",
|
|
246
|
-
)
|
|
247
|
-
expect(phaseLogs[0]).toContain(
|
|
248
|
-
"first multi open ready agency task/first absent absent",
|
|
249
|
-
)
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
test("outputs created task and phase records as JSON", async () => {
|
|
253
|
-
const taskLogs = await captureLogs(() =>
|
|
254
|
-
runTestEffect(
|
|
255
|
-
task({
|
|
256
|
-
subcommand: "create",
|
|
257
|
-
args: ["another"],
|
|
258
|
-
ticketUrl: "https://example.com/another",
|
|
259
|
-
multiPhase: true,
|
|
260
|
-
cwd: root,
|
|
261
|
-
json: true,
|
|
262
|
-
}),
|
|
263
|
-
),
|
|
264
|
-
)
|
|
265
|
-
expect(JSON.parse(taskLogs[0]!)).toMatchObject({
|
|
266
|
-
id: "another",
|
|
267
|
-
data: { ticketUrl: "https://example.com/another", phases: [] },
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
const phaseLogs = await captureLogs(() =>
|
|
271
|
-
runTestEffect(
|
|
272
|
-
phase({
|
|
273
|
-
subcommand: "create",
|
|
274
|
-
args: ["another", "first"],
|
|
275
|
-
repo: "agency",
|
|
276
|
-
branch: "task/another-first",
|
|
277
|
-
base: "main",
|
|
278
|
-
cwd: root,
|
|
279
|
-
json: true,
|
|
280
|
-
}),
|
|
281
|
-
),
|
|
282
|
-
)
|
|
283
|
-
expect(JSON.parse(phaseLogs[0]!)).toMatchObject({
|
|
284
|
-
taskId: "another",
|
|
285
|
-
id: "first",
|
|
286
|
-
data: {
|
|
287
|
-
repo: "agency",
|
|
288
|
-
branch: "task/another-first",
|
|
289
|
-
base: "main",
|
|
290
|
-
status: "open",
|
|
291
|
-
},
|
|
292
|
-
})
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
test("starts work on a newly created phase", async () => {
|
|
296
|
-
const launches: unknown[] = []
|
|
297
|
-
|
|
298
|
-
await runTestEffect(
|
|
299
|
-
phase(
|
|
300
|
-
{
|
|
301
|
-
subcommand: "new",
|
|
302
|
-
args: ["multi", "immediate"],
|
|
303
|
-
repo: "agency",
|
|
304
|
-
branch: "task/immediate",
|
|
305
|
-
base: "main",
|
|
306
|
-
work: true,
|
|
307
|
-
auto: true,
|
|
308
|
-
cwd: root,
|
|
309
|
-
silent: true,
|
|
310
|
-
},
|
|
311
|
-
(options) =>
|
|
312
|
-
Effect.sync(() => {
|
|
313
|
-
launches.push(options)
|
|
314
|
-
return undefined
|
|
315
|
-
}),
|
|
316
|
-
),
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
expect(launches).toEqual([
|
|
320
|
-
expect.objectContaining({
|
|
321
|
-
taskId: "multi",
|
|
322
|
-
phaseId: "immediate",
|
|
323
|
-
auto: true,
|
|
324
|
-
cwd: root,
|
|
325
|
-
}),
|
|
326
|
-
])
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
test("sets task and phase status", async () => {
|
|
330
|
-
const phaseLogs = await captureLogs(() =>
|
|
331
|
-
runTestEffect(
|
|
332
|
-
phase({
|
|
333
|
-
subcommand: "status",
|
|
334
|
-
args: ["multi", "first", "working"],
|
|
335
|
-
cwd: root,
|
|
336
|
-
json: true,
|
|
337
|
-
}),
|
|
338
|
-
),
|
|
339
|
-
)
|
|
340
|
-
expect(JSON.parse(phaseLogs[0]!).data.status).toBe("working")
|
|
341
|
-
|
|
342
|
-
await runTestEffect(
|
|
343
|
-
task({
|
|
344
|
-
subcommand: "create",
|
|
345
|
-
args: ["single-status"],
|
|
346
|
-
ticketUrl: "https://example.com/task",
|
|
347
|
-
repo: "agency",
|
|
348
|
-
branch: "task/single-status",
|
|
349
|
-
base: "main",
|
|
350
|
-
cwd: root,
|
|
351
|
-
silent: true,
|
|
352
|
-
}),
|
|
353
|
-
)
|
|
354
|
-
const taskLogs = await captureLogs(() =>
|
|
355
|
-
runTestEffect(
|
|
356
|
-
task({
|
|
357
|
-
subcommand: "status",
|
|
358
|
-
args: ["single-status", "working"],
|
|
359
|
-
cwd: root,
|
|
360
|
-
json: true,
|
|
361
|
-
}),
|
|
362
|
-
),
|
|
363
|
-
)
|
|
364
|
-
expect(JSON.parse(taskLogs[0]!).data.status).toBe("working")
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
test("converts a single-phase task with an explicit first phase ID", async () => {
|
|
368
|
-
await runTestEffect(
|
|
369
|
-
task({
|
|
370
|
-
subcommand: "create",
|
|
371
|
-
args: ["single"],
|
|
372
|
-
ticketUrl: "https://example.com/single",
|
|
373
|
-
repo: "agency",
|
|
374
|
-
branch: "task/single",
|
|
375
|
-
base: "main",
|
|
376
|
-
cwd: root,
|
|
377
|
-
silent: true,
|
|
378
|
-
}),
|
|
379
|
-
)
|
|
380
|
-
|
|
381
|
-
await runTestEffect(
|
|
382
|
-
phase({
|
|
383
|
-
subcommand: "create",
|
|
384
|
-
args: ["single", "follow-up"],
|
|
385
|
-
firstPhase: "implementation",
|
|
386
|
-
repo: "agency",
|
|
387
|
-
branch: "task/follow-up",
|
|
388
|
-
base: "main",
|
|
389
|
-
dependsOn: ["implementation"],
|
|
390
|
-
cwd: root,
|
|
391
|
-
silent: true,
|
|
392
|
-
}),
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
const logs = await captureLogs(() =>
|
|
396
|
-
runTestEffect(
|
|
397
|
-
task({
|
|
398
|
-
subcommand: "show",
|
|
399
|
-
args: ["single"],
|
|
400
|
-
cwd: root,
|
|
401
|
-
json: true,
|
|
402
|
-
}),
|
|
403
|
-
),
|
|
404
|
-
)
|
|
405
|
-
expect(JSON.parse(logs[0]!).data.phases).toEqual([
|
|
406
|
-
{ id: "implementation" },
|
|
407
|
-
{ id: "follow-up", dependsOn: ["implementation"] },
|
|
408
|
-
])
|
|
409
|
-
})
|
|
410
|
-
})
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import { mkdir } from "node:fs/promises"
|
|
4
|
-
import { join } from "node:path"
|
|
5
|
-
import {
|
|
6
|
-
captureLogs,
|
|
7
|
-
cleanupTempDir,
|
|
8
|
-
createTempDir,
|
|
9
|
-
runTestEffect,
|
|
10
|
-
} from "../test-utils"
|
|
11
|
-
import { task, type TaskInteraction } from "./task"
|
|
12
|
-
|
|
13
|
-
describe("task creation input", () => {
|
|
14
|
-
let root: string
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
root = await createTempDir()
|
|
18
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
19
|
-
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
afterEach(async () => cleanupTempDir(root))
|
|
23
|
-
|
|
24
|
-
test("guides task creation and defaults branch metadata", async () => {
|
|
25
|
-
await mkdir(join(root, "epics/delivery"), { recursive: true })
|
|
26
|
-
await Bun.write(
|
|
27
|
-
join(root, "epics/delivery/EPIC.md"),
|
|
28
|
-
"---\nticketUrl: https://example.com/delivery\nrepos:\n - repo: agency\n ref: main\ntasks: []\n---\n\n# Delivery\n",
|
|
29
|
-
)
|
|
30
|
-
const textAnswers = ["guided-task", "", ""]
|
|
31
|
-
const prompts: string[] = []
|
|
32
|
-
const interaction: TaskInteraction = {
|
|
33
|
-
text: (prompt) => {
|
|
34
|
-
prompts.push(prompt)
|
|
35
|
-
return Effect.succeed(textAnswers.shift() ?? "")
|
|
36
|
-
},
|
|
37
|
-
select: (prompt, choices) => {
|
|
38
|
-
prompts.push(`${prompt}: ${choices.join(",")}`)
|
|
39
|
-
return Effect.succeed(
|
|
40
|
-
prompt === "Parent epic"
|
|
41
|
-
? "(none)"
|
|
42
|
-
: prompt === "Task type"
|
|
43
|
-
? "single-phase"
|
|
44
|
-
: "agency",
|
|
45
|
-
)
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
await runTestEffect(
|
|
50
|
-
task(
|
|
51
|
-
{ subcommand: "new", args: [], cwd: root, silent: true },
|
|
52
|
-
interaction,
|
|
53
|
-
),
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
const content = await Bun.file(
|
|
57
|
-
join(root, "tasks/guided-task/TASK.md"),
|
|
58
|
-
).text()
|
|
59
|
-
expect(content).toContain("ticketUrl: null")
|
|
60
|
-
expect(content).toContain("repo: agency")
|
|
61
|
-
expect(content).toContain("branch: task/guided-task")
|
|
62
|
-
expect(content).toContain("base: main")
|
|
63
|
-
expect(prompts).toEqual([
|
|
64
|
-
"Task ID: ",
|
|
65
|
-
"Ticket URL (optional): ",
|
|
66
|
-
"Description (optional): ",
|
|
67
|
-
"Parent epic: (none),delivery",
|
|
68
|
-
"Task type: single-phase,multi-phase",
|
|
69
|
-
])
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test("asks for a repository only when more than one is available", async () => {
|
|
73
|
-
await mkdir(join(root, "repos/web"), { recursive: true })
|
|
74
|
-
const prompts: string[] = []
|
|
75
|
-
const interaction: TaskInteraction = {
|
|
76
|
-
text: () => Effect.fail(new Error("unexpected text prompt")),
|
|
77
|
-
select: (prompt, choices) => {
|
|
78
|
-
prompts.push(`${prompt}: ${choices.join(",")}`)
|
|
79
|
-
return Effect.succeed(prompt === "Task type" ? "single-phase" : "web")
|
|
80
|
-
},
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await runTestEffect(
|
|
84
|
-
task(
|
|
85
|
-
{
|
|
86
|
-
subcommand: "new",
|
|
87
|
-
args: ["multi-repo"],
|
|
88
|
-
ticketUrl: "",
|
|
89
|
-
description: "",
|
|
90
|
-
cwd: root,
|
|
91
|
-
silent: true,
|
|
92
|
-
},
|
|
93
|
-
interaction,
|
|
94
|
-
),
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
expect(prompts).toEqual([
|
|
98
|
-
"Task type: single-phase,multi-phase",
|
|
99
|
-
"Writable repository: agency,web",
|
|
100
|
-
])
|
|
101
|
-
expect(
|
|
102
|
-
await Bun.file(join(root, "tasks/multi-repo/TASK.md")).text(),
|
|
103
|
-
).toContain("repo: web")
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
test("keeps scripted creation non-interactive and permits no ticket URL", async () => {
|
|
107
|
-
const interaction: TaskInteraction = {
|
|
108
|
-
text: () => Effect.fail(new Error("unexpected text prompt")),
|
|
109
|
-
select: () => Effect.fail(new Error("unexpected selection prompt")),
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
await runTestEffect(
|
|
113
|
-
task(
|
|
114
|
-
{
|
|
115
|
-
subcommand: "create",
|
|
116
|
-
args: ["scripted-task"],
|
|
117
|
-
repo: "agency",
|
|
118
|
-
cwd: root,
|
|
119
|
-
silent: true,
|
|
120
|
-
},
|
|
121
|
-
interaction,
|
|
122
|
-
),
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
const content = await Bun.file(
|
|
126
|
-
join(root, "tasks/scripted-task/TASK.md"),
|
|
127
|
-
).text()
|
|
128
|
-
expect(content).toContain("ticketUrl: null")
|
|
129
|
-
expect(content).toContain("branch: task/scripted-task")
|
|
130
|
-
expect(content).toContain("base: main")
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test("returns revision-bound validation evidence and normalized recalled context", async () => {
|
|
134
|
-
const [output] = await captureLogs(() =>
|
|
135
|
-
runTestEffect(
|
|
136
|
-
task({
|
|
137
|
-
subcommand: "create",
|
|
138
|
-
args: ["scripted-context"],
|
|
139
|
-
contextRepo: "agency",
|
|
140
|
-
contextBase: "main",
|
|
141
|
-
contextSlug: "scripted-context",
|
|
142
|
-
authoritativeSources: [
|
|
143
|
-
"https://example.com/spec",
|
|
144
|
-
join(root, "SOURCE.md"),
|
|
145
|
-
],
|
|
146
|
-
cwd: root,
|
|
147
|
-
json: true,
|
|
148
|
-
}),
|
|
149
|
-
),
|
|
150
|
-
)
|
|
151
|
-
const result = JSON.parse(output!)
|
|
152
|
-
expect(result.selector).toBe("execution-unit:task/scripted-context")
|
|
153
|
-
expect(result.documentPath).toBe(
|
|
154
|
-
join(root, "tasks/scripted-context/TASK.md"),
|
|
155
|
-
)
|
|
156
|
-
expect(result.validation.valid).toBe(true)
|
|
157
|
-
expect(result.evidence).toEqual(
|
|
158
|
-
expect.objectContaining({
|
|
159
|
-
version: 1,
|
|
160
|
-
target: "execution-unit:task/scripted-context",
|
|
161
|
-
documentRevision: result.revision,
|
|
162
|
-
valid: true,
|
|
163
|
-
digest: expect.any(String),
|
|
164
|
-
}),
|
|
165
|
-
)
|
|
166
|
-
expect(result.recalledContext).toEqual({
|
|
167
|
-
repo: "agency",
|
|
168
|
-
base: "main",
|
|
169
|
-
preferredSlug: "scripted-context",
|
|
170
|
-
authoritativeSources: [
|
|
171
|
-
join(root, "SOURCE.md"),
|
|
172
|
-
"https://example.com/spec",
|
|
173
|
-
],
|
|
174
|
-
})
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
test("rejects stale or conflicting recalled context", async () => {
|
|
178
|
-
await expect(
|
|
179
|
-
runTestEffect(
|
|
180
|
-
task({
|
|
181
|
-
subcommand: "create",
|
|
182
|
-
args: ["conflict"],
|
|
183
|
-
repo: "agency",
|
|
184
|
-
contextRepo: "other",
|
|
185
|
-
cwd: root,
|
|
186
|
-
silent: true,
|
|
187
|
-
}),
|
|
188
|
-
),
|
|
189
|
-
).rejects.toThrow("conflicts with --repo")
|
|
190
|
-
await expect(
|
|
191
|
-
runTestEffect(
|
|
192
|
-
task({
|
|
193
|
-
subcommand: "create",
|
|
194
|
-
args: ["conflict"],
|
|
195
|
-
contextRepo: "agency",
|
|
196
|
-
contextSlug: "stale-slug",
|
|
197
|
-
cwd: root,
|
|
198
|
-
silent: true,
|
|
199
|
-
}),
|
|
200
|
-
),
|
|
201
|
-
).rejects.toThrow("conflicts with task ID")
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
test("never prompts when scripted creation is incomplete", async () => {
|
|
205
|
-
const interaction: TaskInteraction = {
|
|
206
|
-
text: () => Effect.fail(new Error("unexpected text prompt")),
|
|
207
|
-
select: () => Effect.fail(new Error("unexpected selection prompt")),
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
await expect(
|
|
211
|
-
runTestEffect(
|
|
212
|
-
task(
|
|
213
|
-
{
|
|
214
|
-
subcommand: "create",
|
|
215
|
-
args: ["scripted-task"],
|
|
216
|
-
cwd: root,
|
|
217
|
-
silent: true,
|
|
218
|
-
},
|
|
219
|
-
interaction,
|
|
220
|
-
),
|
|
221
|
-
),
|
|
222
|
-
).rejects.toThrow("Writable repository is required")
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test("refuses guided creation when input is disabled", async () => {
|
|
226
|
-
const interaction: TaskInteraction = {
|
|
227
|
-
text: () => Effect.fail(new Error("unexpected text prompt")),
|
|
228
|
-
select: () => Effect.fail(new Error("unexpected selection prompt")),
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
await expect(
|
|
232
|
-
runTestEffect(
|
|
233
|
-
task(
|
|
234
|
-
{
|
|
235
|
-
subcommand: "new",
|
|
236
|
-
args: [],
|
|
237
|
-
cwd: root,
|
|
238
|
-
silent: true,
|
|
239
|
-
inputAllowed: false,
|
|
240
|
-
},
|
|
241
|
-
interaction,
|
|
242
|
-
),
|
|
243
|
-
),
|
|
244
|
-
).rejects.toThrow("task new requires interactive input")
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
test("starts work on a newly created task", async () => {
|
|
248
|
-
const launches: unknown[] = []
|
|
249
|
-
|
|
250
|
-
await runTestEffect(
|
|
251
|
-
task(
|
|
252
|
-
{
|
|
253
|
-
subcommand: "new",
|
|
254
|
-
args: ["immediate"],
|
|
255
|
-
ticketUrl: "",
|
|
256
|
-
description: "",
|
|
257
|
-
multiPhase: false,
|
|
258
|
-
repo: "agency",
|
|
259
|
-
work: true,
|
|
260
|
-
auto: true,
|
|
261
|
-
cwd: root,
|
|
262
|
-
silent: true,
|
|
263
|
-
},
|
|
264
|
-
undefined,
|
|
265
|
-
(options) =>
|
|
266
|
-
Effect.sync(() => {
|
|
267
|
-
launches.push(options)
|
|
268
|
-
return undefined
|
|
269
|
-
}),
|
|
270
|
-
),
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
expect(launches).toEqual([
|
|
274
|
-
expect.objectContaining({
|
|
275
|
-
taskId: "immediate",
|
|
276
|
-
auto: true,
|
|
277
|
-
cwd: root,
|
|
278
|
-
}),
|
|
279
|
-
])
|
|
280
|
-
})
|
|
281
|
-
})
|