@moonquake2004/dsh-doctor 0.4.8 → 0.4.9
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/dsh-doctor.mjs +26 -2
- package/package.json +1 -1
package/dsh-doctor.mjs
CHANGED
|
@@ -1917,10 +1917,34 @@ async function run() {
|
|
|
1917
1917
|
// 获取最新会话文件(供 SR*/SS* 检查使用)
|
|
1918
1918
|
// 世代感知定位(与 S11 同一规则):三层 sessions/<user>/<session>/session*.jsonl*,
|
|
1919
1919
|
// 目录内取最高世代(v0/v3 并存时取 v3),跨目录按 mtime 取最新,忽略 session.lock
|
|
1920
|
+
// 运行时检查(SR*/SS*)扫"最新会话",而最新会话通常**就是当前正在写入的会话** ——
|
|
1921
|
+
// 那会把操作者自己的操作报成安全发现(2026-09 实测:SR1 报的 critical 全是本次会话里
|
|
1922
|
+
// 自己写的 `curl|bash` 测试串,SR2 的 `doas` 来自自己引用的规则文本)。
|
|
1923
|
+
// 故默认跳过"仍在写入"的会话:取 mtime 早于活跃窗口的最新会话;
|
|
1924
|
+
// 窗口可用 DSH_DOCTOR_LIVE_WINDOW_MS 调整(默认 120s,设 0 关闭该保护)。
|
|
1925
|
+
const LIVE_WINDOW_MS = (() => {
|
|
1926
|
+
const v = Number(process.env.DSH_DOCTOR_LIVE_WINDOW_MS);
|
|
1927
|
+
return Number.isFinite(v) && v >= 0 ? v : 120000;
|
|
1928
|
+
})();
|
|
1920
1929
|
const findLatestSession = () => {
|
|
1921
|
-
if (sessionArg) return sessionArg;
|
|
1922
|
-
try {
|
|
1930
|
+
if (sessionArg) return sessionArg; // 显式指定则始终尊重
|
|
1931
|
+
try {
|
|
1932
|
+
const root = join(HOME, 'sessions');
|
|
1933
|
+
const all = listSessionLogs(root); // 已按 mtime 降序
|
|
1934
|
+
if (!all.length) return null;
|
|
1935
|
+
if (LIVE_WINDOW_MS === 0) return all[0].f;
|
|
1936
|
+
const cutoff = Date.now() - LIVE_WINDOW_MS;
|
|
1937
|
+
const settled = all.find((x) => (x.m ?? 0) < cutoff);
|
|
1938
|
+
return (settled ?? all[0]).f;
|
|
1939
|
+
} catch { return null; }
|
|
1923
1940
|
};
|
|
1941
|
+
const sessionIsLive = (() => {
|
|
1942
|
+
if (sessionArg || LIVE_WINDOW_MS === 0) return false;
|
|
1943
|
+
try {
|
|
1944
|
+
const all = listSessionLogs(join(HOME, 'sessions'));
|
|
1945
|
+
return all.length > 0 && (all[0].m ?? 0) >= Date.now() - LIVE_WINDOW_MS;
|
|
1946
|
+
} catch { return false; }
|
|
1947
|
+
})();
|
|
1924
1948
|
|
|
1925
1949
|
const { results: secResults, exitCode: secExit, summary: secSummary } = await registry.runAll(
|
|
1926
1950
|
(check) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonquake2004/dsh-doctor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "Offline diagnostic for DeepSeek Harness — 28 built-in + 5 catalog checks across env/profile/session (Layer A checks-as-data), self-update (Layer B), and a semi-automatic LLM observer (Layer C, --observe); Doctor panel in web UI settings.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|