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

AntigravityProvider.test.ts

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