11import * as NodeOS from "node:os" ;
22
33import * as NodeServices from "@effect/platform-node/NodeServices" ;
4+ import { it as effectIt } from "@effect/vitest" ;
45import type * as Crypto from "effect/Crypto" ;
56import * as Effect from "effect/Effect" ;
67import * as FileSystem from "effect/FileSystem" ;
78import * as Path from "effect/Path" ;
9+ import * as Stream from "effect/Stream" ;
810import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner" ;
911import { describe , expect , it } from "vite-plus/test" ;
1012import type * as EffectAcpSchema from "effect-acp/schema" ;
11- import type { CursorSettings } from "@t3tools/contracts" ;
13+ import { ProviderDriverKind , ProviderInstanceId , type CursorSettings } from "@t3tools/contracts" ;
1214import { createModelCapabilities } from "@t3tools/shared/model" ;
1315
1416import {
@@ -17,6 +19,7 @@ import {
1719 checkCursorProviderStatus ,
1820 discoverCursorModelsViaAcp ,
1921 makeCursorModelDiscovery ,
22+ makeCursorCommandCatalog ,
2023 getCursorParameterizedModelPickerUnsupportedMessage ,
2124 parseCursorAboutOutput ,
2225 parseCursorCliConfigChannel ,
@@ -475,6 +478,69 @@ describe("Cursor skills", () => {
475478 } ) ;
476479} ) ;
477480
481+ describe ( "Cursor command catalog" , ( ) => {
482+ effectIt . effect (
483+ "publishes workspace commands without leaking them globally and retains them across refreshes" ,
484+ ( ) =>
485+ Effect . gen ( function * ( ) {
486+ const base = {
487+ ...buildCursorProviderSnapshot ( {
488+ checkedAt : "2026-01-01T00:00:00.000Z" ,
489+ cursorSettings : baseCursorSettings ,
490+ parsed : { version : null , status : "ready" , auth : { status : "authenticated" } } ,
491+ } ) ,
492+ instanceId : ProviderInstanceId . make ( "cursor-catalog" ) ,
493+ driver : ProviderDriverKind . make ( "cursor" ) ,
494+ } ;
495+ const catalog = yield * makeCursorCommandCatalog ( {
496+ getSnapshot : Effect . succeed ( base ) ,
497+ refresh : Effect . succeed ( base ) ,
498+ streamChanges : Stream . empty ,
499+ resolveMaintenance : ( ) => Effect . die ( "Not used" ) ,
500+ applyUsageLimits : ( ) => Effect . void ,
501+ } ) ;
502+ const skills = [
503+ { name : "review" , path : "/one/.cursor/skills/review/SKILL.md" , enabled : true } ,
504+ ] ;
505+ yield * catalog . onAvailableCommands (
506+ [
507+ { name : "review" , description : "Review changes" , input : { hint : "target" } } ,
508+ { name : "compact" , description : "Native duplicate" } ,
509+ { name : "review" , description : "Duplicate" } ,
510+ ] ,
511+ "/one" ,
512+ skills ,
513+ ) ;
514+ yield * catalog . onAvailableCommands ( [ { name : "deploy" , description : "Deploy" } ] , "/two" , [ ] ) ;
515+ const published = yield * catalog . snapshot . streamChanges . pipe (
516+ Stream . take ( 1 ) ,
517+ Stream . runCollect ,
518+ ) ;
519+ expect ( published [ 0 ] ?. slashCommands . map ( ( command ) => command . name ) ) . toEqual ( [ "compact" ] ) ;
520+ const refreshed = yield * catalog . snapshot . refresh ;
521+ expect ( refreshed . workspaceSnapshots ?. find ( ( entry ) => entry . cwd === "/one" ) ) . toMatchObject ( {
522+ slashCommands : [
523+ { name : "compact" } ,
524+ { name : "review" , description : "Review changes" , input : { hint : "target" } } ,
525+ ] ,
526+ skills,
527+ } ) ;
528+ yield * catalog . onAvailableCommands ( [ ] , "/one" , skills ) ;
529+ const updated = yield * catalog . snapshot . getSnapshot ;
530+ expect (
531+ updated . workspaceSnapshots
532+ ?. find ( ( entry ) => entry . cwd === "/one" )
533+ ?. slashCommands . map ( ( command ) => command . name ) ,
534+ ) . toEqual ( [ "compact" ] ) ;
535+ expect (
536+ updated . workspaceSnapshots
537+ ?. find ( ( entry ) => entry . cwd === "/two" )
538+ ?. slashCommands . map ( ( command ) => command . name ) ,
539+ ) . toEqual ( [ "compact" , "deploy" ] ) ;
540+ } ) ,
541+ ) ;
542+ } ) ;
543+
478544describe ( "buildCursorProviderSnapshot" , ( ) => {
479545 it ( "downgrades ready status to warning when ACP model discovery times out" , ( ) => {
480546 expect (
0 commit comments