fix(identity): 合并 PR #83,assemble 代理层不再每步叠加

Fixes #82

提交者对着 1.1.59 的 wrap(prompt.assemble) 每步叠 createShadowMethod,诊断正确。1.1.60 起已有 Symbol 守卫;冲突保留该守卫和按服务 slot 更新 rewrite,并纳入 PR 的 _dshPurgeWrapped 早退,避免描述符读不到时把新代理写进 accessor。不采用模块级 activeAssembleRewrite,以免多 prompt 抢同一改写函数。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-09 10:15:33 +08:00
commit bb850ce8d4
1 file changed
+10 -1
+10 -1
View File
@@ -636,10 +636,19 @@ export function installAssembleGuard(prompt, rewriteFn) {
return false;
}
if (typeof original !== "function") return false;
// cordis 每次读 assemble 都新包一层 createShadowMethod。已包装则立刻返回,
// 绝不把这次读到的新代理写进 accessor(#82 / PR #83)。
if (original._dshPurgeWrapped) {
if (original._dshPurgeSlot) original._dshPurgeSlot.rewrite = rewriteFn;
return true;
}
const slot = { rewrite: rewriteFn };
const wrap = (fn) => {
if (typeof fn !== "function") return fn;
if (fn._dshPurgeWrapped && fn._dshPurgeSlot === slot) return fn;
if (fn._dshPurgeWrapped) {
if (fn._dshPurgeSlot) fn._dshPurgeSlot.rewrite = slot.rewrite;
return fn;
}
const orig = typeof fn.bind === "function" ? fn.bind(prompt) : fn;
const wrapped = async function assembleWithPurge(...args) {
const assembled = await orig(...args);