mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 11:10:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cdf5596cd | ||
|
|
e139407af8 |
No files matched your search
@@ -6,6 +6,11 @@ npm-debug.log*
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# 本地草稿,不进仓库
|
||||||
|
scripts/tmp-*.mjs
|
||||||
|
scripts/test-*.mjs
|
||||||
|
dsh-redteam-mode-main/
|
||||||
|
|
||||||
# 外部参考,不是本插件
|
# 外部参考,不是本插件
|
||||||
choirboy-prompt/
|
choirboy-prompt/
|
||||||
/choirboy-prompt/
|
/choirboy-prompt/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||||
|
|
||||||
<p align="center"><strong>Version 1.1.53</strong></p>
|
<p align="center"><strong>Version 1.1.55</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
||||||
@@ -118,7 +118,7 @@ This release supports **DeepSeek Harness 0.2** only (official desktop **0.2.0-rc
|
|||||||
| Official Harness 0.1.x | Not supported |
|
| Official Harness 0.1.x | Not supported |
|
||||||
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
|
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
|
||||||
|
|
||||||
The plugin version is **1.1.53**. 1.1.45 is skipped; it has bugs.
|
The plugin version is **1.1.55**. 1.1.45 is skipped; it has bugs.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
||||||
·
|
·
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
|
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
🔗 **Raw protocol URL:**
|
🔗 **Raw protocol URL:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
id: 'dsh-purge',
|
id: 'dsh-purge',
|
||||||
name: 'dsh-purge',
|
name: 'dsh-purge',
|
||||||
version: '1.1.53',
|
version: '1.1.55',
|
||||||
repo: 'YuJunZhiXue/dsh-purge',
|
repo: 'YuJunZhiXue/dsh-purge',
|
||||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||||
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML link:**
|
**HTML link:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||||
🚀 Install in desktop client
|
🚀 Install in desktop client
|
||||||
</a>
|
</a>
|
||||||
```
|
```
|
||||||
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | Plugin id |
|
| id | `dsh-purge` | Plugin id |
|
||||||
| name | `dsh-purge` | Display name |
|
| name | `dsh-purge` | Display name |
|
||||||
| version | `1.1.53` | Semver |
|
| version | `1.1.55` | Semver |
|
||||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
||||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
||||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
||||||
|
|||||||
+7
-7
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||||
|
|
||||||
<p align="center"><strong>Version 1.1.53</strong></p>
|
<p align="center"><strong>Version 1.1.55</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||||
@@ -118,7 +118,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
|||||||
| 官方 Harness 0.1.x | 不支持 |
|
| 官方 Harness 0.1.x | 不支持 |
|
||||||
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
||||||
|
|
||||||
插件版本是 **1.1.53**。1.1.45 有问题,略过。
|
插件版本是 **1.1.55**。1.1.45 有问题,略过。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
||||||
·
|
·
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
|
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
🔗 **原生协议链接:**
|
🔗 **原生协议链接:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
id: 'dsh-purge',
|
id: 'dsh-purge',
|
||||||
name: 'dsh-purge',
|
name: 'dsh-purge',
|
||||||
version: '1.1.53',
|
version: '1.1.55',
|
||||||
repo: 'YuJunZhiXue/dsh-purge',
|
repo: 'YuJunZhiXue/dsh-purge',
|
||||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||||
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML 静态链接方式:**
|
**HTML 静态链接方式:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.53&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||||
🚀 唤起客户端一键安装
|
🚀 唤起客户端一键安装
|
||||||
</a>
|
</a>
|
||||||
```
|
```
|
||||||
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | 插件唯一标识符 |
|
| id | `dsh-purge` | 插件唯一标识符 |
|
||||||
| name | `dsh-purge` | 插件展示名称 |
|
| name | `dsh-purge` | 插件展示名称 |
|
||||||
| version | `1.1.53` | 语义化版本号 |
|
| version | `1.1.55` | 语义化版本号 |
|
||||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
||||||
|
|||||||
@@ -1429,9 +1429,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (ticket !== actionTicket.current) return;
|
if (ticket !== actionTicket.current) return;
|
||||||
const posted = action === "apply" ? applyContent : override;
|
if (responseNeedsPrompt(d)) {
|
||||||
const applyEmptyBlocked = action === "apply" && promptBoxEmpty(posted) && (!d || d.injectSource !== "rule");
|
|
||||||
if (responseNeedsPrompt(d) || applyEmptyBlocked) {
|
|
||||||
rejectNeedPrompt(tr);
|
rejectNeedPrompt(tr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1480,7 +1478,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
loadAll();
|
loadAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action === "apply" && (d.restart_after_apply || d.restarting || d.unpacked_asar || d.needs_full_quit)) {
|
if (action === "apply" && (d.restart_after_apply || d.restarting)) {
|
||||||
setNotice({
|
setNotice({
|
||||||
kind: "ok",
|
kind: "ok",
|
||||||
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("update.restarting"),
|
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("update.restarting"),
|
||||||
@@ -1490,6 +1488,14 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
restartDsh(setNotice, setPatchBusy, tr, surf);
|
restartDsh(setNotice, setPatchBusy, tr, surf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (action === "apply" && (d.needs_full_quit || d.unpacked_asar)) {
|
||||||
|
setNotice({
|
||||||
|
kind: "ok",
|
||||||
|
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("ok.done"),
|
||||||
|
});
|
||||||
|
loadAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
setNotice({ kind: "ok", text: tr("ok.done") });
|
setNotice({ kind: "ok", text: tr("ok.done") });
|
||||||
loadAll();
|
loadAll();
|
||||||
})
|
})
|
||||||
@@ -1501,18 +1507,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
if (ticket === actionTicket.current) setPatchBusy(false);
|
if (ticket === actionTicket.current) setPatchBusy(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (action !== "apply") {
|
run();
|
||||||
run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bothInjectEmpty(overrideRef.current, defaultOverrideRef.current).then((empty) => {
|
|
||||||
if (ticket !== actionTicket.current) return;
|
|
||||||
if (empty) {
|
|
||||||
rejectNeedPrompt(tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
});
|
|
||||||
}, [loadAll, rejectNeedPrompt]);
|
}, [loadAll, rejectNeedPrompt]);
|
||||||
|
|
||||||
const saveOverride = useCallback(() => {
|
const saveOverride = useCallback(() => {
|
||||||
|
|||||||
+136
-41
@@ -19,6 +19,14 @@ import * as continueRetry from "./continue-retry.js";
|
|||||||
import * as uninstaller from "./uninstall.js";
|
import * as uninstaller from "./uninstall.js";
|
||||||
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
||||||
import * as refusalRecover from "./refusal-recover.js";
|
import * as refusalRecover from "./refusal-recover.js";
|
||||||
|
import {
|
||||||
|
applyShouldRestart,
|
||||||
|
isInactiveContextError,
|
||||||
|
settleDelayMs,
|
||||||
|
settleMayReapply,
|
||||||
|
settleMayRestart,
|
||||||
|
watchContextLife,
|
||||||
|
} from "./settle-policy.js";
|
||||||
|
|
||||||
export const name = "dsh-purge";
|
export const name = "dsh-purge";
|
||||||
|
|
||||||
@@ -196,9 +204,17 @@ function rejectIfNeedPrompt(dshHome, boxText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function ensureRestartReady() {
|
async function ensureRestartReady() {
|
||||||
const inject = rules.resolveInjectText(core.findDshHome());
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
|
||||||
|
const inject = rules.resolveInjectText(home);
|
||||||
if (!inject.text) return { ok: false, error: "没有可注入的提示词,已取消重启" };
|
if (!inject.text) return { ok: false, error: "没有可注入的提示词,已取消重启" };
|
||||||
return core.ensureHostClean();
|
const clean = await core.ensureHostClean();
|
||||||
|
if (clean.ok) return clean;
|
||||||
|
// 密封 asar 读的是旧包,清洗写在解包目录;允许换包重启,注入靠 assemble 包装。
|
||||||
|
try {
|
||||||
|
if (core.desktopAsarStillSealed()) return { ok: true, pending: clean.pending || [] };
|
||||||
|
} catch { /* 非桌面 */ }
|
||||||
|
return clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerPromptSections(ctx, config, _injectFile) {
|
export function registerPromptSections(ctx, config, _injectFile) {
|
||||||
@@ -208,7 +224,7 @@ export function registerPromptSections(ctx, config, _injectFile) {
|
|||||||
interpolate: false,
|
interpolate: false,
|
||||||
text: (context) => {
|
text: (context) => {
|
||||||
if (!injectAllowedNow(config)) return "";
|
if (!injectAllowedNow(config)) return "";
|
||||||
return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
|
return readInjectFallback(context);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -242,7 +258,9 @@ export function registerPromptSections(ctx, config, _injectFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readInjectFallback(context) {
|
function readInjectFallback(context) {
|
||||||
return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 落盘失败仍试读默认 */ }
|
||||||
|
return rules.resolveModeInject(home, isRedteamSession(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
function installMnemonMessageStrip(ctx, config = {}) {
|
function installMnemonMessageStrip(ctx, config = {}) {
|
||||||
@@ -353,33 +371,46 @@ function installRewindDeriveFilter(ctx) {
|
|||||||
function installIdentityOverride(ctx, config = {}) {
|
function installIdentityOverride(ctx, config = {}) {
|
||||||
if (typeof ctx.on !== "function") return;
|
if (typeof ctx.on !== "function") return;
|
||||||
installSubagentRoleCapture(ctx);
|
installSubagentRoleCapture(ctx);
|
||||||
if (ctx.__dshPurgeAssembleHook) return;
|
|
||||||
ctx.__dshPurgeAssembleHook = true;
|
|
||||||
const hook = async (_assembly, context, next) => {
|
|
||||||
const assembled = typeof next === "function" ? await next() : _assembly;
|
|
||||||
return rewriteLiveAssembly(config, assembled, context);
|
|
||||||
};
|
|
||||||
// 只挂一次。不改 contexts,不改 pre-step 白名单,梁神 phase-1 和其它插件的消息原样保留。
|
|
||||||
ctx.on("system-prompt/assemble", hook, { global: true, prepend: true });
|
|
||||||
// 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
|
|
||||||
// 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
|
|
||||||
// 包住 assemble 的返回值,按 prompt-inject.md 再补回。
|
|
||||||
const wrapAssemble = () => {
|
const wrapAssemble = () => {
|
||||||
const prompt = ctx.systemPrompt;
|
try {
|
||||||
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return false;
|
const prompt = ctx.systemPrompt;
|
||||||
const orig = prompt.assemble;
|
if (!prompt || typeof prompt.assemble !== "function") return false;
|
||||||
prompt.assemble = async function (...args) {
|
if (prompt.assemble._dshPurgeWrapped) return true;
|
||||||
const assembled = await orig.apply(this, args);
|
const orig = prompt.assemble.bind(prompt);
|
||||||
return rewriteLiveAssembly(config, assembled, args[0]);
|
const wrapped = async function assembleWithPurge(...args) {
|
||||||
};
|
const assembled = await orig(...args);
|
||||||
prompt.__dshPurgeAssembleWrapped = true;
|
return rewriteLiveAssembly(config, assembled, args[0]);
|
||||||
return true;
|
};
|
||||||
|
wrapped._dshPurgeWrapped = true;
|
||||||
|
prompt.assemble = wrapped;
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (!wrapAssemble()) {
|
if (!ctx.__dshPurgeAssembleHook) {
|
||||||
queueMicrotask(wrapAssemble);
|
ctx.__dshPurgeAssembleHook = true;
|
||||||
setTimeout(wrapAssemble, 500);
|
ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
||||||
setTimeout(wrapAssemble, 2000);
|
const assembled = typeof next === "function" ? await next() : _assembly;
|
||||||
|
return rewriteLiveAssembly(config, assembled, context);
|
||||||
|
}, { global: true, prepend: true });
|
||||||
}
|
}
|
||||||
|
// complete:true 会在 waterfall 之后盖掉 sections;包住 assemble 返回值,每轮都补回注入。
|
||||||
|
wrapAssemble();
|
||||||
|
const started = Date.now();
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
wrapAssemble();
|
||||||
|
if (Date.now() - started > 20000) clearInterval(timer);
|
||||||
|
}, 400);
|
||||||
|
if (typeof timer.unref === "function") timer.unref();
|
||||||
|
try { ctx.effect(() => () => clearInterval(timer)); } catch { /* 无 effect 时靠 unref */ }
|
||||||
|
try { ctx.on("session/created", wrapAssemble); } catch { /* ignore */ }
|
||||||
|
try {
|
||||||
|
ctx.on("agent/pre-step", (payload, next) => {
|
||||||
|
wrapAssemble();
|
||||||
|
return typeof next === "function" ? next() : payload;
|
||||||
|
}, { global: true, prepend: true });
|
||||||
|
} catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
function shimNeedsPatch(state) {
|
function shimNeedsPatch(state) {
|
||||||
@@ -391,7 +422,14 @@ function shimNeedsPatch(state) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function settleInstalledPatches(config, ctx) {
|
function currentSettleScope() {
|
||||||
|
let sealed = false;
|
||||||
|
try { sealed = core.desktopAsarStillSealed(); } catch { /* 非桌面或还没定位安装目录 */ }
|
||||||
|
return { surface: hostctl.currentSurface(), sealed };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function settleInstalledPatches(config, ctx, life) {
|
||||||
|
if (life && !life.alive) return "skip:inactive";
|
||||||
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
||||||
try {
|
try {
|
||||||
reapply.ensureInstalledRevSeed();
|
reapply.ensureInstalledRevSeed();
|
||||||
@@ -404,17 +442,24 @@ async function settleInstalledPatches(config, ctx) {
|
|||||||
log(config, "heal applied stamp failed:", String(e && e.message ? e.message : e));
|
log(config, "heal applied stamp failed:", String(e && e.message ? e.message : e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scope = currentSettleScope();
|
||||||
if (!reapply.patchesMatchInstall()) {
|
if (!reapply.patchesMatchInstall()) {
|
||||||
|
if (!settleMayReapply(scope)) {
|
||||||
|
log(config, "sealed desktop: skip startup reapply (wait for Apply)");
|
||||||
|
return "skip:sealed-wait-apply";
|
||||||
|
}
|
||||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
||||||
|
if (life && !life.alive) return "skip:inactive";
|
||||||
if (!upgraded.ok) {
|
if (!upgraded.ok) {
|
||||||
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
||||||
return "reapply-failed";
|
return "reapply-failed";
|
||||||
}
|
}
|
||||||
officialUpdate.clearUpgradeMarker(process.execPath);
|
officialUpdate.clearUpgradeMarker(process.execPath);
|
||||||
officialUpdate.clearStaleExtractedApps(process.execPath);
|
officialUpdate.clearStaleExtractedApps(process.execPath);
|
||||||
if (reapply.shouldSkipSettleRestart()) {
|
if (!settleMayRestart(currentSettleScope()) || reapply.shouldSkipSettleRestart()) {
|
||||||
log(config, "official upgrade reapplied; skip settle restart (cooldown)");
|
if (upgraded.needsFullQuit) bootFullQuit = true;
|
||||||
|
log(config, "official upgrade reapplied; skip settle restart");
|
||||||
return "reapplied-no-restart";
|
return "reapplied-no-restart";
|
||||||
}
|
}
|
||||||
reapply.markSettleRestart();
|
reapply.markSettleRestart();
|
||||||
@@ -428,7 +473,9 @@ async function settleInstalledPatches(config, ctx) {
|
|||||||
return "restarting";
|
return "restarting";
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await reapply.reapplyInstalled();
|
// 启动自愈只写盘,不 swap asar / 不杀进程,避免官方 Host Fiber._reload 撞 INACTIVE_EFFECT。
|
||||||
|
const result = await reapply.reapplyInstalled({ scheduleSwap: false });
|
||||||
|
if (life && !life.alive) return "skip:inactive";
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
log(config, "reapply failed:", result.error || "");
|
log(config, "reapply failed:", result.error || "");
|
||||||
return "reapply-failed";
|
return "reapply-failed";
|
||||||
@@ -440,6 +487,10 @@ async function settleInstalledPatches(config, ctx) {
|
|||||||
log(config, "reapply wrote patches; official host needs a full quit");
|
log(config, "reapply wrote patches; official host needs a full quit");
|
||||||
return "full-quit";
|
return "full-quit";
|
||||||
}
|
}
|
||||||
|
if (!settleMayRestart(currentSettleScope())) {
|
||||||
|
log(config, "reapply wrote patches; desktop settle does not restart");
|
||||||
|
return "reapplied-no-restart";
|
||||||
|
}
|
||||||
if (reapply.shouldSkipSettleRestart()) {
|
if (reapply.shouldSkipSettleRestart()) {
|
||||||
log(config, "reapply wrote patches; skip settle restart (cooldown)");
|
log(config, "reapply wrote patches; skip settle restart (cooldown)");
|
||||||
return "reapplied-no-restart";
|
return "reapplied-no-restart";
|
||||||
@@ -467,7 +518,7 @@ async function settleInstalledPatches(config, ctx) {
|
|||||||
.then((r) => {
|
.then((r) => {
|
||||||
log(config, "auto-update:", JSON.stringify(r));
|
log(config, "auto-update:", JSON.stringify(r));
|
||||||
if (r && r.needsFullQuit) bootFullQuit = true;
|
if (r && r.needsFullQuit) bootFullQuit = true;
|
||||||
if (r && r.restartAfter) {
|
if (r && r.restartAfter && settleMayRestart(currentSettleScope())) {
|
||||||
try { hostctl.scheduleRestart(null, ctx, { openBrowser: false }); } catch (e) {
|
try { hostctl.scheduleRestart(null, ctx, { openBrowser: false }); } catch (e) {
|
||||||
console.warn("[dsh-purge] auto-update restart failed:", e);
|
console.warn("[dsh-purge] auto-update restart failed:", e);
|
||||||
}
|
}
|
||||||
@@ -867,6 +918,11 @@ async function handleSkillsCommand(rawInput) {
|
|||||||
export function apply(ctx, config) {
|
export function apply(ctx, config) {
|
||||||
const cfg = { ...DEFAULTS, ...(config || {}) };
|
const cfg = { ...DEFAULTS, ...(config || {}) };
|
||||||
if (!cfg.enabled) return;
|
if (!cfg.enabled) return;
|
||||||
|
const life = watchContextLife(ctx);
|
||||||
|
if (!life.alive) {
|
||||||
|
console.warn("[dsh-purge] skip apply: inactive context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
log(cfg, "plugin enabled");
|
log(cfg, "plugin enabled");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -883,14 +939,34 @@ export function apply(ctx, config) {
|
|||||||
console.warn("[dsh-purge] desktop runtime scrub error:", String(e));
|
console.warn("[dsh-purge] desktop runtime scrub error:", String(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
setImmediate(() => {
|
const settleTimer = setTimeout(() => {
|
||||||
settleInstalledPatches(cfg, ctx)
|
if (!life.alive) {
|
||||||
|
log(cfg, "settle skipped: inactive context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
settleInstalledPatches(cfg, ctx, life)
|
||||||
.then((r) => log(cfg, "settle:", r))
|
.then((r) => log(cfg, "settle:", r))
|
||||||
.catch((e) => console.warn("[dsh-purge] settle error:", String(e)));
|
.catch((e) => {
|
||||||
|
if (isInactiveContextError(e)) {
|
||||||
|
log(cfg, "settle skipped: inactive context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.warn("[dsh-purge] settle error:", String(e));
|
||||||
|
});
|
||||||
rules.ensureInitialState(core.findDshHome())
|
rules.ensureInitialState(core.findDshHome())
|
||||||
.then((r) => log(cfg, "rules init:", JSON.stringify(r)))
|
.then((r) => log(cfg, "rules init:", JSON.stringify(r)))
|
||||||
.catch((e) => console.warn("[dsh-purge] rules init error:", String(e)));
|
.catch((e) => console.warn("[dsh-purge] rules init error:", String(e)));
|
||||||
});
|
}, settleDelayMs(hostctl.currentSurface()));
|
||||||
|
try {
|
||||||
|
ctx.effect(() => () => clearTimeout(settleTimer));
|
||||||
|
} catch (e) {
|
||||||
|
if (isInactiveContextError(e)) {
|
||||||
|
clearTimeout(settleTimer);
|
||||||
|
console.warn("[dsh-purge] skip apply: inactive context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.seedOverrideSync(core.findDshHome());
|
core.seedOverrideSync(core.findDshHome());
|
||||||
@@ -901,6 +977,18 @@ export function apply(ctx, config) {
|
|||||||
core.installOverride(core.findDshHome(), false).catch((e) => {
|
core.installOverride(core.findDshHome(), false).catch((e) => {
|
||||||
console.warn("[dsh-purge] install override error:", String(e));
|
console.warn("[dsh-purge] install override error:", String(e));
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
applyHostHooks(ctx, cfg);
|
||||||
|
} catch (e) {
|
||||||
|
if (isInactiveContextError(e)) {
|
||||||
|
console.warn("[dsh-purge] skip apply: inactive context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyHostHooks(ctx, cfg) {
|
||||||
installIdentityOverride(ctx, cfg);
|
installIdentityOverride(ctx, cfg);
|
||||||
installRegionGate(ctx);
|
installRegionGate(ctx);
|
||||||
try {
|
try {
|
||||||
@@ -1439,7 +1527,13 @@ function installWebServer(ctx, cfg) {
|
|||||||
const leaveTray = renamed || pendingQuit;
|
const leaveTray = renamed || pendingQuit;
|
||||||
if (complete) reapply.markPatchesApplied();
|
if (complete) reapply.markPatchesApplied();
|
||||||
if (leaveTray) bootFullQuit = true;
|
if (leaveTray) bootFullQuit = true;
|
||||||
const shouldRestart = complete;
|
const sealedNow = core.desktopAsarStillSealed();
|
||||||
|
const shouldRestart = applyShouldRestart({
|
||||||
|
complete,
|
||||||
|
sealed: sealedNow,
|
||||||
|
appliedCount: summary.applied,
|
||||||
|
});
|
||||||
|
if (shouldRestart) reapply.markSettleRestart();
|
||||||
sendJson(response, 200, {
|
sendJson(response, 200, {
|
||||||
ok: true,
|
ok: true,
|
||||||
complete,
|
complete,
|
||||||
@@ -1447,8 +1541,8 @@ function installWebServer(ctx, cfg) {
|
|||||||
restart_after_apply: shouldRestart,
|
restart_after_apply: shouldRestart,
|
||||||
unpacked_asar: leaveTray,
|
unpacked_asar: leaveTray,
|
||||||
needs_full_quit: leaveTray,
|
needs_full_quit: leaveTray,
|
||||||
asar_still_sealed: core.desktopAsarStillSealed(),
|
asar_still_sealed: sealedNow,
|
||||||
asar_swap_started: Boolean(shouldRestart && handoff && core.desktopAsarStillSealed()),
|
asar_swap_started: Boolean(shouldRestart && handoff && sealedNow),
|
||||||
applied: summary.applied,
|
applied: summary.applied,
|
||||||
already: summary.already,
|
already: summary.already,
|
||||||
failed: summary.failed.length,
|
failed: summary.failed.length,
|
||||||
@@ -1468,7 +1562,7 @@ function installWebServer(ctx, cfg) {
|
|||||||
cli_repair: cliRepair,
|
cli_repair: cliRepair,
|
||||||
cmd_flash: flash,
|
cmd_flash: flash,
|
||||||
});
|
});
|
||||||
if (shouldRestart && handoff && core.desktopAsarStillSealed()) {
|
if (shouldRestart && handoff && sealedNow) {
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
try {
|
try {
|
||||||
core.restartSealedDesktopIfNeeded();
|
core.restartSealedDesktopIfNeeded();
|
||||||
@@ -1542,6 +1636,7 @@ function installWebServer(ctx, cfg) {
|
|||||||
if (request.method === "GET") {
|
if (request.method === "GET") {
|
||||||
try {
|
try {
|
||||||
const home = core.findDshHome();
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
|
||||||
const ui = await core.readOverrideForUi(home);
|
const ui = await core.readOverrideForUi(home);
|
||||||
sendJson(response, 200, { ok: true, ...ui, ...injectSnapshot(home) });
|
sendJson(response, 200, { ok: true, ...ui, ...injectSnapshot(home) });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/** 官方桌面启动时 Fiber._reload 还在挂 desktop-office,settle 不得解包/杀进程。 */
|
||||||
|
|
||||||
|
export const DESKTOP_SETTLE_DELAY_MS = 4000;
|
||||||
|
|
||||||
|
export function isInactiveContextError(error) {
|
||||||
|
if (!error) return false;
|
||||||
|
if (error.code === "INACTIVE_EFFECT") return true;
|
||||||
|
return /inactive context/i.test(String(error.message || error));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function watchContextLife(ctx) {
|
||||||
|
const life = { alive: true };
|
||||||
|
if (!ctx || typeof ctx.effect !== "function") return life;
|
||||||
|
try {
|
||||||
|
ctx.effect(() => () => {
|
||||||
|
life.alive = false;
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (isInactiveContextError(error)) {
|
||||||
|
life.alive = false;
|
||||||
|
return life;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return life;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function settleDelayMs(surface) {
|
||||||
|
return surface === "desktop" ? DESKTOP_SETTLE_DELAY_MS : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 桌面启动自愈不得 requestRestart / taskkill,否则 Cordis 会 INACTIVE_EFFECT。 */
|
||||||
|
export function settleMayRestart({ surface, sealed = false } = {}) {
|
||||||
|
if (surface === "desktop") return false;
|
||||||
|
if (sealed) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 密封 asar 上就地 extract/swap 会和官方 Host 的 Fiber._reload 抢锁。 */
|
||||||
|
export function settleMayReapply({ surface, sealed = false } = {}) {
|
||||||
|
if (surface === "desktop" && sealed) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点「应用」后是否重启:密封 asar 还要换包就重启;否则只在这次真的写了宿主补丁时重启。
|
||||||
|
* 冷却不放在这里——否则第一次重启没换掉 asar,第二次应用会被当成取消。
|
||||||
|
*/
|
||||||
|
export function applyShouldRestart({
|
||||||
|
complete = false,
|
||||||
|
sealed = false,
|
||||||
|
appliedCount = 0,
|
||||||
|
} = {}) {
|
||||||
|
if (!complete) return false;
|
||||||
|
if (sealed) return true;
|
||||||
|
return Number(appliedCount) > 0;
|
||||||
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-purge",
|
"name": "dsh-purge",
|
||||||
"version": "1.1.53",
|
"version": "1.1.55",
|
||||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
|||||||
@@ -1,3 +1,35 @@
|
|||||||
|
# 1.1.55
|
||||||
|
|
||||||
|
## 中文
|
||||||
|
|
||||||
|
- 版本升级到 1.1.55。
|
||||||
|
- 点「应用」并重启后,每一轮 assemble 都会把提示词补回最前;宿主换成新 assemble 也会再包一次,不会第二轮丢掉。
|
||||||
|
- 空框不再在前端误取消应用;重启前先落下默认提示词。密封 asar 不会因为当前进程还是旧包而取消重启。
|
||||||
|
- 第二次应用不会因为冷却把重启/注入当成取消;密封包在换掉之前每次应用都会重启一次,补丁写完后不再空转。
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
- Version 1.1.55.
|
||||||
|
- After Apply + restart, every assemble turn puts the operator prompt back at the front. If the host replaces assemble, it is wrapped again so turn 2 does not drop the inject.
|
||||||
|
- An empty settings box no longer cancels Apply on the client; Restart seeds the default prompt first. A sealed asar no longer cancels restart just because the running process still has the old archive.
|
||||||
|
- A second Apply is not treated as a cancel because of settle cooldown. A sealed archive still restarts on each Apply until swapped; after patches are in, it does not loop.
|
||||||
|
|
||||||
|
# 1.1.54
|
||||||
|
|
||||||
|
## 中文
|
||||||
|
|
||||||
|
- 版本升级到 1.1.54。
|
||||||
|
- 官方桌面密封 asar 启动不再中途解包/杀进程:避开 Host Fiber._reload 的 INACTIVE_EFFECT / DesktopHostFatalError;补丁留给设置页「应用」。
|
||||||
|
- 桌面 settle 延后并在 context 停用时退出;启动自愈只写盘、不 scheduleRestart(#59 / #60 / #61)。
|
||||||
|
- 市场 tar 安装与空 sha / 缺 installed-rev 的无限重启修复仍在(#58–#61,1.1.53)。
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
- Version 1.1.54.
|
||||||
|
- Official desktop no longer unpacks or kills the host mid-boot on a sealed asar; that raced Fiber._reload and threw INACTIVE_EFFECT / DesktopHostFatalError. Patches wait for Settings Apply.
|
||||||
|
- Desktop settle is delayed and aborts on an inactive context; startup self-heal writes files only and does not scheduleRestart (#59 / #60 / #61).
|
||||||
|
- Marketplace tarball install and empty-sha / missing installed-rev restart loops remain fixed (#58–#61, 1.1.53).
|
||||||
|
|
||||||
# 1.1.53
|
# 1.1.53
|
||||||
|
|
||||||
## 中文
|
## 中文
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
import assert from "node:assert/strict";
|
|
||||||
import fs from "node:fs";
|
|
||||||
import os from "node:os";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-purge-stamp-"));
|
|
||||||
process.env.DSH_HOME = tmp;
|
|
||||||
|
|
||||||
const {
|
|
||||||
stampMatches,
|
|
||||||
resolveApplySha,
|
|
||||||
markPatchesApplied,
|
|
||||||
readAppliedStamp,
|
|
||||||
healEmptyAppliedStamp,
|
|
||||||
ensureInstalledRevSeed,
|
|
||||||
shouldSkipSettleRestart,
|
|
||||||
markSettleRestart,
|
|
||||||
canHealEmptyStamp,
|
|
||||||
} = await import("../lib/reapply.js");
|
|
||||||
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "" }, "1.1.52", "abc"), false);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "abc"), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", ""), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "apply:1.1.52" }, "1.1.52", "deadbeef"), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "def"), false);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.51", sha: "abc" }, "1.1.52", "abc"), false);
|
|
||||||
|
|
||||||
// #56:空 sha 仍不能当对齐;#57:密封/缺标记不能就地补戳。
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: true, hasAiBase: true, markersPresent: true }), false);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: false }), false);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: true }), true);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: false, markersPresent: false }), true);
|
|
||||||
|
|
||||||
assert.equal(resolveApplySha("deadbeef"), "deadbeef");
|
|
||||||
assert.match(resolveApplySha(""), /^(apply:|applied)/);
|
|
||||||
|
|
||||||
const sha = markPatchesApplied();
|
|
||||||
assert.ok(sha);
|
|
||||||
assert.ok(sha.length > 0);
|
|
||||||
const stamp = readAppliedStamp();
|
|
||||||
assert.equal(stamp.sha, sha);
|
|
||||||
assert.ok(stamp.sha);
|
|
||||||
const revFile = path.join(tmp, "dsh-purge", "installed-rev");
|
|
||||||
assert.equal(fs.readFileSync(revFile, "utf8").trim(), sha);
|
|
||||||
assert.equal(stampMatches(stamp, stamp.version, sha), true);
|
|
||||||
|
|
||||||
fs.writeFileSync(path.join(tmp, "dsh-purge", "applied.json"), `${JSON.stringify({
|
|
||||||
version: stamp.version,
|
|
||||||
sha: "",
|
|
||||||
at: new Date().toISOString(),
|
|
||||||
}, null, 2)}\n`);
|
|
||||||
assert.equal(healEmptyAppliedStamp(), true);
|
|
||||||
assert.ok(readAppliedStamp().sha);
|
|
||||||
|
|
||||||
// #60:缺 installed-rev 时种子
|
|
||||||
fs.rmSync(path.join(tmp, "dsh-purge", "installed-rev"), { force: true });
|
|
||||||
const seeded = ensureInstalledRevSeed();
|
|
||||||
assert.ok(seeded);
|
|
||||||
assert.equal(fs.readFileSync(path.join(tmp, "dsh-purge", "installed-rev"), "utf8").trim(), seeded);
|
|
||||||
|
|
||||||
assert.equal(shouldSkipSettleRestart(), false);
|
|
||||||
markSettleRestart();
|
|
||||||
assert.equal(shouldSkipSettleRestart(), true);
|
|
||||||
|
|
||||||
console.log("ok: reapply stamp / infinite-restart guards");
|
|
||||||
Reference in new issue
Block a user