✨ feat(vscode): 提交代码按钮可配置 Claude profile
This commit is contained in:
1 parent
e9543d37ce
commit
84a5cda8d2
11 files changed
+269
-9
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 工具栏「提交代码」所用 profile 的解析与默认 seed。
|
||||
* 纯逻辑:不碰 VS Code API,便于单测。
|
||||
*/
|
||||
|
||||
export const DEFAULT_COMMIT_PROFILE_NAME = 'deepseek-v4-pro'
|
||||
|
||||
export interface ProfileRef {
|
||||
name: string
|
||||
path: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级迁移:stored 里从未出现 `commitProfilePath` key 时,
|
||||
* 若本机 profiles 有 deepseek-v4-pro 则预填其 path,否则 ''。
|
||||
* 已出现 key(含用户主动清空的 '')一律原样返回。
|
||||
*/
|
||||
export function seedCommitProfilePath(
|
||||
stored: string | undefined,
|
||||
profiles: ProfileRef[],
|
||||
): string {
|
||||
if (typeof stored === 'string')
|
||||
return stored
|
||||
const hit = profiles.find(p => p.name === DEFAULT_COMMIT_PROFILE_NAME)
|
||||
return hit?.path ?? ''
|
||||
}
|
||||
|
||||
export type CommitProfileResolution
|
||||
= | { ok: true, profilePath: string }
|
||||
| { ok: false, reason: 'empty' }
|
||||
| { ok: false, reason: 'unreadable', profilePath: string }
|
||||
|
||||
/**
|
||||
* 提交前解析:trim → 空失败 → resolvePath → 可读性检查。
|
||||
* resolvePath / isReadable 由调用方注入(跨机 remap / fs)。
|
||||
*/
|
||||
export function resolveCommitProfileForRun(
|
||||
raw: string,
|
||||
resolvePath: (stored: string) => string,
|
||||
isReadable: (profilePath: string) => boolean,
|
||||
): CommitProfileResolution {
|
||||
const trimmed = raw.trim()
|
||||
if (!trimmed)
|
||||
return { ok: false, reason: 'empty' }
|
||||
const profilePath = resolvePath(trimmed)
|
||||
if (!isReadable(profilePath))
|
||||
return { ok: false, reason: 'unreadable', profilePath }
|
||||
return { ok: true, profilePath }
|
||||
}
|
||||
Reference in new issue
Block a user