summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-16 16:33:52 -0400
committerGitHub <[email protected]>2026-04-16 20:33:52 +0000
commit23f97ac49d5e39f8b9cd1f269ad3f1c33404a557 (patch)
tree61cf014b75f84c5cd8d683db5568cb14aec04879
parent021ab50fb105153de174c664ce90f5c90e4ba840 (diff)
downloadopencode-23f97ac49d5e39f8b9cd1f269ad3f1c33404a557.tar.gz
opencode-23f97ac49d5e39f8b9cd1f269ad3f1c33404a557.zip
refactor: collapse global barrel into global/index.ts (#22905)
-rw-r--r--packages/opencode/src/global/global.ts56
-rw-r--r--packages/opencode/src/global/index.ts59
2 files changed, 58 insertions, 57 deletions
diff --git a/packages/opencode/src/global/global.ts b/packages/opencode/src/global/global.ts
deleted file mode 100644
index 3633e0855..000000000
--- a/packages/opencode/src/global/global.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import fs from "fs/promises"
-import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir"
-import path from "path"
-import os from "os"
-import { Filesystem } from "../util"
-import { Flock } from "@opencode-ai/shared/util/flock"
-
-const app = "opencode"
-
-const data = path.join(xdgData!, app)
-const cache = path.join(xdgCache!, app)
-const config = path.join(xdgConfig!, app)
-const state = path.join(xdgState!, app)
-
-export const Path = {
- // Allow override via OPENCODE_TEST_HOME for test isolation
- get home() {
- return process.env.OPENCODE_TEST_HOME || os.homedir()
- },
- data,
- bin: path.join(cache, "bin"),
- log: path.join(data, "log"),
- cache,
- config,
- state,
-}
-
-// Initialize Flock with global state path
-Flock.setGlobal({ state })
-
-await Promise.all([
- fs.mkdir(Path.data, { recursive: true }),
- fs.mkdir(Path.config, { recursive: true }),
- fs.mkdir(Path.state, { recursive: true }),
- fs.mkdir(Path.log, { recursive: true }),
- fs.mkdir(Path.bin, { recursive: true }),
-])
-
-const CACHE_VERSION = "21"
-
-const version = await Filesystem.readText(path.join(Path.cache, "version")).catch(() => "0")
-
-if (version !== CACHE_VERSION) {
- try {
- const contents = await fs.readdir(Path.cache)
- await Promise.all(
- contents.map((item) =>
- fs.rm(path.join(Path.cache, item), {
- recursive: true,
- force: true,
- }),
- ),
- )
- } catch {}
- await Filesystem.write(path.join(Path.cache, "version"), CACHE_VERSION)
-}
diff --git a/packages/opencode/src/global/index.ts b/packages/opencode/src/global/index.ts
index 9262bf2a9..27bac598f 100644
--- a/packages/opencode/src/global/index.ts
+++ b/packages/opencode/src/global/index.ts
@@ -1 +1,58 @@
-export * as Global from "./global"
+import fs from "fs/promises"
+import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir"
+import path from "path"
+import os from "os"
+import { Filesystem } from "../util"
+import { Flock } from "@opencode-ai/shared/util/flock"
+
+const app = "opencode"
+
+const data = path.join(xdgData!, app)
+const cache = path.join(xdgCache!, app)
+const config = path.join(xdgConfig!, app)
+const state = path.join(xdgState!, app)
+
+export const Path = {
+ // Allow override via OPENCODE_TEST_HOME for test isolation
+ get home() {
+ return process.env.OPENCODE_TEST_HOME || os.homedir()
+ },
+ data,
+ bin: path.join(cache, "bin"),
+ log: path.join(data, "log"),
+ cache,
+ config,
+ state,
+}
+
+// Initialize Flock with global state path
+Flock.setGlobal({ state })
+
+await Promise.all([
+ fs.mkdir(Path.data, { recursive: true }),
+ fs.mkdir(Path.config, { recursive: true }),
+ fs.mkdir(Path.state, { recursive: true }),
+ fs.mkdir(Path.log, { recursive: true }),
+ fs.mkdir(Path.bin, { recursive: true }),
+])
+
+const CACHE_VERSION = "21"
+
+const version = await Filesystem.readText(path.join(Path.cache, "version")).catch(() => "0")
+
+if (version !== CACHE_VERSION) {
+ try {
+ const contents = await fs.readdir(Path.cache)
+ await Promise.all(
+ contents.map((item) =>
+ fs.rm(path.join(Path.cache, item), {
+ recursive: true,
+ force: true,
+ }),
+ ),
+ )
+ } catch {}
+ await Filesystem.write(path.join(Path.cache, "version"), CACHE_VERSION)
+}
+
+export * as Global from "."