@shgroup/dsh-serenity-hooks 1.17.2 → 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 +1 -1
- package/lib/index.js +39 -7
- 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.17.
|
|
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
|
-
|
|
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
|
-
/**
|
|
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
|
|
@@ -626,6 +644,20 @@ flags 是 new-style 对象数组,用于参数校验与 path 逃逸守卫:
|
|
|
626
644
|
- 配对 .test.ts 或 .spec.ts(DC-M1,vitest)
|
|
627
645
|
- 业务子进程环境:注入 SERENITY_ROOT / SERENITY_CCC / SERENITY_VERSION
|
|
628
646
|
|
|
647
|
+
## 交互与确认规范(禁止阻塞性确认)
|
|
648
|
+
- MSM 运行在**无用户交互的子进程**(spawn/execFile,600s 超时)——**禁止**用
|
|
649
|
+
readline / prompt / process.stdin 等阻塞等待用户输入(会卡死至超时被 kill)
|
|
650
|
+
- 需要二次确认时:**直接返回确认信息**(输出将执行的操作与影响 + 如何带确认参数重试),
|
|
651
|
+
以非 0 退出码返回(或明确提示)
|
|
652
|
+
- agent 确认后**重新调用 MSM 并带上确认参数**(如 --confirm / --yes / --force)重试
|
|
653
|
+
- 标准模式(两段式):
|
|
654
|
+
1. 首次调用:检测到破坏性/需确认操作且未带确认 flag → 输出确认请求(列出操作/影响/回滚),
|
|
655
|
+
exit 非 0(如 1 user),**不执行任何变更**
|
|
656
|
+
2. agent 评估后重新调用:带确认 flag → 执行并输出结果
|
|
657
|
+
- 适用场景:删除/覆盖/推送/批量操作 等不可逆或影响面大的操作
|
|
658
|
+
- 反例(禁止):readline 等待用户输入、process.stdin.on('data') 阻塞等待
|
|
659
|
+
(MSM 无 stdin 交互通道——卡死至 600s 超时)
|
|
660
|
+
|
|
629
661
|
## 品质检查(acc_msm check,DC-M1~M4)
|
|
630
662
|
DC-M1 有 .test.ts/.spec.ts;DC-M2 有 main() 守卫(function main( / isMain / require.main === / import.meta.url);
|
|
631
663
|
DC-M3 双向:脚本未注册 + 注册表引用脚本缺失;DC-M4 路径型 flag 标记 type:"path"
|
|
@@ -1861,7 +1893,7 @@ function decideGuard(input) {
|
|
|
1861
1893
|
};
|
|
1862
1894
|
const hit = matchBlacklist(rel, blacklist);
|
|
1863
1895
|
if (hit) return {
|
|
1864
|
-
deny: `blacklist blocked: "${pathArg}" 命中规则 "${hit}"`,
|
|
1896
|
+
deny: hit.message ?? `blacklist blocked: "${pathArg}" 命中规则 "${hit.pattern}"`,
|
|
1865
1897
|
kind: "deny"
|
|
1866
1898
|
};
|
|
1867
1899
|
}
|
|
@@ -3736,7 +3768,7 @@ function safeModeBlock(root) {
|
|
|
3736
3768
|
"remain available, subject to path-escape and blacklist guards.",
|
|
3737
3769
|
"Behavior constraints: do not attempt to bypass restrictions; do not write to",
|
|
3738
3770
|
"blacklisted paths or governance files.",
|
|
3739
|
-
blacklist.length > 0 ? `\nActive blacklist rules: ${blacklist.join(", ")}` : "",
|
|
3771
|
+
blacklist.length > 0 ? `\nActive blacklist rules: ${blacklist.map((b) => b.message ?? b.pattern).join(", ")}` : "",
|
|
3740
3772
|
""
|
|
3741
3773
|
].join("\n");
|
|
3742
3774
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.17.
|
|
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": {
|