release: 1.3.5 适配 dsh 0.1.2-rc.1 / Node 24 Windows 无感与首轮注入

修复 Node 24 ESM spawn 补丁无效导致的 CMD 闪窗;梁神 phase-1 保留完整 system-prompt;README 写明适配版本与变更说明。
This commit is contained in:
yang committed 2026-09-05 19:57:42 +08:00
1 parent 905383165b
commit 9d139bf474
10 files changed
+1097 -171

No files matched your search

+23 -12
View File
@@ -37,9 +37,19 @@ function stripHarnessPersona(text) {
.replace(/You are a coding agent powered by the [^\n.]+ model\.?\s*/g, "");
}
function collectInjectText(purgeSections, fallbackText) {
const fromSections = purgeSections
.map((s) => String(s.text || "").trim())
.filter(Boolean)
.join("\n\n")
.trim();
if (fromSections) return fromSections;
return typeof fallbackText === "string" ? fallbackText.trim() : "";
}
/** Fold user inject into the persona slot so Liangshen phase-1 cannot strip it. */
function foldInjectIntoPersona(sections, injectText) {
if (!injectText) return { sections, folded: false };
if (!injectText) return sections;
let folded = false;
const out = sections.map((section) => {
if (!PERSONA_NAMES.has(String(section?.name || ""))) return section;
@@ -54,10 +64,18 @@ function foldInjectIntoPersona(sections, injectText) {
text: prior ? `${injectText}\n\n${prior}` : injectText,
};
});
return { sections: out, folded };
if (folded) return out;
// Phase-1 / minimal may omit persona briefly — synthesize one so inject still lands turn 1.
return [{ name: "deployment:persona", text: injectText }, ...out];
}
export function rewritePromptAssembly(assembled) {
/**
* @param {object} assembled
* @param {string} [fallbackInject] raw prompt-inject.md when purge sections were
* already filtered out by an outer Liangshen hook (first-turn race).
*/
export function rewritePromptAssembly(assembled, fallbackInject = "") {
if (!assembled || !Array.isArray(assembled.sections)) return assembled;
const rest = [];
const purge = [];
@@ -71,16 +89,9 @@ export function rewritePromptAssembly(assembled) {
else rest.push(next);
}
const injectText = purge
.map((s) => String(s.text || "").trim())
.filter(Boolean)
.join("\n\n")
.trim();
const { sections: withPersona, folded } = foldInjectIntoPersona(rest, injectText);
const injectText = collectInjectText(purge, fallbackInject);
// After promotion Liangshen restores all sections — keep dsh-purge at the end.
// During phase-1 only persona survives; inject is already inside it when folded.
assembled.sections = folded && injectText ? [...withPersona, ...purge] : [...withPersona, ...purge];
assembled.sections = [...foldInjectIntoPersona(rest, injectText), ...purge];
return assembled;
}