dsh-vscode-mode 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -10
- package/lib/client.js +143 -52
- package/lib/client.js.map +1 -1
- package/lib/index.js +3549 -1465
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/dsh-vscodemode-html-plan/LICENSE +202 -0
- package/skills/dsh-vscodemode-html-plan/SKILL.md +147 -0
- package/skills/dsh-vscodemode-html-plan/examples/scheduled-send.html +298 -0
- package/skills/dsh-vscodemode-html-plan/references/blocks.md +227 -0
- package/skills/dsh-vscodemode-html-plan/references/subagent-brief.md +17 -0
- package/skills/dsh-vscodemode-html-plan/references/upstream-SKILL.md +174 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +564 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +1299 -0
- package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +300 -0
- package/src/ai/llmTask.ts +178 -0
- package/src/ai/llmTypes.ts +6 -0
- package/src/ai/svnCommitMsg.ts +107 -0
- package/src/ai/svnTriage.ts +34 -85
- package/src/client/aiCommit.ts +57 -0
- package/src/client/htmlPlan/HtmlPlanPanel.ts +261 -0
- package/src/client/htmlPlan/planActions.ts +347 -0
- package/src/client/htmlPlan/planPage.ts +333 -0
- package/src/client/htmlPreview.ts +218 -0
- package/src/client/index.ts +8 -0
- package/src/client/officialSidebar.ts +11 -3
- package/src/client/planState.ts +8 -2
- package/src/client/sidebar/menuItems.ts +1 -0
- package/src/client/sidebar/panels/SvnPanel.ts +17 -0
- package/src/client/sidebar/types.ts +2 -0
- package/src/client/styles/editor.css +77 -0
- package/src/client/svnActions.ts +7 -0
- package/src/client/svnCommit.ts +109 -0
- package/src/client/svnNotice.ts +1 -1
- package/src/client/svnStatus.ts +5 -2
- package/src/client/ui/EditorView.ts +85 -7
- package/src/client/ui/McpSettings.ts +59 -0
- package/src/client/ui/SvnAiPlanDialog.ts +24 -4
- package/src/client/ui/SvnCommitDialog.ts +458 -0
- package/src/client/ui/commandCatalog.ts +11 -0
- package/src/client/ui/svnCommitModel.ts +204 -0
- package/src/fileOpenSettings.ts +113 -5
- package/src/htmlPlanCommand.ts +176 -0
- package/src/index.ts +4 -0
- package/src/shared/keybindings.ts +11 -0
- package/src/shared/rpc.ts +13 -4
- package/src/shared/svn.ts +191 -10
- package/src/shared/svnActions.ts +16 -0
- package/src/svn.ts +205 -47
- package/src/svnCommit.ts +348 -0
- package/src/svnCore.ts +254 -0
- package/src/svnToolJson.ts +73 -0
- package/src/svnTools.ts +566 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-vscode-mode client — HTML 文件判定与官方 HTML 渲染器探测。
|
|
3
|
+
*
|
|
4
|
+
* 背景:.html/.htm 的网页渲染交给官方 documentpreviews 的内置 html body;
|
|
5
|
+
* 本模块只回答两个问题:一是该路径是否 HTML,二是当前 DSH 是否真的注册了
|
|
6
|
+
* HTML 渲染器。探针必须有界、可卸载、异常不抛:旧版 DSH 没有 documentPreviews
|
|
7
|
+
* 服务时,调用方据此回退到本插件文本编辑,而不是把文件送进官方纯文本查看器。
|
|
8
|
+
* 纯函数 + 模块级探针态,无 DOM 依赖,可在 node 环境单测。
|
|
9
|
+
* @author ddj 2026年11月21号
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** 可进入官方 HTML 预览的扩展名(小写、无点)。 */
|
|
13
|
+
const HTML_EXT_SET: Set<string> = new Set(['html', 'htm'])
|
|
14
|
+
|
|
15
|
+
/** 官方 documentpreviews 服务名(官方以 ctx.reflect.provide('documentPreviews') 暴露)。 */
|
|
16
|
+
export const DOCUMENT_PREVIEWS_SERVICE = 'documentPreviews'
|
|
17
|
+
|
|
18
|
+
/** 探针默认重试次数(与既有可选服务探测的 15×2s 同节奏)。 */
|
|
19
|
+
const PROBE_ATTEMPTS = 15
|
|
20
|
+
|
|
21
|
+
/** 探针默认重试间隔(毫秒)。 */
|
|
22
|
+
const PROBE_INTERVAL_MS = 2000
|
|
23
|
+
|
|
24
|
+
/** 官方 body 定义的最小结构面。 */
|
|
25
|
+
interface PreviewDefinition {
|
|
26
|
+
extensions?: unknown
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 官方 documentpreviews 服务的最小结构面。 */
|
|
30
|
+
export interface DocumentPreviewsLike {
|
|
31
|
+
getSnapshot?: () => unknown
|
|
32
|
+
subscribe?: (listener: () => void) => unknown
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 探针安装选项(schedule 可注入,便于单测)。 */
|
|
36
|
+
export interface HtmlPreviewProbeOptions {
|
|
37
|
+
/** 延时调度器(缺省 setTimeout);注入后单测可同步推进。 */
|
|
38
|
+
schedule?: (fn: () => void, ms: number) => void
|
|
39
|
+
/** 尝试次数(含首次;缺省 15)。 */
|
|
40
|
+
attempts?: number
|
|
41
|
+
/** 尝试间隔毫秒(缺省 2000)。 */
|
|
42
|
+
intervalMs?: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 模块级探针态:true = 官方 HTML 渲染器可用。 */
|
|
46
|
+
let officialAvailable = false
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 判断路径是否为可进入官方预览的 HTML 文件(取 basename 后缀,大小写不敏感)。
|
|
50
|
+
* @author ddj 2026年11月21号
|
|
51
|
+
* @param path 文件路径(/ 或 \ 分隔均可)
|
|
52
|
+
* @returns 是否 HTML 文件
|
|
53
|
+
*/
|
|
54
|
+
export function isHtmlPath(path: unknown): boolean {
|
|
55
|
+
const base = String(path ?? '').replace(/\\/g, '/').split('/').pop() ?? ''
|
|
56
|
+
const dot = base.lastIndexOf('.')
|
|
57
|
+
if (dot <= 0) return false
|
|
58
|
+
return HTML_EXT_SET.has(base.slice(dot + 1).toLowerCase())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 判断官方 documentpreviews 快照里是否声明了 html/htm 渲染器。
|
|
63
|
+
* 容忍带点、大小写、null/异常行;任何畸形输入一律按「没有」处理。
|
|
64
|
+
* @author ddj 2026年11月21号
|
|
65
|
+
* @param snapshot getSnapshot() 的返回值
|
|
66
|
+
* @returns 是否命中 HTML body
|
|
67
|
+
*/
|
|
68
|
+
export function hasHtmlPreviewBody(snapshot: unknown): boolean {
|
|
69
|
+
if (!Array.isArray(snapshot)) return false
|
|
70
|
+
for (const row of snapshot) {
|
|
71
|
+
if (row === null || typeof row !== 'object') continue
|
|
72
|
+
const extensions = (row as PreviewDefinition).extensions
|
|
73
|
+
if (!Array.isArray(extensions)) continue
|
|
74
|
+
for (const raw of extensions) {
|
|
75
|
+
if (typeof raw !== 'string') continue
|
|
76
|
+
if (HTML_EXT_SET.has(raw.trim().replace(/^\./, '').toLowerCase())) return true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 当前是否可用官方 HTML 渲染器。
|
|
84
|
+
* @author ddj 2026年11月21号
|
|
85
|
+
* @returns 探针结论
|
|
86
|
+
*/
|
|
87
|
+
export function hasOfficialHtmlPreview(): boolean {
|
|
88
|
+
return officialAvailable
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 直接写入探针结论(测试注入与运行时校正用)。
|
|
93
|
+
* @author ddj 2026年11月21号
|
|
94
|
+
* @param available 是否可用
|
|
95
|
+
*/
|
|
96
|
+
export function setOfficialHtmlPreview(available: boolean): void {
|
|
97
|
+
officialAvailable = available === true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 复位探针结论(卸载/测试隔离用)。
|
|
102
|
+
* @author ddj 2026年11月21号
|
|
103
|
+
*/
|
|
104
|
+
export function resetHtmlPreviewProbe(): void {
|
|
105
|
+
officialAvailable = false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 缺省调度器:setTimeout,并在可能时 unref,避免长驻进程被探针拖住。
|
|
110
|
+
* @author ddj 2026年11月21号
|
|
111
|
+
* @param fn 回调
|
|
112
|
+
* @param ms 延时毫秒
|
|
113
|
+
*/
|
|
114
|
+
function defaultSchedule(fn: () => void, ms: number): void {
|
|
115
|
+
const timer = setTimeout(fn, ms) as unknown as { unref?: () => void }
|
|
116
|
+
try {
|
|
117
|
+
timer.unref?.()
|
|
118
|
+
} catch {
|
|
119
|
+
/* 无 unref 的运行环境忽略 */
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 安装官方 HTML 渲染器探针:命中即置真并订阅后续变化;未命中按间隔有界重试。
|
|
125
|
+
* 服务缺失、快照畸形、订阅抛错都只影响探针结论,不影响插件装配。
|
|
126
|
+
* @author ddj 2026年11月21号
|
|
127
|
+
* @param ctx 客户端上下文(只需 get)
|
|
128
|
+
* @param options 调度与重试参数
|
|
129
|
+
* @returns 幂等卸载器(同时复位结论)
|
|
130
|
+
*/
|
|
131
|
+
export function installHtmlPreviewProbe(
|
|
132
|
+
ctx: { get: (name: string) => unknown },
|
|
133
|
+
options: HtmlPreviewProbeOptions = {},
|
|
134
|
+
): () => void {
|
|
135
|
+
const schedule = typeof options.schedule === 'function' ? options.schedule : defaultSchedule
|
|
136
|
+
const attempts = Number.isFinite(options.attempts) ? Math.max(1, Number(options.attempts)) : PROBE_ATTEMPTS
|
|
137
|
+
const intervalMs = Number.isFinite(options.intervalMs) ? Math.max(0, Number(options.intervalMs)) : PROBE_INTERVAL_MS
|
|
138
|
+
|
|
139
|
+
let disposed = false
|
|
140
|
+
let remaining = attempts
|
|
141
|
+
let offSubscribe: (() => void) | null = null
|
|
142
|
+
let subscribing = false
|
|
143
|
+
|
|
144
|
+
/** @private @author ddj 2026年11月21号 @returns Optional previews service. */
|
|
145
|
+
function serviceOf(): DocumentPreviewsLike | undefined {
|
|
146
|
+
try {
|
|
147
|
+
return ctx.get(DOCUMENT_PREVIEWS_SERVICE) as DocumentPreviewsLike | undefined
|
|
148
|
+
} catch {
|
|
149
|
+
return undefined
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 订阅服务变化(只订一次;回调自身异常不扩散)。
|
|
155
|
+
* @author ddj 2026年11月21号
|
|
156
|
+
* @param service 已命中的服务
|
|
157
|
+
*/
|
|
158
|
+
function attach(service: DocumentPreviewsLike): void {
|
|
159
|
+
if (offSubscribe !== null || subscribing || typeof service.subscribe !== 'function') return
|
|
160
|
+
subscribing = true
|
|
161
|
+
try {
|
|
162
|
+
const off = service.subscribe(() => {
|
|
163
|
+
refresh()
|
|
164
|
+
})
|
|
165
|
+
offSubscribe = typeof off === 'function' ? (off as () => void) : null
|
|
166
|
+
} catch {
|
|
167
|
+
offSubscribe = null
|
|
168
|
+
} finally {
|
|
169
|
+
subscribing = false
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 读取一次快照并更新结论;命中时补订阅。
|
|
175
|
+
* @author ddj 2026年11月21号
|
|
176
|
+
* @returns 本次是否命中
|
|
177
|
+
*/
|
|
178
|
+
function refresh(): boolean {
|
|
179
|
+
if (disposed) return false
|
|
180
|
+
const service = serviceOf()
|
|
181
|
+
if (!service || typeof service.getSnapshot !== 'function') return false
|
|
182
|
+
let present = false
|
|
183
|
+
try {
|
|
184
|
+
present = hasHtmlPreviewBody(service.getSnapshot())
|
|
185
|
+
} catch {
|
|
186
|
+
present = false
|
|
187
|
+
}
|
|
188
|
+
officialAvailable = present
|
|
189
|
+
// 服务已就绪就订阅:官方 html body 可能晚于服务注册(客户端插件加载顺序不定),
|
|
190
|
+
// 只在命中时订阅会漏掉「先有服务、后注册 html body」的时序。
|
|
191
|
+
attach(service)
|
|
192
|
+
return present
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 一轮探测:命中即停,否则按剩余次数继续调度。
|
|
197
|
+
* @author ddj 2026年11月21号
|
|
198
|
+
*/
|
|
199
|
+
function tick(): void {
|
|
200
|
+
if (disposed) return
|
|
201
|
+
if (refresh()) return
|
|
202
|
+
remaining -= 1
|
|
203
|
+
if (remaining > 0) schedule(tick, intervalMs)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
tick()
|
|
207
|
+
return () => {
|
|
208
|
+
disposed = true
|
|
209
|
+
officialAvailable = false
|
|
210
|
+
const off = offSubscribe
|
|
211
|
+
offSubscribe = null
|
|
212
|
+
try {
|
|
213
|
+
off?.()
|
|
214
|
+
} catch {
|
|
215
|
+
/* 卸载异常不影响调用方 */
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -43,6 +43,8 @@ import { clientSummary } from './compatSummary.js'
|
|
|
43
43
|
import { detectSidebarService, hasSideRoute, installSideEditor, routeSideEditor, setEnsureSideEditor, SIDEBAR_INSTALL_CMD } from './sidebarBridge.js'
|
|
44
44
|
import { detectOfficial, installOfficial, registerOfficialFileClaim, OFFICIAL_TAB_KIND, OFFICIAL_TAB_TITLE, isEditorTabActive, markEditorActive, restoreEditorTab, buildFileAddress, readSavedTab, setEditorTabScope } from './officialSidebar.js'
|
|
45
45
|
import { setNativeCsv, setNativeOpenHandler, resetNativeOpen } from './nativeOpenStore.js'
|
|
46
|
+
import { hasOfficialHtmlPreview, installHtmlPreviewProbe, isHtmlPath } from './htmlPreview.js'
|
|
47
|
+
import { installHtmlPlanActions } from './htmlPlan/planActions.js'
|
|
46
48
|
import { setFeaturePrefs } from './featurePrefs.js'
|
|
47
49
|
import { SideEditorTab } from './ui/SideEditorTab.js'
|
|
48
50
|
import { OfficialSideTab } from './ui/OfficialSideTab.js'
|
|
@@ -326,6 +328,10 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
326
328
|
let claimDisposer: (() => void) | null = null
|
|
327
329
|
/** 「添加到对话」动作集:编辑区/Tab 右键菜单注入文件引用与代码块(conversation 服务缺失时各动作安全降级)。 */
|
|
328
330
|
const addToConversation = createAddToConversation(ctx)
|
|
331
|
+
// 官方 HTML 渲染器探针:可选服务,缺失/旧版一律回退文本编辑,不阻断装配。
|
|
332
|
+
ctx.effect(() => installHtmlPreviewProbe(ctx, { schedule }), 'vscode-mode: html preview probe')
|
|
333
|
+
// HTML 计划页动作桥:状态读取 / 官方审批作答 / /plan off / 回填输入框(全部可选服务)。
|
|
334
|
+
ctx.effect(() => installHtmlPlanActions(ctx), 'vscode-mode: html plan actions')
|
|
329
335
|
|
|
330
336
|
/**
|
|
331
337
|
* 读取规则列表(rules.list;失败抛错,由快捷菜单按「未校验」降级)。
|
|
@@ -772,6 +778,8 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
772
778
|
//(claim 的 canOpen 同步让位该范围,否则地址又被认领转发回本插件);形态撤下时解绑
|
|
773
779
|
ctx.effect(() => {
|
|
774
780
|
setNativeOpenHandler((path) => {
|
|
781
|
+
// 旧版/无官方 HTML 渲染器:不调 openResource,回退本插件文本编辑。
|
|
782
|
+
if (isHtmlPath(path) && !hasOfficialHtmlPreview()) return false
|
|
775
783
|
const scope = readSessionScope(ctx)
|
|
776
784
|
if (!scope.sessionId) return false
|
|
777
785
|
official.service.openResource?.(buildFileAddress(path, scope.sessionId))
|
|
@@ -14,6 +14,7 @@ import { setEnsureSideEditor } from './sidebarBridge.js'
|
|
|
14
14
|
import { CACHE_KEY } from './paths.js'
|
|
15
15
|
import { OFFICE_EXT, BLIND_EXT, suffixOf } from '../shared/nativeOpen.js'
|
|
16
16
|
import { inNativePath } from './nativeOpenStore.js'
|
|
17
|
+
import { hasOfficialHtmlPreview, isHtmlPath } from './htmlPreview.js'
|
|
17
18
|
import { univerCapability } from './univer/store.js'
|
|
18
19
|
import { isOfficePath, isUniverPath } from '../shared/univer.js'
|
|
19
20
|
|
|
@@ -46,16 +47,20 @@ export const OFFICIAL_FILE_KIND = 'edrvEditorFile'
|
|
|
46
47
|
const DEFER_EXT_SET: Set<string> = new Set([...OFFICE_EXT, ...BLIND_EXT])
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
* 该路径是否应让位官方查看器(Office 文档
|
|
50
|
+
* 该路径是否应让位官方查看器(Office 文档 / 官方不可预览的二进制容器 / 可渲染的 HTML)。
|
|
50
51
|
* 命中即不认领 `dsh-resource://file/**`,回落官方预览/提示。
|
|
52
|
+
* HTML 仅在官方 HTML 渲染器确实可用时让位:旧版 DSH 缺少 documentPreviews 的
|
|
53
|
+
* html body 时继续由本插件文本编辑,避免把可编辑源码送进官方纯文本查看器。
|
|
51
54
|
* 注:用户经设置 nativeOpenExts 追加的范围不走本函数,由 claim 的 canOpen 与
|
|
52
55
|
* 文件树 openFile 叠加 nativeOpenStore 判定(见 registerOfficialFileClaim)。
|
|
53
|
-
* @author ddj 2026年09月18号
|
|
56
|
+
* @author ddj 2026年09月18号 / 2026年11月21号
|
|
54
57
|
* @param path 文件路径(工作区相对或绝对)
|
|
55
58
|
* @returns 是否让位官方
|
|
56
59
|
*/
|
|
57
60
|
export function deferToOfficial(path: unknown): boolean {
|
|
58
|
-
|
|
61
|
+
const ext = suffixOf(path)
|
|
62
|
+
if (ext === 'html' || ext === 'htm') return hasOfficialHtmlPreview()
|
|
63
|
+
return ext !== 'xlsx' && DEFER_EXT_SET.has(ext)
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
/** 官方 Tab 打开参数(官方运行时不校验的 JSON,正文经 navigation.params 读回)。 */
|
|
@@ -369,6 +374,9 @@ export function registerOfficialFileClaim(options: {
|
|
|
369
374
|
if (parsed === null) return false
|
|
370
375
|
if (parsed.sessionId && univerCapability(parsed.sessionId)?.available && (isUniverPath(parsed.path) || isOfficePath(parsed.path))) return true
|
|
371
376
|
if (isUniverPath(parsed.path)) return false
|
|
377
|
+
// 绝对域地址没有 session 段,官方 fallback 的 canOpen 只认 session 域;
|
|
378
|
+
// HTML 让位会变成无人接手的死路,故绝对域仍由本插件打开(文本编辑)。
|
|
379
|
+
if (isHtmlPath(parsed.path) && !parsed.sessionId) return true
|
|
372
380
|
return !deferToOfficial(parsed.path) && (suffixOf(parsed.path) === 'xlsx' || !inNativePath(parsed.path))
|
|
373
381
|
},
|
|
374
382
|
title: (address: string) => officialFileTitle(address),
|
package/src/client/planState.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Plan identities and live-only event reduction. @author ddj 2026年10月08号 */
|
|
2
|
-
|
|
2
|
+
import { planPagePathOf } from './htmlPlan/planPage.js'
|
|
3
|
+
|
|
4
|
+
export interface PlanDocument { address: string; markdown: string; title: string; htmlPath?: string }
|
|
3
5
|
export interface PlanOpen { path?: string; plan?: PlanDocument }
|
|
4
6
|
export interface PlanEntry { type?: string; event: { type: string; seq?: number; data: unknown } }
|
|
5
7
|
export interface PlanWindow { revision: number; entries: readonly PlanEntry[]; change: { kind: string; entries?: readonly PlanEntry[] } }
|
|
@@ -51,7 +53,11 @@ export function planDocument(address: string, value: unknown): PlanDocument | un
|
|
|
51
53
|
if (!isPlanAddress(address) || typeof data.markdown !== 'string') return undefined
|
|
52
54
|
const title = /^#\s+(\S[^\r\n]*)/.exec(data.markdown.trim())?.[1]
|
|
53
55
|
if (!title) return undefined
|
|
54
|
-
|
|
56
|
+
// HTML 计划页:正文标记行命中时随文档携带路径,计划页签据此切到 iframe 渲染。
|
|
57
|
+
const htmlPath = planPagePathOf(data.markdown)
|
|
58
|
+
return htmlPath
|
|
59
|
+
? { address, markdown: data.markdown, title, htmlPath }
|
|
60
|
+
: { address, markdown: data.markdown, title }
|
|
55
61
|
}
|
|
56
62
|
/** @private @author ddj 2026年10月08号 @param sessionId Current session. @param path Explicit plan path. @param cwd Workspace. Stores bounded associations, not file contents. */
|
|
57
63
|
function associate(sessionId: string, path: string, cwd: string): void {
|
|
@@ -543,6 +543,7 @@ function treeRunCtx(target: TreeMenuTarget, ctx: SidebarCtx): SvnActionRunCtx {
|
|
|
543
543
|
openSvnDiff: (p) => ctx.openSvnDiff?.(p),
|
|
544
544
|
openSvnUpdate: (p) => ctx.openSvnUpdate?.(p),
|
|
545
545
|
openSvnLog: ctx.openSvnLog,
|
|
546
|
+
openCommitDialog: (seed) => ctx.openSvnCommit?.(seed),
|
|
546
547
|
refreshChanges: ctx.refreshSvnChanges,
|
|
547
548
|
// 确认对话框可注入(测试/宿主可替换;缺省走 window.confirm)
|
|
548
549
|
confirm: ctx.confirm,
|
|
@@ -445,6 +445,12 @@ function svnToolbarEl(props) {
|
|
|
445
445
|
className: 'edrv-svn-act', title: '导出当前列表为 HTML 报表(仅本地查看,不外发)',
|
|
446
446
|
onClick: handlers.onExportHtml,
|
|
447
447
|
}, '导出 HTML'),
|
|
448
|
+
React.createElement('button', {
|
|
449
|
+
className: 'edrv-svn-act edrv-svnplan-primary',
|
|
450
|
+
disabled: handlers.busy,
|
|
451
|
+
title: '打开原生提交对话框(勾选文件 → 写信息 → 提交;未版本控制默认不勾)',
|
|
452
|
+
onClick: () => handlers.commit?.(),
|
|
453
|
+
}, '提交…'),
|
|
448
454
|
((paths.unversioned.length || paths.revert.length)
|
|
449
455
|
? React.createElement('span', { className: 'edrv-svn-sep' })
|
|
450
456
|
: null),
|
|
@@ -997,6 +1003,8 @@ export function SvnPanel(props) {
|
|
|
997
1003
|
onExportHtml: () => onExport('html'),
|
|
998
1004
|
add: onAdd,
|
|
999
1005
|
revert: onRevert,
|
|
1006
|
+
// 提交入口:只打开对话框(提交范围与信息由人在对话框里确认)
|
|
1007
|
+
commit: () => ctxRef.current?.openSvnCommit?.({}),
|
|
1000
1008
|
}),
|
|
1001
1009
|
})
|
|
1002
1010
|
/** @private @author ddj 2026年10月15号 Open the shared update window independently of selection and local changes. */
|
|
@@ -1051,6 +1059,15 @@ export function SvnPanel(props) {
|
|
|
1051
1059
|
onResume: aiResume,
|
|
1052
1060
|
onCancelRest: aiCancelRest,
|
|
1053
1061
|
onClose: closeAiPlan,
|
|
1062
|
+
// 逐组提交只预填提交对话框(绝不自动提交)
|
|
1063
|
+
onCommitGroup: (group) => {
|
|
1064
|
+
closeAiPlan()
|
|
1065
|
+
const body = group.body ?? ''
|
|
1066
|
+
ctxRef.current?.openSvnCommit?.({
|
|
1067
|
+
paths: group.paths,
|
|
1068
|
+
message: body ? group.subject + '\n\n' + body : group.subject,
|
|
1069
|
+
})
|
|
1070
|
+
},
|
|
1054
1071
|
})
|
|
1055
1072
|
: null
|
|
1056
1073
|
|
|
@@ -52,6 +52,8 @@ export interface SidebarCtx {
|
|
|
52
52
|
openSvnUpdate?: (path: string) => void
|
|
53
53
|
/** 打开 SVN 日志弹窗(P3;菜单/命令栏「查看日志」)。 */
|
|
54
54
|
openSvnLog?: (path?: string) => void
|
|
55
|
+
/** 打开原生提交对话框(seed = 预选路径/预填信息)。 */
|
|
56
|
+
openSvnCommit?: (seed?: { paths?: string[]; message?: string }) => void
|
|
55
57
|
/** 确认对话框(破坏性动作守卫;缺省走 window.confirm,测试可注入)。 */
|
|
56
58
|
confirm?: (message: string) => boolean
|
|
57
59
|
/** 面板动作反馈(如右键菜单操作结果 → 编辑区路径栏状态)。 */
|
|
@@ -135,6 +135,19 @@
|
|
|
135
135
|
[data-edrv-view] .edrv-editor-area > .edrv-diffbar { max-height: calc(100% - 20px); }
|
|
136
136
|
[data-edrv-view] .edrv-diffbar-row { display: flex; align-items: center; gap: 6px; height: 36px; padding: 4px 5px 4px 12px; flex-wrap: nowrap; }
|
|
137
137
|
[data-edrv-view] .edrv-diffbar-count { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary, #1f2933); min-width: 42px; text-align: center; white-space: nowrap; cursor: pointer; }
|
|
138
|
+
|
|
139
|
+
/* HTML 计划页签(计划模式):状态条 + 官方动作 + 沙箱 iframe。
|
|
140
|
+
iframe 采用 allow-scripts 但不给 allow-same-origin,页面与宿主隔离。 */
|
|
141
|
+
[data-edrv-view] .edrv-htmlplan { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--dsw-alias-bg-base, #fff); }
|
|
142
|
+
[data-edrv-view] .edrv-htmlplan-bar { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; flex: 0 0 auto; border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0,0,0,.08)); }
|
|
143
|
+
[data-edrv-view] .edrv-htmlplan-title { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; }
|
|
144
|
+
[data-edrv-view] .edrv-htmlplan-state { font-size: 11px; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--dsw-alias-border-l1, rgba(0,0,0,.12)); color: var(--dsw-alias-label-secondary, #6b7280); white-space: nowrap; }
|
|
145
|
+
[data-edrv-view] .edrv-htmlplan-state-reviewing { color: var(--dsw-alias-state-warning-primary, #b45309); border-color: currentColor; }
|
|
146
|
+
[data-edrv-view] .edrv-htmlplan-state-approved { color: var(--dsw-alias-state-success-primary, #15803d); border-color: currentColor; }
|
|
147
|
+
[data-edrv-view] .edrv-htmlplan-state-planning, [data-edrv-view] .edrv-htmlplan-state-revising { color: var(--dsw-alias-state-accent-primary, #2563eb); border-color: currentColor; }
|
|
148
|
+
[data-edrv-view] .edrv-htmlplan-notice { flex: 0 0 auto; padding: 3px 10px; font-size: 11px; color: var(--dsw-alias-label-secondary, #6b7280); }
|
|
149
|
+
[data-edrv-view] .edrv-htmlplan-warn { flex: 0 0 auto; padding: 4px 10px; font-size: 11px; color: var(--dsw-alias-state-warning-primary, #b45309); background: var(--dsw-alias-bg-layer-1, rgba(255,193,7,.1)); border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0,0,0,.08)); }
|
|
150
|
+
[data-edrv-view] .edrv-htmlplan-frame { flex: 1 1 auto; width: 100%; min-height: 0; border: none; background: #fff; }
|
|
138
151
|
[data-edrv-view] .edrv-diffbar-count.edrv-count-file { min-width: 64px; cursor: default; }
|
|
139
152
|
[data-edrv-view] .edrv-diffbar-file { flex: 1; min-width: 0; font-size: 11px; color: var(--dsw-alias-label-tertiary, #9aa5b1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
140
153
|
[data-edrv-view] .edrv-pill { font-size: 11px; padding: 3px 10px; border: none; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; }
|
|
@@ -762,6 +775,70 @@
|
|
|
762
775
|
[data-edrv-view] .edrv-update-counts { flex-basis: 100%; }
|
|
763
776
|
}
|
|
764
777
|
|
|
778
|
+
/* 原生 SVN 提交窗口:勾选范围是主信息,骨架与更新窗口一致;本前缀规则独立,不覆盖侧栏 .edrv-svn-*。 */
|
|
779
|
+
[data-edrv-view] .edrv-floating-content.edrv-svncommit-dialog { padding: 0; gap: 0; overflow: hidden; }
|
|
780
|
+
[data-edrv-view] .edrv-svncommit-close { display: grid; place-items: center; flex: none; width: 24px; height: 22px; border: 0; border-radius: 4px; background: none; color: var(--dsw-alias-label-secondary, #485762); font-size: 12px; line-height: 1; cursor: pointer; }
|
|
781
|
+
[data-edrv-view] .edrv-svncommit-close:disabled { opacity: .35; cursor: default; }
|
|
782
|
+
[data-edrv-view] .edrv-svncommit-close:not(:disabled):hover { background: var(--dsw-alias-interactive-bg-hover, #e7edf0); color: var(--dsw-alias-label-primary, #1f2933); }
|
|
783
|
+
[data-edrv-view] .edrv-svncommit-close:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #2869b4); outline-offset: 1px; }
|
|
784
|
+
[data-edrv-view] .edrv-svncommit-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: none; min-height: 34px; padding: 6px 14px; border-bottom: 1px solid var(--dsw-alias-border-l1, #d9e0e4); background: var(--dsw-alias-bg-layer-1, #fff); }
|
|
785
|
+
[data-edrv-view] .edrv-svncommit-ctl { flex: none; max-width: 160px; height: 24px; padding: 0 8px; font-size: 11px; line-height: 22px; }
|
|
786
|
+
[data-edrv-view] .edrv-svncommit-bar .edrv-svn-check { flex: none; gap: 4px; font-size: 11px; color: var(--dsw-alias-label-secondary, #485762); }
|
|
787
|
+
[data-edrv-view] .edrv-svncommit-badge { flex: none; margin-left: auto; padding: 1px 8px; border: 1px solid var(--dsw-alias-border-l1, #d9e0e4); border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f1f4f5); color: var(--dsw-alias-label-secondary, #485762); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
788
|
+
[data-edrv-view] .edrv-svncommit-table { display: flex; flex-direction: column; flex: 1; min-height: 120px; margin: 10px 14px 0; border: 1px solid var(--dsw-alias-border-l1, #d9e0e4); border-radius: 5px; overflow: hidden; background: var(--dsw-alias-bg-layer-1, #fff); }
|
|
789
|
+
[data-edrv-view] .edrv-svncommit-cols, [data-edrv-view] .edrv-svncommit-row { display: grid; grid-template-columns: 34px 24px minmax(0, 1fr); align-items: center; }
|
|
790
|
+
[data-edrv-view] .edrv-svncommit-cols { flex: none; height: 28px; padding: 0 10px; background: var(--dsw-alias-bg-layer-2, #f1f4f5); border-bottom: 1px solid var(--dsw-alias-border-l1, #d9e0e4); color: var(--dsw-alias-label-secondary, #485762); font-size: 11px; font-weight: 600; }
|
|
791
|
+
[data-edrv-view] .edrv-svncommit-cols > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
792
|
+
[data-edrv-view] .edrv-svncommit-list { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
|
|
793
|
+
[data-edrv-view] .edrv-svncommit-group { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 10px; background: var(--dsw-alias-bg-layer-2, #f1f4f5); border-bottom: 1px solid var(--dsw-alias-border-l1, #d9e0e4); color: var(--dsw-alias-label-secondary, #485762); font-size: 11px; font-weight: 600; }
|
|
794
|
+
[data-edrv-view] .edrv-svncommit-gname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
795
|
+
[data-edrv-view] .edrv-svncommit-gnote { flex: none; padding: 0 6px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover, #e7edf0); color: var(--dsw-alias-state-warn-primary, #a05d22); font-size: 10px; font-weight: 400; }
|
|
796
|
+
[data-edrv-view] .edrv-svncommit-gcount { flex: none; margin-left: auto; color: var(--dsw-alias-label-tertiary, #65737c); font-size: 10px; font-weight: 400; font-variant-numeric: tabular-nums; }
|
|
797
|
+
[data-edrv-view] .edrv-svncommit-row { height: 26px; padding: 0 10px; font-size: 12px; color: var(--dsw-alias-label-primary, #202932); }
|
|
798
|
+
[data-edrv-view] .edrv-svncommit-row:hover { background: var(--dsw-alias-interactive-bg-hover, #ecf3f9); }
|
|
799
|
+
[data-edrv-view] .edrv-svncommit-pick { display: flex; align-items: center; }
|
|
800
|
+
[data-edrv-view] .edrv-svncommit-path { min-width: 0; padding-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ds-font-family-code, ui-monospace, monospace); font-size: 11px; }
|
|
801
|
+
[data-edrv-view] .edrv-svncommit-empty { display: grid; place-items: center; flex: 1; padding: 24px; color: var(--dsw-alias-label-tertiary, #65737c); font-size: 12px; }
|
|
802
|
+
[data-edrv-view] .edrv-svncommit-cb { position: relative; flex: none; box-sizing: border-box; width: 13px; height: 13px; margin: 0; border: 1px solid var(--dsw-alias-border-l2, #cdd6da); border-radius: 3px; background: var(--dsw-alias-bg-layer-1, #fff); cursor: pointer; appearance: none; -webkit-appearance: none; }
|
|
803
|
+
[data-edrv-view] .edrv-svncommit-cb:checked, [data-edrv-view] .edrv-svncommit-cb:indeterminate { border-color: var(--dsw-alias-brand-primary, #2869b4); background: var(--dsw-alias-brand-primary, #2869b4); }
|
|
804
|
+
/* 勾/半勾用 SVG 背景绘制:::after 在 input 上不生成。 */
|
|
805
|
+
[data-edrv-view] .edrv-svncommit-cb:checked { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2.4 6.3 4.7 8.5 9.6 3.3' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-size: 12px 12px; background-position: center; background-repeat: no-repeat; }
|
|
806
|
+
[data-edrv-view] .edrv-svncommit-cb:indeterminate { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><rect x='2.4' y='5' width='7.2' height='2' rx='1' fill='%23fff'/></svg>"); background-size: 12px 12px; background-position: center; background-repeat: no-repeat; }
|
|
807
|
+
[data-edrv-view] .edrv-svncommit-cb:disabled { opacity: .45; cursor: default; }
|
|
808
|
+
[data-edrv-view] .edrv-svncommit-cb:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #2869b4); outline-offset: 1px; }
|
|
809
|
+
[data-edrv-view] .edrv-svncommit-compose { display: flex; flex-direction: column; gap: 4px; flex: none; padding: 10px 14px 0; }
|
|
810
|
+
[data-edrv-view] .edrv-svncommit-composehead { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: 11px; }
|
|
811
|
+
[data-edrv-view] .edrv-svncommit-label { flex: none; font-weight: 600; color: var(--dsw-alias-label-primary, #1f2933); }
|
|
812
|
+
[data-edrv-view] .edrv-svncommit-hint { flex: none; color: var(--dsw-alias-label-tertiary, #65737c); font-variant-numeric: tabular-nums; }
|
|
813
|
+
[data-edrv-view] .edrv-svncommit-error { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-state-error-primary, #b93b43); }
|
|
814
|
+
[data-edrv-view] .edrv-svncommit-warn { color: var(--dsw-alias-state-warn-primary, #a05d22); }
|
|
815
|
+
[data-edrv-view] .edrv-svncommit-msg { box-sizing: border-box; flex: none; width: 100%; min-height: 76px; max-height: 30vh; padding: 7px 9px; border: 1px solid var(--dsw-alias-border-l1, #d9e0e4); border-radius: 6px; background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #202932); font-family: var(--ds-font-family-code, ui-monospace, monospace); font-size: 12px; line-height: 1.6; resize: vertical; }
|
|
816
|
+
[data-edrv-view] .edrv-svncommit-msg:focus { outline: none; border-color: var(--dsw-alias-brand-primary, #2869b4); box-shadow: 0 0 0 1px var(--dsw-alias-brand-primary, #2869b4); }
|
|
817
|
+
[data-edrv-view] .edrv-svncommit-msg::placeholder { color: var(--dsw-alias-label-tertiary, #9aa5b1); }
|
|
818
|
+
[data-edrv-view] .edrv-svncommit-result { flex: none; max-height: 96px; margin: 8px 14px 0; padding: 6px 10px; overflow: auto; border: 1px solid var(--dsw-alias-border-l1, #d9e0e4); border-left-width: 3px; border-radius: 5px; background: var(--dsw-alias-bg-layer-2, #f1f4f5); color: var(--dsw-alias-label-secondary, #485762); font-family: var(--ds-font-family-code, ui-monospace, monospace); font-size: 11px; line-height: 1.6; user-select: text; }
|
|
819
|
+
[data-edrv-view] .edrv-svncommit-result.is-ok { border-left-color: var(--dsw-alias-state-success-primary, #23704e); color: var(--dsw-alias-label-primary, #202932); }
|
|
820
|
+
[data-edrv-view] .edrv-svncommit-telemetry { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; flex: none; min-height: 26px; padding: 6px 14px; font-size: 11px; color: var(--dsw-alias-label-secondary, #485762); font-variant-numeric: tabular-nums; }
|
|
821
|
+
[data-edrv-view] .edrv-svncommit-ai { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary, #65737c); }
|
|
822
|
+
[data-edrv-view] .edrv-svncommit-foot { display: flex; align-items: center; gap: 8px; flex: none; padding: 10px 14px; border-top: 1px solid var(--dsw-alias-border-l1, #d9e0e4); font-size: 11px; }
|
|
823
|
+
[data-edrv-view] .edrv-svncommit-counts { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-secondary, #485762); font-variant-numeric: tabular-nums; }
|
|
824
|
+
[data-edrv-view] .edrv-svncommit-foot .edrv-svn-act { flex: none; min-width: 74px; height: 26px; padding: 0 10px; font-size: 11px; line-height: 24px; }
|
|
825
|
+
[data-edrv-view] .edrv-svncommit-foot .edrv-svncommit-primary { border-color: var(--dsw-alias-brand-primary, #2869b4); background: var(--dsw-alias-brand-primary, #2869b4); color: #fff; font-weight: 600; }
|
|
826
|
+
[data-edrv-view] .edrv-svncommit-foot .edrv-svncommit-primary:not(:disabled):hover { background: var(--dsw-alias-brand-primary-hover, #1f5aa0); color: #fff; }
|
|
827
|
+
[data-edrv-view] .edrv-svncommit-foot .edrv-svn-act:focus-visible, [data-edrv-view] .edrv-svncommit-ctl:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #2869b4); outline-offset: 2px; }
|
|
828
|
+
[data-edrv-view] .edrv-svncommit-foot .edrv-svn-act:disabled { opacity: .45; cursor: default; }
|
|
829
|
+
@media (max-width: 620px) {
|
|
830
|
+
[data-edrv-view] .edrv-svncommit-bar { padding: 6px 8px; }
|
|
831
|
+
[data-edrv-view] .edrv-svncommit-badge { margin-left: 0; }
|
|
832
|
+
[data-edrv-view] .edrv-svncommit-table { margin: 8px 8px 0; }
|
|
833
|
+
[data-edrv-view] .edrv-svncommit-cols, [data-edrv-view] .edrv-svncommit-row { grid-template-columns: 26px 24px minmax(0, 1fr); }
|
|
834
|
+
[data-edrv-view] .edrv-svncommit-row { height: auto; min-height: 34px; padding: 3px 8px; }
|
|
835
|
+
[data-edrv-view] .edrv-svncommit-path { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
|
836
|
+
[data-edrv-view] .edrv-svncommit-compose { padding: 8px 8px 0; }
|
|
837
|
+
[data-edrv-view] .edrv-svncommit-telemetry { padding: 6px 8px; }
|
|
838
|
+
[data-edrv-view] .edrv-svncommit-foot { flex-wrap: wrap; padding: 8px; }
|
|
839
|
+
[data-edrv-view] .edrv-svncommit-counts { flex-basis: 100%; }
|
|
840
|
+
}
|
|
841
|
+
|
|
765
842
|
/* ===== 侧栏形态(betterSidebar 面板内编辑区) ===== */
|
|
766
843
|
[data-edrv-view][data-edrv-layout='side'] { box-sizing: border-box; height: 100%; }
|
|
767
844
|
|
package/src/client/svnActions.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface SvnActionRunCtx {
|
|
|
35
35
|
openPatchDialog?: (payload: { path: string; text: string; truncated: boolean; binary: boolean }) => void
|
|
36
36
|
/** 打开目录对比对话框(diff-summarize 动作;目标目录相对路径,'' = 工作副本根)。 */
|
|
37
37
|
openSumDialog?: (path: string) => void
|
|
38
|
+
/** 打开原生提交对话框(commit 动作;seed = 预选路径/预填信息)。 */
|
|
39
|
+
openCommitDialog?: (seed?: { paths?: string[]; message?: string }) => void
|
|
38
40
|
/** 重查变更清单(写操作后)。 */
|
|
39
41
|
refreshChanges?: () => void
|
|
40
42
|
/** 就地打开文件(日志面板点击变更文件)。 */
|
|
@@ -119,6 +121,11 @@ export const SVN_ACTION_RUNNERS: Record<string, SvnActionRunner> = {
|
|
|
119
121
|
}
|
|
120
122
|
afterWrite(ctx, svnCleanup(ctx.sessionId, options))
|
|
121
123
|
},
|
|
124
|
+
// 原生提交:打出对话框,提交范围与信息由人确认(动作只负责打开,不直接提交)
|
|
125
|
+
commit: (ctx) => {
|
|
126
|
+
if (!ctx.openCommitDialog) { ctx.notify?.('提交对话框不可用(请刷新页面)'); return }
|
|
127
|
+
ctx.openCommitDialog(ctx.path ? { paths: [ctx.path] } : {})
|
|
128
|
+
},
|
|
122
129
|
// Tortoise 组:统一由 svnTortoise 发射(action 由 id 后缀解析)
|
|
123
130
|
'tortoise-commit': (ctx) => runTortoiseAction(ctx, 'commit'),
|
|
124
131
|
'tortoise-log': (ctx) => runTortoiseAction(ctx, 'log'),
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-vscode-mode client — 提交通道(计划 / 原生提交 / AI 提交信息)的 RPC 封装。
|
|
3
|
+
*
|
|
4
|
+
* 只做「调用 + 文案归一」,不持状态:勾选态与弹窗生命周期在 ui/SvnCommitDialog,
|
|
5
|
+
* 纯投影规则在 ui/svnCommitModel(可单测)。
|
|
6
|
+
* @author ddj 2026年11月15号
|
|
7
|
+
*/
|
|
8
|
+
import type { AiCommitStyle, SvnCommitPlan, SvnCommitResult } from '../shared/svn.js'
|
|
9
|
+
import { rpc } from './rpc.js'
|
|
10
|
+
|
|
11
|
+
/** 提交计划结果。 */
|
|
12
|
+
export interface SvnCommitPlanOutcome {
|
|
13
|
+
/** 是否成功。 */
|
|
14
|
+
ok: boolean
|
|
15
|
+
/** 计划(ok 时存在)。 */
|
|
16
|
+
plan?: SvnCommitPlan
|
|
17
|
+
/** 反馈文案(失败含原因)。 */
|
|
18
|
+
message: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 提交结果。 */
|
|
22
|
+
export interface SvnCommitDoOutcome {
|
|
23
|
+
/** 是否成功。 */
|
|
24
|
+
ok: boolean
|
|
25
|
+
/** 提交结果(ok 时存在;失败时也可能带 conflicts 等诊断)。 */
|
|
26
|
+
result?: SvnCommitResult
|
|
27
|
+
/** 反馈文案(失败含原因)。 */
|
|
28
|
+
message: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** AI 提交信息结果。 */
|
|
32
|
+
export interface SvnAiCommitOutcome {
|
|
33
|
+
/** 是否成功。 */
|
|
34
|
+
ok: boolean
|
|
35
|
+
/** 首行。 */
|
|
36
|
+
subject?: string
|
|
37
|
+
/** 正文。 */
|
|
38
|
+
body?: string
|
|
39
|
+
/** 完整提交信息(首行 + 空行 + 正文)。 */
|
|
40
|
+
text?: string
|
|
41
|
+
/** 实际使用的模型。 */
|
|
42
|
+
model?: string
|
|
43
|
+
/** 分析统计(文件数 / diff 字节 / 是否含 diff)。 */
|
|
44
|
+
stats?: { files: number; diffBytes: number; diffIncluded: boolean }
|
|
45
|
+
/** 反馈文案(失败含原因)。 */
|
|
46
|
+
message: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 读取提交计划(变更清单 + changelist + 最近信息)。
|
|
51
|
+
* @author ddj 2026年11月15号
|
|
52
|
+
* @param sessionId 会话 id
|
|
53
|
+
* @returns 计划或错误文案
|
|
54
|
+
*/
|
|
55
|
+
export async function svnCommitPlan(sessionId?: string): Promise<SvnCommitPlanOutcome> {
|
|
56
|
+
try {
|
|
57
|
+
const res = await rpc('svn.commitPlan', { sessionId })
|
|
58
|
+
if (!res.ok) return { ok: false, message: '读取提交清单失败:' + res.error }
|
|
59
|
+
return { ok: true, plan: res as unknown as SvnCommitPlan, message: '已读取提交清单' }
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return { ok: false, message: '读取提交清单失败:' + String(error) }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 执行提交(host 会先 status 重查,再按开关自动整理)。
|
|
67
|
+
* @author ddj 2026年11月15号
|
|
68
|
+
* @param sessionId 会话 id
|
|
69
|
+
* @param request 提交请求
|
|
70
|
+
* @returns 提交结果或错误文案
|
|
71
|
+
*/
|
|
72
|
+
export async function svnCommitNow(
|
|
73
|
+
sessionId: string | undefined,
|
|
74
|
+
request: { paths: string[]; message: string; changelist?: string; keepLocks?: boolean; autoAdd?: boolean; autoDelete?: boolean },
|
|
75
|
+
): Promise<SvnCommitDoOutcome> {
|
|
76
|
+
try {
|
|
77
|
+
const res = await rpc('svn.commit', { sessionId, ...request })
|
|
78
|
+
if (!res.ok) return { ok: false, message: '提交失败:' + res.error }
|
|
79
|
+
return { ok: true, result: res as unknown as SvnCommitResult, message: res.summary ?? '提交完成' }
|
|
80
|
+
} catch (error) {
|
|
81
|
+
return { ok: false, message: '提交失败:' + String(error) }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 生成提交信息草稿(只分析给定路径,不提交)。
|
|
87
|
+
* @author ddj 2026年11月15号
|
|
88
|
+
* @param sessionId 会话 id
|
|
89
|
+
* @param paths 提交范围
|
|
90
|
+
* @param style 风格(缺省由 host 按设置决定)
|
|
91
|
+
* @returns 草稿或错误文案
|
|
92
|
+
*/
|
|
93
|
+
export async function svnAiCommitMsg(sessionId: string | undefined, paths: string[], style?: AiCommitStyle): Promise<SvnAiCommitOutcome> {
|
|
94
|
+
try {
|
|
95
|
+
const res = await rpc('svn.aiCommitMsg', { sessionId, paths, ...(style ? { style } : {}) })
|
|
96
|
+
if (!res.ok) return { ok: false, message: 'AI 生成提交信息失败:' + res.error }
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
subject: res.subject,
|
|
100
|
+
body: res.body,
|
|
101
|
+
text: res.message,
|
|
102
|
+
model: res.model,
|
|
103
|
+
stats: res.stats,
|
|
104
|
+
message: '已生成提交信息(请确认后再提交)',
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
return { ok: false, message: 'AI 生成提交信息失败:' + String(error) }
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/client/svnNotice.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function bindSvnScope(sessionId: string | undefined, scope: string): void
|
|
|
8
8
|
scopes.delete(sessionId); scopes.set(sessionId, scope)
|
|
9
9
|
if (scopes.size > 512) scopes.delete(scopes.keys().next().value!)
|
|
10
10
|
}
|
|
11
|
-
const WRITES = new Set<RpcMethod>(['svn.add', 'svn.revert', 'svn.resolve', 'svn.ignore', 'svn.cleanup', 'svn.update', 'svn.tortoise'])
|
|
11
|
+
const WRITES = new Set<RpcMethod>(['svn.add', 'svn.revert', 'svn.resolve', 'svn.ignore', 'svn.cleanup', 'svn.update', 'svn.commit', 'svn.tortoise'])
|
|
12
12
|
/** @public @author ddj 2026年10月10号 @param method RPC operation. @returns Whether local evidence may change (launching a writable native dialog counts, not its completion). */
|
|
13
13
|
export function isSvnWrite(method: RpcMethod): boolean { return WRITES.has(method) }
|
|
14
14
|
/** @public @author ddj 2026年10月10号 @param method Operation. @param args Typed request. @param ok Completed successfully. Notify even failed/partially applied operations; no repository access. */
|
package/src/client/svnStatus.ts
CHANGED
|
@@ -312,6 +312,8 @@ export interface SvnAiPlanOutcome {
|
|
|
312
312
|
plan?: SvnAiPlan
|
|
313
313
|
/** 分析所依据的变更条目总数。 */
|
|
314
314
|
entriesCount?: number
|
|
315
|
+
/** 本次实际分析范围条目数(paths 限定时的条数)。 */
|
|
316
|
+
analyzedCount?: number
|
|
315
317
|
/** 是否附带 diff 上下文(false = paths-only 降级)。 */
|
|
316
318
|
diffIncluded?: boolean
|
|
317
319
|
/** AI 被丢弃的候选路径数(幻觉/状态不符/互斥落选)。 */
|
|
@@ -328,14 +330,15 @@ export interface SvnAiPlanOutcome {
|
|
|
328
330
|
* @param sessionId 会话 id
|
|
329
331
|
* @returns 三段方案与分析元信息
|
|
330
332
|
*/
|
|
331
|
-
export async function svnAiPlan(sessionId: string | undefined): Promise<SvnAiPlanOutcome> {
|
|
333
|
+
export async function svnAiPlan(sessionId: string | undefined, paths?: string[]): Promise<SvnAiPlanOutcome> {
|
|
332
334
|
try {
|
|
333
|
-
const res = await rpc('svn.aiPlan', { sessionId })
|
|
335
|
+
const res = await rpc('svn.aiPlan', { sessionId, ...(paths && paths.length ? { paths } : {}) })
|
|
334
336
|
if (!res.ok) return { ok: false, message: 'AI 分析失败:' + res.error }
|
|
335
337
|
return {
|
|
336
338
|
ok: true,
|
|
337
339
|
plan: res.plan,
|
|
338
340
|
entriesCount: res.entriesCount,
|
|
341
|
+
analyzedCount: res.analyzedCount,
|
|
339
342
|
diffIncluded: res.diffIncluded,
|
|
340
343
|
dropped: res.dropped,
|
|
341
344
|
model: res.model,
|