@shgroup/dsh-serenity-hooks 1.17.3 → 1.17.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.17.3",
3
+ "version": "1.17.4",
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
@@ -87,16 +87,34 @@ const SAFE_MODE_MARKER = ".serenity-safe-on";
87
87
  function isSafeModeOn(root) {
88
88
  return existsSync(resolve(root, SAFE_MODE_MARKER));
89
89
  }
90
+ /**
91
+ * 读取黑名单(对齐 osp readBlacklist):支持两种条目格式——
92
+ * string:".secrets/" 或 "regex:^..."(前缀 / 正则)
93
+ * object:{ "pattern": ".secrets/", "message": "自定义提示" }
94
+ * dsp v1.17.4 前只支持 string(对象会被 String() 成 "[object Object]" → 规则失效,不拦截)。
95
+ */
90
96
  function readBlacklist(root, paths = DEFAULT_SERENITY_CONFIG_PATHS) {
91
97
  const rules = loadSerenityConfig(root, paths).safeMode?.blacklist;
92
- return Array.isArray(rules) ? rules.map(String) : [];
98
+ if (!Array.isArray(rules)) return [];
99
+ const out = [];
100
+ for (const item of rules) if (typeof item === "string") {
101
+ if (item) out.push({ pattern: item });
102
+ } else if (item && typeof item === "object" && typeof item.pattern === "string") {
103
+ const obj = item;
104
+ const p = obj.pattern;
105
+ if (p) out.push({
106
+ pattern: p,
107
+ message: typeof obj.message === "string" ? obj.message : void 0
108
+ });
109
+ }
110
+ return out;
93
111
  }
94
- /** 匹配黑名单规则;命中返回规则,未命中返回 null。前缀匹配 / regex: 前缀 */
112
+ /** 匹配黑名单规则;命中返回条目,未命中返回 null。前缀匹配 / regex: 前缀(对齐 osp) */
95
113
  function matchBlacklist(relPath, rules) {
96
- for (const rule of rules) if (rule.startsWith("regex:")) try {
97
- if (new RegExp(rule.slice(6)).test(relPath)) return rule;
114
+ for (const rule of rules) if (rule.pattern.startsWith("regex:")) try {
115
+ if (new RegExp(rule.pattern.slice(6)).test(relPath)) return rule;
98
116
  } catch {}
99
- else if (relPath.startsWith(rule)) return rule;
117
+ else if (relPath.startsWith(rule.pattern)) return rule;
100
118
  return null;
101
119
  }
102
120
  //#endregion
@@ -1875,7 +1893,7 @@ function decideGuard(input) {
1875
1893
  };
1876
1894
  const hit = matchBlacklist(rel, blacklist);
1877
1895
  if (hit) return {
1878
- deny: `blacklist blocked: "${pathArg}" 命中规则 "${hit}"`,
1896
+ deny: hit.message ?? `blacklist blocked: "${pathArg}" 命中规则 "${hit.pattern}"`,
1879
1897
  kind: "deny"
1880
1898
  };
1881
1899
  }
@@ -3750,7 +3768,7 @@ function safeModeBlock(root) {
3750
3768
  "remain available, subject to path-escape and blacklist guards.",
3751
3769
  "Behavior constraints: do not attempt to bypass restrictions; do not write to",
3752
3770
  "blacklisted paths or governance files.",
3753
- blacklist.length > 0 ? `\nActive blacklist rules: ${blacklist.join(", ")}` : "",
3771
+ blacklist.length > 0 ? `\nActive blacklist rules: ${blacklist.map((b) => b.message ?? b.pattern).join(", ")}` : "",
3754
3772
  ""
3755
3773
  ].join("\n");
3756
3774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.17.3",
3
+ "version": "1.17.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": {