From 3232af0877ad3f249395e895c1b3c62007bd4ba3 Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Wed, 12 Feb 2025 10:16:40 +0100 Subject: [PATCH] moved to copyfoldertojson --- .../src/agents/completionAgent.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/remix-ai-core/src/agents/completionAgent.ts b/libs/remix-ai-core/src/agents/completionAgent.ts index bc9a499eff..d0df5b1bcf 100644 --- a/libs/remix-ai-core/src/agents/completionAgent.ts +++ b/libs/remix-ai-core/src/agents/completionAgent.ts @@ -55,24 +55,23 @@ export class CodeCompletionAgent { } async getDcocuments() { - const documents: Document[] = []; - const dirs = await this.props.call('fileManager', 'dirList', '/'); - let c = 0; - for (const dir of dirs) { - const files = await this.props.call('fileManager', 'fileList', dir); - for (const file of files) { - const content = await this.props.call('fileManager', 'readFile', file); - // filter out any SupportedFileExtensions - if (! Object.values(SupportedFileExtensions).some(ext => file.endsWith(ext))) continue; + try { + const documents: Document[] = []; + const jsonDirsContracts = await this.props.call('fileManager', 'copyFolderToJson', '/').then((res) => res.contracts); + let c = 0; + for (const file in jsonDirsContracts.children) { + if (!Object.values(SupportedFileExtensions).some(ext => file.endsWith(ext))) continue; documents.push({ id: ++c, filename: file, - content: content, - identifier: c-1, + content: jsonDirsContracts.children[file].content, + identifier: c - 1, }); } + return documents; + } catch (error) { + return []; } - return documents; } indexWorkspace() { @@ -98,6 +97,7 @@ export class CodeCompletionAgent { if (!this.indexed.isIndexed) { await this.indexWorkspace(); } + const currentFile = await this.props.call('fileManager', 'getCurrentFile'); const content = prompt; const searchResult = this.indexer.search(content)