6 Commits

7 changed files with 62 additions and 53 deletions
+16 -7
View File
@@ -16,8 +16,17 @@ Tu peux interrompre la génération à tout moment depuis le même panneau.
## Installation ## Installation
### Via le marketplace (recommandé)
Recherche **Zemit** dans l'onglet Extensions de ton éditeur, ou installe directement depuis :
- **VS Code** : [marketplace.visualstudio.com](https://marketplace.visualstudio.com/items?itemName=hykocx.zemit)
- **VSCodium / Open VSX** : [open-vsx.org](https://open-vsx.org/extension/hykocx/zemit)
### Via un fichier VSIX
1. Télécharge le fichier `.vsix` depuis les [releases](https://git.hyko.cx/hykocx/zemit/releases). 1. Télécharge le fichier `.vsix` depuis les [releases](https://git.hyko.cx/hykocx/zemit/releases).
2. Dans VS Code, ouvre la palette de commandes (`Ctrl+Shift+P` / `Cmd+Shift+P`). 2. Ouvre la palette de commandes (`Ctrl+Shift+P` / `Cmd+Shift+P`).
3. Cherche **Extensions: Installer depuis un fichier VSIX...** et sélectionne le fichier téléchargé. 3. Cherche **Extensions: Installer depuis un fichier VSIX...** et sélectionne le fichier téléchargé.
Ou via le menu **Extensions** (icône en barre latérale) → `...`**Installer depuis un fichier VSIX...** Ou via le menu **Extensions** (icône en barre latérale) → `...`**Installer depuis un fichier VSIX...**
@@ -28,12 +37,12 @@ Les paramètres se trouvent dans les préférences VS Code sous **Zemit**.
| Paramètre | Description | Défaut | | Paramètre | Description | Défaut |
|---|---|---| |---|---|---|
| `aiCommit.provider` | Fournisseur d'IA : `anthropic`, `openai` ou `ollama` | `anthropic` | | `zemit.provider` | Fournisseur d'IA : `anthropic`, `openai` ou `ollama` | `anthropic` |
| `aiCommit.apiKey` | Clé API du fournisseur (inutile pour Ollama) | _(vide)_ | | `zemit.apiKey` | Clé API du fournisseur (inutile pour Ollama) | _(vide)_ |
| `aiCommit.model` | Modèle à utiliser | `claude-haiku-4-5-20251001` | | `zemit.model` | Modèle à utiliser | `claude-sonnet-4-6` |
| `aiCommit.baseUrl` | URL de base personnalisée (ex. Ollama local) | _(vide)_ | | `zemit.baseUrl` | URL de base personnalisée (ex. Ollama local) | _(vide)_ |
| `aiCommit.commitStyle` | Style du message : `conventional` ou `simple` | `conventional` | | `zemit.commitStyle` | Style du message : `conventional` ou `simple` | `conventional` |
| `aiCommit.maxDiffSize` | Taille maximale du diff envoyé à l'IA (en caractères) | `5000` | | `zemit.maxDiffSize` | Taille maximale du diff envoyé à l'IA (en caractères) | `5000` |
Pour choisir un modèle parmi ceux disponibles chez ton fournisseur, lance la commande **Zemit: Select Model** depuis la palette de commandes. Pour choisir un modèle parmi ceux disponibles chez ton fournisseur, lance la commande **Zemit: Select Model** depuis la palette de commandes.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "zemit", "name": "zemit",
"version": "1.1.0", "version": "1.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "zemit", "name": "zemit",
"version": "1.1.0", "version": "1.1.1",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"devDependencies": { "devDependencies": {
"@types/node": "^18.0.0", "@types/node": "^18.0.0",
+15 -15
View File
@@ -1,6 +1,6 @@
{ {
"name": "zemit", "name": "zemit",
"version": "1.1.0", "version": "1.1.1",
"displayName": "Zemit", "displayName": "Zemit",
"description": "Génère des messages de commit dans VSCode à partir du diff en cours, via un modèle d'IA.", "description": "Génère des messages de commit dans VSCode à partir du diff en cours, via un modèle d'IA.",
"repository": { "repository": {
@@ -31,7 +31,7 @@
"configuration": { "configuration": {
"title": "Zemit", "title": "Zemit",
"properties": { "properties": {
"aiCommit.provider": { "zemit.provider": {
"type": "string", "type": "string",
"enum": [ "enum": [
"anthropic", "anthropic",
@@ -41,22 +41,22 @@
"default": "anthropic", "default": "anthropic",
"description": "Fournisseur d'IA utilisé pour générer les messages de commit." "description": "Fournisseur d'IA utilisé pour générer les messages de commit."
}, },
"aiCommit.apiKey": { "zemit.apiKey": {
"type": "string", "type": "string",
"default": "", "default": "",
"markdownDescription": "Clé API du fournisseur sélectionné. Non requise pour Ollama." "markdownDescription": "Clé API du fournisseur sélectionné. Non requise pour Ollama."
}, },
"aiCommit.model": { "zemit.model": {
"type": "string", "type": "string",
"default": "claude-haiku-4-5-20251001", "default": "claude-sonnet-4-6",
"markdownDescription": "Modèle à utiliser. Lance **Zemit : Sélectionner un modèle** pour parcourir les modèles disponibles du fournisseur configuré." "markdownDescription": "Modèle à utiliser. Lance **Zemit : Sélectionner un modèle** pour parcourir les modèles disponibles du fournisseur configuré."
}, },
"aiCommit.baseUrl": { "zemit.baseUrl": {
"type": "string", "type": "string",
"default": "", "default": "",
"markdownDescription": "URL de base personnalisée (ex. `http://localhost:11434/v1` pour Ollama). Laisser vide pour utiliser la valeur par défaut du fournisseur." "markdownDescription": "URL de base personnalisée (ex. `http://localhost:11434/v1` pour Ollama). Laisser vide pour utiliser la valeur par défaut du fournisseur."
}, },
"aiCommit.commitStyle": { "zemit.commitStyle": {
"type": "string", "type": "string",
"enum": [ "enum": [
"conventional", "conventional",
@@ -69,7 +69,7 @@
"default": "conventional", "default": "conventional",
"description": "Format du message de commit généré." "description": "Format du message de commit généré."
}, },
"aiCommit.maxDiffSize": { "zemit.maxDiffSize": {
"type": "number", "type": "number",
"default": 5000, "default": 5000,
"minimum": 500, "minimum": 500,
@@ -80,19 +80,19 @@
}, },
"commands": [ "commands": [
{ {
"command": "aiCommit.generateCommitMessage", "command": "zemit.generateCommitMessage",
"title": "Générer un message de commit", "title": "Générer un message de commit",
"category": "Zemit", "category": "Zemit",
"icon": "$(sparkle)" "icon": "$(sparkle)"
}, },
{ {
"command": "aiCommit.abortGeneration", "command": "zemit.abortGeneration",
"title": "Arrêter la génération", "title": "Arrêter la génération",
"category": "Zemit", "category": "Zemit",
"icon": "$(debug-stop)" "icon": "$(debug-stop)"
}, },
{ {
"command": "aiCommit.selectModel", "command": "zemit.selectModel",
"title": "Sélectionner un modèle", "title": "Sélectionner un modèle",
"category": "Zemit", "category": "Zemit",
"icon": "$(list-selection)" "icon": "$(list-selection)"
@@ -101,14 +101,14 @@
"menus": { "menus": {
"scm/title": [ "scm/title": [
{ {
"command": "aiCommit.generateCommitMessage", "command": "zemit.generateCommitMessage",
"group": "navigation@1", "group": "navigation@1",
"when": "config.git.enabled && scmProvider == git && !aiCommit.isGenerating" "when": "config.git.enabled && scmProvider == git && !zemit.isGenerating"
}, },
{ {
"command": "aiCommit.abortGeneration", "command": "zemit.abortGeneration",
"group": "navigation@1", "group": "navigation@1",
"when": "config.git.enabled && scmProvider == git && aiCommit.isGenerating" "when": "config.git.enabled && scmProvider == git && zemit.isGenerating"
} }
] ]
} }
+12 -12
View File
@@ -9,19 +9,19 @@ export async function generateCommitMsg(scm?: vscode.SourceControl): Promise<voi
try { try {
const gitExtension = vscode.extensions.getExtension("vscode.git")?.exports const gitExtension = vscode.extensions.getExtension("vscode.git")?.exports
if (!gitExtension) { if (!gitExtension) {
throw new Error("Git extension not found") throw new Error("Extension Git introuvable")
} }
const git = gitExtension.getAPI(1) const git = gitExtension.getAPI(1)
if (git.repositories.length === 0) { if (git.repositories.length === 0) {
throw new Error("No Git repositories available") throw new Error("Aucun dépôt Git disponible")
} }
// If invoked from SCM panel button, a specific repo is provided // If invoked from SCM panel button, a specific repo is provided
if (scm) { if (scm) {
const repository = git.getRepository(scm.rootUri) const repository = git.getRepository(scm.rootUri)
if (!repository) { if (!repository) {
throw new Error("Repository not found for the selected SCM") throw new Error("Dépôt introuvable pour le SCM sélectionné")
} }
await generateForRepository(repository) await generateForRepository(repository)
return return
@@ -36,7 +36,7 @@ export async function generateCommitMsg(scm?: vscode.SourceControl): Promise<voi
export function abortGeneration(): void { export function abortGeneration(): void {
abortController?.abort() abortController?.abort()
vscode.commands.executeCommand("setContext", "aiCommit.isGenerating", false) vscode.commands.executeCommand("setContext", "zemit.isGenerating", false)
} }
// ─── Multi-repo orchestration ───────────────────────────────────────────────── // ─── Multi-repo orchestration ─────────────────────────────────────────────────
@@ -45,7 +45,7 @@ async function orchestrateMultiRepo(repos: unknown[]): Promise<void> {
const reposWithChanges = await filterReposWithChanges(repos) const reposWithChanges = await filterReposWithChanges(repos)
if (reposWithChanges.length === 0) { if (reposWithChanges.length === 0) {
vscode.window.showInformationMessage("[Zemit] No changes found in any repository.") vscode.window.showInformationMessage("[Zemit] Aucune modification trouvée dans les dépôts.")
return return
} }
@@ -62,12 +62,12 @@ async function orchestrateMultiRepo(repos: unknown[]): Promise<void> {
items.unshift({ items.unshift({
label: "$(git-commit) All repositories with changes", label: "$(git-commit) All repositories with changes",
description: `Generate for ${reposWithChanges.length} repositories`, description: `Générer pour ${reposWithChanges.length} dépôts`,
repo: null as any, repo: null as any,
}) })
const selection = await vscode.window.showQuickPick(items, { const selection = await vscode.window.showQuickPick(items, {
placeHolder: "Select a repository to generate a commit message for", placeHolder: "Sélectionner un dépôt pour générer un message de commit",
}) })
if (!selection) return if (!selection) return
@@ -104,7 +104,7 @@ async function generateForRepository(repository: any): Promise<void> {
await vscode.window.withProgress( await vscode.window.withProgress(
{ {
location: vscode.ProgressLocation.SourceControl, location: vscode.ProgressLocation.SourceControl,
title: `Zemit: Generating commit message for ${repoName}...`, title: `Zemit : Génération du message de commit pour ${repoName}...`,
cancellable: true, cancellable: true,
}, },
(_progress, token) => performGeneration(repository.inputBox, diff, token), (_progress, token) => performGeneration(repository.inputBox, diff, token),
@@ -116,7 +116,7 @@ async function performGeneration(
diff: string, diff: string,
token: vscode.CancellationToken, token: vscode.CancellationToken,
): Promise<void> { ): Promise<void> {
const config = vscode.workspace.getConfiguration("aiCommit") const config = vscode.workspace.getConfiguration("zemit")
const maxDiffSize = config.get<number>("maxDiffSize", 5000) const maxDiffSize = config.get<number>("maxDiffSize", 5000)
const style = config.get<string>("commitStyle", "conventional") const style = config.get<string>("commitStyle", "conventional")
@@ -135,7 +135,7 @@ async function performGeneration(
token.onCancellationRequested(() => abortController?.abort()) token.onCancellationRequested(() => abortController?.abort())
try { try {
await vscode.commands.executeCommand("setContext", "aiCommit.isGenerating", true) await vscode.commands.executeCommand("setContext", "zemit.isGenerating", true)
const provider = createProvider(config) const provider = createProvider(config)
let response = "" let response = ""
@@ -147,10 +147,10 @@ async function performGeneration(
} }
if (!inputBox.value) { if (!inputBox.value) {
throw new Error("The AI returned an empty response") throw new Error("L'IA n'a retourné aucune réponse")
} }
} finally { } finally {
await vscode.commands.executeCommand("setContext", "aiCommit.isGenerating", false) await vscode.commands.executeCommand("setContext", "zemit.isGenerating", false)
} }
} }
+9 -9
View File
@@ -4,21 +4,21 @@ import { fetchAvailableModels } from "./providers"
export function activate(context: vscode.ExtensionContext): void { export function activate(context: vscode.ExtensionContext): void {
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("aiCommit.generateCommitMessage", (scm?: vscode.SourceControl) => vscode.commands.registerCommand("zemit.generateCommitMessage", (scm?: vscode.SourceControl) =>
generateCommitMsg(scm), generateCommitMsg(scm),
), ),
vscode.commands.registerCommand("aiCommit.abortGeneration", () => abortGeneration()), vscode.commands.registerCommand("zemit.abortGeneration", () => abortGeneration()),
vscode.commands.registerCommand("aiCommit.selectModel", () => selectModel()), vscode.commands.registerCommand("zemit.selectModel", () => selectModel()),
) )
} }
async function selectModel(): Promise<void> { async function selectModel(): Promise<void> {
const config = vscode.workspace.getConfiguration("aiCommit") const config = vscode.workspace.getConfiguration("zemit")
let models: string[] let models: string[]
try { try {
models = await vscode.window.withProgress( models = await vscode.window.withProgress(
{ location: vscode.ProgressLocation.Notification, title: "Zemit: Fetching available models…", cancellable: false }, { location: vscode.ProgressLocation.Notification, title: "Zemit : Récupération des modèles disponibles…", cancellable: false },
() => fetchAvailableModels(config), () => fetchAvailableModels(config),
) )
} catch (err) { } catch (err) {
@@ -28,25 +28,25 @@ async function selectModel(): Promise<void> {
} }
if (models.length === 0) { if (models.length === 0) {
vscode.window.showWarningMessage("[Zemit] No models found for the configured provider.") vscode.window.showWarningMessage("[Zemit] Aucun modèle trouvé pour le fournisseur configuré.")
return return
} }
const currentModel = config.get<string>("model", "") const currentModel = config.get<string>("model", "")
const items = models.map((id) => ({ const items = models.map((id) => ({
label: id, label: id,
description: id === currentModel ? "current" : undefined, description: id === currentModel ? "actuel" : undefined,
})) }))
const picked = await vscode.window.showQuickPick(items, { const picked = await vscode.window.showQuickPick(items, {
placeHolder: "Select a model", placeHolder: "Sélectionner un modèle",
matchOnDescription: false, matchOnDescription: false,
}) })
if (!picked) return if (!picked) return
await config.update("model", picked.label, vscode.ConfigurationTarget.Global) await config.update("model", picked.label, vscode.ConfigurationTarget.Global)
vscode.window.showInformationMessage(`[Zemit] Model set to ${picked.label}`) vscode.window.showInformationMessage(`[Zemit] Modèle défini sur ${picked.label}`)
} }
export function deactivate(): void {} export function deactivate(): void {}
+3 -3
View File
@@ -32,10 +32,10 @@ async function hasCommits(cwd: string): Promise<boolean> {
export async function getGitDiff(cwd: string, stagedOnly = false): Promise<string> { export async function getGitDiff(cwd: string, stagedOnly = false): Promise<string> {
if (!(await isGitInstalled())) { if (!(await isGitInstalled())) {
throw new Error("Git is not installed") throw new Error("Git n'est pas installé")
} }
if (!(await isGitRepo(cwd))) { if (!(await isGitRepo(cwd))) {
throw new Error("Not a git repository") throw new Error("Pas un dépôt git")
} }
let diff = "" let diff = ""
@@ -72,7 +72,7 @@ export async function getGitDiff(cwd: string, stagedOnly = false): Promise<strin
} }
if (!diff) { if (!diff) {
throw new Error("No changes found to generate a commit message from") throw new Error("Aucune modification trouvée pour générer un message de commit")
} }
return diff return diff
+5 -5
View File
@@ -164,13 +164,13 @@ function extractAnthropicDelta(data: string): string | null {
export function createProvider(config: vscode.WorkspaceConfiguration): AIProvider { export function createProvider(config: vscode.WorkspaceConfiguration): AIProvider {
const provider = config.get<string>("provider", "anthropic") const provider = config.get<string>("provider", "anthropic")
const apiKey = config.get<string>("apiKey", "") const apiKey = config.get<string>("apiKey", "")
const model = config.get<string>("model", "claude-haiku-4-5-20251001") const model = config.get<string>("model", "claude-sonnet-4-6")
const customBaseUrl = config.get<string>("baseUrl", "") const customBaseUrl = config.get<string>("baseUrl", "")
switch (provider) { switch (provider) {
case "anthropic": { case "anthropic": {
const baseUrl = customBaseUrl || "https://api.anthropic.com/v1" const baseUrl = customBaseUrl || "https://api.anthropic.com/v1"
if (!apiKey) throw new Error("Anthropic API key is required. Set it in Settings → Zemit AI Commit.") if (!apiKey) throw new Error("Clé API Anthropic requise. Configurez-la dans Paramètres → Zemit AI Commit.")
return new AnthropicProvider(apiKey, model, baseUrl) return new AnthropicProvider(apiKey, model, baseUrl)
} }
case "ollama": { case "ollama": {
@@ -179,7 +179,7 @@ export function createProvider(config: vscode.WorkspaceConfiguration): AIProvide
} }
default: { default: {
const baseUrl = customBaseUrl || "https://api.openai.com/v1" const baseUrl = customBaseUrl || "https://api.openai.com/v1"
if (!apiKey) throw new Error("OpenAI API key is required. Set it in Settings → Zemit AI Commit.") if (!apiKey) throw new Error("Clé API OpenAI requise. Configurez-la dans Paramètres → Zemit AI Commit.")
return new OpenAICompatibleProvider(apiKey, model, baseUrl) return new OpenAICompatibleProvider(apiKey, model, baseUrl)
} }
} }
@@ -195,7 +195,7 @@ export async function fetchAvailableModels(config: vscode.WorkspaceConfiguration
switch (provider) { switch (provider) {
case "anthropic": { case "anthropic": {
const baseUrl = customBaseUrl || "https://api.anthropic.com/v1" const baseUrl = customBaseUrl || "https://api.anthropic.com/v1"
if (!apiKey) throw new Error("Anthropic API key is required. Set it in Settings → Zemit AI Commit.") if (!apiKey) throw new Error("Clé API Anthropic requise. Configurez-la dans Paramètres → Zemit AI Commit.")
const response = await fetch(`${baseUrl}/models`, { const response = await fetch(`${baseUrl}/models`, {
headers: { headers: {
"x-api-key": apiKey, "x-api-key": apiKey,
@@ -208,7 +208,7 @@ export async function fetchAvailableModels(config: vscode.WorkspaceConfiguration
} }
case "openai": { case "openai": {
const baseUrl = customBaseUrl || "https://api.openai.com/v1" const baseUrl = customBaseUrl || "https://api.openai.com/v1"
if (!apiKey) throw new Error("OpenAI API key is required. Set it in Settings → Zemit AI Commit.") if (!apiKey) throw new Error("Clé API OpenAI requise. Configurez-la dans Paramètres → Zemit AI Commit.")
const response = await fetch(`${baseUrl}/models`, { const response = await fetch(`${baseUrl}/models`, {
headers: { Authorization: `Bearer ${apiKey}` }, headers: { Authorization: `Bearer ${apiKey}` },
}) })