dsh-vscode-mode 0.34.0 → 0.36.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 (43) hide show
  1. package/README.md +25 -4
  2. package/lib/client.js +63 -63
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +1841 -73
  5. package/lib/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/skills/dsh-vscodemode-html-plan/SKILL.md +23 -0
  8. package/skills/dsh-vscodemode-html-plan/references/blocks.md +14 -0
  9. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +20 -0
  10. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +36 -1
  11. package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +35 -4
  12. package/skills/dsh-vscodemode-html-plan/runtime/plan.mjs +17 -6
  13. package/src/capture.ts +3 -0
  14. package/src/client/htmlPlan/HtmlPlanPanel.ts +8 -3
  15. package/src/client/htmlPlan/planPage.ts +31 -1
  16. package/src/client/reviewBatch.ts +8 -0
  17. package/src/client/state/diffSummary.ts +6 -1
  18. package/src/client/state/reviewFeed.ts +35 -4
  19. package/src/client/ui/EditorView.ts +7 -0
  20. package/src/client/ui/McpSettings.ts +21 -0
  21. package/src/client/ui/OfficialReview.ts +20 -2
  22. package/src/fileOpenSettings.ts +29 -0
  23. package/src/htmlPlanAttachments.ts +362 -0
  24. package/src/htmlPlanCommand.ts +257 -18
  25. package/src/index.ts +74 -6
  26. package/src/mcpManaged.ts +12 -3
  27. package/src/mcpManagerBridge.ts +5 -1
  28. package/src/mcpRuntime.ts +33 -4
  29. package/src/pending/capture.ts +32 -4
  30. package/src/pending/decide.ts +12 -3
  31. package/src/pending/externalAlign.ts +297 -0
  32. package/src/pending/externalCapture.ts +581 -0
  33. package/src/pending/kernel.ts +19 -1
  34. package/src/pending/persist.ts +114 -12
  35. package/src/pending/provenance.ts +239 -0
  36. package/src/pending/store.ts +30 -4
  37. package/src/pending/vcs.ts +122 -0
  38. package/src/pendingCompat.ts +13 -6
  39. package/src/pendingRpc.ts +19 -2
  40. package/src/rpc.ts +7 -2
  41. package/src/shared/pendingReview.ts +19 -1
  42. package/src/shared/review.ts +3 -1
  43. package/src/shared/rpc.ts +4 -0
@@ -6,6 +6,7 @@
6
6
  import type { ReviewDetail, ReviewItem, ReviewPage } from './shared/review.js'
7
7
  import type { PendingDetail, PendingItem, PendingPage } from './shared/pendingReview.js'
8
8
  import { pathKeyFor } from './shared/pathKey.js'
9
+ import { sourceLabelOf } from './pending/provenance.js'
9
10
 
10
11
  /**
11
12
  * 进程内"已被待审接管"的路径集合;旧写入口守卫只读它,绝不碰数据库。
@@ -102,7 +103,7 @@ export function pendingDisplay(cwd: string, path: string): string {
102
103
  * @returns 面板列表项
103
104
  */
