Skip to content

Commit 9dd1b0f

Browse files
CopilotMte90
andcommitted
Remove redundant code and add GitHub CI for plugin builds
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent 9630f47 commit 9dd1b0f

File tree

7 files changed

+81
-113
lines changed

7 files changed

+81
-113
lines changed

.github/workflows/build-plugin.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build PyCharm Plugin
2+
3+
on:
4+
release:
5+
types: [created, published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
21+
- name: Setup Gradle
22+
uses: gradle/gradle-build-action@v2
23+
24+
- name: Build plugin
25+
run: |
26+
cd plugin
27+
./gradlew buildPlugin
28+
29+
- name: Get plugin version
30+
id: plugin_version
31+
run: |
32+
cd plugin
33+
VERSION=$(grep "^version" build.gradle.kts | cut -d'"' -f2)
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
36+
- name: Upload plugin artifact
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: picocode-plugin-${{ steps.plugin_version.outputs.version }}
40+
path: plugin/build/distributions/*.zip
41+
42+
- name: Upload to Release
43+
if: github.event_name == 'release'
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
files: plugin/build/distributions/*.zip
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,6 @@ Prerequisites
3636
- If you use Astral `uv`, install/configure `uv` according to the official docs:
3737
https://docs.astral.sh/uv/
3838

39-
## Quick Start with API
40-
41-
PicoCode now provides a production-ready REST API for IDE integration:
42-
43-
```python
44-
import requests
45-
46-
# 1. Start the server
47-
# python main.py
48-
49-
# 2. Create/get a project
50-
response = requests.post("http://127.0.0.1:8000/api/projects",
51-
json={"path": "/path/to/your/project", "name": "My Project"})
52-
project = response.json()
53-
project_id = project["id"]
54-
55-
# 3. Index the project
56-
requests.post("http://127.0.0.1:8000/api/projects/index",
57-
json={"project_id": project_id})
58-
59-
# 4. Query your codebase
60-
response = requests.post("http://127.0.0.1:8000/api/query",
61-
json={"project_id": project_id, "query": "authentication flow"})
62-
results = response.json()
63-
64-
# 5. Get code suggestions
65-
response = requests.post("http://127.0.0.1:8000/api/code",
66-
json={"project_id": project_id, "prompt": "Explain the auth system"})
67-
suggestion = response.json()
68-
```
69-
70-
See [PYCHARM_INTEGRATION.md](PYCHARM_INTEGRATION.md) for complete API documentation.
71-
7239
## Installation and run commands
7340

7441
First step: Example .env (copy `.env.example` -> `.env` and edit)

main.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919
from models import (
2020
CreateProjectRequest, IndexProjectRequest,
21-
QueryRequest, CodeCompletionRequest
21+
QueryRequest
2222
)
2323

2424
DATABASE = CFG.get("database_path", "codebase.db")
@@ -180,62 +180,6 @@ def api_query(request: QueryRequest):
180180
return JSONResponse({"error": "Query failed"}, status_code=500)
181181

182182

183-
@app.post("/api/code")
184-
def api_code_completion(request: CodeCompletionRequest):
185-
"""Get code suggestions using RAG + LLM (PyCharm-compatible)."""
186-
import logging
187-
logger = logging.getLogger(__name__)
188-
try:
189-
project = get_project_by_id(request.project_id)
190-
if not project:
191-
return JSONResponse({"error": "Project not found"}, status_code=404)
192-
193-
db_path = project["database_path"]
194-
195-
# Get context from RAG if enabled
196-
combined_context = request.context or ""
197-
used_context = []
198-
199-
if request.use_rag:
200-
analyses = list_analyses(db_path)
201-
if analyses:
202-
analysis_id = analyses[0]["id"]
203-
try:
204-
retrieved = search_semantic(request.prompt, db_path, analysis_id=analysis_id, top_k=request.top_k)
205-
context_parts = []
206-
total_len = len(combined_context)
207-
for r in retrieved:
208-
part = f"File: {r.get('path')} (score: {r.get('score', 0):.4f})\n"
209-
if total_len + len(part) > TOTAL_CONTEXT_LIMIT:
210-
break
211-
context_parts.append(part)
212-
total_len += len(part)
213-
used_context.append({"path": r.get("path"), "score": r.get("score")})
214-
if context_parts:
215-
retrieved_text = "\n".join(context_parts)
216-
if combined_context:
217-
combined_context = combined_context + "\n\nRetrieved:\n" + retrieved_text
218-
else:
219-
combined_context = "Retrieved:\n" + retrieved_text
220-
except Exception:
221-
pass
222-
223-
# Call coding model
224-
try:
225-
response = call_coding_model(request.prompt, combined_context)
226-
except Exception as e:
227-
logger.error(f"Coding model call failed: {e}")
228-
return JSONResponse({"error": "Code generation failed"}, status_code=500)
229-
230-
return JSONResponse({
231-
"response": response,
232-
"used_context": used_context,
233-
"project_id": request.project_id
234-
})
235-
except Exception as e:
236-
logger.exception(f"Error in code completion: {e}")
237-
return JSONResponse({"error": "Code completion failed"}, status_code=500)
238-
239183

240184
@app.get("/api/health")
241185
def api_health():

models.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,3 @@ class QueryRequest(BaseModel):
1919
query: str
2020
top_k: Optional[int] = 5
2121

22-
23-
class CodeCompletionRequest(BaseModel):
24-
project_id: str
25-
prompt: str
26-
context: Optional[str] = ""
27-
use_rag: Optional[bool] = True
28-
top_k: Optional[int] = 5

plugin/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,3 @@ To modify the plugin:
8484
3. Run `./gradlew runIde` to test in a sandbox IDE
8585
4. Build with `./gradlew buildPlugin`
8686

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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

plugin/gradlew

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# Gradle wrapper script
3+
4+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
5+
APP_NAME="Gradle"
6+
APP_BASE_NAME=$(basename "$0")
7+
8+
# Resolve links
9+
PRG="$0"
10+
while [ -h "$PRG" ] ; do
11+
ls=$(ls -ld "$PRG")
12+
link=$(expr "$ls" : '.*-> \(.*\)$')
13+
if expr "$link" : '/.*' > /dev/null; then
14+
PRG="$link"
15+
else
16+
PRG=$(dirname "$PRG")"/$link"
17+
fi
18+
done
19+
20+
SAVED="$(pwd)"
21+
cd "$(dirname \"$PRG\")/" >/dev/null
22+
APP_HOME="$(pwd -P)"
23+
cd "$SAVED" >/dev/null
24+
25+
exec gradle "$@"

0 commit comments

Comments
 (0)