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

Method upsertDocument

src/CodeIndex.ts:413–431  ·  view source on GitHub ↗

* Adds a document to the index. * @param path Path to the document to add.

(path: string)

Source from the content-addressed store, hash-verified

411 * @param path Path to the document to add.
412 */
413 public async upsertDocument(path: string): Promise<void> {
414 if (!await this.isCreated()) {
415 throw new Error('Index has not been created yet. Please run `codepilot create` first.');
416 }
417 if (!await this.hasKeys()) {
418 throw new Error("A local vectra.keys file couldn't be found. Please run `codepilot set --key <your OpenAI key>`.");
419 }
420
421 // Ensure index is loaded
422 const index = await this.load();
423
424 // Fetch document
425 const fetcher = new FileFetcher();
426 await fetcher.fetch(path, async (uri, text, docType) => {
427 // Upsert document
428 await index.upsertDocument(uri, text, docType);
429 return true;
430 });
431 }
432}

Callers 2

rebuildMethod · 0.45
addCreateFileFunction · 0.45

Calls 3

isCreatedMethod · 0.95
hasKeysMethod · 0.95
loadMethod · 0.95

Tested by

no test coverage detected