mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-15 10:00:28 +00:00
fix: use dynamic imports for tree-sitter and shell-aware metadata tags
This commit is contained in:
parent
048ac63abd
commit
67dfbcbcfd
2 changed files with 4 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue