Skip to content

Commit 8609cc5

Browse files
authored
refactor(core): finish moving shell permission checks off tree-sitter (#60332)
1 parent c24c5af commit 8609cc5

27 files changed

Lines changed: 1167 additions & 1080 deletions

‎bun.lock‎

Lines changed: 0 additions & 13 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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
"jsonc-parser": "3.3.1",
5050
"picocolors": "1.1.1",
5151
"solid-js": "catalog:",
52-
"tree-sitter-bash": "0.25.0",
53-
"tree-sitter-powershell": "0.25.10",
5452
"web-tree-sitter": "0.25.10",
5553
"ws": "8.21.0"
5654
},

‎packages/cli/script/node-assets.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { copyFile, mkdir, 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, shellParserWasmAssets } from "../src/node/target"
6+
import { attentionSoundAssets, type NodeTarget, photonWasmAsset } from "../src/node/target"
77
import { collectFiles } from "./files"
88
import { resolveOpencodePty } from "./opencode-pty"
99

@@ -39,10 +39,6 @@ export async function collectNodeAssets(target: NodeTarget) {
3939
key: photonWasmAsset,
4040
source: fileURLToPath(import.meta.resolve(photonWasmAsset)),
4141
},
42-
...Object.values(shellParserWasmAssets).map((key) => ({
43-
key,
44-
source: fileURLToPath(import.meta.resolve(key)),
45-
})),
4642
...attentionSoundAssets.map((key) => ({
4743
key,
4844
source: path.resolve(dir, "../ui/src/assets/audio", path.basename(key)),

‎packages/cli/src/node/target.ts‎

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

3333
export const photonWasmAsset = "@silvia-odwyer/photon-node/photon_rs_bg.wasm"
34-
export const shellParserWasmAssets = {
35-
runtime: "web-tree-sitter/tree-sitter.wasm",
36-
bash: "tree-sitter-bash/tree-sitter-bash.wasm",
37-
powershell: "tree-sitter-powershell/tree-sitter-powershell.wasm",
38-
} as const
3934
export const nodeExecArgv = ["--experimental-ffi", "--use-system-ca", "--disable-warning=ExperimentalWarning"] as const
4035

4136
export const attentionSoundAssets = [
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { expect, test } from "bun:test"
22
import { fileURLToPath } from "node:url"
33
import { collectNodeAssets } from "../script/node-assets"
4-
import { nodeTarget, shellParserWasmAssets } from "../src/node/target"
4+
import { nodeTarget, photonWasmAsset } from "../src/node/target"
55

66
test("collects each SEA asset key once", async () => {
77
const assets = await collectNodeAssets(nodeTarget(process.platform, process.arch))
88
const keys = assets.map((asset) => asset.key)
99

1010
expect(new Set(keys).size).toBe(keys.length)
1111
expect(keys.filter((key) => key === nodeTarget(process.platform, process.arch).opencodePtyAsset)).toHaveLength(1)
12-
expect(assets.filter((asset) => asset.key === shellParserWasmAssets.runtime)).toEqual([
12+
expect(assets.filter((asset) => asset.key === photonWasmAsset)).toEqual([
1313
{
14-
key: shellParserWasmAssets.runtime,
15-
source: fileURLToPath(import.meta.resolve(shellParserWasmAssets.runtime)),
14+
key: photonWasmAsset,
15+
source: fileURLToPath(import.meta.resolve(photonWasmAsset)),
1616
},
1717
])
1818
})

‎packages/cli/vite.node.config.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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, shellParserWasmAssets } from "./src/node/target"
6+
import { nodeExecArgv, nodeTarget, type NodeTarget, photonWasmAsset } from "./src/node/target"
77
import { verifySimulationGraph } from "./script/verify-artifact"
88

99
const dir = import.meta.dirname
@@ -237,9 +237,6 @@ process.env.OTUI_ASSET_ROOT = __ocAssetRoot
237237
process.env.OPENCODE_NODE_PTY_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.nodePtyEntryAsset)})
238238
process.env.OPENCODE_PARCEL_WATCHER_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.parcelWatcherAsset)})
239239
process.env.OPENCODE_PHOTON_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(photonWasmAsset)})
240-
process.env.OPENCODE_TREE_SITTER_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.runtime)})
241-
process.env.OPENCODE_TREE_SITTER_BASH_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.bash)})
242-
process.env.OPENCODE_TREE_SITTER_POWERSHELL_WASM_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(shellParserWasmAssets.powershell)})
243240
process.env.FFF_BINARY_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.fffAsset)})
244241
process.env.OPENCODE_FFF_FFI_PATH = __ocPath.join(__ocAssetRoot, ${JSON.stringify(input.target.fffFfiAsset)})
245242
if (__ocPersistentPty && !process.env.OPENCODE_PTY_BIN) process.env.OPENCODE_PTY_BIN = __ocPath.join(__ocAssetRoot, __ocPersistentPty)

‎packages/core/package.json‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@
6262
"node": "./src/image/photon-wasm.node.ts",
6363
"default": "./src/image/photon-wasm.bun.ts"
6464
},
65-
"#shell-parser-wasm": {
66-
"workerd": "./src/shell/parser-wasm.workerd.ts",
67-
"bun": "./src/shell/parser-wasm.bun.ts",
68-
"node": "./src/shell/parser-wasm.node.ts",
69-
"default": "./src/shell/parser-wasm.bun.ts"
70-
},
7165
"#v1-migration": {
7266
"types": "./src/database/v1-migration.bun.ts",
7367
"bun": "./src/database/v1-migration.bun.ts",
@@ -129,9 +123,6 @@
129123
"jose": "6.0.11",
130124
"jsonc-parser": "3.3.1",
131125
"mime-types": "3.0.2",
132-
"tree-sitter-bash": "0.25.0",
133-
"tree-sitter-powershell": "0.25.10",
134-
"web-tree-sitter": "0.25.10",
135126
"which": "6.0.1",
136127
"zod": "catalog:"
137128
}

‎packages/core/script/build.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const result = await Bun.build({
2626
"#persistent-pty-binary",
2727
"#fff",
2828
"#photon-wasm",
29-
"#shell-parser-wasm",
3029
"#v1-migration",
3130
],
3231
splitting: true,

‎packages/core/src/plugin/provider/local.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { define } from "@opencode/plugin/effect/plugin"
22
import type { Entry } from "@opencode/schema/config"
33
import { Duration, Effect, Option, Schedule, type Schema, Semaphore, Stream } from "effect"
44
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
5-
import { shellParserWasm } from "#shell-parser-wasm"
5+
import photonWasm from "#photon-wasm"
66
import { Config } from "../../config.js"
77
import { Environment } from "../../environment/index.js"
88
import { EnvironmentUnavailable } from "../../environment/unavailable.js"
@@ -45,7 +45,7 @@ export function createLocalProviderPlugin<Discovered>(input: {
4545
const location = yield* Effect.serviceOption(Location.Service)
4646
const defaultOrigin =
4747
origin ??
48-
(shellParserWasm.bash === "" ||
48+
(photonWasm === "" ||
4949
(Option.isSome(location) && location.value.workspaceID !== undefined) ||
5050
(Option.isSome(environment) && environment.value.spawner === EnvironmentUnavailable.spawner)
5151
? undefined

0 commit comments

Comments
 (0)