@bookedsolid/reagent 0.3.0 → 0.4.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.
Files changed (114) hide show
  1. package/README.md +163 -82
  2. package/agents/ai-platforms/ai-anthropic-specialist.md +1 -1
  3. package/agents/ai-platforms/ai-fine-tuning-specialist.md +1 -1
  4. package/agents/ai-platforms/ai-gemini-specialist.md +1 -1
  5. package/agents/ai-platforms/ai-mcp-developer.md +1 -1
  6. package/agents/ai-platforms/ai-multi-modal-specialist.md +1 -1
  7. package/agents/ai-platforms/ai-open-source-models-specialist.md +1 -1
  8. package/agents/ai-platforms/ai-openai-specialist.md +1 -1
  9. package/agents/ai-platforms/ai-platform-strategist.md +1 -1
  10. package/agents/ai-platforms/ai-prompt-engineer.md +1 -1
  11. package/agents/ai-platforms/ai-rag-architect.md +1 -1
  12. package/agents/ai-platforms/ai-rea.md +2 -2
  13. package/agents/ai-platforms/ai-safety-reviewer.md +1 -1
  14. package/agents/engineering/accessibility-engineer.md +1 -1
  15. package/agents/engineering/aws-architect.md +1 -1
  16. package/agents/engineering/backend-engineer-payments.md +1 -1
  17. package/agents/engineering/backend-engineering-manager.md +1 -1
  18. package/agents/engineering/code-reviewer.md +1 -1
  19. package/agents/engineering/css3-animation-purist.md +1 -1
  20. package/agents/engineering/data-engineer.md +1 -1
  21. package/agents/engineering/database-architect.md +1 -1
  22. package/agents/engineering/design-system-developer.md +1 -1
  23. package/agents/engineering/design-systems-animator.md +1 -1
  24. package/agents/engineering/devops-engineer.md +1 -1
  25. package/agents/engineering/drupal-integration-specialist.md +1 -1
  26. package/agents/engineering/drupal-specialist.md +1 -1
  27. package/agents/engineering/engineering-manager-frontend.md +1 -1
  28. package/agents/engineering/frontend-specialist.md +1 -1
  29. package/agents/engineering/infrastructure-engineer.md +1 -1
  30. package/agents/engineering/lit-specialist.md +1 -1
  31. package/agents/engineering/migration-specialist.md +1 -1
  32. package/agents/engineering/ml-engineer.md +1 -1
  33. package/agents/engineering/mobile-engineer.md +1 -1
  34. package/agents/engineering/motion-designer-interactive.md +1 -1
  35. package/agents/engineering/nextjs-specialist.md +1 -1
  36. package/agents/engineering/open-source-specialist.md +1 -1
  37. package/agents/engineering/performance-engineer.md +1 -1
  38. package/agents/engineering/performance-qa-engineer.md +1 -1
  39. package/agents/engineering/pr-maintainer.md +1 -1
  40. package/agents/engineering/principal-engineer.md +1 -1
  41. package/agents/engineering/privacy-engineer.md +1 -1
  42. package/agents/engineering/qa-engineer.md +1 -1
  43. package/agents/engineering/security-engineer.md +1 -1
  44. package/agents/engineering/security-qa-engineer.md +1 -1
  45. package/agents/engineering/senior-backend-engineer.md +1 -1
  46. package/agents/engineering/senior-database-engineer.md +1 -1
  47. package/agents/engineering/senior-frontend-engineer.md +1 -1
  48. package/agents/engineering/senior-product-manager-platform.md +1 -1
  49. package/agents/engineering/senior-technical-project-manager.md +1 -1
  50. package/agents/engineering/site-reliability-engineer-2.md +1 -1
  51. package/agents/engineering/solutions-architect.md +1 -1
  52. package/agents/engineering/sre-lead.md +1 -1
  53. package/agents/engineering/staff-engineer-platform.md +1 -1
  54. package/agents/engineering/staff-software-engineer.md +1 -1
  55. package/agents/engineering/storybook-specialist.md +1 -1
  56. package/agents/engineering/supabase-specialist.md +1 -1
  57. package/agents/engineering/technical-project-manager.md +1 -1
  58. package/agents/engineering/technical-writer.md +1 -1
  59. package/agents/engineering/test-architect.md +1 -1
  60. package/agents/engineering/typescript-specialist.md +1 -1
  61. package/agents/engineering/ux-researcher.md +1 -1
  62. package/agents/engineering/vp-engineering.md +1 -1
  63. package/dist/cli/commands/init.d.ts.map +1 -1
  64. package/dist/cli/commands/init.js +52 -3
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/config/gateway-config.d.ts.map +1 -1
  67. package/dist/config/gateway-config.js +5 -1
  68. package/dist/config/gateway-config.js.map +1 -1
  69. package/dist/config/policy-loader.d.ts.map +1 -1
  70. package/dist/config/policy-loader.js +15 -1
  71. package/dist/config/policy-loader.js.map +1 -1
  72. package/dist/config/tier-map.d.ts +1 -1
  73. package/dist/config/tier-map.d.ts.map +1 -1
  74. package/dist/config/tier-map.js +38 -5
  75. package/dist/config/tier-map.js.map +1 -1
  76. package/dist/gateway/client-manager.d.ts.map +1 -1
  77. package/dist/gateway/client-manager.js +9 -3
  78. package/dist/gateway/client-manager.js.map +1 -1
  79. package/dist/gateway/middleware/audit.d.ts +2 -1
  80. package/dist/gateway/middleware/audit.d.ts.map +1 -1
  81. package/dist/gateway/middleware/audit.js +57 -46
  82. package/dist/gateway/middleware/audit.js.map +1 -1
  83. package/dist/gateway/middleware/blocked-paths.d.ts +13 -0
  84. package/dist/gateway/middleware/blocked-paths.d.ts.map +1 -0
  85. package/dist/gateway/middleware/blocked-paths.js +118 -0
  86. package/dist/gateway/middleware/blocked-paths.js.map +1 -0
  87. package/dist/gateway/middleware/policy.d.ts +3 -1
  88. package/dist/gateway/middleware/policy.d.ts.map +1 -1
  89. package/dist/gateway/middleware/policy.js +22 -3
  90. package/dist/gateway/middleware/policy.js.map +1 -1
  91. package/dist/gateway/middleware/redact.d.ts.map +1 -1
  92. package/dist/gateway/middleware/redact.js +18 -5
  93. package/dist/gateway/middleware/redact.js.map +1 -1
  94. package/dist/gateway/server.d.ts.map +1 -1
  95. package/dist/gateway/server.js +7 -4
  96. package/dist/gateway/server.js.map +1 -1
  97. package/dist/gateway/tool-proxy.d.ts.map +1 -1
  98. package/dist/gateway/tool-proxy.js +18 -6
  99. package/dist/gateway/tool-proxy.js.map +1 -1
  100. package/dist/types/enums.d.ts +0 -4
  101. package/dist/types/enums.d.ts.map +1 -1
  102. package/dist/types/enums.js +0 -5
  103. package/dist/types/enums.js.map +1 -1
  104. package/dist/types/index.d.ts +1 -1
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/index.js +1 -1
  107. package/dist/types/index.js.map +1 -1
  108. package/hooks/attribution-advisory.sh +1 -1
  109. package/hooks/dangerous-bash-interceptor.sh +1 -1
  110. package/hooks/env-file-protection.sh +1 -1
  111. package/hooks/secret-scanner.sh +1 -1
  112. package/package.json +16 -1
  113. package/profiles/bst-internal.json +1 -1
  114. package/templates/CLAUDE.md +14 -1
