Code Completion Extension
AI-powered code completion extension for VS Code with server-based indexing.
Features
- Repository Indexing: Manually index your repository files for better code completion suggestions
- Inline Code Completion: Get intelligent code suggestions as you type
- Multi-language Support: Works with Python, JavaScript, TypeScript, and Go
- Smart File Filtering: Automatically excludes node_modules, .git, virtual environments, and respects .gitignore
- Secure Token Storage: Your access token is stored securely using VS Code's secret storage
Supported Languages
- Python (
.py)
- JavaScript (
.js, .jsx)
- TypeScript (
.ts, .tsx)
- Go (
.go)
Getting Started
1. Set Your Access Token
Before using the extension, you need to configure your personal access token:
- Open Command Palette (
Ctrl+Shift+P / Cmd+Shift+P)
- Run
Code Completion: Set Access Token
- Enter your personal access token
2. Index Your Repository
To enable code completions, you need to index your repository:
- Open Command Palette (
Ctrl+Shift+P / Cmd+Shift+P)
- Run
Code Completion: Index Repository
- Select the programming language (auto-detected)
- Wait for indexing to complete
3. Start Coding
Once indexed, you'll automatically receive code completion suggestions as you type!
Commands
| Command |
Description |
Code Completion: Index Repository |
Index the current repository for code completion |
Code Completion: Show Index Status |
Show the current index status and last indexed time |
Code Completion: Set Access Token |
Set your personal access token |
Code Completion: Clear Access Token |
Remove the stored access token |
Extension Settings
This extension contributes the following settings:
| Setting |
Default |
Description |
codeCompletion.serverUrl |
http://localhost:8000 |
The URL of the code completion server |
codeCompletion.enableAutoComplete |
true |
Enable/disable automatic code completion |
codeCompletion.maxCompletionLength |
500 |
Maximum characters of code context sent to server |
Status Bar
The extension adds a status bar item showing:
- Whether the repository is indexed
- The language and number of indexed files
- Last indexed time (on hover)
Click the status bar item to view index status or trigger indexing.
Server API
The extension communicates with a code completion server. The server should implement:
POST /api/index
Index repository files.
Request:
{
"files": [
{
"path": "src/main.py",
"content": "...",
"language": "python"
}
],
"language": "python",
"repositoryName": "my-project"
}
Response:
{
"indexId": "idx_123456",
"indexedAt": "2024-01-15T10:30:00Z",
"fileCount": 42,
"language": "python"
}
POST /api/complete
Get code completion suggestions.
Request:
{
"indexId": "idx_123456",
"codeBefore": "def hello(",
"codeAfter": "):\n pass",
"language": "python",
"filePath": "src/main.py"
}
Response:
{
"suggestions": [
{
"text": "name: str",
"confidence": 0.95
}
]
}
GET /api/index/:indexId
Get index information.
Response:
{
"indexId": "idx_123456",
"indexedAt": "2024-01-15T10:30:00Z",
"fileCount": 42,
"language": "python"
}
Development
Building the Extension
npm install
npm run compile
Running in Debug Mode
- Press
F5 to open a new VS Code window with the extension loaded
- Use the extension in the new window
Packaging
npm run package
License
MIT