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

Method remove

src/CodeIndex.ts:325–352  ·  view source on GitHub ↗

* Removes sources and extensions from the index. * @param config The configuration containing the sources and extensions to remove.

(config: Partial<CodeIndexConfig>)

Source from the content-addressed store, hash-verified

323 * @param config The configuration containing the sources and extensions to remove.
324 */
325 public async remove(config: Partial<CodeIndexConfig>): Promise<void> {
326 if (!await this.isCreated()) {
327 throw new Error('Index has not been created yet. Please run `codepilot create` first.');
328 }
329
330 // Ensure config loaded
331 const configPath = path.join(this.folderPath, 'config.json');
332 if (!this._config) {
333 this._config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
334 }
335
336 // Clone config
337 const newConfig = Object.assign({}, this._config);
338
339 // Remove sources
340 if (Array.isArray(config.sources)) {
341 newConfig.sources = newConfig.sources.filter(source => !config.sources!.includes(source));
342 }
343
344 // Remove extensions
345 if (Array.isArray(config.extensions)) {
346 newConfig.extensions = newConfig.extensions?.filter(extension => !config.extensions!.includes(extension));
347 }
348
349 // Write config
350 await fs.writeFile(configPath, JSON.stringify(newConfig));
351 this._config = newConfig;
352 }
353
354 // LLM-REGION
355

Callers 1

runFunction · 0.95

Calls 1

isCreatedMethod · 0.95

Tested by

no test coverage detected