diff --git a/packages/opencode/src/cli/ink/entry.ts b/packages/opencode/src/cli/ink/entry.ts
index 3ca82840c6eb..2ca926e30059 100644
--- a/packages/opencode/src/cli/ink/entry.ts
+++ b/packages/opencode/src/cli/ink/entry.ts
@@ -1,5 +1,46 @@
#!/usr/bin/env bun
-/** @jsxImportSource react */
+import { Global } from "@/global"
+import { Log } from "@/util/log"
+import { Instance } from "@/project/instance"
+import { InstanceBootstrap } from "@/project/bootstrap"
+import { Installation } from "@/installation"
import { startInkTUI } from "./index.tsx"
-startInkTUI()
+async function main() {
+ try {
+ await Global.init()
+ await Log.init({
+ print: process.stdout.isTTY,
+ dev: Installation.isLocal(),
+ level: "INFO",
+ })
+
+ process.on("unhandledRejection", (e) => {
+ Log.Default.error("rejection", {
+ e: e instanceof Error ? e.message : e,
+ })
+ })
+
+ process.on("uncaughtException", (e) => {
+ Log.Default.error("exception", {
+ e: e instanceof Error ? e.message : e,
+ })
+ })
+
+ await Instance.provide({
+ directory: process.cwd(),
+ init: InstanceBootstrap,
+ fn: async () => {
+ await startInkTUI()
+ },
+ })
+ } catch (error) {
+ console.error("Failed to start oclite:", error)
+ process.exit(1)
+ }
+}
+
+main().catch((error) => {
+ console.error("Fatal error:", error)
+ process.exit(1)
+})
diff --git a/packages/opencode/src/cli/ink/index.tsx b/packages/opencode/src/cli/ink/index.tsx
index bbd322f76051..68e1155150ad 100644
--- a/packages/opencode/src/cli/ink/index.tsx
+++ b/packages/opencode/src/cli/ink/index.tsx
@@ -3,5 +3,6 @@ import { render } from "ink"
import App from "./App"
export function startInkTUI() {
- render()
+ const instance = render()
+ return instance.waitUntilExit()
}