✨ feat(vscode): 提交代码按钮可配置 Claude profile

This commit is contained in:
cruldra committed 2026-07-25 07:29:05 +08:00
1 parent e9543d37ce
commit 84a5cda8d2
11 files changed
+269 -9

No files matched your search

+27
View File
@@ -13,6 +13,8 @@
import { readFileSync } from 'node:fs'
import path from 'node:path'
import type { ExtensionContext } from 'vscode'
import { listClaudeProfiles } from '../cc/profiles'
import { seedCommitProfilePath } from '../cc/commitProfile'
/**
* Fallback prompt strings used when the on-disk markdown can't be read.
@@ -169,6 +171,11 @@ export interface Settings {
* (drag to 完成 when PR merge conflicts). Empty = DEFAULT_PROFILE_PATH.
*/
conflictResolutionProfilePath: string
/**
* 工具栏「提交代码」使用的 Claude profile 绝对路径。
* 空串 = 未配置 → 提交严格失败。升级时 key 缺失会 seed deepseek-v4-pro(若存在)。
*/
commitProfilePath: string
/**
* codex 审查会话使用的模型(`-c model=`)。空串 = 不传,用 codex
* `config.toml` 默认。
@@ -209,6 +216,7 @@ function defaults(ctx: ExtensionContext): Settings {
youtrackProjectShortName: '',
youtrackCloseCommand: '',
conflictResolutionProfilePath: '',
commitProfilePath: '',
codexModel: '',
codexReasoningEffort: '',
profilesDirectory: '',
@@ -296,6 +304,11 @@ export function getSettings(ctx: ExtensionContext): Settings {
const conflictResolutionProfilePath = typeof stored.conflictResolutionProfilePath === 'string'
? stored.conflictResolutionProfilePath
: base.conflictResolutionProfilePath
// 提交 profile:'' 有意义(= 未配置 → 提交失败)。缺 key 时先给 '';
// deepseek seed 在 getEffectiveCommitProfilePath 里做(需异步 list profiles)。
const commitProfilePath = typeof stored.commitProfilePath === 'string'
? stored.commitProfilePath
: base.commitProfilePath
// codex 模型 / 思考级别:'' 有意义(= 用 codex 默认),不强制回退。
const codexModel = typeof stored.codexModel === 'string'
? stored.codexModel
@@ -328,12 +341,26 @@ export function getSettings(ctx: ExtensionContext): Settings {
youtrackProjectShortName,
youtrackCloseCommand,
conflictResolutionProfilePath,
commitProfilePath,
codexModel,
codexReasoningEffort,
profilesDirectory,
}
}
/**
* 读取工具栏「提交代码」有效的 profile path。
* ① raw stored 已有 key(含用户清空的 '')→ 原样返回
* ② key 从未出现 → list profiles 后 seed deepseek-v4-pro(不写回磁盘)
*/
export async function getEffectiveCommitProfilePath(ctx: ExtensionContext): Promise<string> {
const stored = ctx.globalState.get<Partial<Settings>>(SETTINGS_KEY) ?? {}
if (typeof stored.commitProfilePath === 'string')
return stored.commitProfilePath
const profiles = await listClaudeProfiles()
return seedCommitProfilePath(undefined, profiles)
}
export async function saveSettings(ctx: ExtensionContext, next: Partial<Settings>): Promise<void> {
const current = ctx.globalState.get<Partial<Settings>>(SETTINGS_KEY) ?? {}
const merged: Partial<Settings> = { ...current, ...next }