@shgroup/dsh-serenity-hooks 1.23.2 → 1.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh.plugin.json +1 -1
- package/lib/index.js +34 -11
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-serenity-hooks",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/loop/session_rebuild + 拦截缝机械约束(safe-mode/路径守卫)+ 高级设定面板(双端口网关/账号管理)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。",
|
|
6
6
|
"engines": {
|
package/lib/index.js
CHANGED
|
@@ -5106,13 +5106,13 @@ function parseSessionContextFromEvents(events) {
|
|
|
5106
5106
|
const idx = s.indexOf(SESSION_CONTEXT_MARKER);
|
|
5107
5107
|
if (idx < 0) continue;
|
|
5108
5108
|
const dirName = s.slice(idx + 28).trim().split("\n")[0]?.trim() ?? "";
|
|
5109
|
-
const mdMatch = s.match(/SESSION\.md path:\s*(\
|
|
5109
|
+
const mdMatch = s.match(/SESSION\.md path:\s*([^\r\n]+)/);
|
|
5110
5110
|
if (/^\d{4}-\d{2}-\d{2}--/.test(dirName) && mdMatch) {
|
|
5111
5111
|
const idMatch = dirName.match(/--S(\d{3,})--/);
|
|
5112
5112
|
return {
|
|
5113
5113
|
sessionId: idMatch ? `S${idMatch[1]}` : basename(dirName),
|
|
5114
5114
|
dirName,
|
|
5115
|
-
mdPath: mdMatch[1]
|
|
5115
|
+
mdPath: mdMatch[1].trim()
|
|
5116
5116
|
};
|
|
5117
5117
|
}
|
|
5118
5118
|
}
|
|
@@ -5988,11 +5988,14 @@ function stripAckSuffix(text) {
|
|
|
5988
5988
|
*/
|
|
5989
5989
|
function buildRebuildAnchor(root, sessionName, activeMdPath, anchorMessages = DEFAULT_ANCHOR_MESSAGES) {
|
|
5990
5990
|
const rel = activeMdPath.startsWith(root) ? activeMdPath.slice(root.length + 1) : activeMdPath;
|
|
5991
|
+
const sessionDir = basename(dirname(activeMdPath));
|
|
5992
|
+
const sessionLine = sessionDir !== "AGENT_SESSIONS" ? `- Serenity session: ${sessionName !== "" ? `${sessionName} (${sessionDir})` : sessionDir}` : null;
|
|
5991
5993
|
return [
|
|
5992
5994
|
"[TRAJECTORY-REBUILD] The conversation has been cleared and rebuilt (Ship of Theseus: the carrier is replaced, the trajectory continues).",
|
|
5993
5995
|
"",
|
|
5994
5996
|
...anchorMessages.flatMap((text) => [stripAckSuffix(text), ""]),
|
|
5995
5997
|
sessionName !== "" ? `Continue the work of ${sessionName}.` : "Continue the current work.",
|
|
5998
|
+
...sessionLine ? [sessionLine] : [],
|
|
5996
5999
|
`- Persistent trajectory (SESSION.md, unmoved): ${rel}`,
|
|
5997
6000
|
`- Read that SESSION.md first (goal/decisions/progress/unresolved), then continue from the last checkpoint.`
|
|
5998
6001
|
].join("\n");
|
|
@@ -6265,11 +6268,20 @@ var KeeperTracker = class {
|
|
|
6265
6268
|
function reminderText(code, score) {
|
|
6266
6269
|
return `[TRAJECTORY-STEWARD] Score threshold reached (${score}). Please acknowledge with [TRAJECTORY-STEWARD-recorded-${code}] once progress is synced to the working session (acc-session show). No need to interrupt your work — just acknowledge inline and keep going.`;
|
|
6267
6270
|
}
|
|
6268
|
-
/**
|
|
6269
|
-
*
|
|
6270
|
-
*
|
|
6271
|
-
|
|
6272
|
-
|
|
6271
|
+
/**
|
|
6272
|
+
* F2 rebuild 提示(v1.21;v1.22.1 对齐"轨迹跟踪器"概念;v1.23.0 英化 + 载体关系;
|
|
6273
|
+
* v1.23.3 行动指令化——用户反馈"一直在触发为啥没执行":旧文案是状态播报式
|
|
6274
|
+
* ("[TRAJECTORY] Context usage at N%..."),模型当成系统状态而非行动请求,可一直忽略。
|
|
6275
|
+
* 新文案 = 明确的行动指令(ACT NOW + 何时执行 + 必须执行),对齐 steward ACK 协议风格。
|
|
6276
|
+
*
|
|
6277
|
+
* escalated=true(v1.23.3):连续多轮超阈值仍未 rebuild → 升级强制语气
|
|
6278
|
+
* (STOP and rebuild now,持续注入直到调用 session_rebuild)。
|
|
6279
|
+
*/
|
|
6280
|
+
function rebuildReminderText(ratio, threshold, escalated = false) {
|
|
6281
|
+
const pct = (ratio * 100).toFixed(0);
|
|
6282
|
+
const thr = (threshold * 100).toFixed(0);
|
|
6283
|
+
if (escalated) return `[TRAJECTORY-ESCALATED] Context usage at ${pct}% (threshold ${thr}%) — you have been reminded repeatedly and have NOT called session_rebuild. This is now mandatory: STOP at the current task step and call the session_rebuild tool immediately. The conversation will be cleared and rebuilt in place; SESSION.md is the persistent trajectory and stays in place — identity continues from it. Do not continue working without rebuilding; this reminder persists until you call session_rebuild.`;
|
|
6284
|
+
return `[TRAJECTORY] Context usage at ${pct}% (threshold ${thr}%). This session is the rebuildable carrier of the trajectory: SESSION.md is the persistent body, this conversation is only a temporary work copy. ACT NOW: at the next natural pause (end of the current task step), call the session_rebuild tool to clear and rebuild this conversation — the current copy is discarded, identity continues from SESSION.md. If you are in the middle of an unbreakable step, continue it, then rebuild at its end. Do not ignore this; rebuild is the expected action, not an option.`;
|
|
6273
6285
|
}
|
|
6274
6286
|
/** 读取会话 contextPressure 投影(sessionProjections 可选服务;未装配返回 null) */
|
|
6275
6287
|
function readContextPressure(ctx, session) {
|
|
@@ -6292,6 +6304,9 @@ const PLUGIN_SOURCE$1 = {
|
|
|
6292
6304
|
};
|
|
6293
6305
|
/** 每 agent 一个跟踪器(进程内存态,agent token 维度) */
|
|
6294
6306
|
const trackers = /* @__PURE__ */ new Map();
|
|
6307
|
+
/** 连续超阈值轮数达此值 → 升级为 [TRAJECTORY-ESCALATED] 强制语气(此后持续升级催,直到 rebuild) */
|
|
6308
|
+
const REBUILD_ESCALATE_AFTER = 3;
|
|
6309
|
+
const rebuildReminderStates = /* @__PURE__ */ new Map();
|
|
6295
6310
|
function registerKeeper(ctx, opts = {}) {
|
|
6296
6311
|
const defaultThreshold = opts.defaultThreshold ?? 150;
|
|
6297
6312
|
const trackerFor = (exec) => {
|
|
@@ -6324,10 +6339,18 @@ function registerKeeper(ctx, opts = {}) {
|
|
|
6324
6339
|
const pressure = readContextPressure(ctx, session);
|
|
6325
6340
|
if (pressure && pressure.contextWindow && pressure.contextWindow > 0) {
|
|
6326
6341
|
const ratio = pressure.projectedTokens / pressure.contextWindow;
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6342
|
+
const threshold = readSimpleSettings().rebuildThreshold;
|
|
6343
|
+
if (ratio >= threshold) {
|
|
6344
|
+
const key = exec.agent?.session?.id ?? "global";
|
|
6345
|
+
const st = rebuildReminderStates.get(key) ?? { consecutive: 0 };
|
|
6346
|
+
st.consecutive += 1;
|
|
6347
|
+
const escalated = st.consecutive >= REBUILD_ESCALATE_AFTER;
|
|
6348
|
+
blocks.push({
|
|
6349
|
+
type: "text",
|
|
6350
|
+
text: rebuildReminderText(ratio, threshold, escalated)
|
|
6351
|
+
});
|
|
6352
|
+
rebuildReminderStates.set(key, st);
|
|
6353
|
+
}
|
|
6331
6354
|
}
|
|
6332
6355
|
}
|
|
6333
6356
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.4",
|
|
4
4
|
"description": "宁静号 ACC harness — Native Cordis 插件(DeepSeek Harness 运行时)。真实 DSH 工具注册(cc_fs/session/acc_msm 等 9 工具)+ 拦截缝机械约束(safe-mode/路径守卫/会话落盘)+ 系统提示词注入(ACC/CCE/Constraints/SKILL/Session 五块)。适配 DSH 公开版(deepseek-ai/deepseek-harness 0.1.0-rc)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|