@bookedsolid/reagent 0.3.0 → 0.5.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/README.md +552 -118
- package/agents/ai-platforms/ai-anthropic-specialist.md +1 -1
- package/agents/ai-platforms/ai-fine-tuning-specialist.md +1 -1
- package/agents/ai-platforms/ai-gemini-specialist.md +1 -1
- package/agents/ai-platforms/ai-mcp-developer.md +1 -1
- package/agents/ai-platforms/ai-multi-modal-specialist.md +1 -1
- package/agents/ai-platforms/ai-open-source-models-specialist.md +1 -1
- package/agents/ai-platforms/ai-openai-specialist.md +1 -1
- package/agents/ai-platforms/ai-platform-strategist.md +1 -1
- package/agents/ai-platforms/ai-prompt-engineer.md +1 -1
- package/agents/ai-platforms/ai-rag-architect.md +1 -1
- package/agents/ai-platforms/ai-rea.md +2 -2
- package/agents/ai-platforms/ai-safety-reviewer.md +1 -1
- package/agents/engineering/accessibility-engineer.md +1 -1
- package/agents/engineering/aws-architect.md +1 -1
- package/agents/engineering/backend-engineer-payments.md +1 -1
- package/agents/engineering/backend-engineering-manager.md +1 -1
- package/agents/engineering/code-reviewer.md +1 -1
- package/agents/engineering/css3-animation-purist.md +1 -1
- package/agents/engineering/data-engineer.md +1 -1
- package/agents/engineering/database-architect.md +1 -1
- package/agents/engineering/design-system-developer.md +1 -1
- package/agents/engineering/design-systems-animator.md +1 -1
- package/agents/engineering/devops-engineer.md +1 -1
- package/agents/engineering/drupal-integration-specialist.md +1 -1
- package/agents/engineering/drupal-specialist.md +1 -1
- package/agents/engineering/engineering-manager-frontend.md +1 -1
- package/agents/engineering/frontend-specialist.md +1 -1
- package/agents/engineering/infrastructure-engineer.md +1 -1
- package/agents/engineering/lit-specialist.md +1 -1
- package/agents/engineering/migration-specialist.md +1 -1
- package/agents/engineering/ml-engineer.md +1 -1
- package/agents/engineering/mobile-engineer.md +1 -1
- package/agents/engineering/motion-designer-interactive.md +1 -1
- package/agents/engineering/nextjs-specialist.md +1 -1
- package/agents/engineering/open-source-specialist.md +1 -1
- package/agents/engineering/performance-engineer.md +1 -1
- package/agents/engineering/performance-qa-engineer.md +1 -1
- package/agents/engineering/pr-maintainer.md +1 -1
- package/agents/engineering/principal-engineer.md +1 -1
- package/agents/engineering/privacy-engineer.md +1 -1
- package/agents/engineering/qa-engineer.md +1 -1
- package/agents/engineering/security-engineer.md +1 -1
- package/agents/engineering/security-qa-engineer.md +1 -1
- package/agents/engineering/senior-backend-engineer.md +1 -1
- package/agents/engineering/senior-database-engineer.md +1 -1
- package/agents/engineering/senior-frontend-engineer.md +1 -1
- package/agents/engineering/senior-product-manager-platform.md +1 -1
- package/agents/engineering/senior-technical-project-manager.md +1 -1
- package/agents/engineering/site-reliability-engineer-2.md +1 -1
- package/agents/engineering/solutions-architect.md +1 -1
- package/agents/engineering/sre-lead.md +1 -1
- package/agents/engineering/staff-engineer-platform.md +1 -1
- package/agents/engineering/staff-software-engineer.md +1 -1
- package/agents/engineering/storybook-specialist.md +1 -1
- package/agents/engineering/supabase-specialist.md +1 -1
- package/agents/engineering/technical-project-manager.md +1 -1
- package/agents/engineering/technical-writer.md +1 -1
- package/agents/engineering/test-architect.md +1 -1
- package/agents/engineering/typescript-specialist.md +1 -1
- package/agents/engineering/ux-researcher.md +1 -1
- package/agents/engineering/vp-engineering.md +1 -1
- package/agents/product-owner.md +44 -0
- package/commands/plan-work.md +19 -0
- package/commands/tasks.md +26 -0
- package/dist/cli/commands/cache.d.ts +2 -0
- package/dist/cli/commands/cache.d.ts.map +1 -0
- package/dist/cli/commands/cache.js +114 -0
- package/dist/cli/commands/cache.js.map +1 -0
- package/dist/cli/commands/init/agents.d.ts +3 -0
- package/dist/cli/commands/init/agents.d.ts.map +1 -0
- package/dist/cli/commands/init/agents.js +47 -0
- package/dist/cli/commands/init/agents.js.map +1 -0
- package/dist/cli/commands/init/claude-hooks.d.ts +3 -0
- package/dist/cli/commands/init/claude-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/claude-hooks.js +134 -0
- package/dist/cli/commands/init/claude-hooks.js.map +1 -0
- package/dist/cli/commands/init/claude-md.d.ts +3 -0
- package/dist/cli/commands/init/claude-md.d.ts.map +1 -0
- package/dist/cli/commands/init/claude-md.js +52 -0
- package/dist/cli/commands/init/claude-md.js.map +1 -0
- package/dist/cli/commands/init/commands.d.ts +3 -0
- package/dist/cli/commands/init/commands.d.ts.map +1 -0
- package/dist/cli/commands/init/commands.js +31 -0
- package/dist/cli/commands/init/commands.js.map +1 -0
- package/dist/cli/commands/init/cursor-rules.d.ts +3 -0
- package/dist/cli/commands/init/cursor-rules.d.ts.map +1 -0
- package/dist/cli/commands/init/cursor-rules.js +30 -0
- package/dist/cli/commands/init/cursor-rules.js.map +1 -0
- package/dist/cli/commands/init/gateway-config.d.ts +3 -0
- package/dist/cli/commands/init/gateway-config.d.ts.map +1 -0
- package/dist/cli/commands/init/gateway-config.js +51 -0
- package/dist/cli/commands/init/gateway-config.js.map +1 -0
- package/dist/cli/commands/init/gitignore.d.ts +3 -0
- package/dist/cli/commands/init/gitignore.d.ts.map +1 -0
- package/dist/cli/commands/init/gitignore.js +20 -0
- package/dist/cli/commands/init/gitignore.js.map +1 -0
- package/dist/cli/commands/init/husky-hooks.d.ts +3 -0
- package/dist/cli/commands/init/husky-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/husky-hooks.js +73 -0
- package/dist/cli/commands/init/husky-hooks.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +1 -1
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +121 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/pm.d.ts +9 -0
- package/dist/cli/commands/init/pm.d.ts.map +1 -0
- package/dist/cli/commands/init/pm.js +40 -0
- package/dist/cli/commands/init/pm.js.map +1 -0
- package/dist/cli/commands/init/policy.d.ts +3 -0
- package/dist/cli/commands/init/policy.d.ts.map +1 -0
- package/dist/cli/commands/init/policy.js +61 -0
- package/dist/cli/commands/init/policy.js.map +1 -0
- package/dist/cli/commands/init/types.d.ts +29 -0
- package/dist/cli/commands/init/types.d.ts.map +1 -0
- package/dist/cli/commands/init/types.js +2 -0
- package/dist/cli/commands/init/types.js.map +1 -0
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/gateway-config.d.ts.map +1 -1
- package/dist/config/gateway-config.js +5 -1
- package/dist/config/gateway-config.js.map +1 -1
- package/dist/config/policy-loader.d.ts.map +1 -1
- package/dist/config/policy-loader.js +15 -1
- package/dist/config/policy-loader.js.map +1 -1
- package/dist/config/tier-map.d.ts +1 -1
- package/dist/config/tier-map.d.ts.map +1 -1
- package/dist/config/tier-map.js +38 -5
- package/dist/config/tier-map.js.map +1 -1
- package/dist/gateway/client-manager.d.ts.map +1 -1
- package/dist/gateway/client-manager.js +9 -3
- package/dist/gateway/client-manager.js.map +1 -1
- package/dist/gateway/middleware/audit.d.ts +2 -1
- package/dist/gateway/middleware/audit.d.ts.map +1 -1
- package/dist/gateway/middleware/audit.js +57 -46
- package/dist/gateway/middleware/audit.js.map +1 -1
- package/dist/gateway/middleware/blocked-paths.d.ts +13 -0
- package/dist/gateway/middleware/blocked-paths.d.ts.map +1 -0
- package/dist/gateway/middleware/blocked-paths.js +118 -0
- package/dist/gateway/middleware/blocked-paths.js.map +1 -0
- package/dist/gateway/middleware/policy.d.ts +3 -1
- package/dist/gateway/middleware/policy.d.ts.map +1 -1
- package/dist/gateway/middleware/policy.js +22 -3
- package/dist/gateway/middleware/policy.js.map +1 -1
- package/dist/gateway/middleware/redact.d.ts.map +1 -1
- package/dist/gateway/middleware/redact.js +18 -5
- package/dist/gateway/middleware/redact.js.map +1 -1
- package/dist/gateway/native-tools.d.ts +8 -0
- package/dist/gateway/native-tools.d.ts.map +1 -0
- package/dist/gateway/native-tools.js +190 -0
- package/dist/gateway/native-tools.js.map +1 -0
- package/dist/gateway/server.d.ts.map +1 -1
- package/dist/gateway/server.js +14 -7
- package/dist/gateway/server.js.map +1 -1
- package/dist/gateway/tool-proxy.d.ts.map +1 -1
- package/dist/gateway/tool-proxy.js +18 -6
- package/dist/gateway/tool-proxy.js.map +1 -1
- package/dist/pm/github-bridge.d.ts +36 -0
- package/dist/pm/github-bridge.d.ts.map +1 -0
- package/dist/pm/github-bridge.js +138 -0
- package/dist/pm/github-bridge.js.map +1 -0
- package/dist/pm/task-store.d.ts +39 -0
- package/dist/pm/task-store.d.ts.map +1 -0
- package/dist/pm/task-store.js +189 -0
- package/dist/pm/task-store.js.map +1 -0
- package/dist/pm/types.d.ts +70 -0
- package/dist/pm/types.d.ts.map +1 -0
- package/dist/pm/types.js +22 -0
- package/dist/pm/types.js.map +1 -0
- package/dist/types/enums.d.ts +0 -4
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/enums.js +0 -5
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/hooks/_lib/common.sh +87 -0
- package/hooks/architecture-review-gate.sh +84 -0
- package/hooks/attribution-advisory.sh +1 -1
- package/hooks/blocked-paths-enforcer.sh +169 -0
- package/hooks/commit-review-gate.sh +131 -0
- package/hooks/dangerous-bash-interceptor.sh +33 -1
- package/hooks/dependency-audit-gate.sh +118 -0
- package/hooks/env-file-protection.sh +1 -1
- package/hooks/push-review-gate.sh +105 -0
- package/hooks/secret-scanner.sh +1 -1
- package/hooks/settings-protection.sh +145 -0
- package/hooks/task-link-gate.sh +70 -0
- package/package.json +16 -1
- package/profiles/bst-internal.json +21 -4
- package/profiles/client-engagement.json +20 -3
- package/templates/CLAUDE.md +14 -1
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -511
- package/dist/cli/commands/init.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,21 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Zero-trust MCP gateway and agentic infrastructure for AI-assisted development.
|
|
4
4
|
|
|
5
|
-
Reagent is
|
|
5
|
+
Reagent is three things:
|
|
6
6
|
|
|
7
|
-
1. **MCP Gateway** (`reagent serve`)
|
|
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`)
|
|
9
|
+
2. **Config Scaffolder** (`reagent init`) -- installs safety hooks, behavioral policies, quality gates, and developer tooling into any project.
|
|
10
|
+
|
|
11
|
+
3. **Project Management Layer** -- lightweight task tracking with JSONL event store, native MCP tools, GitHub issue sync, and a product-owner agent for task planning.
|
|
10
12
|
|
|
11
13
|
## Why Reagent?
|
|
12
14
|
|
|
13
15
|
AI coding assistants are powerful but unconstrained. Reagent adds the missing governance layer:
|
|
14
16
|
|
|
15
|
-
- **Policy enforcement**
|
|
16
|
-
- **Kill switch**
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
17
|
+
- **Policy enforcement** -- graduated autonomy levels (L0 read-only through L3 full access) control which tiers of tools an agent can invoke
|
|
18
|
+
- **Kill switch** -- `reagent freeze` immediately blocks all tool calls across every connected MCP server
|
|
19
|
+
- **Blocked path enforcement** -- tool arguments referencing protected paths (including `.reagent/` itself) are denied before execution
|
|
20
|
+
- **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
|
|
21
|
+
- **Audit trail** -- every tool invocation is logged as hash-chained JSONL with serialized writes for chain integrity
|
|
22
|
+
- **Tool blocking** -- individual tools can be permanently blocked regardless of autonomy level
|
|
23
|
+
- **Tier downgrade protection** -- `tool_overrides` cannot lower a tool's tier below its static or convention-based classification
|
|
24
|
+
- **Security hooks** -- 11 Claude Code hooks enforce settings protection, secret scanning, dangerous command interception, blocked path enforcement, and more
|
|
25
|
+
- **Quality gates** -- commit and push review gates with triage scoring, review caching, and agent-spawned code review
|
|
26
|
+
- **Task management** -- native MCP tools for task CRUD, GitHub issue sync, and a product-owner agent with guardrails
|
|
20
27
|
|
|
21
28
|
## Quick Start
|
|
22
29
|
|
|
@@ -68,37 +75,85 @@ npx @bookedsolid/reagent init --dry-run
|
|
|
68
75
|
| `reagent serve` | Start the MCP gateway server (stdio transport) |
|
|
69
76
|
| `reagent init` | Install reagent config into the current directory |
|
|
70
77
|
| `reagent check` | Verify what reagent components are installed |
|
|
71
|
-
| `reagent freeze --reason "..."` | Create `.reagent/HALT`
|
|
72
|
-
| `reagent unfreeze` | Remove `.reagent/HALT`
|
|
78
|
+
| `reagent freeze --reason "..."` | Create `.reagent/HALT` -- suspends all tool calls |
|
|
79
|
+
| `reagent unfreeze` | Remove `.reagent/HALT` -- resumes tool calls |
|
|
80
|
+
| `reagent cache check <sha>` | Check review cache for a file SHA |
|
|
81
|
+
| `reagent cache set <sha> <res>` | Store a review result (pass/fail/advisory) |
|
|
82
|
+
| `reagent cache clear` | Clear all cached review results |
|
|
73
83
|
| `reagent help` | Show usage help |
|
|
74
84
|
|
|
85
|
+
### `reagent init` Options
|
|
86
|
+
|
|
87
|
+
| Flag | Description | Default |
|
|
88
|
+
| ------------------ | ---------------------------------------------- | ------------------- |
|
|
89
|
+
| `--profile <name>` | Profile to install | `client-engagement` |
|
|
90
|
+
| `--dry-run` | Preview what would be installed without writes | -- |
|
|
91
|
+
|
|
92
|
+
### `reagent freeze` Options
|
|
93
|
+
|
|
94
|
+
| Flag | Description | Default |
|
|
95
|
+
| ----------------- | ---------------------------------- | --------------- |
|
|
96
|
+
| `--reason <text>` | Reason for freeze (stored in HALT) | `Manual freeze` |
|
|
97
|
+
|
|
98
|
+
### `reagent cache` Subcommands
|
|
99
|
+
|
|
100
|
+
The review cache stores code review results to avoid redundant agent reviews on unchanged code.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Check if a file has a cached review
|
|
104
|
+
reagent cache check abc123 --branch main --base def456
|
|
105
|
+
|
|
106
|
+
# Store a review result
|
|
107
|
+
reagent cache set abc123 pass --branch main --reviewer code-reviewer --findings 0 --ttl 86400
|
|
108
|
+
|
|
109
|
+
# Clear all cache entries
|
|
110
|
+
reagent cache clear
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| Flag | Description | Default |
|
|
114
|
+
| ------------------- | ------------------------- | --------- |
|
|
115
|
+
| `--branch <name>` | Branch name for cache key | `""` |
|
|
116
|
+
| `--base <commit>` | Base commit for cache key | `""` |
|
|
117
|
+
| `--reviewer <name>` | Reviewer agent name | `unknown` |
|
|
118
|
+
| `--findings <n>` | Number of findings | `0` |
|
|
119
|
+
| `--ttl <seconds>` | Cache entry TTL | `86400` |
|
|
120
|
+
|
|
121
|
+
Cache file: `.reagent/review-cache.json`, keyed on `${branch}:${baseCommit}:${fileSHA256}`.
|
|
122
|
+
|
|
75
123
|
## MCP Gateway
|
|
76
124
|
|
|
77
125
|
### How It Works
|
|
78
126
|
|
|
79
127
|
```
|
|
80
128
|
AI Assistant (Claude Code, Cursor, etc.)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
|
|
|
130
|
+
| stdio (MCP protocol)
|
|
131
|
+
v
|
|
132
|
+
+-----------------------------+
|
|
133
|
+
| Reagent Gateway |
|
|
134
|
+
| |
|
|
135
|
+
| +------------------------+ |
|
|
136
|
+
| | Middleware Chain | |
|
|
137
|
+
| | | |
|
|
138
|
+
| | 1. Audit (outermost) | |
|
|
139
|
+
| | 2. Session context | |
|
|
140
|
+
| | 3. Kill switch | |
|
|
141
|
+
| | 4. Tier classify | |
|
|
142
|
+
| | 5. Policy enforce | |
|
|
143
|
+
| | 6. Blocked paths | |
|
|
144
|
+
| | 7. Secret redaction | |
|
|
145
|
+
| | 8. [Execute] | |
|
|
146
|
+
| +------------------------+ |
|
|
147
|
+
| |
|
|
148
|
+
| Native Tools: |
|
|
149
|
+
| task_create, task_update |
|
|
150
|
+
| task_list, task_get |
|
|
151
|
+
| task_delete |
|
|
152
|
+
| task_sync_github |
|
|
153
|
+
| |
|
|
154
|
+
+----------+------------------+
|
|
155
|
+
| stdio (MCP protocol)
|
|
156
|
+
v
|
|
102
157
|
Downstream MCP Servers
|
|
103
158
|
(discord-ops, filesystem, etc.)
|
|
104
159
|
```
|
|
@@ -108,8 +163,22 @@ The gateway:
|
|
|
108
163
|
1. Connects to all downstream MCP servers defined in `.reagent/gateway.yaml`
|
|
109
164
|
2. Discovers their tools via MCP `tools/list`
|
|
110
165
|
3. Re-registers each tool on the gateway with namespace prefixes (`servername__toolname`)
|
|
111
|
-
4.
|
|
112
|
-
5.
|
|
166
|
+
4. Registers native first-party tools (task management) through the same middleware chain
|
|
167
|
+
5. Wraps every tool call in the middleware chain
|
|
168
|
+
6. Listens on stdio for incoming MCP requests from the AI assistant
|
|
169
|
+
|
|
170
|
+
### Native MCP Tools
|
|
171
|
+
|
|
172
|
+
Reagent registers 6 first-party tools directly on the gateway. These go through the same middleware chain (audit, policy, blocked paths, redaction) as proxied tools.
|
|
173
|
+
|
|
174
|
+
| Tool | Description |
|
|
175
|
+
| ------------------ | ---------------------------------------------------- |
|
|
176
|
+
| `task_create` | Create a new task in `.reagent/tasks.jsonl` |
|
|
177
|
+
| `task_update` | Update a task's status, title, urgency, or fields |
|
|
178
|
+
| `task_list` | List tasks with optional status/urgency/phase filter |
|
|
179
|
+
| `task_get` | Get a single task by ID (T-NNN format) |
|
|
180
|
+
| `task_delete` | Cancel a task (soft delete via cancelled event) |
|
|
181
|
+
| `task_sync_github` | Sync local tasks to GitHub issues (requires `gh`) |
|
|
113
182
|
|
|
114
183
|
### Gateway Configuration
|
|
115
184
|
|
|
@@ -136,9 +205,9 @@ servers:
|
|
|
136
205
|
blocked: true
|
|
137
206
|
```
|
|
138
207
|
|
|
139
|
-
**Environment variable resolution:** Use `${VAR_NAME}` syntax in env values
|
|
208
|
+
**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
209
|
|
|
141
|
-
**Tool overrides:** Each downstream tool can be assigned a tier (`read`, `write`, `destructive`) and optionally blocked entirely.
|
|
210
|
+
**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
211
|
|
|
143
212
|
### Tool Namespacing
|
|
144
213
|
|
|
@@ -177,7 +246,7 @@ Every tool call passes through the middleware chain in onion (Koa-style) order.
|
|
|
177
246
|
|
|
178
247
|
### 1. Audit (outermost)
|
|
179
248
|
|
|
180
|
-
Records every invocation
|
|
249
|
+
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
250
|
|
|
182
251
|
```json
|
|
183
252
|
{
|
|
@@ -194,18 +263,18 @@ Records every invocation — including denials — as a hash-chained JSONL entry
|
|
|
194
263
|
}
|
|
195
264
|
```
|
|
196
265
|
|
|
197
|
-
The `prev_hash` field chains records together
|
|
266
|
+
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
267
|
|
|
199
268
|
### 2. Session Context
|
|
200
269
|
|
|
201
|
-
Attaches a unique session ID (UUID) to every invocation. Each gateway instance generates one session ID at startup.
|
|
270
|
+
Attaches a unique session ID (UUID via `crypto.randomUUID()`) to every invocation. Each gateway instance generates one session ID at startup.
|
|
202
271
|
|
|
203
272
|
### 3. Kill Switch
|
|
204
273
|
|
|
205
|
-
Checks for `.reagent/HALT` file. If present, the invocation is immediately denied. The HALT file contents become the denial reason.
|
|
274
|
+
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
275
|
|
|
207
276
|
```bash
|
|
208
|
-
# Emergency stop
|
|
277
|
+
# Emergency stop -- all tool calls blocked immediately
|
|
209
278
|
reagent freeze --reason "security incident at 2026-04-09T12:00:00Z"
|
|
210
279
|
|
|
211
280
|
# Resume
|
|
@@ -214,7 +283,23 @@ reagent unfreeze
|
|
|
214
283
|
|
|
215
284
|
### 4. Tier Classification
|
|
216
285
|
|
|
217
|
-
Classifies the tool into one of three tiers:
|
|
286
|
+
Classifies the tool into one of three tiers using a layered approach:
|
|
287
|
+
|
|
288
|
+
| Source | Priority | Description |
|
|
289
|
+
| ---------------- | -------- | ------------------------------------------ |
|
|
290
|
+
| Static map | 1st | Known tools with explicit tier assignments |
|
|
291
|
+
| Convention-based | 2nd | Prefix patterns for unknown tools |
|
|
292
|
+
| Default | 3rd | Falls back to `write` |
|
|
293
|
+
|
|
294
|
+
**Convention-based classification** allows non-Discord downstream servers to get sensible defaults:
|
|
295
|
+
|
|
296
|
+
| Prefix pattern | Tier |
|
|
297
|
+
| ------------------------------------------------------------------------------------------------------------ | ------------- |
|
|
298
|
+
| `get_`, `list_`, `search_`, `query_`, `read_`, `fetch_`, `check_`, `health_`, `describe_`, `show_`, `count_` | `read` |
|
|
299
|
+
| `delete_`, `drop_`, `purge_`, `remove_`, `destroy_`, `ban_`, `kick_`, `revoke_`, `truncate_` | `destructive` |
|
|
300
|
+
| Everything else | `write` |
|
|
301
|
+
|
|
302
|
+
**Tier levels:**
|
|
218
303
|
|
|
219
304
|
| Tier | Description | Examples |
|
|
220
305
|
| ------------- | ------------------------------- | ------------------------------------------------ |
|
|
@@ -222,43 +307,179 @@ Classifies the tool into one of three tiers:
|
|
|
222
307
|
| `write` | Modifies state | `send_message`, `create_channel`, `edit_message` |
|
|
223
308
|
| `destructive` | Irreversible state changes | `delete_channel`, `purge_messages`, `ban_member` |
|
|
224
309
|
|
|
225
|
-
Tiers are assigned via `tool_overrides` in gateway config. Unknown tools default to `write`.
|
|
226
|
-
|
|
227
310
|
### 5. Policy Enforcement
|
|
228
311
|
|
|
229
|
-
Checks the tool's tier against the project's autonomy level
|
|
312
|
+
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
313
|
|
|
231
314
|
| Autonomy Level | Allowed Tiers |
|
|
232
315
|
| ------------------ | -------------------------------- |
|
|
233
|
-
| `L0` (read-only) | `read`
|
|
316
|
+
| `L0` (read-only) | `read` |
|
|
234
317
|
| `L1` (standard) | `read` + `write` |
|
|
235
|
-
| `L2` (elevated) | `read` + `write`
|
|
236
|
-
| `L3` (full access) |
|
|
318
|
+
| `L2` (elevated) | `read` + `write` |
|
|
319
|
+
| `L3` (full access) | `read` + `write` + `destructive` |
|
|
237
320
|
|
|
238
|
-
Also checks for explicitly blocked tools
|
|
321
|
+
Also checks for explicitly blocked tools -- a tool marked `blocked: true` in gateway config is denied regardless of autonomy level.
|
|
239
322
|
|
|
240
|
-
### 6.
|
|
323
|
+
### 6. Blocked Paths
|
|
241
324
|
|
|
242
|
-
|
|
325
|
+
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).
|
|
326
|
+
|
|
327
|
+
### 7. Secret Redaction
|
|
328
|
+
|
|
329
|
+
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
330
|
|
|
244
331
|
- AWS Access Keys (`AKIA...`)
|
|
245
332
|
- AWS Secret Keys
|
|
246
333
|
- GitHub Tokens (`ghp_...`, `gho_...`, `ghs_...`, `ghu_...`, `ghr_...`)
|
|
247
334
|
- Generic API Keys
|
|
248
335
|
- Bearer Tokens
|
|
249
|
-
- PEM Private Keys
|
|
336
|
+
- PEM Private Keys (RSA, EC, DSA)
|
|
250
337
|
- Discord Bot Tokens
|
|
251
338
|
- Base64-encoded AWS Keys
|
|
252
339
|
|
|
253
|
-
Redaction
|
|
340
|
+
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
341
|
|
|
255
342
|
### Security Invariants
|
|
256
343
|
|
|
257
|
-
- **Denial is permanent**
|
|
258
|
-
- **Audit records everything**
|
|
259
|
-
- **Policy re-derives tier**
|
|
260
|
-
- **Fail-closed**
|
|
261
|
-
- **All logging to stderr**
|
|
344
|
+
- **Denial is permanent** -- once any middleware denies an invocation, no subsequent middleware can revert it (enforced by `executeChain`)
|
|
345
|
+
- **Audit records everything** -- audit is outermost, so even kill-switch denials are recorded
|
|
346
|
+
- **Policy re-derives tier** -- never trusts mutable context; always re-classifies from tool name
|
|
347
|
+
- **Fail-closed** -- errors in kill-switch or policy checks result in denial, not passthrough
|
|
348
|
+
- **All logging to stderr** -- stdout is reserved for the MCP stdio transport
|
|
349
|
+
- **Per-tool timeout** -- each downstream tool call has a 30-second timeout with timer cleanup to prevent leaks
|
|
350
|
+
- **Graceful shutdown** -- `process.exitCode = 0` (not `process.exit(0)`) to allow event loop drain
|
|
351
|
+
|
|
352
|
+
## Claude Code Hooks
|
|
353
|
+
|
|
354
|
+
Reagent installs 11 Claude Code hooks that enforce security, quality, and project management policies. Hooks are shell scripts that run as PreToolUse or PostToolUse interceptors.
|
|
355
|
+
|
|
356
|
+
### Hook Architecture
|
|
357
|
+
|
|
358
|
+
Hooks use a shared library (`hooks/_lib/common.sh`) providing:
|
|
359
|
+
|
|
360
|
+
| Function | Purpose |
|
|
361
|
+
| -------------- | ----------------------------------------------------- |
|
|
362
|
+
| `reagent_root` | Find the `.reagent/` directory by walking up from cwd |
|
|
363
|
+
| `check_halt` | Exit with code 2 if `.reagent/HALT` exists |
|
|
364
|
+
| `require_jq` | Verify jq is available |
|
|
365
|
+
| `json_output` | Build structured JSON response (block/allow/advisory) |
|
|
366
|
+
| `triage_score` | Score a diff as trivial/standard/significant |
|
|
367
|
+
|
|
368
|
+
### Exit Code Convention
|
|
369
|
+
|
|
370
|
+
| Code | Meaning |
|
|
371
|
+
| ---- | ------------------- |
|
|
372
|
+
| `0` | Allow the tool call |
|
|
373
|
+
| `2` | Block the tool call |
|
|
374
|
+
|
|
375
|
+
### Security Hooks
|
|
376
|
+
|
|
377
|
+
#### `settings-protection.sh` (PreToolUse: Write, Edit)
|
|
378
|
+
|
|
379
|
+
**P0 Critical.** Prevents agents from modifying their own safety rails. Blocks writes to:
|
|
380
|
+
|
|
381
|
+
- `.claude/settings.json`, `.claude/settings.local.json`
|
|
382
|
+
- `.claude/hooks/*`
|
|
383
|
+
- `.husky/*`
|
|
384
|
+
- `.reagent/policy.yaml`, `.reagent/HALT`, `.reagent/review-cache.json`
|
|
385
|
+
|
|
386
|
+
Includes case-insensitive bypass detection and URL-decode normalization to prevent encoding attacks.
|
|
387
|
+
|
|
388
|
+
#### `blocked-paths-enforcer.sh` (PreToolUse: Write, Edit)
|
|
389
|
+
|
|
390
|
+
**P0 Critical.** Reads `blocked_paths` from `.reagent/policy.yaml` and blocks writes to matching paths. Handles both inline YAML arrays (`[a, b]`) and block sequences. Supports directory prefix matching, glob patterns, and exact match.
|
|
391
|
+
|
|
392
|
+
#### `dangerous-bash-interceptor.sh` (PreToolUse: Bash)
|
|
393
|
+
|
|
394
|
+
Intercepts dangerous shell commands before execution:
|
|
395
|
+
|
|
396
|
+
| Detection | Blocked Command Pattern |
|
|
397
|
+
| --------- | ----------------------------------------------------------------------------------- |
|
|
398
|
+
| H1 | `git push --force` / `-f` to protected branches (main, master, staging, production) |
|
|
399
|
+
| H2 | `rm -rf /` or `rm -rf ~` |
|
|
400
|
+
| H3 | `chmod 777` |
|
|
401
|
+
| H4 | `curl \| sh`, `wget \| sh` (pipe-to-shell) |
|
|
402
|
+
| H5 | `> /dev/sda` (disk overwrite) |
|
|
403
|
+
| H6 | `:(){ :\|:& };:` (fork bomb) |
|
|
404
|
+
| H7 | `mkfs` (disk format) |
|
|
405
|
+
| H8 | `dd if=` (disk copy) |
|
|
406
|
+
| H9 | `.env` file access via cat/less/head/tail |
|
|
407
|
+
| H10 | `shutdown`, `reboot`, `halt`, `poweroff` |
|
|
408
|
+
| H11 | `kill -9`, `killall`, `pkill` |
|
|
409
|
+
| H12 | `iptables` / `ufw` (firewall modification) |
|
|
410
|
+
| H13 | `git push --no-verify` |
|
|
411
|
+
| H14 | `git -c core.hooksPath=` (hook path override) |
|
|
412
|
+
| H15 | `REAGENT_BYPASS` environment variable |
|
|
413
|
+
| H16 | Alias/function definitions containing bypass strings |
|
|
414
|
+
|
|
415
|
+
#### `secret-scanner.sh` (PreToolUse: Write, Edit)
|
|
416
|
+
|
|
417
|
+
Scans file content being written for secrets:
|
|
418
|
+
|
|
419
|
+
- AWS Access Keys (`AKIA...`)
|
|
420
|
+
- PEM private key headers (RSA, EC, DSA)
|
|
421
|
+
- GitHub PATs (`ghp_`, `gho_`, `ghs_`, `ghu_`, `ghr_` with 36+ chars)
|
|
422
|
+
- Stripe live keys (`sk_live_`)
|
|
423
|
+
- Generic `SECRET=`/`PASSWORD=`/`TOKEN=`/`API_KEY=` assignments with real values
|
|
424
|
+
|
|
425
|
+
Allows placeholders (`<your_key_here>`, `changeme`, `xxx`), `process.env` references, and `.env.example` files.
|
|
426
|
+
|
|
427
|
+
#### `env-file-protection.sh` (PreToolUse: Write, Edit)
|
|
428
|
+
|
|
429
|
+
Blocks writes to `.env` files (`.env`, `.env.local`, `.env.production`, etc.). Allows `.env.example` and `.env.template` files.
|
|
430
|
+
|
|
431
|
+
#### `attribution-advisory.sh` (PreToolUse: Bash)
|
|
432
|
+
|
|
433
|
+
When `block_ai_attribution` is enabled in policy.yaml, blocks `gh pr create`, `gh pr edit`, and `git commit` commands containing AI attribution patterns:
|
|
434
|
+
|
|
435
|
+
- `Co-Authored-By` with AI names (Claude, Copilot, GPT, Cursor, etc.)
|
|
436
|
+
- `Generated with [Tool]` footers
|
|
437
|
+
- `AI-generated` markers
|
|
438
|
+
|
|
439
|
+
### Quality Gate Hooks
|
|
440
|
+
|
|
441
|
+
#### `commit-review-gate.sh` (PreToolUse: Bash)
|
|
442
|
+
|
|
443
|
+
Intercepts `git commit` commands and applies triage-based review:
|
|
444
|
+
|
|
445
|
+
| Triage Level | Criteria | Action |
|
|
446
|
+
| --------------- | ------------------------------------- | ---------------------------------------------- |
|
|
447
|
+
| **Trivial** | <20 changed lines, no sensitive paths | Pass immediately |
|
|
448
|
+
| **Standard** | 20-200 changed lines | Check review cache; pass if cached |
|
|
449
|
+
| **Significant** | >200 lines OR sensitive paths | Block; instruct agent to spawn `code-reviewer` |
|
|
450
|
+
|
|
451
|
+
Sensitive paths: `.reagent/`, `.claude/`, `.env`, `auth`, `security`, `.github/workflows`.
|
|
452
|
+
|
|
453
|
+
Returns `additionalContext` instructing the agent to spawn a `code-reviewer` specialist agent when blocked.
|
|
454
|
+
|
|
455
|
+
#### `push-review-gate.sh` (PreToolUse: Bash)
|
|
456
|
+
|
|
457
|
+
Intercepts `git push` commands. Analyzes the full diff against the target branch:
|
|
458
|
+
|
|
459
|
+
1. Computes triage score of all commits being pushed
|
|
460
|
+
2. Checks review cache for cached results
|
|
461
|
+
3. On cache miss for standard/significant changes: blocks with instructions to spawn `code-reviewer` and `security-engineer` agents
|
|
462
|
+
|
|
463
|
+
#### `architecture-review-gate.sh` (PostToolUse: Write, Edit)
|
|
464
|
+
|
|
465
|
+
**Advisory only (never blocks).** Flags writes to architecture-sensitive paths:
|
|
466
|
+
|
|
467
|
+
- `src/types/`, `src/gateway/`, `src/config/`
|
|
468
|
+
- `src/cli/commands/init/`
|
|
469
|
+
- `package.json`, `tsconfig*.json`
|
|
470
|
+
- `.github/workflows/`
|
|
471
|
+
|
|
472
|
+
Returns a stderr advisory suggesting the agent consider architectural implications.
|
|
473
|
+
|
|
474
|
+
### Project Management Hook
|
|
475
|
+
|
|
476
|
+
#### `task-link-gate.sh` (PreToolUse: Bash)
|
|
477
|
+
|
|
478
|
+
**Opt-in** (requires `task_link_gate: true` in policy.yaml). Intercepts `git commit` commands and checks that the commit message contains a task ID reference (`T-NNN` format). Allows merge commits, version bumps, and `chore:`/`style:`/`ci:` prefixed commits without task references.
|
|
479
|
+
|
|
480
|
+
#### `dependency-audit-gate.sh` (PreToolUse: Bash)
|
|
481
|
+
|
|
482
|
+
Intercepts `npm install`, `pnpm add`, `yarn add`, and `npx` commands. Extracts package names and verifies each exists in the npm registry via `npm view` before allowing the install.
|
|
262
483
|
|
|
263
484
|
## Policy File
|
|
264
485
|
|
|
@@ -267,60 +488,180 @@ Redaction operates on individual string values within structured results — it
|
|
|
267
488
|
```yaml
|
|
268
489
|
version: '1'
|
|
269
490
|
profile: bst-internal
|
|
270
|
-
installed_by: 'reagent
|
|
491
|
+
installed_by: 'reagent@0.5.0'
|
|
271
492
|
installed_at: '2026-04-09T00:00:00.000Z'
|
|
272
493
|
autonomy_level: L1
|
|
273
|
-
max_autonomy_level:
|
|
494
|
+
max_autonomy_level: L2
|
|
274
495
|
promotion_requires_human_approval: true
|
|
496
|
+
block_ai_attribution: true
|
|
275
497
|
blocked_paths:
|
|
276
|
-
- .
|
|
277
|
-
- .env
|
|
278
|
-
|
|
498
|
+
- '.reagent/'
|
|
499
|
+
- '.env'
|
|
500
|
+
- '.env.*'
|
|
501
|
+
notification_channel: ''
|
|
502
|
+
task_link_gate: false
|
|
279
503
|
```
|
|
280
504
|
|
|
281
|
-
| Field | Description
|
|
282
|
-
| ----------------------------------- |
|
|
283
|
-
| `
|
|
284
|
-
| `
|
|
285
|
-
| `
|
|
286
|
-
| `
|
|
505
|
+
| Field | Type | Description |
|
|
506
|
+
| ----------------------------------- | ---------- | -------------------------------------------------------------- |
|
|
507
|
+
| `version` | `string` | Schema version (currently `"1"`) |
|
|
508
|
+
| `profile` | `string` | Profile name used during init |
|
|
509
|
+
| `installed_by` | `string` | Tool and version that generated this file |
|
|
510
|
+
| `installed_at` | `string` | ISO 8601 timestamp of installation |
|
|
511
|
+
| `autonomy_level` | `enum` | Current level (L0-L3) -- controls which tool tiers are allowed |
|
|
512
|
+
| `max_autonomy_level` | `enum` | Ceiling -- `autonomy_level` is clamped to this on load |
|
|
513
|
+
| `promotion_requires_human_approval` | `boolean` | Whether level changes need human sign-off |
|
|
514
|
+
| `block_ai_attribution` | `boolean` | When true, commit-msg hook rejects AI attribution markers |
|
|
515
|
+
| `blocked_paths` | `string[]` | Paths the agent must never modify (`.reagent/` always added) |
|
|
516
|
+
| `notification_channel` | `string` | Optional notification channel identifier |
|
|
517
|
+
| `task_link_gate` | `boolean` | When true, commits must reference a task ID (T-NNN) |
|
|
518
|
+
|
|
519
|
+
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.
|
|
520
|
+
|
|
521
|
+
## Project Management
|
|
522
|
+
|
|
523
|
+
Reagent includes a lightweight project management layer for tracking tasks alongside code.
|
|
524
|
+
|
|
525
|
+
### Task Store
|
|
526
|
+
|
|
527
|
+
Tasks are stored as an append-only event log in `.reagent/tasks.jsonl`. Each line is a JSON event:
|
|
528
|
+
|
|
529
|
+
```json
|
|
530
|
+
{"id":"T-001","type":"created","title":"Implement review cache","urgency":"normal","phase":"Phase 2","timestamp":"2026-04-09T12:00:00.000Z"}
|
|
531
|
+
{"id":"T-001","type":"started","title":"Implement review cache","timestamp":"2026-04-09T13:00:00.000Z"}
|
|
532
|
+
{"id":"T-001","type":"completed","title":"Implement review cache","commit_refs":["abc123"],"timestamp":"2026-04-09T14:00:00.000Z"}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
The current state of each task is materialized by replaying events -- the latest event for each task ID determines its status. This append-only design means no data is ever lost and concurrent writes are safe with advisory file locking.
|
|
536
|
+
|
|
537
|
+
#### Task Schema
|
|
538
|
+
|
|
539
|
+
| Field | Type | Required | Description |
|
|
540
|
+
| -------------- | ------------------------------------------------- | -------- | ----------------------------- |
|
|
541
|
+
| `id` | `string` (T-NNN) | Yes | Auto-incrementing task ID |
|
|
542
|
+
| `type` | `created\|started\|completed\|blocked\|cancelled` | Yes | Event type |
|
|
543
|
+
| `title` | `string` (1-200 chars) | Yes | Task title |
|
|
544
|
+
| `description` | `string` | No | Detailed description |
|
|
545
|
+
| `urgency` | `critical\|normal\|low` | No | Defaults to `normal` |
|
|
546
|
+
| `phase` | `string` | No | Project phase |
|
|
547
|
+
| `milestone` | `string` | No | Milestone reference |
|
|
548
|
+
| `assignee` | `string` | No | Assigned agent or person |
|
|
549
|
+
| `parent_id` | `string` (T-NNN) | No | Parent task for hierarchy |
|
|
550
|
+
| `commit_refs` | `string[]` | No | Related commit SHAs |
|
|
551
|
+
| `pr_ref` | `string` | No | Related PR reference |
|
|
552
|
+
| `blocked_by` | `string` | No | What's blocking this task |
|
|
553
|
+
| `github_issue` | `number` | No | Linked GitHub issue number |
|
|
554
|
+
| `timestamp` | `string` (ISO 8601) | Yes | Event timestamp |
|
|
555
|
+
| `session_id` | `string` | No | Agent session that created it |
|
|
556
|
+
|
|
557
|
+
All fields are validated with Zod on read. Malformed lines are skipped with a stderr warning.
|
|
558
|
+
|
|
559
|
+
### GitHub Bridge
|
|
560
|
+
|
|
561
|
+
The GitHub bridge syncs local tasks to GitHub issues:
|
|
562
|
+
|
|
563
|
+
- **Detection:** checks for `gh` CLI with `gh auth status`. Falls back to `local-only` mode if unavailable.
|
|
564
|
+
- **Sync scope:** only creates issues with the `reagent:` label. Never imports all repository issues.
|
|
565
|
+
- **Rate limiting:** 300-second cooldown between sync operations.
|
|
566
|
+
- **Conflict resolution:** local JSONL is the source of truth; GitHub is the display layer.
|
|
567
|
+
- **Auto-close:** when a task is marked completed and has a linked `github_issue`, the corresponding issue is closed via `gh issue close`.
|
|
568
|
+
|
|
569
|
+
### MCP Tools
|
|
570
|
+
|
|
571
|
+
The 6 native task management tools are registered directly on the gateway and go through the full middleware chain:
|
|
572
|
+
|
|
573
|
+
```
|
|
574
|
+
task_create -- Create a task: title (required), description, urgency, phase, milestone, assignee, parent_id
|
|
575
|
+
task_update -- Update a task: id (required), type (started|completed|blocked|cancelled), plus any updatable fields
|
|
576
|
+
task_list -- List tasks: optional filters for status, urgency, phase
|
|
577
|
+
task_get -- Get one task by ID (T-NNN format)
|
|
578
|
+
task_delete -- Soft-delete (cancelled event) a task by ID
|
|
579
|
+
task_sync_github -- Trigger GitHub issue sync (requires gh CLI)
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### Product Owner Agent
|
|
583
|
+
|
|
584
|
+
The `product-owner` agent (`agents/product-owner.md`) manages the task backlog with built-in guardrails:
|
|
585
|
+
|
|
586
|
+
| Guardrail | Rule |
|
|
587
|
+
| ----------------- | -------------------------------------------------------- |
|
|
588
|
+
| Anti-duplication | Must call `task_list` before any `task_create` |
|
|
589
|
+
| Rate limit | Max 10 task creations per invocation |
|
|
590
|
+
| Critical urgency | Cannot set `urgency: critical` without human approval |
|
|
591
|
+
| Scope boundary | Cannot modify policy, hooks, or agent definitions |
|
|
592
|
+
| Parent grouping | Must use `parent_id` when creating 5+ tasks for one goal |
|
|
593
|
+
| Evidence required | Cannot auto-close tasks without commit ref or sign-off |
|
|
594
|
+
|
|
595
|
+
### Slash Commands
|
|
596
|
+
|
|
597
|
+
| Command | Description |
|
|
598
|
+
| ------------ | ---------------------------------------------------------------- |
|
|
599
|
+
| `/tasks` | Render a markdown table of current tasks from tasks.jsonl |
|
|
600
|
+
| `/plan-work` | Invoke the product-owner agent to propose tasks for a goal |
|
|
601
|
+
| `/restart` | Session handoff command for agent continuity |
|
|
602
|
+
| `/rea` | Invoke the REA (Reactive Execution Agent) for team orchestration |
|
|
287
603
|
|
|
288
604
|
## Config Scaffolder
|
|
289
605
|
|
|
290
606
|
`reagent init` configures your repository with:
|
|
291
607
|
|
|
292
|
-
- **Git hooks**
|
|
293
|
-
- **Cursor rules**
|
|
294
|
-
- **Claude hooks**
|
|
295
|
-
- **Claude settings**
|
|
296
|
-
- **Policy file**
|
|
297
|
-
- **CLAUDE.md**
|
|
298
|
-
- **
|
|
608
|
+
- **Git hooks** -- commit-msg validation, pre-commit checks, and pre-push quality gates (via Husky)
|
|
609
|
+
- **Cursor rules** -- AI behavioral constraints for Cursor IDE (no-hallucination, verify-before-act, attribution)
|
|
610
|
+
- **Claude hooks** -- 11 safety and quality hooks (see [Claude Code Hooks](#claude-code-hooks) section)
|
|
611
|
+
- **Claude settings** -- permission boundaries for Claude Code (`.claude/settings.json`)
|
|
612
|
+
- **Policy file** -- `.reagent/policy.yaml` with graduated autonomy levels
|
|
613
|
+
- **CLAUDE.md** -- project-level AI agent instructions (managed block with markers)
|
|
614
|
+
- **Agent definitions** -- AI agent team definitions (`.claude/agents/`)
|
|
615
|
+
- **Commands** -- `/restart`, `/rea`, `/tasks`, `/plan-work` slash commands
|
|
616
|
+
- **Gateway config** -- `.reagent/gateway.yaml` template for MCP server configuration
|
|
617
|
+
- **Task store** -- `.reagent/tasks.jsonl` (empty, gitignored) for project management
|
|
299
618
|
|
|
300
619
|
### What Gets Installed
|
|
301
620
|
|
|
302
|
-
| Path
|
|
303
|
-
|
|
|
304
|
-
| `.reagent/policy.yaml`
|
|
305
|
-
| `.reagent/gateway.yaml`
|
|
306
|
-
| `.reagent/audit/`
|
|
307
|
-
| `.
|
|
308
|
-
| `.
|
|
309
|
-
| `.
|
|
310
|
-
| `.
|
|
311
|
-
| `.
|
|
312
|
-
| `
|
|
621
|
+
| Path | Committed | Purpose |
|
|
622
|
+
| ---------------------------- | --------------- | ------------------------------------ |
|
|
623
|
+
| `.reagent/policy.yaml` | Yes | Autonomy levels and agent policy |
|
|
624
|
+
| `.reagent/gateway.yaml` | Yes | MCP gateway downstream server config |
|
|
625
|
+
| `.reagent/audit/` | No (gitignored) | Hash-chained JSONL audit logs |
|
|
626
|
+
| `.reagent/tasks.jsonl` | No (gitignored) | Task event store |
|
|
627
|
+
| `.reagent/review-cache.json` | No (gitignored) | Review cache for quality gates |
|
|
628
|
+
| `.cursor/rules/` | Yes | Cursor IDE behavioral rules |
|
|
629
|
+
| `.husky/commit-msg` | Yes | Git commit message validation |
|
|
630
|
+
| `.husky/pre-commit` | Yes | Pre-commit checks |
|
|
631
|
+
| `.husky/pre-push` | Yes | Pre-push quality gates |
|
|
632
|
+
| `.claude/hooks/` | No (gitignored) | Claude Code safety hooks |
|
|
633
|
+
| `.claude/settings.json` | No (gitignored) | Claude Code permissions |
|
|
634
|
+
| `.claude/agents/` | No (gitignored) | Agent team definitions |
|
|
635
|
+
| `.claude/commands/` | Yes | Slash commands |
|
|
636
|
+
| `CLAUDE.md` | Yes | AI agent project instructions |
|
|
313
637
|
|
|
314
638
|
### Profiles
|
|
315
639
|
|
|
316
|
-
| Profile | Use Case |
|
|
317
|
-
| ------------------- | -------------------------- |
|
|
318
|
-
| `
|
|
319
|
-
| `
|
|
640
|
+
| Profile | Use Case | Default Autonomy | Blocked Paths |
|
|
641
|
+
| ------------------- | -------------------------- | ---------------- | --------------------------------------------------- |
|
|
642
|
+
| `client-engagement` | Client consulting projects | L1 / max L2 | `.reagent/`, `.github/workflows/`, `.env`, `.env.*` |
|
|
643
|
+
| `bst-internal` | BST's own repositories | L1 / max L2 | `.reagent/`, `.env` |
|
|
644
|
+
|
|
645
|
+
Both profiles install the full hook suite, quality gates, Cursor rules, and Claude commands. Profile configuration includes:
|
|
646
|
+
|
|
647
|
+
```json
|
|
648
|
+
{
|
|
649
|
+
"qualityGates": {
|
|
650
|
+
"commitReview": { "enabled": true, "trivialThreshold": 20, "significantThreshold": 200 },
|
|
651
|
+
"pushReview": { "enabled": true },
|
|
652
|
+
"architectureAdvisory": { "enabled": true }
|
|
653
|
+
},
|
|
654
|
+
"pm": {
|
|
655
|
+
"enabled": true,
|
|
656
|
+
"taskLinkGate": false,
|
|
657
|
+
"maxOpenTasks": 50
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
```
|
|
320
661
|
|
|
321
662
|
### Idempotent
|
|
322
663
|
|
|
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.
|
|
664
|
+
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
665
|
|
|
325
666
|
### Verify Installation
|
|
326
667
|
|
|
@@ -336,6 +677,7 @@ To remove reagent from a project:
|
|
|
336
677
|
# Remove reagent-managed files
|
|
337
678
|
rm -rf .cursor/rules/ .claude/hooks/ .claude/settings.json .claude/agents/
|
|
338
679
|
rm -rf .claude/commands/restart.md .claude/commands/rea.md
|
|
680
|
+
rm -rf .claude/commands/tasks.md .claude/commands/plan-work.md
|
|
339
681
|
rm -rf .reagent/
|
|
340
682
|
|
|
341
683
|
# Remove the reagent-managed block from CLAUDE.md (between the marker comments)
|
|
@@ -348,38 +690,130 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
|
|
|
348
690
|
```
|
|
349
691
|
@bookedsolid/reagent
|
|
350
692
|
├── src/
|
|
351
|
-
│ ├── cli/
|
|
352
|
-
│ │ ├── index.ts
|
|
353
|
-
│ │ ├── commands/
|
|
354
|
-
│ │
|
|
355
|
-
│ ├──
|
|
356
|
-
│ │ ├──
|
|
357
|
-
│ │ ├──
|
|
358
|
-
│ │
|
|
359
|
-
│ ├──
|
|
360
|
-
│ │ ├──
|
|
361
|
-
│ │ ├──
|
|
362
|
-
│ │ ├──
|
|
363
|
-
│ │
|
|
364
|
-
│ │
|
|
365
|
-
│ │
|
|
366
|
-
│ │
|
|
367
|
-
│ │
|
|
368
|
-
│ │
|
|
369
|
-
│ │
|
|
370
|
-
│ │
|
|
371
|
-
│ └──
|
|
372
|
-
├──
|
|
373
|
-
├──
|
|
374
|
-
├──
|
|
375
|
-
|
|
376
|
-
|
|
693
|
+
│ ├── cli/ # CLI entry point and commands
|
|
694
|
+
│ │ ├── index.ts # ESM entry point, routes to commands
|
|
695
|
+
│ │ ├── commands/
|
|
696
|
+
│ │ │ ├── init/ # Modular init step-runner
|
|
697
|
+
│ │ │ │ ├── index.ts # Step sequencer
|
|
698
|
+
│ │ │ │ ├── types.ts # InstallResult, ProfileConfig
|
|
699
|
+
│ │ │ │ ├── gitignore.ts # .gitignore entries
|
|
700
|
+
│ │ │ │ ├── cursor-rules.ts # Cursor IDE rules
|
|
701
|
+
│ │ │ │ ├── husky-hooks.ts # Git hooks (Husky)
|
|
702
|
+
│ │ │ │ ├── claude-hooks.ts # Claude Code hooks + settings.json
|
|
703
|
+
│ │ │ │ ├── claude-md.ts # CLAUDE.md template
|
|
704
|
+
│ │ │ │ ├── policy.ts # policy.yaml generation
|
|
705
|
+
│ │ │ │ ├── gateway-config.ts # gateway.yaml generation
|
|
706
|
+
│ │ │ │ ├── agents.ts # Agent file installation
|
|
707
|
+
│ │ │ │ ├── commands.ts # Slash command installation
|
|
708
|
+
│ │ │ │ └── pm.ts # Task store scaffolding
|
|
709
|
+
│ │ │ ├── cache.ts # Review cache CLI (check/set/clear)
|
|
710
|
+
│ │ │ ├── check.ts # Installation verification
|
|
711
|
+
│ │ │ ├── freeze.ts # Kill switch (freeze/unfreeze)
|
|
712
|
+
│ │ │ └── serve.ts # Gateway server launcher
|
|
713
|
+
│ │ └── utils.ts # Shared CLI utilities
|
|
714
|
+
│ ├── config/ # Configuration loaders
|
|
715
|
+
│ │ ├── policy-loader.ts # Zod-validated policy.yaml parser
|
|
716
|
+
│ │ ├── gateway-config.ts # Zod-validated gateway.yaml parser
|
|
717
|
+
│ │ └── tier-map.ts # Tool tier classification
|
|
718
|
+
│ ├── gateway/ # MCP gateway core
|
|
719
|
+
│ │ ├── server.ts # Gateway orchestrator (startup, shutdown)
|
|
720
|
+
│ │ ├── client-manager.ts # Downstream MCP server connections
|
|
721
|
+
│ │ ├── tool-proxy.ts # Tool discovery, namespacing, registration
|
|
722
|
+
│ │ ├── native-tools.ts # First-party task management MCP tools
|
|
723
|
+
│ │ └── middleware/ # Middleware chain
|
|
724
|
+
│ │ ├── chain.ts # Onion-style middleware executor
|
|
725
|
+
│ │ ├── session.ts # Session ID attachment
|
|
726
|
+
│ │ ├── kill-switch.ts # HALT file check
|
|
727
|
+
│ │ ├── tier.ts # Tier classification
|
|
728
|
+
│ │ ├── policy.ts # Autonomy level enforcement
|
|
729
|
+
│ │ ├── blocked-paths.ts # Blocked path enforcement
|
|
730
|
+
│ │ ├── redact.ts # Secret pattern redaction
|
|
731
|
+
│ │ └── audit.ts # Hash-chained JSONL logging
|
|
732
|
+
│ ├── pm/ # Project management layer
|
|
733
|
+
│ │ ├── types.ts # Zod task schema (single source of truth)
|
|
734
|
+
│ │ ├── task-store.ts # JSONL event store with advisory locking
|
|
735
|
+
│ │ └── github-bridge.ts # GitHub CLI integration
|
|
736
|
+
│ └── types/ # TypeScript type definitions
|
|
737
|
+
├── hooks/ # Claude Code hook scripts
|
|
738
|
+
│ ├── _lib/
|
|
739
|
+
│ │ └── common.sh # Shared hook library
|
|
740
|
+
│ ├── settings-protection.sh # P0: Settings/hook modification guard
|
|
741
|
+
│ ├── blocked-paths-enforcer.sh # P0: Policy blocked_paths enforcement
|
|
742
|
+
│ ├── dangerous-bash-interceptor.sh # Dangerous command interception (16 rules)
|
|
743
|
+
│ ├── secret-scanner.sh # Secret detection in file writes
|
|
744
|
+
│ ├── env-file-protection.sh # .env file write protection
|
|
745
|
+
│ ├── attribution-advisory.sh # AI attribution blocking
|
|
746
|
+
│ ├── commit-review-gate.sh # Commit-time review with triage scoring
|
|
747
|
+
│ ├── push-review-gate.sh # Push-time review gate
|
|
748
|
+
│ ├── architecture-review-gate.sh # Architecture advisory (PostToolUse)
|
|
749
|
+
│ ├── dependency-audit-gate.sh # Package install verification
|
|
750
|
+
│ └── task-link-gate.sh # Opt-in task ID in commits
|
|
751
|
+
├── profiles/ # Init profiles (bst-internal, client-engagement)
|
|
752
|
+
├── templates/ # Template files for scaffolding
|
|
753
|
+
├── husky/ # Husky git hook scripts
|
|
754
|
+
├── cursor/ # Cursor IDE rules
|
|
755
|
+
├── agents/ # Agent definitions
|
|
756
|
+
│ ├── product-owner.md # Task management agent with guardrails
|
|
757
|
+
│ ├── reagent-orchestrator.md # Team orchestration agent
|
|
758
|
+
│ ├── engineering/ # Engineering specialist agents
|
|
759
|
+
│ └── ai-platforms/ # AI platform specialist agents
|
|
760
|
+
└── commands/ # Claude slash commands
|
|
761
|
+
├── restart.md # Session handoff
|
|
762
|
+
├── rea.md # REA orchestration
|
|
763
|
+
├── tasks.md # Task table view
|
|
764
|
+
└── plan-work.md # Guided task planning
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
## Package Exports
|
|
768
|
+
|
|
769
|
+
```json
|
|
770
|
+
{
|
|
771
|
+
".": "types/index.js",
|
|
772
|
+
"./config": "config/policy-loader.js",
|
|
773
|
+
"./middleware": "gateway/middleware/chain.js"
|
|
774
|
+
}
|
|
377
775
|
```
|
|
378
776
|
|
|
379
777
|
## Requirements
|
|
380
778
|
|
|
381
779
|
- Node.js >= 22
|
|
382
|
-
- Git repository
|
|
780
|
+
- Git repository (for hooks and init)
|
|
781
|
+
- `jq` (for hook scripts that parse JSON)
|
|
782
|
+
- `gh` CLI (optional, for GitHub issue sync)
|
|
783
|
+
|
|
784
|
+
## Dependencies
|
|
785
|
+
|
|
786
|
+
3 runtime dependencies:
|
|
787
|
+
|
|
788
|
+
- `@modelcontextprotocol/sdk` -- MCP client/server protocol
|
|
789
|
+
- `yaml` -- YAML parsing for policy and gateway config
|
|
790
|
+
- `zod` -- Schema validation for all configuration files
|
|
791
|
+
|
|
792
|
+
## Testing
|
|
793
|
+
|
|
794
|
+
```bash
|
|
795
|
+
pnpm test
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
309 tests across 30 test files covering:
|
|
799
|
+
|
|
800
|
+
- CLI commands (init step-runner, cache, check, freeze)
|
|
801
|
+
- Middleware chain (session, kill-switch, tier, policy, blocked-paths, redact, audit)
|
|
802
|
+
- Tier classification (static map, convention-based, overrides)
|
|
803
|
+
- Policy enforcement (autonomy levels, blocked tools, max clamping)
|
|
804
|
+
- Secret redaction (AWS, GitHub, PEM, Discord, generic patterns)
|
|
805
|
+
- Hook scripts (settings-protection, blocked-paths, dangerous-bash, dependency-audit, secret-scanner, env-file, attribution)
|
|
806
|
+
- Project management (task store CRUD, event materialization, advisory locking)
|
|
807
|
+
- End-to-end gateway smoke tests (native + proxied tools)
|
|
808
|
+
|
|
809
|
+
Quality gates (run via `pnpm preflight`):
|
|
810
|
+
|
|
811
|
+
1. Secret scan (gitleaks)
|
|
812
|
+
2. Format check (prettier)
|
|
813
|
+
3. Lint (eslint)
|
|
814
|
+
4. Type check (tsc --noEmit)
|
|
815
|
+
5. Tests (vitest)
|
|
816
|
+
6. Pack dry-run (npm pack)
|
|
383
817
|
|
|
384
818
|
## Scope
|
|
385
819
|
|