Dax Raad hai 8 meses
pai
achega
f50a57041f

+ 1 - 0
packages/opencode/.gitignore

@@ -1,3 +1,4 @@
 node_modules
 dist
 gen
+app.log

+ 12 - 11
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`

+ 28 - 2
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()
   })
 })
 

+ 0 - 8
packages/tui/app.log

@@ -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}"