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 { lazy } from "@/util/lazy"
|
||||||
import { resolveWasm, resolvePath, unquote, home, expand, type Scan, type Part } from "./util"
|
import { resolveWasm, resolvePath, unquote, home, expand, type Scan, type Part } from "./util"
|
||||||
import { Instance } from "@/project/instance"
|
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, {
|
const { default: psWasm } = await import("tree-sitter-powershell/tree-sitter-powershell.wasm" as string, {
|
||||||
with: { type: "wasm" },
|
with: { type: "wasm" },
|
||||||
})
|
})
|
||||||
|
const { Language } = await import("web-tree-sitter")
|
||||||
const bashPath = resolveWasm(bashWasm)
|
const bashPath = resolveWasm(bashWasm)
|
||||||
const psPath = resolveWasm(psWasm)
|
const psPath = resolveWasm(psWasm)
|
||||||
const bashLanguage = await Language.load(bashPath)
|
const bashLanguage = await Language.load(bashPath)
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,10 @@ export namespace ShellRunner {
|
||||||
})
|
})
|
||||||
|
|
||||||
const metadata: string[] = []
|
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 (aborted) metadata.push("User aborted the command")
|
||||||
if (metadata.length > 0) {
|
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 {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue