failproofai 0.0.5 → 0.0.6-beta.1
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 +112 -0
- 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 +5 -5
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0g72weg._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__092s1ta._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__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]__0okos0k._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0a~g15g._.js → [root-of-the-server]__0rh.18_._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0w6l33k._.js +6 -6
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0qn95h3._.js → [root-of-the-server]__0~kmh8w._.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 +5 -5
- 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/{0sme4lkv.tgn-.js → 01b~z8f1ws0rk.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0lgbwkfqmnsmc.js → 03rz6ykw-a2xi.js} +1 -1
- package/.next/standalone/.next/static/chunks/{17manv47o-~wp.js → 08t08igdql9yt.js} +1 -1
- package/.next/standalone/.next/static/chunks/09_k80d~cq2wg.js +4 -0
- package/.next/standalone/.next/static/chunks/{0ksdlt_1hucdm.js → 0bvhsa6zva2o..js} +1 -1
- package/.next/standalone/.next/static/chunks/{09ikntpt2-o9b.js → 0gbf4cphy8ksq.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0yumumfzx_f27.js → 0v.yd0kg_ld3r.js} +1 -1
- package/.next/standalone/.next/static/chunks/{13juklu.vksks.js → 0wlyoif4_kj_t.js} +1 -1
- package/.next/standalone/.next/static/chunks/{09e7drilkf1sn.js → 12simlrcfk3g2.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0em7tspi4kylh.js → 12~yi9oj8av8p.js} +2 -2
- package/.next/standalone/.next/static/chunks/{turbopack-0r26pc8h0y_-e.js → turbopack-0o7k.hakttp4k.js} +1 -1
- package/.next/standalone/CHANGELOG.md +13 -0
- package/.next/standalone/README.md +2 -2
- package/.next/standalone/bun.lock +43 -85
- package/.next/standalone/dist/cli.mjs +107 -3
- package/.next/standalone/docs/ar/architecture.mdx +65 -64
- package/.next/standalone/docs/ar/configuration.mdx +42 -42
- package/.next/standalone/docs/ar/custom-policies.mdx +62 -64
- package/.next/standalone/docs/built-in-policies.mdx +37 -0
- package/.next/standalone/docs/custom-policies.mdx +1 -1
- package/.next/standalone/docs/de/architecture.mdx +92 -92
- package/.next/standalone/docs/de/configuration.mdx +34 -34
- package/.next/standalone/docs/de/custom-policies.mdx +49 -50
- package/.next/standalone/docs/es/architecture.mdx +72 -72
- package/.next/standalone/docs/es/configuration.mdx +25 -25
- package/.next/standalone/docs/es/custom-policies.mdx +48 -49
- package/.next/standalone/docs/examples.mdx +54 -0
- package/.next/standalone/docs/fr/architecture.mdx +53 -53
- package/.next/standalone/docs/fr/configuration.mdx +25 -25
- package/.next/standalone/docs/fr/custom-policies.mdx +42 -43
- package/.next/standalone/docs/getting-started.mdx +52 -0
- package/.next/standalone/docs/he/architecture.mdx +66 -66
- package/.next/standalone/docs/he/configuration.mdx +53 -52
- package/.next/standalone/docs/he/custom-policies.mdx +72 -73
- package/.next/standalone/docs/hi/architecture.mdx +106 -106
- package/.next/standalone/docs/hi/configuration.mdx +39 -39
- package/.next/standalone/docs/hi/custom-policies.mdx +75 -76
- package/.next/standalone/docs/i18n/README.ar.md +66 -66
- package/.next/standalone/docs/i18n/README.de.md +38 -38
- package/.next/standalone/docs/i18n/README.es.md +38 -38
- package/.next/standalone/docs/i18n/README.fr.md +42 -42
- package/.next/standalone/docs/i18n/README.he.md +67 -67
- package/.next/standalone/docs/i18n/README.hi.md +70 -70
- package/.next/standalone/docs/i18n/README.it.md +62 -62
- package/.next/standalone/docs/i18n/README.ja.md +54 -54
- package/.next/standalone/docs/i18n/README.ko.md +58 -58
- package/.next/standalone/docs/i18n/README.pt-br.md +43 -43
- package/.next/standalone/docs/i18n/README.ru.md +69 -69
- package/.next/standalone/docs/i18n/README.tr.md +76 -76
- package/.next/standalone/docs/i18n/README.vi.md +70 -70
- package/.next/standalone/docs/i18n/README.zh.md +52 -52
- package/.next/standalone/docs/it/architecture.mdx +54 -53
- package/.next/standalone/docs/it/configuration.mdx +44 -45
- package/.next/standalone/docs/it/custom-policies.mdx +76 -78
- package/.next/standalone/docs/ja/architecture.mdx +93 -93
- package/.next/standalone/docs/ja/configuration.mdx +47 -47
- package/.next/standalone/docs/ja/custom-policies.mdx +62 -63
- package/.next/standalone/docs/ko/architecture.mdx +66 -66
- package/.next/standalone/docs/ko/configuration.mdx +35 -35
- package/.next/standalone/docs/ko/custom-policies.mdx +71 -72
- package/.next/standalone/docs/pt-br/architecture.mdx +55 -55
- package/.next/standalone/docs/pt-br/configuration.mdx +35 -35
- package/.next/standalone/docs/pt-br/custom-policies.mdx +60 -61
- 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 +68 -69
- package/.next/standalone/docs/tr/architecture.mdx +124 -124
- package/.next/standalone/docs/tr/configuration.mdx +45 -46
- package/.next/standalone/docs/tr/custom-policies.mdx +75 -75
- package/.next/standalone/docs/vi/architecture.mdx +65 -64
- package/.next/standalone/docs/vi/configuration.mdx +41 -41
- package/.next/standalone/docs/vi/custom-policies.mdx +68 -69
- package/.next/standalone/docs/zh/architecture.mdx +67 -67
- package/.next/standalone/docs/zh/configuration.mdx +34 -34
- package/.next/standalone/docs/zh/custom-policies.mdx +53 -54
- package/.next/standalone/node_modules/@next/env/package.json +1 -1
- package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +7 -7
- package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/.next/standalone/node_modules/next/dist/server/config-schema.js +10 -2
- package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/render.js +27 -20
- package/.next/standalone/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
- package/.next/standalone/node_modules/next/package.json +15 -15
- package/.next/standalone/package.json +2 -2
- package/.next/standalone/server.js +1 -1
- package/.next/standalone/src/hooks/builtin-policies.ts +131 -0
- package/README.md +2 -2
- package/dist/cli.mjs +107 -3
- package/package.json +2 -2
- package/src/hooks/builtin-policies.ts +131 -0
- package/.next/standalone/.next/static/chunks/0_yayar~bpphd.js +0 -4
- /package/.next/standalone/.next/static/{hYQM6iCWnF1W5XDpsIRhV → CkmOT-ZvDN-sVULinGVKT}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{hYQM6iCWnF1W5XDpsIRhV → CkmOT-ZvDN-sVULinGVKT}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{hYQM6iCWnF1W5XDpsIRhV → CkmOT-ZvDN-sVULinGVKT}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Benutzerdefinierte Richtlinien
|
|
3
|
-
description: "
|
|
3
|
+
description: "Schreibe eigene Richtlinien in JavaScript – Konventionen durchsetzen, Drift verhindern, Fehler erkennen, externe Systeme integrieren"
|
|
4
4
|
icon: code
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Benutzerdefinierte Richtlinien ermöglichen es
|
|
7
|
+
Benutzerdefinierte Richtlinien ermöglichen es dir, Regeln für jedes Agentenverhalten zu schreiben: Projektkonventionen durchsetzen, Drift verhindern, destruktive Operationen absichern, feststeckende Agenten erkennen oder Slack, Genehmigungsworkflows und mehr integrieren. Sie verwenden dasselbe Hook-Event-System und dieselben `allow`-, `deny`-, `instruct`-Entscheidungen wie eingebaute Richtlinien.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ customPolicies.add({
|
|
|
29
29
|
});
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Installieren:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
failproofai policies --install --custom ./my-policies.js
|
|
@@ -37,14 +37,14 @@ failproofai policies --install --custom ./my-policies.js
|
|
|
37
37
|
|
|
38
38
|
---
|
|
39
39
|
|
|
40
|
-
## Zwei
|
|
40
|
+
## Zwei Möglichkeiten, benutzerdefinierte Richtlinien zu laden
|
|
41
41
|
|
|
42
42
|
### Option 1: Konventionsbasiert (empfohlen)
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
Lege `*policies.{js,mjs,ts}`-Dateien in `.failproofai/policies/` ab – sie werden automatisch geladen, ohne Flags oder Konfigurationsänderungen. Das funktioniert wie Git-Hooks: Datei ablegen, fertig.
|
|
45
45
|
|
|
46
46
|
```
|
|
47
|
-
# Projektebene –
|
|
47
|
+
# Projektebene – in Git eingecheckt, mit dem Team geteilt
|
|
48
48
|
.failproofai/policies/security-policies.mjs
|
|
49
49
|
.failproofai/policies/workflow-policies.mjs
|
|
50
50
|
|
|
@@ -52,15 +52,15 @@ Legen Sie `*policies.{js,mjs,ts}`-Dateien in `.failproofai/policies/` ab – sie
|
|
|
52
52
|
~/.failproofai/policies/my-policies.mjs
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
**
|
|
56
|
-
- Sowohl Projekt- als auch Benutzerverzeichnisse werden durchsucht (Vereinigung – kein
|
|
57
|
-
- Dateien werden innerhalb jedes Verzeichnisses alphabetisch geladen.
|
|
58
|
-
- Nur Dateien, die `*policies.{js,mjs,ts}`
|
|
55
|
+
**Funktionsweise:**
|
|
56
|
+
- Sowohl Projekt- als auch Benutzerverzeichnisse werden durchsucht (Vereinigung – kein „erste Scope gewinnt")
|
|
57
|
+
- Dateien werden innerhalb jedes Verzeichnisses alphabetisch geladen. Mit `01-`, `02-` als Präfix lässt sich die Reihenfolge steuern
|
|
58
|
+
- Nur Dateien, die auf `*policies.{js,mjs,ts}` passen, werden geladen; andere Dateien werden ignoriert
|
|
59
59
|
- Jede Datei wird unabhängig geladen (fail-open pro Datei)
|
|
60
60
|
- Funktioniert zusammen mit explizitem `--custom` und eingebauten Richtlinien
|
|
61
61
|
|
|
62
62
|
<Tip>
|
|
63
|
-
|
|
63
|
+
Konventionsrichtlinien sind der einfachste Weg, Richtlinien im Team zu teilen. Checke `.failproofai/policies/` in Git ein und alle Teammitglieder erhalten sie automatisch.
|
|
64
64
|
</Tip>
|
|
65
65
|
|
|
66
66
|
### Option 2: Expliziter Dateipfad
|
|
@@ -76,13 +76,13 @@ failproofai policies --install --custom ./new-policies.js
|
|
|
76
76
|
failproofai policies --uninstall --custom
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Der aufgelöste absolute Pfad wird in `policies-config.json` als `customPoliciesPath` gespeichert. Die Datei wird bei jedem Hook-
|
|
79
|
+
Der aufgelöste absolute Pfad wird in `policies-config.json` als `customPoliciesPath` gespeichert. Die Datei wird bei jedem Hook-Event neu geladen – es gibt kein Caching zwischen Events.
|
|
80
80
|
|
|
81
|
-
### Beide
|
|
81
|
+
### Beide Varianten kombiniert
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Konventionsrichtlinien und die explizite `--custom`-Datei können nebeneinander existieren. Ladereihenfolge:
|
|
84
84
|
|
|
85
|
-
1. Explizite `customPoliciesPath`-Datei (
|
|
85
|
+
1. Explizite `customPoliciesPath`-Datei (sofern konfiguriert)
|
|
86
86
|
2. Projekt-Konventionsdateien (`{cwd}/.failproofai/policies/`, alphabetisch)
|
|
87
87
|
3. Benutzer-Konventionsdateien (`~/.failproofai/policies/`, alphabetisch)
|
|
88
88
|
|
|
@@ -98,13 +98,13 @@ import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
|
98
98
|
|
|
99
99
|
### `customPolicies.add(hook)`
|
|
100
100
|
|
|
101
|
-
Registriert eine Richtlinie. Kann
|
|
101
|
+
Registriert eine Richtlinie. Kann mehrfach aufgerufen werden, um mehrere Richtlinien in derselben Datei zu definieren.
|
|
102
102
|
|
|
103
103
|
```ts
|
|
104
104
|
customPolicies.add({
|
|
105
105
|
name: string; // erforderlich – eindeutiger Bezeichner
|
|
106
|
-
description?: string; //
|
|
107
|
-
match?: { events?: HookEventType[] }; // nach
|
|
106
|
+
description?: string; // erscheint in der `failproofai policies`-Ausgabe
|
|
107
|
+
match?: { events?: HookEventType[] }; // nach Event-Typ filtern; weglassen für alle Events
|
|
108
108
|
fn: (ctx: PolicyContext) => PolicyResult | Promise<PolicyResult>;
|
|
109
109
|
});
|
|
110
110
|
```
|
|
@@ -115,29 +115,28 @@ customPolicies.add({
|
|
|
115
115
|
|----------|---------|------------|
|
|
116
116
|
| `allow()` | Operation lautlos zulassen | Die Aktion ist sicher, keine Meldung erforderlich |
|
|
117
117
|
| `deny(message)` | Operation blockieren | Der Agent soll diese Aktion nicht ausführen |
|
|
118
|
-
| `instruct(message)` | Kontext hinzufügen ohne zu blockieren | Dem Agenten zusätzlichen Kontext geben, um auf Kurs zu
|
|
118
|
+
| `instruct(message)` | Kontext hinzufügen ohne zu blockieren | Dem Agenten zusätzlichen Kontext geben, um ihn auf Kurs zu halten |
|
|
119
119
|
|
|
120
|
-
`deny(message)` – die Nachricht erscheint
|
|
120
|
+
`deny(message)` – die Nachricht erscheint für Claude mit dem Präfix `"Blocked by failproofai:"`. Ein einzelnes `deny` bricht alle weitere Auswertung ab.
|
|
121
121
|
|
|
122
|
-
`instruct(message)` – die Nachricht wird dem
|
|
122
|
+
`instruct(message)` – die Nachricht wird dem Kontext von Claude für den aktuellen Tool-Aufruf angehängt. Alle `instruct`-Nachrichten werden gesammelt und gemeinsam zugestellt.
|
|
123
123
|
|
|
124
124
|
<Tip>
|
|
125
|
-
|
|
125
|
+
Zu jeder `deny`- oder `instruct`-Nachricht können zusätzliche Hinweise hinzugefügt werden, indem ein `hint`-Feld in `policyParams` gesetzt wird – ohne Codeänderung. Das funktioniert auch für benutzerdefinierte (`custom/`), Projekt-Konventions- (`.failproofai-project/`) und Benutzer-Konventionsrichtlinien (`.failproofai-user/`). Siehe [Konfiguration → hint](/de/configuration#hint-cross-cutting) für Details.
|
|
126
126
|
</Tip>
|
|
127
127
|
|
|
128
|
-
### Informative
|
|
128
|
+
### Informative Allow-Nachrichten
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
`allow(message)` lässt die Operation zu **und** sendet eine informative Nachricht an Claude zurück. Die Nachricht wird als `additionalContext` in der stdout-Antwort des Hook-Handlers zugestellt – derselbe Mechanismus wie bei `instruct`, jedoch semantisch anders: Es handelt sich um eine Statusmeldung, nicht um eine Warnung.
|
|
130
|
+
`allow(message)` erlaubt die Operation **und** sendet eine informative Nachricht zurück an Claude. Die Nachricht wird als `additionalContext` in der stdout-Antwort des Hook-Handlers zugestellt – derselbe Mechanismus wie bei `instruct`, aber semantisch anders: Es ist eine Statusmeldung, keine Warnung.
|
|
132
131
|
|
|
133
132
|
| Funktion | Wirkung | Verwendung |
|
|
134
133
|
|----------|---------|------------|
|
|
135
|
-
| `allow(message)` | Zulassen und Kontext an Claude senden | Bestätigen, dass eine Prüfung bestanden wurde, oder erklären, warum
|
|
134
|
+
| `allow(message)` | Zulassen und Kontext an Claude senden | Bestätigen, dass eine Prüfung bestanden wurde, oder erklären, warum sie übersprungen wurde |
|
|
136
135
|
|
|
137
136
|
Anwendungsfälle:
|
|
138
|
-
- **Statusbestätigungen:** `allow("All CI checks passed.")` – teilt Claude mit, dass alles
|
|
137
|
+
- **Statusbestätigungen:** `allow("All CI checks passed.")` – teilt Claude mit, dass alles grün ist
|
|
139
138
|
- **Fail-open-Erklärungen:** `allow("GitHub CLI not installed, skipping CI check.")` – erklärt Claude, warum eine Prüfung übersprungen wurde, damit er den vollen Kontext hat
|
|
140
|
-
- **Mehrere Nachrichten werden
|
|
139
|
+
- **Mehrere Nachrichten werden akkumuliert:** Geben mehrere Richtlinien je ein `allow(message)` zurück, werden alle Nachrichten mit Zeilenumbrüchen verbunden und gemeinsam zugestellt
|
|
141
140
|
|
|
142
141
|
```js
|
|
143
142
|
customPolicies.add({
|
|
@@ -163,23 +162,23 @@ customPolicies.add({
|
|
|
163
162
|
| `eventType` | `string` | `"PreToolUse"`, `"PostToolUse"`, `"Notification"`, `"Stop"` |
|
|
164
163
|
| `toolName` | `string \| undefined` | Das aufgerufene Tool (z. B. `"Bash"`, `"Write"`, `"Read"`) |
|
|
165
164
|
| `toolInput` | `Record<string, unknown> \| undefined` | Die Eingabeparameter des Tools |
|
|
166
|
-
| `payload` | `Record<string, unknown>` |
|
|
165
|
+
| `payload` | `Record<string, unknown>` | Vollständiger roher Event-Payload von Claude Code |
|
|
167
166
|
| `session` | `SessionMetadata \| undefined` | Sitzungskontext (siehe unten) |
|
|
168
167
|
|
|
169
168
|
### `SessionMetadata`-Felder
|
|
170
169
|
|
|
171
170
|
| Feld | Typ | Beschreibung |
|
|
172
171
|
|------|-----|--------------|
|
|
173
|
-
| `sessionId` | `string` | Claude Code-
|
|
172
|
+
| `sessionId` | `string` | Claude Code-Sitzungskennung |
|
|
174
173
|
| `cwd` | `string` | Arbeitsverzeichnis der Claude Code-Sitzung |
|
|
175
174
|
| `transcriptPath` | `string` | Pfad zur JSONL-Transkriptdatei der Sitzung |
|
|
176
175
|
|
|
177
|
-
###
|
|
176
|
+
### Event-Typen
|
|
178
177
|
|
|
179
|
-
|
|
|
180
|
-
|
|
178
|
+
| Event | Wann es ausgelöst wird | Inhalt von `toolInput` |
|
|
179
|
+
|-------|----------------------|----------------------|
|
|
181
180
|
| `PreToolUse` | Bevor Claude ein Tool ausführt | Die Eingabe des Tools (z. B. `{ command: "..." }` für Bash) |
|
|
182
|
-
| `PostToolUse` | Nachdem ein Tool abgeschlossen
|
|
181
|
+
| `PostToolUse` | Nachdem ein Tool abgeschlossen wurde | Die Eingabe des Tools + `tool_result` (die Ausgabe) |
|
|
183
182
|
| `Notification` | Wenn Claude eine Benachrichtigung sendet | `{ message: "...", notification_type: "idle" \| "permission_prompt" \| ... }` – Hooks müssen immer `allow()` zurückgeben, Benachrichtigungen können nicht blockiert werden |
|
|
184
183
|
| `Stop` | Wenn die Claude-Sitzung endet | Leer |
|
|
185
184
|
|
|
@@ -219,13 +218,13 @@ customPolicies.add({
|
|
|
219
218
|
});
|
|
220
219
|
```
|
|
221
220
|
|
|
222
|
-
Alle relativen Importe
|
|
221
|
+
Alle transitiv erreichbaren relativen Importe von der Einstiegsdatei werden aufgelöst. Dies wird umgesetzt, indem `from "failproofai"`-Importe auf den tatsächlichen dist-Pfad umgeschrieben und temporäre `.mjs`-Dateien erstellt werden, um ESM-Kompatibilität sicherzustellen.
|
|
223
222
|
|
|
224
223
|
---
|
|
225
224
|
|
|
226
|
-
##
|
|
225
|
+
## Event-Typ-Filterung
|
|
227
226
|
|
|
228
|
-
|
|
227
|
+
Mit `match.events` lässt sich einschränken, wann eine Richtlinie ausgelöst wird:
|
|
229
228
|
|
|
230
229
|
```js
|
|
231
230
|
customPolicies.add({
|
|
@@ -239,13 +238,13 @@ customPolicies.add({
|
|
|
239
238
|
});
|
|
240
239
|
```
|
|
241
240
|
|
|
242
|
-
|
|
241
|
+
`match` ganz weglassen, um bei jedem Event-Typ auszulösen.
|
|
243
242
|
|
|
244
243
|
---
|
|
245
244
|
|
|
246
|
-
## Fehlerbehandlung und
|
|
245
|
+
## Fehlerbehandlung und Fehlerverhalten
|
|
247
246
|
|
|
248
|
-
Benutzerdefinierte Richtlinien sind **fail-open**: Fehler blockieren niemals eingebaute Richtlinien
|
|
247
|
+
Benutzerdefinierte Richtlinien sind **fail-open**: Fehler blockieren niemals eingebaute Richtlinien oder bringen den Hook-Handler zum Absturz.
|
|
249
248
|
|
|
250
249
|
| Fehler | Verhalten |
|
|
251
250
|
|--------|-----------|
|
|
@@ -254,11 +253,11 @@ Benutzerdefinierte Richtlinien sind **fail-open**: Fehler blockieren niemals ein
|
|
|
254
253
|
| Syntax-/Importfehler (explizit) | Fehler wird in `~/.failproofai/hook.log` protokolliert; explizite benutzerdefinierte Richtlinien werden übersprungen |
|
|
255
254
|
| Syntax-/Importfehler (Konvention) | Fehler wird protokolliert; diese Datei wird übersprungen, andere Konventionsdateien werden weiterhin geladen |
|
|
256
255
|
| `fn` wirft zur Laufzeit | Fehler wird protokolliert; dieser Hook wird als `allow` behandelt; andere Hooks laufen weiter |
|
|
257
|
-
| `fn` dauert länger als
|
|
256
|
+
| `fn` dauert länger als 10 s | Timeout wird protokolliert; wird als `allow` behandelt |
|
|
258
257
|
| Konventionsverzeichnis fehlt | Keine Konventionsrichtlinien werden ausgeführt; kein Fehler |
|
|
259
258
|
|
|
260
259
|
<Tip>
|
|
261
|
-
|
|
260
|
+
Zum Debuggen von benutzerdefinierten Richtlinienfehlern die Log-Datei beobachten:
|
|
262
261
|
|
|
263
262
|
```bash
|
|
264
263
|
tail -f ~/.failproofai/hook.log
|
|
@@ -267,7 +266,7 @@ tail -f ~/.failproofai/hook.log
|
|
|
267
266
|
|
|
268
267
|
---
|
|
269
268
|
|
|
270
|
-
## Vollständiges Beispiel:
|
|
269
|
+
## Vollständiges Beispiel: Mehrere Richtlinien
|
|
271
270
|
|
|
272
271
|
```js
|
|
273
272
|
// my-policies.js
|
|
@@ -286,7 +285,7 @@ customPolicies.add({
|
|
|
286
285
|
},
|
|
287
286
|
});
|
|
288
287
|
|
|
289
|
-
// Agenten auf Kurs
|
|
288
|
+
// Hält den Agenten auf Kurs: Tests vor dem Commit prüfen
|
|
290
289
|
customPolicies.add({
|
|
291
290
|
name: "remind-test-before-commit",
|
|
292
291
|
description: "Keep the agent on track: verify tests pass before committing",
|
|
@@ -301,7 +300,7 @@ customPolicies.add({
|
|
|
301
300
|
},
|
|
302
301
|
});
|
|
303
302
|
|
|
304
|
-
//
|
|
303
|
+
// Verhindert ungeplante Abhängigkeitsänderungen während des Freeze
|
|
305
304
|
customPolicies.add({
|
|
306
305
|
name: "dependency-freeze",
|
|
307
306
|
description: "Prevent unplanned dependency changes during freeze period",
|
|
@@ -324,14 +323,14 @@ export { customPolicies };
|
|
|
324
323
|
|
|
325
324
|
## Beispiele
|
|
326
325
|
|
|
327
|
-
Das Verzeichnis `examples/` enthält
|
|
326
|
+
Das Verzeichnis `examples/` enthält direkt ausführbare Richtliniendateien:
|
|
328
327
|
|
|
329
328
|
| Datei | Inhalt |
|
|
330
329
|
|-------|--------|
|
|
331
330
|
| `examples/policies-basic.js` | Fünf Starter-Richtlinien für häufige Agenten-Fehlermodi |
|
|
332
|
-
| `examples/policies-advanced/index.js` | Fortgeschrittene Muster: transitive Importe, asynchrone Aufrufe,
|
|
333
|
-
| `examples/convention-policies/security-policies.mjs` | Konventionsbasierte Sicherheitsrichtlinien (blockiert .env-Schreibzugriffe, verhindert Git-
|
|
334
|
-
| `examples/convention-policies/workflow-policies.mjs` | Konventionsbasierte Workflow-Richtlinien (Test-Erinnerungen,
|
|
331
|
+
| `examples/policies-advanced/index.js` | Fortgeschrittene Muster: transitive Importe, asynchrone Aufrufe, Ausgabebereinigung und Sitzungsend-Hooks |
|
|
332
|
+
| `examples/convention-policies/security-policies.mjs` | Konventionsbasierte Sicherheitsrichtlinien (blockiert .env-Schreibzugriffe, verhindert Umschreiben der Git-Historie) |
|
|
333
|
+
| `examples/convention-policies/workflow-policies.mjs` | Konventionsbasierte Workflow-Richtlinien (Test-Erinnerungen, Protokollierung von Datei-Schreibzugriffen) |
|
|
335
334
|
|
|
336
335
|
### Explizite Dateibeispiele verwenden
|
|
337
336
|
|
|
@@ -351,4 +350,4 @@ mkdir -p ~/.failproofai/policies
|
|
|
351
350
|
cp examples/convention-policies/*.mjs ~/.failproofai/policies/
|
|
352
351
|
```
|
|
353
352
|
|
|
354
|
-
Kein Installationsbefehl erforderlich – die Dateien werden beim nächsten Hook-
|
|
353
|
+
Kein Installationsbefehl erforderlich – die Dateien werden beim nächsten Hook-Event automatisch erkannt.
|
|
@@ -4,16 +4,16 @@ description: "Cómo funcionan internamente el manejador de hooks, la carga de co
|
|
|
4
4
|
icon: sitemap
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Este documento explica cómo funciona failproofai internamente: cómo el sistema de hooks intercepta las llamadas a herramientas del agente, cómo se carga y
|
|
7
|
+
Este documento explica cómo funciona failproofai internamente: cómo el sistema de hooks intercepta las llamadas a herramientas del agente, cómo se carga y combina la configuración, cómo se evalúan las políticas y cómo el panel de control monitoriza la actividad del agente.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
## Descripción general
|
|
12
12
|
|
|
13
|
-
failproofai
|
|
13
|
+
failproofai tiene dos subsistemas independientes:
|
|
14
14
|
|
|
15
|
-
1. **Manejador de hooks**
|
|
16
|
-
2. **Monitor de agentes (Panel de control)**
|
|
15
|
+
1. **Manejador de hooks** — Un subproceso CLI rápido que Claude Code invoca en cada llamada a herramienta del agente. Evalúa las políticas y devuelve una decisión.
|
|
16
|
+
2. **Monitor de agentes (Panel de control)** — Una aplicación web Next.js para monitorizar sesiones de agentes y gestionar políticas.
|
|
17
17
|
|
|
18
18
|
Ambos subsistemas comparten archivos de configuración en `~/.failproofai/` y en el directorio `.failproofai/` del proyecto, pero se ejecutan como procesos separados y se comunican únicamente a través del sistema de archivos.
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@ Ambos subsistemas comparten archivos de configuración en `~/.failproofai/` y en
|
|
|
23
23
|
|
|
24
24
|
### Integración con Claude Code
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Cuando ejecutas `failproofai policies --install`, escribe entradas como esta en `~/.claude/settings.json`:
|
|
27
27
|
|
|
28
28
|
```json
|
|
29
29
|
{
|
|
@@ -44,7 +44,7 @@ Al ejecutar `failproofai policies --install`, se escriben entradas como estas en
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Claude Code
|
|
47
|
+
Claude Code invoca entonces `failproofai --hook PreToolUse` como subproceso antes de cada llamada a herramienta, pasando un payload JSON por stdin.
|
|
48
48
|
|
|
49
49
|
### Formato del payload
|
|
50
50
|
|
|
@@ -62,7 +62,7 @@ Claude Code luego invoca `failproofai --hook PreToolUse` como subproceso antes d
|
|
|
62
62
|
|
|
63
63
|
Para eventos `PostToolUse`, el payload también contiene `tool_result` con la salida de la herramienta.
|
|
64
64
|
|
|
65
|
-
El manejador
|
|
65
|
+
El manejador impone un límite de 1 MB en stdin. Los payloads que superen este tamaño se descartan y todas las políticas permiten implícitamente.
|
|
66
66
|
|
|
67
67
|
### Formato de respuesta
|
|
68
68
|
|
|
@@ -96,7 +96,7 @@ El manejador aplica un límite de 1 MB en stdin. Los payloads que superen este l
|
|
|
96
96
|
|
|
97
97
|
**Instruir en evento Stop:**
|
|
98
98
|
- Código de salida: `2`
|
|
99
|
-
-
|
|
99
|
+
- El motivo se escribe en stderr (no en stdout)
|
|
100
100
|
|
|
101
101
|
**Permitir:**
|
|
102
102
|
- Código de salida: `0`
|
|
@@ -104,7 +104,7 @@ El manejador aplica un límite de 1 MB en stdin. Los payloads que superen este l
|
|
|
104
104
|
|
|
105
105
|
**Permitir con mensaje:**
|
|
106
106
|
|
|
107
|
-
`allow(message)` permite que una política envíe contexto informativo a Claude incluso cuando la operación está permitida. El manejador de hooks escribe el siguiente JSON en **stdout** (no en un archivo de configuración — esta es la respuesta del manejador a Claude Code, igual que las respuestas de deny e instruct anteriores):
|
|
107
|
+
`allow(message)` permite que una política envíe contexto informativo de vuelta a Claude incluso cuando la operación está permitida. El manejador de hooks escribe el siguiente JSON en **stdout** (no en un archivo de configuración — esta es la respuesta del manejador a Claude Code, igual que las respuestas de deny e instruct anteriores):
|
|
108
108
|
|
|
109
109
|
```json
|
|
110
110
|
// Written to stdout by the hook handler process
|
|
@@ -115,8 +115,8 @@ El manejador aplica un límite de 1 MB en stdin. Los payloads que superen este l
|
|
|
115
115
|
}
|
|
116
116
|
```
|
|
117
117
|
- Código de salida: `0` (la operación está permitida)
|
|
118
|
-
- Cuando
|
|
119
|
-
- Si ninguna política proporciona un mensaje, stdout
|
|
118
|
+
- Cuando varias políticas devuelven `allow` con un mensaje, sus mensajes se unen con saltos de línea en una sola cadena `additionalContext`
|
|
119
|
+
- Si ninguna política proporciona un mensaje, stdout queda vacío (igual que antes)
|
|
120
120
|
|
|
121
121
|
### Pipeline de procesamiento
|
|
122
122
|
|
|
@@ -124,22 +124,22 @@ El manejador aplica un límite de 1 MB en stdin. Los payloads que superen este l
|
|
|
124
124
|
|
|
125
125
|
```text
|
|
126
126
|
stdin JSON
|
|
127
|
-
→
|
|
128
|
-
→
|
|
129
|
-
→ readMergedHooksConfig(cwd) ←
|
|
130
|
-
→
|
|
131
|
-
→
|
|
132
|
-
→
|
|
133
|
-
→
|
|
134
|
-
→
|
|
135
|
-
→
|
|
136
|
-
→
|
|
137
|
-
→
|
|
138
|
-
→
|
|
139
|
-
→
|
|
127
|
+
→ parse payload (max 1 MB)
|
|
128
|
+
→ extract session metadata (session_id, cwd, tool_name, tool_input, etc.)
|
|
129
|
+
→ readMergedHooksConfig(cwd) ← merges project + local + global config
|
|
130
|
+
→ register enabled builtin policies with resolved params
|
|
131
|
+
→ load custom policies from customPoliciesPath (if set)
|
|
132
|
+
→ register custom policies into policy registry
|
|
133
|
+
→ evaluate all policies (builtins first, then custom)
|
|
134
|
+
→ first deny short-circuits
|
|
135
|
+
→ instruct decisions accumulate
|
|
136
|
+
→ allow messages accumulate
|
|
137
|
+
→ write JSON decision to stdout
|
|
138
|
+
→ persist event to ~/.failproofai/hook-activity.jsonl
|
|
139
|
+
→ exit
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
Todo el proceso se ejecuta en menos de 100 ms para payloads típicos sin
|
|
142
|
+
Todo el proceso se ejecuta en menos de 100 ms para payloads típicos sin ninguna llamada a LLM.
|
|
143
143
|
|
|
144
144
|
---
|
|
145
145
|
|
|
@@ -148,18 +148,18 @@ Todo el proceso se ejecuta en menos de 100 ms para payloads típicos sin llamada
|
|
|
148
148
|
`src/hooks/hooks-config.ts` implementa la carga de configuración en tres ámbitos.
|
|
149
149
|
|
|
150
150
|
```text
|
|
151
|
-
[1] {cwd}/.failproofai/policies-config.json ← proyecto (
|
|
151
|
+
[1] {cwd}/.failproofai/policies-config.json ← proyecto (máxima prioridad)
|
|
152
152
|
[2] {cwd}/.failproofai/policies-config.local.json ← local
|
|
153
|
-
[3] ~/.failproofai/policies-config.json ← global (
|
|
153
|
+
[3] ~/.failproofai/policies-config.json ← global (mínima prioridad)
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
Lógica de
|
|
157
|
-
- `enabledPolicies`
|
|
158
|
-
- `policyParams`
|
|
159
|
-
- `customPoliciesPath`
|
|
160
|
-
- `llm`
|
|
156
|
+
Lógica de combinación:
|
|
157
|
+
- `enabledPolicies` — unión sin duplicados de los tres archivos
|
|
158
|
+
- `policyParams` — clave por política; gana íntegramente el primer archivo que la defina
|
|
159
|
+
- `customPoliciesPath` — gana el primer archivo que lo defina
|
|
160
|
+
- `llm` — gana el primer archivo que lo defina
|
|
161
161
|
|
|
162
|
-
El panel de control web utiliza `readHooksConfig()` (solo global) para
|
|
162
|
+
El panel de control web utiliza `readHooksConfig()` (solo global) para lectura y escritura, ya que no se invoca con un cwd de proyecto.
|
|
163
163
|
|
|
164
164
|
---
|
|
165
165
|
|
|
@@ -169,18 +169,18 @@ El panel de control web utiliza `readHooksConfig()` (solo global) para leer y es
|
|
|
169
169
|
|
|
170
170
|
Para cada política:
|
|
171
171
|
|
|
172
|
-
1.
|
|
173
|
-
2.
|
|
174
|
-
3.
|
|
175
|
-
4.
|
|
176
|
-
5. Si el resultado es `deny`,
|
|
177
|
-
6. Si el resultado es `instruct`,
|
|
178
|
-
7. Si el resultado es `allow`,
|
|
172
|
+
1. Busca el esquema `params` de la política (si tiene uno).
|
|
173
|
+
2. Lee `policyParams[policy.name]` de la configuración combinada.
|
|
174
|
+
3. Combina los valores proporcionados por el usuario sobre los valores predeterminados del esquema para producir `ctx.params`.
|
|
175
|
+
4. Llama a `policy.fn(ctx)` con el contexto resuelto.
|
|
176
|
+
5. Si el resultado es `deny`, se detiene inmediatamente y devuelve esa decisión.
|
|
177
|
+
6. Si el resultado es `instruct`, acumula el mensaje y continúa.
|
|
178
|
+
7. Si el resultado es `allow`, continúa con la siguiente política.
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
- Si se devolvió algún `deny`,
|
|
182
|
-
- Si se recopilaron respuestas `instruct`,
|
|
183
|
-
- En caso contrario,
|
|
180
|
+
Tras ejecutar todas las políticas:
|
|
181
|
+
- Si se devolvió algún `deny`, emite la respuesta de deny.
|
|
182
|
+
- Si se recopilaron respuestas `instruct`, emite una única respuesta instruct con todos los mensajes unidos.
|
|
183
|
+
- En caso contrario, emite una respuesta allow (stdout vacío, exit 0).
|
|
184
184
|
|
|
185
185
|
---
|
|
186
186
|
|
|
@@ -206,7 +206,7 @@ interface BuiltinPolicyDefinition {
|
|
|
206
206
|
|
|
207
207
|
Las políticas que aceptan `params` declaran un `PolicyParamsSchema` con tipos y valores predeterminados para cada parámetro. El evaluador de políticas inyecta los valores resueltos en `ctx.params` antes de llamar a `fn`. Las funciones de política leen `ctx.params` sin comprobaciones de nulo porque los valores predeterminados siempre se aplican primero.
|
|
208
208
|
|
|
209
|
-
La coincidencia de patrones dentro de las políticas
|
|
209
|
+
La coincidencia de patrones dentro de las políticas utiliza tokens de comando analizados (argv), no coincidencia de cadenas sin procesar. Esto evita la elusión mediante inyección de operadores de shell (p. ej., un patrón para `sudo systemctl status *` no puede eludirse añadiendo `; rm -rf /` al comando).
|
|
210
210
|
|
|
211
211
|
---
|
|
212
212
|
|
|
@@ -227,23 +227,23 @@ export function clearCustomHooks(): void { ... } // used in tests
|
|
|
227
227
|
|
|
228
228
|
`src/hooks/custom-hooks-loader.ts` carga el archivo de políticas del usuario:
|
|
229
229
|
|
|
230
|
-
1.
|
|
231
|
-
2.
|
|
232
|
-
3.
|
|
233
|
-
4.
|
|
234
|
-
5.
|
|
235
|
-
6.
|
|
236
|
-
7.
|
|
230
|
+
1. Lee `customPoliciesPath` de la configuración; omite si no existe.
|
|
231
|
+
2. Resuelve a ruta absoluta; comprueba que el archivo existe.
|
|
232
|
+
3. Reescribe todas las importaciones `from "failproofai"` a la ruta dist real para que `customPolicies` resuelva al mismo registro `globalThis`.
|
|
233
|
+
4. Reescribe recursivamente las importaciones locales transitivas para garantizar la compatibilidad con ESM.
|
|
234
|
+
5. Escribe archivos `.mjs` temporales e importa el archivo de entrada con `import()`.
|
|
235
|
+
6. Llama a `getCustomHooks()` para recuperar los hooks registrados.
|
|
236
|
+
7. Limpia todos los archivos temporales en un bloque `finally`.
|
|
237
237
|
|
|
238
238
|
Ante cualquier error (archivo no encontrado, error de sintaxis, fallo de importación), el error se registra en `~/.failproofai/hook.log` y el cargador devuelve un array vacío. Las políticas integradas no se ven afectadas.
|
|
239
239
|
|
|
240
|
-
Las políticas personalizadas se evalúan después de todas las políticas integradas. Un `deny` de una política personalizada sigue
|
|
240
|
+
Las políticas personalizadas se evalúan después de todas las políticas integradas. Un `deny` de una política personalizada sigue cortocircuitando las demás políticas personalizadas (pero en ese punto todas las integradas ya han sido ejecutadas).
|
|
241
241
|
|
|
242
242
|
---
|
|
243
243
|
|
|
244
244
|
## Registro de actividad
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
Tras cada evento de hook, el manejador añade una línea JSONL a `~/.failproofai/hook-activity.jsonl`:
|
|
247
247
|
|
|
248
248
|
```json
|
|
249
249
|
{
|
|
@@ -258,7 +258,7 @@ Después de cada evento de hook, el manejador añade una línea JSONL a `~/.fail
|
|
|
258
258
|
}
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
-
Una línea por política que tomó una decisión
|
|
261
|
+
Una línea por política que tomó una decisión distinta de allow. Las decisiones allow no se registran (para mantener el archivo pequeño).
|
|
262
262
|
|
|
263
263
|
---
|
|
264
264
|
|
|
@@ -268,11 +268,11 @@ El panel de control es una aplicación **Next.js 16** que utiliza el App Router
|
|
|
268
268
|
|
|
269
269
|
```text
|
|
270
270
|
app/
|
|
271
|
-
layout.tsx ←
|
|
272
|
-
projects/page.tsx ← Componente servidor:
|
|
273
|
-
project/[name]/page.tsx ← Componente servidor:
|
|
271
|
+
layout.tsx ← Diseño raíz (tema, telemetría, nav)
|
|
272
|
+
projects/page.tsx ← Componente servidor: lista todos los proyectos Claude
|
|
273
|
+
project/[name]/page.tsx ← Componente servidor: lista sesiones de un proyecto
|
|
274
274
|
project/[name]/session/
|
|
275
|
-
[sessionId]/page.tsx ← Componente servidor:
|
|
275
|
+
[sessionId]/page.tsx ← Componente servidor: renderiza el visor de sesión
|
|
276
276
|
policies/page.tsx ← Componente cliente: gestión de políticas + registro de actividad
|
|
277
277
|
actions/
|
|
278
278
|
get-hooks-config.ts ← Leer configuración + lista de políticas
|
|
@@ -286,16 +286,16 @@ app/
|
|
|
286
286
|
|
|
287
287
|
**Flujo de datos:**
|
|
288
288
|
|
|
289
|
-
- Los componentes de página llaman a `lib/projects.ts` y `lib/log-entries.ts` para leer datos de proyectos
|
|
290
|
-
- La página de políticas usa Server Actions para todas las mutaciones (activar/desactivar,
|
|
291
|
-
- El visor de
|
|
289
|
+
- Los componentes de página llaman a `lib/projects.ts` y `lib/log-entries.ts` para leer datos de proyectos y sesiones directamente desde el sistema de archivos (sin capa de API para lecturas).
|
|
290
|
+
- La página de políticas usa Server Actions para todas las mutaciones (activar/desactivar, actualizar parámetros, instalar/eliminar).
|
|
291
|
+
- El visor de sesiones analiza el formato de transcripción JSONL de Claude y renderiza una línea de tiempo de mensajes y llamadas a herramientas.
|
|
292
292
|
|
|
293
293
|
**Decisiones de diseño clave:**
|
|
294
294
|
|
|
295
|
-
- Sin base de datos
|
|
296
|
-
- Server Actions para mutaciones
|
|
297
|
-
- React Server Components para páginas de lectura
|
|
298
|
-
- Componentes cliente solo donde se necesita interactividad (activación de políticas, búsqueda de actividad, visor de
|
|
295
|
+
- Sin base de datos — todo el estado persistente está en archivos planos (`~/.failproofai/`, `~/.claude/projects/`).
|
|
296
|
+
- Server Actions para mutaciones — no se necesita una API REST para operaciones CRUD.
|
|
297
|
+
- React Server Components para páginas de lectura — carga inicial más rápida, sin bundle de cliente para la obtención de datos.
|
|
298
|
+
- Componentes cliente solo donde se necesita interactividad (activación de políticas, búsqueda de actividad, visor de registros).
|
|
299
299
|
|
|
300
300
|
---
|
|
301
301
|
|
|
@@ -313,20 +313,20 @@ failproofai/
|
|
|
313
313
|
│ ├── policy-types.ts # Interfaces TypeScript
|
|
314
314
|
│ ├── hooks-config.ts # Carga de configuración multi-ámbito
|
|
315
315
|
│ ├── custom-hooks-registry.ts # Registro de hooks respaldado por globalThis
|
|
316
|
-
│ ├── custom-hooks-loader.ts # Cargador ESM para hooks JS
|
|
317
|
-
│ ├── manager.ts # Operaciones de
|
|
316
|
+
│ ├── custom-hooks-loader.ts # Cargador ESM para hooks JS de usuario
|
|
317
|
+
│ ├── manager.ts # Operaciones de instalar / eliminar / listar
|
|
318
318
|
│ ├── install-prompt.ts # Prompt interactivo de selección de políticas
|
|
319
319
|
│ ├── hook-logger.ts # Registro en hook.log
|
|
320
320
|
│ ├── hook-activity-store.ts # Persistir actividad en hook-activity.jsonl
|
|
321
|
-
│ └── llm-client.ts # Cliente API
|
|
321
|
+
│ └── llm-client.ts # Cliente API LLM (para políticas con IA)
|
|
322
322
|
├── app/ # Panel de control Next.js (páginas + server actions)
|
|
323
323
|
├── lib/ # Utilidades compartidas
|
|
324
324
|
│ ├── projects.ts # Enumerar proyectos Claude desde el sistema de archivos
|
|
325
|
-
│ ├── log-entries.ts #
|
|
325
|
+
│ ├── log-entries.ts # Analizar el formato JSONL de transcripción de Claude
|
|
326
326
|
│ ├── paths.ts # Resolver rutas del sistema
|
|
327
327
|
│ └── ...
|
|
328
|
-
├── components/ # Componentes UI
|
|
328
|
+
├── components/ # Componentes React UI compartidos
|
|
329
329
|
├── contexts/ # Proveedores de contexto React (tema, auto-refresco, telemetría)
|
|
330
330
|
├── examples/ # Archivos de hooks personalizados de ejemplo
|
|
331
|
-
└── __tests__/ #
|
|
331
|
+
└── __tests__/ # Pruebas unitarias y E2E
|
|
332
332
|
```
|