Skip to content

Commit 71847cb

Browse files
Merge branch 'main' into feature/support-deepseek
2 parents dbaac45 + bae4760 commit 71847cb

File tree

15 files changed

+887
-369
lines changed

15 files changed

+887
-369
lines changed

README.md

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,97 @@ https://marketplace.visualstudio.com/items?itemName=fiatinnovations.ola-code-bud
99

1010

1111
## Architecture
12-
1312
```mermaid
14-
graph TB
15-
subgraph VSCode["VS Code Extension"]
16-
Editor["Editor Interface"]
17-
Commands["Commands Layer"]
18-
Webview["Webview UI (React)"]
13+
flowchart TD
14+
15+
%% VS Code Extension Frontend
16+
subgraph "VS Code Extension Frontend"
17+
CE["Editor Interface"]:::frontend
18+
CL["Commands Layer"]:::frontend
19+
WV1["Webview (VS Code)"]:::frontend
20+
WV2["Webview (React UI)"]:::frontend
1921
end
2022
21-
subgraph Core["Core Application"]
22-
direction TB
23-
Agents["AI Agents Layer"]
24-
AppServices["Application Services"]
25-
Infrastructure["Infrastructure Layer"]
26-
Memory["Memory System"]
23+
%% Core Application Layer
24+
subgraph "Core Application"
25+
AA["AI Agents"]:::core
26+
MS["Memory System"]:::core
27+
subgraph "Application Services"
28+
BL["Business Logic"]:::core
29+
AI["Application Interfaces"]:::core
30+
end
31+
subgraph "Infrastructure Layer"
32+
HTTP["HTTP Services"]:::infra
33+
LOG["Logging"]:::infra
34+
REP["Repository"]:::infra
35+
LS["Local Storage"]:::infra
36+
end
2737
end
2838
29-
subgraph AIProviders["AI Providers"]
30-
Gemini["Gemini API"]
31-
Groq["Groq API"]
32-
Anthropic["Anthropic API"]
33-
XGrok["XGrok API"]
34-
Deepseek["Deepseel API"]
39+
%% AI Providers
40+
subgraph "AI Providers"
41+
LLM["Language Model Integrations"]:::provider
42+
ESP["External Service Providers"]:::provider
3543
end
3644
37-
subgraph Storage["Storage Layer"]
38-
SQLite["SQLite Database"]
39-
VectorDB["Vector Embeddings"]
40-
FileSystem["File System Service"]
45+
%% Storage Layer
46+
subgraph "Storage Layer"
47+
DB["Database (SQLite)"]:::storage
48+
FS["File System"]:::storage
49+
VD["Vector Database"]:::storage
4150
end
4251
43-
%% Main Flow Connections
44-
Editor -->|"User Input"| Commands
45-
Commands -->|"Process Request"| Agents
46-
Agents -->|"Context Management"| Memory
47-
Agents -->|"API Requests"| Infrastructure
48-
Infrastructure -->|"Model Selection"| AIProviders
49-
AppServices -->|"Data Access"| Storage
50-
Memory -->|"Store Context"| Storage
51-
Infrastructure -->|"Response"| Webview
52-
53-
%% Additional Connections
54-
Agents -->|"Business Logic"| AppServices
55-
Commands -->|"UI Updates"| Webview
56-
FileSystem -->|"Code Analysis"| Agents
57-
58-
59-
class VSCode vscode
60-
class Core core
61-
class AIProviders ai
62-
class Storage storage
52+
%% Connections between VS Code Extension Frontend
53+
CE -->|"UserInput"| CL
54+
CL -->|"ProcessRequest"| AA
55+
CL -->|"UIUpdate"| WV1
56+
57+
%% Connections within Core Application
58+
AA -->|"ContextManagement"| MS
59+
AA -->|"Orchestration"| BL
60+
AA -->|"ContractCall"| AI
61+
62+
%% Connections to Infrastructure
63+
AA -->|"APIRequest"| HTTP
64+
HTTP -->|"APICall"| LLM
65+
HTTP -->|"APICall"| ESP
66+
HTTP -->|"Feedback"| WV1
67+
68+
%% Connections from Application Services to Storage
69+
BL -->|"DataAccess"| DB
70+
BL -->|"FileAccess"| FS
71+
BL -->|"EmbedData"| VD
72+
AI -->|"RepositoryAccess"| REP
73+
74+
%% Memory System stores context to Storage
75+
MS -->|"StoreContext"| DB
76+
77+
%% Styling Classes
78+
classDef frontend fill:#cce5ff,stroke:#2a6592,stroke-width:2px;
79+
classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
80+
classDef infra fill:#f8d7da,stroke:#a71d2a,stroke-width:2px;
81+
classDef provider fill:#fff3cd,stroke:#856404,stroke-width:2px;
82+
classDef storage fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
83+
84+
%% Click Events
85+
click CE "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/extension.ts"
86+
click CL "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/commands"
87+
click WV1 "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/webview"
88+
click WV2 "https://github.com/olasunkanmi-se/codebuddy/tree/main/webviewUi"
89+
click AA "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/agents"
90+
click MS "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/memory"
91+
click BL "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/services"
92+
click AI "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/application"
93+
click HTTP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/http"
94+
click LOG "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/infrastructure/logger/logger.ts"
95+
click REP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/repository"
96+
click LS "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/infrastructure/storage/local-storage.ts"
97+
click LLM "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/llms"
98+
click ESP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/providers"
99+
click DB "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/repository"
100+
click FS "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/services/file-system.ts"
63101
```
102+
64103
### Database
65104
- SQLite database for code pattern storage
66105
- Vector embeddings for semantic code search

