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,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
---
|
|
3
3
|
title: السياسات المخصصة
|
|
4
|
-
description: "اكتب سياساتك الخاصة بلغة JavaScript - فرض
|
|
4
|
+
description: "اكتب سياساتك الخاصة بلغة JavaScript - فرض الاتفاقيات ومنع الانجراف والكشف عن الأعطال والتكامل مع الأنظمة الخارجية"
|
|
5
5
|
icon: code
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
تتيح لك السياسات المخصصة كتابة قواعد لأي سلوك وكيل: فرض اتفاقيات
|
|
8
|
+
تتيح لك السياسات المخصصة كتابة قواعد لأي سلوك وكيل: فرض اتفاقيات المشروع ومنع الانجراف والتحكم في العمليات المدمرة والكشف عن الوكلاء المعلقة أو التكامل مع Slack وسير العمل الموافقة وغيرها. تستخدم نفس نظام أحداث الخطاف وقرارات `allow` و`deny` و`instruct` مثل السياسات المدمجة.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -30,7 +30,7 @@ customPolicies.add({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
ثبتها:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
failproofai policies --install --custom ./my-policies.js
|
|
@@ -40,12 +40,12 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
40
40
|
|
|
41
41
|
## طريقتان لتحميل السياسات المخصصة
|
|
42
42
|
|
|
43
|
-
### الخيار 1: قائم على الاتفاقية (
|
|
43
|
+
### الخيار 1: قائم على الاتفاقية (مُوصى به)
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
أسقط ملفات `*policies.{js,mjs,ts}` في `.failproofai/policies/` وسيتم تحميلها تلقائياً - لا توجد علامات أو تغييرات إعدادات مطلوبة. يعمل هذا مثل خطافات git: أسقط ملف وسيعمل فحسب.
|
|
46
46
|
|
|
47
47
|
```
|
|
48
|
-
#
|
|
48
|
+
# المستوى المشروع — معهود إلى git ومشترك مع الفريق
|
|
49
49
|
.failproofai/policies/security-policies.mjs
|
|
50
50
|
.failproofai/policies/workflow-policies.mjs
|
|
51
51
|
|
|
@@ -54,17 +54,17 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
**كيف يعمل:**
|
|
57
|
-
- يتم
|
|
58
|
-
- يتم تحميل الملفات أبجدياً داخل كل
|
|
59
|
-
- يتم تحميل الملفات المطابقة فقط `*policies.{js,mjs,ts}`؛
|
|
60
|
-
- يتم تحميل كل ملف بشكل مستقل (فتح
|
|
57
|
+
- يتم مسح كلا دليل المشروع والمستخدم (اتحاد - وليس أول نطاق يفوز)
|
|
58
|
+
- يتم تحميل الملفات أبجدياً داخل كل دليل. استخدم البادئة `01-` و`02-` للتحكم في الترتيب
|
|
59
|
+
- يتم تحميل الملفات المطابقة فقط لـ `*policies.{js,mjs,ts}`؛ تُتجاهل الملفات الأخرى
|
|
60
|
+
- يتم تحميل كل ملف بشكل مستقل (فتح مفشول لكل ملف)
|
|
61
61
|
- يعمل جنباً إلى جنب مع السياسات الصريحة `--custom` والمدمجة
|
|
62
62
|
|
|
63
63
|
<Tip>
|
|
64
|
-
سياسات الاتفاقية هي أسهل طريقة
|
|
64
|
+
سياسات الاتفاقية هي أسهل طريقة لبناء معيار جودة لمؤسستك. عهد `.failproofai/policies/` إلى git وكل عضو في الفريق سيحصل على نفس القواعد تلقائياً - لا توجد حاجة لإعداد كل مطور. عندما يكتشف فريقك أنماط أعطال جديدة، أضف سياسة واضغط. بمرور الوقت، تصبح هذه معيار جودة حي يستمر في التحسن مع كل مساهمة.
|
|
65
65
|
</Tip>
|
|
66
66
|
|
|
67
|
-
### الخيار 2: مسار
|
|
67
|
+
### الخيار 2: مسار ملف صريح
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
# التثبيت مع ملف سياسات مخصص
|
|
@@ -73,19 +73,19 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
73
73
|
# استبدل مسار ملف السياسات
|
|
74
74
|
failproofai policies --install --custom ./new-policies.js
|
|
75
75
|
|
|
76
|
-
#
|
|
76
|
+
# أزل مسار السياسات المخصصة من الإعدادات
|
|
77
77
|
failproofai policies --uninstall --custom
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
يتم تخزين المسار المطلق
|
|
80
|
+
يتم تخزين المسار المطلق المحلول في `policies-config.json` كـ `customPoliciesPath`. يتم تحميل الملف بشكل جديد في كل حدث خطاف - لا يوجد تخزين مؤقت بين الأحداث.
|
|
81
81
|
|
|
82
82
|
### استخدام كليهما معاً
|
|
83
83
|
|
|
84
|
-
يمكن أن
|
|
84
|
+
يمكن أن توجد سياسات الاتفاقية وملف `--custom` الصريح معاً. ترتيب التحميل:
|
|
85
85
|
|
|
86
|
-
1. ملف `customPoliciesPath` الصريح (
|
|
87
|
-
2. ملفات
|
|
88
|
-
3. ملفات
|
|
86
|
+
1. ملف `customPoliciesPath` الصريح (إن تم تكوينه)
|
|
87
|
+
2. ملفات اتفاقية المشروع (`{cwd}/.failproofai/policies/`، أبجدياً)
|
|
88
|
+
3. ملفات اتفاقية المستخدم (`~/.failproofai/policies/`، أبجدياً)
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
@@ -99,45 +99,45 @@ import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
|
99
99
|
|
|
100
100
|
### `customPolicies.add(hook)`
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
يسجل سياسة. استدعِ هذا عدة مرات حسب الحاجة لسياسات متعددة في نفس الملف.
|
|
103
103
|
|
|
104
104
|
```ts
|
|
105
105
|
customPolicies.add({
|
|
106
|
-
name: string; //
|
|
107
|
-
description?: string; //
|
|
108
|
-
match?: { events?: HookEventType[] }; //
|
|
106
|
+
name: string; // مطلوب - معرّف فريد
|
|
107
|
+
description?: string; // معروض في إخراج `failproofai policies`
|
|
108
|
+
match?: { events?: HookEventType[] }; // تصفية حسب نوع الحدث؛ احذف للمطابقة مع الكل
|
|
109
109
|
fn: (ctx: PolicyContext) => PolicyResult | Promise<PolicyResult>;
|
|
110
110
|
});
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
###
|
|
113
|
+
### مساعدات القرار
|
|
114
114
|
|
|
115
115
|
| الدالة | التأثير | استخدم عندما |
|
|
116
116
|
|----------|--------|----------|
|
|
117
|
-
| `allow()` | السماح بالعملية بصمت | الإجراء آمن، لا توجد
|
|
118
|
-
| `deny(message)` |
|
|
117
|
+
| `allow()` | السماح بالعملية بصمت | الإجراء آمن، لا توجد حاجة لرسالة |
|
|
118
|
+
| `deny(message)` | حجب العملية | لا يجب على الوكيل اتخاذ هذا الإجراء |
|
|
119
119
|
| `instruct(message)` | إضافة سياق بدون حجب | أعط الوكيل سياق إضافي للبقاء على المسار |
|
|
120
120
|
|
|
121
|
-
`deny(message)` - تظهر الرسالة لـ Claude مع البادئة `"Blocked by failproofai:"`. يؤدي
|
|
121
|
+
`deny(message)` - تظهر الرسالة لـ Claude مع البادئة `"Blocked by failproofai:"`. يؤدي رفض واحد إلى قطع جميع التقييمات الإضافية.
|
|
122
122
|
|
|
123
|
-
`instruct(message)` - يتم إلحاق الرسالة بسياق Claude
|
|
123
|
+
`instruct(message)` - يتم إلحاق الرسالة بسياق Claude لاستدعاء الأداة الحالي. يتم تجميع جميع رسائل `instruct` وتسليمها معاً.
|
|
124
124
|
|
|
125
125
|
<Tip>
|
|
126
|
-
يمكنك
|
|
126
|
+
يمكنك إضافة إرشادات إضافية إلى أي رسالة `deny` أو `instruct` بإضافة حقل `hint` في `policyParams` - لا حاجة لتغيير الكود. هذا يعمل مع السياسات المخصصة (`custom/`) واتفاقية المشروع (`.failproofai-project/`) واتفاقية المستخدم (`.failproofai-user/`) أيضاً. انظر [Configuration → hint](/ar/configuration#hint-cross-cutting) للتفاصيل.
|
|
127
127
|
</Tip>
|
|
128
128
|
|
|
129
129
|
### رسائل السماح المعلوماتية
|
|
130
130
|
|
|
131
|
-
`allow(message)` يسمح بالعملية **و** يرسل رسالة معلوماتية مرة أخرى إلى Claude. يتم تسليم الرسالة كـ `additionalContext` في استجابة stdout
|
|
131
|
+
`allow(message)` يسمح بالعملية **و** يرسل رسالة معلوماتية مرة أخرى إلى Claude. يتم تسليم الرسالة كـ `additionalContext` في استجابة stdout لمعالج الخطاف - نفس الآلية المستخدمة بـ `instruct`، لكن مختلفة دلالياً: إنها تحديث حالة وليس تحذير.
|
|
132
132
|
|
|
133
133
|
| الدالة | التأثير | استخدم عندما |
|
|
134
134
|
|----------|--------|----------|
|
|
135
|
-
| `allow(message)` | السماح وإرسال
|
|
135
|
+
| `allow(message)` | السماح وإرسال سياق إلى Claude | تأكيد اجتياز الفحص أو شرح السبب في تخطي الفحص |
|
|
136
136
|
|
|
137
137
|
حالات الاستخدام:
|
|
138
|
-
- **تأكيدات الحالة:** `allow("All CI checks passed.")`
|
|
139
|
-
-
|
|
140
|
-
- **تراكم رسائل متعددة:** إذا أرجعت عدة سياسات `allow(message)`، يتم ربط جميع الرسائل
|
|
138
|
+
- **تأكيدات الحالة:** `allow("All CI checks passed.")` - يخبر Claude أن كل شيء أخضر
|
|
139
|
+
- **شروحات الفتح المفشول:** `allow("GitHub CLI not installed, skipping CI check.")` - يخبر Claude لماذا تم تخطي الفحص بحيث يكون لديه سياق كامل
|
|
140
|
+
- **تراكم رسائل متعددة:** إذا أرجعت عدة سياسات `allow(message)`، يتم ربط جميع الرسائل بفواصل أسطر وتسليمها معاً
|
|
141
141
|
|
|
142
142
|
```js
|
|
143
143
|
customPolicies.add({
|
|
@@ -147,7 +147,7 @@ customPolicies.add({
|
|
|
147
147
|
const cwd = ctx.session?.cwd;
|
|
148
148
|
if (!cwd) return allow("No working directory, skipping branch check.");
|
|
149
149
|
|
|
150
|
-
// ...
|
|
150
|
+
// ... تحقق من حالة الفرع ...
|
|
151
151
|
if (allPushed) {
|
|
152
152
|
return allow("Branch is up to date with remote.");
|
|
153
153
|
}
|
|
@@ -163,24 +163,24 @@ customPolicies.add({
|
|
|
163
163
|
| `eventType` | `string` | `"PreToolUse"`، `"PostToolUse"`، `"Notification"`، `"Stop"` |
|
|
164
164
|
| `toolName` | `string \| undefined` | الأداة التي يتم استدعاؤها (مثل `"Bash"`، `"Write"`، `"Read"`) |
|
|
165
165
|
| `toolInput` | `Record<string, unknown> \| undefined` | معاملات إدخال الأداة |
|
|
166
|
-
| `payload` | `Record<string, unknown>` |
|
|
166
|
+
| `payload` | `Record<string, unknown>` | الحمولة الحدث الخام الكاملة من Claude Code |
|
|
167
167
|
| `session` | `SessionMetadata \| undefined` | سياق الجلسة (انظر أدناه) |
|
|
168
168
|
|
|
169
169
|
### حقول `SessionMetadata`
|
|
170
170
|
|
|
171
171
|
| الحقل | النوع | الوصف |
|
|
172
172
|
|-------|------|-------------|
|
|
173
|
-
| `sessionId` | `string` |
|
|
173
|
+
| `sessionId` | `string` | معرّف جلسة Claude Code |
|
|
174
174
|
| `cwd` | `string` | دليل العمل لجلسة Claude Code |
|
|
175
|
-
| `transcriptPath` | `string` | المسار إلى ملف
|
|
175
|
+
| `transcriptPath` | `string` | المسار إلى ملف النسخ JSONL للجلسة |
|
|
176
176
|
|
|
177
177
|
### أنواع الأحداث
|
|
178
178
|
|
|
179
|
-
| الحدث | متى
|
|
180
|
-
|
|
179
|
+
| الحدث | متى يتم تشغيله | محتويات `toolInput` |
|
|
180
|
+
|-------|--------------|----------------------|
|
|
181
181
|
| `PreToolUse` | قبل تشغيل Claude لأداة | إدخال الأداة (مثل `{ command: "..." }` لـ Bash) |
|
|
182
|
-
| `PostToolUse` | بعد اكتمال
|
|
183
|
-
| `Notification` | عندما يرسل Claude
|
|
182
|
+
| `PostToolUse` | بعد اكتمال أداة | إدخال الأداة + `tool_result` (الإخراج) |
|
|
183
|
+
| `Notification` | عندما يرسل Claude إخطار | `{ message: "...", notification_type: "idle" \| "permission_prompt" \| ... }` - يجب أن ترجع الخطافات دائماً `allow()`، لا يمكنها حجب الإخطارات |
|
|
184
184
|
| `Stop` | عند انتهاء جلسة Claude | فارغ |
|
|
185
185
|
|
|
186
186
|
---
|
|
@@ -191,18 +191,18 @@ customPolicies.add({
|
|
|
191
191
|
|
|
192
192
|
1. السياسات المدمجة (بترتيب التعريف)
|
|
193
193
|
2. السياسات المخصصة الصريحة من `customPoliciesPath` (بترتيب `.add()`)
|
|
194
|
-
3. سياسات الاتفاقية من مشروع `.failproofai/policies/` (
|
|
195
|
-
4. سياسات الاتفاقية من مستخدم `~/.failproofai/policies/` (
|
|
194
|
+
3. سياسات الاتفاقية من مشروع `.failproofai/policies/` (ملفات أبجدياً، `.add()` بترتيب داخل)
|
|
195
|
+
4. سياسات الاتفاقية من مستخدم `~/.failproofai/policies/` (ملفات أبجدياً، `.add()` بترتيب داخل)
|
|
196
196
|
|
|
197
197
|
<Note>
|
|
198
|
-
|
|
198
|
+
يقطع أول `deny` جميع السياسات اللاحقة. يتم تجميع جميع رسائل `instruct` وتسليمها معاً.
|
|
199
199
|
</Note>
|
|
200
200
|
|
|
201
201
|
---
|
|
202
202
|
|
|
203
|
-
##
|
|
203
|
+
## الاستيرادات المتعدية
|
|
204
204
|
|
|
205
|
-
يمكن لملفات السياسات المخصصة استيراد
|
|
205
|
+
يمكن لملفات السياسات المخصصة استيراد وحدات محلية باستخدام المسارات النسبية:
|
|
206
206
|
|
|
207
207
|
```js
|
|
208
208
|
// my-policies.js
|
|
@@ -219,46 +219,46 @@ customPolicies.add({
|
|
|
219
219
|
});
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
يتم حل جميع
|
|
222
|
+
يتم حل جميع الاستيرادات النسبية القابلة للوصول من ملف الإدخال. يتم تطبيق هذا بإعادة كتابة استيرادات `from "failproofai"` إلى مسار dist الفعلي وإنشاء ملفات `.mjs` مؤقتة لضمان توافق ESM.
|
|
223
223
|
|
|
224
224
|
---
|
|
225
225
|
|
|
226
226
|
## تصفية نوع الحدث
|
|
227
227
|
|
|
228
|
-
استخدم `match.events` لتحديد متى
|
|
228
|
+
استخدم `match.events` لتحديد متى يتم تشغيل السياسة:
|
|
229
229
|
|
|
230
230
|
```js
|
|
231
231
|
customPolicies.add({
|
|
232
232
|
name: "require-summary-on-stop",
|
|
233
233
|
match: { events: ["Stop"] },
|
|
234
234
|
fn: async (ctx) => {
|
|
235
|
-
//
|
|
236
|
-
// ctx.session.transcriptPath
|
|
235
|
+
// يتم التشغيل فقط عند انتهاء الجلسة
|
|
236
|
+
// ctx.session.transcriptPath يحتوي على سجل الجلسة الكامل
|
|
237
237
|
return allow();
|
|
238
238
|
},
|
|
239
239
|
});
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
احذف `match`
|
|
242
|
+
احذف `match` بالكامل للتشغيل على كل نوع حدث.
|
|
243
243
|
|
|
244
244
|
---
|
|
245
245
|
|
|
246
|
-
## معالجة الأخطاء
|
|
246
|
+
## معالجة الأخطاء وأنماط الفشل
|
|
247
247
|
|
|
248
|
-
السياسات المخصصة
|
|
248
|
+
السياسات المخصصة **فتح مفشول**: الأخطاء لا تحجب أبداً السياسات المدمجة أو تعطل معالج الخطاف.
|
|
249
249
|
|
|
250
250
|
| الفشل | السلوك |
|
|
251
251
|
|---------|----------|
|
|
252
|
-
| `customPoliciesPath`
|
|
253
|
-
|
|
|
254
|
-
| خطأ
|
|
255
|
-
| خطأ
|
|
256
|
-
| `fn` يرمي في وقت التشغيل | خطأ مسجل؛ يتم التعامل مع الخطاف كـ `allow`؛ تستمر الخطافات الأخرى |
|
|
257
|
-
| `fn` يستغرق أطول من 10
|
|
258
|
-
|
|
|
252
|
+
| `customPoliciesPath` غير معيّن | لا تعمل السياسات المخصصة الصريحة؛ تستمر سياسات الاتفاقية والمدمجة بشكل طبيعي |
|
|
253
|
+
| الملف غير موجود | تحذير مسجل في `~/.failproofai/hook.log`؛ تستمر المدمجة |
|
|
254
|
+
| خطأ بناء الجملة/الاستيراد (صريح) | خطأ مسجل في `~/.failproofai/hook.log`؛ السياسات المخصصة الصريحة مخطوطة |
|
|
255
|
+
| خطأ بناء الجملة/الاستيراد (اتفاقية) | خطأ مسجل؛ هذا الملف مخطوط، لا تزال ملفات الاتفاقية الأخرى تحمل |
|
|
256
|
+
| `fn` يرمي في وقت التشغيل | خطأ مسجل؛ يتم التعامل مع هذا الخطاف كـ `allow`؛ تستمر الخطافات الأخرى |
|
|
257
|
+
| `fn` يستغرق وقتاً أطول من 10 ثانية | مهلة زمنية مسجلة؛ يتم التعامل معها كـ `allow` |
|
|
258
|
+
| دليل الاتفاقية مفقود | لا تعمل سياسات الاتفاقية؛ بدون خطأ |
|
|
259
259
|
|
|
260
260
|
<Tip>
|
|
261
|
-
لتصحيح أخطاء السياسات المخصصة،
|
|
261
|
+
لتصحيح أخطاء السياسات المخصصة، راقب ملف السجل:
|
|
262
262
|
|
|
263
263
|
```bash
|
|
264
264
|
tail -f ~/.failproofai/hook.log
|
|
@@ -273,7 +273,7 @@ tail -f ~/.failproofai/hook.log
|
|
|
273
273
|
// my-policies.js
|
|
274
274
|
import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
275
275
|
|
|
276
|
-
//
|
|
276
|
+
// منع الوكيل من الكتابة إلى دليل secrets/
|
|
277
277
|
customPolicies.add({
|
|
278
278
|
name: "block-secrets-dir",
|
|
279
279
|
description: "Prevent agent from writing to secrets/ directory",
|
|
@@ -286,7 +286,7 @@ customPolicies.add({
|
|
|
286
286
|
},
|
|
287
287
|
});
|
|
288
288
|
|
|
289
|
-
//
|
|
289
|
+
// ابق الوكيل على المسار: تحقق من الاختبارات قبل الالتزام
|
|
290
290
|
customPolicies.add({
|
|
291
291
|
name: "remind-test-before-commit",
|
|
292
292
|
description: "Keep the agent on track: verify tests pass before committing",
|
|
@@ -301,7 +301,7 @@ customPolicies.add({
|
|
|
301
301
|
},
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
-
//
|
|
304
|
+
// منع تغييرات المتعلقات غير المخطط لها أثناء التجميد
|
|
305
305
|
customPolicies.add({
|
|
306
306
|
name: "dependency-freeze",
|
|
307
307
|
description: "Prevent unplanned dependency changes during freeze period",
|
|
@@ -324,14 +324,14 @@ export { customPolicies };
|
|
|
324
324
|
|
|
325
325
|
## أمثلة
|
|
326
326
|
|
|
327
|
-
يحتوي
|
|
327
|
+
يحتوي دليل `examples/` على ملفات سياسات جاهزة للتشغيل:
|
|
328
328
|
|
|
329
329
|
| الملف | المحتويات |
|
|
330
330
|
|------|----------|
|
|
331
|
-
| `examples/policies-basic.js` | خمس سياسات
|
|
332
|
-
| `examples/policies-advanced/index.js` | أنماط متقدمة:
|
|
333
|
-
| `examples/convention-policies/security-policies.mjs` | سياسات
|
|
334
|
-
| `examples/convention-policies/workflow-policies.mjs` | سياسات سير
|
|
331
|
+
| `examples/policies-basic.js` | خمس سياسات البداية التي تغطي أنماط فشل الوكيل الشائعة |
|
|
332
|
+
| `examples/policies-advanced/index.js` | أنماط متقدمة: استيرادات متعدية، استدعاءات غير متزامنة، تنظيف الإخراج، وخطافات نهاية الجلسة |
|
|
333
|
+
| `examples/convention-policies/security-policies.mjs` | سياسات أمان قائمة على الاتفاقية (حجب كتابات .env، منع إعادة كتابة سجل git) |
|
|
334
|
+
| `examples/convention-policies/workflow-policies.mjs` | سياسات سير عمل قائمة على الاتفاقية (تذكيرات الاختبار وملفات الكتابة بالتدقيق) |
|
|
335
335
|
|
|
336
336
|
### استخدام أمثلة الملفات الصريحة
|
|
337
337
|
|
|
@@ -342,13 +342,13 @@ failproofai policies --install --custom ./examples/policies-basic.js
|
|
|
342
342
|
### استخدام أمثلة قائمة على الاتفاقية
|
|
343
343
|
|
|
344
344
|
```bash
|
|
345
|
-
#
|
|
345
|
+
# انسخ إلى مستوى المشروع
|
|
346
346
|
mkdir -p .failproofai/policies
|
|
347
347
|
cp examples/convention-policies/*.mjs .failproofai/policies/
|
|
348
348
|
|
|
349
|
-
#
|
|
349
|
+
# أو انسخ إلى مستوى المستخدم
|
|
350
350
|
mkdir -p ~/.failproofai/policies
|
|
351
351
|
cp examples/convention-policies/*.mjs ~/.failproofai/policies/
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
لا
|
|
354
|
+
لا توجد حاجة لأمر التثبيت - يتم التقاط الملفات تلقائياً في حدث الخطاف التالي.
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
---
|
|
3
2
|
title: أمثلة
|
|
4
|
-
description: "كيفية إعداد
|
|
3
|
+
description: "كيفية إعداد الخطافات لـ Claude Code و Agents SDK"
|
|
5
4
|
icon: book-open
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
أمثلة جاهزة للاستخدام
|
|
7
|
+
أمثلة جاهزة للاستخدام لسيناريوهات شائعة. يوضح كل منها كيفية التثبيت وما يمكن توقعه.
|
|
9
8
|
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
## إعداد
|
|
11
|
+
## إعداد الخطافات لـ Claude Code
|
|
13
12
|
|
|
14
|
-
يتكامل Failproof AI مع Claude Code عبر [نظام
|
|
13
|
+
يتكامل Failproof AI مع Claude Code عبر [نظام الخطافات الخاص به](https://docs.anthropic.com/en/docs/claude-code/hooks). عند تشغيل `failproofai policies --install`، يسجل أوامر الخطافات في `settings.json` الخاص بـ Claude Code والتي تعمل عند كل استدعاء أداة.
|
|
15
14
|
|
|
16
15
|
<Steps>
|
|
17
16
|
<Step title="تثبيت failproofai">
|
|
@@ -24,27 +23,27 @@ icon: book-open
|
|
|
24
23
|
failproofai policies --install
|
|
25
24
|
```
|
|
26
25
|
</Step>
|
|
27
|
-
<Step title="التحقق من تسجيل
|
|
26
|
+
<Step title="التحقق من تسجيل الخطافات">
|
|
28
27
|
```bash
|
|
29
28
|
cat ~/.claude/settings.json | grep failproofai
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
يجب أن تشاهد إدخالات
|
|
31
|
+
يجب أن تشاهد إدخالات خطافات لأحداث `PreToolUse` و `PostToolUse` و `Notification` و `Stop`.
|
|
33
32
|
</Step>
|
|
34
33
|
<Step title="تشغيل Claude Code">
|
|
35
34
|
```bash
|
|
36
35
|
claude
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
تعمل السياسات الآن تلقائياً
|
|
38
|
+
تعمل السياسات الآن تلقائياً عند كل استدعاء أداة. جرب طلب Claude لتشغيل `sudo rm -rf /` - سيتم حظره.
|
|
40
39
|
</Step>
|
|
41
40
|
</Steps>
|
|
42
41
|
|
|
43
42
|
---
|
|
44
43
|
|
|
45
|
-
## إعداد
|
|
44
|
+
## إعداد الخطافات لـ Agents SDK
|
|
46
45
|
|
|
47
|
-
إذا كنت تبني باستخدام [Agents SDK](https://docs.anthropic.com/en/docs/agents-sdk)، يمكنك استخدام نفس نظام
|
|
46
|
+
إذا كنت تبني باستخدام [Agents SDK](https://docs.anthropic.com/en/docs/agents-sdk)، يمكنك استخدام نفس نظام الخطافات برمجياً.
|
|
48
47
|
|
|
49
48
|
<Steps>
|
|
50
49
|
<Step title="تثبيت failproofai في مشروعك">
|
|
@@ -52,15 +51,15 @@ icon: book-open
|
|
|
52
51
|
npm install failproofai
|
|
53
52
|
```
|
|
54
53
|
</Step>
|
|
55
|
-
<Step title="تكوين
|
|
56
|
-
مرر أوامر
|
|
54
|
+
<Step title="تكوين الخطافات في الوكيل الخاص بك">
|
|
55
|
+
مرر أوامر الخطافات عند إنشاء عملية الوكيل الخاص بك. تعمل الخطافات بنفس الطريقة كما في Claude Code - عبر JSON في stdin/stdout:
|
|
57
56
|
|
|
58
57
|
```bash
|
|
59
|
-
failproofai --hook PreToolUse #
|
|
60
|
-
failproofai --hook PostToolUse #
|
|
58
|
+
failproofai --hook PreToolUse # يُستدعى قبل كل أداة
|
|
59
|
+
failproofai --hook PostToolUse # يُستدعى بعد كل أداة
|
|
61
60
|
```
|
|
62
61
|
</Step>
|
|
63
|
-
<Step title="
|
|
62
|
+
<Step title="كتابة سياسة مخصصة للوكيل الخاص بك">
|
|
64
63
|
```javascript
|
|
65
64
|
import { customPolicies, allow, deny } from "failproofai";
|
|
66
65
|
|
|
@@ -89,17 +88,17 @@ icon: book-open
|
|
|
89
88
|
|
|
90
89
|
## حظر الأوامر المدمرة
|
|
91
90
|
|
|
92
|
-
الإعداد الأكثر شيوعاً - منع الوكلاء من إلحاق
|
|
91
|
+
الإعداد الأكثر شيوعاً - منع الوكلاء من إلحاق ضرر لا يمكن التراجع عنه.
|
|
93
92
|
|
|
94
93
|
```bash
|
|
95
94
|
failproofai policies --install block-sudo block-rm-rf block-force-push block-curl-pipe-sh
|
|
96
95
|
```
|
|
97
96
|
|
|
98
|
-
ما
|
|
97
|
+
ما يفعله:
|
|
99
98
|
- `block-sudo` - يحظر جميع أوامر `sudo`
|
|
100
99
|
- `block-rm-rf` - يحظر حذف الملفات بشكل متكرر
|
|
101
100
|
- `block-force-push` - يحظر `git push --force`
|
|
102
|
-
- `block-curl-pipe-sh` - يحظر
|
|
101
|
+
- `block-curl-pipe-sh` - يحظر أنابيب البرامج النصية البعيدة إلى shell
|
|
103
102
|
|
|
104
103
|
---
|
|
105
104
|
|
|
@@ -111,13 +110,13 @@ failproofai policies --install block-sudo block-rm-rf block-force-push block-cur
|
|
|
111
110
|
failproofai policies --install sanitize-api-keys sanitize-jwt sanitize-connection-strings sanitize-bearer-tokens
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
تعمل هذه على `PostToolUse` - بعد تشغيل أداة، تقوم
|
|
113
|
+
تعمل هذه السياسات على `PostToolUse` - بعد تشغيل أداة، تقوم بتنظيف المخرجات قبل أن يراها الوكيل.
|
|
115
114
|
|
|
116
115
|
---
|
|
117
116
|
|
|
118
117
|
## الحصول على تنبيهات Slack عندما يحتاج الوكلاء إلى الاهتمام
|
|
119
118
|
|
|
120
|
-
استخدم
|
|
119
|
+
استخدم خطاف الإشعار لإعادة توجيه تنبيهات الخمول إلى Slack.
|
|
121
120
|
|
|
122
121
|
```javascript
|
|
123
122
|
import { customPolicies, allow, instruct } from "failproofai";
|
|
@@ -151,7 +150,7 @@ customPolicies.add({
|
|
|
151
150
|
});
|
|
152
151
|
```
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
تثبيتها:
|
|
155
154
|
|
|
156
155
|
```bash
|
|
157
156
|
SLACK_WEBHOOK_URL=https://hooks.slack.com/... failproofai policies --install --custom ./slack-alerts.js
|
|
@@ -159,7 +158,7 @@ SLACK_WEBHOOK_URL=https://hooks.slack.com/... failproofai policies --install --c
|
|
|
159
158
|
|
|
160
159
|
---
|
|
161
160
|
|
|
162
|
-
##
|
|
161
|
+
## إبقاء الوكلاء على فرع معين
|
|
163
162
|
|
|
164
163
|
منع الوكلاء من تبديل الفروع أو الدفع إلى الفروع المحمية.
|
|
165
164
|
|
|
@@ -183,9 +182,9 @@ customPolicies.add({
|
|
|
183
182
|
|
|
184
183
|
---
|
|
185
184
|
|
|
186
|
-
##
|
|
185
|
+
## اشتراط الاختبارات قبل الالتزام
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
تذكير الوكلاء بتشغيل الاختبارات قبل الالتزام.
|
|
189
188
|
|
|
190
189
|
```javascript
|
|
191
190
|
import { customPolicies, allow, instruct } from "failproofai";
|
|
@@ -207,9 +206,9 @@ customPolicies.add({
|
|
|
207
206
|
|
|
208
207
|
---
|
|
209
208
|
|
|
210
|
-
##
|
|
209
|
+
## تأمين مستودع الإنتاج
|
|
211
210
|
|
|
212
|
-
التزم
|
|
211
|
+
التزم بإعداد على مستوى المشروع حتى يحصل كل مطور في فريقك على نفس السياسات.
|
|
213
212
|
|
|
214
213
|
أنشئ `.failproofai/policies-config.json` في مستودعك:
|
|
215
214
|
|
|
@@ -239,16 +238,70 @@ git add .failproofai/policies-config.json
|
|
|
239
238
|
git commit -m "Add failproofai team policies"
|
|
240
239
|
```
|
|
241
240
|
|
|
242
|
-
|
|
241
|
+
سيحصل كل عضو في الفريق الذي لديه failproofai مثبت تلقائياً على هذه القواعد.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## بناء معيار جودة على مستوى المنظمة باستخدام سياسات الاتفاقية
|
|
246
|
+
|
|
247
|
+
الإعداد الأكثر تأثيراً: التزم بـ `.failproofai/policies/` في مستودعك مع سياسات مخصصة لمشروعك. يحصل كل عضو في الفريق عليها تلقائياً - بدون أوامر تثبيت، بدون تغييرات إعدادات.
|
|
248
|
+
|
|
249
|
+
<Steps>
|
|
250
|
+
<Step title="إنشاء المجلد وإضافة السياسات">
|
|
251
|
+
```bash
|
|
252
|
+
mkdir -p .failproofai/policies
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
```js
|
|
256
|
+
// .failproofai/policies/team-policies.mjs
|
|
257
|
+
import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
258
|
+
|
|
259
|
+
// Enforce your team's preferred package manager
|
|
260
|
+
// (or enable the built-in prefer-package-manager policy instead)
|
|
261
|
+
customPolicies.add({
|
|
262
|
+
name: "enforce-bun",
|
|
263
|
+
match: { events: ["PreToolUse"] },
|
|
264
|
+
fn: async (ctx) => {
|
|
265
|
+
if (ctx.toolName !== "Bash") return allow();
|
|
266
|
+
const cmd = String(ctx.toolInput?.command ?? "");
|
|
267
|
+
if (/\bnpm\b/.test(cmd)) return deny("Use bun instead of npm.");
|
|
268
|
+
return allow();
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Remind the agent to run tests before committing
|
|
273
|
+
customPolicies.add({
|
|
274
|
+
name: "test-before-commit",
|
|
275
|
+
match: { events: ["PreToolUse"] },
|
|
276
|
+
fn: async (ctx) => {
|
|
277
|
+
if (ctx.toolName !== "Bash") return allow();
|
|
278
|
+
if (/git\s+commit/.test(ctx.toolInput?.command ?? "")) {
|
|
279
|
+
return instruct("Run tests before committing.");
|
|
280
|
+
}
|
|
281
|
+
return allow();
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
</Step>
|
|
286
|
+
<Step title="الالتزام بـ git">
|
|
287
|
+
```bash
|
|
288
|
+
git add .failproofai/policies/
|
|
289
|
+
git commit -m "Add team quality policies"
|
|
290
|
+
```
|
|
291
|
+
</Step>
|
|
292
|
+
<Step title="الاستمرار في التحسين">
|
|
293
|
+
عندما يواجه فريقك أنماط فشل جديدة، أضف سياسات وادفع. يحصل الجميع على التحديث عند `git pull` التالي. تصبح هذه السياسات معيار جودة حي ينمو مع فريقك.
|
|
294
|
+
</Step>
|
|
295
|
+
</Steps>
|
|
243
296
|
|
|
244
297
|
---
|
|
245
298
|
|
|
246
|
-
##
|
|
299
|
+
## أمثلة إضافية
|
|
247
300
|
|
|
248
|
-
يحتوي
|
|
301
|
+
يحتوي المجلد [`examples/`](https://github.com/exospherehost/failproofai/tree/main/examples) في المستودع على:
|
|
249
302
|
|
|
250
|
-
| الملف | ما
|
|
303
|
+
| الملف | ما يوضحه |
|
|
251
304
|
|------|----------|
|
|
252
|
-
| `policies-basic.js` |
|
|
253
|
-
| `policies-notification.js` | تنبيهات Slack لإشعارات
|
|
254
|
-
| `policies-advanced/index.js` | الاستيرادات
|
|
305
|
+
| `policies-basic.js` | سياسات للمبتدئين - حظر كتابات الإنتاج وفرض الدفع والبرامج النصية المأنوبة |
|
|
306
|
+
| `policies-notification.js` | تنبيهات Slack لإشعارات الخمول ونهاية الجلسة |
|
|
307
|
+
| `policies-advanced/index.js` | الاستيرادات الانتقالية والخطافات غير المتزامنة وتنظيف مخرجات PostToolUse ومعالجة حدث Stop |
|