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.
Files changed (2) hide show
  1. package/README.md +49 -35
  2. 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-guardian --help
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.ts
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.ts"
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.ts
332
+ schemaFile: BACKEND_SCHEMA.mjs
311
333
 
312
334
  schema:
313
335
  enabled: true
314
- file: BACKEND_SCHEMA.ts
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. Copy frontend schema example (then customize!)
374
- cp node_modules/cerber-core/examples/frontend-schema.ts ./FRONTEND_SCHEMA.ts
395
+ # 1. Initialize Cerber (generates CERBER.md + templates)
396
+ npx cerber init --mode=solo
375
397
 
376
- # 2. Copy validation script
377
- mkdir -p scripts
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. Install pre-commit hook
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.ts to match YOUR folder structure, YOUR rules, YOUR tech stack.
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. Copy backend schema example (then customize!)
401
- cp node_modules/cerber-core/examples/backend-schema.ts ./BACKEND_SCHEMA.ts
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
- # 3. Install pre-commit hook
408
- npx husky-init
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
- # 4. Add health endpoint
423
+ # 3. Add health endpoint (see example below)
412
424
  ```
413
425
 
414
- **Then customize:** Edit BACKEND_SCHEMA.ts to match YOUR routes, YOUR layers, YOUR security rules.
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.ts, FRONTEND_SCHEMA.ts):**
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
- ```typescript
552
- // BACKEND_SCHEMA.ts
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
- npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
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
- ```typescript
711
- // BACKEND_SCHEMA.ts
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
- ```typescript
844
- // BACKEND_SCHEMA.ts
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.5",
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
- "contract",
43
- "contract-first",
44
- "project-guard",
45
- "single-source-of-truth",
46
- "pre-commit",
47
- "ci-cd",
48
- "github-actions",
49
- "schema-enforcement",
50
- "health-check",
51
- "deployment-gate",
52
- "dev-workflow",
53
- "automation",
54
- "architecture",
55
- "validation",
56
- "cerber",
57
- "guardian"
58
- ],
59
- "author": {
60
- "name": "Agata Sleziak",
61
- "email": "agata@example.com",
62
- "url": "https://github.com/Agaslez"
63
- },
64
- "contributors": [
65
- {
66
- "name": "Stefan Pitek",
67
- "role": "Collaborator"
68
- }
69
- ],
70
- "license": "MIT",
71
- "bugs": {
72
- "url": "https://github.com/Agaslez/cerber-core/issues"
73
- },
74
- "homepage": "https://github.com/Agaslez/cerber-core#readme",
75
- "peerDependencies": {
76
- "typescript": ">=5.0.0"
77
- },
78
- "dependencies": {
79
- "chalk": "^5.3.0",
80
- "commander": "^12.0.0"
81
- },
82
- "devDependencies": {
83
- "@types/jest": "^29.5.0",
84
- "@types/node": "^20.0.0",
85
- "@typescript-eslint/eslint-plugin": "^6.0.0",
86
- "@typescript-eslint/parser": "^6.0.0",
87
- "eslint": "^8.50.0",
88
- "jest": "^29.7.0",
89
- "prettier": "^3.0.0",
90
- "ts-jest": "^29.1.0",
91
- "typescript": "^5.3.0"
92
- },
93
- "engines": {
94
- "node": ">=16.0.0"
95
- },
96
- "files": [
97
- "dist",
98
- "bin",
99
- "examples",
100
- ".cerber-example",
101
- "solo",
102
- "dev",
103
- "team",
104
- "LICENSE",
105
- "README.md",
106
- "CHANGELOG.md",
107
- "USAGE_GUIDE.md"
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
+ }