@markjaquith/agency 2.71.25 → 2.71.27
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 +1 -1
- package/src/cli.test.ts +43 -0
- package/src/commands/archive.test.ts +17 -0
- package/src/commands/pr.test.ts +40 -0
- package/src/commands/pr.ts +21 -18
- package/src/services/TaskService.ts +3 -1
package/package.json
CHANGED
package/src/cli.test.ts
CHANGED
|
@@ -507,6 +507,49 @@ describe("CLI", () => {
|
|
|
507
507
|
})
|
|
508
508
|
})
|
|
509
509
|
|
|
510
|
+
test("preserves the JSON error contract when archiving an already archived task", async () => {
|
|
511
|
+
const root = await createTempDir()
|
|
512
|
+
tempDirs.push(root)
|
|
513
|
+
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
514
|
+
expect(
|
|
515
|
+
Bun.spawnSync(["git", "init", "--bare", join(root, "repos/agency")])
|
|
516
|
+
.exitCode,
|
|
517
|
+
).toBe(0)
|
|
518
|
+
await mkdir(join(root, "tasks/example"), { recursive: true })
|
|
519
|
+
await Bun.write(
|
|
520
|
+
join(root, "tasks/example/TASK.md"),
|
|
521
|
+
`---
|
|
522
|
+
ticketUrl: null
|
|
523
|
+
repo: agency
|
|
524
|
+
branch: task/example
|
|
525
|
+
base: main
|
|
526
|
+
pr: null
|
|
527
|
+
status: dropped
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
# Example
|
|
531
|
+
`,
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
expect((await runCli(["archive", "task", "example"], root)).exitCode).toBe(
|
|
535
|
+
0,
|
|
536
|
+
)
|
|
537
|
+
const result = await runCli(["archive", "task", "example", "--json"], root)
|
|
538
|
+
|
|
539
|
+
expect(result.exitCode).toBe(1)
|
|
540
|
+
expect(result.stderr).toBe("")
|
|
541
|
+
expect(JSON.parse(result.stdout)).toEqual({
|
|
542
|
+
version: 1,
|
|
543
|
+
ok: false,
|
|
544
|
+
error: {
|
|
545
|
+
code: "TASK_ERROR",
|
|
546
|
+
message: "Task 'example' is already archived",
|
|
547
|
+
fields: {},
|
|
548
|
+
retryable: false,
|
|
549
|
+
},
|
|
550
|
+
})
|
|
551
|
+
})
|
|
552
|
+
|
|
510
553
|
test("rejects malformed input before running a command", async () => {
|
|
511
554
|
const parent = await createTempDir()
|
|
512
555
|
tempDirs.push(parent)
|
|
@@ -93,6 +93,23 @@ describe("archive command", () => {
|
|
|
93
93
|
)
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
+
test("reports an already archived task", async () => {
|
|
97
|
+
await runTestEffect(
|
|
98
|
+
archive({ type: "task", args: ["example"], cwd: root, silent: true }),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
await expect(
|
|
102
|
+
runTestEffect(
|
|
103
|
+
archive({
|
|
104
|
+
type: "task",
|
|
105
|
+
args: ["example"],
|
|
106
|
+
cwd: root,
|
|
107
|
+
silent: true,
|
|
108
|
+
}),
|
|
109
|
+
),
|
|
110
|
+
).rejects.toThrow("Task 'example' is already archived")
|
|
111
|
+
})
|
|
112
|
+
|
|
96
113
|
test("outputs one deterministic bulk archive object and a concise human summary", async () => {
|
|
97
114
|
const jsonLogs = await captureLogs(() =>
|
|
98
115
|
runTestEffect(
|
package/src/commands/pr.test.ts
CHANGED
|
@@ -148,6 +148,33 @@ status: open
|
|
|
148
148
|
return root
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
const createReviewWorkbase = async () => {
|
|
152
|
+
const root = join(tempRoot, "review-workbase")
|
|
153
|
+
await write(root, "agency.json", '{"version":2}\n')
|
|
154
|
+
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
155
|
+
await mkdir(join(root, "tasks/review/code/agency"), { recursive: true })
|
|
156
|
+
await write(
|
|
157
|
+
root,
|
|
158
|
+
"tasks/review/TASK.md",
|
|
159
|
+
`---
|
|
160
|
+
ticketUrl: null
|
|
161
|
+
description: Review a branch
|
|
162
|
+
review:
|
|
163
|
+
repo: agency
|
|
164
|
+
source:
|
|
165
|
+
kind: branch
|
|
166
|
+
ref: refs/heads/review
|
|
167
|
+
commit: 0123456789abcdef0123456789abcdef01234567
|
|
168
|
+
refreshedAt: 2026-08-19T00:00:00.000Z
|
|
169
|
+
status: working
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
# Review
|
|
173
|
+
`,
|
|
174
|
+
)
|
|
175
|
+
return root
|
|
176
|
+
}
|
|
177
|
+
|
|
151
178
|
test("creates and records an Agency pull request", async () => {
|
|
152
179
|
const url = "https://github.com/markjaquith/agency/pull/123"
|
|
153
180
|
let received: unknown[] = []
|
|
@@ -221,6 +248,19 @@ status: open
|
|
|
221
248
|
])
|
|
222
249
|
})
|
|
223
250
|
|
|
251
|
+
test("focuses a review task invocation on its review checkout", async () => {
|
|
252
|
+
const root = await createReviewWorkbase()
|
|
253
|
+
const task = join(root, "tasks/review")
|
|
254
|
+
|
|
255
|
+
expect(await runTestEffect(pr(["view", "--web"], task))).toBe(0)
|
|
256
|
+
expect(await captured()).toEqual([
|
|
257
|
+
await realpath(join(task, "code/agency")),
|
|
258
|
+
"pr",
|
|
259
|
+
"view",
|
|
260
|
+
"--web",
|
|
261
|
+
])
|
|
262
|
+
})
|
|
263
|
+
|
|
224
264
|
test("injects the execution branch and repository for jj targets", async () => {
|
|
225
265
|
const root = await createExecutionWorkbase("jj")
|
|
226
266
|
const task = join(root, "tasks/single")
|
package/src/commands/pr.ts
CHANGED
|
@@ -98,28 +98,31 @@ export const pr = (args: readonly string[], cwd: string = process.cwd()) =>
|
|
|
98
98
|
context?.validation.valid && context.workspace?.writable?.materialized
|
|
99
99
|
? context.authority.writable?.checkoutPath
|
|
100
100
|
: null
|
|
101
|
-
const
|
|
101
|
+
const reviewCheckout =
|
|
102
|
+
context?.validation.valid && context.review?.checkout?.materialized
|
|
103
|
+
? context.review.checkout.checkoutPath
|
|
104
|
+
: null
|
|
105
|
+
const focusedCheckout = writableCheckout ?? reviewCheckout
|
|
106
|
+
const focusedCwd = focusedCheckout ?? invocationCwd
|
|
102
107
|
let forwardedArgs = args
|
|
103
108
|
let environment: Record<string, string> = {}
|
|
104
|
-
if (
|
|
105
|
-
writableCheckout &&
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
repositoryFromRemote(remote),
|
|
119
|
-
)
|
|
109
|
+
if (focusedCheckout && context?.workbase.vcs === "jj") {
|
|
110
|
+
if (writableCheckout && context.authority.writable) {
|
|
111
|
+
const execution =
|
|
112
|
+
context.documents?.phase?.data ?? context.documents?.task?.data
|
|
113
|
+
const { config } = yield* workbase.loadConfig(context.workbase.root)
|
|
114
|
+
const remote =
|
|
115
|
+
config.repositories?.[context.authority.writable.repo]?.remote
|
|
116
|
+
if (execution && "branch" in execution && remote) {
|
|
117
|
+
forwardedArgs = withJjContext(
|
|
118
|
+
args,
|
|
119
|
+
execution.branch,
|
|
120
|
+
repositoryFromRemote(remote),
|
|
121
|
+
)
|
|
122
|
+
}
|
|
120
123
|
}
|
|
121
124
|
const backend = yield* versionControl.forWorkbase(context.workbase.root)
|
|
122
|
-
environment = yield* backend.gitEnvironment(
|
|
125
|
+
environment = yield* backend.gitEnvironment(focusedCheckout)
|
|
123
126
|
}
|
|
124
127
|
const result = yield* fs.runCommand(["gh", "pr", ...forwardedArgs], {
|
|
125
128
|
cwd: focusedCwd,
|
|
@@ -589,7 +589,9 @@ export class TaskService extends Effect.Service<TaskService>()("TaskService", {
|
|
|
589
589
|
const path = join(root, "tasks", validId, "TASK.md")
|
|
590
590
|
if (!(yield* fs.exists(path))) {
|
|
591
591
|
return yield* new TaskError({
|
|
592
|
-
message:
|
|
592
|
+
message: (yield* fs.exists(archivedTaskDirectory(root, validId)))
|
|
593
|
+
? `Task '${validId}' is already archived`
|
|
594
|
+
: `Task '${validId}' does not exist`,
|
|
593
595
|
})
|
|
594
596
|
}
|
|
595
597
|
const content = yield* fs.readFile(path)
|