@bookedsolid/reagent 0.4.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.
Files changed (92) hide show
  1. package/README.md +407 -54
  2. package/agents/product-owner.md +44 -0
  3. package/commands/plan-work.md +19 -0
  4. package/commands/tasks.md +26 -0
  5. package/dist/cli/commands/cache.d.ts +2 -0
  6. package/dist/cli/commands/cache.d.ts.map +1 -0
  7. package/dist/cli/commands/cache.js +114 -0
  8. package/dist/cli/commands/cache.js.map +1 -0
  9. package/dist/cli/commands/init/agents.d.ts +3 -0
  10. package/dist/cli/commands/init/agents.d.ts.map +1 -0
  11. package/dist/cli/commands/init/agents.js +47 -0
  12. package/dist/cli/commands/init/agents.js.map +1 -0
  13. package/dist/cli/commands/init/claude-hooks.d.ts +3 -0
  14. package/dist/cli/commands/init/claude-hooks.d.ts.map +1 -0
  15. package/dist/cli/commands/init/claude-hooks.js +134 -0
  16. package/dist/cli/commands/init/claude-hooks.js.map +1 -0
  17. package/dist/cli/commands/init/claude-md.d.ts +3 -0
  18. package/dist/cli/commands/init/claude-md.d.ts.map +1 -0
  19. package/dist/cli/commands/init/claude-md.js +52 -0
  20. package/dist/cli/commands/init/claude-md.js.map +1 -0
  21. package/dist/cli/commands/init/commands.d.ts +3 -0
  22. package/dist/cli/commands/init/commands.d.ts.map +1 -0
  23. package/dist/cli/commands/init/commands.js +31 -0
  24. package/dist/cli/commands/init/commands.js.map +1 -0
  25. package/dist/cli/commands/init/cursor-rules.d.ts +3 -0
  26. package/dist/cli/commands/init/cursor-rules.d.ts.map +1 -0
  27. package/dist/cli/commands/init/cursor-rules.js +30 -0
  28. package/dist/cli/commands/init/cursor-rules.js.map +1 -0
  29. package/dist/cli/commands/init/gateway-config.d.ts +3 -0
  30. package/dist/cli/commands/init/gateway-config.d.ts.map +1 -0
  31. package/dist/cli/commands/init/gateway-config.js +51 -0
  32. package/dist/cli/commands/init/gateway-config.js.map +1 -0
  33. package/dist/cli/commands/init/gitignore.d.ts +3 -0
  34. package/dist/cli/commands/init/gitignore.d.ts.map +1 -0
  35. package/dist/cli/commands/init/gitignore.js +20 -0
  36. package/dist/cli/commands/init/gitignore.js.map +1 -0
  37. package/dist/cli/commands/init/husky-hooks.d.ts +3 -0
  38. package/dist/cli/commands/init/husky-hooks.d.ts.map +1 -0
  39. package/dist/cli/commands/init/husky-hooks.js +73 -0
  40. package/dist/cli/commands/init/husky-hooks.js.map +1 -0
  41. package/dist/cli/commands/{init.d.ts → init/index.d.ts} +1 -1
  42. package/dist/cli/commands/init/index.d.ts.map +1 -0
  43. package/dist/cli/commands/init/index.js +121 -0
  44. package/dist/cli/commands/init/index.js.map +1 -0
  45. package/dist/cli/commands/init/pm.d.ts +9 -0
  46. package/dist/cli/commands/init/pm.d.ts.map +1 -0
  47. package/dist/cli/commands/init/pm.js +40 -0
  48. package/dist/cli/commands/init/pm.js.map +1 -0
  49. package/dist/cli/commands/init/policy.d.ts +3 -0
  50. package/dist/cli/commands/init/policy.d.ts.map +1 -0
  51. package/dist/cli/commands/init/policy.js +61 -0
  52. package/dist/cli/commands/init/policy.js.map +1 -0
  53. package/dist/cli/commands/init/types.d.ts +29 -0
  54. package/dist/cli/commands/init/types.d.ts.map +1 -0
  55. package/dist/cli/commands/init/types.js +2 -0
  56. package/dist/cli/commands/init/types.js.map +1 -0
  57. package/dist/cli/index.js +6 -1
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/gateway/native-tools.d.ts +8 -0
  60. package/dist/gateway/native-tools.d.ts.map +1 -0
  61. package/dist/gateway/native-tools.js +190 -0
  62. package/dist/gateway/native-tools.js.map +1 -0
  63. package/dist/gateway/server.d.ts.map +1 -1
  64. package/dist/gateway/server.js +7 -3
  65. package/dist/gateway/server.js.map +1 -1
  66. package/dist/pm/github-bridge.d.ts +36 -0
  67. package/dist/pm/github-bridge.d.ts.map +1 -0
  68. package/dist/pm/github-bridge.js +138 -0
  69. package/dist/pm/github-bridge.js.map +1 -0
  70. package/dist/pm/task-store.d.ts +39 -0
  71. package/dist/pm/task-store.d.ts.map +1 -0
  72. package/dist/pm/task-store.js +189 -0
  73. package/dist/pm/task-store.js.map +1 -0
  74. package/dist/pm/types.d.ts +70 -0
  75. package/dist/pm/types.d.ts.map +1 -0
  76. package/dist/pm/types.js +22 -0
  77. package/dist/pm/types.js.map +1 -0
  78. package/hooks/_lib/common.sh +87 -0
  79. package/hooks/architecture-review-gate.sh +84 -0
  80. package/hooks/blocked-paths-enforcer.sh +169 -0
  81. package/hooks/commit-review-gate.sh +131 -0
  82. package/hooks/dangerous-bash-interceptor.sh +32 -0
  83. package/hooks/dependency-audit-gate.sh +118 -0
  84. package/hooks/push-review-gate.sh +105 -0
  85. package/hooks/settings-protection.sh +145 -0
  86. package/hooks/task-link-gate.sh +70 -0
  87. package/package.json +1 -1
  88. package/profiles/bst-internal.json +20 -3
  89. package/profiles/client-engagement.json +20 -3
  90. package/dist/cli/commands/init.d.ts.map +0 -1
  91. package/dist/cli/commands/init.js +0 -560
  92. package/dist/cli/commands/init.js.map +0 -1
