refactor(core): consolidate references (#31539)
This commit is contained in:
@@ -6,7 +6,6 @@ import { Search } from "@opencode-ai/core/filesystem/search"
|
||||
import { assertExternalDirectoryEffect } from "./external-directory"
|
||||
import DESCRIPTION from "./grep.txt"
|
||||
import * as Tool from "./tool"
|
||||
import { Reference } from "@/reference/reference"
|
||||
|
||||
const MAX_LINE_LENGTH = 2000
|
||||
|
||||
@@ -25,7 +24,6 @@ export const GrepTool = Tool.define(
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FSUtil.Service
|
||||
const searchSvc = yield* Search.Service
|
||||
const reference = yield* Reference.Service
|
||||
|
||||
return {
|
||||
description: DESCRIPTION,
|
||||
@@ -56,10 +54,9 @@ export const GrepTool = Tool.define(
|
||||
const requested = path.isAbsolute(params.path ?? ins.directory)
|
||||
? (params.path ?? ins.directory)
|
||||
: path.join(ins.directory, params.path ?? ".")
|
||||
yield* reference.ensure(requested)
|
||||
const requestedInfo = yield* fs.stat(requested).pipe(Effect.catch(() => Effect.succeed(undefined)))
|
||||
yield* assertExternalDirectoryEffect(ctx, requested, {
|
||||
bypass: yield* reference.contains(requested),
|
||||
bypass: false,
|
||||
kind: requestedInfo?.type === "Directory" ? "directory" : "file",
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user