@neuralnomads/codenomad-dev 0.10.3-dev-20260215-35ff359c → 0.10.3-dev-20260215-f3b9ee4e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/events/bus.js +4 -4
- package/dist/index.js +8 -18
- package/dist/opencode-config/package.json +2 -2
- package/dist/server/http-server.js +2 -2
- package/dist/server/routes/settings.js +96 -0
- package/dist/settings/binaries.js +37 -0
- package/dist/settings/merge-patch.js +33 -0
- package/dist/settings/migrate.js +233 -0
- package/dist/settings/service.js +39 -0
- package/dist/settings/yaml-doc-store.js +96 -0
- package/dist/workspaces/manager.js +4 -3
- package/package.json +1 -1
- package/public/assets/{index-YrKmkw3o.css → index-By_h9DNJ.css} +1 -1
- package/public/assets/index-DsjjcQfd.js +1 -0
- package/public/assets/{loading-CuOFA7ML.js → loading-a39b5Opd.js} +1 -1
- package/public/assets/main-DyLBOo5S.js +190 -0
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- package/public/sw.js +1 -1
- package/dist/config/binaries.js +0 -148
- package/dist/config/store.js +0 -200
- package/dist/server/routes/config.js +0 -59
- package/public/assets/index-D0PYs_Ly.js +0 -1
- package/public/assets/main-EgCUCdV9.js +0 -190
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
4
|
+
import { applyMergePatch, isPlainObject } from "./merge-patch";
|
|
5
|
+
function ensureTrailingNewline(content) {
|
|
6
|
+
if (!content)
|
|
7
|
+
return "\n";
|
|
8
|
+
return content.endsWith("\n") ? content : `${content}\n`;
|
|
9
|
+
}
|
|
10
|
+
function normalizeDoc(input) {
|
|
11
|
+
if (!isPlainObject(input)) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return input;
|
|
15
|
+
}
|
|
16
|
+
export class YamlDocStore {
|
|
17
|
+
constructor(filePath, logger) {
|
|
18
|
+
this.filePath = filePath;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.cache = {};
|
|
21
|
+
this.loaded = false;
|
|
22
|
+
}
|
|
23
|
+
load() {
|
|
24
|
+
if (this.loaded) {
|
|
25
|
+
return this.cache;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
if (!fs.existsSync(this.filePath)) {
|
|
29
|
+
this.cache = {};
|
|
30
|
+
this.loaded = true;
|
|
31
|
+
return this.cache;
|
|
32
|
+
}
|
|
33
|
+
const content = fs.readFileSync(this.filePath, "utf-8");
|
|
34
|
+
const parsed = parseYaml(content);
|
|
35
|
+
this.cache = normalizeDoc(parsed);
|
|
36
|
+
this.loaded = true;
|
|
37
|
+
return this.cache;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
this.logger.warn({ err: error, filePath: this.filePath }, "Failed to read YAML doc; using empty object");
|
|
41
|
+
this.cache = {};
|
|
42
|
+
this.loaded = true;
|
|
43
|
+
return this.cache;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get() {
|
|
47
|
+
return this.load();
|
|
48
|
+
}
|
|
49
|
+
replace(next) {
|
|
50
|
+
const normalized = normalizeDoc(next);
|
|
51
|
+
this.cache = normalized;
|
|
52
|
+
this.loaded = true;
|
|
53
|
+
this.persist();
|
|
54
|
+
return this.cache;
|
|
55
|
+
}
|
|
56
|
+
mergePatch(patch) {
|
|
57
|
+
if (!isPlainObject(patch)) {
|
|
58
|
+
throw new Error("Patch must be a JSON object");
|
|
59
|
+
}
|
|
60
|
+
const current = this.get();
|
|
61
|
+
const next = applyMergePatch(current, patch);
|
|
62
|
+
return this.replace(next);
|
|
63
|
+
}
|
|
64
|
+
getOwner(owner) {
|
|
65
|
+
const doc = this.get();
|
|
66
|
+
const value = doc?.[owner];
|
|
67
|
+
return normalizeDoc(value);
|
|
68
|
+
}
|
|
69
|
+
replaceOwner(owner, value) {
|
|
70
|
+
const doc = this.get();
|
|
71
|
+
const nextDoc = { ...doc, [owner]: normalizeDoc(value) };
|
|
72
|
+
this.replace(nextDoc);
|
|
73
|
+
return nextDoc[owner];
|
|
74
|
+
}
|
|
75
|
+
mergePatchOwner(owner, patch) {
|
|
76
|
+
if (!isPlainObject(patch)) {
|
|
77
|
+
throw new Error("Patch must be a JSON object");
|
|
78
|
+
}
|
|
79
|
+
const doc = this.get();
|
|
80
|
+
const currentOwner = normalizeDoc(doc?.[owner]);
|
|
81
|
+
const nextOwner = normalizeDoc(applyMergePatch(currentOwner, patch));
|
|
82
|
+
const nextDoc = { ...doc, [owner]: nextOwner };
|
|
83
|
+
this.replace(nextDoc);
|
|
84
|
+
return nextOwner;
|
|
85
|
+
}
|
|
86
|
+
persist() {
|
|
87
|
+
try {
|
|
88
|
+
fs.mkdirSync(path.dirname(this.filePath), { recursive: true });
|
|
89
|
+
const yaml = stringifyYaml(this.cache);
|
|
90
|
+
fs.writeFileSync(this.filePath, ensureTrailingNewline(yaml), "utf-8");
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.logger.warn({ err: error, filePath: this.filePath }, "Failed to persist YAML doc");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -49,7 +49,7 @@ export class WorkspaceManager {
|
|
|
49
49
|
}
|
|
50
50
|
async create(folder, name) {
|
|
51
51
|
const id = `${Date.now().toString(36)}`;
|
|
52
|
-
const binary = this.options.
|
|
52
|
+
const binary = this.options.binaryResolver.resolveDefault();
|
|
53
53
|
const resolvedBinaryPath = this.resolveBinaryPath(binary.path);
|
|
54
54
|
const workspacePath = path.isAbsolute(folder) ? folder : path.resolve(this.options.rootDir, folder);
|
|
55
55
|
clearWorkspaceSearchCache(workspacePath);
|
|
@@ -72,8 +72,9 @@ export class WorkspaceManager {
|
|
|
72
72
|
}
|
|
73
73
|
this.workspaces.set(id, descriptor);
|
|
74
74
|
this.options.eventBus.publish({ type: "workspace.created", workspace: descriptor });
|
|
75
|
-
const
|
|
76
|
-
const
|
|
75
|
+
const serverConfig = this.options.settings.getOwner("config", "server");
|
|
76
|
+
const envVars = serverConfig?.environmentVariables;
|
|
77
|
+
const userEnvironment = envVars && typeof envVars === "object" && !Array.isArray(envVars) ? envVars : {};
|
|
77
78
|
const opencodeUsername = DEFAULT_OPENCODE_USERNAME;
|
|
78
79
|
const opencodePassword = generateOpencodeServerPassword();
|
|
79
80
|
const authorization = buildOpencodeBasicAuthHeader({ username: opencodeUsername, password: opencodePassword });
|