package/README.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  Zero-trust MCP gateway and agentic infrastructure for AI-assisted development.
4
4
 
5
- Reagent is two things:
5
+ Reagent is three things:
6
6
 
7
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, 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
 
@@ -19,6 +21,9 @@ AI coding assistants are powerful but unconstrained. Reagent adds the missing go
19
21
  - **Audit trail** -- every tool invocation is logged as hash-chained JSONL with serialized writes for chain integrity
20
22
  - **Tool blocking** -- individual tools can be permanently blocked regardless of autonomy level
21
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
22
27
 
23
28
  ## Quick Start
24
29
 
@@ -72,6 +77,9 @@ npx @bookedsolid/reagent init --dry-run
72
77
  | `reagent check` | Verify what reagent components are installed |
73
78
  | `reagent freeze --reason "..."` | Create `.reagent/HALT` -- suspends all tool calls |
74
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 |
75
83
  | `reagent help` | Show usage help |
76
84
 
77
85
  ### `reagent init` Options
@@ -87,6 +95,31 @@ npx @bookedsolid/reagent init --dry-run
87
95
  | ----------------- | ---------------------------------- | --------------- |
88
96
  | `--reason <text>` | Reason for freeze (stored in HALT) | `Manual freeze` |
89
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
+
90
123
  ## MCP Gateway
91
124
 
92
125
  ### How It Works
@@ -112,6 +145,12 @@ AI Assistant (Claude Code, Cursor, etc.)
112
145
  | | 8. [Execute] | |
