cerber-core 1.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 (67) hide show
  1. package/.cerber-example/BIBLE.md +132 -0
  2. package/.cerber-example/CERBER_LAW.md +200 -0
  3. package/.cerber-example/connections/contracts/booking-to-pricing.json +44 -0
  4. package/.cerber-example/connections/contracts/pricing-to-booking.json +37 -0
  5. package/.cerber-example/modules/booking-calendar/MODULE.md +225 -0
  6. package/.cerber-example/modules/booking-calendar/contract.json +106 -0
  7. package/.cerber-example/modules/booking-calendar/dependencies.json +8 -0
  8. package/.cerber-example/modules/pricing-engine/MODULE.md +160 -0
  9. package/.cerber-example/modules/pricing-engine/contract.json +64 -0
  10. package/.cerber-example/modules/pricing-engine/dependencies.json +8 -0
  11. package/CHANGELOG.md +68 -0
  12. package/LICENSE +21 -0
  13. package/README.md +1379 -0
  14. package/bin/cerber +105 -0
  15. package/bin/cerber-focus +31 -0
  16. package/bin/cerber-guardian +90 -0
  17. package/bin/cerber-health +113 -0
  18. package/bin/cerber-morning +19 -0
  19. package/bin/cerber-repair +21 -0
  20. package/dist/cerber/index.d.ts +47 -0
  21. package/dist/cerber/index.d.ts.map +1 -0
  22. package/dist/cerber/index.js +154 -0
  23. package/dist/cerber/index.js.map +1 -0
  24. package/dist/guardian/index.d.ts +70 -0
  25. package/dist/guardian/index.d.ts.map +1 -0
  26. package/dist/guardian/index.js +271 -0
  27. package/dist/guardian/index.js.map +1 -0
  28. package/dist/index.d.ts +9 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +9 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/types.d.ts +76 -0
  33. package/dist/types.d.ts.map +1 -0
  34. package/dist/types.js +5 -0
  35. package/dist/types.js.map +1 -0
  36. package/examples/backend-schema.ts +72 -0
  37. package/examples/frontend-schema.ts +67 -0
  38. package/examples/health-checks.ts +196 -0
  39. package/examples/solo-integration/README.md +457 -0
  40. package/examples/solo-integration/package.json +47 -0
  41. package/examples/team-integration/README.md +347 -0
  42. package/examples/team-integration/package.json +23 -0
  43. package/package.json +104 -0
  44. package/solo/README.md +258 -0
  45. package/solo/config/performance-budget.json +53 -0
  46. package/solo/config/solo-contract.json +71 -0
  47. package/solo/lib/feature-flags.ts +177 -0
  48. package/solo/scripts/cerber-auto-repair.js +260 -0
  49. package/solo/scripts/cerber-daily-check.js +282 -0
  50. package/solo/scripts/cerber-dashboard.js +191 -0
  51. package/solo/scripts/cerber-deps-health.js +247 -0
  52. package/solo/scripts/cerber-docs-sync.js +304 -0
  53. package/solo/scripts/cerber-flags-check.js +229 -0
  54. package/solo/scripts/cerber-performance-budget.js +271 -0
  55. package/solo/scripts/cerber-rollback.js +229 -0
  56. package/solo/scripts/cerber-snapshot.js +319 -0
  57. package/team/README.md +327 -0
  58. package/team/config/team-contract.json +27 -0
  59. package/team/lib/module-system.ts +157 -0
  60. package/team/scripts/cerber-add-module.sh +195 -0
  61. package/team/scripts/cerber-connections-check.sh +186 -0
  62. package/team/scripts/cerber-focus.sh +170 -0
  63. package/team/scripts/cerber-module-check.sh +165 -0
  64. package/team/scripts/cerber-team-morning.sh +210 -0
  65. package/team/templates/BIBLE_TEMPLATE.md +52 -0
  66. package/team/templates/CONNECTION_TEMPLATE.json +20 -0
  67. package/team/templates/MODULE_TEMPLATE.md +60 -0
