Merge port/pr-642:AI 生成提交信息(Ctrl+G / 多行提交框 / 可固定生成模型)

无冲突。本分支是「建议提交信息」的唯一实现来源(纯逻辑 src/commit-message.ts +
三条宿主路由 ctx.llm / agentDefaultModel / 设置缝 + CommitModelSettings.tsx +
多行 textarea / Ctrl+G / ✨ 按钮);随后合入的 port/pr-434 只取其 Push/Pull 部分,
434 的重复 suggest 接线/图标/CSS/词典键在那一批里删除。
This commit is contained in:
Menghuan1918 committed 2026-10-05 02:38:21 +08:00
commit 2b19de4e4e
34 files changed
+2177 -43

No files matched your search

+51
View File
@@ -80,6 +80,42 @@ export interface GitWorktree {
changes: number
}
/** One model a provider advertises (the pinned commit-message dropdown). */
export interface GitModelInfo {
/** Provider-side model id (dispatched verbatim). */
id: string
/** Display name; equals `id` when the adapter reports none. */
name: string
}
/** One provider route with the models its adapter advertises. */
export interface GitModelProvider {
provider: string
name: string
models: GitModelInfo[]
}
/** The model catalog `git.models` answers with. It merges three sources so
* the picker is usable even before a conversation has run:
* - `providers`: the adapters' own catalog (`llm.listModels`),
* - `recent`: routes THIS session already used (newest first),
* - `default`: the harness default selection (`agent-default-model`), which
* exists without any session at all.
* `llm` says whether the harness exposes an LLM surface: an empty catalog is
* then "no adapters registered", not "the route failed". */
export interface GitModelCatalog {
llm: boolean
providers: GitModelProvider[]
recent: GitModelRoute[]
default?: GitModelRoute
}
/** One pinned-model value: the route the host dispatches on. */
export interface GitModelRoute {
provider: string
model: string
}
/** One git log row. */
export interface GitLogEntry {
/** Short hash (7+ chars, display). */
@@ -349,6 +385,21 @@ export const api = {
call<{ ok: true }>('git.unstage', gitPayload(scope, worktree, { ...(path !== undefined ? { path } : {}) })),
gitCommit: (scope: SessionScope, message: string, worktree?: string) =>
call<{ ok: true }>('git.commit', gitPayload(scope, worktree, { message })),
/** Ask the host to generate a commit message from the pending changes: it
* streams the diff through the harness LLM on the pinned route (or the
* conversation's own) and answers with the route actually used.
* `language` follows the sidebar's active locale ('zh' | 'en'). */
gitSuggestMessage: (scope: SessionScope, language: 'zh' | 'en', worktree?: string) =>
call<{ message: string; provider: string; model: string }>('git.suggest-message', gitPayload(scope, worktree, { language })),
/** The discoverable provider/model catalog for the Git card's pinned-route
* setting (advisory; empty when the harness exposes no LLM service). */
gitModels: (scope: SessionScope, signal?: AbortSignal) =>
call<GitModelCatalog>('git.models', scopePayload(scope, {}), signal),
/** The route the NEXT commit-message suggestion would use (pinned → the
* conversation's own → the harness default); absent when none resolves.
* Cheaper than `gitModels`: no catalog discovery. */
gitCommitModel: (scope: SessionScope, signal?: AbortSignal) =>
call<{ route?: GitModelRoute; pinned: boolean }>('git.commit-model', scopePayload(scope, {}), signal),
gitBranch: (scope: SessionScope, worktree?: string, signal?: AbortSignal) =>
call<{ current: string; names: string[] }>('git.branch', gitPayload(scope, worktree, {}), signal),
gitCheckout: (scope: SessionScope, branch: string, worktree?: string) =>