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.
Files changed (53) hide show
  1. package/README.md +54 -10
  2. package/lib/client.js +143 -52
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +3549 -1465
  5. package/lib/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/skills/dsh-vscodemode-html-plan/LICENSE +202 -0
  8. package/skills/dsh-vscodemode-html-plan/SKILL.md +147 -0
  9. package/skills/dsh-vscodemode-html-plan/examples/scheduled-send.html +298 -0
  10. package/skills/dsh-vscodemode-html-plan/references/blocks.md +227 -0
  11. package/skills/dsh-vscodemode-html-plan/references/subagent-brief.md +17 -0
  12. package/skills/dsh-vscodemode-html-plan/references/upstream-SKILL.md +174 -0
  13. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +564 -0
  14. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +1299 -0
  15. package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +300 -0
  16. package/src/ai/llmTask.ts +178 -0
  17. package/src/ai/llmTypes.ts +6 -0
  18. package/src/ai/svnCommitMsg.ts +107 -0
  19. package/src/ai/svnTriage.ts +34 -85
  20. package/src/client/aiCommit.ts +57 -0
  21. package/src/client/htmlPlan/HtmlPlanPanel.ts +261 -0
  22. package/src/client/htmlPlan/planActions.ts +347 -0
  23. package/src/client/htmlPlan/planPage.ts +333 -0
  24. package/src/client/htmlPreview.ts +218 -0
  25. package/src/client/index.ts +8 -0
  26. package/src/client/officialSidebar.ts +11 -3
  27. package/src/client/planState.ts +8 -2
  28. package/src/client/sidebar/menuItems.ts +1 -0
  29. package/src/client/sidebar/panels/SvnPanel.ts +17 -0
  30. package/src/client/sidebar/types.ts +2 -0
  31. package/src/client/styles/editor.css +77 -0
  32. package/src/client/svnActions.ts +7 -0
  33. package/src/client/svnCommit.ts +109 -0
  34. package/src/client/svnNotice.ts +1 -1
  35. package/src/client/svnStatus.ts +5 -2
  36. package/src/client/ui/EditorView.ts +85 -7
  37. package/src/client/ui/McpSettings.ts +59 -0
  38. package/src/client/ui/SvnAiPlanDialog.ts +24 -4
  39. package/src/client/ui/SvnCommitDialog.ts +458 -0
  40. package/src/client/ui/commandCatalog.ts +11 -0
  41. package/src/client/ui/svnCommitModel.ts +204 -0
  42. package/src/fileOpenSettings.ts +113 -5
  43. package/src/htmlPlanCommand.ts +176 -0
  44. package/src/index.ts +4 -0
  45. package/src/shared/keybindings.ts +11 -0
  46. package/src/shared/rpc.ts +13 -4
  47. package/src/shared/svn.ts +191 -10
  48. package/src/shared/svnActions.ts +16 -0
  49. package/src/svn.ts +205 -47
  50. package/src/svnCommit.ts +348 -0
  51. package/src/svnCore.ts +254 -0
  52. package/src/svnToolJson.ts +73 -0
  53. package/src/svnTools.ts +566 -0