package/README.md CHANGED
@@ -4,19 +4,21 @@ Zero-trust MCP gateway and agentic infrastructure for AI-assisted development.
4
4
 
5
5
  Reagent is two things:
6
6
 
7
- 1. **MCP Gateway** (`reagent serve`) a proxy server that sits between your AI assistant (Claude Code, Cursor, etc.) and downstream MCP tool servers. Every tool call flows through a zero-trust middleware chain: policy enforcement, tier classification, secret redaction, and hash-chained audit logging.
7
+ 1. **MCP Gateway** (`reagent serve`) -- a proxy server that sits between your AI assistant (Claude Code, Cursor, etc.) and downstream MCP tool servers. Every tool call flows through a zero-trust middleware chain: policy enforcement, tier classification, blocked path enforcement, secret redaction, and hash-chained audit logging.
8
8
 
9
- 2. **Config Scaffolder** (`reagent init`) installs safety hooks, behavioral policies, and developer tooling into any project.
9
+ 2. **Config Scaffolder** (`reagent init`) -- installs safety hooks, behavioral policies, and developer tooling into any project.
10
10
 
11
11
  ## Why Reagent?
12
12
 
13
13
  AI coding assistants are powerful but unconstrained. Reagent adds the missing governance layer:
14
14
 
15
- - **Policy enforcement** graduated autonomy levels (L0 read-only L3 full access) control which tiers of tools an agent can invoke
16
- - **Kill switch** `reagent freeze` immediately blocks all tool calls across every connected MCP server
17
- - **Secret redaction** tool outputs are scanned for AWS keys, GitHub tokens, API keys, PEM private keys, Discord tokens, and more — redacted before they reach the AI
18
- - **Audit trail** every tool invocation is logged as hash-chained JSONL, providing tamper-evident compliance records
19
- - **Tool blocking** individual tools can be permanently blocked regardless of autonomy level
15
+ - **Policy enforcement** -- graduated autonomy levels (L0 read-only through L3 full access) control which tiers of tools an agent can invoke
16
+ - **Kill switch** -- `reagent freeze` immediately blocks all tool calls across every connected MCP server
17
+ - **Blocked path enforcement** -- tool arguments referencing protected paths (including `.reagent/` itself) are denied before execution
18
+ - **Secret redaction** -- tool arguments and outputs are scanned for AWS keys, GitHub tokens, API keys, PEM private keys, Discord tokens, and more -- redacted before they reach the AI or the downstream tool
19
+ - **Audit trail** -- every tool invocation is logged as hash-chained JSONL with serialized writes for chain integrity
20
+ - **Tool blocking** -- individual tools can be permanently blocked regardless of autonomy level
21
+ - **Tier downgrade protection** -- `tool_overrides` cannot lower a tool's tier below its static or convention-based classification
20
22
 
