summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-05-02 11:12:07 -0500
committerGitHub <[email protected]>2026-05-02 11:12:07 -0500
commitb460db15d7cb8613e7619f429f9b660506954639 (patch)
tree99e868324204f3576e15b3f1411ef64553386963 /packages
parentff4779ca11a0a2daa7541dcaa054d5c7c4a88d8b (diff)
downloadopencode-b460db15d7cb8613e7619f429f9b660506954639.tar.gz
opencode-b460db15d7cb8613e7619f429f9b660506954639.zip
tweak: allow read tool to accept offset of 0 (#25431)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/tool/read.ts8
1 files changed, 2 insertions, 6 deletions
diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts
index 78436489f..bf01fc7d2 100644
--- a/packages/opencode/src/tool/read.ts
+++ b/packages/opencode/src/tool/read.ts
@@ -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(