mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 12:40:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bed650680 |
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.17</strong></p>
|
<p align="center"><strong>Version 1.1.18</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Evaluate and adjust host safety policy on a controlled local install; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Evaluate and adjust host safety policy on a controlled local install; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
||||||
@@ -197,13 +197,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.17&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.18&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.17&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.18&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>
|
||||||
@@ -219,7 +219,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.17',
|
version: '1.1.18',
|
||||||
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',
|
||||||
@@ -238,7 +238,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML link:**
|
**HTML link:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.17&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.18&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>
|
||||||
```
|
```
|
||||||
@@ -249,7 +249,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.17` | Semver |
|
| version | `1.1.18` | 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 |
|
||||||
|
|||||||
+6
-6
@@ -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.17</strong></p>
|
<p align="center"><strong>Version 1.1.18</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。在受控本机里评测并调整宿主安全策略,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。在受控本机里评测并调整宿主安全策略,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||||
@@ -197,13 +197,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.17&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.18&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.17&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.18&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>
|
||||||
@@ -219,7 +219,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.17',
|
version: '1.1.18',
|
||||||
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',
|
||||||
@@ -238,7 +238,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML 静态链接方式:**
|
**HTML 静态链接方式:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.17&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.18&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>
|
||||||
```
|
```
|
||||||
@@ -249,7 +249,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | 插件唯一标识符 |
|
| id | `dsh-purge` | 插件唯一标识符 |
|
||||||
| name | `dsh-purge` | 插件展示名称 |
|
| name | `dsh-purge` | 插件展示名称 |
|
||||||
| version | `1.1.17` | 语义化版本号 |
|
| version | `1.1.18` | 语义化版本号 |
|
||||||
| 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 源码包地址 |
|
||||||
|
|||||||
@@ -1979,9 +1979,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reopenAfterRestart() {
|
function reopenAfterRestart() {
|
||||||
const url = new URL(window.location.href);
|
window.location.reload();
|
||||||
url.searchParams.delete("token");
|
|
||||||
window.location.replace(url.pathname + url.search + url.hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForRestart(setNotice, setBusy, t) {
|
function waitForRestart(setNotice, setBusy, t) {
|
||||||
|
|||||||
+72
-6
@@ -3406,8 +3406,65 @@ export function sanitizeYamlPersonaScalars(text) {
|
|||||||
return crlf ? out.replace(/\n/g, "\r\n") : out;
|
return crlf ? out.replace(/\n/g, "\r\n") : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function legacyApplyPathStarts(text) {
|
||||||
|
const hay = asLf(text);
|
||||||
|
const key = "function legacyApplyPath(section, op) {";
|
||||||
|
let count = 0;
|
||||||
|
let from = 0;
|
||||||
|
while (from < hay.length) {
|
||||||
|
const at = hay.indexOf(key, from);
|
||||||
|
if (at < 0) break;
|
||||||
|
count += 1;
|
||||||
|
from = at + key.length;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function endOfBalancedBlock(text, openAt) {
|
||||||
|
let depth = 0;
|
||||||
|
for (let i = openAt; i < text.length; i += 1) {
|
||||||
|
const ch = text[i];
|
||||||
|
if (ch === "{") depth += 1;
|
||||||
|
else if (ch === "}") {
|
||||||
|
depth -= 1;
|
||||||
|
if (depth === 0) return i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 1.1.17 之前 #42 会叠多份 legacyApplyPath,settings 整文件语法错误、提供商目录起不来。 */
|
||||||
|
export function collapseDuplicateLegacyApplyPath(text) {
|
||||||
|
const crlf = typeof text === "string" && text.includes("\r\n");
|
||||||
|
const src = asLf(text);
|
||||||
|
const key = "function legacyApplyPath(section, op) {";
|
||||||
|
const starts = [];
|
||||||
|
let from = 0;
|
||||||
|
while (from < src.length) {
|
||||||
|
const at = src.indexOf(key, from);
|
||||||
|
if (at < 0) break;
|
||||||
|
starts.push(at);
|
||||||
|
from = at + key.length;
|
||||||
|
}
|
||||||
|
if (starts.length < 2) return text;
|
||||||
|
const firstOpen = src.indexOf("{", starts[0]);
|
||||||
|
const firstEnd = endOfBalancedBlock(src, firstOpen);
|
||||||
|
let out = src.slice(0, firstEnd);
|
||||||
|
let cursor = firstEnd;
|
||||||
|
for (let n = 1; n < starts.length; n += 1) {
|
||||||
|
const open = src.indexOf("{", starts[n]);
|
||||||
|
const end = endOfBalancedBlock(src, open);
|
||||||
|
out += src.slice(cursor, starts[n]);
|
||||||
|
cursor = end;
|
||||||
|
}
|
||||||
|
out += src.slice(cursor);
|
||||||
|
out = out.replace(/\n{3,}/g, "\n\n");
|
||||||
|
return crlf ? out.replace(/\n/g, "\r\n") : out;
|
||||||
|
}
|
||||||
|
|
||||||
function patchApplied(text, patch) {
|
function patchApplied(text, patch) {
|
||||||
const hay = asLf(text);
|
const hay = asLf(text);
|
||||||
|
if (patch?.id === 42 && legacyApplyPathStarts(hay) > 1) return false;
|
||||||
if (Array.isArray(patch.forbid) && patch.forbid.some((marker) => hay.includes(asLf(marker)))) return false;
|
if (Array.isArray(patch.forbid) && patch.forbid.some((marker) => hay.includes(asLf(marker)))) return false;
|
||||||
if (Array.isArray(patch.markers) && patch.markers.length > 0) {
|
if (Array.isArray(patch.markers) && patch.markers.length > 0) {
|
||||||
// markersAny:任一标记即可;默认要全部命中。
|
// markersAny:任一标记即可;默认要全部命中。
|
||||||
@@ -3522,13 +3579,22 @@ export function yamlJsCommentsToHash(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function applyReplacementsToText(text, patch, fp = "") {
|
export function applyReplacementsToText(text, patch, fp = "") {
|
||||||
// 插入型补丁锚点仍在,已有标记则不再 replaceAll。
|
let source = text;
|
||||||
if (patch.skipIfMarked && patchApplied(text, patch)) {
|
let preChanged = false;
|
||||||
return { text, changed: false };
|
if (patch?.id === 42) {
|
||||||
|
const collapsed = collapseDuplicateLegacyApplyPath(source);
|
||||||
|
if (collapsed !== source) {
|
||||||
|
source = collapsed;
|
||||||
|
preChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const crlf = typeof text === "string" && text.includes("\r\n");
|
// 插入型补丁锚点仍在,已有标记则不再 replaceAll。
|
||||||
|
if (patch.skipIfMarked && patchApplied(source, patch)) {
|
||||||
|
return { text: source, changed: preChanged };
|
||||||
|
}
|
||||||
|
const crlf = typeof source === "string" && source.includes("\r\n");
|
||||||
const yaml = isYamlPath(fp);
|
const yaml = isYamlPath(fp);
|
||||||
let out = asLf(text);
|
let out = asLf(source);
|
||||||
let changed = false;
|
let changed = false;
|
||||||
for (const { pattern, replace } of patchReplacements(patch)) {
|
for (const { pattern, replace } of patchReplacements(patch)) {
|
||||||
if (!pattern || typeof replace !== "string") continue;
|
if (!pattern || typeof replace !== "string") continue;
|
||||||
@@ -3554,7 +3620,7 @@ export function applyReplacementsToText(text, patch, fp = "") {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (crlf) out = out.replace(/\n/g, "\r\n");
|
if (crlf) out = out.replace(/\n/g, "\r\n");
|
||||||
return { text: out, changed };
|
return { text: out, changed: changed || preChanged };
|
||||||
}
|
}
|
||||||
|
|
||||||
function rollupPatchStatus({ applied, already, missing, notFound, lastError, keyCount, layoutSoft }) {
|
function rollupPatchStatus({ applied, already, missing, notFound, lastError, keyCount, layoutSoft }) {
|
||||||
|
|||||||
+50
-6
@@ -1,5 +1,5 @@
|
|||||||
import net from "node:net";
|
import net from "node:net";
|
||||||
import { spawn } from "node:child_process";
|
import { spawn, spawnSync } from "node:child_process";
|
||||||
import { envForDetachedSpawn } from "./core.js";
|
import { envForDetachedSpawn } from "./core.js";
|
||||||
|
|
||||||
const encoded = process.env.DSH_PURGE_RESTART;
|
const encoded = process.env.DSH_PURGE_RESTART;
|
||||||
@@ -25,8 +25,38 @@ function portFree() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function killOldServer() {
|
||||||
|
const pid = Number(info.pid);
|
||||||
|
if (!pid || pid === process.pid) return;
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
spawnSync("taskkill", ["/PID", String(pid), "/F"], { windowsHide: true, stdio: "ignore" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try { process.kill(pid, "SIGTERM"); } catch { /* already gone */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
function openBrowser(url) {
|
||||||
|
if (!url) return;
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
spawn("cmd.exe", ["/d", "/s", "/c", "start", "", url], {
|
||||||
|
detached: true,
|
||||||
|
stdio: "ignore",
|
||||||
|
windowsHide: true,
|
||||||
|
}).unref();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const opener = process.platform === "darwin" ? "open" : "xdg-open";
|
||||||
|
spawn(opener, [url], { detached: true, stdio: "ignore" }).unref();
|
||||||
|
}
|
||||||
|
|
||||||
async function waitFree() {
|
async function waitFree() {
|
||||||
for (let i = 0; i < 80; i++) {
|
for (let i = 0; i < 40; i++) {
|
||||||
|
if (await portFree()) return true;
|
||||||
|
if (i === 8) killOldServer();
|
||||||
|
await new Promise((r) => setTimeout(r, 120));
|
||||||
|
}
|
||||||
|
killOldServer();
|
||||||
|
for (let i = 0; i < 40; i++) {
|
||||||
if (await portFree()) return true;
|
if (await portFree()) return true;
|
||||||
await new Promise((r) => setTimeout(r, 120));
|
await new Promise((r) => setTimeout(r, 120));
|
||||||
}
|
}
|
||||||
@@ -36,17 +66,31 @@ async function waitFree() {
|
|||||||
const ok = await waitFree();
|
const ok = await waitFree();
|
||||||
if (!ok) process.exit(1);
|
if (!ok) process.exit(1);
|
||||||
|
|
||||||
// detached + windowsHide;shell:false 避免再走 dsh.cmd / cmd.exe。
|
// 接着 stdout 里的新地址打开浏览器。旧页面的 token 在新进程里无效,只刷新会打不开。
|
||||||
|
let opened = false;
|
||||||
const child = spawn(info.execPath, info.argv, {
|
const child = spawn(info.execPath, info.argv, {
|
||||||
detached: true,
|
detached: true,
|
||||||
stdio: "ignore",
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
cwd: info.cwd || process.cwd(),
|
cwd: info.cwd || process.cwd(),
|
||||||
env: envForDetachedSpawn(),
|
env: envForDetachedSpawn(),
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
shell: false,
|
shell: false,
|
||||||
});
|
});
|
||||||
child.on("error", () => process.exit(1));
|
child.on("error", () => process.exit(1));
|
||||||
|
const takeUrl = (chunk) => {
|
||||||
|
const text = String(chunk || "");
|
||||||
|
if (opened) return;
|
||||||
|
const match = text.match(/dsh web:\s+(https?:\/\/\S+)/);
|
||||||
|
if (!match) return;
|
||||||
|
opened = true;
|
||||||
|
const url = match[1].replace(/[),.;]+$/, "");
|
||||||
|
openBrowser(url);
|
||||||
|
};
|
||||||
|
child.stdout?.on("data", takeUrl);
|
||||||
|
child.stderr?.on("data", takeUrl);
|
||||||
child.unref();
|
child.unref();
|
||||||
// 等子进程脱离 job,避免 helper 退出时带走新进程。
|
const started = Date.now();
|
||||||
await new Promise((r) => setTimeout(r, 400));
|
while (!opened && Date.now() - started < 20000) {
|
||||||
|
await new Promise((r) => setTimeout(r, 200));
|
||||||
|
}
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
@@ -77,6 +77,7 @@ export function scheduleRestart(request) {
|
|||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
host: hostFromRequest(request),
|
host: hostFromRequest(request),
|
||||||
port: portFromRequest(request),
|
port: portFromRequest(request),
|
||||||
|
pid: process.pid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-purge",
|
"name": "dsh-purge",
|
||||||
"version": "1.1.17",
|
"version": "1.1.18",
|
||||||
"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,15 @@
|
|||||||
|
# 1.1.18
|
||||||
|
|
||||||
|
## 中文
|
||||||
|
|
||||||
|
- **重启**:点「重启」后旧页面的 token 会失效,只刷新等于打不开。现在会等端口释放(必要时结束旧进程),并按新进程打印的地址打开浏览器。请用新打开的页面,再新开一轮对话。
|
||||||
|
- **设置**:1.1.17 之前若已把 `legacyApplyPath` 叠进 `dsh-settings`,点「应用」会收成一份,提供商目录才能起来。收好之后再重启一次。
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
- **Restart**: the old page token dies with the process, so a refresh looks like restart did nothing. Restart now frees the port and opens the browser at the new `dsh web:` URL. Use that page and start a new chat.
|
||||||
|
- **Settings**: Apply collapses duplicate `legacyApplyPath` left by earlier 1.1.17 patches so `dsh-settings` can load. Restart once after that apply.
|
||||||
|
|
||||||
# 1.1.17
|
# 1.1.17
|
||||||
|
|
||||||
## 中文
|
## 中文
|
||||||
|
|||||||
Reference in new issue
Block a user