113
146
  | +------------------------+ |
114
147
  | |
148
+ | Native Tools: |
149
+ | task_create, task_update |
150
+ | task_list, task_get |
151
+ | task_delete |
152
+ | task_sync_github |
153
+ | |
115
154
  +----------+------------------+
116
155
  | stdio (MCP protocol)
117
156
  v
@@ -124,8 +163,22 @@ The gateway:
124
163
  1. Connects to all downstream MCP servers defined in `.reagent/gateway.yaml`
125
164
  2. Discovers their tools via MCP `tools/list`
126
165
  3. Re-registers each tool on the gateway with namespace prefixes (`servername__toolname`)
127
- 4. Wraps every tool call in the middleware chain
128
- 5. Listens on stdio for incoming MCP requests from the AI assistant
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`) |
129
182
 
130
183
  ### Gateway Configuration
131
184
 
@@ -246,7 +299,7 @@ Classifies the tool into one of three tiers using a layered approach:
246
299
  | `delete_`, `drop_`, `purge_`, `remove_`, `destroy_`, `ban_`, `kick_`, `revoke_`, `truncate_` | `destructive` |
247
300
  | Everything else | `write` |
248
301
 
249
- **Tier tiers:**
302
+ **Tier levels:**
250
303
 
251
304
  | Tier | Description | Examples |
252
305
  | ------------- | ------------------------------- | ------------------------------------------------ |
@@ -296,6 +349,138 @@ Redaction uses `redactDeep` to walk object structures in-place with a circular r
296
349
  - **Per-tool timeout** -- each downstream tool call has a 30-second timeout with timer cleanup to prevent leaks
297
350
  - **Graceful shutdown** -- `process.exitCode = 0` (not `process.exit(0)`) to allow event loop drain
298
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.
483
+
299
484
  ## Policy File
300
485
 
301
486
  `.reagent/policy.yaml` controls agent behavior:
@@ -303,7 +488,7 @@ Redaction uses `redactDeep` to walk object structures in-place with a circular r
303
488
  ```yaml
304
489
  version: '1'
305
490
  profile: bst-internal
306
- installed_by: 'reagent@0.3.0'
491
+ installed_by: 'reagent@0.5.0'
307
492
  installed_at: '2026-04-09T00:00:00.000Z'
308
493
  autonomy_level: L1
309
494
  max_autonomy_level: L2
@@ -314,6 +499,7 @@ blocked_paths:
314
499
  - '.env'
315
500
  - '.env.*'
316
501
  notification_channel: ''
