From 6ae6f0fe8f16e5754a48838799c18b66aaac1d90 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Wed, 10 Jun 2026 00:39:58 +0000 Subject: [PATCH] chore: generate --- packages/core/src/ripgrep.ts | 4 +- packages/core/src/ripgrep/binary.ts | 10 +++- packages/core/src/tool/glob.ts | 34 +++++++------ packages/core/src/tool/grep.ts | 53 +++++++++++--------- packages/core/test/filesystem/search.test.ts | 1 - packages/core/test/ripgrep.test.ts | 8 +-- packages/opencode/src/cli/cmd/debug/file.ts | 12 +---- packages/sdk/js/src/v2/gen/types.gen.ts | 1 - packages/sdk/openapi.json | 5 +- 9 files changed, 61 insertions(+), 67 deletions(-) diff --git a/packages/core/src/ripgrep.ts b/packages/core/src/ripgrep.ts index 19d27a63f..c3d13f4e2 100644 --- a/packages/core/src/ripgrep.ts +++ b/packages/core/src/ripgrep.ts @@ -279,6 +279,4 @@ export const layer = Layer.effect( }), ) -export const defaultLayer = layer.pipe( - Layer.provide(Layer.merge(RipgrepBinary.defaultLayer, AppProcess.defaultLayer)), -) +export const defaultLayer = layer.pipe(Layer.provide(Layer.merge(RipgrepBinary.defaultLayer, AppProcess.defaultLayer))) diff --git a/packages/core/src/ripgrep/binary.ts b/packages/core/src/ripgrep/binary.ts index dbe31bff6..013e9fc91 100644 --- a/packages/core/src/ripgrep/binary.ts +++ b/packages/core/src/ripgrep/binary.ts @@ -61,12 +61,18 @@ export namespace RipgrepBinary { "-Command", `$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${archive.replaceAll("'", "''")}' -DestinationPath '${dir.replaceAll("'", "''")}' -Force`, ]) - if (result.code !== 0) throw new Error(result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`) + if (result.code !== 0) + throw new Error( + result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`, + ) } if (config.extension === "tar.gz") { const result = yield* run("tar", ["-xzf", archive, "-C", dir]) - if (result.code !== 0) throw new Error(result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`) + if (result.code !== 0) + throw new Error( + result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`, + ) } const extracted = path.join( diff --git a/packages/core/src/tool/glob.ts b/packages/core/src/tool/glob.ts index 88054d46c..af0838b9a 100644 --- a/packages/core/src/tool/glob.ts +++ b/packages/core/src/tool/glob.ts @@ -50,7 +50,9 @@ export const layer = Layer.effectDiscard( toModelOutput: ({ output }) => [ { type: "text", - text: toModelOutput(output.map((entry) => ({ ...entry, path: path.resolve(location.directory, entry.path) }))), + text: toModelOutput( + output.map((entry) => ({ ...entry, path: path.resolve(location.directory, entry.path) })), + ), }, ], execute: (input, context) => @@ -69,21 +71,23 @@ export const layer = Layer.effectDiscard( source: { type: "tool", messageID: context.assistantMessageID, callID: context.toolCallID }, }) const cwd = path.resolve(location.directory, input.path ?? ".") - return yield* ripgrep.glob({ - cwd, - pattern: input.pattern, - limit: input.limit ?? Number.MAX_SAFE_INTEGER, - }).pipe( - Effect.map((result) => - result.map( - (entry) => - new FileSystem.Entry({ - ...entry, - path: RelativePath.make(path.relative(location.directory, path.resolve(cwd, entry.path))), - }), + return yield* ripgrep + .glob({ + cwd, + pattern: input.pattern, + limit: input.limit ?? Number.MAX_SAFE_INTEGER, + }) + .pipe( + Effect.map((result) => + result.map( + (entry) => + new FileSystem.Entry({ + ...entry, + path: RelativePath.make(path.relative(location.directory, path.resolve(cwd, entry.path))), + }), + ), ), - ), - ) + ) }).pipe( Effect.mapError(() => new ToolFailure({ message: `Unable to find files matching ${input.pattern}` })), ), diff --git a/packages/core/src/tool/grep.ts b/packages/core/src/tool/grep.ts index 5a8aacca6..dd8df8725 100644 --- a/packages/core/src/tool/grep.ts +++ b/packages/core/src/tool/grep.ts @@ -92,34 +92,37 @@ export const layer = Layer.effectDiscard( }) const target = path.resolve(location.directory, input.path ?? ".") const info = yield* fs.stat(target).pipe(Effect.catch(() => Effect.succeed(undefined))) - return yield* ripgrep.grep({ - cwd: info?.type === "Directory" ? target : path.dirname(target), - pattern: input.pattern, - file: info?.type === "File" ? path.basename(target) : undefined, - include: input.include, - limit: input.limit ?? Number.MAX_SAFE_INTEGER, - }).pipe( - Effect.map((result) => - result.map( - (match) => - new FileSystem.Match({ - ...match, - entry: new FileSystem.Entry({ - ...match.entry, - path: RelativePath.make( - path.relative( - location.directory, - path.resolve(info?.type === "Directory" ? target : path.dirname(target), match.entry.path), + return yield* ripgrep + .grep({ + cwd: info?.type === "Directory" ? target : path.dirname(target), + pattern: input.pattern, + file: info?.type === "File" ? path.basename(target) : undefined, + include: input.include, + limit: input.limit ?? Number.MAX_SAFE_INTEGER, + }) + .pipe( + Effect.map((result) => + result.map( + (match) => + new FileSystem.Match({ + ...match, + entry: new FileSystem.Entry({ + ...match.entry, + path: RelativePath.make( + path.relative( + location.directory, + path.resolve( + info?.type === "Directory" ? target : path.dirname(target), + match.entry.path, + ), + ), ), - ), + }), }), - }), + ), ), - ), - ) - }).pipe( - Effect.mapError(() => new ToolFailure({ message: `Unable to grep for ${input.pattern}` })), - ), + ) + }).pipe(Effect.mapError(() => new ToolFailure({ message: `Unable to grep for ${input.pattern}` }))), }), }) .pipe(Effect.orDie) diff --git a/packages/core/test/filesystem/search.test.ts b/packages/core/test/filesystem/search.test.ts index ff2dfa6f3..cdc8344de 100644 --- a/packages/core/test/filesystem/search.test.ts +++ b/packages/core/test/filesystem/search.test.ts @@ -40,5 +40,4 @@ describe("Ripgrep", () => { }), ), ) - }) diff --git a/packages/core/test/ripgrep.test.ts b/packages/core/test/ripgrep.test.ts index 011b9d1a5..d0b4fe33f 100644 --- a/packages/core/test/ripgrep.test.ts +++ b/packages/core/test/ripgrep.test.ts @@ -26,12 +26,8 @@ describe("Ripgrep", () => { expect(files.map((item) => item.path)).toContain(RelativePath.make(".git/config")) const matches = yield* ripgrep.grep({ cwd: tmp.path, pattern: "needle", include: "config", limit: 10 }) - expect(matches.map((item) => item.entry.path)).toContain( - RelativePath.make(".opencode/config"), - ) - expect(matches.map((item) => item.entry.path)).toContain( - RelativePath.make(".git/config"), - ) + expect(matches.map((item) => item.entry.path)).toContain(RelativePath.make(".opencode/config")) + expect(matches.map((item) => item.entry.path)).toContain(RelativePath.make(".git/config")) }), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), ), diff --git a/packages/opencode/src/cli/cmd/debug/file.ts b/packages/opencode/src/cli/cmd/debug/file.ts index 770853e8b..5ad31985d 100644 --- a/packages/opencode/src/cli/cmd/debug/file.ts +++ b/packages/opencode/src/cli/cmd/debug/file.ts @@ -22,11 +22,7 @@ const FileSearchCommand = effectCmd({ description: "Search query", }), handler: Effect.fn("Cli.debug.file.search")(function* (args) { - const results = yield* Effect.orDie( - filesystem( - FileSystem.Service.use((svc) => svc.find({ query: args.query })), - ), - ) + const results = yield* Effect.orDie(filesystem(FileSystem.Service.use((svc) => svc.find({ query: args.query })))) process.stdout.write(results.map((item) => item.path).join(EOL) + EOL) }), }) @@ -65,10 +61,6 @@ export const FileCommand = cmd({ command: "file", describe: "file system debugging utilities", builder: (yargs) => - yargs - .command(FileReadCommand) - .command(FileListCommand) - .command(FileSearchCommand) - .demandCommand(), + yargs.command(FileReadCommand).command(FileListCommand).command(FileSearchCommand).demandCommand(), async handler() {}, }) diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index 2dce3f6f5..2b4677e40 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -4129,7 +4129,6 @@ export type FileSystemContent = { export type FileSystemEntry = { path: string - uri: string type: "file" | "directory" mime: string } diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json index 32479cf82..162e7d495 100644 --- a/packages/sdk/openapi.json +++ b/packages/sdk/openapi.json @@ -25071,9 +25071,6 @@ "path": { "type": "string" }, - "uri": { - "type": "string" - }, "type": { "type": "string", "enum": ["file", "directory"] @@ -25082,7 +25079,7 @@ "type": "string" } }, - "required": ["path", "uri", "type", "mime"], + "required": ["path", "type", "mime"], "additionalProperties": false }, "CommandV2Info": {