|
5 | 5 | ProviderInstanceId, |
6 | 6 | ProviderSetupError, |
7 | 7 | } from "@t3tools/contracts"; |
| 8 | +import { symlinksSupported } from "@t3tools/shared/testing/symlinks"; |
8 | 9 | import * as Deferred from "effect/Deferred"; |
9 | 10 | import * as Effect from "effect/Effect"; |
10 | 11 | import * as Exit from "effect/Exit"; |
@@ -60,6 +61,7 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* |
60 | 61 | readonly startError?: AcpError; |
61 | 62 | readonly rejectAdmission?: boolean; |
62 | 63 | readonly sessionId?: string; |
| 64 | + readonly startupSkills?: boolean; |
63 | 65 | } = {}, |
64 | 66 | ) { |
65 | 67 | const fs = yield* FileSystem.FileSystem; |
@@ -135,6 +137,13 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* |
135 | 137 | start: () => |
136 | 138 | Effect.gen(function* () { |
137 | 139 | if (options.startError) return yield* options.startError; |
| 140 | + if (options.startupSkills) { |
| 141 | + for (const directory of [".agents", ".gemini"]) { |
| 142 | + yield* fs |
| 143 | + .makeDirectory(path.join(cwd, directory, "skills"), { recursive: true }) |
| 144 | + .pipe(Effect.orDie); |
| 145 | + } |
| 146 | + } |
138 | 147 | yield* fs.makeDirectory(brainDirectory, { recursive: true }).pipe(Effect.orDie); |
139 | 148 | yield* fs.writeFileString(`${sessionBase}.db`, "helper session").pipe(Effect.orDie); |
140 | 149 | yield* fs.writeFileString(`${sessionBase}.db-wal`, "helper journal").pipe(Effect.orDie); |
@@ -279,11 +288,12 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* |
279 | 288 | }); |
280 | 289 |
|
281 | 290 | it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => { |
282 | | - it.effect( |
283 | | - "generates all helper types in empty workspaces and removes only owned session files", |
284 | | - () => |
| 291 | + it.effect.each([false, true])( |
| 292 | + "generates all helper types and cleans up with startupSkills=%s", |
| 293 | + (startupSkills) => |
285 | 294 | Effect.gen(function* () { |
286 | 295 | const fixture = yield* makeFixture({ |
| 296 | + startupSkills, |
287 | 297 | outputs: [ |
288 | 298 | '{"subject":" Repair Google login.\\nExtra line","body":" Keep the remote callback. ","branch":"Repair Login"}', |
289 | 299 | '```json\n{"title":" Repair Google login\\nExtra line","body":" ## Summary\\nSupport remote callbacks. "}\n```', |
@@ -442,29 +452,51 @@ it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => { |
442 | 452 | }).pipe(Effect.scoped), |
443 | 453 | ); |
444 | 454 |
|
445 | | - it.effect("rejects a helper that writes files in its temporary workspace", () => |
446 | | - Effect.gen(function* () { |
447 | | - const fs = yield* FileSystem.FileSystem; |
448 | | - const path = yield* Path.Path; |
449 | | - const fixture = yield* makeFixture({ |
450 | | - prompt: ({ cwd, emit }) => |
451 | | - Effect.gen(function* () { |
452 | | - yield* fs |
453 | | - .writeFileString(path.join(cwd, "unexpected.txt"), "unexpected") |
454 | | - .pipe(Effect.orDie); |
455 | | - yield* emit({ |
456 | | - sessionUpdate: "agent_message_chunk", |
457 | | - content: { type: "text", text: '{"title":"Ignored output"}' }, |
458 | | - }); |
459 | | - return { stopReason: "end_turn" }; |
460 | | - }), |
461 | | - }); |
462 | | - const error = yield* fixture.textGeneration |
463 | | - .generateThreadTitle(fixture.titleInput) |
464 | | - .pipe(Effect.flip); |
465 | | - expect(error.detail).toContain("wrote files"); |
466 | | - yield* fixture.assertCleaned; |
467 | | - }).pipe(Effect.scoped), |
| 455 | + it.effect.each([ |
| 456 | + { relativePath: "unexpected.txt", kind: "file" }, |
| 457 | + { relativePath: ".agents/skills/unexpected.txt", kind: "file" }, |
| 458 | + { relativePath: ".gemini/unexpected", kind: "directory" }, |
| 459 | + { relativePath: ".agents/skills", kind: "file" }, |
| 460 | + ...(symlinksSupported ? [{ relativePath: ".gemini/skills", kind: "symlink" }] : []), |
| 461 | + ])( |
| 462 | + "rejects an unexpected $kind at $relativePath in its temporary workspace", |
| 463 | + ({ relativePath, kind }) => |
| 464 | + Effect.gen(function* () { |
| 465 | + const fs = yield* FileSystem.FileSystem; |
| 466 | + const path = yield* Path.Path; |
| 467 | + const target = |
| 468 | + kind === "symlink" |
| 469 | + ? yield* fs.makeTempDirectoryScoped({ prefix: "t3-antigravity-link-test-" }) |
| 470 | + : undefined; |
| 471 | + const fixture = yield* makeFixture({ |
| 472 | + startupSkills: true, |
| 473 | + prompt: ({ cwd, emit }) => |
| 474 | + Effect.gen(function* () { |
| 475 | + const entry = path.join(cwd, relativePath); |
| 476 | + if (yield* fs.exists(entry).pipe(Effect.orDie)) { |
| 477 | + yield* fs.remove(entry, { recursive: true }).pipe(Effect.orDie); |
| 478 | + } |
| 479 | + yield* ( |
| 480 | + target !== undefined |
| 481 | + ? fs.symlink(target, entry) |
| 482 | + : kind === "directory" |
| 483 | + ? fs.makeDirectory(entry) |
| 484 | + : fs.writeFileString(entry, "unexpected") |
| 485 | + ).pipe(Effect.orDie); |
| 486 | + yield* emit({ |
| 487 | + sessionUpdate: "agent_message_chunk", |
| 488 | + content: { type: "text", text: '{"title":"Ignored output"}' }, |
| 489 | + }); |
| 490 | + return { stopReason: "end_turn" }; |
| 491 | + }), |
| 492 | + }); |
| 493 | + const error = yield* fixture.textGeneration |
| 494 | + .generateThreadTitle(fixture.titleInput) |
| 495 | + .pipe(Effect.flip); |
| 496 | + expect(error.detail).toContain("wrote files"); |
| 497 | + if (target !== undefined) expect(yield* fs.exists(target)).toBe(true); |
| 498 | + yield* fixture.assertCleaned; |
| 499 | + }).pipe(Effect.scoped), |
468 | 500 | ); |
469 | 501 |
|
470 | 502 | it.effect("uses the native default without sending T3's default selection as a model ID", () => |
@@ -576,3 +608,15 @@ it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => { |
576 | 608 | }).pipe(Effect.scoped), |
577 | 609 | ); |
578 | 610 | }); |
| 611 | + |
| 612 | +it.effect("retains filesystem services supplied only during construction", () => |
| 613 | + Effect.gen(function* () { |
| 614 | + const fixture = yield* makeFixture({ startupSkills: true }).pipe( |
| 615 | + Effect.provide(NodeServices.layer), |
| 616 | + ); |
| 617 | + expect(yield* fixture.textGeneration.generateThreadTitle(fixture.titleInput)).toEqual({ |
| 618 | + title: "Repair login", |
| 619 | + }); |
| 620 | + yield* fixture.assertCleaned; |
| 621 | + }).pipe(Effect.scoped), |
| 622 | +); |
0 commit comments