Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AntigravityProvider.test.ts

673 lines25.3 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { describe, expect, it } from "@effect/vitest";
3import {
4 ANTIGRAVITY_DEFAULT_MODEL,
5 AntigravitySettings,
6 ProviderDriverKind,
7 ProviderInstanceId,
8 ProviderSetupError,
9} from "@t3tools/contracts";
10import * as Deferred from "effect/Deferred";
11import * as Effect from "effect/Effect";
12import * as Fiber from "effect/Fiber";
13import * as Layer from "effect/Layer";
14import * as Ref from "effect/Ref";
15import * as Schema from "effect/Schema";
16import * as Stream from "effect/Stream";
17import * as TestClock from "effect/testing/TestClock";
18import * as EffectAcpErrors from "effect-acp/errors";
19import type * as EffectAcpSchema from "effect-acp/compat";
20​
21import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
22import * as ServerConfig from "../config.ts";
23import * as ServerSettings from "../serverSettings.ts";
24import * as ProviderHostLive from "./ProviderHostLive.ts";
25import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
26import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
27import {
28 buildAntigravityModelsFromSession,
29 makeAntigravityProvider,
30} from "./AntigravityProvider.ts";
31​
32const decodeSettings = Schema.decodeSync(AntigravitySettings);
33const instanceId = ProviderInstanceId.make("antigravity-test");
34const driver = ProviderDriverKind.make("antigravity");
35​
36const initializeResult = {
37 protocolVersion: 1,
38 agentCapabilities: {
39 loadSession: true,
40 promptCapabilities: { image: true, audio: true, embeddedContext: true },
41 sessionCapabilities: { list: {}, resume: {} },
42 },
43 authMethods: [{ id: "oauth-personal", name: "Log in with Google" }],
44 agentInfo: {
45 name: "antigravity-acp",
46 title: "Google Antigravity",
47 version: "agy_acp_server_20260818_01_RC01",
48 },
49} satisfies EffectAcpSchema.InitializeResponse;
50​
51const modelOptions = [
52 { value: "gemini-3.8-flash-high", name: "Gemini 3.8 Flash (High)" },
53 { value: "gemini-3.8-flash-medium", name: "Gemini 3.8 Flash (Medium)" },
54 { value: "gemini-3.8-flash-low", name: "Gemini 3.8 Flash (Low)" },
55 { value: "gemini-3.7-flash-high", name: "Gemini 3.7 Flash (High)" },
56 { value: "gemini-3.7-flash-medium", name: "Gemini 3.7 Flash (Medium)" },
57 { value: "gemini-3.7-flash-low", name: "Gemini 3.7 Flash (Low)" },
58 { value: "gemini-3.6-flash-high", name: "Gemini 3.6 Flash (High)" },
59 { value: "gemini-3.6-flash-medium", name: "Gemini 3.6 Flash (Medium)" },
60 { value: "gemini-3.6-flash-low", name: "Gemini 3.6 Flash (Low)" },
61 { value: "gemini-pro-agent", name: "Gemini 3.1 Pro (High)" },
62 { value: "gemini-3.1-pro-low", name: "Gemini 3.1 Pro (Low)" },
63];
64​
65const modelConfig = {
66 id: "model",
67 name: "Model",
68 category: "model",
69 type: "select",
70 currentValue: "gemini-3.7-flash-high",
71 options: modelOptions,
72} satisfies EffectAcpSchema.SessionConfigOption;
73​
74const sessionSetupResult = {
75 sessionId: "session-1",
76 models: {
77 currentModelId: "gemini-3.7-flash-high",
78 availableModels: modelOptions.map((option) => ({ modelId: option.value, name: option.name })),
79 },
80 configOptions: [
81 modelConfig,
82 {
83 id: "mode",
84 name: "Session Mode",
85 category: "mode",
86 type: "select",
87 currentValue: "default",
88 options: [
89 { value: "default", name: "Default" },
90 { value: "yolo", name: "YOLO" },
91 ],
92 },
93 ],
94} satisfies EffectAcpSchema.NewSessionResponse;
95​
96const started = {
97 sessionId: "session-1",
98 initializeResult,
99 sessionSetupResult,
100 modelConfigId: "model",
101} satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult;
102​
103const commands = [
104 { name: "plan", description: "Create a plan", input: { type: "text", hint: "What to plan" } },
105 { name: "logout", description: "Sign out of Google" },
106] satisfies ReadonlyArray<EffectAcpSchema.AvailableCommand>;
107​
108const expectedCommands = [
109 { name: "plan", description: "Create a plan", input: { hint: "What to plan" } },
110 { name: "logout", description: "Sign out of Google" },
111];
112​
113const layerTest = ProviderHostLive.layer.pipe(
114 Layer.provideMerge(
115 Layer.mock(BackgroundPolicy.BackgroundPolicy)({
116 shouldRunScopeWork: () => Effect.succeed(false),
117 }),
118 ),
119 Layer.provideMerge(ServerSettings.layerTest()),
120 Layer.provideMerge(ServerSecretStore.layer),
121 Layer.provide(
122 ServerConfig.layerTest(process.cwd(), { prefix: "t3-antigravity-provider-test-" }).pipe(
123 Layer.provideMerge(NodeServices.layer),
124 ),
125 ),
126);
127​
128type ProbeError = EffectAcpErrors.AcpError | ProviderSetupError;
129​
130const makeHarness = Effect.fn("makeAntigravityProviderHarness")(function* (
131 options: { readonly enabled?: boolean; readonly safe?: boolean } = {},
132) {
133 const initialProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse, ProbeError>();
134 const probeCalls = yield* Ref.make(0);
135 const safetyCalls = yield* Ref.make(0);
136 const probe = yield* Ref.make<Effect.Effect<EffectAcpSchema.InitializeResponse, ProbeError>>(
137 Deferred.await(initialProbe),
138 );
139 const safety = yield* Ref.make<Effect.Effect<boolean>>(Effect.succeed(options.safe ?? true));
140 const provider = yield* makeAntigravityProvider(
141 decodeSettings({ enabled: options.enabled ?? true, customModels: ["do-not-seed-me"] }),
142 {
143 stampIdentity: (snapshot) => Effect.succeed({ ...snapshot, instanceId, driver }),
144 probe: Ref.update(probeCalls, (count) => count + 1).pipe(
145 Effect.andThen(Ref.get(probe)),
146 Effect.flatten,
147 ),
148 supportsTextGeneration: Ref.update(safetyCalls, (count) => count + 1).pipe(
149 Effect.andThen(Ref.get(safety)),
150 Effect.flatten,
151 ),
152 },
153 );
154 const initialUpdate = yield* Stream.toPull(
155 provider.snapshot.streamChanges.pipe(
156 Stream.filter((snapshot) => snapshot.installed || snapshot.status === "error"),
157 ),
158 );
159 const initialize = Deferred.succeed(initialProbe, initializeResult).pipe(
160 Effect.andThen(initialUpdate),
161 Effect.asVoid,
162 );
163 return {
164 provider,
165 probe,
166 probeCalls,
167 safety,
168 safetyCalls,
169 initialProbe,
170 initialUpdate,
171 initialize,
172 };
173});
174​
175describe("Antigravity model catalog", () => {
176 it("keeps the captured personal catalog's IDs, labels, order, and selected default", () => {
177 const models = buildAntigravityModelsFromSession(sessionSetupResult);
178 expect(models.map((model) => [model.slug, model.name])).toEqual(
179 modelOptions.map((option) => [option.value, option.name]),
180 );
181 expect(models.filter((model) => model.isDefault).map((model) => model.slug)).toEqual([
182 "gemini-3.7-flash-high",
183 ]);
184 expect(
185 models
186 .filter((model) => model.aliases?.includes(ANTIGRAVITY_DEFAULT_MODEL))
187 .map((model) => model.slug),
188 ).toEqual(["gemini-3.7-flash-high"]);
189 expect(models.every((model) => model.capabilities?.optionDescriptors?.length === 0)).toBe(true);
190 expect(models.every((model) => !model.isCustom)).toBe(true);
191 });
192​
193 it("uses legacy session models only when model config is absent", () => {
194 const fromLegacy = buildAntigravityModelsFromSession({
195 models: sessionSetupResult.models,
196 });
197 expect(fromLegacy).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
198 expect(
199 buildAntigravityModelsFromSession({
200 ...sessionSetupResult,
201 configOptions: [{ ...modelConfig, options: [] }],
202 }),
203 ).toEqual([]);
204 });
205​
206 it("flattens native option groups without combining distinct model IDs", () => {
207 const models = buildAntigravityModelsFromSession({
208 configOptions: [
209 {
210 ...modelConfig,
211 currentValue: "gemini-pro-agent",
212 options: [
213 { groupId: "Flash", name: "Flash", options: [modelOptions[3]!, modelOptions[4]!] },
214 { groupId: "Pro", name: "Pro", options: [modelOptions[9]!, modelOptions[3]!] },
215 ],
216 },
217 ],
218 });
219 expect(models.map((model) => model.slug)).toEqual([
220 "gemini-3.7-flash-high",
221 "gemini-3.7-flash-medium",
222 "gemini-pro-agent",
223 ]);
224 expect(models.find((model) => model.isDefault)?.slug).toBe("gemini-pro-agent");
225 expect(models.find((model) => model.aliases?.includes(ANTIGRAVITY_DEFAULT_MODEL))?.slug).toBe(
226 "gemini-pro-agent",
227 );
228 });
229});
230​
231it.layer(layerTest)("Antigravity provider snapshots", (it) => {
232 it.effect("does not probe or run helper safety checks while disabled", () =>
233 Effect.scoped(
234 Effect.gen(function* () {
235 const harness = yield* makeHarness({ enabled: false });
236 const snapshot = yield* harness.provider.snapshot.refresh;
237 expect(snapshot).toMatchObject({
238 enabled: false,
239 installed: false,
240 status: "disabled",
241 auth: { status: "unknown" },
242 models: [],
243 setup: { canAuthenticate: true, canInstall: true },
244 showInteractionModeToggle: false,
245 supportsConversationRollback: false,
246 supportsTextGeneration: false,
247 });
248 expect(yield* Ref.get(harness.probeCalls)).toBe(0);
249 expect(yield* Ref.get(harness.safetyCalls)).toBe(0);
250 }),
251 ),
252 );
253​
254 it.effect("records explicit sign-in while disabled without starting a health probe", () =>
255 Effect.scoped(
256 Effect.gen(function* () {
257 const harness = yield* makeHarness({ enabled: false });
258 const signedIn = yield* Stream.toPull(
259 harness.provider.snapshot.streamChanges.pipe(
260 Stream.filter(
261 (snapshot) =>
262 snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0,
263 ),
264 ),
265 );
266 yield* harness.provider.onSessionStarted(started);
267 yield* harness.provider.onAvailableCommands(commands);
268 const [snapshot] = yield* signedIn;
269 expect(snapshot).toMatchObject({
270 enabled: false,
271 installed: true,
272 status: "disabled",
273 auth: { status: "authenticated", type: "oauth-personal" },
274 workspaceSnapshots: [],
275 });
276 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
277 expect(snapshot.slashCommands).toEqual(expectedCommands);
278 expect((yield* harness.provider.snapshot.refresh).models).toEqual(snapshot.models);
279 expect(yield* Ref.get(harness.probeCalls)).toBe(0);
280 }),
281 ),
282 );
283​
284 it.effect("publishes the configured sign-in method before any account is checked", () =>
285 Effect.scoped(
286 Effect.gen(function* () {
287 const provider = yield* makeAntigravityProvider(decodeSettings({ enabled: true }), {
288 stampIdentity: (snapshot) => Effect.succeed({ ...snapshot, instanceId, driver }),
289 probe: Effect.succeed(initializeResult),
290 supportsTextGeneration: Effect.succeed(true),
291 auth: { type: "gemini-api-key", label: "Gemini API key" },
292 });
293 expect((yield* provider.snapshot.getSnapshot).auth).toEqual({
294 status: "unknown",
295 type: "gemini-api-key",
296 });
297 }),
298 ),
299 );
300​
301 it.effect("treats initialize as installation proof, not account or model discovery", () =>
302 Effect.scoped(
303 Effect.gen(function* () {
304 const harness = yield* makeHarness();
305 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
306 installed: false,
307 status: "warning",
308 auth: { status: "unknown" },
309 models: [],
310 });
311 yield* harness.initialize;
312 const snapshot = yield* harness.provider.snapshot.getSnapshot;
313 expect(snapshot).toMatchObject({
314 installed: true,
315 status: "warning",
316 version: "agy_acp_server_20260818_01_RC01",
317 auth: { status: "unknown" },
318 models: [],
319 });
320 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
321 }),
322 ),
323 );
324​
325 it.effect("publishes session metadata and native commands without another health probe", () =>
326 Effect.scoped(
327 Effect.gen(function* () {
328 const harness = yield* makeHarness();
329 yield* harness.initialize;
330 const nextReady = yield* Stream.toPull(
331 harness.provider.snapshot.streamChanges.pipe(
332 Stream.filter(
333 (snapshot) =>
334 snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0,
335 ),
336 ),
337 );
338 yield* harness.provider.onSessionStarted(started, "/workspace");
339 yield* harness.provider.onAvailableCommands(commands, "/workspace");
340 const [snapshot] = yield* nextReady;
341 expect(snapshot).toMatchObject({
342 status: "ready",
343 auth: { status: "authenticated", type: "oauth-personal" },
344 supportsTextGeneration: true,
345 });
346 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
347 expect(snapshot.slashCommands).toEqual(expectedCommands);
348 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual(
349 expectedCommands,
350 );
351 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
352 }),
353 ),
354 );
355​
356 it.effect("does not retain a disposable sign-in workspace", () =>
357 Effect.scoped(
358 Effect.gen(function* () {
359 const harness = yield* makeHarness();
360 yield* harness.initialize;
361 yield* harness.provider.onSessionStarted(started);
362 yield* harness.provider.onAvailableCommands(commands);
363 const snapshot = yield* harness.provider.snapshot.getSnapshot;
364 expect(snapshot.models).toHaveLength(11);
365 expect(snapshot.slashCommands).toEqual(expectedCommands);
366 expect(snapshot.workspaceSnapshots).toEqual([]);
367 }),
368 ),
369 );
370​
371 it.effect("clears all account metadata on sign-out and authentication failure", () =>
372 Effect.scoped(
373 Effect.gen(function* () {
374 const harness = yield* makeHarness();
375 yield* harness.initialize;
376 for (const clear of [harness.provider.onSignedOut, harness.provider.onAuthRequired]) {
377 yield* harness.provider.onSessionStarted(started, "/workspace");
378 yield* harness.provider.onAvailableCommands(commands, "/workspace");
379 yield* clear;
380 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
381 installed: true,
382 status: "warning",
383 auth: { status: "unauthenticated" },
384 models: [],
385 slashCommands: [],
386 skills: [],
387 workspaceSnapshots: [],
388 supportsTextGeneration: false,
389 });
390 yield* harness.provider.onAvailableCommands(commands, "/workspace");
391 yield* harness.provider.onConfigOptionsUpdated([modelConfig]);
392 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual([]);
393 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
394 }
395 const refreshed = yield* harness.provider.snapshot.refresh;
396 expect(refreshed.auth.status).toBe("unauthenticated");
397 expect(refreshed.supportsTextGeneration).toBe(false);
398 }),
399 ),
400 );
401​
402 it.effect("replaces live model choices and accepts an empty catalog", () =>
403 Effect.scoped(
404 Effect.gen(function* () {
405 const harness = yield* makeHarness();
406 yield* harness.initialize;
407 yield* harness.provider.onSessionStarted(started, "/workspace");
408 yield* harness.provider.onAvailableCommands(commands, "/workspace");
409 const before = yield* harness.provider.snapshot.getSnapshot;
410 const configOptions = [
411 {
412 ...modelConfig,
413 currentValue: "gemini-3.8-flash-high",
414 options: modelOptions.slice(0, 3),
415 },
416 ];
417 const nextSnapshot = yield* Stream.toPull(
418 harness.provider.snapshot.streamChanges.pipe(
419 Stream.filter((snapshot) => snapshot.models.length === 3),
420 ),
421 );
422 yield* harness.provider.onConfigOptionsUpdated(configOptions);
423 expect((yield* nextSnapshot)[0]).toMatchObject({
424 models: buildAntigravityModelsFromSession({ configOptions }),
425 auth: before.auth,
426 workspaceSnapshots: before.workspaceSnapshots,
427 slashCommands: expectedCommands,
428 });
429 yield* harness.provider.onConfigOptionsUpdated([]);
430 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
431 }),
432 ),
433 );
434​
435 it.effect("replaces one account's catalog instead of combining accounts", () =>
436 Effect.scoped(
437 Effect.gen(function* () {
438 const harness = yield* makeHarness();
439 yield* harness.initialize;
440 yield* harness.provider.onSessionStarted(started);
441 yield* harness.provider.onSignedOut;
442 yield* harness.provider.onSessionStarted({
443 ...started,
444 sessionSetupResult: {
445 sessionId: "new-account-session",
446 configOptions: [
447 { ...modelConfig, currentValue: "gemini-pro-agent", options: [modelOptions[9]!] },
448 ],
449 },
450 });
451 expect(
452 (yield* harness.provider.snapshot.getSnapshot).models.map((model) => model.slug),
453 ).toEqual(["gemini-pro-agent"]);
454 }),
455 ),
456 );
457​
458 it.effect("retains known account metadata when a local health check fails", () =>
459 Effect.scoped(
460 Effect.gen(function* () {
461 const harness = yield* makeHarness();
462 yield* harness.initialize;
463 yield* harness.provider.onSessionStarted(started, "/workspace");
464 yield* harness.provider.onAvailableCommands(commands, "/workspace");
465 yield* Ref.set(
466 harness.probe,
467 Effect.fail(EffectAcpErrors.AcpRequestError.internalError("probe failed")),
468 );
469 const snapshot = yield* harness.provider.snapshot.refresh;
470 expect(snapshot).toMatchObject({
471 installed: true,
472 status: "error",
473 auth: { status: "authenticated" },
474 });
475 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
476 expect(snapshot.slashCommands).toEqual(expectedCommands);
477 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace");
478 }),
479 ),
480 );
481​
482 it.effect("allows a slow packaged runtime health check to finish", () =>
483 Effect.scoped(
484 Effect.gen(function* () {
485 const harness = yield* makeHarness();
486 yield* harness.initialize;
487 const entered = yield* Deferred.make<void>();
488 const initialized = yield* Deferred.make<EffectAcpSchema.InitializeResponse>();
489 yield* Ref.set(
490 harness.probe,
491 Deferred.succeed(entered, undefined).pipe(Effect.andThen(Deferred.await(initialized))),
492 );
493​
494 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
495 yield* Deferred.await(entered);
496 yield* TestClock.adjust("47 seconds");
497 yield* Deferred.succeed(initialized, initializeResult);
498 const snapshot = yield* Fiber.join(refresh);
499​
500 expect(snapshot).toMatchObject({
501 installed: true,
502 status: "warning",
503 auth: { status: "unknown" },
504 });
505 }),
506 ),
507 );
508​
509 it.effect("closes a stalled health probe at its deadline", () =>
510 Effect.scoped(
511 Effect.gen(function* () {
512 const harness = yield* makeHarness();
513 yield* harness.initialize;
514 const entered = yield* Deferred.make<void>();
515 const closed = yield* Deferred.make<void>();
516 yield* Ref.set(
517 harness.probe,
518 Deferred.succeed(entered, undefined).pipe(
519 Effect.andThen(Effect.never),
520 Effect.ensuring(Deferred.succeed(closed, undefined)),
521 ),
522 );
523 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
524 yield* Deferred.await(entered);
525 yield* TestClock.adjust("90 seconds");
526 const snapshot = yield* Fiber.join(refresh);
527 yield* Deferred.await(closed);
528 expect(snapshot.status).toBe("error");
529 expect(snapshot.message).toContain("90 seconds");
530 }),
531 ),
532 );
533​
534 it.effect("distinguishes missing executables from a failed installed executable", () =>
535 Effect.scoped(
536 Effect.gen(function* () {
537 const harness = yield* makeHarness();
538 yield* harness.initialize;
539 const failures = [
540 {
541 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "ENOENT" } }),
542 installed: false,
543 },
544 {
545 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "EACCES" } }),
546 installed: true,
547 },
548 {
549 error: new ProviderSetupError({
550 instanceId,
551 operation: "resolve",
552 detail: "Antigravity is not installed.",
553 }),
554 installed: false,
555 },
556 ];
557 for (const { error, installed } of failures) {
558 yield* harness.provider.onSessionStarted(started, "/workspace");
559 yield* harness.provider.onAvailableCommands(commands, "/workspace");
560 yield* Ref.set(harness.probe, Effect.fail(error));
561 const snapshot = yield* harness.provider.snapshot.refresh;
562 expect(snapshot).toMatchObject({
563 installed,
564 status: "error",
565 auth: { status: "authenticated" },
566 });
567 expect(snapshot.models).toHaveLength(installed ? 11 : 0);
568 expect(snapshot.slashCommands).toHaveLength(installed ? 2 : 0);
569 expect(snapshot.workspaceSnapshots).toHaveLength(installed ? 1 : 0);
570 expect(snapshot.supportsTextGeneration).toBe(installed);
571 }
572 }),
573 ),
574 );
575​
576 it.effect("does not let an old health result restore a signed-out account", () =>
577 Effect.scoped(
578 Effect.gen(function* () {
579 const harness = yield* makeHarness();
580 yield* harness.initialize;
581 yield* harness.provider.onSessionStarted(started);
582 const releaseProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse>();
583 const probeEntered = yield* Deferred.make<void>();
584 yield* Ref.set(
585 harness.probe,
586 Deferred.succeed(probeEntered, undefined).pipe(
587 Effect.andThen(Deferred.await(releaseProbe)),
588 ),
589 );
590 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
591 yield* Deferred.await(probeEntered);
592 yield* harness.provider.onSignedOut;
593 yield* Deferred.succeed(releaseProbe, initializeResult);
594 const snapshot = yield* Fiber.join(refresh);
595 expect(snapshot).toMatchObject({
596 auth: { status: "unauthenticated" },
597 models: [],
598 supportsTextGeneration: false,
599 });
600 }),
601 ),
602 );
603​
604 it.effect("exposes helper support only when the supplied safety check allows it", () =>
605 Effect.scoped(
606 Effect.gen(function* () {
607 const harness = yield* makeHarness({ safe: false });
608 yield* harness.initialize;
609 yield* harness.provider.onSessionStarted(started);
610 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(false);
611 yield* Ref.set(harness.safety, Effect.succeed(true));
612 yield* harness.provider.snapshot.refresh;
613 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(true);
614 }),
615 ),
616 );
617​
618 it.effect("keeps discovered workspace skills through session and command updates", () =>
619 Effect.scoped(
620 Effect.gen(function* () {
621 const harness = yield* makeHarness();
622 yield* harness.initialize;
623 const skills = [
624 {
625 name: "deploy",
626 description: "Ship it",
627 path: "/workspace/.agent/skills/deploy",
628 enabled: true,
629 },
630 ];
631 const discovered = yield* harness.provider.snapshotForCwd("/workspace", skills);
632 expect(discovered.skills).toEqual(skills);
633 yield* harness.provider.onSessionStarted(started, "/workspace");
634 yield* harness.provider.onAvailableCommands(commands, "/workspace");
635 const after = yield* harness.provider.snapshot.getSnapshot;
636 expect(
637 after.workspaceSnapshots?.find((entry) => entry.cwd === "/workspace")?.skills,
638 ).toEqual(skills);
639 expect((yield* harness.provider.snapshotForCwd("/workspace")).skills).toEqual(skills);
640​
641 const rescanned = [
642 ...skills,
643 { name: "review", path: "/workspace/.agent/skills/review", enabled: true },
644 ];
645 yield* harness.provider.snapshotForCwd("/workspace", rescanned);
646 yield* harness.provider.onSessionStarted(started, "/workspace");
647 expect(
648 (yield* harness.provider.snapshot.getSnapshot).workspaceSnapshots?.find(
649 (entry) => entry.cwd === "/workspace",
650 )?.skills,
651 ).toEqual(rescanned);
652 }),
653 ),
654 );
655​
656 it.effect("bounds workspace metadata without starting sessions for workspace lookup", () =>
657 Effect.scoped(
658 Effect.gen(function* () {
659 const harness = yield* makeHarness();
660 yield* harness.initialize;
661 yield* harness.provider.onSessionStarted(started);
662 for (let index = 0; index < 35; index++) {
663 yield* harness.provider.onAvailableCommands(commands, `/workspace-${index}`);
664 }
665 const snapshot = yield* harness.provider.snapshotForCwd("/workspace-34");
666 expect(snapshot.workspaceSnapshots).toHaveLength(32);
667 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace-3");
668 expect(snapshot.slashCommands).toEqual(expectedCommands);
669 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
670 }),
671 ),
672 );
673});