@bookedsolid/reagent 0.12.0 → 0.12.2
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
CHANGED
|
@@ -48,8 +48,8 @@ Point your AI assistant's MCP configuration at the gateway:
|
|
|
48
48
|
{
|
|
49
49
|
"mcpServers": {
|
|
50
50
|
"reagent": {
|
|
51
|
-
"command": "
|
|
52
|
-
"args": ["serve"]
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "@bookedsolid/reagent", "serve"]
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -78,12 +78,124 @@ npx @bookedsolid/reagent init --discord # configure Discord notifications
|
|
|
78
78
|
npx @bookedsolid/reagent init --dry-run
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
## Installing Reagent in Your Project
|
|
82
|
+
|
|
83
|
+
This section documents the end-to-end setup for a new project — including the nuances of MCP transport, token passing, and env var expansion that aren't obvious from first principles.
|
|
84
|
+
|
|
85
|
+
### Step 1 — Run `reagent init`
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cd /path/to/your-project
|
|
89
|
+
npx @bookedsolid/reagent init --profile bst-internal
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This installs hooks, policy, agent team, gateway config template, and Claude settings. It also writes a managed block into `CLAUDE.md` with agent behavioral rules.
|
|
93
|
+
|
|
94
|
+
To pick up an updated hook suite after a reagent version bump:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx @bookedsolid/reagent upgrade
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`upgrade` re-syncs hooks that are already installed and bumps `installed_by` in `policy.yaml`. It never adds new hooks without consent.
|
|
101
|
+
|
|
102
|
+
### Step 2 — Configure `.mcp.json`
|
|
103
|
+
|
|
104
|
+
**Use stdio transport — not HTTP.** Claude Code's HTTP MCP transport requires OAuth 2.1, which the reagent server does not implement. The stdio transport is what works:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"mcpServers": {
|
|
109
|
+
"reagent": {
|
|
110
|
+
"command": "npx",
|
|
111
|
+
"args": ["-y", "@bookedsolid/reagent", "serve"]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
> **Why `npx` instead of `reagent`?** Using the bare `reagent` command requires a global install. `npx` works from any project, always uses the registry version, and avoids "command not found" errors on machines where reagent isn't globally installed.
|
|
118
|
+
|
|
119
|
+
> **Env vars in `.mcp.json`:** Claude Code does **not** expand `${VAR}` syntax in `.mcp.json` env values — the literal string `${MY_TOKEN}` is passed to the process, not the value. If reagent needs tokens to pass to downstream MCP servers (e.g., Discord bots), use the gateway proxy pattern instead (see Step 3). The gateway **does** expand `${VAR}` from the shell environment at startup.
|
|
120
|
+
|
|
121
|
+
If you need to pass env vars to `reagent serve` itself (e.g., tokens used by native tools like `discord_notify`), set them in your shell environment rather than in `.mcp.json`:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# In your shell profile or .env (never committed):
|
|
125
|
+
export BOOKED_DISCORD_BOT_TOKEN="..."
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Step 3 — Configure downstream MCP servers (gateway proxy)
|
|
129
|
+
|
|
130
|
+
If your project uses other MCP servers that need secrets (API keys, bot tokens, etc.), proxy them through reagent's gateway rather than adding them directly to `.mcp.json`. This is the **only** way to pass env vars reliably from Claude Code.
|
|
131
|
+
|
|
132
|
+
Edit `.reagent/gateway.yaml`:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
version: '1'
|
|
136
|
+
|
|
137
|
+
servers:
|
|
138
|
+
discord-ops:
|
|
139
|
+
command: npx
|
|
140
|
+
args: ['-y', 'discord-ops@latest']
|
|
141
|
+
env:
|
|
142
|
+
BOOKED_DISCORD_BOT_TOKEN: '${BOOKED_DISCORD_BOT_TOKEN}'
|
|
143
|
+
CLARITY_DISCORD_BOT_TOKEN: '${CLARITY_DISCORD_BOT_TOKEN}'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The `${VAR}` syntax here is resolved by reagent from `process.env` at gateway startup — it works because reagent inherits the shell environment from Claude Code's process. The spawned child MCP server receives the resolved values.
|
|
147
|
+
|
|
148
|
+
Do **not** add the same server to both `gateway.yaml` and `.mcp.json` directly — `reagent init` warns about this. Direct `.mcp.json` entries with `${VAR}` env values will pass the literal string, not the token.
|
|
149
|
+
|
|
150
|
+
### Step 4 — Commit the config files
|
|
151
|
+
|
|
152
|
+
`reagent init` generates files in two categories:
|
|
153
|
+
|
|
154
|
+
| File | Commit? |
|
|
155
|
+
| ---------------------------- | --------------------------------------------------- |
|
|
156
|
+
| `.reagent/policy.yaml` | Yes — defines autonomy level for the team |
|
|
157
|
+
| `.reagent/gateway.yaml` | Yes — documents which MCP servers this project uses |
|
|
158
|
+
| `.claude/settings.json` | Yes — permission gates for Claude Code |
|
|
159
|
+
| `.claude/hooks/` | Yes — safety and quality hooks |
|
|
160
|
+
| `.claude/agents/` | Yes — agent team definitions |
|
|
161
|
+
| `CLAUDE.md` (managed block) | Yes — behavioral rules for AI agents |
|
|
162
|
+
| `.reagent/tasks.jsonl` | No — gitignored, local task store |
|
|
163
|
+
| `.reagent/audit/` | No — gitignored, local audit log |
|
|
164
|
+
| `.reagent/review-cache.json` | No — gitignored, local review cache |
|
|
165
|
+
|
|
166
|
+
### Upgrading an existing install
|
|
167
|
+
|
|
168
|
+
When a new version of reagent ships with updated hooks or agents:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npx @bookedsolid/reagent upgrade
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This re-syncs all hooks in `.claude/hooks/` and `.husky/` that were installed by a previous `reagent init`. It will not add hooks that weren't installed originally.
|
|
175
|
+
|
|
176
|
+
### How `reagent serve` runs in Claude Code
|
|
177
|
+
|
|
178
|
+
When Claude Code reads `.mcp.json`, it spawns `npx -y @bookedsolid/reagent serve` as a child process. The MCP protocol runs over stdio between Claude Code and the reagent process. Reagent then spawns its own child processes for each entry in `gateway.yaml`, also over stdio.
|
|
179
|
+
|
|
180
|
+
The resulting process tree:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Claude Code
|
|
184
|
+
└── reagent serve (stdio MCP to Claude Code)
|
|
185
|
+
└── discord-ops (stdio MCP, proxied through reagent)
|
|
186
|
+
└── other-server (stdio MCP, proxied through reagent)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
All tool calls from Claude Code go through reagent's middleware chain before reaching downstream servers.
|
|
190
|
+
|
|
81
191
|
## Commands
|
|
82
192
|
|
|
83
193
|
| Command | Description |
|
|
84
194
|
| ------------------------------- | ------------------------------------------------- |
|
|
85
195
|
| `reagent serve` | Start the MCP gateway server (stdio transport) |
|
|
196
|
+
| `reagent serve` | Start the MCP gateway server (stdio transport) |
|
|
86
197
|
| `reagent init` | Install reagent config into the current directory |
|
|
198
|
+
| `reagent upgrade` | Re-sync hooks and bump installed_by in policy |
|
|
87
199
|
| `reagent catalyze` | Analyze project stack and generate gap report |
|
|
88
200
|
| `reagent check` | Verify what reagent components are installed |
|
|
89
201
|
| `reagent freeze --reason "..."` | Create `.reagent/HALT` — suspends all tool calls |
|
|
@@ -107,6 +219,14 @@ npx @bookedsolid/reagent init --dry-run
|
|
|
107
219
|
| `--releases-channel <id>` | Discord channel for release events | — |
|
|
108
220
|
| `--dev-channel <id>` | Discord channel for dev activity | — |
|
|
109
221
|
|
|
222
|
+
### `reagent upgrade` Options
|
|
223
|
+
|
|
224
|
+
| Flag | Description | Default |
|
|
225
|
+
| ----------- | -------------------------------------------- | ------- |
|
|
226
|
+
| `--dry-run` | Preview what would be updated without writes | — |
|
|
227
|
+
|
|
228
|
+
Re-syncs hooks in `.claude/hooks/` and `.husky/` that were installed by a previous `reagent init`. Updates `installed_by` in `.reagent/policy.yaml`. Never adds hooks that weren't originally installed.
|
|
229
|
+
|
|
110
230
|
### `reagent catalyze` Options
|
|
111
231
|
|
|
112
232
|
| Flag | Description | Default |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/D,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,OAAO,GACd,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/D,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,OAAO,GACd,aAAa,EAAE,CAkFjB"}
|
|
@@ -16,7 +16,9 @@ export function installPolicy(targetDir, profileName, profile, dryRun) {
|
|
|
16
16
|
const coverageEnabled = profile.coverage?.enabled === true;
|
|
17
17
|
const coverageThreshold = profile.coverage?.threshold ?? 80;
|
|
18
18
|
const blockedPaths = profile.blockedPaths ?? [
|
|
19
|
-
'.reagent/',
|
|
19
|
+
'.reagent/policy.yaml',
|
|
20
|
+
'.reagent/HALT',
|
|
21
|
+
'.reagent/review-cache.json',
|
|
20
22
|
'.github/workflows/',
|
|
21
23
|
'.env',
|
|
22
24
|
'.env.*',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa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,KAAK,CAAC;QACV,MAAM,OAAO,GAAG,+DAA+D,WAAW;;;;;YAKlF,WAAW;yBACE,WAAW;iBACnB,GAAG;;;;;;;;;;;;;;;;;;wBAkBI,gBAAgB;;;gBAGxB,gBAAgB;;;;;;;;;;;;aAYnB,eAAe;eACb,iBAAiB;;;;;;;;sBAQV,cAAc;CACnC,CAAC;QACE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -90,28 +90,36 @@ if [[ ${#BLOCKED_PATHS[@]} -eq 0 ]]; then
|
|
|
90
90
|
exit 0
|
|
91
91
|
fi
|
|
92
92
|
|
|
93
|
-
# ── 6.
|
|
93
|
+
# ── 6. Agent-writable allowlist ───────────────────────────────────────────────
|
|
94
|
+
# These paths under .reagent/ must always be writable by agents regardless of
|
|
95
|
+
# what blocked_paths says. Blocking the whole .reagent/ directory in policy
|
|
96
|
+
# is a common default, but tasks.jsonl is the PM data store — agents must
|
|
97
|
+
# write there. Settings-protection.sh guards the sensitive files explicitly.
|
|
98
|
+
AGENT_WRITABLE=(
|
|
99
|
+
'.reagent/tasks.jsonl'
|
|
100
|
+
'.reagent/audit/'
|
|
101
|
+
)
|
|
94
102
|
|
|
95
|
-
# Convert to relative path from project root
|
|
96
103
|
normalize_path() {
|
|
97
104
|
local p="$1"
|
|
98
105
|
local root="$REAGENT_ROOT"
|
|
99
|
-
|
|
100
|
-
# Strip project root prefix if present
|
|
101
106
|
if [[ "$p" == "$root"/* ]]; then
|
|
102
107
|
p="${p#$root/}"
|
|
103
108
|
fi
|
|
104
|
-
|
|
105
|
-
# URL decode common sequences
|
|
106
109
|
p=$(printf '%s' "$p" | sed 's/%2[Ff]/\//g; s/%2[Ee]/./g; s/%20/ /g')
|
|
107
|
-
|
|
108
|
-
# Remove ./ prefix
|
|
109
110
|
p="${p#./}"
|
|
110
|
-
|
|
111
111
|
printf '%s' "$p"
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
NORMALIZED=$(normalize_path "$FILE_PATH")
|
|
115
|
+
|
|
116
|
+
for writable in "${AGENT_WRITABLE[@]}"; do
|
|
117
|
+
if [[ "$NORMALIZED" == "$writable" ]] || [[ "$NORMALIZED" == "$writable"* && "$writable" == */ ]]; then
|
|
118
|
+
exit 0
|
|
119
|
+
fi
|
|
120
|
+
done
|
|
121
|
+
|
|
122
|
+
# ── 7. Match against blocked_paths ───────────────────────────────────────────
|
|
115
123
|
LOWER_NORM=$(printf '%s' "$NORMALIZED" | tr '[:upper:]' '[:lower:]')
|
|
116
124
|
|
|
117
125
|
for blocked in "${BLOCKED_PATHS[@]}"; do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bookedsolid/reagent",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Zero-trust MCP gateway — policy enforcement, secret redaction, and audit logging for AI-assisted projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Booked Solid Technology <oss@bookedsolid.tech> (https://bookedsolid.tech)",
|