Refactor devcontainer and MCP tools for containerized development

Ajout et configuration d’un environnement de développement conteneurisé (devcontainer) avec support multi-langages (Go, Rust, Python), intégration d’outils LLM locaux/cloud (LM Studio, Claude Pro), et refonte des outils MCP : suppression du module sandbox, correction de la gestion des chemins projet dans jj.py, ajout d’une fonction jj_new_tool, et structuration du Makefile pour le build multiplateforme. Mise à jour des scripts (docker-entrypoint.sh, setup-devcontainer.sh), du README.md et de bin/jj-ai-commit.sh pour automatiser la génération de messages de commit à partir des résumés des fichiers modifiés.
This commit is contained in:
2026-03-11 16:34:09 +01:00
parent 1c9cee35df
commit d6fb4e33e5
30 changed files with 3502 additions and 193 deletions

View File

@@ -1,8 +1,8 @@
import json
import os
import urllib.request
import urllib.error
from typing import Dict, List, Optional
import urllib.request
from typing import Dict
def structure_to_json(text: str, schema: Dict) -> Dict:
@@ -17,11 +17,13 @@ def structure_to_json(text: str, schema: Dict) -> Dict:
dict: The parsed JSON object
"""
# Get the API URL from environment variable
local_llm_api = os.environ.get("LOCAL_LLM_API", "http://host.docker.internal:1248/v1")
local_llm_api = os.environ.get(
"LOCAL_LLM_API", "http://host.docker.internal:1248/v1"
)
# Format the schema as JSON string
schema_json = json.dumps(schema, indent=2)
# Create the prompt following the pattern from jj-ai-commit.sh
prompt_text = f"""Analyse this text and respond ONLY with a valid JSON object matching the schema.
@@ -30,27 +32,22 @@ Text:
Schema:
{schema_json}"""
# Build the request body
request_body = {
"model": "qwen3-coder",
"messages": [
{"role": "user", "content": prompt_text}
]
"messages": [{"role": "user", "content": prompt_text}],
}
# Build the URL
url = f"{local_llm_api}/chat/completions"
# Create the request
data = json.dumps(request_body).encode("utf-8")
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json"},
method="POST"
url, data=data, headers={"Content-Type": "application/json"}, method="POST"
)
try:
# Execute the request
with urllib.request.urlopen(req) as response:
@@ -59,18 +56,21 @@ Schema:
return {"error": f"API request failed: {e}", "raw_response": ""}
except json.JSONDecodeError as e:
return {"error": f"Failed to parse response: {e}", "raw_response": ""}
try:
content = result.get("choices", [{}])[0].get("message", {}).get("content", "")
# Clean markdown backticks from response
clean_content = content.strip()
while clean_content.startswith("`") or clean_content.startswith("```"):
clean_content = clean_content[1:].strip()
while clean_content.endswith("`") or clean_content.endswith("```"):
clean_content = clean_content[:-1].strip()
# Parse the JSON content
return json.loads(clean_content)
except (json.JSONDecodeError, KeyError, IndexError) as e:
return {"error": f"Failed to parse JSON: {e}", "raw_response": json.dumps(result)}
return {
"error": f"Failed to parse JSON: {e}",
"raw_response": json.dumps(result),
}