502
+ task_link_gate: false
317
503
  ```
318
504
 
319
505
  | Field | Type | Description |
@@ -328,38 +514,126 @@ notification_channel: ''
328
514
  | `block_ai_attribution` | `boolean` | When true, commit-msg hook rejects AI attribution markers |
329
515
  | `blocked_paths` | `string[]` | Paths the agent must never modify (`.reagent/` always added) |
330
516
  | `notification_channel` | `string` | Optional notification channel identifier |
517
+ | `task_link_gate` | `boolean` | When true, commits must reference a task ID (T-NNN) |
331
518
 
332
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.
333
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 |
603
+
334
604
  ## Config Scaffolder
335
605
 
336
606
  `reagent init` configures your repository with:
337
607
 
338
608
  - **Git hooks** -- commit-msg validation, pre-commit checks, and pre-push quality gates (via Husky)
339
609
  - **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
610
+ - **Claude hooks** -- 11 safety and quality hooks (see [Claude Code Hooks](#claude-code-hooks) section)
341
611
  - **Claude settings** -- permission boundaries for Claude Code (`.claude/settings.json`)
342
612
  - **Policy file** -- `.reagent/policy.yaml` with graduated autonomy levels
343
613
  - **CLAUDE.md** -- project-level AI agent instructions (managed block with markers)
344
614
  - **Agent definitions** -- AI agent team definitions (`.claude/agents/`)
345
- - **Commands** -- `/restart` (session handoff) and `/rea` (AI team orchestration)
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
346
618
 
347
619
  ### What Gets Installed
348
620
 
349
- | Path | Committed | Purpose |
350
- | ----------------------- | --------------- | ------------------------------------ |
351
- | `.reagent/policy.yaml` | Yes | Autonomy levels and agent policy |
352
- | `.reagent/gateway.yaml` | Yes | MCP gateway downstream server config |
353
- | `.reagent/audit/` | No (gitignored) | Hash-chained JSONL audit logs |
354
- | `.cursor/rules/` | Yes | Cursor IDE behavioral rules |
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 |
358
- | `.claude/hooks/` | No (gitignored) | Claude Code safety hooks |
359
- | `.claude/settings.json` | No (gitignored) | Claude Code permissions |
360
- | `.claude/agents/` | No (gitignored) | Agent team definitions |
361
- | `.claude/commands/` | Yes | Slash commands (restart, rea) |
362
- | `CLAUDE.md` | Yes | AI agent project instructions |
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 |
363
637
 
364
638
  ### Profiles
365
639
 
@@ -368,7 +642,22 @@ The `max_autonomy_level` field is enforced at config load time: if `autonomy_lev
368
642
  | `client-engagement` | Client consulting projects | L1 / max L2 | `.reagent/`, `.github/workflows/`, `.env`, `.env.*` |
369
643
  | `bst-internal` | BST's own repositories | L1 / max L2 | `.reagent/`, `.env` |
370
644
 
371
- Both profiles install the full hook suite (dangerous-bash-interceptor, env-file-protection, secret-scanner, attribution-advisory), Cursor rules, and Claude commands.
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
+ ```
372
661
 
373
662
  ### Idempotent
374
663
 
@@ -388,6 +677,7 @@ To remove reagent from a project:
388
677
  # Remove reagent-managed files
389
678
  rm -rf .cursor/rules/ .claude/hooks/ .claude/settings.json .claude/agents/
390
679
  rm -rf .claude/commands/restart.md .claude/commands/rea.md
680
+ rm -rf .claude/commands/tasks.md .claude/commands/plan-work.md
391
681
  rm -rf .reagent/
392
682
 
393
683
  # Remove the reagent-managed block from CLAUDE.md (between the marker comments)
@@ -400,35 +690,78 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
400
690
  ```
401
691
  @bookedsolid/reagent
402
692
  ├── src/
403
- │ ├── cli/ # CLI entry point and commands
404
- │ │ ├── index.ts # ESM entry point, routes to commands
405
- │ │ ├── commands/ # init, check, freeze, unfreeze, serve
406
- │ │ └── utils.ts # Shared CLI utilities
407
- │ ├── config/ # Configuration loaders
408
- │ │ ├── policy-loader.ts # Zod-validated policy.yaml parser
409
- │ │ ├── gateway-config.ts # Zod-validated gateway.yaml parser
410
- │ │ └── tier-map.ts # Tool tier classification (static + convention)
411
- │ ├── gateway/ # MCP gateway core
412
- │ │ ├── server.ts # Gateway orchestrator (startup, shutdown)
413
- │ │ ├── client-manager.ts # Downstream MCP server connections
414
- │ │ ├── tool-proxy.ts # Tool discovery, namespacing, registration
415
- │ │ └── middleware/ # Middleware chain
416
- │ │ ├── chain.ts # Onion-style middleware executor
417
- │ │ ├── session.ts # Session ID attachment
418
- │ │ ├── kill-switch.ts # HALT file check
419
- │ │ ├── tier.ts # Tier classification
420
- │ │ ├── policy.ts # Autonomy level enforcement
421
- │ │ ├── blocked-paths.ts # Blocked path enforcement
422
- │ │ ├── redact.ts # Secret pattern redaction (pre + post)
423
- │ │ └── audit.ts # Hash-chained JSONL logging
424
- └── types/ # TypeScript type definitions
425
- ├── profiles/ # Init profiles (bst-internal, client-engagement)
426
- ├── templates/ # Template files for scaffolding
427
- ├── hooks/ # Shell hook scripts
428
- ├── husky/ # Husky git hook scripts
429
- ├── cursor/ # Cursor IDE rules
430
- ├── agents/ # Agent definitions
431
- └── commands/ # Claude slash commands (restart, rea)
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
432
765
  ```
433
766
 
434
767
  ## Package Exports
@@ -445,6 +778,8 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
445
778
 
446
779
  - Node.js >= 22
447
780
  - Git repository (for hooks and init)
781
+ - `jq` (for hook scripts that parse JSON)
782
+ - `gh` CLI (optional, for GitHub issue sync)
448
783
 
449
784
  ## Dependencies
450
785
 
@@ -457,10 +792,28 @@ rm -f .husky/commit-msg .husky/pre-commit .husky/pre-push
457
792
  ## Testing
458
793
 
459
794
  ```bash
