@@ -31,6 +31,7 @@ import {
3131 checkCursorProviderStatus ,
3232 makeCursorModelDiscovery ,
3333 enrichCursorSnapshot ,
34+ makeCursorCommandCatalog ,
3435} from "../Layers/CursorProvider.ts" ;
3536import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts" ;
3637import { makeManagedServerProvider } from "../makeManagedServerProvider.ts" ;
@@ -53,7 +54,7 @@ import {
5354 makeProviderSnapshotSettingsSource ,
5455 type ProviderSnapshotSettings ,
5556} from "../providerUpdateSettings.ts" ;
56- import { probeCursorSkills } from "./CursorSkills.ts" ;
57+ import { discoverCursorSkills , probeCursorSkills } from "./CursorSkills.ts" ;
5758const decodeCursorSettings = Schema . decodeSync ( CursorSettings ) ;
5859
5960const DRIVER_KIND = ProviderDriverKind . make ( "cursor" ) ;
@@ -130,11 +131,6 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
130131 ) ,
131132 ) ;
132133
133- const adapter = yield * makeCursorAdapter ( effectiveConfig , {
134- environment : processEnv ,
135- ...( eventLoggers . native ? { nativeEventLogger : eventLoggers . native } : { } ) ,
136- instanceId,
137- } ) ;
138134 const textGeneration = yield * makeCursorTextGeneration ( effectiveConfig , processEnv ) ;
139135
140136 const discoverModels = yield * makeCursorModelDiscovery ( effectiveConfig , processEnv ) ;
@@ -151,7 +147,9 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
151147 ) ;
152148
153149 const snapshotSettings = makeProviderSnapshotSettingsSource ( effectiveConfig , serverSettings ) ;
154- const snapshot = yield * makeManagedServerProvider < ProviderSnapshotSettings < CursorSettings > > ( {
150+ const managedSnapshot = yield * makeManagedServerProvider <
151+ ProviderSnapshotSettings < CursorSettings >
152+ > ( {
155153 resolveMaintenance,
156154 getSettings : snapshotSettings . getSettings ,
157155 streamSettings : snapshotSettings . streamSettings ,
@@ -188,6 +186,20 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
188186 ) ,
189187 ) ;
190188
189+ const { snapshot, onAvailableCommands, snapshotForCwd } =
190+ yield * makeCursorCommandCatalog ( managedSnapshot ) ;
191+ const adapter = yield * makeCursorAdapter ( effectiveConfig , {
192+ environment : processEnv ,
193+ ...( eventLoggers . native ? { nativeEventLogger : eventLoggers . native } : { } ) ,
194+ instanceId,
195+ onAvailableCommands : ( commands , cwd ) =>
196+ discoverCursorSkills ( cwd , processEnv ) . pipe (
197+ Effect . provideService ( FileSystem . FileSystem , fileSystem ) ,
198+ Effect . provideService ( Path . Path , path ) ,
199+ Effect . flatMap ( ( skills ) => onAvailableCommands ( commands , cwd , skills ) ) ,
200+ ) ,
201+ } ) ;
202+
191203 return {
192204 instanceId,
193205 driverKind : DRIVER_KIND ,
@@ -199,22 +211,20 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
199211 snapshotForCwd : ( cwd ) =>
200212 ! effectiveConfig . enabled
201213 ? snapshot . getSnapshot
202- : Effect . all ( [
203- snapshot . getSnapshot ,
204- probeCursorSkills ( cwd , processEnv ) . pipe (
205- Effect . provideService ( FileSystem . FileSystem , fileSystem ) ,
206- Effect . provideService ( Path . Path , path ) ,
207- Effect . mapError (
208- ( cause ) =>
209- new ProviderDriverError ( {
210- driver : DRIVER_KIND ,
211- instanceId,
212- detail : `Failed to discover Cursor skills for '${ cwd } '` ,
213- cause,
214- } ) ,
215- ) ,
214+ : probeCursorSkills ( cwd , processEnv ) . pipe (
215+ Effect . provideService ( FileSystem . FileSystem , fileSystem ) ,
216+ Effect . provideService ( Path . Path , path ) ,
217+ Effect . mapError (
218+ ( cause ) =>
219+ new ProviderDriverError ( {
220+ driver : DRIVER_KIND ,
221+ instanceId,
222+ detail : `Failed to discover Cursor skills for '${ cwd } '` ,
223+ cause,
224+ } ) ,
216225 ) ,
217- ] ) . pipe ( Effect . map ( ( [ machineSnapshot , skills ] ) => ( { ...machineSnapshot , skills } ) ) ) ,
226+ Effect . flatMap ( ( skills ) => snapshotForCwd ( cwd , skills ) ) ,
227+ ) ,
218228 adapter,
219229 textGeneration,
220230 } satisfies ProviderInstance ;
0 commit comments