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
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-vscode-mode client — HTML 计划页签面板:状态条 + 官方动作 + 沙箱 iframe。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 页面来源按优先级解析:作者页(已打包直接显示、未打包自动打包、声明缺失时试备用路径)
|
|
5
|
+
* → HTML 计划模式下用计划正文渲染自动页 → 报错(并把回落控制权交回 EditorView)。
|
|
5
6
|
* 同意执行 / 继续规划走官方 userQuestions 答案通道,退出计划模式走官方 /plan off,
|
|
6
7
|
* 页面答复经桥接脚本回填对话输入框。iframe 一律 sandbox 且不给 allow-same-origin。
|
|
7
8
|
* @author ddj 2026年11月21号
|
|
9
|
+
* @author ddj 2026年11月25号(HTML 计划模式:模式徽标、自动页、页面来源与 Markdown 回落)
|
|
8
10
|
*/
|
|
9
11
|
import React from 'react'
|
|
10
12
|
import { rpc } from '../rpc.js'
|
|
11
13
|
import {
|
|
12
14
|
buildPlanSrcDoc,
|
|
15
|
+
deriveHtmlPlanUiState,
|
|
13
16
|
derivePlanUiState,
|
|
14
17
|
isMissingPage,
|
|
15
18
|
planAttachInfoOf,
|
|
19
|
+
planPageAltPath,
|
|
20
|
+
planPageDecisionOf,
|
|
16
21
|
planPagePathOf,
|
|
17
22
|
planRepairInstruction,
|
|
18
23
|
resolvePlanPagePath,
|
|
19
24
|
unresolvedRuntimeRefs,
|
|
20
25
|
type PendingReview,
|
|
26
|
+
type PlanPageRead,
|
|
21
27
|
} from './planPage.js'
|
|
22
28
|
import {
|
|
23
29
|
answerPlanReview,
|
|
30
|
+
exitHtmlPlanMode,
|
|
24
31
|
exitPlanMode,
|
|
25
32
|
fillComposer,
|
|
33
|
+
readHtmlPlanMode,
|
|
26
34
|
readPendingReview,
|
|
27
35
|
readPlanProjection,
|
|
28
36
|
revealPlanReview,
|
|
@@ -38,28 +46,43 @@ export interface HtmlPlanPanelProps {
|
|
|
38
46
|
title?: string
|
|
39
47
|
htmlPath?: string
|
|
40
48
|
markdown?: string
|
|
49
|
+
/** 计划由 HTML 计划模式提交:允许插件渲染自动页,缺页不再视为错误。 */
|
|
50
|
+
htmlPlanMode?: boolean
|
|
51
|
+
/** 页面无法生成时交回 EditorView 回落官方 Markdown。 */
|
|
52
|
+
onMarkdownFallback?: () => void
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
/** 本地刚完成的动作(用于状态文案,不持久化)。 */
|
|
44
56
|
type PlanAct = 'approved' | 'revising' | 'exited'
|
|
45
57
|
type ReadResult = { ok?: boolean; content?: string; error?: string; code?: string }
|
|
58
|
+
type PageSource = 'authored' | 'packed' | 'auto'
|
|
59
|
+
|
|
60
|
+
/** 页面来源徽标文案。 */
|
|
61
|
+
const SOURCE_LABEL: Record<PageSource, string> = {
|
|
62
|
+
authored: '作者页',
|
|
63
|
+
packed: '已打包',
|
|
64
|
+
auto: '自动页',
|
|
65
|
+
}
|
|
46
66
|
|
|
47
67
|
/**
|
|
48
68
|
* HTML 计划面板。
|
|
49
69
|
* @author ddj 2026年11月21号
|
|
50
|
-
* @param props
|
|
70
|
+
* @param props 会话/工作区/计划页路径、标题与模式
|
|
51
71
|
* @returns 计划页签正文
|
|
52
72
|
*/
|
|
53
73
|
export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
54
74
|
const sessionId = String(props.sessionId ?? '')
|
|
75
|
+
const htmlPlanMode = props.htmlPlanMode === true
|
|
55
76
|
const declared = String(props.htmlPath ?? planPagePathOf(props.markdown) ?? '')
|
|
56
77
|
const absPath = resolvePlanPagePath(props.cwd, declared)
|
|
57
78
|
const title = String(props.title ?? 'HTML 计划')
|
|
58
79
|
|
|
59
80
|
const [html, setHtml] = React.useState<string | null>(null)
|
|
81
|
+
const [source, setSource] = React.useState<PageSource | null>(null)
|
|
60
82
|
const [error, setError] = React.useState<string | null>(null)
|
|
61
83
|
const [staleRefs, setStaleRefs] = React.useState<string[]>([])
|
|
62
84
|
const [projection, setProjection] = React.useState<unknown>(undefined)
|
|
85
|
+
const [htmlMode, setHtmlMode] = React.useState<unknown>(undefined)
|
|
63
86
|
const [review, setReview] = React.useState<PendingReview | null>(null)
|
|
64
87
|
const [acted, setActed] = React.useState<PlanAct | null>(null)
|
|
65
88
|
const [busy, setBusy] = React.useState(false)
|
|
@@ -70,8 +93,9 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
70
93
|
const [repairing, setRepairing] = React.useState(false)
|
|
71
94
|
const frameRef = React.useRef<HTMLIFrameElement | null>(null)
|
|
72
95
|
const pollRef = React.useRef<number | null>(null)
|
|
73
|
-
const
|
|
74
|
-
pageRef
|
|
96
|
+
const aliveRef = React.useRef(true)
|
|
97
|
+
const pageRef = React.useRef({ absPath, declared, sessionId, markdown: props.markdown })
|
|
98
|
+
pageRef.current = { absPath, declared, sessionId, markdown: props.markdown }
|
|
75
99
|
|
|
76
100
|
/** 停掉等待页面出现的轮询(卸载/重读/成功时都调一次)。 */
|
|
77
101
|
function stopPolling(): void {
|
|
@@ -80,45 +104,176 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
80
104
|
pollRef.current = null
|
|
81
105
|
}
|
|
82
106
|
}
|
|
83
|
-
React.useEffect(() => stopPolling, [])
|
|
107
|
+
React.useEffect(() => () => { aliveRef.current = false; stopPolling() }, [])
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 读一页并把结果归一成三态 + 是否需要打包。
|
|
111
|
+
* @author ddj 2026年11月25号
|
|
112
|
+
* @param path 绝对路径
|
|
113
|
+
* @returns 读取结果
|
|
114
|
+
*/
|
|
115
|
+
async function readPage(path: string): Promise<{ read: PlanPageRead; text: string; refs: string[] }> {
|
|
116
|
+
try {
|
|
117
|
+
const raw = await rpc('edrv.read', { sessionId, path })
|
|
118
|
+
const result = raw as ReadResult
|
|
119
|
+
if (result?.ok === true) {
|
|
120
|
+
const text = String(result.content ?? '')
|
|
121
|
+
return { read: 'ok', text, refs: unresolvedRuntimeRefs(text) }
|
|
122
|
+
}
|
|
123
|
+
return { read: isMissingPage(result) ? 'missing' : 'error', text: '', refs: [] }
|
|
124
|
+
} catch {
|
|
125
|
+
return { read: 'error', text: '', refs: [] }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 调 host 打包作者页;失败返回可读原因。
|
|
131
|
+
* @author ddj 2026年11月25号
|
|
132
|
+
* @param path 页面路径
|
|
133
|
+
* @returns 打包后的 HTML 或错误
|
|
134
|
+
*/
|
|
135
|
+
async function packPage(path: string): Promise<{ ok: boolean; html?: string; error?: string }> {
|
|
136
|
+
try {
|
|
137
|
+
const raw = await rpc('edrv.planPage.pack', { sessionId, path })
|
|
138
|
+
const result = raw as { ok?: boolean; html?: string; error?: string }
|
|
139
|
+
return result?.ok === true ? { ok: true, html: String(result.html ?? '') } : { ok: false, error: String(result?.error ?? '打包失败') }
|
|
140
|
+
} catch (cause) {
|
|
141
|
+
return { ok: false, error: String(cause) }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 调 host 用计划正文渲染自动页。
|
|
147
|
+
* @author ddj 2026年11月25号
|
|
148
|
+
* @returns 自动页 HTML 或错误
|
|
149
|
+
*/
|
|
150
|
+
async function renderAutoPage(): Promise<{ ok: boolean; html?: string; error?: string }> {
|
|
151
|
+
try {
|
|
152
|
+
const raw = await rpc('edrv.planPage.render', { sessionId, markdown: String(props.markdown ?? '') })
|
|
153
|
+
const result = raw as { ok?: boolean; html?: string; error?: string }
|
|
154
|
+
return result?.ok === true ? { ok: true, html: String(result.html ?? '') } : { ok: false, error: String(result?.error ?? '渲染失败') }
|
|
155
|
+
} catch (cause) {
|
|
156
|
+
return { ok: false, error: String(cause) }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
84
159
|
|
|
85
|
-
//
|
|
160
|
+
// 读取计划页:作者页 → 自动打包 → 备用路径 → 自动页 → 报错/回落。
|
|
86
161
|
React.useEffect(() => {
|
|
87
|
-
|
|
162
|
+
aliveRef.current = true
|
|
88
163
|
setHtml(null)
|
|
164
|
+
setSource(null)
|
|
89
165
|
setError(null)
|
|
90
166
|
setStaleRefs([])
|
|
91
167
|
setMissing(false)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
168
|
+
setNotice('')
|
|
169
|
+
|
|
170
|
+
let alive = true
|
|
171
|
+
const isAlive = (): boolean => alive && aliveRef.current
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 页面解析主流程(异步,失败一律落到可读状态,不抛)。
|
|
175
|
+
* @author ddj 2026年11月25号
|
|
176
|
+
*/
|
|
177
|
+
async function resolvePage(): Promise<void> {
|
|
178
|
+
let read: PlanPageRead = 'missing'
|
|
179
|
+
let needsPack = false
|
|
180
|
+
let alternateExists = false
|
|
181
|
+
let rawText = ''
|
|
182
|
+
let rawRefs: string[] = []
|
|
183
|
+
let alternatePath = ''
|
|
184
|
+
|
|
185
|
+
if (declared) {
|
|
186
|
+
const first = await readPage(absPath)
|
|
187
|
+
read = first.read
|
|
188
|
+
rawText = first.text
|
|
189
|
+
rawRefs = first.refs
|
|
190
|
+
needsPack = first.read === 'ok' && first.refs.length > 0
|
|
191
|
+
if (first.read !== 'ok') {
|
|
192
|
+
const alt = planPageAltPath(declared)
|
|
193
|
+
if (alt) {
|
|
194
|
+
alternatePath = resolvePlanPagePath(props.cwd, alt)
|
|
195
|
+
const alternate = await readPage(alternatePath)
|
|
196
|
+
alternateExists = alternate.read === 'ok'
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (!isAlive()) return
|
|
202
|
+
const decision = planPageDecisionOf({ declared, htmlPlanMode, read, needsPack, alternateExists })
|
|
203
|
+
|
|
204
|
+
if (decision.action === 'show') {
|
|
205
|
+
setHtml(rawText)
|
|
206
|
+
setStaleRefs(rawRefs)
|
|
207
|
+
setSource('authored')
|
|
208
|
+
setMissing(false)
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (decision.action === 'pack') {
|
|
213
|
+
const target = resolvePlanPagePath(props.cwd, String(decision.target ?? ''))
|
|
214
|
+
const packed = await packPage(target)
|
|
215
|
+
if (!isAlive()) return
|
|
216
|
+
if (packed.ok && packed.html !== undefined) {
|
|
217
|
+
setHtml(packed.html)
|
|
218
|
+
setStaleRefs([])
|
|
219
|
+
setSource('packed')
|
|
220
|
+
setMissing(false)
|
|
221
|
+
setNotice('已自动打包计划页')
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
// 打包失败但作者页本身读得到:原样展示并保留告警,不吞掉内容。
|
|
225
|
+
if (read === 'ok') {
|
|
226
|
+
setHtml(rawText)
|
|
227
|
+
setStaleRefs(rawRefs)
|
|
228
|
+
setSource('authored')
|
|
229
|
+
setNotice('自动打包失败:' + String(packed.error ?? '未知原因'))
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
// 否则继续走兜底/报错。
|
|
233
|
+
setNotice('自动打包失败:' + String(packed.error ?? '未知原因'))
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (decision.action === 'auto') {
|
|
237
|
+
const rendered = await renderAutoPage()
|
|
238
|
+
if (!isAlive()) return
|
|
239
|
+
if (rendered.ok && rendered.html !== undefined) {
|
|
240
|
+
setHtml(rendered.html)
|
|
241
|
+
setStaleRefs([])
|
|
242
|
+
setSource('auto')
|
|
243
|
+
setMissing(false)
|
|
244
|
+
setNotice('自动页:由计划正文渲染,作者页可让它更丰富')
|
|
245
|
+
return
|
|
246
|
+
}
|
|
247
|
+
setError('自动页渲染失败:' + String(rendered.error ?? '未知原因') + ';已回落 Markdown 计划')
|
|
248
|
+
props.onMarkdownFallback?.()
|
|
103
249
|
return
|
|
104
250
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
251
|
+
|
|
252
|
+
// 没有作者页、也不是 HTML 计划模式:保持原行为(缺页给生成入口)。
|
|
253
|
+
setMissing(read === 'missing' || alternateExists)
|
|
254
|
+
if (!declared) {
|
|
255
|
+
setError('计划未声明 HTML 页路径(计划正文缺少「HTML 计划页:…」一行)')
|
|
256
|
+
} else if (read === 'missing') {
|
|
257
|
+
setError('计划页还没生成:' + absPath)
|
|
258
|
+
} else {
|
|
259
|
+
setError('读取计划页失败:' + absPath)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
void resolvePage()
|
|
112
264
|
return () => { alive = false }
|
|
113
|
-
|
|
265
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
266
|
+
}, [absPath, declared, htmlPlanMode, markdownKey(props.markdown), sessionId, reloadToken, props.cwd])
|
|
114
267
|
|
|
115
268
|
// 计划状态读取一律不可抛:侧栏 slot 里抛一次异常就会把整片正文刷空(连编辑器一起消失)。
|
|
116
269
|
const refresh = React.useCallback(() => {
|
|
117
270
|
try {
|
|
118
271
|
setProjection(readPlanProjection(sessionId))
|
|
272
|
+
setHtmlMode(readHtmlPlanMode(sessionId))
|
|
119
273
|
setReview(readPendingReview(sessionId))
|
|
120
274
|
} catch {
|
|
121
275
|
setProjection(undefined)
|
|
276
|
+
setHtmlMode(undefined)
|
|
122
277
|
setReview(null)
|
|
123
278
|
}
|
|
124
279
|
}, [sessionId])
|
|
@@ -160,7 +315,8 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
160
315
|
|
|
161
316
|
React.useEffect(() => { postPlanState() }, [review])
|
|
162
317
|
|
|
163
|
-
const
|
|
318
|
+
const officialState = derivePlanUiState(projection, review !== null, acted)
|
|
319
|
+
const state = htmlPlanMode ? deriveHtmlPlanUiState(htmlMode, review !== null, acted) : officialState
|
|
164
320
|
const attachments = html === null ? { total: 0, pending: 0 } : planAttachInfoOf(html)
|
|
165
321
|
|
|
166
322
|
/**
|
|
@@ -210,7 +366,9 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
210
366
|
return
|
|
211
367
|
}
|
|
212
368
|
setBusy(true)
|
|
213
|
-
const result = action === 'exited'
|
|
369
|
+
const result = action === 'exited'
|
|
370
|
+
? (htmlPlanMode ? await exitHtmlPlanMode(sessionId) : await exitPlanMode(sessionId))
|
|
371
|
+
: await answerPlanReview(sessionId, action === 'approved')
|
|
214
372
|
setBusy(false)
|
|
215
373
|
if (result.ok) {
|
|
216
374
|
setActed(action)
|
|
@@ -230,38 +388,32 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
230
388
|
}
|
|
231
389
|
|
|
232
390
|
/**
|
|
233
|
-
*
|
|
234
|
-
* @author ddj 2026年11月
|
|
391
|
+
* 重新解析一次页面(⟳ 与轮询共用;走 reloadToken 让解析流程重跑)。
|
|
392
|
+
* @author ddj 2026年11月25号
|
|
235
393
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
try {
|
|
240
|
-
const raw = await rpc('edrv.read', { sessionId: sid, path })
|
|
241
|
-
const result = raw as ReadResult
|
|
242
|
-
if (result?.ok !== true) return
|
|
243
|
-
stopPolling()
|
|
244
|
-
setMissing(false)
|
|
245
|
-
setError(null)
|
|
246
|
-
setHtml(String(result.content ?? ''))
|
|
247
|
-
setStaleRefs(unresolvedRuntimeRefs(result.content))
|
|
248
|
-
setNotice('计划页已生成')
|
|
249
|
-
} catch {
|
|
250
|
-
/* 下一轮再试 */
|
|
251
|
-
}
|
|
394
|
+
function reloadPage(): void {
|
|
395
|
+
stopPolling()
|
|
396
|
+
setReloadToken((value) => value + 1)
|
|
252
397
|
}
|
|
253
398
|
|
|
254
399
|
/**
|
|
255
|
-
* 让 agent 现场生成计划页:先发修复指令,再每 2
|
|
400
|
+
* 让 agent 现场生成计划页:先发修复指令,再每 2 秒重读一次,最多等 90 秒。
|
|
256
401
|
*
|
|
257
402
|
* 有待审批卡片时把「继续规划」和修复指令一起交给 agent(先 steer 指令再结算),
|
|
258
403
|
* 否则 agent 会先按「继续规划」开始修订、指令等到下一回合才被读到。
|
|
259
|
-
*
|
|
404
|
+
* HTML 计划模式下页面由插件负责,这里只重新解析,不再要求 agent 写文件。
|
|
260
405
|
* @author ddj 2026年11月23号
|
|
261
406
|
* @author ddj 2026年11月24号(与「继续规划」一起提交,保证同一步送达)
|
|
262
407
|
*/
|
|
263
408
|
async function regenerate(): Promise<void> {
|
|
264
409
|
if (repairing) return
|
|
410
|
+
if (htmlPlanMode) {
|
|
411
|
+
setRepairing(true)
|
|
412
|
+
reloadPage()
|
|
413
|
+
setRepairing(false)
|
|
414
|
+
setNotice('已重新解析计划页')
|
|
415
|
+
return
|
|
416
|
+
}
|
|
265
417
|
setRepairing(true)
|
|
266
418
|
const hadReview = reviewRef.current
|
|
267
419
|
const result = await submitPlanResponse(sessionId, planRepairInstruction(declared), false)
|
|
@@ -278,18 +430,22 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
278
430
|
let waited = 0
|
|
279
431
|
pollRef.current = window.setInterval(() => {
|
|
280
432
|
waited += 1
|
|
281
|
-
void retryRead()
|
|
282
433
|
if (waited >= 45) {
|
|
283
434
|
stopPolling()
|
|
284
435
|
setRepairing(false)
|
|
285
436
|
setNotice('还没等到计划页:可以再点一次「生成 HTML 计划页」,或让 agent 跑技能的 runtime/plan.mjs 打包')
|
|
437
|
+
return
|
|
286
438
|
}
|
|
439
|
+
setReloadToken((value) => value + 1)
|
|
287
440
|
}, 2000)
|
|
288
441
|
}
|
|
289
442
|
|
|
290
443
|
const canAnswer = review !== null && !busy
|
|
444
|
+
const sourceLabel = source ? SOURCE_LABEL[source] : ''
|
|
291
445
|
const chrome = React.createElement('div', { className: 'edrv-htmlplan-bar' },
|
|
292
446
|
React.createElement('span', { className: 'edrv-htmlplan-title', title: absPath }, title),
|
|
447
|
+
(htmlPlanMode ? React.createElement('span', { className: 'edrv-htmlplan-mode' }, 'HTML 计划模式') : null),
|
|
448
|
+
(sourceLabel ? React.createElement('span', { className: 'edrv-htmlplan-src' }, sourceLabel) : null),
|
|
293
449
|
React.createElement('span', { className: 'edrv-htmlplan-state edrv-htmlplan-state-' + state.mode }, state.label),
|
|
294
450
|
React.createElement('span', { style: { flex: 1 } }),
|
|
295
451
|
React.createElement('button', {
|
|
@@ -304,7 +460,7 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
304
460
|
}, '继续规划'),
|
|
305
461
|
React.createElement('button', {
|
|
306
462
|
className: 'edrv-pill edrv-pill-ghost', disabled: busy || !state.active,
|
|
307
|
-
title: '等价 composer 计划徽标的 /plan off',
|
|
463
|
+
title: htmlPlanMode ? '等价底部栏 chip 的 /html-plan off' : '等价 composer 计划徽标的 /plan off',
|
|
308
464
|
onClick: () => { void run('exited') },
|
|
309
465
|
}, '退出计划模式'),
|
|
310
466
|
(review ? React.createElement('button', {
|
|
@@ -315,7 +471,7 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
315
471
|
title: copied ? '把页面答复填入对话输入框(不自动发送)' : '先在页面里点 Copy response',
|
|
316
472
|
onClick: () => { void run('fill') },
|
|
317
473
|
}, '填入对话输入框'),
|
|
318
|
-
(missing || !absPath ? React.createElement('button', {
|
|
474
|
+
(!htmlPlanMode && (missing || !absPath) ? React.createElement('button', {
|
|
319
475
|
className: 'edrv-pill edrv-pill-accent',
|
|
320
476
|
disabled: repairing || !sessionId,
|
|
321
477
|
title: '让 agent 现在就写 plans/<slug>/plan.html 并打包(计划模式里允许写计划文件)',
|
|
@@ -323,20 +479,22 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
323
479
|
}, repairing ? '生成中…' : '生成 HTML 计划页') : null),
|
|
324
480
|
React.createElement('button', {
|
|
325
481
|
className: 'edrv-pill edrv-pill-ghost', title: '重新读取计划页',
|
|
326
|
-
onClick: () => { setCopied('');
|
|
482
|
+
onClick: () => { setCopied(''); reloadPage() },
|
|
327
483
|
}, '⟳'))
|
|
328
484
|
|
|
329
485
|
const noticeLine = notice ? React.createElement('div', { className: 'edrv-htmlplan-notice' }, notice) : null
|
|
330
486
|
|
|
331
487
|
let stage
|
|
332
488
|
if (error) {
|
|
333
|
-
const canRepair = missing || !absPath
|
|
489
|
+
const canRepair = !htmlPlanMode && (missing || !absPath)
|
|
334
490
|
stage = React.createElement('div', { className: 'edrv-empty', role: 'alert' },
|
|
335
491
|
React.createElement('div', null, error),
|
|
336
492
|
React.createElement('div', { style: { fontSize: 12, opacity: 0.75 } },
|
|
337
|
-
|
|
338
|
-
? '
|
|
339
|
-
:
|
|
493
|
+
htmlPlanMode
|
|
494
|
+
? '点 ⟳ 重新解析;仍失败可关闭页签回到 Markdown 计划预览。'
|
|
495
|
+
: canRepair
|
|
496
|
+
? '点下面的按钮让 agent 现在就写页面并打包;也可以关掉页签回到 Markdown 计划预览。'
|
|
497
|
+
: '可关闭页签回到 Markdown 计划预览;或让 agent 重新打包计划页。'),
|
|
340
498
|
canRepair ? React.createElement('button', {
|
|
341
499
|
className: 'edrv-pill edrv-pill-accent', style: { marginTop: 10 },
|
|
342
500
|
disabled: repairing || !sessionId,
|
|
@@ -344,20 +502,20 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
344
502
|
onClick: () => { void regenerate() },
|
|
345
503
|
}, repairing ? '生成中…' : '生成 HTML 计划页') : null)
|
|
346
504
|
} else if (html === null) {
|
|
347
|
-
stage = React.createElement('div', { className: 'edrv-empty' }, '读取计划页…')
|
|
505
|
+
stage = React.createElement('div', { className: 'edrv-empty' }, htmlPlanMode ? '解析计划页…' : '读取计划页…')
|
|
348
506
|
} else {
|
|
349
507
|
const warnLines: string[] = []
|
|
350
|
-
if (staleRefs.length) warnLines.push('页面未打包:仍引用 ' + staleRefs.join('、') + '
|
|
351
|
-
if (attachments.pending) warnLines.push(String(attachments.pending) + '
|
|
508
|
+
if (staleRefs.length) warnLines.push('页面未打包:仍引用 ' + staleRefs.join('、') + '。样式/脚本可能缺失。')
|
|
509
|
+
if (attachments.pending) warnLines.push(String(attachments.pending) + ' 个附件没内联:点开是空链接。')
|
|
352
510
|
const warn = warnLines.length
|
|
353
511
|
? React.createElement('div', { className: 'edrv-htmlplan-warn' },
|
|
354
512
|
warnLines.join(' '),
|
|
355
513
|
React.createElement('button', {
|
|
356
514
|
className: 'edrv-pill edrv-pill-accent', style: { marginLeft: 8 },
|
|
357
515
|
disabled: repairing || !sessionId,
|
|
358
|
-
title: '让 agent 重新跑 plan.mjs 打包这一页',
|
|
516
|
+
title: htmlPlanMode ? '重新解析计划页' : '让 agent 重新跑 plan.mjs 打包这一页',
|
|
359
517
|
onClick: () => { void regenerate() },
|
|
360
|
-
}, repairing ? '
|
|
518
|
+
}, repairing ? '处理中…' : htmlPlanMode ? '重新解析' : '重新打包'))
|
|
361
519
|
: null
|
|
362
520
|
stage = React.createElement(React.Fragment, null,
|
|
363
521
|
warn,
|
|
@@ -372,3 +530,14 @@ export function HtmlPlanPanel(props: HtmlPlanPanelProps) {
|
|
|
372
530
|
|
|
373
531
|
return React.createElement('div', { className: 'edrv-htmlplan' }, chrome, noticeLine, stage)
|
|
374
532
|
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* 取 markdown 的稳定依赖键(避免父级每次渲染都触发重解析)。
|
|
536
|
+
* @author ddj 2026年11月25号
|
|
537
|
+
* @param markdown 计划正文
|
|
538
|
+
* @returns 长度 + 前缀指纹
|
|
539
|
+
*/
|
|
540
|
+
function markdownKey(markdown: unknown): string {
|
|
541
|
+
const text = typeof markdown === 'string' ? markdown : ''
|
|
542
|
+
return String(text.length) + ':' + text.slice(0, 64)
|
|
543
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { createAddToConversation } from '../addToConversation.js'
|
|
10
10
|
import { findPendingReview, reviewAnswerOf, reviewLabelsOf, type PendingReview } from './planPage.js'
|
|
11
|
+
import { HTML_PLAN_MODE_KEY, HTML_PLAN_OFF_LINE } from '../../shared/htmlPlanMode.js'
|
|
11
12
|
|
|
12
13
|
/** 客户端上下文的最小结构面。 */
|
|
13
14
|
export interface PlanActionCtx {
|
|
@@ -105,6 +106,13 @@ export function readPlanProjection(sessionId: string): unknown {
|
|
|
105
106
|
return probe(() => faceSnapshot(faceOf(ctx, sessionId, 'plan')))
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
/** 读 HTML 计划模式投影快照({ active } 或 undefined)。 */
|
|
110
|
+
export function readHtmlPlanMode(sessionId: string): unknown {
|
|
111
|
+
if (!host) return undefined
|
|
112
|
+
const ctx = host.ctx
|
|
113
|
+
return probe(() => faceSnapshot(faceOf(ctx, sessionId, HTML_PLAN_MODE_KEY)))
|
|
114
|
+
}
|
|
115
|
+
|
|
108
116
|
/** 在线待审批的会话卡片(PendingQuestion 实例:带 answer 与 intent)。 */
|
|
109
117
|
interface LiveReview {
|
|
110
118
|
pending: { answer: (answer: unknown) => Promise<unknown> }
|
|
@@ -178,7 +186,7 @@ export function readPendingReview(sessionId: string): PendingReview | null {
|
|
|
178
186
|
export function subscribePlanFaces(sessionId: string, listener: () => void): () => void {
|
|
179
187
|
if (!host) return () => {}
|
|
180
188
|
const offs: Array<() => void> = []
|
|
181
|
-
for (const key of ['plan', 'userQuestions']) {
|
|
189
|
+
for (const key of ['plan', 'userQuestions', HTML_PLAN_MODE_KEY]) {
|
|
182
190
|
const face = faceOf(host.ctx, sessionId, key) as { subscribe?: (fn: () => void) => unknown } | undefined
|
|
183
191
|
if (!face || typeof face.subscribe !== 'function') continue
|
|
184
192
|
try {
|
|
@@ -360,25 +368,47 @@ export async function answerPlanReview(sessionId: string, approve: boolean): Pro
|
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
/**
|
|
363
|
-
*
|
|
364
|
-
* @author ddj 2026年11月
|
|
371
|
+
* 执行一条退出命令并归一结果(计划徽标与模式 chip 共用)。
|
|
372
|
+
* @author ddj 2026年11月25号
|
|
365
373
|
* @param sessionId 会话 id
|
|
374
|
+
* @param line 完整命令行
|
|
375
|
+
* @param failure 失败文案前缀
|
|
366
376
|
* @returns 动作结果
|
|
367
377
|
*/
|
|
368
|
-
|
|
369
|
-
if (!host) return fail('
|
|
378
|
+
async function exitWithLine(sessionId: string, line: string, failure: string): Promise<PlanActionResult> {
|
|
379
|
+
if (!host) return fail('计划动作桥未就绪,请点输入框里的模式 chip 退出')
|
|
370
380
|
if (!sessionId) return fail('当前没有活动会话')
|
|
371
381
|
const commands = serviceOf(host.ctx, 'remote.commands') as { execute?: (id: string, line: string, attachments: unknown[]) => Promise<unknown> } | undefined
|
|
372
382
|
if (!commands || typeof commands.execute !== 'function') {
|
|
373
|
-
return fail('当前 DSH
|
|
383
|
+
return fail('当前 DSH 不支持在插件内执行命令,请点输入框里的模式 chip 退出')
|
|
374
384
|
}
|
|
375
385
|
try {
|
|
376
|
-
return unwrap(await commands.execute(sessionId,
|
|
386
|
+
return unwrap(await commands.execute(sessionId, line, []))
|
|
377
387
|
} catch (error) {
|
|
378
|
-
return fail('
|
|
388
|
+
return fail(failure + ':' + messageOf(error))
|
|
379
389
|
}
|
|
380
390
|
}
|
|
381
391
|
|
|
392
|
+
/**
|
|
393
|
+
* 退出计划模式(等价 composer 计划徽标的 /plan off)。
|
|
394
|
+
* @author ddj 2026年11月21号
|
|
395
|
+
* @param sessionId 会话 id
|
|
396
|
+
* @returns 动作结果
|
|
397
|
+
*/
|
|
398
|
+
export async function exitPlanMode(sessionId: string): Promise<PlanActionResult> {
|
|
399
|
+
return exitWithLine(sessionId, '/plan off', '退出计划模式失败')
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* 退出 HTML 计划模式(等价底部栏 chip 的 /html-plan off)。
|
|
404
|
+
* @author ddj 2026年11月25号
|
|
405
|
+
* @param sessionId 会话 id
|
|
406
|
+
* @returns 动作结果
|
|
407
|
+
*/
|
|
408
|
+
export async function exitHtmlPlanMode(sessionId: string): Promise<PlanActionResult> {
|
|
409
|
+
return exitWithLine(sessionId, HTML_PLAN_OFF_LINE, '退出 HTML 计划模式失败')
|
|
410
|
+
}
|
|
411
|
+
|
|
382
412
|
/**
|
|
383
413
|
* 把手填正文交给 agent,并同时结算官方审批(页面「回复」/「回复并执行」)。
|
|
384
414
|
*
|