460
- npm test
795
+ pnpm test
461
796
  ```
462
797
 
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.
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)
464
817
 
465
818
  ## Scope
466
819
 
@@ -0,0 +1,44 @@
1
+ ---
2
+ model: sonnet
3
+ description: Product Owner agent for task management — creates, prioritizes, and tracks tasks with guardrails to prevent over-ticketing and scope creep
4
+ tools: task_create, task_update, task_list, task_get, task_delete, task_sync_github
5
+ ---
6
+
7
+ # Product Owner Agent
8
+
9
+ You are a Product Owner agent responsible for managing the project task backlog. You translate goals, plans, and requirements into well-structured, actionable tasks.
10
+
11
+ ## Guardrails
12
+
13
+ These are non-negotiable constraints on your behavior:
14
+
15
+ 1. **Anti-duplication**: You MUST call `task_list` before any `task_create` to check for existing tasks that cover the same scope.
16
+ 2. **Rate limit**: Maximum 10 task creations per invocation. If a goal requires more, group into parent tasks with subtasks.
17
+ 3. **Critical urgency**: You CANNOT set `urgency: critical` without explicit human approval. Default to `normal`.
18
+ 4. **Scope boundary**: You CANNOT modify policy.yaml, hooks, agent definitions, or any infrastructure files. You only manage tasks.
19
+ 5. **Parent grouping**: When creating 5+ tasks for a single goal, you MUST use `parent_id` to create a hierarchy.
20
+ 6. **Evidence required**: You CANNOT auto-close tasks without evidence — a `commit_ref` or explicit human sign-off.
21
+ 7. **Ticket quality**: Every task must be:
22
+ - Human-developer-friendly (clear title, actionable description)
23
+ - GitHub API-friendly (under 200 chars for title)
24
+ - AI-friendly (unambiguous scope, measurable completion criteria)
25
+
26
+ ## Task Creation Template
27
+
28
+ When creating tasks, follow this structure:
29
+
30
+ - **title**: Verb-noun format, under 80 characters (e.g., "Implement review cache CLI subcommand")
31
+ - **description**: What needs to happen, acceptance criteria, and any constraints
32
+ - **phase**: Which project phase this belongs to (if applicable)
33
+ - **urgency**: `normal` by default. Only `low` for nice-to-haves
34
+ - **parent_id**: Set when this is a subtask of a larger initiative
35
+
36
+ ## Workflow
37
+
38
+ 1. Receive a goal or requirement from the user
39
+ 2. Call `task_list` to understand current backlog state
40
+ 3. Propose tasks (display them to the user for review)
41
+ 4. Wait for user confirmation before creating
42
+ 5. Create approved tasks via `task_create`
43
+
44
+ Never auto-create tasks without showing the proposed list first.