dsh-better-debug 0.2.1 → 0.2.3
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.en.md +10 -6
- package/README.md +15 -6
- package/lib/index.js +38 -4
- package/lib/panel.js +49 -8
- package/package.json +1 -1
- package/web/index.html +43 -6
package/README.en.md
CHANGED
|
@@ -184,7 +184,7 @@ dsh plugin add dsh-better-debug
|
|
|
184
184
|
**Or from the Release tarball (pnpm treats it as a normal package):**
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
|
-
dsh plugin add https://github.com/Leonlee114514/dsh-better-debug/releases/download/v0.2.
|
|
187
|
+
dsh plugin add https://github.com/Leonlee114514/dsh-better-debug/releases/download/v0.2.3/dsh-better-debug-0.2.3.tgz
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
(Both install the same package: the npm tarball is byte-identical to the Release asset.
|
|
@@ -299,13 +299,13 @@ Not writing a file was the v0.1 default, and the cost was new users installing i
|
|
|
299
299
|
|
|
300
300
|
```bash
|
|
301
301
|
node --check lib/index.js && node --check lib/panel.js && node --check lib/text.js && node --check client.js
|
|
302
|
-
node test/sim.mjs #
|
|
303
|
-
node test/panel.mjs #
|
|
302
|
+
node test/sim.mjs # 46 cases: gate semantics + portability
|
|
303
|
+
node test/panel.mjs # 40 cases: log parsing, aggregation, generation scoping, instrumentation
|
|
304
304
|
npm run test:posix # re-runs both suites under POSIX path semantics
|
|
305
305
|
npm run verify # all of the above (with syntax checks)
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
`test/sim.mjs` uses a fake ctx that replicates agent-loop call order (`emitPlain` / `emitWaterfall`) and covers **
|
|
308
|
+
`test/sim.mjs` uses a fake ctx that replicates agent-loop call order (`emitPlain` / `emitWaterfall`) and covers **46 cases**.
|
|
309
309
|
|
|
310
310
|
Semantics (each with a positive and a negative):
|
|
311
311
|
|
|
@@ -335,7 +335,7 @@ and then **re-runs both suites unchanged** — so a Windows dev machine reproduc
|
|
|
335
335
|
semantics. CI runs `npm run verify` on ubuntu / windows / macos × node 20 / 22 / 24, so this
|
|
336
336
|
cannot quietly regress. (24 is not padding: the desktop build runs Electron's bundled node 24.)
|
|
337
337
|
|
|
338
|
-
|
|
338
|
+
The rest of the same family, all fixed in v0.2 / v0.2.1 / v0.2.2 / v0.2.3:
|
|
339
339
|
|
|
340
340
|
| Symptom | Root cause | Now |
|
|
341
341
|
| --- | --- | --- |
|
|
@@ -344,6 +344,10 @@ Four more of the same family, all fixed in v0.2 / v0.2.1:
|
|
|
344
344
|
| Plugin silently not loaded — no error, no log line | static `inject: ['skills']` makes `apply()` never run when the service is missing | `inject = []`, dynamic `ctx.inject` |
|
|
345
345
|
| Clicking "enable" in the market does nothing | bundle patch carried a `config:` block | patch keeps only `id` + `name` |
|
|
346
346
|
| A too-old host is never rejected | the range lived in `dsh.engines.dsh`, but the host and the market read only top-level `engines.dsh` | moved to top-level `engines.dsh` |
|
|
347
|
+
| In a real project every error is reported as "the same operation failed again" | node's stack is `file:///C:/...`, and the path regex hits the `e:` inside the scheme, so every stack becomes `"e:///c"` | `stripFileUrl` removes the URL head first |
|
|
348
|
+
| `a1.js` and `a2.js` are treated as the same place | normalisation replaced every digit in the path with `<n>`; only line/column should go | only the trailing `(:\d+)+$` is stripped |
|
|
349
|
+
| Running tests in a sibling directory washed out this directory's blind-edit count | `measureDirs` treated `cd <dir>` as a file and took its parent (`cd ~/projB` → `~`) | `cd` is recognised; that segment is a directory |
|
|
350
|
+
| The panel kept showing "the plugin is currently disabled" while it was clearly running | the banner counted `disabled` / `panel failed` over the **whole log**, so one historical failure counted as "broken now" forever | the banner only reads the generation after the last `apply` (`log.current`); history is reported separately in the footer |
|
|
347
351
|
|
|
348
352
|
**Case folding is decided per platform** (`CASE_INSENSITIVE`): only on `win32` / `darwin`.
|
|
349
353
|
The cost of folding wrong is asymmetric — not folding when you should under-reports, folding
|
|
@@ -351,7 +355,7 @@ when you should not **over-reports** (crying wolf), and over-reporting is the on
|
|
|
351
355
|
gate must not make. A case-sensitive APFS volume on macOS under-reports a little, which is
|
|
352
356
|
still the safe direction.
|
|
353
357
|
|
|
354
|
-
`test/panel.mjs` covers **
|
|
358
|
+
`test/panel.mjs` covers **40 cases**: quoted and escaped field splitting; six line kinds (`inject` / `outcome` / `change` / `measure` / `arm` / `panel-failed`); zero drift between `charsFor` and the real text length across 6 signal combinations; `worstStreak` preserved along log→parse→aggregate→panel; `suppress` and `arm` lines parsed and not counted as fires; the aggregated `firstAction` / `turned` / `measures`; **assertions that v0.1's field names `changed` / `changedRate` / `outcomes` must not come back**; thresholds from the last `apply`; empty logs and bad lines not throwing; and an end-to-end run that really calls `apply()`, walks one turn, and reads the log back to assert `inject` carries `inj=`, `outcome` carries `before=write`, `measure ok=false exit=1`, and `change` is written and aggregated. Generation scoping has its own group: failures in the history with a clean generation after the last `apply` must leave `log.current` at zero and keep the banner quiet; a failure *after* the last `apply` must light it; a log with no `apply` line at all gives `markers=0`, and the panel says it only has a fragment rather than claiming health. **The page itself is asserted too** — the test reads `web/index.html` and checks the banner consumes `log.current` and no whole-log branch survived.
|
|
355
359
|
|
|
356
360
|
## Known boundaries
|
|
357
361
|
|
package/README.md
CHANGED
|
@@ -222,7 +222,7 @@ dsh plugin add dsh-better-debug
|
|
|
222
222
|
**或者从 Release tarball 装(pnpm 会把它当普通包装进 profile):**
|
|
223
223
|
|
|
224
224
|
```bash
|
|
225
|
-
dsh plugin add https://github.com/Leonlee114514/dsh-better-debug/releases/download/v0.2.
|
|
225
|
+
dsh plugin add https://github.com/Leonlee114514/dsh-better-debug/releases/download/v0.2.3/dsh-better-debug-0.2.3.tgz
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
(两条装的是同一个包:npm 上的 tarball 与 Release 资产逐字节相同。走 npm 的好处是
|
|
@@ -363,14 +363,14 @@ bundle 层按原样加载」。也就是说:**写了 config,用户点「启
|
|
|
363
363
|
|
|
364
364
|
```bash
|
|
365
365
|
node --check lib/index.js && node --check lib/panel.js && node --check lib/text.js && node --check client.js
|
|
366
|
-
node test/sim.mjs #
|
|
367
|
-
node test/panel.mjs #
|
|
366
|
+
node test/sim.mjs # 46 个用例:闸门语义 + 可移植性
|
|
367
|
+
node test/panel.mjs # 40 个用例:日志解析、聚合、世代判定、埋点落盘
|
|
368
368
|
npm run test:posix # 把上面两套用 POSIX 路径语义再跑一遍
|
|
369
369
|
npm run verify # 上面全部(含语法检查)
|
|
370
370
|
```
|
|
371
371
|
|
|
372
372
|
`test/sim.mjs` 用假 ctx 复刻 agent-loop 的调用顺序(`emitPlain` / `emitWaterfall`),
|
|
373
|
-
覆盖 **
|
|
373
|
+
覆盖 **46 个用例**。
|
|
374
374
|
|
|
375
375
|
语义层(每条都有正例 + 反例):
|
|
376
376
|
|
|
@@ -402,7 +402,7 @@ npm run verify # 上面全部(含语法检查)
|
|
|
402
402
|
ubuntu / windows / macos × node 20 / 22 / 24 上跑 `npm run verify`,所以这条不会退回去。
|
|
403
403
|
(24 不是凑数:桌面版 DSH 跑的是 Electron 内置的 node 24。)
|
|
404
404
|
|
|
405
|
-
|
|
405
|
+
同一类问题的其余各处,都在 v0.2 / v0.2.1 / v0.2.2 / v0.2.3 修掉了:
|
|
406
406
|
|
|
407
407
|
| 症状 | 根因 | 现在 |
|
|
408
408
|
| --- | --- | --- |
|
|
@@ -411,12 +411,16 @@ ubuntu / windows / macos × node 20 / 22 / 24 上跑 `npm run verify`,所以
|
|
|
411
411
|
| 插件静默不加载,无报错无日志 | 静态 `inject: ['skills']` 缺服务时 `apply()` 整个不执行 | `inject = []`,走 `ctx.inject` 动态订阅 |
|
|
412
412
|
| 市场点「启用」没反应 | bundle patch 带 `config:` 块 | patch 只留 `id` + `name` |
|
|
413
413
|
| 宿主版本太旧也不拦 | 版本范围写在 `dsh.engines.dsh`,而宿主与市场只读顶层 `engines.dsh` | 移到顶层 `engines.dsh` |
|
|
414
|
+
| 新项目里一报错就误报「同一个操作重复报错」 | node 的栈是 `file:///C:/...`,路径正则先撞上 scheme 里的 `e:`,每份栈都变成 `"e:///c"` | `stripFileUrl` 先剥 URL 头 |
|
|
415
|
+
| `a1.js` 与 `a2.js` 被当成同一处 | 归一化把路径里每个数字都换成 `<n>`,只该剥行号列号 | 只剥末尾 `(:\d+)+$` |
|
|
416
|
+
| 在兄弟目录跑测试,把这个目录的盲改计数洗白了 | `measureDirs` 把 `cd <dir>` 当文件取父目录(`cd ~/projB` → `~`) | 认 `cd` 形式,那段路径按目录处理 |
|
|
417
|
+
| 面板永远红着脸说「插件当前被关闭」,而它明明在跑 | 横幅数的是**整份日志**里的 `disabled` / `panel failed`,历史里挂过一次就永久算「现在坏了」 | 横幅只认最后一次 `apply` 之后(`log.current`),历史单独的个数写在页脚 |
|
|
414
418
|
|
|
415
419
|
**大小写折叠按平台判**(`CASE_INSENSITIVE`):只在 `win32` / `darwin` 上折叠。折叠错了的
|
|
416
420
|
后果不对称——该折叠却不折叠是漏报,不该折叠却折叠是**误报**(狼来了),后者才是这道闸门
|
|
417
421
|
最不能犯的错。macOS 上装了区分大小写的 APFS 会少报一点,仍然是安全方向。
|
|
418
422
|
|
|
419
|
-
`test/panel.mjs` 覆盖 **
|
|
423
|
+
`test/panel.mjs` 覆盖 **40 个用例**:带引号与转义的字段切分、六种行型解析(`inject` / `outcome` /
|
|
420
424
|
`change` / `measure` / `arm` / `panel-failed`)、`charsFor` 与真实文案长度零漂移(6 组信号组合)、
|
|
421
425
|
`worstStreak` 在日志→解析→聚合→面板全链路保留、`suppress` 与 `arm` 行可解析且不计入触发、
|
|
422
426
|
聚合出的 `firstAction` / `turned` / `measures`、**断言 v0.1 的旧字段名
|
|
@@ -424,6 +428,11 @@ ubuntu / windows / macos × node 20 / 22 / 24 上跑 `npm run verify`,所以
|
|
|
424
428
|
以及端到端——真跑 `apply()` 走完一个 turn,读回日志断言 `inject` 带 `inj=`、
|
|
425
429
|
`outcome` 带 `before=write`、`measure ok=false exit=1`、`change` 行都写了且被聚合。
|
|
426
430
|
|
|
431
|
+
世代判定单列一组:历史里有失败、最后一次 `apply` 之后干净 → `log.current` 全 0、横幅不亮;
|
|
432
|
+
`apply` 之后又失败 → `log.current` 必须亮;日志里根本没有 `apply` 行 → `markers=0`,
|
|
433
|
+
面板明说「读到的只是片段」,不冒充健康。**页面本身也被断言**——直接读 `web/index.html`,
|
|
434
|
+
确认横幅读的是 `log.current`、没有残留按全量计数判红的老分支。
|
|
435
|
+
|
|
427
436
|
## 已知边界
|
|
428
437
|
|
|
429
438
|
- 「同一文件」按**绝对路径**判定。删了重建同名文件也算同一处——这通常是对的(说明在同一个
|
package/lib/index.js
CHANGED
|
@@ -255,6 +255,20 @@ function foldCase(text) {
|
|
|
255
255
|
return CASE_INSENSITIVE ? text.toLowerCase() : text
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/**
|
|
259
|
+
* 剥掉 `file://` URL 头,把它变回普通路径。
|
|
260
|
+
*
|
|
261
|
+
* node 在 Windows 上抛异常时栈里写的是 `file:///C:/Users/.../a.mjs:12:29`,
|
|
262
|
+
* 在 POSIX 上是 `file:///home/u/.../a.mjs:12:29`。不剥的话,路径正则先撞上
|
|
263
|
+
* scheme 里的 `e:`,`file:///C:/a.mjs` 会被认成目标 `"e:///c"` —— 所有 Windows 栈
|
|
264
|
+
* 就此塌成同一个 episode,B 信号对任何三次不同文件的报错都会误报。
|
|
265
|
+
*/
|
|
266
|
+
function stripFileUrl(text) {
|
|
267
|
+
return String(text ?? '')
|
|
268
|
+
.replace(/file:\/\/\/(?=[A-Za-z]:[\\/])/gi, '')
|
|
269
|
+
.replace(/file:\/\/(?=\/)/gi, '')
|
|
270
|
+
}
|
|
271
|
+
|
|
258
272
|
/** 规整成一个可比对的目录:posix 分隔符、去尾斜杠、按平台折叠大小写。 */
|
|
259
273
|
function normDir(path) {
|
|
260
274
|
const normalized = String(path ?? '').replace(/\\/g, '/').replace(/\/+$/, '')
|
|
@@ -316,7 +330,25 @@ export function measureDirs(args) {
|
|
|
316
330
|
if (workspace.length > 0) dirs.add(workspace)
|
|
317
331
|
const collect = (text) => {
|
|
318
332
|
if (typeof text !== 'string' || text.length === 0) return
|
|
319
|
-
|
|
333
|
+
// `cd <dir> && npm test`:这里那段路径本身就是目录,不能交给 dirOf(会多剥一层,
|
|
334
|
+
// 让 `cd ~/projB` 变成 `~`,于是兄弟目录的测量洗白了 projA 的盲改计数)。
|
|
335
|
+
let rest = text
|
|
336
|
+
for (const match of text.matchAll(/\bcd\s+("[^"]+"|'[^']+'|[^\s&;|]+)/gi)) {
|
|
337
|
+
const raw = match[1].replace(/^["']|["']$/g, '')
|
|
338
|
+
if (raw.length > 0) {
|
|
339
|
+
const expanded = raw.startsWith('~') ? expandHome(raw) : raw
|
|
340
|
+
// `cd src` 这种相对写法要靠 workdir 才能落地;两者都缺就跳过,
|
|
341
|
+
// 否则 `cd ..` 会变成一个恒不匹配的目录名,白占一个候选。
|
|
342
|
+
const dir = isAbsPath(expanded)
|
|
343
|
+
? normDir(expanded)
|
|
344
|
+
: workspace.length > 0
|
|
345
|
+
? normDir(join(workspace, expanded))
|
|
346
|
+
: ''
|
|
347
|
+
if (dir.length > 0) dirs.add(dir)
|
|
348
|
+
}
|
|
349
|
+
rest = rest.split(match[0]).join(' ')
|
|
350
|
+
}
|
|
351
|
+
for (const match of rest.matchAll(/[A-Za-z]:[\\/][^\s"'`;,)]+|\/(?:[\w.-]+\/)+[\w.-]*/g)) {
|
|
320
352
|
dirs.add(dirOf(match[0]))
|
|
321
353
|
}
|
|
322
354
|
}
|
|
@@ -330,7 +362,7 @@ export function measureDirs(args) {
|
|
|
330
362
|
* 报错变的是行号、时间戳、临时路径、内存地址,不变的是异常类和消息骨架。
|
|
331
363
|
*/
|
|
332
364
|
export function errorFingerprint(text) {
|
|
333
|
-
const head =
|
|
365
|
+
const head = stripFileUrl(text)
|
|
334
366
|
.split('\n')
|
|
335
367
|
.slice(0, 6)
|
|
336
368
|
.join('\n')
|
|
@@ -353,11 +385,13 @@ export function errorFingerprint(text) {
|
|
|
353
385
|
* 就被当成「同一个报错吃了两次」)。
|
|
354
386
|
*/
|
|
355
387
|
export function errorTargetOf(text) {
|
|
356
|
-
const match = /(?:[A-Za-z]:[\\/]|(?<![\w.])\.{0,2}\/)[^\s"'
|
|
388
|
+
const match = /(?:[A-Za-z]:[\\/]|(?<![\w.])\.{0,2}\/)[^\s"';)]+/i.exec(stripFileUrl(text))
|
|
357
389
|
if (match === null) return ''
|
|
390
|
+
// 只剥末尾的行号列号(`a.mjs:12:29` → `a.mjs`)。**不要**把路径里每个数字都归一:
|
|
391
|
+
// `a1.js` 与 `a2.js`、`proj1/` 与 `proj2/` 是两个不同位置,归一后会把它们塌成一个 episode。
|
|
358
392
|
// 大小写按平台折叠,和 normDir 同理:在区分大小写的系统上折叠会把 a.js 与 A.js
|
|
359
393
|
// 合成同一个 episode,把两个不同文件各错一次误报成「同一个报错吃了两次」。
|
|
360
|
-
return foldCase(match[0].replace(
|
|
394
|
+
return foldCase(match[0].replace(/(?::\d+)+$/, '').replace(/\\/g, '/'))
|
|
361
395
|
}
|
|
362
396
|
|
|
363
397
|
/** 从 tool/result 的事件数据里拔出人能读的错误摘要。 */
|
package/lib/panel.js
CHANGED
|
@@ -272,6 +272,15 @@ export function aggregate(records, options = {}) {
|
|
|
272
272
|
let skillFailed = 0
|
|
273
273
|
let panelFailed = 0
|
|
274
274
|
let suppressed = 0
|
|
275
|
+
/**
|
|
276
|
+
* 世代计数:只算**最后一次 apply 之后**发生的失败。
|
|
277
|
+
*
|
|
278
|
+
* 为什么必须分两套:`disabled by config` / `panel register failed` 这类行是
|
|
279
|
+
* 「那一刻的状态」,不是「永久事实」。全量计数会让历史里挂过一次的插件
|
|
280
|
+
* 在修好之后仍然永久显示红条 —— 面板说「插件当前被关闭」,而它明明在跑,
|
|
281
|
+
* 这比没有面板更坏。全量留在 log.disabled 等字段里给「历史上出过事」用。
|
|
282
|
+
*/
|
|
283
|
+
const current = { disabled: 0, skillFailed: 0, panelFailed: 0, since: '', pid: 0, markers: 0 }
|
|
275
284
|
|
|
276
285
|
for (const record of records) {
|
|
277
286
|
if (record.kind === 'inject') injects.push(record)
|
|
@@ -279,12 +288,33 @@ export function aggregate(records, options = {}) {
|
|
|
279
288
|
else if (record.kind === 'change') changes.push(record)
|
|
280
289
|
else if (record.kind === 'measure') measures.push(record)
|
|
281
290
|
else if (record.kind === 'arm') arms.push(record)
|
|
282
|
-
else if (record.kind === 'apply')
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
291
|
+
else if (record.kind === 'apply') {
|
|
292
|
+
applies.push(record)
|
|
293
|
+
// 新的世代开始:之前那些失败属于上一代,不再代表「现在」。
|
|
294
|
+
current.disabled = 0
|
|
295
|
+
current.skillFailed = 0
|
|
296
|
+
current.panelFailed = 0
|
|
297
|
+
current.since = record.at
|
|
298
|
+
current.pid = record.pid
|
|
299
|
+
current.markers += 1
|
|
300
|
+
} else if (record.kind === 'skill') skills.push(record)
|
|
301
|
+
else if (record.kind === 'disabled') {
|
|
302
|
+
disabled += 1
|
|
303
|
+
// `disabled by config` 之后 apply 不会再写(index.js 里直接 return),
|
|
304
|
+
// 所以它本身就是一次世代分界:这一代的状态就是「关着」。不认这一点的话,
|
|
305
|
+
// 一个真的被关掉的插件会因为「没有 apply 行」被判成「无从判断」。
|
|
306
|
+
current.disabled = 1
|
|
307
|
+
current.skillFailed = 0
|
|
308
|
+
current.panelFailed = 0
|
|
309
|
+
current.since = record.at
|
|
310
|
+
current.markers += 1
|
|
311
|
+
} else if (record.kind === 'skill-failed') {
|
|
312
|
+
skillFailed += 1
|
|
313
|
+
current.skillFailed += 1
|
|
314
|
+
} else if (record.kind === 'panel-failed') {
|
|
315
|
+
panelFailed += 1
|
|
316
|
+
current.panelFailed += 1
|
|
317
|
+
} else if (record.kind === 'suppress') suppressed += 1
|
|
288
318
|
}
|
|
289
319
|
|
|
290
320
|
const bySignal = { A: 0, B: 0, C: 0 }
|
|
@@ -349,7 +379,18 @@ export function aggregate(records, options = {}) {
|
|
|
349
379
|
suppressed,
|
|
350
380
|
arms: arms.length,
|
|
351
381
|
skills: skills.length,
|
|
352
|
-
skillPath: skills.length > 0 ? skills[skills.length - 1].path : ''
|
|
382
|
+
skillPath: skills.length > 0 ? skills[skills.length - 1].path : '',
|
|
383
|
+
// 「现在这一代怎么样」——横幅只看这一段。全量在上面,供事后查历史。
|
|
384
|
+
// markers=0 表示日志里没有任何世代分界(既没有 apply 也没有 disabled),
|
|
385
|
+
// 说明读到的是残缺片段;此时失败仍然照实计入,只是面板没法说「这是哪一次加载之后」。
|
|
386
|
+
current: {
|
|
387
|
+
disabled: current.disabled,
|
|
388
|
+
skillFailed: current.skillFailed,
|
|
389
|
+
panelFailed: current.panelFailed,
|
|
390
|
+
since: current.since,
|
|
391
|
+
pid: current.pid,
|
|
392
|
+
markers: current.markers
|
|
393
|
+
}
|
|
353
394
|
},
|
|
354
395
|
thresholds: lastApply !== null && lastApply.thresholds.A > 0
|
|
355
396
|
? lastApply.thresholds
|
|
@@ -477,7 +518,7 @@ export function registerPanel(ctx, getConfig) {
|
|
|
477
518
|
send(
|
|
478
519
|
200,
|
|
479
520
|
'application/json; charset=utf-8',
|
|
480
|
-
JSON.stringify({ id: 'dsh-better-debug', version:
|
|
521
|
+
JSON.stringify({ id: 'dsh-better-debug', version: 3 }, null, 2)
|
|
481
522
|
)
|
|
482
523
|
return
|
|
483
524
|
}
|
package/package.json
CHANGED
package/web/index.html
CHANGED
|
@@ -154,6 +154,7 @@
|
|
|
154
154
|
|
|
155
155
|
<div class="foot">
|
|
156
156
|
<p><b>每个数字都能逐行数出来。</b>触发次数、覆盖会话、信号分布来自 <code>inject</code> 行;「提示后首个动作」来自紧接着的那条 <code>outcome</code> 行;窗口内转向来自 <code>change</code> 行;测量回路来自 <code>measure</code> 行(它是「有没有反馈回路」的直接证据,跟任何动作分类无关)。<span id="suppressed-note"></span></p>
|
|
157
|
+
<p><b>顶部那条红条只说「现在」。</b>它只数最后一次 <code>apply</code>(也就是最近一次加载)之后的失败行——那之前的关闭/挂载失败已经被这次加载取代,不代表当下状态,只在这里列个数。<span id="hist-note"></span></p>
|
|
157
158
|
<p><b>这些数字不证明什么。</b>「提示后首个动作」只说明提示之后模型做了什么,它不能证明提示促成了这个动作,更不能证明它发现了缺陷——要回答那个问题需要对照组或历史回放。面板也不估算「省掉了多少 token」:那要先假设模型本来会失败,属于编数。</p>
|
|
158
159
|
</div>
|
|
159
160
|
|
|
@@ -307,16 +308,52 @@
|
|
|
307
308
|
}).join('')
|
|
308
309
|
}
|
|
309
310
|
|
|
310
|
-
|
|
311
|
+
// 横幅只说「现在」:只数最后一次 apply 之后发生的失败。
|
|
312
|
+
// 历史里挂过一次、修好之后仍永久染红,会让面板说「插件当前被关闭」
|
|
313
|
+
// 而它明明在跑 —— 那比没有面板更坏。全量计数仍留在 log.disabled 等字段,
|
|
314
|
+
// 并在页脚如实写成「历史日志里记过」。
|
|
315
|
+
var cur = lg.current || {}
|
|
316
|
+
var curDisabled = Number(cur.disabled) || 0
|
|
317
|
+
var curSkillFailed = Number(cur.skillFailed) || 0
|
|
318
|
+
var curPanelFailed = Number(cur.panelFailed) || 0
|
|
319
|
+
var sincePrefix = cur.since ? '最后一次加载(' + esc(cur.since) + ')之后,' : ''
|
|
320
|
+
// 老 API(没有 current 段)只能退回全量口径:宁可多报,也不把真实故障咽下去。
|
|
321
|
+
if (lg.current === undefined || lg.current === null) {
|
|
322
|
+
curDisabled = Number(lg.disabled) || 0
|
|
323
|
+
curSkillFailed = Number(lg.skillFailed) || 0
|
|
324
|
+
curPanelFailed = Number(lg.panelFailed) || 0
|
|
325
|
+
sincePrefix = '日志里有 '
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (curDisabled) {
|
|
311
329
|
$('error').hidden = false
|
|
312
|
-
$('error').textContent = '
|
|
313
|
-
} else if (
|
|
330
|
+
$('error').textContent = sincePrefix + '记了 ' + curDisabled + ' 条 disabled by config —— 插件当前被关闭。'
|
|
331
|
+
} else if (curSkillFailed) {
|
|
314
332
|
$('error').hidden = false
|
|
315
|
-
$('error').textContent = '
|
|
316
|
-
} else if (
|
|
333
|
+
$('error').textContent = sincePrefix + '记了 ' + curSkillFailed + ' 次技能注册失败,闸门本身不受影响。'
|
|
334
|
+
} else if (curPanelFailed) {
|
|
317
335
|
$('error').hidden = false
|
|
318
|
-
$('error').textContent = '
|
|
336
|
+
$('error').textContent = sincePrefix + '记了 ' + curPanelFailed + ' 次面板路由挂载失败 —— 闸门可能仍在工作,但读数面板没挂上。'
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 历史归历史:不染红,但要如实说明它存在,否则「0」会被读成「从来没出过事」。
|
|
340
|
+
var stale = (Number(lg.disabled) || 0) - curDisabled +
|
|
341
|
+
(Number(lg.skillFailed) || 0) - curSkillFailed +
|
|
342
|
+
(Number(lg.panelFailed) || 0) - curPanelFailed
|
|
343
|
+
var notes = []
|
|
344
|
+
if (stale > 0) {
|
|
345
|
+
notes.push('另外,历史日志里还记着 ' + stale + ' 条更早的关闭 / 挂载失败(都在最后一次加载之前),已被当前这次加载取代;它们不代表现在的状态。')
|
|
346
|
+
}
|
|
347
|
+
// markers=0:日志里既没有 apply 也没有 disabled,读到的只是一段片段。
|
|
348
|
+
// 这时候「没有红条」不等于「现在健康」,得说出来,不能默认绿灯。
|
|
349
|
+
if (lg.current === undefined || lg.current === null) {
|
|
350
|
+
// 页面是每次请求现读的,插件模块不是。改完代码但还没重启时,
|
|
351
|
+
// 新页面会拿到旧 API(没有 current 段)—— 说出来,别让它看起来像健康。
|
|
352
|
+
notes.push('这个页面比插件新:API 还没有 <code>log.current</code> 段(插件需要重载才会用上新代码)。上面的红条按老口径判断,可能误报。')
|
|
353
|
+
} else if ((Number(cur.markers) || 0) === 0) {
|
|
354
|
+
notes.push('这份日志里没有 <code>apply</code> 行,认不出是哪一次加载之后的记录 —— 上面这些数字只是读到的片段,不能当作「现在健康」。')
|
|
319
355
|
}
|
|
356
|
+
$('hist-note').innerHTML = notes.length > 0 ? ' ' + notes.join(' ') : ''
|
|
320
357
|
}
|
|
321
358
|
|
|
322
359
|
function fail(message) {
|