@compr/opscontext-mcp 2.0.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 (48) hide show
  1. package/CHANGELOG.md +313 -0
  2. package/LICENSE +83 -0
  3. package/README.md +470 -0
  4. package/defaults/learnings.json +146 -0
  5. package/dist/activation.d.ts +48 -0
  6. package/dist/activation.js +377 -0
  7. package/dist/adapters.d.ts +101 -0
  8. package/dist/adapters.js +171 -0
  9. package/dist/agents.d.ts +137 -0
  10. package/dist/agents.js +1638 -0
  11. package/dist/audit.d.ts +23 -0
  12. package/dist/audit.js +163 -0
  13. package/dist/cache.d.ts +15 -0
  14. package/dist/cache.js +117 -0
  15. package/dist/claude-integration.d.ts +95 -0
  16. package/dist/claude-integration.js +247 -0
  17. package/dist/cli.d.ts +18 -0
  18. package/dist/cli.js +1823 -0
  19. package/dist/code-chunker.d.ts +12 -0
  20. package/dist/code-chunker.js +270 -0
  21. package/dist/collectors.d.ts +63 -0
  22. package/dist/collectors.js +617 -0
  23. package/dist/config.d.ts +73 -0
  24. package/dist/config.js +239 -0
  25. package/dist/embeddings.d.ts +36 -0
  26. package/dist/embeddings.js +124 -0
  27. package/dist/firewall.d.ts +133 -0
  28. package/dist/firewall.js +631 -0
  29. package/dist/hooks.d.ts +76 -0
  30. package/dist/hooks.js +313 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.js +1081 -0
  33. package/dist/ingest.d.ts +32 -0
  34. package/dist/ingest.js +162 -0
  35. package/dist/learnings.d.ts +108 -0
  36. package/dist/learnings.js +714 -0
  37. package/dist/license-sig.d.ts +47 -0
  38. package/dist/license-sig.js +104 -0
  39. package/dist/policy.d.ts +131 -0
  40. package/dist/policy.js +182 -0
  41. package/dist/search.d.ts +11 -0
  42. package/dist/search.js +99 -0
  43. package/dist/sessions.d.ts +46 -0
  44. package/dist/sessions.js +153 -0
  45. package/examples/adapters/notion-adapter.js +108 -0
  46. package/examples/adapters/rss-adapter.js +76 -0
  47. package/package.json +87 -0
  48. package/skills/opscontext/SKILL.md +260 -0
