MCPcopy Create free account
hub / github.com/Stevenic/codepilot / setConfig

Method setConfig

src/CodeIndex.ts:374–405  ·  view source on GitHub ↗

* Updates the code index configuration. * @param config Settings to update.

(config: Partial<CodeIndexConfig>)

Source from the content-addressed store, hash-verified

372 * @param config Settings to update.
373 */
374 public async setConfig(config: Partial<CodeIndexConfig>): Promise<void> {
375 if (!await this.isCreated()) {
376 throw new Error('Index has not been created yet. Please run `codepilot create` first.');
377 }
378
379 // Ensure config loaded
380 const configPath = path.join(this.folderPath, 'config.json');
381 if (!this._config) {
382 this._config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
383 }
384
385 // Clone config
386 const newConfig = Object.assign({}, this._config);
387
388 // Apply changes
389 if (config.model !== undefined) {
390 newConfig.model = config.model;
391 }
392 if (config.max_input_tokens !== undefined) {
393 newConfig.max_input_tokens = config.max_input_tokens;
394 }
395 if (config.max_tokens !== undefined) {
396 newConfig.max_tokens = config.max_tokens;
397 }
398 if (config.temperature !== undefined) {
399 newConfig.temperature = config.temperature;
400 }
401
402 // Write config
403 await fs.writeFile(configPath, JSON.stringify(newConfig));
404 this._config = newConfig;
405 }
406
407 // LLM-REGION
408

Callers 1

runFunction · 0.95

Calls 1

isCreatedMethod · 0.95

Tested by

no test coverage detected