mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 04:50:22 +08:00
feat: 发布 1.1.9,将提示词从仓库中下线
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
443f23136c
commit
f16ba86ad1
11 files changed
+320
-46
No files matched your search
@@ -1,36 +1,33 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { sealSlot } from "../lib/table-key.js";
|
||||
|
||||
const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const src = path.join(root, "lib", "default-prompt-inject.md");
|
||||
const dest = path.join(root, "lib", "default-prompt-data.js");
|
||||
const dest = path.join(root, "lib", "asset-table.js");
|
||||
|
||||
if (!fs.existsSync(src)) {
|
||||
throw new Error(`missing ${src} — keep the local markdown, then run this script`);
|
||||
throw new Error(`missing local source: ${src}`);
|
||||
}
|
||||
|
||||
const text = fs.readFileSync(src, "utf8");
|
||||
if (!text.trim()) {
|
||||
throw new Error("default-prompt-inject.md is empty");
|
||||
}
|
||||
if (!text.trim()) throw new Error("local source is empty");
|
||||
|
||||
const normalized = text.replace(/\r\n/g, "\n").trim();
|
||||
const hash = createHash("sha256").update(normalized, "utf8").digest("hex");
|
||||
const b64 = Buffer.from(text, "utf8").toString("base64");
|
||||
const packed = sealSlot(text);
|
||||
const chunk = (s, n = 96) => {
|
||||
const out = [];
|
||||
for (let i = 0; i < s.length; i += n) out.push(s.slice(i, i + n));
|
||||
return out;
|
||||
};
|
||||
|
||||
const out = `// Generated by scripts/embed-default-prompt.mjs. Do not edit.
|
||||
// Local source lib/default-prompt-inject.md is gitignored and not published.
|
||||
const out = `const SLOT_ROWS = ${JSON.stringify(chunk(packed.SLOT), null, 2)};
|
||||
|
||||
export const DEFAULT_PROMPT_INJECT_SHA256 = ${JSON.stringify(hash)};
|
||||
|
||||
const DEFAULT_PROMPT_INJECT_B64 = ${JSON.stringify(b64)};
|
||||
|
||||
export function defaultPromptInjectText() {
|
||||
return Buffer.from(DEFAULT_PROMPT_INJECT_B64, "base64").toString("utf8");
|
||||
}
|
||||
export const SLOT = SLOT_ROWS.join("");
|
||||
export const MASK = ${JSON.stringify(packed.MASK)};
|
||||
export const TAG = ${JSON.stringify(packed.TAG)};
|
||||
export const IV = ${JSON.stringify(packed.IV)};
|
||||
`;
|
||||
|
||||
fs.writeFileSync(dest, out, "utf8");
|
||||
process.stdout.write(`wrote ${path.relative(root, dest)} sha256=${hash} bytes=${text.length}\n`);
|
||||
process.stdout.write(`wrote ${path.relative(root, dest)} bytes=${text.length}\n`);
|
||||
Reference in new issue
Block a user