@markjaquith/agency 2.71.24 → 2.71.26
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/commands/pr.test.ts +40 -0
- package/src/commands/pr.ts +21 -18
- package/src/services/SyncService.test.ts +7 -10
- package/src/services/SyncService.ts +2 -3
package/package.json
CHANGED
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,
|
|
@@ -1030,10 +1030,16 @@ JSON
|
|
|
1030
1030
|
expect(
|
|
1031
1031
|
applied.changes.some(
|
|
1032
1032
|
(change) =>
|
|
1033
|
-
change.kind === "record-pr" ||
|
|
1033
|
+
change.kind === "record-pr" ||
|
|
1034
|
+
change.kind === "mark-done" ||
|
|
1035
|
+
change.kind === "materialize-workspace",
|
|
1034
1036
|
),
|
|
1035
1037
|
).toBe(false)
|
|
1038
|
+
expect(applied.executions[0]?.checkouts).toEqual([])
|
|
1036
1039
|
}
|
|
1040
|
+
expect(
|
|
1041
|
+
await Bun.file(join(root, "tasks/non-pr/code/agency")).exists(),
|
|
1042
|
+
).toBe(false)
|
|
1037
1043
|
|
|
1038
1044
|
const task = await runTestEffect(
|
|
1039
1045
|
TaskService.pipe(
|
|
@@ -1080,15 +1086,6 @@ JSON
|
|
|
1080
1086
|
Effect.flatMap((service) => service.materialize(id, undefined, root)),
|
|
1081
1087
|
),
|
|
1082
1088
|
)
|
|
1083
|
-
await runTestEffect(
|
|
1084
|
-
TaskService.pipe(
|
|
1085
|
-
Effect.flatMap((service) =>
|
|
1086
|
-
service.setStatus(id, "done", root, {
|
|
1087
|
-
summary: `Completed ${id}`,
|
|
1088
|
-
}),
|
|
1089
|
-
),
|
|
1090
|
-
),
|
|
1091
|
-
)
|
|
1092
1089
|
}
|
|
1093
1090
|
|
|
1094
1091
|
const callsPath = join(root, "workspace-list-calls")
|
|
@@ -506,9 +506,8 @@ export class SyncService extends Effect.Service<SyncService>()("SyncService", {
|
|
|
506
506
|
? null
|
|
507
507
|
: mergedPullRequestFromGitHub(data, query)
|
|
508
508
|
const skipCheckoutReconciliation =
|
|
509
|
-
|
|
510
|
-
data.claim?.state !== "active"
|
|
511
|
-
!data.completion
|
|
509
|
+
Boolean(data.completion) ||
|
|
510
|
+
(remoteMergedPr !== null && data.claim?.state !== "active")
|
|
512
511
|
let materialize = false
|
|
513
512
|
let workspaceConflict = false
|
|
514
513
|
const declared: readonly (
|