mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-06 08:21:50 +00:00
tweak: allow read tool to accept offset of 0 (#25431)
This commit is contained in:
parent
ff4779ca11
commit
b460db15d7
1 changed files with 2 additions and 6 deletions
|
|
@ -154,10 +154,6 @@ export const ReadTool = Tool.define(
|
|||
params: Schema.Schema.Type<typeof Parameters>,
|
||||
ctx: Tool.Context,
|
||||
) {
|
||||
if (params.offset !== undefined && params.offset < 1) {
|
||||
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)) {
|
||||
|
|
@ -192,7 +188,7 @@ export const ReadTool = Tool.define(
|
|||
if (stat.type === "Directory") {
|
||||
const items = yield* list(filepath)
|
||||
const limit = params.limit ?? DEFAULT_READ_LIMIT
|
||||
const offset = params.offset ?? 1
|
||||
const offset = params.offset || 1
|
||||
const start = offset - 1
|
||||
const sliced = items.slice(start, start + limit)
|
||||
const truncated = start + sliced.length < items.length
|
||||
|
|
@ -249,7 +245,7 @@ export const ReadTool = Tool.define(
|
|||
}
|
||||
|
||||
const file = yield* Effect.promise(() =>
|
||||
lines(filepath, { limit: params.limit ?? DEFAULT_READ_LIMIT, offset: params.offset ?? 1 }),
|
||||
lines(filepath, { limit: params.limit ?? DEFAULT_READ_LIMIT, offset: params.offset || 1 }),
|
||||
)
|
||||
if (file.count < file.offset && !(file.count === 0 && file.offset === 1)) {
|
||||
return yield* Effect.fail(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue