Skip to content

Commit ea6f272

Browse files
CopilotMte90
andcommitted
Add PyCharm plugin and refactor to use shared db functions
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent a048a45 commit ea6f272

File tree

8 files changed

+629
-240
lines changed

8 files changed

+629
-240
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ This tool is a way to achieve this!
3333
- Semantic search and code completion endpoints
3434
- See [PYCHARM_INTEGRATION.md](PYCHARM_INTEGRATION.md) for full API documentation
3535

36+
### PyCharm Plugin
37+
38+
A full-featured PyCharm/IntelliJ IDEA plugin is available in the `plugin/` directory:
39+
40+
- **Per-Project Indexing**: Automatically indexes current project
41+
- **Secure API Keys**: Stores credentials in IDE password safe
42+
- **Real-time Responses**: Streams answers from your coding model
43+
- **File Navigation**: Click retrieved files to open in editor
44+
- **Progress Indicators**: Visual feedback during indexing
45+
46+
See [plugin/README.md](plugin/README.md) for installation and usage instructions.
47+
3648
Prerequisites
3749
- Python 3.8+ (3.11+ recommended for builtin tomllib)
3850
- Git (optional, if you clone the repo)

example_client.py

Lines changed: 0 additions & 223 deletions
This file was deleted.

plugin/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# PicoCode PyCharm Plugin
2+
3+
PyCharm/IntelliJ IDEA plugin for PicoCode RAG Assistant with per-project persistent storage.
4+
5+
## Features
6+
7+
- **Per-Project Storage**: Indexes each project into `.local_rag` directory
8+
- **Secure API Key Storage**: Uses IDE's built-in password safe
9+
- **Real-time Responses**: Streams responses from the coding model
10+
- **File Navigation**: Click on retrieved files to open them in the editor
11+
- **Progress Tracking**: Visual progress indicator during indexing
12+
13+
## Building the Plugin
14+
15+
```bash
16+
cd plugin
17+
./gradlew buildPlugin
18+
```
19+
20+
The plugin ZIP will be in `build/distributions/`.
21+
22+
## Installation
23+
24+
1. Build the plugin or download from releases
25+
2. In PyCharm/IntelliJ IDEA: `Settings``Plugins``⚙️``Install Plugin from Disk`
26+
3. Select the plugin ZIP file
27+
4. Restart IDE
28+
29+
## Usage
30+
31+
1. Open the PicoCode RAG tool window (right sidebar)
32+
2. Configure your OpenAI-compatible API:
33+
- API Base URL (e.g., `https://api.openai.com/v1`)
34+
- API Key (stored securely in IDE password safe)
35+
- Embedding Model (e.g., `text-embedding-3-small`)
36+
- Coding Model (e.g., `gpt-4`)
37+
3. Click "Save API Key" to store it securely
38+
4. Click "Start Server" to launch the Python backend
39+
5. Click "Index Project" to index your current project
40+
6. Ask questions in the query box and click "Query"
41+
42+
## Requirements
43+
44+
- PyCharm/IntelliJ IDEA 2023.1 or later
45+
- Python 3.8+ installed and in PATH
46+
- PicoCode backend dependencies installed (`pip install -r pyproject.toml`)
47+
48+
## Project Structure
49+
50+
```
51+
plugin/
52+
├── build.gradle.kts # Gradle build configuration
53+
└── src/
54+
└── main/
55+
├── kotlin/
56+
│ └── com/picocode/
57+
│ ├── PicoCodeToolWindowFactory.kt # Tool window factory
58+
│ └── PicoCodeToolWindowContent.kt # Main UI and logic
59+
└── resources/
60+
└── META-INF/
61+
└── plugin.xml # Plugin descriptor
62+
```
63+
64+
## Architecture
65+
66+
1. **Server Management**: Plugin starts Python server as subprocess in project directory
67+
2. **API Communication**: HTTP REST API for project management and queries
68+
3. **Secure Storage**: API keys stored using IntelliJ's `PasswordSafe` API
69+
4. **File Navigation**: Uses IntelliJ's Open API to navigate to retrieved files
70+
71+
## API Endpoints Used
72+
73+
- `POST /api/projects` - Create/get project
74+
- `POST /api/projects/index` - Start indexing
75+
- `POST /api/code` - Query with RAG context
76+
- `GET /api/projects` - List projects
77+
78+
## Development
79+
80+
To modify the plugin:
81+
82+
1. Open `plugin/` in IntelliJ IDEA
83+
2. Make changes to Kotlin files
84+
3. Run `./gradlew runIde` to test in a sandbox IDE
85+
4. Build with `./gradlew buildPlugin`
86+
87+
## Troubleshooting
88+
89+
**Server won't start**
90+
- Check Python is in PATH
91+
- Verify PicoCode dependencies are installed
92+
- Check console for error messages
93+
94+
**Indexing fails**
95+
- Ensure project path is accessible
96+
- Check API key is configured correctly
97+
- Verify API base URL is reachable
98+
99+
**No query results**
100+
- Index the project first
101+
- Check server is running
102+
- Verify embeddings model is correct

plugin/build.gradle.kts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
plugins {
2+
id("java")
3+
id("org.jetbrains.kotlin.jvm") version "1.9.0"
4+
id("org.jetbrains.intellij") version "1.15.0"
5+
}
6+
7+
group = "com.picocode"
8+
version = "0.2.0"
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
dependencies {
15+
implementation("com.google.code.gson:gson:2.10.1")
16+
implementation("org.java-websocket:Java-WebSocket:1.5.3")
17+
}
18+
19+
intellij {
20+
version.set("2023.1")
21+
type.set("IC") // IntelliJ IDEA Community Edition
22+
plugins.set(listOf())
23+
}
24+
25+
tasks {
26+
withType<JavaCompile> {
27+
sourceCompatibility = "17"
28+
targetCompatibility = "17"
29+
}
30+
31+
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
32+
kotlinOptions.jvmTarget = "17"
33+
}
34+
35+
patchPluginXml {
36+
sinceBuild.set("231")
37+
untilBuild.set("241.*")
38+
}
39+
40+
signPlugin {
41+
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
42+
privateKey.set(System.getenv("PRIVATE_KEY"))
43+
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
44+
}
45+
46+
publishPlugin {
47+
token.set(System.getenv("PUBLISH_TOKEN"))
48+
}
49+
}

0 commit comments

Comments
 (0)