summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-16 16:35:04 -0400
committerGitHub <[email protected]>2026-04-16 20:35:04 +0000
commit8c191b10c2bdceee607b0b549f9632f5adb5b511 (patch)
tree9413daf0395732f4fd0cf7779f68b43fee3fd91d /packages
parentcb6a9253fe8c4439bcfeff6c152b22b470de2eda (diff)
downloadopencode-8c191b10c2bdceee607b0b549f9632f5adb5b511.tar.gz
opencode-8c191b10c2bdceee607b0b549f9632f5adb5b511.zip
refactor: collapse ide barrel into ide/index.ts (#22904)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/ide/ide.ts71
-rw-r--r--packages/opencode/src/ide/index.ts74
2 files changed, 73 insertions, 72 deletions
diff --git a/packages/opencode/src/ide/ide.ts b/packages/opencode/src/ide/ide.ts
deleted file mode 100644
index 65e80d7f2..000000000
--- a/packages/opencode/src/ide/ide.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import { BusEvent } from "@/bus/bus-event"
-import z from "zod"
-import { NamedError } from "@opencode-ai/shared/util/error"
-import { Log } from "../util"
-import { Process } from "@/util"
-
-const SUPPORTED_IDES = [
- { name: "Windsurf" as const, cmd: "windsurf" },
- { name: "Visual Studio Code - Insiders" as const, cmd: "code-insiders" },
- { name: "Visual Studio Code" as const, cmd: "code" },
- { name: "Cursor" as const, cmd: "cursor" },
- { name: "VSCodium" as const, cmd: "codium" },
-]
-
-const log = Log.create({ service: "ide" })
-
-export const Event = {
- Installed: BusEvent.define(
- "ide.installed",
- z.object({
- ide: z.string(),
- }),
- ),
-}
-
-export const AlreadyInstalledError = NamedError.create("AlreadyInstalledError", z.object({}))
-
-export const InstallFailedError = NamedError.create(
- "InstallFailedError",
- z.object({
- stderr: z.string(),
- }),
-)
-
-export function ide() {
- if (process.env["TERM_PROGRAM"] === "vscode") {
- const v = process.env["GIT_ASKPASS"]
- for (const ide of SUPPORTED_IDES) {
- if (v?.includes(ide.name)) return ide.name
- }
- }
- return "unknown"
-}
-
-export function alreadyInstalled() {
- return process.env["OPENCODE_CALLER"] === "vscode" || process.env["OPENCODE_CALLER"] === "vscode-insiders"
-}
-
-export async function install(ide: (typeof SUPPORTED_IDES)[number]["name"]) {
- const cmd = SUPPORTED_IDES.find((i) => i.name === ide)?.cmd
- if (!cmd) throw new Error(`Unknown IDE: ${ide}`)
-
- const p = await Process.run([cmd, "--install-extension", "sst-dev.opencode"], {
- nothrow: true,
- })
- const stdout = p.stdout.toString()
- const stderr = p.stderr.toString()
-
- log.info("installed", {
- ide,
- stdout,
- stderr,
- })
-
- if (p.code !== 0) {
- throw new InstallFailedError({ stderr })
- }
- if (stdout.includes("already installed")) {
- throw new AlreadyInstalledError({})
- }
-}
diff --git a/packages/opencode/src/ide/index.ts b/packages/opencode/src/ide/index.ts
index 9716ecbc7..ee80c3474 100644
--- a/packages/opencode/src/ide/index.ts
+++ b/packages/opencode/src/ide/index.ts
@@ -1 +1,73 @@
-export * as Ide from "./ide"
+import { BusEvent } from "@/bus/bus-event"
+import z from "zod"
+import { NamedError } from "@opencode-ai/shared/util/error"
+import { Log } from "../util"
+import { Process } from "@/util"
+
+const SUPPORTED_IDES = [
+ { name: "Windsurf" as const, cmd: "windsurf" },
+ { name: "Visual Studio Code - Insiders" as const, cmd: "code-insiders" },
+ { name: "Visual Studio Code" as const, cmd: "code" },
+ { name: "Cursor" as const, cmd: "cursor" },
+ { name: "VSCodium" as const, cmd: "codium" },
+]
+
+const log = Log.create({ service: "ide" })
+
+export const Event = {
+ Installed: BusEvent.define(
+ "ide.installed",
+ z.object({
+ ide: z.string(),
+ }),
+ ),
+}
+
+export const AlreadyInstalledError = NamedError.create("AlreadyInstalledError", z.object({}))
+
+export const InstallFailedError = NamedError.create(
+ "InstallFailedError",
+ z.object({
+ stderr: z.string(),
+ }),
+)
+
+export function ide() {
+ if (process.env["TERM_PROGRAM"] === "vscode") {
+ const v = process.env["GIT_ASKPASS"]
+ for (const ide of SUPPORTED_IDES) {
+ if (v?.includes(ide.name)) return ide.name
+ }
+ }
+ return "unknown"
+}
+
+export function alreadyInstalled() {
+ return process.env["OPENCODE_CALLER"] === "vscode" || process.env["OPENCODE_CALLER"] === "vscode-insiders"
+}
+
+export async function install(ide: (typeof SUPPORTED_IDES)[number]["name"]) {
+ const cmd = SUPPORTED_IDES.find((i) => i.name === ide)?.cmd
+ if (!cmd) throw new Error(`Unknown IDE: ${ide}`)
+
+ const p = await Process.run([cmd, "--install-extension", "sst-dev.opencode"], {
+ nothrow: true,
+ })
+ const stdout = p.stdout.toString()
+ const stderr = p.stderr.toString()
+
+ log.info("installed", {
+ ide,
+ stdout,
+ stderr,
+ })
+
+ if (p.code !== 0) {
+ throw new InstallFailedError({ stderr })
+ }
+ if (stdout.includes("already installed")) {
+ throw new AlreadyInstalledError({})
+ }
+}
+
+export * as Ide from "."