dsh-vscode-mode 0.37.0 → 0.39.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 -33
- package/lib/client.js +69 -66
- package/lib/client.js.map +1 -1
- package/lib/index.js +6774 -1925
- package/lib/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/dsh-vscodemode-html-plan/SKILL.md +44 -42
- package/src/archiveDb.ts +24 -0
- package/src/archivePurge.ts +120 -28
- package/src/client/htmlPlan/HtmlPlanModeChip.ts +181 -0
- package/src/client/htmlPlan/HtmlPlanPanel.ts +230 -61
- package/src/client/htmlPlan/planActions.ts +38 -8
- package/src/client/htmlPlan/planPage.ts +111 -9
- package/src/client/index.ts +3 -0
- package/src/client/planBridge.ts +27 -2
- package/src/client/planState.ts +51 -4
- package/src/client/reviewBatch.ts +48 -1
- package/src/client/state/diffSummary.ts +5 -1
- package/src/client/styles/editor.css +16 -1
- package/src/client/ui/EditorView.ts +16 -10
- package/src/client/ui/McpSettings.ts +2 -2
- package/src/client/ui/OfficialReview.ts +6 -4
- package/src/client/ui/SvnCommitDialog.ts +256 -31
- package/src/client/ui/svnCommitModel.ts +63 -0
- package/src/htmlPlanCommand.ts +87 -177
- package/src/htmlPlanGuidance.ts +67 -0
- package/src/htmlPlanMode.ts +547 -0
- package/src/index.ts +32 -54
- package/src/officialCapture.ts +58 -9
- package/src/pending/capture.ts +201 -34
- package/src/pending/decide.ts +33 -1
- package/src/pending/externalCapture.ts +194 -333
- package/src/pending/kernel.ts +36 -2
- package/src/pending/noteTool.ts +96 -0
- package/src/pending/notes.ts +83 -0
- package/src/pending/persist.ts +312 -62
- package/src/pending/provenance.ts +50 -39
- package/src/pending/receipt.ts +177 -0
- package/src/pending/store.ts +230 -164
- package/src/pending/tracking.ts +81 -0
- package/src/pending/verdict.ts +170 -0
- package/src/pendingCompat.ts +40 -2
- package/src/pendingRpc.ts +8 -56
- package/src/planAutoPage.ts +306 -0
- package/src/planPagePack.ts +148 -0
- package/src/registry.ts +7 -2
- package/src/reviewDb.ts +64 -3
- package/src/reviewRpc.ts +61 -7
- package/src/rpc.ts +47 -7
- package/src/shared/htmlPlanMode.ts +26 -0
- package/src/shared/pendingReview.ts +35 -9
- package/src/shared/review.ts +22 -0
- package/src/shared/reviewRegions.ts +48 -3
- package/src/shared/rpc.ts +13 -9
- package/src/slowLog.ts +74 -0
- package/src/store.ts +17 -1
- package/src/textEncoding.probe.ts +1 -0
- package/src/pending/externalAlign.ts +0 -297
- package/src/pending/vcs.ts +0 -584
|
@@ -250,23 +250,91 @@ export function planSlugOf(declared: unknown): string {
|
|
|
250
250
|
return /^[a-z0-9][a-z0-9-]*$/i.test(raw) ? raw : 'html-plan'
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
//region 页面来源决策(HTML 计划模式)
|
|
254
|
+
|
|
255
|
+
/** 计划页读取结果的三态(读不到 / 不存在 / 读到)。 */
|
|
256
|
+
export type PlanPageRead = 'ok' | 'missing' | 'error'
|
|
257
|
+
|
|
258
|
+
/** 计划签打开页面时要执行的动作。 */
|
|
259
|
+
export type PlanPageAction = 'show' | 'pack' | 'auto' | 'error'
|
|
260
|
+
|
|
261
|
+
/** 页面动作决策入参。 */
|
|
262
|
+
export interface PlanPageDecisionInput {
|
|
263
|
+
/** 计划正文声明的页面路径(可能为空)。 */
|
|
264
|
+
declared: string
|
|
265
|
+
/** 是否在 HTML 计划模式里提交(允许插件兜底页)。 */
|
|
266
|
+
htmlPlanMode: boolean
|
|
267
|
+
/** 声明路径的读取结果。 */
|
|
268
|
+
read: PlanPageRead
|
|
269
|
+
/** 读到的页面是否还引用未内联的运行时(需要重新打包)。 */
|
|
270
|
+
needsPack: boolean
|
|
271
|
+
/** 备用路径(`.packed.html` ↔ `.html`)是否存在。 */
|
|
272
|
+
alternateExists: boolean
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** 页面动作决策结果。 */
|
|
276
|
+
export interface PlanPageDecision {
|
|
277
|
+
/** 动作。 */
|
|
278
|
+
action: PlanPageAction
|
|
279
|
+
/** pack 动作的目标路径(绝对或相对,由调用方归位)。 */
|
|
280
|
+
target?: string
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 决定计划签怎样拿到一页 HTML。
|
|
285
|
+
*
|
|
286
|
+
* 顺序:作者页可直接显示 → 作者页需要打包 → 备用路径打包 → HTML 计划模式下用正文渲染 → 报错。
|
|
287
|
+
* `htmlPlanMode` 为真时,声明页缺失/读不到也允许兜底渲染,保证模式内不出现「只剩报错」。
|
|
288
|
+
* @author ddj 2026年11月25号
|
|
289
|
+
* @param input 决策入参
|
|
290
|
+
* @returns 动作与打包目标
|
|
291
|
+
*/
|
|
292
|
+
export function planPageDecisionOf(input: PlanPageDecisionInput): PlanPageDecision {
|
|
293
|
+
const declared = String(input.declared ?? '').trim()
|
|
294
|
+
if (declared && input.read === 'ok') {
|
|
295
|
+
return input.needsPack ? { action: 'pack', target: declared } : { action: 'show' }
|
|
296
|
+
}
|
|
297
|
+
const alternate = declared ? planPageAltPath(declared) : null
|
|
298
|
+
if (alternate && input.alternateExists) return { action: 'pack', target: alternate }
|
|
299
|
+
if (input.htmlPlanMode) return { action: 'auto' }
|
|
300
|
+
return { action: 'error' }
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 推导作者页的备用路径:`plan.packed.html` ↔ `plan.html`。
|
|
305
|
+
* 没有这两种后缀时返回 null(不做无意义重试)。
|
|
306
|
+
* @author ddj 2026年11月25号
|
|
307
|
+
* @param path 声明路径
|
|
308
|
+
* @returns 备用路径;推导不出时 null
|
|
309
|
+
*/
|
|
310
|
+
export function planPageAltPath(path: unknown): string | null {
|
|
311
|
+
const value = String(path ?? '').trim().replace(/\\/g, '/')
|
|
312
|
+
if (!value) return null
|
|
313
|
+
if (/\.packed\.html?$/i.test(value)) return value.replace(/\.packed\.html?$/i, '.html')
|
|
314
|
+
if (/\.html?$/i.test(value)) return value.replace(/\.html?$/i, '.packed.html')
|
|
315
|
+
return null
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
//endregion
|
|
319
|
+
|
|
253
320
|
/**
|
|
254
|
-
* 让 agent
|
|
255
|
-
*
|
|
321
|
+
* 让 agent 重写作者页的修复指令(计划页签「生成 HTML 计划页」按钮发给 agent)。
|
|
322
|
+
* 插件会自动打包,所以不再要求模型跑 plan.mjs(那条命令会删中间文件,不能用于用户文件)。
|
|
256
323
|
* @author ddj 2026年11月23号
|
|
324
|
+
* @author ddj 2026年11月25号(改为「只写页、插件打包」,去掉运行 plan.mjs 的要求)
|
|
257
325
|
* @param declared 计划正文声明的页面路径(可为空)
|
|
258
326
|
* @returns 发给 agent 的用户消息
|
|
259
327
|
*/
|
|
260
328
|
export function planRepairInstruction(declared: unknown): string {
|
|
261
329
|
const slug = planSlugOf(declared)
|
|
262
330
|
return [
|
|
263
|
-
'请按 dsh-vscodemode-html-plan
|
|
331
|
+
'请按 dsh-vscodemode-html-plan 技能生成 HTML 计划页,然后重新提交计划:',
|
|
264
332
|
'1. 计划模式里允许写 plans/ 下的计划交付物:直接在计划模式里写页面,不要让我退出计划模式。',
|
|
265
|
-
`2.
|
|
266
|
-
`3. 页面若引用附件(<doc-file src="assets/…">),确认文件在 plans/${slug}/assets
|
|
267
|
-
'
|
|
268
|
-
`4.
|
|
269
|
-
'不要只写路径不生成文件;页面确实生成失败就说清原因,并交付纯 Markdown
|
|
333
|
+
`2. 只写 plans/${slug}/plan.html 即可:计划签打开时插件会自动打包,不要运行 plan.mjs 或任何 node 命令。`,
|
|
334
|
+
`3. 页面若引用附件(<doc-file src="assets/…">),确认文件在 plans/${slug}/assets/;插件打包时会把它们内联。`,
|
|
335
|
+
' 附件目录不会被插件删除;文件缺失时让我重新附一次,不要凭空造图。',
|
|
336
|
+
`4. 页面写好后调用 exit_plan_mode:正文第一行「# 计划:<标题>」,并单独一行「HTML 计划页:plans/${slug}/plan.html」。`,
|
|
337
|
+
'不要只写路径不生成文件;页面确实生成失败就说清原因,并交付纯 Markdown 计划(插件会用正文兜底渲染)。',
|
|
270
338
|
].join('\n')
|
|
271
339
|
}
|
|
272
340
|
|
|
@@ -300,7 +368,41 @@ export function derivePlanUiState(
|
|
|
300
368
|
return { mode: 'off', label: '计划模式未开启', active, pending }
|
|
301
369
|
}
|
|
302
370
|
|
|
303
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* HTML 计划模式的状态推导(独立模式不走官方 plan 投影)。
|
|
373
|
+
*
|
|
374
|
+
* 投影缺失时按「提交即活跃」乐观处理:计划能走到计划签,说明提交时模式是活跃的;
|
|
375
|
+
* 批准/退出动作后按本地动作收口,避免按钮一直可点。
|
|
376
|
+
* @author ddj 2026年11月25号
|
|
377
|
+
* @param mode html-plan 投影快照({ active } 或 undefined)
|
|
378
|
+
* @param reviewPending 是否有待审批的 plan-review
|
|
379
|
+
* @param acted 本地刚完成动作
|
|
380
|
+
* @returns 计划页签状态
|
|
381
|
+
*/
|
|
382
|
+
export function deriveHtmlPlanUiState(
|
|
383
|
+
mode: unknown,
|
|
384
|
+
reviewPending: boolean,
|
|
385
|
+
acted?: 'approved' | 'revising' | 'exited' | null,
|
|
386
|
+
): PlanUiState {
|
|
387
|
+
const row = mode !== null && typeof mode === 'object' ? mode as { active?: unknown } : undefined
|
|
388
|
+
const active = row ? row.active === true : acted !== 'approved' && acted !== 'exited'
|
|
389
|
+
const pending = false
|
|
390
|
+
if (acted === 'approved') {
|
|
391
|
+
return { mode: 'approved', label: active ? '已批准 · 等待退出 HTML 计划模式' : '已批准 · 已退出 HTML 计划模式', active, pending }
|
|
392
|
+
}
|
|
393
|
+
if (acted === 'exited' && !active) return { mode: 'exited', label: '已退出 HTML 计划模式', active, pending }
|
|
394
|
+
if (acted === 'revising' && active) return { mode: 'revising', label: '继续规划中', active, pending }
|
|
395
|
+
if (active && reviewPending) return { mode: 'reviewing', label: '待审批', active, pending }
|
|
396
|
+
if (active) return { mode: 'planning', label: 'HTML 计划模式中', active, pending }
|
|
397
|
+
return { mode: 'off', label: 'HTML 计划模式未开启', active, pending }
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* 选项标签归一:字符串或 { label } 数组。
|
|
402
|
+
* @author ddj 2026年11月21号
|
|
403
|
+
* @param options 选项列表
|
|
404
|
+
* @returns 非空标签
|
|
405
|
+
*/
|
|
304
406
|
function labelsOf(options: unknown): string[] {
|
|
305
407
|
if (!Array.isArray(options)) return []
|
|
306
408
|
const out: string[] = []
|
package/src/client/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ import { detectOfficial, installOfficial, registerOfficialFileClaim, OFFICIAL_TA
|
|
|
46
46
|
import { setNativeCsv, setNativeOpenHandler, resetNativeOpen } from './nativeOpenStore.js'
|
|
47
47
|
import { hasOfficialHtmlPreview, installHtmlPreviewProbe, isHtmlPath } from './htmlPreview.js'
|
|
48
48
|
import { installHtmlPlanActions } from './htmlPlan/planActions.js'
|
|
49
|
+
import { installHtmlPlanModeChip } from './htmlPlan/HtmlPlanModeChip.js'
|
|
49
50
|
import { setFeaturePrefs } from './featurePrefs.js'
|
|
50
51
|
import { SideEditorTab } from './ui/SideEditorTab.js'
|
|
51
52
|
import { OfficialSideTab } from './ui/OfficialSideTab.js'
|
|
@@ -333,6 +334,8 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
333
334
|
ctx.effect(() => installHtmlPreviewProbe(ctx, { schedule }), 'vscode-mode: html preview probe')
|
|
334
335
|
// HTML 计划页动作桥:状态读取 / 官方审批作答 / /plan off / 回填输入框(全部可选服务)。
|
|
335
336
|
ctx.effect(() => installHtmlPlanActions(ctx), 'vscode-mode: html plan actions')
|
|
337
|
+
// HTML 计划模式 chip:输入框工具行的 list 槽,模式活跃时出现,点击执行 /html-plan off。
|
|
338
|
+
ctx.effect(() => installHtmlPlanModeChip(ctx), 'vscode-mode: html plan mode chip')
|
|
336
339
|
// 官方代码审阅扩展位(0.2.3+):变更视图工具条与文件菜单加两条动作。
|
|
337
340
|
// 服务/slot 缺失时零注册,不影响自有 diff 面板。
|
|
338
341
|
ctx.effect(() => installOfficialReview(ctx, {
|
package/src/client/planBridge.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Optional DSH plan integration; no provider or approval UI replacement. @author ddj 2026年10月08号 */
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { requestOpen } from './openReceipt.js'
|
|
4
|
-
import { createPlanFeed, clearPlanState, isPlanAddress, planDocument, type PlanWindow, type PlanOpen } from './planState.js'
|
|
4
|
+
import { cachedPlan, createPlanFeed, clearPlanState, isPlanAddress, planDocument, planFromEntries, type PlanWindow, type PlanOpen } from './planState.js'
|
|
5
5
|
import { installPlanDirect, optionalService, type PlanOpenOptions } from './planDirect.js'
|
|
6
6
|
import { detectOfficial, OFFICIAL_SLOT_NAME, type OfficialSidebar } from './officialSidebar.js'
|
|
7
7
|
import { readSessionScope, subscribeScope } from './sessionScope.js'
|
|
@@ -41,6 +41,31 @@ function planRouter(ctx: PlanContext, official: OfficialSidebar, native: (addres
|
|
|
41
41
|
/** @private @author ddj 2026年10月08号 React to owning-session changes without cancelling on unrelated list updates. */
|
|
42
42
|
function scopeChanged(): void { cancel() }
|
|
43
43
|
const offScope = subscribeScope(ctx, scopeChanged)
|
|
44
|
+
/**
|
|
45
|
+
* 解析计划地址对应的正文:官方资源 → 本插件缓存 → 会话窗口扫一遍。
|
|
46
|
+
*
|
|
47
|
+
* 官方 `dsh-client-ui-plan` 的资源提供方只认 `exit_plan_mode`,HTML 计划模式提交的
|
|
48
|
+
* `exit_html_plan_mode` 在它那里是「not-found」;不补这两级,计划页签只会显示读取失败。
|
|
49
|
+
* @author ddj 2026年11月25号
|
|
50
|
+
* @param sessionId 归属会话
|
|
51
|
+
* @param address 计划地址
|
|
52
|
+
* @param value 官方资源或审批参数里的计划正文
|
|
53
|
+
* @returns 计划文档;都不命中时 undefined
|
|
54
|
+
*/
|
|
55
|
+
function resolvePlan(sessionId: string, address: string, value: unknown): ReturnType<typeof planDocument> {
|
|
56
|
+
const official = planDocument(address, value)
|
|
57
|
+
if (official) return official
|
|
58
|
+
const cached = cachedPlan(address)
|
|
59
|
+
if (cached) return cached
|
|
60
|
+
try {
|
|
61
|
+
const sessions = optionalService(ctx, 'sessions') as Sessions | undefined
|
|
62
|
+
const feed = sessionId && typeof sessions?.binding === 'function' ? sessions.binding(sessionId)?.eventSource : undefined
|
|
63
|
+
const window = feed?.getSnapshot?.() as PlanWindow | undefined
|
|
64
|
+
if (window && Array.isArray(window.entries)) return planFromEntries(sessionId, address, window.entries)
|
|
65
|
+
} catch { /* 事件窗口不可用:按未找到处理 */ }
|
|
66
|
+
return undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
44
69
|
/** @private @author ddj 2026年10月08号 @param props Official slot props. @returns Transfer status; only closes after preview readiness. */
|
|
45
70
|
function PlanRouter(props: PlanProps) {
|
|
46
71
|
const tab = props.useTabInfo?.()?.tab
|
|
@@ -48,7 +73,7 @@ function planRouter(ctx: PlanContext, official: OfficialSidebar, native: (addres
|
|
|
48
73
|
const address = nav?.address ?? ''
|
|
49
74
|
const resource = props.useResource?.(address) ?? EMPTY_RESOURCE
|
|
50
75
|
const review = nav?.params?.planReview
|
|
51
|
-
const plan =
|
|
76
|
+
const plan = resolvePlan(props.sessionId ?? '', address, review ?? ('value' in resource ? resource.value : undefined))
|
|
52
77
|
const [failed, setFailed] = React.useState(false)
|
|
53
78
|
const done = React.useRef('')
|
|
54
79
|
const key = address + ':' + nav?.revision
|
package/src/client/planState.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Plan identities and live-only event reduction. @author ddj 2026年10月08号 */
|
|
2
2
|
import { planPagePathOf } from './htmlPlan/planPage.js'
|
|
3
|
+
import { HTML_PLAN_EXIT_TOOL, OFFICIAL_PLAN_EXIT_TOOL } from '../shared/htmlPlanMode.js'
|
|
3
4
|
|
|
4
|
-
export interface PlanDocument { address: string; markdown: string; title: string; htmlPath?: string }
|
|
5
|
+
export interface PlanDocument { address: string; markdown: string; title: string; htmlPath?: string; htmlPlanMode?: boolean }
|
|
5
6
|
export interface PlanOpen { path?: string; plan?: PlanDocument }
|
|
6
7
|
export interface PlanEntry { type?: string; event: { type: string; seq?: number; data: unknown } }
|
|
7
8
|
export interface PlanWindow { revision: number; entries: readonly PlanEntry[]; change: { kind: string; entries?: readonly PlanEntry[] } }
|
|
@@ -47,6 +48,48 @@ export function isPlanAddress(address: unknown): address is string {
|
|
|
47
48
|
&& ['one-shot', 'continuable', 'unknown'].includes(segments[3]))
|
|
48
49
|
} catch { return false }
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 取计划地址里的工具调用 id(agent 地址与 subagent 地址都取最后一段)。
|
|
54
|
+
* @author ddj 2026年11月25号
|
|
55
|
+
* @param address 官方计划地址
|
|
56
|
+
* @returns 调用 id;无法解析时 null
|
|
57
|
+
*/
|
|
58
|
+
export function planCallIdOf(address: unknown): string | null {
|
|
59
|
+
if (!isPlanAddress(address)) return null
|
|
60
|
+
try {
|
|
61
|
+
const segments = address.split('/').slice(3).map(decodeURIComponent)
|
|
62
|
+
return segments[segments.length - 1] ?? null
|
|
63
|
+
} catch { return null }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 在会话窗口里按调用 id 找已提交的计划(官方资源提供方只认 `exit_plan_mode`,
|
|
68
|
+
* 不认 HTML 计划模式的 `exit_html_plan_mode`;刷新后缓存为空时靠这里兜底)。
|
|
69
|
+
* @author ddj 2026年11月25号
|
|
70
|
+
* @param sessionId 归属会话
|
|
71
|
+
* @param address 计划地址
|
|
72
|
+
* @param entries 会话窗口条目
|
|
73
|
+
* @returns 计划文档;没找到时 undefined
|
|
74
|
+
*/
|
|
75
|
+
export function planFromEntries(sessionId: string, address: unknown, entries: readonly PlanEntry[]): PlanDocument | undefined {
|
|
76
|
+
const callId = planCallIdOf(address)
|
|
77
|
+
if (!callId || !Array.isArray(entries)) return undefined
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
const event = entry?.event
|
|
80
|
+
if (!event || (event.type !== 'tool/call' && event.type !== 'tool/ptc-dispatch-start')) continue
|
|
81
|
+
const data = record(event.data)
|
|
82
|
+
if (data.name !== HTML_PLAN_EXIT_TOOL && data.name !== OFFICIAL_PLAN_EXIT_TOOL) continue
|
|
83
|
+
const id = typeof data.callId === 'string' ? data.callId : (typeof data.subCallId === 'string' ? data.subCallId : '')
|
|
84
|
+
if (id !== callId) continue
|
|
85
|
+
const plan = planDocument(address as string, {
|
|
86
|
+
markdown: argsOf(data.arguments).plan,
|
|
87
|
+
htmlPlanMode: data.name === HTML_PLAN_EXIT_TOOL,
|
|
88
|
+
})
|
|
89
|
+
if (plan) return plan
|
|
90
|
+
}
|
|
91
|
+
return undefined
|
|
92
|
+
}
|
|
50
93
|
/** @public @author ddj 2026年10月08号 @param address Official address. @param value Provider or review payload. @returns Valid complete read-only plan, if available. */
|
|
51
94
|
export function planDocument(address: string, value: unknown): PlanDocument | undefined {
|
|
52
95
|
const data = record(value)
|
|
@@ -55,9 +98,13 @@ export function planDocument(address: string, value: unknown): PlanDocument | un
|
|
|
55
98
|
if (!title) return undefined
|
|
56
99
|
// HTML 计划页:正文标记行命中时随文档携带路径,计划页签据此切到 iframe 渲染。
|
|
57
100
|
const htmlPath = planPagePathOf(data.markdown)
|
|
58
|
-
|
|
101
|
+
// HTML 计划模式提交的计划:客户端据此渲染自动页,并允许无标记行的计划页签走插件渲染。
|
|
102
|
+
const htmlPlanMode = data.htmlPlanMode === true
|
|
103
|
+
const document: PlanDocument = htmlPath
|
|
59
104
|
? { address, markdown: data.markdown, title, htmlPath }
|
|
60
105
|
: { address, markdown: data.markdown, title }
|
|
106
|
+
if (htmlPlanMode) document.htmlPlanMode = true
|
|
107
|
+
return document
|
|
61
108
|
}
|
|
62
109
|
/** @private @author ddj 2026年10月08号 @param sessionId Current session. @param path Explicit plan path. @param cwd Workspace. Stores bounded associations, not file contents. */
|
|
63
110
|
function associate(sessionId: string, path: string, cwd: string): void {
|
|
@@ -111,10 +158,10 @@ export function createPlanFeed(sessionId: string, cwd = '') {
|
|
|
111
158
|
const call = event.type === 'tool/result' ? pending.get(id) : { name: String(data.name), args }
|
|
112
159
|
if (settled) pending.delete(id)
|
|
113
160
|
if (!call || !live || seen.has(id) || result.isError === true || data.error) return undefined
|
|
114
|
-
if (call.name ===
|
|
161
|
+
if (call.name === OFFICIAL_PLAN_EXIT_TOOL || call.name === HTML_PLAN_EXIT_TOOL) {
|
|
115
162
|
if (event.type === 'tool/result') return undefined
|
|
116
163
|
const address = 'dsh-resource://plan/' + encodeURIComponent(sessionId) + '/' + encodeURIComponent(id)
|
|
117
|
-
const plan = planDocument(address, { markdown: call.args.plan })
|
|
164
|
+
const plan = planDocument(address, { markdown: call.args.plan, htmlPlanMode: call.name === HTML_PLAN_EXIT_TOOL })
|
|
118
165
|
if (plan) { rememberPlan(plan); remember(id); return { plan } }
|
|
119
166
|
return undefined
|
|
120
167
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Official bulk decisions use persisted metadata, never the visible history page. @author ddj 2026年10月27号 */
|
|
2
|
-
import type { ReviewDetail, ReviewItem, ReviewPage, ReviewResult } from '../shared/review.js'
|
|
2
|
+
import type { ReviewDetail, ReviewItem, ReviewPage, ReviewResult, UndoAllItem, UndoAllResult } from '../shared/review.js'
|
|
3
3
|
import { PENDING_PREFIX } from '../shared/pendingReview.js'
|
|
4
4
|
|
|
5
5
|
export interface BatchPort {
|
|
@@ -13,6 +13,53 @@ export interface BatchPort {
|
|
|
13
13
|
}
|
|
14
14
|
export interface BatchResult { completed: number; total: number; paths: string[]; error: string }
|
|
15
15
|
|
|
16
|
+
/** 批量 Undo 的宿主通道:一次往返搞定整批,不再逐条取详情再逐条判定。 */
|
|
17
|
+
export interface UndoAllPort {
|
|
18
|
+
snapshot: () => Promise<ReviewPage>
|
|
19
|
+
undoAll: (items: UndoAllItem[], batchId: string, confirmed: boolean) => Promise<ReviewResult<{ result: UndoAllResult }>>
|
|
20
|
+
/** 需要显式确认时的整批确认;返回 false 视为取消。 */
|
|
21
|
+
confirmExternal: (count: number) => boolean
|
|
22
|
+
guard: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
* @author ddj 2026年11月25号
|
|
28
|
+
* @description: Undo All 走宿主批量通道:一次 RPC、一次事务,遇冲突即停。
|
|
29
|
+
* 非本会话工具写入的来源先要一次确认,确认后带 confirmed 重试同一批。
|
|
30
|
+
* @param port 已鉴权的 RPC 适配器
|
|
31
|
+
* @returns 与逐条口径一致的批量结果
|
|
32
|
+
*/
|
|
33
|
+
export async function runUndoAll(port: UndoAllPort): Promise<BatchResult> {
|
|
34
|
+
const result: BatchResult = { completed: 0, total: 0, paths: [], error: '' }
|
|
35
|
+
try {
|
|
36
|
+
port.guard()
|
|
37
|
+
const items = await loadPending(port)
|
|
38
|
+
// 待审条目走单条判定;批量通道只处理官方审查记录
|
|
39
|
+
const official = items.filter((item) => !item.id.startsWith(PENDING_PREFIX))
|
|
40
|
+
if (!official.length) throw new Error('没有可撤销的官方审查记录')
|
|
41
|
+
result.total = official.length
|
|
42
|
+
|
|
43
|
+
const targets: UndoAllItem[] = official.map((item) => ({
|
|
44
|
+
id: item.id, display: item.display, seq: item.seq, revision: item.revision, operationId: crypto.randomUUID(),
|
|
45
|
+
}))
|
|
46
|
+
const batchId = crypto.randomUUID()
|
|
47
|
+
let reply = await port.undoAll(targets, batchId, false)
|
|
48
|
+
if (!reply.ok) throw new Error(reply.error)
|
|
49
|
+
if (reply.result.needsConfirm) {
|
|
50
|
+
if (!port.confirmExternal(reply.result.needsConfirm)) {
|
|
51
|
+
throw new Error('已取消:这批修改里有非本会话工具写入的来源,撤销前需要确认')
|
|
52
|
+
}
|
|
53
|
+
reply = await port.undoAll(targets, batchId, true)
|
|
54
|
+
if (!reply.ok) throw new Error(reply.error)
|
|
55
|
+
}
|
|
56
|
+
result.completed = reply.result.completed
|
|
57
|
+
result.paths = reply.result.paths
|
|
58
|
+
result.error = reply.result.error
|
|
59
|
+
} catch (cause) { result.error = cause instanceof Error ? cause.message : String(cause) }
|
|
60
|
+
return result
|
|
61
|
+
}
|
|
62
|
+
|
|
16
63
|
/**
|
|
17
64
|
* @public
|
|
18
65
|
* @author ddj 2026年10月31号
|
|
@@ -75,6 +75,8 @@ function pendingCoverKeys(page: ReviewPage | null): Set<string> {
|
|
|
75
75
|
keys.add(diffPathKey(item.currentPath || item.path))
|
|
76
76
|
keys.add(diffPathKey(item.id.slice(PENDING_PREFIX.length)))
|
|
77
77
|
}
|
|
78
|
+
// 已关窗的条目不在 items 里,但路径仍算被窗口接管:旧行与旧工具记录都不能再回来。
|
|
79
|
+
for (const path of page?.pendingCoveredPaths ?? []) keys.add(diffPathKey(path))
|
|
78
80
|
return keys
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -107,7 +109,8 @@ function pendingRowsOf(page: ReviewPage | null): { rows: DiffFile[]; covered: Se
|
|
|
107
109
|
rows.push({
|
|
108
110
|
path,
|
|
109
111
|
// 非 agent 来源才在标签上带徽标:agent 行保持原样,面板不被新增文案刷屏
|
|
110
|
-
|
|
112
|
+
// (agent 行现在还会带证据强度后缀,这里按前缀匹配,不看结尾)。
|
|
113
|
+
label: item.sourceLabel && !/· agent(?: ·|$)/.test(item.sourceLabel) ? `${label} · ${item.sourceLabel}` : label,
|
|
111
114
|
recs: [],
|
|
112
115
|
pending: item.decision === 'pending' ? 1 : 0,
|
|
113
116
|
added: item.added,
|
|
@@ -127,6 +130,7 @@ export function diffSummary(records: (RecordView & { archived?: boolean })[], pa
|
|
|
127
130
|
&& !pending.covered.has(diffPathKey(record.path)) && !officialPath(record.path, page)))
|
|
128
131
|
const files: DiffFile[] = [...pending.rows]
|
|
129
132
|
for (const file of page?.overview?.files ?? []) {
|
|
133
|
+
// 被窗口接管过的路径(含已关窗)不再列官方概览行,否则同一文件处理完又会出现一条。
|
|
130
134
|
if (pending.covered.has(diffPathKey(file.path))) continue
|
|
131
135
|
files.push({ ...file, recs: [] })
|
|
132
136
|
}
|
|
@@ -828,6 +828,8 @@
|
|
|
828
828
|
[data-edrv-view] .edrv-svncommit-close:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #2869b4); outline-offset: 1px; }
|
|
829
829
|
[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); }
|
|
830
830
|
[data-edrv-view] .edrv-svncommit-ctl { flex: none; max-width: 160px; height: 24px; padding: 0 8px; font-size: 11px; line-height: 22px; }
|
|
831
|
+
[data-edrv-view] .edrv-svncommit-sels { display: inline-flex; flex: none; gap: 6px; }
|
|
832
|
+
[data-edrv-view] .edrv-svncommit-sels .edrv-svn-act { height: 24px; padding: 0 8px; font-size: 11px; line-height: 22px; }
|
|
831
833
|
[data-edrv-view] .edrv-svncommit-bar .edrv-svn-check { flex: none; gap: 4px; font-size: 11px; color: var(--dsw-alias-label-secondary, #485762); }
|
|
832
834
|
[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; }
|
|
833
835
|
[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); }
|
|
@@ -839,7 +841,7 @@
|
|
|
839
841
|
[data-edrv-view] .edrv-svncommit-gname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
840
842
|
[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; }
|
|
841
843
|
[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; }
|
|
842
|
-
[data-edrv-view] .edrv-svncommit-row { height: 26px; padding: 0 10px; font-size: 12px; color: var(--dsw-alias-label-primary, #202932); }
|
|
844
|
+
[data-edrv-view] .edrv-svncommit-row { height: 26px; padding: 0 10px; font-size: 12px; color: var(--dsw-alias-label-primary, #202932); -webkit-user-select: none; user-select: none; }
|
|
843
845
|
[data-edrv-view] .edrv-svncommit-row:hover { background: var(--dsw-alias-interactive-bg-hover, #ecf3f9); }
|
|
844
846
|
[data-edrv-view] .edrv-svncommit-row.is-menu { background: var(--dsw-alias-interactive-bg-hover, #ecf3f9); box-shadow: inset 2px 0 0 var(--dsw-alias-brand-primary, #2869b4); }
|
|
845
847
|
[data-edrv-view] .edrv-svncommit-row.is-selected { background: var(--dsw-alias-interactive-bg-hover, #dceaf9); box-shadow: inset 2px 0 0 var(--dsw-alias-brand-primary, #2869b4); }
|
|
@@ -1262,3 +1264,16 @@
|
|
|
1262
1264
|
@media (prefers-reduced-motion: reduce) { .edrv-drag-overlay { transition: none; } }
|
|
1263
1265
|
/* 宿主节点在表格引擎 chunk 加载前就必须有高度,故留在根样式而非 panel.css。 */
|
|
1264
1266
|
.edrv-excel-host { height: 100%; min-height: 0; flex: 1; }
|
|
1267
|
+
|
|
1268
|
+
/* ── HTML 计划模式:计划签徽标(编辑器面板内) ── */
|
|
1269
|
+
[data-edrv-view] .edrv-htmlplan-mode { font-size: 11px; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--dsw-alias-state-accent-primary, #2563eb); color: var(--dsw-alias-state-accent-primary, #2563eb); white-space: nowrap; }
|
|
1270
|
+
[data-edrv-view] .edrv-htmlplan-src { font-size: 11px; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--dsw-alias-state-success-primary, #15803d); color: var(--dsw-alias-state-success-primary, #15803d); white-space: nowrap; }
|
|
1271
|
+
|
|
1272
|
+
/* ── HTML 计划模式:输入框底部栏 chip(composer 区,不在编辑器面板内,选择器不加作用域) ── */
|
|
1273
|
+
.edrv-htmlplan-chip-wrap { display: inline-flex; align-items: center; gap: 6px; }
|
|
1274
|
+
.edrv-htmlplan-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--dsw-alias-state-accent-primary, #2563eb); background: transparent; color: var(--dsw-alias-state-accent-primary, #2563eb); font-size: 12px; font-weight: 600; cursor: pointer; }
|
|
1275
|
+
.edrv-htmlplan-chip:hover:not(:disabled) { filter: brightness(.96); }
|
|
1276
|
+
.edrv-htmlplan-chip:disabled { opacity: .55; cursor: default; }
|
|
1277
|
+
.edrv-htmlplan-chip-glyph { font-size: 9px; }
|
|
1278
|
+
.edrv-htmlplan-chip-x { font-size: 10px; opacity: .75; }
|
|
1279
|
+
.edrv-htmlplan-chip-error { font-size: 11px; color: var(--dsw-alias-state-warning-primary, #b45309); }
|
|
@@ -26,7 +26,7 @@ import { bindPanelCommand } from '../panelCommands.js'
|
|
|
26
26
|
import { dbg, isDebug, rpc } from '../rpc.js'
|
|
27
27
|
import { refreshFeed, subscribeErrors, subscribeRecords } from '../state/recordsFeed.js'
|
|
28
28
|
import { subscribeReview, refreshReview } from '../state/reviewFeed.js'
|
|
29
|
-
import {
|
|
29
|
+
import { runUndoAll } from '../reviewBatch.js'
|
|
30
30
|
import { runKeepAll } from '../reviewKeepAll.js'
|
|
31
31
|
import { toastDom } from '../externalOpen.js'
|
|
32
32
|
import { ReviewAllConfirm } from './ReviewAllConfirm.js'
|
|
@@ -3843,16 +3843,15 @@ export function EditorView(props) {
|
|
|
3843
3843
|
return res.page
|
|
3844
3844
|
}
|
|
3845
3845
|
|
|
3846
|
-
/** @private @author ddj 2026年11月03号 @param token 起批时的会话寿命 @returns
|
|
3846
|
+
/** @private @author ddj 2026年11月03号 / 2026年11月25号 @param token 起批时的会话寿命 @returns 一次往返的批量 Undo(遇冲突即停) */
|
|
3847
3847
|
function undoAllBatch(token) {
|
|
3848
|
-
return
|
|
3848
|
+
return runUndoAll({
|
|
3849
3849
|
snapshot: batchSnapshot,
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
}, true)
|
|
3850
|
+
undoAll: (items, batchId, confirmed) => rpc('edrv.review.undoAll', { sessionId, batchId, items, confirmed }),
|
|
3851
|
+
confirmExternal: (count) => window.confirm(
|
|
3852
|
+
`这批修改里有 ${count} 条不是本会话工具写入的来源(例如编辑器保存、版本库基线或外部脚本)。\n确认整批撤销并写回修改前内容?`),
|
|
3853
|
+
guard: () => guardReviewAll(true, token),
|
|
3854
|
+
})
|
|
3856
3855
|
}
|
|
3857
3856
|
|
|
3858
3857
|
/** @private @author ddj 2026年11月03号 @param token 起批时的会话寿命 @returns 一次 RPC 的批量 Keep 结果(跳过项不算失败) */
|
|
@@ -5083,10 +5082,15 @@ export function EditorView(props) {
|
|
|
5083
5082
|
return React.createElement('div', { className: 'edrv-mdview-stage' }, React.createElement('div', { className: 'edrv-mdview-doc' }, render))
|
|
5084
5083
|
}
|
|
5085
5084
|
|
|
5085
|
+
/** HTML 计划模式:自动页/作者页都失败时,按计划地址回落到官方 Markdown 预览。 */
|
|
5086
|
+
const [planMarkdownFallback, setPlanMarkdownFallback] = React.useState('')
|
|
5087
|
+
|
|
5086
5088
|
let body
|
|
5087
5089
|
if (activePlan) {
|
|
5090
|
+
const planPanelAllowed = Boolean(activePlan.htmlPath || activePlan.htmlPlanMode)
|
|
5091
|
+
const planFallenBack = planMarkdownFallback === activePlan.address
|
|
5088
5092
|
body = React.createElement('div', { className: 'edrv-mdview', ref: planHostRef, 'data-plan-address': activePlan.address },
|
|
5089
|
-
|
|
5093
|
+
planPanelAllowed && !planFallenBack
|
|
5090
5094
|
? React.createElement(HtmlPlanPanel, {
|
|
5091
5095
|
key: activePlan.address,
|
|
5092
5096
|
sessionId,
|
|
@@ -5094,7 +5098,9 @@ export function EditorView(props) {
|
|
|
5094
5098
|
address: activePlan.address,
|
|
5095
5099
|
title: activePlan.title,
|
|
5096
5100
|
htmlPath: activePlan.htmlPath,
|
|
5101
|
+
htmlPlanMode: activePlan.htmlPlanMode,
|
|
5097
5102
|
markdown: activePlan.markdown,
|
|
5103
|
+
onMarkdownFallback: () => setPlanMarkdownFallback(activePlan.address),
|
|
5098
5104
|
})
|
|
5099
5105
|
: planMarkdownBody(activePlan))
|
|
5100
5106
|
} else if (pageChanged === pageIdentity && largeCandidate === pageIdentity) {
|
|
@@ -374,13 +374,13 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
374
374
|
React.createElement('section', { className: 'vsm-panel' },
|
|
375
375
|
React.createElement('h3', { className: 'vsm-panel-title' }, '改动捕获'),
|
|
376
376
|
React.createElement('div', { className: 'vsm-panel-body' },
|
|
377
|
-
React.createElement(SettingRow, { label: '
|
|
377
|
+
React.createElement(SettingRow, { label: '实时跟随', description: '只跟随 AI 文件工具动过的文件:AI 一改就开窗,窗口内的保存与脚本改动都并进同一条差异;没被 AI 动过的文件不产生记录。' },
|
|
378
378
|
React.createElement('input', {
|
|
379
379
|
type: 'checkbox', checked: extWatchOn,
|
|
380
380
|
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
381
381
|
onChange: (event) => saveToggle('externalWatch', event.target.checked, setExtWatchOn),
|
|
382
382
|
})),
|
|
383
|
-
React.createElement(SettingRow, { label: '
|
|
383
|
+
React.createElement(SettingRow, { label: '定期校准', description: '启动时与每 10 分钟把开窗文件与磁盘对齐一次,补齐漏掉的监听事件;关闭后仍可手动校准。' },
|
|
384
384
|
React.createElement('input', {
|
|
385
385
|
type: 'checkbox', checked: extScanOn,
|
|
386
386
|
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
@@ -40,14 +40,16 @@ export function ReviewLedger(props: { sessionId: string; first: ReviewPage | nul
|
|
|
40
40
|
else setError(result.error)
|
|
41
41
|
} catch (cause) { if (!controller.signal.aborted) setError(String(cause)) }
|
|
42
42
|
}
|
|
43
|
-
/** @private @author ddj 2026年11月
|
|
43
|
+
/** @private @author ddj 2026年11月25号 @description 手动校准:把已开窗的文件与磁盘对齐一次,补齐漏掉的改动。 */
|
|
44
44
|
async function align(): Promise<void> {
|
|
45
45
|
if (aligning) return
|
|
46
46
|
setAligning(true)
|
|
47
47
|
try {
|
|
48
48
|
const result = await rpc('edrv.pending.align', { sessionId: props.sessionId })
|
|
49
49
|
if (!result.ok) { setAlignNote(result.error); return }
|
|
50
|
-
setAlignNote(result.
|
|
50
|
+
setAlignNote(result.folded
|
|
51
|
+
? `检查了 ${result.checked} 个追踪中文件,折入 ${result.folded} 条改动`
|
|
52
|
+
: `检查了 ${result.checked} 个追踪中文件,没有新改动`)
|
|
51
53
|
refreshReview(props.sessionId)
|
|
52
54
|
} catch (cause) { setAlignNote(String(cause)) }
|
|
53
55
|
finally { setAligning(false) }
|
|
@@ -56,8 +58,8 @@ export function ReviewLedger(props: { sessionId: string; first: ReviewPage | nul
|
|
|
56
58
|
return h('div', { style: { marginTop: 8 } },
|
|
57
59
|
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center' } },
|
|
58
60
|
h('label', null, h('input', { type: 'checkbox', checked: history, onChange: () => { setHistory(!history); setCursor(0) } }), '显示已处理及被替换的历史'),
|
|
59
|
-
h('button', { type: 'button', disabled: aligning, title: '
|
|
60
|
-
aligning ? '
|
|
61
|
+
h('button', { type: 'button', disabled: aligning, title: '把已开窗的文件与磁盘对齐一次,补齐漏掉的改动', onClick: () => { void align() } },
|
|
62
|
+
aligning ? '校准中…' : '校准一次')),
|
|
61
63
|
alignNote ? h('small', { role: 'status', style: { display: 'block', marginTop: 4 } }, alignNote) : null,
|
|
62
64
|
error ? h('div', { role: 'alert' }, error) : null,
|
|
63
65
|
!page ? h('p', { role: 'status' }, '正在读取官方审查记录…') : null,
|