cerber-core 1.1.5 → 1.1.6
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 +49 -35
- package/package.json +117 -109
package/README.md
CHANGED
|
@@ -25,13 +25,35 @@ It's a contract that everything else must obey.
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
npm install cerber-core --save-dev
|
|
28
|
-
npx cerber
|
|
28
|
+
npx cerber init
|
|
29
|
+
# Follow prompts to generate CERBER.md contract + guardian hooks
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
⭐ **Like what you see?** [Star the repo](https://github.com/Agaslez/cerber-core) and share with your team!
|
|
32
33
|
|
|
33
34
|
---
|
|
34
35
|
|
|
36
|
+
## 🤖 For AI Agents (Copilot, Cursor, Windsurf, Claude, etc.)
|
|
37
|
+
|
|
38
|
+
**Cerber's one rule:** `CERBER.md` is the single source of truth.
|
|
39
|
+
|
|
40
|
+
- If `CERBER.md` is missing → generate template and **STOP**. User must fill the contract.
|
|
41
|
+
- If `CERBER.md` exists → execute contract exactly as specified.
|
|
42
|
+
- **Never guess architecture.** Never invent rules. Never auto-design.
|
|
43
|
+
|
|
44
|
+
**Schema modes:**
|
|
45
|
+
- `schema.mode: template_only` → Generate minimal starter with "NOT SOURCE OF TRUTH" header
|
|
46
|
+
- `schema.mode: strict` → Require existing schema file, never generate
|
|
47
|
+
|
|
48
|
+
**Three enforcement points:**
|
|
49
|
+
1. **Pre-commit** (Guardian) - Blocks violating commits
|
|
50
|
+
2. **CI** (GitHub Actions) - Validates on push
|
|
51
|
+
3. **Post-deploy** - Health gate checks production
|
|
52
|
+
|
|
53
|
+
**Working with Cerber:** Read `CERBER.md` first. It tells you what's allowed and what's protected.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
35
57
|
## 📊 Real Production Metrics
|
|
36
58
|
|
|
37
59
|
> From Eliksir SaaS Backend (2026-01-02 session)
|
|
@@ -228,7 +250,7 @@ In `CERBER.md` contract, you control schema generation:
|
|
|
228
250
|
```yaml
|
|
229
251
|
schema:
|
|
230
252
|
enabled: true
|
|
231
|
-
file: BACKEND_SCHEMA.
|
|
253
|
+
file: BACKEND_SCHEMA.mjs
|
|
232
254
|
mode: strict # or template_only
|
|
233
255
|
```
|
|
234
256
|
|
|
@@ -236,7 +258,7 @@ schema:
|
|
|
236
258
|
- ✅ Cerber NEVER creates schema file
|
|
237
259
|
- ✅ You create schema based on YOUR architecture
|
|
238
260
|
- ✅ Full control, no helpers, no assumptions
|
|
239
|
-
- ✅ `npx cerber init` shows: "You must create BACKEND_SCHEMA.
|
|
261
|
+
- ✅ `npx cerber init` shows: "You must create BACKEND_SCHEMA.mjs"
|
|
240
262
|
|
|
241
263
|
**For beginners → `mode: template_only`**
|
|
242
264
|
- ✅ Cerber creates minimal template if file missing
|
|
@@ -307,11 +329,11 @@ mode: dev # solo | dev | team
|
|
|
307
329
|
|
|
308
330
|
guardian:
|
|
309
331
|
enabled: true
|
|
310
|
-
schemaFile: BACKEND_SCHEMA.
|
|
332
|
+
schemaFile: BACKEND_SCHEMA.mjs
|
|
311
333
|
|
|
312
334
|
schema:
|
|
313
335
|
enabled: true
|
|
314
|
-
file: BACKEND_SCHEMA.
|
|
336
|
+
file: BACKEND_SCHEMA.mjs
|
|
315
337
|
mode: template_only # strict (mature teams) | template_only (beginners)
|
|
316
338
|
# strict = You create schema, Cerber never generates
|
|
317
339
|
# template_only = Cerber creates minimal helper if missing
|
|
@@ -370,18 +392,13 @@ npm install cerber-core --save-dev
|
|
|
370
392
|
#### 🎨 **Frontend Developer (React/Vue/Angular)**
|
|
371
393
|
|
|
372
394
|
```bash
|
|
373
|
-
# 1.
|
|
374
|
-
|
|
395
|
+
# 1. Initialize Cerber (generates CERBER.md + templates)
|
|
396
|
+
npx cerber init --mode=solo
|
|
375
397
|
|
|
376
|
-
# 2.
|
|
377
|
-
|
|
378
|
-
cp node_modules/cerber-core/guardian/templates/validate-schema.mjs scripts/
|
|
398
|
+
# 2. Customize your schema for frontend
|
|
399
|
+
# Edit BACKEND_SCHEMA.mjs (rename to FRONTEND_SCHEMA.mjs if you prefer)
|
|
379
400
|
|
|
380
|
-
# 3.
|
|
381
|
-
npx husky-init
|
|
382
|
-
npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
|
|
383
|
-
|
|
384
|
-
# 4. Test it!
|
|
401
|
+
# 3. Test it!
|
|
385
402
|
git commit -m "test"
|
|
386
403
|
# Guardian will validate automatically (<1s)
|
|
387
404
|
```
|
|
@@ -392,26 +409,21 @@ git commit -m "test"
|
|
|
392
409
|
- ✅ Required imports (`react`, `react-dom`)
|
|
393
410
|
- ✅ Required files (`tsconfig.json`, `vite.config.ts`)
|
|
394
411
|
|
|
395
|
-
**Then customize:** Edit FRONTEND_SCHEMA.
|
|
412
|
+
**Then customize:** Edit BACKEND_SCHEMA.mjs (rename to FRONTEND_SCHEMA.mjs if you prefer) to match YOUR folder structure, YOUR rules, YOUR tech stack.
|
|
396
413
|
|
|
397
414
|
#### ⚙️ **Backend Developer (Node.js/Express/NestJS)**
|
|
398
415
|
|
|
399
416
|
```bash
|
|
400
|
-
# 1.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
# 2. Copy validation script
|
|
404
|
-
mkdir -p scripts
|
|
405
|
-
cp node_modules/cerber-core/guardian/templates/validate-schema.mjs scripts/
|
|
417
|
+
# 1. Initialize Cerber (generates CERBER.md + guardian + health templates)
|
|
418
|
+
npx cerber init --mode=dev
|
|
406
419
|
|
|
407
|
-
#
|
|
408
|
-
|
|
409
|
-
npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
|
|
420
|
+
# 2. Customize BACKEND_SCHEMA.mjs
|
|
421
|
+
# Edit to match YOUR routes, YOUR layers, YOUR security rules
|
|
410
422
|
|
|
411
|
-
#
|
|
423
|
+
# 3. Add health endpoint (see example below)
|
|
412
424
|
```
|
|
413
425
|
|
|
414
|
-
**Then customize:** Edit BACKEND_SCHEMA.
|
|
426
|
+
**Then customize:** Edit BACKEND_SCHEMA.mjs to match YOUR routes, YOUR layers, YOUR security rules.
|
|
415
427
|
|
|
416
428
|
```javascript
|
|
417
429
|
// server.js (ESM)
|
|
@@ -529,7 +541,7 @@ cerber-focus
|
|
|
529
541
|
|
|
530
542
|
Before diving into examples below, understand this:
|
|
531
543
|
|
|
532
|
-
**📋 Schema files (BACKEND_SCHEMA.
|
|
544
|
+
**📋 Schema files (BACKEND_SCHEMA.mjs, FRONTEND_SCHEMA.mjs):**
|
|
533
545
|
- Are **examples** and **optional templates**
|
|
534
546
|
- Mirror YOUR architecture decisions from CERBER.md
|
|
535
547
|
- Are user-owned and user-created (in strict mode)
|
|
@@ -548,8 +560,8 @@ Before diving into examples below, understand this:
|
|
|
548
560
|
|
|
549
561
|
**1. Create architecture schema:**
|
|
550
562
|
|
|
551
|
-
```
|
|
552
|
-
// BACKEND_SCHEMA.
|
|
563
|
+
```javascript
|
|
564
|
+
// BACKEND_SCHEMA.mjs
|
|
553
565
|
export const BACKEND_SCHEMA = {
|
|
554
566
|
version: '1.0.0',
|
|
555
567
|
rules: [
|
|
@@ -573,7 +585,9 @@ export const BACKEND_SCHEMA = {
|
|
|
573
585
|
**2. Add pre-commit hook:**
|
|
574
586
|
|
|
575
587
|
```bash
|
|
576
|
-
|
|
588
|
+
# Pre-commit hook is automatically installed by npx cerber init
|
|
589
|
+
# Or manually:
|
|
590
|
+
npx husky add .husky/pre-commit "npm run cerber:guardian"
|
|
577
591
|
```
|
|
578
592
|
|
|
579
593
|
**3. Done!** Guardian now blocks commits that violate architecture rules.
|
|
@@ -707,8 +721,8 @@ curl https://your-api.com/api/health
|
|
|
707
721
|
|
|
708
722
|
### Example 1: Enforce Express Router in routes
|
|
709
723
|
|
|
710
|
-
```
|
|
711
|
-
// BACKEND_SCHEMA.
|
|
724
|
+
```javascript
|
|
725
|
+
// BACKEND_SCHEMA.mjs
|
|
712
726
|
{
|
|
713
727
|
name: 'Route files must import Router',
|
|
714
728
|
pattern: /routes\/.*\.ts$/,
|
|
@@ -840,8 +854,8 @@ export const cloudinaryCheck = async () => {
|
|
|
840
854
|
|
|
841
855
|
### Guardian Configuration
|
|
842
856
|
|
|
843
|
-
```
|
|
844
|
-
// BACKEND_SCHEMA.
|
|
857
|
+
```javascript
|
|
858
|
+
// BACKEND_SCHEMA.mjs
|
|
845
859
|
export const BACKEND_SCHEMA = {
|
|
846
860
|
version: '1.0.0',
|
|
847
861
|
|
package/package.json
CHANGED
|
@@ -1,109 +1,117 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cerber-core",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "AI doesn't break your project. Lack of a contract does. Cerber is a contract-driven project guardian for AI-assisted development. It enforces a single source of truth (CERBER.md) across pre-commit, CI, and post-deploy health gates.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"bin": {
|
|
9
|
-
"cerber": "./bin/cerber",
|
|
10
|
-
"cerber-guardian": "./bin/cerber-guardian",
|
|
11
|
-
"cerber-health": "./bin/cerber-health",
|
|
12
|
-
"cerber-focus": "./bin/cerber-focus",
|
|
13
|
-
"cerber-morning": "./bin/cerber-morning",
|
|
14
|
-
"cerber-repair": "./bin/cerber-repair"
|
|
15
|
-
},
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/index.js",
|
|
18
|
-
"./guardian": "./dist/guardian/index.js",
|
|
19
|
-
"./cerber": "./dist/cerber/index.js",
|
|
20
|
-
"./types": "./dist/types.js"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"test": "jest",
|
|
25
|
-
"lint": "eslint src/**/*.ts",
|
|
26
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
27
|
-
"prepublishOnly": "npm run build",
|
|
28
|
-
"validate": "node bin/cerber-guardian",
|
|
29
|
-
"health-check": "node bin/cerber-health",
|
|
30
|
-
"morning": "node solo/scripts/cerber-daily-check.js",
|
|
31
|
-
"repair": "node solo/scripts/cerber-auto-repair.js",
|
|
32
|
-
"repair:dry": "node solo/scripts/cerber-auto-repair.js --dry-run",
|
|
33
|
-
"dashboard": "node solo/scripts/cerber-dashboard.js"
|
|
34
|
-
},
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/Agaslez/cerber-core.git"
|
|
38
|
-
},
|
|
39
|
-
"keywords": [
|
|
40
|
-
"ai",
|
|
41
|
-
"ai-agents",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
},
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "cerber-core",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "AI doesn't break your project. Lack of a contract does. Cerber is a contract-driven project guardian for AI-assisted development. It enforces a single source of truth (CERBER.md) across pre-commit, CI, and post-deploy health gates.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"cerber": "./bin/cerber",
|
|
10
|
+
"cerber-guardian": "./bin/cerber-guardian",
|
|
11
|
+
"cerber-health": "./bin/cerber-health",
|
|
12
|
+
"cerber-focus": "./bin/cerber-focus",
|
|
13
|
+
"cerber-morning": "./bin/cerber-morning",
|
|
14
|
+
"cerber-repair": "./bin/cerber-repair"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./guardian": "./dist/guardian/index.js",
|
|
19
|
+
"./cerber": "./dist/cerber/index.js",
|
|
20
|
+
"./types": "./dist/types.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"lint": "eslint src/**/*.ts",
|
|
26
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
27
|
+
"prepublishOnly": "npm run build",
|
|
28
|
+
"validate": "node bin/cerber-guardian",
|
|
29
|
+
"health-check": "node bin/cerber-health",
|
|
30
|
+
"morning": "node solo/scripts/cerber-daily-check.js",
|
|
31
|
+
"repair": "node solo/scripts/cerber-auto-repair.js",
|
|
32
|
+
"repair:dry": "node solo/scripts/cerber-auto-repair.js --dry-run",
|
|
33
|
+
"dashboard": "node solo/scripts/cerber-dashboard.js"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/Agaslez/cerber-core.git"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"ai",
|
|
41
|
+
"ai-agents",
|
|
42
|
+
"ai-coding",
|
|
43
|
+
"copilot",
|
|
44
|
+
"cursor",
|
|
45
|
+
"windsurf",
|
|
46
|
+
"llm",
|
|
47
|
+
"contract",
|
|
48
|
+
"contract-first",
|
|
49
|
+
"project-guard",
|
|
50
|
+
"single-source-of-truth",
|
|
51
|
+
"pre-commit",
|
|
52
|
+
"husky",
|
|
53
|
+
"guardrails",
|
|
54
|
+
"workflow-generator",
|
|
55
|
+
"ci-cd",
|
|
56
|
+
"github-actions",
|
|
57
|
+
"schema-enforcement",
|
|
58
|
+
"health-check",
|
|
59
|
+
"deployment-gate",
|
|
60
|
+
"dev-workflow",
|
|
61
|
+
"automation",
|
|
62
|
+
"architecture",
|
|
63
|
+
"validation",
|
|
64
|
+
"cerber",
|
|
65
|
+
"guardian"
|
|
66
|
+
],
|
|
67
|
+
"author": {
|
|
68
|
+
"name": "Agata Sleziak",
|
|
69
|
+
"email": "agata@example.com",
|
|
70
|
+
"url": "https://github.com/Agaslez"
|
|
71
|
+
},
|
|
72
|
+
"contributors": [
|
|
73
|
+
{
|
|
74
|
+
"name": "Stefan Pitek",
|
|
75
|
+
"role": "Collaborator"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"license": "MIT",
|
|
79
|
+
"bugs": {
|
|
80
|
+
"url": "https://github.com/Agaslez/cerber-core/issues"
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://github.com/Agaslez/cerber-core#readme",
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"typescript": ">=5.0.0"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"chalk": "^5.3.0",
|
|
88
|
+
"commander": "^12.0.0"
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@types/jest": "^29.5.0",
|
|
92
|
+
"@types/node": "^20.0.0",
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
94
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
95
|
+
"eslint": "^8.50.0",
|
|
96
|
+
"jest": "^29.7.0",
|
|
97
|
+
"prettier": "^3.0.0",
|
|
98
|
+
"ts-jest": "^29.1.0",
|
|
99
|
+
"typescript": "^5.3.0"
|
|
100
|
+
},
|
|
101
|
+
"engines": {
|
|
102
|
+
"node": ">=16.0.0"
|
|
103
|
+
},
|
|
104
|
+
"files": [
|
|
105
|
+
"dist",
|
|
106
|
+
"bin",
|
|
107
|
+
"examples",
|
|
108
|
+
".cerber-example",
|
|
109
|
+
"solo",
|
|
110
|
+
"dev",
|
|
111
|
+
"team",
|
|
112
|
+
"LICENSE",
|
|
113
|
+
"README.md",
|
|
114
|
+
"CHANGELOG.md",
|
|
115
|
+
"USAGE_GUIDE.md"
|
|
116
|
+
]
|
|
117
|
+
}
|