summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-30 21:26:53 -0400
committerDax Raad <[email protected]>2025-05-30 21:26:53 -0400
commitf50a57041f5900e7f4b9e963729e4db0189b4598 (patch)
treeaca570c4e316f278cc6a9f2cdcb733ef7070f329
parentf3da73553c45f17e04b1e77cb13eb0fca714d1bd (diff)
downloadopencode-f50a57041f5900e7f4b9e963729e4db0189b4598.tar.gz
opencode-f50a57041f5900e7f4b9e963729e4db0189b4598.zip
embed go
-rw-r--r--packages/opencode/.gitignore1
-rwxr-xr-xpackages/opencode/script/release.ts23
-rw-r--r--packages/opencode/src/index.ts30
-rw-r--r--packages/tui/app.log8
4 files changed, 41 insertions, 21 deletions
diff --git a/packages/opencode/.gitignore b/packages/opencode/.gitignore
index 5f9a3e7af..0188d5c79 100644
--- a/packages/opencode/.gitignore
+++ b/packages/opencode/.gitignore
@@ -1,3 +1,4 @@
node_modules
dist
gen
+app.log
diff --git a/packages/opencode/script/release.ts b/packages/opencode/script/release.ts
index af770cc33..7e457b3ed 100755
--- a/packages/opencode/script/release.ts
+++ b/packages/opencode/script/release.ts
@@ -4,19 +4,15 @@ import { $ } from "bun"
import pkg from "../package.json"
+const dry = process.argv.includes("--dry")
+
const version = `0.0.0-${Date.now()}`
-const ARCH = {
+const GOARCH: Record<string, string> = {
arm64: "arm64",
x64: "amd64",
}
-const OS = {
- linux: "linux",
- darwin: "mac",
- win32: "windows",
-}
-
const targets = [
["linux", "arm64"],
["linux", "x64"],
@@ -32,20 +28,24 @@ for (const [os, arch] of targets) {
console.log(`building ${os}-${arch}`)
const name = `${pkg.name}-${os}-${arch}`
await $`mkdir -p dist/${name}/bin`
- await $`bun build --compile --minify --target=bun-${os}-${arch} --outfile=dist/${name}/bin/${pkg.name} ./src/index.ts`
+ await $`GOOS=${os} GOARCH=${GOARCH[arch]} go build -o ../opencode/dist/${name}/bin/tui ../tui/main.go`.cwd(
+ "../tui",
+ )
+ await $`bun build --compile --minify --target=bun-${os}-${arch} --outfile=dist/${name}/bin/opencode ./src/index.ts ./dist/${name}/bin/tui`
+ await $`rm -rf ./dist/${name}/bin/tui`
await Bun.file(`dist/${name}/package.json`).write(
JSON.stringify(
{
name,
version,
- os: [os],
+ os: [os === "windows" ? "win32" : os],
cpu: [arch],
},
null,
2,
),
)
- await $`cd dist/${name} && npm publish --access public --tag latest`
+ if (!dry) await $`cd dist/${name} && npm publish --access public --tag latest`
optionalDependencies[name] = version
}
@@ -65,4 +65,5 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
2,
),
)
-await $`cd ./dist/${pkg.name} && npm publish --access public --tag latest`
+if (!dry)
+ await $`cd ./dist/${pkg.name} && npm publish --access public --tag latest`
diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts
index 26f25f783..6d7ba0cfb 100644
--- a/packages/opencode/src/index.ts
+++ b/packages/opencode/src/index.ts
@@ -7,16 +7,42 @@ import { Bus } from "./bus"
import { Session } from "./session/session"
import cac from "cac"
import { Share } from "./share/share"
-import { Storage } from "./storage/storage"
import { LLM } from "./llm/llm"
import { Message } from "./session/message"
+import { Global } from "./global"
const cli = cac("opencode")
cli.command("", "Start the opencode in interactive mode").action(async () => {
await App.provide({ directory: process.cwd() }, async () => {
await Share.init()
- Server.listen()
+ const server = Server.listen()
+
+ let cmd = ["go", "run", "./main.go"]
+ let cwd = "../tui"
+ if (Bun.embeddedFiles.length > 0) {
+ const blob = Bun.embeddedFiles[0] as File
+ const binary = path.join(Global.cache(), "tui", blob.name)
+ const file = Bun.file(binary)
+ if (!(await file.exists())) {
+ console.log("installing tui binary...")
+ await Bun.write(file, blob, { mode: 0o755 })
+ }
+ cwd = process.cwd()
+ cmd = [binary]
+ }
+ const proc = Bun.spawn({
+ cmd,
+ cwd,
+ stdout: "inherit",
+ stderr: "inherit",
+ stdin: "inherit",
+ onExit: () => {
+ server.stop()
+ },
+ })
+ await proc.exited
+ await server.stop()
})
})
diff --git a/packages/tui/app.log b/packages/tui/app.log
deleted file mode 100644
index b985bc5f4..000000000
--- a/packages/tui/app.log
+++ /dev/null
@@ -1,8 +0,0 @@
-time=2025-05-30T19:37:27.576-04:00 level=DEBUG msg="Set theme from config" theme=opencode
-time=2025-05-30T19:37:27.580-04:00 level=INFO msg="Reading directory: /home/thdxr"
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="Cancelling all subscriptions"
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="subscription cancelled" name=status
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="All subscription goroutines completed successfully"
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="TUI message channel closed"
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="All goroutines cleaned up"
-time=2025-05-30T19:37:29.815-04:00 level=INFO msg="TUI exited" result="{width:272 height:73 currentPage:chat previousPage: pages:map[chat:0xc0002c4280] loadedPages:map[chat:true] status:{app:0xc0002aa690 queue:[] width:272 messageTTL:4000000000 activeUntil:{wall:0 ext:0 loc:<nil>}} app:0xc0002aa690 showPermissions:false permissions:0xc000279408 showHelp:false help:0xc00052da10 showQuit:true quit:0xc0004761f9 showSessionDialog:false sessionDialog:0xc0000adcc0 showCommandDialog:false commandDialog:0xc000429500 commands:[{ID:init Title:Initialize Project Description:Create/Update the CONTEXT.md memory file Handler:0xb6a7a0} {ID:compact_conversation Title:Compact Conversation Description:Summarize the current session to save tokens Handler:0xb6a620}] showModelDialog:false modelDialog:0xc000261860 showInitDialog:true initDialog:{width:272 height:73 selected:0 keys:{Tab:{keys:[] help:{Key: Desc:} disabled:false} Left:{keys:[] help:{Key: Desc:} disabled:false} Right:{keys:[] help:{Key: Desc:} disabled:false} Enter:{keys:[] help:{Key: Desc:} disabled:false} Escape:{keys:[] help:{Key: Desc:} disabled:false} Y:{keys:[] help:{Key: Desc:} disabled:false} N:{keys:[] help:{Key: Desc:} disabled:false}}} showFilepicker:false filepicker:0xc0000d6c88 showThemeDialog:false themeDialog:0xc0000adf00 showMultiArgumentsDialog:false multiArgumentsDialog:{width:0 height:0 inputs:[] focusIndex:0 keys:{Enter:{keys:[] help:{Key: Desc:} disabled:false} Escape:{keys:[] help:{Key: Desc:} disabled:false}} commandID: content: argNames:[]} showToolsDialog:false toolsDialog:0xc0000adf40}"