feat: 设置面板 + Provider 扩展 + 构建脚本

- 设置面板:三步引导 / AI 配置 / API Key / 规则管理 / 连接测试
- Provider 重构:统一 OpenAICompatibleProvider 基类,新增 Gemini/Claude/混元/智谱等
- 审查面板 Webview:三 Tab、统计卡片、问题列表、postMessage 通信
- esbuild 构建脚本 + 生产打包 + PMD 下载
- 保存文件自动静态分析(500ms debounce)
This commit is contained in:
范智鹏
2026-07-16 22:20:30 +08:00
parent 1144c9b5db
commit 805737fcfc
27 changed files with 1130 additions and 481 deletions
@@ -61,7 +61,7 @@ import * as vscode from 'vscode';
export interface AIConfig {
provider: string;
model: string;
endpoint: string;
baseUrl: string;
temperature: number;
timeout: number;
outputLanguage: string;
@@ -72,7 +72,7 @@ export function getAIConfig(): AIConfig {
return {
provider: config.get<string>('ai.provider', 'deepseek'),
model: config.get<string>('ai.model', 'deepseek-chat'),
endpoint: config.get<string>('ai.endpoint', 'https://api.deepseek.com/v1'),
baseUrl: config.get<string>('ai.baseUrl', 'https://api.deepseek.com/v1'),
temperature: config.get<number>('ai.temperature', 0.2),
timeout: config.get<number>('ai.timeout', 300),
outputLanguage: config.get<string>('ai.outputLanguage', 'zh-CN'),
@@ -86,7 +86,7 @@ export function getAIConfig(): AIConfig {
|-----|------|--------|
| `ai.provider` | enum | `deepseek` |
| `ai.model` | string | `deepseek-chat` |
| `ai.endpoint` | string | `https://api.deepseek.com/v1` |
| `ai.baseUrl` | string | `https://api.deepseek.com/v1` |
| `ai.temperature` | number | 0.2 |
| `ai.timeout` | number | 300 |
| `ai.outputLanguage` | string | `zh-CN` |
@@ -33,7 +33,7 @@ export abstract class AIProvider {
constructor(
protected apiKey: string,
protected endpoint: string
protected baseUrl: string
) {}
abstract chat(
@@ -56,7 +56,7 @@ export class DeepSeekProvider extends AIProvider {
name = 'DeepSeek';
async chat(systemPrompt: string, userPrompt: string, options: ChatOptions): Promise<string> {
const url = `${this.endpoint}/chat/completions`;
const url = `${this.baseUrl}/chat/completions`;
const body = JSON.stringify({
model: options.model,
@@ -112,7 +112,7 @@ export class OpenAIProvider extends AIProvider {
name = 'OpenAI';
async chat(systemPrompt: string, userPrompt: string, options: ChatOptions): Promise<string> {
const url = `${this.endpoint}/chat/completions`;
const url = `${this.baseUrl}/chat/completions`;
const body = JSON.stringify({
model: options.model,
@@ -165,19 +165,19 @@ import { AIProvider } from './providers/base';
import { DeepSeekProvider } from './providers/deepseek';
import { OpenAIProvider } from './providers/openai';
type ProviderConstructor = new (apiKey: string, endpoint: string) => AIProvider;
type ProviderConstructor = new (apiKey: string, baseUrl: string) => AIProvider;
const registry: Record<string, ProviderConstructor> = {
deepseek: DeepSeekProvider,
openai: OpenAIProvider,
};
export function createProvider(providerId: string, apiKey: string, endpoint: string): AIProvider {
export function createProvider(providerId: string, apiKey: string, baseUrl: string): AIProvider {
const Cls = registry[providerId];
if (!Cls) {
throw new Error(`未知的 Provider: ${providerId}`);
}
return new Cls(apiKey, endpoint);
return new Cls(apiKey, baseUrl);
}
export function getProviderIds(): string[] {
@@ -142,7 +142,7 @@ export async function runAIReview(
let provider: AIProvider;
try {
provider = createProvider(config.provider, apiKey, config.endpoint);
provider = createProvider(config.provider, apiKey, config.baseUrl);
} catch (err) {
return {
customRuleResults: [],
@@ -343,7 +343,7 @@ context.subscriptions.push(
cancellable: false,
}, async () => {
try {
const provider = createProvider(config.provider, apiKey, config.endpoint);
const provider = createProvider(config.provider, apiKey, config.baseUrl);
await provider.chat('回复 ok', 'ping', {
model: config.model,
temperature: 0,