dsh-aftermath 0.0.0-stage → 0.6.4
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/GUIDE.md +277 -0
- package/LICENSE +21 -0
- package/README.md +220 -2
- package/assets/icon-128.png +0 -0
- package/assets/icon-256.png +0 -0
- package/assets/icon-512.png +0 -0
- package/assets/icon-96.png +0 -0
- package/assets/icon-e-dark.html +26 -0
- package/assets/icon-e-light.html +26 -0
- package/assets/icon-light-512.png +0 -0
- package/assets/icon-light-96.png +0 -0
- package/cordis.patch.yml +3 -0
- package/lib/attribution.js +641 -0
- package/lib/client.js +894 -0
- package/lib/command-registration.js +21 -0
- package/lib/commands.js +379 -0
- package/lib/config.js +237 -0
- package/lib/diff.js +231 -0
- package/lib/index.js +603 -0
- package/lib/panel.js +126 -0
- package/lib/report.js +428 -0
- package/lib/scan.js +186 -0
- package/lib/schema.js +196 -0
- package/lib/store.js +188 -0
- package/lib/symptoms.js +148 -0
- package/lib/version.js +22 -0
- package/package.json +72 -4
package/lib/symptoms.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 症状表:用户描述的是“我的桌面图标全白了”,不是“14:32 删了三个文件”。
|
|
3
|
+
* 这里把变更翻回人话,并给出可以自己复制的检查命令(只打印,绝不执行)。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const RECYCLE_HINT = '回收站:Explorer 地址栏输入 shell:RecycleBinFolder';
|
|
7
|
+
|
|
8
|
+
const SHORTCUT_TARGET_CHECK = String.raw`Get-ChildItem "$env:USERPROFILE\Desktop\*.lnk" -Force | ForEach-Object {
|
|
9
|
+
$s = (New-Object -ComObject WScript.Shell).CreateShortcut($_.FullName)
|
|
10
|
+
if (-not (Test-Path -LiteralPath $s.TargetPath)) { "目标已失效: $($_.Name) -> $($s.TargetPath)" }
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
const ICON_CACHE_REBUILD = 'ie4uinit.exe -show # Win10/11 重建图标缓存(无需重启资源管理器)';
|
|
14
|
+
|
|
15
|
+
const DESKTOP_FOLDER_QUERY = String.raw`Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' |
|
|
16
|
+
Select-Object Desktop, '{374DE290-123F-4565-9164-39C4925E467B}'`;
|
|
17
|
+
|
|
18
|
+
const ONEDRIVE_CHECK = 'Get-Process OneDrive -ErrorAction SilentlyContinue | Select-Object Id, Path';
|
|
19
|
+
|
|
20
|
+
function isShortcut(rel) {
|
|
21
|
+
return rel.toLowerCase().endsWith('.lnk');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function inRoot(change, rootId) {
|
|
25
|
+
return change.rootId === rootId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function pick(changes, rootId, kinds) {
|
|
29
|
+
return changes.filter((change) => inRoot(change, rootId) && kinds.includes(change.kind));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const SYMPTOMS = [
|
|
33
|
+
{
|
|
34
|
+
id: 'icons-blank',
|
|
35
|
+
title: '桌面图标大面积变空白 / 变成白纸图标',
|
|
36
|
+
question: '是不是图标全白了、双击没反应?',
|
|
37
|
+
detect({ changes, roots }) {
|
|
38
|
+
const desktop = roots.find((root) => root.id === 'desktop');
|
|
39
|
+
if (!desktop) return null;
|
|
40
|
+
const goneShortcuts = pick(changes, 'desktop', ['deleted', 'moved']).filter((c) => isShortcut(c.rel));
|
|
41
|
+
const touchedShortcuts = pick(changes, 'desktop', ['modified']).filter((c) => isShortcut(c.rel));
|
|
42
|
+
if (goneShortcuts.length === 0 && touchedShortcuts.length === 0) return null;
|
|
43
|
+
const score = goneShortcuts.length * 3 + touchedShortcuts.length;
|
|
44
|
+
return {
|
|
45
|
+
score,
|
|
46
|
+
because: goneShortcuts.length > 0
|
|
47
|
+
? `桌面有 ${goneShortcuts.length} 个快捷方式被删除或移走`
|
|
48
|
+
: `桌面有 ${touchedShortcuts.length} 个快捷方式文件本身被改写`,
|
|
49
|
+
checks: [
|
|
50
|
+
{ label: '目标失效的快捷方式(最常见的“白图标”)', command: SHORTCUT_TARGET_CHECK },
|
|
51
|
+
{ label: '重建图标缓存', command: ICON_CACHE_REBUILD },
|
|
52
|
+
{ label: '被删的快捷方式', command: `${RECYCLE_HINT},找 .lnk 恢复` },
|
|
53
|
+
],
|
|
54
|
+
note: '快捷方式文件还在、但目标路径失效时,表现为白图标;快捷方式文件被删时,表现为图标消失。两者的修法完全不同。',
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'desktop-files-gone',
|
|
60
|
+
title: '桌面的文件 / 文件夹不见了',
|
|
61
|
+
question: '是不是桌面上少了文件或文件夹?',
|
|
62
|
+
detect({ changes, roots }) {
|
|
63
|
+
const desktop = roots.find((root) => root.id === 'desktop');
|
|
64
|
+
if (!desktop) return null;
|
|
65
|
+
const gone = pick(changes, 'desktop', ['deleted', 'moved']).filter((c) => !isShortcut(c.rel));
|
|
66
|
+
if (gone.length === 0) return null;
|
|
67
|
+
return {
|
|
68
|
+
score: gone.length * 2,
|
|
69
|
+
because: `桌面有 ${gone.length} 个非快捷方式条目被删除或移走`,
|
|
70
|
+
checks: [
|
|
71
|
+
{ label: '先看回收站', command: RECYCLE_HINT },
|
|
72
|
+
{ label: '确认桌面路径有没有被改到别处', command: DESKTOP_FOLDER_QUERY },
|
|
73
|
+
],
|
|
74
|
+
note: 'moved 是启发式判断(同名+同大小+时间接近),如果条目出现在下面的“移走候选”里,大概率换了个目录而不是被删。',
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'downloads-files-gone',
|
|
80
|
+
title: '下载目录里的文件不见了',
|
|
81
|
+
question: '是不是下载的东西找不到了?',
|
|
82
|
+
detect({ changes, roots }) {
|
|
83
|
+
const downloads = roots.find((root) => root.id === 'downloads');
|
|
84
|
+
if (!downloads) return null;
|
|
85
|
+
const gone = pick(changes, 'downloads', ['deleted', 'moved']);
|
|
86
|
+
if (gone.length === 0) return null;
|
|
87
|
+
return {
|
|
88
|
+
score: gone.length * 2,
|
|
89
|
+
because: `下载目录有 ${gone.length} 个条目被删除或移走`,
|
|
90
|
+
checks: [{ label: '回收站', command: RECYCLE_HINT }],
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'desktop-redirected',
|
|
96
|
+
title: '桌面被重定向 / 被 OneDrive 接管',
|
|
97
|
+
question: '是不是桌面变成空的了、或者多出一个 OneDrive 桌面?',
|
|
98
|
+
detect({ changes, roots }) {
|
|
99
|
+
const desktop = roots.find((root) => root.id === 'desktop');
|
|
100
|
+
const reasons = [];
|
|
101
|
+
if (desktop && desktop.ok === false) reasons.push(`桌面根读不到(${desktop.error})`);
|
|
102
|
+
const ini = pick(changes, 'desktop', ['created', 'modified']).filter((c) => c.rel.toLowerCase().endsWith('desktop.ini'));
|
|
103
|
+
if (ini.length > 0) reasons.push('desktop.ini 被改写(目录定制信息变动)');
|
|
104
|
+
const oneDrive = changes.filter((c) => /onedrive/i.test(c.rel));
|
|
105
|
+
if (oneDrive.length > 0) reasons.push(`出现了 ${oneDrive.length} 处 OneDrive 相关变更`);
|
|
106
|
+
if (reasons.length === 0) return null;
|
|
107
|
+
return {
|
|
108
|
+
score: 2 + reasons.length,
|
|
109
|
+
because: reasons.join(';'),
|
|
110
|
+
checks: [
|
|
111
|
+
{ label: '桌面真实路径(注册表)', command: DESKTOP_FOLDER_QUERY },
|
|
112
|
+
{ label: 'OneDrive 是否在运行', command: ONEDRIVE_CHECK },
|
|
113
|
+
],
|
|
114
|
+
note: '桌面路径被改动后,旧文件通常还在原目录里,只是资源管理器不再显示它。先查注册表再动手。',
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'many-renames',
|
|
120
|
+
title: '一批文件被改名 / 挪位置',
|
|
121
|
+
question: '是不是文件名或位置被批量改过?',
|
|
122
|
+
detect({ changes }) {
|
|
123
|
+
const moved = changes.filter((c) => c.kind === 'moved');
|
|
124
|
+
if (moved.length < 3) return null;
|
|
125
|
+
return {
|
|
126
|
+
score: moved.length,
|
|
127
|
+
because: `有 ${moved.length} 个条目判定为“移动”(启发式)`,
|
|
128
|
+
checks: [{ label: '逐个核对移动前后的路径', command: '见上方“移走候选”表' }],
|
|
129
|
+
note: '批量移动常见于整理脚本;如果是 AI 干的,命令原文会出现在归因列的“依据”里。',
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
/** @returns {Array} 命中的症状,按 score 降序。 */
|
|
136
|
+
export function detectSymptoms(changes, context) {
|
|
137
|
+
const hits = [];
|
|
138
|
+
for (const symptom of SYMPTOMS) {
|
|
139
|
+
let hit = null;
|
|
140
|
+
try {
|
|
141
|
+
hit = symptom.detect({ changes, roots: context.roots || [] });
|
|
142
|
+
} catch {
|
|
143
|
+
hit = null;
|
|
144
|
+
}
|
|
145
|
+
if (hit && hit.score > 0) hits.push({ ...symptom, ...hit });
|
|
146
|
+
}
|
|
147
|
+
return hits.sort((a, b) => b.score - a.score);
|
|
148
|
+
}
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 版本号的单一来源:package.json。
|
|
3
|
+
*
|
|
4
|
+
* 之前是 lib/index.js 里的一个硬编码常量,跟 package.json 各改各的,
|
|
5
|
+
* 结果 /aftermath status 显示 0.1.0、包却是 0.2.0。这里改成运行时读一次,
|
|
6
|
+
* 读不到才退回 0.0.0(表示「读不到」,不是「旧版本」)。
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
|
|
10
|
+
const UNKNOWN = '0.0.0';
|
|
11
|
+
|
|
12
|
+
function readVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
15
|
+
if (pkg && typeof pkg.version === 'string' && pkg.version.trim()) return pkg.version.trim();
|
|
16
|
+
} catch {
|
|
17
|
+
// 打包裁剪、文件缺失、JSON 损坏都不该影响插件运行
|
|
18
|
+
}
|
|
19
|
+
return UNKNOWN;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const VERSION = readVersion();
|
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-aftermath",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.6.4",
|
|
4
|
+
"description": "记录每轮对话中观测目录的文件变更,事后可倒查改了什么、出自哪条命令。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./client": "./lib/client.js",
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
"./icon": "./assets/icon-256.png"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"lib",
|
|
15
|
+
"cordis.patch.yml",
|
|
16
|
+
"README.md",
|
|
17
|
+
"GUIDE.md",
|
|
18
|
+
"assets"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"dsh",
|
|
22
|
+
"dsh-plugin",
|
|
23
|
+
"forensics",
|
|
24
|
+
"snapshot",
|
|
25
|
+
"diff",
|
|
26
|
+
"windows",
|
|
27
|
+
"desktop",
|
|
28
|
+
"ui"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/2-qing/dsh-aftermath.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/2-qing/dsh-aftermath/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/2-qing/dsh-aftermath#readme",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22.12.0",
|
|
41
|
+
"dsh": ">=0.2.2-0 <0.3.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "node --test \"test/*.test.js\"",
|
|
45
|
+
"test:watch": "node --test --watch \"test/*.test.js\""
|
|
46
|
+
},
|
|
47
|
+
"dsh": {
|
|
48
|
+
"bundle": {
|
|
49
|
+
"patch": "./cordis.patch.yml"
|
|
50
|
+
},
|
|
51
|
+
"capabilities": [
|
|
52
|
+
"fs:read",
|
|
53
|
+
"tools:register",
|
|
54
|
+
"network:ingress"
|
|
55
|
+
],
|
|
56
|
+
"compatibility": {
|
|
57
|
+
"dshReleases": {
|
|
58
|
+
"0.2.2-rc.3": "compatible"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"client": {
|
|
62
|
+
"platform": "web",
|
|
63
|
+
"immediately": true,
|
|
64
|
+
"inject": [
|
|
65
|
+
"@deepseek-ai/dsh-client-locale",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"labels": [
|
|
71
|
+
"remote-access"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|