From ef680b8e10acbfe3a97157797d8dd6b234d331d7 Mon Sep 17 00:00:00 2001 From: SpencerJung Date: Tue, 26 May 2026 18:42:28 +0900 Subject: [PATCH 1/2] fix(snapshot): use worktree root as cwd for git operations --- packages/opencode/src/snapshot/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index f974a457ad7b..ee91a7b49995 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -122,7 +122,7 @@ export const layer: Layer.Layer Date: Tue, 26 May 2026 19:14:01 +0900 Subject: [PATCH 2/2] fix(shell): use byte length for preview truncation --- packages/opencode/src/tool/shell.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/tool/shell.ts b/packages/opencode/src/tool/shell.ts index b6a95b5c0970..2cf664ba1104 100644 --- a/packages/opencode/src/tool/shell.ts +++ b/packages/opencode/src/tool/shell.ts @@ -221,8 +221,12 @@ function pathArgs(list: Part[], ps: boolean, cmd = false) { } function preview(text: string) { - if (text.length <= MAX_METADATA_LENGTH) return text - return "...\n\n" + text.slice(-MAX_METADATA_LENGTH) + if (Buffer.byteLength(text, "utf-8") <= MAX_METADATA_LENGTH) return text + const buf = Buffer.from(text, "utf-8") + let start = buf.length - MAX_METADATA_LENGTH + if (start < 0) start = 0 + while (start < buf.length && (buf[start] & 0xc0) === 0x80) start++ + return "...\n\n" + buf.subarray(start).toString("utf-8") } function tail(text: string, maxLines: number, maxBytes: number) {