21
23
  ## Quick Start
22
24
 
@@ -68,37 +70,51 @@ npx @bookedsolid/reagent init --dry-run
68
70
  | `reagent serve` | Start the MCP gateway server (stdio transport) |
69
71
  | `reagent init` | Install reagent config into the current directory |
70
72
  | `reagent check` | Verify what reagent components are installed |
71
- | `reagent freeze --reason "..."` | Create `.reagent/HALT` suspends all tool calls |
72
- | `reagent unfreeze` | Remove `.reagent/HALT` resumes tool calls |
73
+ | `reagent freeze --reason "..."` | Create `.reagent/HALT` -- suspends all tool calls |
74
+ | `reagent unfreeze` | Remove `.reagent/HALT` -- resumes tool calls |
73
75
  | `reagent help` | Show usage help |
74
76
 
77
+ ### `reagent init` Options
78
+
79
+ | Flag | Description | Default |
80
+ | ------------------ | ---------------------------------------------- | ------------------- |
81
+ | `--profile <name>` | Profile to install | `client-engagement` |
82
+ | `--dry-run` | Preview what would be installed without writes | -- |
83
+
84
+ ### `reagent freeze` Options
85
+
86
+ | Flag | Description | Default |
87
+ | ----------------- | ---------------------------------- | --------------- |
88
+ | `--reason <text>` | Reason for freeze (stored in HALT) | `Manual freeze` |
89
+
75
90
  ## MCP Gateway
76
91
 
77
92
  ### How It Works
78
93
 
79
94
  ```
80
95
  AI Assistant (Claude Code, Cursor, etc.)
81
-
82
- stdio (MCP protocol)
83
-
84
- ┌─────────────────────────────┐
85
- Reagent Gateway
86
-
87
- ┌───────────────────────┐ │
88
- Middleware Chain │ │
89
- │ │ │
90
- 1. Audit (outermost) │ │
91
- 2. Session context │ │
92
- 3. Kill switch │ │
93
- 4. Tier classify │ │
94
- 5. Policy enforce │ │
95
- 6. Secret redaction │ │
96
- 7. [Execute] │ │
97
- └───────────────────────┘
98
- │ │
99
- └──────────┬──────────────────┘
100
- │ stdio (MCP protocol)
101
-
96
+ |
97
+ | stdio (MCP protocol)
98
+ v
99
+ +-----------------------------+
100
+ | Reagent Gateway |
101
+ | |
102
+ | +------------------------+ |
103
+ | | Middleware Chain | |
104
+ | | | |
105
+ | | 1. Audit (outermost) | |
106
+ | | 2. Session context | |
107
+ | | 3. Kill switch | |
108
+ | | 4. Tier classify | |
109
+ | | 5. Policy enforce | |
110
+ | | 6. Blocked paths | |
111
+ | | 7. Secret redaction | |
112
+ | | 8. [Execute] | |
113
+ | +------------------------+ |
114
+ | |
115
+ +----------+------------------+
116
+ | stdio (MCP protocol)
117
+ v
102
118
  Downstream MCP Servers
103
119
  (discord-ops, filesystem, etc.)
104
120
  ```
@@ -136,9 +152,9 @@ servers:
136
152
  blocked: true