package/README.md ADDED
@@ -0,0 +1,470 @@
1
+ # OpsContext for AI Agents
2
+
3
+ **The ops + compliance layer Claude Code can't grow natively.** Read-only visibility into PM2 / nginx / Docker / git / cron — plus a tamper-evident audit log and policy-as-code git hooks.
4
+
5
+ > Previously published as `@compr/contextengine-mcp`. The 2.0 rename reflects what the project actually does: Claude Code sees the **code**, OpsContext sees the **infra that runs it**.
6
+
7
+ [![npm](https://img.shields.io/npm/v/@compr/opscontext-mcp)](https://www.npmjs.com/package/@compr/opscontext-mcp)
8
+ [![License: BSL-1.1](https://img.shields.io/badge/License-BSL--1.1-blue.svg)](https://www.npmjs.com/package/@compr/opscontext-mcp)
9
+ [![VS Code](https://img.shields.io/badge/VS%20Code-Extension-007ACC?logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=css-llc.contextengine)
10
+
11
+ OpsContext is an [MCP](https://modelcontextprotocol.io) server. It runs locally, snapshots your live infra (PM2 processes, nginx config, Docker containers, git status, cron jobs, redacted env), and exposes it via tools your AI coding agents (Claude Code, Cursor, Copilot, Windsurf, OpenClaw) can call in real time. Everything stays on your machine — no telemetry, no code uploads.
12
+
13
+ ## Why
14
+
15
+ Claude Code already reads your `CLAUDE.md`, `copilot-instructions.md`, and source files. It has hooks, skills, and native memory. It does not — and structurally cannot — see what's running on your servers. Live process state, nginx routes, port conflicts across fleets, git working-tree drift across 30+ repos — that's the operational context AI agents lack.
16
+
17
+ OpsContext fills that gap, plus two compliance layers regulated industries demand from any agent stack:
18
+
19
+ 1. **Operational visibility (the moat)** — collectors for PM2 / nginx / Docker / git / cron / .env (redacted) / composer / systemd. Cross-project + check_ports + fleet HTML scoring. Claude Code can't see this; we feed it cleanly.
20
+ 2. **Tamper-evident audit log (compliance)** — hash-chained JSONL at `~/.contextengine/audit.log`. Every state change recorded with `prev_hash`/`hash`. SOC2 CC7.2 and ISO 27001 A.12.4.1 evidence out of the box.
21
+ 3. **Policy-as-code hooks (enforcement)** — declarative `.contextengine/policy.json` for secret patterns (with `paths` scoping), diff-aware doc coverage (replaces the workaround-y 4-hour staleness gate), deploy-verify hosts, and signed bypass tokens. Runs as a pre-commit hook layer alongside gitleaks.
22
+
23
+ Plus the persistent-memory + search features carried forward from the contextengine era:
24
+
25
+ - 🔍 **Hybrid Search** — keyword (BM25) ships always; semantic re-ranking is opt-in
26
+ - 🧠 **Semantic Search (optional)** — `all-MiniLM-L6-v2` runs locally on CPU, no API keys. Install with `npm install @huggingface/transformers` (~250MB, native onnxruntime). BM25 alone is plenty for most workspaces; turn semantic on when you have many similar projects and want fuzzy matches.
27
+ - 📁 **Auto-discover** — finds `copilot-instructions.md`, `CLAUDE.md`, `.cursorrules`, `AGENTS.md` across all projects
28
+ - 💻 **Code Parsing** — extracts functions, classes, interfaces from TS/JS/Python source files
29
+ - ⚙️ **Operational Intelligence** — collects git, Docker, PM2, nginx, cron, package.json data
30
+ - 🔒 **Local-only** — nothing leaves your machine
31
+ - ⚡ **Instant startup** — keyword search ready immediately, embeddings load in background
32
+ - 💾 **Session Persistence** — AI agents can save/restore context across conversations
33
+ - 💡 **Learning Store** — permanent operational rules that auto-surface in search results
34
+ - �️ **Protocol Firewall** — progressive enforcement that ensures agents commit, document, and save learnings
35
+ - �🔌 **Plugin Adapters** — extend with custom data sources (Notion, Jira, RSS, etc.)
36
+ - 🧩 **MCP native** — works with any MCP-compatible client (VS Code, Claude, Cursor, OpenClaw)
37
+
38
+ ### What OpsContext is NOT
39
+
40
+ - **Not a replacement for Claude Code, Cursor, or your IDE assistant.** It runs *alongside* them as their ops/compliance backend. Code context = their job. Infra context + audit + policy = ours.
41
+ - **Not a code quality tool** — it checks project structure (CI, tests, Docker, docs) and validates content depth, but won't tell you if your code is good. An A+ score means "well-organized for AI agents," not "production-ready."
42
+ - **Not required for tiny / solo projects** — agents read `copilot-instructions.md` natively, and the audit log + policy gates earn their keep when there's more than one developer to coordinate or a compliance officer to answer to.
43
+ - **Not worth chasing 100% score** — invest in your PIPELINES.md and SKILLS docs instead of score-chasing. Those prevent costly mistakes; the score keeps you honest.
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Scaffold config (optional)
48
+
49
+ ```bash
50
+ npx @compr/opscontext-mcp init
51
+ ```
52
+
53
+ Detects your project type, creates `contextengine.json` + `.github/copilot-instructions.md` template.
54
+
55
+ ### 2. Add to your MCP client
56
+
57
+ **VS Code (recommended — per-project setup)**
58
+
59
+ Create `.vscode/mcp.json` in your project root:
60
+
61
+ ```json
62
+ {
63
+ "servers": {
64
+ "contextengine": {
65
+ "type": "stdio",
66
+ "command": "npx",
67
+ "args": ["-y", "@compr/opscontext-mcp"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ This activates ContextEngine when the workspace is open. Add this file to each project that needs it.
74
+
75
+ > **Note:** VS Code deprecated MCP configuration in user `settings.json`. Use `.vscode/mcp.json` per workspace instead.
76
+
77
+ **Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "ContextEngine": {
83
+ "command": "npx",
84
+ "args": ["-y", "@compr/opscontext-mcp"]
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ **Cursor** — add to MCP settings:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "ContextEngine": {
96
+ "command": "npx",
97
+ "args": ["-y", "@compr/opscontext-mcp"]
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ **OpenClaw** — add ContextEngine as an MCP server in your OpenClaw config, or use the bundled skill:
104
+
105
+ ```bash
106
+ # Option 1: Copy the skill to your OpenClaw workspace
107
+ cp -r node_modules/@compr/opscontext-mcp/skills/contextengine ~/.openclaw/workspace/skills/
108
+
109
+ # Option 2: Add as MCP server in openclaw.json
110
+ ```
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "contextengine": {
116
+ "command": "npx",
117
+ "args": ["-y", "@compr/opscontext-mcp"],
118
+ "env": { "CONTEXTENGINE_WORKSPACES": "~/Projects" }
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### 3. Pin your config (recommended)
125
+
126
+ If you have a `contextengine.json` with custom sources, add this to your shell profile (`~/.zshrc` or `~/.bashrc`):
127
+
128
+ ```bash
129
+ export CONTEXTENGINE_CONFIG="$HOME/path/to/contextengine.json"
130
+ ```
131
+
132
+ Without this, ContextEngine falls back to auto-discovery (finds `copilot-instructions.md` etc.) but won't load your explicit sources, code dirs, or custom patterns.
133
+
134
+ That's it. ContextEngine auto-discovers your docs in `~/Projects`.
135
+
136
+ ## 📦 VS Code Extension
137
+
138
+ ContextEngine has a **free VS Code extension** that provides proactive enforcement — no MCP setup required:
139
+
140
+ [![Install Extension](https://img.shields.io/badge/Install-VS%20Code%20Marketplace-007ACC?logo=visualstudiocode&style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=css-llc.contextengine)
141
+
142
+ - **📊 Value meter** — shows what ContextEngine saved you this session: learnings recalled, learnings saved, estimated time saved. Falls back to git status when no MCP session is active
143
+ - **📈 Live stats dashboard** — click ℹ️ to see real-time session metrics (tool calls, recalls, nudges, truncations, time saved)
144
+ - **@contextengine chat** — `/status`, `/commit`, `/search`, `/remind`, `/sync` in Copilot Chat
145
+ - **Escalating notifications** — warns when files accumulate without commits
146
+ - **Terminal watcher** — monitors commands with smart classification (git, deploy, database, python, build, test), credential redaction in logs, and stuck-pattern detection (alerts after 3+ consecutive failures)
147
+ - **One-click commit** — commit all changes across all repos
148
+
149
+ The extension reads live metrics from the MCP server (via `~/.contextengine/session-stats.json`). For search, learnings, sessions, and scoring — it uses the MCP server (`npx @compr/opscontext-mcp`).
150
+
151
+ ## ⭐ PRO Features
152
+
153
+ ContextEngine is **free and open-core**. The free tier covers everything agents need — search, memory, sessions, and compliance enforcement. PRO adds **team and ops intelligence** across multiple projects:
154
+
155
+ | Feature | Free | PRO |
156
+ |---------|------|-----|
157
+ | Hybrid search (keyword + semantic) | ✅ | ✅ |
158
+ | Persistent learnings | ✅ | ✅ |
159
+ | Session save/load | ✅ | ✅ |
160
+ | End-of-session enforcement | ✅ | ✅ |
161
+ | Protocol Firewall (agent compliance) | ✅ | ✅ |
162
+ | VS Code extension (git monitor, chat) | ✅ | ✅ |
163
+ | Plugin adapters | ✅ | ✅ |
164
+ | **Project health score (A+ to F)** | — | ✅ |
165
+ | **Compliance audit** | — | ✅ |
166
+ | **Port conflict detection** | — | ✅ |
167
+ | **Multi-project discovery** | — | ✅ |
168
+ | **HTML score reports** | — | ✅ |
169
+
170
+ ### Pricing
171
+
172
+ | Plan | Price | Machines |
173
+ |------|-------|----------|
174
+ | **Pro** | CHF 2/mo | 2 |
175
+ | **Team** | CHF 12/mo | 5 |
176
+ | **Enterprise** | CHF 36/mo | 10 |
177
+
178
+ → **[Get PRO](https://api.compr.ch/contextengine/pricing)** · Annual plans save 17%
179
+
180
+ ```bash
181
+ # Activate after purchase
182
+ npx @compr/opscontext-mcp activate
183
+ ```
184
+
185
+ ## CLI Usage (no MCP required)
186
+
187
+ ContextEngine also works as a **standalone CLI tool** — no MCP client setup needed:
188
+
189
+ ```bash
190
+ # Search across all your project knowledge
191
+ npx @compr/opscontext-mcp search "docker nginx"
192
+ npx @compr/opscontext-mcp search "rate limiting" -n 10
193
+
194
+ # List all indexed sources
195
+ npx @compr/opscontext-mcp list-sources
196
+
197
+ # Discover and analyze all projects
198
+ npx @compr/opscontext-mcp list-projects
199
+
200
+ # AI-readiness score (one or all projects)
201
+ npx @compr/opscontext-mcp score
202
+ npx @compr/opscontext-mcp score ContextEngine
203
+
204
+ # Visual HTML report (opens in browser)
205
+ npx @compr/opscontext-mcp score --html
206
+ npx @compr/opscontext-mcp score ContextEngine --html
207
+
208
+ # List permanent learnings (optionally by category)
209
+ npx @compr/opscontext-mcp list-learnings
210
+ npx @compr/opscontext-mcp list-learnings security
211
+
212
+ # Show live MCP session stats (value meter)
213
+ npx @compr/opscontext-mcp stats
214
+
215
+ # Run compliance audit across all projects
216
+ npx @compr/opscontext-mcp audit
217
+
218
+ # Scaffold config for a new project
219
+ npx @compr/opscontext-mcp init
220
+
221
+ # Show all commands
222
+ npx @compr/opscontext-mcp help
223
+ ```
224
+
225
+ CLI mode uses keyword search (BM25) which is instant — no model loading required.
226
+
227
+ ## Tools (20)
228
+
229
+ | Tool | Description | Tier |
230
+ |------|-------------|------|
231
+ | `search_context` | Hybrid keyword+semantic search with mode selector | Free |
232
+ | `list_sources` | Show all indexed sources with chunk counts | Free |
233
+ | `read_source` | Read full content of a knowledge source by name | Free |
234
+ | `reindex` | Force full re-index of all sources | Free |
235
+ | `save_session` | Save key-value entry to a named session | Free |
236
+ | `load_session` | Load all entries from a named session | Free |
237
+ | `list_sessions` | List all saved sessions | Free |
238
+ | `delete_session` | Delete a saved session | Free |
239
+ | `end_session` | Pre-flight checklist — uncommitted changes + doc freshness | Free |
240
+ | `save_learning` | Save a permanent operational rule — auto-surfaces in search | Free |
241
+ | `list_learnings` | List all permanent learnings, optionally by category | Free |
242
+ | `delete_learning` | Remove a learning by ID | Free |
243
+ | `import_learnings` | Bulk-import learnings from Markdown or JSON files | Free |
244
+ | `audit_verify` | Verify tamper-evident audit log chain (SOC2 CC7.2, ISO 27001 A.12.4.1) | Free |
245
+ | `activate` | Activate a PRO license on this machine | Free |
246
+ | `activation_status` | Check current license status | Free |
247
+ | `list_projects` | Discover and analyze all projects (tech stack, git, docker) | PRO |
248
+ | `check_ports` | Scan all projects for port conflicts | PRO |
249
+ | `run_audit` | Compliance agent — git, hooks, .env, Docker, PM2, versions | PRO |
250
+ | `score_project` | AI-readiness scoring 0-100% with letter grades (A+ to F) | PRO |
251
+
252
+ All tools are wrapped by the **Protocol Firewall** — a built-in enforcement layer that ensures agents save learnings, persist sessions, and commit code. No action needed from users; it's automatic.
253
+
254
+ ## Configuration
255
+
256
+ ContextEngine works **zero-config** — it auto-discovers documentation files in `~/Projects`.
257
+
258
+ For full control, create a `contextengine.json`:
259
+
260
+ ```json
261
+ {
262
+ "sources": [
263
+ { "name": "Team Runbook", "path": "./docs/RUNBOOK.md" },
264
+ { "name": "Architecture", "path": "./docs/ARCHITECTURE.md" }
265
+ ],
266
+ "workspaces": ["~/Projects"],
267
+ "patterns": [
268
+ ".github/copilot-instructions.md",
269
+ "CLAUDE.md",
270
+ ".cursorrules",
271
+ "AGENTS.md"
272
+ ],
273
+ "codeDirs": ["src"],
274
+ "adapters": [
275
+ { "name": "feeds", "module": "./adapters/rss-adapter.js", "config": { "feeds": ["https://blog.example.com/rss.xml"] } }
276
+ ]
277
+ }
278
+ ```
279
+
280
+ ### Auto-discovered patterns
281
+
282
+ | Pattern | Description |
283
+ |---------|-------------|
284
+ | `.github/copilot-instructions.md` | GitHub Copilot project instructions |
285
+ | `.github/instructions/copilot-instructions.md` | VS Code instructions folder format |
286
+ | `.github/SKILLS.md` | Team skills inventory |
287
+ | `CLAUDE.md` | Claude Code project instructions |
288
+ | `.cursorrules` | Cursor AI rules |
289
+ | `.cursor/rules` | Cursor AI rules (folder format) |
290
+ | `AGENTS.md` | Multi-agent instructions |
291
+ | `CONTEXT_MAP.md` | File-to-concern mapping for agents |
292
+
293
+ ### Config resolution order
294
+
295
+ | Priority | Source |
296
+ |----------|--------|
297
+ | 1 | `CONTEXTENGINE_CONFIG` env var |
298
+ | 2 | `./contextengine.json` |
299
+ | 3 | `~/.contextengine.json` |
300
+ | 4 | `CONTEXTENGINE_WORKSPACES` env var |
301
+ | 5 | `~/Projects` auto-discover |
302
+
303
+ ## Plugin Adapters
304
+
305
+ Extend ContextEngine with custom data sources via the adapter interface. Adapters are ES modules that collect data and return searchable chunks.
306
+
307
+ ```json
308
+ {
309
+ "adapters": [
310
+ {
311
+ "name": "notion",
312
+ "module": "./adapters/notion-adapter.js",
313
+ "config": { "token": "$NOTION_API_TOKEN" }
314
+ },
315
+ {
316
+ "name": "feeds",
317
+ "module": "./adapters/rss-adapter.js",
318
+ "config": { "feeds": ["https://blog.example.com/rss.xml"], "maxItems": 20 }
319
+ }
320
+ ]
321
+ }
322
+ ```
323
+
324
+ ### Creating an Adapter
325
+
326
+ An adapter is a JS/TS module that exports an object with a `collect()` method:
327
+
328
+ ```javascript
329
+ // my-adapter.js
330
+ export default {
331
+ name: "my-source",
332
+ description: "Fetches data from My Source",
333
+
334
+ validate(config) {
335
+ if (!config?.apiKey) return "Missing apiKey";
336
+ return null;
337
+ },
338
+
339
+ async collect(config) {
340
+ // Fetch data and return Chunk[]
341
+ return [{
342
+ source: "my-source",
343
+ section: "## Title",
344
+ content: "Content to index...",
345
+ lineStart: 1,
346
+ lineEnd: 1,
347
+ }];
348
+ },
349
+ };
350
+ ```
351
+
352
+ See [examples/adapters/](examples/adapters/) for complete Notion and RSS adapter examples.
353
+
354
+ ### Adapter Features
355
+
356
+ - **Environment variable resolution** — use `"$ENV_VAR"` syntax in config
357
+ - **Factory pattern** — export `createAdapter(config)` for per-instance configuration
358
+ - **Validation** — optional `validate()` method checks config before collection
359
+ - **Lifecycle hooks** — optional `init()` and `destroy()` for setup/cleanup
360
+ - **Safe execution** — adapter failures never crash the server
361
+
362
+ ## How It Works
363
+
364
+ ```
365
+ Your Project Files ContextEngine AI Agent
366
+ +-----------------+ +-------------------+ +---------------+
367
+ | copilot- | | 1. Parse & chunk | | GitHub |
368
+ | instructions |--->| 2. Embed vectors |<-->| Copilot |
369
+ | CLAUDE.md | | 3. Hybrid search | | Claude |
370
+ | source code | | 4. Return top-k | | Cursor |
371
+ | git/docker/pm2 | | 5. Persist state | | Windsurf |
372
+ +-----------------+ +-------------------+ +---------------+
373
+ stdio (MCP)
374
+ ```
375
+
376
+ 1. **Parse** — chunks markdown + extracts functions from source code
377
+ 2. **Embed** — sentence embeddings run locally on CPU (no API keys)
378
+ 3. **Search** — hybrid keyword + semantic scoring
379
+ 4. **Collect** — operational data from git, package.json, Docker, PM2, nginx
380
+ 5. **Audit** — compliance checks, port conflicts, AI-readiness scoring
381
+
382
+ ## Scoring
383
+
384
+ The `score` command evaluates project AI-readiness across **documentation, infrastructure, code quality, and security** — producing a letter grade from A+ to F.
385
+
386
+ **Grade scale:** A+ (90%+) · A (80%+) · B (70%+) · C (60%+) · D (50%+) · F (<50%)
387
+
388
+ ### Project Naming & Structure Tips
389
+
390
+ The scorer discovers projects from your configured `workspaces` directories (default: `~/Projects`).
391
+ Each subdirectory is treated as a separate project. For best results:
392
+
393
+ - **Use descriptive folder names** — the folder name becomes the project name in reports
394
+ - **Keep one project per directory** — monorepos should have a root `copilot-instructions.md`
395
+ - **Real files over symlinks** — each project should have its own configs with project-specific content
396
+ - **Install your tools** — a linting config without the linter installed doesn't count as linting
397
+
398
+ ## Architecture
399
+
400
+ TypeScript monorepo — MCP server + CLI + search engine + operational collectors.
401
+
402
+ See the [npm package](https://www.npmjs.com/package/@compr/opscontext-mcp) for installation and usage.
403
+
404
+ ## Development
405
+
406
+ ```bash
407
+ npm install @compr/opscontext-mcp
408
+ npx @compr/opscontext-mcp help
409
+ ```
410
+
411
+ ## Requirements
412
+
413
+ - Node.js 18+
414
+ - No API keys needed — embeddings run locally
415
+
416
+ ## Contributing
417
+
418
+ Feedback, feature requests, and bug reports welcome — email [yannick@compr.ch](mailto:yannick@compr.ch).
419
+
420
+ If you're using ContextEngine, we'd love to hear about it.
421
+
422
+ ## Privacy & Data Security
423
+
424
+ **ContextEngine runs 100% on your machine. Your code, your data, your rules.**
425
+
426
+ Everything happens locally — search, scoring, learnings, sessions, embeddings. No project data is ever sent to an external server.
427
+
428
+ ### What stays on your machine (always)
429
+
430
+ | Data | Storage | Leaves your machine? |
431
+ |---|---|---|
432
+ | Project files & source code | Read locally, never stored externally | ❌ Never |
433
+ | Learnings (operational rules) | `~/.contextengine/learnings.json` | ❌ Never |
434
+ | Sessions (decisions, progress) | `~/.contextengine/sessions/` | ❌ Never |
435
+ | Session stats (value meter) | `~/.contextengine/session-stats.json` | ❌ Never |
436
+ | Search index & embeddings | In-memory + `~/.contextengine/embedding-cache.json` | ❌ Never |
437
+ | Git history & branches | Local `git` commands | ❌ Never |
438
+ | Dependencies & package.json | Read locally | ❌ Never |
439
+ | .env variable names | Read locally (values are never read) | ❌ Never |
440
+
441
+ ### What the activation server receives (PRO only)
442
+
443
+ | Data | When | Purpose |
444
+ |---|---|---|
445
+ | License key (`CE-XXXX-...`) | Activation + daily heartbeat | Validate subscription |
446
+ | Machine ID (SHA-256 hash) | Activation + daily heartbeat | Enforce machine limit |
447
+ | Platform/arch (e.g., `darwin/arm64`) | Activation only | Compatibility check |
448
+
449
+ **The server never receives:** project names, file contents, learnings, sessions, git history, dependencies, code, .env variables, or anything about your actual work.
450
+
451
+ ### Why this matters
452
+
453
+ Most AI coding tools (Copilot, Cursor, Codeium) send your code to external servers for processing. ContextEngine takes the opposite approach — **embeddings run locally on CPU**, search runs locally, and all persistent state stays in `~/.contextengine/` on your disk. The only network call is a lightweight license check for PRO users.
454
+
455
+ ## License
456
+
457
+ BSL-1.1 (Business Source License) — see [LICENSE](LICENSE).
458
+
459
+ You may use ContextEngine for any purpose, including production, **except** offering it as a hosted/managed service competing with ContextEngine PRO/Team/Enterprise.
460
+
461
+ Converts to AGPL-3.0 on February 22, 2030.
462
+
463
+ For commercial licensing: [yannick@compr.ch](mailto:yannick@compr.ch)
464
+
465
+ ---
466
+
467
+ ## Built by [PROD LLC](https://compr.fr)
468
+
469
+ ContextEngine is built by the team behind
470
+ [compr.app](https://compr.app) · [crowlr.io](https://crowlr.io) · [crowlr.com](https://crowlr.com) · [invoc.io](https://invoc.io) · [plank.io](https://plank.io) · [konive.com](https://konive.com) · [invoc.me](https://invoc.me)
@@ -0,0 +1,146 @@
1
+ [
2
+ {
3
+ "category": "security",
4
+ "rule": "Auth on write endpoints is non-negotiable",
5
+ "context": "Write endpoints launched without auth = IDOR vulnerability. Client-supplied user_id in request body can be spoofed. Always extract identity from JWT/session.",
6
+ "tags": [
7
+ "auth",
8
+ "IDOR",
9
+ "JWT",
10
+ "API"
11
+ ]
12
+ },
13
+ {
14
+ "category": "security",
15
+ "rule": "Rate-limit auth endpoints on day one",
16
+ "context": "Login/register without rate limiting = free brute-force. Apply rate limiting immediately: login 5-10/min, register 3-5/hr per IP.",
17
+ "tags": [
18
+ "rate-limiting",
19
+ "auth",
20
+ "brute-force"
21
+ ]
22
+ },
23
+ {
24
+ "category": "architecture",
25
+ "rule": "Single source of truth for constants",
26
+ "context": "Duplicated values (API URLs, color codes, config) always drift. Create one canonical file and import everywhere. Time saved on future changes: massive.",
27
+ "tags": [
28
+ "constants",
29
+ "DRY",
30
+ "refactoring"
31
+ ]
32
+ },
33
+ {
34
+ "category": "architecture",
35
+ "rule": "Shared database requires schema isolation",
36
+ "context": "When multiple apps share one PostgreSQL/MySQL instance, always use dedicated schemas or databases. Prevents accidental cross-contamination and simplifies migrations.",
37
+ "tags": [
38
+ "PostgreSQL",
39
+ "multi-app",
40
+ "schema",
41
+ "database"
42
+ ]
43
+ },
44
+ {
45
+ "category": "architecture",
46
+ "rule": "Extension modules prevent circular imports",
47
+ "context": "Shared instances (rate limiter, logger, DB) in a separate extensions/utils module break circular dependency between app entry point and route files. Applies to Flask, FastAPI, Express, etc.",
48
+ "tags": [
49
+ "circular-imports",
50
+ "extensions",
51
+ "modules"
52
+ ]
53
+ },
54
+ {
55
+ "category": "deployment",
56
+ "rule": "PM2 restart counter masks real crashes",
57
+ "context": "Hundreds of restarts can be a single missing module repeating. Use pm2 reset after fixing to clear noise. Check pm2 logs for the actual error before assuming instability.",
58
+ "tags": [
59
+ "PM2",
60
+ "debugging",
61
+ "restart-counter"
62
+ ]
63
+ },
64
+ {
65
+ "category": "deployment",
66
+ "rule": "Version strings drift across files",
67
+ "context": "Backend health endpoint, frontend UI, package.json all showing different versions. Use a single source constant and update all locations together.",
68
+ "tags": [
69
+ "versioning",
70
+ "consistency",
71
+ "drift"
72
+ ]
73
+ },
74
+ {
75
+ "category": "bug-patterns",
76
+ "rule": "Use == not >= for one-time reward thresholds",
77
+ "context": "if count >= 3: award() fires on 3, 4, 5, 6... Use == for exact threshold. This class of bug is invisible until data grows past the threshold.",
78
+ "tags": [
79
+ "threshold",
80
+ "comparison",
81
+ "logic-error"
82
+ ]
83
+ },
84
+ {
85
+ "category": "bug-patterns",
86
+ "rule": "GPS drift between independent getCurrentPosition calls",
87
+ "context": "Each call returns different coords within accuracy radius (~35m). Use watchPosition for consistent tracking in location-aware apps.",
88
+ "tags": [
89
+ "GPS",
90
+ "geolocation",
91
+ "drift",
92
+ "mobile"
93
+ ]
94
+ },
95
+ {
96
+ "category": "frontend",
97
+ "rule": "Run tsc --noEmit before every commit",
98
+ "context": "TypeScript errors silently accumulate when type-checking is not enforced. Zero-tolerance policy prevents drift. Add to CI or pre-commit hook.",
99
+ "tags": [
100
+ "TypeScript",
101
+ "CI",
102
+ "type-checking"
103
+ ]
104
+ },
105
+ {
106
+ "category": "testing",
107
+ "rule": "SQLite in-memory for backend tests",
108
+ "context": "Override DATABASE_URL with sqlite:// in test config. No schema migration needed, instant teardown. Disable rate-limiters in test mode.",
109
+ "tags": [
110
+ "SQLite",
111
+ "pytest",
112
+ "in-memory",
113
+ "testing"
114
+ ]
115
+ },
116
+ {
117
+ "category": "testing",
118
+ "rule": "Test the contract not the implementation",
119
+ "context": "Assert on status codes, response shapes, and output values. Don't mock internal functions \u2014 test through the API boundary. Tests survive refactoring this way.",
120
+ "tags": [
121
+ "contract-testing",
122
+ "assertions",
123
+ "API"
124
+ ]
125
+ },
126
+ {
127
+ "category": "tooling",
128
+ "rule": "Score your project early and often",
129
+ "context": "A structured rubric (tests, CI, docs, security, AI-readiness) reveals blind spots immediately. First audit often shows 30-50% \u2014 knowing the gaps drives prioritization.",
130
+ "tags": [
131
+ "scoring",
132
+ "audit",
133
+ "prioritization"
134
+ ]
135
+ },
136
+ {
137
+ "category": "git",
138
+ "rule": "Push every 5-10 commits, never accumulate 20+",
139
+ "context": "Large push backlogs risk merge conflicts, lost work, and difficult rollbacks. Push frequently, especially after critical fixes. Auto-push hooks help enforce this.",
140
+ "tags": [
141
+ "git",
142
+ "push-frequency",
143
+ "workflow"
144
+ ]
145
+ }
146
+ ]
@@ -0,0 +1,48 @@
1
+ export declare const PREMIUM_MODULES: readonly ["agents", "search-adv"];
2
+ export declare const PREMIUM_TOOLS: readonly ["score_project", "run_audit", "check_ports", "list_projects"];
3
+ export interface LicenseInfo {
4
+ key: string;
5
+ email: string;
6
+ plan: "community" | "pro" | "team" | "enterprise";
7
+ activatedAt: string;
8
+ expiresAt: string;
9
+ machineId: string;
10
+ lastHeartbeat: string;
11
+ deltaVersion: string;
12
+ signature: string;
13
+ }
14
+ export declare function loadLicense(): LicenseInfo | null;
15
+ export declare function activate(licenseKey: string, email: string): Promise<{
16
+ success: boolean;
17
+ message: string;
18
+ plan?: string;
19
+ }>;
20
+ /**
21
+ * Check if delta modules are installed and valid.
22
+ */
23
+ export declare function isDeltaInstalled(): boolean;
24
+ /**
25
+ * Dynamically import a delta module.
26
+ * Returns null if not activated or module not found.
27
+ */
28
+ export declare function loadDeltaModule(name: string): Promise<any | null>;
29
+ export declare function heartbeat(): Promise<boolean>;
30
+ export declare function deactivate(): void;
31
+ export declare function getActivationStatus(): {
32
+ activated: boolean;
33
+ plan: string;
34
+ expiresAt: string;
35
+ deltaVersion: string;
36
+ premiumTools: string[];
37
+ machineId: string;
38
+ };
39
+ /**
40
+ * Check if a specific tool requires activation.
41
+ */
42
+ export declare function requiresActivation(toolName: string): boolean;
43
+ /**
44
+ * Gate check — returns error message if tool requires activation but isn't activated.
45
+ * Returns null if tool is available.
46
+ */
47
+ export declare function gateCheck(toolName: string): string | null;
48
+ //# sourceMappingURL=activation.d.ts.map