smart-coding-mcp 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -9
- package/docs/ide-setup/antigravity.md +109 -0
- package/docs/ide-setup/claude-desktop.md +88 -0
- package/docs/ide-setup/cursor.md +93 -0
- package/docs/ide-setup/raycast.md +90 -0
- package/docs/ide-setup/vscode.md +116 -0
- package/docs/ide-setup/windsurf.md +95 -0
- package/features/index-codebase.js +6 -4
- package/lib/cache.js +8 -0
- package/lib/sqlite-cache.js +8 -0
- package/package.json +2 -2
- package/test/better-sqlite3.test.js +153 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
|
|
8
|
-
An extensible Model Context Protocol (MCP) server that provides intelligent semantic code search for AI assistants. Built with local AI models using Matryoshka Representation Learning (MRL) for flexible embedding dimensions (64-768d
|
|
8
|
+
An extensible Model Context Protocol (MCP) server that provides intelligent semantic code search for AI assistants. Built with local AI models using Matryoshka Representation Learning (MRL) for flexible embedding dimensions (64-768d.
|
|
9
9
|
|
|
10
10
|
### Available Tools
|
|
11
11
|
|
|
@@ -90,15 +90,27 @@ npm update -g smart-coding-mcp
|
|
|
90
90
|
|
|
91
91
|
## Configuration
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
## IDE Integration
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
| **
|
|
100
|
-
| **
|
|
101
|
-
| **
|
|
95
|
+
Detailed setup instructions for your preferred environment:
|
|
96
|
+
|
|
97
|
+
| IDE / App | Setup Guide | Supported Variables |
|
|
98
|
+
| ------------------ | -------------------------------------------------- | -------------------- |
|
|
99
|
+
| **VS Code** | [**View Guide**](docs/ide-setup/vscode.md) | `${workspaceFolder}` |
|
|
100
|
+
| **Cursor** | [**View Guide**](docs/ide-setup/cursor.md) | `${workspaceFolder}` |
|
|
101
|
+
| **Windsurf** | [**View Guide**](docs/ide-setup/windsurf.md) | Absolute paths only |
|
|
102
|
+
| **Claude Desktop** | [**View Guide**](docs/ide-setup/claude-desktop.md) | Absolute paths only |
|
|
103
|
+
| **Raycast** | [**View Guide**](docs/ide-setup/raycast.md) | Absolute paths only |
|
|
104
|
+
| **Antigravity** | [**View Guide**](docs/ide-setup/antigravity.md) | Absolute paths only |
|
|
105
|
+
|
|
106
|
+
### Common Configuration Paths
|
|
107
|
+
|
|
108
|
+
| IDE | OS | Config Path |
|
|
109
|
+
| ------------------ | ------- | ----------------------------------------------------------------- |
|
|
110
|
+
| **Claude Desktop** | macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
111
|
+
| **Claude Desktop** | Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
112
|
+
| **Windsurf** | macOS | `~/.codeium/windsurf/mcp_config.json` |
|
|
113
|
+
| **Windsurf** | Windows | `%USERPROFILE%\.codeium\windsurf\mcp_config.json` |
|
|
102
114
|
|
|
103
115
|
Add the server configuration to the `mcpServers` object in your config file:
|
|
104
116
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Antigravity (Gemini IDE) Integration
|
|
2
|
+
|
|
3
|
+
Antigravity is Google's AI-powered IDE built on VS Code with deep Gemini integration.
|
|
4
|
+
|
|
5
|
+
## MCP Configuration
|
|
6
|
+
|
|
7
|
+
Edit your MCP config file:
|
|
8
|
+
|
|
9
|
+
- **macOS:** `~/.gemini/antigravity/mcp_config.json`
|
|
10
|
+
- **Windows:** `%USERPROFILE%\.gemini\antigravity\mcp_config.json`
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"mcpServers": {
|
|
15
|
+
"smart-coding-mcp": {
|
|
16
|
+
"command": "npx",
|
|
17
|
+
"args": [
|
|
18
|
+
"-y",
|
|
19
|
+
"smart-coding-mcp",
|
|
20
|
+
"--workspace",
|
|
21
|
+
"/absolute/path/to/project"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> **Note:** Antigravity does **NOT** support `${workspaceFolder}`. You must use absolute paths.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Configuring Agent Rules
|
|
33
|
+
|
|
34
|
+
Antigravity supports powerful agent rules to control AI behavior.
|
|
35
|
+
|
|
36
|
+
### Rule Locations
|
|
37
|
+
|
|
38
|
+
| Scope | Location |
|
|
39
|
+
| ------------------- | ----------------------------------------- |
|
|
40
|
+
| **Global** | `~/.gemini/GEMINI.md` |
|
|
41
|
+
| **Workspace** | `.agent/rules/*.md` |
|
|
42
|
+
| **Project Context** | `GEMINI.md` or `AGENT.md` at project root |
|
|
43
|
+
|
|
44
|
+
### Creating a Rule to Use Smart Coding MCP
|
|
45
|
+
|
|
46
|
+
1. **Create the rules directory** in your project:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
mkdir -p .agent/rules
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. **Create a rule file** `.agent/rules/smart-mcp.md`:
|
|
53
|
+
|
|
54
|
+
```markdown
|
|
55
|
+
---
|
|
56
|
+
trigger: always_on
|
|
57
|
+
description: Mandatory usage of Smart Coding MCP tools for dependencies and search
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
# Smart Coding MCP Usage Rules
|
|
61
|
+
|
|
62
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
63
|
+
|
|
64
|
+
## 1. Dependency Management
|
|
65
|
+
|
|
66
|
+
**Trigger:** When checking, adding, or updating package versions (npm, python, go, rust, etc.).
|
|
67
|
+
**Action:**
|
|
68
|
+
|
|
69
|
+
- **MUST** use the `d_check_last_version` tool.
|
|
70
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
71
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
72
|
+
|
|
73
|
+
## 2. Codebase Research
|
|
74
|
+
|
|
75
|
+
**Trigger:** When asking about "how" something works, finding logic, or understanding architecture.
|
|
76
|
+
**Action:**
|
|
77
|
+
|
|
78
|
+
- **PREFER** `a_semantic_search` (Smart Coding) over `grep_search` or `find_by_name`.
|
|
79
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
80
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
81
|
+
|
|
82
|
+
## 3. Environment & Status
|
|
83
|
+
|
|
84
|
+
**Trigger:** When starting a session or debugging the environment.
|
|
85
|
+
**Action:**
|
|
86
|
+
|
|
87
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
88
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Activation Modes
|
|
92
|
+
|
|
93
|
+
| Mode | Description |
|
|
94
|
+
| ---------------- | ---------------------------------- |
|
|
95
|
+
| `always_on` | Rule is always applied |
|
|
96
|
+
| `manual` | Activated when mentioned in prompt |
|
|
97
|
+
| `model_decision` | AI decides based on description |
|
|
98
|
+
| `glob` | Applied to matching file patterns |
|
|
99
|
+
|
|
100
|
+
### Global Rules
|
|
101
|
+
|
|
102
|
+
For rules that apply to all projects, edit `~/.gemini/GEMINI.md`:
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
# Global Agent Rules
|
|
106
|
+
|
|
107
|
+
- Always verify package versions before installing
|
|
108
|
+
- Prefer semantic search when available
|
|
109
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Claude Desktop Integration
|
|
2
|
+
|
|
3
|
+
The official Claude Desktop app is the reference implementation for MCP.
|
|
4
|
+
|
|
5
|
+
## Configuration Location
|
|
6
|
+
|
|
7
|
+
Edit the configuration file located at:
|
|
8
|
+
|
|
9
|
+
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
10
|
+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
Open the file in any text editor (VS Code, TextEdit, Notepad) and add the server:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"smart-coding-mcp": {
|
|
20
|
+
"command": "npx",
|
|
21
|
+
"args": [
|
|
22
|
+
"-y",
|
|
23
|
+
"smart-coding-mcp",
|
|
24
|
+
"--workspace",
|
|
25
|
+
"/absolute/path/to/your/project"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> **Important:** Claude Desktop does **NOT** support `${workspaceFolder}`. You must provide the absolute path to the directory you want to index.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Configuring Rules (Project Instructions)
|
|
37
|
+
|
|
38
|
+
Claude Desktop uses **Projects** with custom instructions.
|
|
39
|
+
|
|
40
|
+
### Creating Project Instructions
|
|
41
|
+
|
|
42
|
+
1. **Create a new Project** in Claude Desktop
|
|
43
|
+
2. Click **"Set project instructions"**
|
|
44
|
+
3. Add your guidelines:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
# Smart Coding MCP Usage Rules
|
|
48
|
+
|
|
49
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
50
|
+
|
|
51
|
+
## 1. Dependency Management
|
|
52
|
+
|
|
53
|
+
**Trigger:** When checking, adding, or updating package versions (npm, python, go, rust, etc.).
|
|
54
|
+
**Action:**
|
|
55
|
+
|
|
56
|
+
- **MUST** use the `d_check_last_version` tool.
|
|
57
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
58
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
59
|
+
|
|
60
|
+
## 2. Codebase Research
|
|
61
|
+
|
|
62
|
+
**Trigger:** When asking about "how" something works, finding logic, or understanding architecture.
|
|
63
|
+
**Action:**
|
|
64
|
+
|
|
65
|
+
- **PREFER** `a_semantic_search` (Smart Coding) over `grep_search` or `find_by_name`.
|
|
66
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
67
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
68
|
+
|
|
69
|
+
## 3. Environment & Status
|
|
70
|
+
|
|
71
|
+
**Trigger:** When starting a session or debugging the environment.
|
|
72
|
+
**Action:**
|
|
73
|
+
|
|
74
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
75
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
4. Click **"Save instructions"**
|
|
79
|
+
|
|
80
|
+
These instructions apply to all chats within that project.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Verification
|
|
85
|
+
|
|
86
|
+
1. Restart Claude Desktop.
|
|
87
|
+
2. Look for the plug icon 🔌 in the top right of the chat interface.
|
|
88
|
+
3. Click it to see the list of connected servers. You should see `smart-coding-mcp` with status "Connected".
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Cursor (Cascade) Integration
|
|
2
|
+
|
|
3
|
+
Cursor's "Cascade" agent natively supports MCP servers.
|
|
4
|
+
|
|
5
|
+
## Configuration Steps
|
|
6
|
+
|
|
7
|
+
1. **Open Settings**
|
|
8
|
+
|
|
9
|
+
- Press `Cmd+K` or click the gear icon to open **Cursor Settings**.
|
|
10
|
+
- Navigate to **Features** > **MCP**.
|
|
11
|
+
|
|
12
|
+
2. **Add New Server**
|
|
13
|
+
|
|
14
|
+
- Click the **+ Add New MCP Server** button.
|
|
15
|
+
|
|
16
|
+
3. **Enter Details**
|
|
17
|
+
|
|
18
|
+
- **Name:** `smart-coding-mcp`
|
|
19
|
+
- **Type:** `command`
|
|
20
|
+
- **Command:** `npx -y smart-coding-mcp --workspace ${workspaceFolder}`
|
|
21
|
+
|
|
22
|
+
> **Important:** The `${workspaceFolder}` variable allows Smart Coding MCP to dynamically index the project you are currently working on.
|
|
23
|
+
|
|
24
|
+
4. **Verify Connection**
|
|
25
|
+
- Cursor should show a green "Connected" status.
|
|
26
|
+
- You can now use tools like `semantic_search` in your Composer (`Cmd+I`) or Chat (`Cmd+L`) windows.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Configuring Rules
|
|
31
|
+
|
|
32
|
+
Cursor uses `.cursor/rules/` for project-specific AI rules.
|
|
33
|
+
|
|
34
|
+
### Creating a Rule
|
|
35
|
+
|
|
36
|
+
1. **Create the rules directory**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
mkdir -p .cursor/rules
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. **Create a rule file** `.cursor/rules/smart-mcp/RULE.md`:
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+
---
|
|
46
|
+
description: Mandatory usage of Smart Coding MCP tools for dependencies and search
|
|
47
|
+
alwaysApply: true
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
# Smart Coding MCP Usage Rules
|
|
51
|
+
|
|
52
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
53
|
+
|
|
54
|
+
## 1. Dependency Management
|
|
55
|
+
|
|
56
|
+
**Trigger:** When checking, adding, or updating package versions (npm, python, go, rust, etc.).
|
|
57
|
+
**Action:**
|
|
58
|
+
|
|
59
|
+
- **MUST** use the `d_check_last_version` tool.
|
|
60
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
61
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
62
|
+
|
|
63
|
+
## 2. Codebase Research
|
|
64
|
+
|
|
65
|
+
**Trigger:** When asking about "how" something works, finding logic, or understanding architecture.
|
|
66
|
+
**Action:**
|
|
67
|
+
|
|
68
|
+
- **PREFER** `a_semantic_search` (Smart Coding) over `grep_search` or `find_by_name`.
|
|
69
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
70
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
71
|
+
|
|
72
|
+
## 3. Environment & Status
|
|
73
|
+
|
|
74
|
+
**Trigger:** When starting a session or debugging the environment.
|
|
75
|
+
**Action:**
|
|
76
|
+
|
|
77
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
78
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Alternative: User Rules
|
|
82
|
+
|
|
83
|
+
For global rules across all projects:
|
|
84
|
+
|
|
85
|
+
1. Open **Cursor Settings** → **Rules, Commands**
|
|
86
|
+
2. Add your instructions in the User Rules section
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Troubleshooting
|
|
91
|
+
|
|
92
|
+
- **Error: "Variable not expanded"**: Ensure you used `${workspaceFolder}` exactly as shown.
|
|
93
|
+
- **Tools not showing**: Click the "Refresh" icon next to the MCP server list in settings.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Raycast Integration
|
|
2
|
+
|
|
3
|
+
Raycast can use MCP servers to provide AI tools directly in your launcher.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. **Raycast Pro**: You need a subscription to access Raycast AI.
|
|
8
|
+
2. **MCP Extension**: Install the [MCP extension](https://www.raycast.com/extensions/mcp) from the Raycast Store.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
1. **Open Raycast Settings**
|
|
13
|
+
|
|
14
|
+
- Open Raycast (`Cmd+Space`).
|
|
15
|
+
- Type "Extensions" and press Enter.
|
|
16
|
+
- Find "Model Context Protocol".
|
|
17
|
+
|
|
18
|
+
2. **Edit Configuration**
|
|
19
|
+
|
|
20
|
+
- Click on the extension settings.
|
|
21
|
+
- Find the **Config File Path**. It usually defaults to `~/.config/raycast/mcp.json` or similar.
|
|
22
|
+
- Open that file.
|
|
23
|
+
|
|
24
|
+
3. **Add Server**
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"smart-coding-mcp": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": [
|
|
32
|
+
"-y",
|
|
33
|
+
"smart-coding-mcp",
|
|
34
|
+
"--workspace",
|
|
35
|
+
"/absolute/path/to/your/project"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
4. **Using Tools**
|
|
43
|
+
- Open Raycast AI Chat.
|
|
44
|
+
- The tools (like `d_check_last_version` or `a_semantic_search`) will effectively be available to the AI model.
|
|
45
|
+
- You can ask: "Check the latest version of React" or "Search my code for auth logic".
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Configuring Rules (AI Commands & Presets)
|
|
50
|
+
|
|
51
|
+
Raycast uses **AI Commands** and **Presets** for custom instructions.
|
|
52
|
+
|
|
53
|
+
### Creating an AI Preset
|
|
54
|
+
|
|
55
|
+
1. Open Raycast and search for **"Preferences"**
|
|
56
|
+
2. Navigate to **"Manage AI Presets"** → **"Create Preset"**
|
|
57
|
+
3. Configure:
|
|
58
|
+
|
|
59
|
+
- **Name:** `Smart Coding`
|
|
60
|
+
- **System Instructions:**
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
# Smart Coding MCP Usage Rules
|
|
64
|
+
|
|
65
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
66
|
+
|
|
67
|
+
## 1. Dependency Management
|
|
68
|
+
- **MUST** use the `d_check_last_version` tool for package versions.
|
|
69
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
70
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
71
|
+
|
|
72
|
+
## 2. Codebase Research
|
|
73
|
+
- **PREFER** `a_semantic_search` over `grep_search` or `find_by_name`.
|
|
74
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
75
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
76
|
+
|
|
77
|
+
## 3. Environment & Status
|
|
78
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
79
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
4. Set as default if desired
|
|
83
|
+
|
|
84
|
+
### Creating Custom AI Commands
|
|
85
|
+
|
|
86
|
+
1. Search for **"Create AI Command"** in Raycast
|
|
87
|
+
2. Configure:
|
|
88
|
+
- **Title:** `Check Package Version`
|
|
89
|
+
- **Prompt:** `Use d_check_last_version to get the latest version of {argument name="package"}`
|
|
90
|
+
3. Assign a hotkey for quick access
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# VS Code Integration
|
|
2
|
+
|
|
3
|
+
To use Smart Coding MCP in VS Code, you typically need an MCP-compatible extension like **Cline** (formerly Roo Code) or the official **Model Context Protocol** extension.
|
|
4
|
+
|
|
5
|
+
## Using Cline (Roo Code)
|
|
6
|
+
|
|
7
|
+
Cline is an autonomous coding agent extension for VS Code that supports MCP natively.
|
|
8
|
+
|
|
9
|
+
1. **Install the Extension**
|
|
10
|
+
|
|
11
|
+
- Search for "Cline" in the VS Code Marketplace and install it.
|
|
12
|
+
|
|
13
|
+
2. **Open MCP Settings**
|
|
14
|
+
|
|
15
|
+
- Click the **MCP Servers** icon in the Cline sidebar (or open Settings).
|
|
16
|
+
- Click "Edit MCP Settings" to open the configuration file.
|
|
17
|
+
|
|
18
|
+
3. **Add Configuration**
|
|
19
|
+
Add the `smart-coding-mcp` entry to the `mcpServers` object:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"smart-coding-mcp": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "smart-coding-mcp", "--workspace", "${workspaceFolder}"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> **Note:** Cline supports the `${workspaceFolder}` variable, so the server will automatically index whichever project you currently have open.
|
|
33
|
+
|
|
34
|
+
## Using Official MCP Extension
|
|
35
|
+
|
|
36
|
+
1. **Install the Extension**
|
|
37
|
+
|
|
38
|
+
- Install the "Model Context Protocol" extension from the VS Code Marketplace.
|
|
39
|
+
|
|
40
|
+
2. **Configure Settings**
|
|
41
|
+
|
|
42
|
+
- Open VS Code Settings (`Cmd+,`).
|
|
43
|
+
- Search for "MCP".
|
|
44
|
+
- Edit the `configuration.json` equivalent.
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"smart-coding-mcp": {
|
|
50
|
+
"command": "npx",
|
|
51
|
+
"args": [
|
|
52
|
+
"-y",
|
|
53
|
+
"smart-coding-mcp",
|
|
54
|
+
"--workspace",
|
|
55
|
+
"/absolute/path/to/project"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Configuring Rules (Cline)
|
|
65
|
+
|
|
66
|
+
Cline uses `.clinerules` files to control AI behavior.
|
|
67
|
+
|
|
68
|
+
### Creating a Rule
|
|
69
|
+
|
|
70
|
+
1. **Create a file** `.clinerules` or `.clinerules.md` in your project root:
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
---
|
|
74
|
+
trigger: always_on
|
|
75
|
+
description: Mandatory usage of Smart Coding MCP tools for dependencies and search
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
# Smart Coding MCP Usage Rules
|
|
79
|
+
|
|
80
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
81
|
+
|
|
82
|
+
## 1. Dependency Management
|
|
83
|
+
|
|
84
|
+
**Trigger:** When checking, adding, or updating package versions (npm, python, go, rust, etc.).
|
|
85
|
+
**Action:**
|
|
86
|
+
|
|
87
|
+
- **MUST** use the `d_check_last_version` tool.
|
|
88
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
89
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
90
|
+
|
|
91
|
+
## 2. Codebase Research
|
|
92
|
+
|
|
93
|
+
**Trigger:** When asking about "how" something works, finding logic, or understanding architecture.
|
|
94
|
+
**Action:**
|
|
95
|
+
|
|
96
|
+
- **PREFER** `a_semantic_search` (Smart Coding) over `grep_search` or `find_by_name`.
|
|
97
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
98
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
99
|
+
|
|
100
|
+
## 3. Environment & Status
|
|
101
|
+
|
|
102
|
+
**Trigger:** When starting a session or debugging the environment.
|
|
103
|
+
**Action:**
|
|
104
|
+
|
|
105
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
106
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
2. **Or use a folder** `.clinerules/` with multiple files:
|
|
110
|
+
```
|
|
111
|
+
.clinerules/
|
|
112
|
+
├── 01-smart-mcp.md
|
|
113
|
+
└── 02-coding-style.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Rules are version-controlled and automatically loaded by Cline.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Windsurf Integration
|
|
2
|
+
|
|
3
|
+
Windsurf (by Codeium) supports MCP servers via a configuration file.
|
|
4
|
+
|
|
5
|
+
## Configuration Location
|
|
6
|
+
|
|
7
|
+
Edit the MCP configuration file located at:
|
|
8
|
+
|
|
9
|
+
- **macOS/Linux:** `~/.codeium/windsurf/mcp_config.json`
|
|
10
|
+
- **Windows:** `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
Add the server to the `mcpServers` object.
|
|
15
|
+
|
|
16
|
+
> **Note:** Windsurf may not support dynamic variables like `${workspaceFolder}` yet. We recommend using the absolute path or setting up separate "profiles" if needed.
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"mcpServers": {
|
|
21
|
+
"smart-coding-mcp": {
|
|
22
|
+
"command": "npx",
|
|
23
|
+
"args": [
|
|
24
|
+
"-y",
|
|
25
|
+
"smart-coding-mcp",
|
|
26
|
+
"--workspace",
|
|
27
|
+
"/absolute/path/to/your/project"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Configuring Rules
|
|
37
|
+
|
|
38
|
+
Windsurf uses `.windsurfrules` for project-specific AI rules.
|
|
39
|
+
|
|
40
|
+
### Creating a Rule
|
|
41
|
+
|
|
42
|
+
Create a file `.windsurfrules` in your project root:
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+
---
|
|
46
|
+
trigger: always_on
|
|
47
|
+
description: Mandatory usage of Smart Coding MCP tools for dependencies and search
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
# Smart Coding MCP Usage Rules
|
|
51
|
+
|
|
52
|
+
You must prioritize using the **Smart Coding MCP** tools for the following tasks.
|
|
53
|
+
|
|
54
|
+
## 1. Dependency Management
|
|
55
|
+
|
|
56
|
+
**Trigger:** When checking, adding, or updating package versions (npm, python, go, rust, etc.).
|
|
57
|
+
**Action:**
|
|
58
|
+
|
|
59
|
+
- **MUST** use the `d_check_last_version` tool.
|
|
60
|
+
- **DO NOT** guess versions or trust internal training data.
|
|
61
|
+
- **DO NOT** use generic web search unless `d_check_last_version` fails.
|
|
62
|
+
|
|
63
|
+
## 2. Codebase Research
|
|
64
|
+
|
|
65
|
+
**Trigger:** When asking about "how" something works, finding logic, or understanding architecture.
|
|
66
|
+
**Action:**
|
|
67
|
+
|
|
68
|
+
- **PREFER** `a_semantic_search` (Smart Coding) over `grep_search` or `find_by_name`.
|
|
69
|
+
- Use `a_semantic_search` for natural language queries (e.g., "where is the auth logic").
|
|
70
|
+
- Use standard tools (`grep`) only for exact string matching.
|
|
71
|
+
|
|
72
|
+
## 3. Environment & Status
|
|
73
|
+
|
|
74
|
+
**Trigger:** When starting a session or debugging the environment.
|
|
75
|
+
**Action:**
|
|
76
|
+
|
|
77
|
+
- Use `e_set_workspace` if the current workspace path is incorrect.
|
|
78
|
+
- Use `f_get_status` to verify the MCP server is healthy and indexed.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Global Rules
|
|
82
|
+
|
|
83
|
+
For rules across all projects, edit:
|
|
84
|
+
|
|
85
|
+
- **macOS/Linux:** `~/.codeium/windsurf/memories/global_rules.md`
|
|
86
|
+
- **Windows:** `%USERPROFILE%\.codeium\windsurf\memories\global_rules.md`
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Reloading
|
|
91
|
+
|
|
92
|
+
After saving the file:
|
|
93
|
+
|
|
94
|
+
1. Restart Windsurf.
|
|
95
|
+
2. Check the Cascade/Chat panel to see if the tools are available (usually indicated by a hammer/wrench icon).
|
|
@@ -446,11 +446,15 @@ export class CodebaseIndexer {
|
|
|
446
446
|
percentage: 0
|
|
447
447
|
};
|
|
448
448
|
|
|
449
|
+
// Declare counters outside try block so they're accessible in finally
|
|
450
|
+
let processedFiles = 0;
|
|
451
|
+
let skippedFiles = 0;
|
|
452
|
+
|
|
449
453
|
try {
|
|
450
454
|
if (force) {
|
|
451
455
|
console.error("[Indexer] Force reindex requested: clearing cache");
|
|
452
456
|
this.cache.setVectorStore([]);
|
|
453
|
-
this.cache.
|
|
457
|
+
this.cache.clearAllFileHashes();
|
|
454
458
|
}
|
|
455
459
|
|
|
456
460
|
const totalStartTime = Date.now();
|
|
@@ -471,7 +475,7 @@ export class CodebaseIndexer {
|
|
|
471
475
|
// Step 1.5: Prune deleted or excluded files from cache
|
|
472
476
|
if (!force) {
|
|
473
477
|
const currentFilesSet = new Set(files);
|
|
474
|
-
const cachedFiles = Array.from(this.cache.
|
|
478
|
+
const cachedFiles = Array.from(this.cache.getAllFileHashes().keys());
|
|
475
479
|
let prunedCount = 0;
|
|
476
480
|
|
|
477
481
|
for (const cachedFile of cachedFiles) {
|
|
@@ -509,8 +513,6 @@ export class CodebaseIndexer {
|
|
|
509
513
|
}
|
|
510
514
|
|
|
511
515
|
let totalChunks = 0;
|
|
512
|
-
let processedFiles = 0;
|
|
513
|
-
let skippedFiles = 0;
|
|
514
516
|
let batchCounter = 0; // Track batches for incremental saves
|
|
515
517
|
|
|
516
518
|
// Update total file count for status tracking (estimated, will adjust as we filter)
|
package/lib/cache.js
CHANGED
|
@@ -94,6 +94,14 @@ export class EmbeddingsCache {
|
|
|
94
94
|
this.fileHashes.delete(file);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
getAllFileHashes() {
|
|
98
|
+
return this.fileHashes;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
clearAllFileHashes() {
|
|
102
|
+
this.fileHashes = new Map();
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
removeFileFromStore(file) {
|
|
98
106
|
this.vectorStore = this.vectorStore.filter(chunk => chunk.file !== file);
|
|
99
107
|
}
|
package/lib/sqlite-cache.js
CHANGED
|
@@ -390,6 +390,14 @@ export class SQLiteCache {
|
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Clear all file hashes from the database
|
|
395
|
+
*/
|
|
396
|
+
clearAllFileHashes() {
|
|
397
|
+
if (!this.db) return;
|
|
398
|
+
this.db.exec('DELETE FROM file_hashes');
|
|
399
|
+
}
|
|
400
|
+
|
|
393
401
|
/**
|
|
394
402
|
* Set vector store (for compatibility with test code)
|
|
395
403
|
* This is less efficient than batch operations but kept for compatibility
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-coding-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "An extensible MCP server that enhances coding productivity with AI-powered features including semantic code search, intelligent indexing, and more, using local LLMs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@huggingface/transformers": "^3.8.1",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
50
|
-
"better-sqlite3": "^
|
|
50
|
+
"better-sqlite3": "^12.5.0",
|
|
51
51
|
"chokidar": "^3.5.3",
|
|
52
52
|
"fastembed": "^2.1.0",
|
|
53
53
|
"fdir": "^6.5.0",
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for better-sqlite3 compatibility
|
|
3
|
+
*
|
|
4
|
+
* Tests that better-sqlite3 v12.5.0 works correctly with Node.js v25:
|
|
5
|
+
* - Database creation
|
|
6
|
+
* - Table creation
|
|
7
|
+
* - Data insertion
|
|
8
|
+
* - Data querying
|
|
9
|
+
* - Database cleanup
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
13
|
+
import Database from 'better-sqlite3';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import { dirname, join } from 'path';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
const __dirname = dirname(__filename);
|
|
20
|
+
|
|
21
|
+
describe('better-sqlite3 Integration', () => {
|
|
22
|
+
let testDbPath;
|
|
23
|
+
let db;
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
testDbPath = join(__dirname, `test-${Date.now()}.db`);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
// Close database if open
|
|
31
|
+
if (db) {
|
|
32
|
+
try {
|
|
33
|
+
db.close();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// Already closed
|
|
36
|
+
}
|
|
37
|
+
db = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Cleanup test database
|
|
41
|
+
if (fs.existsSync(testDbPath)) {
|
|
42
|
+
fs.unlinkSync(testDbPath);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('Database Operations', () => {
|
|
47
|
+
it('should create a database successfully', () => {
|
|
48
|
+
db = new Database(testDbPath);
|
|
49
|
+
expect(db).toBeDefined();
|
|
50
|
+
expect(fs.existsSync(testDbPath)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create tables', () => {
|
|
54
|
+
db = new Database(testDbPath);
|
|
55
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
56
|
+
|
|
57
|
+
// Verify table exists
|
|
58
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='users'").all();
|
|
59
|
+
expect(tables.length).toBe(1);
|
|
60
|
+
expect(tables[0].name).toBe('users');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should insert data', () => {
|
|
64
|
+
db = new Database(testDbPath);
|
|
65
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
66
|
+
|
|
67
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
68
|
+
const result1 = insert.run('Alice');
|
|
69
|
+
const result2 = insert.run('Bob');
|
|
70
|
+
|
|
71
|
+
expect(result1.changes).toBe(1);
|
|
72
|
+
expect(result2.changes).toBe(1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should query data', () => {
|
|
76
|
+
db = new Database(testDbPath);
|
|
77
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
78
|
+
|
|
79
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
80
|
+
insert.run('Alice');
|
|
81
|
+
insert.run('Bob');
|
|
82
|
+
|
|
83
|
+
const users = db.prepare('SELECT * FROM users').all();
|
|
84
|
+
expect(users.length).toBe(2);
|
|
85
|
+
expect(users[0].name).toBe('Alice');
|
|
86
|
+
expect(users[1].name).toBe('Bob');
|
|
87
|
+
expect(users[0].id).toBe(1);
|
|
88
|
+
expect(users[1].id).toBe(2);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should handle prepared statements', () => {
|
|
92
|
+
db = new Database(testDbPath);
|
|
93
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
94
|
+
|
|
95
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
96
|
+
insert.run('Alice');
|
|
97
|
+
|
|
98
|
+
const getUser = db.prepare('SELECT * FROM users WHERE name = ?');
|
|
99
|
+
const user = getUser.get('Alice');
|
|
100
|
+
|
|
101
|
+
expect(user).toBeDefined();
|
|
102
|
+
expect(user.name).toBe('Alice');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should handle transactions', () => {
|
|
106
|
+
db = new Database(testDbPath);
|
|
107
|
+
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
|
|
108
|
+
|
|
109
|
+
const insert = db.prepare('INSERT INTO users (name) VALUES (?)');
|
|
110
|
+
const insertMany = db.transaction((users) => {
|
|
111
|
+
for (const name of users) {
|
|
112
|
+
insert.run(name);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
insertMany(['Alice', 'Bob', 'Charlie']);
|
|
117
|
+
|
|
118
|
+
const count = db.prepare('SELECT COUNT(*) as count FROM users').get();
|
|
119
|
+
expect(count.count).toBe(3);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should close database properly', () => {
|
|
123
|
+
db = new Database(testDbPath);
|
|
124
|
+
expect(() => db.close()).not.toThrow();
|
|
125
|
+
db = null; // Mark as closed for cleanup
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should work with in-memory database', () => {
|
|
129
|
+
const memDb = new Database(':memory:');
|
|
130
|
+
memDb.exec('CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)');
|
|
131
|
+
memDb.prepare('INSERT INTO test (value) VALUES (?)').run('test');
|
|
132
|
+
|
|
133
|
+
const result = memDb.prepare('SELECT * FROM test').get();
|
|
134
|
+
expect(result.value).toBe('test');
|
|
135
|
+
|
|
136
|
+
memDb.close();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('Node.js v25 Compatibility', () => {
|
|
141
|
+
it('should work with current Node.js version', () => {
|
|
142
|
+
// This test verifies we can use better-sqlite3 with Node.js v25
|
|
143
|
+
expect(process.version).toMatch(/^v25\./);
|
|
144
|
+
|
|
145
|
+
db = new Database(testDbPath);
|
|
146
|
+
db.exec('CREATE TABLE compatibility_test (id INTEGER PRIMARY KEY, version TEXT)');
|
|
147
|
+
db.prepare('INSERT INTO compatibility_test (version) VALUES (?)').run(process.version);
|
|
148
|
+
|
|
149
|
+
const result = db.prepare('SELECT * FROM compatibility_test').get();
|
|
150
|
+
expect(result.version).toBe(process.version);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|