@shgroup/dsh-serenity-hooks 1.18.4 → 1.18.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.18.4",
3
+ "version": "1.18.6",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/loop + 拦截缝机械约束(safe-mode/路径守卫/会话落盘)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。私有(dsh-external 组织)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -1924,16 +1924,18 @@ function decideGuard(input) {
1924
1924
  deny: `path escape blocked: "${pathArg}" 越出 CCC 根`,
1925
1925
  kind: "deny"
1926
1926
  };
1927
- const rel = relative(root, abs).split("\\").join("/");
1928
- if (rel === ".serenity-safe-on" || rel === ".serenity" || rel.startsWith(".serenity-safe-on/") || rel.startsWith(".serenity/")) return {
1929
- deny: `CCC 治理文件 "${rel}" 保留给用户,agent 不可写`,
1930
- kind: "deny"
1931
- };
1932
- const hit = matchBlacklist(rel, blacklist);
1933
- if (hit) return {
1934
- deny: hit.message ?? `blacklist blocked: "${pathArg}" 命中规则 "${hit.pattern}"`,
1935
- kind: "deny"
1936
- };
1927
+ if (toolName === "write" || toolName === "edit" || toolName === "str_replace_editor" || toolName === "cc_fs" || toolName === "bash" || toolName === "append" || toolName === "touch") {
1928
+ const rel = relative(root, abs).split("\\").join("/");
1929
+ if (rel === ".serenity-safe-on" || rel === ".serenity" || rel.startsWith(".serenity-safe-on/") || rel.startsWith(".serenity/")) return {
1930
+ deny: `CCC 治理文件 "${rel}" 保留给用户,agent 不可写`,
1931
+ kind: "deny"
1932
+ };
1933
+ const hit = matchBlacklist(rel, blacklist);
1934
+ if (hit) return {
1935
+ deny: hit.message ?? `blacklist blocked: "${pathArg}" 命中规则 "${hit.pattern}"`,
1936
+ kind: "deny"
1937
+ };
1938
+ }
1937
1939
  }
1938
1940
  return { kind: "allow" };
1939
1941
  }
@@ -3682,6 +3684,8 @@ function readBootstrapConfig(agent) {
3682
3684
  function registerBootstrap(ctx) {
3683
3685
  const settingsByRoot = /* @__PURE__ */ new Map();
3684
3686
  const trackers = /* @__PURE__ */ new Map();
3687
+ /** 已锚定会话(进程内防重:子 agent 每会话只锚定一次) */
3688
+ const anchoredSessions = /* @__PURE__ */ new Set();
3685
3689
  const trackerFor = (root, settings) => {
3686
3690
  let t = trackers.get(root);
3687
3691
  if (!t) {
@@ -3707,8 +3711,11 @@ function registerBootstrap(ctx) {
3707
3711
  if (!root) return;
3708
3712
  const settings = settingsByRoot.get(root) ?? readBootstrapConfig(agent);
3709
3713
  const session = agent.session;
3710
- if ((session?.header?.delegationDepth ?? 0) > 0) return;
3711
- if (session?.events?.some((event) => event.type === "user/message")) return;
3714
+ const depth = session?.header?.delegationDepth ?? 0;
3715
+ const sid = typeof session?.id === "string" ? session.id : void 0;
3716
+ if (depth === 0) {
3717
+ if (session?.events?.some((event) => event.type === "user/message")) return;
3718
+ } else if (sid !== void 0 && anchoredSessions.has(sid)) return;
3712
3719
  if (message?.source?.kind === "plugin") return;
3713
3720
  const inbox = agent.inbox;
3714
3721
  if (!inbox?.prepend) return;
@@ -3726,6 +3733,7 @@ function registerBootstrap(ctx) {
3726
3733
  summary: "bootstrap anchor turn"
3727
3734
  }
3728
3735
  });
3736
+ if (sid !== void 0) anchoredSessions.add(sid);
3729
3737
  warnOnce(`anchor turns injected: ${settings.anchorMessages.length} 条(${settings.anchorMessages[0].slice(0, 40)}…)`);
3730
3738
  } catch {}
3731
3739
  });
@@ -4250,9 +4258,14 @@ function codeModeAdaptationLine(ctx, scope) {
4250
4258
  ""
4251
4259
  ].join("\n");
4252
4260
  }
4253
- /** 从 assembly context 解析 agent cwd(subagent/后台 agent 同样带 agent) */
4261
+ /** 从 assembly context 解析 agent cwd(subagent/后台 agent 同样带 agent);
4262
+ * 无 agent → undefined(不注入);有 agent 但无 header.cwd(workflow subagent 等)
4263
+ * 回退 process.cwd()——对齐 context.ts,否则这些 agent 系统提示词注入为空
4264
+ * (v1.18.6:workflow subagent 无宁静号上下文 bug) */
4254
4265
  function agentCwd(context) {
4255
- return (context.agent?.session)?.header?.cwd;
4266
+ const agent = context.agent;
4267
+ if (!agent) return void 0;
4268
+ return agent.session?.header?.cwd ?? process.cwd();
4256
4269
  }
4257
4270
  /** 从 assembly context 解析 dsh 会话 id(Session 块按会话隔离的 scope) */
4258
4271
  function agentScope$1(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.18.4",
3
+ "version": "1.18.6",
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": {