fix: use dynamic imports for tree-sitter and shell-aware metadata tags

This commit is contained in:
LukeParkerDev 2026-03-30 20:12:36 +10:00
parent 048ac63abd
commit 67dfbcbcfd
2 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

@ -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 {