Skip to content

Commit e11fd1f

Browse files
Apply PR #17803: Remove CLI from electron app
2 parents 327918c + 9154038 commit e11fd1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+826
-1133
lines changed

bun.lock

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

packages/desktop-electron/electron-builder.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ const getBase = (): Configuration => ({
1414
},
1515
files: ["out/**/*", "resources/**/*"],
1616
extraResources: [
17-
{
18-
from: "resources/",
19-
to: "",
20-
filter: ["opencode-cli*"],
21-
},
2217
{
2318
from: "native/",
2419
to: "native/",

packages/desktop-electron/electron.vite.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { defineConfig } from "electron-vite"
22
import appPlugin from "@opencode-ai/app/vite"
3+
import * as fs from "node:fs/promises"
34

45
const channel = (() => {
56
const raw = process.env.OPENCODE_CHANNEL
67
if (raw === "dev" || raw === "beta" || raw === "prod") return raw
78
return "dev"
89
})()
910

11+
const OPENCODE_SERVER_DIST = "../opencode/dist/node"
12+
1013
export default defineConfig({
1114
main: {
1215
define: {
@@ -17,6 +20,25 @@ export default defineConfig({
1720
input: { index: "src/main/index.ts" },
1821
},
1922
},
23+
plugins: [
24+
{
25+
name: "opencode:virtual-server-module",
26+
enforce: "pre",
27+
resolveId(id) {
28+
if (id === "virtual:opencode-server") return this.resolve(`${OPENCODE_SERVER_DIST}/node.js`)
29+
},
30+
},
31+
{
32+
name: "opencode:copy-server-assets",
33+
enforce: "post",
34+
async closeBundle() {
35+
for (const l of await fs.readdir(OPENCODE_SERVER_DIST)) {
36+
if (l.endsWith(".js")) continue
37+
await fs.writeFile(`./out/main/${l}`, await fs.readFile(`${OPENCODE_SERVER_DIST}/${l}`))
38+
}
39+
},
40+
},
41+
],
2042
},
2143
preload: {
2244
build: {

packages/desktop-electron/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
3030
"@solid-primitives/storage": "catalog:",
3131
"@solidjs/meta": "catalog:",
3232
"@solidjs/router": "0.15.4",
33+
"@valibot/to-json-schema": "1.6.0",
3334
"effect": "catalog:",
3435
"electron-log": "^5",
3536
"electron-store": "^10",
3637
"electron-updater": "^6",
3738
"electron-window-state": "^5.0.3",
3839
"marked": "^15",
3940
"solid-js": "catalog:",
40-
"tree-kill": "^1.2.2"
41+
"sury": "11.0.0-alpha.4",
42+
"tree-kill": "^1.2.2",
43+
"zod-openapi": "5.4.6"
4144
},
4245
"devDependencies": {
4346
"@actions/artifact": "4.0.0",
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { $ } from "bun"
22

3-
import { copyBinaryToSidecarFolder, getCurrentSidecar, windowsify } from "./utils"
4-
53
await $`bun ./scripts/copy-icons.ts ${process.env.OPENCODE_CHANNEL ?? "dev"}`
64

7-
const RUST_TARGET = Bun.env.RUST_TARGET
8-
9-
const sidecarConfig = getCurrentSidecar(RUST_TARGET)
10-
11-
const binaryPath = windowsify(`../opencode/dist/${sidecarConfig.ocBinary}/bin/opencode`)
12-
13-
await (sidecarConfig.ocBinary.includes("-baseline")
14-
? $`cd ../opencode && bun run build --single --baseline`
15-
: $`cd ../opencode && bun run build --single`)
16-
17-
await copyBinaryToSidecarFolder(binaryPath, RUST_TARGET)
5+
await $`cd ../opencode && bun script/build-node.ts`

packages/desktop-electron/scripts/prepare.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { $ } from "bun"
33

44
import { Script } from "@opencode-ai/script"
5-
import { copyBinaryToSidecarFolder, getCurrentSidecar, resolveChannel, windowsify } from "./utils"
5+
import { resolveChannel } from "./utils"
66

77
const channel = resolveChannel()
88
await $`bun ./scripts/copy-icons.ts ${channel}`
@@ -12,13 +12,4 @@ pkg.version = Script.version
1212
await Bun.write("./package.json", JSON.stringify(pkg, null, 2) + "\n")
1313
console.log(`Updated package.json version to ${Script.version}`)
1414

15-
const sidecarConfig = getCurrentSidecar()
16-
17-
const dir = "resources/opencode-binaries"
18-
19-
await $`mkdir -p ${dir}`
20-
await $`gh run download ${Bun.env.GITHUB_RUN_ID} -n opencode-cli`.cwd(dir)
21-
22-
await copyBinaryToSidecarFolder(windowsify(`${dir}/${sidecarConfig.ocBinary}/bin/opencode`))
23-
24-
await $`rm -rf ${dir}`
15+
await $`cd ../opencode && bun script/build-node.ts`

packages/desktop-electron/src/main/cli.ts

Lines changed: 0 additions & 280 deletions
This file was deleted.

0 commit comments

Comments
 (0)