summaryrefslogtreecommitdiffhomepage
path: root/packages/core/src/global.ts
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2026-04-25 13:29:52 -0400
committerDax Raad <[email protected]>2026-04-25 13:30:37 -0400
commit1a734adb4d1ce6071432bd68ac45fa4457f0dc2e (patch)
treeaed9acae5ae3da2fb93d3184ea2dc1f6a9412104 /packages/core/src/global.ts
parenta9740b9133a8056f5992b17f1b3fde15cc039f8d (diff)
downloadopencode-1a734adb4d1ce6071432bd68ac45fa4457f0dc2e.tar.gz
opencode-1a734adb4d1ce6071432bd68ac45fa4457f0dc2e.zip
core: consolidate shared infrastructure into core package
Moves effect logging, observability, runtime utilities, flags, installation version info, and process utilities from opencode to core package. This enables better code sharing across packages and establishes core as the single source of truth for foundational utilities. All internal imports updated to use @opencode-ai/core paths for consistency.
Diffstat (limited to 'packages/core/src/global.ts')
-rw-r--r--packages/core/src/global.ts41
1 files changed, 25 insertions, 16 deletions
diff --git a/packages/core/src/global.ts b/packages/core/src/global.ts
index 538cc091b..bf605618f 100644
--- a/packages/core/src/global.ts
+++ b/packages/core/src/global.ts
@@ -3,6 +3,24 @@ import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir"
import os from "os"
import { Context, Effect, Layer } from "effect"
+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 = {
+ get home() {
+ return process.env.OPENCODE_TEST_HOME ?? os.homedir()
+ },
+ data,
+ bin: path.join(cache, "bin"),
+ log: path.join(data, "log"),
+ cache,
+ config,
+ state,
+}
+
export namespace Global {
export class Service extends Context.Service<Service, Interface>()("@opencode/Global") {}
@@ -19,23 +37,14 @@ export namespace Global {
export const layer = Layer.effect(
Service,
Effect.gen(function* () {
- const app = "opencode"
- const home = process.env.OPENCODE_TEST_HOME ?? os.homedir()
- const data = path.join(xdgData!, app)
- const cache = path.join(xdgCache!, app)
- const cfg = path.join(xdgConfig!, app)
- const state = path.join(xdgState!, app)
- const bin = path.join(cache, "bin")
- const log = path.join(data, "log")
-
return Service.of({
- home,
- data,
- cache,
- config: cfg,
- state,
- bin,
- log,
+ home: Path.home,
+ data: Path.data,
+ cache: Path.cache,
+ config: Path.config,
+ state: Path.state,
+ bin: Path.bin,
+ log: Path.log,
})
}),
)