failproofai 0.0.6-beta.1 → 0.0.6-beta.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.
- 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]__0~kmh8w._.js → [root-of-the-server]__05akje6._.js} +2 -2
- 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]__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]__0i5kvry._.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/{08t08igdql9yt.js → 00j0rr7rh8ef8.js} +1 -1
- package/.next/standalone/.next/static/chunks/{12~yi9oj8av8p.js → 05j1px0r8yzh6.js} +2 -2
- package/.next/standalone/.next/static/chunks/{09_k80d~cq2wg.js → 0badv41uxa56..js} +1 -1
- package/.next/standalone/.next/static/chunks/{0wlyoif4_kj_t.js → 0ijk_kek9_wyx.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0bvhsa6zva2o..js → 0ksdlt_1hucdm.js} +1 -1
- package/.next/standalone/.next/static/chunks/{03rz6ykw-a2xi.js → 0npb~873.wvg3.js} +1 -1
- package/.next/standalone/.next/static/chunks/{01b~z8f1ws0rk.js → 0xpl.oscrakvx.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0gbf4cphy8ksq.js → 1052sguyd-.ka.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0v.yd0kg_ld3r.js → 14cl9poem30dq.js} +1 -1
- package/.next/standalone/CHANGELOG.md +11 -0
- package/.next/standalone/dist/cli.mjs +3 -3
- package/.next/standalone/docs/ar/built-in-policies.mdx +124 -87
- 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 +1 -1
- package/.next/standalone/docs/de/built-in-policies.mdx +93 -56
- 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 +115 -78
- 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 +83 -46
- 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 +156 -117
- 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 +101 -60
- 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 +118 -81
- 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 +98 -61
- 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 +137 -100
- 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 +94 -57
- 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 +142 -105
- 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 +104 -67
- 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 +110 -72
- 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 +132 -95
- 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/hooks/builtin-policies.ts +5 -1
- package/dist/cli.mjs +3 -3
- package/package.json +1 -1
- package/src/hooks/builtin-policies.ts +5 -1
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → A9pNTZdoYJTVyPAYwQMx5}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → A9pNTZdoYJTVyPAYwQMx5}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{CkmOT-ZvDN-sVULinGVKT → A9pNTZdoYJTVyPAYwQMx5}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 内置策略
|
|
3
|
-
description: "
|
|
3
|
+
description: "涵盖常见 Agent 故障模式的 30 条内置策略"
|
|
4
4
|
icon: shield
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
failproofai 内置了 30
|
|
7
|
+
failproofai 内置了 30 条策略,用于捕获常见的 Agent 故障模式。每条策略针对特定的钩子事件类型和工具名称触发。九条策略接受参数,让你无需编写代码即可调整其行为。四条工作流策略在 Claude 停止前强制执行 提交 → 推送 → PR → CI 的流水线。
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -13,45 +13,46 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
13
13
|
策略按类别分组:
|
|
14
14
|
|
|
15
15
|
| 类别 | 策略 | 钩子类型 |
|
|
16
|
-
|
|
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-`** — 在条件满足之前阻止 Stop
|
|
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
|
-
|
|
49
|
+
阻止包含 `sudo` 关键字的调用。模式匹配基于解析后的命令词元(token),而非原始字符串,以防止通过 shell 运算符注入绕过检测。
|
|
49
50
|
|
|
50
51
|
**参数:**
|
|
51
52
|
|
|
52
|
-
| 参数 | 类型 | 默认值 |
|
|
53
|
-
|
|
54
|
-
| `allowPatterns` | `string[]` | `[]` |
|
|
53
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
54
|
+
|-------|------|---------|-------------|
|
|
55
|
+
| `allowPatterns` | `string[]` | `[]` | 允许执行的精确命令前缀。每个条目与解析后的 argv 词元进行匹配。 |
|
|
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
|
+
模式匹配基于解析后的词元,而非原始命令字符串。这可以防止通过追加 shell 运算符绕过(例如 `sudo systemctl status x; rm -rf /` 不会匹配 `sudo systemctl status *`)。
|
|
72
73
|
</Note>
|
|
73
74
|
|
|
74
75
|
---
|
|
@@ -80,8 +81,8 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
80
81
|
|
|
81
82
|
**参数:**
|
|
82
83
|
|
|
83
|
-
| 参数 | 类型 | 默认值 |
|
|
84
|
-
|
|
84
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
85
|
+
|-------|------|---------|-------------|
|
|
85
86
|
| `allowPaths` | `string[]` | `[]` | 允许递归删除的安全路径(例如 `/tmp`)。 |
|
|
86
87
|
|
|
87
88
|
**示例:**
|
|
@@ -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 令牌(三段由 `.` 分隔的 base64url 片段)。
|
|
127
128
|
|
|
128
129
|
无参数。
|
|
129
130
|
|
|
@@ -132,13 +133,13 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
132
133
|
### `sanitize-api-keys`
|
|
133
134
|
|
|
134
135
|
**事件:** PostToolUse(所有工具)
|
|
135
|
-
**默认行为:**
|
|
136
|
+
**默认行为:** 脱敏常见 API 密钥格式:Anthropic(`sk-ant-`)、OpenAI(`sk-`)、GitHub PAT(`ghp_`)、AWS 访问密钥(`AKIA`)、Stripe 密钥(`sk_live_`、`sk_test_`)以及 Google API 密钥(`AIza`)。
|
|
136
137
|
|
|
137
138
|
**参数:**
|
|
138
139
|
|
|
139
|
-
| 参数 | 类型 | 默认值 |
|
|
140
|
-
|
|
141
|
-
| `additionalPatterns` | `{ regex: string; label: string }[]` | `[]` |
|
|
140
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
141
|
+
|-------|------|---------|-------------|
|
|
142
|
+
| `additionalPatterns` | `{ regex: string; label: string }[]` | `[]` | 需要视为密钥的额外正则表达式模式。 |
|
|
142
143
|
|
|
143
144
|
**示例:**
|
|
144
145
|
|
|
@@ -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 个字符的令牌。
|
|
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
|
+
**事件:** PreToolUse (Bash, Read)
|
|
194
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
|
-
|
|
224
|
-
| `allowPaths` | `string[]` | `[]` |
|
|
223
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
224
|
+
|-------|------|---------|-------------|
|
|
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
|
+
**事件:** PreToolUse (Write, Edit)
|
|
243
244
|
**默认行为:** 拒绝写入常用于私钥和证书的文件:`id_rsa`、`id_ed25519`、`*.key`、`*.pem`、`*.p12`、`*.pfx`。
|
|
244
245
|
|
|
245
246
|
**参数:**
|
|
246
247
|
|
|
247
|
-
| 参数 | 类型 | 默认值 |
|
|
248
|
-
|
|
249
|
-
| `additionalPatterns` | `string[]` | `[]` |
|
|
248
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
249
|
+
|-------|------|---------|-------------|
|
|
250
|
+
| `additionalPatterns` | `string[]` | `[]` | 需要阻止的额外文件名模式(glob 风格)。 |
|
|
250
251
|
|
|
251
252
|
**示例:**
|
|
252
253
|
|
|
@@ -262,19 +263,19 @@ 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
|
**参数:**
|
|
275
276
|
|
|
276
|
-
| 参数 | 类型 | 默认值 |
|
|
277
|
-
|
|
277
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
278
|
+
|-------|------|---------|-------------|
|
|
278
279
|
| `protectedBranches` | `string[]` | `["main", "master"]` | 不允许直接推送的分支名称。 |
|
|
279
280
|
|
|
280
281
|
**示例:**
|
|
@@ -290,30 +291,30 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
290
291
|
```
|
|
291
292
|
|
|
292
293
|
<Tip>
|
|
293
|
-
若要允许推送到所有分支(即在不从 `enabledPolicies`
|
|
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
|
**参数:**
|
|
304
305
|
|
|
305
|
-
| 参数 | 类型 | 默认值 |
|
|
306
|
-
|
|
306
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
307
|
+
|-------|------|---------|-------------|
|
|
307
308
|
| `protectedBranches` | `string[]` | `["main", "master"]` | 不允许直接切换的分支名称。 |
|
|
308
309
|
|
|
309
310
|
---
|
|
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
|
-
**默认行为:**
|
|
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`
|
|
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
|
-
**默认行为:**
|
|
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,26 +370,26 @@ 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
|
|
|
390
|
-
| 参数 | 类型 | 默认值 |
|
|
391
|
-
|
|
391
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
392
|
+
|-------|------|---------|-------------|
|
|
392
393
|
| `thresholdKb` | `number` | `1024` | 触发警告的文件大小阈值(单位:KB)。 |
|
|
393
394
|
|
|
394
395
|
**示例:**
|
|
@@ -404,14 +405,14 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
404
405
|
```
|
|
405
406
|
|
|
406
407
|
<Note>
|
|
407
|
-
|
|
408
|
+
钩子处理器对 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,8 +421,8 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
420
421
|
|
|
421
422
|
### `warn-background-process`
|
|
422
423
|
|
|
423
|
-
**事件:** PreToolUse
|
|
424
|
-
**默认行为:**
|
|
424
|
+
**事件:** PreToolUse (Bash)
|
|
425
|
+
**默认行为:** 当通过 `nohup`、`&`、`disown` 或 `screen` 启动后台进程时,指示 Claude 保持谨慎。
|
|
425
426
|
|
|
426
427
|
无参数。
|
|
427
428
|
|
|
@@ -429,36 +430,72 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
429
430
|
|
|
430
431
|
### `warn-global-package-install`
|
|
431
432
|
|
|
432
|
-
**事件:** PreToolUse
|
|
433
|
-
**默认行为:** 在运行 `npm install -g`、`yarn global add`
|
|
433
|
+
**事件:** PreToolUse (Bash)
|
|
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
|
-
**默认行为:**
|
|
483
|
+
**默认行为:** 当同一工具以完全相同的参数被调用 3 次及以上时,指示 Claude 重新考虑——这通常是 Agent 陷入循环的常见信号。
|
|
447
484
|
|
|
448
485
|
无参数。
|
|
449
486
|
|
|
450
487
|
---
|
|
451
488
|
|
|
452
|
-
## 工作流
|
|
489
|
+
## 工作流 {#workflow}
|
|
453
490
|
|
|
454
|
-
|
|
491
|
+
强制执行规范的会话结束工作流。这些策略在 **Stop** 事件上触发,在每个条件满足之前拒绝 Claude 停止。它们遵循自然的依赖链:提交 → 推送 → PR → CI。如果某条策略返回 deny,则链中后续策略会被跳过(deny 短路)。
|
|
455
492
|
|
|
456
|
-
|
|
493
|
+
所有工作流策略都是**失败开放**的:如果所需工具不可用(例如未安装 `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
|
+
**默认行为:** 当存在未推送的提交,或当前分支没有远程追踪分支时,拒绝停止。如需创建追踪分支,建议使用 `git push -u`。若未配置远程仓库,则失败开放。
|
|
471
508
|
|
|
472
509
|
**参数:**
|
|
473
510
|
|
|
474
|
-
| 参数 | 类型 | 默认值 |
|
|
475
|
-
|
|
476
|
-
| `remote` | `string` | `"origin"` |
|
|
511
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
512
|
+
|-------|------|---------|-------------|
|
|
513
|
+
| `remote` | `string` | `"origin"` | 推送目标的远程仓库名称。 |
|
|
477
514
|
|
|
478
515
|
**示例:**
|
|
479
516
|
|
|
@@ -492,13 +529,13 @@ 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
537
|
此策略需要安装并完成身份验证的 [GitHub CLI](https://cli.github.com/)(`gh`)。
|
|
501
|
-
|
|
538
|
+
运行 `gh auth login` 时,请使用具有 `repo` 权限(用于读取 Pull Request)的个人访问令牌。若 `gh` 未安装或未通过身份验证,该策略会失败开放并向 Claude 报告原因。
|
|
502
539
|
</Note>
|
|
503
540
|
|
|
504
541
|
---
|
|
@@ -506,13 +543,13 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
506
543
|
### `require-ci-green-before-stop`
|
|
507
544
|
|
|
508
545
|
**事件:** Stop
|
|
509
|
-
**默认行为:** 当当前分支的 CI 检查失败或仍在运行时,拒绝停止。同时检查 GitHub Actions 工作流运行和第三方机器人检查(例如 CodeRabbit、SonarCloud、Codecov)。将 `skipped`
|
|
546
|
+
**默认行为:** 当当前分支的 CI 检查失败或仍在运行时,拒绝停止。同时检查 GitHub Actions 工作流运行和第三方机器人检查(例如 CodeRabbit、SonarCloud、Codecov)。将 `skipped` 结论视为成功。所有检查通过时返回说明性消息。
|
|
510
547
|
|
|
511
548
|
无参数。
|
|
512
549
|
|
|
513
550
|
<Note>
|
|
514
551
|
此策略需要安装并完成身份验证的 [GitHub CLI](https://cli.github.com/)(`gh`)。
|
|
515
|
-
|
|
552
|
+
运行 `gh auth login` 时,请使用具有 `repo` 权限(用于读取 Actions 工作流运行和 Checks API)的个人访问令牌。若 `gh` 未安装或未通过身份验证,该策略会失败开放并向 Claude 报告原因。
|
|
516
553
|
</Note>
|
|
517
554
|
|
|
518
555
|
---
|
|
@@ -521,7 +558,7 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
521
558
|
|
|
522
559
|
## 禁用单条策略
|
|
523
560
|
|
|
524
|
-
|
|
561
|
+
从配置文件的 `enabledPolicies` 中移除特定策略,或在控制台的"策略"标签页中将其关闭。
|
|
525
562
|
|
|
526
563
|
```json
|
|
527
564
|
{
|
|
@@ -532,4 +569,4 @@ failproofai 内置了 30 条策略,用于捕获常见的代理失败模式。
|
|
|
532
569
|
}
|
|
533
570
|
```
|
|
534
571
|
|
|
535
|
-
|
|
572
|
+
未列在 `enabledPolicies` 中的策略不会运行,即使在 `policyParams` 中存在对应的条目也不例外。
|