diff --git a/package.json b/package.json index 22a6d81..4d170ae 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "color": "#1e1e2e", "theme": "dark" }, - "activationEvents": [], + "activationEvents": [ + "onStartupFinished" + ], "main": "./out/extension.js", "contributes": { "commands": [ @@ -69,161 +71,207 @@ } ] }, - "configuration": { - "title": "Nuvo Commit", - "properties": { - "nuvoCommit.autoAccept": { - "type": "boolean", - "default": true, - "order": 1, - "description": "Skip the approval dialog and directly fill the commit message input. Disable to see the approval dialog." - }, - "nuvoCommit.autoCommit": { - "type": "boolean", - "default": false, - "order": 2, - "description": "Run `git commit -m ` automatically after the user accepts the suggestion." - }, - "nuvoCommit.includeBody": { - "type": "boolean", - "default": false, - "order": 3, - "description": "Generate a commit body after the Conventional Commit header. Disabled by default." - }, - "nuvoCommit.maxDiffChars": { - "type": "number", - "default": 12000, - "minimum": 1000, - "order": 4, - "description": "Maximum diff characters sent to the model. Diffs above this are truncated." - }, - "nuvoCommit.pullRequestBaseBranch": { - "type": "string", - "default": "", - "order": 5, - "description": "Base branch used when generating pull request content. Leave empty to auto-detect origin/HEAD, then main, then master." - }, - "nuvoCommit.pullRequestOpenCreateView": { - "type": "boolean", - "default": true, - "order": 6, - "description": "Open the GitHub Pull Requests create view after accepting generated pull request content." - }, - "nuvoCommit.pullRequestIncludeCommitList": { - "type": "boolean", - "default": true, - "order": 7, - "description": "Include branch commit summaries in the prompt when generating pull request content." - }, - "nuvoCommit.provider": { - "type": "string", - "enum": [ - "ollama", - "openai", - "anthropic" - ], - "enumDescriptions": [ - "Ollama - Local AI provider for running models locally", - "OpenAI - Cloud API provider (requires API key)", - "Anthropic - Cloud API provider (requires API key)" - ], - "default": "ollama", - "order": 8, - "description": "AI provider used to generate commit messages." - }, - "nuvoCommit.ollama.endpoint": { - "type": "string", - "default": "http://localhost:11434/api/generate", - "order": 9, - "description": "Ollama API endpoint URL." - }, - "nuvoCommit.ollama.model": { - "type": "string", - "default": "qwen3:4b", - "order": 10, - "examples": [ - "qwen3:4b", - "llama3.2:3b", - "mistral:7b", - "codellama:7b", - "deepseek-coder:6.7b" - ], - "description": "Ollama model identifier." - }, - "nuvoCommit.openai.endpoint": { - "type": "string", - "default": "", - "order": 11, - "description": "OpenAI API endpoint URL. Leave empty to use the default OpenAI endpoint." - }, - "nuvoCommit.openai.model": { - "type": "string", - "default": "gpt-4o-mini", - "order": 12, - "examples": [ - "gpt-4o", - "gpt-4o-mini", - "local-model" - ], - "description": "OpenAI model identifier." - }, - "nuvoCommit.anthropic.endpoint": { - "type": "string", - "default": "", - "order": 13, - "description": "Anthropic API endpoint URL. Leave empty to use the default Anthropic endpoint." - }, - "nuvoCommit.anthropic.model": { - "type": "string", - "default": "claude-3-5-sonnet-20241022", - "order": 14, - "examples": [ - "claude-sonnet-4-20250514", - "claude-3-5-sonnet-20241022" - ], - "description": "Anthropic model identifier." - }, - "nuvoCommit.requestTimeoutMs": { - "type": "number", - "default": 30000, - "minimum": 1000, - "order": 15, - "description": "Maximum time in milliseconds to wait for a provider response before aborting the request." - }, - "nuvoCommit.apiKey": { - "type": "string", - "default": "", - "order": 16, - "markdownDeprecationMessage": "**Deprecated:** API keys are now stored securely. Run the `Nuvo Commit: Set API Key` command instead. Any value here is migrated automatically and then cleared.", - "description": "Deprecated. Use the 'Nuvo Commit: Set API Key' command instead." - }, - "nuvoCommit.endpoint": { - "type": "string", - "default": "http://localhost:11434/api/generate", - "order": 17, - "markdownDeprecationMessage": "**Deprecated:** Use provider-specific endpoint settings such as `nuvoCommit.ollama.endpoint`, `nuvoCommit.openai.endpoint`, or `nuvoCommit.anthropic.endpoint`.", - "description": "Deprecated fallback endpoint setting." - }, - "nuvoCommit.model": { - "type": "string", - "default": "qwen3:4b", - "order": 18, - "examples": [ - "qwen3:4b", - "llama3.2:3b", - "mistral:7b", - "codellama:7b", - "deepseek-coder:6.7b", - "gpt-4o", - "gpt-4o-mini", - "claude-sonnet-4-20250514", - "claude-3-5-sonnet-20241022" - ], - "markdownDeprecationMessage": "**Deprecated:** Use provider-specific model settings such as `nuvoCommit.ollama.model`, `nuvoCommit.openai.model`, or `nuvoCommit.anthropic.model`.", - "description": "Deprecated fallback model setting." + "configuration": [ + { + "id": "nuvoCommit.general", + "title": "General", + "order": 1, + "properties": { + "nuvoCommit.autoAccept": { + "type": "boolean", + "default": true, + "order": 1, + "description": "Skip the approval dialog and directly fill the commit message input. Disable to see the approval dialog." + }, + "nuvoCommit.autoCommit": { + "type": "boolean", + "default": false, + "order": 2, + "description": "Run `git commit -m ` automatically after the user accepts the suggestion." + }, + "nuvoCommit.includeBody": { + "type": "boolean", + "default": false, + "order": 3, + "description": "Generate a commit body after the Conventional Commit header. Disabled by default." + }, + "nuvoCommit.maxDiffChars": { + "type": "number", + "default": 12000, + "minimum": 1000, + "order": 4, + "description": "Maximum diff characters sent to the model. Diffs above this are truncated." + } + } + }, + { + "id": "nuvoCommit.pullrequests", + "title": "Pull Requests", + "order": 2, + "properties": { + "nuvoCommit.pullRequestBaseBranch": { + "type": "string", + "default": "", + "order": 1, + "description": "Base branch used when generating pull request content. Leave empty to auto-detect origin/HEAD, then main, then master." + }, + "nuvoCommit.pullRequestOpenCreateView": { + "type": "boolean", + "default": true, + "order": 2, + "description": "Open the GitHub Pull Requests create view after accepting generated pull request content." + }, + "nuvoCommit.pullRequestIncludeCommitList": { + "type": "boolean", + "default": true, + "order": 3, + "description": "Include branch commit summaries in the prompt when generating pull request content." + } + } + }, + { + "id": "nuvoCommit.provider", + "title": "Provider", + "order": 3, + "properties": { + "nuvoCommit.provider": { + "type": "string", + "enum": [ + "ollama", + "openai", + "anthropic" + ], + "enumDescriptions": [ + "Ollama - Local AI provider for running models locally", + "OpenAI - Cloud API provider (requires API key)", + "Anthropic - Cloud API provider (requires API key)" + ], + "default": "ollama", + "order": 1, + "description": "AI provider used to generate commit messages." + }, + "nuvoCommit.requestTimeoutMs": { + "type": "number", + "default": 30000, + "minimum": 1000, + "order": 2, + "description": "Maximum time in milliseconds to wait for a provider response before aborting the request." + } + } + }, + { + "id": "nuvoCommit.ollama", + "title": "Ollama", + "order": 4, + "properties": { + "nuvoCommit.ollama.endpoint": { + "type": "string", + "default": "http://localhost:11434/api/generate", + "order": 1, + "description": "Ollama API endpoint URL." + }, + "nuvoCommit.ollama.model": { + "type": "string", + "default": "qwen3:4b", + "order": 2, + "examples": [ + "qwen3:4b", + "llama3.2:3b", + "mistral:7b", + "codellama:7b", + "deepseek-coder:6.7b" + ], + "description": "Ollama model identifier." + } + } + }, + { + "id": "nuvoCommit.openai", + "title": "OpenAI", + "order": 5, + "properties": { + "nuvoCommit.openai.endpoint": { + "type": "string", + "default": "", + "order": 1, + "description": "OpenAI API endpoint URL. Leave empty to use the default OpenAI endpoint." + }, + "nuvoCommit.openai.model": { + "type": "string", + "default": "gpt-4o-mini", + "order": 2, + "examples": [ + "gpt-4o", + "gpt-4o-mini", + "local-model" + ], + "description": "OpenAI model identifier." + } + } + }, + { + "id": "nuvoCommit.anthropic", + "title": "Anthropic", + "order": 6, + "properties": { + "nuvoCommit.anthropic.endpoint": { + "type": "string", + "default": "", + "order": 1, + "description": "Anthropic API endpoint URL. Leave empty to use the default Anthropic endpoint." + }, + "nuvoCommit.anthropic.model": { + "type": "string", + "default": "claude-3-5-sonnet-20241022", + "order": 2, + "examples": [ + "claude-sonnet-4-20250514", + "claude-3-5-sonnet-20241022" + ], + "description": "Anthropic model identifier." + } + } + }, + { + "id": "nuvoCommit.deprecated", + "title": "Deprecated", + "order": 7, + "properties": { + "nuvoCommit.apiKey": { + "type": "string", + "default": "", + "order": 1, + "markdownDeprecationMessage": "**Deprecated:** API keys are now stored securely. Run the `Nuvo Commit: Set API Key` command instead. Any value here is migrated automatically and then cleared.", + "description": "Deprecated. Use the 'Nuvo Commit: Set API Key' command instead." + }, + "nuvoCommit.endpoint": { + "type": "string", + "default": "http://localhost:11434/api/generate", + "order": 2, + "markdownDeprecationMessage": "**Deprecated:** Use provider-specific endpoint settings such as `nuvoCommit.ollama.endpoint`, `nuvoCommit.openai.endpoint`, or `nuvoCommit.anthropic.endpoint`.", + "description": "Deprecated fallback endpoint setting." + }, + "nuvoCommit.model": { + "type": "string", + "default": "qwen3:4b", + "order": 3, + "examples": [ + "qwen3:4b", + "llama3.2:3b", + "mistral:7b", + "codellama:7b", + "deepseek-coder:6.7b", + "gpt-4o", + "gpt-4o-mini", + "claude-sonnet-4-20250514", + "claude-3-5-sonnet-20241022" + ], + "markdownDeprecationMessage": "**Deprecated:** Use provider-specific model settings such as `nuvoCommit.ollama.model`, `nuvoCommit.openai.model`, or `nuvoCommit.anthropic.model`.", + "description": "Deprecated fallback model setting." + } } } - } + ] }, "scripts": { "clean": "node -e \"require('fs').rmSync('out',{recursive:true,force:true})\"", diff --git a/src/extension.ts b/src/extension.ts index a26a8c3..68c718e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1010,6 +1010,28 @@ export function activate(context: vscode.ExtensionContext): void { vscode.commands.registerCommand("nuvoCommit.selectModel", selectModel), vscode.commands.registerCommand("nuvoCommit.setApiKey", setApiKey), ); + + // Always-visible provider/model; click opens the settings picker (Provider is its first item). + const status = vscode.window.createStatusBarItem( + vscode.StatusBarAlignment.Right, + ); + status.command = "nuvoCommit.settings"; + status.tooltip = "Nuvo Commit: switch provider or model"; + const refreshStatus = () => { + status.text = statusBarText(readSettings()); + status.show(); + }; + refreshStatus(); + context.subscriptions.push( + status, + vscode.workspace.onDidChangeConfiguration((e) => { + if (e.affectsConfiguration("nuvoCommit")) refreshStatus(); + }), + ); +} + +export function statusBarText(settings: Settings): string { + return `$(sparkle) ${providerLabel(settings.provider)}: ${settings.model}`; } export function deactivate(): void {} diff --git a/src/extension.unit.test.ts b/src/extension.unit.test.ts index 9392f3b..da1a5f5 100644 --- a/src/extension.unit.test.ts +++ b/src/extension.unit.test.ts @@ -9,19 +9,27 @@ import { openGitHubPullRequestCreate, orderBaseBranches, readSettings, + statusBarText, updateActiveProvider, updateProviderEndpoint, updateProviderModel, } from "./extension"; -const packageManifest = packageJson as { +const packageManifest = packageJson as unknown as { contributes: { configuration: { + title: string; properties: Record; - }; + }[]; }; }; +const properties: Record = + Object.assign( + {}, + ...packageManifest.contributes.configuration.map((c) => c.properties), + ); + function mockNuvoConfig(values: Record) { const update = jest.fn(); const config = { @@ -71,10 +79,7 @@ describe("extension helpers", () => { }); it("should expose includeBody as a boolean checkbox setting", () => { - const setting = - packageManifest.contributes.configuration.properties[ - "nuvoCommit.includeBody" - ]; + const setting = properties["nuvoCommit.includeBody"]; expect(setting).toEqual( expect.objectContaining({ @@ -85,8 +90,6 @@ describe("extension helpers", () => { }); it("should expose pull request settings", () => { - const properties = packageManifest.contributes.configuration.properties; - expect(properties["nuvoCommit.pullRequestBaseBranch"]).toEqual( expect.objectContaining({ type: "string", @@ -108,8 +111,6 @@ describe("extension helpers", () => { }); it("should expose provider-specific settings", () => { - const properties = packageManifest.contributes.configuration.properties; - expect(properties["nuvoCommit.ollama.model"]).toEqual( expect.objectContaining({ type: "string", default: "qwen3:4b" }), ); @@ -396,6 +397,29 @@ describe("extension helpers", () => { }); }); +describe("settings layout", () => { + it("groups settings into titled categories", () => { + expect( + packageManifest.contributes.configuration.map((c) => c.title), + ).toEqual([ + "General", + "Pull Requests", + "Provider", + "Ollama", + "OpenAI", + "Anthropic", + "Deprecated", + ]); + }); +}); + +describe("statusBarText", () => { + it("shows the active provider and model", () => { + mockNuvoConfig({ provider: "openai", "openai.model": "gpt-4o" }); + expect(statusBarText(readSettings())).toBe("$(sparkle) OpenAI: gpt-4o"); + }); +}); + describe("orderBaseBranches", () => { it("moves the default branch to the top", () => { expect(orderBaseBranches(["develop", "master", "x"], "master")).toEqual([