mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 06:40:22 +08:00
fix: 检测更新按提交号读版本,避免 jsDelivr 缓存显示成 1.1.2
This commit is contained in:
1 parent
238b39b8ff
commit
f11078eb1f
4 files changed
+44
-17
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">dsh-purge</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.3</strong></p>
|
||||
<p align="center"><strong>Version 1.1.4</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness jailbreak (破甲): every model can jailbreak; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
||||
@@ -537,6 +537,10 @@ If nothing is found, set `DSH_BASE`. No files are changed.
|
||||
|
||||
## Changelog
|
||||
|
||||
### 1.1.4
|
||||
|
||||
- Update check reads `package.json` at the GitHub commit SHA, instead of the stale jsDelivr `@master` cache or falling back to the local version.
|
||||
|
||||
### 1.1.3
|
||||
|
||||
- Prompt inject once on the first turn; later turns pin the committed system prompt instead of appending a second copy.
|
||||
|
||||
+5
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">dsh-purge</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.3</strong></p>
|
||||
<p align="center"><strong>Version 1.1.4</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||
@@ -541,6 +541,10 @@ npm 嵌套布局下,审批在 `dsh-user-approval/lib/index.js`,升级逻辑
|
||||
|
||||
## 更新记录
|
||||
|
||||
### 1.1.4
|
||||
|
||||
- 检测更新按 GitHub 提交号读 `package.json`,不再误用 jsDelivr `@master` 缓存,也不会在读不到远端版本时显示成「有新版本 1.1.2,当前 1.1.2」。
|
||||
|
||||
### 1.1.3
|
||||
|
||||
- 系统提示词只在每个会话第一轮注入一份;后续轮次钉住已提交的系统提示词,不再追加第二份。
|
||||
|
||||
+33
-14
@@ -251,7 +251,7 @@ function isAbortError(e) {
|
||||
return (e && (e.name === "AbortError" || e.name === "TimeoutError")) || /aborted|abort/i.test(msg);
|
||||
}
|
||||
|
||||
async function fetchRes(url, ms = 20000) {
|
||||
async function fetchRes(url, ms = 20000, headers = {}) {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => {
|
||||
try {
|
||||
@@ -262,8 +262,9 @@ async function fetchRes(url, ms = 20000) {
|
||||
}, ms);
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
headers: { "user-agent": "dsh-purge-update", accept: "*/*" },
|
||||
headers: { "user-agent": "dsh-purge-update", accept: "*/*", ...headers },
|
||||
redirect: "follow",
|
||||
cache: "no-store",
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
if (!res.ok) throw new Error(`http ${res.status}`);
|
||||
@@ -276,23 +277,40 @@ async function fetchRes(url, ms = 20000) {
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchText(url, ms = 20000) {
|
||||
return (await fetchRes(url, ms)).text();
|
||||
async function fetchText(url, ms = 20000, headers = {}) {
|
||||
return (await fetchRes(url, ms, headers)).text();
|
||||
}
|
||||
|
||||
async function fetchJson(url) {
|
||||
return JSON.parse(await fetchText(url));
|
||||
async function fetchJson(url, ms = 20000, headers = {}) {
|
||||
return JSON.parse(await fetchText(url, ms, headers));
|
||||
}
|
||||
|
||||
async function remotePackageVersion() {
|
||||
function versionFromPackageText(text) {
|
||||
const pkg = JSON.parse(text);
|
||||
return pkg && pkg.version ? String(pkg.version) : "";
|
||||
}
|
||||
|
||||
async function remotePackageVersion(sha = "") {
|
||||
const ref = sha || BRANCH;
|
||||
const urls = [
|
||||
`https://raw.githubusercontent.com/${REPO}/${BRANCH}/package.json`,
|
||||
`https://cdn.jsdelivr.net/gh/${REPO}@${BRANCH}/package.json`,
|
||||
];
|
||||
sha ? `https://cdn.jsdelivr.net/gh/${REPO}@${sha}/package.json` : "",
|
||||
`https://raw.githubusercontent.com/${REPO}/${ref}/package.json`,
|
||||
`https://cdn.jsdelivr.net/gh/${REPO}@${ref}/package.json`,
|
||||
`https://api.github.com/repos/${REPO}/contents/package.json?ref=${encodeURIComponent(ref)}`,
|
||||
].filter(Boolean);
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const pkg = await fetchJson(url);
|
||||
if (pkg && pkg.version) return String(pkg.version);
|
||||
if (url.includes("api.github.com/repos/")) {
|
||||
const data = await fetchJson(url, 20000, { accept: "application/vnd.github.raw" });
|
||||
if (typeof data === "string") return versionFromPackageText(data);
|
||||
if (data && data.version) return String(data.version);
|
||||
if (data && data.content && data.encoding === "base64") {
|
||||
return versionFromPackageText(Buffer.from(data.content.replace(/\s/g, ""), "base64").toString("utf8"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const ver = versionFromPackageText(await fetchText(url));
|
||||
if (ver) return ver;
|
||||
} catch {
|
||||
// 换下一个源。
|
||||
}
|
||||
@@ -316,7 +334,8 @@ async function remoteHeadSha() {
|
||||
|
||||
export async function checkUpdate() {
|
||||
const localVer = localVersion();
|
||||
const [remoteSha, remoteVer] = await Promise.all([remoteHeadSha(), remotePackageVersion()]);
|
||||
const remoteSha = await remoteHeadSha();
|
||||
const remoteVer = await remotePackageVersion(remoteSha);
|
||||
if (!remoteSha && !remoteVer) throw new Error("无法读取 GitHub master");
|
||||
const gitSha = gitOk() ? gitHead(PLUGIN_ROOT) : "";
|
||||
const stamp = readStamp();
|
||||
@@ -334,7 +353,7 @@ export async function checkUpdate() {
|
||||
ok: true,
|
||||
hasUpdate,
|
||||
localVersion: localVer,
|
||||
remoteVersion: remoteVer || localVer,
|
||||
remoteVersion: remoteVer || (remoteSha ? remoteSha.slice(0, 7) : ""),
|
||||
localSha: localRev ? localRev.slice(0, 7) : "",
|
||||
remoteSha: remoteSha ? remoteSha.slice(0, 7) : "",
|
||||
via: detectVia(),
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"description": "DeepSeek Harness 破甲:所有模型都可破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model. 求 Star ⭐",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
Reference in new issue
Block a user