@@ -14,7 +14,6 @@ import { GenerateCommitMessage } from "./commands/generate-commit-message";
1414import { GenerateUnitTest } from "./commands/generate-unit-test" ;
1515import { InLineChat } from "./commands/inline-chat" ;
1616import { InterviewMe } from "./commands/interview-me" ;
17- import { ReadFromKnowledgeBase } from "./commands/knowledge-base" ;
1817import { OptimizeCode } from "./commands/optimize" ;
1918import { RefactorCode } from "./commands/refactor" ;
2019import { ReviewCode } from "./commands/review" ;
@@ -30,7 +29,9 @@ import { GroqWebViewProvider } from "./providers/groq";
3029import { FileManager } from "./services/file-manager" ;
3130import { initializeGenerativeAiEnvironment } from "./services/generative-ai-model-manager" ;
3231import { Credentials } from "./services/github-authentication" ;
33- import { getConfigValue } from "./utils/utils" ;
32+ import { getAPIKey , getConfigValue } from "./utils/utils" ;
33+ import { FileUploadAgent } from "./agents/file-upload" ;
34+ import * as fs from "fs" ;
3435
3536const {
3637 geminiKey,
@@ -50,9 +51,13 @@ const logger = new Logger("extension");
5051let quickFixCodeAction : vscode . Disposable ;
5152let agentEventEmmitter : EventEmitter ;
5253
53- async function connectToDatabase ( ) {
54+ async function connectToDatabase ( context : vscode . ExtensionContext ) {
5455 try {
55- const dbPath = path . join ( __dirname , ".." , "patterns" , "aii.db" ) ;
56+ const dbDir = path . join ( context . extensionPath , "database" ) ;
57+ if ( ! fs . existsSync ( dbDir ) ) {
58+ fs . mkdirSync ( dbDir ) ;
59+ }
60+ const dbPath = path . join ( __dirname , ".." , "database" , "aii.db" ) ;
5661 const urlPath = dbPath . replace ( / \\ / g, "/" ) ;
5762 const isWindows = dbPath . includes ( "\\" ) ;
5863 const filePath = isWindows ? `file:/${ urlPath } ` : `file:${ urlPath } ` ;
@@ -65,7 +70,7 @@ async function connectToDatabase() {
6570
6671async function createFileDB ( context : vscode . ExtensionContext ) {
6772 try {
68- const fileUploader = new FileManager ( context ) ;
73+ const fileUploader = new FileManager ( context , "database" ) ;
6974 const files = await fileUploader . getFiles ( ) ;
7075 if ( ! files ?. find ( ( file ) => file . includes ( "dev.db" ) ) ) {
7176 await fileUploader . createFile ( "dev.db" ) ;
@@ -79,14 +84,16 @@ async function createFileDB(context: vscode.ExtensionContext) {
7984export async function activate ( context : vscode . ExtensionContext ) {
8085 try {
8186 await createFileDB ( context ) ;
82- await connectToDatabase ( ) ;
87+ await connectToDatabase ( context ) ;
8388 const credentials = new Credentials ( ) ;
89+ const geminiApiKey = getAPIKey ( "gemini" ) ;
90+ FileUploadAgent . initialize ( geminiApiKey ) ;
8491 await credentials . initialize ( context ) ;
8592 const session : vscode . AuthenticationSession | undefined =
8693 await credentials . getSession ( ) ;
8794 logger . info ( `Logged into GitHub as ${ session ?. account . label } ` ) ;
8895 Memory . getInstance ( ) ;
89- const fileUpload = new FileManager ( context ) ;
96+
9097 // TODO This is broken. Need to Fix
9198 // const index = CodeIndexingService.createInstance();
9299 // Get each of the folders and call the next line for each
@@ -136,11 +143,6 @@ export async function activate(context: vscode.ExtensionContext) {
136143 `${ USER_MESSAGE } creates the code chart...` ,
137144 context ,
138145 ) ;
139- const codePattern = fileUpload ;
140- const knowledgeBase = new ReadFromKnowledgeBase (
141- `${ USER_MESSAGE } generate your code pattern...` ,
142- context ,
143- ) ;
144146 const generateCommitMessage = new GenerateCommitMessage (
145147 `${ USER_MESSAGE } generates a commit message...` ,
146148 context ,
@@ -169,8 +171,6 @@ export async function activate(context: vscode.ExtensionContext) {
169171 errorMessage ,
170172 ) . execute ( errorMessage ) ,
171173 [ explain ] : async ( ) => await explainCode . execute ( ) ,
172- [ pattern ] : async ( ) => await codePattern . uploadFileHandler ( ) ,
173- [ knowledge ] : async ( ) => await knowledgeBase . execute ( ) ,
174174 [ commitMessage ] : async ( ) =>
175175 await generateCommitMessage . execute ( "commitMessage" ) ,
176176 [ generateCodeChart ] : async ( ) => await codeChartGenerator . execute ( ) ,
0 commit comments