MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / loadConfig

Function loadConfig

src/config/loader.ts:81–116  ·  view source on GitHub ↗
(cwd: string = process.cwd())

Source from the content-addressed store, hash-verified

79}
80
81export async function loadConfig(cwd: string = process.cwd()): Promise<QodexConfig> {
82 await ensureQodexHome();
83
84 let config = { ...DEFAULT_CONFIG };
85
86 // User-level config
87 try {
88 const userYaml = await fs.readFile(QODEX_CONFIG_FILE, 'utf-8');
89 const userCfg = yaml.load(userYaml);
90 if (isMergeableConfig(userCfg)) config = deepMerge(config, userCfg);
91 else if (userCfg != null) {
92 logger.warn('Ignoring user config: top-level value is not a mapping', { file: QODEX_CONFIG_FILE, got: Array.isArray(userCfg) ? 'array' : typeof userCfg });
93 }
94 } catch (err: any) {
95 if (err.code !== 'ENOENT') {
96 logger.warn('Failed to load user config', { err: err.message });
97 }
98 }
99
100 // Project-level config
101 const projectConfig = path.join(cwd, '.qodex', 'config.yaml');
102 try {
103 const projectYaml = await fs.readFile(projectConfig, 'utf-8');
104 const projCfg = yaml.load(projectYaml);
105 if (isMergeableConfig(projCfg)) config = deepMerge(config, projCfg);
106 else if (projCfg != null) {
107 logger.warn('Ignoring project config: top-level value is not a mapping', { file: projectConfig, got: Array.isArray(projCfg) ? 'array' : typeof projCfg });
108 }
109 } catch (err: any) {
110 if (err.code !== 'ENOENT') {
111 logger.warn('Failed to load project config', { err: err.message });
112 }
113 }
114
115 return config;
116}
117
118export async function saveUserConfig(config: Partial<QodexConfig>): Promise<void> {
119 await ensureQodexHome();

Callers 10

bootstrapFunction · 0.85
index.tsFile · 0.85
writeConfigFunction · 0.85
gatherDashboardDataFunction · 0.85
buildSkillCommandFunction · 0.85
dispatchActionFunction · 0.85
curateCandidatesFunction · 0.85
evalSkillMdFunction · 0.85

Calls 5

ensureQodexHomeFunction · 0.85
isMergeableConfigFunction · 0.85
loadMethod · 0.80
warnMethod · 0.80
deepMergeFunction · 0.70

Tested by

no test coverage detected