dsh-vscode-mode 0.38.0 → 0.40.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 +38 -33
- package/lib/client.js +87 -68
- package/lib/client.js.map +1 -1
- package/lib/index.js +11406 -4920
- package/lib/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/dsh-vscodemode-html-plan/SKILL.md +44 -42
- package/skills/dsh-vscodemode-test-check/SKILL.md +82 -0
- package/src/archiveDb.ts +24 -0
- package/src/attachmentBytes.ts +84 -0
- 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 +9 -0
- package/src/client/openReceipt.ts +5 -2
- package/src/client/planBridge.ts +27 -2
- package/src/client/planState.ts +51 -4
- package/src/client/sidebar/panels/TestCheckPanel.ts +485 -0
- package/src/client/sidebar/panels/useTestCheckData.ts +414 -0
- package/src/client/sidebar/types.ts +2 -0
- package/src/client/state/diffSummary.ts +3 -0
- package/src/client/styles/editor.css +91 -0
- package/src/client/testCheck/TestCheckChip.ts +181 -0
- package/src/client/testCheck/TestCheckPanel.ts +339 -0
- package/src/client/testCheckPanelState.ts +173 -0
- package/src/client/ui/EditorView.ts +77 -7
- package/src/client/ui/McpSettings.ts +2 -2
- package/src/client/ui/OfficialReview.ts +6 -4
- package/src/htmlPlanAttachments.ts +4 -1
- package/src/htmlPlanCommand.ts +87 -235
- package/src/htmlPlanGuidance.ts +67 -0
- package/src/htmlPlanMode.ts +547 -0
- package/src/index.ts +28 -55
- package/src/officialCapture.ts +58 -9
- package/src/pending/externalCapture.ts +195 -401
- package/src/pending/kernel.ts +24 -1
- package/src/pending/persist.ts +109 -22
- package/src/pending/provenance.ts +5 -28
- package/src/pending/store.ts +109 -100
- package/src/pending/tracking.ts +81 -0
- package/src/pendingCompat.ts +26 -1
- 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 +1 -1
- package/src/reviewRpc.ts +14 -6
- package/src/rpc.ts +34 -0
- package/src/shared/htmlPlanMode.ts +26 -0
- package/src/shared/pendingReview.ts +15 -7
- package/src/shared/review.ts +5 -0
- package/src/shared/rpc.ts +53 -7
- package/src/shared/testCheck.ts +759 -0
- package/src/shared/testCheckHtml.ts +276 -0
- package/src/shared/testCheckPolicyDefault.ts +37 -0
- package/src/shared/testCheckSnippets.ts +197 -0
- package/src/store.ts +17 -1
- package/src/testCheckCommand.ts +287 -0
- package/src/testCheckGuidance.ts +79 -0
- package/src/testCheckMode.ts +654 -0
- package/src/testCheckPolicy.ts +141 -0
- package/src/testCheckRpc.ts +196 -0
- package/src/testCheckStore.ts +822 -0
- package/src/pending/externalAlign.ts +0 -297
- package/src/pending/vcs.ts +0 -584
package/src/index.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { installCapture } from './officialCapture.js'
|
|
|
5
5
|
import { installEvidence } from './reviewCapture.js'
|
|
6
6
|
import { installPending } from './pending/capture.js'
|
|
7
7
|
import type { PendingWrite } from './pending/capture.js'
|
|
8
|
-
import { installExternalCapture,
|
|
8
|
+
import { installExternalCapture, setCapture } from './pending/externalCapture.js'
|
|
9
9
|
import { windows } from './pending/provenance.js'
|
|
10
|
-
import {
|
|
10
|
+
import { isTrackedPath } from './pending/tracking.js'
|
|
11
|
+
import { foldTracked, recordWrite } from './pending/store.js'
|
|
11
12
|
import { cwdOfSession } from './store.js'
|
|
12
|
-
import { resolveScope } from './registry.js'
|
|
13
13
|
import { trackPendingCover } from './pendingCompat.js'
|
|
14
14
|
import { closeArchiveDbs } from './archiveDb.js'
|
|
15
15
|
import { startArchiveSweep } from './archivePurge.js'
|
|
@@ -43,7 +43,9 @@ import { installSvnTools } from './svnTools.js'
|
|
|
43
43
|
import { createDapRpc } from './dap/rpc.js'
|
|
44
44
|
import { installRulesSection } from './rules.js'
|
|
45
45
|
import { installSkillGroup } from './skills.js'
|
|
46
|
-
import {
|
|
46
|
+
import { installHtmlPlanMode } from './htmlPlanMode.js'
|
|
47
|
+
import { installCheckMode } from './testCheckMode.js'
|
|
48
|
+
import { disposeTestCheck } from './testCheckStore.js'
|
|
47
49
|
import type { RpcHandlerMap, RpcMethod, RpcRequestMap } from './shared/rpc.js'
|
|
48
50
|
import type { Registry } from './registry.js'
|
|
49
51
|
import type { Ctx } from './store.js'
|
|
@@ -82,45 +84,37 @@ function createRuntime(ctx: Ctx, config: unknown) {
|
|
|
82
84
|
* @param ctx Host context.
|
|
83
85
|
* @param runtime Managers created by this instance.
|
|
84
86
|
*/
|
|
85
|
-
function attachRuntime(ctx: Ctx, runtime: Runtime):
|
|
87
|
+
function attachRuntime(ctx: Ctx, runtime: Runtime): void {
|
|
86
88
|
const evidence = installEvidence(ctx)
|
|
87
|
-
|
|
89
|
+
// 官方快照只保留正在追踪窗口内的文件:Unity 自己写盘不再借官方线冒出来
|
|
90
|
+
const stopCapture = installCapture(
|
|
91
|
+
ctx,
|
|
92
|
+
(cwd, snapshot) => { evidence.persist(cwd, snapshot); return true },
|
|
93
|
+
(cwd, identity) => isTrackedPath(cwd, identity),
|
|
94
|
+
)
|
|
88
95
|
/** @author ddj 2026年11月24号 @param write 已确认的一次写入 @returns 无;落库失败不打断用户工具调用 */
|
|
89
96
|
function recordPendingWrite(write: PendingWrite): void {
|
|
90
97
|
try { trackPendingCover(write.cwd, write.path, true, write.sessionId) } catch { /* 内存登记失败不阻断采集 */ }
|
|
91
98
|
try { recordWrite(write) } catch (error) { log.warn('待审差异落库失败:' + String(error)) }
|
|
92
99
|
}
|
|
100
|
+
/** @author ddj 2026年11月25号 @param write 窗口内的外部/编辑器改动 @returns 是否折进窗口;失败不打断写盘方 */
|
|
101
|
+
function foldPendingWrite(write: PendingWrite): boolean {
|
|
102
|
+
try { trackPendingCover(write.cwd, write.path, true, write.sessionId) } catch { /* 内存登记失败不阻断采集 */ }
|
|
103
|
+
try { return foldTracked(write) } catch (error) { log.warn('窗口改动折叠失败:' + String(error)); return false }
|
|
104
|
+
}
|
|
93
105
|
// 待审累计基线:只有写后内容确实变化才落库,异常一律不打断用户工具调用
|
|
94
106
|
const pending = installPending(ctx, recordPendingWrite)
|
|
95
|
-
//
|
|
107
|
+
// 差异窗口跟随器:只跟随 AI 文件工具动过的文件,其余路径的写盘一律忽略
|
|
96
108
|
const external = installExternalCapture({
|
|
97
109
|
ctx,
|
|
98
110
|
settings: () => runtime.settings.external(),
|
|
99
|
-
|
|
111
|
+
fold: foldPendingWrite,
|
|
100
112
|
})
|
|
113
|
+
setCapture(external)
|
|
101
114
|
// 归档库每日清理:保留期 + 每文件上限,独立于会话存续
|
|
102
115
|
const sweep = startArchiveSweep()
|
|
103
116
|
// 事件循环看门狗:宿主是单进程单事件循环,任何同步大活都会把所有 RPC 一起拖住
|
|
104
117
|
const loopWatch = startLoopWatchdog()
|
|
105
|
-
/**
|
|
106
|
-
* @author ddj 2026年11月24号
|
|
107
|
-
* @description: 任一工具调用期间都是 agent 写入窗口:bash / python 写盘落在窗口内时归属 agent。
|
|
108
|
-
* 版本库写工具结束后再补扫一次,把命令造成的成片变化对齐进待审投影。
|
|
109
|
-
* @param exec 工具执行描述
|
|
110
|
-
* @param next 原始分发
|
|
111
|
-
* @returns 原始结果
|
|
112
|
-
*/
|
|
113
|
-
function aroundToolWindow(exec: { name?: unknown; agent?: { session?: unknown } }, next: () => Promise<unknown>): Promise<unknown> {
|
|
114
|
-
windows.enterTool()
|
|
115
|
-
return Promise.resolve()
|
|
116
|
-
.then(next)
|
|
117
|
-
.finally(() => {
|
|
118
|
-
windows.exitTool()
|
|
119
|
-
if (!VCS_WRITE_TOOLS.has(String(exec.name ?? ''))) return
|
|
120
|
-
const cwd = cwdOfSession(ctx, exec.agent?.session)
|
|
121
|
-
if (cwd) external.requestAlign(cwd)
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
118
|
/** @author ddj 2026年11月24号 @param session 新建会话 @returns 无;工作区可用即开始监听 */
|
|
125
119
|
function onCreated(session: { id?: unknown }): void {
|
|
126
120
|
if (typeof session.id !== 'string') return
|
|
@@ -149,25 +143,25 @@ function attachRuntime(ctx: Ctx, runtime: Runtime): { external: ReturnType<typeo
|
|
|
149
143
|
evidence.dispose()
|
|
150
144
|
pending.dispose()
|
|
151
145
|
external.dispose()
|
|
146
|
+
setCapture(undefined)
|
|
152
147
|
clearNotes()
|
|
153
148
|
sweep.dispose()
|
|
154
|
-
|
|
149
|
+
loopWatch.dispose()
|
|
155
150
|
windows.dispose()
|
|
156
151
|
runtime.fileVersions.dispose()
|
|
152
|
+
disposeTestCheck()
|
|
157
153
|
closeArchiveDbs()
|
|
158
154
|
disposeAllServers()
|
|
159
155
|
const tasks = [() => runtime.lspManager.disposeAll(), () => runtime.svnRpc.dispose(), () => runtime.dapRpc.dispose()]
|
|
160
156
|
await Promise.allSettled(tasks.map((run) => Promise.resolve().then(run)))
|
|
161
157
|
}
|
|
162
158
|
ctx.on('tools/result', onResult)
|
|
163
|
-
ctx.on('tools/execute', aroundToolWindow)
|
|
164
159
|
ctx.on('session/created', onCreated)
|
|
165
160
|
ctx.on('session/disposed', onDisposed)
|
|
166
161
|
// 启动时给已有会话的工作区各开一份监听(会话内 cd 后由 session/created 与 ensure 幂等补齐)
|
|
167
162
|
for (const session of ctx.get('sessions').list()) onCreated(session)
|
|
168
163
|
ctx.effect(() => cleanup, 'vscode-mode:runtime')
|
|
169
164
|
hookExitReclaim()
|
|
170
|
-
return { external }
|
|
171
165
|
}
|
|
172
166
|
|
|
173
167
|
/**
|
|
@@ -178,7 +172,6 @@ function attachRuntime(ctx: Ctx, runtime: Runtime): { external: ReturnType<typeo
|
|
|
178
172
|
function installContent(ctx: Ctx): void {
|
|
179
173
|
if (!installRulesSection(ctx)) log.warn('未检测到 systemPrompt 服务,规则仅可管理不注入')
|
|
180
174
|
if (!installSkillGroup(ctx)) log.warn('技能组未调度,插件技能组不可用')
|
|
181
|
-
if (!installHtmlPlanCommand(ctx)) log.warn('/html-plan 命令未调度(官方 /plan 不可用时该命令不可用)')
|
|
182
175
|
}
|
|
183
176
|
// #endregion
|
|
184
177
|
|
|
@@ -193,35 +186,15 @@ export async function apply(ctx: Ctx, config?: unknown): Promise<void> {
|
|
|
193
186
|
bindHostLog(ctx)
|
|
194
187
|
const runtime = createRuntime(ctx, config)
|
|
195
188
|
const warnings: string[] = []
|
|
196
|
-
|
|
189
|
+
attachRuntime(ctx, runtime)
|
|
197
190
|
installContent(ctx)
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
if (!installHtmlPlanMode(ctx)) log.warn('/html-plan 未调度:DSH 未提供 ctx.inject')
|
|
192
|
+
if (!installCheckMode(ctx)) log.warn('/test-check 未调度:DSH 未提供 ctx.inject')
|
|
200
193
|
/** @author ddj 2026年09月28号 @param method RPC name. @param args Typed request. @returns RPC result. */
|
|
201
194
|
function dispatch<M extends RpcMethod>(method: M, args: RpcRequestMap[M]) {
|
|
202
195
|
const { registry, searcher, contentSearcher, lspRpc, aiRpc, fileVersions, svnRpc, dapRpc } = runtime
|
|
203
|
-
|
|
196
|
+
return handleRpc(ctx, registry, method, args, searcher, contentSearcher, lspRpc.handlers,
|
|
204
197
|
aiRpc.handlers, fileVersions, svnRpc.handlers as Partial<RpcHandlerMap>, dapRpc.handlers)
|
|
205
|
-
// 版本库写操作(提交/更新/还原/清理…)之后补扫一次:命令造成的成片变化要能进待审投影
|
|
206
|
-
if (!VCS_WRITE_METHODS.has(method)) return pendingResult
|
|
207
|
-
alignChain = alignChain.then(async () => {
|
|
208
|
-
const cwd = await workspaceOfSession((args as { sessionId?: string } | undefined)?.sessionId)
|
|
209
|
-
if (cwd) capture.external.requestAlign(cwd)
|
|
210
|
-
}).catch(() => {})
|
|
211
|
-
return pendingResult
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* @author ddj 2026年11月24号
|
|
215
|
-
* @description: 取 RPC 参数里的会话工作区;取不到就跳过补扫,绝不影响 RPC 本身。
|
|
216
|
-
* @param sessionId 请求会话
|
|
217
|
-
* @returns 工作区路径或 null
|
|
218
|
-
*/
|
|
219
|
-
async function workspaceOfSession(sessionId: string | undefined): Promise<string | null> {
|
|
220
|
-
try {
|
|
221
|
-
if (!sessionId) return null
|
|
222
|
-
const scope = await resolveScope(ctx, sessionId)
|
|
223
|
-
return 'err' in scope ? null : scope.cwd
|
|
224
|
-
} catch { return null }
|
|
225
198
|
}
|
|
226
199
|
/** @author ddj 2026年09月28号 @param warning Startup compatibility diagnostic. */
|
|
227
200
|
function noteWarning(warning: string): void { warnings.push(warning) }
|
package/src/officialCapture.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Deferred official-event collection; no private snapshot access. @author ddj 2026年10月26号 */
|
|
2
2
|
import { captureState, repairPaths, saveSnapshot } from './reviewDb.js'
|
|
3
|
-
import type { OfficialDiff, OfficialSummary, ReviewSnapshot } from './shared/review.js'
|
|
3
|
+
import type { ChangedFile, OfficialDiff, OfficialSummary, ReviewSnapshot } from './shared/review.js'
|
|
4
4
|
import type { Ctx } from './store.js'
|
|
5
5
|
import { loadBucket } from './store.js'
|
|
6
6
|
import { log } from './log.js'
|
|
@@ -18,6 +18,8 @@ export interface CaptureDeps {
|
|
|
18
18
|
identity(cwd: string, path: string): Promise<string>
|
|
19
19
|
persist: typeof saveSnapshot
|
|
20
20
|
state: typeof captureState
|
|
21
|
+
/** 是否只保留正在追踪窗口内的文件;缺省全部保留(测试与旧装配的兼容默认)。 */
|
|
22
|
+
tracked?(cwd: string, identity: string): boolean | Promise<boolean>
|
|
21
23
|
report(message: string): void
|
|
22
24
|
timeoutMs?: number
|
|
23
25
|
retryMs?: number
|
|
@@ -67,22 +69,44 @@ export function createCollector(deps: CaptureDeps) {
|
|
|
67
69
|
if (stopped) return
|
|
68
70
|
deps.state(summary.cwd, { ...task, error: '' }, 'queued')
|
|
69
71
|
try {
|
|
72
|
+
// 官方快照涵盖整个回合的工作区变化(含 Unity 自己的写盘):只保留当前有追踪窗口的文件。
|
|
73
|
+
const kept = await keepTracked(summary)
|
|
74
|
+
if (stopped) return
|
|
75
|
+
// 一条都没命中:不落空快照,但把采集状态标完成,避免面板出现假缺口。
|
|
76
|
+
if (!kept.length && summary.files.length) { deps.state(summary.cwd, { ...task, error: '' }, 'complete'); return }
|
|
70
77
|
const files = []
|
|
71
|
-
for (const
|
|
78
|
+
for (const item of kept) {
|
|
72
79
|
if (stopped) return
|
|
73
80
|
const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(deps.timeoutMs ?? 10000)])
|
|
74
|
-
const diff = await readDiff(source, task, index, signal)
|
|
75
|
-
if (!diff || diff.path !== file.path || diff.display !== file.display) throw new Error('官方文件差异缺失或身份不一致')
|
|
76
|
-
|
|
77
|
-
files.push({ identity, diff: structuredClone(diff) })
|
|
81
|
+
const diff = await readDiff(source, task, item.index, signal)
|
|
82
|
+
if (!diff || diff.path !== item.file.path || diff.display !== item.file.display) throw new Error('官方文件差异缺失或身份不一致')
|
|
83
|
+
files.push({ identity: item.identity, diff: structuredClone(diff) })
|
|
78
84
|
}
|
|
79
|
-
if (!stopped) deps.persist(summary.cwd, { ...task, sourceKind: 'official', capturedAt: new Date().toISOString(), summary, files })
|
|
85
|
+
if (!stopped) deps.persist(summary.cwd, { ...task, sourceKind: 'official', capturedAt: new Date().toISOString(), summary: filterSummary(summary, kept), files })
|
|
80
86
|
} catch (error) {
|
|
81
87
|
if (!stopped) deps.state(summary.cwd, { ...task, error: String(error) }, 'gap')
|
|
82
88
|
throw error
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @private
|
|
94
|
+
* @author ddj 2026年11月25号
|
|
95
|
+
* @description: 按追踪窗口筛官方文件:只有当前开窗的文件才读取差异并落库。
|
|
96
|
+
* @param summary 官方摘要
|
|
97
|
+
* @returns 保留的文件及其下标与身份
|
|
98
|
+
*/
|
|
99
|
+
async function keepTracked(summary: OfficialSummary): Promise<Array<{ index: number; file: ChangedFile; identity: string }>> {
|
|
100
|
+
const kept: Array<{ index: number; file: ChangedFile; identity: string }> = []
|
|
101
|
+
for (const [index, file] of summary.files.entries()) {
|
|
102
|
+
if (stopped) return kept
|
|
103
|
+
const identity = await deps.identity(summary.cwd, file.path)
|
|
104
|
+
if (deps.tracked && !(await deps.tracked(summary.cwd, identity))) continue
|
|
105
|
+
kept.push({ index, file, identity })
|
|
106
|
+
}
|
|
107
|
+
return kept
|
|
108
|
+
}
|
|
109
|
+
|
|
86
110
|
/** @private @author ddj 2026年10月26号 Starts at most two independent event reads, with each event's file reads serial. */
|
|
87
111
|
function drain(): void {
|
|
88
112
|
while (!stopped && active < 2 && waiting.length) {
|
|
@@ -147,8 +171,33 @@ async function readDiff(source: SourceService, task: CaptureTask, index: number,
|
|
|
147
171
|
})
|
|
148
172
|
}
|
|
149
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @private
|
|
176
|
+
* @author ddj 2026年11月25号
|
|
177
|
+
* @description: 过滤后的官方摘要:只留被追踪窗口命中的文件,并重算总数与增删行数。
|
|
178
|
+
* 不重算 total 会让面板把过滤误报成「官方列表已截断」。
|
|
179
|
+
* @param summary 原始摘要
|
|
180
|
+
* @param kept 保留的文件(下标与文件)
|
|
181
|
+
* @returns 过滤后的摘要
|
|
182
|
+
*/
|
|
183
|
+
function filterSummary(
|
|
184
|
+
summary: OfficialSummary, kept: Array<{ index: number; file: ChangedFile }>,
|
|
185
|
+
): OfficialSummary {
|
|
186
|
+
const files = kept.map((item) => item.file)
|
|
187
|
+
return {
|
|
188
|
+
...summary,
|
|
189
|
+
files,
|
|
190
|
+
total: files.length,
|
|
191
|
+
added: files.reduce((sum, file) => sum + file.added, 0),
|
|
192
|
+
deleted: files.reduce((sum, file) => sum + file.deleted, 0),
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
150
196
|
/** @public @author ddj 2026年10月26号 @param ctx Host lifecycle owner; services remain optional for older Hosts. */
|
|
151
|
-
export function installCapture(
|
|
197
|
+
export function installCapture(
|
|
198
|
+
ctx: Ctx, onSnapshot?: (cwd: string, snapshot: ReviewSnapshot) => void,
|
|
199
|
+
tracked?: (cwd: string, identity: string) => boolean,
|
|
200
|
+
): () => Promise<void> {
|
|
152
201
|
const collector = createCollector({
|
|
153
202
|
source: () => ctx.get('workspaceChanges'),
|
|
154
203
|
prepare: async (cwd) => { await loadBucket(ctx, cwd); await repairPaths(cwd, resolvePath) },
|
|
@@ -157,7 +206,7 @@ export function installCapture(ctx: Ctx, onSnapshot?: (cwd: string, snapshot: Re
|
|
|
157
206
|
const saved = saveSnapshot(cwd, snapshot)
|
|
158
207
|
onSnapshot?.(cwd, snapshot)
|
|
159
208
|
return saved
|
|
160
|
-
}, state: captureState, report: (message) => log.warn(message),
|
|
209
|
+
}, state: captureState, tracked, report: (message) => log.warn(message),
|
|
161
210
|
})
|
|
162
211
|
// Subscribe first: seed reads must not create a live-event race window.
|
|
163
212
|
ctx.on('session/event', collector.enqueue)
|