@code-rag/core 0.1.5 → 0.1.7
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/dist/config/config-parser.js +27 -0
- package/package.json +1 -1
|
@@ -249,6 +249,21 @@ function applyDefaults(partial) {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
// --- Main ---
|
|
252
|
+
/** Deep-merge source into target (source wins). Arrays are replaced, not concatenated. */
|
|
253
|
+
function deepMerge(target, source) {
|
|
254
|
+
const result = { ...target };
|
|
255
|
+
for (const key of Object.keys(source)) {
|
|
256
|
+
const sv = source[key];
|
|
257
|
+
const tv = target[key];
|
|
258
|
+
if (sv !== null && typeof sv === 'object' && !Array.isArray(sv) && tv !== null && typeof tv === 'object' && !Array.isArray(tv)) {
|
|
259
|
+
result[key] = deepMerge(tv, sv);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
result[key] = sv;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
252
267
|
export async function loadConfig(rootDir) {
|
|
253
268
|
const configPath = join(rootDir, '.coderag.yaml');
|
|
254
269
|
let content;
|
|
@@ -269,6 +284,18 @@ export async function loadConfig(rootDir) {
|
|
|
269
284
|
if (parsed === null || parsed === undefined || typeof parsed !== 'object') {
|
|
270
285
|
return err(new ConfigError('Config file is empty or not a valid YAML object'));
|
|
271
286
|
}
|
|
287
|
+
// Merge .coderag.local.yaml overrides if present (gitignored, for private settings)
|
|
288
|
+
const localPath = join(rootDir, '.coderag.local.yaml');
|
|
289
|
+
try {
|
|
290
|
+
const localContent = await readFile(localPath, 'utf-8');
|
|
291
|
+
const localParsed = parse(localContent);
|
|
292
|
+
if (localParsed !== null && localParsed !== undefined && typeof localParsed === 'object') {
|
|
293
|
+
parsed = deepMerge(parsed, localParsed);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
// No local overrides — that's fine
|
|
298
|
+
}
|
|
272
299
|
// Interpolate environment variables (e.g., ${ADO_PAT} → process.env.ADO_PAT)
|
|
273
300
|
const interpolated = interpolateEnvVars(parsed);
|
|
274
301
|
if (interpolated instanceof ConfigError) {
|
package/package.json
CHANGED