Open History to see the last commit
1import {
2 EnvironmentId,
3 ProjectId,
4 ProviderInstanceId,
5 ThreadId,
6 type OrchestrationV2ServerCommand as OrchestrationCommand,
7 PullRequestOperationError,
8 type OrchestrationProjectShell,
9 type PullRequestRef,
10 type PullRequestReviewGuideResult,
11 type ThreadPullRequestLink,
12} from "@t3tools/contracts";
13import { describe, expect, it } from "@effect/vitest";
14import * as Crypto from "effect/Crypto";
15import * as Effect from "effect/Effect";
16import * as Layer from "effect/Layer";
17import * as Option from "effect/Option";
18import * as Ref from "effect/Ref";
19import * as Stream from "effect/Stream";
20import type { Tool } from "effect/ai";
21
22import * as Orchestrator from "../../../orchestration-v2/Orchestrator.ts";
23import {
24 type PullRequestTestThread,
25 v2PullRequestThread,
26} from "../../../orchestration-v2/testkit/pullRequestFixtures.ts";
27import * as ProjectService from "../../../project/ProjectService.ts";
28import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts";
29import * as McpInvocationContext from "../../McpInvocationContext.ts";
30import * as McpToolAccess from "../../McpToolAccess.ts";
31import * as McpToolAccessTestkit from "../../McpToolAccess.testkit.ts";
32import { listThreadPullRequests } from "./handlers.ts";
33import * as PullRequestsHandlers from "./handlers.ts";
34import { PullRequestsToolkit } from "./tools.ts";
35
36const PROJECT_ID = ProjectId.make("project-1");
37const THREAD_ID = ThreadId.make("thread-1");
38
39const testCrypto = Crypto.make({
40 randomBytes: (size) => new Uint8Array(size).fill(7),
41 digest: (_algorithm, data) => Effect.succeed(data),
42});
43
44const invocation = (
45 capabilities: ReadonlyArray<McpInvocationContext.McpCapability>,
46): McpInvocationContext.McpInvocationScope => ({
47 environmentId: EnvironmentId.make("environment-1"),
48 requestNamespace: "provider-session-1",
49 thread: {
50 threadId: THREAD_ID,
51 providerSessionId: "provider-session-1",
52 providerInstanceId: ProviderInstanceId.make("codex"),
53 },
54 client: undefined,
55 capabilities: new Set(capabilities),
56 issuedAt: 1,
57});
58
59function makeProject(
60 repositoryIdentity: OrchestrationProjectShell["repositoryIdentity"] = {
61 canonicalKey: "github.com/t3tools/t3code",
62 locator: {
63 source: "git-remote",
64 remoteName: "origin",
65 remoteUrl: "git@github.com:T3Tools/T3Code.git",
66 },
67 provider: "github",
68 displayName: "T3Tools/T3Code",
69 owner: "T3Tools",
70 name: "T3Code",
71 },
72): OrchestrationProjectShell {
73 return {
74 id: PROJECT_ID,
75 title: "Project",
76 workspaceRoot: "/workspace/project",
77 defaultModelSelection: null,
78 scripts: [],
79 repositoryIdentity,
80 createdAt: "2026-08-01T00:00:00.000Z",
81 updatedAt: "2026-08-01T00:00:00.000Z",
82 };
83}
84
85function makeThread(pullRequests: ReadonlyArray<ThreadPullRequestLink>): PullRequestTestThread {
86 return {
87 id: THREAD_ID,
88 projectId: PROJECT_ID,
89 title: "Thread",
90 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
91 runtimeMode: "full-access",
92 interactionMode: "default",
93 branch: null,
94 worktreePath: null,
95 pullRequests,
96 createdAt: "2026-08-01T00:00:00.000Z",
97 updatedAt: "2026-08-20T00:00:00.000Z",
98 archivedAt: null,
99 settledOverride: null,
100 settledAt: null,
101 latestUserMessageAt: "2026-08-20T00:00:00.000Z",
102 };
103}
104
105function makeLink(
106 number: number,
107 overrides: Partial<ThreadPullRequestLink> & {
108 readonly headBranch?: string;
109 readonly baseBranch?: string;
110 } = {},
111): ThreadPullRequestLink {
112 const { headBranch, baseBranch, ...rest } = overrides;
113 return {
114 host: "github.com",
115 repository: "t3tools/t3code",
116 number,
117 url: `https://github.com/t3tools/t3code/pull/${number}`,
118 source: "manual",
119 linkedAt: "2026-08-10T00:00:00.000Z",
120 snapshot:
121 headBranch === undefined
122 ? null
123 : {
124 state: "open",
125 title: `PR ${number}`,
126 headBranch,
127 baseBranch: baseBranch ?? "main",
128 isDraft: false,
129 updatedAt: null,
130 syncedAt: "2026-08-27T00:00:00.000Z",
131 },
132 stack: null,
133 ...rest,
134 };
135}
136
137interface HarnessOptions {
138 readonly thread?: PullRequestTestThread | null;
139 readonly project?: OrchestrationProjectShell | null;
140 readonly reject?: (command: OrchestrationCommand) => string | null;
141 readonly projects?: ReadonlyArray<OrchestrationProjectShell>;
142 readonly generate?: (
143 input: PullRequestRef,
144 ) => Effect.Effect<
145 PullRequestReviewGuideResult & { started: boolean },
146 PullRequestOperationError
147 >;
148}
149
150const NO_GUIDE: PullRequestReviewGuideResult = { guide: null, run: null, currentHeadSha: "head-1" };
151
152const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
153 options: HarnessOptions = {},
154) {
155 const commands = yield* Ref.make<ReadonlyArray<OrchestrationCommand>>([]);
156 const guideRequests = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
157 const thread = options.thread === undefined ? makeThread([]) : options.thread;
158 const project = options.project === undefined ? makeProject() : options.project;
159 const dispatch: Orchestrator.OrchestratorV2Shape["dispatch"] = (command) =>
160 Effect.gen(function* () {
161 const rejection = options.reject?.(command) ?? null;
162 if (rejection !== null)
163 return yield* new Orchestrator.OrchestratorDispatchError({
164 commandId: command.commandId,
165 commandType: command.type,
166 cause: rejection,
167 });
168 yield* Ref.update(commands, (recorded) => [...recorded, command]);
169 return { sequence: 1, storedEvents: [] };
170 });
171 const layerDependencies = Layer.mergeAll(
172 Layer.mock(ProjectService.ProjectService)({
173 getShell: () => Effect.succeed(Option.fromNullishOr(project)),
174 listShells: () => Effect.succeed(options.projects ?? (project ? [project] : [])),
175 }),
176 Layer.mock(PullRequestReviewGuideService.PullRequestReviewGuideService)({
177 get: () => Effect.succeed(NO_GUIDE),
178 generate: (input) =>
179 Ref.update(guideRequests, (recorded) => [...recorded, input]).pipe(
180 Effect.andThen(
181 options.generate?.(input) ??
182 Effect.succeed({
183 ...NO_GUIDE,
184 run: {
185 _tag: "Running" as const,
186 headSha: "head-1",
187 startedAt: "2026-10-11T00:00:00.000Z",
188 },
189 started: true,
190 }),
191 ),
192 ),
193 }),
194 Layer.mock(Orchestrator.OrchestratorV2)({
195 getThreadShell: (id) =>
196 Effect.succeed(id === THREAD_ID && thread ? v2PullRequestThread(thread) : null),
197 dispatch,
198 }),
199 Layer.succeed(Crypto.Crypto, testCrypto),
200 McpToolAccessTestkit.liveThreadsLayer,
201 );
202 const toolkit = yield* PullRequestsToolkit.pipe(
203 Effect.provide(
204 McpToolAccess.HandlersLayer.layer(PullRequestsHandlers.layer).pipe(
205 Layer.provide(layerDependencies),
206 ),
207 ),
208 );
209 const call = <Name extends keyof typeof PullRequestsToolkit.tools>(
210 name: Name,
211 params: Parameters<typeof toolkit.handle<Name>>[1],
212 capabilities: ReadonlyArray<McpInvocationContext.McpCapability> = ["pull-requests"],
213 ) =>
214 toolkit.handle(name, params).pipe(
215 Stream.unwrap,
216 Stream.runCollect,
217 Effect.map(
218 (chunk) => chunk.at(-1)!.result as Tool.Success<(typeof PullRequestsToolkit.tools)[Name]>,
219 ),
220 Effect.provideService(McpInvocationContext.McpInvocationContext, invocation(capabilities)),
221 Effect.provide(layerDependencies),
222 );
223 return { commands, guideRequests, call };
224});
225
226describe("pull request toolkit handlers", () => {
227 it.effect("refuses a credential without the pull-requests capability", () =>
228 Effect.gen(function* () {
229 const harness = yield* makeHarness();
230 const error = yield* harness
231 .call("list_thread_pull_requests", {}, ["preview"])
232 .pipe(Effect.flip);
233 expect(error).toMatchObject({
234 _tag: "McpCapabilityUnavailableError",
235 capability: "pull-requests",
236 threadId: THREAD_ID,
237 });
238 expect(yield* Ref.get(harness.commands)).toEqual([]);
239 }),
240 );
241
242 it.effect("links by URL with source agent on the token's thread", () =>
243 Effect.gen(function* () {
244 const harness = yield* makeHarness();
245 const result = yield* harness.call("link_pull_request", {
246 url: "https://github.com/T3Tools/T3Code/pull/123/files",
247 });
248 expect(result).toEqual({
249 host: "github.com",
250 repository: "t3tools/t3code",
251 number: 123,
252 url: "https://github.com/T3Tools/T3Code/pull/123/files",
253 alreadyLinked: false,
254 });
255 expect(yield* Ref.get(harness.commands)).toMatchObject([
256 {
257 type: "thread.pull-request.link",
258 threadId: THREAD_ID,
259 host: "github.com",
260 repository: "t3tools/t3code",
261 number: 123,
262 source: "agent",
263 },
264 ]);
265 }),
266 );
267
268 it.effect("watching an unlinked pull request links it first", () =>
269 Effect.gen(function* () {
270 const harness = yield* makeHarness();
271 const result = yield* harness.call("watch_pull_request", {
272 url: "https://github.com/t3tools/t3code/pull/9",
273 });
274 expect(result).toMatchObject({ number: 9, watching: false, wasWatching: false });
275 expect(yield* Ref.get(harness.commands)).toMatchObject([
276 {
277 type: "thread.pull-request.watch",
278 number: 9,
279 watching: true,
280 link: { url: "https://github.com/t3tools/t3code/pull/9", source: "agent" },
281 },
282 ]);
283 }),
284 );
285
286 it.effect("refuses to watch a merged pull request and stops an existing watch", () =>
287 Effect.gen(function* () {
288 const watch = {
289 startedAt: "2026-08-20T00:00:00.000Z",
290 headSha: null,
291 failedChecks: [],
292 passed: false,
293 passedChecks: [],
294 remarksThrough: "2026-08-20T00:00:00.000Z",
295 remarkIds: [],
296 conflicting: false,
297 wakes: 0,
298 };
299 const merged = makeLink(1, { headBranch: "done" });
300 const harness = yield* makeHarness({
301 thread: makeThread([
302 { ...merged, snapshot: merged.snapshot && { ...merged.snapshot, state: "merged" } },
303 makeLink(2, { headBranch: "idle" }),
304 makeLink(3, { headBranch: "watched", watch }),
305 ]),
306 });
307 const error = yield* harness
308 .call("watch_pull_request", { repository: "t3tools/t3code", number: 1 })
309 .pipe(Effect.flip);
310 expect(error).toMatchObject({ _tag: "PullRequestNotOpenError", state: "merged" });
311 expect(
312 yield* harness.call("unwatch_pull_request", { repository: "t3tools/t3code", number: 3 }),
313 ).toMatchObject({ wasWatching: true });
314 expect(yield* Ref.get(harness.commands)).toMatchObject([
315 { type: "thread.pull-request.watch", number: 3, watching: false },
316 ]);
317 }),
318 );
319
320 it.effect("watches a pull request saved as closed, since it may have reopened", () =>
321 Effect.gen(function* () {
322 const closed = makeLink(1, { headBranch: "closed" });
323 const harness = yield* makeHarness({
324 thread: makeThread([
325 { ...closed, snapshot: closed.snapshot && { ...closed.snapshot, state: "closed" } },
326 ]),
327 });
328 yield* harness.call("watch_pull_request", { repository: "t3tools/t3code", number: 1 });
329 expect(yield* Ref.get(harness.commands)).toMatchObject([
330 { type: "thread.pull-request.watch", number: 1, watching: true },
331 ]);
332 }),
333 );
334
335 it.effect("refuses a watch from a subagent thread, whose parent owns the pull request", () =>
336 Effect.gen(function* () {
337 const harness = yield* makeHarness({
338 thread: {
339 ...makeThread([makeLink(1, { headBranch: "feature" })]),
340 lineage: {
341 rootThreadId: ThreadId.make("parent"),
342 parentThreadId: ThreadId.make("parent"),
343 relationshipToParent: "subagent",
344 },
345 },
346 });
347 const error = yield* harness
348 .call("watch_pull_request", { repository: "t3tools/t3code", number: 1 })
349 .pipe(Effect.flip);
350 expect(error).toMatchObject({ _tag: "PullRequestWatchFromSubagentError" });
351 expect(yield* Ref.get(harness.commands)).toEqual([]);
352 }),
353 );
354
355 it.effect("builds the URL in the project host's own shape", () =>
356 Effect.gen(function* () {
357 const harness = yield* makeHarness({
358 project: makeProject({
359 canonicalKey: "gitlab.com/group/sub/project",
360 locator: {
361 source: "git-remote",
362 remoteName: "origin",
363 remoteUrl: "git@gitlab.com:group/sub/project.git",
364 },
365 provider: "gitlab",
366 displayName: "group/sub/project",
367 }),
368 });
369 const result = yield* harness.call("link_pull_request", {
370 repository: "group/sub/project",
371 number: 42,
372 });
373 expect(result.url).toBe("https://gitlab.com/group/sub/project/-/merge_requests/42");
374 expect(result.host).toBe("gitlab.com");
375 }),
376 );
377
378 it.effect("links a numeric Forgejo reference with its remote's web origin and mount path", () =>
379 Effect.gen(function* () {
380 const harness = yield* makeHarness({
381 project: makeProject({
382 canonicalKey: "forge.example/git/owner/repo",
383 locator: {
384 source: "git-remote",
385 remoteName: "origin",
386 remoteUrl: "http://forge.example:3000/git/owner/repo.git",
387 },
388 provider: "forgejo",
389 displayName: "git/owner/repo",
390 }),
391 });
392 const result = yield* harness.call("link_pull_request", {
393 repository: "git/owner/repo",
394 number: 42,
395 });
396 expect(result).toEqual({
397 host: "forge.example:3000",
398 repository: "git/owner/repo",
399 number: 42,
400 url: "http://forge.example:3000/git/owner/repo/pulls/42",
401 alreadyLinked: false,
402 });
403 const other = yield* harness.call("link_pull_request", {
404 host: "other.example",
405 repository: "owner/repo",
406 number: 42,
407 });
408 expect(other.url).toBe("https://other.example/owner/repo/pull/42");
409 }),
410 );
411
412 it.effect("links Azure DevOps Server URLs and numeric references without a known provider", () =>
413 Effect.gen(function* () {
414 const harness = yield* makeHarness({
415 project: makeProject({
416 canonicalKey: "scm.example.test/tfs/collection/project/_git/repo",
417 locator: {
418 source: "git-remote",
419 remoteName: "origin",
420 remoteUrl: "http://dummy:secret@scm.example.test:8080/tfs/Collection/Project/_git/Repo",
421 },
422 provider: "unknown",
423 displayName: "tfs/collection/project/_git/repo",
424 }),
425 });
426 const generated =
427 "http://scm.example.test:8080/tfs/collection/project/_git/repo/pullrequest/124";
428 const fromNumber = yield* harness.call("link_pull_request", {
429 repository: "tfs/Collection/Project/_git/Repo",
430 number: 124,
431 });
432 expect.soft(fromNumber.url).toBe(generated);
433
434 const supplied = "https://scm.example.test/tfs/Collection/Project/_git/Repo/pullrequest/123";
435 const fromUrl = yield* harness.call("link_pull_request", { url: supplied });
436 expect(fromUrl).toEqual({
437 host: "scm.example.test",
438 repository: "tfs/collection/project/_git/repo",
439 number: 123,
440 url: supplied,
441 alreadyLinked: false,
442 });
443 expect(yield* Ref.get(harness.commands)).toMatchObject([
444 { type: "thread.pull-request.link", number: 124, url: generated },
445 { type: "thread.pull-request.link", number: 123, url: supplied },
446 ]);
447 }),
448 );
449
450 it.effect("treats a duplicate link as alreadyLinked rather than an error", () =>
451 Effect.gen(function* () {
452 const harness = yield* makeHarness({
453 thread: makeThread([makeLink(123)]),
454 reject: (command) =>
455 command.type === "thread.pull-request.link" ? "already linked" : null,
456 });
457 const result = yield* harness.call("link_pull_request", {
458 url: "https://github.com/t3tools/t3code/pull/123",
459 });
460 expect(result.alreadyLinked).toBe(true);
461 }),
462 );
463
464 it.effect("unlinks a linked pull request and reports a missing one as wasLinked=false", () =>
465 Effect.gen(function* () {
466 const harness = yield* makeHarness({
467 thread: makeThread([makeLink(5)]),
468 reject: (command) =>
469 command.type === "thread.pull-request.unlink" && command.number !== 5
470 ? "not linked"
471 : null,
472 });
473 const linked = yield* harness.call("unlink_pull_request", {
474 repository: "t3tools/t3code",
475 number: 5,
476 });
477 expect(linked).toEqual({
478 host: "github.com",
479 repository: "t3tools/t3code",
480 number: 5,
481 wasLinked: true,
482 });
483 const missing = yield* harness.call("unlink_pull_request", {
484 url: "https://github.com/t3tools/t3code/pull/9",
485 });
486 expect(missing.wasLinked).toBe(false);
487 expect(yield* Ref.get(harness.commands)).toMatchObject([
488 { type: "thread.pull-request.unlink", number: 5 },
489 ]);
490 }),
491 );
492
493 it("reports an older Forgejo link's HTTP port when listing thread links", () => {
494 const result = listThreadPullRequests(
495 makeThread([
496 makeLink(42, {
497 host: "forge.example",
498 url: "http://forge.example:3000/t3tools/t3code/pulls/42",
499 }),
500 ]),
501 );
502 expect(result.pullRequests[0]?.host).toBe("forge.example:3000");
503 });
504
505 it.effect("lists visible links with host state and derived chain order", () =>
506 Effect.gen(function* () {
507 const harness = yield* makeHarness({
508 thread: makeThread([
509 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-b", source: "agent" }),
510 makeLink(1, { headBranch: "feat-a", baseBranch: "main", source: "created" }),
511 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a", source: "agent" }),
512 makeLink(9, { source: "stack-dismissed" }),
513 makeLink(10),
514 ]),
515 });
516 const result = yield* harness.call("list_thread_pull_requests", {});
517 expect(result.pullRequests.map((entry) => entry.number)).toEqual([3, 1, 2, 10]);
518 expect(result.pullRequests[0]).toEqual({
519 host: "github.com",
520 repository: "t3tools/t3code",
521 number: 3,
522 url: "https://github.com/t3tools/t3code/pull/3",
523 source: "agent",
524 watching: false,
525 state: "open",
526 title: "PR 3",
527 headBranch: "feat-c",
528 baseBranch: "feat-b",
529 isDraft: false,
530 stack: { kind: "derived", position: 3, size: 3 },
531 });
532 expect(result.pullRequests[3]).toMatchObject({
533 number: 10,
534 state: null,
535 title: null,
536 headBranch: null,
537 stack: null,
538 });
539 expect(result.chains).toEqual([
540 { kind: "derived", numbers: [1, 2, 3] },
541 { kind: "derived", numbers: [10] },
542 ]);
543 }),
544 );
545});
546
547describe("listThreadPullRequests", () => {
548 it("reports a native stack position for each member", () => {
549 const stack = {
550 kind: "native" as const,
551 id: "stack-1",
552 number: 1,
553 url: "https://github.com/t3tools/t3code/stack/1",
554 base: "main",
555 layers: [
556 { number: 1, headBranch: "a", state: "open" as const },
557 { number: 2, headBranch: "b", state: "open" as const },
558 ],
559 };
560 const result = listThreadPullRequests({
561 pullRequests: [
562 makeLink(2, { stack, source: "stack" }),
563 makeLink(1, { stack, source: "created" }),
564 ],
565 });
566 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
567 [2, { kind: "native", position: 2, size: 2 }],
568 [1, { kind: "native", position: 1, size: 2 }],
569 ]);
570 expect(result.chains).toEqual([{ kind: "native", numbers: [1, 2] }]);
571 });
572
573 it("gives pull requests built on the same one the same position", () => {
574 const result = listThreadPullRequests({
575 pullRequests: [
576 makeLink(1, { headBranch: "feat-a", baseBranch: "main" }),
577 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a" }),
578 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-a" }),
579 ],
580 });
581 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
582 [1, { kind: "derived", position: 1, size: 3 }],
583 [2, { kind: "derived", position: 2, size: 3 }],
584 [3, { kind: "derived", position: 2, size: 3 }],
585 ]);
586 expect(result.chains).toEqual([{ kind: "derived", numbers: [1, 2, 3] }]);
587 });
588});
589
590describe("pull request guide tools", () => {
591 it.effect(
592 "writes guides through the project whose checkout is each pull request's repository",
593 () =>
594 Effect.gen(function* () {
595 const other = {
596 ...makeProject({
597 canonicalKey: "github.com/acme/web",
598 locator: {
599 source: "git-remote",
600 remoteName: "origin",
601 remoteUrl: "git@github.com:acme/web.git",
602 },
603 provider: "github",
604 displayName: "acme/web",
605 owner: "acme",
606 name: "web",
607 }),
608 id: ProjectId.make("project-web"),
609 };
610 const harness = yield* makeHarness({ projects: [makeProject(), other] });
611 const result = yield* harness.call("write_pull_request_guides", {
612 pullRequests: [
613 { url: "https://github.com/acme/web/pull/7" },
614 { repository: "t3tools/t3code", number: 12 },
615 { url: "https://github.com/someone/else/pull/1" },
616 ],
617 });
618 expect(
619 result.guides.map((guide) => [guide.repository, guide.number, guide.outcome]),
620 ).toEqual([
621 ["acme/web", 7, "started"],
622 ["t3tools/t3code", 12, "started"],
623 ["someone/else", 1, "failed"],
624 ]);
625 expect(result.guides[2]?.detail).toContain("No project in this environment");
626 expect(
627 (yield* Ref.get(harness.guideRequests)).map((ref) => [ref.projectId, ref.number]),
628 ).toEqual([
629 ["project-web", 7],
630 [PROJECT_ID, 12],
631 ]);
632 }),
633 );
634
635 it.effect("reports an unreadable entry on its own and still writes the rest of the batch", () =>
636 Effect.gen(function* () {
637 const harness = yield* makeHarness();
638 const result = yield* harness.call("write_pull_request_guides", {
639 pullRequests: [
640 { url: "https://example.com/not-a-pull-request" },
641 { repository: "t3tools/t3code" },
642 { repository: "t3tools/t3code", number: 5 },
643 ],
644 });
645 expect(result.guides.map((guide) => guide.outcome)).toEqual(["failed", "failed", "started"]);
646 expect(result.guides[0]?.detail).toContain("not a recognised pull request URL");
647 expect(result.guides[1]?.detail).toContain("Pass either url");
648 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.number)).toEqual([5]);
649 }),
650 );
651
652 it.effect("finds an Azure DevOps checkout for a pull request named by its full path", () =>
653 Effect.gen(function* () {
654 const azure = {
655 ...makeProject({
656 canonicalKey: "dev.azure.com/org/project/_git/web",
657 locator: {
658 source: "git-remote",
659 remoteName: "origin",
660 remoteUrl: "https://dev.azure.com/org/project/_git/web",
661 },
662 provider: "azure-devops",
663 displayName: "org/project/_git/web",
664 owner: "org",
665 name: "web",
666 }),
667 id: ProjectId.make("project-azure"),
668 };
669 const harness = yield* makeHarness({ projects: [makeProject(), azure] });
670 const result = yield* harness.call("write_pull_request_guides", {
671 pullRequests: [{ host: "dev.azure.com", repository: "org/project/_git/web", number: 9 }],
672 });
673 expect(result.guides.map((guide) => guide.outcome)).toEqual(["started"]);
674 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.projectId)).toEqual([
675 "project-azure",
676 ]);
677 }),
678 );
679});