summaryrefslogtreecommitdiffhomepage
path: root/js/src/config
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-17 21:31:42 -0400
committerDax Raad <[email protected]>2025-05-26 12:40:17 -0400
commita34d020bc6b252e842f042d935c7a0e6444460cf (patch)
treeea3484499dff80e82d421e879ab639133ae9c3b4 /js/src/config
parent96fbc37f0175052291f8a096d530bd4480f6cb19 (diff)
downloadopencode-a34d020bc6b252e842f042d935c7a0e6444460cf.tar.gz
opencode-a34d020bc6b252e842f042d935c7a0e6444460cf.zip
sync
Diffstat (limited to 'js/src/config')
-rw-r--r--js/src/config/config.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/config/config.ts b/js/src/config/config.ts
new file mode 100644
index 000000000..d76b1a842
--- /dev/null
+++ b/js/src/config/config.ts
@@ -0,0 +1,42 @@
+import path from "node:path";
+import { Log } from "../util/log";
+import { App } from "../app";
+
+export namespace Config {
+ const log = Log.create({ service: "config" });
+
+ // TODO: this should be zod
+ export interface Info {
+ mcp: any; // TODO
+ lsp: any; // TODO
+ }
+
+ function state() {
+ return App.service("config", async () => {
+ const app = await App.use();
+ let result: Info = {
+ mcp: {},
+ lsp: {},
+ };
+ for (const file of ["opencode.jsonc", "opencode.json"]) {
+ const resolved = path.join(app.root, file);
+ log.info("searching", { path: resolved });
+ try {
+ result = await import(path.join(app.root, file)).then(
+ (mod) => mod.default,
+ );
+ log.info("found", { path: resolved });
+ break;
+ } catch (e) {
+ continue;
+ }
+ }
+ log.info("loaded", result);
+ return result;
+ });
+ }
+
+ function get() {
+ return state();
+ }
+}