@@ -0,0 +1,458 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * dsh-vscode-mode client — 原生提交对话框(22-agent-tools-and-commit)。
4
+ *
5
+ * 结构对齐「SVN 更新」窗口:标题栏(✕ 走 FloatingWindow 的 actions)+ 工具带 + 有列头的
6
+ * 勾选表格 + 提交信息编排区 + 遥测行 + 页脚主操作。勾选范围是主信息,主按钮自带数量;
7
+ * 分组头三态勾选;ignore-on-commit 与未版本控制默认不勾并在分组头就地标注。
8
+ * 提交前仍单次 window.confirm 确认;AI 结果只回填文本框,**绝不自动提交**。
9
+ * @author ddj 2026年11月15号
10
+ */
11
+ import React from 'react'
12
+ import { FloatingWindow } from './FloatingWindow.js'
13
+ import { AI_COMMIT_STYLE_LABEL, AI_COMMIT_IDLE, runAiCommit } from '../aiCommit.js'
14
+ import { svnCommitNow, svnCommitPlan } from '../svnCommit.js'
15
+ import { SVN_STATUS_LABEL, SVN_STATUS_LETTER, SVN_STATUS_TONE } from '../../shared/svn.js'
16
+ import {
17
+ commitHintOf,
18
+ commitMessageErrorOf,
19
+ commitResultLinesOf,
20
+ commitSectionsOf,
21
+ commitStatsOf,
22
+ defaultCheckedOf,
23
+ groupTriStateOf,
24
+ } from './svnCommitModel.js'
25
+
26
+ /** 状态分级的展示顺序(页脚计数同序,避免数字跳动)。 */
27
+ const TONE_ORDER = ['modified', 'added', 'deleted', 'conflict', 'plain']
28
+
29
+ /** 状态分级 → 中文标签。 */
30
+ const TONE_LABEL = { modified: '修改', added: '新增', deleted: '删除', conflict: '冲突', plain: '其他' }
31
+
32
+ /**
33
+ * 勾选范围 → 一行计数文案(页脚左键位)。
34
+ * @author ddj 2026年11月15号
35
+ * @param stats 勾选统计
36
+ * @returns 如「已选 6 / 17 个文件 · 修改 5 · 新增 1」
37
+ */
38
+ function statsTextOf(stats) {
39
+ const parts = ['已选 ' + stats.picked + ' / ' + stats.total + ' 个文件']
40
+ for (const tone of TONE_ORDER) {
41
+ const count = stats.byTone[tone] ?? 0
42
+ if (count) parts.push(TONE_LABEL[tone] + ' ' + count)
43
+ }
44
+ return parts.join(' · ')
45
+ }
46
+
47
+ /**
48
+ * 分组头右侧的默认不勾标记(勾选规则本身在模型层,这里只负责说清楚)。
49
+ * @author ddj 2026年11月15号
50
+ * @param section 分区
51
+ * @returns 标记文案;默认勾选的分组返回 null
52
+ */
53
+ function sectionNoteOf(section) {
54
+ if (section.defaultChecked) return null
55
+
56
+ return section.key === 'unversioned' ? '默认不选' : '默认不提交'
57
+ }
58
+
59
+ /**
60
+ * 勾选里是否含未版本控制文件(提交确认文案用)。
61
+ * @author ddj 2026年11月15号
62
+ * @param sections 分区
63
+ * @param checked 勾选路径集合
64
+ * @returns 是否含未版本控制条目
65
+ */
66
+ function hasUnversionedOf(sections, checked) {
67
+ return sections.some((section) => section.key === 'unversioned'
68
+ && section.entries.some((entry) => checked.has(entry.path)))
69
+ }
70
+
71
+ /**
72
+ * 复选框元素(仓库 UI 原语无 Checkbox,沿用原生控件 + CSS 定制外观)。
73
+ * @author ddj 2026年11月15号
74
+ * @param checked 是否勾选 @param onToggle 切换回调 @param title 提示 @param indeterminate 半选
75
+ * @returns 复选框元素
76
+ */
77
+ function checkBoxEl(checked, onToggle, title, indeterminate = false) {
78
+ return React.createElement('input', {
79
+ type: 'checkbox',
80
+ className: 'edrv-svncommit-cb',
81
+ checked,
82
+ title,
83
+ onChange: () => onToggle(),
84
+ ref: (node) => { if (node) node.indeterminate = indeterminate },
85
+ })
86
+ }
87
+
88
+ /**
89
+ * 分组头(吸顶):三态勾选 + 分区名 + 默认不勾标记 + 条目数。
90
+ * @author ddj 2026年11月15号
91
+ * @param section 分区 @param tri 三态 @param onToggle 整组切换
92
+ * @returns 分组头元素
93
+ */
94
+ function sectionHeadEl(section, tri, onToggle) {
95
+ const note = sectionNoteOf(section)
96
+ return React.createElement('div', { className: 'edrv-svncommit-group', key: section.key },
97
+ checkBoxEl(tri === 'all', onToggle, tri === 'part' ? '部分勾选,点击全选本分区' : '全选本分区', tri === 'part'),
98
+ React.createElement('span', { className: 'edrv-svncommit-gname', title: section.label }, section.label),
99
+ note ? React.createElement('span', { className: 'edrv-svncommit-gnote', title: '该分区默认不勾选;需要提交时逐条勾上' }, note) : null,
100
+ React.createElement('span', { className: 'edrv-svncommit-gcount' }, section.entries.length + ' 项'))
101
+ }
102
+
103
+ /**
104
+ * 单条待提交文件(勾选 / 状态字母 / 路径)。
105
+ * @author ddj 2026年11月15号
106
+ * @param entry 变更条目 @param checked 是否勾选 @param onToggle 切换
107
+ * @returns 行元素
108
+ */
109
+ function rowEl(entry, checked, onToggle) {
110
+ const tone = SVN_STATUS_TONE[entry.status] ?? 'plain'
111
+ return React.createElement('div', { className: 'edrv-svncommit-row', role: 'row', key: entry.path },
112
+ React.createElement('span', { className: 'edrv-svncommit-pick', role: 'cell' }, checkBoxEl(checked, onToggle, entry.path)),
113
+ React.createElement('span', {
114
+ className: 'edrv-svn-ch edrv-svn-ch-' + tone,
115
+ role: 'cell',
116
+ title: SVN_STATUS_LABEL[entry.status] ?? entry.status,
117
+ }, SVN_STATUS_LETTER[entry.status] ?? '?'),
118
+ React.createElement('span', { className: 'edrv-svncommit-path', role: 'cell', title: entry.path }, entry.path))
119
+ }
120
+
121
+ /**
122
+ * 勾选表格:列头固定,分组头与行在同一个滚动区里。
123
+ * @author ddj 2026年11月15号
124
+ * @param s 视图状态
125
+ * @returns 表格元素
126
+ */
127
+ function tableEl(s) {
128
+ if (!s.sections.length) {
129
+ return React.createElement('div', { className: 'edrv-svncommit-table' },
130
+ React.createElement('div', { className: 'edrv-svncommit-empty' }, s.plan ? '没有可提交的变更' : '正在读取变更清单…'))
131
+ }
132
+
133
+ const body = []
134
+ for (const section of s.sections) {
135
+ body.push(sectionHeadEl(section, groupTriStateOf(section, s.checked), () => s.toggleSection(section)))
136
+ for (const entry of section.entries) {
137
+ body.push(rowEl(entry, s.checked.has(entry.path), () => s.toggle(entry.path)))
138
+ }
139
+ }
140
+ return React.createElement('div', { className: 'edrv-svncommit-table' },
141
+ React.createElement('div', { className: 'edrv-svncommit-cols' },
142
+ React.createElement('span', null, '勾选'),
143
+ React.createElement('span', null, '状态'),
144
+ React.createElement('span', null, '路径')),
145
+ React.createElement('div', { className: 'edrv-svncommit-list', role: 'table', 'aria-label': '待提交文件清单' }, ...body))
146
+ }
147
+
148
+ /**
149
+ * 工具带:最近信息 / AI 风格 / AI 生成 / 保持锁定 / 已选计数。
150
+ * @author ddj 2026年11月15号
151
+ * @param s 视图状态
152
+ * @returns 工具带元素
153
+ */
154
+ function barEl(s) {
155
+ const recent = s.plan?.recent?.length
156
+ ? React.createElement('select', {
157
+ className: 'edrv-svn-act edrv-svncommit-ctl',
158
+ defaultValue: '',
159
+ disabled: s.busy,
160
+ title: '最近提交信息(选择后填入信息框)',
161
+ onChange: (event) => {
162
+ const index = Number(event.target.value)
163
+ if (Number.isInteger(index) && index >= 0) s.setMessage(s.plan.recent[index] ?? '')
164
+ event.target.value = ''
165
+ },
166
+ },
167
+ React.createElement('option', { value: '' }, '最近信息…'),
168
+ ...s.plan.recent.map((item, index) => React.createElement('option', {
169
+ key: 'recent-' + index,
170
+ value: String(index),
171
+ }, item.split('\n')[0].slice(0, 60))))
172
+ : null
173
+
174
+ return React.createElement('div', { className: 'edrv-svncommit-bar' },
175
+ recent,
176
+ React.createElement('select', {
177
+ className: 'edrv-svn-act edrv-svncommit-ctl',
178
+ value: s.style,
179
+ disabled: s.busy || s.aiBusy,
180
+ title: 'AI 提交信息风格',
181
+ onChange: (event) => s.setStyle(event.target.value),
182
+ }, ...Object.keys(AI_COMMIT_STYLE_LABEL).map((key) => React.createElement('option', { key, value: key }, AI_COMMIT_STYLE_LABEL[key]))),
183
+ React.createElement('button', {
184
+ type: 'button',
185
+ className: 'edrv-svn-act edrv-svncommit-ctl',
186
+ title: 'AI 只分析已勾选文件,产出提交信息草稿(不会自动提交)',
187
+ disabled: s.aiBusy || s.busy || !s.paths.length,
188
+ onClick: s.generate,
189
+ }, '✨ AI 生成提交信息'),
190
+ React.createElement('label', { className: 'edrv-svn-check', title: '提交后保留锁定(--no-unlock)' },
191
+ React.createElement('input', {
192
+ className: 'edrv-svncommit-cb',
193
+ type: 'checkbox',
194
+ checked: s.keepLocks,
195
+ disabled: s.busy,
196
+ onChange: () => s.setKeepLocks(!s.keepLocks),
197
+ }),
198
+ ' 保持锁定'),
199
+ React.createElement('span', { className: 'edrv-svncommit-badge', title: '已勾选 / 清单内全部文件' },
200
+ '已选 ' + s.stats.picked + ' / ' + s.stats.total))
201
+ }
202
+
203
+ /**
204
+ * 提交信息编排区:标签行(首行计数 / 就地错误)+ 文本框。
205
+ * @author ddj 2026年11月15号
206
+ * @param s 视图状态
207
+ * @returns 编排区元素
208
+ */
209
+ function composeEl(s) {
210
+ const error = s.message.trim() ? s.messageError : null
211
+ return React.createElement('div', { className: 'edrv-svncommit-compose' },
212
+ React.createElement('div', { className: 'edrv-svncommit-composehead' },
213
+ React.createElement('span', { className: 'edrv-svncommit-label' }, '提交信息'),
214
+ React.createElement('span', { className: 'edrv-svncommit-hint' }, commitHintOf(s.message)),
215
+ error ? React.createElement('span', { className: 'edrv-svncommit-error' }, error) : null),
216
+ React.createElement('textarea', {
217
+ className: 'edrv-svncommit-msg',
218
+ value: s.message,
219
+ rows: 4,
220
+ spellCheck: false,
221
+ placeholder: '首行是提交标题,例如:修复删除道具后背包不刷新。空一行可写正文。',
222
+ onChange: (event) => s.setMessage(event.target.value),
223
+ }))
224
+ }
225
+
226
+ /**
227
+ * 提交结果回显(新版本号 / 逐文件动作 / 跳过 / 冲突)。
228
+ * @author ddj 2026年11月15号
229
+ * @param result 提交结果
230
+ * @returns 结果元素;无结果返回 null
231
+ */
232
+ function resultEl(result) {
233
+ if (!result) return null
234
+ const lines = commitResultLinesOf(result)
235
+ return React.createElement('div', { className: 'edrv-svncommit-result' + (result.revision !== undefined ? ' is-ok' : '') },
236
+ ...lines.map((line, index) => React.createElement('div', { key: 'r-' + index }, line)))
237
+ }
238
+
239
+ /**
240
+ * 遥测行:错误 / 截断告警 / AI 状态与模型。
241
+ * @author ddj 2026年11月15号
242
+ * @param s 视图状态
243
+ * @returns 遥测元素
244
+ */
245
+ function telemetryEl(s) {
246
+ const error = s.failed || s.loadError
247
+ const aiText = s.ai.phase === 'running' ? 'AI 生成中…' : 'AI:' + s.ai.note
248
+ return React.createElement('div', { className: 'edrv-svncommit-telemetry', role: 'status' },
249
+ error ? React.createElement('span', { className: 'edrv-svncommit-error' }, error) : null,
250
+ s.plan?.truncated
251
+ ? React.createElement('span', { className: 'edrv-svncommit-warn', title: '变更清单被截断,可能未列出全部变更;请缩小范围或先用命令行确认' }, '清单已截断,可能未列出全部变更')
252
+ : null,
253
+ React.createElement('span', { className: 'edrv-svncommit-ai' }, aiText),
254
+ s.ai.model ? React.createElement('span', { className: 'edrv-svncommit-ai', title: s.ai.model }, s.ai.model) : null)
255
+ }
256
+
257
+ /**
258
+ * 页脚:计数 + 取消 + 主操作(提交按钮自带数量)。
259
+ * @author ddj 2026年11月15号
260
+ * @param s 视图状态
261
+ * @returns 页脚元素
262
+ */
263
+ function footEl(s) {
264
+ return React.createElement('div', { className: 'edrv-svncommit-foot' },
265
+ React.createElement('span', { className: 'edrv-svncommit-counts' }, s.paths.length ? statsTextOf(s.stats) : '未勾选任何文件'),
266
+ React.createElement('button', { type: 'button', className: 'edrv-svn-act', disabled: s.busy, title: '取消(不提交)', onClick: s.onClose }, '取消'),
267
+ React.createElement('button', {
268
+ type: 'button',
269
+ className: 'edrv-svn-act edrv-svncommit-primary',
270
+ title: s.messageError ?? '提交已勾选文件',
271
+ disabled: s.busy || Boolean(s.messageError) || !s.paths.length,
272
+ onClick: s.submit,
273
+ }, s.busy ? '提交中…' : '提交(' + s.paths.length + ')'))
274
+ }
275
+
276
+ /**
277
+ * 读取提交计划与勾选态(seeded 时不再覆盖已有勾选,逐组提交预填优先)。
278
+ * @author ddj 2026年11月15号
279
+ * @param sessionId 会话 id
280
+ * @param seed 预填(路径 + 信息)
281
+ * @returns 计划、分区、勾选集合与提交信息
282
+ */
283
+ function useCommitLoad(sessionId, seed) {
284
+ const [plan, setPlan] = React.useState(null)
285
+ const [loadError, setLoadError] = React.useState('')
286
+ const [sections, setSections] = React.useState([])
287
+ const [checked, setChecked] = React.useState(() => new Set(seed?.paths ?? []))
288
+ const [message, setMessage] = React.useState(() => seed?.message ?? '')
289
+ const seeded = React.useRef(Boolean(seed?.paths?.length))
290
+
291
+ React.useEffect(() => {
292
+ let alive = true
293
+ void svnCommitPlan(sessionId).then((outcome) => {
294
+ if (!alive) return
295
+ if (!outcome.ok || !outcome.plan) { setLoadError(outcome.message); return }
296
+
297
+ setPlan(outcome.plan)
298
+ const next = commitSectionsOf(outcome.plan.entries)
299
+ setSections(next)
300
+ if (!seeded.current) setChecked(defaultCheckedOf(next))
301
+ if (!seeded.current && !message && outcome.plan.recent?.length) setMessage(outcome.plan.recent[0])
302
+ })
303
+ return () => { alive = false }
304
+ }, [sessionId])
305
+
306
+ return { plan, loadError, sections, checked, setChecked, message, setMessage }
307
+ }
308
+
309
+ /**
310
+ * 提交对话框的写动作:AI 生成提交信息与提交本体(失败零重试)。
311
+ * @author ddj 2026年11月15号
312
+ * @param ctx 会话、勾选范围与提交口径
313
+ * @returns 生成/提交动作及其状态
314
+ */
315
+ function useCommitWrite(ctx) {
316
+ const { sessionId, paths, sections, checked, setChecked, message, messageError, keepLocks, style, setMessage, notify, onCommitted } = ctx
317
+ const [ai, setAi] = React.useState(AI_COMMIT_IDLE)
318
+ const [busy, setBusy] = React.useState(false)
319
+ const [result, setResult] = React.useState(null)
320
+ const [failed, setFailed] = React.useState('')
321
+ const aiBusy = ai.phase === 'running'
322
+
323
+ /**
324
+ * AI 生成提交信息(只分析已勾选文件)。
325
+ * @author ddj 2026年11月15号
326
+ */
327
+ const generate = () => {
328
+ if (aiBusy || busy) return
329
+ setAi({ phase: 'running', note: '生成中…' })
330
+ void runAiCommit(sessionId, paths, style).then((outcome) => {
331
+ setAi(outcome.state)
332
+ if (outcome.text) setMessage(outcome.text)
333
+ else if (outcome.state.error) setFailed(outcome.state.error)
334
+ })
335
+ }
336
+
337
+ /**
338
+ * 提交(单次确认;失败零重试)。
339
+ * @author ddj 2026年11月15号
340
+ */
341
+ const submit = () => {
342
+ if (busy || messageError || !paths.length) return
343
+ const ok = typeof window === 'undefined' ? false : window.confirm(
344
+ '确认提交以下 ' + paths.length + ' 个文件?\n提交后无法用 SVN 撤销(只能反向合并或再提交修复)。'
345
+ + (hasUnversionedOf(sections, checked) ? '\n\n注意:未版本控制文件将先被 svn add 再提交。' : ''),
346
+ )
347
+ if (!ok) return
348
+
349
+ setBusy(true)
350
+ setFailed('')
351
+ void svnCommitNow(sessionId, { paths, message, keepLocks }).then((outcome) => {
352
+ if (!outcome.ok || !outcome.result) { setFailed(outcome.message); notify?.(outcome.message); return }
353
+
354
+ setResult(outcome.result)
355
+ notify?.(outcome.message)
356
+ if (outcome.result.revision !== undefined) {
357
+ setChecked(new Set())
358
+ onCommitted?.(outcome.result)
359
+ }
360
+ }).finally(() => setBusy(false))
361
+ }
362
+
363
+ return { ai, aiBusy, busy, result, failed, generate, submit }
364
+ }
365
+
366
+ /**
367
+ * 提交对话框的全部状态与动作(渲染在下面的 builder 里按同一份视图取值)。
368
+ * @author ddj 2026年11月15号
369
+ * @param sessionId 会话 id
370
+ * @param seed 预填(路径 + 信息;来自 AI 逐组提交)
371
+ * @param notify 状态栏反馈
372
+ * @param onCommitted 提交成功回调(刷新变更清单)
373
+ * @returns 视图状态
374
+ */
375
+ function useCommitState(sessionId, seed, notify, onCommitted) {
376
+ const { plan, loadError, sections, checked, setChecked, message, setMessage } = useCommitLoad(sessionId, seed)
377
+ const [keepLocks, setKeepLocks] = React.useState(false)
378
+ const [style, setStyle] = React.useState('plain')
379
+ const paths = React.useMemo(() => [...checked], [checked])
380
+ const stats = React.useMemo(() => commitStatsOf(sections, checked), [sections, checked])
381
+ const messageError = commitMessageErrorOf(message)
382
+ const write = useCommitWrite({
383
+ sessionId, paths, sections, checked, setChecked, message, messageError, keepLocks, style, setMessage, notify, onCommitted,
384
+ })
385
+
386
+ /**
387
+ * 单条勾选切换。
388
+ * @author ddj 2026年11月15号
389
+ * @param path 条目路径
390
+ */
391
+ const toggle = (path) => {
392
+ const next = new Set(checked)
393
+ if (next.has(path)) next.delete(path)
394
+ else next.add(path)
395
+ setChecked(next)
396
+ }
397
+
398
+ /**
399
+ * 分区全选 / 全不选(半选时先全选)。
400
+ * @author ddj 2026年11月15号
401
+ * @param section 分区
402
+ */
403
+ const toggleSection = (section) => {
404
+ const next = new Set(checked)
405
+ const all = section.entries.every((entry) => next.has(entry.path))
406
+ for (const entry of section.entries) {
407
+ if (all) next.delete(entry.path)
408
+ else next.add(entry.path)
409
+ }
410
+ setChecked(next)
411
+ }
412
+
413
+ return {
414
+ plan, loadError, sections, checked, message, setMessage, keepLocks, setKeepLocks, style, setStyle,
415
+ paths, stats, messageError, toggle, toggleSection,
416
+ ai: write.ai, aiBusy: write.aiBusy, busy: write.busy, result: write.result, failed: write.failed,
417
+ generate: write.generate, submit: write.submit,
418
+ }
419
+ }
420
+
421
+ /**
422
+ * 提交对话框。
423
+ * @author ddj 2026年11月15号
424
+ * @param props.sessionId 会话 id
425
+ * @param props.seed 预填(路径 + 信息;来自 AI 逐组提交)
426
+ * @param props.onClose 关闭回调
427
+ * @param props.onCommitted 提交成功回调(刷新变更清单)
428
+ * @param props.notify 状态栏反馈
429
+ * @returns 浮窗元素
430
+ */
431
+ export function SvnCommitDialog(props) {
432
+ const { sessionId, seed, onClose, onCommitted, notify } = props
433
+ const s = useCommitState(sessionId, seed, notify, onCommitted)
434
+ const view = { ...s, onClose }
435
+ return React.createElement(FloatingWindow, {
436
+ title: 'SVN 提交',
437
+ dialogClass: 'edrv-svncommit-dialog',
438
+ width: 880,
439
+ height: 680,
440
+ // 提交进行中禁止 Esc 关闭:关窗会丢掉 onCommitted 的成功回填与清单刷新。
441
+ closeOnEsc: !s.busy,
442
+ onClose,
443
+ actions: React.createElement('button', {
444
+ type: 'button',
445
+ className: 'edrv-svncommit-close',
446
+ title: s.busy ? '提交进行中;请等待结果' : '关闭(不提交)',
447
+ 'aria-label': '关闭提交窗口',
448
+ disabled: s.busy,
449
+ onClick: onClose,
450
+ }, '✕'),
451
+ },
452
+ barEl(view),
453
+ tableEl(view),
454
+ composeEl(view),
455
+ resultEl(s.result),
456
+ telemetryEl(view),
457
+ footEl(view))
458
+ }
@@ -11,6 +11,7 @@ import { pageKeysAllowed } from '../pageReload.js'
11
11
  import { hasEditorModel, hasOpenTabs } from '../editorModelState.js'