137
153
  ```
138
154
 
139
- **Environment variable resolution:** Use `${VAR_NAME}` syntax in env values Reagent resolves them from `process.env` at startup.
155
+ **Environment variable resolution:** Use `${VAR_NAME}` syntax in env values -- Reagent resolves them from `process.env` at startup. Missing env vars produce a warning and resolve to empty string.
140
156
 
141
- **Tool overrides:** Each downstream tool can be assigned a tier (`read`, `write`, `destructive`) and optionally blocked entirely.
157
+ **Tool overrides:** Each downstream tool can be assigned a tier (`read`, `write`, `destructive`) and optionally blocked entirely. Overrides cannot lower a tool's tier below its static or convention-based classification (the override is ignored with a warning if attempted).
142
158
 
143
159
  ### Tool Namespacing
144
160
 
@@ -177,7 +193,7 @@ Every tool call passes through the middleware chain in onion (Koa-style) order.
177
193
 
178
194
  ### 1. Audit (outermost)
179
195
 
180
- Records every invocation including denials as a hash-chained JSONL entry. Written to `.reagent/audit/YYYY-MM-DD.jsonl`. Each record contains:
196
+ Records every invocation -- including denials and errors -- as a hash-chained JSONL entry. Written to `.reagent/audit/YYYY-MM-DD.jsonl`. Each record contains:
181
197
 
182
198
  ```json
183
199
  {
@@ -194,18 +210,18 @@ Records every invocation — including denials — as a hash-chained JSONL entry
194
210
  }
195
211
  ```
196
212
 
197
- The `prev_hash` field chains records together tamper with one record and every subsequent hash becomes invalid.
213
+ The `prev_hash` field chains records together -- tamper with one record and every subsequent hash becomes invalid. Audit writes are serialized via a queue to maintain hash chain linearity under concurrent invocations. The `autonomy_level` is sourced from the loaded policy object, not from mutable invocation context.
198
214
 
199
215
  ### 2. Session Context
200
216
 
201
- Attaches a unique session ID (UUID) to every invocation. Each gateway instance generates one session ID at startup.
217
+ Attaches a unique session ID (UUID via `crypto.randomUUID()`) to every invocation. Each gateway instance generates one session ID at startup.
202
218
 
203
219
  ### 3. Kill Switch
204
220
 
205
- Checks for `.reagent/HALT` file. If present, the invocation is immediately denied. The HALT file contents become the denial reason.
221
+ Checks for `.reagent/HALT` file. If present, the invocation is immediately denied. The HALT file contents become the denial reason. Reads are capped at 1024 bytes. The file is validated as a regular file (symlinks outside `.reagent/` are rejected).
206
222
 
207
223
  ```bash
208
- # Emergency stop all tool calls blocked immediately
224
+ # Emergency stop -- all tool calls blocked immediately
209
225
  reagent freeze --reason "security incident at 2026-04-09T12:00:00Z"
210
226
 
211
227
  # Resume
@@ -214,7 +230,23 @@ reagent unfreeze
214
230
 
215
231
  ### 4. Tier Classification
216
232
 
217
- Classifies the tool into one of three tiers:
233
+ Classifies the tool into one of three tiers using a layered approach:
234
+
235
+ | Source | Priority | Description |
236
+ | ---------------- | -------- | ------------------------------------------ |
237
+ | Static map | 1st | Known tools with explicit tier assignments |
238
+ | Convention-based | 2nd | Prefix patterns for unknown tools |
239
+ | Default | 3rd | Falls back to `write` |
240
+
241
+ **Convention-based classification** allows non-Discord downstream servers to get sensible defaults:
242
+
243
+ | Prefix pattern | Tier |
244
+ | ------------------------------------------------------------------------------------------------------------ | ------------- |
245
+ | `get_`, `list_`, `search_`, `query_`, `read_`, `fetch_`, `check_`, `health_`, `describe_`, `show_`, `count_` | `read` |
246
+ | `delete_`, `drop_`, `purge_`, `remove_`, `destroy_`, `ban_`, `kick_`, `revoke_`, `truncate_` | `destructive` |
247
+ | Everything else | `write` |
248
+
249
+ **Tier tiers:**
218
250
 
219
251
  | Tier | Description | Examples |
220
252
  | ------------- | ------------------------------- | ------------------------------------------------ |
@@ -222,43 +254,47 @@ Classifies the tool into one of three tiers:
222
254
  | `write` | Modifies state | `send_message`, `create_channel`, `edit_message` |
223
255
  | `destructive` | Irreversible state changes | `delete_channel`, `purge_messages`, `ban_member` |
224
256
 
225
- Tiers are assigned via `tool_overrides` in gateway config. Unknown tools default to `write`.
226
-
227
257
  ### 5. Policy Enforcement
228
258
 
229
- Checks the tool's tier against the project's autonomy level:
259
+ Checks the tool's tier against the project's autonomy level. The policy middleware re-derives the tier from the tool name independently -- it never trusts `ctx.tier` from prior middleware.
230
260
 
231
261
  | Autonomy Level | Allowed Tiers |
