dsh-vscode-mode 0.35.0 → 0.37.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 +28 -5
- package/lib/client.js +63 -63
- package/lib/client.js.map +1 -1
- package/lib/index.js +1885 -54
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/dsh-vscodemode-html-plan/SKILL.md +1 -1
- package/src/archivePurge.ts +319 -0
- package/src/capture.ts +3 -0
- package/src/client/addToConversation.ts +77 -18
- package/src/client/htmlPlan/HtmlPlanPanel.ts +9 -13
- package/src/client/htmlPlan/planActions.ts +97 -23
- package/src/client/htmlPlan/planPage.ts +2 -2
- package/src/client/reviewBatch.ts +8 -0
- package/src/client/state/diffSummary.ts +6 -1
- package/src/client/state/reviewFeed.ts +35 -4
- package/src/client/ui/EditorView.ts +7 -0
- package/src/client/ui/McpSettings.ts +21 -0
- package/src/client/ui/OfficialReview.ts +20 -2
- package/src/fileOpenSettings.ts +29 -0
- package/src/index.ts +78 -6
- package/src/mcpManaged.ts +12 -3
- package/src/mcpManagerBridge.ts +5 -1
- package/src/mcpRuntime.ts +33 -4
- package/src/pending/capture.ts +32 -4
- package/src/pending/decide.ts +12 -3
- package/src/pending/externalAlign.ts +297 -0
- package/src/pending/externalCapture.ts +677 -0
- package/src/pending/kernel.ts +19 -1
- package/src/pending/persist.ts +201 -12
- package/src/pending/provenance.ts +239 -0
- package/src/pending/store.ts +67 -6
- package/src/pending/vcs.ts +140 -0
- package/src/pendingCompat.ts +13 -6
- package/src/pendingRpc.ts +37 -2
- package/src/rpc.ts +30 -2
- package/src/shared/pendingReview.ts +19 -1
- package/src/shared/review.ts +3 -1
- package/src/shared/rpc.ts +8 -0
|
@@ -25,6 +25,7 @@ let host: {
|
|
|
25
25
|
ctx: PlanActionCtx
|
|
26
26
|
appendText: (sessionId: string | undefined, text: string) => Promise<string>
|
|
27
27
|
sendTask: (sessionId: string | undefined, text: string) => Promise<PlanActionResult>
|
|
28
|
+
steerTask: (sessionId: string | undefined, text: string) => Promise<PlanActionResult>
|
|
28
29
|
} | null = null
|
|
29
30
|
/** 取异常的展示文案。 */
|
|
30
31
|
function messageOf(error: unknown): string {
|
|
@@ -211,15 +212,15 @@ function unwrap(result: unknown): PlanActionResult {
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
/**
|
|
214
|
-
*
|
|
215
|
+
* 安装选项(appendText / sendTask / steerTask 可注入,便于单测;生产缺省用会话输入门面)。
|
|
215
216
|
* @author ddj 2026年11月21号
|
|
216
|
-
* @
|
|
217
|
-
* @returns 幂等卸载器
|
|
217
|
+
* @author ddj 2026年11月24号(新增 steerTask)
|
|
218
218
|
*/
|
|
219
|
-
/** 安装选项(appendText / sendTask 可注入,便于单测;生产缺省用会话输入门面)。 */
|
|
220
219
|
export interface HtmlPlanActionOptions {
|
|
221
220
|
appendText?: (sessionId: string | undefined, text: string) => Promise<string>
|
|
222
221
|
sendTask?: (sessionId: string | undefined, text: string) => Promise<unknown>
|
|
222
|
+
/** 送进 agent 当前回合(steer):答复先到、审批后结算,两者才落在同一次请求里。 */
|
|
223
|
+
steerTask?: (sessionId: string | undefined, text: string) => Promise<unknown>
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
/**
|
|
@@ -244,28 +245,81 @@ function sendResultOf(raw: unknown): PlanActionResult {
|
|
|
244
245
|
return fail('发送结果未知' + detail)
|
|
245
246
|
}
|
|
246
247
|
|
|
248
|
+
/**
|
|
249
|
+
* 安装动作宿主(index.ts 装配一次)。
|
|
250
|
+
* @author ddj 2026年11月21号
|
|
251
|
+
* @param ctx 客户端上下文
|
|
252
|
+
* @returns 幂等卸载器
|
|
253
|
+
*/
|
|
247
254
|
export function installHtmlPlanActions(ctx: PlanActionCtx, options: HtmlPlanActionOptions = {}): () => void {
|
|
248
255
|
const injectedAppend = options.appendText
|
|
249
256
|
const injectedSend = options.sendTask
|
|
257
|
+
const injectedSteer = options.steerTask
|
|
250
258
|
const addToConversation = injectedAppend && injectedSend ? null : createAddToConversation(ctx as never)
|
|
251
259
|
const sendInjected = injectedSend
|
|
260
|
+
const steerInjected = injectedSteer
|
|
252
261
|
const conversations = addToConversation
|
|
262
|
+
|
|
263
|
+
/** 走会话投递门面的详细回执(sendTaskResult 缺失时给可读失败)。 */
|
|
264
|
+
const sendViaResults = async (
|
|
265
|
+
sessionId: string | undefined,
|
|
266
|
+
text: string,
|
|
267
|
+
mode: 'queue' | 'steer',
|
|
268
|
+
): Promise<PlanActionResult> => {
|
|
269
|
+
const send = conversations?.sendTaskResult
|
|
270
|
+
if (typeof send !== 'function') return fail('当前 DSH 不支持直接发送,请用「填入对话输入框」')
|
|
271
|
+
return sendResultOf(await send.call(conversations, sessionId, text, mode))
|
|
272
|
+
}
|
|
273
|
+
|
|
253
274
|
host = {
|
|
254
275
|
ctx,
|
|
255
276
|
appendText: injectedAppend ?? ((sessionId, text) => conversations!.appendText(sessionId, text)),
|
|
256
277
|
sendTask: typeof sendInjected === 'function'
|
|
257
278
|
? async (sessionId, text) => sendResultOf(await sendInjected(sessionId, text))
|
|
258
|
-
:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
279
|
+
: (sessionId, text) => sendViaResults(sessionId, text, 'queue'),
|
|
280
|
+
steerTask: typeof steerInjected === 'function'
|
|
281
|
+
? async (sessionId, text) => sendResultOf(await steerInjected(sessionId, text))
|
|
282
|
+
: (sessionId, text) => sendViaResults(sessionId, text, 'steer'),
|
|
263
283
|
}
|
|
264
284
|
return () => {
|
|
265
285
|
host = null
|
|
266
286
|
}
|
|
267
287
|
}
|
|
268
288
|
|
|
289
|
+
/**
|
|
290
|
+
* 已送进当前回合、但审批结算还没成功的答复:同一 callId 与同一正文不重复送。
|
|
291
|
+
*
|
|
292
|
+
* 批准这一步可能失败(网络、审批已被别处结算),用户会再点一次;没有这张表,
|
|
293
|
+
* 同一份答复会被送两遍给模型。
|
|
294
|
+
*/
|
|
295
|
+
const steeredReplies = new Map<string, { callId: string; text: string }>()
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 把一段正文送进 agent 当前回合(steer),让它和审批结果落在同一次模型请求里。
|
|
299
|
+
*
|
|
300
|
+
* 顺序只能是「先 steer 正文,再结算审批」。反过来时,审批一结算宿主立刻把工具结果
|
|
301
|
+
* 交给模型并开始下一步,而排队投递(queue)的消息属于下一回合,于是表现为
|
|
302
|
+
* 「agent 直接开始执行,我填的答复等这一轮跑完才送到」。
|
|
303
|
+
* @author ddj 2026年11月24号
|
|
304
|
+
* @param sessionId 会话 id
|
|
305
|
+
* @param callId 待审批调用的 id(同一份答复的去重键)
|
|
306
|
+
* @param body 正文
|
|
307
|
+
* @returns 动作结果
|
|
308
|
+
*/
|
|
309
|
+
async function steerIntoRun(sessionId: string, callId: string, body: string): Promise<PlanActionResult> {
|
|
310
|
+
const previous = steeredReplies.get(sessionId)
|
|
311
|
+
if (previous && previous.callId === callId && previous.text === body) return ok()
|
|
312
|
+
if (!host) return fail('计划动作桥未就绪')
|
|
313
|
+
let result: PlanActionResult
|
|
314
|
+
try {
|
|
315
|
+
result = await host.steerTask(sessionId, body)
|
|
316
|
+
} catch (error) {
|
|
317
|
+
return fail('送进当前回合失败:' + messageOf(error))
|
|
318
|
+
}
|
|
319
|
+
if (result.ok) steeredReplies.set(sessionId, { callId, text: body })
|
|
320
|
+
return result
|
|
321
|
+
}
|
|
322
|
+
|
|
269
323
|
/**
|
|
270
324
|
* 回答官方 plan-review:批准 = 选批准标签;不批准 = 选继续规划标签(若官方提供)。
|
|
271
325
|
* @author ddj 2026年11月21号
|
|
@@ -282,6 +336,7 @@ export async function answerPlanReview(sessionId: string, approve: boolean): Pro
|
|
|
282
336
|
if (!label) return fail(approve ? '该审批没有可用的批准选项' : '官方审批没有「继续规划」选项,请在对话中要求修改')
|
|
283
337
|
try {
|
|
284
338
|
await live.pending.answer({ answers: [{ id: live.labels.questionId, selected: [label] }] })
|
|
339
|
+
steeredReplies.delete(sessionId)
|
|
285
340
|
return ok()
|
|
286
341
|
} catch (error) {
|
|
287
342
|
return fail('提交审批失败:' + messageOf(error))
|
|
@@ -296,7 +351,9 @@ export async function answerPlanReview(sessionId: string, approve: boolean): Pro
|
|
|
296
351
|
return fail('当前 DSH 不支持在插件内作答,请在对话审批卡片中操作')
|
|
297
352
|
}
|
|
298
353
|
try {
|
|
299
|
-
|
|
354
|
+
const result = unwrap(await questions.answer(sessionId, review.callId, answer))
|
|
355
|
+
if (result.ok) steeredReplies.delete(sessionId)
|
|
356
|
+
return result
|
|
300
357
|
} catch (error) {
|
|
301
358
|
return fail('提交审批失败:' + messageOf(error))
|
|
302
359
|
}
|
|
@@ -323,27 +380,44 @@ export async function exitPlanMode(sessionId: string): Promise<PlanActionResult>
|
|
|
323
380
|
}
|
|
324
381
|
|
|
325
382
|
/**
|
|
326
|
-
*
|
|
383
|
+
* 把手填正文交给 agent,并同时结算官方审批(页面「回复」/「回复并执行」)。
|
|
384
|
+
*
|
|
385
|
+
* 有待审批卡片时:先把正文 steer 进当前回合,再结算审批(approve=true 选批准标签,
|
|
386
|
+
* false 选「继续规划」)。宿主在审批一结算就把工具结果交给模型并开始下一步,
|
|
387
|
+
* 所以顺序不能反——反过来时答复只能排到下一回合,表现为「agent 先执行,答复晚一步才送到」。
|
|
388
|
+
* steer 失败就不动审批(保持可重试),避免出现「批了但答复没送到」的半截状态。
|
|
327
389
|
* @author ddj 2026年11月21号
|
|
390
|
+
* @author ddj 2026年11月24号(批准前先把正文送进当前回合;新增 approve 参数)
|
|
328
391
|
* @param sessionId 会话 id
|
|
329
|
-
* @param text 答复 markdown
|
|
330
|
-
* @
|
|
392
|
+
* @param text 答复 / 指令 markdown
|
|
393
|
+
* @param approve true 结算为「同意执行」,false 结算为「继续规划」;没有待审批时只发消息
|
|
394
|
+
* @returns 动作结果(失败带原因,正文不丢)
|
|
331
395
|
*/
|
|
332
|
-
export async function submitPlanResponse(sessionId: string, text: string): Promise<PlanActionResult> {
|
|
396
|
+
export async function submitPlanResponse(sessionId: string, text: string, approve = true): Promise<PlanActionResult> {
|
|
333
397
|
if (!host) return fail('计划动作桥未就绪')
|
|
334
398
|
if (!sessionId) return fail('当前没有活动会话')
|
|
335
399
|
const body = String(text ?? '').trim()
|
|
336
|
-
if (!body) return fail('答复为空:先在页面里作答再点「回复」')
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
|
|
400
|
+
if (!body) return fail(approve ? '答复为空:先在页面里作答再点「回复」' : '指令为空')
|
|
401
|
+
const review = readPendingReview(sessionId)
|
|
402
|
+
if (!review) {
|
|
403
|
+
try {
|
|
404
|
+
return await host.sendTask(sessionId, body)
|
|
405
|
+
} catch (error) {
|
|
406
|
+
return fail('发送失败:' + messageOf(error))
|
|
407
|
+
}
|
|
341
408
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return fail('
|
|
409
|
+
const bodyLabel = approve ? '答复' : '指令'
|
|
410
|
+
const steered = await steerIntoRun(sessionId, review.callId, body)
|
|
411
|
+
if (!steered.ok) {
|
|
412
|
+
return fail(bodyLabel + '没送进当前回合,审批保持待处理:' + String(steered.error ?? '') + '。可点「填入对话输入框」手动发送')
|
|
346
413
|
}
|
|
414
|
+
const settled = await answerPlanReview(sessionId, approve)
|
|
415
|
+
if (!settled.ok) {
|
|
416
|
+
const settleLabel = approve ? '批准' : '「继续规划」'
|
|
417
|
+
return fail(bodyLabel + '已送进当前回合,但' + settleLabel + '失败:' + String(settled.error ?? '')
|
|
418
|
+
+ '。点页签的「' + (approve ? '同意执行' : '继续规划') + '」重试即可,' + bodyLabel + '不会重复发送')
|
|
419
|
+
}
|
|
420
|
+
return ok()
|
|
347
421
|
}
|
|
348
422
|
|
|
349
423
|
/**
|
|
@@ -95,7 +95,7 @@ const BRIDGE_SCRIPT = [
|
|
|
95
95
|
' const copy = Array.from(footer.querySelectorAll("button")).find((btn) => /copy response|复制答复/i.test(btn.textContent || ""))',
|
|
96
96
|
' footer.insertBefore(reply, copy || footer.firstChild)',
|
|
97
97
|
' const hint = sheet.querySelector("p.hint")',
|
|
98
|
-
' if (hint) hint.textContent = reviewPending ? "点「回复并执行」=
|
|
98
|
+
' if (hint) hint.textContent = reviewPending ? "点「回复并执行」= 把答复和批准一起交给 agent(同一步读到);要改计划请先点页签「继续规划」。" : "点「回复」直接发送给 agent;也可以复制后手动粘贴。"',
|
|
99
99
|
' }',
|
|
100
100
|
' }',
|
|
101
101
|
' try { new MutationObserver(() => { try { hookSheet() } catch (error) { /* 忽略 */ } }).observe(document.body || document.documentElement, { childList: true, subtree: true }) } catch (error) { /* 无 MutationObserver */ }',
|
|
@@ -109,7 +109,7 @@ const BRIDGE_SCRIPT = [
|
|
|
109
109
|
' const reply = Array.from(sheet.querySelectorAll("footer button")).find((btn) => /回复|发送中|已发送|发送失败/.test(btn.textContent || ""))',
|
|
110
110
|
' if (reply && !reply.disabled) reply.textContent = reviewPending ? "回复并执行" : "回复"',
|
|
111
111
|
' const hint = sheet.querySelector("p.hint")',
|
|
112
|
-
' if (hint && !/发送失败/.test(hint.textContent || "")) hint.textContent = reviewPending ? "点「回复并执行」=
|
|
112
|
+
' if (hint && !/发送失败/.test(hint.textContent || "")) hint.textContent = reviewPending ? "点「回复并执行」= 把答复和批准一起交给 agent(同一步读到);要改计划请先点页签「继续规划」。" : "点「回复」直接发送给 agent;也可以复制后手动粘贴。"',
|
|
113
113
|
' }',
|
|
114
114
|
' return',
|
|
115
115
|
' }',
|
|
@@ -8,6 +8,8 @@ export interface BatchPort {
|
|
|
8
8
|
decide: (detail: ReviewDetail, reject: boolean, operationId: string) => Promise<ReviewResult<{ revision: number }>>
|
|
9
9
|
guard: () => void
|
|
10
10
|
operation: (detail: ReviewDetail, reject: boolean) => string
|
|
11
|
+
/** 撤销里含非 agent 来源时的整批确认;缺省视为不允许(严格口径)。 */
|
|
12
|
+
confirmExternal?: (details: ReviewDetail[]) => boolean
|
|
11
13
|
}
|
|
12
14
|
export interface BatchResult { completed: number; total: number; paths: string[]; error: string }
|
|
13
15
|
|
|
@@ -59,6 +61,12 @@ export async function runReviewBatch(port: BatchPort, reject: boolean): Promise<
|
|
|
59
61
|
if (reject && !detail.capability.undo) throw new Error(`${item.display}:${detail.capability.reason}`)
|
|
60
62
|
details.push(detail)
|
|
61
63
|
}
|
|
64
|
+
// 非 agent 来源(编辑器保存 / 版本库基线 / 外部写入)先问一次,避免整批撤销误伤用户代码
|
|
65
|
+
if (reject && details.some((detail) => detail.capability.confirmUndo)) {
|
|
66
|
+
if (!port.confirmExternal || !port.confirmExternal(details.filter((detail) => detail.capability.confirmUndo))) {
|
|
67
|
+
throw new Error('已取消:这批修改里有非本会话工具写入的来源,撤销前需要确认')
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
// Reverse chronological snapshots allow a newer round's result to expose the previous round's endpoint.
|
|
63
71
|
details.sort((left, right) => right.capturedAt.localeCompare(left.capturedAt) || right.item.seq - left.item.seq)
|
|
64
72
|
for (const detail of details) {
|
|
@@ -12,6 +12,8 @@ export interface DiffFile extends FileSummary {
|
|
|
12
12
|
added?: number
|
|
13
13
|
/** 待审行的删除行数。 */
|
|
14
14
|
deleted?: number
|
|
15
|
+
/** 待审行的来源徽标(如「watch · 外部」);官方与历史行为空。 */
|
|
16
|
+
sourceLabel?: string
|
|
15
17
|
}
|
|
16
18
|
export interface DiffSummary extends Summary { files: DiffFile[]; pendingFiles: DiffFile[] }
|
|
17
19
|
|
|
@@ -101,14 +103,17 @@ function pendingRowsOf(page: ReviewPage | null): { rows: DiffFile[]; covered: Se
|
|
|
101
103
|
for (const item of page?.items ?? []) {
|
|
102
104
|
if (!item.id.startsWith(PENDING_PREFIX)) continue
|
|
103
105
|
const path = item.currentPath || item.path
|
|
106
|
+
const label = item.display || path
|
|
104
107
|
rows.push({
|
|
105
108
|
path,
|
|
106
|
-
|
|
109
|
+
// 非 agent 来源才在标签上带徽标:agent 行保持原样,面板不被新增文案刷屏
|
|
110
|
+
label: item.sourceLabel && !item.sourceLabel.endsWith('· agent') ? `${label} · ${item.sourceLabel}` : label,
|
|
107
111
|
recs: [],
|
|
108
112
|
pending: item.decision === 'pending' ? 1 : 0,
|
|
109
113
|
added: item.added,
|
|
110
114
|
deleted: item.deleted,
|
|
111
115
|
sourceKind: 'pending',
|
|
116
|
+
sourceLabel: item.sourceLabel,
|
|
112
117
|
})
|
|
113
118
|
}
|
|
114
119
|
return { rows, covered: pendingCoverKeys(page) }
|
|
@@ -4,8 +4,12 @@ import type { ReviewPage } from '../../shared/review.js'
|
|
|
4
4
|
|
|
5
5
|
export interface ReviewFeed { page: ReviewPage | null; error: string }
|
|
6
6
|
type Listener = (feed: ReviewFeed) => void
|
|
7
|
-
interface Entry { listeners: Set<Listener>; value: ReviewFeed; controller: AbortController; timer?: ReturnType<typeof setTimeout>; loading: boolean; again: boolean; onRefresh: () => void; onVisible?: () => void }
|
|
7
|
+
interface Entry { listeners: Set<Listener>; value: ReviewFeed; controller: AbortController; timer?: ReturnType<typeof setTimeout>; loading: boolean; again: boolean; onRefresh: () => void; onVisible?: () => void; version: number; versionTimer?: ReturnType<typeof setInterval> }
|
|
8
8
|
const feeds = new Map<string, Entry>()
|
|
9
|
+
/** 列表轮询间隔:版本号没变时不重读列表。 */
|
|
10
|
+
const POLL_MS = 5000
|
|
11
|
+
/** 待审版本号轮询间隔:只读 Host 内存计数,用来把「新记录出现」的延迟压到 1s 量级。 */
|
|
12
|
+
const VERSION_POLL_MS = 1000
|
|
9
13
|
|
|
10
14
|
/** @private @author ddj 2026年10月26号 @param entry Shared feed. Notify mounted observers only. */
|
|
11
15
|
function notify(entry: Entry): void { for (const listener of entry.listeners) listener(entry.value) }
|
|
@@ -33,18 +37,44 @@ async function refresh(sessionId: string, entry: Entry, force = false): Promise<
|
|
|
33
37
|
if (!force && JSON.stringify(previous) === JSON.stringify(entry.value)) entry.value = previous
|
|
34
38
|
else notify(entry)
|
|
35
39
|
if (entry.again) void refresh(sessionId, entry, true)
|
|
36
|
-
else entry.timer = setTimeout(() => { void refresh(sessionId, entry) },
|
|
40
|
+
else entry.timer = setTimeout(() => { void refresh(sessionId, entry) }, POLL_MS)
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
* @author ddj 2026年11月24号
|
|
48
|
+
* @description: 轮询待审版本号:只读 Host 内存计数,变号才触发整页重读。
|
|
49
|
+
* 这条通道把「agent 用 bash 改完文件」到「面板出现记录」的延迟从 5s 压到 1s 量级。
|
|
50
|
+
* @param sessionId 会话作用域
|
|
51
|
+
* @param entry 共享订阅
|
|
52
|
+
* @returns 无
|
|
53
|
+
*/
|
|
54
|
+
function pollVersion(sessionId: string, entry: Entry): void {
|
|
55
|
+
const controller = entry.controller
|
|
56
|
+
const tick = async (): Promise<void> => {
|
|
57
|
+
if (controller.signal.aborted || (typeof document !== 'undefined' && document.hidden)) return
|
|
58
|
+
try {
|
|
59
|
+
const result = await rpc('edrv.pending.version', { sessionId }, controller.signal)
|
|
60
|
+
if (controller.signal.aborted || !result.ok) return
|
|
61
|
+
if (entry.version === 0) { entry.version = result.version; return }
|
|
62
|
+
if (result.version === entry.version) return
|
|
63
|
+
entry.version = result.version
|
|
64
|
+
void refresh(sessionId, entry, true)
|
|
65
|
+
} catch { /* 版本探测失败不影响列表轮询 */ }
|
|
66
|
+
}
|
|
67
|
+
entry.versionTimer = setInterval(() => { void tick() }, VERSION_POLL_MS)
|
|
68
|
+
void tick()
|
|
69
|
+
}
|
|
70
|
+
|
|
41
71
|
/** @public @author ddj 2026年10月26号 @param sessionId Live scope. @param listener Mounted observer. @returns Cleanup cancelling requests and timers when unused. */
|
|
42
72
|
export function subscribeReview(sessionId: string, listener: Listener): () => void {
|
|
43
73
|
let entry = feeds.get(sessionId)
|
|
44
74
|
if (!entry) {
|
|
45
75
|
/** @private @author ddj 2026年10月26号 Refresh the shared official metadata after edits/decisions. */
|
|
46
76
|
const onRefresh = (): void => refreshReview(sessionId)
|
|
47
|
-
entry = { listeners: new Set(), value: { page: null, error: '' }, controller: new AbortController(), loading: false, again: false, onRefresh }
|
|
77
|
+
entry = { listeners: new Set(), value: { page: null, error: '' }, controller: new AbortController(), loading: false, again: false, onRefresh, version: 0 }
|
|
48
78
|
feeds.set(sessionId, entry)
|
|
49
79
|
if (typeof window !== 'undefined') window.addEventListener('edrv:refresh', onRefresh)
|
|
50
80
|
if (typeof document !== 'undefined') {
|
|
@@ -53,12 +83,13 @@ export function subscribeReview(sessionId: string, listener: Listener): () => vo
|
|
|
53
83
|
document.addEventListener('visibilitychange', entry.onVisible)
|
|
54
84
|
}
|
|
55
85
|
void refresh(sessionId, entry)
|
|
86
|
+
pollVersion(sessionId, entry)
|
|
56
87
|
}
|
|
57
88
|
entry.listeners.add(listener); listener(entry.value)
|
|
58
89
|
return () => {
|
|
59
90
|
entry.listeners.delete(listener)
|
|
60
91
|
if (entry.listeners.size || feeds.get(sessionId) !== entry) return
|
|
61
|
-
entry.controller.abort(); clearTimeout(entry.timer); feeds.delete(sessionId)
|
|
92
|
+
entry.controller.abort(); clearTimeout(entry.timer); clearInterval(entry.versionTimer); feeds.delete(sessionId)
|
|
62
93
|
if (typeof window !== 'undefined') window.removeEventListener('edrv:refresh', entry.onRefresh)
|
|
63
94
|
if (entry.onVisible && typeof document !== 'undefined') document.removeEventListener('visibilitychange', entry.onVisible)
|
|
64
95
|
}
|
|
@@ -3580,6 +3580,11 @@ export function EditorView(props) {
|
|
|
3580
3580
|
*/
|
|
3581
3581
|
async function submitOfficialDecision(detail, reject, blockId) {
|
|
3582
3582
|
const source = detail.item
|
|
3583
|
+
// 撤销白名单:非 agent 来源(编辑器保存 / 版本库基线 / 外部写入)先确认一次再写盘
|
|
3584
|
+
if (reject && detail.capability?.confirmUndo && !window.confirm(
|
|
3585
|
+
`「${source.display || source.path}」的改动来自 ${source.sourceLabel || '外部来源'},不是本会话工具写的。\n确认撤销并写回修改前内容?`)) {
|
|
3586
|
+
throw new Error('已取消撤销')
|
|
3587
|
+
}
|
|
3583
3588
|
const opKey = JSON.stringify([sessionId, source.id, source.seq, source.revision, blockId, reject])
|
|
3584
3589
|
let operationId = reviewOpsRef.current.get(opKey)
|
|
3585
3590
|
if (!operationId) { operationId = crypto.randomUUID(); reviewOpsRef.current.set(opKey, operationId) }
|
|
@@ -3844,6 +3849,8 @@ export function EditorView(props) {
|
|
|
3844
3849
|
snapshot: batchSnapshot,
|
|
3845
3850
|
detail: async (id) => { const res = await rpc('edrv.review.detail', { sessionId, id }); if (!res.ok) throw new Error(res.error); return res.detail },
|
|
3846
3851
|
decide: (detail, undo, operationId) => rpc('edrv.review.decide', { sessionId, id: detail.item.id, seq: detail.item.seq, revision: detail.item.revision, operationId, scope: 'file', decision: undo ? 'rejected' : 'accepted' }),
|
|
3852
|
+
confirmExternal: (details) => window.confirm(
|
|
3853
|
+
`这批修改里有 ${details.length} 条不是本会话工具写入的来源(例如编辑器保存、版本库基线或外部脚本)。\n确认整批撤销并写回修改前内容?`),
|
|
3847
3854
|
guard: () => guardReviewAll(true, token), operation: batchOperation,
|
|
3848
3855
|
}, true)
|
|
3849
3856
|
}
|
|
@@ -151,6 +151,8 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
151
151
|
const [nativeDraft, setNativeDraft] = React.useState(null) // 原生打开范围草稿(同上提交语义)
|
|
152
152
|
const [refIntakeOn, setRefIntakeOn] = React.useState(true) // 引用接入(拖拽/粘贴/复制 → 引用 chip)
|
|
153
153
|
const [searchReplaceOn, setSearchReplaceOn] = React.useState(true) // 搜索面板全局替换
|
|
154
|
+
const [extWatchOn, setExtWatchOn] = React.useState(true) // 外部改动实时捕获(watch)
|
|
155
|
+
const [extScanOn, setExtScanOn] = React.useState(true) // 外部改动补扫(启动对齐与定时)
|
|
154
156
|
const [kbMessage, setKbMessage] = React.useState('') // 打开官方快捷键弹窗的失败说明(空 = 未失败)
|
|
155
157
|
const settings = React.useContext(SettingsContext)
|
|
156
158
|
const snapshot = settings?.getSnapshot?.()
|
|
@@ -168,6 +170,8 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
168
170
|
setNativeSaved(typeof native === 'string' && native.trim() ? native : DEFAULT_NATIVE_CSV)
|
|
169
171
|
setRefIntakeOn(snap?.value?.refIntake !== false)
|
|
170
172
|
setSearchReplaceOn(snap?.value?.searchReplace !== false)
|
|
173
|
+
setExtWatchOn(snap?.value?.externalWatch !== false)
|
|
174
|
+
setExtScanOn(snap?.value?.externalScan !== false)
|
|
171
175
|
}
|
|
172
176
|
onChange()
|
|
173
177
|
return settings?.subscribe?.(onChange)
|
|
@@ -367,6 +371,23 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
367
371
|
})),
|
|
368
372
|
),
|
|
369
373
|
),
|
|
374
|
+
React.createElement('section', { className: 'vsm-panel' },
|
|
375
|
+
React.createElement('h3', { className: 'vsm-panel-title' }, '改动捕获'),
|
|
376
|
+
React.createElement('div', { className: 'vsm-panel-body' },
|
|
377
|
+
React.createElement(SettingRow, { label: '实时捕获', description: 'agent 用 shell 或脚本(node -e、prettier、生成器)写文件时,改动也会进审查面板;关闭后只认 edit/write 等写工具。' },
|
|
378
|
+
React.createElement('input', {
|
|
379
|
+
type: 'checkbox', checked: extWatchOn,
|
|
380
|
+
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
381
|
+
onChange: (event) => saveToggle('externalWatch', event.target.checked, setExtWatchOn),
|
|
382
|
+
})),
|
|
383
|
+
React.createElement(SettingRow, { label: '补扫对齐', description: '启动时与每 10 分钟用版本库比对一次,把漏采的改动补录进来;关闭后仍可手动补扫。' },
|
|
384
|
+
React.createElement('input', {
|
|
385
|
+
type: 'checkbox', checked: extScanOn,
|
|
386
|
+
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
387
|
+
onChange: (event) => saveToggle('externalScan', event.target.checked, setExtScanOn),
|
|
388
|
+
})),
|
|
389
|
+
),
|
|
390
|
+
),
|
|
370
391
|
React.createElement('section', { className: 'vsm-panel' },
|
|
371
392
|
React.createElement('h3', { className: 'vsm-panel-title' }, '快捷键'),
|
|
372
393
|
React.createElement('div', { className: 'vsm-panel-body' },
|
|
@@ -13,6 +13,8 @@ export function ReviewLedger(props: { sessionId: string; first: ReviewPage | nul
|
|
|
13
13
|
const [cursor, setCursor] = React.useState(0)
|
|
14
14
|
const [detail, setDetail] = React.useState<ReviewDetail | null>(null)
|
|
15
15
|
const [error, setError] = React.useState('')
|
|
16
|
+
const [aligning, setAligning] = React.useState(false)
|
|
17
|
+
const [alignNote, setAlignNote] = React.useState('')
|
|
16
18
|
const selected = React.useRef<AbortController | null>(null)
|
|
17
19
|
React.useEffect(() => () => selected.current?.abort(), [])
|
|
18
20
|
React.useEffect(() => {
|
|
@@ -38,9 +40,25 @@ export function ReviewLedger(props: { sessionId: string; first: ReviewPage | nul
|
|
|
38
40
|
else setError(result.error)
|
|
39
41
|
} catch (cause) { if (!controller.signal.aborted) setError(String(cause)) }
|
|
40
42
|
}
|
|
43
|
+
/** @private @author ddj 2026年11月24号 @description 手动补扫:用版本库基线与已知内容对齐一次,把漏采的改动补进列表。 */
|
|
44
|
+
async function align(): Promise<void> {
|
|
45
|
+
if (aligning) return
|
|
46
|
+
setAligning(true)
|
|
47
|
+
try {
|
|
48
|
+
const result = await rpc('edrv.pending.align', { sessionId: props.sessionId })
|
|
49
|
+
if (!result.ok) { setAlignNote(result.error); return }
|
|
50
|
+
setAlignNote(result.imported ? `补扫新增 ${result.imported} 条(版本库报告 ${result.changed} 个改动)` : `没有需要补录的改动(版本库报告 ${result.changed} 个改动)`)
|
|
51
|
+
refreshReview(props.sessionId)
|
|
52
|
+
} catch (cause) { setAlignNote(String(cause)) }
|
|
53
|
+
finally { setAligning(false) }
|
|
54
|
+
}
|
|
41
55
|
const gaps = page?.gaps ?? []
|
|
42
56
|
return h('div', { style: { marginTop: 8 } },
|
|
43
|
-
h('
|
|
57
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center' } },
|
|
58
|
+
h('label', null, h('input', { type: 'checkbox', checked: history, onChange: () => { setHistory(!history); setCursor(0) } }), '显示已处理及被替换的历史'),
|
|
59
|
+
h('button', { type: 'button', disabled: aligning, title: '用版本库基线与已知内容对齐一次,补录漏采的改动', onClick: () => { void align() } },
|
|
60
|
+
aligning ? '补扫中…' : '补扫一次')),
|
|
61
|
+
alignNote ? h('small', { role: 'status', style: { display: 'block', marginTop: 4 } }, alignNote) : null,
|
|
44
62
|
error ? h('div', { role: 'alert' }, error) : null,
|
|
45
63
|
!page ? h('p', { role: 'status' }, '正在读取官方审查记录…') : null,
|
|
46
64
|
page && !page.items.length ? h('p', null, history ? '暂无已落盘历史。' : '没有待处理的官方记录;可切换查看历史。') : null,
|
|
@@ -49,7 +67,7 @@ export function ReviewLedger(props: { sessionId: string; first: ReviewPage | nul
|
|
|
49
67
|
title: item.currentPath || item.path,
|
|
50
68
|
style: { display: 'block', width: '100%', textAlign: 'left', padding: '6px 4px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' },
|
|
51
69
|
}, item.id.startsWith(PENDING_PREFIX)
|
|
52
|
-
? `【待审】${item.display} +${item.added} −${item.deleted} · ${item.decision}${item.kind === 'oversized' ? ' · 过大' : ''}`
|
|
70
|
+
? `【待审】${item.display} +${item.added} −${item.deleted} · ${item.decision}${item.sourceLabel ? ' · ' + item.sourceLabel : ''}${item.kind === 'oversized' ? ' · 过大' : ''}`
|
|
53
71
|
: `轮次 ${item.turn} · ${item.display} +${item.added} −${item.deleted} · ${item.decision}${item.current ? '' : '(已被同轮新版本替换)'}`))),
|
|
54
72
|
cursor > 0 ? h('button', { type: 'button', onClick: () => setCursor(Math.max(0, cursor - 50)) }, '上一页') : null,
|
|
55
73
|
page?.nextCursor !== null && page?.nextCursor !== undefined ? h('button', { type: 'button', onClick: () => setCursor(page.nextCursor!) }, '下一页') : null,
|
package/src/fileOpenSettings.ts
CHANGED
|
@@ -41,6 +41,10 @@ export interface FileOpenSettings {
|
|
|
41
41
|
svnReadOnly?: boolean
|
|
42
42
|
/** AI 提交信息风格(默认 plain)。 */
|
|
43
43
|
aiCommitStyle?: 'plain' | 'conventional'
|
|
44
|
+
/** 外部改动实时捕获(watch,默认 true)。 */
|
|
45
|
+
externalWatch?: boolean
|
|
46
|
+
/** 外部改动补扫(启动对齐与定时,默认 true)。 */
|
|
47
|
+
externalScan?: boolean
|
|
44
48
|
}
|
|
45
49
|
export interface FileOpenSettingsState { value: string; revision?: number; update: (value: string, expectedRevision?: number) => Promise<void> }
|
|
46
50
|
|
|
@@ -462,6 +466,9 @@ export function buildSettingsSchema(z: SettingsDeps['z'], options?: { volatile?:
|
|
|
462
466
|
// 交互特性开关(默认开):拖拽/粘贴/复制的引用接入;搜索面板的全局替换
|
|
463
467
|
refIntake: withVol(z.boolean().default(true)),
|
|
464
468
|
searchReplace: withVol(z.boolean().default(true)),
|
|
469
|
+
// 外部改动捕获(默认开):watch 实时采集 / 版本库补扫。关掉即退回只认工具链路的行为。
|
|
470
|
+
externalWatch: withVol(z.boolean().default(true)),
|
|
471
|
+
externalScan: withVol(z.boolean().default(true)),
|
|
465
472
|
}
|
|
466
473
|
if (wantVolatile) configVolatile = { requested: true, marked, total: Object.keys(shape).length }
|
|
467
474
|
return z.object(shape)
|
|
@@ -652,6 +659,14 @@ export interface PluginAiUiSettings {
|
|
|
652
659
|
commitStyle: 'plain' | 'conventional'
|
|
653
660
|
}
|
|
654
661
|
|
|
662
|
+
/** 外部改动捕获开关视图(host 采集层与设置页共用)。 */
|
|
663
|
+
export interface PluginExternalSettings {
|
|
664
|
+
/** 实时监听工作区写事件并补记录。 */
|
|
665
|
+
watch: boolean
|
|
666
|
+
/** 启动对齐与定时补扫。 */
|
|
667
|
+
scan: boolean
|
|
668
|
+
}
|
|
669
|
+
|
|
655
670
|
/** setupOpenSettings 句柄(设置读写 + 分面视图读取)。 */
|
|
656
671
|
export interface OpenSettingsHandle extends FileOpenSettingsState {
|
|
657
672
|
/** AI 补全配置。 */
|
|
@@ -664,6 +679,8 @@ export interface OpenSettingsHandle extends FileOpenSettingsState {
|
|
|
664
679
|
svnCommitDefaults: () => PluginSvnCommitDefaults
|
|
665
680
|
/** AI 界面设置。 */
|
|
666
681
|
aiUi: () => PluginAiUiSettings
|
|
682
|
+
/** 外部改动捕获开关。 */
|
|
683
|
+
external: () => PluginExternalSettings
|
|
667
684
|
}
|
|
668
685
|
|
|
669
686
|
/**
|
|
@@ -703,6 +720,11 @@ export function setupOpenSettings(ctx: Ctx, config: unknown, onChange: (value: s
|
|
|
703
720
|
}
|
|
704
721
|
/** AI 界面设置当前值(提交信息风格 / 整理是否默认按勾选范围)。 */
|
|
705
722
|
let aiUiCurrent: PluginAiUiSettings = { commitStyle: commitStyleValueOf(config) }
|
|
723
|
+
/** 外部改动捕获开关当前值(settings 未就绪回退配置值)。 */
|
|
724
|
+
let externalCurrent: PluginExternalSettings = {
|
|
725
|
+
watch: boolValueOf(config, 'externalWatch', true),
|
|
726
|
+
scan: boolValueOf(config, 'externalScan', true),
|
|
727
|
+
}
|
|
706
728
|
const svnSync = (stored: unknown): void => {
|
|
707
729
|
svnCurrent = {
|
|
708
730
|
svnPath: svnPathValueOf(stored),
|
|
@@ -713,6 +735,10 @@ export function setupOpenSettings(ctx: Ctx, config: unknown, onChange: (value: s
|
|
|
713
735
|
autoDelete: boolValueOf(stored, 'svnAutoDeleteMissing', true),
|
|
714
736
|
}
|
|
715
737
|
aiUiCurrent = { commitStyle: commitStyleValueOf(stored) }
|
|
738
|
+
externalCurrent = {
|
|
739
|
+
watch: boolValueOf(stored, 'externalWatch', true),
|
|
740
|
+
scan: boolValueOf(stored, 'externalScan', true),
|
|
741
|
+
}
|
|
716
742
|
}
|
|
717
743
|
/** 读取 settings 存储值(describe 未就绪返回 undefined)。 */
|
|
718
744
|
const storedValue = (): unknown => {
|
|
@@ -729,6 +755,8 @@ export function setupOpenSettings(ctx: Ctx, config: unknown, onChange: (value: s
|
|
|
729
755
|
svnAutoDeleteMissing: svnCurrent.autoDelete,
|
|
730
756
|
svnReadOnly: svnCurrent.readOnly,
|
|
731
757
|
aiCommitStyle: aiUiCurrent.commitStyle,
|
|
758
|
+
externalWatch: externalCurrent.watch,
|
|
759
|
+
externalScan: externalCurrent.scan,
|
|
732
760
|
}, {
|
|
733
761
|
setSource: (source) => {
|
|
734
762
|
notify(source().fileOpenTool)
|
|
@@ -764,6 +792,7 @@ export function setupOpenSettings(ctx: Ctx, config: unknown, onChange: (value: s
|
|
|
764
792
|
svn: () => svnCurrent,
|
|
765
793
|
svnCommitDefaults: () => ({ autoAdd: svnCurrent.autoAdd, autoDelete: svnCurrent.autoDelete }),
|
|
766
794
|
aiUi: () => aiUiCurrent,
|
|
795
|
+
external: () => externalCurrent,
|
|
767
796
|
aiUpdate: async (patch: AiConfigPatch, expectedRevision?: number): Promise<AiConfigView> => {
|
|
768
797
|
const stored = { ...aiCurrent }
|
|
769
798
|
const body: Record<string, unknown> = {}
|