MCPcopy Index your code
hub / github.com/continuedev/continue / generate

Method generate

core/util/generateRepoMap.ts:52–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50 }
51
52 async generate(): Promise<string> {
53 this.dirs = this.options.dirUris ?? (await this.ide.getWorkspaceDirs());
54 this.allUris = await walkDirs(
55 this.ide,
56 {
57 source: "generate repo map",
58 },
59 this.dirs,
60 );
61
62 // Initialize
63 await this.writeToStream(this.PREAMBLE);
64
65 if (this.options.includeSignatures) {
66 // Process uris and signatures
67 let snippetOffset = 0;
68 let uriOffset = 0;
69 while (true) {
70 const { groupedByUri, hasMoreSnippets, hasMoreUris } =
71 await CodeSnippetsCodebaseIndex.getPathsAndSignatures(
72 this.allUris,
73 uriOffset,
74 this.URI_BATCH_SIZE,
75 snippetOffset,
76 this.SNIPPETS_BATCH_SIZE,
77 );
78 // process batch
79 for (const [uri, signatures] of Object.entries(groupedByUri)) {
80 let fileContent: string;
81
82 try {
83 fileContent = await this.ide.readFile(uri);
84 } catch (err) {
85 console.error(
86 "Failed to read file:\n" +
87 ` Uri: ${uri}\n` +
88 ` Error: ${err instanceof Error ? err.message : String(err)}`,
89 );
90
91 continue;
92 }
93
94 const filteredSignatures = signatures.filter(
95 (signature) => signature.trim() !== fileContent.trim(),
96 );
97
98 if (filteredSignatures.length > 0) {
99 this.pathsInDirsWithSnippets.add(uri);
100 }
101
102 let content = `${this.getUriForWrite(uri)}:\n`;
103
104 for (const signature of signatures.slice(0, -1)) {
105 content += `${this.indentMultilineString(signature)}\n\t...\n`;
106 }
107
108 content += `${this.indentMultilineString(
109 signatures[signatures.length - 1],

Callers 1

generateRepoMapFunction · 0.95

Calls 10

writeToStreamMethod · 0.95
getUriForWriteMethod · 0.95
indentMultilineStringMethod · 0.95
walkDirsFunction · 0.90
getPathsAndSignaturesMethod · 0.80
errorMethod · 0.80
getWorkspaceDirsMethod · 0.65
readFileMethod · 0.65
addMethod · 0.65
debugMethod · 0.45

Tested by

no test coverage detected