104
105
  export function pendingItemOf(item: PendingItem, cwd?: string): ReviewItem {
105
- return {
106
+ const row: ReviewItem = {
106
107
  id: PENDING_PREFIX + item.id,
107
108
  sessionId: item.sessionId,
108
109
  turn: 0,
@@ -117,6 +118,9 @@ export function pendingItemOf(item: PendingItem, cwd?: string): ReviewItem {
117
118
  revision: item.revision,
118
119
  current: true,
119
120
  }
121
+ // 来源徽标只对待审条目有意义:官方行没有采集通道。
122
+ if (item.settled !== true) row.sourceLabel = sourceLabelOf(item)
123
+ return row
120
124
  }
121
125
 
122
126
  /**
@@ -127,16 +131,19 @@ export function pendingItemOf(item: PendingItem, cwd?: string): ReviewItem {
127
131
  * @returns 面板详情
128
132
  */
129
133
  export function pendingDetailOf(detail: PendingDetail, capturedAt: string, cwd?: string): ReviewDetail {
134
+ const capability: ReviewDetail['capability'] = {
135
+ keep: detail.capability.keep,
136
+ undo: detail.capability.revert,
137
+ reason: detail.capability.reason,
138
+ }
139
+ // 非 agent 来源的撤销需要客户端先确认:能力位原样透出,由界面弹一次确认。
140
+ if (detail.capability.confirmRevert === true) capability.confirmUndo = true
130
141
  return {
131
142
  item: pendingItemOf(detail.item, cwd),
132
143
  diff: detail.diff,
133
144
  capturedAt,
134
145
  blocks: detail.blocks,
135
- capability: {
136
- keep: detail.capability.keep,
137
- undo: detail.capability.revert,
138
- reason: detail.capability.reason,
139
- },
146
+ capability,
140
147
  }
141
148
  }
142
149
 
package/src/pendingRpc.ts CHANGED
@@ -6,8 +6,9 @@ import type { Registry } from './registry.js'
6
6
  import { bucketOf } from './registry.js'
7
7
  import { readText } from './pending/capture.js'
8
8
  import { pendingRawId, setPendingCovers, trackPendingCover } from './pendingCompat.js'
9
- import { loadEntries, saveEntry } from './pending/persist.js'
10
- import { applyDecide, importFromVcs, itemOf, loadDetail, loadPage, refreshed, removeEntry, undoDecide } from './pending/store.js'
9
+ import { loadEntries, pendingVersion, saveEntry } from './pending/persist.js'
10
+ import { applyDecide, importFromVcs, itemOf, loadDetail, loadPage, recordWrite, refreshed, removeEntry, undoDecide } from './pending/store.js'
11
+ import { alignInWorkspace } from './pending/externalAlign.js'
11
12
  import type { ShellLike } from './pending/vcs.js'
12
13
  import type { Ctx } from './store.js'
13
14
  import { policyOf } from './store.js'
@@ -94,6 +95,11 @@ function readHandlers(kit: ScopeKit): Partial<RpcHandlerMap> {
94
95
  const detail = loadDetail(cwd, rawId)
95
96
  return detail ? { ok: true, detail } : { ok: false, error: '待审条目不存在' }
96
97
  },
98
+ 'edrv.pending.version': async (args: PendingRequest) => {
99
+ // 只读内存计数:供客户端用 1s 轻量轮询替代把整页列表拉到 5s 一次
100
+ const cwd = await kit.read(args.sessionId)
101
+ return { ok: true, version: pendingVersion(cwd) }
102
+ },
97
103
  }
98
104
  }
99
105
 
@@ -188,6 +194,17 @@ function refreshHandlers(kit: ScopeKit): Partial<RpcHandlerMap> {
188
194
  if (next) saveEntry(cwd, next)
189
195
  return { ok: true, item: itemOf(next ?? stored) }
190
196
  },
197
+ 'edrv.pending.align': async (args) => {
198
+ // 手动补扫:与启动对齐同一条路径,只是明确要求本端活跃会话
199
+ const cwd = await kit.write(args.sessionId)
200
+ const outcome = await alignInWorkspace(kit.ctx, cwd, args.sessionId, (write) => {
201
+ try { trackPendingCover(write.cwd, write.path, true, write.sessionId) } catch { /* 登记失败不影响落库 */ }
202
+ recordWrite(write)
203
+ })
204
+ const page = loadPage(cwd, args.sessionId)
205
+ setPendingCovers(cwd, args.sessionId, page.items.map((item) => item.path))
206
+ return { ok: true, imported: outcome.imported, changed: outcome.changed, gaps: outcome.gaps }
207
+ },
191
208
  }
192
209
  }
193
210
 
package/src/rpc.ts CHANGED
@@ -55,6 +55,7 @@ import type { EncodingVerdict } from './textEncoding.js'
55
55
  import { backupPathOf, classifyEncoding, decodePreview, isEncodingError, lossyCountOf, repairBytes } from './textEncoding.js'
