dsh-rule-engine 0.4.1 → 0.4.2

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.
@@ -18,6 +18,10 @@ export const SENSITIVE_CMD =
18
18
  export const CONFIG_FILE_RE =
19
19
  /(?:^|[\\/])(?:AGENTS\.md|settings\.yaml|\.credentials\.yaml|workspace\.json|cordis\.patch\.yml|rule-understanding\.json|rule-guard\.json|rule-engine\.json)$/i;
20
20
 
21
+ /** 受保护文件名(命令文本中出现即需警惕;P0-1c 起仅在写类命令中生效) */
22
+ export const PROTECTED_FILENAME_RE =
23
+ /(?:AGENTS\.md|settings\.yaml|\.credentials\.yaml|workspace\.json|cordis\.patch\.yml|rule-understanding\.json|rule-engine\.json)/i;
24
+
21
25
  export const DATA_DIR_RE =
22
26
  /(?:^|[\\/])\.dsh[\\/](?:sessions|storages|\.backups)[\\/]/i;
23
27
 
@@ -373,7 +377,10 @@ export function isSensitiveToolCall(toolName, args) {
373
377
  if (name === "edit" || name === "write" || name === "pwsh" || name === "bash") return true;
374
378
  }
375
379
  if (name === "pwsh" || name === "bash") {
376
- if (cmd && (SENSITIVE_CMD.test(cmd) || /(?:AGENTS\.md|settings\.yaml|\.credentials\.yaml|workspace\.json|cordis\.patch\.yml|rule-understanding\.json|rule-engine\.json)/i.test(cmd) || commandHasOutsideWrite(cmd))) return true;
380
+ // P0-1c:受保护文件名检查必须配合「写类命令」——纯描述性文本(如 gh release --notes 里的
381
+ // "AGENTS.md" 字样、echo 输出内容)不再触发敏感判定;真写类命令(Set-Content/Remove-Item 等
382
+ // 命中 MUTATING_CMD_RE)提到受保护文件仍判敏感。
383
+ if (cmd && (SENSITIVE_CMD.test(cmd) || (MUTATING_CMD_RE.test(cmd) && PROTECTED_FILENAME_RE.test(cmd)) || commandHasOutsideWrite(cmd))) return true;
377
384
  }
378
385
  if (name === "edit" || name === "write") {
379
386
  if (p && (isProtectedConfigPath(p) || isOutsideWorkspace(p))) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-rule-engine",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "DSH 规则执行引擎 v3:容器解析 AGENTS.md + 理解器 + 匹配机 + 执行框架",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",