failproofai 0.0.5-beta.0 → 0.0.6-beta.0
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/workflow-policies.mjs +2 -1
- 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]__0r6vvp5._.js → [root-of-the-server]__0.~fd7s._.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]__0z5dd-f._.js → [root-of-the-server]__0a.nuas._.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]__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/{0j_ivegn3i5wt.js → 0.z51twd.0l5z.js} +1 -1
- package/.next/standalone/.next/static/chunks/{04fpsjft~cje..js → 0hctoh28rg838.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0.io32u7gjgsb.js → 0hplx-8c-4vpv.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0yf_mmdukq6up.js → 0maq.q1t.ri85.js} +2 -2
- package/.next/standalone/.next/static/chunks/{0x8vagatq36_7.js → 0teq8wdh3po1n.js} +1 -1
- package/.next/standalone/.next/static/chunks/{04mtv9jnqknn3.js → 0uc0um_uz51m_.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0h4qcn40dunn7.js → 0ul6fk-z.6k-0.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0kvldut6ndzyz.js → 0w9lwqy0-v1dk.js} +1 -1
- package/.next/standalone/CHANGELOG.md +9 -1
- package/.next/standalone/README.md +2 -2
- package/.next/standalone/dist/cli.mjs +19 -2
- package/.next/standalone/docs/ar/architecture.mdx +66 -65
- package/.next/standalone/docs/ar/configuration.mdx +42 -42
- package/.next/standalone/docs/ar/custom-policies.mdx +63 -68
- package/.next/standalone/docs/architecture.mdx +2 -2
- package/.next/standalone/docs/configuration.mdx +1 -1
- package/.next/standalone/docs/custom-policies.mdx +2 -6
- package/.next/standalone/docs/de/architecture.mdx +92 -92
- package/.next/standalone/docs/de/configuration.mdx +35 -35
- package/.next/standalone/docs/de/custom-policies.mdx +50 -54
- package/.next/standalone/docs/es/architecture.mdx +73 -73
- package/.next/standalone/docs/es/configuration.mdx +25 -25
- package/.next/standalone/docs/es/custom-policies.mdx +49 -53
- package/.next/standalone/docs/fr/architecture.mdx +55 -55
- package/.next/standalone/docs/fr/configuration.mdx +26 -26
- package/.next/standalone/docs/fr/custom-policies.mdx +42 -46
- package/.next/standalone/docs/he/architecture.mdx +67 -67
- package/.next/standalone/docs/he/configuration.mdx +53 -52
- package/.next/standalone/docs/he/custom-policies.mdx +73 -77
- package/.next/standalone/docs/hi/architecture.mdx +107 -107
- package/.next/standalone/docs/hi/configuration.mdx +39 -39
- package/.next/standalone/docs/hi/custom-policies.mdx +77 -81
- package/.next/standalone/docs/i18n/README.ar.md +66 -66
- package/.next/standalone/docs/i18n/README.de.md +40 -40
- package/.next/standalone/docs/i18n/README.es.md +40 -40
- package/.next/standalone/docs/i18n/README.fr.md +44 -44
- package/.next/standalone/docs/i18n/README.he.md +67 -67
- package/.next/standalone/docs/i18n/README.hi.md +71 -71
- package/.next/standalone/docs/i18n/README.it.md +63 -63
- package/.next/standalone/docs/i18n/README.ja.md +55 -55
- package/.next/standalone/docs/i18n/README.ko.md +59 -59
- package/.next/standalone/docs/i18n/README.pt-br.md +45 -45
- package/.next/standalone/docs/i18n/README.ru.md +71 -71
- package/.next/standalone/docs/i18n/README.tr.md +76 -76
- package/.next/standalone/docs/i18n/README.vi.md +71 -71
- package/.next/standalone/docs/i18n/README.zh.md +53 -53
- package/.next/standalone/docs/it/architecture.mdx +55 -54
- package/.next/standalone/docs/it/configuration.mdx +45 -46
- package/.next/standalone/docs/it/custom-policies.mdx +77 -82
- package/.next/standalone/docs/ja/architecture.mdx +93 -93
- package/.next/standalone/docs/ja/configuration.mdx +48 -48
- package/.next/standalone/docs/ja/custom-policies.mdx +63 -67
- package/.next/standalone/docs/ko/architecture.mdx +66 -66
- package/.next/standalone/docs/ko/configuration.mdx +36 -36
- package/.next/standalone/docs/ko/custom-policies.mdx +73 -77
- package/.next/standalone/docs/pt-br/architecture.mdx +55 -55
- package/.next/standalone/docs/pt-br/configuration.mdx +36 -36
- package/.next/standalone/docs/pt-br/custom-policies.mdx +62 -66
- package/.next/standalone/docs/ru/architecture.mdx +59 -60
- package/.next/standalone/docs/ru/configuration.mdx +52 -53
- package/.next/standalone/docs/ru/custom-policies.mdx +70 -74
- package/.next/standalone/docs/tr/architecture.mdx +124 -124
- package/.next/standalone/docs/tr/configuration.mdx +46 -47
- package/.next/standalone/docs/tr/custom-policies.mdx +75 -78
- package/.next/standalone/docs/vi/architecture.mdx +65 -64
- package/.next/standalone/docs/vi/configuration.mdx +42 -42
- package/.next/standalone/docs/vi/custom-policies.mdx +68 -72
- package/.next/standalone/docs/zh/architecture.mdx +67 -67
- package/.next/standalone/docs/zh/configuration.mdx +35 -35
- package/.next/standalone/docs/zh/custom-policies.mdx +54 -58
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/server.js +1 -1
- package/.next/standalone/src/hooks/builtin-policies.ts +30 -0
- package/README.md +2 -2
- package/dist/cli.mjs +19 -2
- package/package.json +1 -1
- package/src/hooks/builtin-policies.ts +30 -0
- /package/.next/standalone/.next/static/{ICeMHZ-8ZR7HY5GLm7oSJ → 8mygPGI5bzrtWK36ZYO59}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{ICeMHZ-8ZR7HY5GLm7oSJ → 8mygPGI5bzrtWK36ZYO59}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{ICeMHZ-8ZR7HY5GLm7oSJ → 8mygPGI5bzrtWK36ZYO59}/_ssgManifest.js +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
2
|
---
|
|
4
3
|
title: السياسات المخصصة
|
|
5
|
-
description: "اكتب سياساتك الخاصة
|
|
4
|
+
description: "اكتب سياساتك الخاصة بلغة JavaScript - فرض الاتفاقيات، منع الانجراف، اكتشاف الأعطال، التكامل مع الأنظمة الخارجية"
|
|
6
5
|
icon: code
|
|
7
6
|
---
|
|
8
7
|
|
|
9
|
-
تتيح لك السياسات المخصصة كتابة قواعد لأي سلوك وكيل: فرض اتفاقيات المشروع، منع الانجراف،
|
|
8
|
+
تتيح لك السياسات المخصصة كتابة قواعد لأي سلوك وكيل: فرض اتفاقيات المشروع، منع الانجراف، حماية العمليات المدمرة، كشف الوكلاء العالقين، أو التكامل مع Slack وسير العمل الموافقة والمزيد. تستخدم نفس نظام أحداث الخطاف وقرارات `allow` و `deny` و `instruct` مثل السياسات المدمجة.
|
|
10
9
|
|
|
11
10
|
---
|
|
12
11
|
|
|
@@ -31,7 +30,7 @@ customPolicies.add({
|
|
|
31
30
|
});
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
قم بتثبيته:
|
|
35
34
|
|
|
36
35
|
```bash
|
|
37
36
|
failproofai policies --install --custom ./my-policies.js
|
|
@@ -41,56 +40,56 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
41
40
|
|
|
42
41
|
## طريقتان لتحميل السياسات المخصصة
|
|
43
42
|
|
|
44
|
-
### الخيار 1:
|
|
43
|
+
### الخيار 1: قائم على الاتفاقية (موصى به)
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
ضع ملفات `*policies.{js,mjs,ts}` في `.failproofai/policies/` وسيتم تحميلها تلقائياً — لا توجد علامات أو تغييرات في الإعدادات المطلوبة. يعمل هذا مثل خطافات git: ضع ملفاً، وسيعمل فقط.
|
|
47
46
|
|
|
48
47
|
```
|
|
49
|
-
#
|
|
48
|
+
# مستوى المشروع — يتم الالتزام به في git، مشترك مع الفريق
|
|
50
49
|
.failproofai/policies/security-policies.mjs
|
|
51
50
|
.failproofai/policies/workflow-policies.mjs
|
|
52
51
|
|
|
53
|
-
#
|
|
52
|
+
# مستوى المستخدم — شخصي، ينطبق على جميع المشاريع
|
|
54
53
|
~/.failproofai/policies/my-policies.mjs
|
|
55
54
|
```
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
- يتم فحص
|
|
59
|
-
- يتم تحميل الملفات أبجدياً
|
|
60
|
-
- يتم تحميل الملفات المطابقة `*policies.{js,mjs,ts}
|
|
61
|
-
- يتم تحميل كل ملف بشكل مستقل (
|
|
56
|
+
**كيف يعمل:**
|
|
57
|
+
- يتم فحص كل من مجلدات المشروع والمستخدم (الاتحاد — وليس السيطرة الأولى)
|
|
58
|
+
- يتم تحميل الملفات أبجدياً داخل كل مجلد. البادئة مع `01-`، `02-` للتحكم في الترتيب
|
|
59
|
+
- يتم تحميل الملفات المطابقة فقط `*policies.{js,mjs,ts}`؛ يتم تجاهل الملفات الأخرى
|
|
60
|
+
- يتم تحميل كل ملف بشكل مستقل (فتح بفشل لكل ملف)
|
|
62
61
|
- يعمل جنباً إلى جنب مع السياسات الصريحة `--custom` والمدمجة
|
|
63
62
|
|
|
64
63
|
<Tip>
|
|
65
|
-
سياسات الاتفاقية هي أسهل طريقة لمشاركة السياسات عبر الفريق. التزم `.failproofai/policies/`
|
|
64
|
+
سياسات الاتفاقية هي أسهل طريقة لمشاركة السياسات عبر الفريق. التزم بـ `.failproofai/policies/` إلى git وسيحصل كل عضو فريق عليها تلقائياً.
|
|
66
65
|
</Tip>
|
|
67
66
|
|
|
68
67
|
### الخيار 2: مسار الملف الصريح
|
|
69
68
|
|
|
70
69
|
```bash
|
|
71
|
-
#
|
|
70
|
+
# التثبيت مع ملف سياسات مخصص
|
|
72
71
|
failproofai policies --install --custom ./my-policies.js
|
|
73
72
|
|
|
74
|
-
#
|
|
73
|
+
# استبدل مسار ملف السياسات
|
|
75
74
|
failproofai policies --install --custom ./new-policies.js
|
|
76
75
|
|
|
77
|
-
#
|
|
76
|
+
# إزالة مسار السياسات المخصصة من الإعدادات
|
|
78
77
|
failproofai policies --uninstall --custom
|
|
79
78
|
```
|
|
80
79
|
|
|
81
|
-
يتم
|
|
80
|
+
يتم تخزين المسار المطلق المحل في `policies-config.json` كـ `customPoliciesPath`. يتم تحميل الملف بشكل جديد في كل حدث خطاف - لا يوجد تخزين مؤقت بين الأحداث.
|
|
82
81
|
|
|
83
82
|
### استخدام كليهما معاً
|
|
84
83
|
|
|
85
|
-
يمكن
|
|
84
|
+
يمكن أن تتعايش سياسات الاتفاقية وملف `--custom` الصريح. ترتيب التحميل:
|
|
86
85
|
|
|
87
86
|
1. ملف `customPoliciesPath` الصريح (إذا تم تكوينه)
|
|
88
|
-
2. ملفات
|
|
89
|
-
3. ملفات
|
|
87
|
+
2. ملفات الاتفاقية للمشروع (`{cwd}/.failproofai/policies/`، أبجدياً)
|
|
88
|
+
3. ملفات الاتفاقية للمستخدم (`~/.failproofai/policies/`، أبجدياً)
|
|
90
89
|
|
|
91
90
|
---
|
|
92
91
|
|
|
93
|
-
##
|
|
92
|
+
## API
|
|
94
93
|
|
|
95
94
|
### الاستيراد
|
|
96
95
|
|
|
@@ -100,7 +99,7 @@ import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
|
100
99
|
|
|
101
100
|
### `customPolicies.add(hook)`
|
|
102
101
|
|
|
103
|
-
تسجيل سياسة.
|
|
102
|
+
تسجيل سياسة. استدعِ هذا عدة مرات حسب الحاجة لسياسات متعددة في نفس الملف.
|
|
104
103
|
|
|
105
104
|
```ts
|
|
106
105
|
customPolicies.add({
|
|
@@ -116,33 +115,29 @@ customPolicies.add({
|
|
|
116
115
|
| الدالة | التأثير | استخدم عندما |
|
|
117
116
|
|----------|--------|----------|
|
|
118
117
|
| `allow()` | السماح بالعملية بصمت | الإجراء آمن، لا توجد رسالة مطلوبة |
|
|
119
|
-
| `deny(message)` |
|
|
120
|
-
| `instruct(message)` | إضافة سياق
|
|
118
|
+
| `deny(message)` | منع العملية | لا يجب أن يقوم الوكيل بهذا الإجراء |
|
|
119
|
+
| `instruct(message)` | إضافة سياق بدون حجب | أعط الوكيل سياق إضافي للبقاء على المسار |
|
|
121
120
|
|
|
122
|
-
`deny(message)` - تظهر الرسالة
|
|
121
|
+
`deny(message)` - تظهر الرسالة لـ Claude مع البادئة `"Blocked by failproofai:"`. يؤدي `deny` واحد إلى اختصار جميع التقييمات الإضافية.
|
|
123
122
|
|
|
124
|
-
`instruct(message)` - يتم إلحاق الرسالة بسياق Claude
|
|
123
|
+
`instruct(message)` - يتم إلحاق الرسالة بسياق Claude للاستدعاء الحالي للأداة. يتم تجميع جميع رسائل `instruct` وتسليمها معاً.
|
|
125
124
|
|
|
126
125
|
<Tip>
|
|
127
|
-
يمكنك إلحاق إرشادات إضافية بأي رسالة `deny` أو `instruct` بإضافة حقل `hint` في `policyParams`
|
|
126
|
+
يمكنك إلحاق إرشادات إضافية بأي رسالة `deny` أو `instruct` بإضافة حقل `hint` في `policyParams` — لا يلزم تغيير الكود. يعمل هذا أيضاً مع السياسات المخصصة (`custom/`) وسياسات اتفاقية المشروع (`.failproofai-project/`) وسياسات اتفاقية المستخدم (`.failproofai-user/`). راجع [التكوين → hint](/ar/configuration#hint-cross-cutting) للتفاصيل.
|
|
128
127
|
</Tip>
|
|
129
128
|
|
|
130
|
-
### رسائل السماح المعلوماتية
|
|
131
|
-
|
|
132
|
-
<Note>
|
|
133
|
-
`allow(message)` هي ميزة بيتا متاحة منذ v0.0.2-beta.3. قد تتغير واجهة برمجية التطبيقات في الإصدارات المستقبلية. الإصدارات السابقة تدعم فقط `allow()` بدون وسائط.
|
|
134
|
-
</Note>
|
|
129
|
+
### رسائل السماح المعلوماتية
|
|
135
130
|
|
|
136
|
-
`allow(message)` يسمح بالعملية **و** يرسل رسالة
|
|
131
|
+
`allow(message)` يسمح بالعملية **و** يرسل رسالة معلوماتية مرة أخرى إلى Claude. يتم تسليم الرسالة كـ `additionalContext` في استجابة stdout معالج الخطاف — نفس الآلية المستخدمة بواسطة `instruct`، لكن بمعنى مختلف: إنها تحديث الحالة، وليست تحذيراً.
|
|
137
132
|
|
|
138
133
|
| الدالة | التأثير | استخدم عندما |
|
|
139
134
|
|----------|--------|----------|
|
|
140
|
-
| `allow(message)` | السماح وإرسال السياق إلى Claude | تأكيد
|
|
135
|
+
| `allow(message)` | السماح وإرسال السياق إلى Claude | تأكيد اجتياز الفحص، أو شرح سبب تخطي الفحص |
|
|
141
136
|
|
|
142
137
|
حالات الاستخدام:
|
|
143
|
-
- **تأكيدات الحالة:** `allow("All CI checks passed.")`
|
|
144
|
-
-
|
|
145
|
-
- **تراكم
|
|
138
|
+
- **تأكيدات الحالة:** `allow("All CI checks passed.")` — يخبر Claude بأن كل شيء أخضر
|
|
139
|
+
- **شرح الفتح الفاشل:** `allow("GitHub CLI not installed, skipping CI check.")` — يخبر Claude لماذا تم تخطي الفحص حتى يكون لديه سياق كامل
|
|
140
|
+
- **تراكم رسائل متعددة:** إذا أرجعت عدة سياسات `allow(message)`، يتم ربط جميع الرسائل بأسطر جديدة وتسليمها معاً
|
|
146
141
|
|
|
147
142
|
```js
|
|
148
143
|
customPolicies.add({
|
|
@@ -168,25 +163,25 @@ customPolicies.add({
|
|
|
168
163
|
| `eventType` | `string` | `"PreToolUse"`، `"PostToolUse"`، `"Notification"`، `"Stop"` |
|
|
169
164
|
| `toolName` | `string \| undefined` | الأداة التي يتم استدعاؤها (مثل `"Bash"`، `"Write"`، `"Read"`) |
|
|
170
165
|
| `toolInput` | `Record<string, unknown> \| undefined` | معاملات إدخال الأداة |
|
|
171
|
-
| `payload` | `Record<string, unknown>` | حمل الحدث الخام
|
|
166
|
+
| `payload` | `Record<string, unknown>` | حمل الحدث الكامل الخام من Claude Code |
|
|
172
167
|
| `session` | `SessionMetadata \| undefined` | سياق الجلسة (انظر أدناه) |
|
|
173
168
|
|
|
174
169
|
### حقول `SessionMetadata`
|
|
175
170
|
|
|
176
171
|
| الحقل | النوع | الوصف |
|
|
177
172
|
|-------|------|-------------|
|
|
178
|
-
| `sessionId` | `string` |
|
|
173
|
+
| `sessionId` | `string` | معرف جلسة Claude Code |
|
|
179
174
|
| `cwd` | `string` | دليل العمل لجلسة Claude Code |
|
|
180
|
-
| `transcriptPath` | `string` | المسار إلى ملف النسخة JSONL
|
|
175
|
+
| `transcriptPath` | `string` | المسار إلى ملف النسخة المكتوبة JSONL للجلسة |
|
|
181
176
|
|
|
182
177
|
### أنواع الأحداث
|
|
183
178
|
|
|
184
|
-
| الحدث | متى
|
|
185
|
-
|
|
179
|
+
| الحدث | متى يطلق | محتويات `toolInput` |
|
|
180
|
+
|------|--------------|----------------------|
|
|
186
181
|
| `PreToolUse` | قبل تشغيل Claude لأداة | إدخال الأداة (مثل `{ command: "..." }` لـ Bash) |
|
|
187
182
|
| `PostToolUse` | بعد اكتمال الأداة | إدخال الأداة + `tool_result` (الإخراج) |
|
|
188
|
-
| `Notification` | عندما يرسل Claude إشعاراً | `{ message: "...", notification_type: "idle" \| "permission_prompt" \| ... }` - يجب أن تعيد الخطافات دائماً `allow()`،
|
|
189
|
-
| `Stop` | عند انتهاء جلسة Claude |
|
|
183
|
+
| `Notification` | عندما يرسل Claude إشعاراً | `{ message: "...", notification_type: "idle" \| "permission_prompt" \| ... }` - يجب أن تعيد الخطافات دائماً `allow()`، لا يمكنها حجب الإشعارات |
|
|
184
|
+
| `Stop` | عند انتهاء جلسة Claude | فارغ |
|
|
190
185
|
|
|
191
186
|
---
|
|
192
187
|
|
|
@@ -196,18 +191,18 @@ customPolicies.add({
|
|
|
196
191
|
|
|
197
192
|
1. السياسات المدمجة (بترتيب التعريف)
|
|
198
193
|
2. السياسات المخصصة الصريحة من `customPoliciesPath` (بترتيب `.add()`)
|
|
199
|
-
3. سياسات الاتفاقية من `.failproofai/policies/`
|
|
200
|
-
4. سياسات الاتفاقية من `~/.failproofai/policies/`
|
|
194
|
+
3. سياسات الاتفاقية من مشروع `.failproofai/policies/` (الملفات أبجدياً، ترتيب `.add()` بداخلها)
|
|
195
|
+
4. سياسات الاتفاقية من مستخدم `~/.failproofai/policies/` (الملفات أبجدياً، ترتيب `.add()` بداخلها)
|
|
201
196
|
|
|
202
197
|
<Note>
|
|
203
|
-
|
|
198
|
+
يؤدي أول `deny` إلى اختصار جميع السياسات اللاحقة. يتم تجميع جميع رسائل `instruct` وتسليمها معاً.
|
|
204
199
|
</Note>
|
|
205
200
|
|
|
206
201
|
---
|
|
207
202
|
|
|
208
203
|
## الواردات المتعدية
|
|
209
204
|
|
|
210
|
-
يمكن لملفات
|
|
205
|
+
يمكن لملفات السياسات المخصصة استيراد الوحدات المحلية باستخدام المسارات النسبية:
|
|
211
206
|
|
|
212
207
|
```js
|
|
213
208
|
// my-policies.js
|
|
@@ -224,13 +219,13 @@ customPolicies.add({
|
|
|
224
219
|
});
|
|
225
220
|
```
|
|
226
221
|
|
|
227
|
-
يتم حل جميع الواردات النسبية
|
|
222
|
+
يتم حل جميع الواردات النسبية التي يمكن الوصول إليها من ملف الإدخال. يتم تنفيذ هذا بإعادة كتابة استيراد `from "failproofai"` إلى مسار dist الفعلي وإنشاء ملفات `.mjs` مؤقتة لضمان توافق ESM.
|
|
228
223
|
|
|
229
224
|
---
|
|
230
225
|
|
|
231
226
|
## تصفية نوع الحدث
|
|
232
227
|
|
|
233
|
-
استخدم `match.events` لتحديد متى
|
|
228
|
+
استخدم `match.events` لتحديد متى تطلق السياسة:
|
|
234
229
|
|
|
235
230
|
```js
|
|
236
231
|
customPolicies.add({
|
|
@@ -244,26 +239,26 @@ customPolicies.add({
|
|
|
244
239
|
});
|
|
245
240
|
```
|
|
246
241
|
|
|
247
|
-
|
|
242
|
+
احذف `match` تماماً لتطلق على كل نوع حدث.
|
|
248
243
|
|
|
249
244
|
---
|
|
250
245
|
|
|
251
246
|
## معالجة الأخطاء وأوضاع الفشل
|
|
252
247
|
|
|
253
|
-
السياسات المخصصة
|
|
248
|
+
السياسات المخصصة **تفتح الفشل**: لا تحجب الأخطاء أبداً السياسات المدمجة أو تحطم معالج الخطاف.
|
|
254
249
|
|
|
255
250
|
| الفشل | السلوك |
|
|
256
251
|
|---------|----------|
|
|
257
|
-
| `customPoliciesPath` لم
|
|
258
|
-
|
|
|
259
|
-
| خطأ
|
|
260
|
-
| خطأ
|
|
261
|
-
| `fn`
|
|
262
|
-
| `fn` يستغرق
|
|
252
|
+
| `customPoliciesPath` لم يتم تعيينه | لا تعمل سياسات مخصصة صريحة؛ تستمر السياسات والمدمجات الاتفاقية بشكل طبيعي |
|
|
253
|
+
| لم يتم العثور على الملف | تحذير مسجل في `~/.failproofai/hook.log`؛ تستمر المدمجات |
|
|
254
|
+
| خطأ الصيغة/الاستيراد (صريح) | خطأ مسجل في `~/.failproofai/hook.log`؛ تم تخطي السياسات المخصصة الصريحة |
|
|
255
|
+
| خطأ الصيغة/الاستيراد (الاتفاقية) | خطأ مسجل؛ هذا الملف مخطي، لكن ملفات الاتفاقية الأخرى تحمل لا تزال |
|
|
256
|
+
| `fn` يرمي في وقت التشغيل | خطأ مسجل؛ يتم التعامل مع الخطاف كـ `allow`؛ تستمر الخطافات الأخرى |
|
|
257
|
+
| `fn` يستغرق أطول من 10 ثوانٍ | انتهاء المهلة الزمنية المسجلة؛ يتم التعامل معها كـ `allow` |
|
|
263
258
|
| مجلد الاتفاقية مفقود | لا تعمل سياسات الاتفاقية؛ لا خطأ |
|
|
264
259
|
|
|
265
260
|
<Tip>
|
|
266
|
-
لتصحيح أخطاء
|
|
261
|
+
لتصحيح أخطاء السياسات المخصصة، شاهد ملف السجل:
|
|
267
262
|
|
|
268
263
|
```bash
|
|
269
264
|
tail -f ~/.failproofai/hook.log
|
|
@@ -329,14 +324,14 @@ export { customPolicies };
|
|
|
329
324
|
|
|
330
325
|
## أمثلة
|
|
331
326
|
|
|
332
|
-
يحتوي
|
|
327
|
+
يحتوي مجلد `examples/` على ملفات السياسات الجاهزة للتشغيل:
|
|
333
328
|
|
|
334
|
-
| الملف |
|
|
329
|
+
| الملف | المحتويات |
|
|
335
330
|
|------|----------|
|
|
336
|
-
| `examples/policies-basic.js` | خمس سياسات للمبتدئين تغطي
|
|
337
|
-
| `examples/policies-advanced/index.js` | أنماط متقدمة: واردات متعدية، استدعاءات غير متزامنة،
|
|
338
|
-
| `examples/convention-policies/security-policies.mjs` | سياسات الأمان
|
|
339
|
-
| `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` | سياسات سير العمل القائمة على الاتفاقية (تذكيرات الاختبار، ملفات الكتابة بالتدقيق) |
|
|
340
335
|
|
|
341
336
|
### استخدام أمثلة الملفات الصريحة
|
|
342
337
|
|
|
@@ -344,7 +339,7 @@ export { customPolicies };
|
|
|
344
339
|
failproofai policies --install --custom ./examples/policies-basic.js
|
|
345
340
|
```
|
|
346
341
|
|
|
347
|
-
### استخدام أمثلة الاتفاقية
|
|
342
|
+
### استخدام أمثلة قائمة على الاتفاقية
|
|
348
343
|
|
|
349
344
|
```bash
|
|
350
345
|
# Copy to project level
|
|
@@ -356,4 +351,4 @@ mkdir -p ~/.failproofai/policies
|
|
|
356
351
|
cp examples/convention-policies/*.mjs ~/.failproofai/policies/
|
|
357
352
|
```
|
|
358
353
|
|
|
359
|
-
لا
|
|
354
|
+
لا يلزم أمر التثبيت — يتم التقاط الملفات تلقائياً في حدث الخطاف التالي.
|
|
@@ -102,9 +102,9 @@ The handler enforces a 1 MB stdin limit. Payloads exceeding this are discarded a
|
|
|
102
102
|
- Exit code: `0`
|
|
103
103
|
- Empty stdout
|
|
104
104
|
|
|
105
|
-
**Allow with message
|
|
105
|
+
**Allow with message:**
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
`allow(message)` lets a policy send informational context back to Claude even when the operation is permitted. The hook handler writes the following JSON to **stdout** (not a config file — this is the handler's response to Claude Code, just like deny and instruct responses above):
|
|
108
108
|
|
|
109
109
|
```json
|
|
110
110
|
// Written to stdout by the hook handler process
|
|
@@ -153,7 +153,7 @@ Path to a JavaScript file containing custom hook policies. This is set automatic
|
|
|
153
153
|
|
|
154
154
|
The file is loaded fresh on every hook event - there is no caching. See [Custom Policies](/custom-policies) for authoring details.
|
|
155
155
|
|
|
156
|
-
### Convention-based policies
|
|
156
|
+
### Convention-based policies
|
|
157
157
|
|
|
158
158
|
In addition to the explicit `customPoliciesPath`, failproofai automatically discovers and loads policy files from `.failproofai/policies/` directories:
|
|
159
159
|
|
|
@@ -39,7 +39,7 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
39
39
|
|
|
40
40
|
## Two ways to load custom policies
|
|
41
41
|
|
|
42
|
-
### Option 1: Convention-based (recommended
|
|
42
|
+
### Option 1: Convention-based (recommended)
|
|
43
43
|
|
|
44
44
|
Drop `*policies.{js,mjs,ts}` files into `.failproofai/policies/` and they're automatically loaded — no flags or config changes needed. This works like git hooks: drop a file, it just works.
|
|
45
45
|
|
|
@@ -125,11 +125,7 @@ customPolicies.add({
|
|
|
125
125
|
You can append extra guidance to any `deny` or `instruct` message by adding a `hint` field in `policyParams` — no code change needed. This works for custom (`custom/`), project convention (`.failproofai-project/`), and user convention (`.failproofai-user/`) policies too. See [Configuration → hint](/configuration#hint-cross-cutting) for details.
|
|
126
126
|
</Tip>
|
|
127
127
|
|
|
128
|
-
### Informational allow messages
|
|
129
|
-
|
|
130
|
-
<Note>
|
|
131
|
-
`allow(message)` is a beta feature available since v0.0.2-beta.3. The API may change in future releases. Earlier versions only support `allow()` without arguments.
|
|
132
|
-
</Note>
|
|
128
|
+
### Informational allow messages
|
|
133
129
|
|
|
134
130
|
`allow(message)` permits the operation **and** sends an informational message back to Claude. The message is delivered as `additionalContext` in the hook handler's stdout response — the same mechanism used by `instruct`, but semantically different: it's a status update, not a warning.
|
|
135
131
|
|