Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ samples
patterns
.codebuddy
scripts
lancedb
156 changes: 156 additions & 0 deletions docs/COMMAND_REGISTRATION_FIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Fix: Command 'codebuddy.vectorDb.showStats' Not Found

## 🐞 **Problem**

When clicking on the "CodeBuddy Vector DB" status bar item, users got the error:

```
command 'codebuddy.vectorDb.showStats' not found
```

## 🎯 **Root Cause**

The vector database commands were registered in the extension code but were **not declared** in the `package.json` file's `contributes.commands` section. VS Code requires all commands to be declared in the manifest before they can be used.

### **What Was Missing:**

```json
// package.json was missing these command declarations:
{
"contributes": {
"commands": [
// ❌ Missing vector database commands
]
}
}
```

### **What Was Present:**

```typescript
// extension.ts - Commands were registered in code ✅
const showStatsCommand = vscode.commands.registerCommand("codebuddy.vectorDb.showStats", async () => {
/* ... */
});
```

## ✅ **Solution**

Added all missing vector database command declarations to `package.json`:

```json
{
"contributes": {
"commands": [
// ... existing commands ...
{
"command": "codebuddy.vectorDb.showStats",
"title": "CodeBuddy: Show Vector Database Statistics"
},
{
"command": "codebuddy.vectorDb.forceReindex",
"title": "CodeBuddy: Force Full Reindex"
},
{
"command": "codebuddy.showIndexingStatus",
"title": "CodeBuddy: Show Indexing Status"
},
{
"command": "codebuddy.vectorDb.diagnostic",
"title": "CodeBuddy: Vector Database Diagnostic"
},
{
"command": "codebuddy.showPerformanceReport",
"title": "CodeBuddy: Show Performance Report"
},
{
"command": "codebuddy.clearVectorCache",
"title": "CodeBuddy: Clear Vector Cache"
},
{
"command": "codebuddy.reduceBatchSize",
"title": "CodeBuddy: Reduce Batch Size"
},
{
"command": "codebuddy.pauseIndexing",
"title": "CodeBuddy: Pause Indexing"
},
{
"command": "codebuddy.resumeIndexing",
"title": "CodeBuddy: Resume Indexing"
},
{
"command": "codebuddy.restartVectorWorker",
"title": "CodeBuddy: Restart Vector Worker"
},
{
"command": "codebuddy.emergencyStop",
"title": "CodeBuddy: Emergency Stop"
},
{
"command": "codebuddy.resumeFromEmergencyStop",
"title": "CodeBuddy: Resume From Emergency Stop"
},
{
"command": "codebuddy.optimizePerformance",
"title": "CodeBuddy: Optimize Performance"
}
]
}
}
```

## 🔧 **Technical Details**

### **VS Code Command System:**

1. **Declaration Required**: All commands must be declared in `package.json`
2. **Registration Required**: Commands must be registered in extension code
3. **Both Required**: VS Code needs both declaration AND registration to work

### **Command Flow:**

```
package.json declares → VS Code recognizes → Extension registers → Command works
✅ FIXED ✅ NOW WORKS ✅ ALREADY OK ✅ SUCCESS
```

### **Previous State:**

```
package.json declares → VS Code recognizes → Extension registers → Command works
❌ MISSING ❌ NOT FOUND ✅ ALREADY OK ❌ FAILED
```

## 🎉 **Result**

### **Before Fix:**

- ❌ Clicking "CodeBuddy Vector DB" shows "command not found" error
- ❌ All vector database commands inaccessible via Command Palette
- ❌ Status bar integration broken
- ❌ User feedback service couldn't show statistics

### **After Fix:**

- ✅ Clicking "CodeBuddy Vector DB" shows database statistics
- ✅ All vector database commands available in Command Palette
- ✅ Status bar integration working correctly
- ✅ Proper user feedback and statistics display

### **Commands Now Working:**

- **codebuddy.vectorDb.showStats** - Shows vector database statistics
- **codebuddy.vectorDb.forceReindex** - Forces full workspace reindex
- **codebuddy.showIndexingStatus** - Shows current indexing progress
- **codebuddy.vectorDb.diagnostic** - Runs vector database diagnostic
- **All performance/production commands** - Cache management, batch size control, etc.

## 📚 **Lesson Learned**

Always ensure VS Code extension commands are declared in BOTH places:

1. **package.json** (`contributes.commands`) - For VS Code to recognize them
2. **extension.ts** (`vscode.commands.registerCommand`) - For functionality

Missing either one will cause the command to fail! 🚀
Loading