failproofai 0.0.6-beta.1 → 0.0.6-beta.3
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/.next/standalone/.failproofai/policies/review-policies.mjs +4 -3
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +2 -2
- package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0g72weg._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__092s1ta._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0~kmh8w._.js → [root-of-the-server]__096k.db._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09icjsf._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0g.lg8b._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h..k-e._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0rh.18_._.js → [root-of-the-server]__0kyh86x._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0okos0k._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0w6l33k._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11pa2ra._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12t-wym._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_10lm7or._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_0xerkr6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_0q-m0y-._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +2 -2
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +9 -9
- package/.next/standalone/.next/static/chunks/{0gbf4cphy8ksq.js → 0-dm_9a6nsc2l.js} +1 -1
- package/.next/standalone/.next/static/chunks/{12~yi9oj8av8p.js → 01pmw1-asbek~.js} +2 -2
- package/.next/standalone/.next/static/chunks/{0v.yd0kg_ld3r.js → 051m32nx~n5yr.js} +1 -1
- package/.next/standalone/.next/static/chunks/{09_k80d~cq2wg.js → 0a-yctdwn368y.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0bvhsa6zva2o..js → 0ksdlt_1hucdm.js} +1 -1
- package/.next/standalone/.next/static/chunks/{01b~z8f1ws0rk.js → 0l-mu4okl-cj1.js} +1 -1
- package/.next/standalone/.next/static/chunks/{08t08igdql9yt.js → 0mazj-p-~2kc6.js} +1 -1
- package/.next/standalone/.next/static/chunks/0qakntsrpc~1j.js +6 -0
- package/.next/standalone/.next/static/chunks/{03rz6ykw-a2xi.js → 156zca6aewyr-.js} +1 -1
- package/.next/standalone/CHANGELOG.md +18 -0
- package/.next/standalone/bin/failproofai.mjs +91 -4
- package/.next/standalone/dist/cli.mjs +1156 -55
- package/.next/standalone/docs/ar/built-in-policies.mdx +140 -103
- package/.next/standalone/docs/ar/custom-policies.mdx +72 -72
- package/.next/standalone/docs/ar/examples.mdx +86 -33
- package/.next/standalone/docs/ar/getting-started.mdx +82 -29
- package/.next/standalone/docs/built-in-policies.mdx +3 -3
- package/.next/standalone/docs/de/built-in-policies.mdx +97 -60
- package/.next/standalone/docs/de/custom-policies.mdx +56 -56
- package/.next/standalone/docs/de/examples.mdx +72 -18
- package/.next/standalone/docs/de/getting-started.mdx +72 -20
- package/.next/standalone/docs/es/built-in-policies.mdx +91 -54
- package/.next/standalone/docs/es/custom-policies.mdx +55 -55
- package/.next/standalone/docs/es/examples.mdx +73 -19
- package/.next/standalone/docs/es/getting-started.mdx +72 -20
- package/.next/standalone/docs/fr/built-in-policies.mdx +99 -62
- package/.next/standalone/docs/fr/custom-policies.mdx +51 -51
- package/.next/standalone/docs/fr/examples.mdx +78 -24
- package/.next/standalone/docs/fr/getting-started.mdx +65 -13
- package/.next/standalone/docs/he/built-in-policies.mdx +139 -99
- package/.next/standalone/docs/he/custom-policies.mdx +75 -75
- package/.next/standalone/docs/he/examples.mdx +87 -33
- package/.next/standalone/docs/he/getting-started.mdx +84 -33
- package/.next/standalone/docs/hi/built-in-policies.mdx +203 -166
- package/.next/standalone/docs/hi/custom-policies.mdx +71 -70
- package/.next/standalone/docs/hi/examples.mdx +90 -36
- package/.next/standalone/docs/hi/getting-started.mdx +80 -27
- package/.next/standalone/docs/i18n/README.ar.md +69 -69
- package/.next/standalone/docs/i18n/README.de.md +46 -46
- package/.next/standalone/docs/i18n/README.es.md +42 -42
- package/.next/standalone/docs/i18n/README.fr.md +39 -39
- package/.next/standalone/docs/i18n/README.he.md +83 -83
- package/.next/standalone/docs/i18n/README.hi.md +69 -69
- package/.next/standalone/docs/i18n/README.it.md +72 -72
- package/.next/standalone/docs/i18n/README.ja.md +71 -71
- package/.next/standalone/docs/i18n/README.ko.md +52 -52
- package/.next/standalone/docs/i18n/README.pt-br.md +44 -44
- package/.next/standalone/docs/i18n/README.ru.md +66 -66
- package/.next/standalone/docs/i18n/README.tr.md +82 -83
- package/.next/standalone/docs/i18n/README.vi.md +70 -71
- package/.next/standalone/docs/i18n/README.zh.md +51 -51
- package/.next/standalone/docs/it/built-in-policies.mdx +115 -78
- package/.next/standalone/docs/it/custom-policies.mdx +69 -69
- package/.next/standalone/docs/it/examples.mdx +93 -39
- package/.next/standalone/docs/it/getting-started.mdx +73 -21
- package/.next/standalone/docs/ja/built-in-policies.mdx +155 -118
- package/.next/standalone/docs/ja/custom-policies.mdx +71 -71
- package/.next/standalone/docs/ja/examples.mdx +76 -22
- package/.next/standalone/docs/ja/getting-started.mdx +65 -13
- package/.next/standalone/docs/ko/built-in-policies.mdx +103 -66
- package/.next/standalone/docs/ko/custom-policies.mdx +67 -67
- package/.next/standalone/docs/ko/examples.mdx +87 -33
- package/.next/standalone/docs/ko/getting-started.mdx +61 -9
- package/.next/standalone/docs/pt-br/built-in-policies.mdx +72 -35
- package/.next/standalone/docs/pt-br/custom-policies.mdx +56 -56
- package/.next/standalone/docs/pt-br/examples.mdx +78 -24
- package/.next/standalone/docs/pt-br/getting-started.mdx +64 -12
- package/.next/standalone/docs/ru/built-in-policies.mdx +135 -98
- package/.next/standalone/docs/ru/custom-policies.mdx +82 -81
- package/.next/standalone/docs/ru/examples.mdx +77 -22
- package/.next/standalone/docs/ru/getting-started.mdx +74 -22
- package/.next/standalone/docs/tr/built-in-policies.mdx +126 -89
- package/.next/standalone/docs/tr/custom-policies.mdx +59 -60
- package/.next/standalone/docs/tr/examples.mdx +97 -42
- package/.next/standalone/docs/tr/getting-started.mdx +75 -23
- package/.next/standalone/docs/vi/built-in-policies.mdx +116 -81
- package/.next/standalone/docs/vi/custom-policies.mdx +68 -68
- package/.next/standalone/docs/vi/examples.mdx +93 -38
- package/.next/standalone/docs/vi/getting-started.mdx +74 -22
- package/.next/standalone/docs/zh/built-in-policies.mdx +117 -82
- package/.next/standalone/docs/zh/custom-policies.mdx +49 -49
- package/.next/standalone/docs/zh/examples.mdx +90 -36
- package/.next/standalone/docs/zh/getting-started.mdx +73 -21
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/server.js +1 -1
- package/.next/standalone/src/auth/login.ts +104 -0
- package/.next/standalone/src/auth/logout.ts +50 -0
- package/.next/standalone/src/auth/token-store.ts +64 -0
- package/.next/standalone/src/hooks/builtin-policies.ts +27 -21
- package/.next/standalone/src/hooks/handler.ts +35 -15
- package/.next/standalone/src/relay/daemon.ts +362 -0
- package/.next/standalone/src/relay/pid.ts +76 -0
- package/.next/standalone/src/relay/queue.ts +225 -0
- package/bin/failproofai.mjs +91 -4
- package/dist/cli.mjs +1156 -55
- package/package.json +1 -1
- package/src/auth/login.ts +104 -0
- package/src/auth/logout.ts +50 -0
- package/src/auth/token-store.ts +64 -0
- package/src/hooks/builtin-policies.ts +27 -21
- package/src/hooks/handler.ts +35 -15
- package/src/relay/daemon.ts +362 -0
- package/src/relay/pid.ts +76 -0
- package/src/relay/queue.ts +225 -0
- package/.next/standalone/.next/static/chunks/0wlyoif4_kj_t.js +0 -6
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → r-wX0MuAfCjbhJm3phQc8}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → r-wX0MuAfCjbhJm3phQc8}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → r-wX0MuAfCjbhJm3phQc8}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 内置策略
|
|
3
|
-
description: "
|
|
3
|
+
description: "30 条内置策略,可捕获常见的 Agent 故障模式"
|
|
4
4
|
icon: shield
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
failproofai 内置了 30
|
|
7
|
+
failproofai 内置了 30 条策略,用于捕获常见的 Agent 故障模式。每条策略会在特定的 Hook 事件类型和工具名称上触发。其中九条策略支持参数配置,让你无需编写代码即可调整其行为。四条工作流策略在 Claude 停止前强制执行 commit → push → PR → CI 流水线。
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -12,46 +12,47 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
12
12
|
|
|
13
13
|
策略按类别分组:
|
|
14
14
|
|
|
15
|
-
| 类别 | 策略 |
|
|
16
|
-
|
|
15
|
+
| 类别 | 策略 | Hook 类型 |
|
|
16
|
+
|------|------|-----------|
|
|
17
17
|
| [危险命令](#dangerous-commands) | block-sudo, block-rm-rf, block-curl-pipe-sh, block-failproofai-commands | PreToolUse |
|
|
18
|
-
| [
|
|
18
|
+
| [密钥(清理器)](#secrets-sanitizers) | sanitize-jwt, sanitize-api-keys, sanitize-connection-strings, sanitize-private-key-content, sanitize-bearer-tokens | PostToolUse |
|
|
19
19
|
| [环境](#environment) | block-env-files, protect-env-vars | PreToolUse |
|
|
20
20
|
| [文件访问](#file-access) | block-read-outside-cwd, block-secrets-write | PreToolUse |
|
|
21
21
|
| [Git](#git) | block-push-master, block-work-on-main, block-force-push, warn-git-amend, warn-git-stash-drop, warn-all-files-staged | PreToolUse |
|
|
22
22
|
| [数据库](#database) | warn-destructive-sql, warn-schema-alteration | PreToolUse |
|
|
23
23
|
| [警告](#warnings) | warn-large-file-write, warn-package-publish, warn-background-process, warn-global-package-install | PreToolUse |
|
|
24
|
+
| [包管理器](#package-managers) | prefer-package-manager | PreToolUse |
|
|
24
25
|
| [工作流](#workflow) | require-commit-before-stop, require-push-before-stop, require-pr-before-stop, require-ci-green-before-stop | Stop |
|
|
25
26
|
|
|
26
|
-
- **`block-`** —
|
|
27
|
-
- **`warn-`** —
|
|
28
|
-
- **`sanitize-`** —
|
|
29
|
-
- **`require-`** —
|
|
27
|
+
- **`block-`** — 阻止 Agent 继续执行。
|
|
28
|
+
- **`warn-`** — 为 Agent 提供额外上下文,使其能够自我纠正。
|
|
29
|
+
- **`sanitize-`** — 在 Agent 看到工具输出之前,从中清除敏感数据。
|
|
30
|
+
- **`require-`** — 在条件满足之前阻断 Stop 事件。
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
33
34
|
<Tip>
|
|
34
|
-
|
|
35
|
+
每条策略都支持在 `policyParams` 中设置可选的 `hint` 字段。该提示会追加到 Claude 看到的 deny 或 instruct 消息中,提供可操作的指导,无需修改策略代码。适用于内置策略、自定义策略和约定策略。详见 [配置 → hint](/zh/configuration#hint-cross-cutting)。
|
|
35
36
|
</Tip>
|
|
36
37
|
|
|
37
38
|
---
|
|
38
39
|
|
|
39
|
-
## 危险命令
|
|
40
|
+
## 危险命令 {#dangerous-commands}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
防止 Agent 执行难以撤销或可能损坏宿主系统的操作。
|
|
42
43
|
|
|
43
44
|
### `block-sudo`
|
|
44
45
|
|
|
45
46
|
**事件:** PreToolUse (Bash)
|
|
46
|
-
**默认行为:**
|
|
47
|
+
**默认行为:** 拒绝所有包含 `sudo` 关键字的命令。
|
|
47
48
|
|
|
48
|
-
拦截包含 `sudo`
|
|
49
|
+
拦截包含 `sudo` 关键字的调用。模式匹配基于解析后的命令 token,而非原始字符串,以防止通过 Shell 操作符注入来绕过检测。
|
|
49
50
|
|
|
50
51
|
**参数:**
|
|
51
52
|
|
|
52
53
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
53
54
|
|------|------|--------|------|
|
|
54
|
-
| `allowPatterns` | `string[]` | `[]` |
|
|
55
|
+
| `allowPatterns` | `string[]` | `[]` | 允许通过的精确命令前缀。每个条目与解析后的 argv token 进行匹配。 |
|
|
55
56
|
|
|
56
57
|
**示例:**
|
|
57
58
|
|
|
@@ -65,10 +66,10 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
65
66
|
}
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
使用此配置,`sudo systemctl status nginx`
|
|
69
|
+
使用此配置,`sudo systemctl status nginx` 将被允许,而 `sudo rm /etc/hosts` 将被拒绝。
|
|
69
70
|
|
|
70
71
|
<Note>
|
|
71
|
-
|
|
72
|
+
模式匹配基于解析后的 token,而非原始命令字符串。这可以防止通过附加 Shell 操作符来绕过检测(例如,`sudo systemctl status x; rm -rf /` 不会匹配 `sudo systemctl status *`)。
|
|
72
73
|
</Note>
|
|
73
74
|
|
|
74
75
|
---
|
|
@@ -82,7 +83,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
82
83
|
|
|
83
84
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
84
85
|
|------|------|--------|------|
|
|
85
|
-
| `allowPaths` | `string[]` | `[]` |
|
|
86
|
+
| `allowPaths` | `string[]` | `[]` | 允许递归删除的安全路径(如 `/tmp`)。 |
|
|
86
87
|
|
|
87
88
|
**示例:**
|
|
88
89
|
|
|
@@ -110,20 +111,20 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
110
111
|
### `block-failproofai-commands`
|
|
111
112
|
|
|
112
113
|
**事件:** PreToolUse (Bash)
|
|
113
|
-
**默认行为:**
|
|
114
|
+
**默认行为:** 拒绝可能卸载或禁用 failproofai 自身的命令(如 `npm uninstall failproofai`、`failproofai policies --uninstall`)。
|
|
114
115
|
|
|
115
116
|
无参数。
|
|
116
117
|
|
|
117
118
|
---
|
|
118
119
|
|
|
119
|
-
##
|
|
120
|
+
## 密钥(清理器){#secrets-sanitizers}
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
防止 Agent 将凭证泄露到其上下文或输出中。清理器策略在 **PostToolUse** 事件上触发。当 Claude 运行 Bash 命令、读取文件或调用任何工具时,这些策略会在输出返回给 Claude 之前对其进行检查。若检测到密钥模式,策略将返回 deny 决策,阻止输出被传回。
|
|
122
123
|
|
|
123
124
|
### `sanitize-jwt`
|
|
124
125
|
|
|
125
126
|
**事件:** PostToolUse(所有工具)
|
|
126
|
-
**默认行为:**
|
|
127
|
+
**默认行为:** 脱敏 JWT token(三段由 `.` 分隔的 base64url 字符串)。
|
|
127
128
|
|
|
128
129
|
无参数。
|
|
129
130
|
|
|
@@ -132,7 +133,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
132
133
|
### `sanitize-api-keys`
|
|
133
134
|
|
|
134
135
|
**事件:** PostToolUse(所有工具)
|
|
135
|
-
**默认行为:**
|
|
136
|
+
**默认行为:** 脱敏常见 API Key 格式:Anthropic(`sk-ant-`)、OpenAI(`sk-`)、GitHub PAT(`ghp_`)、AWS Access Key(`AKIA`)、Stripe Key(`sk_live_`、`sk_test_`)以及 Google API Key(`AIza`)。
|
|
136
137
|
|
|
137
138
|
**参数:**
|
|
138
139
|
|
|
@@ -160,7 +161,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
160
161
|
### `sanitize-connection-strings`
|
|
161
162
|
|
|
162
163
|
**事件:** PostToolUse(所有工具)
|
|
163
|
-
**默认行为:**
|
|
164
|
+
**默认行为:** 脱敏包含内嵌凭证的数据库连接字符串(如 `postgresql://user:password@host/db`)。
|
|
164
165
|
|
|
165
166
|
无参数。
|
|
166
167
|
|
|
@@ -169,7 +170,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
169
170
|
### `sanitize-private-key-content`
|
|
170
171
|
|
|
171
172
|
**事件:** PostToolUse(所有工具)
|
|
172
|
-
**默认行为:**
|
|
173
|
+
**默认行为:** 脱敏 PEM 块(`-----BEGIN PRIVATE KEY-----`、`-----BEGIN RSA PRIVATE KEY-----` 等)。
|
|
173
174
|
|
|
174
175
|
无参数。
|
|
175
176
|
|
|
@@ -178,22 +179,22 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
178
179
|
### `sanitize-bearer-tokens`
|
|
179
180
|
|
|
180
181
|
**事件:** PostToolUse(所有工具)
|
|
181
|
-
**默认行为:**
|
|
182
|
+
**默认行为:** 脱敏 `Authorization: Bearer <token>` 请求头中长度大于等于 20 个字符的 token。
|
|
182
183
|
|
|
183
184
|
无参数。
|
|
184
185
|
|
|
185
186
|
---
|
|
186
187
|
|
|
187
|
-
## 环境
|
|
188
|
+
## 环境 {#environment}
|
|
188
189
|
|
|
189
|
-
|
|
190
|
+
保护敏感的环境配置,防止 Agent 读取或暴露这些信息。
|
|
190
191
|
|
|
191
192
|
### `block-env-files`
|
|
192
193
|
|
|
193
|
-
**事件:** PreToolUse
|
|
194
|
-
**默认行为:** 拒绝通过 `cat .env
|
|
194
|
+
**事件:** PreToolUse (Bash, Read)
|
|
195
|
+
**默认行为:** 拒绝通过 `cat .env`、文件路径为 `.env` 的 `Read` 工具调用等方式读取 `.env` 文件。
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
不拦截 `.envrc` 或其他相关环境文件,仅拦截名称严格为 `.env` 的文件。
|
|
197
198
|
|
|
198
199
|
无参数。
|
|
199
200
|
|
|
@@ -201,27 +202,27 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
201
202
|
|
|
202
203
|
### `protect-env-vars`
|
|
203
204
|
|
|
204
|
-
**事件:** PreToolUse
|
|
205
|
+
**事件:** PreToolUse (Bash)
|
|
205
206
|
**默认行为:** 拒绝打印环境变量的命令:`printenv`、`env`、`echo $VAR`。
|
|
206
207
|
|
|
207
208
|
无参数。
|
|
208
209
|
|
|
209
210
|
---
|
|
210
211
|
|
|
211
|
-
## 文件访问
|
|
212
|
+
## 文件访问 {#file-access}
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
将 Agent 限制在项目目录内,并使其远离敏感文件。
|
|
214
215
|
|
|
215
216
|
### `block-read-outside-cwd`
|
|
216
217
|
|
|
217
|
-
**事件:** PreToolUse
|
|
218
|
-
**默认行为:**
|
|
218
|
+
**事件:** PreToolUse (Read, Bash)
|
|
219
|
+
**默认行为:** 拒绝读取当前工作目录(项目根目录)之外的文件。
|
|
219
220
|
|
|
220
221
|
**参数:**
|
|
221
222
|
|
|
222
223
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
223
224
|
|------|------|--------|------|
|
|
224
|
-
| `allowPaths` | `string[]` | `[]` |
|
|
225
|
+
| `allowPaths` | `string[]` | `[]` | 即使在当前工作目录之外也允许访问的绝对路径前缀。 |
|
|
225
226
|
|
|
226
227
|
**示例:**
|
|
227
228
|
|
|
@@ -239,14 +240,14 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
239
240
|
|
|
240
241
|
### `block-secrets-write`
|
|
241
242
|
|
|
242
|
-
**事件:** PreToolUse
|
|
243
|
-
**默认行为:**
|
|
243
|
+
**事件:** PreToolUse (Write, Edit)
|
|
244
|
+
**默认行为:** 拒绝写入常用于存储私钥和证书的文件:`id_rsa`、`id_ed25519`、`*.key`、`*.pem`、`*.p12`、`*.pfx`。
|
|
244
245
|
|
|
245
246
|
**参数:**
|
|
246
247
|
|
|
247
248
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
248
249
|
|------|------|--------|------|
|
|
249
|
-
| `additionalPatterns` | `string[]` | `[]` |
|
|
250
|
+
| `additionalPatterns` | `string[]` | `[]` | 额外需要拦截的文件名模式(glob 风格)。 |
|
|
250
251
|
|
|
251
252
|
**示例:**
|
|
252
253
|
|
|
@@ -262,13 +263,13 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
262
263
|
|
|
263
264
|
---
|
|
264
265
|
|
|
265
|
-
## Git
|
|
266
|
+
## Git {#git}
|
|
266
267
|
|
|
267
|
-
|
|
268
|
+
防止意外推送、强制推送以及难以撤销的分支操作失误。
|
|
268
269
|
|
|
269
270
|
### `block-push-master`
|
|
270
271
|
|
|
271
|
-
**事件:** PreToolUse
|
|
272
|
+
**事件:** PreToolUse (Bash)
|
|
272
273
|
**默认行为:** 拒绝 `git push origin main` 和 `git push origin master`。
|
|
273
274
|
|
|
274
275
|
**参数:**
|
|
@@ -290,14 +291,14 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
290
291
|
```
|
|
291
292
|
|
|
292
293
|
<Tip>
|
|
293
|
-
|
|
294
|
+
若要允许推送到所有分支(即在不将其从 `enabledPolicies` 中移除的情况下有效禁用此策略),可将 `protectedBranches` 设为 `[]`。
|
|
294
295
|
</Tip>
|
|
295
296
|
|
|
296
297
|
---
|
|
297
298
|
|
|
298
299
|
### `block-work-on-main`
|
|
299
300
|
|
|
300
|
-
**事件:** PreToolUse
|
|
301
|
+
**事件:** PreToolUse (Bash)
|
|
301
302
|
**默认行为:** 拒绝直接切换到 `main` 或 `master` 分支。
|
|
302
303
|
|
|
303
304
|
**参数:**
|
|
@@ -310,10 +311,10 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
310
311
|
|
|
311
312
|
### `block-force-push`
|
|
312
313
|
|
|
313
|
-
**事件:** PreToolUse
|
|
314
|
+
**事件:** PreToolUse (Bash)
|
|
314
315
|
**默认行为:** 拒绝 `git push --force` 和 `git push -f`。
|
|
315
316
|
|
|
316
|
-
|
|
317
|
+
无策略特定参数。可使用通用 [`hint`](/zh/configuration#hint-cross-cutting) 建议替代方案:
|
|
317
318
|
|
|
318
319
|
```json
|
|
319
320
|
{
|
|
@@ -329,8 +330,8 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
329
330
|
|
|
330
331
|
### `warn-git-amend`
|
|
331
332
|
|
|
332
|
-
**事件:** PreToolUse
|
|
333
|
-
**默认行为:** 在运行 `git commit --amend` 时指示 Claude
|
|
333
|
+
**事件:** PreToolUse (Bash)
|
|
334
|
+
**默认行为:** 在运行 `git commit --amend` 时指示 Claude 谨慎操作。不阻止该命令执行。
|
|
334
335
|
|
|
335
336
|
无参数。
|
|
336
337
|
|
|
@@ -338,8 +339,8 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
338
339
|
|
|
339
340
|
### `warn-git-stash-drop`
|
|
340
341
|
|
|
341
|
-
**事件:** PreToolUse
|
|
342
|
-
**默认行为:** 在运行 `git stash drop` 前指示 Claude
|
|
342
|
+
**事件:** PreToolUse (Bash)
|
|
343
|
+
**默认行为:** 在运行 `git stash drop` 前指示 Claude 进行确认。不阻止该命令执行。
|
|
343
344
|
|
|
344
345
|
无参数。
|
|
345
346
|
|
|
@@ -347,21 +348,21 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
347
348
|
|
|
348
349
|
### `warn-all-files-staged`
|
|
349
350
|
|
|
350
|
-
**事件:** PreToolUse
|
|
351
|
-
**默认行为:** 在运行 `git add -A` 或 `git add .` 时指示 Claude
|
|
351
|
+
**事件:** PreToolUse (Bash)
|
|
352
|
+
**默认行为:** 在运行 `git add -A` 或 `git add .` 时指示 Claude 检查其所暂存的内容。不阻止该命令执行。
|
|
352
353
|
|
|
353
354
|
无参数。
|
|
354
355
|
|
|
355
356
|
---
|
|
356
357
|
|
|
357
|
-
## 数据库
|
|
358
|
+
## 数据库 {#database}
|
|
358
359
|
|
|
359
|
-
在破坏性 SQL
|
|
360
|
+
在破坏性 SQL 操作对数据库执行之前将其拦截。
|
|
360
361
|
|
|
361
362
|
### `warn-destructive-sql`
|
|
362
363
|
|
|
363
|
-
**事件:** PreToolUse
|
|
364
|
-
**默认行为:** 在运行包含 `DROP TABLE`、`DROP DATABASE` 或不带 `WHERE` 子句的 `DELETE` 的 SQL
|
|
364
|
+
**事件:** PreToolUse (Bash)
|
|
365
|
+
**默认行为:** 在运行包含 `DROP TABLE`、`DROP DATABASE` 或不带 `WHERE` 子句的 `DELETE` 的 SQL 之前,指示 Claude 进行确认。
|
|
365
366
|
|
|
366
367
|
无参数。
|
|
367
368
|
|
|
@@ -369,21 +370,21 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
369
370
|
|
|
370
371
|
### `warn-schema-alteration`
|
|
371
372
|
|
|
372
|
-
**事件:** PreToolUse
|
|
373
|
+
**事件:** PreToolUse (Bash)
|
|
373
374
|
**默认行为:** 在运行 `ALTER TABLE` 语句之前,指示 Claude 进行确认。
|
|
374
375
|
|
|
375
376
|
无参数。
|
|
376
377
|
|
|
377
378
|
---
|
|
378
379
|
|
|
379
|
-
## 警告
|
|
380
|
+
## 警告 {#warnings}
|
|
380
381
|
|
|
381
|
-
|
|
382
|
+
在执行潜在有风险但非破坏性的操作前,为 Agent 提供额外上下文。
|
|
382
383
|
|
|
383
384
|
### `warn-large-file-write`
|
|
384
385
|
|
|
385
|
-
**事件:** PreToolUse
|
|
386
|
-
**默认行为:**
|
|
386
|
+
**事件:** PreToolUse (Write)
|
|
387
|
+
**默认行为:** 在写入大于 1024 KB 的文件之前,指示 Claude 进行确认。
|
|
387
388
|
|
|
388
389
|
**参数:**
|
|
389
390
|
|
|
@@ -404,14 +405,14 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
404
405
|
```
|
|
405
406
|
|
|
406
407
|
<Note>
|
|
407
|
-
|
|
408
|
+
Hook 处理器对 stdin 负载强制执行 1 MB 的大小限制。若要使用较小内容测试此策略,请将 `thresholdKb` 设为远低于 1024 的值。
|
|
408
409
|
</Note>
|
|
409
410
|
|
|
410
411
|
---
|
|
411
412
|
|
|
412
413
|
### `warn-package-publish`
|
|
413
414
|
|
|
414
|
-
**事件:** PreToolUse
|
|
415
|
+
**事件:** PreToolUse (Bash)
|
|
415
416
|
**默认行为:** 在运行 `npm publish` 之前,指示 Claude 进行确认。
|
|
416
417
|
|
|
417
418
|
无参数。
|
|
@@ -420,7 +421,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
420
421
|
|
|
421
422
|
### `warn-background-process`
|
|
422
423
|
|
|
423
|
-
**事件:** PreToolUse
|
|
424
|
+
**事件:** PreToolUse (Bash)
|
|
424
425
|
**默认行为:** 在通过 `nohup`、`&`、`disown` 或 `screen` 启动后台进程时,指示 Claude 谨慎操作。
|
|
425
426
|
|
|
426
427
|
无参数。
|
|
@@ -429,36 +430,72 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
429
430
|
|
|
430
431
|
### `warn-global-package-install`
|
|
431
432
|
|
|
432
|
-
**事件:** PreToolUse
|
|
433
|
+
**事件:** PreToolUse (Bash)
|
|
433
434
|
**默认行为:** 在运行 `npm install -g`、`yarn global add` 或未在虚拟环境中执行的 `pip install` 之前,指示 Claude 进行确认。
|
|
434
435
|
|
|
435
436
|
无参数。
|
|
436
437
|
|
|
437
438
|
---
|
|
438
439
|
|
|
440
|
+
## 包管理器 {#package-managers}
|
|
441
|
+
|
|
442
|
+
限制 Agent 只能使用指定的包管理器。
|
|
443
|
+
|
|
444
|
+
### `prefer-package-manager`
|
|
445
|
+
|
|
446
|
+
**事件:** PreToolUse (Bash)
|
|
447
|
+
**默认行为:** 默认禁用。启用后,将拦截不在 `allowed` 列表中的任何包管理器命令,并告知 Claude 使用允许的包管理器重写该命令。
|
|
448
|
+
|
|
449
|
+
可检测的包管理器:pip, pip3, python -m pip, npm, npx, yarn, pnpm, pnpx, bun, bunx, uv, poetry, pipenv, conda, cargo。
|
|
450
|
+
|
|
451
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
452
|
+
|------|------|--------|------|
|
|
453
|
+
| `allowed` | string[] | `[]` | 允许使用的包管理器名称。检测到的管理器若不在此列表中将被拦截。列表为空时,策略不生效。 |
|
|
454
|
+
| `blocked` | string[] | `[]` | 除内置列表之外需要额外拦截的包管理器名称(如 `['pdm', 'pipx']`)。 |
|
|
455
|
+
|
|
456
|
+
内置拦截列表包含:pip, pip3, npm, npx, yarn, pnpm, pnpx, bun, bunx, uv, poetry, pipenv, conda, cargo。使用 `blocked` 可追加不在此列表中的包管理器。
|
|
457
|
+
|
|
458
|
+
**示例配置:**
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"enabledPolicies": ["prefer-package-manager"],
|
|
463
|
+
"policyParams": {
|
|
464
|
+
"prefer-package-manager": {
|
|
465
|
+
"allowed": ["uv", "bun"],
|
|
466
|
+
"blocked": ["pdm", "pipx"]
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
使用此配置,`pip install flask` 和 `pdm install flask` 均会被拒绝,并告知 Claude 改用 `uv` 或 `bun`。而 `uv pip install flask` 则会被允许,因为 `uv` 在允许列表中且优先检查。
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
439
476
|
## AI 行为
|
|
440
477
|
|
|
441
|
-
|
|
478
|
+
检测 Agent 陷入循环或行为异常的情况。
|
|
442
479
|
|
|
443
480
|
### `warn-repeated-tool-calls`
|
|
444
481
|
|
|
445
482
|
**事件:** PreToolUse(所有工具)
|
|
446
|
-
**默认行为:** 当同一工具以相同参数被调用 3 次或以上时,指示 Claude
|
|
483
|
+
**默认行为:** 当同一工具以相同参数被调用 3 次或以上时,指示 Claude 重新考虑——这通常是 Agent 陷入循环的信号。
|
|
447
484
|
|
|
448
485
|
无参数。
|
|
449
486
|
|
|
450
487
|
---
|
|
451
488
|
|
|
452
|
-
## 工作流
|
|
489
|
+
## 工作流 {#workflow}
|
|
453
490
|
|
|
454
|
-
|
|
491
|
+
强制执行有纪律的会话结束工作流。这些策略在 **Stop** 事件上触发,在每个条件满足之前拒绝 Claude 停止。它们遵循自然的依赖链:commit → push → PR → CI。若某条策略拒绝,则链中后续策略将被跳过(deny 短路)。
|
|
455
492
|
|
|
456
|
-
所有工作流策略均为**失败开放(fail-open
|
|
493
|
+
所有工作流策略均为**失败开放(fail-open)**模式:如果所需工具不可用(如 `gh` 未安装、无 git 远程仓库),策略将放行并附带说明性消息,解释跳过检查的原因。
|
|
457
494
|
|
|
458
495
|
### `require-commit-before-stop`
|
|
459
496
|
|
|
460
497
|
**事件:** Stop
|
|
461
|
-
**默认行为:**
|
|
498
|
+
**默认行为:** 当存在未提交的更改(已修改、已暂存或未跟踪的文件)时,拒绝停止。当工作目录干净时,返回说明性消息。
|
|
462
499
|
|
|
463
500
|
无参数。
|
|
464
501
|
|
|
@@ -467,13 +504,13 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
467
504
|
### `require-push-before-stop`
|
|
468
505
|
|
|
469
506
|
**事件:** Stop
|
|
470
|
-
**默认行为:**
|
|
507
|
+
**默认行为:** 当存在未推送的 commit,或当前分支没有远程追踪分支时,拒绝停止。若需要,建议使用 `git push -u` 创建追踪分支。如果未配置远程仓库,则失败开放。
|
|
471
508
|
|
|
472
509
|
**参数:**
|
|
473
510
|
|
|
474
511
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
475
512
|
|------|------|--------|------|
|
|
476
|
-
| `remote` | `string` | `"origin"` |
|
|
513
|
+
| `remote` | `string` | `"origin"` | 推送目标的远程仓库名称。 |
|
|
477
514
|
|
|
478
515
|
**示例:**
|
|
479
516
|
|
|
@@ -492,13 +529,12 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
492
529
|
### `require-pr-before-stop`
|
|
493
530
|
|
|
494
531
|
**事件:** Stop
|
|
495
|
-
**默认行为:**
|
|
532
|
+
**默认行为:** 当当前分支不存在 Pull Request,或现有 PR 已关闭/已合并时,拒绝停止。指示 Claude 使用 `gh pr create` 创建 PR。
|
|
496
533
|
|
|
497
534
|
无参数。
|
|
498
535
|
|
|
499
536
|
<Note>
|
|
500
|
-
|
|
501
|
-
请使用具有 `repo` 权限范围(用于读取拉取请求)的个人访问令牌运行 `gh auth login`。若 `gh` 未安装或未完成身份验证,策略将以开放方式失败,并向 Claude 报告原因。
|
|
537
|
+
此策略需要安装并已完成身份验证的 [GitHub CLI](https://cli.github.com/)(`gh`)。请使用具有 `repo` 作用域(用于读取 Pull Request)的个人访问 token 运行 `gh auth login`。如果 `gh` 未安装或未完成身份验证,策略将失败开放并向 Claude 报告原因。
|
|
502
538
|
</Note>
|
|
503
539
|
|
|
504
540
|
---
|
|
@@ -506,13 +542,12 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
506
542
|
### `require-ci-green-before-stop`
|
|
507
543
|
|
|
508
544
|
**事件:** Stop
|
|
509
|
-
**默认行为:**
|
|
545
|
+
**默认行为:** 当当前分支上的 CI 检查失败或仍在运行时,拒绝停止。同时检查 GitHub Actions 工作流运行状态和第三方 Bot 检查(如 CodeRabbit、SonarCloud、Codecov)。将 `skipped` 和 `cancelled` 结论视为成功。所有检查通过时,返回说明性消息。
|
|
510
546
|
|
|
511
547
|
无参数。
|
|
512
548
|
|
|
513
549
|
<Note>
|
|
514
|
-
|
|
515
|
-
请使用具有 `repo` 权限范围(用于读取 Actions 工作流运行和 Checks API)的个人访问令牌运行 `gh auth login`。若 `gh` 未安装或未完成身份验证,策略将以开放方式失败,并向 Claude 报告原因。
|
|
550
|
+
此策略需要安装并已完成身份验证的 [GitHub CLI](https://cli.github.com/)(`gh`)。请使用具有 `repo` 作用域(用于读取 Actions 工作流运行状态和 Checks API)的个人访问 token 运行 `gh auth login`。如果 `gh` 未安装或未完成身份验证,策略将失败开放并向 Claude 报告原因。
|
|
516
551
|
</Note>
|
|
517
552
|
|
|
518
553
|
---
|
|
@@ -521,7 +556,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
521
556
|
|
|
522
557
|
## 禁用单条策略
|
|
523
558
|
|
|
524
|
-
|
|
559
|
+
从配置文件的 `enabledPolicies` 中移除特定策略,或在控制台的策略标签页中将其关闭。
|
|
525
560
|
|
|
526
561
|
```json
|
|
527
562
|
{
|
|
@@ -532,4 +567,4 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
532
567
|
}
|
|
533
568
|
```
|
|
534
569
|
|
|
535
|
-
未在 `enabledPolicies` 中列出的策略不会运行,即使 `policyParams`
|
|
570
|
+
未在 `enabledPolicies` 中列出的策略不会运行,即使 `policyParams` 中存在对应的条目也不例外。
|