mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 09:00:22 +08:00
fix: 发布 1.1.65,截图报告与默认提示词
接入上游截图登记和六段报告,默认提示词按当前文稿重新加密。缺外部工具或密钥时技能仍可加载。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ed676bcb11
commit
2bf8bfb618
20 files changed
+1616
-753
No files matched your search
+48
-2
@@ -6568,8 +6568,6 @@ export function defaultOverrideHash() {
|
||||
return hashOverride(defaultOverrideText());
|
||||
}
|
||||
|
||||
export const OVERRIDE_TEXT = defaultOverrideText();
|
||||
|
||||
export function overrideStatePath(dshHome) {
|
||||
return path.join(dshHome, "dsh-purge", "override-state.json");
|
||||
}
|
||||
@@ -6665,6 +6663,54 @@ export async function readOverrideForUi(dshHome) {
|
||||
};
|
||||
}
|
||||
|
||||
function writeOverrideStateSync(dshHome, state) {
|
||||
const fp = overrideStatePath(dshHome);
|
||||
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||
fs.writeFileSync(fp, `${JSON.stringify(state, null, 2)}\n`, "utf8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装/对话读的是磁盘 prompt-inject.md;设置框里的预览来自加密槽,点保存才 POST。
|
||||
* 缺文件或仍是插件落盘的旧默认时,静默同步当前槽到磁盘,避免「界面看着对、聊天却用旧稿/空稿」。
|
||||
*/
|
||||
export function syncPromptInjectOnDiskSync(dshHome) {
|
||||
const home = path.normalize(String(dshHome || findDshHome() || ""));
|
||||
if (!home) return { action: "skip", reason: "no_home" };
|
||||
const bundled = defaultOverrideText();
|
||||
const bundledNorm = normalizeOverride(bundled);
|
||||
if (!bundledNorm) return { action: "skip", reason: "empty_slot" };
|
||||
const fp = findOverrideFile(home);
|
||||
const diskRaw = readPromptInjectFileSync(home);
|
||||
const diskNorm = normalizeOverride(diskRaw);
|
||||
const state = readOverrideStateSync(home);
|
||||
if (
|
||||
diskNorm
|
||||
&& hashOverride(diskNorm) !== defaultOverrideHash()
|
||||
&& !overrideTextIsOurs(state, diskRaw)
|
||||
) {
|
||||
return { action: "keep", reason: "user_custom" };
|
||||
}
|
||||
if (state.customized === true && diskNorm && hashOverride(diskNorm) !== defaultOverrideHash()) {
|
||||
return { action: "keep", reason: "user_flag" };
|
||||
}
|
||||
if (diskNorm === bundledNorm) {
|
||||
return { action: "keep", reason: "current" };
|
||||
}
|
||||
try {
|
||||
fs.mkdirSync(home, { recursive: true });
|
||||
fs.writeFileSync(fp, bundled, "utf8");
|
||||
writeOverrideStateSync(home, {
|
||||
customized: false,
|
||||
hash: hashOverride(bundled),
|
||||
seedHash: defaultOverrideHash(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
});
|
||||
} catch (error) {
|
||||
return { action: "error", reason: String(error && error.message ? error.message : error) };
|
||||
}
|
||||
return { action: "wrote", reason: diskNorm ? "refresh_default" : "seed_default" };
|
||||
}
|
||||
|
||||
/**
|
||||
* 解包/应用成功后:把加密槽写入 $DSH_HOME/prompt-inject.md(用户自改时不覆盖)。
|
||||
* force 仅用于显式「恢复默认」。
|
||||
|
||||
Reference in new issue
Block a user