Skip to content

Commit 1297193

Browse files
authored
feat(core): parse shell permission commands (#39567)
1 parent 78c139b commit 1297193

13 files changed

Lines changed: 513 additions & 30 deletions

File tree

bun.lock

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
"open": "10.1.2",
4141
"semver": "catalog:",
4242
"solid-js": "catalog:",
43+
"tree-sitter-bash": "0.25.0",
44+
"tree-sitter-powershell": "0.25.10",
45+
"web-tree-sitter": "0.25.10",
4346
"uqr": "0.1.3",
4447
"ws": "8.21.0"
4548
},

packages/cli/script/build-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ for (const target of targets) {
6262
await rm("dist-node", { recursive: true, force: true })
6363
const assetHash = await hashNodeAssets(assets)
6464
const input = { version: Script.version, channel: Script.channel, models: modelsData, assetHash, target }
65-
await build(mainConfig(input))
6665
await copyNodeAssets(assets)
66+
await build(mainConfig(input))
6767

6868
const host = target.platform === process.platform && target.arch === process.arch
6969
if (host) {

packages/cli/script/node-assets.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { copyFile, mkdir, readdir, readFile, stat } from "node:fs/promises"
33
import path from "node:path"
44
import { fileURLToPath } from "node:url"
55
import { getNodeAssets } from "@opentui/core/node-assets"
6-
import { attentionSoundAssets, type NodeTarget, photonWasmAsset } from "../src/node/target"
6+
import { attentionSoundAssets, type NodeTarget, photonWasmAsset, shellParserWasmAssets } from "../src/node/target"
77

88
const dir = path.resolve(import.meta.dirname, "..")
99

@@ -43,6 +43,10 @@ export async function collectNodeAssets(target: NodeTarget) {
4343
key: photonWasmAsset,
4444
source: fileURLToPath(import.meta.resolve(photonWasmAsset)),
4545
},
46+
...Object.values(shellParserWasmAssets).map((key) => ({
47+
key,
48+
source: fileURLToPath(import.meta.resolve(key)),
49+
})),
4650
...attentionSoundAssets.map((key) => ({
4751
key,
4852
source: path.resolve(dir, "../ui/src/assets/audio", path.basename(key)),

packages/cli/src/node/target.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export function nodeTarget(platform: string, arch: string) {
2929
}
3030

3131
export const photonWasmAsset = "@silvia-odwyer/photon-node/photon_rs_bg.wasm"
32+
export const shellParserWasmAssets = {
33+
runtime: "web-tree-sitter/tree-sitter.wasm",
34+
bash: "tree-sitter-bash/tree-sitter-bash.wasm",
35+
powershell: "tree-sitter-powershell/tree-sitter-powershell.wasm",
36+
} as const
3237
export const nodeExecArgv = ["--experimental-ffi", "--use-system-ca", "--disable-warning=ExperimentalWarning"] as const
3338

3439
export const attentionSoundAssets = [

packages/cli/vite.node.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { readFile } from "node:fs/promises"
33
import { createRequire } from "node:module"
44
import { defineConfig, type Plugin, type UserConfig } from "vite"
55
import solid from "vite-plugin-solid"
6-
import { nodeExecArgv, nodeTarget, type NodeTarget, photonWasmAsset } from "./src/node/target"
6+
import {
7+
nodeExecArgv,
8+
nodeTarget,
9+
type NodeTarget,
10+
photonWasmAsset,
11+
shellParserWasmAssets,
12+
} from "./src/node/target"
713

814
const dir = import.meta.dirname
915

@@ -194,6 +200,9 @@ process.env.OTUI_ASSET_ROOT = __ocAssetRoot
194200
process.env.OPENCODE_NODE_PTY_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.nodePtyEntryAsset)})
195201
process.env.OPENCODE_PARCEL_WATCHER_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.parcelWatcherAsset)})
196202
process.env.OPENCODE_PHOTON_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(photonWasmAsset)})
203+
process.env.OPENCODE_TREE_SITTER_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.runtime)})
204+
process.env.OPENCODE_TREE_SITTER_BASH_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.bash)})
205+
process.env.OPENCODE_TREE_SITTER_POWERSHELL_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.powershell)})
197206
process.env.FFF_BINARY_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.fffAsset)})
198207
process.env.OPENCODE_FFF_FFI_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.fffFfiAsset)})
199208
try {

packages/core/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"node": "./src/image/photon-wasm.node.ts",
4242
"default": "./src/image/photon-wasm.bun.ts"
4343
},
44+
"#shell-parser-wasm": {
45+
"bun": "./src/shell/parser-wasm.bun.ts",
46+
"node": "./src/shell/parser-wasm.node.ts",
47+
"default": "./src/shell/parser-wasm.bun.ts"
48+
},
4449
"#process-lock-ffi": {
4550
"bun": "./src/util/process-lock-ffi.bun.ts",
4651
"node": "./src/util/process-lock-ffi.node.ts",
@@ -119,7 +124,10 @@
119124
"jsonc-parser": "3.3.1",
120125
"semver": "^7.6.3",
121126
"turndown": "7.2.0",
127+
"tree-sitter-bash": "0.25.0",
128+
"tree-sitter-powershell": "0.25.10",
122129
"venice-ai-sdk-provider": "2.1.1",
130+
"web-tree-sitter": "0.25.10",
123131
"which": "6.0.1",
124132
"zod": "catalog:"
125133
},

0 commit comments

Comments
 (0)