Skip to content
Closed
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions packages/opencode/src/tool/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { Format } from "../format"
import { FileTime } from "../file/time"
import { Filesystem } from "../util/filesystem"
import { Instance } from "../project/instance"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}
import { Snapshot } from "@/snapshot"
import { assertExternalDirectoryEffect } from "./external-directory"
import { AppFileSystem } from "../filesystem"
Expand Down Expand Up @@ -79,7 +83,7 @@ export const EditTool = Tool.define(
diff = trimDiff(createTwoFilesPatch(filePath, filePath, contentOld, contentNew))
yield* ctx.ask({
permission: "edit",
patterns: [path.relative(Instance.worktree, filePath)],
patterns: [toPosix(path.relative(Instance.worktree, filePath))],
always: ["*"],
metadata: {
filepath: filePath,
Expand Down Expand Up @@ -119,7 +123,7 @@ export const EditTool = Tool.define(
)
yield* ctx.ask({
permission: "edit",
patterns: [path.relative(Instance.worktree, filePath)],
patterns: [toPosix(path.relative(Instance.worktree, filePath))],
always: ["*"],
metadata: {
filepath: filePath,
Expand Down Expand Up @@ -179,7 +183,7 @@ export const EditTool = Tool.define(
diff,
filediff,
},
title: `${path.relative(Instance.worktree, filePath)}`,
title: toPosix(path.relative(Instance.worktree, filePath)),
output,
}
}),
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { Instance } from "../project/instance"
import { assertExternalDirectoryEffect } from "./external-directory"
import { AppFileSystem } from "../filesystem"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

export const GlobTool = Tool.define(
"glob",
Effect.gen(function* () {
Expand Down Expand Up @@ -81,7 +85,7 @@ export const GlobTool = Tool.define(
}

return {
title: path.relative(Instance.worktree, search),
title: toPosix(path.relative(Instance.worktree, search)),
metadata: {
count: files.length,
truncated,
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { Instance } from "../project/instance"
import { Ripgrep } from "../file/ripgrep"
import { assertExternalDirectoryEffect } from "./external-directory"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

export const IGNORE_PATTERNS = [
"node_modules/",
"__pycache__/",
Expand Down Expand Up @@ -121,7 +125,7 @@ export const ListTool = Tool.define(
const output = `${searchPath}/\n` + renderDir(".", 0)

return {
title: path.relative(Instance.worktree, searchPath),
title: toPosix(path.relative(Instance.worktree, searchPath)),
metadata: {
count: files.length,
truncated: files.length >= LIMIT,
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { pathToFileURL } from "url"
import { assertExternalDirectoryEffect } from "./external-directory"
import { AppFileSystem } from "../filesystem"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

const operations = [
"goToDefinition",
"findReferences",
Expand Down Expand Up @@ -46,7 +50,7 @@ export const LspTool = Tool.define(

const uri = pathToFileURL(file).href
const position = { file, line: args.line - 1, character: args.character - 1 }
const relPath = path.relative(Instance.worktree, file)
const relPath = toPosix(path.relative(Instance.worktree, file))
const title = `${args.operation} ${relPath}:${args.line}:${args.character}`

const exists = yield* fs.existsSafe(file)
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/multiedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import DESCRIPTION from "./multiedit.txt"
import path from "path"
import { Instance } from "../project/instance"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

export const MultiEditTool = Tool.define(
"multiedit",
Effect.gen(function* () {
Expand Down Expand Up @@ -49,7 +53,7 @@ export const MultiEditTool = Tool.define(
results.push(result)
}
return {
title: path.relative(Instance.worktree, params.filePath),
title: toPosix(path.relative(Instance.worktree, params.filePath)),
metadata: {
results: results.map((r) => r.metadata),
},
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { Instance } from "../project/instance"
import { type SessionID, MessageID, PartID } from "../session/schema"
import EXIT_DESCRIPTION from "./plan-exit.txt"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

function getLastModel(sessionID: SessionID) {
for (const item of MessageV2.stream(sessionID)) {
if (item.info.role === "user" && item.info.model) return item.info.model
Expand All @@ -30,7 +34,7 @@ export const PlanExitTool = Tool.define(
execute: (_params: {}, ctx: Tool.Context) =>
Effect.gen(function* () {
const info = yield* session.get(ctx.sessionID)
const plan = path.relative(Instance.worktree, Session.plan(info))
const plan = toPosix(path.relative(Instance.worktree, Session.plan(info)))
const answers = yield* question.ask({
sessionID: ctx.sessionID,
questions: [
Expand Down
6 changes: 5 additions & 1 deletion packages/opencode/src/tool/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { Instance } from "../project/instance"
import { assertExternalDirectoryEffect } from "./external-directory"
import { Instruction } from "../session/instruction"

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

const DEFAULT_READ_LIMIT = 2000
const MAX_LINE_LENGTH = 2000
const MAX_LINE_SUFFIX = `... (line truncated to ${MAX_LINE_LENGTH} chars)`
Expand Down Expand Up @@ -92,7 +96,7 @@ export const ReadTool = Tool.define(
if (process.platform === "win32") {
filepath = AppFileSystem.normalizePath(filepath)
}
const title = path.relative(Instance.worktree, filepath)
const title = toPosix(path.relative(Instance.worktree, filepath))

const stat = yield* fs.stat(filepath).pipe(
Effect.catchIf(
Expand Down
8 changes: 6 additions & 2 deletions packages/opencode/src/tool/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { assertExternalDirectoryEffect } from "./external-directory"

const MAX_PROJECT_DIAGNOSTICS_FILES = 5

function toPosix(p: string): string {
return p.replaceAll("\\", "/")
}

export const WriteTool = Tool.define(
"write",
Effect.gen(function* () {
Expand Down Expand Up @@ -46,7 +50,7 @@ export const WriteTool = Tool.define(
const diff = trimDiff(createTwoFilesPatch(filepath, filepath, contentOld, params.content))
yield* ctx.ask({
permission: "edit",
patterns: [path.relative(Instance.worktree, filepath)],
patterns: [toPosix(path.relative(Instance.worktree, filepath))],
always: ["*"],
metadata: {
filepath,
Expand Down Expand Up @@ -82,7 +86,7 @@ export const WriteTool = Tool.define(
}

return {
title: path.relative(Instance.worktree, filepath),
title: toPosix(path.relative(Instance.worktree, filepath)),
metadata: {
diagnostics,
filepath,
Expand Down
Loading