Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/opencode/src/tool/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,17 @@ export const ShellTool = Tool.define(
const plugin = yield* Plugin.Service

const cygpath = Effect.fn("ShellTool.cygpath")(function* (shell: string, text: string) {
const lines = yield* spawner
.lines(ChildProcess.make(shell, ["-lc", 'cygpath -w -- "$1"', "_", text]))
.pipe(Effect.catch(() => Effect.succeed([] as string[])))
const file = lines[0]?.trim()
const file = yield* Effect.scoped(
Effect.gen(function* () {
const handle = yield* spawner.spawn(ChildProcess.make(shell, ["-lc", 'cygpath -w -- "$1"', "_", text]))
const [exitCode, stdout] = yield* Effect.all([
handle.exitCode,
Stream.runFold(Stream.decodeText(handle.stdout), () => "", (acc, chunk) => acc + chunk),
])
if (exitCode !== 0) return
return stdout.split("\n")[0]?.trim()
}),
).pipe(Effect.catch(() => Effect.succeed(undefined)))
if (!file) return
return AppFileSystem.normalizePath(file)
})
Expand Down
Loading