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,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
|
-
### Option 1: Konventionsbasiert (empfohlen
|
|
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,32 +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)` ist eine Beta-Funktion, verfügbar seit v0.0.2-beta.3. Die API kann sich in zukünftigen Releases ändern. Ältere Versionen unterstützen nur `allow()` ohne Argumente.
|
|
132
|
-
</Note>
|
|
133
|
-
|
|
134
|
-
`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.
|
|
135
131
|
|
|
136
132
|
| Funktion | Wirkung | Verwendung |
|
|
137
133
|
|----------|---------|------------|
|
|
138
|
-
| `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 |
|
|
139
135
|
|
|
140
136
|
Anwendungsfälle:
|
|
141
|
-
- **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
|
|
142
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
|
|
143
|
-
- **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
|
|
144
140
|
|
|
145
141
|
```js
|
|
146
142
|
customPolicies.add({
|
|
@@ -166,23 +162,23 @@ customPolicies.add({
|
|
|
166
162
|
| `eventType` | `string` | `"PreToolUse"`, `"PostToolUse"`, `"Notification"`, `"Stop"` |
|
|
167
163
|
| `toolName` | `string \| undefined` | Das aufgerufene Tool (z. B. `"Bash"`, `"Write"`, `"Read"`) |
|
|
168
164
|
| `toolInput` | `Record<string, unknown> \| undefined` | Die Eingabeparameter des Tools |
|
|
169
|
-
| `payload` | `Record<string, unknown>` |
|
|
165
|
+
| `payload` | `Record<string, unknown>` | Vollständiger roher Event-Payload von Claude Code |
|
|
170
166
|
| `session` | `SessionMetadata \| undefined` | Sitzungskontext (siehe unten) |
|
|
171
167
|
|
|
172
168
|
### `SessionMetadata`-Felder
|
|
173
169
|
|
|
174
170
|
| Feld | Typ | Beschreibung |
|
|
175
171
|
|------|-----|--------------|
|
|
176
|
-
| `sessionId` | `string` | Claude Code-
|
|
172
|
+
| `sessionId` | `string` | Claude Code-Sitzungskennung |
|
|
177
173
|
| `cwd` | `string` | Arbeitsverzeichnis der Claude Code-Sitzung |
|
|
178
174
|
| `transcriptPath` | `string` | Pfad zur JSONL-Transkriptdatei der Sitzung |
|
|
179
175
|
|
|
180
|
-
###
|
|
176
|
+
### Event-Typen
|
|
181
177
|
|
|
182
|
-
|
|
|
183
|
-
|
|
178
|
+
| Event | Wann es ausgelöst wird | Inhalt von `toolInput` |
|
|
179
|
+
|-------|----------------------|----------------------|
|
|
184
180
|
| `PreToolUse` | Bevor Claude ein Tool ausführt | Die Eingabe des Tools (z. B. `{ command: "..." }` für Bash) |
|
|
185
|
-
| `PostToolUse` | Nachdem ein Tool abgeschlossen
|
|
181
|
+
| `PostToolUse` | Nachdem ein Tool abgeschlossen wurde | Die Eingabe des Tools + `tool_result` (die Ausgabe) |
|
|
186
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 |
|
|
187
183
|
| `Stop` | Wenn die Claude-Sitzung endet | Leer |
|
|
188
184
|
|
|
@@ -222,13 +218,13 @@ customPolicies.add({
|
|
|
222
218
|
});
|
|
223
219
|
```
|
|
224
220
|
|
|
225
|
-
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.
|
|
226
222
|
|
|
227
223
|
---
|
|
228
224
|
|
|
229
|
-
##
|
|
225
|
+
## Event-Typ-Filterung
|
|
230
226
|
|
|
231
|
-
|
|
227
|
+
Mit `match.events` lässt sich einschränken, wann eine Richtlinie ausgelöst wird:
|
|
232
228
|
|
|
233
229
|
```js
|
|
234
230
|
customPolicies.add({
|
|
@@ -242,13 +238,13 @@ customPolicies.add({
|
|
|
242
238
|
});
|
|
243
239
|
```
|
|
244
240
|
|
|
245
|
-
|
|
241
|
+
`match` ganz weglassen, um bei jedem Event-Typ auszulösen.
|
|
246
242
|
|
|
247
243
|
---
|
|
248
244
|
|
|
249
|
-
## Fehlerbehandlung und
|
|
245
|
+
## Fehlerbehandlung und Fehlerverhalten
|
|
250
246
|
|
|
251
|
-
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.
|
|
252
248
|
|
|
253
249
|
| Fehler | Verhalten |
|
|
254
250
|
|--------|-----------|
|
|
@@ -257,11 +253,11 @@ Benutzerdefinierte Richtlinien sind **fail-open**: Fehler blockieren niemals ein
|
|
|
257
253
|
| Syntax-/Importfehler (explizit) | Fehler wird in `~/.failproofai/hook.log` protokolliert; explizite benutzerdefinierte Richtlinien werden übersprungen |
|
|
258
254
|
| Syntax-/Importfehler (Konvention) | Fehler wird protokolliert; diese Datei wird übersprungen, andere Konventionsdateien werden weiterhin geladen |
|
|
259
255
|
| `fn` wirft zur Laufzeit | Fehler wird protokolliert; dieser Hook wird als `allow` behandelt; andere Hooks laufen weiter |
|
|
260
|
-
| `fn` dauert länger als
|
|
256
|
+
| `fn` dauert länger als 10 s | Timeout wird protokolliert; wird als `allow` behandelt |
|
|
261
257
|
| Konventionsverzeichnis fehlt | Keine Konventionsrichtlinien werden ausgeführt; kein Fehler |
|
|
262
258
|
|
|
263
259
|
<Tip>
|
|
264
|
-
|
|
260
|
+
Zum Debuggen von benutzerdefinierten Richtlinienfehlern die Log-Datei beobachten:
|
|
265
261
|
|
|
266
262
|
```bash
|
|
267
263
|
tail -f ~/.failproofai/hook.log
|
|
@@ -270,7 +266,7 @@ tail -f ~/.failproofai/hook.log
|
|
|
270
266
|
|
|
271
267
|
---
|
|
272
268
|
|
|
273
|
-
## Vollständiges Beispiel:
|
|
269
|
+
## Vollständiges Beispiel: Mehrere Richtlinien
|
|
274
270
|
|
|
275
271
|
```js
|
|
276
272
|
// my-policies.js
|
|
@@ -289,7 +285,7 @@ customPolicies.add({
|
|
|
289
285
|
},
|
|
290
286
|
});
|
|
291
287
|
|
|
292
|
-
// Agenten auf Kurs
|
|
288
|
+
// Hält den Agenten auf Kurs: Tests vor dem Commit prüfen
|
|
293
289
|
customPolicies.add({
|
|
294
290
|
name: "remind-test-before-commit",
|
|
295
291
|
description: "Keep the agent on track: verify tests pass before committing",
|
|
@@ -304,7 +300,7 @@ customPolicies.add({
|
|
|
304
300
|
},
|
|
305
301
|
});
|
|
306
302
|
|
|
307
|
-
//
|
|
303
|
+
// Verhindert ungeplante Abhängigkeitsänderungen während des Freeze
|
|
308
304
|
customPolicies.add({
|
|
309
305
|
name: "dependency-freeze",
|
|
310
306
|
description: "Prevent unplanned dependency changes during freeze period",
|
|
@@ -327,14 +323,14 @@ export { customPolicies };
|
|
|
327
323
|
|
|
328
324
|
## Beispiele
|
|
329
325
|
|
|
330
|
-
Das Verzeichnis `examples/` enthält
|
|
326
|
+
Das Verzeichnis `examples/` enthält direkt ausführbare Richtliniendateien:
|
|
331
327
|
|
|
332
328
|
| Datei | Inhalt |
|
|
333
329
|
|-------|--------|
|
|
334
330
|
| `examples/policies-basic.js` | Fünf Starter-Richtlinien für häufige Agenten-Fehlermodi |
|
|
335
|
-
| `examples/policies-advanced/index.js` | Fortgeschrittene Muster: transitive Importe, asynchrone Aufrufe,
|
|
336
|
-
| `examples/convention-policies/security-policies.mjs` | Konventionsbasierte Sicherheitsrichtlinien (blockiert .env-Schreibzugriffe, verhindert Git-
|
|
337
|
-
| `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) |
|
|
338
334
|
|
|
339
335
|
### Explizite Dateibeispiele verwenden
|
|
340
336
|
|
|
@@ -354,4 +350,4 @@ mkdir -p ~/.failproofai/policies
|
|
|
354
350
|
cp examples/convention-policies/*.mjs ~/.failproofai/policies/
|
|
355
351
|
```
|
|
356
352
|
|
|
357
|
-
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,15 +96,15 @@ 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`
|
|
103
103
|
- stdout vacío
|
|
104
104
|
|
|
105
|
-
**Permitir con mensaje
|
|
105
|
+
**Permitir con mensaje:**
|
|
106
106
|
|
|
107
|
-
|
|
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 @@ Desde v0.0.2-beta.3, `allow(message)` permite que una política envíe contexto
|
|
|
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 @@ Desde v0.0.2-beta.3, `allow(message)` permite que una política envíe contexto
|
|
|
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
|
```
|