mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-27 19:00:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
318b3e3db3 | ||
|
|
6a3f89da8d | ||
|
|
278eabbc07 |
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.13</strong></p>
|
||||
<p align="center"><strong>Version 1.1.14</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>Local official DeepSeek Harness cybersecurity red-team plugin: evaluate and harden host safety policy in a controlled local install; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
||||
@@ -246,13 +246,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
<p align="center">
|
||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&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.14&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
|
||||
</p>
|
||||
|
||||
🔗 **Raw protocol URL:**
|
||||
|
||||
```
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.14&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
|
||||
```
|
||||
|
||||
**Web trigger example:**
|
||||
@@ -265,7 +265,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.13',
|
||||
version: '1.1.14',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -284,7 +284,7 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML link:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.14&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
🚀 Install in desktop client
|
||||
</a>
|
||||
```
|
||||
@@ -295,7 +295,7 @@ export function installDshPurgeToDesktop() {
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | Plugin id |
|
||||
| name | `dsh-purge` | Display name |
|
||||
| version | `1.1.13` | Semver |
|
||||
| version | `1.1.14` | Semver |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
||||
@@ -753,6 +753,16 @@ If nothing is found, set `DSH_BASE` / `DSH_DESKTOP_INSTALL`. No files are change
|
||||
|
||||
## Changelog
|
||||
|
||||
### 1.1.14
|
||||
|
||||
- Rewind waits for `updateQueue` to finish. A queue item that is already gone no longer becomes an unhandled rejection that can take down the host.
|
||||
- The fallback rewind button records this rewind’s timestamp. The 1.2s poll does not open and refill the same rewind a second time.
|
||||
- When the text being restored belongs to a turn that is still open, the fork point is the last closed turn. The previous completed turn is no longer dropped. If that turn is still running and does not close within 8 seconds, rewind still fails instead of cutting an incomplete log.
|
||||
- The bash timeout patch is now one whole-line regular expression, and values that grew extra zeros are pulled back to 10 minutes. Startup no longer appends another zero (#22, #31).
|
||||
- Patch replacement accepts regular expressions, and `$1` expands. A finished bundle-layout clean matches `persona: ""`, so the panel does not stay on pending. #39 is optional. The skipped hint now says the patch is not needed for this version, or the component is not installed.
|
||||
- Beta versions already covered by the current stable release are hidden from the version list. When the commit does not match, 「当前」follows the local version number.
|
||||
- Phase-1 no longer clears runtime context or the message allowlist. 梁神 and official plugin messages stay as they are.
|
||||
|
||||
### 1.1.13
|
||||
|
||||
- In-plugin updates rewrite `github:` and `git+https` to the GitHub `master.tar.gz` archive, so a reinstall does not need a local git (#30).
|
||||
|
||||
+16
-6
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.13</strong></p>
|
||||
<p align="center"><strong>Version 1.1.14</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件:在受控本机环境评测并加固宿主安全策略,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||
@@ -243,13 +243,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
<p align="center">
|
||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&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.14&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
|
||||
</p>
|
||||
|
||||
🔗 **原生协议链接:**
|
||||
|
||||
```
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.14&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
|
||||
```
|
||||
|
||||
**网页端(前端)触发代码示例:**
|
||||
@@ -262,7 +262,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.13',
|
||||
version: '1.1.14',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -281,7 +281,7 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML 静态链接方式:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.13&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.14&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
🚀 唤起客户端一键安装
|
||||
</a>
|
||||
```
|
||||
@@ -292,7 +292,7 @@ export function installDshPurgeToDesktop() {
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | 插件唯一标识符 |
|
||||
| name | `dsh-purge` | 插件展示名称 |
|
||||
| version | `1.1.13` | 语义化版本号 |
|
||||
| version | `1.1.14` | 语义化版本号 |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
||||
@@ -740,6 +740,16 @@ prompt-inject.md 有内容? ──是──> 原样写入 dsh-purge systemPrompt
|
||||
|
||||
## 更新记录
|
||||
|
||||
### 1.1.14
|
||||
|
||||
- 回退清队列时会等 `updateQueue` 结束。条目已经不在时不再变成未处理的拒绝,避免把宿主带崩。
|
||||
- 兜底回退按钮成功后会记下这次的时间。1.2 秒后的轮询不会把同一次回退再打开、再回填一遍。
|
||||
- 回填的是还没结束的那一句时,切点改到最后一个已闭合回合。不再多丢上一整轮。回合还在进行、8 秒内等不到结束时,仍然直接失败,不会按不完整日志去切。
|
||||
- bash 超时补丁改成整行正则,并把已经多写出来的 0 收回到 10 分钟。每次启动不再给超时再补一个 0(#22,#31)。
|
||||
- 补丁替换支持正则,`$1` 会展开。bundle 布局清洗完成后能认出 `persona: ""`,面板不再一直显示待应用。#39 改为可选。跳过说明改为「当前版本不需要或组件未安装」。
|
||||
- 正式版已经追上的测试版不再出现在版本列表里。提交号对不上时,按本机版本号标「当前」。
|
||||
- phase-1 不再清空 runtime context,也不改消息白名单。梁神和官方插件的消息照旧保留。
|
||||
|
||||
### 1.1.13
|
||||
|
||||
- 插件自己更新时,`github:` 和 `git+https` 改走 GitHub `master.tar.gz`,没装 git 也能重装(#30)。
|
||||
|
||||
@@ -153,7 +153,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"status.applied": "已应用",
|
||||
"status.pending": "待应用",
|
||||
"status.skipped": "跳过",
|
||||
"apply.hint": "待应用=原文还在。跳过=没装或官方已改写,再点也不会变。",
|
||||
"apply.hint": "待应用=原文还在。跳过=当前版本不需要或组件未安装,再点也不会变。",
|
||||
"warn.noRoot": "未定位到当前宿主的 @deepseek-ai,清洗不会生效。请完全退出后再打开本宿主,在本页点「应用」。桌面端安装目录可以是任意盘符,不要用官方 dsh 去清桌面端。",
|
||||
"warn.noRoot.desktop": "未定位到当前桌面应用里的 @deepseek-ai。请退出托盘后重新打开 DSH Desktop.exe,再在桌面端设置页点「应用」。安装目录不限盘符。",
|
||||
"warn.noInject": "提示词优先;为空则注入当前启用的规则集。两边都空会提示必须添加。Skill 不顶替提示词。",
|
||||
@@ -363,7 +363,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"status.applied": "Applied",
|
||||
"status.pending": "Pending",
|
||||
"status.skipped": "Skipped",
|
||||
"apply.hint": "Pending = original text still present. Skipped = missing or already rewritten.",
|
||||
"apply.hint": "Pending = original text still present. Skipped = not needed for this version or component not installed.",
|
||||
"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; do not use official dsh to purge Desktop.",
|
||||
"warn.noRoot.desktop": "Could not find @deepseek-ai inside this desktop app. Quit the tray, reopen DSH Desktop.exe, then Apply on the desktop Settings page. The install folder can be on any drive.",
|
||||
"warn.noInject": "The prompt box wins. If it is empty, the enabled rule set is injected. If both are empty you will be asked to add a prompt. Skills do not replace the prompt.",
|
||||
@@ -879,12 +879,12 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
|
||||
const syncPicks = (d) => {
|
||||
const versions = (d && d.versions) || [];
|
||||
const ceiling = listedCeiling(versions, d && d.localVersion);
|
||||
const next = { stable: "", beta: "" };
|
||||
for (const id of ["stable", "beta"]) {
|
||||
const list = versions.filter((item) => item.channel === id && keepListedVersion(item));
|
||||
const cur = list.find((item) => item.current);
|
||||
const latest = list.find((item) => item.latest);
|
||||
next[id] = (cur || latest || {}).ref || "";
|
||||
const list = versions.filter((item) => item.channel === id && keepListedVersion(item, ceiling));
|
||||
const hit = preferListed(list, d && d.localVersion);
|
||||
next[id] = (hit && hit.ref) || "";
|
||||
}
|
||||
setPick(next);
|
||||
};
|
||||
@@ -1251,11 +1251,12 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
const localVer = (s && s.plugin_version) || (updateInfo && updateInfo.localVersion) || "";
|
||||
const renderEdition = (id) => {
|
||||
const lane = (updateInfo && updateInfo.lanes && updateInfo.lanes[id]) || {};
|
||||
const list = versions.filter((item) => item.channel === id && keepListedVersion(item));
|
||||
const ceiling = listedCeiling(versions, localVer || (updateInfo && updateInfo.localVersion));
|
||||
const list = versions.filter((item) => item.channel === id && keepListedVersion(item, ceiling));
|
||||
const selectedRef = pick[id] || "";
|
||||
const hit = list.find((item) => item.ref === selectedRef) || list.find((item) => item.current) || list.find((item) => item.latest);
|
||||
const hit = list.find((item) => item.ref === selectedRef) || preferListed(list, localVer);
|
||||
const onLane = channelNow === id;
|
||||
const noBeta = id === "beta" && updateInfo && updateInfo.hasBeta === false && !list.length;
|
||||
const noBeta = id === "beta" && Array.isArray(updateInfo && updateInfo.versions) && !list.length;
|
||||
const pickedOther = Boolean(hit && selectedRef && !hit.current);
|
||||
const thisJob = updateJob && updateJob.id === id ? updateJob : null;
|
||||
let actionLabel = t("btn.checkUpdate");
|
||||
@@ -1293,7 +1294,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
),
|
||||
h("select", {
|
||||
className: "dshp-field dshp-ver",
|
||||
value: selectedRef || (hit && hit.ref) || "",
|
||||
value: list.length ? ((hit && hit.ref) || "") : "",
|
||||
disabled: updateBusy || !list.length,
|
||||
onChange: (e) => setPick((prev) => Object.assign({}, prev, { [id]: e.target.value })),
|
||||
"aria-label": t("update.pick"),
|
||||
@@ -1302,7 +1303,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
? list.map((item) => h("option", {
|
||||
key: item.ref + (item.sha || ""),
|
||||
value: item.ref,
|
||||
}, (item.version ? "v" + item.version : item.label) + (item.latest && !item.current ? " · " + t("update.tip") : "")))
|
||||
}, versionChoiceLabel(item, t)))
|
||||
: h("option", { value: "" }, noBeta ? t("update.noBeta") : t("update.pick")),
|
||||
),
|
||||
h(Btn, { tiny: true, kind: actionKind, disabled: actionDisabled, onClick: actionClick }, actionLabel),
|
||||
@@ -1630,8 +1631,63 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
return +parts[3] >= 12;
|
||||
}
|
||||
|
||||
function keepListedVersion(item) {
|
||||
return !/^1\.1\.11-beta/i.test(String((item && item.version) || "").replace(/^v/i, ""));
|
||||
function splitListedVersion(raw) {
|
||||
const text = String(raw || "").trim().replace(/^v/i, "");
|
||||
const cut = text.split("-");
|
||||
const core = String(cut[0] || "").split(".").map((n) => parseInt(n, 10) || 0);
|
||||
return { core: [core[0] || 0, core[1] || 0, core[2] || 0], pre: cut.slice(1).join("-") };
|
||||
}
|
||||
|
||||
function listedVersionNewer(remote, local) {
|
||||
if (!remote || !local || String(remote) === String(local)) return false;
|
||||
const a = splitListedVersion(remote);
|
||||
const b = splitListedVersion(local);
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
if (a.core[i] !== b.core[i]) return a.core[i] > b.core[i];
|
||||
}
|
||||
if (a.pre && !b.pre) return false;
|
||||
if (!a.pre && b.pre) return true;
|
||||
return a.pre > b.pre;
|
||||
}
|
||||
|
||||
function listedCeiling(versions, localVer) {
|
||||
let best = "";
|
||||
const rows = (versions || []).slice();
|
||||
const local = String(localVer || "").replace(/^v/i, "");
|
||||
if (local && !/(?:^|[-._])(beta|rc|pre|preview|test)(?:\d|$|[-._])/i.test(local)) {
|
||||
rows.push({ channel: "stable", version: local });
|
||||
}
|
||||
for (const item of rows) {
|
||||
if (!item || item.channel === "beta") continue;
|
||||
const ver = String(item.version || "").replace(/^v/i, "");
|
||||
if (!/^\d+\.\d+\.\d+/.test(ver) || /(?:^|[-._])(beta|rc|pre|preview|test)(?:\d|$|[-._])/i.test(ver)) continue;
|
||||
if (!best || listedVersionNewer(ver, best)) best = ver;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
function keepListedVersion(item, ceiling) {
|
||||
const ver = String((item && (item.version || item.ref)) || "").replace(/^v/i, "");
|
||||
if (/^1\.1\.11-beta/i.test(ver)) return false;
|
||||
if (item && item.channel === "beta" && ceiling && !listedVersionNewer(ver, ceiling)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function preferListed(list, localVer) {
|
||||
const ver = String(localVer || "").replace(/^v/i, "");
|
||||
return (list || []).find((item) => item.current)
|
||||
|| (list || []).find((item) => ver && String(item.version || "").replace(/^v/i, "") === ver)
|
||||
|| (list || []).find((item) => item.latest)
|
||||
|| (list || [])[0]
|
||||
|| null;
|
||||
}
|
||||
|
||||
function versionChoiceLabel(item, tr) {
|
||||
const ver = String((item && item.version) || "").replace(/^v/i, "");
|
||||
const base = ver ? ("v" + ver) : ((item && (item.label || item.ref)) || "—");
|
||||
if (item && item.current) return base + " · " + tr("update.current");
|
||||
if (item && item.latest) return base + " · " + tr("update.tip");
|
||||
return base;
|
||||
}
|
||||
|
||||
function SkillsSection() {
|
||||
@@ -2308,6 +2364,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
body: JSON.stringify({ sessionId, mode: "once" }),
|
||||
});
|
||||
if (data && data.ok && data.sessionId) {
|
||||
if (data.at) rewindSeenAt = data.at;
|
||||
const text = isPluginDraft(data.text) ? "" : (data.text || "");
|
||||
armComposerFill(data.sessionId, text);
|
||||
scheduleComposerFill(data.sessionId, text);
|
||||
|
||||
+61
-16
@@ -620,7 +620,7 @@ function listLiangshenCustomBashFiles(dshHome) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// phase-1 只留 persona + dsh-purge*,不全量放行以免官方身份段漏回去。
|
||||
// phase-1 只留 persona + dsh-purge*。不改 contexts、不改消息白名单,梁神和官方插件照旧。
|
||||
export function silenceLiangshenPhase1Strip(dshHome = findDshHome()) {
|
||||
const marker = "[dsh-purge] phase-1 keep persona+inject sections";
|
||||
const keepAllMarker = "[dsh-purge] phase-1 keep full system-prompt sections";
|
||||
@@ -689,11 +689,32 @@ export function silenceLiangshenPhase1Strip(dshHome = findDshHome()) {
|
||||
" // " + marker + "\n",
|
||||
);
|
||||
|
||||
const contextMarker = "[dsh-purge] phase-1 keep runtime context";
|
||||
const keptContexts = " // " + contextMarker + "\n";
|
||||
if (next.includes(keptContexts)) {
|
||||
next = next.replace(keptContexts, " contexts: [],\n");
|
||||
}
|
||||
const allowNew =
|
||||
"function isAllowedMessage(message, allowedSources) {\n" +
|
||||
" const kind = message.source?.kind\n" +
|
||||
" // " + contextMarker + "\n" +
|
||||
' if (message?.source?.plugin === "@deepseek-ai/dsh-system-prompt") return true\n' +
|
||||
" return kind !== undefined && allowedSources.has(kind)\n" +
|
||||
"}";
|
||||
const allowOld =
|
||||
"function isAllowedMessage(message, allowedSources) {\n" +
|
||||
" const kind = message.source?.kind\n" +
|
||||
" return kind !== undefined && allowedSources.has(kind)\n" +
|
||||
"}";
|
||||
if (next.includes(allowNew)) next = next.replace(allowNew, allowOld);
|
||||
|
||||
const already =
|
||||
next.includes(marker) &&
|
||||
!next.includes(keepAllMarker) &&
|
||||
next.includes('startsWith("dsh-purge")') &&
|
||||
!next.includes(unfiltered);
|
||||
!next.includes(unfiltered) &&
|
||||
!next.includes(contextMarker) &&
|
||||
!next.includes('plugin === "@deepseek-ai/dsh-system-prompt"');
|
||||
if (already && next === text.replace(/\r\n/g, "\n")) {
|
||||
hit = "already";
|
||||
continue;
|
||||
@@ -1744,6 +1765,11 @@ const PATCHES = [
|
||||
'personaPrefix: ""',
|
||||
'prefix: ""',
|
||||
'text: ""',
|
||||
// bundle 布局 (0.1.5):web-app / headless 的 persona 是 `persona:` 键,
|
||||
// 上面三条都命中不了,会让已完成的清洗在 UI 上报待应用。见下方 markersAny。
|
||||
'persona: ""',
|
||||
// 1.3.x cordis preset:身份段删除后留下的 purge 注记同样是完成态。
|
||||
'[dsh-purge] identity stripped',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -2237,21 +2263,16 @@ const NEW_TOOL_PATCHES = [
|
||||
rel: ["cordis.patch.yml"],
|
||||
replacements: [
|
||||
{
|
||||
pattern:
|
||||
' - id: bash-sandbox\n' +
|
||||
" name: '@deepseek-ai/dsh-bash-sandbox'\n" +
|
||||
" disabled: !!js process.platform === 'win32'\n" +
|
||||
' config:\n' +
|
||||
' timeoutMs: 60000',
|
||||
replace:
|
||||
' - id: bash-sandbox\n' +
|
||||
" name: '@deepseek-ai/dsh-bash-sandbox'\n" +
|
||||
" disabled: !!js process.platform === 'win32'\n" +
|
||||
' config:\n' +
|
||||
' timeoutMs: 600000',
|
||||
// 幂等性:原 pattern 以 `timeoutMs: 60000` 结尾,替换产物 `600000` 仍然
|
||||
// 包含它,于是每次 autoApplyOnStart 都会再拼一个 0(实测已涨到
|
||||
// 600000000000000)。
|
||||
// 现在的做法:锚在 bash-sandbox 行内,`[^\n]*` 必须吃到行尾 —— 这样上一次
|
||||
// 追加的注记会被整体重写而不是再叠一层,数值也不再有可再匹配的"前缀"。
|
||||
pattern: /(name: '@deepseek-ai\/dsh-bash-sandbox'[\s\S]*?\n {8}timeoutMs: )6[0-9]+[^\n]*/g,
|
||||
replace: "$1600000 // [dsh-purge] bash timeout raised",
|
||||
},
|
||||
],
|
||||
markers: ["timeoutMs: 600000"],
|
||||
markers: ["timeoutMs: 600000 // [dsh-purge] bash timeout raised"],
|
||||
},
|
||||
{
|
||||
id: 23, name: "READ_CAPS_RAISED", layer: "代码", layer_en: "Code",
|
||||
@@ -2439,6 +2460,9 @@ const NEW_TOOL_PATCHES = [
|
||||
markers: [
|
||||
"[dsh-purge] identity stripped",
|
||||
'prefix: ""',
|
||||
// bundle 布局:web-app / headless 的官方 persona 挂在 `persona:` 键上,
|
||||
// 清掉后是 `persona: ""` —— 既无 purge 注记也无 prefix 键。
|
||||
'persona: ""',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -2956,6 +2980,7 @@ const NEW_TOOL_PATCHES = [
|
||||
id: 39, name: "PERSONA_TEXT_PREFIX_ALIAS", layer: "代码", layer_en: "Code",
|
||||
desc: "dsh-persona:兼容 0.1.2 text 字段,否则梁神会话起不来 / accept legacy text as prefix",
|
||||
file: "persona",
|
||||
optional: true, // 仅旧版 0.1.2 persona 使用;新版 prefix 结构无需改写
|
||||
replacements: [
|
||||
{
|
||||
pattern:
|
||||
@@ -3591,6 +3616,15 @@ function patchApplied(text, patch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function matchesPattern(hay, pattern) {
|
||||
if (pattern instanceof RegExp) {
|
||||
const re = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags);
|
||||
re.lastIndex = 0;
|
||||
return re.test(hay);
|
||||
}
|
||||
return hay.includes(asLf(pattern));
|
||||
}
|
||||
|
||||
function patchHasRemainingWork(text, patch, fp = "") {
|
||||
const hay = asLf(text);
|
||||
const yaml = isYamlPath(fp);
|
||||
@@ -3598,7 +3632,7 @@ function patchHasRemainingWork(text, patch, fp = "") {
|
||||
if (!pattern || typeof replace !== "string") continue;
|
||||
// 与 apply 一致:YAML 里无缩进 identity 不能 replaceAll,不算待做。
|
||||
if (yaml && isBareIdentityNeedle(pattern)) continue;
|
||||
if (hay.includes(asLf(pattern))) return true;
|
||||
if (matchesPattern(hay, pattern)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -3658,6 +3692,17 @@ function applyReplacementsToText(text, patch, fp = "") {
|
||||
if (!pattern || typeof replace !== "string") continue;
|
||||
// YAML 块标量行首有缩进;无缩进 identity+\n\n 会留下 6 空格,再和下一段拼成 12 空格。
|
||||
if (yaml && isBareIdentityNeedle(pattern)) continue;
|
||||
// 正则 pattern:用于自匹配型替换(产物包含原 pattern,如 timeoutMs 追加 0)。
|
||||
if (pattern instanceof RegExp) {
|
||||
const re = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + "g");
|
||||
if (!re.test(out)) continue;
|
||||
// 用字符串形态调用:保留 $1..$9 展开语义(回调形态会把 "$1" 当字面量写进文件)。
|
||||
const next = out.replace(re, asLf(replace));
|
||||
if (next === out) continue;
|
||||
out = next;
|
||||
changed = true;
|
||||
continue;
|
||||
}
|
||||
const needle = asLf(pattern);
|
||||
if (!out.includes(needle)) continue;
|
||||
out = out.split(needle).join(asLf(replace));
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ function installIdentityOverride(ctx, config = {}) {
|
||||
context,
|
||||
});
|
||||
};
|
||||
// 只挂一次:挂多次会让同一轮 assemble 折两遍,UI 也会显示两次注入。
|
||||
// 只挂一次。不改 contexts,不改 pre-step 白名单,梁神 phase-1 和其它插件的消息原样保留。
|
||||
ctx.on("system-prompt/assemble", hook, { global: true, prepend: true });
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -6,6 +6,10 @@ function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function ignoreSettled(value) {
|
||||
Promise.resolve(value).catch(() => {});
|
||||
}
|
||||
|
||||
function errorText(err) {
|
||||
if (!err) return "回退失败";
|
||||
if (typeof err === "string") return err;
|
||||
@@ -149,11 +153,16 @@ export function planRewind(events) {
|
||||
return { ok: false, error: "没有可回退的上一句" };
|
||||
}
|
||||
const text = userTextFromEvent(lastUser);
|
||||
if (turnEnds.length >= 2) {
|
||||
const open = lastOpenTurn(list);
|
||||
const fromOpenTurn = Boolean(open && lastUser.seq >= open.seq);
|
||||
// 开放回合的那句还没进历史,切在最后一个已闭合 turn/end。
|
||||
// 已闭合的上一句要整轮拿掉,所以再往前一个 end。
|
||||
const cutIndex = fromOpenTurn ? turnEnds.length - 1 : turnEnds.length - 2;
|
||||
if (cutIndex >= 0) {
|
||||
return {
|
||||
ok: true,
|
||||
mode: "fork",
|
||||
atSeq: turnEnds[turnEnds.length - 2].seq,
|
||||
atSeq: turnEnds[cutIndex].seq,
|
||||
text,
|
||||
};
|
||||
}
|
||||
@@ -301,7 +310,7 @@ async function disarmRewoundSession(ctx, sessionId) {
|
||||
const disarmOnce = async () => {
|
||||
const agent = getAgent(ctx, sessionId);
|
||||
try { agent?.inbox?.clear?.(); } catch { /* ignore */ }
|
||||
try { agent?.cancel?.({ kind: "user" }, { keepInbox: false }); } catch { /* ignore */ }
|
||||
try { ignoreSettled(agent?.cancel?.({ kind: "user" }, { keepInbox: false })); } catch { /* ignore */ }
|
||||
|
||||
const ids = [];
|
||||
try {
|
||||
@@ -319,7 +328,7 @@ async function disarmRewoundSession(ctx, sessionId) {
|
||||
if (!id || seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
try {
|
||||
controller?.updateQueue?.({
|
||||
await controller?.updateQueue?.({
|
||||
sessionId,
|
||||
itemId: id,
|
||||
action: { kind: "remove" },
|
||||
@@ -329,7 +338,7 @@ async function disarmRewoundSession(ctx, sessionId) {
|
||||
|
||||
try { agent?.inbox?.clear?.(); } catch { /* ignore */ }
|
||||
if (agent?.status === "running") {
|
||||
try { agent.cancel({ kind: "user" }, { keepInbox: false }); } catch { /* ignore */ }
|
||||
try { ignoreSettled(agent.cancel({ kind: "user" }, { keepInbox: false })); } catch { /* ignore */ }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -380,7 +389,7 @@ async function resolveMainSession(ctx, sessionId) {
|
||||
async function rewindOneSession(ctx, controller, sessionId) {
|
||||
let log = await readSessionLog(ctx, sessionId);
|
||||
if (lastOpenTurn(log.events)) {
|
||||
try { controller.cancel?.({ sessionId }); } catch { /* ignore */ }
|
||||
try { ignoreSettled(controller.cancel?.({ sessionId })); } catch { /* ignore */ }
|
||||
log = await waitTurnClosed(ctx, sessionId);
|
||||
}
|
||||
const plan = planRewind(log.events);
|
||||
@@ -438,7 +447,7 @@ export async function applyRewind(ctx, sessionId, mode) {
|
||||
if (action === "round") {
|
||||
const target = await resolveMainSession(ctx, sessionId);
|
||||
if (sessionId !== target.sessionId) {
|
||||
try { controller.cancel?.({ sessionId }); } catch { /* ignore */ }
|
||||
try { ignoreSettled(controller.cancel?.({ sessionId })); } catch { /* ignore */ }
|
||||
}
|
||||
const result = await rewindOneSession(ctx, controller, target.sessionId);
|
||||
if (!result.ok) return result;
|
||||
|
||||
+82
-19
@@ -96,6 +96,29 @@ export function versionIsNewer(remote, local) {
|
||||
return a.pre > b.pre;
|
||||
}
|
||||
|
||||
export function latestStableVersion(versions) {
|
||||
let best = "";
|
||||
for (const item of versions || []) {
|
||||
if (!item || item.channel === "beta") continue;
|
||||
const ver = String(item.version || "").replace(/^v/i, "");
|
||||
if (!/^\d+\.\d+\.\d+/.test(ver) || isBetaName(ver)) continue;
|
||||
if (!best || versionIsNewer(ver, best)) best = ver;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/** 正式版已经追上的测试版不再列出。1.1.11-beta 始终下线。 */
|
||||
export function hideListedVersion(item, stableVersion = "") {
|
||||
if (!item || withdrawnVersion(item)) return true;
|
||||
const beta = item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id);
|
||||
if (!beta) return false;
|
||||
const ceiling = String(stableVersion || "").replace(/^v/i, "");
|
||||
if (!ceiling || isBetaName(ceiling)) return false;
|
||||
const ver = String(item.version || item.ref || item.id || "").replace(/^v/i, "");
|
||||
if (!/^\d+\.\d+/.test(ver)) return false;
|
||||
return !versionIsNewer(ver, ceiling);
|
||||
}
|
||||
|
||||
export function readChannelState() {
|
||||
const raw = readJson(channelStatePath()) || {};
|
||||
return {
|
||||
@@ -490,17 +513,29 @@ export function safeUpdateRef(ref) {
|
||||
|
||||
export function markCurrent(versions, state, localVer, localSha) {
|
||||
const pin = String(state?.pin || "");
|
||||
return (versions || []).map((item) => {
|
||||
const rows = versions || [];
|
||||
const ver = String(localVer || "").replace(/^v/i, "");
|
||||
const shaMatched = rows.some((item) => localSha && item.sha && sameRev(localSha, item.sha));
|
||||
const versionOnLatest = rows.some((item) => (
|
||||
item.latest
|
||||
&& item.channel === state?.channel
|
||||
&& String(item.version || "").replace(/^v/i, "") === ver
|
||||
));
|
||||
const versionFallback = versionOnLatest ? null : rows.find((item) => (
|
||||
item.channel === state?.channel
|
||||
&& String(item.version || "").replace(/^v/i, "") === ver
|
||||
));
|
||||
return rows.map((item) => {
|
||||
const shaHit = Boolean(localSha && item.sha && sameRev(localSha, item.sha));
|
||||
const pinHit = Boolean(pin && item.ref === pin);
|
||||
// 没有本地提交号时,只把本通道「最新」标成当前。同版本号的旧标签不能再标。
|
||||
// 提交号对不上时,只把本通道里和本机版本号相同的那一条标成当前。
|
||||
const headHit = Boolean(
|
||||
!pin
|
||||
&& !localSha
|
||||
&& item.latest
|
||||
&& item.channel === state?.channel
|
||||
&& item.version
|
||||
&& item.version === localVer
|
||||
&& !shaMatched
|
||||
&& ver
|
||||
&& (versionOnLatest
|
||||
? item.latest && item.channel === state?.channel && String(item.version || "").replace(/^v/i, "") === ver
|
||||
: versionFallback && item === versionFallback)
|
||||
);
|
||||
return {
|
||||
...item,
|
||||
@@ -534,6 +569,25 @@ async function listGithubTags() {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureRunningVersion(versions, state, localVer, localSha) {
|
||||
const ver = String(localVer || "").replace(/^v/i, "");
|
||||
if (!ver || isBetaName(ver) || state?.channel === "beta") return versions;
|
||||
if ((versions || []).some((item) => item.channel === "stable" && String(item.version || "").replace(/^v/i, "") === ver)) {
|
||||
return versions;
|
||||
}
|
||||
const ref = (versions || []).some((item) => item.ref === "master") ? `local-${ver}` : "master";
|
||||
return [{
|
||||
id: ref,
|
||||
ref,
|
||||
sha: localSha || "",
|
||||
version: ver,
|
||||
channel: "stable",
|
||||
label: versionLabel(ver, "stable", localSha),
|
||||
kind: "local",
|
||||
latest: !(versions || []).some((item) => item.channel === "stable" && item.latest),
|
||||
}, ...(versions || [])];
|
||||
}
|
||||
|
||||
async function listRemoteVersions() {
|
||||
const state = readChannelState();
|
||||
const seen = new Set();
|
||||
@@ -589,11 +643,18 @@ async function listRemoteVersions() {
|
||||
|
||||
const localVer = localVersion();
|
||||
const localSha = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || readStamp();
|
||||
const withLocal = ensureRunningVersion(out, state, localVer, localSha);
|
||||
const ceiling = latestStableVersion([
|
||||
...withLocal,
|
||||
localVer && !isBetaName(localVer) ? { channel: "stable", version: localVer } : null,
|
||||
].filter(Boolean));
|
||||
const visible = withLocal.filter((item) => !hideListedVersion(item, ceiling));
|
||||
const betaOpen = visible.some((item) => item.channel === "beta");
|
||||
return {
|
||||
versions: markCurrent(out.filter((item) => !withdrawnVersion(item)), state, localVer, localSha),
|
||||
hasBeta: Boolean(betaSha || out.some((item) => item.channel === "beta" && item.kind === "tag")),
|
||||
versions: markCurrent(visible, state, localVer, localSha),
|
||||
hasBeta: betaOpen,
|
||||
stableSha,
|
||||
betaSha,
|
||||
betaSha: betaOpen ? betaSha : "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -891,21 +952,23 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) {
|
||||
export async function switchChannel(channel, { apply = true } = {}) {
|
||||
const next = normalizeChannel(channel);
|
||||
if (next === "beta") {
|
||||
const betaSha = await remoteHeadSha(BETA_REF);
|
||||
const tags = await listGithubTags();
|
||||
const hasBeta = Boolean(betaSha || tags.some((item) => item.channel === "beta"));
|
||||
if (!hasBeta) {
|
||||
const listed = await listRemoteVersions();
|
||||
if (!listed.hasBeta) {
|
||||
const state = readChannelState();
|
||||
const localVer = localVersion();
|
||||
const localRev = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || readStamp();
|
||||
return rememberUpdate({
|
||||
ok: false,
|
||||
error: "还没有测试版",
|
||||
hasBeta: false,
|
||||
...channelPublic(),
|
||||
versions: [],
|
||||
lanes: { stable: { id: "stable", hasRemote: true }, beta: { id: "beta", hasRemote: false } },
|
||||
localVersion: localVer,
|
||||
versions: listed.versions,
|
||||
lanes: lanesOf(listed, state, localVer, localRev),
|
||||
...channelPublic(state),
|
||||
});
|
||||
}
|
||||
if (!betaSha && apply) {
|
||||
const tag = tags.find((item) => item.channel === "beta");
|
||||
if (!listed.betaSha && apply) {
|
||||
const tag = listed.versions.find((item) => item.channel === "beta" && item.kind === "tag");
|
||||
if (tag) return applyUpdate(planUpdates(), { ref: tag.ref, channel: "beta", pin: false, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.13",
|
||||
"version": "1.1.14",
|
||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
@@ -29,7 +29,8 @@
|
||||
"scripts": {
|
||||
"embed-prompt": "node scripts/embed-default-prompt.mjs",
|
||||
"test:identity": "node scripts/test-identity-assembly.mjs",
|
||||
"test:update": "node scripts/test-update-guards.mjs"
|
||||
"test:update": "node scripts/test-update-guards.mjs",
|
||||
"test:rewind": "node scripts/test-rewind-plan.mjs"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { planRewind } from "../lib/rewind.js";
|
||||
|
||||
function user(seq, text) {
|
||||
return { seq, type: "user/message", data: { source: { kind: "user" }, content: text } };
|
||||
}
|
||||
function start(seq) {
|
||||
return { seq, type: "turn/start" };
|
||||
}
|
||||
function end(seq) {
|
||||
return { seq, type: "turn/end" };
|
||||
}
|
||||
|
||||
const closed = planRewind([
|
||||
start(1), user(2, "Q1"), end(3),
|
||||
start(4), user(5, "Q2"), end(6),
|
||||
]);
|
||||
assert.equal(closed.mode, "fork");
|
||||
assert.equal(closed.atSeq, 3);
|
||||
assert.equal(closed.text, "Q2");
|
||||
|
||||
const open = planRewind([
|
||||
start(1), user(2, "Q1"), end(3),
|
||||
start(4), user(5, "Q2"), end(6),
|
||||
start(7), user(8, "Q3"),
|
||||
]);
|
||||
assert.equal(open.mode, "fork");
|
||||
assert.equal(open.atSeq, 6);
|
||||
assert.equal(open.text, "Q3");
|
||||
|
||||
const openWithoutQuestion = planRewind([
|
||||
start(1), user(2, "Q1"), end(3),
|
||||
start(4), user(5, "Q2"), end(6),
|
||||
start(7),
|
||||
]);
|
||||
assert.equal(openWithoutQuestion.mode, "fork");
|
||||
assert.equal(openWithoutQuestion.atSeq, 3);
|
||||
assert.equal(openWithoutQuestion.text, "Q2");
|
||||
|
||||
const oneThenOpen = planRewind([
|
||||
start(1), user(2, "Q1"), end(3),
|
||||
start(4), user(5, "Q2"),
|
||||
]);
|
||||
assert.equal(oneThenOpen.mode, "fork");
|
||||
assert.equal(oneThenOpen.atSeq, 3);
|
||||
assert.equal(oneThenOpen.text, "Q2");
|
||||
|
||||
const onlyOne = planRewind([
|
||||
start(1), user(2, "Q1"), end(3),
|
||||
]);
|
||||
assert.equal(onlyOne.mode, "blank");
|
||||
assert.equal(onlyOne.text, "Q1");
|
||||
|
||||
console.log("ok: rewind plan");
|
||||
@@ -1,5 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { markCurrent, pluginAddSpec, safeUpdateRef } from "../lib/update.js";
|
||||
import { hideListedVersion, latestStableVersion, markCurrent, pluginAddSpec, safeUpdateRef } from "../lib/update.js";
|
||||
|
||||
assert.equal(safeUpdateRef("master"), "master");
|
||||
assert.equal(safeUpdateRef("beta"), "beta");
|
||||
@@ -31,4 +31,26 @@ const onTag = markCurrent(versions, { channel: "stable", pin: "v1.1.11" }, "1.1.
|
||||
assert.equal(onTag.find((item) => item.ref === "v1.1.11").current, true);
|
||||
assert.equal(onTag.find((item) => item.ref === "master").current, false);
|
||||
|
||||
const caughtUp = [
|
||||
{ ref: "master", version: "1.1.12", channel: "stable", latest: true },
|
||||
{ ref: "v1.1.12", version: "1.1.12", channel: "stable" },
|
||||
{ ref: "v1.1.12-beta.1", version: "1.1.12-beta.1", channel: "beta" },
|
||||
{ ref: "beta", version: "1.1.12-beta.1", channel: "beta", latest: true },
|
||||
{ ref: "v1.1.13-beta.1", version: "1.1.13-beta.1", channel: "beta" },
|
||||
];
|
||||
const ceiling = latestStableVersion(caughtUp);
|
||||
assert.equal(ceiling, "1.1.12");
|
||||
assert.equal(hideListedVersion(caughtUp[2], ceiling), true);
|
||||
assert.equal(hideListedVersion(caughtUp[3], ceiling), true);
|
||||
assert.equal(hideListedVersion(caughtUp[4], ceiling), false);
|
||||
assert.equal(hideListedVersion({ ref: "v1.1.11-beta.1", version: "1.1.11-beta.1", channel: "beta" }, ""), true);
|
||||
|
||||
const visible = caughtUp.filter((item) => !hideListedVersion(item, ceiling));
|
||||
assert.deepEqual(visible.map((item) => item.ref), ["master", "v1.1.12", "v1.1.13-beta.1"]);
|
||||
const staleSha = "423a91614baa747b56749003d054fedb8e725714";
|
||||
const shown = markCurrent(visible, { channel: "stable", pin: "" }, "1.1.12", staleSha);
|
||||
assert.equal(shown.find((item) => item.ref === "master").current, true);
|
||||
assert.equal(shown.find((item) => item.ref === "v1.1.12").current, false);
|
||||
assert.equal(shown.find((item) => item.ref === "v1.1.13-beta.1").current, false);
|
||||
|
||||
console.log("ok: update guards");
|
||||
Reference in new issue
Block a user