fix: 空框不再写入默认提示词,玻璃界面跟随宿主主题

应用按框内正文、当前规则集、官方系统提示词的顺序选定;空框且没有规则时停下来要求输入,不再把内置默认写进磁盘。侧栏去掉手动换色,玻璃颜色跟随 DSH。说明只保留官方 Web 和官方桌面。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-04 00:05:11 +08:00
1 parent 14993f515e
commit 25c97e5cd2
9 files changed
+179 -414

No files matched your search

+40
View File
@@ -625,6 +625,46 @@ function sanitizeAssemblySections(sections) {
return out;
}
/** 包住 assemble;宿主再赋值 assemble 时自动再包,避免重启后第一轮丢掉注入。 */
export function installAssembleGuard(prompt, rewriteFn) {
if (!prompt || typeof prompt.assemble !== "function" || typeof rewriteFn !== "function") {
return false;
}
const wrap = (fn) => {
if (typeof fn !== "function") return fn;
if (fn._dshPurgeWrapped) return fn;
const orig = fn.bind(prompt);
const wrapped = async function assembleWithPurge(...args) {
const assembled = await orig(...args);
return rewriteFn(assembled, args[0]);
};
wrapped._dshPurgeWrapped = true;
return wrapped;
};
try {
let current = wrap(prompt.assemble);
Object.defineProperty(prompt, "assemble", {
configurable: true,
enumerable: true,
get() {
return current;
},
set(next) {
current = wrap(next);
},
});
return true;
} catch {
if (prompt.assemble._dshPurgeWrapped) return true;
try {
prompt.assemble = wrap(prompt.assemble);
return Boolean(prompt.assemble._dshPurgeWrapped);
} catch {
return false;
}
}
}
export function rewritePromptAssembly(assembled, fallbackInject = "", options = {}) {
if (!assembled || !Array.isArray(assembled.sections)) return assembled;
const opts = normalizeRewriteOptions(fallbackInject, options);