12
12
  import { activeEditorPath } from '../activePathStore.js'
13
13
  import { isMarkdownPath } from '../markdownPreview.js'
14
+ import { hasOfficialHtmlPreview, isHtmlPath } from '../htmlPreview.js'
14
15
  import { svnCurrentStatus } from '../svnStatus.js'
15
16
  import { dapStore } from '../dap/store.js'
16
17
  import { svnActionOn, svnActionsFor } from '../../shared/svnActions.js'
@@ -175,6 +176,7 @@ function svnEventOf(action: SvnActionDef): string {
175
176
  'diff-base': 'svnDiffBase',
176
177
  add: 'svnAdd',
177
178
  revert: 'svnRevertCli',
179
+ commit: 'svnCommit',
178
180
  log: 'svnLog',
179
181
  'create-patch': 'svnCreatePatch',
180
182
  'diff-summarize': 'svnDiffSum',
@@ -240,6 +242,15 @@ export const EDITOR_COMMANDS: readonly CommandDef[] = [
240
242
  },
241
243
  run: () => emit('toggleMarkdownPreview'),
242
244
  },
245
+ {
246
+ id: 'edrv.previewHtml', label: '预览网页(官方渲染器)', category: '视图', order: 26,
247
+ // 仅活动文件是 .html/.htm 且官方 HTML 渲染器可用时出现;不可用时让官方派发放行。
248
+ available: () => {
249
+ const path = activeEditorPath()
250
+ return typeof path === 'string' && isHtmlPath(path) && hasOfficialHtmlPreview()
251
+ },
252
+ run: () => emit('previewHtml'),
253
+ },
243
254
  {
244
255
  id: 'edrv.showLogs', label: '查看诊断日志', category: '视图', order: 30,
245
256
  available: alwaysAvailable,
@@ -0,0 +1,204 @@
1
+ /**
2
+ * dsh-vscode-mode client — 提交对话框纯投影(分区 / 默认勾选 / 校验 / 结果行)。
3
+ *
4
+ * 纯函数、无 RPC、无 React:勾选规则(谁默认勾、谁默认不勾)是产品口径,
5
+ * 必须能单测,否则「默认不勾未版本化」这类保护很容易在改 UI 时被顺手改掉。
6
+ * @author ddj 2026年11月15号
7
+ */
8
+ import type { SvnAiPlanCommit, SvnChangeEntry, SvnCommitEntry, SvnCommitResult, SvnStatusTone } from '../../shared/svn.js'
9
+ import { COMMIT_SUBJECT_MAX, SVN_STATUS_TONE, commitMsgErrorOf, isSvnChange } from '../../shared/svn.js'
10
+
11
+ /** 提交对话框里的一个分区。 */
12
+ export interface CommitSection {
13
+ /** 分区键(changelist:<name> / ungrouped / unversioned)。 */
14
+ key: string
15
+ /** 展示名。 */
16
+ label: string
17
+ /** 分区内条目。 */
18
+ entries: SvnChangeEntry[]
19
+ /** 默认是否勾选。 */
20
+ defaultChecked: boolean
21
+ }
22
+
23
+ /** 提交范围种子(AI 拆分建议 → 预填提交对话框)。 */
24
+ export interface CommitSeed {
25
+ /** 预选路径。 */
26
+ paths: string[]
27
+ /** 预填提交信息。 */
28
+ message?: string
29
+ }
30
+
31
+ /** 「提交时忽略」保留名(TortoiseSVN 约定:该组默认不提交)。 */
32
+ export const IGNORE_ON_COMMIT = 'ignore-on-commit'
33
+
34
+ /**
35
+ * 变更清单 → 分区(changelist 组 / 未分组 / 未版本控制)。
36
+ * 默认勾选:changelist 组与未分组为是;未版本控制与 ignore-on-commit 为否。
37
+ * @author ddj 2026年11月15号
38
+ * @param entries 变更清单
39
+ * @returns 分区列表(顺序:分组按名字、未分组、未版本控制)
40
+ */
41
+ export function commitSectionsOf(entries: readonly SvnChangeEntry[]): CommitSection[] {
42
+ const groups = new Map<string, SvnChangeEntry[]>()
43
+ const ungrouped: SvnChangeEntry[] = []
44
+ const unversioned: SvnChangeEntry[] = []
45
+ for (const entry of entries) {
46
+ if (!entry || !isSvnChange(entry)) continue
47
+ if (entry.status === 'unversioned') { unversioned.push(entry); continue }
48
+ if (entry.changelist) {
49
+ const bucket = groups.get(entry.changelist)
50
+ if (bucket) bucket.push(entry)
51
+ else groups.set(entry.changelist, [entry])
52
+ continue
53
+ }
54
+ ungrouped.push(entry)
55
+ }
56
+ const sections: CommitSection[] = []
57
+ for (const name of [...groups.keys()].sort((a, b) => a.localeCompare(b))) {
58
+ sections.push({
59
+ key: 'changelist:' + name,
60
+ label: name,
61
+ entries: groups.get(name) ?? [],
62
+ defaultChecked: name !== IGNORE_ON_COMMIT,
63
+ })
64
+ }
65
+ if (ungrouped.length) sections.push({ key: 'ungrouped', label: '(未分组)', entries: ungrouped, defaultChecked: true })
66
+ if (unversioned.length) sections.push({ key: 'unversioned', label: '(未版本控制)', entries: unversioned, defaultChecked: false })
67
+ return sections
68
+ }
69
+
70
+ /**
71
+ * 默认勾选集合(种子存在时只勾种子内路径,用于「逐组提交」预填)。
72
+ * @author ddj 2026年11月15号
73
+ * @param sections 分区
74
+ * @param seed 预选路径(空 = 按分区默认)
75
+ * @returns 勾选路径集合
76
+ */
77
+ export function defaultCheckedOf(sections: readonly CommitSection[], seed: readonly string[] = []): Set<string> {
78
+ if (seed.length) return new Set(seed)
79
+ const checked = new Set<string>()
80
+ for (const section of sections) {
81
+ if (!section.defaultChecked) continue
82
+ for (const entry of section.entries) checked.add(entry.path)
83
+ }
84
+ return checked
85
+ }
86
+
87
+ /** 已勾选范围统计(工具带「已选 N / M」、遥测行与主按钮计数同源)。 */
88
+ export interface CommitStats {
89
+ /** 全部分区条目数。 */
90
+ total: number
91
+ /** 已勾选条目数。 */
92
+ picked: number
93
+ /** 已勾选条目按状态分级计数(分级口径见 SVN_STATUS_TONE)。 */
94
+ byTone: Record<SvnStatusTone, number>
95
+ }
96
+
97
+ /**
98
+ * 统计提交范围:总数、勾选数、勾选条目按状态分级计数。
99
+ * @author ddj 2026年11月15号
100
+ * @param sections 分区
101
+ * @param checked 勾选路径集合
102
+ * @returns 统计结果(byTone 只统计已勾选条目;空集合各计数为 0)
103
+ */
104
+ export function commitStatsOf(sections: readonly CommitSection[], checked: ReadonlySet<string>): CommitStats {
105
+ const byTone: Record<SvnStatusTone, number> = { modified: 0, added: 0, deleted: 0, conflict: 0, plain: 0 }
106
+ let total = 0
107
+ let picked = 0
108
+ for (const section of sections) {
109
+ for (const entry of section.entries) {
110
+ total += 1
111
+ if (!checked.has(entry.path)) continue
112
+
113
+ picked += 1
114
+ byTone[SVN_STATUS_TONE[entry.status] ?? 'plain'] += 1
115
+ }
116
+ }
117
+ return { total, picked, byTone }
118
+ }
119
+
120
+ /**
121
+ * 分区勾选三态(分组头的全选 / 半选 / 未选)。
122
+ * @author ddj 2026年11月15号
123
+ * @param section 分区
124
+ * @param checked 勾选路径集合
125
+ * @returns `all` 全选、`none` 未选(含空分区)、`part` 部分勾选
126
+ */
127
+ export function groupTriStateOf(section: CommitSection, checked: ReadonlySet<string>): 'all' | 'none' | 'part' {
128
+ let picked = 0
129
+ for (const entry of section.entries) {
130
+ if (checked.has(entry.path)) picked += 1
131
+ }
132
+ if (!picked) return 'none'
133
+
134
+ return picked === section.entries.length ? 'all' : 'part'
135
+ }
136
+
137
+ /**
138
+ * 提交信息校验(首行 + 正文;与 host 同口径,只用于按钮禁用与就地提示)。
139
+ * @author ddj 2026年11月15号
140
+ * @param message 完整提交信息
141
+ * @returns 错误文案;合法为 null
142
+ */
143
+ export function commitMessageErrorOf(message: string): string | null {
144
+ const text = String(message ?? '')
145
+ if (!text.trim()) return '请填写提交信息'
146
+ const lines = text.replace(/\r\n/g, '\n').split('\n')
147
+ const subject = (lines[0] ?? '').trim()
148
+ const body = lines.slice(1).join('\n').trim()
149
+ return commitMsgErrorOf(subject, body)
150
+ }
151
+
152
+ /**
153
+ * 提交信息字符数提示(首行超长时前置警告)。
154
+ * @author ddj 2026年11月15号
155
+ * @param message 完整提交信息
156
+ * @returns 状态位文案
157
+ */
158
+ export function commitHintOf(message: string): string {
159
+ const lines = String(message ?? '').replace(/\r\n/g, '\n').split('\n')
160
+ const subject = (lines[0] ?? '').trim()
161
+ if (!subject) return '首行将作为提交标题'
162
+ return '首行 ' + subject.length + '/' + COMMIT_SUBJECT_MAX + ' 字符'
163
+ }
164
+
165
+ /**
166
+ * 提交结果 → 展示行(新版本号 / 逐文件动作 / 跳过项 / 冲突)。
167
+ * @author ddj 2026年11月15号
168
+ * @param result 提交结果
169
+ * @returns 展示行(空数组 = 无内容)
170
+ */
171
+ export function commitResultLinesOf(result: SvnCommitResult | null | undefined): string[] {
172
+ if (!result) return []
173
+ const lines: string[] = []
174
+ lines.push(result.revision !== undefined ? '提交成功:r' + result.revision : result.summary)
175
+ for (const entry of result.entries ?? []) lines.push(entry.action + ' ' + entry.path)
176
+ for (const path of result.skipped ?? []) lines.push('跳过 ' + path + '(无待提交变更)')
177
+ for (const path of result.conflicts ?? []) lines.push('冲突 ' + path + '(请先更新并解决)')
178
+ return lines
179
+ }
180
+
181
+ /**
182
+ * AI 拆分建议 → 提交对话框种子(逐组提交入口只预填,不自动提交)。
183
+ * @author ddj 2026年11月15号
184
+ * @param group AI 拆分建议组
185
+ * @returns 种子(路径 + 信息草稿)
186
+ */
187
+ export function commitSeedOf(group: SvnAiPlanCommit): CommitSeed {
188
+ const body = group.body ?? ''
189
+ return {
190
+ paths: [...group.paths],
191
+ message: body ? group.subject + '\n\n' + body : group.subject,
192
+ }
193
+ }
194
+
195
+ /**
196
+ * 逐文件动作 → 着色分组(结果区)。
197
+ * @author ddj 2026年11月15号
198
+ * @param entries 动作列表
199
+ * @returns 每行文本与语义色
200
+ */
201
+ export function commitEntryLinesOf(entries: readonly SvnCommitEntry[]): Array<{ text: string; tone: string }> {
202
+ const tone: Record<SvnCommitEntry['action'], string> = { M: 'modified', A: 'added', D: 'deleted', R: 'added' }
203
+ return entries.map((entry) => ({ text: entry.action + ' ' + entry.path, tone: tone[entry.action] ?? 'plain' }))
204
+ }