@@ -24,22 +24,17 @@ export const MAX_LINE_PREVIEW_LENGTH = 2_000
2424
2525export const ResultLimit = PositiveInt . check ( Schema . isLessThanOrEqualTo ( MAX_RESULT_LIMIT ) )
2626
27- const RootInput = {
28- path : Schema . String . pipe ( Schema . optional ) ,
29- reference : Schema . NonEmptyString . pipe ( Schema . optional ) ,
30- }
31-
3227export const FilesInput = Schema . Struct ( {
3328 pattern : Schema . String ,
34- ...RootInput ,
29+ ...FileSystem . ListInput . fields ,
3530 limit : ResultLimit . pipe ( Schema . optional ) ,
3631} )
3732export type FilesInput = typeof FilesInput . Type & { readonly signal ?: AbortSignal }
3833
3934export const GrepInput = Schema . Struct ( {
4035 pattern : Schema . String ,
4136 include : Schema . String . pipe ( Schema . optional ) ,
42- ...RootInput ,
37+ ...FileSystem . ListInput . fields ,
4338 limit : ResultLimit . pipe ( Schema . optional ) ,
4439} )
4540export type GrepInput = typeof GrepInput . Type & { readonly signal ?: AbortSignal }
@@ -82,11 +77,8 @@ export class GrepResult extends Schema.Class<GrepResult>("LocationSearch.GrepRes
8277} ) { }
8378
8479export interface Interface {
85- readonly files : ( input : FilesInput , root ?: FileSystem . RootTarget ) => Effect . Effect < FilesResult , Ripgrep . Error >
86- readonly grep : (
87- input : GrepInput ,
88- root ?: FileSystem . RootTarget ,
89- ) => Effect . Effect < GrepResult , Ripgrep . Error | Ripgrep . InvalidPatternError >
80+ readonly files : ( input : FilesInput ) => Effect . Effect < FilesResult , Ripgrep . Error >
81+ readonly grep : ( input : GrepInput ) => Effect . Effect < GrepResult , Ripgrep . Error | Ripgrep . InvalidPatternError >
9082}
9183
9284export class Service extends Context . Service < Service , Interface > ( ) ( "@opencode/v2/LocationSearch" ) { }
@@ -123,8 +115,8 @@ export const layer = Layer.effect(
123115 } )
124116
125117 return Service . of ( {
126- files : Effect . fn ( "LocationSearch.files" ) ( function * ( input , approvedRoot ) {
127- const root = yield * filesystem . revalidateRoot ( approvedRoot ?? ( yield * filesystem . resolveRoot ( input ) ) )
118+ files : Effect . fn ( "LocationSearch.files" ) ( function * ( input ) {
119+ const root = yield * filesystem . resolveRoot ( input )
128120 if ( root . type !== "directory" )
129121 return yield * Effect . die ( new globalThis . Error ( "Files search path must be a directory" ) )
130122 const result = yield * ripgrep . files ( {
@@ -145,8 +137,8 @@ export const layer = Layer.effect(
145137 partial : result . partial || items . length !== result . items . length ,
146138 } )
147139 } ) ,
148- grep : Effect . fn ( "LocationSearch.grep" ) ( function * ( input , approvedRoot ) {
149- const root = yield * filesystem . revalidateRoot ( approvedRoot ?? ( yield * filesystem . resolveRoot ( input ) ) )
140+ grep : Effect . fn ( "LocationSearch.grep" ) ( function * ( input ) {
141+ const root = yield * filesystem . resolveRoot ( input )
150142 const cwd = root . type === "directory" ? root . real : path . dirname ( root . real )
151143 const result = yield * ripgrep . grep ( {
152144 cwd,
0 commit comments