56
56
  import { baseNameOf, checkNewName, checkRenameName, isSubPath, joinRelPath, parentRelOf } from './shared/fsNames.js'
57
57
  import { invalidateIndex, listDirCached } from './treeIndex.js'
58
+ import { pathKeyOf, windows } from './pending/provenance.js'
58
59
  import { findRemoteWs, remoteDisplayOf, type RemoteWs } from './remoteWorkspace.js'
59
60
  import { revealInExplorer } from './reveal.js'
60
61
  import { dshHome, debugLogFile, pluginLogRoot, uiGlobalsFile, uiStateFile } from './paths.js'
@@ -377,9 +378,13 @@ async function afterManualSave(
377
378
  registry: Registry,
378
379
  sc: { session: Session; cwd: string },
379
380
  path: string,
381
+ identity?: string,
380
382
  ): Promise<void> {
381
383
  // 手动保存后目录树可能变化(新建/删除文件):父目录+祖先进失效,后台自愈。
382
384
  invalidateIndex(ctx, sc.cwd, path)
385
+ // 这是用户自己在编辑器里保存:打标记让外部改动采集只推进基线,不新建待审行。
386
+ // 标记必须用解析后的绝对身份,否则与 watch 事件的比较键对不上。
387
+ windows.markEditor(pathKeyOf(identity ?? path))
383
388
  // Editing disk is not a review decision. Keep all historical pending records;
384
389
  // location checks may report conflict but must not silently accept or archive them.
385
390
  }
