ソースを参照

fix formatting of bash tools

Dax Raad 7 ヶ月 前
コミット
03664ba588

+ 2 - 0
packages/opencode/src/tool/bash.ts

@@ -1,6 +1,7 @@
 import { z } from "zod"
 import { Tool } from "./tool"
 import DESCRIPTION from "./bash.txt"
+import { App } from "../app/app"
 
 const MAX_OUTPUT_LENGTH = 30000
 const BANNED_COMMANDS = [
@@ -49,6 +50,7 @@ export const BashTool = Tool.define({
 
     const process = Bun.spawn({
       cmd: ["bash", "-c", params.command],
+      cwd: App.info().path.cwd,
       maxBuffer: MAX_OUTPUT_LENGTH,
       signal: ctx.abort,
       timeout: timeout,

+ 3 - 4
packages/tui/internal/components/chat/message.go

@@ -359,11 +359,10 @@ func renderToolDetails(
 			}
 		}
 	case "bash":
-		stdout := metadata.JSON.ExtraFields["stdout"]
-		if !stdout.IsNull() {
+		stdout := metadata.ExtraFields["stdout"]
+		if stdout != nil {
 			command := toolArgsMap["command"].(string)
-			stdout := stdout.Raw()
-			body = fmt.Sprintf("```console\n> %s\n%s```", command, stdout)
+			body = fmt.Sprintf("```console\n> %s\n%s\n```", command, stdout)
 			body = toMarkdown(body, width, t.BackgroundPanel())
 		}
 	case "webfetch":