232
262
  | ------------------ | -------------------------------- |
233
- | `L0` (read-only) | `read` only |
263
+ | `L0` (read-only) | `read` |
234
264
  | `L1` (standard) | `read` + `write` |
235
- | `L2` (elevated) | `read` + `write` + `destructive` |
236
- | `L3` (full access) | All tiers |
265
+ | `L2` (elevated) | `read` + `write` |
266
+ | `L3` (full access) | `read` + `write` + `destructive` |
267
+
268
+ Also checks for explicitly blocked tools -- a tool marked `blocked: true` in gateway config is denied regardless of autonomy level.
237
269
 
238
- Also checks for explicitly blocked tools — a tool marked `blocked: true` in gateway config is denied regardless of autonomy level.
270
+ ### 6. Blocked Paths
239
271
 
240
- ### 6. Secret Redaction
272
+ Scans all string-valued tool arguments for references to paths listed in the policy's `blocked_paths`. The `.reagent/` directory is always protected regardless of policy configuration. Matching uses normalized path containment (backslashes converted to forward slashes, relative path variants checked).
241
273
 
242
- Post-execution: scans tool output for sensitive patterns and replaces them with `[REDACTED]`:
274
+ ### 7. Secret Redaction
275
+
276
+ Operates both **pre-execution** (scanning tool arguments before they reach the downstream tool) and **post-execution** (scanning tool output before it reaches the AI). Detected patterns are replaced with `[REDACTED]`:
243
277
 
244
278
  - AWS Access Keys (`AKIA...`)
245
279
  - AWS Secret Keys
246
280
  - GitHub Tokens (`ghp_...`, `gho_...`, `ghs_...`, `ghu_...`, `ghr_...`)
247
281
  - Generic API Keys
248
282
  - Bearer Tokens
249
- - PEM Private Keys
283
+ - PEM Private Keys (RSA, EC, DSA)
250
284
  - Discord Bot Tokens
251
285
  - Base64-encoded AWS Keys
252
286
 
253
- Redaction operates on individual string values within structured results it never corrupts JSON structure.
287
+ Redaction uses `redactDeep` to walk object structures in-place with a circular reference guard (WeakSet). Input is sanitized (null bytes and control characters stripped) before pattern matching.
254
288
 
255
289
  ### Security Invariants
256
290
 
257
- - **Denial is permanent** once any middleware denies an invocation, no subsequent middleware can revert it
258
- - **Audit records everything** audit is outermost, so even kill-switch denials are recorded
259
- - **Policy re-derives tier** never trusts mutable context; always re-classifies from tool name
260
- - **Fail-closed** errors in kill-switch or policy checks result in denial, not passthrough
261
- - **All logging to stderr** stdout is reserved for the MCP stdio transport
291
+ - **Denial is permanent** -- once any middleware denies an invocation, no subsequent middleware can revert it (enforced by `executeChain`)
292
+ - **Audit records everything** -- audit is outermost, so even kill-switch denials are recorded
293
+ - **Policy re-derives tier** -- never trusts mutable context; always re-classifies from tool name
294
+ - **Fail-closed** -- errors in kill-switch or policy checks result in denial, not passthrough
295
+ - **All logging to stderr** -- stdout is reserved for the MCP stdio transport
296
+ - **Per-tool timeout** -- each downstream tool call has a 30-second timeout with timer cleanup to prevent leaks
297
+ - **Graceful shutdown** -- `process.exitCode = 0` (not `process.exit(0)`) to allow event loop drain
262
298
 
263
299
  ## Policy File
264
300
 
@@ -267,35 +303,46 @@ Redaction operates on individual string values within structured results — it
267
303
  ```yaml
268
304
  version: '1'
269
305
  profile: bst-internal
270
- installed_by: 'reagent init'
306
+ installed_by: 'reagent@0.3.0'
271
307
  installed_at: '2026-04-09T00:00:00.000Z'
272
308
  autonomy_level: L1
273
- max_autonomy_level: L3
309
+ max_autonomy_level: L2
274
310
  promotion_requires_human_approval: true
311
+ block_ai_attribution: true
275
312
  blocked_paths:
276
- - .github/workflows/
277
- - .env
278
- notification_channel: '#reagent-alerts'
313
+ - '.reagent/'
314
+ - '.env'
315
+ - '.env.*'
316
+ notification_channel: ''
279
317
  ```
280
318
 
