@@ -271,7 +271,7 @@ export const universalGrepCommand: AgentCliEngine = {
271271 const pattern = positionals [ 0 ]
272272 if ( ! pattern ) {
273273 return agentCliFail (
274- 'Usage: sim grep <pattern> [--scope workflows,blocks,...] [--in <id|name>] [-i] [-C n] [--count] [--limit n]'
274+ 'Usage: sim grep <pattern> [--scope workflows,blocks,...] [--in <world| id|name|world/id >] [-i] [-C n] [--count] [--limit n]'
275275 )
276276 }
277277 const scopes = parseScopes ( flags )
@@ -282,12 +282,15 @@ export const universalGrepCommand: AgentCliEngine = {
282282 if ( typeof context === 'string' ) return agentCliFail ( context )
283283 const ignoreCase = flags . i === true
284284 const countOnly = flags . count === true
285- const within = typeof flags . in === 'string' ? flags . in . toLowerCase ( ) : undefined
286285 // `--in tables` reads as "search the tables world", so a world name narrows the scope;
287- // anything else is a resource id or name inside the searched worlds.
288- const withinScope = SCOPES . find ( ( scope ) => scope === within )
286+ // `--in blocks/table_v2` is the path a match line prints (world, then resource); a bare
287+ // value is a resource id or name inside the searched worlds.
288+ const within = typeof flags . in === 'string' ? flags . in . toLowerCase ( ) : undefined
289+ const [ withinHead , ...withinRest ] = within ? within . split ( '/' ) : [ ]
290+ const withinScope = SCOPES . find ( ( scope ) => scope === withinHead )
291+ const withinResource = withinScope ? withinRest . join ( '/' ) : within
289292 const searched : Scope [ ] = withinScope ? [ withinScope ] : scopes
290- const nameFilter = withinScope ? undefined : within
293+ const nameFilter = withinResource || undefined
291294 const matches = compilePattern ( pattern , ignoreCase )
292295
293296 const materialized = (
0 commit comments