mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 10:50:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce5e381ab8 |
No files matched your search
@@ -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.52</strong></p>
|
<p align="center"><strong>Version 1.1.53</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.52**. 1.1.45 is skipped; it has bugs.
|
The plugin version is **1.1.53**. 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.52&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.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>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
🔗 **Raw protocol URL:**
|
🔗 **Raw protocol URL:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.52&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.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
|
||||||
```
|
```
|
||||||
|
|
||||||
<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.52',
|
version: '1.1.53',
|
||||||
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.52&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.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">
|
||||||
🚀 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.52` | Semver |
|
| version | `1.1.53` | 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.52</strong></p>
|
<p align="center"><strong>Version 1.1.53</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.52**。1.1.45 有问题,略过。
|
插件版本是 **1.1.53**。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.52&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.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>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
🔗 **原生协议链接:**
|
🔗 **原生协议链接:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.52&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.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
|
||||||
```
|
```
|
||||||
|
|
||||||
<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.52',
|
version: '1.1.53',
|
||||||
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.52&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.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>
|
</a>
|
||||||
```
|
```
|
||||||
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | 插件唯一标识符 |
|
| id | `dsh-purge` | 插件唯一标识符 |
|
||||||
| name | `dsh-purge` | 插件展示名称 |
|
| name | `dsh-purge` | 插件展示名称 |
|
||||||
| version | `1.1.52` | 语义化版本号 |
|
| version | `1.1.53` | 语义化版本号 |
|
||||||
| 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 源码包地址 |
|
||||||
|
|||||||
+1
-1
@@ -1045,7 +1045,7 @@ function dshHomeForRelaunch() {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scheduleRestart(request, ctx) {
|
export function scheduleRestart(request, ctx, _options = {}) {
|
||||||
const exe =
|
const exe =
|
||||||
officialExeFromProcess() ||
|
officialExeFromProcess() ||
|
||||||
findDesktopAppExecutable() ||
|
findDesktopAppExecutable() ||
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ export function hostAdapter(kind = detectSurface()) {
|
|||||||
return ADAPTERS[adapterFor(kind)] || web;
|
return ADAPTERS[adapterFor(kind)] || web;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scheduleRestart(request, ctx) {
|
export function scheduleRestart(request, ctx, options = {}) {
|
||||||
return hostAdapter().scheduleRestart(request, ctx);
|
return hostAdapter().scheduleRestart(request, ctx, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scheduleCleanupRestart(opts) {
|
export function scheduleCleanupRestart(opts) {
|
||||||
|
|||||||
+49
-18
@@ -393,43 +393,74 @@ function shimNeedsPatch(state) {
|
|||||||
|
|
||||||
async function settleInstalledPatches(config, ctx) {
|
async function settleInstalledPatches(config, ctx) {
|
||||||
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
||||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
try {
|
||||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
reapply.ensureInstalledRevSeed();
|
||||||
if (!upgraded.ok) {
|
} catch (e) {
|
||||||
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
log(config, "seed installed-rev failed:", String(e && e.message ? e.message : e));
|
||||||
return "reapply-failed";
|
|
||||||
}
|
|
||||||
officialUpdate.clearUpgradeMarker(process.execPath);
|
|
||||||
officialUpdate.clearStaleExtractedApps(process.execPath);
|
|
||||||
log(config, "official upgrade reapplied; restarting onto the new build");
|
|
||||||
try {
|
|
||||||
hostctl.scheduleRestart(null, ctx);
|
|
||||||
} catch (e) {
|
|
||||||
log(config, "restart after official upgrade failed:", String(e && e.message ? e.message : e));
|
|
||||||
return "restart-failed";
|
|
||||||
}
|
|
||||||
return "restarting";
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (reapply.healEmptyAppliedStamp()) log(config, "healed empty applied stamp");
|
||||||
|
} catch (e) {
|
||||||
|
log(config, "heal applied stamp failed:", String(e && e.message ? e.message : e));
|
||||||
|
}
|
||||||
|
|
||||||
if (!reapply.patchesMatchInstall()) {
|
if (!reapply.patchesMatchInstall()) {
|
||||||
|
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||||
|
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
||||||
|
if (!upgraded.ok) {
|
||||||
|
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
||||||
|
return "reapply-failed";
|
||||||
|
}
|
||||||
|
officialUpdate.clearUpgradeMarker(process.execPath);
|
||||||
|
officialUpdate.clearStaleExtractedApps(process.execPath);
|
||||||
|
if (reapply.shouldSkipSettleRestart()) {
|
||||||
|
log(config, "official upgrade reapplied; skip settle restart (cooldown)");
|
||||||
|
return "reapplied-no-restart";
|
||||||
|
}
|
||||||
|
reapply.markSettleRestart();
|
||||||
|
log(config, "official upgrade reapplied; restarting onto the new build");
|
||||||
|
try {
|
||||||
|
hostctl.scheduleRestart(null, ctx, { openBrowser: false });
|
||||||
|
} catch (e) {
|
||||||
|
log(config, "restart after official upgrade failed:", String(e && e.message ? e.message : e));
|
||||||
|
return "restart-failed";
|
||||||
|
}
|
||||||
|
return "restarting";
|
||||||
|
}
|
||||||
|
|
||||||
const result = await reapply.reapplyInstalled();
|
const result = await reapply.reapplyInstalled();
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
log(config, "reapply failed:", result.error || "");
|
log(config, "reapply failed:", result.error || "");
|
||||||
return "reapply-failed";
|
return "reapply-failed";
|
||||||
}
|
}
|
||||||
|
// reapply 成功后强制保证非空戳,避免 clean 路径漏写又空转(#59/#60)。
|
||||||
|
try { reapply.markPatchesApplied(); } catch { /* ignore */ }
|
||||||
if (result.needsFullQuit) {
|
if (result.needsFullQuit) {
|
||||||
bootFullQuit = true;
|
bootFullQuit = true;
|
||||||
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 (reapply.shouldSkipSettleRestart()) {
|
||||||
|
log(config, "reapply wrote patches; skip settle restart (cooldown)");
|
||||||
|
return "reapplied-no-restart";
|
||||||
|
}
|
||||||
|
// 已对齐则不必再重启;只在 stamp/宿主仍不一致时重启一次。
|
||||||
|
if (reapply.patchesMatchInstall()) {
|
||||||
|
log(config, "reapply wrote patches; already aligned, no restart");
|
||||||
|
return "reapplied";
|
||||||
|
}
|
||||||
|
reapply.markSettleRestart();
|
||||||
log(config, "reapply wrote patches; restarting");
|
log(config, "reapply wrote patches; restarting");
|
||||||
try {
|
try {
|
||||||
hostctl.scheduleRestart(null, ctx);
|
// web:自愈重启不弹浏览器,关窗后不应再被反复拉起新窗口(#59/#61)。
|
||||||
|
hostctl.scheduleRestart(null, ctx, { openBrowser: false });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(config, "restart after reapply failed:", String(e && e.message ? e.message : e));
|
log(config, "restart after reapply failed:", String(e && e.message ? e.message : e));
|
||||||
return "restart-failed";
|
return "restart-failed";
|
||||||
}
|
}
|
||||||
return "restarting";
|
return "restarting";
|
||||||
}
|
}
|
||||||
|
|
||||||
const applied = await autoApply(config);
|
const applied = await autoApply(config);
|
||||||
if (config.autoUpdateOnStart === true) {
|
if (config.autoUpdateOnStart === true) {
|
||||||
updater.autoUpdateIfNeeded()
|
updater.autoUpdateIfNeeded()
|
||||||
@@ -437,7 +468,7 @@ async function settleInstalledPatches(config, ctx) {
|
|||||||
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) {
|
||||||
try { hostctl.scheduleRestart(null, ctx); } 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+146
-19
@@ -14,9 +14,13 @@ function pluginVersion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function installedRevPath() {
|
||||||
|
return path.join(core.findDshHome(), "dsh-purge", "installed-rev");
|
||||||
|
}
|
||||||
|
|
||||||
function installedRev() {
|
function installedRev() {
|
||||||
try {
|
try {
|
||||||
return fs.readFileSync(path.join(core.findDshHome(), "dsh-purge", "installed-rev"), "utf8").trim();
|
return fs.readFileSync(installedRevPath(), "utf8").trim();
|
||||||
} catch {
|
} catch {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -26,6 +30,10 @@ function appliedStampPath() {
|
|||||||
return path.join(core.findDshHome(), "dsh-purge", "applied.json");
|
return path.join(core.findDshHome(), "dsh-purge", "applied.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function settleGuardPath() {
|
||||||
|
return path.join(core.findDshHome(), "dsh-purge", "settle-restart.guard");
|
||||||
|
}
|
||||||
|
|
||||||
export function readAppliedStamp() {
|
export function readAppliedStamp() {
|
||||||
try {
|
try {
|
||||||
const raw = JSON.parse(fs.readFileSync(appliedStampPath(), "utf8"));
|
const raw = JSON.parse(fs.readFileSync(appliedStampPath(), "utf8"));
|
||||||
@@ -43,16 +51,56 @@ function sameRev(a, b) {
|
|||||||
return a === b || a.startsWith(b) || b.startsWith(a);
|
return a === b || a.startsWith(b) || b.startsWith(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isApplyPlaceholder(sha) {
|
||||||
|
const text = String(sha || "");
|
||||||
|
return text.startsWith("apply:") || text === "applied";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 手动应用未必写过 installed-rev;空 sha 会让 settle 永远判未对齐并无限重启。 */
|
||||||
|
export function resolveApplySha(explicit) {
|
||||||
|
const wanted = String(explicit == null ? "" : explicit).trim();
|
||||||
|
if (wanted) return wanted;
|
||||||
|
const rev = installedRev();
|
||||||
|
if (rev) return rev;
|
||||||
|
const ver = pluginVersion();
|
||||||
|
return ver ? `apply:${ver}` : "applied";
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeInstalledRev(sha) {
|
||||||
|
const value = String(sha || "").trim();
|
||||||
|
if (!value) return;
|
||||||
|
const fp = installedRevPath();
|
||||||
|
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||||
|
fs.writeFileSync(fp, `${value}\n`, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeAppliedStamp(sha) {
|
||||||
|
const fp = appliedStampPath();
|
||||||
|
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||||
|
fs.writeFileSync(fp, `${JSON.stringify({
|
||||||
|
version: pluginVersion(),
|
||||||
|
sha: String(sha || "").trim(),
|
||||||
|
at: new Date().toISOString(),
|
||||||
|
}, null, 2)}\n`, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
/** 当前插件版本和已写入补丁的版本一致时,启动不必再还原重打。 */
|
/** 当前插件版本和已写入补丁的版本一致时,启动不必再还原重打。 */
|
||||||
export function stampMatches(stamp, version, rev) {
|
export function stampMatches(stamp, version, rev) {
|
||||||
if (!stamp || !stamp.version || stamp.version !== version) return false;
|
if (!stamp || !stamp.version || stamp.version !== version) return false;
|
||||||
// sha 为空表示 stamp 不完整(曾误写空串),不能当作已对齐(#56)。
|
// sha 为空表示 stamp 不完整(曾误写空串),不能当作已对齐(#56)。
|
||||||
if (!stamp.sha) return false;
|
if (!stamp.sha) return false;
|
||||||
if (rev && !sameRev(rev, stamp.sha)) return false;
|
const current = String(rev || "").trim();
|
||||||
|
if (!current) return true;
|
||||||
|
// 手动应用占位戳与后续 git rev 并存时,只认 version,避免再空转重启。
|
||||||
|
if (isApplyPlaceholder(stamp.sha) || isApplyPlaceholder(current)) return true;
|
||||||
|
if (!sameRev(current, stamp.sha)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** stamp 对上了,但宿主被官方更新打回 sealed / 找不到插件根时仍算未对齐(#57)。 */
|
/**
|
||||||
|
* stamp 对上了,但宿主被官方更新打回 sealed / 清洗标记没了时仍算未对齐(#57)。
|
||||||
|
* 找不到插件根(web 启动早期、纯 CLI)不等于补丁丢失,否则会无限重打+重启(#59)。
|
||||||
|
*/
|
||||||
export function hostStillHasAppliedPatches() {
|
export function hostStillHasAppliedPatches() {
|
||||||
try {
|
try {
|
||||||
if (core.desktopAsarStillSealed()) return false;
|
if (core.desktopAsarStillSealed()) return false;
|
||||||
@@ -60,10 +108,18 @@ export function hostStillHasAppliedPatches() {
|
|||||||
/* 非桌面面 */
|
/* 非桌面面 */
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!core.findAiBase()) return false;
|
const aiBase = core.findAiBase();
|
||||||
|
if (!aiBase) return true;
|
||||||
|
return core.hostCleanMarkersPresent(aiBase);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 空 sha 只有在「不是密封、也不是明确缺标记」时才允许就地补戳。 */
|
||||||
|
export function canHealEmptyStamp({ sealed = false, hasAiBase = false, markersPresent = false } = {}) {
|
||||||
|
if (sealed) return false;
|
||||||
|
if (hasAiBase && !markersPresent) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,26 +128,97 @@ export function patchesMatchInstall() {
|
|||||||
return hostStillHasAppliedPatches();
|
return hostStillHasAppliedPatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 有 applied 戳但宿主已密封/丢根:面板提示「补丁已丢失」。 */
|
/** 有 applied 戳但宿主已回到密封 asar / 清洗标记没了:面板提示「补丁已丢失」(#57)。找不到根不算丢失。 */
|
||||||
export function patchesLostAfterHostReset() {
|
export function patchesLostAfterHostReset() {
|
||||||
const stamp = readAppliedStamp();
|
const stamp = readAppliedStamp();
|
||||||
if (!stamp?.version || !stamp?.sha) return false;
|
if (!stamp?.version || !stamp?.sha) return false;
|
||||||
return !hostStillHasAppliedPatches();
|
try {
|
||||||
}
|
if (core.desktopAsarStillSealed()) return true;
|
||||||
|
} catch {
|
||||||
function writeAppliedStamp(sha) {
|
/* 非桌面面 */
|
||||||
const fp = appliedStampPath();
|
}
|
||||||
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
try {
|
||||||
fs.writeFileSync(fp, `${JSON.stringify({
|
const aiBase = core.findAiBase();
|
||||||
version: pluginVersion(),
|
if (aiBase && !core.hostCleanMarkersPresent(aiBase)) return true;
|
||||||
sha: sha || "",
|
} catch {
|
||||||
at: new Date().toISOString(),
|
/* ignore */
|
||||||
}, null, 2)}\n`, "utf8");
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 手动「应用」成功后也要打戳,否则重启后 settle 会以为补丁未对齐再要求重启。 */
|
/** 手动「应用」成功后也要打戳,否则重启后 settle 会以为补丁未对齐再要求重启。 */
|
||||||
export function markPatchesApplied(sha) {
|
export function markPatchesApplied(sha) {
|
||||||
writeAppliedStamp(sha == null ? installedRev() : sha);
|
const resolved = resolveApplySha(sha);
|
||||||
|
const current = installedRev();
|
||||||
|
// 已有更新通道写入的 git rev 时沿用;否则用 resolve 结果(含 apply:version 占位)。
|
||||||
|
const finalSha = current && !isApplyPlaceholder(current) ? current : resolved;
|
||||||
|
writeInstalledRev(finalSha);
|
||||||
|
writeAppliedStamp(finalSha);
|
||||||
|
return finalSha;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #59/#60:空 sha 或缺失 installed-rev 会让 settle 每次启动都 reapply+restart。
|
||||||
|
* 版本已对齐时先补非空戳 / 种子 rev,打断自重启;真正缺补丁再由后续逻辑重打。
|
||||||
|
*/
|
||||||
|
export function healEmptyAppliedStamp() {
|
||||||
|
const stamp = readAppliedStamp();
|
||||||
|
const version = pluginVersion();
|
||||||
|
if (!stamp || stamp.version !== version) return false;
|
||||||
|
if (stamp.sha) {
|
||||||
|
if (!installedRev()) writeInstalledRev(stamp.sha);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let sealed = false;
|
||||||
|
try { sealed = core.desktopAsarStillSealed(); } catch { /* ignore */ }
|
||||||
|
let hasAiBase = false;
|
||||||
|
let markersPresent = false;
|
||||||
|
try {
|
||||||
|
const aiBase = core.findAiBase();
|
||||||
|
hasAiBase = Boolean(aiBase);
|
||||||
|
markersPresent = Boolean(aiBase && core.hostCleanMarkersPresent(aiBase));
|
||||||
|
} catch {
|
||||||
|
/* 根还没定位 */
|
||||||
|
}
|
||||||
|
// 密封或明确没打上清洗标记:不能补戳装成已对齐,否则 #57 不再自愈。
|
||||||
|
if (!canHealEmptyStamp({ sealed, hasAiBase, markersPresent })) return false;
|
||||||
|
markPatchesApplied();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 安装后还没有 installed-rev 时先落盘占位(tarball / 手动应用常见)。 */
|
||||||
|
export function ensureInstalledRevSeed() {
|
||||||
|
const current = installedRev();
|
||||||
|
if (current) return current;
|
||||||
|
const stamp = readAppliedStamp();
|
||||||
|
if (stamp?.sha) {
|
||||||
|
writeInstalledRev(stamp.sha);
|
||||||
|
return stamp.sha;
|
||||||
|
}
|
||||||
|
const sha = resolveApplySha();
|
||||||
|
writeInstalledRev(sha);
|
||||||
|
return sha;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** settle 刚重启过则冷却,防止「重打→重启→再重打」打成死循环。 */
|
||||||
|
export function shouldSkipSettleRestart(windowMs = 180000) {
|
||||||
|
try {
|
||||||
|
const raw = JSON.parse(fs.readFileSync(settleGuardPath(), "utf8"));
|
||||||
|
if (String(raw.version || "") !== pluginVersion()) return false;
|
||||||
|
const at = Date.parse(String(raw.at || "")) || 0;
|
||||||
|
return at > 0 && Date.now() - at < windowMs;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function markSettleRestart() {
|
||||||
|
const fp = settleGuardPath();
|
||||||
|
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||||
|
fs.writeFileSync(fp, `${JSON.stringify({
|
||||||
|
version: pluginVersion(),
|
||||||
|
at: new Date().toISOString(),
|
||||||
|
}, null, 2)}\n`, "utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +275,7 @@ export async function reapplyInstalled(options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (clean) {
|
if (clean) {
|
||||||
writeAppliedStamp(installedRev());
|
markPatchesApplied(installedRev() || undefined);
|
||||||
if (freshExtract?.archive) core.writeUnpackedAsarStamp(freshExtract.archive);
|
if (freshExtract?.archive) core.writeUnpackedAsarStamp(freshExtract.archive);
|
||||||
}
|
}
|
||||||
let renamed = false;
|
let renamed = false;
|
||||||
|
|||||||
+10
-3
@@ -77,20 +77,27 @@ const child = spawn(info.execPath, info.argv, {
|
|||||||
shell: false,
|
shell: false,
|
||||||
});
|
});
|
||||||
child.on("error", () => process.exit(1));
|
child.on("error", () => process.exit(1));
|
||||||
|
const wantBrowser = info.openBrowser !== false;
|
||||||
const takeUrl = (chunk) => {
|
const takeUrl = (chunk) => {
|
||||||
const text = String(chunk || "");
|
const text = String(chunk || "");
|
||||||
if (opened) return;
|
if (opened) return;
|
||||||
const match = text.match(/dsh web:\s+(https?:\/\/\S+)/);
|
const match = text.match(/dsh web:\s+(https?:\/\/\S+)/);
|
||||||
if (!match) return;
|
if (!match) return;
|
||||||
opened = true;
|
opened = true;
|
||||||
|
if (!wantBrowser) return;
|
||||||
const url = match[1].replace(/[),.;]+$/, "");
|
const url = match[1].replace(/[),.;]+$/, "");
|
||||||
openBrowser(url);
|
openBrowser(url);
|
||||||
};
|
};
|
||||||
child.stdout?.on("data", takeUrl);
|
child.stdout?.on("data", takeUrl);
|
||||||
child.stderr?.on("data", takeUrl);
|
child.stderr?.on("data", takeUrl);
|
||||||
child.unref();
|
child.unref();
|
||||||
const started = Date.now();
|
if (wantBrowser) {
|
||||||
while (!opened && Date.now() - started < 20000) {
|
const started = Date.now();
|
||||||
await new Promise((r) => setTimeout(r, 200));
|
while (!opened && Date.now() - started < 20000) {
|
||||||
|
await new Promise((r) => setTimeout(r, 200));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 等子进程真正起来再退出,避免端口未监听时父链误判失败又拉一把。
|
||||||
|
await new Promise((r) => setTimeout(r, 1500));
|
||||||
}
|
}
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
+10
-1
@@ -68,7 +68,14 @@ function spawnRestartHelper(helper, payload, exitAfter = 250) {
|
|||||||
setTimeout(() => process.exit(0), exitAfter);
|
setTimeout(() => process.exit(0), exitAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scheduleRestart(request) {
|
/**
|
||||||
|
* @param {object} [request]
|
||||||
|
* @param {unknown} [_ctx]
|
||||||
|
* @param {{ openBrowser?: boolean }} [options]
|
||||||
|
* settle / 自愈重启传 request=null → 默认不弹浏览器,避免关窗后仍被反复拉起新窗口(#59/#61)。
|
||||||
|
*/
|
||||||
|
export function scheduleRestart(request, _ctx, options = {}) {
|
||||||
|
const openBrowser = options.openBrowser ?? (request != null);
|
||||||
const helper = fileURLToPath(new URL("./restart-web.js", import.meta.url));
|
const helper = fileURLToPath(new URL("./restart-web.js", import.meta.url));
|
||||||
spawnRestartHelper(helper, {
|
spawnRestartHelper(helper, {
|
||||||
kind: "web",
|
kind: "web",
|
||||||
@@ -78,6 +85,7 @@ export function scheduleRestart(request) {
|
|||||||
host: hostFromRequest(request),
|
host: hostFromRequest(request),
|
||||||
port: portFromRequest(request),
|
port: portFromRequest(request),
|
||||||
pid: process.pid,
|
pid: process.pid,
|
||||||
|
openBrowser: openBrowser !== false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,5 +102,6 @@ export function scheduleCleanupRestart({ request, restartArgv: argv, cleanup = [
|
|||||||
port: portFromRequest(request),
|
port: portFromRequest(request),
|
||||||
cleanup,
|
cleanup,
|
||||||
helper: dest,
|
helper: dest,
|
||||||
|
openBrowser: request != null,
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
+10
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-purge",
|
"name": "dsh-purge",
|
||||||
"version": "1.1.52",
|
"version": "1.1.53",
|
||||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@@ -74,8 +74,17 @@
|
|||||||
"@deepseek-ai/dsh-client-ui-slots",
|
"@deepseek-ai/dsh-client-ui-slots",
|
||||||
"@deepseek-ai/dsh-client-ui-settings"
|
"@deepseek-ai/dsh-client-ui-settings"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"install": {
|
||||||
|
"preferred": "tarball",
|
||||||
|
"tarball": "https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz",
|
||||||
|
"zip": "https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.zip",
|
||||||
|
"git": "https://github.com/YuJunZhiXue/dsh-purge.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@deepseek-ai/cordis": "^4.0.1"
|
"@deepseek-ai/cordis": "^4.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
# 1.1.53
|
||||||
|
|
||||||
|
## 中文
|
||||||
|
|
||||||
|
- 版本升级到 1.1.53。
|
||||||
|
- 修复点「应用」后无限重启(#59 / #60 / #61):tarball 安装没有 `installed-rev`、或 `applied.json` 空 sha 时,启动不再反复 reapply+restart;对齐后不再空转重启,并加冷却。
|
||||||
|
- web 自愈重启不再自动弹浏览器,关窗后不会再被反复拉起新窗口(#59 / #61)。
|
||||||
|
- 空 sha 只在非密封、且清洗标记还在(或找不到插件根)时补戳,避免冲掉密封宿主自愈(#56 / #57)。
|
||||||
|
- 市场安装:`package.json` 标明优先 tar.gz/zip,避免 Hub 退回 `git ls-remote` 失败(#58)。
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
- Version 1.1.53.
|
||||||
|
- Stop Apply/startup infinite restart (#59 / #60 / #61): missing `installed-rev` after tarball install or empty `applied.json` sha no longer reapply+restart every boot; skip restart once aligned, with a cooldown.
|
||||||
|
- Web self-heal restart does not open a browser, so closing the window no longer respawns tabs (#59 / #61).
|
||||||
|
- Empty-sha heal only runs when the host is not sealed and markers are present (or the plugin root is missing), so sealed-host self-heal still works (#56 / #57).
|
||||||
|
- Marketplace install prefers tar.gz/zip in `package.json` so Hub does not fall back to a failing `git ls-remote` (#58).
|
||||||
|
|
||||||
# 1.1.52
|
# 1.1.52
|
||||||
|
|
||||||
## 中文
|
## 中文
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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