281
- | Field | Description |
282
- | ----------------------------------- | ------------------------------------------------------------- |
283
- | `autonomy_level` | Current level (L0-L3) — controls which tool tiers are allowed |
284
- | `max_autonomy_level` | Ceiling agents cannot request escalation beyond this |
285
- | `promotion_requires_human_approval` | Whether level changes need human sign-off |
286
- | `blocked_paths` | Directories the agent must never modify |
319
+ | Field | Type | Description |
320
+ | ----------------------------------- | ---------- | -------------------------------------------------------------- |
321
+ | `version` | `string` | Schema version (currently `"1"`) |
322
+ | `profile` | `string` | Profile name used during init |
323
+ | `installed_by` | `string` | Tool and version that generated this file |
324
+ | `installed_at` | `string` | ISO 8601 timestamp of installation |
325
+ | `autonomy_level` | `enum` | Current level (L0-L3) -- controls which tool tiers are allowed |
326
+ | `max_autonomy_level` | `enum` | Ceiling -- `autonomy_level` is clamped to this on load |
327
+ | `promotion_requires_human_approval` | `boolean` | Whether level changes need human sign-off |
328
+ | `block_ai_attribution` | `boolean` | When true, commit-msg hook rejects AI attribution markers |
329
+ | `blocked_paths` | `string[]` | Paths the agent must never modify (`.reagent/` always added) |
330
+ | `notification_channel` | `string` | Optional notification channel identifier |
331
+
332
+ The `max_autonomy_level` field is enforced at config load time: if `autonomy_level` exceeds `max_autonomy_level`, it is clamped down with a warning.
287
333
 
288
334
  ## Config Scaffolder
289
335
 
290
336
  `reagent init` configures your repository with:
291
337
 
292
- - **Git hooks** commit-msg validation (Co-Authored-By attribution, secret detection) and pre-push quality gates
293
- - **Cursor rules** AI behavioral constraints for Cursor IDE
294
- - **Claude hooks** dangerous command interception, env file protection, secret scanning
295
- - **Claude settings** permission boundaries for Claude Code
296
- - **Policy file** `.reagent/policy.yaml` with graduated autonomy levels
297
- - **CLAUDE.md** project-level AI agent instructions
298
- - **Commands** `/restart` (session handoff) and `/rea` (AI team orchestration)
338
+ - **Git hooks** -- commit-msg validation, pre-commit checks, and pre-push quality gates (via Husky)
339
+ - **Cursor rules** -- AI behavioral constraints for Cursor IDE (no-hallucination, verify-before-act, attribution)
340
+ - **Claude hooks** -- dangerous command interception, env file protection, secret scanning, attribution advisory
341
+ - **Claude settings** -- permission boundaries for Claude Code (`.claude/settings.json`)
342
+ - **Policy file** -- `.reagent/policy.yaml` with graduated autonomy levels
343
+ - **CLAUDE.md** -- project-level AI agent instructions (managed block with markers)
344
+ - **Agent definitions** -- AI agent team definitions (`.claude/agents/`)
345
+ - **Commands** -- `/restart` (session handoff) and `/rea` (AI team orchestration)
299
346
 
300
347
  ### What Gets Installed
301
348
 
@@ -306,21 +353,26 @@ notification_channel: '#reagent-alerts'
306
353
  | `.reagent/audit/` | No (gitignored) | Hash-chained JSONL audit logs |
307
354
  | `.cursor/rules/` | Yes | Cursor IDE behavioral rules |
308
355
  | `.husky/commit-msg` | Yes | Git commit message validation |
356
+ | `.husky/pre-commit` | Yes | Pre-commit checks |
357
+ | `.husky/pre-push` | Yes | Pre-push quality gates |
309
358
  | `.claude/hooks/` | No (gitignored) | Claude Code safety hooks |
310
359
  | `.claude/settings.json` | No (gitignored) | Claude Code permissions |
360
+ | `.claude/agents/` | No (gitignored) | Agent team definitions |
311
361
  | `.claude/commands/` | Yes | Slash commands (restart, rea) |
312
362
  | `CLAUDE.md` | Yes | AI agent project instructions |
313
363
 
314
364
  ### Profiles
315
365
 
316
- | Profile | Use Case | Hooks |
317
- | ------------------- | -------------------------- | --------------------------------- |
318
- | `bst-internal` | BST's own repositories | Full hook suite + Claude commands |
319
- | `client-engagement` | Client consulting projects | Full hook suite + Claude commands |
366
+ | Profile | Use Case | Default Autonomy | Blocked Paths |
367
+ | ------------------- | -------------------------- | ---------------- | --------------------------------------------------- |
368
+ | `client-engagement` | Client consulting projects | L1 / max L2 | `.reagent/`, `.github/workflows/`, `.env`, `.env.*` |
369
+ | `bst-internal` | BST's own repositories | L1 / max L2 | `.reagent/`, `.env` |
370
+
371
+ Both profiles install the full hook suite (dangerous-bash-interceptor, env-file-protection, secret-scanner, attribution-advisory), Cursor rules, and Claude commands.
320
372
 
