@shgroup/dsh-serenity-hooks 1.16.10 → 1.16.12

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.16.10",
3
+ "version": "1.16.12",
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
@@ -2827,6 +2827,51 @@ function eapBlock() {
2827
2827
  ""
2828
2828
  ].join("\n");
2829
2829
  }
2830
+ /**
2831
+ * 运行时状态块 1) safe-mode(S134 v1.16.12):ON 时告知 agent(行为约束;机制仍由 guards 强制)。
2832
+ * 文案与实现逐项对应(guards.ts):bash 禁用(restrict deny + decideGuard)、
2833
+ * 黑名单路径拦截、CCC 治理文件保护;write/edit 等其余工具保留(受路径逃逸/黑名单约束)。
2834
+ */
2835
+ function safeModeBlock(root) {
2836
+ if (!isSafeModeOn(root)) return "";
2837
+ const blacklist = readBlacklist(root);
2838
+ return [
2839
+ "",
2840
+ "=== Serenity Safe Mode ===",
2841
+ "Safe mode is ON (enabled by the user): bash is disabled (hidden and blocked);",
2842
+ "blacklist rules apply to file paths; CCC governance files (.serenity,",
2843
+ ".serenity-safe-on) are protected from agent writes. Other read/write tools",
2844
+ "remain available, subject to path-escape and blacklist guards.",
2845
+ "Behavior constraints: do not attempt to bypass restrictions; do not write to",
2846
+ "blacklisted paths or governance files.",
2847
+ blacklist.length > 0 ? `\nActive blacklist rules: ${blacklist.join(", ")}` : "",
2848
+ ""
2849
+ ].join("\n");
2850
+ }
2851
+ /**
2852
+ * 运行时状态块 2) localstore git 策略(S134 v1.16.12):localstore.json 存在时按 gitTrack
2853
+ * 提示敏感行为约束。deny(缺省)= 本地私有不提交;allow = 进 git(个人私有仓)但敏感数据
2854
+ * 只限于该文件内(不外泄到其他文件/对话/日志)。
2855
+ */
2856
+ function localstoreBlock(root) {
2857
+ if (!existsSync(localstorePath(root))) return "";
2858
+ return (readGitTrack(root) === "allow" ? [
2859
+ "",
2860
+ "=== Serenity Localstore ===",
2861
+ "localstore.json is committed to git (gitTrack=allow — personal private repository).",
2862
+ "Sensitive data may live in this file, but ONLY in this file: keep credentials and",
2863
+ "secret values confined to localstore.json — never leak them into other files,",
2864
+ "conversation, or logs.",
2865
+ ""
2866
+ ] : [
2867
+ "",
2868
+ "=== Serenity Localstore ===",
2869
+ "localstore.json is a local private file (gitTrack=deny — not committed to git,",
2870
+ ".gitignore enforced). Credentials/config live only on this machine: do not write",
2871
+ "them into conversation or logs; do not attempt to commit this file (cc_git will refuse).",
2872
+ ""
2873
+ ]).join("\n");
2874
+ }
2830
2875
  /** 4) SKILL.md 全文:该 CCC 顶层入口 skill 原文(对齐 osp:原文直推,无包裹头;仅过滤治理内容) */
2831
2876
  function entrySkillSectionText(root) {
2832
2877
  const skills = findEntrySkills(root);
@@ -2882,9 +2927,11 @@ function serenitySystemPrompt(root, scope = DEFAULT_SESSION_SCOPE) {
2882
2927
  const parts = [
2883
2928
  accBlock(root),
2884
2929
  cceBlock(),
2885
- constraintsBlock(root),
2886
- eapBlock()
2930
+ constraintsBlock(root)
2887
2931
  ];
2932
+ const state = [safeModeBlock(root), localstoreBlock(root)].filter((b) => b !== "").join("\n");
2933
+ if (state) parts.push(state);
2934
+ parts.push(eapBlock());
2888
2935
  const skill = entrySkillSectionText(root);
2889
2936
  if (skill) parts.push(skill);
2890
2937
  const session = sessionBlock(root, scope);
@@ -3009,14 +3056,15 @@ const PLUGIN_SOURCE = {
3009
3056
  plugin: "dsh-serenity-hooks"
3010
3057
  };
3011
3058
  /**
3012
- * ACC 注入消息:完整内容 = 简短身份头 + 完整系统提示词(ACC 5 + CCC 顶层 skill 原文)。
3013
- * 用户要求:在此处注入完整 ACC 系统提示词内容 + CCC 顶层 skill 原文(对齐 osp system.transform)。
3014
- * scope = dsh 会话 id:Session 块按会话隔离,不跨会话泄露。
3059
+ * ACC 注入消息(S134 去重):**只含简短身份锚点**([ACC] 已激活 + CCC + 约束 + loop 模型 + Phase 2)。
3060
+ * 完整身份(ACC 5 + CCE + Constraints + EAP + SKILL 全文 + Session 块)由**系统提示词层**
3061
+ * (systemPrompt.section,每轮 prompt 装配自动注入,含 subagent)承担——对话消息流/压缩重注入
3062
+ * 不再重复注入同一内容(token 双倍浪费,见 S134 注入方案梳理)。
3015
3063
  */
3016
- function accMessage(root, configPaths, entrySkillMaxChars, scope = DEFAULT_SESSION_SCOPE) {
3064
+ function accMessage(root, configPaths, entrySkillMaxChars) {
3017
3065
  const content = [{
3018
3066
  type: "text",
3019
- text: `${accIdentityText(root, configPaths, entrySkillMaxChars)}\n\n${serenitySystemPrompt(root, scope)}`
3067
+ text: accIdentityText(root, configPaths, entrySkillMaxChars)
3020
3068
  }];
3021
3069
  return createUserMessage({
3022
3070
  content,
@@ -3063,7 +3111,7 @@ function registerContext(ctx, opts = {}) {
3063
3111
  } catch {}
3064
3112
  if (injected.has(key)) return;
3065
3113
  injected.add(key);
3066
- agent.inject(accMessage(root, configPaths, entrySkillMaxChars, agentScope(agent)));
3114
+ agent.inject(accMessage(root, configPaths, entrySkillMaxChars));
3067
3115
  syncSafeModeRestriction(agent, root);
3068
3116
  };
3069
3117
  if (opts.seedOnStart ?? true) ctx.on("agent/session-start", (payload) => {
@@ -3087,7 +3135,7 @@ function registerContext(ctx, opts = {}) {
3087
3135
  return {
3088
3136
  kind: "enter",
3089
3137
  messages: [
3090
- accMessage(root, configPaths, entrySkillMaxChars, agentScope(agent)),
3138
+ accMessage(root, configPaths, entrySkillMaxChars),
3091
3139
  ...messages,
3092
3140
  ...downstream.messages
3093
3141
  ]
@@ -3110,9 +3158,8 @@ function registerCompactRetention(ctx, opts = {}) {
3110
3158
  if (!agent) return;
3111
3159
  const root = findSerenityRoot(agent.session?.header?.cwd ?? process.cwd());
3112
3160
  if (!root) return;
3113
- const scope = agent.session?.id ?? "default";
3114
3161
  try {
3115
- agent.inject(accMessage(root, configPaths, entrySkillMaxChars, scope));
3162
+ agent.inject(accMessage(root, configPaths, entrySkillMaxChars));
3116
3163
  } catch {}
3117
3164
  });
3118
3165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.16.10",
3
+ "version": "1.16.12",
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": {