Skip to content

Commit 675a46e

Browse files
authored
CLI perf: reduce deps (#22652)
1 parent 150ab07 commit 675a46e

84 files changed

Lines changed: 1413 additions & 1009 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bun.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
research
22
dist
3+
dist-*
34
gen
45
app.log
56
src/provider/models-snapshot.js
67
src/provider/models-snapshot.d.ts
8+
script/build-*.ts
9+
temporary-*.md

packages/opencode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"fix-node-pty": "bun run script/fix-node-pty.ts",
1515
"upgrade-opentui": "bun run script/upgrade-opentui.ts",
1616
"dev": "bun run --conditions=browser ./src/index.ts",
17+
"dev:temporary": "bun run --conditions=browser ./src/temporary.ts",
1718
"db": "bun drizzle-kit"
1819
},
1920
"bin": {

packages/opencode/script/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { z } from "zod"
44
import { Config } from "../src/config"
5-
import { TuiConfig } from "../src/config"
5+
import { TuiConfig } from "../src/cli/cmd/tui/config/tui"
66

77
function generate(schema: z.ZodType) {
88
const result = z.toJSONSchema(schema, {

packages/opencode/src/acp/agent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { z } from "zod"
4949
import { LoadAPIKeyError } from "ai"
5050
import type { AssistantMessage, Event, OpencodeClient, SessionMessageResponse, ToolPart } from "@opencode-ai/sdk/v2"
5151
import { applyPatch } from "diff"
52+
import { InstallationVersion } from "@/installation/version"
5253

5354
type ModeOption = { id: string; name: string; description?: string }
5455
type ModelOption = { modelId: string; name: string }
@@ -570,7 +571,7 @@ export namespace ACP {
570571
authMethods: [authMethod],
571572
agentInfo: {
572573
name: "OpenCode",
573-
version: Installation.VERSION,
574+
version: InstallationVersion,
574575
},
575576
}
576577
}

packages/opencode/src/cli/cmd/mcp.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { McpOAuthProvider } from "../../mcp/oauth-provider"
1010
import { Config } from "../../config"
1111
import { Instance } from "../../project/instance"
1212
import { Installation } from "../../installation"
13+
import { InstallationVersion } from "../../installation/version"
1314
import path from "path"
1415
import { Global } from "../../global"
1516
import { modify, applyEdits } from "jsonc-parser"
@@ -697,7 +698,7 @@ export const McpDebugCommand = cmd({
697698
params: {
698699
protocolVersion: "2024-11-05",
699700
capabilities: {},
700-
clientInfo: { name: "opencode-debug", version: Installation.VERSION },
701+
clientInfo: { name: "opencode-debug", version: InstallationVersion },
701702
},
702703
id: 1,
703704
}),
@@ -746,7 +747,7 @@ export const McpDebugCommand = cmd({
746747
try {
747748
const client = new Client({
748749
name: "opencode-debug",
749-
version: Installation.VERSION,
750+
version: InstallationVersion,
750751
})
751752
await client.connect(transport)
752753
prompts.log.success("Connection successful (already authenticated)")

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { ArgsProvider, useArgs, type Args } from "./context/args"
5757
import open from "open"
5858
import { PromptRefProvider, usePromptRef } from "./context/prompt"
5959
import { TuiConfigProvider, useTuiConfig } from "./context/tui-config"
60-
import { TuiConfig } from "@/config"
60+
import { TuiConfig } from "@/cli/cmd/tui/config/tui"
6161
import { createTuiApi, TuiPluginRuntime, type RouteMap } from "./plugin"
6262
import { FormatError, FormatUnknownError } from "@/cli/error"
6363

@@ -235,7 +235,10 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
235235
renderer,
236236
})
237237
const [ready, setReady] = createSignal(false)
238-
TuiPluginRuntime.init(api)
238+
TuiPluginRuntime.init({
239+
api,
240+
config: tuiConfig,
241+
})
239242
.catch((error) => {
240243
console.error("Failed to load TUI plugins", error)
241244
})

packages/opencode/src/cli/cmd/tui/attach.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { cmd } from "../cmd"
22
import { UI } from "@/cli/ui"
33
import { tui } from "./app"
44
import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
5-
import { TuiConfig } from "@/config"
6-
import { Instance } from "@/project/instance"
7-
import { existsSync } from "fs"
5+
import { TuiConfig } from "@/cli/cmd/tui/config/tui"
86

97
export const AttachCommand = cmd({
108
command: "attach <url>",
@@ -66,10 +64,7 @@ export const AttachCommand = cmd({
6664
const auth = `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`
6765
return { Authorization: auth }
6866
})()
69-
const config = await Instance.provide({
70-
directory: directory && existsSync(directory) ? directory : process.cwd(),
71-
fn: () => TuiConfig.get(),
72-
})
67+
const config = await TuiConfig.get()
7368
await tui({
7469
url: args.url,
7570
config,

packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function DialogAgent() {
2020
return (
2121
<DialogSelect
2222
title="Select agent"
23-
current={local.agent.current().name}
23+
current={local.agent.current()?.name}
2424
options={options()}
2525
onSelect={(option) => {
2626
local.agent.set(option.value)

packages/opencode/src/cli/cmd/tui/component/error-component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { TextAttributes } from "@opentui/core"
22
import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
33
import * as Clipboard from "@tui/util/clipboard"
44
import { createSignal } from "solid-js"
5-
import { Installation } from "@/installation"
5+
import { InstallationVersion } from "@/installation/version"
66
import { win32FlushInputBuffer } from "../win32"
77
import { getScrollAcceleration } from "../util/scroll"
88

@@ -53,7 +53,7 @@ export function ErrorComponent(props: {
5353
)
5454
}
5555

56-
issueURL.searchParams.set("opencode-version", Installation.VERSION)
56+
issueURL.searchParams.set("opencode-version", InstallationVersion)
5757

5858
const copyIssueURL = () => {
5959
void Clipboard.copy(issueURL.toString()).then(() => {

0 commit comments

Comments
 (0)