Compare commits

...
8 Commits
22 changed files with 1732 additions and 287 deletions

No files matched your search

+90 -20
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
<p align="center"><strong>Version 1.1.74</strong></p>
<p align="center"><strong>Version 1.1.79</strong></p>
<p align="center">
<em>DeepSeek Harness jailbreak: every model, swap prompts per model. Default prompt for 小码酱. Please star ⭐ If you build on this, see Attribution required.</em>
@@ -57,7 +57,7 @@ The author's personal channel: [t.me/LLM_PoJia](https://t.me/LLM_PoJia). Notes a
## What this is
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. **1.1.74** targets **DSH 0.2.1-rc.2** (0.2.0 still works). Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. **1.1.79** targets **DSH 0.2.1-rc.2** (0.2.0 still works). Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
Harness does more than forward a prompt. It rewrites prompts, approval gates, sandbox policy, and session migration at runtime. Asking only “will the model answer” treats a host-layer block as a model refusal. This plugin separates those two layers on your own install, for controlled evaluation and for seeing which default policy is too tight.
@@ -131,9 +131,9 @@ This repo is [Apache License 2.0](./LICENSE). Forks and redistributions must kee
## Supported hosts
**1.1.74 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
**1.1.79 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.74**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.79**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
- **dsh 0.2.0-rc.2**: use **1.1.40** or newer; this line also installs.
- **dsh 0.1.7** (incl. rc.1 / rc.2): use **1.1.39** or older — pick the tag on [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases).
@@ -143,28 +143,67 @@ Unmatched patches stay pending or skipped; nothing is rewritten blindly.
## Install
Web and the official desktop EXE are the two maintained hosts. Install and patch each **separately**, and only the host you actually run.
Follow the three steps below. **Do not use the plugin marketplace.** One-click install on [dsh-plugin.org](https://dsh-plugin.org) or in Settings → Plugin Market fails with `already queued: dsh-purge` and never runs a command. The name `dsh-purge` is not on the npm registry; do not `pnpm add dsh-purge`. If this machine only has pnpm, use the pnpm URL in step 2.
### 1. Which host are you running?
Official `dsh web` and the official desktop EXE are installed and patched **separately**. Only install into the host you actually open.
| What you run | Profile | Command |
|---|---|---|
| Official `dsh web` | `web` | `dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` |
| Official desktop EXE | `desktop` | `dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` |
| Official `dsh web` | `web` | First command below |
| Official desktop EXE | `desktop` | Second command below |
If this directory is already a clone, use `add .` instead of the URL. If `dsh` is not on PATH, use [Manual install](#manual). There is no npm package; do not `pnpm add dsh-purge`.
### 2. Add it to the profile (`dsh` or pnpm-only)
For the desktop client you can also click the button (`dsh://` deep link):
Use `codeload.github.com`. Do not use `github.com/.../archive`: that 302 makes pnpm fail with `fetch failed`.
**If you have `dsh`:**
```sh
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
Use `desktop` instead of `web` for the EXE. If this directory is already a clone, use `.` instead of the URL.
**pnpm only (no `dsh` required):** run this inside the profile you actually use, not the repo root.
```sh
cd "$DSH_HOME/profiles/web" # desktop: profiles/desktop
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
Windows PowerShell:
```powershell
cd "$env:USERPROFILE\.dsh\profiles\web" # desktop: profiles\desktop
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
`pnpm add` and `dsh plugin add` fetch the package; `postinstall` writes `dsh-purge` into `dsh.profile.bundles` and adds a body `insert` in the profile `cordis.patch.yml`. Without that insert the host never loads the plugin and no button appears. pnpm 11/12 skips install scripts (`ERR_PNPM_IGNORED_BUILDS`) unless you allow the build:
```sh
pnpm add --allow-build=dsh-purge https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
# If the package is already in node_modules:
pnpm approve-builds dsh-purge
node node_modules/dsh-purge/scripts/ensure-profile-bundle.mjs
```
Success: `node_modules/dsh-purge/package.json` exists, `"dsh-purge"` is in that profile's `bundles`, and `cordis.patch.yml` has an `id: dsh-purge` insert. If neither `dsh` nor pnpm is available, use [Manual install](#manual).
For the desktop client you can also click the button (`dsh://` deep link; it still downloads the same tarball):
<p align="center">
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.74&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.79&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%2Fcodeload.github.com%2FYuJunZhiXue%2Fdsh-purge%2Ftar.gz%2Frefs%2Fheads%2Fmaster"><strong>Install in desktop client</strong></a>
</p>
### After the command: three steps
### 3. Three more clicks after the command
Adding the plugin to a profile does **not** patch `@deepseek-ai` by itself.
1. **Quit and reopen** the host you installed into — stop and restart `dsh web`, or quit the desktop tray and reopen that app.
2. On **that host**, click **dsh-purge** beside the session title, then **Apply** on the **Clean** page. It is not on the host Settings page.
3. A successful **Apply** restarts once so patches load. It does not restart if it did not finish.
1. **Fully quit and reopen** the host you just installed into. Web: stop `dsh web` and start it again. Desktop: quit the tray icon too, then open the exe.
2. On **that host**, click **dsh-purge** beside the session title, open **Clean**, and click **Apply**. It is not on the host Settings page.
3. A successful **Apply** restarts once. It does not restart if it did not finish.
Web controls affect Web only; desktop controls affect the desktop app only. Do not Apply one host from the other.
@@ -174,6 +213,27 @@ Web controls affect Web only; desktop controls affect the desktop app only. Do n
- `/purge status` in chat prints `DSH_HOME` and the patch list — the path should be the home you actually run.
- Optional packages that are not installed (liangshen) show as skipped and do not block Apply.
If the button is missing, run `dsh --dump-config` (or `dsh --profile desktop --dump-config`) and look for a body row `id: dsh-purge` (not `dsh-purge-redteam`). If it is absent, run `ensure-profile-bundle.mjs` above, then fully quit and reopen the host. After this version, a live red-team child entry also writes the missing insert on startup — quit and reopen once more. `entry "redteam-store" not found` at the top is leftover from an old red-team package and can be ignored.
### If the market says `already queued: dsh-purge`
Stop clicking the market. Use `dsh plugin add` or pnpm from step 2 again. If the CLI also says it is already there:
```sh
dsh plugin --profile desktop remove dsh-purge
dsh plugin --profile desktop add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
pnpm only:
```sh
cd "$DSH_HOME/profiles/desktop"
pnpm remove dsh-purge
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
Swap `desktop` for `web` on Web. Then do step 3.
### Hand this to an assistant
Paste the block below to a local assistant. It should only run the install command — no disk scan, no other edits, no Apply, no restart.
@@ -183,17 +243,23 @@ Paste the block below to a local assistant. It should only run the install comma
<!-- AI-AGENT-START -->
Install the DeepSeek Harness plugin `dsh-purge` into the Web profile only. Do not scan the whole disk, do not read or edit other files, do not apply settings, and do not restart the app. Do not install into the desktop profile.
Install the DeepSeek Harness plugin `dsh-purge` into the Web profile only. Do not scan the whole disk, do not read or edit other files, do not apply settings, and do not restart the app. Do not install into the desktop profile. Do not use the plugin marketplace. The name is not on the npm registry; do not `pnpm add dsh-purge`.
**Web (official `dsh web`)**
If `dsh` is not on PATH, tell the user and stop.
If `dsh` is on PATH:
```sh
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
If this directory is already a clone, use `dsh plugin --profile web add .`. There is no npm package; do not `pnpm add dsh-purge`.
If `dsh` is missing and pnpm is available, `cd` into `$DSH_HOME/profiles/web` (often `~/.dsh/profiles/web`) and run:
```sh
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
If this directory is already a clone and `dsh` exists, use `dsh plugin --profile web add .`. If neither `dsh` nor pnpm is available, tell the user and stop.
After the command finishes, tell the user to fully quit and restart `dsh web`, then open **dsh-purge** beside the session title and **Apply** on **Clean**. Then stop.
@@ -277,7 +343,7 @@ Success: `profiles/<web|desktop>/node_modules/dsh-purge/package.json` exists. If
### Uninstall
**dsh-purge** beside the session title → **Clean** → **Uninstall**. Confirm the dialog: it reverts any applied patches, restores the original Harness, and restarts the current host.
**dsh-purge** beside the session title → **Clean** → **Uninstall**. Confirm the dialog: it reverts any applied patches, restores the original Harness, and restarts the current host. Disable or uninstall also resets an agent-preset default that still points at `redteam` back to `standard`, so the host can create sessions after the preset is gone.
```sh
# or from a terminal / chat
@@ -362,6 +428,10 @@ dsh-purge --edit
/rules list | use <id> | create <id> | delete <id> | reset | help
/rewind
# If another plugin already owns /rewind (or /purge, /rules, /skills), that
# name is skipped or remounted as /purge-rewind. Other commands, tools, and
# /dsh-purge/* routes keep working.
purge_status purge_apply purge_revert
```
@@ -512,7 +582,7 @@ The author's personal channel: [t.me/LLM_PoJia](https://t.me/LLM_PoJia). Notes a
- Scope is rendered copy, defaults, and runtime logic inside local `@deepseek-ai/*` packages, plus override files and rule sets under the harness home.
- After an upgrade, unmatched originals show as skipped. Apply still completes, and those files are left unchanged.
- Third-party plugin *source repos* outside `@deepseek-ai` are left alone (CMD silence may **best-effort** patch installed doctor / market / liangshen / mnemon at runtime).
- Install from the GitHub archive (there is no npm package): `dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` (use profile `desktop` for the EXE). From this repo, `add .`.
- Install from the GitHub tarball (the name is not on npm; skip the plugin market). With `dsh`: `dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master`. pnpm only: `pnpm add` that URL inside `$DSH_HOME/profiles/web`. Use `desktop` for the EXE. From this repo, `add .`.
---
+94 -25
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
<p align="center"><strong>Version 1.1.74</strong></p>
<p align="center"><strong>Version 1.1.79</strong></p>
<p align="center">
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分</em>
@@ -57,7 +57,7 @@
## 介绍
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.74** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.79** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
Harness 不只是把问题交给模型。它还会在运行时改提示词、审批门、沙箱和会话格式。只看「模型答不答」,会把宿主拦截误当成模型拒绝。这个插件在你自己的安装里把这两层分开,用来做受控评测,也用来看默认策略该不该收紧。
@@ -133,9 +133,9 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
## 适配范围
**1.1.74 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
**1.1.79 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.74**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.79**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
- **dsh 0.2.0-rc.2**:用 **1.1.40** 及以上;本页这档也能装。
- **dsh 0.1.7**(含 rc.1 / rc.2):用 **1.1.39** 及更早 —— 在 [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases) 里选对应标签。
@@ -145,36 +145,96 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
## 安装
现在只维护官方 `dsh web` 和官方桌面 EXE,**分开装、分开应用**,只装你正在打开的那一个。
按下面三步走。**不要走插件市场**:[dsh-plugin.org](https://dsh-plugin.org) 或设置里的「插件市场」一键安装会报 `already queued: dsh-purge`,命令也走不成。npm 仓库没有 `dsh-purge` 这个名字,不要 `pnpm add dsh-purge`;本机只有 pnpm 时走第 2 步里的 pnpm 地址。
| 你正在用 | profile | 命令 |
### 1. 看你开的是哪一端
官方 `dsh web` 和官方桌面 EXE **分开装、分开应用**,只装你正在打开的那一个。
| 你正在用 | profile | 用哪条命令 |
|---|---|---|
| 官方 `dsh web` | `web` | `dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` |
| 官方桌面 EXE | `desktop` | `dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` |
| 官方 `dsh web` | `web` | 下面第一条 |
| 官方桌面 EXE | `desktop` | 下面第二条 |
当前目录已经是本仓库时,把 URL 换成 `add .`。`dsh` 不在 PATH 时走 [手动安装](#manual)。没有 npm 包,不要 `pnpm add dsh-purge`。
### 2. 装进 profile(有 `dsh` 或只有 pnpm,走一条)
桌面客户端也可以点按钮(`dsh://` 唤起):
压缩包走 `codeload.github.com`,不要用 `github.com/.../archive`:后者 302,pnpm 会 `fetch failed`。
**有 `dsh`:**
```sh
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
桌面把 `web` 换成 `desktop`。当前目录已是本仓库时,把网址换成 `.`。
**只有 pnpm(没有 `dsh` 也行):** 进正在用的那个 profile,不要在仓库根执行。
```sh
cd "$DSH_HOME/profiles/web" # 桌面改 profiles/desktop
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
Windows PowerShell:
```powershell
cd "$env:USERPROFILE\.dsh\profiles\web" # 桌面改 profiles\desktop
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
`pnpm add` 和 `dsh plugin add` 都会拉包;`postinstall` 再把 `dsh-purge` 写进 `dsh.profile.bundles`,并在用户层 `cordis.patch.yml` 补上本体 `insert`(没有这一行,宿主不加载插件,界面没有按钮)。pnpm 11/12 默认拦安装脚本(`ERR_PNPM_IGNORED_BUILDS`),请带上允许构建,或事后补跑:
```sh
pnpm add --allow-build=dsh-purge https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
# 已经装上但只有警告时:
pnpm approve-builds dsh-purge
node node_modules/dsh-purge/scripts/ensure-profile-bundle.mjs
```
成功标志:`node_modules/dsh-purge/package.json` 在,profile 的 `bundles` 里有 `"dsh-purge"`,`cordis.patch.yml` 里有 `id: dsh-purge` 的 insert。`dsh` 和 pnpm 都没有时走 [手动安装](#manual)。
桌面客户端也可以点按钮(`dsh://` 唤起,下的仍是同一份压缩包):
<p align="center">
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.74&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.79&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%2Fcodeload.github.com%2FYuJunZhiXue%2Fdsh-purge%2Ftar.gz%2Frefs%2Fheads%2Fmaster"><strong>唤起客户端一键安装</strong></a>
</p>
### 装完都要做这三步
### 3. 装完还要做这三下
只把插件写进 profile **还不会**改 `@deepseek-ai`。
1. **退出并重新打开**刚装的那个宿主:Web 关掉 `dsh web` 再开;桌面端退出托盘再打开对应 exe。
2. 在**这个宿主**点会话标题旁的 **dsh-purge**,在 **清洗** 页点 **「应用」**。宿主的设置页里没有这个条目。
3. 「应用」成功后会自动重启一次,让补丁进入当前进程。没做完不会重启。
1. **完全退出再打开**刚装的那个宿主。Web:停掉 `dsh web` 再开。桌面:托盘也要退出,再开 exe。
2. 在**这个宿主**点会话标题旁的 **dsh-purge**,打开 **清洗**,点 **「应用」**。宿主自己的设置页里没有这一项。
3. 「应用」成功后会自动重启一次。没做完不会重启。
Web 的控件只动 Web,桌面端的只动桌面应用。不要在一个宿主里点另一个宿主的应用。
Web 的按钮只动 Web,桌面的只动桌面。不要在一个里面点另一个的应用。
### 怎样算装上了
- 会话标题旁有 **dsh-purge**,点开后在「清洗」里能点「应用」。
- 聊天里 `/purge status` 能打出 `DSH_HOME` 和补丁列表,路径应是你正在用的那一份。
- 没装的可选包(例如梁神)显示跳过,不挡住应用完成。
- 会话标题旁有 **dsh-purge**,清洗页能点「应用」。
- 聊天里 `/purge status` 能打出 `DSH_HOME` 和补丁列表,路径是你正在用的那一份。
- 没装的可选包(例如梁神)显示跳过,不挡住完成。
没有按钮时,在对应 profile 跑 `dsh --dump-config`(或 `dsh --profile desktop --dump-config`),看有没有本体行 `id: dsh-purge`(不是 `dsh-purge-redteam`)。没有就再跑上面的 `ensure-profile-bundle.mjs`,然后完全退出重开宿主。升到本版本后,若演练台子行已经在跑,它也会在启动时把缺的 insert 补上,再完全退出重开一次即可。开头那几条 `entry "redteam-store" not found` 只是旧红队包不在,可以忽略。
### 市场报 `already queued: dsh-purge` 时
不要再点市场。按第 2 步用 `dsh plugin add` 或 pnpm 再装一遍。命令也说已经有了,就先卸再装:
```sh
dsh plugin --profile desktop remove dsh-purge
dsh plugin --profile desktop add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
只有 pnpm 时:
```sh
cd "$DSH_HOME/profiles/desktop"
pnpm remove dsh-purge
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
Web 把 `desktop` 换成 `web`。然后再走第 3 步。
### 交给助手安装
@@ -185,17 +245,23 @@ Web 的控件只动 Web,桌面端的只动桌面应用。不要在一个宿主
<!-- AI-AGENT-START -->
安装 DeepSeek Harness 插件 `dsh-purge`,只装到 Web profile。不要全盘搜索,不要读或改其它文件,不要应用设置,也不要重启应用。不要装到桌面 profile。
安装 DeepSeek Harness 插件 `dsh-purge`,只装到 Web profile。不要全盘搜索,不要读或改其它文件,不要应用设置,也不要重启应用。不要装到桌面 profile。不要走插件市场。npm 仓库没有这个包名,不要 `pnpm add dsh-purge`。
**Web 端(官方 `dsh web`)**
`dsh` 不在 PATH 就告诉用户后停止。
有 `dsh`:
```sh
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
当前目录已是本仓库时改用 `dsh plugin --profile web add .`。没有 npm 包,不要 `pnpm add dsh-purge`。
没有 `dsh`、只有 pnpm:找到 `$DSH_HOME/profiles/web`(常见 `~/.dsh/profiles/web`),在该目录执行:
```sh
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
```
当前目录已是本仓库且有 `dsh` 时改用 `dsh plugin --profile web add .`。`dsh` 和 pnpm 都没有再告诉用户后停止。
命令结束后,提醒用户:完全退出并重启 `dsh web`,再点会话标题旁的 **dsh-purge**,在「清洗」里点「应用」。然后停止。
@@ -279,7 +345,7 @@ pnpm install
### 卸载
会话标题旁的 **dsh-purge** →「清洗」→「卸载」。弹窗确认:会先还原已应用的补丁,还原回原版 Harness,再重启当前宿主。
会话标题旁的 **dsh-purge** →「清洗」→「卸载」。弹窗确认:会先还原已应用的补丁,还原回原版 Harness,再重启当前宿主。停用或卸载时会把「智能体预设」里指向红队模式的默认值改回 `standard`,避免宿主因找不到 `redteam` 而无法新建会话。
```sh
# 也可以用命令行 / 聊天
@@ -372,6 +438,9 @@ dsh-purge --edit
/rules list | use <id> | create <id> | delete <id> | reset | help
/rewind
# 其它插件已占 /rewind(或 /purge、/rules、/skills)时,这条命令会跳过或改挂
# /purge-rewind 等备用名;主插件其余命令、工具、/dsh-purge/* 路由不受影响。
# 模型工具
purge_status purge_apply purge_revert
```
@@ -521,7 +590,7 @@ flowchart TD
- 改动范围是本机 `@deepseek-ai/*` 包里的渲染文案、默认策略和执行逻辑,以及用户目录下的覆盖文件与规则集。
- 升级后原文对不上会显示跳过,这次应用仍算完成,不会乱改。
- 不改动非 `@deepseek-ai` 的第三方插件源仓库(启动时的 CMD 无感会**尽力**修补已装的 doctor / market / 梁神 / mnemon,属运行时补丁)。
- 安装走 GitHub 归档(npm 上没有这个包):`dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz`(桌面端把 profile 换成 `desktop`)。当前目录已是本仓库时 `add .`。
- 安装走 GitHub 压缩包(npm 仓库没有这个名字,也不要走插件市场)。有 `dsh`:`dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master`。只有 pnpm:在 `$DSH_HOME/profiles/web` 里 `pnpm add` 同一地址。桌面把 `web` 换成 `desktop`。当前目录已是本仓库时 `add .`。
---
Regular → Executable
View File
File mode changed.
+397 -106
View File
@@ -198,6 +198,20 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"status.unmatched": "没对上",
"status.skipped": "跳过",
"apply.hint": "没改提示词框不用点保存,默认就是这份,启动和应用会写进 prompt-inject.md。只有自己改过再点保存才会覆盖。点应用打补丁。待应用=原文还在。跳过=当前版本不需要或组件未安装。",
"flow.title": "清洗流程",
"flow.apply": "应用",
"flow.revert": "还原",
"flow.uninstall": "卸载",
"flow.home": "家目录",
"flow.locate": "宿主",
"flow.override": "提示词",
"flow.patch": "补丁",
"flow.shim": "启动器",
"flow.flash": "闪窗",
"flow.seed": "落盘",
"flow.done": "完成",
"flow.revert.step": "还原",
"flow.cleanup": "清理",
"warn.noRoot": "未定位到当前宿主的 @deepseek-ai,清洗不会生效。请完全退出后再打开本宿主,在本页点「应用」。桌面端安装目录可以是任意盘符;目录名带 DeepseekHarness / DeepSeek Harness 均可。",
"warn.noRoot.desktop": "官方客户端的代码在 app.asar 里。点「应用」会解开并自动重启,不用另跑脚本。若一直显示还没定位,先完全退出客户端再开,再点「应用」。第三方 DSH Desktop 直接点「应用」。",
"unpack.restarting": "补丁已写入。点「重启」后客户端会自己重新打开。",
@@ -542,6 +556,20 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"status.unmatched": "No match",
"status.skipped": "Skipped",
"apply.hint": "If you did not edit the prompt box, do not save. The default is already used and is written to prompt-inject.md on start/apply. Save only after you change it. Apply writes host patches. Pending = original text still present. Skipped = not needed for this version or the component is not installed.",
"flow.title": "Clean flow",
"flow.apply": "Apply",
"flow.revert": "Restore",
"flow.uninstall": "Uninstall",
"flow.home": "Home",
"flow.locate": "Host",
"flow.override": "Prompt",
"flow.patch": "Patch",
"flow.shim": "Launcher",
"flow.flash": "Flash",
"flow.seed": "Seed",
"flow.done": "Done",
"flow.revert.step": "Restore",
"flow.cleanup": "Cleanup",
"warn.noRoot": "Could not find this host’s @deepseek-ai tree, so Apply will not patch anything. Fully quit and reopen this host, then Apply here. Desktop may live on any drive; folder names like DeepseekHarnessDesktop or DeepSeek Harness are fine.",
"warn.noRoot.desktop": "Official Harness keeps its code in app.asar. Apply unpacks it and restarts the app. If this page stays “not found”, fully quit the client, reopen it, then Apply again. Third-party DSH Desktop: just Apply.",
"unpack.restarting": "Patches are written. Click Restart and the client opens again by itself.",
@@ -814,73 +842,94 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
};
const PURGE_CSS = `
.dshp-root{--dshp-display:"Songti SC","Noto Serif SC","Iowan Old Style",Palatino,"Palatino Linotype",Georgia,serif;--dshp-sans:"Yu Gothic UI","Hiragino Sans GB","Source Han Sans SC",system-ui,sans-serif;--dshp-mono:"Cascadia Mono","Sarasa Mono SC",ui-monospace,monospace;--dshp-ease:cubic-bezier(.16,1,.3,1);max-width:920px;display:flex;flex-direction:column;gap:18px;padding:16px;border-radius:12px;background:var(--dshp-bg);color:var(--dshp-ink);font-family:var(--dshp-sans)}
.dshp-root{--dshp-bg:transparent;--dshp-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#f6f4ef) 74%,transparent);--dshp-ink:var(--dsw-alias-label-primary,#1a1916);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#1a1916) 74%,var(--dsw-alias-label-secondary,#5c564c));--dshp-line:color-mix(in srgb,var(--dsw-alias-border-l1,#c8c2b6) 78%,transparent);--dshp-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 14%,transparent);--dshp-accent:var(--dsw-alias-brand-primary,#3f6b52);--dshp-accent-soft:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 18%,transparent);--dshp-ok:#1f7a45;--dshp-warn:#8a5a12;--dshp-bad:#9a3434}
.dshp-root[data-theme="white"]{color-scheme:light}
.dshp-root[data-theme="dusk"]{color-scheme:dark;--dshp-ok:#8fd0a8;--dshp-warn:#e4c48a;--dshp-bad:#f0b4b4}
.dshp-root{--dshp-display:inherit;--dshp-sans:inherit;--dshp-mono:ui-monospace,"Cascadia Mono","Sarasa Mono SC",monospace;--dshp-ease:cubic-bezier(.22,1,.36,1);--dshp-glass:blur(18px) saturate(1.35);--dshp-hi:color-mix(in srgb,#fff 42%,transparent);max-width:920px;display:flex;flex-direction:column;gap:16px;padding:16px;border-radius:12px;background:transparent;color:var(--dshp-ink);font-family:inherit}
.dshp-root{--dshp-bg:transparent;--dshp-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);--dshp-ink:var(--dsw-alias-label-primary,#16140f);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));--dshp-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);--dshp-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);--dshp-accent:var(--dsw-alias-brand-primary,#3d8f68);--dshp-accent-soft:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent);--dshp-ok:#2f6b4f;--dshp-warn:#8a5a12;--dshp-bad:#9a3434}
.dshp-root[data-theme="white"]{color-scheme:light;--dshp-hi:color-mix(in srgb,#fff 48%,transparent)}
.dshp-root[data-theme="dusk"]{color-scheme:dark;--dshp-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);--dshp-ink:var(--dsw-alias-label-primary,#f4f1ea);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 78%,var(--dsw-alias-label-secondary,#c9c3b8));--dshp-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);--dshp-ok:#8fd0a8;--dshp-warn:#e4c48a;--dshp-bad:#f0b4b4;--dshp-hi:color-mix(in srgb,#fff 10%,transparent)}
.dshp-toolbar{display:flex;align-items:center;justify-content:flex-end;gap:8px}
.dshp-switch{display:inline-flex;border:1px solid var(--dshp-line);border-radius:999px;overflow:hidden;background:var(--dshp-paper)}
.dshp-switch button{appearance:none;border:0;background:transparent;color:var(--dshp-mute);font:12px/1 var(--dshp-sans);padding:6px 14px;cursor:pointer}
.dshp-switch button{appearance:none;border:0;background:transparent;color:var(--dshp-mute);font:12px/1 var(--dshp-sans);padding:8px 12px;cursor:pointer}
.dshp-switch button.is-on{background:var(--dshp-accent-soft);color:var(--dshp-ink)}
.dshp-switch button:focus-visible{outline:2px solid var(--dshp-accent);outline-offset:-2px}
.dshp-panel{border:1px solid var(--dshp-line);background:var(--dshp-paper);border-radius:10px;padding:18px 18px 16px}
.dshp-kicker{font-family:var(--dshp-mono);font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--dshp-mute);margin:0 0 4px}
.dshp-title{font-family:var(--dshp-display);font-size:20px;font-weight:500;letter-spacing:.02em;line-height:1.3;margin:0;color:var(--dshp-ink)}
.dshp-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px;flex-wrap:wrap}
.dshp-sub{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:20px 0 10px}
.dshp-sub h4{margin:0;font-family:var(--dshp-display);font-size:15px;font-weight:500}
.dshp-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:14px}
.dshp-metric{border:1px solid var(--dshp-line);background:var(--dshp-bg);padding:12px;min-height:68px;display:flex;flex-direction:column;gap:4px;border-radius:8px}
.dshp-metric b{font-family:var(--dshp-display);font-size:18px;font-weight:500;line-height:1.2}
.dshp-metric span{font-size:11px;color:var(--dshp-mute)}
.dshp-bar{height:3px;border-radius:99px;background:var(--dshp-line);overflow:hidden;margin:8px 0 14px}
.dshp-bar>i{display:block;height:100%;background:var(--dshp-accent);width:0;transition:width .4s var(--dshp-ease)}
.dshp-group{border:1px solid var(--dshp-line);margin:0 0 8px;background:var(--dshp-bg);border-radius:8px;overflow:hidden}
.dshp-group-h{width:100%;display:flex;align-items:center;gap:10px;padding:9px 12px;border:0;background:transparent;color:inherit;cursor:pointer;font:inherit;text-align:left}
.dshp-panel,.dshp-metric,.dshp-group,.dshp-ask,.dshp-modal,.dshp-rulelist,.dshp-active,.dshp-switch,.dshp-editor,.dshp-cwd-list,.dshp-create{border:1px solid var(--dshp-line);background:var(--dshp-paper);backdrop-filter:var(--dshp-glass);-webkit-backdrop-filter:var(--dshp-glass);box-shadow:inset 0 1px 0 var(--dshp-hi)}
.dshp-panel{border-radius:12px;padding:16px}
.dshp-kicker{font-family:var(--dshp-mono);font-size:12px;letter-spacing:.14em;text-transform:uppercase;color:var(--dshp-mute);margin:0 0 4px}
.dshp-title{font-family:inherit;font-size:20px;font-weight:600;letter-spacing:0;line-height:28px;margin:0;color:var(--dshp-ink);text-wrap:balance}
.dshp-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px;flex-wrap:wrap}
.dshp-sub{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:24px 0 12px}
.dshp-sub h4{margin:0;font-family:inherit;font-size:16px;font-weight:600;line-height:24px}
.dshp-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:16px}
.dshp-metric{padding:12px;min-height:64px;display:flex;flex-direction:column;gap:4px;border-radius:8px}
.dshp-metric b{font-family:inherit;font-size:18px;font-weight:600;line-height:28px}
.dshp-metric span{font-size:12px;line-height:16px;color:var(--dshp-mute)}
.dshp-bar{height:4px;border-radius:999px;background:var(--dshp-line);overflow:hidden;margin:8px 0 16px}
.dshp-bar>i{display:block;height:100%;width:100%;transform:scaleX(0);transform-origin:left center;background:var(--dshp-accent);transition:transform 500ms var(--dshp-ease)}
.dshp-flow{display:flex;align-items:center;gap:0;margin:0 0 16px;overflow-x:auto;padding:4px 0}
.dshp-flow-kind{font:12px/16px var(--dshp-mono);letter-spacing:.08em;text-transform:uppercase;color:var(--dshp-mute);margin:0 12px 0 0;flex:0 0 auto}
.dshp-flow-node{display:flex;flex-direction:column;align-items:center;gap:4px;min-width:44px;opacity:.42;transition:opacity 500ms var(--dshp-ease),transform 500ms var(--dshp-ease)}
.dshp-flow-node b{width:22px;height:22px;border-radius:99px;border:1px solid var(--dshp-line);display:flex;align-items:center;justify-content:center;font:11px/1 var(--dshp-mono);background:var(--dshp-paper)}
.dshp-flow-node em{font-style:normal;font-size:12px;line-height:16px;color:var(--dshp-mute);white-space:nowrap}
.dshp-flow-node.is-cur{opacity:1;transform:translateY(-2px)}
.dshp-flow-node.is-cur b{border-color:var(--dshp-accent);background:var(--dshp-accent-soft);box-shadow:0 0 0 4px var(--dshp-accent-soft)}
.dshp-flow-node.is-done{opacity:.92}
.dshp-flow-node.is-done b{border-color:var(--dshp-ok);background:color-mix(in srgb,var(--dshp-ok) 18%,transparent);color:var(--dshp-ok)}
.dshp-flow-node.is-bad b{border-color:var(--dshp-bad);color:var(--dshp-bad);background:color-mix(in srgb,var(--dshp-bad) 14%,transparent)}
.dshp-flow-wire{flex:1 1 12px;min-width:10px;height:2px;background:var(--dshp-line);position:relative;overflow:hidden;margin:0 4px 16px}
.dshp-flow-wire.is-on{background:color-mix(in srgb,var(--dshp-accent) 55%,var(--dshp-line))}
.dshp-flow-wire.is-on>i{position:absolute;inset:0 auto 0 -40%;width:40%;background:var(--dshp-accent);animation:dshp-flow-pulse 1.4s cubic-bezier(.65,0,.35,1) infinite}
@keyframes dshp-flow-pulse{to{transform:translateX(360%)}}
@media (prefers-reduced-motion:reduce){
.dshp-flow-wire.is-on>i{animation:none;display:none}
.dshp-flow-node.is-cur{transform:none}
}
.dshp-group{margin:0 0 8px;border-radius:8px;overflow:hidden}
.dshp-group-h{width:100%;display:flex;align-items:center;gap:12px;padding:8px 12px;border:0;background:transparent;color:inherit;cursor:pointer;font:inherit;text-align:left}
.dshp-group-h:hover{background:var(--dshp-fill)}
.dshp-group-h:focus-visible{outline:2px solid var(--dshp-accent);outline-offset:-2px}
.dshp-group-h strong{font-family:var(--dshp-display);font-size:14px;font-weight:500}
.dshp-group-h strong{font-family:inherit;font-size:14px;line-height:20px;font-weight:600}
.dshp-group-h em{font-style:normal;font-size:12px;color:var(--dshp-mute);flex:1}
.dshp-count{font-family:var(--dshp-mono);font-size:12px;color:var(--dshp-mute)}
.dshp-table{width:100%;border-collapse:collapse;font-size:12.5px}
.dshp-table th{text-align:left;font-weight:500;font-size:11px;letter-spacing:.06em;color:var(--dshp-mute);padding:7px 12px;border-bottom:1px solid var(--dshp-line)}
.dshp-table{width:100%;border-collapse:collapse;font-size:12px;line-height:16px}
.dshp-table th{text-align:left;font-weight:500;font-size:11px;letter-spacing:.06em;color:var(--dshp-mute);padding:8px 12px;border-bottom:1px solid var(--dshp-line)}
.dshp-table td{padding:8px 12px;border-bottom:1px solid var(--dshp-line);vertical-align:middle}
.dshp-table tr:last-child td{border-bottom:0}
.dshp-table tr.is-on td{background:var(--dshp-accent-soft)}
.dshp-id{font-family:var(--dshp-mono);opacity:.75;width:42px}
.dshp-actions{text-align:right;white-space:nowrap}
.dshp-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.dshp-row+.dshp-row{margin-top:10px}
.dshp-pill{display:inline-flex;align-items:center;gap:6px;font-family:var(--dshp-mono);font-size:11px;padding:2px 8px;border:1px solid var(--dshp-line);border-radius:99px;line-height:1.6;background:var(--dshp-bg)}
.dshp-row+.dshp-row{margin-top:12px}
.dshp-pill{display:inline-flex;align-items:center;gap:4px;font-family:var(--dshp-mono);font-size:12px;padding:2px 8px;border:1px solid var(--dshp-line);border-radius:999px;line-height:16px;background:color-mix(in srgb,var(--dshp-paper) 70%,transparent)}
.dshp-pill::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.dshp-pill.is-ok{color:var(--dshp-ok);border-color:color-mix(in srgb,var(--dshp-ok) 30%,var(--dshp-line))}
.dshp-pill.is-wait{color:var(--dshp-warn);border-color:color-mix(in srgb,var(--dshp-warn) 30%,var(--dshp-line))}
.dshp-pill.is-miss{color:var(--dshp-mute)}
.dshp-pill.is-bad{color:var(--dshp-bad)}
.dshp-btn{appearance:none;font-family:var(--dshp-sans);font-size:13px;font-weight:500;min-height:34px;padding:0 14px;border-radius:8px;border:1px solid transparent;cursor:pointer;transition:background .15s var(--dshp-ease),opacity .15s var(--dshp-ease)}
.dshp-btn{appearance:none;font-family:inherit;font-size:16px;line-height:24px;font-weight:600;padding:8px 12px;border-radius:8px;border:1px solid transparent;cursor:pointer;transition:transform 500ms var(--dshp-ease),opacity 300ms var(--dshp-ease)}
.dshp-btn:hover:not(:disabled){transform:translateY(-1px)}
.dshp-btn:active:not(:disabled){transform:scale(0.98)}
.dshp-btn:disabled{opacity:.45;cursor:not-allowed}
.dshp-btn:focus-visible{outline:2px solid var(--dshp-accent);outline-offset:2px}
.dshp-btn-primary{background:var(--dshp-accent-soft);color:var(--dshp-ink);border-color:color-mix(in srgb,var(--dshp-accent) 35%,var(--dshp-line))}
.dshp-btn-primary:hover:not(:disabled){background:color-mix(in srgb,var(--dshp-accent) 22%,var(--dshp-bg))}
.dshp-btn-primary{background:var(--dshp-accent);color:#fff;border-color:var(--dshp-accent)}
.dshp-btn-primary:hover:not(:disabled){background:color-mix(in srgb,var(--dshp-accent) 86%,#fff);color:#fff}
.dshp-btn-ghost{background:transparent;color:var(--dshp-ink);border-color:var(--dshp-line)}
.dshp-btn-danger{background:transparent;color:var(--dshp-bad);border-color:color-mix(in srgb,var(--dshp-bad) 40%,var(--dshp-line))}
.dshp-btn-solid-danger{background:color-mix(in srgb,var(--dshp-bad) 16%,var(--dshp-bg));color:var(--dshp-bad);border-color:color-mix(in srgb,var(--dshp-bad) 30%,var(--dshp-line))}
.dshp-btn-tiny{min-height:28px;padding:0 10px;font-size:12px}
.dshp-field,.dshp-area{width:100%;box-sizing:border-box;font:13px/1.55 var(--dshp-mono);padding:8px 10px;background:var(--dshp-bg);color:var(--dshp-ink);border:1px solid var(--dshp-line);border-radius:8px}
.dshp-btn-tiny{padding:4px 12px;font-size:14px;line-height:20px}
.dshp-field,.dshp-area{width:100%;box-sizing:border-box;font:13px/1.55 var(--dshp-mono);padding:8px 12px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 38%,transparent);color:var(--dshp-ink);border:1px solid var(--dshp-line);border-radius:8px;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.dshp-field{width:auto;min-width:140px}
.dshp-cr-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:8px 0 0;font-size:13px}
.dshp-cr-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:8px 0 0;font-size:13px}
.dshp-cr-row label{display:inline-flex;align-items:center;gap:6px;color:var(--dshp-ink)}
.dshp-cr-num{width:64px;min-width:64px;height:28px;padding:0 8px}
.dshp-cr-text{width:120px;min-width:88px;height:28px;padding:0 8px}
.dshp-ver{width:100%;min-width:0;max-width:none;height:32px;padding:0 10px;font-size:12px}
.dshp-rel{margin:0 0 14px}
.dshp-rel{margin:0 0 12px}
.dshp-now{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin:0 0 4px}
.dshp-now-label{font-family:var(--dshp-mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--dshp-mute)}
.dshp-now-ver{font-family:var(--dshp-display);font-size:20px;font-weight:500;letter-spacing:.01em}
.dshp-now-mark{display:inline-flex;align-items:center;margin-left:6px;padding:1px 7px;border-radius:99px;font-family:var(--dshp-mono);font-size:11px;font-style:normal;font-weight:500;line-height:1.5;color:var(--dshp-ok);border:1px solid color-mix(in srgb,var(--dshp-ok) 38%,var(--dshp-line));background:color-mix(in srgb,var(--dshp-ok) 14%,var(--dshp-bg))}
.dshp-editions{display:flex;flex-direction:column;margin:10px 0 0;border-top:1px solid var(--dshp-line)}
.dshp-edition{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px;padding:10px 0;border-bottom:1px solid var(--dshp-line)}
.dshp-edition-name{display:inline-flex;align-items:center;gap:0;font-family:var(--dshp-display);font-size:15px;font-weight:500;white-space:nowrap}
.dshp-now-ver{font-family:inherit;font-size:20px;line-height:28px;font-weight:600;letter-spacing:0}
.dshp-now-mark{display:inline-flex;align-items:center;margin-left:8px;padding:2px 8px;border-radius:99px;font-family:var(--dshp-mono);font-size:11px;font-style:normal;font-weight:500;line-height:1.5;color:var(--dshp-ok);border:1px solid color-mix(in srgb,var(--dshp-ok) 38%,var(--dshp-line));background:color-mix(in srgb,var(--dshp-ok) 14%,var(--dshp-bg))}
.dshp-editions{display:flex;flex-direction:column;margin:8px 0 0;border-top:1px solid var(--dshp-line)}
.dshp-edition{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;padding:12px 0;border-bottom:1px solid var(--dshp-line)}
.dshp-edition-name{display:inline-flex;align-items:center;gap:0;font-family:inherit;font-size:16px;line-height:24px;font-weight:600;white-space:nowrap}
.dshp-edition.is-on .dshp-edition-name{color:var(--dshp-ink)}
.dshp-edition:not(.is-on) .dshp-edition-name{color:var(--dshp-mute)}
.dshp-edition .dshp-btn{min-width:118px}
@@ -889,85 +938,90 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
.dshp-area{min-height:220px;resize:vertical}
.dshp-field:focus,.dshp-area:focus{outline:none;border-color:var(--dshp-accent);box-shadow:0 0 0 3px var(--dshp-accent-soft)}
.dshp-field:disabled,.dshp-area:disabled{opacity:.5}
.dshp-ask{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px;padding:10px 12px;border:1px solid var(--dshp-line);border-radius:8px;background:var(--dshp-bg);font-size:13px}
.dshp-modal-bg{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:20px;background:color-mix(in srgb,var(--dshp-ink) 28%,transparent)}
.dshp-modal{width:min(420px,100%);background:var(--dshp-paper);color:var(--dshp-ink);border:1px solid var(--dshp-line);border-radius:12px;padding:20px 20px 16px;box-shadow:0 16px 40px color-mix(in srgb,var(--dshp-ink) 18%,transparent)}
.dshp-modal h4{margin:0 0 8px;font-family:var(--dshp-display);font-size:18px;font-weight:500}
.dshp-modal p{margin:0 0 16px;font-size:13.5px;line-height:1.55}
.dshp-ask{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:12px;padding:12px;border-radius:8px;font-size:14px;line-height:20px}
.dshp-modal-bg{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:24px;background:color-mix(in srgb,var(--dshp-ink) 28%,transparent)}
.dshp-modal{width:min(420px,100%);color:var(--dshp-ink);border-radius:12px;padding:16px;box-shadow:inset 0 1px 0 var(--dshp-hi),0 16px 40px color-mix(in srgb,#000 22%,transparent)}
.dshp-modal h4{margin:0 0 8px;font-family:inherit;font-size:18px;line-height:28px;font-weight:600}
.dshp-modal p{margin:0 0 16px;font-size:14px;line-height:20px;text-wrap:pretty}
.dshp-modal-ops{display:flex;justify-content:flex-end;gap:8px}
.dshp-restart-mask{position:fixed;inset:0;z-index:12000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.62);font-family:"Yu Gothic UI","Hiragino Sans GB","Source Han Sans SC","Microsoft YaHei UI",system-ui,sans-serif}
.dshp-restart-card{width:min(420px,100%);box-sizing:border-box;padding:22px 22px 18px;border-radius:14px;background:var(--dsw-alias-bg-layer-1,#fffcf7);color:var(--dsw-alias-label-primary,#16140f);border:1px solid var(--dsw-alias-border-l1,#c9c3b6);box-shadow:0 18px 50px rgba(0,0,0,.35)}
.dshp-restart-card h4{margin:0 0 10px;font-family:inherit;font-size:20px;font-weight:650;line-height:1.35;color:inherit}
.dshp-restart-card p{margin:0 0 18px;font-size:16px;font-weight:500;line-height:1.65;color:inherit}
.dshp-restart-card .dshp-modal-ops{display:flex;justify-content:flex-end;gap:10px}
.dshp-restart-card .dshp-btn{min-height:38px;padding:0 16px;font-size:15px;font-weight:650;color:var(--dsw-alias-label-primary,#16140f);background:var(--dsw-alias-bg-layer-2,#fff);border:1px solid var(--dsw-alias-border-l1,#c9c3b6)}
.dshp-restart-card .dshp-btn-primary,.dshp-restart-card .dshp-btn-primary:hover:not(:disabled){color:#fff;background:#2f6b4f;border-color:#2f6b4f}
body[data-ds-dark-theme] .dshp-restart-card,.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card{background:#1c1e24;color:#f4f1ea;border-color:#5a5e68}
body[data-ds-dark-theme] .dshp-restart-card .dshp-btn,.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card .dshp-btn{color:#f4f1ea;background:#2a2d34;border-color:#5a5e68}
.dshp-restart-mask{position:fixed;inset:0;z-index:12000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.62);font-family:inherit}
.dshp-restart-card{width:min(420px,100%);box-sizing:border-box;padding:16px;border-radius:16px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);color:var(--dsw-alias-label-primary,#16140f);border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 42%,transparent),0 16px 40px color-mix(in srgb,#000 22%,transparent);backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4)}
.dshp-restart-card h4{margin:0 0 8px;font-family:inherit;font-size:20px;font-weight:600;line-height:28px;color:inherit}
.dshp-restart-card p{margin:0 0 16px;font-size:16px;font-weight:500;line-height:24px;color:inherit}
.dshp-restart-card .dshp-modal-ops{display:flex;justify-content:flex-end;gap:8px}
.dshp-restart-card .dshp-btn{padding:8px 12px;font-size:16px;font-weight:600;color:var(--dsw-alias-label-primary,#16140f);background:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#fff) 40%,transparent);border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent)}
.dshp-restart-card .dshp-btn-primary,.dshp-restart-card .dshp-btn-primary:hover:not(:disabled){color:#fff;background:var(--dsw-alias-brand-primary,#2f6b4f);border-color:var(--dsw-alias-brand-primary,#2f6b4f)}
body[data-ds-dark-theme] .dshp-restart-card,.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);color:#f4f1ea;border-color:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 10%,transparent),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
body[data-ds-dark-theme] .dshp-restart-card .dshp-btn,.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card .dshp-btn{color:#f4f1ea;background:color-mix(in srgb,#1c1e24 42%,transparent);border-color:color-mix(in srgb,#6dbf8c 32%,transparent)}
body[data-ds-dark-theme] .dshp-restart-card .dshp-btn-primary,body[data-ds-dark-theme] .dshp-restart-card .dshp-btn-primary:hover:not(:disabled),.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card .dshp-btn-primary,.dshp-restart-mask[data-theme="dusk"] .dshp-restart-card .dshp-btn-primary:hover:not(:disabled){color:#fff;background:#3d8f68;border-color:#3d8f68}
.dshp-notice{font-size:12.5px;line-height:1.4}
.dshp-notice{font-size:12px;line-height:16px}
.dshp-notice.is-ok{color:var(--dshp-ok)}
.dshp-notice.is-bad{color:var(--dshp-bad)}
.dshp-skel{height:12px;border-radius:6px;background:linear-gradient(90deg,var(--dshp-fill),var(--dshp-line),var(--dshp-fill));background-size:200% 100%;animation:dshp-pulse 1.2s ease-in-out infinite}
.dshp-active{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:10px 12px;margin-bottom:12px;border:1px solid var(--dshp-line);background:var(--dshp-bg);border-radius:8px}
.dshp-active b{font-family:var(--dshp-display);font-weight:500}
.dshp-empty{padding:28px 12px;font-size:13px;color:var(--dshp-mute);text-align:center}
.dshp-skel{height:12px;border-radius:4px;background:var(--dshp-fill);animation:dshp-pulse 1.2s var(--dshp-ease) infinite}
.dshp-active{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:12px;margin-bottom:12px;border-radius:8px}
.dshp-active b{font-family:inherit;font-weight:600}
.dshp-empty{padding:24px 12px;font-size:13px;color:var(--dshp-mute);text-align:center}
.dshp-split{display:flex;flex-direction:column;gap:12px}
.dshp-rulelist{display:flex;flex-direction:column;border:1px solid var(--dshp-line);border-radius:8px;background:var(--dshp-bg);overflow:hidden}
.dshp-rulelist{display:flex;flex-direction:column;border-radius:8px;overflow:hidden}
.dshp-rulebody{max-height:240px;overflow:auto}
.dshp-ruleitem{display:flex;align-items:center;gap:12px;width:100%;padding:10px 12px;border:0;border-bottom:1px solid var(--dshp-line);background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
.dshp-ruleitem{display:flex;align-items:center;gap:12px;width:100%;padding:12px;border:0;border-bottom:1px solid var(--dshp-line);background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
.dshp-ruleitem:hover{background:var(--dshp-fill)}
.dshp-ruleitem.is-edit{background:var(--dshp-accent-soft)}
.dshp-rule-main{flex:1;min-width:0}
.dshp-rule-name{display:flex;align-items:center;gap:8px;font-family:var(--dshp-display);font-size:14px;line-height:1.35}
.dshp-rule-name{display:flex;align-items:center;gap:8px;font-family:inherit;font-size:14px;line-height:20px;font-weight:600}
.dshp-rule-meta{display:block;margin-top:3px;font-family:var(--dshp-mono);font-size:11px;color:var(--dshp-mute)}
.dshp-rule-ops{display:flex;flex-direction:row;align-items:center;gap:6px;flex-shrink:0}
.dshp-create{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-top:1px solid var(--dshp-line);background:var(--dshp-paper)}
.dshp-create{display:flex;flex-direction:column;gap:8px;padding:12px;border-top:1px solid var(--dshp-line)}
.dshp-create-row{display:flex;gap:6px;align-items:center}
.dshp-create .dshp-field{flex:1;min-width:0;width:auto}
.dshp-editor{display:flex;flex-direction:column;gap:10px;min-width:0;border:1px solid var(--dshp-line);border-radius:8px;background:var(--dshp-bg);padding:12px;min-height:320px}
.dshp-editor{display:flex;flex-direction:column;gap:12px;min-width:0;border-radius:8px;padding:12px;min-height:320px}
.dshp-editor .dshp-area{flex:1;min-height:240px}
.dshp-editor-empty{flex:1;display:flex;align-items:center;justify-content:center;color:var(--dshp-mute);font-size:13px;min-height:160px}
.dshp-block{padding:14px 0;border-top:1px solid var(--dshp-line)}
.dshp-block-head{display:flex;align-items:center;gap:10px;margin:0 0 8px}
.dshp-block-head h4{margin:0;font-family:var(--dshp-display);font-size:14px;font-weight:500;flex:1;color:var(--dshp-ink)}
.dshp-block{padding:16px 0;border-top:1px solid var(--dshp-line)}
.dshp-block-head{display:flex;align-items:center;gap:8px;margin:0 0 8px}
.dshp-block-head h4{margin:0;font-family:inherit;font-size:14px;line-height:20px;font-weight:600;flex:1;color:var(--dshp-ink)}
.dshp-block-hint{margin:8px 0 0;font-size:12px;line-height:1.55;color:var(--dshp-mute)}
.dshp-policy-row{display:flex;align-items:center;gap:10px}
.dshp-policy-row{display:flex;align-items:center;gap:8px}
.dshp-policy-row>label{font-size:12px;color:var(--dshp-mute);flex:0 0 auto}
.dshp-cwd-path{margin:0 0 8px;font-family:var(--dshp-mono);font-size:11px;color:var(--dshp-mute);word-break:break-all;line-height:1.5}
.dshp-cwd-list{display:flex;flex-direction:column;border:1px solid var(--dshp-line);border-radius:8px;background:var(--dshp-bg);overflow:hidden}
.dshp-cwd-item{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border-bottom:1px solid var(--dshp-line);cursor:pointer;margin:0}
.dshp-cwd-list{display:flex;flex-direction:column;border-radius:8px;overflow:hidden}
.dshp-cwd-item{display:flex;align-items:flex-start;gap:8px;padding:12px;border-bottom:1px solid var(--dshp-line);cursor:pointer;margin:0}
.dshp-cwd-item:last-child{border-bottom:0}
.dshp-cwd-item:hover{background:var(--dshp-fill)}
.dshp-cwd-item.is-on{background:var(--dshp-accent-soft)}
.dshp-cwd-item input{margin:3px 0 0;flex:0 0 auto}
.dshp-cwd-main{flex:1;min-width:0}
.dshp-cwd-name{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-family:var(--dshp-display);font-size:13.5px;line-height:1.35;color:var(--dshp-ink)}
.dshp-cwd-name{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-family:inherit;font-size:14px;line-height:20px;font-weight:600;color:var(--dshp-ink)}
.dshp-cwd-badge{font-family:var(--dshp-mono);font-size:10px;letter-spacing:.04em;text-transform:uppercase;padding:1px 7px;border-radius:99px;border:1px solid var(--dshp-line);color:var(--dshp-mute);line-height:1.6}
.dshp-cwd-size{font-family:var(--dshp-mono);font-size:11px;color:var(--dshp-mute)}
.dshp-cwd-sub{margin-top:3px;font-family:var(--dshp-mono);font-size:11px;color:var(--dshp-mute);word-break:break-all}
.dshp-cwd-prev{margin-top:4px;font-size:11px;line-height:1.5;color:var(--dshp-mute);max-height:34px;overflow:hidden}
@keyframes dshp-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}
@keyframes dshp-pulse{0%,100%{opacity:.4}50%{opacity:1}}
@media (max-width:640px){.dshp-metrics{grid-template-columns:1fr}.dshp-ruleitem{flex-wrap:wrap}.dshp-rule-ops{width:100%;justify-content:flex-end}}
@media (prefers-reduced-motion:reduce){.dshp-btn,.dshp-bar>i{transition:none}.dshp-skel{animation:none}}
.dshp-root em,.dshp-dock em,.rt-flow-action.inferred,.rt-ap-act.inferred{font-style:normal}
@media (prefers-reduced-motion:reduce){.dshp-btn,.dshp-bar>i,.dshp-flow-node{transition:opacity 300ms var(--dshp-ease)}.dshp-btn:hover:not(:disabled),.dshp-flow-node.is-cur{transform:none}.dshp-skel{animation:none}}
.dshp-dock{position:fixed;top:12px;right:12px;z-index:10050;display:flex;flex-direction:column;width:var(--dshp-dock-w,620px);height:var(--dshp-dock-h,72vh);min-width:380px;min-height:320px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);box-sizing:border-box;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,var(--dshp-paper,#1c1c1c)) 52%,transparent);backdrop-filter:blur(22px) saturate(1.35);-webkit-backdrop-filter:blur(22px) saturate(1.35);border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 65%,transparent);border-radius:12px;box-shadow:0 18px 48px color-mix(in srgb,#000 30%,transparent),0 0 0 1px color-mix(in srgb,#fff 6%,transparent);pointer-events:auto;color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));overflow:visible}
.dshp-dock{position:fixed;top:12px;right:12px;z-index:10050;display:flex;flex-direction:column;width:var(--dshp-dock-w,620px);height:var(--dshp-dock-h,72vh);min-width:380px;min-height:320px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);box-sizing:border-box;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,var(--dshp-paper,#fffcf7)) 52%,transparent);backdrop-filter:blur(22px) saturate(1.35);-webkit-backdrop-filter:blur(22px) saturate(1.35);border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 65%,transparent);border-radius:12px;box-shadow:0 18px 48px color-mix(in srgb,#000 30%,transparent),0 0 0 1px color-mix(in srgb,#fff 6%,transparent);pointer-events:auto;color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));overflow:visible}
.dshp-dock[data-open="0"]{display:none}
.dshp-launch{position:fixed;right:16px;bottom:16px;z-index:10040;appearance:none;display:inline-flex;align-items:center;gap:6px;height:36px;padding:0 14px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 55%,transparent);border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1c1c) 72%,transparent);color:var(--dsw-alias-label-primary,#f2f2f2);cursor:pointer;font:13px/1 inherit;box-shadow:0 8px 22px color-mix(in srgb,#000 28%,transparent);pointer-events:auto}
.dshp-launch{position:fixed;right:16px;bottom:16px;z-index:10040;appearance:none;display:inline-flex;align-items:center;gap:6px;height:36px;padding:0 14px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 55%,transparent);border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);color:var(--dsw-alias-label-primary,#16140f);cursor:pointer;font:13px/1 inherit;box-shadow:0 8px 22px color-mix(in srgb,#000 28%,transparent);pointer-events:auto}
.dshp-launch:hover{border-color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent)}
.dshp-launch[data-open="1"],.dshp-launch[data-hide="1"]{display:none}
.dshp-dock-head{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 55%,transparent);background:transparent;cursor:grab;user-select:none;touch-action:none;color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));border-radius:12px 12px 0 0}
.dshp-dock-head{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 55%,transparent);background:transparent;cursor:grab;user-select:none;touch-action:none;color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));border-radius:12px 12px 0 0}
.dshp-dock-head:active{cursor:grabbing}
.dshp-dock-head b{font-size:14px;font-weight:600;color:inherit;text-shadow:0 1px 0 color-mix(in srgb,#000 18%,transparent)}
.dshp-dock-head button{cursor:pointer;color:inherit;background:color-mix(in srgb,var(--dsw-alias-bg-layer-2,rgba(127,127,127,.18)) 55%,transparent)}
.dshp-dock-tabs{display:flex;gap:4px;padding:0 12px;border-bottom:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 55%,transparent);background:transparent}
.dshp-dock-tab{appearance:none;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--dsw-alias-label-secondary,var(--dshp-mute,#b8b4ac));border-radius:0;padding:10px 14px 8px;margin-bottom:-1px;cursor:pointer;font:13px/1.2 inherit;text-shadow:0 1px 0 color-mix(in srgb,#000 12%,transparent)}
.dshp-dock-tabs{display:flex;gap:8px;padding:0 12px;border-bottom:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 55%,transparent);background:transparent}
.dshp-dock-tab{appearance:none;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--dsw-alias-label-secondary,var(--dshp-mute,#b8b4ac));border-radius:0;padding:8px 12px;margin-bottom:-1px;cursor:pointer;font:13px/1.2 inherit;text-shadow:0 1px 0 color-mix(in srgb,#000 12%,transparent)}
.dshp-dock-tab:hover{color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2))}
.dshp-dock-tab.on{color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));font-weight:600;border-bottom-color:var(--dsw-alias-brand-primary,#6dbf8c);background:transparent}
.dshp-dock-body{flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column;background:transparent;border-radius:0 0 12px 12px}
.dshp-dock-body .dshp-root{max-width:none;height:100%;flex:1;min-height:0;overflow:auto;background:transparent!important;--dshp-bg:transparent;--dshp-paper:color-mix(in srgb,var(--dshp-ink) 7%,transparent);--dshp-fill:color-mix(in srgb,var(--dshp-ink) 6%,transparent);--dshp-line:color-mix(in srgb,var(--dshp-ink) 20%,transparent);--dshp-accent-soft:color-mix(in srgb,var(--dshp-accent) 22%,transparent)}
.dshp-dock-body .dshp-panel,.dshp-dock-body .dshp-metric,.dshp-dock-body .dshp-group,.dshp-dock-body .dshp-editor,.dshp-dock-body .dshp-active,.dshp-dock-body .dshp-ask,.dshp-dock-body .dshp-create,.dshp-dock-body .dshp-rulelist,.dshp-dock-body .dshp-table,.dshp-dock-body .dshp-ruleitem,.dshp-dock-body .dshp-cwd-list,.dshp-dock-body .dshp-cwd-item{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#f7f4ee) 74%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 32%,transparent)!important;color:var(--dshp-ink)!important;box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 32%,transparent);backdrop-filter:blur(16px) saturate(1.3);-webkit-backdrop-filter:blur(16px) saturate(1.3)}
.dshp-dock-body .dshp-field,.dshp-dock-body .dshp-area{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 88%,transparent)!important;color:var(--dshp-ink)!important;border-color:color-mix(in srgb,var(--dsw-alias-border-l1,#8a8478) 72%,transparent)!important}
.dshp-dock-body .dshp-root{max-width:none;height:100%;flex:1;min-height:0;overflow:auto;background:transparent!important;padding:12px;gap:12px}
.dshp-dock-body .dshp-panel{padding:12px}
.dshp-dock-body .dshp-head{margin-bottom:12px}
.dshp-dock-body .dshp-sub{margin:16px 0 8px}
.dshp-dock-body .dshp-metrics{margin-bottom:12px}
.dshp-dock-body .dshp-panel,.dshp-dock-body .dshp-metric,.dshp-dock-body .dshp-group,.dshp-dock-body .dshp-editor,.dshp-dock-body .dshp-active,.dshp-dock-body .dshp-ask,.dshp-dock-body .dshp-create,.dshp-dock-body .dshp-rulelist,.dshp-dock-body .dshp-cwd-list{background:var(--dshp-paper)!important;border-color:var(--dshp-line)!important;color:var(--dshp-ink)!important;box-shadow:inset 0 1px 0 var(--dshp-hi);backdrop-filter:var(--dshp-glass);-webkit-backdrop-filter:var(--dshp-glass)}
.dshp-dock-body .dshp-field,.dshp-dock-body .dshp-area{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 38%,transparent)!important;color:var(--dshp-ink)!important;border-color:var(--dshp-line)!important}
.dshp-dock-body select.dshp-field,.dshp-dock-body .dshp-field.dshp-ver{background:var(--dsw-alias-bg-layer-1,#fff)!important;color:var(--dshp-ink)!important;color-scheme:inherit}
.dshp-dock[data-theme="white"] select.dshp-field option,.dshp-dock[data-theme="white"] .dshp-field.dshp-ver option{background:#fff;color:#16140f}
.dshp-dock[data-theme="dusk"] select.dshp-field option,.dshp-dock[data-theme="dusk"] .dshp-field.dshp-ver option{background:#1b1d22;color:#f4f1ea}
@@ -981,11 +1035,11 @@ body[data-ds-dark-theme] .dshp-restart-card .dshp-btn-primary,body[data-ds-dark-
.dshp-dock-body .rt-pane{min-height:0;overflow:auto!important}
.dshp-dock-body .rt-embedded>.rt-head{padding:8px 12px}
.dshp-dock-body .rt-embedded>.rt-head .rt-title{font-size:14px;letter-spacing:0}
.dshp-dock-body .rt-tabs{gap:2px;padding:6px 10px 0;flex-wrap:wrap}
.dshp-dock-body .rt-tab{border-radius:0;border-bottom:2px solid transparent;margin-bottom:-1px;padding:8px 9px 7px;background:transparent;font-size:14px}
.dshp-dock-body .rt-tabs{gap:8px;padding:0 12px;flex-wrap:wrap}
.dshp-dock-body .rt-tab{border-radius:0;border-bottom:2px solid transparent;margin-bottom:-1px;padding:8px 12px;background:transparent;font-size:14px}
.dshp-dock-body .rt-tab.on{border-bottom-color:var(--dsw-alias-brand-primary,#6d8f78);background:transparent;font-weight:650}
.dshp-dock-body .rt-row:hover,.dshp-dock-body .rt-item:hover,.dshp-dock-body .rt-item.on,.dshp-dock-body .rt-seg:hover,.dshp-dock-body .rt-seg.on,.dshp-dock-body .rt-vrow:hover,.dshp-dock-body .rt-score-row:hover{background:var(--rt-surf-2)!important}
body:not([data-ds-dark-theme]) .dshp-auth-modal{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 92%,transparent);color:var(--dsw-alias-label-primary,#1a1916);border-color:color-mix(in srgb,var(--dsw-alias-border-l1,#c9c3b6) 80%,transparent);backdrop-filter:blur(18px) saturate(1.3);-webkit-backdrop-filter:blur(18px) saturate(1.3)}
body:not([data-ds-dark-theme]) .dshp-auth-modal{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);color:var(--dsw-alias-label-primary,#1a1916);border-color:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 48%,transparent)}
body:not([data-ds-dark-theme]) .dshp-auth-legal{background:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 90%,transparent);color:var(--dsw-alias-label-primary,#1a1916);border-color:color-mix(in srgb,var(--dsw-alias-border-l1,#c9c3b6) 80%,transparent)}
body:not([data-ds-dark-theme]) .dshp-auth-warn{background:color-mix(in srgb,#f5e6c8 88%,transparent);color:#6b4a10}
body:not([data-ds-dark-theme]) .dshp-auth-ops button{border-color:var(--dsw-alias-border-l1,#c9c3b6);color:var(--dsw-alias-label-primary,#1a1916);background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 88%,transparent)}
@@ -999,11 +1053,11 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
.dshp-dock-resize-b:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 35%,transparent)}
.dshp-auth-mask{position:fixed;inset:0;z-index:10100;background:rgba(0,0,0,.62);display:flex;align-items:center;justify-content:center;padding:20px;pointer-events:auto}
.dshp-env-gate{z-index:10200}
.dshp-auth-modal{width:min(680px,100%);max-height:min(88vh,820px);display:flex;flex-direction:column;gap:10px;padding:16px;border:1px solid var(--dsw-alias-border-l1,#333);border-radius:12px;background:var(--dsw-alias-bg-layer-1,#1a1a1a);color:var(--dsw-alias-label-primary,#eee)}
.dshp-auth-modal{width:min(680px,100%);max-height:min(88vh,820px);display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);border-radius:16px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);color:var(--dsw-alias-label-primary,#eee);backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 10%,transparent)}
.dshp-auth-modal h2{margin:0;font-size:16px;font-weight:600}
.dshp-auth-warn{padding:8px 10px;border-radius:8px;background:#3a2e18;color:#f0d48a;font-size:13px}
.dshp-auth-legal{overflow:auto;height:300px;margin:0;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1,#333);border-radius:8px;background:#121212;font-size:13px;line-height:1.55}
.dshp-auth-legal h3{margin:14px 0 4px;font-size:13px}
.dshp-auth-legal{overflow:auto;height:300px;margin:0;padding:12px;border:1px solid var(--dshp-line,var(--dsw-alias-border-l1,#333));border-radius:8px;background:var(--dshp-paper,color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent));font-size:13px;line-height:1.55}
.dshp-auth-legal h3{margin:12px 0 4px;font-size:13px}
.dshp-auth-legal h3:first-child{margin-top:0}
.dshp-auth-legal p{margin:0 0 8px}
.dshp-auth-checks{display:flex;flex-direction:column;gap:8px;font-size:13px}
@@ -1030,26 +1084,29 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
.dshp-tab-btn.on{color:var(--dsw-alias-brand-primary,#6dbf8c)}
.dshp-tab-btn.on:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;border-radius:2px;background:var(--dsw-alias-brand-primary,#6dbf8c)}
/* Glass follows the host color. Weight and background opacity are kept separate: the shell is translucent, the text sits on a more solid layer. */
.dshp-dock{font-family:"Segoe UI","Microsoft YaHei UI","PingFang SC","Noto Sans SC",system-ui,sans-serif;font-size:14px;line-height:1.6;font-weight:500;-webkit-font-smoothing:antialiased;text-shadow:none}
.dshp-dock[data-theme="white"],.dshp-dock[data-theme="dusk"]{background:linear-gradient(165deg,color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 50%,transparent),color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 18%,transparent) 46%,color-mix(in srgb,var(--dsw-alias-bg-layer-2,#fff) 28%,transparent))!important;backdrop-filter:blur(26px) saturate(1.45)!important;-webkit-backdrop-filter:blur(26px) saturate(1.45)!important;color:var(--dshp-ink)!important;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 36%,transparent)!important;box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 42%,transparent),0 18px 44px color-mix(in srgb,#000 18%,transparent)!important}
.dshp-dock[data-theme="dusk"]{--dshp-ink:var(--dsw-alias-label-primary,#f4f1ea);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 84%,var(--dsw-alias-label-secondary,#c9c3b8))}
.dshp-dock[data-theme="white"]{--dshp-ink:var(--dsw-alias-label-primary,#16140f);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 76%,var(--dsw-alias-label-secondary,#3c362e))}
.dshp-dock .dshp-dock-head,.dshp-dock .dshp-dock-tabs{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,transparent) 28%,transparent)!important;color:var(--dshp-ink)!important}
.dshp-dock{font-family:inherit;font-size:14px;line-height:1.6;font-weight:500;-webkit-font-smoothing:antialiased;text-shadow:none}
.dshp-dock[data-theme="white"],.dshp-dock[data-theme="dusk"]{backdrop-filter:blur(22px) saturate(1.4)!important;-webkit-backdrop-filter:blur(22px) saturate(1.4)!important;color:var(--dshp-ink)!important;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent)!important;--dshp-glass:blur(18px) saturate(1.35);--dshp-accent:var(--dsw-alias-brand-primary,#3d8f68);--dshp-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent)}
.dshp-dock[data-theme="white"]{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent)!important;--dshp-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);--dshp-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);--dshp-hi:color-mix(in srgb,#fff 48%,transparent);--dshp-ink:var(--dsw-alias-label-primary,#16140f);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 76%,var(--dsw-alias-label-secondary,#3c362e));--dshp-ok:#2f6b4f;--dshp-warn:#8a5a12;--dshp-bad:#9a3434;box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 48%,transparent),0 16px 40px color-mix(in srgb,#000 16%,transparent)!important}
.dshp-dock[data-theme="dusk"]{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent)!important;--dshp-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);--dshp-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);--dshp-hi:color-mix(in srgb,#fff 10%,transparent);--dshp-ink:var(--dsw-alias-label-primary,#f4f1ea);--dshp-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 84%,var(--dsw-alias-label-secondary,#c9c3b8));--dshp-ok:#8fd0a8;--dshp-warn:#e4c48a;--dshp-bad:#f0b4b4;box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 10%,transparent),0 16px 40px color-mix(in srgb,#000 28%,transparent)!important}
.dshp-dock .dshp-dock-head,.dshp-dock .dshp-dock-tabs{background:transparent!important;color:var(--dshp-ink)!important}
.dshp-dock .dshp-dock-head,.dshp-dock .dshp-dock-head b,.dshp-dock .dshp-dock-head button,.dshp-dock .dshp-dock-tab,.dshp-dock .dshp-dock-tab.on{color:var(--dshp-ink)!important;text-shadow:none!important;font-weight:600}
.dshp-dock .dshp-dock-tab{font-size:14px}
.dshp-dock .dshp-dock-tab.on{border-bottom-color:var(--dsw-alias-brand-primary,#6d8f78)!important}
.dshp-dock-body .rt-dock{font-size:14px!important;line-height:1.6!important;font-weight:500!important;color:var(--dshp-ink)!important;--rt-ink:var(--dshp-ink);--rt-mute:var(--dshp-mute);--rt-surf:color-mix(in srgb,var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-layer-1,#fff)) 40%,transparent);--rt-surf-2:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 62%,transparent);--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 30%,transparent)}
.dshp-dock-body .rt-dock{font-size:14px!important;line-height:1.6!important;font-weight:500!important;color:var(--dshp-ink)!important;--rt-ink:var(--dshp-ink);--rt-mute:var(--dshp-mute);--rt-paper:var(--dshp-paper);--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 28%,transparent);--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);--rt-fill:var(--dshp-fill);--rt-surf:var(--dshp-paper);--rt-surf-2:var(--dshp-fill);--rt-line:var(--dshp-line);--rt-hi:var(--dshp-hi);--rt-glass:var(--dshp-glass);--rt-accent:var(--dshp-accent);--rt-ok:var(--dshp-ok);--rt-warn:var(--dshp-warn);--rt-bad:var(--dshp-bad)}
.dshp-dock[data-theme="dusk"] .dshp-dock-body .rt-dock{--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 28%,transparent);--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 26%,transparent)}
body[data-ds-dark-theme] .dshp-launch{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);color:var(--dsw-alias-label-primary,#f4f1ea)}
.dshp-dock-body .rt-title,.dshp-dock-body .rt-tab,.dshp-dock-body .rt-tab.on,.dshp-dock-body .rt-card,.dshp-dock-body .rt-card h4,.dshp-dock-body .rt-row,.dshp-dock-body .rt-vrow,.dshp-dock-body .rt-kv,.dshp-dock-body .rt-kv b,.dshp-dock-body .rt-kv span,.dshp-dock-body .rt-mono,.dshp-dock-body .rt-empty,.dshp-dock-body .rt-foot,.dshp-dock-body .rt-tag,.dshp-dock-body .rt-item,.dshp-dock-body .rt-item-name,.dshp-dock-body .rt-item-desc,.dshp-dock-body .rt-sec-sub,.dshp-dock-body .rt-kb-sub,.dshp-dock-body .rt-seg-cidr,.dshp-dock-body .rt-seg-meta,.dshp-dock-body .rt-section,.dshp-dock-body .rt-note,.dshp-dock-body .rt-hint{color:var(--dshp-ink)!important;text-shadow:none!important;opacity:1!important}
.dshp-dock-body .rt-tab,.dshp-dock-body .rt-foot,.dshp-dock-body .rt-empty,.dshp-dock-body .rt-item-desc,.dshp-dock-body .rt-kb-sub,.dshp-dock-body .rt-kv span,.dshp-dock-body .rt-tag,.dshp-dock-body .rt-sec-sub{color:var(--dshp-mute)!important}
.dshp-dock-body .rt-card,.dshp-dock-body .rt-pane,.dshp-dock-body .rt-side,.dshp-dock-body .rt-table,.dshp-dock-body .rt-toolbar,.dshp-dock-body .rt-embedded>.rt-head,.dshp-dock-body .rt-tabs{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 72%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 28%,transparent)!important;color:var(--dshp-ink)!important;box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 26%,transparent)!important;backdrop-filter:blur(16px) saturate(1.3);-webkit-backdrop-filter:blur(16px) saturate(1.3)}
.dshp-dock-body .rt-btn,.dshp-dock-body .rt-input,.dshp-dock-body .rt-eng-select,.dshp-dock-body textarea.rt-input{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 90%,transparent)!important;color:var(--dshp-ink)!important;border-color:color-mix(in srgb,var(--dsw-alias-border-l1,#888) 70%,transparent)!important}
.dshp-dock-body .rt-card,.dshp-dock-body .rt-sess,.dshp-dock-body .rt-hit,.dshp-dock-body .rt-cred,.dshp-dock-body .rt-evi,.dshp-dock-body .rt-kb,.dshp-dock-body .rt-rep,.dshp-dock-body .rt-flow-node,.dshp-dock-body .rt-hcol{background:var(--dshp-paper)!important;border-color:var(--dshp-line)!important;color:var(--dshp-ink)!important;box-shadow:inset 0 1px 0 var(--dshp-hi)!important;backdrop-filter:var(--dshp-glass);-webkit-backdrop-filter:var(--dshp-glass)}
.dshp-dock-body .rt-pane,.dshp-dock-body .rt-side,.dshp-dock-body .rt-list,.dshp-dock-body .rt-table,.dshp-dock-body .rt-toolbar,.dshp-dock-body .rt-embedded>.rt-head,.dshp-dock-body .rt-tabs,.dshp-dock-body .rt-foot,.dshp-dock-body .rt-livebar,.dshp-dock-body .rt-concl{background:transparent!important;box-shadow:none!important}
.dshp-dock-body .rt-btn,.dshp-dock-body .rt-input,.dshp-dock-body .rt-eng-select,.dshp-dock-body textarea.rt-input,.dshp-dock-body .rt-textarea,.dshp-dock-body .rt-code,.dshp-dock-body .rt-evi-body{background:var(--rt-well)!important;color:var(--dshp-ink)!important;border-color:var(--dshp-line)!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.dshp-dock-body .rt-btn-primary{background:var(--dsw-alias-brand-primary,#3f6b52)!important;border-color:var(--dsw-alias-brand-primary,#3f6b52)!important;color:#fff!important}
.dshp-dock[data-theme="white"] .dshp-dock-body .rt-eng-select option,.dshp-dock[data-theme="white"] .dshp-dock-body .rt-input option{background:#fff;color:#16140f}
.dshp-dock[data-theme="dusk"] .dshp-dock-body .rt-eng-select option,.dshp-dock[data-theme="dusk"] .dshp-dock-body .rt-input option{background:#1b1d22;color:#f4f1ea}
.dshp-dock-body .rt-err{font-weight:650}
.dshp-dock[data-theme="white"] .dshp-dock-body .rt-err{color:#9a3434!important}
.dshp-dock[data-theme="dusk"] .dshp-dock-body .rt-err{color:#f0b4b4!important}
.dshp-dock-body .rt-rep-http,.dshp-dock-body pre{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 84%,transparent)!important;color:var(--dshp-ink)!important;border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,#888) 60%,transparent)!important}
.dshp-dock-body .rt-rep-http,.dshp-dock-body pre{background:var(--rt-well)!important;color:var(--dshp-ink)!important;border:1px solid var(--dshp-line)!important}
`;
function formatSize(bytes) {
@@ -1098,6 +1155,53 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
return h("button", Object.assign({ type: type || "button", className: cls }, rest), children);
}
const FLOW_STEPS = {
apply: ["home", "locate", "override", "patch", "shim", "flash", "seed", "done"],
revert: ["locate", "revert", "shim", "done"],
uninstall: ["locate", "revert", "shim", "flash", "cleanup", "done"],
};
function flowLabel(id, t) {
if (id === "revert") return t("flow.revert.step");
if (id === "cleanup") return t("flow.cleanup");
return t("flow." + id);
}
function ApplyFlow({ progress, busy, t }) {
const kind = (progress && progress.kind) || "apply";
const steps = FLOW_STEPS[kind] || FLOW_STEPS.apply;
const stage = (progress && progress.stage) || "idle";
const failed = Boolean(progress && progress.error);
const active = Boolean(busy || (progress && progress.active));
const idx = steps.indexOf(stage === "restart" ? "done" : stage);
return h("div", {
className: "dshp-flow" + (active ? " is-on" : "") + (failed ? " is-bad" : ""),
"aria-label": t("flow.title"),
},
h("span", { className: "dshp-flow-kind" }, t("flow." + kind)),
steps.flatMap((id, i) => {
const done = idx > i || (stage === "done" && !failed);
const cur = active && idx === i && stage !== "idle";
const bad = failed && idx === i;
const nodes = [];
if (i) {
nodes.push(h("span", {
key: "w-" + id,
className: "dshp-flow-wire" + (done || cur ? " is-on" : ""),
}, h("i")));
}
nodes.push(h("span", {
key: id,
className: "dshp-flow-node" + (done ? " is-done" : "") + (cur ? " is-cur" : "") + (bad ? " is-bad" : ""),
},
h("b", null, String(i + 1)),
h("em", null, flowLabel(id, t)),
));
return nodes;
}),
);
}
function Pill({ value, label }) {
const t = useT();
return h("span", { className: "dshp-pill is-" + statusKind(value) }, label || statusLabel(value, t));
@@ -1638,6 +1742,30 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
return () => clearTimeout(timer);
}, [loadAll]);
useEffect(() => {
if (!patchBusy && !uninstallBusy) return undefined;
let stop = false;
const tick = () => {
apiJson("/dsh-purge/status")
.then((d) => {
if (stop || !d) return;
if (d.apply_progress) {
setState((prev) => Object.assign({}, prev || {}, d.ok ? d : { apply_progress: d.apply_progress }));
return;
}
if (!d.ok) return;
setState((prev) => Object.assign({}, prev || {}, d));
})
.catch(() => {});
};
tick();
const id = setInterval(tick, 450);
return () => {
stop = true;
clearInterval(id);
};
}, [patchBusy, uninstallBusy]);
const rejectNeedPrompt = useCallback((tr) => {
setAskRestart(false);
setNotice({ kind: "error", text: tr("need.prompt") });
@@ -1652,6 +1780,14 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
setPatchBusy(true);
setAskRestart(false);
setNotice({ kind: "idle", text: "" });
setState((prev) => Object.assign({}, prev || {}, {
apply_progress: {
active: true,
kind: action === "revert" ? "revert" : "apply",
stage: action === "revert" ? "locate" : "home",
error: "",
},
}));
const applyContent = action === "apply" ? readPromptBox() : "";
fetch("/dsh-purge/" + action, {
method: "POST",
@@ -1844,6 +1980,9 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
setAskRestart(false);
const tr = tRef.current;
setNotice({ kind: "ok", text: tr("uninstall.applying") });
setState((prev) => Object.assign({}, prev || {}, {
apply_progress: { active: true, kind: "uninstall", stage: "locate", error: "" },
}));
apiJson("/dsh-purge/uninstall", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
.then((d) => {
if (!d || !d.ok) throw new Error((d && d.error) || "uninstall failed");
@@ -1873,7 +2012,13 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
const tally = located ? tallyPatches(patchRowsOf(s)) : { applied: 0, pending: 0, unmatched: 0, skipped: 0, total: 0 };
const total = tally.total;
const applied = tally.applied;
const pct = located && total ? Math.round((applied / total) * 100) : 0;
const job = s && s.apply_progress;
const jobOn = Boolean(patchBusy || uninstallBusy || (job && job.active));
const jobSteps = FLOW_STEPS[(job && job.kind) || "apply"] || FLOW_STEPS.apply;
const jobIdx = jobSteps.indexOf(job && job.stage === "restart" ? "done" : ((job && job.stage) || "idle"));
const pct = jobOn
? Math.round(((job && job.stage === "done" ? jobSteps.length : Math.max(jobIdx, 0) + 0.45) / jobSteps.length) * 100)
: (located && total ? Math.round((applied / total) * 100) : 0);
const metricNotes = [];
if (tally.pending) metricNotes.push(t("metric.pendingShort", { n: tally.pending }));
if (tally.unmatched) metricNotes.push(t("metric.unmatchedShort", { n: tally.unmatched }));
@@ -1983,10 +2128,11 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
h("div", { className: "dshp-metric" }, h("div", { className: "dshp-skel" }), h("div", { className: "dshp-skel", style: { width: "40%" } })),
h("div", { className: "dshp-metric" }, h("div", { className: "dshp-skel" }), h("div", { className: "dshp-skel", style: { width: "40%" } })),
),
h("div", { className: "dshp-bar", "aria-hidden": "true" }, h("i", { style: { width: pct + "%" } })),
h(ApplyFlow, { progress: s && s.apply_progress, busy: patchBusy || uninstallBusy, t: t }),
h("div", { className: "dshp-bar", "aria-hidden": "true" }, h("i", { style: { transform: "scaleX(" + (pct / 100) + ")" } })),
h(PatchGroups, { state: s }),
h(HooksDenySection, { onSaved: loadAll }),
h("div", { className: "dshp-row", style: { marginTop: 14 } },
h("div", { className: "dshp-row", style: { marginTop: 12 } },
h(Btn, { kind: "primary", disabled: patchBusy || uninstallBusy || !overrideLoaded, onClick: () => doAction("apply", "action.apply") }, patchBusy ? t("btn.apply.busy") : t("btn.apply")),
h(Btn, { kind: "danger", disabled: patchBusy || uninstallBusy, onClick: () => doAction("revert", "action.revert") }, t("btn.revert")),
h(Btn, { kind: "solid-danger", disabled: patchBusy || uninstallBusy, onClick: () => setAskUninstall(true) }, uninstallBusy ? t("btn.uninstall.busy") : t("btn.uninstall")),
@@ -3502,12 +3648,24 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
*/
const CSS = `
.rt-dock{position:fixed;top:12px;right:12px;z-index:20;display:flex;flex-direction:column;box-sizing:border-box;
background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1c1c) 52%,transparent);
backdrop-filter:blur(20px) saturate(1.3);-webkit-backdrop-filter:blur(20px) saturate(1.3);
border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,#444) 70%,transparent);
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
--rt-line-2:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 50%,transparent);
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#16140f);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
background:var(--rt-paper);
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
border:1px solid var(--rt-line);
border-radius:12px;
box-shadow:0 18px 48px color-mix(in srgb,#000 28%,transparent);pointer-events:auto;color:var(--dsw-alias-label-primary);
font-size:13px;line-height:1.5}
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 16%,transparent);
pointer-events:auto;color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5}
.rt-dock.rt-embedded{position:relative;inset:auto;width:100%;height:100%;max-width:none;border:0;border-radius:0;box-shadow:none;background:transparent!important;backdrop-filter:none;-webkit-backdrop-filter:none}
.rt-grip,.rt-resize-r,.rt-resize-b,.rt-resize-c{position:absolute;z-index:3;touch-action:none}
.rt-grip{left:-3px;top:0;bottom:0;width:8px;cursor:ew-resize;background:transparent}
@@ -3645,8 +3803,20 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
.rt-link{color:var(--dsw-alias-brand-primary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rt-link:hover{text-decoration:underline}
.rt-full{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;
background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;
border-top:3px solid var(--dsw-alias-brand-primary)}
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#16140f);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
background:var(--rt-paper);color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5;
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
border:1px solid var(--rt-line);box-shadow:inset 0 1px 0 var(--rt-hi)}
.rt-full .rt-head{padding:12px 18px}
.rt-full .rt-tabs{padding:10px 18px 0;gap:6px;flex-wrap:wrap}
.rt-full .rt-side{width:260px}
@@ -4038,7 +4208,83 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
.rt-shot-zoom{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.82);display:flex;flex-direction:column;
align-items:center;justify-content:center;gap:10px;cursor:zoom-out;padding:18px}
.rt-shot-zoom img{max-width:96vw;max-height:86vh;border-radius:6px;box-shadow:0 18px 48px rgba(0,0,0,.5)}
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}` /* ---------------------------------------------------------- 桥接与状态 */
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}
body[data-ds-dark-theme] .rt-dock,body[data-ds-dark-theme] .rt-full,
.dshp-dock[data-theme="dusk"] .rt-dock,.dshp-dock[data-theme="dusk"] .rt-full{
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#1c1e24) 34%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 26%,transparent);
--rt-hi:color-mix(in srgb,#fff 10%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#f4f1ea);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 78%,var(--dsw-alias-label-secondary,#c9c3b8));
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);
--rt-ok:#8fd0a8;--rt-warn:#e4c48a;--rt-bad:#f0b4b4;
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
.rt-card,.rt-sess,.rt-hit,.rt-cred,.rt-evi,.rt-kb,.rt-rep,.rt-flow-node,.rt-hflow-node,.rt-atest,.rt-hcol,.rt-ap-hit,.rt-rep-req,.rt-rep-trace,.rt-shots,.rt-modal-box{
background:var(--rt-paper)!important;border-color:var(--rt-line)!important;color:var(--rt-ink);
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);box-shadow:inset 0 1px 0 var(--rt-hi)}
.rt-score-group,.rt-sec,.rt-kb-cat,.rt-evi-head,.rt-rep-req-head,.rt-ap-head,.rt-ap-goal,.rt-rep-stage{
background:var(--rt-paper-2)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)}
.rt-head,.rt-tabs,.rt-toolbar,.rt-foot,.rt-side,.rt-list,.rt-pane,.rt-livebar,.rt-concl,.rt-subtabs,.rt-kb-filter,.rt-kb-cats,.rt-body,.rt-table,.rt-main{
background:transparent!important;box-shadow:none}
.rt-row.head,.rt-score-row.head,.rt-vrow.head{
background:var(--rt-paper)!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.rt-row:hover,.rt-vrow:hover,.rt-score-row:hover,.rt-item:hover,.rt-item.on,.rt-seg:hover,.rt-seg.on,.rt-icon-btn:hover,.rt-hbtn:hover,.rt-kb-head:hover,.rt-sidehead-btn:hover,.rt-sec:hover,.rt-rep-stage:hover,.rt-concl-i:hover,.rt-concl-i.on{
background:var(--rt-fill)!important}
.rt-btn,.rt-icon-btn,.rt-hbtn,.rt-input,.rt-eng-select,.rt-textarea,.rt-chip,.rt-code,.rt-hit-evi,.rt-atest-notes,.rt-clip-body,.rt-evi-body,.rt-rep-http,.rt-md,.rt-kb-tpl-row,.rt-hit-row,.rt-ap-asset,.rt-ap-tunnel{
background:var(--rt-well)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)!important;
backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.rt-btn{border-radius:8px;transition:transform 500ms var(--rt-ease),opacity 300ms var(--rt-ease)}
.rt-btn:hover:not(:disabled){transform:translateY(-1px);border-color:var(--rt-accent)}
.rt-btn:active:not(:disabled){transform:scale(.98)}
.rt-btn:focus-visible,.rt-input:focus-visible,.rt-tab:focus-visible,.rt-icon-btn:focus-visible,.rt-hbtn:focus-visible{
outline:2px solid var(--rt-accent);outline-offset:2px}
.rt-btn-primary,.rt-btn-primary:hover:not(:disabled){background:var(--rt-accent)!important;border-color:var(--rt-accent)!important;color:#fff!important;backdrop-filter:none}
.rt-input option,.rt-eng-select option{background:var(--dsw-alias-bg-layer-1,#fff);color:var(--rt-ink)}
body[data-ds-dark-theme] .rt-input option,body[data-ds-dark-theme] .rt-eng-select option,.dshp-dock[data-theme="dusk"] .rt-input option,.dshp-dock[data-theme="dusk"] .rt-eng-select option{background:#1b1d22;color:#f4f1ea}
.rt-pri-high,.rt-test-blocked,.rt-sev-critical,.rt-sev-high{color:var(--rt-bad)!important;background:color-mix(in srgb,var(--rt-bad) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-bad) 40%,var(--rt-line))!important}
.rt-pri-medium,.rt-test-testing,.rt-tag-active{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
.rt-pri-low{color:var(--rt-mute)!important;background:var(--rt-paper-2)!important;border:1px solid var(--rt-line)!important}
.rt-gain,.rt-counted,.rt-scorepts,.rt-flow-pts,.rt-hflow-pts,.rt-hcol-pts,.rt-ap-pts{color:var(--rt-ok)!important;background:color-mix(in srgb,var(--rt-ok) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-ok) 38%,var(--rt-line))!important}
.rt-secret{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 14%,transparent)!important;border-color:color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
.rt-scope-internal{color:#0e7490;background:color-mix(in srgb,#06b6d4 16%,transparent);border:1px solid color-mix(in srgb,#06b6d4 32%,transparent)}
.rt-scope-external{color:var(--rt-warn);background:color-mix(in srgb,var(--rt-warn) 16%,transparent);border:1px solid color-mix(in srgb,var(--rt-warn) 32%,transparent)}
.rt-scope-testing{color:#5b21b6;background:color-mix(in srgb,#8b5cf6 16%,transparent);border:1px solid color-mix(in srgb,#8b5cf6 32%,transparent)}
body[data-ds-dark-theme] .rt-scope-internal,.dshp-dock[data-theme="dusk"] .rt-scope-internal{color:#67e8f9}
body[data-ds-dark-theme] .rt-scope-testing,.dshp-dock[data-theme="dusk"] .rt-scope-testing{color:#c4b5fd}
.rt-modal-box{border-radius:16px;backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4);
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
.rt-flow-action.inferred,.rt-ap-act.inferred{font-style:normal}
@media (prefers-reduced-motion:reduce){.rt-btn,.rt-live-dot{transition:opacity 300ms var(--rt-ease);animation:none;transform:none}}
.rt-head,.rt-toolbar,.rt-foot,.rt-livebar,.rt-concl{padding:8px 12px}
.rt-tabs,.rt-subtabs{gap:8px;padding:0 12px}
.rt-tab{padding:8px 12px;gap:4px}
.rt-pane,.rt-chain,.rt-sess-grid,.rt-flow,.rt-ap,.rt-rep-list,.rt-live-body{padding:12px}
.rt-side,.rt-list{width:192px;padding:8px;box-sizing:border-box}
.rt-seg,.rt-item{padding:8px;border-radius:8px;margin-bottom:4px}
.rt-card{padding:12px;margin-bottom:12px;border-radius:8px}
.rt-card h4{margin:0 0 8px}
.rt-btn{padding:4px 12px;border-radius:8px;font-size:12px;line-height:20px}
.rt-input,.rt-eng-select{padding:4px 12px;border-radius:8px;min-height:32px;box-sizing:border-box}
.rt-textarea{padding:8px 12px;border-radius:8px}
.rt-row,.rt-score-row,.rt-vrow{padding:8px 12px;gap:8px}
.rt-row{grid-template-columns:minmax(96px,1.1fr) minmax(56px,72px) minmax(64px,96px) minmax(0,1.2fr) minmax(0,1fr)}
.rt-toolbar{gap:8px}
.rt-hint{padding:8px 12px;margin-bottom:8px;border-radius:8px}
.rt-empty,.rt-err{padding:8px 12px}
.rt-empty{padding:24px 12px}
.rt-sess{padding:12px;border-radius:8px}
.rt-sess-grid{gap:12px}
.rt-expand,.rt-score-detail,.rt-vdetail{padding:8px 12px 12px}
.rt-section{padding:8px 12px 4px}
.rt-full .rt-head{padding:12px 16px}
.rt-full .rt-tabs{padding:0 16px;gap:8px}
.rt-full .rt-pane,.rt-full .rt-chain,.rt-full .rt-sess-grid{padding:16px}
.rt-full .rt-foot,.rt-full .rt-toolbar,.rt-full .rt-livebar,.rt-full .rt-concl{padding:8px 16px}
.rt-full .rt-side{width:240px}
.rt-full .rt-list{width:256px}
.rt-full .rt-row{grid-template-columns:minmax(0,1.2fr) minmax(64px,90px) minmax(80px,130px) minmax(0,1.4fr) minmax(0,1.2fr)}
` /* ---------------------------------------------------------- 桥接与状态 */
/** 是否在「全面浏览」独立窗口里(URL hash 标记,复用同一套界面代码)。 */
const isFullWindow = () => {
try { return String(window.location.hash || '') === '#redteam-full' } catch { return false }
@@ -8513,9 +8759,54 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
);
}
function isAutoPushedFlexChild(el) {
if (!el || el.nodeType !== 1) return false;
if (/heroOptions/i.test(String(el.className || ""))) return true;
try {
return window.getComputedStyle(el).marginLeft === "auto";
} catch {
return false;
}
}
/** 跟在工作区/模式后面;不要落到 heroOptions(margin-left:auto)后面,否则新建会话会把芯片甩到行尾。 */
function placeHeroChip(row, el) {
if (!row || !el) return;
let auto = null;
for (let i = 0; i < row.children.length; i += 1) {
const kid = row.children[i];
if (kid !== el && isAutoPushedFlexChild(kid)) {
auto = kid;
break;
}
}
if (auto) {
if (el.nextElementSibling !== auto) row.insertBefore(el, auto);
return;
}
if (el.parentNode !== row || row.lastElementChild !== el) row.appendChild(el);
}
/** 紧挨最后一个对话页签,不要 append 到整行末尾。 */
function placeTabChip(row, el) {
if (!row || !el) return;
const tabs = row.querySelectorAll(":scope > [role='tab']");
const last = tabs[tabs.length - 1];
if (last) {
if (el.previousElementSibling !== last) last.after(el);
return;
}
if (el.parentNode !== row) row.appendChild(el);
}
function hasInlinePurgeEntry() {
if (typeof document === "undefined") return false;
if (document.querySelector("[data-testid='dsh-purge-hero-chip'], [data-testid='dsh-purge-tab-chip']")) return true;
const chipBtns = document.querySelectorAll(".dshp-hero-chip-btn, .dshp-tab-btn");
for (let i = 0; i < chipBtns.length; i += 1) {
const btn = chipBtns[i];
if (!btn || (btn.closest && btn.closest(".dshp-dock, .dshp-launch"))) continue;
if (btn.offsetParent || (btn.getClientRects && btn.getClientRects().length)) return true;
}
const nodes = document.querySelectorAll("button, [role='tab'], [role='button'], [class*='chip']");
for (let i = 0; i < nodes.length; i += 1) {
const el = nodes[i];
@@ -8585,8 +8876,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
el = document.createElement("div");
el.className = "dshp-hero-chip";
el.setAttribute("data-testid", "dsh-purge-hero-chip");
row.appendChild(el);
}
placeHeroChip(row, el);
setHost((prev) => (prev === el ? prev : el));
};
ensure();
@@ -8650,8 +8941,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
el = document.createElement("div");
el.className = "dshp-tab-chip";
el.setAttribute("data-testid", "dsh-purge-tab-chip");
row.appendChild(el);
}
placeTabChip(row, el);
setHost((prev) => (prev === el ? prev : el));
};
ensure();
+20 -21
View File
@@ -30,31 +30,30 @@
personaPrefix: ""
personaSuffix: ""
# 本体 insert 写在用户层 profile/cordis.patch.yml(postinstall / 演练台自愈补)。
# 这里只改已入队条目的 inject/config。再 insert 一次会 already queued(#152 / #154 / #159)。
- id: dsh-purge
name: dsh-purge
inject: [systemPrompt, tools]
config:
enabled: true
autoApplyOnStart: false
autoUpdateOnStart: false
autoRevertOnMissing: false
injectOnce: false
stripMnemon: true
verbose: false
postPrompt: ""
postPromptOrder: 5100
autoRetry: true
retryMax: 3
autoContinue: false
continueMax: 3
continueText: "继续"
capabilityProtocol: true
hooksDenyBypass: true
- insert:
- id: dsh-purge
name: 'dsh-purge'
inject: [systemPrompt, tools]
config:
enabled: true
autoApplyOnStart: false
autoUpdateOnStart: false
autoRevertOnMissing: false
injectOnce: false
stripMnemon: true
verbose: false
postPrompt: ""
postPromptOrder: 5100
autoRetry: true
retryMax: 3
autoContinue: false
continueMax: 3
continueText: "继续"
capabilityProtocol: true
hooksDenyBypass: true
# 演练台:预设 + 技能落地(本插件 lib/redteam)
- id: dsh-purge-redteam
name: dsh-purge/redteam
+66
View File
@@ -0,0 +1,66 @@
/**
* Apply / 还原 / 卸载的内存进度。
* 只给 /dsh-purge/status 轮询用,不落盘,也不进 gatherState。
*/
const IDLE = Object.freeze({
active: false,
kind: "apply",
stage: "idle",
detail: "",
applied: 0,
total: 0,
error: "",
startedAt: 0,
updatedAt: 0,
});
let current = { ...IDLE };
export function getApplyProgress() {
return { ...current };
}
export function beginJob(kind = "apply", stage = "home") {
const now = Date.now();
current = {
active: true,
kind,
stage,
detail: "",
applied: 0,
total: 0,
error: "",
startedAt: now,
updatedAt: now,
};
return getApplyProgress();
}
export function beginApply(stage = "home") {
return beginJob("apply", stage);
}
export function setApplyProgress(patch = {}) {
current = {
...current,
...patch,
active: patch.active == null ? true : Boolean(patch.active),
updatedAt: Date.now(),
};
return getApplyProgress();
}
export function endApply(patch = {}) {
current = {
...current,
...patch,
active: false,
updatedAt: Date.now(),
};
return getApplyProgress();
}
export function resetApplyProgress() {
current = { ...IDLE, updatedAt: Date.now() };
return getApplyProgress();
}
+1 -17
View File
@@ -21,28 +21,12 @@ const OFFICIAL_PROTOCOL = `## Capability selection by task (mandatory)
5. **Subagents / sub-delegates inherit this rule**: Any \`subagent\`, teammate, or child agent you start must also read the catalog and call task-matched skills/MCP the same way. Put that requirement in the child brief when you dispatch.
6. Host skills and MCP stay available; this prompt does not remove them.`;
const REDTEAM_LEAD_PROTOCOL = `## Capability selection by task (redteam lead)
1. You plan, dispatch with \`subagent\`, verify results, and report. Executors do hands-on work.
2. Before dispatch, know which skills/MCP fit the next stage (from \`<available_skills>\` / redteam skills / session MCP).
3. In every \`subagent\` brief: require the child to **read the skill/MCP catalog, then call only what the assigned task needs** (name concrete skill codes when you know them).
4. Do not ban skill or MCP for children. Leaf limits apply only to further delegation tools (\`subagent_fork\` / workflow / ralph), not to skill/MCP.
5. Vague “go investigate” briefs are wrong; task-matched skill/MCP instructions are right.`;
const REDTEAM_CHILD_PROTOCOL = `## Capability selection by task (redteam executor)
1. **Read** \`<available_skills>\` / your role skills and available MCP/CLI tools.
2. **Match** them to *your assigned task* (not every skill, not zero skills).
3. **Call** matching skills via \`skill\`, and matching MCP/CLI tools by schema, before freelancing equivalent shell work.
4. DIY only for gaps the catalog does not cover; stay in role; do not re-delegate.`;
/**
* 主智能体和子智能体同一份。红队调度正文仍在预设 ops 里,这里不按身份拆协议。
* @param {{ redteam?: boolean, redteamChild?: boolean, enabled?: boolean }} [opts]
* @returns {string}
*/
export function capabilityProtocolText(opts = {}) {
if (opts.enabled === false) return "";
if (opts.redteamChild) return REDTEAM_CHILD_PROTOCOL;
if (opts.redteam) return REDTEAM_LEAD_PROTOCOL;
return OFFICIAL_PROTOCOL;
}
+161 -16
View File
@@ -48,30 +48,51 @@ const HIDDEN_EXEC = {
// H19:原子写。write-to-tmp + rename。EBUSY/ENOSPC 都不会半写坏原文件。
// 不走 FileHandle:hostFs.promises 只包了 readFile/writeFile/mkdir/unlink/rm/copyFile,无 open。
// 不显式 fsync:原子性靠 rename;KB 级配置文件断电丢最新一次写入可接受,下一次 apply 会补。
// H21:新临时文件默认 0644,rename 会把原权限吃掉。官方 CLI 的 dsh 原本 0755,
// 写一次就变成 0644 → Permission denied(#155 / #157)。写前记下,写完补回。
function existingMode(fp) {
try {
return fs.statSync(fp).mode & 0o7777;
} catch {
return undefined;
}
}
function restoreMode(fp, mode) {
if (mode === undefined) return;
try { fs.chmodSync(fp, mode); } catch { /* 权限补不回来不该让整次写入失败 */ }
}
export function atomicWriteSync(fp, content, encoding = "utf8") {
const dir = path.dirname(fp);
fs.mkdirSync(dir, { recursive: true });
const tmp = `${fp}.${process.pid}.${Date.now()}.tmp`;
const mode = existingMode(fp);
fs.writeFileSync(tmp, content, encoding);
restoreMode(tmp, mode);
try {
fs.renameSync(tmp, fp);
} catch (e) {
try { fs.unlinkSync(tmp); } catch { /* ignore */ }
throw e;
}
restoreMode(fp, mode);
}
export async function atomicWriteFile(fp, content, encoding = "utf8") {
const dir = path.dirname(fp);
await fsp.mkdir(dir, { recursive: true });
const tmp = `${fp}.${process.pid}.${Date.now()}.tmp`;
const mode = existingMode(fp);
await fsp.writeFile(tmp, content, encoding);
restoreMode(tmp, mode);
try {
await fsp.rename(tmp, fp);
} catch (e) {
try { await fsp.unlink(tmp); } catch { /* ignore */ }
throw e;
}
restoreMode(fp, mode);
}
export async function atomicCopyFile(src, dst) {
@@ -1987,6 +2008,13 @@ export async function applyPatchesAllHosts(patches = ALL_PATCHES, options = {})
hostWritten: hostCleanMarkersPresent(aiBase),
flash: silenceCmdFlash(aiBase),
});
if (typeof options.onHost === "function") {
try {
options.onHost({ index: hosts.length, aiBase });
} catch {
/* 进度回调失败不能中断清洗 */
}
}
}
return {
hosts,
@@ -2032,9 +2060,9 @@ export function missingAiBaseMessage() {
}
return `已找到桌面应用 ${exe},但其 resources/app(或 app.asar.unpacked)下没有 @deepseek-ai`;
}
return "未定位到当前桌面应用的 @deepseek-ai。官方客户端点「应用」会解开 app.asar 并重启;第三方 DSH Desktop 直接点「应用」。安装目录任意盘符。";
return "未定位到当前桌面应用的 @deepseek-ai。官方客户端点「应用」会解开 app.asar 并重启;第三方 DSH Desktop / DS Bot 直接点「应用」。安装目录任意盘符。";
}
return "插件根未找到 / set DSH_BASE";
return "插件根未找到 / set DSH_BASE。社区 Electron(DS Bot)若报这句,点「应用」解开 app.asar,或把 DSH_BASE 指到 resources/app 下的 @deepseek-ai。";
}
function aiBaseUnderAppDir(appDir) {
@@ -2344,8 +2372,10 @@ export function desktopAsarStillSealed(input = {}) {
export function findAiBase() {
return remember("ai", () => {
if (adapterFor(detectSurface()) === "desktop") return findAiBaseDesktop();
return findAiBaseWeb();
const desktopFirst = adapterFor(detectSurface()) === "desktop";
const primary = desktopFirst ? findAiBaseDesktop() : findAiBaseWeb();
if (primary) return primary;
return desktopFirst ? findAiBaseWeb() : findAiBaseDesktop();
});
}
@@ -7422,7 +7452,14 @@ export function shimIsPatched(fp) {
export function shimFileStatus(fp) {
if (!isFile(fp)) return "missing";
if (!isTextShim(fp)) return "binary";
return shimIsPatched(fp) ? "patched" : "original";
try {
const text = fs.readFileSync(fp, "utf8");
if (text.includes("dsh-purge shim")) return "patched";
if (text.includes("dsh-purge cli entry")) return "patched";
} catch {
return "original";
}
return "original";
}
function scrubInBinBak(dir, name, cleaned) {
@@ -7526,6 +7563,91 @@ async function stripWinCmdShim(fp, text) {
return "stripped_win_cmd";
}
function isSymlinkPath(fp) {
try {
return fs.lstatSync(fp).isSymbolicLink();
} catch {
return false;
}
}
function canResolveAppBoot(fromFile) {
let dir = path.dirname(fromFile);
for (let i = 0; i < 8; i += 1) {
const hit = path.join(dir, "node_modules", "@deepseek-ai", "dsh-app-boot");
if (isFile(path.join(hit, "package.json")) || isDir(hit)) return true;
const parent = path.dirname(dir);
if (parent === dir) break;
dir = parent;
}
return false;
}
function looksLikeCopiedBinJs(text) {
return /@deepseek-ai\/dsh-app-boot/.test(String(text || ""));
}
function officialBinJsNearLauncher(fp) {
const dir = path.dirname(fp);
const cands = [
path.join(dir, "..", "lib", "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"),
path.join(dir, "..", "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"),
path.join(dir, "..", "..", "lib", "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"),
];
for (const cand of cands) {
if (isFile(cand) && canResolveAppBoot(cand)) return cand;
}
return "";
}
function posixRelLink(fromDir, toFile) {
let rel = path.relative(fromDir, toFile);
if (!rel) return toFile;
rel = rel.split(path.sep).join("/");
if (!rel.startsWith(".") && !path.isAbsolute(rel)) rel = `./${rel}`;
return rel;
}
/** apply 曾把软链 launcher 覆盖成 bin.js 拷贝。能找到官方入口就还原软链(#157)。 */
function healCopiedLauncher(fp) {
const official = officialBinJsNearLauncher(fp);
if (!official) return "";
const rel = posixRelLink(path.dirname(fp), official);
try {
fs.unlinkSync(fp);
fs.symlinkSync(rel, fp);
return official;
} catch {
return "";
}
}
async function resolveShimWriteTarget(fp, fname, text) {
if (isSymlinkPath(fp)) {
try {
return { writeFp: fs.realpathSync(fp), text, healed: false };
} catch (e) {
return { error: `symlink:${e}` };
}
}
if (process.platform === "win32" || fname !== "dsh") {
return { writeFp: fp, text, healed: false };
}
if (looksLikeCopiedBinJs(text) && !canResolveAppBoot(fp)) {
const healed = healCopiedLauncher(fp);
if (!healed) return { skip: "skipped_no_module_root" };
try {
return { writeFp: healed, text: await loadText(healed), healed: true };
} catch (e) {
return { error: String(e) };
}
}
if (shimKindOf(fp) === "node" && !canResolveAppBoot(fp)) {
return { skip: "skipped_no_module_root" };
}
return { writeFp: fp, text, healed: false };
}
export async function patchShim(shimDir) {
const result = {};
if (!shimDir) return { error: "no_shim_dir" };
@@ -7563,21 +7685,37 @@ export async function patchShim(shimDir) {
continue;
}
if (shimIsPatched(fp) && shimInjectCurrent(text)) {
const target = await resolveShimWriteTarget(fp, fname, text);
if (target.error) {
result[fname] = `error:${target.error}`;
continue;
}
if (target.skip) {
result[fname] = target.skip;
continue;
}
const writeFp = target.writeFp;
text = target.text;
if (shimIsPatched(writeFp) && shimInjectCurrent(text)) {
result[fname] = "already_patched";
continue;
}
if (shimIsPatched(fp) || hasLegacyPermissionPin(text)) text = stripShimInject(text);
if (shimIsPatched(writeFp) || hasLegacyPermissionPin(text)) text = stripShimInject(text);
const bak = shimBackupPath(fp);
const bak = shimBackupPath(writeFp);
if (!fs.existsSync(bak)) {
try {
await fsp.mkdir(path.dirname(bak), { recursive: true });
await fsp.copyFile(fp, bak);
await fsp.copyFile(writeFp, bak);
} catch {}
}
try {
await saveText(fp, insertShimInject(text, shimInjectFor(shimKindOf(fp))));
await saveText(writeFp, insertShimInject(text, shimInjectFor(shimKindOf(writeFp))));
if (shimKindOf(writeFp) === "node" && !canResolveAppBoot(writeFp)) {
result[fname] = "error:module_root_lost";
continue;
}
result[fname] = isDesktopCommandRuntimeDir(shimDir) ? "patched_desktop" : "patched";
} catch (e) {
result[fname] = `error:${e}`;
@@ -7623,15 +7761,19 @@ export async function revertShim(shimDir, { scrubDesktop = true } = {}) {
if (!shimDir) return result;
for (const fname of SHIM_NAMES) {
const fp = path.join(shimDir, fname);
const bak = shimBackupPath(fp);
const legacyBak = fp + ".dshpurge.bak";
let writeFp = fp;
if (isSymlinkPath(fp)) {
try { writeFp = fs.realpathSync(fp); } catch { writeFp = fp; }
}
const bak = shimBackupPath(writeFp);
const legacyBak = writeFp + ".dshpurge.bak";
try {
if (fs.existsSync(bak)) {
result[fname] = await restoreFromBak(fp, bak, "reverted");
result[fname] = await restoreFromBak(writeFp, bak, "reverted");
} else if (fs.existsSync(legacyBak)) {
result[fname] = await restoreFromBak(fp, legacyBak, "reverted_legacy_in_bin");
} else if (shimIsPatched(fp)) {
await saveText(fp, stripShimInject(await loadText(fp)));
result[fname] = await restoreFromBak(writeFp, legacyBak, "reverted_legacy_in_bin");
} else if (shimIsPatched(writeFp)) {
await saveText(writeFp, stripShimInject(await loadText(writeFp)));
result[fname] = "stripped_inject";
} else if (!isFile(fp)) {
result[fname] = "missing";
@@ -8014,6 +8156,9 @@ export async function gatherState() {
shim_cmd = shimFileStatus(path.join(desktopShim, "dsh.cmd"));
shim_ps1 = shimFileStatus(path.join(desktopShim, "dsh.ps1"));
shim_bin = shimFileStatus(path.join(desktopShim, "dsh"));
// 桌面官方 CLI 的补丁是入口回退块(dsh-purge cli entry),不是 "dsh-purge shim" 注入。
if (shim_bin === "original" && desktop.desktopCliEntryPatched(path.join(desktopShim, "dsh"))) shim_bin = "patched";
if (shim_cmd === "original" && desktop.desktopCliEntryPatched(path.join(desktopShim, "dsh.cmd"))) shim_cmd = "patched";
}
} else if (shimDir) {
shim_cmd = shimFileStatus(path.join(shimDir, "dsh.cmd"));
+50 -5
View File
@@ -124,8 +124,14 @@ export function looksLikeDesktopName(p) {
/\/deepseek[\s._-]*harness(\/|$)/.test(n) ||
n.includes("/deepseek harness.app/") ||
n.endsWith("/deepseek harness.app") ||
n.includes("/deepseek bot/") ||
n.includes("/deepseek-bot/") ||
n.includes("/ds-bot/") ||
n.endsWith("/deepseek bot") ||
n.endsWith("/deepseek bot.app") ||
/\/dsh desktop\.exe$/i.test(n) ||
/\/deepseek[\s._-]*harness\.exe$/i.test(n)
/\/deepseek[\s._-]*harness\.exe$/i.test(n) ||
/\/deepseek[\s._-]*bot\.exe$/i.test(n)
);
}
@@ -163,7 +169,12 @@ export function looksLikeDesktopNameTail(p) {
tail === "deepseek-harness" ||
tail === "deepseekharness" ||
/^dsh-desktop/.test(tail) ||
/^deepseek[\s._-]*harness(\.exe)?$/.test(tail)
/^deepseek[\s._-]*harness(\.exe)?$/.test(tail) ||
tail === "deepseek bot" ||
tail === "deepseek bot.app" ||
tail === "deepseek-bot" ||
tail === "ds-bot" ||
/^deepseek[\s._-]*bot(\.exe)?$/.test(tail)
);
}
@@ -175,6 +186,7 @@ export function isDesktopExecutable(fp) {
const base = path.basename(String(fp || "")).toLowerCase();
if (base === "dsh desktop.exe" || base === "dsh desktop") return true;
if (OFFICIAL_HARNESS_BASES.has(base)) return true;
if (/^deepseek[\s._-]*bot(\.exe)?$/.test(base) || /^ds[\s._-]*bot(\.exe)?$/.test(base)) return true;
return /^deepseek[\s._-]*harness(\.exe)?$/.test(base);
}
@@ -237,12 +249,17 @@ function exeCandidatesBeside(dir) {
path.join(dir, "deepseek-harness"),
path.join(dir, "DSH Desktop.exe"),
path.join(dir, "DSH Desktop"),
path.join(dir, "DeepSeek Bot.exe"),
path.join(dir, "DeepSeek-Bot.exe"),
path.join(dir, "DeepSeek Bot"),
path.join(dir, "MacOS", "DeepSeek Harness"),
path.join(dir, "MacOS", "deepseek-harness"),
path.join(dir, "MacOS", "DSH Desktop"),
path.join(dir, "MacOS", "DeepSeek Bot"),
path.join(dir, "Contents", "MacOS", "DeepSeek Harness"),
path.join(dir, "Contents", "MacOS", "deepseek-harness"),
path.join(dir, "Contents", "MacOS", "DSH Desktop"),
path.join(dir, "Contents", "MacOS", "DeepSeek Bot"),
];
}
@@ -307,7 +324,7 @@ function trustedInstallDir(dir) {
const REGISTRY_INSTALL_SCRIPT = `
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
$names = @('DeepSeek Harness','DSH Desktop')
$names = @('DeepSeek Harness','DSH Desktop','DeepSeek Bot','DS Bot')
$roots = @(
'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
'HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
@@ -568,17 +585,21 @@ export function commonDesktopInstallDirs(env = process.env, input = {}) {
...extraDiscoveredInstallDirs(env, { discover }),
path.join(local, "Programs", "DeepSeek Harness"),
path.join(local, "Programs", "DSH Desktop"),
path.join(local, "Programs", "DeepSeek Bot"),
path.join(local, "DeepSeek Harness"),
path.join(local, "DeepSeek Bot"),
...(pf
? [path.join(pf, "DeepSeek Harness"), path.join(pf, "DSH Desktop")]
? [path.join(pf, "DeepSeek Harness"), path.join(pf, "DSH Desktop"), path.join(pf, "DeepSeek Bot")]
: []),
...(pf86
? [path.join(pf86, "DeepSeek Harness"), path.join(pf86, "DSH Desktop")]
? [path.join(pf86, "DeepSeek Harness"), path.join(pf86, "DSH Desktop"), path.join(pf86, "DeepSeek Bot")]
: []),
"/Applications/DeepSeek Harness.app",
"/Applications/DSH Desktop.app",
"/Applications/DeepSeek Bot.app",
path.join(home, "Applications", "DeepSeek Harness.app"),
path.join(home, "Applications", "DSH Desktop.app"),
path.join(home, "Applications", "DeepSeek Bot.app"),
"/opt/DeepSeek Harness",
"/opt/deepseek-harness",
"/usr/lib/DeepSeek Harness",
@@ -655,6 +676,15 @@ export function findDesktopAppExecutable(input = {}) {
if (isDesktopExecutable(execPath) && isFile(execPath)) return path.normalize(execPath);
const electron = (input.versions ?? process.versions)?.electron;
if (
electron
&& isFile(execPath)
&& !/^node(\.exe)?$/i.test(path.basename(execPath))
) {
return path.normalize(execPath);
}
if (resourcesPath) {
const hit = firstExistingExe([path.dirname(path.normalize(resourcesPath))]);
if (hit) return hit;
@@ -1639,6 +1669,16 @@ function stripShimEntryBlock(text) {
return text.replace(/# dsh-purge cli entry begin[\s\S]*?# dsh-purge cli entry end\r?\n?/g, "");
}
/** 官方 CLI 启动脚本是否已经补过入口回退块。桌面端修的是这个,不是 "dsh-purge shim" 注入。 */
export function desktopCliEntryPatched(fp) {
if (!isFile(fp)) return false;
try {
return fs.readFileSync(fp, "utf8").includes("dsh-purge cli entry");
} catch {
return false;
}
}
function patchOfficialCliShimText(text) {
if (!text) return { changed: false, text };
// 老版本已改成 "$entry"、asar 原文不在了,但 BEGIN 标记还在 → 也要进来升级成三级回退。
@@ -1794,6 +1834,11 @@ export function repairOfficialCliAfterUnpack(exe = findDesktopAppExecutable()) {
try { atomicCopyFileSync(fp, bak); } catch { /* 写不了 bak 不致命 */ }
}
atomicWriteSync(fp, patched.text, "utf8");
// 启动脚本必须可执行。官方发的是 0755,一旦被写成 0644,`dsh` 就再也起不来。
// 原子写只保留原权限,权限已经丢过一次的情况下要显式补回来。
if (!fp.toLowerCase().endsWith(".cmd")) {
try { fs.chmodSync(fp, 0o755); } catch { /* 补不上不算这次修补失败 */ }
}
report.shims.push({ path: fp, status: "patched" });
} catch (e) {
report.shims.push({ path: fp, status: "write_error", error: String(e && e.message ? e.message : e) });
+6 -10
View File
@@ -507,10 +507,11 @@ function mountedPresetId(context) {
}
export function sessionAgentPreset(context) {
const session = sessionOfContext(context);
// 先看这一轮已经挂上的预设,再看用户选过的事件。
// 投影和会话头经常停在创建时的 standard,不能拿它们盖住当前选择。
const mounted = mountedPresetId(context);
const own = sessionOfContext(context);
const session = sessionForInject(context) || own;
// 子会话沿父会话读预设。子自己的 mounted/standard 不能盖住父会话的红队/极简。
const walked = Boolean(session && own && session !== own);
const mounted = walked ? "" : mountedPresetId(context);
if (mounted) return mounted;
let selected = "";
for (const event of eventList(session)) {
@@ -527,10 +528,6 @@ export function sessionAgentPreset(context) {
}
export function isRedteamSession(context) {
const session = sessionForInject(context);
if (session && session !== sessionOfContext(context)) {
return isRedteamPresetId(sessionAgentPreset({ session }));
}
return isRedteamPresetId(sessionAgentPreset(context));
}
@@ -953,7 +950,6 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
}
const redteam = isRedteamSession(opts.context) || assemblyLooksRedteam(originalSections);
const redteamChild = redteam && isRedteamSubagent(opts.context);
const rawInject = modePromptText(collectInjectText(purge, opts.fallbackInject), redteam);
const injectText = escapeDshInterpolation(
peelChatmlEnvelope(adaptInjectForMinimalPreset(withOwnServers(rawInject), opts.context)),
@@ -962,7 +958,7 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
? ""
: capabilityProtocolText({
redteam,
redteamChild,
redteamChild: false,
enabled: true,
});
// #29: 不要把上一条 system/message 全文钉回 sections。
+164 -16
View File
@@ -27,6 +27,12 @@ import * as continueRetry from "./continue-retry.js";
import * as uninstaller from "./uninstall.js";
import { readDrillGrant, writeDrillGrant } from "./drill-grant.js";
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
import {
cancelClearOwnedSelectedDefault,
clearOwnedSelectedDefault,
removeStaleAgentPresetDir,
scheduleClearOwnedSelectedDefault,
} from "./preset-default.js";
import {
applyShouldRestart,
isInactiveContextError,
@@ -35,6 +41,15 @@ import {
settleMayRestart,
watchContextLife,
} from "./settle-policy.js";
import { ensureAllProfileInstall } from "./profile-insert.js";
import {
beginApply,
beginJob,
endApply,
getApplyProgress,
resetApplyProgress,
setApplyProgress,
} from "./apply-progress.js";
export const name = "dsh-purge";
@@ -69,6 +84,7 @@ const log = (config, ...args) => {
};
let webTreeReady = false;
let lastStatusPayload = null;
function watchWebTreeReady(ctx) {
// 必须挂在 connection 上再 await,与官方打印 URL 同一时刻。
@@ -400,7 +416,7 @@ export function registerPromptSections(ctx, config) {
const redteam = isRedteamSession(context);
return capabilityProtocolText({
redteam,
redteamChild: redteam && context?.agent?.session?.header?.origin === "subagent",
redteamChild: false,
enabled: true,
});
},
@@ -598,8 +614,27 @@ function permissionPresetsOf(ctx) {
return null;
}
function parentPermissionPreset(ctx, session) {
const parentId = session?.header?.parentSession;
if (!parentId || !ctx) return "";
try {
const registry = ctx.agents || ctx.get?.("agents");
const parent = registry?.get?.(parentId);
let parentSession = parent?.session;
if (!parentSession) {
const store = ctx.get?.("sessions");
parentSession = typeof store?.get === "function" ? store.get(parentId) : null;
}
if (!parentSession) return "";
const svc = permissionPresetsOf(ctx);
const state = typeof svc?.permissionState === "function" ? svc.permissionState(parentSession) : null;
return state?.preset || parentSession?.header?.permissionPreset || "";
} catch {
return "";
}
}
function shouldKeepFreshFullAccess(session, svc) {
if (session?.header?.origin === "subagent") return false;
const state = typeof svc.permissionState === "function" ? svc.permissionState(session) : null;
const preset = state?.preset;
if (preset === "danger-full-access" || preset === "auto" || preset === "custom") return false;
@@ -612,7 +647,14 @@ function shouldKeepFreshFullAccess(session, svc) {
function upgradeFreshSessionAccess(ctx, session) {
try {
const svc = permissionPresetsOf(ctx);
if (!svc || !shouldKeepFreshFullAccess(session, svc)) return;
if (!svc) return;
const inherited = parentPermissionPreset(ctx, session);
if (inherited) {
const state = typeof svc.permissionState === "function" ? svc.permissionState(session) : null;
if (state?.preset !== inherited) svc.set(session, inherited);
return;
}
if (!shouldKeepFreshFullAccess(session, svc)) return;
svc.set(session, "danger-full-access");
} catch (error) {
console.warn("[dsh-purge] full-access pin:", error instanceof Error ? error.message : String(error));
@@ -620,6 +662,16 @@ function upgradeFreshSessionAccess(ctx, session) {
}
/** 空会话界面按部署默认显示完全权限;建会话时若钉成 workspace-write,发消息后芯片会掉下去。 */
function pinExistingSessionAccess(ctx) {
try {
const store = ctx.get?.("sessions");
const all = typeof store?.all === "function" ? store.all()
: typeof store?.list === "function" ? store.list()
: [];
for (const session of all || []) upgradeFreshSessionAccess(ctx, session);
} catch { /* 注册表还没起来时等 session/created */ }
}
function installFreshFullAccess(ctx) {
if (typeof ctx.on !== "function" || ctx.__dshPurgeFullPin) return;
ctx.__dshPurgeFullPin = true;
@@ -629,6 +681,7 @@ function installFreshFullAccess(ctx) {
try { disposer = ctx.on("session/created", (session) => {
queueMicrotask(() => upgradeFreshSessionAccess(ctx, session));
}); } catch { /* ignore */ }
queueMicrotask(() => pinExistingSessionAccess(ctx));
return () => {
try { if (typeof disposer === "function") disposer(); } catch { /* ignore */ }
delete ctx.__dshPurgeFullPin;
@@ -1455,8 +1508,16 @@ export function apply(ctx, config) {
const cfg = { ...DEFAULTS, ...(config || {}) };
if (!cfg.enabled) {
purgeLog("boot", { enabled: false });
try { clearOwnedSelectedDefault({ ctx, dshHome: core.findDshHome() }); } catch { /* 停用不被清默认挡住 */ }
try { removeStaleAgentPresetDir(core.findDshHome(), "redteam"); } catch { /* ignore */ }
return;
}
cancelClearOwnedSelectedDefault();
try {
ctx.effect(() => () => {
try { scheduleClearOwnedSelectedDefault({ ctx, dshHome: core.findDshHome() }); } catch { /* 停用不被清默认挡住 */ }
});
} catch { /* 无 effect 时靠 uninstall / enabled:false 清 */ }
purgeLog("boot", {
enabled: true,
surface: hostctl.currentSurface(),
@@ -1495,6 +1556,15 @@ export function apply(ctx, config) {
return;
}
log(cfg, "plugin enabled");
try {
const home = core.pinDshHome() || core.findDshHome();
const healed = ensureAllProfileInstall(home);
for (const item of healed) {
if (item.insert?.wrote || item.bundles?.wrote) {
log(cfg, "profile heal:", item.dir, item.insert?.wrote ? "insert" : "", item.bundles?.wrote ? "bundles" : "");
}
}
} catch { /* 自愈失败不挡主入口 */ }
core.applyRuntimeEnv();
try {
const home = core.pinDshHome() || core.findDshHome();
@@ -1541,6 +1611,29 @@ export function apply(ctx, config) {
}
}
function isDuplicateCommandError(error) {
return /is already registered|already registered/i.test(String(error && error.message || error));
}
/** 逐命令注册:撞名只丢那一条,可退到备用名(#162)。 */
function tryRegisterCommand(commands, spec, fallbacks = []) {
const names = [spec.name, ...fallbacks];
for (const name of names) {
try {
commands.register({ ...spec, name });
if (name !== spec.name) {
console.warn(`[dsh-purge] /${spec.name} taken, registered /${name}`);
}
return name;
} catch (error) {
if (isDuplicateCommandError(error)) continue;
throw error;
}
}
console.warn(`[dsh-purge] skip /${spec.name}: already registered`);
return null;
}
function applyHostHooks(ctx, cfg) {
try {
const home = core.pinDshHome() || core.findDshHome();
@@ -1568,25 +1661,25 @@ function applyHostHooks(ctx, cfg) {
const commands = ctx.get?.("commands");
if (commands) {
commands.register({
tryRegisterCommand(commands, {
name: "purge",
description: "dsh 指令权威性清洗(status/apply/revert/uninstall/edit/help)",
input: { hint: "status | apply | revert | uninstall | edit | help" },
handler: async (invocation) => handlePurgeCommand(invocation.rawInput ?? "", cfg, ctx),
});
commands.register({
}, ["purge-cmd"]);
tryRegisterCommand(commands, {
name: "rules",
description: "规则集切换(写入 AGENTS.md/CLAUDE.md): list | use <id> | create <id> [别名] [目标] | delete <id> | reset | help",
input: { hint: "list | use <id> | create <id> [别名] [目标] | delete <id> | reset | help" },
handler: async (invocation) => handleRulesCommand(invocation.rawInput ?? ""),
});
commands.register({
}, ["purge-rules"]);
tryRegisterCommand(commands, {
name: "skills",
description: "官方用户 Skill($DSH_HOME/skills):list | import <路径> | create <id> [说明] | delete <id> | help",
input: { hint: "list | import <路径> | create <id> [说明] | delete <id> | help" },
handler: async (invocation) => handleSkillsCommand(invocation.rawInput ?? ""),
});
commands.register({
}, ["purge-skills"]);
tryRegisterCommand(commands, {
name: "rewind",
description: "回退:子代理直接回退一次;主代理 /rewind once 或 /rewind round",
input: { hint: "once | round" },
@@ -1610,7 +1703,7 @@ function applyHostHooks(ctx, cfg) {
: "已回退一次。还在这条对话里,上一句已放回输入框。再发送时,之前的回复不会带上。",
};
},
});
}, ["purge-rewind"]);
}
if (ctx.tools) {
@@ -1776,14 +1869,25 @@ function installWebServer(ctx, cfg) {
return;
}
try {
const progress = getApplyProgress();
if (progress.active) {
const base = lastStatusPayload || { ok: true };
sendJson(response, 200, {
...base,
ok: true,
ready: webTreeReady || Boolean(lastStatusPayload),
apply_progress: progress,
});
return;
}
if (!webTreeReady) {
sendJson(response, 503, { ok: false, ready: false });
sendJson(response, 503, { ok: false, ready: false, apply_progress: progress });
return;
}
const state = await core.gatherState();
const patch_names = {};
for (const p of core.ALL_PATCHES) patch_names[String(p.id)] = p.name;
sendJson(response, 200, {
const payload = {
ok: true,
ready: true,
surface: state.surface || hostctl.currentSurface(),
@@ -1820,9 +1924,11 @@ function installWebServer(ctx, cfg) {
...updater.channelPublic(),
hooks_deny_bypass: core.getHooksDenySettings().hooksDenyBypass,
...(await skills.skillsStatus(core.findDshHome()).catch(() => ({ skills: [] }))),
});
};
lastStatusPayload = payload;
sendJson(response, 200, { ...payload, apply_progress: progress });
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });
sendJson(response, 500, { ok: false, error: String(e), apply_progress: getApplyProgress() });
}
},
}, "dsh-purge: status");
@@ -1974,6 +2080,7 @@ function installWebServer(ctx, cfg) {
response.end();
return;
}
beginApply("home");
try {
const body = await readJsonBody(request);
const incoming = typeof body?.content === "string" ? body.content : null;
@@ -1984,13 +2091,16 @@ function installWebServer(ctx, cfg) {
const state = await core.gatherState();
if (home) state.dsh_home = home;
let located;
setApplyProgress({ stage: "locate" });
try {
located = await core.resolveOfficialAiBase(state.ai_base, { forApply: true });
} catch (e) {
endApply({ stage: "locate", error: String(e && e.message ? e.message : e) });
sendJson(response, 500, { ok: false, error: String(e && e.message ? e.message : e) });
return;
}
if (!located.aiBase) {
endApply({ stage: "locate", error: "no_base" });
sendJson(response, 500, { ok: false, error: core.missingAiBaseMessage() });
return;
}
@@ -2002,6 +2112,7 @@ function installWebServer(ctx, cfg) {
const handoff = located.handoff && located.handoff.swapAsar ? located.handoff : null;
const blocked = rejectIfNeedPrompt(state.dsh_home, incoming === null ? undefined : incoming);
if (blocked) {
resetApplyProgress();
const ui = await core.readOverrideForUi(state.dsh_home);
sendJson(response, 400, {
ok: false,
@@ -2012,16 +2123,26 @@ function installWebServer(ctx, cfg) {
});
return;
}
setApplyProgress({ stage: "override" });
try {
await core.commitOverrideOnApply(state.dsh_home, incoming);
} catch (e) {
console.warn("[dsh-purge] apply override:", String(e && e.message ? e.message : e));
}
setApplyProgress({ stage: "patch" });
const httpMulti = await core.applyPatchesAllHosts(core.ALL_PATCHES, {
preserveClientBundles: false,
forApply: true,
onHost(info) {
setApplyProgress({
stage: "patch",
applied: info.index || 0,
detail: info.aiBase || "",
});
},
});
const report = httpMulti.report;
setApplyProgress({ stage: "shim" });
const shim = await core.patchAllShims();
let cliRepair = null;
try {
@@ -2029,6 +2150,7 @@ function installWebServer(ctx, cfg) {
} catch (e) {
cliRepair = { ok: false, error: String(e && e.message ? e.message : e) };
}
setApplyProgress({ stage: "flash" });
const flash = core.silenceCmdFlash(httpMulti.hosts[0]?.aiBase || state.ai_base);
const summary = core.summarizeApplyReport(report);
const hostWritten =
@@ -2051,6 +2173,7 @@ function installWebServer(ctx, cfg) {
else bootFullQuit = false;
if (shouldRestart) reapply.markSettleRestart();
let promptInjectInstall = "skipped";
setApplyProgress({ stage: "seed" });
if (hostWritten && flash.ok === true) {
// Apply → cleanup → restart 成功后,默认把加密提示词 seed 进 prompt-inject.md。
// 用户自改过的内容保留;仅当文件不存在或仍是插件旧默认时才写。
@@ -2063,6 +2186,10 @@ function installWebServer(ctx, cfg) {
}
const hung = refreshHungOperator(state.dsh_home);
const override = await core.readOverrideForUi(state.dsh_home);
endApply({
stage: "done",
error: complete || (promptReady && hostWritten) ? "" : "incomplete",
});
sendJson(response, 200, {
ok: true,
complete,
@@ -2092,6 +2219,7 @@ function installWebServer(ctx, cfg) {
cmd_flash: flash,
});
} catch (e) {
endApply({ error: String(e && e.message ? e.message : e) });
sendJson(response, 500, { ok: false, error: String(e) });
}
},
@@ -2105,17 +2233,26 @@ function installWebServer(ctx, cfg) {
response.end();
return;
}
beginJob("revert", "locate");
try {
const state = await core.gatherState();
const result = {};
setApplyProgress({ kind: "revert", stage: "revert" });
if (state.ai_base) {
const { reverted, errors } = await core.revertAll(state.ai_base);
result.reverted = reverted.length;
result.errors = errors.length;
}
setApplyProgress({ kind: "revert", stage: "shim" });
result.shim = await core.revertAllShims();
endApply({
kind: "revert",
stage: "done",
error: result.errors ? "incomplete" : "",
});
sendJson(response, 200, { ok: true, ...result, note: "重启 dsh 恢复; prompt-inject.md 保留" });
} catch (e) {
endApply({ kind: "revert", error: String(e && e.message ? e.message : e) });
sendJson(response, 500, { ok: false, error: String(e) });
}
},
@@ -2129,8 +2266,18 @@ function installWebServer(ctx, cfg) {
response.end();
return;
}
beginJob("uninstall", "locate");
try {
const result = await uninstaller.uninstallPurge();
const result = await uninstaller.uninstallPurge({
onStage(stage) {
setApplyProgress({ kind: "uninstall", stage });
},
});
endApply({
kind: "uninstall",
stage: "done",
error: result.ok ? "" : (result.errors && result.errors[0]) || "incomplete",
});
sendJson(response, result.ok ? 200 : 500, {
...result,
surface: hostctl.currentSurface(),
@@ -2145,6 +2292,7 @@ function installWebServer(ctx, cfg) {
});
}
} catch (e) {
endApply({ kind: "uninstall", error: String(e && e.message ? e.message : e) });
sendJson(response, 500, { ok: false, error: String(e && e.message ? e.message : e) });
}
},
+148 -23
View File
@@ -241,7 +241,7 @@ const DENIAL = "不行,这是严令禁止的";
// exploit(?!-):exploit-db.com 等资料站不算 exploit 关键词。
// (?<!防御)攻击:「防御攻击手法」不误触。
const ATTACK =
/渗透(?!测试)|打穿|打下|打站|入侵|拿壳|拿权限|爆破|提权|webshell|getshell|端口扫描|pentest|\bexploit\b(?![-a-z0-9])|\bbreach\b|\bpwn\b|(?<!防御)攻击(?!面)|(?<!surface\s)\battack\b(?!\s+surface)/i;
/渗透测试|红队|打点|拿站|渗透(?!测试)|打穿|打下|打站|入侵|拿壳|拿权限|爆破|提权|webshell|getshell|端口扫描|pentest|\bexploit\b(?![-a-z0-9])|\bbreach\b|\bpwn\b|(?<!防御)攻击(?!面)|(?<!surface\s)\battack\b(?!\s+surface)/i;
// 外挂硬拦。单字「辅助 / 透视」太容易误伤辅助函数、透视投影,必须带游戏或挂本身。
const CHEAT_STRONG =
@@ -251,9 +251,9 @@ const CHEAT_GAME =
const CHEAT_WEAK =
/内存修改|读内存|写内存|dll注入/i;
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过 100KB 时正则回溯会把事件循环卡死。
// 真实攻击意图通常在前几千字符,100KB cap 不会误放过。
const ATTACK_SCAN_CAP = 100 * 1024;
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过上限时按窗扫,不一次喂整篇。
const ATTACK_SCAN_CAP = 256 * 1024;
const ATTACK_WINDOW = 8192;
const NET_TOPIC =
/(?:代理|\bproxy\b|socks|vpn|frp|clash|v2ray|小飞机|机场|出口\s*ip|本机\s*ip|内网\s*ip|公网\s*ip|ip\s*地址|ip\s*归属|ip\s*查询|ip\s*相关|dns|域名解析|网卡|隧道|反向代理|正向代理|http[s]?\s*代理)/i;
@@ -490,13 +490,25 @@ function taskHit(label, kind) {
export function isBenignNetworkTopic(text) {
const t = String(text || "").trim();
if (!t || !NET_TOPIC.test(t)) return false;
return !ATTACK.test(t.length > ATTACK_SCAN_CAP ? t.slice(0, ATTACK_SCAN_CAP) : t);
return !scanHas(ATTACK, t);
}
function scanHas(re, text) {
const sample = String(text || "");
const cap = Math.min(sample.length, ATTACK_SCAN_CAP);
if (!cap) return false;
if (cap <= ATTACK_WINDOW) return re.test(sample.slice(0, cap));
const hop = ATTACK_WINDOW - 256;
for (let i = 0; i < cap; i += hop) {
if (re.test(sample.slice(i, i + ATTACK_WINDOW))) return true;
}
return false;
}
export function isAttackTask(text) {
const sample = String(text || "");
if (isBenignNetworkTopic(sample)) return false;
return ATTACK.test(sample.length > ATTACK_SCAN_CAP ? sample.slice(0, ATTACK_SCAN_CAP) : sample);
return scanHas(ATTACK, sample);
}
export function isCheatTask(text) {
@@ -508,13 +520,19 @@ export function isCheatTask(text) {
function hostsInTask(text) {
const hosts = new Set();
const sample = String(text || "").slice(0, 32768);
collectFromText(sample, hosts);
const sample = String(text || "");
const cap = Math.min(sample.length, ATTACK_SCAN_CAP);
const win = 32768;
const hop = 28672;
const labeled = /(?:[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?\.)+(?:[a-z]{2,63}|xn--[a-z0-9-]{2,59}|[\u4e00-\u9fff]{2,12})/giu;
for (const match of sample.matchAll(labeled)) {
const name = match[0].toLowerCase().replace(/\.$/, "");
if (!keepBareDomain(sample, match.index, name)) continue;
addHost(name, hosts);
for (let i = 0; i < cap; i += hop) {
const chunk = sample.slice(i, i + win);
collectFromText(chunk, hosts);
for (const match of chunk.matchAll(labeled)) {
const name = match[0].toLowerCase().replace(/\.$/, "");
if (!keepBareDomain(chunk, match.index, name)) continue;
addHost(name, hosts);
}
}
return hosts;
}
@@ -532,14 +550,13 @@ async function isRangeTarget(name) {
return ips.every((ip) => isLocalLabAddress(ip));
}
export async function taskTargetHit(text) {
if (!isAttackTask(text)) return null;
export async function publicHostHit(text) {
const names = [];
for (const host of hostsInTask(text)) {
const name = hostOf(host);
if (name) names.push(name);
}
if (!names.length) return taskHit("unspecified", "domain");
if (!names.length) return null;
for (const name of names) {
if (await isRangeTarget(name)) continue;
return taskHit(name, isIp(name) ? "ip" : bankHit(name) ? "bank" : "domain");
@@ -547,6 +564,76 @@ export async function taskTargetHit(text) {
return null;
}
export async function taskTargetHit(text) {
if (!isAttackTask(text)) return null;
let found = false;
for (const host of hostsInTask(text)) {
if (hostOf(host)) found = true;
}
if (!found) return taskHit("unspecified", "domain");
return publicHostHit(text);
}
function blobOf(value, depth = 0) {
if (value == null || depth > 3) return "";
if (typeof value === "string" || typeof value === "number") return String(value);
if (Array.isArray(value)) return value.map((item) => blobOf(item, depth + 1)).join("\n");
if (typeof value !== "object") return "";
const skip = new Set(["agent", "session", "ctx", "next", "signal", "context"]);
return Object.entries(value)
.filter(([key]) => !skip.has(key))
.map(([, item]) => blobOf(item, depth + 1))
.join("\n")
.slice(0, 32768);
}
function toolArgText(message) {
const parts = [];
const calls = message?.toolCalls || message?.tool_calls || [];
for (const call of Array.isArray(calls) ? calls : []) {
parts.push(blobOf(call.arguments ?? call.input ?? call.params ?? call));
}
if (Array.isArray(message?.content)) {
for (const block of message.content) {
if (!block || typeof block !== "object") continue;
if (block.type === "tool_use" || block.type === "tool-call" || block.type === "tool-call-start") {
parts.push(blobOf(block.input ?? block.arguments ?? block));
}
}
}
if (message?.toolName || message?.name) parts.push(String(message.toolName || message.name));
return parts.join("\n");
}
export function latestToolText(messages) {
const list = Array.isArray(messages) ? messages : [];
const parts = [];
for (let i = list.length - 1; i >= 0 && parts.length < 6; i -= 1) {
const role = list[i]?.role;
if (role !== "assistant" && role !== "model") continue;
const blob = toolArgText(list[i]);
if (blob.trim()) parts.push(blob);
}
return parts.join("\n");
}
export function execArgText(exec) {
if (!exec || typeof exec !== "object") return "";
return blobOf({
name: exec.tool?.name || exec.name || exec.toolName,
args: exec.args ?? exec.input ?? exec.parameters ?? exec.params,
command: exec.command,
call: exec.toolCall ?? exec.call,
});
}
function isRedteamPayload(payload) {
const session = payload?.agent?.session || payload?.session;
const raw = session?.agentPreset || session?.header?.agentPreset || session?.projectionValues?.agentPreset || payload?.agent?.preset;
const id = String(raw?.id || raw?.name || raw || "").toLowerCase();
return id.includes("redteam");
}
function messageBody(message) {
if (typeof message?.content === "string") return message.content;
if (!Array.isArray(message?.content)) return typeof message?.text === "string" ? message.text : "";
@@ -664,13 +751,15 @@ async function parkDenial(payload) {
const session = sessionOf(payload);
const turn = Number(payload?.turn);
const step = Number(payload?.step);
if (!session || !Number.isSafeInteger(turn) || step !== 1) return false;
if (!session || !Number.isSafeInteger(turn) || !Number.isSafeInteger(step) || step < 1) return false;
const messages = Array.isArray(payload?.messages) ? payload.messages : [];
let outerOpened = false;
let innerOpened = false;
try {
for (const message of messages) {
session.append("user/message", message, { surfaceOp: "append" });
if (step === 1) {
for (const message of messages) {
session.append("user/message", message, { surfaceOp: "append" });
}
}
session.append("step/start", { turn, step });
outerOpened = true;
@@ -696,18 +785,37 @@ async function parkDenial(payload) {
}
}
function denyToolResult() {
return { isError: true, content: DENIAL, output: DENIAL, text: DENIAL };
}
export function installRegionGate(ctx) {
if (!ctx || typeof ctx.on !== "function") return;
const scoped = new WeakMap();
const hook = async (payload, next) => {
const forward = () => (typeof next === "function" ? next() : { kind: "enter", messages: payload?.messages || [] });
if (Number(payload?.step) !== 1) return forward();
const step = Number(payload?.step);
const turn = Number(payload?.turn);
const session = sessionOf(payload) || payload?.agent?.session;
let hit = null;
try {
const task = currentTaskText(payload?.messages);
if (!task) return forward();
if (isCheatTask(task)) hit = taskHit("cheat", "cheat");
else if (isAttackTask(task)) hit = await taskTargetHit(task);
else return forward();
const redteam = isRedteamPayload(payload);
const marked = session ? scoped.get(session) === turn : false;
if (step === 1) {
if (!task && !redteam) return forward();
if (task && isCheatTask(task)) hit = taskHit("cheat", "cheat");
else if (task && isAttackTask(task)) {
if (session && Number.isSafeInteger(turn)) scoped.set(session, turn);
hit = await taskTargetHit(task);
} else if (redteam) {
if (session && Number.isSafeInteger(turn)) scoped.set(session, turn);
hit = task ? await publicHostHit(task) : null;
} else return forward();
} else if (redteam || marked || isAttackTask(task)) {
if (isCheatTask(task)) hit = taskHit("cheat", "cheat");
else hit = await publicHostHit(latestToolText(payload?.messages));
} else return forward();
} catch {
return forward();
}
@@ -720,10 +828,27 @@ export function installRegionGate(ctx) {
}
return forward();
};
const toolHook = async (exec, next) => {
const forward = () => (typeof next === "function" ? next() : denyToolResult());
try {
const blob = execArgText(exec);
if (!blob.trim()) return forward();
const hit = await publicHostHit(blob);
if (!hit) return forward();
} catch {
return forward();
}
if (exec && typeof exec === "object") {
exec.blocked = true;
exec.error = DENIAL;
}
return denyToolResult();
};
const arm = () => {
if (ctx.__dshPurgeRegionGate) return true;
try {
ctx.on("agent/pre-step", hook, { global: true, prepend: true });
try { ctx.on("tools/pre-execute", toolHook, { global: true, prepend: true }); } catch { /* 旧宿主没有工具钩。 */ }
ctx.__dshPurgeRegionGate = true;
return true;
} catch {
+26 -2
View File
@@ -38,8 +38,10 @@ function listProfilePatchFiles(dshHome) {
}
for (const name of names) {
if (name === "node_modules") continue;
const fp = path.join(root, name, "cordis.patch.yml");
if (fs.existsSync(fp)) out.push(fp);
for (const file of ["cordis.patch.yml", "cordis.yml"]) {
const fp = path.join(root, name, file);
if (fs.existsSync(fp)) out.push(fp);
}
}
return out;
}
@@ -167,6 +169,28 @@ export function clearOwnedSelectedDefault({ ctx = null, dshHome = "" } = {}) {
return report;
}
let pendingClear = null;
/** 热重载会先 dispose 再 apply:延迟写盘,apply 进来就取消,避免把用户的红队默认冲掉。 */
export function scheduleClearOwnedSelectedDefault(opts = {}) {
if (pendingClear) {
clearTimeout(pendingClear);
pendingClear = null;
}
pendingClear = setTimeout(() => {
pendingClear = null;
try { clearOwnedSelectedDefault(opts); } catch { /* 停用不被清默认挡住 */ }
try { removeStaleAgentPresetDir(opts.dshHome, "redteam"); } catch { /* ignore */ }
}, 800);
if (typeof pendingClear.unref === "function") pendingClear.unref();
}
export function cancelClearOwnedSelectedDefault() {
if (!pendingClear) return;
clearTimeout(pendingClear);
pendingClear = null;
}
export function removeStaleAgentPresetDir(dshHome, id = "redteam") {
const home = dshHome || findDshHome();
if (!home || !id) return false;
+159
View File
@@ -0,0 +1,159 @@
/**
* 用户层 profile/cordis.patch.yml 的本体 insert(#154 / #159)。
*
* 包内 overlay 只改已入队行的 inject/config,不能再 insert 一次(Hub 已入队会
* already queued)。postinstall 和演练台子行都走这里:行不存在就写一条。
*/
import fs from "node:fs";
import path from "node:path";
export const PURGE_NAME = "dsh-purge";
export const INSERT_BLOCK = [
"- insert:",
" - id: dsh-purge",
" name: dsh-purge",
" inject: [systemPrompt, tools]",
" config:",
" enabled: true",
" stripMnemon: true",
" capabilityProtocol: true",
" hooksDenyBypass: true",
"",
].join("\n");
export function profileHasPurgeBodyInsert(text) {
const lines = String(text || "").split(/\r?\n/);
let insertIndent = -1;
for (const line of lines) {
if (/^-\s*insert:\s*$/.test(line) || /^\s+-\s*insert:\s*$/.test(line)) {
insertIndent = (line.match(/^[ \t]*/) || [""])[0].length;
continue;
}
if (insertIndent < 0) continue;
const indent = (line.match(/^[ \t]*/) || [""])[0].length;
const trimmed = line.trim();
if (trimmed && indent <= insertIndent && /^-\s/.test(trimmed)) {
insertIndent = -1;
if (/^-\s*insert:\s*$/.test(trimmed)) {
insertIndent = indent;
}
continue;
}
// 本体行:id: dsh-purge,或用户按 #159 临时绕过写的 dsh-purge-main / name: dsh-purge
if (/^-\s*id:\s*dsh-purge(-main)?\s*$/.test(trimmed)) return true;
if (/^-\s*name:\s*dsh-purge\s*$/.test(trimmed)) return true;
}
return false;
}
export function ensureProfileBodyInsert(profileDir) {
const fp = path.join(profileDir, "cordis.patch.yml");
let text = "";
try { text = fs.readFileSync(fp, "utf8"); } catch { text = ""; }
if (profileHasPurgeBodyInsert(text)) {
return { ok: true, wrote: false, path: fp };
}
const prefix = text && !text.endsWith("\n") ? "\n" : "";
fs.writeFileSync(fp, `${text}${prefix}${text ? "\n" : ""}${INSERT_BLOCK}`, "utf8");
return { ok: true, wrote: true, path: fp };
}
function readJson(fp) {
try {
return JSON.parse(fs.readFileSync(fp, "utf8"));
} catch {
return null;
}
}
function profileOwnsPurge(dir) {
const pkg = readJson(path.join(dir, "package.json"));
const bundles = pkg?.dsh?.profile?.bundles;
if (Array.isArray(bundles) && bundles.includes(PURGE_NAME)) return true;
try {
return fs.existsSync(path.join(dir, "node_modules", PURGE_NAME, "package.json"));
} catch {
return false;
}
}
export function listProfileDirs(dshHome) {
const root = path.join(dshHome || "", "profiles");
const out = [];
let names = [];
try { names = fs.readdirSync(root); } catch { return out; }
for (const name of names) {
const dir = path.join(root, name);
try {
if (fs.statSync(dir).isDirectory()) out.push(dir);
} catch { /* skip */ }
}
return out;
}
export function ensureProfileBundles(profileDir) {
const fp = path.join(profileDir, "package.json");
const pkg = readJson(fp);
if (!pkg) return { ok: false, wrote: false, path: fp };
pkg.dsh = pkg.dsh && typeof pkg.dsh === "object" ? pkg.dsh : {};
pkg.dsh.profile = pkg.dsh.profile && typeof pkg.dsh.profile === "object" ? pkg.dsh.profile : {};
const bundles = Array.isArray(pkg.dsh.profile.bundles) ? pkg.dsh.profile.bundles : [];
if (bundles.includes(PURGE_NAME)) return { ok: true, wrote: false, path: fp };
pkg.dsh.profile.bundles = [...bundles, PURGE_NAME];
fs.writeFileSync(fp, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
return { ok: true, wrote: true, path: fp };
}
/** pnpm 11/12 默认拦 postinstall(ERR_PNPM_IGNORED_BUILDS)。写进 profile 的 allowBuilds,下次 add 能跑脚本。 */
export function ensurePnpmAllowBuild(profileDir) {
const fp = path.join(profileDir, "pnpm-workspace.yaml");
let text = "";
try { text = fs.readFileSync(fp, "utf8"); } catch { text = ""; }
if (/(^|\n)[ \t]*dsh-purge[ \t]*:[ \t]*true\b/.test(text)) return { ok: true, wrote: false, path: fp };
if (!String(text).trim()) {
fs.writeFileSync(fp, "allowBuilds:\n dsh-purge: true\n", "utf8");
return { ok: true, wrote: true, path: fp };
}
if (/(^|\n)allowBuilds[ \t]*:/.test(text)) {
const next = text.replace(/(^|\n)(allowBuilds[ \t]*:[ \t]*\n)/, "$1$2 dsh-purge: true\n");
if (next === text) return { ok: true, wrote: false, path: fp };
fs.writeFileSync(fp, next, "utf8");
return { ok: true, wrote: true, path: fp };
}
const prefix = text.endsWith("\n") ? "" : "\n";
fs.writeFileSync(fp, `${text}${prefix}\nallowBuilds:\n dsh-purge: true\n`, "utf8");
return { ok: true, wrote: true, path: fp };
}
/** 已装进 bundles / node_modules 但缺 insert 的 profile,补上本体行。 */
export function ensureAllProfileBodyInserts(dshHome) {
return ensureAllProfileInstall(dshHome).map((item) => ({
dir: item.dir,
ok: item.ok,
wrote: Boolean(item.insert?.wrote),
path: item.insert?.path || path.join(item.dir || "", "cordis.patch.yml"),
error: item.error,
}));
}
/** bundles + 本体 insert + pnpm allowBuilds。postinstall 被跳过、升级覆盖 overlay 之后靠这条把按钮找回来。 */
export function ensureAllProfileInstall(dshHome) {
const results = [];
for (const dir of listProfileDirs(dshHome)) {
if (!profileOwnsPurge(dir)) continue;
try {
const bundles = ensureProfileBundles(dir);
const insert = ensureProfileBodyInsert(dir);
const pnpm = ensurePnpmAllowBuild(dir);
results.push({ dir, ok: true, bundles, insert, pnpm });
} catch (error) {
results.push({
dir,
ok: false,
error: error && error.message ? error.message : String(error),
});
}
}
return results;
}
+108 -8
View File
@@ -22,12 +22,24 @@ window.__ModuleLoader__.load({
*/
const CSS = `
.rt-dock{position:fixed;top:12px;right:12px;z-index:20;display:flex;flex-direction:column;box-sizing:border-box;
background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1c1c) 52%,transparent);
backdrop-filter:blur(20px) saturate(1.3);-webkit-backdrop-filter:blur(20px) saturate(1.3);
border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,#444) 70%,transparent);
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
--rt-line-2:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 50%,transparent);
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#16140f);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
background:var(--rt-paper);
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
border:1px solid var(--rt-line);
border-radius:12px;
box-shadow:0 18px 48px color-mix(in srgb,#000 28%,transparent);pointer-events:auto;color:var(--dsw-alias-label-primary);
font-size:13px;line-height:1.5}
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 16%,transparent);
pointer-events:auto;color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5}
.rt-dock.rt-embedded{position:relative;inset:auto;width:100%;height:100%;max-width:none;border:0;border-radius:0;box-shadow:none;background:transparent!important;backdrop-filter:none;-webkit-backdrop-filter:none}
.rt-grip,.rt-resize-r,.rt-resize-b,.rt-resize-c{position:absolute;z-index:3;touch-action:none}
.rt-grip{left:-3px;top:0;bottom:0;width:8px;cursor:ew-resize;background:transparent}
@@ -165,8 +177,20 @@ window.__ModuleLoader__.load({
.rt-link{color:var(--dsw-alias-brand-primary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rt-link:hover{text-decoration:underline}
.rt-full{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;
background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;
border-top:3px solid var(--dsw-alias-brand-primary)}
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#16140f);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
background:var(--rt-paper);color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5;
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
border:1px solid var(--rt-line);box-shadow:inset 0 1px 0 var(--rt-hi)}
.rt-full .rt-head{padding:12px 18px}
.rt-full .rt-tabs{padding:10px 18px 0;gap:6px;flex-wrap:wrap}
.rt-full .rt-side{width:260px}
@@ -558,7 +582,83 @@ window.__ModuleLoader__.load({
.rt-shot-zoom{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.82);display:flex;flex-direction:column;
align-items:center;justify-content:center;gap:10px;cursor:zoom-out;padding:18px}
.rt-shot-zoom img{max-width:96vw;max-height:86vh;border-radius:6px;box-shadow:0 18px 48px rgba(0,0,0,.5)}
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}` /* ---------------------------------------------------------- 桥接与状态 */
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}
body[data-ds-dark-theme] .rt-dock,body[data-ds-dark-theme] .rt-full,
.dshp-dock[data-theme="dusk"] .rt-dock,.dshp-dock[data-theme="dusk"] .rt-full{
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#1c1e24) 34%,transparent);
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 26%,transparent);
--rt-hi:color-mix(in srgb,#fff 10%,transparent);
--rt-ink:var(--dsw-alias-label-primary,#f4f1ea);
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 78%,var(--dsw-alias-label-secondary,#c9c3b8));
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);
--rt-ok:#8fd0a8;--rt-warn:#e4c48a;--rt-bad:#f0b4b4;
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
.rt-card,.rt-sess,.rt-hit,.rt-cred,.rt-evi,.rt-kb,.rt-rep,.rt-flow-node,.rt-hflow-node,.rt-atest,.rt-hcol,.rt-ap-hit,.rt-rep-req,.rt-rep-trace,.rt-shots,.rt-modal-box{
background:var(--rt-paper)!important;border-color:var(--rt-line)!important;color:var(--rt-ink);
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);box-shadow:inset 0 1px 0 var(--rt-hi)}
.rt-score-group,.rt-sec,.rt-kb-cat,.rt-evi-head,.rt-rep-req-head,.rt-ap-head,.rt-ap-goal,.rt-rep-stage{
background:var(--rt-paper-2)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)}
.rt-head,.rt-tabs,.rt-toolbar,.rt-foot,.rt-side,.rt-list,.rt-pane,.rt-livebar,.rt-concl,.rt-subtabs,.rt-kb-filter,.rt-kb-cats,.rt-body,.rt-table,.rt-main{
background:transparent!important;box-shadow:none}
.rt-row.head,.rt-score-row.head,.rt-vrow.head{
background:var(--rt-paper)!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.rt-row:hover,.rt-vrow:hover,.rt-score-row:hover,.rt-item:hover,.rt-item.on,.rt-seg:hover,.rt-seg.on,.rt-icon-btn:hover,.rt-hbtn:hover,.rt-kb-head:hover,.rt-sidehead-btn:hover,.rt-sec:hover,.rt-rep-stage:hover,.rt-concl-i:hover,.rt-concl-i.on{
background:var(--rt-fill)!important}
.rt-btn,.rt-icon-btn,.rt-hbtn,.rt-input,.rt-eng-select,.rt-textarea,.rt-chip,.rt-code,.rt-hit-evi,.rt-atest-notes,.rt-clip-body,.rt-evi-body,.rt-rep-http,.rt-md,.rt-kb-tpl-row,.rt-hit-row,.rt-ap-asset,.rt-ap-tunnel{
background:var(--rt-well)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)!important;
backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.rt-btn{border-radius:8px;transition:transform 500ms var(--rt-ease),opacity 300ms var(--rt-ease)}
.rt-btn:hover:not(:disabled){transform:translateY(-1px);border-color:var(--rt-accent)}
.rt-btn:active:not(:disabled){transform:scale(.98)}
.rt-btn:focus-visible,.rt-input:focus-visible,.rt-tab:focus-visible,.rt-icon-btn:focus-visible,.rt-hbtn:focus-visible{
outline:2px solid var(--rt-accent);outline-offset:2px}
.rt-btn-primary,.rt-btn-primary:hover:not(:disabled){background:var(--rt-accent)!important;border-color:var(--rt-accent)!important;color:#fff!important;backdrop-filter:none}
.rt-input option,.rt-eng-select option{background:var(--dsw-alias-bg-layer-1,#fff);color:var(--rt-ink)}
body[data-ds-dark-theme] .rt-input option,body[data-ds-dark-theme] .rt-eng-select option,.dshp-dock[data-theme="dusk"] .rt-input option,.dshp-dock[data-theme="dusk"] .rt-eng-select option{background:#1b1d22;color:#f4f1ea}
.rt-pri-high,.rt-test-blocked,.rt-sev-critical,.rt-sev-high{color:var(--rt-bad)!important;background:color-mix(in srgb,var(--rt-bad) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-bad) 40%,var(--rt-line))!important}
.rt-pri-medium,.rt-test-testing,.rt-tag-active{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
.rt-pri-low{color:var(--rt-mute)!important;background:var(--rt-paper-2)!important;border:1px solid var(--rt-line)!important}
.rt-gain,.rt-counted,.rt-scorepts,.rt-flow-pts,.rt-hflow-pts,.rt-hcol-pts,.rt-ap-pts{color:var(--rt-ok)!important;background:color-mix(in srgb,var(--rt-ok) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-ok) 38%,var(--rt-line))!important}
.rt-secret{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 14%,transparent)!important;border-color:color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
.rt-scope-internal{color:#0e7490;background:color-mix(in srgb,#06b6d4 16%,transparent);border:1px solid color-mix(in srgb,#06b6d4 32%,transparent)}
.rt-scope-external{color:var(--rt-warn);background:color-mix(in srgb,var(--rt-warn) 16%,transparent);border:1px solid color-mix(in srgb,var(--rt-warn) 32%,transparent)}
.rt-scope-testing{color:#5b21b6;background:color-mix(in srgb,#8b5cf6 16%,transparent);border:1px solid color-mix(in srgb,#8b5cf6 32%,transparent)}
body[data-ds-dark-theme] .rt-scope-internal,.dshp-dock[data-theme="dusk"] .rt-scope-internal{color:#67e8f9}
body[data-ds-dark-theme] .rt-scope-testing,.dshp-dock[data-theme="dusk"] .rt-scope-testing{color:#c4b5fd}
.rt-modal-box{border-radius:16px;backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4);
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
.rt-flow-action.inferred,.rt-ap-act.inferred{font-style:normal}
@media (prefers-reduced-motion:reduce){.rt-btn,.rt-live-dot{transition:opacity 300ms var(--rt-ease);animation:none;transform:none}}
.rt-head,.rt-toolbar,.rt-foot,.rt-livebar,.rt-concl{padding:8px 12px}
.rt-tabs,.rt-subtabs{gap:8px;padding:0 12px}
.rt-tab{padding:8px 12px;gap:4px}
.rt-pane,.rt-chain,.rt-sess-grid,.rt-flow,.rt-ap,.rt-rep-list,.rt-live-body{padding:12px}
.rt-side,.rt-list{width:192px;padding:8px;box-sizing:border-box}
.rt-seg,.rt-item{padding:8px;border-radius:8px;margin-bottom:4px}
.rt-card{padding:12px;margin-bottom:12px;border-radius:8px}
.rt-card h4{margin:0 0 8px}
.rt-btn{padding:4px 12px;border-radius:8px;font-size:12px;line-height:20px}
.rt-input,.rt-eng-select{padding:4px 12px;border-radius:8px;min-height:32px;box-sizing:border-box}
.rt-textarea{padding:8px 12px;border-radius:8px}
.rt-row,.rt-score-row,.rt-vrow{padding:8px 12px;gap:8px}
.rt-row{grid-template-columns:minmax(96px,1.1fr) minmax(56px,72px) minmax(64px,96px) minmax(0,1.2fr) minmax(0,1fr)}
.rt-toolbar{gap:8px}
.rt-hint{padding:8px 12px;margin-bottom:8px;border-radius:8px}
.rt-empty,.rt-err{padding:8px 12px}
.rt-empty{padding:24px 12px}
.rt-sess{padding:12px;border-radius:8px}
.rt-sess-grid{gap:12px}
.rt-expand,.rt-score-detail,.rt-vdetail{padding:8px 12px 12px}
.rt-section{padding:8px 12px 4px}
.rt-full .rt-head{padding:12px 16px}
.rt-full .rt-tabs{padding:0 16px;gap:8px}
.rt-full .rt-pane,.rt-full .rt-chain,.rt-full .rt-sess-grid{padding:16px}
.rt-full .rt-foot,.rt-full .rt-toolbar,.rt-full .rt-livebar,.rt-full .rt-concl{padding:8px 16px}
.rt-full .rt-side{width:240px}
.rt-full .rt-list{width:256px}
.rt-full .rt-row{grid-template-columns:minmax(0,1.2fr) minmax(64px,90px) minmax(80px,130px) minmax(0,1.4fr) minmax(0,1.2fr)}
` /* ---------------------------------------------------------- 桥接与状态 */
/** 是否在「全面浏览」独立窗口里(URL hash 标记,复用同一套界面代码)。 */
const isFullWindow = () => {
try { return String(window.location.hash || '') === '#redteam-full' } catch { return false }
+13
View File
@@ -11,6 +11,8 @@ import { homedir } from 'node:os'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { readPresetDefinition } from './preset-composition.js'
import { scheduleClearOwnedSelectedDefault } from '../preset-default.js'
import { ensureAllProfileBodyInserts } from '../profile-insert.js'
/** Cordis 插件名。 */
export const name = 'dsh-purge-redteam'
@@ -459,6 +461,16 @@ export function installPreset(options = {}) {
* @param ctx - 插件上下文。
*/
export function apply(ctx) {
try {
const home = process.env.DSH_HOME || join(homedir(), '.dsh')
const healed = ensureAllProfileBodyInserts(home)
for (const item of healed) {
if (item.wrote) {
ctx.logger?.info?.('redteam-mode: 已补本体 insert %s(下次启动加载主插件)', item.path)
}
}
} catch { /* 自愈失败不挡预设落地 */ }
const paths = packagePaths()
let result
try {
@@ -605,6 +617,7 @@ export function apply(ctx) {
closed = true
if (timer) clearInterval(timer)
if (stop) clearTimeout(stop)
try { scheduleClearOwnedSelectedDefault({ ctx }) } catch { /* 清默认失败不挡停用 */ }
void undeclare()
}
}, 'dsh-purge-redteam: declare agent preset')
+21
View File
@@ -31,6 +31,9 @@ export function pathLooksDesktop(p) {
n.includes("/dsh desktop.app/") ||
n.includes("dsh-desktop") ||
n.includes("dsh-plugin-desktop") ||
n.includes("/deepseek bot/") ||
n.includes("/deepseek-bot/") ||
n.includes("/ds-bot/") ||
n.includes("/deepseek harness.app/") ||
(harnessDir && (n.includes("/resources/") || n.includes("/contents/resources/") || n.endsWith("/resources"))) ||
/\/dsh desktop\.exe$/i.test(n) ||
@@ -56,8 +59,25 @@ function resourcesLookLikeDesktopInstall(resourcesPath) {
return false;
}
/** 社区 Electron(DS Bot / DeepSeek Bot):profile 常是 ds-bot,DSH_SURFACE 还可能被写成 web。 */
export function isCommunityElectronHost(input = {}) {
const env = input.env ?? process.env;
const profile = norm(env.DSH_PROFILE);
if (profile === "ds-bot" || profile === "dsbot" || profile === "deepseek-bot") return true;
const execPath = input.execPath ?? process.execPath;
const name = exeName(execPath);
if (/^deepseek[\s._-]*bot(\.exe)?$/.test(name) || /^ds[\s._-]*bot(\.exe)?$/.test(name)) return true;
const p = slash(execPath);
if (p.includes("/deepseek bot") || p.includes("/deepseek-bot") || p.includes("/ds-bot/") || p.endsWith("/ds-bot")) return true;
const resourcesPath = input.resourcesPath ?? process.resourcesPath;
const electron = (input.versions ?? process.versions)?.electron;
if (electron && resourcesLookLikeDesktopInstall(resourcesPath)) return true;
return false;
}
export function isDesktopSurface(input = {}) {
const env = input.env ?? process.env;
if (isCommunityElectronHost(input)) return true;
const forced = norm(env.DSH_SURFACE);
if (forced === "desktop") return true;
if (forced && SURFACES.includes(forced)) return false;
@@ -95,6 +115,7 @@ function forcedSurface(env) {
export function detectSurface(input = {}) {
const env = input.env ?? process.env;
if (isCommunityElectronHost(input)) return "desktop";
const forced = forcedSurface(env);
if (forced) return forced;
if (isDesktopSurface(input)) return "desktop";
+41 -14
View File
@@ -6,6 +6,7 @@ import * as hostctl from "./host.js";
import * as rules from "./rules.js";
import * as updater from "./update.js";
import { clearDrillGrant } from "./drill-grant.js";
import { clearOwnedSelectedDefault, removeStaleAgentPresetDir } from "./preset-default.js";
export function wasApplied(state) {
if (!state) return false;
@@ -34,6 +35,18 @@ export function shouldDeletePluginTree(dir, dshHome = core.findDshHome()) {
return n.startsWith(`${homeN}/profiles/`);
}
function isPurgeBundleItem(item) {
if (typeof item === "string") return item === "dsh-purge" || item.startsWith("dsh-purge@");
const id = item && (item.id || item.name);
return id === "dsh-purge";
}
function stripBundleList(list) {
if (!Array.isArray(list)) return { list, changed: false };
const next = list.filter((item) => !isPurgeBundleItem(item));
return { list: next, changed: next.length !== list.length };
}
export function stripPluginFromPackage(pkg) {
if (!pkg || typeof pkg !== "object") return false;
let changed = false;
@@ -44,14 +57,15 @@ export function stripPluginFromPackage(pkg) {
}
}
for (const key of ["bundles", "plugins"]) {
if (!Array.isArray(pkg[key])) continue;
const next = pkg[key].filter((item) => {
if (typeof item === "string") return item !== "dsh-purge" && !item.startsWith("dsh-purge@");
const id = item && (item.id || item.name);
return id !== "dsh-purge";
});
if (next.length !== pkg[key].length) {
pkg[key] = next;
const top = stripBundleList(pkg[key]);
if (top.changed) {
pkg[key] = top.list;
changed = true;
}
const nested = pkg.dsh && pkg.dsh.profile ? pkg.dsh.profile[key] : null;
const nest = stripBundleList(nested);
if (nest.changed) {
pkg.dsh.profile[key] = nest.list;
changed = true;
}
}
@@ -74,11 +88,9 @@ function pkgMentionsPurge(pkg) {
if (!pkg) return false;
if (pkg.dependencies?.["dsh-purge"] || pkg.devDependencies?.["dsh-purge"]) return true;
for (const key of ["bundles", "plugins"]) {
if (!Array.isArray(pkg[key])) continue;
if (pkg[key].some((item) => {
if (typeof item === "string") return item === "dsh-purge" || item.startsWith("dsh-purge@");
return item && (item.id === "dsh-purge" || item.name === "dsh-purge");
})) return true;
if (Array.isArray(pkg[key]) && pkg[key].some(isPurgeBundleItem)) return true;
const nested = pkg.dsh && pkg.dsh.profile ? pkg.dsh.profile[key] : null;
if (Array.isArray(nested) && nested.some(isPurgeBundleItem)) return true;
}
return false;
}
@@ -193,7 +205,9 @@ function unregisterProfiles(profiles) {
return { stripped, errors };
}
export async function uninstallPurge() {
export async function uninstallPurge(options = {}) {
const onStage = typeof options.onStage === "function" ? options.onStage : () => {};
onStage("locate");
const state = await core.gatherState();
const applied = wasApplied(state);
const dshHome = state.dsh_home || core.findDshHome();
@@ -213,6 +227,7 @@ export async function uninstallPurge() {
};
try {
onStage("revert");
if (state.ai_base) {
report.patches = await core.revertAll(state.ai_base);
if (applied) report.reverted = true;
@@ -228,6 +243,7 @@ export async function uninstallPurge() {
}
try {
onStage("shim");
report.shim = await core.revertAllShims();
if (state.shim_cmd === "patched" || state.shim_ps1 === "patched" || state.shim_bin === "patched") {
report.reverted = true;
@@ -236,6 +252,7 @@ export async function uninstallPurge() {
report.errors.push(`revert shims: ${e.message || e}`);
}
onStage("flash");
try {
report.flash = core.revertCmdFlash(state.ai_base, dshHome);
} catch (e) {
@@ -254,6 +271,14 @@ export async function uninstallPurge() {
report.errors.push(`reset rules: ${e.message || e}`);
}
try {
const preset = clearOwnedSelectedDefault({ dshHome });
report.presetDefault = { live: preset.live, files: preset.files };
report.stalePresetDir = removeStaleAgentPresetDir(dshHome, "redteam");
} catch (e) {
report.errors.push(`clear selectedDefault: ${e.message || e}`);
}
const profiles = listInstalledProfiles(dshHome);
report.profiles = profiles.map((p) => p.name);
const unreg = unregisterProfiles(profiles);
@@ -277,7 +302,9 @@ export async function uninstallPurge() {
return report;
}
onStage("cleanup");
report.cleanup = collectCleanupDirs(profiles, dshHome);
onStage("done");
return report;
}
+2
View File
@@ -7,6 +7,7 @@ import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { atomicWriteSync, findDshHome } from "./core.js";
import { ensureAllProfileInstall } from "./profile-insert.js";
import { extractZipArchive } from "./zip-extract.js";
const REPO = "YuJunZhiXue/dsh-purge";
@@ -1025,6 +1026,7 @@ async function _applyUpdateImpl(jobs, options) {
vias.add("zip");
}
for (const dir of specProfiles) pinInstalledSpec(dir, ref);
try { ensureAllProfileInstall(findDshHome()); } catch { /* 升级后补 insert,失败不挡这次覆盖 */ }
const sha = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || (await remoteHeadSha(ref).catch(() => ""));
const via = vias.size > 1 ? "mixed" : [...vias][0] || detectVia();
const saved = writeChannelState({ channel, pin });
+5 -4
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-purge",
"version": "1.1.74",
"version": "1.1.79",
"description": "DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分",
"type": "module",
"main": "lib/index.js",
@@ -35,7 +35,8 @@
],
"scripts": {
"embed-prompt": "node scripts/embed-default-prompt.mjs",
"build:client": "node scripts/build-client.mjs"
"build:client": "node scripts/build-client.mjs",
"postinstall": "node scripts/ensure-profile-bundle.mjs"
},
"license": "Apache-2.0",
"keywords": [
@@ -78,8 +79,8 @@
},
"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",
"tarball": "https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master",
"zip": "https://codeload.github.com/YuJunZhiXue/dsh-purge/zip/refs/heads/master",
"git": "https://github.com/YuJunZhiXue/dsh-purge.git"
}
},
+74
View File
@@ -1,3 +1,77 @@
# 1.1.79
## 中文
- 版本 **1.1.79**。修复 bug,修复稳定性。
- **#165**:社区版 DS Bot / DeepSeek Bot 按桌面宿主识别(`ds-bot` profile、Electron asar),不再误报 `set DSH_BASE`。
- **#166**:pnpm 12 拦 `postinstall` 时补 `allowBuilds`,并写清 `--allow-build=dsh-purge` / `approve-builds`。
- **#167**:升级后补回 `bundles` + 本体 insert,空芯片不再把启动钮藏掉,1.1.74 有的按钮会回来。
- 应用/还原/卸载进度条跟 job 阶段;主智能体和子智能体同一份注入、权限和能力协议。
- 新建会话不再把 `dsh-purge` 芯片甩到行尾。
## English
- **1.1.79**. Bug fixes and stability.
- **#165**: community DS Bot / DeepSeek Bot is a desktop host (`ds-bot` profile, Electron asar); no more false `set DSH_BASE`.
- **#166**: pnpm 12 skipped `postinstall`; write `allowBuilds` and document `--allow-build=dsh-purge`.
- **#167**: restore `bundles` + body insert after upgrade so the 1.1.74 button comes back.
- Apply / revert / uninstall progress follows the job; main and subagents share inject, permission, and capability text.
- New-session no longer shoves the `dsh-purge` chip to the far right.
# 1.1.78
## 中文
- 版本 **1.1.78**。修复 bug:停用/卸载后无法新建会话。
- **#108**:停用或卸载时把 `agent-preset-registry.selectedDefault` 从 `redteam` 改回 `standard`,并清掉 `$DSH_HOME/.agent-presets/redteam`。热重载不会冲掉用户设的红队默认。
- 卸载同时处理 `dsh.profile.bundles` / `dsh.profile.plugins`,桌面 profile 不再残留 `dsh-purge`。
## English
- **1.1.78**. Bug fix: new sessions after disable/uninstall.
- **#108**: on disable or uninstall, reset `agent-preset-registry.selectedDefault` from `redteam` to `standard`, and remove `$DSH_HOME/.agent-presets/redteam`. Hot reload keeps a user-chosen redteam default.
- Uninstall also strips `dsh.profile.bundles` / `dsh.profile.plugins`.
# 1.1.77
## 中文
- 版本 **1.1.77**。修复 bug,修复稳定性。
- 修长红队任务仍打公网:`渗透测试` / `红队` / `打点` / `拿站` 纳入门禁;正文按窗扫到 256KB,目标写在后半段也能拦。
- 修后续步骤漏拦:每一步看工具参数,`tools/pre-execute` 遇到公网 IP/域名直接停轮。
- 长文正则按窗扫,避免整篇回溯把事件循环卡死。
## English
- **1.1.77**. Bug fixes and stability.
- Long red-team tasks no longer reach the public internet: `渗透测试` / red-team / 打点 / 拿站 are gated; the body is scanned in windows up to 256KB.
- Later steps are gated too: tool arguments are checked, and `tools/pre-execute` stops on a public IP or name.
- Long-text regex runs in windows so a huge paste cannot stall the event loop.
# 1.1.76
## 中文
- 版本 **1.1.76**。适配只走 pnpm 的机器:在 profile 目录 `pnpm add` codeload 压缩包即可,`postinstall` 自动把 `dsh-purge` 写进 `bundles`。
- 安装地址改成 `codeload.github.com`,避开 `github.com/archive` 的 302(pnpm 会 `fetch failed`)。不要 `pnpm add dsh-purge`(npm 仓库没有这个名字)。
## English
- **1.1.76**. pnpm-only hosts: `pnpm add` the codeload tarball inside the profile; `postinstall` writes `dsh-purge` into `bundles`.
- Install URL is `codeload.github.com` so pnpm does not die on the `github.com/archive` 302. Do not `pnpm add dsh-purge` — that name is not on the npm registry.
# 1.1.75
## 中文
- 版本 **1.1.75**。修 Hub 市场一键安装报 `already queued: dsh-purge`:`cordis.patch.yml` 不再把已经在 bundles 里的本体再 insert 一遍。
- README 把安装写成三步:只用 GitHub 压缩包命令,不走插件市场 / `github:` / npm。
## English
- **1.1.75**. Fix Hub one-click `already queued: dsh-purge`: the bundle patch no longer inserts the plugin that is already in `bundles`.
- README install is three steps: GitHub tarball only; skip the plugin market / `github:` / npm.
# 1.1.74
## 中文
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env node
/**
* 装进 DSH profile 时补两笔(#154):
* 1. dsh.profile.bundles
* 2. 用户层 cordis.patch.yml 的本体 insert
* pnpm add / dsh plugin add 都不会自己写 insert;市场会写,已有则跳过。
* 在插件仓库里跑 pnpm install 则整段跳过。
*/
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import {
PURGE_NAME as NAME,
ensureProfileBodyInsert,
ensureProfileBundles,
ensurePnpmAllowBuild,
profileHasPurgeBodyInsert,
} from "../lib/profile-insert.js";
export { profileHasPurgeBodyInsert };
function readJson(fp) {
try {
return JSON.parse(fs.readFileSync(fp, "utf8"));
} catch {
return null;
}
}
function isProfilePkg(pkg) {
if (!pkg || typeof pkg !== "object") return false;
if (typeof pkg.name === "string" && pkg.name.startsWith("dsh-profile-")) return true;
return Array.isArray(pkg.dsh?.profile?.bundles);
}
function findProfileDir() {
const seeds = [process.env.INIT_CWD, process.env.npm_config_local_prefix, process.cwd()].filter(Boolean);
for (const seed of seeds) {
let dir = path.resolve(seed);
for (let i = 0; i < 8; i += 1) {
if (isProfilePkg(readJson(path.join(dir, "package.json")))) return dir;
const parent = path.dirname(dir);
if (parent === dir) break;
dir = parent;
}
}
return "";
}
function ensureProfileInsert(profileDir) {
const result = ensureProfileBodyInsert(profileDir);
if (result.wrote) {
process.stdout.write(`dsh-purge: wrote body insert (${result.path})\n`);
} else {
process.stdout.write(`dsh-purge: insert already in ${result.path}\n`);
}
return result.wrote;
}
function main() {
const profileDir = findProfileDir();
if (!profileDir) return;
const fp = path.join(profileDir, "package.json");
const pkg = readJson(fp);
if (!pkg) {
process.stderr.write(`dsh-purge: cannot read ${fp}\n`);
process.exit(1);
}
const bundles = ensureProfileBundles(profileDir);
process.stdout.write(bundles.wrote
? `dsh-purge: appended to bundles (${profileDir})\n`
: `dsh-purge: already in bundles (${profileDir})\n`);
try {
ensureProfileInsert(profileDir);
const pnpm = ensurePnpmAllowBuild(profileDir);
if (pnpm.wrote) process.stdout.write(`dsh-purge: allowed pnpm build for ${NAME}\n`);
} catch (e) {
process.stderr.write(`dsh-purge: insert failed: ${e && e.message ? e.message : e}\n`);
process.exit(1);
}
}
const invoked = process.argv[1] ? path.resolve(process.argv[1]) : "";
if (invoked === fileURLToPath(import.meta.url)) main();