package/bin/cerber ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Core - Unified CLI
5
+ *
6
+ * Main entry point for all Cerber commands
7
+ *
8
+ * @author Stefan Pitek
9
+ * @license MIT
10
+ */
11
+
12
+ import chalk from 'chalk';
13
+ import { program } from 'commander';
14
+
15
+ program
16
+ .name('cerber')
17
+ .description('Cerber Core - Code quality & health monitoring')
18
+ .version('1.0.0');
19
+
20
+ program
21
+ .command('guardian')
22
+ .description('Run Guardian pre-commit validation')
23
+ .option('-s, --schema <file>', 'Schema file path')
24
+ .option('-v, --verbose', 'Verbose output')
25
+ .option('--fail-on-warning', 'Exit with error on warnings')
26
+ .action(async (options) => {
27
+ const { Guardian } = await import('../dist/guardian/index.js');
28
+ const schema = options.schema ? await import(options.schema) : null;
29
+
30
+ const guardian = new Guardian(schema?.default || {});
31
+ const result = await guardian.validate();
32
+
33
+ if (!result.success) {
34
+ console.error(chalk.red('❌ Guardian validation failed'));
35
+ process.exit(1);
36
+ }
37
+
38
+ console.log(chalk.green('✅ Guardian validation passed'));
39
+ });
40
+
41
+ program
42
+ .command('health')
43
+ .description('Run Cerber health checks')
44
+ .option('-c, --checks <file>', 'Health checks file path')
45
+ .option('-u, --url <url>', 'Fetch health from URL')
46
+ .option('-p, --parallel', 'Run checks in parallel')
47
+ .action(async (options) => {
48
+ const { Cerber } = await import('../dist/cerber/index.js');
49
+
50
+ if (options.url) {
51
+ const response = await fetch(options.url);
52
+ const result = await response.json();
53
+ console.log(JSON.stringify(result, null, 2));
54
+ process.exit(result.status === 'healthy' ? 0 : 1);
55
+ }
56
+
57
+ const checksModule = options.checks ? await import(options.checks) : null;
58
+ const checks = checksModule ? Object.values(checksModule).filter(v => typeof v === 'function') : [];
59
+
60
+ const cerber = new Cerber(checks);
61
+ const result = await cerber.runChecks({ parallel: options.parallel });
62
+
63
+ process.exit(result.status === 'healthy' ? 0 : 1);
64
+ });
65
+
66
+ program
67
+ .command('morning')
68
+ .description('Run morning dashboard (SOLO)')
69
+ .action(async () => {
70
+ const { execSync } = await import('child_process');
71
+ execSync('node solo/scripts/cerber-daily-check.js', { stdio: 'inherit' });
72
+ });
73
+
74
+ program
75
+ .command('repair')
76
+ .description('Auto-repair common issues (SOLO)')
77
+ .option('--dry-run', 'Show what would be fixed without making changes')
78
+ .option('--approve', 'Require approval for each fix')
79
+ .action(async (options) => {
80
+ const { execSync } = await import('child_process');
81
+ const args = [
82
+ options.dryRun && '--dry-run',
83
+ options.approve && '--approve'
84
+ ].filter(Boolean).join(' ');
85
+
86
+ execSync(`node solo/scripts/cerber-auto-repair.js ${args}`, { stdio: 'inherit' });
87
+ });
88
+
89
+ program
90
+ .command('focus <module>')
91
+ .description('Generate focus context for module (TEAM)')
92
+ .action(async (module) => {
93
+ const { execSync } = await import('child_process');
94
+ execSync(`bash team/scripts/cerber-focus.sh ${module}`, { stdio: 'inherit' });
95
+ });
96
+
97
+ program
98
+ .command('dashboard')
99
+ .description('Show system dashboard (SOLO)')
100
+ .action(async () => {
101
+ const { execSync } = await import('child_process');
102
+ execSync('node solo/scripts/cerber-dashboard.js', { stdio: 'inherit' });
103
+ });
104
+
105
+ program.parse();
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Focus - Team collaboration focus mode
5
+ *
6
+ * @author Stefan Pitek
7
+ * @license MIT
8
+ */
9
+
10
+ import chalk from 'chalk';
11
+ import { execSync } from 'child_process';
12
+
13
+ const module = process.argv[2];
14
+
15
+ if (!module) {
16
+ console.error(chalk.red('❌ Error: Module name required'));
17
+ console.log('\nUsage: cerber-focus <module-name>');
18
+ console.log('\nExample:');
19
+ console.log(' cerber-focus pricing-engine');
20
+ process.exit(1);
21
+ }
22
+
23
+ try {
24
+ execSync(`bash team/scripts/cerber-focus.sh ${module}`, {
25
+ stdio: 'inherit',
26
+ cwd: process.cwd()
27
+ });
28
+ } catch (err) {
29
+ console.error(chalk.red('\n❌ Focus mode failed'));
30
+ process.exit(1);
31
+ }
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Guardian - Pre-commit validator CLI
5
+ *
6
+ * @author Stefan Pitek
7
+ * @license MIT
8
+ */
9
+
10
+ import chalk from 'chalk';
11
+ import { program } from 'commander';
12
+ import * as path from 'path';
13
+
14
+ program
15
+ .name('cerber-guardian')
16
+ .description('Guardian - Pre-commit architecture validator')
17
+ .version('1.0.0')
18
+ .option('-s, --schema <file>', 'Schema file path', './SCHEMA.ts')
19
+ .option('-v, --verbose', 'Verbose output', false)
20
+ .option('--fail-on-warning', 'Exit with error on warnings', false)
21
+ .parse();
22
+
23
+ const options = program.opts();
24
+
25
+ async function main() {
26
+ try {
27
+ const { Guardian } = await import('../dist/guardian/index.js');
28
+
29
+ // Load schema
30
+ const schemaPath = path.resolve(process.cwd(), options.schema);
31
+ let schema = {};
32
+
33
+ try {
34
+ const schemaModule = await import(schemaPath);
35
+ schema = schemaModule.default || schemaModule.SCHEMA || schemaModule;
36
+ } catch (err) {
37
+ console.warn(chalk.yellow(`⚠️ Could not load schema from ${schemaPath}`));
38
+ console.warn(chalk.dim('Using empty schema'));
39
+ }
40
+
41
+ // Run validation
42
+ const guardian = new Guardian(schema);
43
+ const result = await guardian.validate();
44
+
45
+ if (options.verbose) {
46
+ console.log('\n📋 Guardian Validation Results:');
47
+ console.log(chalk.dim('─'.repeat(50)));
48
+
49
+ if (result.approvals.length > 0) {
50
+ console.log(chalk.cyan(`\n✅ Architect Approvals: ${result.approvals.length}`));
51
+ result.approvals.forEach(a => {
52
+ console.log(chalk.dim(` ${a.file}:${a.line} - ${a.reason}`));
53
+ });
54
+ }
55
+
56
+ if (result.warnings.length > 0) {
57
+ console.log(chalk.yellow(`\n⚠️ Warnings: ${result.warnings.length}`));
58
+ result.warnings.forEach(w => console.log(chalk.yellow(` ${w}`)));
59
+ }
60
+
61
+ if (result.errors.length > 0) {
62
+ console.log(chalk.red(`\n❌ Errors: ${result.errors.length}`));
63
+ result.errors.forEach(e => console.log(chalk.red(` ${e}`)));
64
+ }
65
+ }
66
+
67
+ // Exit handling
68
+ if (!result.success) {
69
+ console.error(chalk.red('\n❌ Guardian validation failed\n'));
70
+ process.exit(1);
71
+ }
72
+
73
+ if (options.failOnWarning && result.warnings.length > 0) {
74
+ console.error(chalk.yellow('\n⚠️ Guardian validation failed (warnings treated as errors)\n'));
75
+ process.exit(1);
76
+ }
77
+
78
+ console.log(chalk.green('✅ Guardian validation passed\n'));
79
+ process.exit(0);
80
+
81
+ } catch (err) {
82
+ console.error(chalk.red('❌ Guardian error:'), err.message);
83
+ if (options.verbose) {
84
+ console.error(err.stack);
85
+ }
86
+ process.exit(1);
87
+ }
88
+ }
89
+
90
+ main();
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Health - Runtime health monitoring CLI
5
+ *
6
+ * @author Stefan Pitek
7
+ * @license MIT
8
+ */
9
+
10
+ import chalk from 'chalk';
11
+ import { program } from 'commander';
12
+ import * as path from 'path';
13
+
14
+ program
15
+ .name('cerber-health')
16
+ .description('Cerber - Runtime health diagnostics')
17
+ .version('2.1.0')
18
+ .option('-c, --checks <file>', 'Health checks file path', './health-checks.ts')
19
+ .option('-u, --url <url>', 'Fetch health status from URL')
20
+ .option('-p, --parallel', 'Run checks in parallel', false)
21
+ .option('--json', 'Output as JSON', false)
22
+ .parse();
23
+
24
+ const options = program.opts();
25
+
26
+ async function main() {
27
+ try {
28
+ const { Cerber } = await import('../dist/cerber/index.js');
29
+
30
+ // Fetch from URL if provided
31
+ if (options.url) {
32
+ const response = await fetch(options.url);
33
+ const result = await response.json();
34
+
35
+ if (options.json) {
36
+ console.log(JSON.stringify(result, null, 2));
37
+ } else {
38
+ printResult(result);
39
+ }
40
+
41
+ process.exit(result.status === 'healthy' ? 0 : 1);
42
+ }
43
+
44
+ // Load health checks from file
45
+ const checksPath = path.resolve(process.cwd(), options.checks);
46
+ let checks = [];
47
+
48
+ try {
49
+ const checksModule = await import(checksPath);
50
+ checks = Object.values(checksModule).filter(v => typeof v === 'function');
51
+
52
+ if (checks.length === 0) {
53
+ console.warn(chalk.yellow(`⚠️ No health checks found in ${checksPath}`));
54
+ }
55
+ } catch (err) {
56
+ console.warn(chalk.yellow(`⚠️ Could not load health checks from ${checksPath}`));
57
+ console.warn(chalk.dim('Using empty checks array'));
58
+ }
59
+
60
+ // Run checks
61
+ const cerber = new Cerber(checks);
62
+ const result = await cerber.runChecks({ parallel: options.parallel });
63
+
64
+ if (options.json) {
65
+ console.log(JSON.stringify(result, null, 2));
66
+ }
67
+
68
+ // Exit based on status
69
+ const exitCode = result.status === 'healthy' ? 0 :
70
+ result.status === 'degraded' ? 1 : 2;
71
+
72
+ process.exit(exitCode);
73
+
74
+ } catch (err) {
75
+ console.error(chalk.red('❌ Cerber error:'), err.message);
76
+ process.exit(2);
77
+ }
78
+ }
79
+
80
+ function printResult(result) {
81
+ console.log('\n' + chalk.cyan('═'.repeat(60)));
82
+ console.log(chalk.bold('🔍 Cerber Health Check Results'));
83
+ console.log(chalk.cyan('═'.repeat(60)));
84
+
85
+ const statusColor = result.status === 'healthy' ? 'green' :
86
+ result.status === 'degraded' ? 'yellow' : 'red';
87
+
88
+ console.log(`\nStatus: ${chalk[statusColor](result.status.toUpperCase())}`);
89
+ console.log(`Duration: ${result.durationMs}ms`);
90
+
91
+ console.log('\nSummary:');
92
+ console.log(` Total Checks: ${result.summary.totalChecks}`);
93
+ console.log(` Failed: ${result.summary.failedChecks}`);
94
+ console.log(` Critical: ${chalk.red(result.summary.criticalIssues)}`);
95
+ console.log(` Errors: ${chalk.yellow(result.summary.errorIssues)}`);
96
+ console.log(` Warnings: ${chalk.dim(result.summary.warningIssues)}`);
97
+
98
+ if (result.components && result.components.length > 0) {
99
+ console.log('\nComponents:');
100
+ result.components.forEach(c => {
101
+ const icon = c.severity === 'critical' ? '🔴' :
102
+ c.severity === 'error' ? '❌' : '⚠️';
103
+ console.log(` ${icon} ${c.name}: ${c.message}`);
104
+ if (c.fix) {
105
+ console.log(chalk.dim(` 💡 ${c.fix}`));
106
+ }
107
+ });
108
+ }
109
+
110
+ console.log('\n' + chalk.cyan('═'.repeat(60)) + '\n');
111
+ }
112
+
113
+ main();
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Morning - SOLO daily dashboard
5
+ *
6
+ * @author Stefan Pitek
7
+ * @license MIT
8
+ */
9
+
10
+ import { execSync } from 'child_process';
11
+
12
+ try {
13
+ execSync('node solo/scripts/cerber-daily-check.js', {
14
+ stdio: 'inherit',
15
+ cwd: process.cwd()
16
+ });
17
+ } catch (err) {
18
+ process.exit(1);
19
+ }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cerber Repair - SOLO auto-repair system
5
+ *
6
+ * @author Stefan Pitek
7
+ * @license MIT
8
+ */
9
+
10
+ import { execSync } from 'child_process';
11
+
12
+ const args = process.argv.slice(2).join(' ');
13
+
14
+ try {
15
+ execSync(`node solo/scripts/cerber-auto-repair.js ${args}`, {
16
+ stdio: 'inherit',
17
+ cwd: process.cwd()
18
+ });
19
+ } catch (err) {
20
+ process.exit(1);
21
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Cerber - Runtime Health Monitoring
3
+ * Validates system health and blocks deployments on critical issues
4
+ */
5
+ import type { CerberCheck, CerberCheckContext, CerberIssue, CerberResult } from '../types';
6
+ export declare class Cerber {
7
+ private checks;
8
+ private context;
9
+ constructor(checks: CerberCheck[], context?: Partial<CerberCheckContext>);
10
+ /**
11
+ * Run all health checks
12
+ */
13
+ runChecks(options?: {
14
+ parallel?: boolean;
15
+ }): Promise<CerberResult>;
16
+ /**
17
+ * Calculate summary statistics
18
+ */
19
+ private calculateSummary;
20
+ /**
21
+ * Print result to console
22
+ */
23
+ private printResult;
24
+ }
25
+ /**
26
+ * Helper to create issue object
27
+ */
28
+ export declare function makeIssue(params: {
29
+ code: string;
30
+ component?: string;
31
+ severity: 'critical' | 'error' | 'warning';
32
+ message: string;
33
+ rootCause?: string;
34
+ fix?: string;
35
+ durationMs?: number;
36
+ details?: Record<string, any>;
37
+ }): CerberIssue;
38
+ /**
39
+ * Main function for CLI
40
+ */
41
+ export declare function runHealthChecks(options: {
42
+ checks: string;
43
+ parallel?: boolean;
44
+ url?: string;
45
+ }): Promise<CerberResult>;
46
+ export { CerberCheck, CerberCheckContext, CerberIssue, CerberResult };
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceR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- Runtime Health Monitoring
3
+ * Validates system health and blocks deployments on critical issues
4
+ */
5
+ export class Cerber {
6
+ checks;
7
+ context;
8
+ constructor(checks, context) {
9
+ this.checks = checks;
10
+ this.context = {
11
+ rootDir: context?.rootDir || process.cwd(),
12
+ ...context,
13
+ };
14
+ }
15
+ /**
16
+ * Run all health checks
17
+ */
18
+ async runChecks(options) {
19
+ const startTime = Date.now();
20
+ console.log('🐕 Running Cerber health checks...\n');
21
+ let allIssues = [];
22
+ if (options?.parallel) {
23
+ // Parallel execution
24
+ const results = await Promise.allSettled(this.checks.map(check => check(this.context)));
25
+ allIssues = results
26
+ .filter((r) => r.status === 'fulfilled')
27
+ .flatMap(r => r.value);
28
+ }
29
+ else {
30
+ // Sequential execution
31
+ for (const check of this.checks) {
32
+ try {
33
+ const issues = await check(this.context);
34
+ allIssues.push(...issues);
35
+ }
36
+ catch (err) {
37
+ const error = err;
38
+ console.error(`Check failed: ${error.message}`);
39
+ }
40
+ }
41
+ }
42
+ // Calculate summary
43
+ const summary = this.calculateSummary(allIssues);
44
+ const duration = Date.now() - startTime;
45
+ // Determine status
46
+ let status;
47
+ if (summary.criticalIssues > 0 || summary.errorIssues > 0) {
48
+ status = 'unhealthy';
49
+ }
50
+ else if (summary.warningIssues > 0) {
51
+ status = 'degraded';
52
+ }
53
+ else {
54
+ status = 'healthy';
55
+ }
56
+ const result = {
57
+ timestamp: new Date().toISOString(),
58
+ status,
59
+ app: {
60
+ version: process.env.APP_VERSION || '1.0.0',
61
+ env: process.env.NODE_ENV || 'development',
62
+ uptime: process.uptime(),
63
+ nodeVersion: process.version,
64
+ },
65
+ components: allIssues.map(issue => ({
66
+ id: issue.code,
67
+ name: issue.component || 'unknown',
68
+ severity: issue.severity,
69
+ message: issue.message,
70
+ details: issue.details,
71
+ fix: issue.fix,
72
+ })),
73
+ summary,
74
+ durationMs: duration,
75
+ };
76
+ this.printResult(result);
77
+ return result;
78
+ }
79
+ /**
80
+ * Calculate summary statistics
81
+ */
82
+ calculateSummary(issues) {
83
+ return {
84
+ totalChecks: this.checks.length,
85
+ failedChecks: issues.length,
86
+ criticalIssues: issues.filter(i => i.severity === 'critical').length,
87
+ errorIssues: issues.filter(i => i.severity === 'error').length,
88
+ warningIssues: issues.filter(i => i.severity === 'warning').length,
89
+ };
90
+ }
91
+ /**
92
+ * Print result to console
93
+ */
94
+ printResult(result) {
95
+ console.log('═══════════════════════════════════════════════════');
96
+ console.log('🐕 CERBER HEALTH CHECK RESULTS');
97
+ console.log('═══════════════════════════════════════════════════');
98
+ console.log(`Status: ${result.status}`);
99
+ console.log(`Duration: ${result.durationMs}ms`);
100
+ console.log(`\nSummary:`);
101
+ console.log(` Total Checks: ${result.summary.totalChecks}`);
102
+ console.log(` Failed: ${result.summary.failedChecks}`);
103
+ console.log(` Critical: ${result.summary.criticalIssues}`);
104
+ console.log(` Errors: ${result.summary.errorIssues}`);
105
+ console.log(` Warnings: ${result.summary.warningIssues}`);
106
+ if (result.components.length > 0) {
107
+ console.log('\n🔍 Issues Found:');
108
+ result.components.forEach((c) => {
109
+ const icon = c.severity === 'critical' ? '🔴'
110
+ : c.severity === 'error' ? '❌'
111
+ : '⚠️';
112
+ console.log(`\n${icon} [${c.severity.toUpperCase()}] ${c.name}`);
113
+ console.log(` ${c.message}`);
114
+ if (c.fix) {
115
+ console.log(` 💡 Fix: ${c.fix}`);
116
+ }
117
+ });
118
+ }
119
+ console.log('\n═══════════════════════════════════════════════════\n');
120
+ }
121
+ }
122
+ /**
123
+ * Helper to create issue object
124
+ */
125
+ export function makeIssue(params) {
126
+ return {
127
+ code: params.code,
128
+ component: params.component,
129
+ severity: params.severity,
130
+ message: params.message,
131
+ rootCause: params.rootCause,
132
+ fix: params.fix,
133
+ durationMs: params.durationMs,
134
+ details: params.details,
135
+ };
136
+ }
137
+ /**
138
+ * Main function for CLI
139
+ */
140
+ export async function runHealthChecks(options) {
141
+ if (options.url) {
142
+ // Fetch from URL
143
+ const response = await fetch(options.url);
144
+ return response.json();
145
+ }
146
+ // Load checks from file
147
+ const checksPath = path.resolve(process.cwd(), options.checks);
148
+ const checksModule = await import(checksPath);
149
+ const checks = Object.values(checksModule).filter((v) => typeof v === 'function');
150
+ const cerber = new Cerber(checks);
151
+ return cerber.runChecks({ parallel: options.parallel });
152
+ }
153
+ import * as path from 'path';
154
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cerber/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,OAAO,MAAM;IACT,MAAM,CAAgB;IACtB,OAAO,CAAqB;IAEpC,YAAY,MAAqB,EAAE,OAAqC;QACtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;YAC1C,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,OAAgC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAEpD,IAAI,SAAS,GAAkB,EAAE,CAAC;QAElC,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,qBAAqB;YACrB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAC9C,CAAC;YAEF,SAAS,GAAG,OAAO;iBAChB,MAAM,CAAC,CAAC,CAAC,EAA8C,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC;iBACnF,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,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MAAM,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Guardian - Pre-Commit Architecture Validator
3
+ * Blocks commits that violate architecture rules
4
+ */
5
+ import type { ArchitectApproval, GuardianSchema, ValidationResult } from '../types';
6
+ export declare class Guardian {
7
+ private schema;
8
+ private errors;
9
+ private warnings;
10
+ private approvals;
11
+ constructor(schema: GuardianSchema);
12
+ /**
13
+ * Main validation entry point
14
+ */
15
+ validate(): Promise<ValidationResult>;
16
+ /**
17
+ * Check if required files exist
18
+ */
19
+ private checkRequiredFiles;
20
+ /**
21
+ * Check for forbidden patterns with architect approval support
22
+ */
23
+ private checkForbiddenPatterns;
24
+ /**
25
+ * Recursively scan directory for violations
26
+ */
27
+ private scanDirectory;
28
+ /**
29
+ * Scan single file for violations
30
+ */
31
+ private scanFile;
32
+ /**
33
+ * Check if file is in exception list
34
+ */
35
+ private isException;
36
+ /**
37
+ * Check for architect approval comment
38
+ * Format: // ARCHITECT_APPROVED: [reason] - [date] - [architect]
39
+ */
40
+ private checkArchitectApproval;
41
+ /**
42
+ * Check required imports
43
+ */
44
+ private checkRequiredImports;
45
+ /**
46
+ * Check package.json and package-lock.json sync
47
+ */
48
+ private checkPackageLockSync;
49
+ /**
50
+ * Add error message
51
+ */
52
+ private addError;
53
+ /**
54
+ * Add warning message
55
+ */
56
+ private addWarning;
57
+ /**
58
+ * Get validation result
59
+ */
60
+ private getResult;
61
+ }
62
+ /**
63
+ * Main validation function for CLI
64
+ */
65
+ export declare function validateGuardian(options: {
66
+ schema: string;
67
+ verbose?: boolean;
68
+ }): Promise<ValidationResult>;
69
+ export { ArchitectApproval, GuardianSchema, ValidationResult };
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guardian/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpF,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAA2B;gBAEhC,MAAM,EAAE,cAAc;IAIlC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAa3C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;YACW,sBAAsB;IAiBpC;;OAEG;YACW,aAAa;IAmB3B;;OAEG;YACW,QAAQ;IAqCtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAkC9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAyB5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,SAAS;CAiDlB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQhH;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC"}