mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 10:50:22 +08:00
fix: 发布 1.1.58,打开即挂上默认提示词
重启或重新打开后不用再点保存。磁盘正文优先,其次规则集,再没有就用内置默认。应用成功仍先询问是否重启。前端模块只在页面发出前改写,避免输入框消失。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
71defcc3da
commit
c032942e5f
8 files changed
+158
-37
No files matched your search
+32
-5
@@ -176,9 +176,13 @@ function injectAllowedNow(config) {
|
||||
return config.enabled !== false;
|
||||
}
|
||||
|
||||
/** 有默认提示词用默认,没有才用当前规则集。两边都空则段上不挂正文。 */
|
||||
/** 有磁盘提示词用磁盘,没有才用规则集,再没有就用内置默认。打开就能挂上。 */
|
||||
function refreshHungOperator(dshHome = core.findDshHome()) {
|
||||
const resolved = rules.resolveInjectText(dshHome);
|
||||
const home = dshHome || core.findDshHome();
|
||||
if (home) {
|
||||
try { core.seedOverrideSync(home); } catch { /* 默认写不进去时,组装仍会用内存里的内置正文 */ }
|
||||
}
|
||||
const resolved = rules.resolveInjectText(home);
|
||||
core.hangOperatorPrompt(resolved.text);
|
||||
return resolved;
|
||||
}
|
||||
@@ -192,7 +196,7 @@ function injectSnapshot(dshHome = core.findDshHome()) {
|
||||
};
|
||||
}
|
||||
|
||||
/** 框里有字用框;空框才看规则集;都没有则要求先写提示词。不看内置默认。 */
|
||||
/** 框里有字用框;空框才看规则集;都没有就用内置默认,不要求先点保存。 */
|
||||
function injectSnapshotFromBox(dshHome, boxText) {
|
||||
const ruleId = rules.activeRuleId(dshHome);
|
||||
if (typeof boxText === "string" && core.normalizeOverride(boxText)) {
|
||||
@@ -201,6 +205,9 @@ function injectSnapshotFromBox(dshHome, boxText) {
|
||||
if (core.normalizeOverride(rules.activeRuleText(dshHome))) {
|
||||
return { injectSource: "rule", injectRuleId: ruleId, needPrompt: false };
|
||||
}
|
||||
if (core.normalizeOverride(core.defaultOverrideText())) {
|
||||
return { injectSource: "default", injectRuleId: null, needPrompt: false };
|
||||
}
|
||||
if (typeof boxText !== "string") return injectSnapshot(dshHome);
|
||||
return { injectSource: "none", injectRuleId: ruleId, needPrompt: true };
|
||||
}
|
||||
@@ -435,6 +442,21 @@ function installIdentityOverride(ctx, config = {}) {
|
||||
return rewriteLiveAssembly(config, assembled, context);
|
||||
}, { global: true, prepend: true });
|
||||
}
|
||||
// 切换预设会换掉 assemble。pre-step 瀑布在 assemble 之后才跑,第一次发送包不上。
|
||||
// 宿主在 assemble 之前调用这个函数,用的就是当前模式自己的 systemPrompt。
|
||||
const prepareAssemble = (loopCtx) => {
|
||||
try { rules.ensureOperatorBody(core.findDshHome()); } catch { /* 主目录还没有提示词 */ }
|
||||
const prompt = loopCtx && loopCtx.systemPrompt;
|
||||
if (prompt) {
|
||||
try {
|
||||
installAssembleGuard(prompt, (assembled, context) => (
|
||||
rewriteLiveAssembly(config, assembled, context)
|
||||
));
|
||||
} catch { /* 这一层代理包不上时,下面再包插件自己的 */ }
|
||||
}
|
||||
wrapAssemble();
|
||||
};
|
||||
globalThis.__dshPurgePrepareAssemble = prepareAssemble;
|
||||
// complete:true 会在 waterfall 之后盖掉 sections;包住 assemble 返回值,每轮都补回注入。
|
||||
wrapAssemble();
|
||||
const started = Date.now();
|
||||
@@ -1017,7 +1039,10 @@ export function apply(ctx, config) {
|
||||
} catch (e) {
|
||||
console.warn("[dsh-purge] client bundle boot patch:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
try { refreshHungOperator(core.findDshHome()); } catch { /* 主目录还没有提示词时段上留空 */ }
|
||||
try {
|
||||
const home = core.pinDshHome() || core.findDshHome();
|
||||
refreshHungOperator(home);
|
||||
} catch { /* 主目录还没有提示词时,组装会再挂内置默认 */ }
|
||||
try {
|
||||
const scrubbed = core.sanitizeDesktopCommandRuntimes();
|
||||
if (scrubbed.length) log(cfg, "desktop runtime scrub on load:", JSON.stringify(scrubbed));
|
||||
@@ -1568,7 +1593,9 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (incoming !== null) await core.saveOverrideContent(state.dsh_home, incoming);
|
||||
if (incoming !== null && core.normalizeOverride(incoming)) {
|
||||
await core.saveOverrideContent(state.dsh_home, incoming);
|
||||
}
|
||||
refreshHungOperator(state.dsh_home);
|
||||
await core.backupAll(state.ai_base);
|
||||
const report = await core.applyPatches(state.ai_base, core.ALL_PATCHES, { preserveClientBundles: true });
|
||||
|
||||
Reference in new issue
Block a user