|
|
@@ -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,
|
|
|
})
|
|
|
}),
|
|
|
)
|