Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions packages/opencode/src/cli/ink/entry.ts
Original file line number Diff line number Diff line change
@@ -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)
})
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/ink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { render } from "ink"
import App from "./App"

export function startInkTUI() {
render(<App />)
const instance = render(<App />)
return instance.waitUntilExit()
}