@@ -1082,7 +1087,7 @@ export function buildHandlers(
1082
1087
  const rev = typeof args.rev === 'string' && args.rev ? args.rev : null
1083
1088
  const intent = rev ? { kind: 'replaceIfVersion', version: rev } : undefined
1084
1089
  const outcome = await fs.writeText(target, args.content, intent, void 0, policyOf(ctx, sc.session))
1085
- await afterManualSave(ctx, registry, sc, args.path)
1090
+ await afterManualSave(ctx, registry, sc, args.path, fs.processPath(target))
1086
1091
  return { ok: true, rev: outcome?.version ? String(outcome.version) : rev ?? undefined }
1087
1092
  } catch (error) {
1088
1093
  if (isStaleVersion(error)) {
@@ -1111,7 +1116,7 @@ export function buildHandlers(
1111
1116
  if (bytes.byteLength === 0) return { ok: false, error: '内容为空,拒绝写回' }
1112
1117
  if (bytes.byteLength > BINARY_READ_CAP) return { ok: false, error: '内容过大(>32MB),拒绝写回' }
1113
1118
  await writeFile(fs.processPath(target), bytes)
1114
- await afterManualSave(ctx, registry, sc, args.path)
1119
+ await afterManualSave(ctx, registry, sc, args.path, fs.processPath(target))
1115
1120
  return { ok: true }
1116
1121
  } catch (error) {
1117
1122
  return { ok: false, error: '二进制保存失败:' + String(error) }
@@ -9,6 +9,18 @@ import type { ReviewBlockState } from './reviewRegions.js'
9
9
  /** 基线形态:`file` 写回内容,`none` 说明基线没有该路径(Revert 语义是删除文件)。 */
10
10
  export type PendingEarlier = 'file' | 'none'
11
11
 
12
+ /**
13
+ * 采集通道:谁把这次变化变成了一条记录。
14
+ * `tool` 是旧记录与未知写工具的默认值;`remote_ssh_write` 目前只走旧链路,为桥接保留。
15
+ */
16
+ export type PendingSource = 'edit' | 'write' | 'remote_ssh_write' | 'tool' | 'watch' | 'scan' | 'vcs'
17
+
18
+ /** 归属:谁动的文件。撤销白名单只看它。 */
19
+ export type PendingOrigin = 'agent' | 'editor' | 'vcs' | 'external'
20
+
21
+ /** 修改前内容的可信度:known 已知内容,absent 当时不存在,vcs 版本库基线,unknown 拿不到。 */
22
+ export type PendingBaseKind = 'known' | 'absent' | 'vcs' | 'unknown'
23
+
12
24
  /** 会话血缘,用于子代理/派生会话归属到同一待审视图。 */
13
25
  export interface PendingLineage {
14
26
  parentSessionId?: string
@@ -41,6 +53,12 @@ export interface PendingItem {
41
53
  sessionId: string
42
54
  sessionIds: string[]
43
55
  lineage?: PendingLineage
56
+ /** 采集通道;旧条目没有该字段,按 `tool` 处理。 */
57
+ source?: PendingSource
58
+ /** 归属;旧条目没有该字段,按 `agent` 处理。 */
59
+ origin?: PendingOrigin
60
+ /** 修改前内容的可信度;旧条目没有该字段,按 `known` 处理。 */
61
+ baseKind?: PendingBaseKind
44
62
  }
45
63
 
46
64
  /** 一页待审条目。 */
@@ -57,7 +75,7 @@ export interface PendingDetail {
57
75
  item: PendingItem
58
76
  diff: OfficialDiff
59
77
  blocks: ReviewBlockState[]
60
- capability: { keep: boolean; revert: boolean; reason: string }
78
+ capability: { keep: boolean; revert: boolean; reason: string; confirmRevert?: boolean }
61
79
  }
62
80
 
63
81
  /** 全部请求都带会话作用域,工作区由 host 解析,永不采信客户端 cwd。 */
@@ -55,6 +55,8 @@ export interface ReviewItem {
55
55
  decision: ReviewFileDecision
56
56
  revision: number
57
57
  current: boolean
58
+ /** 待审条目的来源徽标(如「watch · agent」);官方行为空。 */
59
+ sourceLabel?: string
58
60
  }
59
61
  export interface ReviewDetail {
60
62
  item: ReviewItem
@@ -62,7 +64,7 @@ export interface ReviewDetail {
62
64
  capturedAt: string
63
65
  blocks: import('./reviewRegions.js').ReviewBlockState[]
64
66
  /** live 缺省视为未知:只有 host 明确给出 false 时才代表会话不在本端活跃。 */
65
- capability: { keep: boolean; undo: boolean; reason: string; live?: boolean }
67
+ capability: { keep: boolean; undo: boolean; reason: string; live?: boolean; confirmUndo?: boolean }
66
68
  }
67
69
  export interface CaptureGap {
68
70
  sessionId: string
package/src/shared/rpc.ts CHANGED
@@ -392,6 +392,8 @@ export interface RpcRequestMap {
392
392
  'edrv.pending.refresh': PendingRequest & { id: string }
393
393
  'edrv.pending.history': PendingHistoryMove
394
394
  'edrv.pending.import': PendingImport
395
+ 'edrv.pending.align': PendingRequest & { includeUntracked?: boolean }
396
+ 'edrv.pending.version': PendingRequest
395
397
  'edrv.list': { sessionId?: string; callIds?: string[]; skipStale?: boolean }
396
398
  'edrv.accept': { sessionId?: string; callId: string; scope?: RpcScope; hunkIndex?: number }
397
399
  'edrv.reject': { sessionId?: string; callId: string; scope?: RpcScope; hunkIndex?: number }
@@ -600,6 +602,8 @@ export interface RpcOkMap {
600
602
  'edrv.pending.refresh': { item: PendingItem }
601
603
  'edrv.pending.history': { item: PendingItem; wrote: boolean }
602
604
  'edrv.pending.import': { imported: number; changes: number }
605
+ 'edrv.pending.align': { imported: number; changed: number; gaps: string[] }
606
+ 'edrv.pending.version': { version: number }
603
607
  'edrv.list': { records: RecordView[] }
604
608
  'edrv.accept': { record: RecordView }
605
609
  'edrv.reject': { record: RecordView }