✨ feat(vscode): 提交代码按钮可配置 Claude profile
This commit is contained in:
@@ -21,7 +21,7 @@ import { loadIssues } from '../gitea/issueLoader'
|
||||
import type { IssueRef } from '../issues/stateRouter'
|
||||
import { closeIssueByRef, mergeIssueState, readIssueState } from '../issues/stateRouter'
|
||||
import { logger } from '../logging/logger'
|
||||
import { getSettings } from '../settings/store'
|
||||
import { getEffectiveCommitProfilePath, getSettings } from '../settings/store'
|
||||
import { webhookCoordinator } from '../webhook/coordinator'
|
||||
import { loadYouTrackIssues } from '../youtrack/issueLoader'
|
||||
import * as issues from './handlers/issues'
|
||||
@@ -864,6 +864,7 @@ export class KanbanWebviewPanel {
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
implTabPostCloseScript: s.implTabPostCloseScript,
|
||||
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
|
||||
commitProfilePath: await getEffectiveCommitProfilePath(this.context),
|
||||
codexModel: s.codexModel,
|
||||
codexReasoningEffort: s.codexReasoningEffort,
|
||||
profilesDirectory: s.profilesDirectory,
|
||||
@@ -930,6 +931,7 @@ export class KanbanWebviewPanel {
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
implTabPostCloseScript: s.implTabPostCloseScript,
|
||||
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
|
||||
commitProfilePath: await getEffectiveCommitProfilePath(this.context),
|
||||
codexModel: s.codexModel,
|
||||
codexReasoningEffort: s.codexReasoningEffort,
|
||||
profilesDirectory: s.profilesDirectory,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { listClaudeProfiles, setProfilesDirOverride } from '../../cc/profiles'
|
||||
import { detectRepo } from '../../git/remote'
|
||||
import { logger } from '../../logging/logger'
|
||||
import { readProfiles, writeProfiles } from '../../profiles/store'
|
||||
import { getSettings, saveSettings } from '../../settings/store'
|
||||
import { getEffectiveCommitProfilePath, getSettings, saveSettings } from '../../settings/store'
|
||||
import { webhookCoordinator } from '../../webhook/coordinator'
|
||||
import { youtrackHost } from '../../youtrack/issueLoader'
|
||||
import { makeNonce } from '../KanbanPanel'
|
||||
@@ -33,6 +33,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
implTabPreCreateScript: string
|
||||
implTabPostCloseScript: string
|
||||
conflictResolutionProfilePath: string
|
||||
commitProfilePath: string
|
||||
codexModel: string
|
||||
codexReasoningEffort: string
|
||||
profilesDirectory: string
|
||||
@@ -64,6 +65,8 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
const trimmedImplPost = payload.implTabPostCloseScript.trim()
|
||||
// conflict-resolution profile: '' is meaningful (= DEFAULT_PROFILE_PATH).
|
||||
const trimmedConflictProfile = payload.conflictResolutionProfilePath.trim()
|
||||
// 提交代码 profile:'' 有意义(= 未配置 → 提交严格失败),只 trim。
|
||||
const trimmedCommitProfile = payload.commitProfilePath.trim()
|
||||
// codex 模型 / 思考级别:空串有意义(= 用 codex 默认),只 trim。
|
||||
const trimmedCodexModel = payload.codexModel.trim()
|
||||
const trimmedCodexReasoningEffort = payload.codexReasoningEffort.trim()
|
||||
@@ -99,6 +102,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
implTabPreCreateScript: trimmedImplPre,
|
||||
implTabPostCloseScript: trimmedImplPost,
|
||||
conflictResolutionProfilePath: trimmedConflictProfile,
|
||||
commitProfilePath: trimmedCommitProfile,
|
||||
codexModel: trimmedCodexModel,
|
||||
codexReasoningEffort: trimmedCodexReasoningEffort,
|
||||
profilesDirectory: trimmedProfilesDirectory,
|
||||
@@ -124,6 +128,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
implTabPreCreateScript: trimmedImplPre,
|
||||
implTabPostCloseScript: trimmedImplPost,
|
||||
conflictResolutionProfilePath: trimmedConflictProfile,
|
||||
commitProfilePath: trimmedCommitProfile,
|
||||
codexModel: trimmedCodexModel,
|
||||
codexReasoningEffort: trimmedCodexReasoningEffort,
|
||||
profilesDirectory: trimmedProfilesDirectory,
|
||||
@@ -194,6 +199,8 @@ export async function handleEditSettingsRequest(panel: KanbanWebviewPanel): Prom
|
||||
const ytTok = s.youtrackBaseUrl.trim()
|
||||
? await getYouTrackToken(panel.context, youtrackHost(s.youtrackBaseUrl.trim()))
|
||||
: undefined
|
||||
// 升级 seed:key 缺失时预填 deepseek path(若有),仅展示不写回。
|
||||
const commitProfilePath = await getEffectiveCommitProfilePath(panel.context)
|
||||
// User clicked the gear themselves — let them back out without saving.
|
||||
panel.postMessage({
|
||||
type: 'settings/show',
|
||||
@@ -215,6 +222,7 @@ export async function handleEditSettingsRequest(panel: KanbanWebviewPanel): Prom
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
implTabPostCloseScript: s.implTabPostCloseScript,
|
||||
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
|
||||
commitProfilePath,
|
||||
codexModel: s.codexModel,
|
||||
codexReasoningEffort: s.codexReasoningEffort,
|
||||
profilesDirectory: s.profilesDirectory,
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import type { Uri } from 'vscode'
|
||||
import type { KanbanWebviewPanel } from '../KanbanPanel'
|
||||
import { accessSync, constants } from 'node:fs'
|
||||
import * as path from 'node:path'
|
||||
import { extensions, workspace } from 'vscode'
|
||||
import { listClaudeProfiles } from '../../cc/profiles'
|
||||
import { resolveCommitProfileForRun } from '../../cc/commitProfile'
|
||||
import { resolveProfilePath } from '../../cc/profiles'
|
||||
import { spawnClaude } from '../../cc/spawnClaude'
|
||||
import { findEnvFiles, lockEnvFiles, unlockEnvFiles } from '../../files/envLock'
|
||||
import { checkBranchSync, runBranchSync } from '../../git/branchSync'
|
||||
import { logger } from '../../logging/logger'
|
||||
import { getSettings } from '../../settings/store'
|
||||
import { getEffectiveCommitProfilePath, getSettings } from '../../settings/store'
|
||||
import { makeNonce } from '../KanbanPanel'
|
||||
|
||||
/**
|
||||
@@ -54,14 +57,30 @@ export async function handleCommitRun(panel: KanbanWebviewPanel): Promise<void>
|
||||
return
|
||||
}
|
||||
|
||||
const profiles = await listClaudeProfiles()
|
||||
const deepseek = profiles.find(p => p.name === 'deepseek-v4-pro')
|
||||
if (!deepseek) {
|
||||
// ① 读有效 path(含升级 seed)→ ② 严格校验 → ③ 才标记 running
|
||||
const raw = await getEffectiveCommitProfilePath(panel.context)
|
||||
const resolution = resolveCommitProfileForRun(
|
||||
raw,
|
||||
resolveProfilePath,
|
||||
(p) => {
|
||||
try {
|
||||
accessSync(p, constants.R_OK)
|
||||
return true
|
||||
}
|
||||
catch {
|
||||
return false
|
||||
}
|
||||
},
|
||||
)
|
||||
if (!resolution.ok) {
|
||||
const message = resolution.reason === 'empty'
|
||||
? '未配置提交代码 profile,请在设置中选择'
|
||||
: `提交 profile 不可用:${path.basename(resolution.profilePath)}(路径:${resolution.profilePath})`
|
||||
panel.postMessage({
|
||||
type: 'toast/show',
|
||||
id: makeNonce(),
|
||||
level: 'error',
|
||||
message: '未找到 deepseek profile(deepseek-v4-pro / deepseek),请在 Claude profiles 目录下创建对应 .json',
|
||||
message,
|
||||
dismissOnTimer: 8000,
|
||||
})
|
||||
return
|
||||
@@ -76,7 +95,7 @@ export async function handleCommitRun(panel: KanbanWebviewPanel): Promise<void>
|
||||
await spawnClaude({
|
||||
prompt: '提交下代码',
|
||||
cwd: workspaceRoot,
|
||||
profilePath: deepseek.path,
|
||||
profilePath: resolution.profilePath,
|
||||
timeoutMs: 30 * 60 * 1000,
|
||||
bare: true,
|
||||
})
|
||||
|
||||
@@ -67,6 +67,7 @@ export type ExtensionToWebview
|
||||
implTabPreCreateScript: string
|
||||
implTabPostCloseScript: string
|
||||
conflictResolutionProfilePath: string
|
||||
commitProfilePath: string
|
||||
codexModel: string
|
||||
codexReasoningEffort: string
|
||||
profilesDirectory: string
|
||||
@@ -133,6 +134,7 @@ export type WebviewToExtension
|
||||
implTabPreCreateScript: string
|
||||
implTabPostCloseScript: string
|
||||
conflictResolutionProfilePath: string
|
||||
commitProfilePath: string
|
||||
codexModel: string
|
||||
codexReasoningEffort: string
|
||||
profilesDirectory: string
|
||||
|
||||
Reference in New Issue
Block a user