321
373
  ### Idempotent
322
374
 
323
- Run `reagent init` as many times as you want. It skips files that are already up-to-date and only updates what has changed.
375
+ Run `reagent init` as many times as you want. It skips files that are already up-to-date and only updates what has changed. Policy files are never overwritten if they already exist.
324
376
 
325
377
  ### Verify Installation
326
378
 
@@ -355,7 +407,7 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
355
407
  │ ├── config/ # Configuration loaders
356
408
  │ │ ├── policy-loader.ts # Zod-validated policy.yaml parser
357
409
  │ │ ├── gateway-config.ts # Zod-validated gateway.yaml parser
358
- │ │ └── tier-map.ts # Tool tier classification
410
+ │ │ └── tier-map.ts # Tool tier classification (static + convention)
359
411
  │ ├── gateway/ # MCP gateway core
360
412
  │ │ ├── server.ts # Gateway orchestrator (startup, shutdown)
361
413
  │ │ ├── client-manager.ts # Downstream MCP server connections
@@ -366,20 +418,49 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
366
418
  │ │ ├── kill-switch.ts # HALT file check
367
419
  │ │ ├── tier.ts # Tier classification
368
420
  │ │ ├── policy.ts # Autonomy level enforcement
369
- │ │ ├── redact.ts # Secret pattern redaction
421
+ │ │ ├── blocked-paths.ts # Blocked path enforcement
422
+ │ │ ├── redact.ts # Secret pattern redaction (pre + post)
370
423
  │ │ └── audit.ts # Hash-chained JSONL logging
371
424
  │ └── types/ # TypeScript type definitions
372
425
  ├── profiles/ # Init profiles (bst-internal, client-engagement)
373
426
  ├── templates/ # Template files for scaffolding
374
- ├── hooks/ # Git hook scripts
427
+ ├── hooks/ # Shell hook scripts
428
+ ├── husky/ # Husky git hook scripts
375
429
  ├── cursor/ # Cursor IDE rules
