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
22 changes: 21 additions & 1 deletion packages/app/public/site.webmanifest
18 changes: 17 additions & 1 deletion packages/app/src/custom-elements.d.ts
18 changes: 17 additions & 1 deletion packages/enterprise/src/custom-elements.d.ts
22 changes: 21 additions & 1 deletion packages/opencode/src/pty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { WSContext } from "hono/ws"
import { Instance } from "../project/instance"
import { lazy } from "@opencode-ai/util/lazy"
import { Shell } from "@/shell/shell"
import path from "path"

export namespace Pty {
const log = Log.create({ service: "pty" })
Expand Down Expand Up @@ -96,10 +97,23 @@ export namespace Pty {
export async function create(input: CreateInput) {
const id = Identifier.create("pty", false)
const command = input.command || Shell.preferred()
const args = input.args || []
let args = input.args || []
if (command.endsWith("sh")) {
args.push("-l")
}
if (process.platform === "win32" && args.length === 0) {
const base = path.win32.basename(command).toLowerCase()
if (base === "cmd.exe" || base === "cmd") {
args = ["/k", "chcp 65001>nul"]
} else if (base === "powershell.exe" || base === "pwsh.exe") {
args = [
"-NoLogo",
"-NoExit",
"-Command",
"[Console]::OutputEncoding=[Text.UTF8Encoding]::UTF8; [Console]::InputEncoding=[Text.UTF8Encoding]::UTF8",
]
}
}

const cwd = input.cwd || Instance.directory
const env = {
Expand All @@ -108,6 +122,12 @@ export namespace Pty {
TERM: "xterm-256color",
OPENCODE_TERMINAL: "1",
} as Record<string, string>
if (process.platform === "win32") {
env.LANG = env.LANG || "en_US.UTF-8"
env.LC_ALL = env.LC_ALL || "en_US.UTF-8"
env.PYTHONUTF8 = env.PYTHONUTF8 || "1"
env.PYTHONIOENCODING = env.PYTHONIOENCODING || "utf-8"
}
log.info("creating session", { id, cmd: command, args, cwd })

const spawn = await pty()
Expand Down