engrm 0.1.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/.mcp.json +9 -0
- package/AUTH-DESIGN.md +436 -0
- package/BRIEF.md +197 -0
- package/CLAUDE.md +44 -0
- package/COMPETITIVE.md +174 -0
- package/CONTEXT-OPTIMIZATION.md +305 -0
- package/INFRASTRUCTURE.md +252 -0
- package/LICENSE +105 -0
- package/MARKET.md +230 -0
- package/PLAN.md +278 -0
- package/README.md +121 -0
- package/SENTINEL.md +293 -0
- package/SERVER-API-PLAN.md +553 -0
- package/SPEC.md +843 -0
- package/SWOT.md +148 -0
- package/SYNC-ARCHITECTURE.md +294 -0
- package/VIBE-CODER-STRATEGY.md +250 -0
- package/bun.lock +375 -0
- package/hooks/post-tool-use.ts +144 -0
- package/hooks/session-start.ts +64 -0
- package/hooks/stop.ts +131 -0
- package/mem-page.html +1305 -0
- package/package.json +30 -0
- package/src/capture/dedup.test.ts +103 -0
- package/src/capture/dedup.ts +76 -0
- package/src/capture/extractor.test.ts +245 -0
- package/src/capture/extractor.ts +330 -0
- package/src/capture/quality.test.ts +168 -0
- package/src/capture/quality.ts +104 -0
- package/src/capture/retrospective.test.ts +115 -0
- package/src/capture/retrospective.ts +121 -0
- package/src/capture/scanner.test.ts +131 -0
- package/src/capture/scanner.ts +100 -0
- package/src/capture/scrubber.test.ts +144 -0
- package/src/capture/scrubber.ts +181 -0
- package/src/cli.ts +517 -0
- package/src/config.ts +238 -0
- package/src/context/inject.test.ts +940 -0
- package/src/context/inject.ts +382 -0
- package/src/embeddings/backfill.ts +50 -0
- package/src/embeddings/embedder.test.ts +76 -0
- package/src/embeddings/embedder.ts +139 -0
- package/src/lifecycle/aging.test.ts +103 -0
- package/src/lifecycle/aging.ts +36 -0
- package/src/lifecycle/compaction.test.ts +264 -0
- package/src/lifecycle/compaction.ts +190 -0
- package/src/lifecycle/purge.test.ts +100 -0
- package/src/lifecycle/purge.ts +37 -0
- package/src/lifecycle/scheduler.test.ts +120 -0
- package/src/lifecycle/scheduler.ts +101 -0
- package/src/provisioning/browser-auth.ts +172 -0
- package/src/provisioning/provision.test.ts +198 -0
- package/src/provisioning/provision.ts +94 -0
- package/src/register.test.ts +167 -0
- package/src/register.ts +178 -0
- package/src/server.ts +436 -0
- package/src/storage/migrations.test.ts +244 -0
- package/src/storage/migrations.ts +261 -0
- package/src/storage/outbox.test.ts +229 -0
- package/src/storage/outbox.ts +131 -0
- package/src/storage/projects.test.ts +137 -0
- package/src/storage/projects.ts +184 -0
- package/src/storage/sqlite.test.ts +798 -0
- package/src/storage/sqlite.ts +934 -0
- package/src/storage/vec.test.ts +198 -0
- package/src/sync/auth.test.ts +76 -0
- package/src/sync/auth.ts +68 -0
- package/src/sync/client.ts +183 -0
- package/src/sync/engine.test.ts +94 -0
- package/src/sync/engine.ts +127 -0
- package/src/sync/pull.test.ts +279 -0
- package/src/sync/pull.ts +170 -0
- package/src/sync/push.test.ts +117 -0
- package/src/sync/push.ts +230 -0
- package/src/tools/get.ts +34 -0
- package/src/tools/pin.ts +47 -0
- package/src/tools/save.test.ts +301 -0
- package/src/tools/save.ts +231 -0
- package/src/tools/search.test.ts +69 -0
- package/src/tools/search.ts +181 -0
- package/src/tools/timeline.ts +64 -0
- package/tsconfig.json +22 -0
package/SENTINEL.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Engrm Sentinel — Real-Time AI Audit for Coding Agents
|
|
2
|
+
|
|
3
|
+
**Status**: Planned (Phase 5)
|
|
4
|
+
**Target Launch**: April 22, 2026 (6 weeks from 2026-03-11)
|
|
5
|
+
**Tier**: Pro + Team (paid upsell feature)
|
|
6
|
+
|
|
7
|
+
## Executive Summary
|
|
8
|
+
|
|
9
|
+
Sentinel is a real-time code validation layer that intercepts AI agent tool calls (file writes, edits) **before execution**, retrieves team-specific coding standards from Engrm's vector memory, and routes the diff through a configurable audit LLM for judgment. If the code violates team standards, Sentinel blocks the write and tells the agent exactly what to fix — the agent self-corrects automatically.
|
|
10
|
+
|
|
11
|
+
No competitor offers this. Every existing AI code review tool (CodeRabbit, Qodo, Greptile, Ellipsis) operates at PR level — **after** code is written. Sentinel operates at the pre-execution level, preventing mistakes before they happen.
|
|
12
|
+
|
|
13
|
+
## Market Gap
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Static Standards Dynamic RAG Standards
|
|
17
|
+
───────────────── ──────────────────────
|
|
18
|
+
PR-Level Review │ CodeRabbit ($24) │ Qodo ($30)
|
|
19
|
+
│ Ellipsis ($20) │ Greptile ($30)
|
|
20
|
+
│ Sourcery ($12) │
|
|
21
|
+
│ Copilot ($19-39) │
|
|
22
|
+
─────────────────┼───────────────────────┼─────────────────────────
|
|
23
|
+
Real-Time │ decider/claude-hooks │
|
|
24
|
+
Pre-Execution │ trailofbits config │ ← ENGRM SENTINEL
|
|
25
|
+
Interception │ (local-only, no RAG) │ (UNOCCUPIED)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Competitive Research (March 2026)
|
|
29
|
+
|
|
30
|
+
| Tool | Pricing | Timing | Custom Standards | RAG/Vector | Agent Hooks |
|
|
31
|
+
|------|---------|--------|-----------------|------------|-------------|
|
|
32
|
+
| CodeRabbit | $0-24/dev/mo | PR-level + IDE inline | Yes (.coderabbit.yml) | No | No |
|
|
33
|
+
| Qodo | $0-30/dev/mo | PR-level + IDE | Yes (auto-generated) | Yes (proprietary) | No |
|
|
34
|
+
| Greptile | $30/dev/mo | PR-level | Learns from PRs | Yes (AST + vector) | No |
|
|
35
|
+
| Ellipsis | ~$20/dev/mo | PR-level | Yes (natural language) | No | No |
|
|
36
|
+
| Cursor Bugbot | Included ($20-40/mo) | PR-level (background) | .cursor/rules | Proprietary | Cursor-only |
|
|
37
|
+
| Copilot Review | $19-39/user/mo | PR-level | Repository rules | Proprietary | Copilot-only |
|
|
38
|
+
| **Engrm Sentinel** | **$15-25/dev/mo** | **Pre-execution** | **Dynamic RAG** | **Hybrid FTS5+vec** | **Any MCP agent** |
|
|
39
|
+
|
|
40
|
+
### GitHub Reference Implementations
|
|
41
|
+
|
|
42
|
+
| Repo | Stars | Pattern | What We Learn |
|
|
43
|
+
|------|-------|---------|--------------|
|
|
44
|
+
| disler/claude-code-hooks-mastery | 3.3k | Builder/Validator agents, PostToolUse linting | Builder/Validator separation pattern |
|
|
45
|
+
| trailofbits/claude-code-config | 1.6k | Security blocking hooks, anti-rationalization gate | Stop hook prompt checking for incomplete work |
|
|
46
|
+
| qodo-ai/pr-agent | 10.5k | PR review tools, AGPL | PR compression for large diffs |
|
|
47
|
+
| ChrisWiles/claude-code-showcase | 5.5k | Skills, agents, GitHub Actions | Skill evaluation hook as pattern |
|
|
48
|
+
| decider/claude-hooks | 67 | Static rule enforcement | Hierarchical config (root + dir overrides) |
|
|
49
|
+
| praneybehl/code-review-mcp | 29 | MCP server for multi-provider review | Stateless — no memory, no team sharing |
|
|
50
|
+
|
|
51
|
+
**Key insight**: Every existing implementation is stateless. None retrieves project-specific standards from vector memory. None syncs findings across a team.
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
### Flow
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Developer working with Claude Code...
|
|
59
|
+
|
|
60
|
+
Claude tries to write a file
|
|
61
|
+
│
|
|
62
|
+
▼
|
|
63
|
+
PreToolUse(Write|Edit) fires → hooks/sentinel.ts
|
|
64
|
+
│
|
|
65
|
+
├─ 1. SKIP CHECK
|
|
66
|
+
│ Is sentinel enabled? Is this file in skip_patterns?
|
|
67
|
+
│
|
|
68
|
+
├─ 2. RETRIEVE STANDARDS
|
|
69
|
+
│ engrm search("auth middleware security")
|
|
70
|
+
│ → "Decision: all auth must use bcrypt, not MD5"
|
|
71
|
+
│ → "Bugfix: session tokens were stored unencrypted"
|
|
72
|
+
│ → "Standard: never log auth credentials"
|
|
73
|
+
│
|
|
74
|
+
├─ 3. AUDIT LLM CALL
|
|
75
|
+
│ POST base_url/chat/completions
|
|
76
|
+
│ { model, messages: [system + standards + diff] }
|
|
77
|
+
│ temperature: 0, max_tokens: 150
|
|
78
|
+
│
|
|
79
|
+
├─ 4a. PASS → exit 0 (Claude proceeds)
|
|
80
|
+
├─ 4b. WARN → exit 0 + log observation
|
|
81
|
+
└─ 4c. BLOCK → exit 2 + stderr reason
|
|
82
|
+
(Claude receives error, self-corrects, retries)
|
|
83
|
+
│
|
|
84
|
+
▼
|
|
85
|
+
Finding saved as observation → syncs to team → future audits are smarter
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Dashboard → Server → Client Config Push
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Dashboard (engrm.dev/sentinel)
|
|
92
|
+
│ POST /v1/mem/sentinel/config
|
|
93
|
+
▼
|
|
94
|
+
Candengo Vector (sync_events, record_type="sentinel_config")
|
|
95
|
+
│ GET /v1/sync/changes (existing pull loop, every 60s)
|
|
96
|
+
▼
|
|
97
|
+
Client (~/.engrm/settings.json → sentinel config merged)
|
|
98
|
+
│
|
|
99
|
+
▼
|
|
100
|
+
PreToolUse hook reads config on each invocation
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Provider Agnostic (OpenAI-Compatible API)
|
|
104
|
+
|
|
105
|
+
All major LLM providers speak the same `POST /v1/chat/completions` format:
|
|
106
|
+
|
|
107
|
+
| Provider | Base URL | Models | Cost/1K audits |
|
|
108
|
+
|----------|----------|--------|---------------|
|
|
109
|
+
| OpenAI | api.openai.com/v1 | gpt-4o-mini | ~$0.40 |
|
|
110
|
+
| xAI/Grok | api.x.ai/v1 | grok-3-mini | ~$0.30 |
|
|
111
|
+
| Mistral | api.mistral.ai/v1 | mistral-small | ~$0.20 |
|
|
112
|
+
| Anthropic | via proxy | haiku-4.5 | ~$0.50 |
|
|
113
|
+
| Local vLLM | 192.168.5.5:8000/v1 | devstral-24b | $0 |
|
|
114
|
+
| Ollama | localhost:11434/v1 | llama3-8b | $0 |
|
|
115
|
+
|
|
116
|
+
One client function, ~40 lines. No provider-specific code.
|
|
117
|
+
|
|
118
|
+
## Config Schema
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
interface SentinelConfig {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
mode: "advisory" | "blocking"; // WARN-only vs BLOCK+WARN
|
|
124
|
+
provider: "openai" | "xai" | "mistral" | "anthropic" | "custom";
|
|
125
|
+
base_url: string; // OpenAI-compatible endpoint
|
|
126
|
+
model: string; // e.g. "gpt-4o-mini"
|
|
127
|
+
api_key_env?: string; // Client-side env var name
|
|
128
|
+
encrypted_api_key?: string; // Server-pushed, decrypted client-side
|
|
129
|
+
match_tools: string[]; // ["Write", "Edit"] default
|
|
130
|
+
timeout_ms: number; // Max wait (default 8000)
|
|
131
|
+
skip_patterns: string[]; // e.g. ["*.test.ts", "*.md"]
|
|
132
|
+
max_diff_lines: number; // Truncate large diffs (default 200)
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Stored in `~/.engrm/settings.json` under `sentinel` key. Pushed from dashboard via sync_events.
|
|
137
|
+
|
|
138
|
+
## Standards
|
|
139
|
+
|
|
140
|
+
Standards are **observations tagged as audit-relevant**. No separate schema needed.
|
|
141
|
+
|
|
142
|
+
- Add `"standard"` to the observation type enum
|
|
143
|
+
- Tag with `sentinel-standard` in concepts
|
|
144
|
+
- Standards sync through the existing push/pull pipeline
|
|
145
|
+
- Dashboard provides UI for creating/managing them
|
|
146
|
+
- Every past decision, bugfix, and pattern is a potential standard — just tag it
|
|
147
|
+
|
|
148
|
+
## Graceful Degradation
|
|
149
|
+
|
|
150
|
+
Following the sqlite-vec precedent:
|
|
151
|
+
|
|
152
|
+
| Failure | Behavior |
|
|
153
|
+
|---------|----------|
|
|
154
|
+
| LLM API down/timeout | exit 0 (allow), log warning |
|
|
155
|
+
| No standards found | Skip audit, exit 0 |
|
|
156
|
+
| Config not synced yet | Sentinel disabled by default |
|
|
157
|
+
| API key missing | Skip audit, log once |
|
|
158
|
+
| Free tier user | Sentinel hooks not registered |
|
|
159
|
+
|
|
160
|
+
## Feedback Loop (The Moat)
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Sentinel blocks a write
|
|
164
|
+
→ Claude self-corrects
|
|
165
|
+
→ Corrected code passes
|
|
166
|
+
→ Block + correction saved as observation
|
|
167
|
+
→ Observation syncs to all team members
|
|
168
|
+
→ Future audits retrieve it as context
|
|
169
|
+
→ Sentinel gets smarter over time
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Static rules don't learn. Sentinel does. This is the competitive moat.
|
|
173
|
+
|
|
174
|
+
## Pricing
|
|
175
|
+
|
|
176
|
+
| Tier | Sentinel | Observations | Price |
|
|
177
|
+
|------|----------|-------------|-------|
|
|
178
|
+
| Free | Not available | 10K, 2 devices | $0 |
|
|
179
|
+
| Pro | Advisory mode, 100 audits/day, own API keys | 50K, unlimited devices | $15/dev/mo |
|
|
180
|
+
| Team | Full blocking + advisory, unlimited, dashboard config push, shared standards, audit heatmap | 100K, unlimited devices | $25/dev/mo |
|
|
181
|
+
|
|
182
|
+
Users bring their own LLM API keys. Engrm's marginal cost per audit is near-zero (one vector search + config lookup).
|
|
183
|
+
|
|
184
|
+
## Implementation Plan
|
|
185
|
+
|
|
186
|
+
### Phase 1: Core Hook + Local Audit (Week 1)
|
|
187
|
+
|
|
188
|
+
| Task | File | Effort |
|
|
189
|
+
|------|------|--------|
|
|
190
|
+
| Add `SentinelConfig` to config interface | `src/config.ts` | 1h |
|
|
191
|
+
| Add `"standard"` to observation type enum | `src/types.ts` | 30m |
|
|
192
|
+
| Create `src/sentinel/types.ts` | New | 30m |
|
|
193
|
+
| Create `src/sentinel/llm-client.ts` (OpenAI-compatible) | New (~40 lines) | 1h |
|
|
194
|
+
| Create `src/sentinel/prompts.ts` | New | 2h |
|
|
195
|
+
| Create `src/sentinel/audit.ts` (orchestrator) | New | 3h |
|
|
196
|
+
| Create `hooks/sentinel.ts` (PreToolUse hook) | New | 2h |
|
|
197
|
+
| Register sentinel hook in `registerHooks()` | `src/register.ts` | 30m |
|
|
198
|
+
| Tests | `src/sentinel/*.test.ts` | 3h |
|
|
199
|
+
| Integration test (hook → local LLM) | Manual | 2h |
|
|
200
|
+
|
|
201
|
+
### Phase 2: Dashboard Config Push (Week 2)
|
|
202
|
+
|
|
203
|
+
| Task | Location | Effort |
|
|
204
|
+
|------|----------|--------|
|
|
205
|
+
| `POST /v1/mem/sentinel/config` endpoint | candengo-vector | 3h |
|
|
206
|
+
| `GET /v1/mem/sentinel/config` endpoint | candengo-vector | 1h |
|
|
207
|
+
| Store config in sync_events (record_type="sentinel_config") | candengo-vector | 2h |
|
|
208
|
+
| Handle sentinel_config in pull loop | `src/sync/pull.ts` | 2h |
|
|
209
|
+
| Dashboard: LLM provider config page | website/mem/sentinel.html | 4h |
|
|
210
|
+
| Dashboard: standards manager (CRUD) | website/mem/sentinel.html | 4h |
|
|
211
|
+
| API key encryption (server→client) | Both | 3h |
|
|
212
|
+
|
|
213
|
+
### Phase 3: Standards Library + Feedback Loop (Week 3)
|
|
214
|
+
|
|
215
|
+
| Task | Location | Effort |
|
|
216
|
+
|------|----------|--------|
|
|
217
|
+
| `POST /v1/mem/sentinel/standards` CRUD | candengo-vector | 3h |
|
|
218
|
+
| Standards sync via pull loop | `src/sync/pull.ts` | 2h |
|
|
219
|
+
| Save audit findings as observations | `src/sentinel/audit.ts` | 2h |
|
|
220
|
+
| Dashboard: audit results + heatmap | candengo-vector website | 4h |
|
|
221
|
+
| `engrm sentinel status` CLI | `src/cli.ts` | 1h |
|
|
222
|
+
| `engrm sentinel test` CLI | `src/cli.ts` | 2h |
|
|
223
|
+
|
|
224
|
+
### Phase 4: Polish + Tier Enforcement (Week 4)
|
|
225
|
+
|
|
226
|
+
| Task | Effort |
|
|
227
|
+
|------|--------|
|
|
228
|
+
| Rate limiting (100/day pro, unlimited team) | 2h |
|
|
229
|
+
| Tier check on hook registration | 1h |
|
|
230
|
+
| Anti-rationalization gate (Stop hook, from TrailOfBits) | 3h |
|
|
231
|
+
| Skip patterns, file-type filtering | 2h |
|
|
232
|
+
| Docs + onboarding in dashboard | 3h |
|
|
233
|
+
| Performance profiling (target: <3s/audit) | 2h |
|
|
234
|
+
|
|
235
|
+
### Phase 5: Beta + Launch (Weeks 5-6)
|
|
236
|
+
|
|
237
|
+
| Task | Effort |
|
|
238
|
+
|------|--------|
|
|
239
|
+
| Internal dogfood (Unimpossible team) | 1 week |
|
|
240
|
+
| Bug fixes from dogfood | Variable |
|
|
241
|
+
| Launch blog post + HN announcement | 1 day |
|
|
242
|
+
| Waitlist conversion emails | 1 day |
|
|
243
|
+
|
|
244
|
+
## Files to Create
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
src/sentinel/
|
|
248
|
+
├── types.ts # SentinelConfig, AuditResult, etc.
|
|
249
|
+
├── llm-client.ts # OpenAI-compatible API client (~40 lines)
|
|
250
|
+
├── prompts.ts # System prompt, audit request formatter, response parser
|
|
251
|
+
├── audit.ts # Orchestrator: search → LLM → decision → save finding
|
|
252
|
+
└── *.test.ts # Tests
|
|
253
|
+
|
|
254
|
+
hooks/
|
|
255
|
+
└── sentinel.ts # PreToolUse hook (follows post-tool-use.ts pattern)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Files to Modify
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
src/config.ts # Add SentinelConfig to Config interface + defaults
|
|
262
|
+
src/register.ts # Register PreToolUse sentinel hook
|
|
263
|
+
src/sync/pull.ts # Handle record_type="sentinel_config" | "sentinel_standard"
|
|
264
|
+
src/cli.ts # Add `engrm sentinel status|test` commands
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Key Design Patterns to Follow
|
|
268
|
+
|
|
269
|
+
| Pattern | Source | Application |
|
|
270
|
+
|---------|--------|-------------|
|
|
271
|
+
| Silent error handling | hooks/post-tool-use.ts | Never crash; exit 0 on any error |
|
|
272
|
+
| Config merging | src/config.ts | Defaults → disk → sync override |
|
|
273
|
+
| Reentrancy guards | src/sync/engine.ts | Prevent concurrent audits |
|
|
274
|
+
| Graceful degradation | sqlite-vec integration | If unavailable, skip silently |
|
|
275
|
+
| Observation pipeline | src/capture/ | Findings go through same scrub→quality→dedup→save flow |
|
|
276
|
+
|
|
277
|
+
## References
|
|
278
|
+
|
|
279
|
+
### Competitors
|
|
280
|
+
- [CodeRabbit](https://www.coderabbit.ai/) — PR-level, $0-24/dev/mo
|
|
281
|
+
- [Qodo](https://www.qodo.ai/) — Best RAG, PR-level, $0-30/dev/mo
|
|
282
|
+
- [Greptile](https://www.greptile.com/) — Learns from PRs, $30/dev/mo
|
|
283
|
+
- [Ellipsis](https://www.ellipsis.dev/) — PR-level, ~$20/dev/mo
|
|
284
|
+
|
|
285
|
+
### GitHub Repos
|
|
286
|
+
- [disler/claude-code-hooks-mastery](https://github.com/disler/claude-code-hooks-mastery) (3.3k★)
|
|
287
|
+
- [trailofbits/claude-code-config](https://github.com/trailofbits/claude-code-config) (1.6k★)
|
|
288
|
+
- [qodo-ai/pr-agent](https://github.com/qodo-ai/pr-agent) (10.5k★)
|
|
289
|
+
- [praneybehl/code-review-mcp](https://github.com/praneybehl/code-review-mcp)
|
|
290
|
+
|
|
291
|
+
### Claude Code Docs
|
|
292
|
+
- [Hooks Reference](https://code.claude.com/docs/en/hooks)
|
|
293
|
+
- [Hooks Guide](https://code.claude.com/docs/en/hooks-guide)
|