@@ -1737,6 +1737,97 @@ it.layer(
17371737 } ) ,
17381738 ) ;
17391739
1740+ it . effect ( "scans scanCwd and keys the workspace snapshot by cwd" , ( ) =>
1741+ Effect . gen ( function * ( ) {
1742+ const driver = ProviderDriverKind . make ( "codex" ) ;
1743+ const instanceId = ProviderInstanceId . make ( "codex" ) ;
1744+ const provider = {
1745+ instanceId,
1746+ driver,
1747+ status : "ready" ,
1748+ enabled : true ,
1749+ installed : true ,
1750+ auth : { status : "authenticated" } ,
1751+ checkedAt : "2026-06-10T00:00:00.000Z" ,
1752+ version : "1.0.0" ,
1753+ models : [ ] ,
1754+ slashCommands : [ ] ,
1755+ skills : [ ] ,
1756+ } as const satisfies ServerProvider ;
1757+ const scannedDirectories = yield * Ref . make < ReadonlyArray < string > > ( [ ] ) ;
1758+ const instance : ProviderInstance = {
1759+ instanceId,
1760+ driverKind : driver ,
1761+ continuationIdentity : { driverKind : driver , continuationKey : "codex:instance:codex" } ,
1762+ displayName : undefined ,
1763+ enabled : true ,
1764+ snapshot : {
1765+ resolveMaintenance : ( ) =>
1766+ Effect . succeed (
1767+ makeManualOnlyProviderMaintenanceCapabilities ( {
1768+ provider : driver ,
1769+ packageName : null ,
1770+ } ) ,
1771+ ) ,
1772+ getSnapshot : Effect . succeed ( provider ) ,
1773+ refresh : Effect . succeed ( provider ) ,
1774+ streamChanges : Stream . empty ,
1775+ applyUsageLimits : ( ) => Effect . void ,
1776+ } ,
1777+ snapshotForCwd : ( directory ) =>
1778+ Ref . update ( scannedDirectories , ( directories ) => [ ...directories , directory ] ) . pipe (
1779+ Effect . as ( {
1780+ ...provider ,
1781+ skills : [ { name : "finalize" , path : `${ directory } /finalize` , enabled : true } ] ,
1782+ } ) ,
1783+ ) ,
1784+ orchestrationAdapter : { } as ProviderInstance [ "orchestrationAdapter" ] ,
1785+ textGeneration : { } as ProviderInstance [ "textGeneration" ] ,
1786+ } ;
1787+ const layerInstanceRegistry = Layer . succeed (
1788+ ProviderInstanceRegistry . ProviderInstanceRegistry ,
1789+ {
1790+ getInstance : ( requestedId ) =>
1791+ Effect . succeed ( requestedId === instanceId ? instance : undefined ) ,
1792+ listInstances : Effect . succeed ( [ instance ] ) ,
1793+ listUnavailable : Effect . succeed ( [ ] ) ,
1794+ streamChanges : Stream . empty ,
1795+ subscribeChanges : Effect . flatMap ( PubSub . unbounded < void > ( ) , PubSub . subscribe ) ,
1796+ } ,
1797+ ) ;
1798+ const scope = yield * Scope . make ( ) ;
1799+ yield * Effect . addFinalizer ( ( ) => Scope . close ( scope , Exit . void ) ) ;
1800+ const runtimeServices = yield * Layer . build (
1801+ ProviderRegistry . layer . pipe (
1802+ Layer . provide ( layerUnusedMutator ) ,
1803+ Layer . provideMerge ( layerInstanceRegistry ) ,
1804+ Layer . provideMerge (
1805+ ServerConfig . layerTest ( process . cwd ( ) , {
1806+ prefix : "t3-provider-registry-scan-cwd-" ,
1807+ } ) ,
1808+ ) ,
1809+ Layer . provideMerge ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ,
1810+ ) ,
1811+ ) . pipe ( Scope . provide ( scope ) ) ;
1812+
1813+ yield * Effect . gen ( function * ( ) {
1814+ const registry = yield * ProviderRegistry . ProviderRegistry ;
1815+ const providers = yield * registry . refreshWorkspaceSnapshot ( {
1816+ instanceId,
1817+ cwd : "/worktree" ,
1818+ scanCwd : "/project" ,
1819+ } ) ;
1820+ assert . deepStrictEqual ( yield * Ref . get ( scannedDirectories ) , [ "/project" ] ) ;
1821+ assert . deepStrictEqual (
1822+ providers [ 0 ] ?. workspaceSnapshots
1823+ ?. find ( ( snapshot ) => snapshot . cwd === "/worktree" )
1824+ ?. skills ?. map ( ( skill ) => skill . path ) ,
1825+ [ "/project/finalize" ] ,
1826+ ) ;
1827+ } ) . pipe ( Effect . provide ( runtimeServices ) ) ;
1828+ } ) ,
1829+ ) ;
1830+
17401831 it . effect ( "publishes workspace skills while machine health is in error" , ( ) =>
17411832 Effect . gen ( function * ( ) {
17421833 const driver = ProviderDriverKind . make ( "codex" ) ;
0 commit comments