Skip to content
Open
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
25 changes: 17 additions & 8 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,44 @@
"lint": "eslint src --ext .ts --max-warnings=0",
"check-types": "tsc --noEmit",
"test": "vitest run",
"build": "tsup",
"build": "tsup && bun scripts/build-ui-next.ts",
"build:ui-next": "bun scripts/build-ui-next.ts",
"build:extension": "pnpm --filter roo-cline bundle",
"dev": "ROO_AUTH_BASE_URL=https://app.roocode.com ROO_SDK_BASE_URL=https://cloud-api.roocode.com ROO_CODE_PROVIDER_URL=https://api.roocode.com/proxy tsx src/index.ts -y",
"dev:local": "ROO_AUTH_BASE_URL=http://localhost:3000 ROO_SDK_BASE_URL=http://localhost:3001 ROO_CODE_PROVIDER_URL=http://localhost:8080/proxy tsx src/index.ts",
"clean": "rimraf dist .turbo"
},
"dependencies": {
"@inkjs/ui": "^2.0.0",
"@opentui/core": "^0.1.77",
"@opentui/solid": "^0.1.77",
"@roo-code/core": "workspace:^",
"@roo-code/types": "workspace:^",
"@roo-code/vscode-shim": "workspace:^",
"@solid-primitives/event-bus": "^1.1.2",
"@solid-primitives/scheduled": "^1.5.2",
"@trpc/client": "^11.8.1",
"@vscode/ripgrep": "^1.15.9",
"commander": "^12.1.0",
"cross-spawn": "^7.0.6",
"execa": "^9.5.2",
"fuzzysort": "^3.1.0",
"ink": "^6.6.0",
"p-wait-for": "^5.0.2",
"react": "^19.1.0",
"superjson": "^2.2.6",
"zustand": "^5.0.0"
"solid-js": "^1.9.11",
"superjson": "^2.2.6"
},
"optionalDependencies": {
"@opentui/core-darwin-arm64": "^0.1.77",
"@opentui/core-darwin-x64": "^0.1.77",
"@opentui/core-linux-x64": "^0.1.77",
"@opentui/core-linux-arm64": "^0.1.77",
"@opentui/core-win32-x64": "^0.1.77"
},
"devDependencies": {
"@babel/core": "^7.29.0",
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@types/node": "^24.1.0",
"@types/react": "^19.1.6",
"ink-testing-library": "^4.0.0",
"babel-preset-solid": "^1.9.10",
"rimraf": "^6.0.1",
"tsup": "^8.4.0",
"vitest": "^3.2.3"
Expand Down
56 changes: 56 additions & 0 deletions apps/cli/scripts/build-ui-next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bun

/**
* Build script for the SolidJS/opentui TUI.
*
* Uses Bun.build with the solid plugin to properly transform SolidJS JSX.
*
* Usage:
* cd apps/cli && bun scripts/build-ui-next.ts
*
* Output:
* dist/ui-next/main.js
*/

import solidPlugin from "../node_modules/@opentui/solid/scripts/solid-plugin"
import path from "path"

const dir = path.resolve(import.meta.dir, "..")

process.chdir(dir)

const result = await Bun.build({
entrypoints: ["./src/ui-next/main.tsx"],
outdir: "./dist/ui-next",
target: "bun",
plugins: [solidPlugin],
external: [
// Keep native modules external
"@vscode/ripgrep",
"@anthropic-ai/sdk",
"@anthropic-ai/bedrock-sdk",
"@anthropic-ai/vertex-sdk",
],
sourcemap: "external",
})

if (!result.success) {
console.error("Build failed:")
for (const msg of result.logs) {
console.error(msg)
}
process.exit(1)
}

console.log(`Build succeeded: ${result.outputs.length} outputs`)
for (const output of result.outputs) {
const size = output.size
const sizeStr =
size > 1024 * 1024
? `${(size / (1024 * 1024)).toFixed(2)} MB`
: size > 1024
? `${(size / 1024).toFixed(2)} KB`
: `${size} B`

console.log(` ${path.relative(dir, output.path)} (${sizeStr})`)
}
43 changes: 28 additions & 15 deletions apps/cli/src/commands/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import fs from "fs"
import path from "path"
import { fileURLToPath } from "url"

import { createElement } from "react"

import { setLogger } from "@roo-code/vscode-shim"

import {
Expand Down Expand Up @@ -204,19 +202,34 @@ export async function run(promptArg: string | undefined, flagOptions: FlagOption

if (isTuiEnabled) {
try {
const { render } = await import("ink")
const { App } = await import("../../ui/App.js")

render(
createElement(App, {
...extensionHostOptions,
initialPrompt: prompt,
version: VERSION,
createExtensionHost: (opts: ExtensionHostOptions) => new ExtensionHost(opts),
}),
// Handle Ctrl+C in App component for double-press exit.
{ exitOnCtrlC: false },
)
const cliRoot = process.env.ROO_CLI_ROOT || path.resolve(__dirname, "..")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cliRoot resolves incorrectly in dev mode. __dirname here points to src/commands/cli/, so path.resolve(__dirname, "..") yields src/commands/ -- not the CLI package root. This means tuiBundlePath resolves to src/commands/dist/ui-next/main.js, which doesn't exist. The bundled (tsup) case works because __dirname is dist/, going up one lands at the package root. The existing extension-host.ts solves this with findCliPackageRoot() (walks up to the nearest package.json); the same approach would work here.

Suggested change
const cliRoot = process.env.ROO_CLI_ROOT || path.resolve(__dirname, "..")
const cliRoot = process.env.ROO_CLI_ROOT || findCliPackageRoot(__dirname)

Fix it with Roo Code or mention @roomote and request a fix.

const tuiBundlePath = path.join(cliRoot, "dist", "ui-next", "main.js")

if (!fs.existsSync(tuiBundlePath)) {
throw new Error(
`TUI bundle not found at: ${tuiBundlePath}\n` +
`Run 'cd apps/cli && bun scripts/build-ui-next.ts' to build it.`,
)
}

// Dynamic import the pre-built SolidJS/opentui TUI bundle
interface UINextModule {
startTUI: (
props: ExtensionHostOptions & {
initialPrompt?: string
version: string
createExtensionHost: (opts: ExtensionHostOptions) => ExtensionHost
},
) => Promise<void>
}
const { startTUI } = (await import(tuiBundlePath)) as UINextModule

await startTUI({
...extensionHostOptions,
initialPrompt: prompt,
version: VERSION,
createExtensionHost: (opts: ExtensionHostOptions) => new ExtensionHost(opts),
})
} catch (error) {
console.error("[CLI] Failed to start TUI:", error instanceof Error ? error.message : String(error))

Expand Down
128 changes: 0 additions & 128 deletions apps/cli/src/lib/utils/__tests__/input.test.ts

This file was deleted.

6 changes: 5 additions & 1 deletion apps/cli/src/lib/utils/context-window.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { ProviderSettings } from "@roo-code/types"

import type { RouterModels } from "@/ui/store.js"
/**
* Map of provider name → model ID → model info (including context window).
* Previously imported from the old React/Ink UI store; now defined locally.
*/
export type RouterModels = Record<string, Record<string, { contextWindow?: number }>>

const DEFAULT_CONTEXT_WINDOW = 200_000

Expand Down
Loading