refactor(tool/read): yield InstanceState.context instead of reading ALS (#25183)

This commit is contained in:
Kit Langton 2026-04-30 20:33:04 -04:00 committed by GitHub
parent 451650b584
commit a499fe2b17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,7 @@ import * as Tool from "./tool"
import { AppFileSystem } from "@opencode-ai/core/filesystem"
import { LSP } from "@/lsp/lsp"
import DESCRIPTION from "./read.txt"
import { Instance } from "../project/instance"
import { InstanceState } from "@/effect/instance-state"
import { assertExternalDirectoryEffect } from "./external-directory"
import { Instruction } from "../session/instruction"
import { isImageAttachment, isPdfAttachment, sniffAttachmentMime } from "@/util/media"
@ -157,14 +157,15 @@ export const ReadTool = Tool.define(
return yield* Effect.fail(new Error("offset must be greater than or equal to 1"))
}
const instance = yield* InstanceState.context
let filepath = params.filePath
if (!path.isAbsolute(filepath)) {
filepath = path.resolve(Instance.directory, filepath)
filepath = path.resolve(instance.directory, filepath)
}
if (process.platform === "win32") {
filepath = AppFileSystem.normalizePath(filepath)
}
const title = path.relative(Instance.worktree, filepath)
const title = path.relative(instance.worktree, filepath)
const stat = yield* fs.stat(filepath).pipe(
Effect.catchIf(