376
- └── agents/ # Agent definitions
430
+ ├── agents/ # Agent definitions
431
+ └── commands/ # Claude slash commands (restart, rea)
432
+ ```
433
+
434
+ ## Package Exports
435
+
436
+ ```json
437
+ {
438
+ ".": "types/index.js",
439
+ "./config": "config/policy-loader.js",
440
+ "./middleware": "gateway/middleware/chain.js"
441
+ }
377
442
  ```
378
443
 
379
444
  ## Requirements
380
445
 
381
446
  - Node.js >= 22
382
- - Git repository
447
+ - Git repository (for hooks and init)
448
+
449
+ ## Dependencies
450
+
451
+ 3 runtime dependencies:
452
+
453
+ - `@modelcontextprotocol/sdk` -- MCP client/server protocol
454
+ - `yaml` -- YAML parsing for policy and gateway config
455
+ - `zod` -- Schema validation for all configuration files
456
+
457
+ ## Testing
458
+
459
+ ```bash
460
+ npm test
461
+ ```
462
+
463
+ 153 tests across 20 test files covering CLI commands, middleware chain, tier classification, policy enforcement, blocked paths, secret redaction, audit logging, and end-to-end gateway smoke tests.
383
464
 
384
465
  ## Scope
385
466
 
@@ -58,7 +58,7 @@ You are the Anthropic/Claude platform specialist for this project.
58
58
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
59
59
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
60
60
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
61
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
61
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
62
62
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
63
63
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
64
64
 
@@ -69,7 +69,7 @@ You are the fine-tuning specialist for this project.
69
69
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
70
70
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
71
71
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
72
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
72
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
73
73
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
74
74
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
75
75
 
@@ -61,7 +61,7 @@ You are the Google Gemini platform specialist for this project.
61
61
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
62
62
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
63
63
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
64
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
64
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
65
65
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
66
66
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
67
67
 
@@ -81,7 +81,7 @@ await server.connect(transport);
81
81
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
82
82
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
83
83
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
84
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
84
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
85
85
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
86
86
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
87
87
 
@@ -159,7 +159,7 @@ You are the multi-modal AI specialist for this project.
159
159
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
160
160
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
161
161
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
162
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
162
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
163
163
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
164
164
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
165
165
 
@@ -102,7 +102,7 @@ You are the open-source and self-hosted AI specialist for this project, the expe
102
102
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
103
103
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
104
104
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
105
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
105
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
106
106
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
107
107
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
108
108
 
@@ -65,7 +65,7 @@ You are the OpenAI platform specialist for this project.
65
65
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
66
66
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
67
67
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
68
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
68
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
69
69
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
70
70
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
71
71
 
@@ -74,7 +74,7 @@ When recommending platforms:
74
74
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
75
75
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
76
76
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
77
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
77
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
78
78
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
79
79
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
80
80
 
@@ -66,7 +66,7 @@ You are the prompt engineering specialist for this project.
66
66
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
67
67
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
68
68
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
69
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
69
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
70
70
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
71
71
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
72
72
 
@@ -69,7 +69,7 @@ Context Assembly → LLM Generation → Citation Extraction → Response
69
69
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
70
70
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
71
71
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
72
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
72
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
73
73
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
74
74
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
75
75
 
@@ -12,7 +12,7 @@ category: ai-platforms
12
12
 
13
13
  You are REA — the Reactive Execution Agent. The active ingredient of reagent (`rea` + `gent` = `reagent`).
14
14
 
15
- You are the chief AI orchestrator for this project, the authority on AI team composition, task routing, and zero-trust enforcement. You govern the entire AI agent roster across engineering (49 agents) and AI platforms (20 agents), ensuring every agent delivers measurable value, operates under zero-trust constraints, and respects reagent autonomy levels.
15
+ You are the AI team orchestrator responsible for AI agent roster management, evaluation, gap analysis, and zero-trust governance across the AI platforms team (20 agents). You work alongside the `reagent-orchestrator`, which handles implementation task routing and process enforcement for the full engineering team. When the user invokes `/rea`, you handle strategic AI team operations; the `reagent-orchestrator` handles tactical implementation delegation via CLAUDE.md's delegation rule.
16
16
 
17
17
  ## Expertise
18
18
 
@@ -45,7 +45,7 @@ Every agent under REA's governance must satisfy:
45
45
  2. **Never trust LLM memory** — Always verify via tools/code/docs. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
46
46
  3. **Cross-validate** — Verify claims against authoritative sources
47
47
  4. **Cite freshness** — Flag potentially stale information with dates
48
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
48
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
49
49
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop
50
50
  7. **Audit awareness** — All tool use may be logged; behave accordingly
51
51
 
@@ -63,7 +63,7 @@ You are the AI safety and alignment specialist for this project.
63
63
  2. **Never trust LLM memory** — Always verify via tools, code, or documentation. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
64
64
  3. **Cross-validate** — Verify claims against authoritative sources before recommending
65
65
  4. **Cite freshness** — Flag potentially stale information with dates; AI moves fast
66
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
66
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
67
67
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
68
68
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
69
69
 
@@ -79,7 +79,7 @@ Adapt your patterns to what the project actually uses.
79
79
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
80
80
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
81
81
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
82
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
82
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
83
83
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
84
84
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
85
85
 
@@ -76,7 +76,7 @@ You are the AWS Solutions Architect for this project.
76
76
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
77
77
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
78
78
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
79
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
79
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
80
80
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
81
81
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
82
82
 
@@ -265,7 +265,7 @@ WHEN IN DOUBT:
265
265
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
266
266
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
267
267
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
268
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
268
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
269
269
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
270
270
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
271
271
 
@@ -197,7 +197,7 @@ WHEN IN DOUBT:
197
197
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
198
198
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
199
199
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
200
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
200
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
201
201
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
202
202
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
203
203
 
@@ -274,7 +274,7 @@ TIER 3 REJECT #[n]: [File:Line]
274
274
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
275
275
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
276
276
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
277
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
277
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
278
278
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
279
279
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
280
280
 
@@ -105,7 +105,7 @@ CONSTRAINTS:
105
105
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
106
106
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
107
107
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
108
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
108
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
109
109
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
110
110
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
111
111
 
@@ -60,7 +60,7 @@ You are the Data Engineer for this project.
60
60
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
61
61
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
62
62
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
63
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
63
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
64
64
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
65
65
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
66
66
 
@@ -215,7 +215,7 @@ You are the guardian of data integrity and performance for this project.
215
215
  2. **Never trust LLM memory** — Verify current state via tools, git, and file reads. Programmatic project memory (`.claude/MEMORY.md`, `.reagent/`) is OK
216
216
  3. **Verify before claiming** — Check actual state (build output, test results, git status) before reporting status
217
217
  4. **Validate dependencies** — Verify packages exist (`npm view`) before installing; check version compatibility
218
- 5. **Graduated autonomy** — Respect reagent L0-L4 levels from `.reagent/policy.yaml`
218
+ 5. **Graduated autonomy** — Respect reagent L0-L3 levels from `.reagent/policy.yaml`
219
219
  6. **HALT compliance** — Check `.reagent/HALT` before any action; if present, stop immediately
220
220
  7. **Audit awareness** — All tool invocations may be logged; behave as if every action is observed
221
221