dsh-vscode-mode 0.36.0 → 0.38.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 +32 -4
- package/lib/client.js +68 -65
- package/lib/client.js.map +1 -1
- package/lib/index.js +1961 -222
- 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 +411 -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 +48 -1
- package/src/client/state/diffSummary.ts +2 -1
- package/src/client/styles/editor.css +3 -1
- package/src/client/ui/EditorView.ts +8 -9
- package/src/client/ui/SvnCommitDialog.ts +256 -31
- package/src/client/ui/svnCommitModel.ts +63 -0
- package/src/index.ts +13 -0
- package/src/pending/capture.ts +201 -34
- package/src/pending/decide.ts +33 -1
- package/src/pending/externalCapture.ts +171 -8
- package/src/pending/kernel.ts +13 -2
- package/src/pending/noteTool.ts +96 -0
- package/src/pending/notes.ts +83 -0
- package/src/pending/persist.ts +301 -51
- package/src/pending/provenance.ts +45 -11
- package/src/pending/receipt.ts +177 -0
- package/src/pending/store.ts +161 -69
- package/src/pending/vcs.ts +25 -7
- package/src/pending/verdict.ts +170 -0
- package/src/pendingCompat.ts +14 -1
- package/src/pendingRpc.ts +19 -1
- package/src/reviewDb.ts +63 -2
- package/src/reviewRpc.ts +47 -1
- package/src/rpc.ts +36 -4
- package/src/shared/pendingReview.ts +20 -2
- package/src/shared/review.ts +17 -0
- package/src/shared/reviewRegions.ts +48 -3
- package/src/shared/rpc.ts +7 -1
- package/src/slowLog.ts +74 -0
- package/src/textEncoding.probe.ts +1 -0
package/src/pending/kernel.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* 无 IO、无时钟、不改入参;调用方传入 now 与内容,便于测试与复用。
|
|
4
4
|
* @author ddj 2026年10月29号
|
|
5
5
|
*/
|
|
6
|
-
import type { PendingBaseKind, PendingEarlier, PendingLineage, PendingOrigin, PendingSource } from '../shared/pendingReview.js'
|
|
6
|
+
import type { PendingBaseKind, PendingEarlier, PendingEvidence, PendingLineage, PendingOrigin, PendingSource, PendingVerdict } from '../shared/pendingReview.js'
|
|
7
7
|
import { logicalLines } from '../shared/lineEndings.js'
|
|
8
|
-
import { strongerSource } from './provenance.js'
|
|
8
|
+
import { strongerEvidence, strongerSource } from './provenance.js'
|
|
9
9
|
|
|
10
10
|
/** 内存态条目:比展示投影多保存两侧全文。 */
|
|
11
11
|
export interface PendingEntry {
|
|
@@ -25,6 +25,10 @@ export interface PendingEntry {
|
|
|
25
25
|
origin?: PendingOrigin
|
|
26
26
|
/** 修改前内容的可信度;缺省按 `known` 解释。 */
|
|
27
27
|
baseKind?: PendingBaseKind
|
|
28
|
+
/** 证据强度;缺省按 `snapshot` 解释。 */
|
|
29
|
+
evidence?: PendingEvidence
|
|
30
|
+
/** 这次调用的结局;缺省按 `changed` 解释。 */
|
|
31
|
+
verdict?: PendingVerdict
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/** 新建条目的入参。 */
|
|
@@ -40,6 +44,8 @@ export interface NewPending {
|
|
|
40
44
|
source?: PendingSource
|
|
41
45
|
origin?: PendingOrigin
|
|
42
46
|
baseKind?: PendingBaseKind
|
|
47
|
+
evidence?: PendingEvidence
|
|
48
|
+
verdict?: PendingVerdict
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/** 决定后对条目的局部推进;未出现的字段表示不改。 */
|
|
@@ -91,6 +97,9 @@ export function mergeEntries(earlier: PendingEntry, later: PendingEntry): Pendin
|
|
|
91
97
|
origin: later.origin ?? earlier.origin,
|
|
92
98
|
// 基线一旦落成"已知内容",就不再退回未知;未知只来自首次观察失败的那条记录。
|
|
93
99
|
baseKind: later.baseKind ?? earlier.baseKind,
|
|
100
|
+
// 证据强度同样取更强的一侧:回执胜过自己的快照,结局取最近一次调用。
|
|
101
|
+
evidence: strongerEvidence(earlier.evidence, later.evidence),
|
|
102
|
+
verdict: later.verdict ?? earlier.verdict,
|
|
94
103
|
}
|
|
95
104
|
if (later.lineage === undefined && earlier.lineage !== undefined) merged.lineage = earlier.lineage
|
|
96
105
|
if (earlier.earlierVersion === 'none' && later.earlierVersion === 'none') {
|
|
@@ -125,6 +134,8 @@ export function entryFromNew(input: NewPending): PendingEntry {
|
|
|
125
134
|
if (input.source !== undefined) entry.source = input.source
|
|
126
135
|
if (input.origin !== undefined) entry.origin = input.origin
|
|
127
136
|
if (input.baseKind !== undefined) entry.baseKind = input.baseKind
|
|
137
|
+
if (input.evidence !== undefined) entry.evidence = input.evidence
|
|
138
|
+
if (input.verdict !== undefined) entry.verdict = input.verdict
|
|
128
139
|
return entry
|
|
129
140
|
}
|
|
130
141
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** 只读编辑说明的工具入口:模型可以留一句话,但它不参与差异判定。 @author ddj 2026年11月25号 */
|
|
2
|
+
import { loadHostModule } from '../hostImport.js'
|
|
3
|
+
import type { Ctx } from '../store.js'
|
|
4
|
+
import { declareNote, NOTE_MAX } from './notes.js'
|
|
5
|
+
|
|
6
|
+
/** 工具参数。 */
|
|
7
|
+
interface NoteArgs {
|
|
8
|
+
path?: unknown
|
|
9
|
+
note?: unknown
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** 工具执行上下文里本工具关心的字段。 */
|
|
13
|
+
interface NoteExec {
|
|
14
|
+
agent?: { session?: { id?: string } }
|
|
15
|
+
signal?: AbortSignal
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 工具回执。 */
|
|
19
|
+
interface NoteResult {
|
|
20
|
+
ok: boolean
|
|
21
|
+
path?: string
|
|
22
|
+
note?: string
|
|
23
|
+
error?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** 会话 → 工作区。 */
|
|
27
|
+
export type CwdOf = (session: unknown) => string | null
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @author ddj 2026年11月25号
|
|
31
|
+
* @description: 构造工具定义;只写进程内说明表,不碰磁盘、不碰工具参数。
|
|
32
|
+
* @param ctx Host 上下文(取 fs 解析路径)
|
|
33
|
+
* @param cwdOf 会话工作区解析
|
|
34
|
+
* @returns 定义选项
|
|
35
|
+
*/
|
|
36
|
+
export function noteToolOptions(ctx: Ctx, cwdOf: CwdOf) {
|
|
37
|
+
/**
|
|
38
|
+
* @author ddj 2026年11月25号
|
|
39
|
+
* @description: 记录一条说明;非法输入返回可读原因,不抛错。
|
|
40
|
+
* @param args 模型参数
|
|
41
|
+
* @param exec 执行上下文
|
|
42
|
+
* @returns 回执
|
|
43
|
+
*/
|
|
44
|
+
async function execute(args: NoteArgs, exec: NoteExec): Promise<NoteResult> {
|
|
45
|
+
const path = typeof args.path === 'string' ? args.path.trim() : ''
|
|
46
|
+
const note = typeof args.note === 'string' ? args.note.trim() : ''
|
|
47
|
+
if (!path || !note) return { ok: false, error: 'path 与 note 都必须是非空字符串' }
|
|
48
|
+
if (note.length > NOTE_MAX) return { ok: false, error: 'note 超过 ' + NOTE_MAX + ' 个字符' }
|
|
49
|
+
if (exec.signal?.aborted) return { ok: false, error: '说明已取消' }
|
|
50
|
+
const cwd = cwdOf(exec.agent?.session)
|
|
51
|
+
if (!cwd) return { ok: false, error: '编辑说明需要所属会话的工作区' }
|
|
52
|
+
const target = await ctx.get('fs').resolve(path, { cwd })
|
|
53
|
+
const identity = ctx.get('fs').processPath(target)
|
|
54
|
+
if (typeof identity !== 'string' || !identity) return { ok: false, error: '路径不可解析:' + path }
|
|
55
|
+
declareNote(cwd, identity, note)
|
|
56
|
+
return { ok: true, path, note }
|
|
57
|
+
}
|
|
58
|
+
/** @author ddj 2026年11月25号 @param _args 模型参数 @param result 回执 @returns 模型可见文本 */
|
|
59
|
+
function render(_args: NoteArgs, result: NoteResult) {
|
|
60
|
+
return [{ type: 'text', text: result.ok ? '已记录只读说明:' + result.path : '说明未记录:' + result.error }]
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
name: 'edit_note',
|
|
64
|
+
description: 'Record a read-only note on a file for the review panel: why this file was changed. '
|
|
65
|
+
+ 'It is display-only: it never decides whether a diff is real, never writes files, and never changes tool arguments.',
|
|
66
|
+
parameters: {
|
|
67
|
+
path: { type: 'string', required: true, description: 'File path, resolved by the filesystem backend in the session workspace.' },
|
|
68
|
+
note: { type: 'string', required: true, description: 'One sentence for the reviewer. At most ' + NOTE_MAX + ' characters.' },
|
|
69
|
+
},
|
|
70
|
+
output: { schema: { type: 'json' }, render },
|
|
71
|
+
isConcurrencySafe: true,
|
|
72
|
+
execute,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @author ddj 2026年11月25号
|
|
78
|
+
* @description: 注册工具;宿主缺少工具服务时静默跳过,不影响其余功能。
|
|
79
|
+
* @param ctx Host 插件上下文
|
|
80
|
+
* @param cwdOf 会话工作区解析
|
|
81
|
+
* @returns 无
|
|
82
|
+
*/
|
|
83
|
+
export async function installNoteTool(ctx: Ctx, cwdOf: CwdOf): Promise<void> {
|
|
84
|
+
let module: { defineTool: (options: unknown) => unknown }
|
|
85
|
+
try {
|
|
86
|
+
module = await loadHostModule('@deepseek-ai/dsh-tools') as typeof module
|
|
87
|
+
} catch {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
const definition = module.defineTool(noteToolOptions(ctx, cwdOf))
|
|
91
|
+
/** @author ddj 2026年11月25号 @returns 注册释放器 */
|
|
92
|
+
function install(): () => void {
|
|
93
|
+
return ctx.get('tools').register(definition)
|
|
94
|
+
}
|
|
95
|
+
ctx.effect(install, 'vscode-mode:edit-note')
|
|
96
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 只读编辑说明:AI 给某个文件留一句「为什么改」,只供面板展示。
|
|
3
|
+
* 不参与真假判定、不改写工具参数、不落库;插件卸载或换工作区即清空。
|
|
4
|
+
* @author ddj 2026年11月25号
|
|
5
|
+
*/
|
|
6
|
+
import { pathKeyOf } from './provenance.js'
|
|
7
|
+
|
|
8
|
+
/** 单条说明上限(字符)。 */
|
|
9
|
+
export const NOTE_MAX = 500
|
|
10
|
+
/** 每个工作区最多记住多少条,超出按写入序逐出最旧。 */
|
|
11
|
+
export const NOTE_SPACE_MAX = 200
|
|
12
|
+
|
|
13
|
+
/** 一个工作区的说明表。 */
|
|
14
|
+
interface NoteSpace {
|
|
15
|
+
/** 插入顺序,逐出时用。 */
|
|
16
|
+
order: string[]
|
|
17
|
+
/** 条目身份 → 说明。 */
|
|
18
|
+
byPath: Map<string, string>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 进程内说明表:随插件装配创建,卸载清空。 */
|
|
22
|
+
const spaces = new Map<string, NoteSpace>()
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @author ddj 2026年11月25号
|
|
27
|
+
* @description: 取(或建)一个工作区的说明表。
|
|
28
|
+
* @param cwd 工作区
|
|
29
|
+
* @returns 说明表
|
|
30
|
+
*/
|
|
31
|
+
function spaceOf(cwd: string): NoteSpace {
|
|
32
|
+
const key = pathKeyOf(cwd)
|
|
33
|
+
const existing = spaces.get(key)
|
|
34
|
+
if (existing) return existing
|
|
35
|
+
const created: NoteSpace = { order: [], byPath: new Map() }
|
|
36
|
+
spaces.set(key, created)
|
|
37
|
+
return created
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @public
|
|
42
|
+
* @author ddj 2026年11月25号
|
|
43
|
+
* @description: 记录一条只读说明;同一文件后写的覆盖先写的,超出上限逐出最旧。
|
|
44
|
+
* @param cwd 工作区
|
|
45
|
+
* @param identity 条目身份(文件绝对路径)
|
|
46
|
+
* @param note 说明文本
|
|
47
|
+
* @returns 无
|
|
48
|
+
*/
|
|
49
|
+
export function declareNote(cwd: string, identity: string, note: string): void {
|
|
50
|
+
if (!cwd || !identity || !note) return
|
|
51
|
+
const space = spaceOf(cwd)
|
|
52
|
+
const key = pathKeyOf(identity)
|
|
53
|
+
if (!space.byPath.has(key)) space.order.push(key)
|
|
54
|
+
space.byPath.set(key, note.slice(0, NOTE_MAX))
|
|
55
|
+
while (space.order.length > NOTE_SPACE_MAX) {
|
|
56
|
+
const oldest = space.order.shift()
|
|
57
|
+
if (oldest !== undefined) space.byPath.delete(oldest)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @public
|
|
63
|
+
* @author ddj 2026年11月25号
|
|
64
|
+
* @description: 读某个文件的只读说明;没有时返回 undefined。
|
|
65
|
+
* @param cwd 工作区
|
|
66
|
+
* @param identity 条目身份(文件绝对路径)
|
|
67
|
+
* @returns 说明或 undefined
|
|
68
|
+
*/
|
|
69
|
+
export function noteOf(cwd: string, identity: string): string | undefined {
|
|
70
|
+
return spaces.get(pathKeyOf(cwd))?.byPath.get(pathKeyOf(identity))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
* @author ddj 2026年11月25号
|
|
76
|
+
* @description: 清空说明;不传工作区时清全部(插件卸载)。
|
|
77
|
+
* @param cwd 工作区
|
|
78
|
+
* @returns 无
|
|
79
|
+
*/
|
|
80
|
+
export function clearNotes(cwd?: string): void {
|
|
81
|
+
if (cwd === undefined) spaces.clear()
|
|
82
|
+
else spaces.delete(pathKeyOf(cwd))
|
|
83
|
+
}
|