mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-20 19:06:22 +00:00
fix: use dynamic imports for tree-sitter and shell-aware metadata tags
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Language, Parser, type Node } from "web-tree-sitter"
|
||||
import type { Node } from "web-tree-sitter"
|
||||
import { lazy } from "@/util/lazy"
|
||||
import { resolveWasm, resolvePath, unquote, home, expand, type Scan, type Part } from "./util"
|
||||
import { Instance } from "@/project/instance"
|
||||
@@ -141,6 +141,7 @@ export namespace ShellParser {
|
||||
const { default: psWasm } = await import("tree-sitter-powershell/tree-sitter-powershell.wasm" as string, {
|
||||
with: { type: "wasm" },
|
||||
})
|
||||
const { Language } = await import("web-tree-sitter")
|
||||
const bashPath = resolveWasm(bashWasm)
|
||||
const psPath = resolveWasm(psWasm)
|
||||
const bashLanguage = await Language.load(bashPath)
|
||||
|
||||
@@ -121,10 +121,10 @@ export namespace ShellRunner {
|
||||
})
|
||||
|
||||
const metadata: string[] = []
|
||||
if (expired) metadata.push(`bash tool terminated command after exceeding timeout ${input.timeout} ms`)
|
||||
if (expired) metadata.push(`${input.name} tool terminated command after exceeding timeout ${input.timeout} ms`)
|
||||
if (aborted) metadata.push("User aborted the command")
|
||||
if (metadata.length > 0) {
|
||||
output += "\n\n<bash_metadata>\n" + metadata.join("\n") + "\n</bash_metadata>"
|
||||
output += "\n\n<shell_metadata>\n" + metadata.join("\n") + "\n</shell_metadata>"
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user