package.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@
7878
"command": "CodeBuddy.explain",
7979
"group": "CodeBuddy"
8080
},
81-
{
82-
"when": "editorHasSelection",
83-
"command": "CodeBuddy.sendChatMessage",
84-
"group": "CodeBuddy"
85-
},
86-
{
87-
"command": "CodeBuddy.savePattern",
88-
"group": "CodeBuddy"
89-
},
9081
{
9182
"when": "editorHasSelection",
9283
"command": "CodeBuddy.readFromKnowledgeBase",
@@ -134,18 +125,10 @@
134125
"command": "CodeBuddy.codeOptimize",
135126
"title": "CodeBuddy. Optimize these selected code."
136127
},
137-
{
138-
"command": "CodeBuddy.sendChatMessage",
139-
"title": "Send to CodeBuddy"
140-
},
141128
{
142129
"command": "CodeBuddy.explain",
143130
"title": "CodeBuddy. Explain this code"
144131
},
145-
{
146-
"command": "CodeBuddy.savePattern",
147-
"title": "CodeBuddy. Save this code pattern"
148-
},
149132
{
150133
"command": "CodeBuddy.readFromKnowledgeBase",
151134
"title": "CodeBuddy. Generate based on knowledgeBase"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { UUID } from "crypto";
2+
3+
export interface IWorkspaceService {
4+
getWorkspaceFiles(rootPath: string): Promise<Record<string, string>>;
5+
getActiveFileContent(): string | undefined;
6+
getContextInfo(useWorkspaceContext: boolean): Promise<IContextInfo>;
7+
}
8+
9+
export interface IContextInfo {
10+
activeFileContent?: string;
11+
workspaceFiles?: Map<string, FolderEntry[]>;
12+
openFiles: IOpenFiles[];
13+
}
14+
15+
export interface IOpenFiles {
16+
path: string;
17+
language: string;
18+
}
19+
20+
export interface FolderEntry {
21+
id: UUID;
22+
type: "folder";
23+
name: string;
24+
children: (FolderEntry | FileEntry)[];
25+
}
26+
27+
export interface FileEntry {
28+
id: UUID;
29+
type: "file";
30+
name: string;
31+
}

src/extension.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as path from "path";
12
import * as vscode from "vscode";
23
import {
34
APP_CONFIG,
@@ -18,6 +19,7 @@ import { OptimizeCode } from "./commands/optimize";
1819
import { RefactorCode } from "./commands/refactor";
1920
import { ReviewCode } from "./commands/review";
2021
import { EventEmitter } from "./emitter/agent-emitter";
22+
import { Logger } from "./infrastructure/logger/logger";
2123
import { dbManager } from "./infrastructure/repository/data-base-manager";
2224
import { Memory } from "./memory/base";
2325
import { AnthropicWebViewProvider } from "./providers/anthropic";
@@ -43,40 +45,48 @@ const {
4345
deepseekModel,
4446
} = APP_CONFIG;
4547

46-
const connectDB = async () => {
47-
await dbManager.connect(
48-
"file:/Users/olasunkanmi/Documents/Github/codebuddy/patterns/dev.db",
49-
);
50-
};
48+
const logger = new Logger("extension");
5149

5250
let quickFixCodeAction: vscode.Disposable;
5351
let agentEventEmmitter: EventEmitter;
5452

53+
async function connectToDatabase() {
54+
try {
55+
const dbPath = path.join(__dirname, "..", "patterns", "dev.db");
56+
const urlPath = dbPath.replace(/\\/g, "/");
57+
const isWindows = dbPath.includes("\\");
58+
const filePath = isWindows ? `file:/${urlPath}` : `file:${urlPath}`;
59+
await dbManager.connect(filePath);
60+
} catch (error: any) {
61+
logger.error("Unable to connect to DB", error);
62+
throw new Error(error);
63+
}
64+
}
65+
66+
async function createFileDB(context: vscode.ExtensionContext) {
67+
try {
68+
const fileUploader = new FileUploader(context);
69+
const files = await fileUploader.getFiles();
70+
if (!files?.find((file) => file.includes("dev.db"))) {
71+
await fileUploader.createFile("dev.db");
72+
}
73+
} catch (error: any) {
74+
logger.error("Unable to ", error);
75+
throw new Error(error);
76+
}
77+
}
78+
5579
export async function activate(context: vscode.ExtensionContext) {
5680
try {
81+
await createFileDB(context);
82+
await connectToDatabase();
5783
const credentials = new Credentials();
5884
await credentials.initialize(context);
5985
const session: vscode.AuthenticationSession | undefined =
6086
await credentials.getSession();
61-
vscode.window.showInformationMessage(
62-
`Logged into GitHub as ${session?.account.label}`,
63-
);
87+
logger.info(`Logged into GitHub as ${session?.account.label}`);
6488
Memory.getInstance();
65-
await connectDB();
66-
// const web = WebSearchService.getInstance();
67-
// const x = CodeRepository.getInstance();
68-
// const apiKey = getGeminiAPIKey();
69-
// const embeddingService = new EmbeddingService(apiKey);
70-
// const embedding = await embeddingService.generateEmbedding("is jwt web token used withnin this app ?");
71-
// const y = await x.searchSimilarFunctions(embedding, 2);
72-
// console.log(y);
7389
const fileUpload = new FileUploader(context);
74-
// await fileUpload.createFile("aiix.db");
75-
76-
// const files = await fileUpload.getFiles();
77-
// const names = await fileUpload.getFileNames();
78-
// console.log(files, names);
79-
8090
// const index = CodeIndexingService.createInstance();
8191
// Get each of the folders and call the next line for each
8292
// const result = await index.buildFunctionStructureMap();

0 commit comments

Comments
 (0)