@theihtisham/agent-shadow-brain 2.1.0 → 3.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.
- package/dist/brain/accessibility-checker.d.ts +10 -0
- package/dist/brain/accessibility-checker.d.ts.map +1 -0
- package/dist/brain/accessibility-checker.js +379 -0
- package/dist/brain/accessibility-checker.js.map +1 -0
- package/dist/brain/api-contract-analyzer.d.ts +19 -0
- package/dist/brain/api-contract-analyzer.d.ts.map +1 -0
- package/dist/brain/api-contract-analyzer.js +251 -0
- package/dist/brain/api-contract-analyzer.js.map +1 -0
- package/dist/brain/ast-analyzer.d.ts +23 -0
- package/dist/brain/ast-analyzer.d.ts.map +1 -0
- package/dist/brain/ast-analyzer.js +462 -0
- package/dist/brain/ast-analyzer.js.map +1 -0
- package/dist/brain/code-age-analyzer.d.ts +11 -0
- package/dist/brain/code-age-analyzer.d.ts.map +1 -0
- package/dist/brain/code-age-analyzer.js +152 -0
- package/dist/brain/code-age-analyzer.js.map +1 -0
- package/dist/brain/config-drift-detector.d.ts +13 -0
- package/dist/brain/config-drift-detector.d.ts.map +1 -0
- package/dist/brain/config-drift-detector.js +198 -0
- package/dist/brain/config-drift-detector.js.map +1 -0
- package/dist/brain/dead-code-eliminator.d.ts +16 -0
- package/dist/brain/dead-code-eliminator.d.ts.map +1 -0
- package/dist/brain/dead-code-eliminator.js +359 -0
- package/dist/brain/dead-code-eliminator.js.map +1 -0
- package/dist/brain/env-analyzer.d.ts +13 -0
- package/dist/brain/env-analyzer.d.ts.map +1 -0
- package/dist/brain/env-analyzer.js +277 -0
- package/dist/brain/env-analyzer.js.map +1 -0
- package/dist/brain/i18n-detector.d.ts +12 -0
- package/dist/brain/i18n-detector.d.ts.map +1 -0
- package/dist/brain/i18n-detector.js +242 -0
- package/dist/brain/i18n-detector.js.map +1 -0
- package/dist/brain/license-compliance.d.ts +13 -0
- package/dist/brain/license-compliance.d.ts.map +1 -0
- package/dist/brain/license-compliance.js +213 -0
- package/dist/brain/license-compliance.js.map +1 -0
- package/dist/brain/llm-client.d.ts.map +1 -1
- package/dist/brain/llm-client.js +3 -0
- package/dist/brain/llm-client.js.map +1 -1
- package/dist/brain/mutation-advisor.d.ts +11 -0
- package/dist/brain/mutation-advisor.d.ts.map +1 -0
- package/dist/brain/mutation-advisor.js +154 -0
- package/dist/brain/mutation-advisor.js.map +1 -0
- package/dist/brain/orchestrator.d.ts +48 -1
- package/dist/brain/orchestrator.d.ts.map +1 -1
- package/dist/brain/orchestrator.js +178 -2
- package/dist/brain/orchestrator.js.map +1 -1
- package/dist/cli.js +408 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +151 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// src/cli.ts — CLI entry point for Shadow Brain
|
|
2
|
+
// src/cli.ts — CLI entry point for Shadow Brain v3.0.0
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import Conf from 'conf';
|
|
@@ -7,7 +7,7 @@ import * as fs from 'fs';
|
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
import { Orchestrator } from './brain/orchestrator.js';
|
|
9
9
|
import { detectRunningAgents, createAdapter } from './adapters/index.js';
|
|
10
|
-
const VERSION = '
|
|
10
|
+
const VERSION = '3.0.0';
|
|
11
11
|
const config = new Conf({
|
|
12
12
|
projectName: 'shadow-brain',
|
|
13
13
|
defaults: {
|
|
@@ -1460,11 +1460,404 @@ meshCmd.command('aggregate')
|
|
|
1460
1460
|
process.exit(1);
|
|
1461
1461
|
}
|
|
1462
1462
|
});
|
|
1463
|
+
// ─── AST (Complexity Analysis) ────────────────────────────────────────────────
|
|
1464
|
+
const astCmd = new Command('ast')
|
|
1465
|
+
.description('Run AST-level complexity analysis — cyclomatic complexity, nesting, function size')
|
|
1466
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1467
|
+
.option('--json', 'Output as JSON')
|
|
1468
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1469
|
+
.action(async (projectDir, opts) => {
|
|
1470
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1471
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1472
|
+
try {
|
|
1473
|
+
console.log(chalk.cyan(' Running AST complexity analysis...'));
|
|
1474
|
+
const insights = await orchestrator.runASTAnalysis(parseInt(opts.maxFiles));
|
|
1475
|
+
if (opts.json) {
|
|
1476
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN AST Analysis (${insights.length} findings)\n`));
|
|
1480
|
+
if (insights.length === 0) {
|
|
1481
|
+
console.log(chalk.green(' No complexity issues detected!'));
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
for (const insight of insights) {
|
|
1485
|
+
const color = insight.priority === 'critical' ? 'red' : insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1486
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1487
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1488
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1489
|
+
console.log();
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
catch (err) {
|
|
1493
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1494
|
+
process.exit(1);
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
// ─── A11Y (Accessibility Audit) ──────────────────────────────────────────────
|
|
1498
|
+
const a11yCmd = new Command('a11y')
|
|
1499
|
+
.description('Run WCAG accessibility audit on frontend code')
|
|
1500
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1501
|
+
.option('--json', 'Output as JSON')
|
|
1502
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1503
|
+
.action(async (projectDir, opts) => {
|
|
1504
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1505
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1506
|
+
try {
|
|
1507
|
+
console.log(chalk.cyan(' Running accessibility audit...'));
|
|
1508
|
+
const insights = await orchestrator.runA11yCheck(parseInt(opts.maxFiles));
|
|
1509
|
+
if (opts.json) {
|
|
1510
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Accessibility Audit (${insights.length} issues)\n`));
|
|
1514
|
+
if (insights.length === 0) {
|
|
1515
|
+
console.log(chalk.green(' No accessibility issues found!'));
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
for (const insight of insights) {
|
|
1519
|
+
const color = insight.priority === 'critical' ? 'red' : insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1520
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1521
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1522
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1523
|
+
console.log();
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
catch (err) {
|
|
1527
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1528
|
+
process.exit(1);
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
// ─── I18N (Internationalization) ──────────────────────────────────────────────
|
|
1532
|
+
const i18nCmd = new Command('i18n')
|
|
1533
|
+
.description('Check internationalization readiness — hardcoded strings, locale support')
|
|
1534
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1535
|
+
.option('--json', 'Output as JSON')
|
|
1536
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1537
|
+
.action(async (projectDir, opts) => {
|
|
1538
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1539
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1540
|
+
try {
|
|
1541
|
+
console.log(chalk.cyan(' Running i18n readiness check...'));
|
|
1542
|
+
const insights = await orchestrator.runI18nAnalysis(parseInt(opts.maxFiles));
|
|
1543
|
+
if (opts.json) {
|
|
1544
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN i18n Analysis (${insights.length} findings)\n`));
|
|
1548
|
+
if (insights.length === 0) {
|
|
1549
|
+
console.log(chalk.green(' No i18n issues found!'));
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
for (const insight of insights) {
|
|
1553
|
+
const color = insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1554
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1555
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1556
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1557
|
+
console.log();
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
catch (err) {
|
|
1561
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1562
|
+
process.exit(1);
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
// ─── DEAD-CODE ────────────────────────────────────────────────────────────────
|
|
1566
|
+
const deadCodeCmd = new Command('dead-code')
|
|
1567
|
+
.description('Detect dead code — unreachable code, unused exports, unused variables')
|
|
1568
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1569
|
+
.option('--json', 'Output as JSON')
|
|
1570
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1571
|
+
.action(async (projectDir, opts) => {
|
|
1572
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1573
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1574
|
+
try {
|
|
1575
|
+
console.log(chalk.cyan(' Scanning for dead code...'));
|
|
1576
|
+
const insights = await orchestrator.runDeadCodeAnalysis(parseInt(opts.maxFiles));
|
|
1577
|
+
if (opts.json) {
|
|
1578
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Dead Code Detection (${insights.length} findings)\n`));
|
|
1582
|
+
if (insights.length === 0) {
|
|
1583
|
+
console.log(chalk.green(' No dead code detected!'));
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
for (const insight of insights) {
|
|
1587
|
+
const color = insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1588
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1589
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1590
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1591
|
+
console.log();
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
catch (err) {
|
|
1595
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1596
|
+
process.exit(1);
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
// ─── MUTATION (Mutation Testing Advisor) ──────────────────────────────────────
|
|
1600
|
+
const mutationCmd = new Command('mutation')
|
|
1601
|
+
.description('Suggest mutation testing cases — tests that would catch real bugs')
|
|
1602
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1603
|
+
.option('--json', 'Output as JSON')
|
|
1604
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1605
|
+
.action(async (projectDir, opts) => {
|
|
1606
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1607
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1608
|
+
try {
|
|
1609
|
+
console.log(chalk.cyan(' Running mutation testing advisor...'));
|
|
1610
|
+
const insights = await orchestrator.runMutationAnalysis(parseInt(opts.maxFiles));
|
|
1611
|
+
if (opts.json) {
|
|
1612
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Mutation Advisor (${insights.length} suggestions)\n`));
|
|
1616
|
+
if (insights.length === 0) {
|
|
1617
|
+
console.log(chalk.green(' No mutation suggestions — code looks well-tested or analysis found nothing!'));
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
for (const insight of insights) {
|
|
1621
|
+
const color = insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1622
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1623
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1624
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1625
|
+
console.log();
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
catch (err) {
|
|
1629
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1630
|
+
process.exit(1);
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
// ─── CODE-AGE ─────────────────────────────────────────────────────────────────
|
|
1634
|
+
const codeAgeCmd = new Command('code-age')
|
|
1635
|
+
.description('Analyze code freshness — stale files, ownership, change frequency')
|
|
1636
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1637
|
+
.option('--json', 'Output as JSON')
|
|
1638
|
+
.action(async (projectDir, opts) => {
|
|
1639
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1640
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1641
|
+
try {
|
|
1642
|
+
console.log(chalk.cyan(' Analyzing code age and freshness...'));
|
|
1643
|
+
const insights = await orchestrator.runCodeAgeAnalysis();
|
|
1644
|
+
if (opts.json) {
|
|
1645
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Code Age Analysis (${insights.length} findings)\n`));
|
|
1649
|
+
if (insights.length === 0) {
|
|
1650
|
+
console.log(chalk.green(' Code looks fresh and well-maintained!'));
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
for (const insight of insights) {
|
|
1654
|
+
const color = insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1655
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1656
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1657
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1658
|
+
console.log();
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
catch (err) {
|
|
1662
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1663
|
+
process.exit(1);
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
// ─── API (API Contract Analysis) ──────────────────────────────────────────────
|
|
1667
|
+
const apiCmd = new Command('api')
|
|
1668
|
+
.description('Analyze API contracts — endpoint discovery, security, consistency')
|
|
1669
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1670
|
+
.option('--json', 'Output as JSON')
|
|
1671
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1672
|
+
.action(async (projectDir, opts) => {
|
|
1673
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1674
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1675
|
+
try {
|
|
1676
|
+
console.log(chalk.cyan(' Running API contract analysis...'));
|
|
1677
|
+
const insights = await orchestrator.runAPIContractAnalysis(parseInt(opts.maxFiles));
|
|
1678
|
+
if (opts.json) {
|
|
1679
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN API Contract Analysis (${insights.length} findings)\n`));
|
|
1683
|
+
if (insights.length === 0) {
|
|
1684
|
+
console.log(chalk.green(' No API contract issues detected!'));
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
for (const insight of insights) {
|
|
1688
|
+
const color = insight.priority === 'critical' ? 'red' : insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1689
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1690
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1691
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1692
|
+
console.log();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
catch (err) {
|
|
1696
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1697
|
+
process.exit(1);
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
// ─── ENV (Environment Variable Analysis) ──────────────────────────────────────
|
|
1701
|
+
const envCmd = new Command('env')
|
|
1702
|
+
.description('Analyze environment variables — secrets, validation, naming conventions')
|
|
1703
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1704
|
+
.option('--json', 'Output as JSON')
|
|
1705
|
+
.option('--max-files <n>', 'Max files to analyze', '200')
|
|
1706
|
+
.action(async (projectDir, opts) => {
|
|
1707
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1708
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1709
|
+
try {
|
|
1710
|
+
console.log(chalk.cyan(' Analyzing environment variables...'));
|
|
1711
|
+
const insights = await orchestrator.runEnvAnalysis(parseInt(opts.maxFiles));
|
|
1712
|
+
if (opts.json) {
|
|
1713
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Environment Analysis (${insights.length} findings)\n`));
|
|
1717
|
+
if (insights.length === 0) {
|
|
1718
|
+
console.log(chalk.green(' No environment variable issues detected!'));
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
for (const insight of insights) {
|
|
1722
|
+
const color = insight.priority === 'critical' ? 'red' : insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1723
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1724
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1725
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1726
|
+
console.log();
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
catch (err) {
|
|
1730
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1731
|
+
process.exit(1);
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
// ─── LICENSE (License Compliance) ─────────────────────────────────────────────
|
|
1735
|
+
const licenseCmd = new Command('license')
|
|
1736
|
+
.description('Audit dependency licenses — restricted, copyleft, unknown licenses')
|
|
1737
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1738
|
+
.option('--json', 'Output as JSON')
|
|
1739
|
+
.action(async (projectDir, opts) => {
|
|
1740
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1741
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1742
|
+
try {
|
|
1743
|
+
console.log(chalk.cyan(' Running license compliance audit...'));
|
|
1744
|
+
const insights = await orchestrator.runLicenseCompliance();
|
|
1745
|
+
if (opts.json) {
|
|
1746
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN License Compliance (${insights.length} findings)\n`));
|
|
1750
|
+
if (insights.length === 0) {
|
|
1751
|
+
console.log(chalk.green(' All dependency licenses are compliant!'));
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
for (const insight of insights) {
|
|
1755
|
+
const color = insight.priority === 'critical' ? 'red' : insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1756
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1757
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1758
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1759
|
+
console.log();
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
catch (err) {
|
|
1763
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1764
|
+
process.exit(1);
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
// ─── CONFIG-DRIFT ─────────────────────────────────────────────────────────────
|
|
1768
|
+
const configDriftCmd = new Command('config-drift')
|
|
1769
|
+
.description('Detect configuration drift — missing configs, inconsistent settings')
|
|
1770
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1771
|
+
.option('--json', 'Output as JSON')
|
|
1772
|
+
.action(async (projectDir, opts) => {
|
|
1773
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1774
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1775
|
+
try {
|
|
1776
|
+
console.log(chalk.cyan(' Detecting configuration drift...'));
|
|
1777
|
+
const insights = await orchestrator.runConfigDriftDetection();
|
|
1778
|
+
if (opts.json) {
|
|
1779
|
+
console.log(JSON.stringify(insights, null, 2));
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN Config Drift Detection (${insights.length} findings)\n`));
|
|
1783
|
+
if (insights.length === 0) {
|
|
1784
|
+
console.log(chalk.green(' No configuration drift detected!'));
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
for (const insight of insights) {
|
|
1788
|
+
const color = insight.priority === 'high' ? 'yellow' : 'blue';
|
|
1789
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1790
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1791
|
+
console.log(` ${insight.content.slice(0, 200)}${insight.content.length > 200 ? '...' : ''}`);
|
|
1792
|
+
console.log();
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
catch (err) {
|
|
1796
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1797
|
+
process.exit(1);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
// ─── HYPER (Full Hyper-Analysis) ──────────────────────────────────────────────
|
|
1801
|
+
const hyperCmd = new Command('hyper')
|
|
1802
|
+
.description('Run ALL v3.0.0 hyper-intelligence analyses at once')
|
|
1803
|
+
.argument('[project-dir]', 'Project directory', process.cwd())
|
|
1804
|
+
.option('--json', 'Output as JSON')
|
|
1805
|
+
.option('--max-files <n>', 'Max files per analysis', '200')
|
|
1806
|
+
.action(async (projectDir, opts) => {
|
|
1807
|
+
const brainConfig = mergeConfig({ projectDir, watchMode: false });
|
|
1808
|
+
const orchestrator = new Orchestrator(brainConfig);
|
|
1809
|
+
try {
|
|
1810
|
+
console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Hyper-Intelligence Full Scan\n`));
|
|
1811
|
+
console.log(chalk.cyan(' Running all 10 hyper-intelligence modules in parallel...'));
|
|
1812
|
+
console.log(chalk.dim(' This may take a moment for large projects.\n'));
|
|
1813
|
+
const results = await orchestrator.runFullHyperAnalysis({
|
|
1814
|
+
maxFiles: parseInt(opts.maxFiles),
|
|
1815
|
+
});
|
|
1816
|
+
if (opts.json) {
|
|
1817
|
+
console.log(JSON.stringify(results, null, 2));
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
const modules = [
|
|
1821
|
+
{ name: 'ast', label: 'AST Complexity', insights: results.ast },
|
|
1822
|
+
{ name: 'a11y', label: 'Accessibility (WCAG)', insights: results.a11y },
|
|
1823
|
+
{ name: 'i18n', label: 'Internationalization', insights: results.i18n },
|
|
1824
|
+
{ name: 'deadCode', label: 'Dead Code', insights: results.deadCode },
|
|
1825
|
+
{ name: 'mutation', label: 'Mutation Testing', insights: results.mutation },
|
|
1826
|
+
{ name: 'codeAge', label: 'Code Age', insights: results.codeAge },
|
|
1827
|
+
{ name: 'apiContract', label: 'API Contracts', insights: results.apiContract },
|
|
1828
|
+
{ name: 'env', label: 'Environment Variables', insights: results.env },
|
|
1829
|
+
{ name: 'license', label: 'License Compliance', insights: results.license },
|
|
1830
|
+
{ name: 'configDrift', label: 'Config Drift', insights: results.configDrift },
|
|
1831
|
+
];
|
|
1832
|
+
for (const mod of modules) {
|
|
1833
|
+
const count = mod.insights.length;
|
|
1834
|
+
const color = count === 0 ? 'green' : count < 5 ? 'yellow' : 'red';
|
|
1835
|
+
const icon = count === 0 ? '✓' : '⚠';
|
|
1836
|
+
console.log(chalk ` {${color}.bold ${icon}} ${chalk.bold(mod.label)}: ${count} finding(s)`);
|
|
1837
|
+
}
|
|
1838
|
+
console.log(chalk.bold(`\n Total findings: ${results.total}\n`));
|
|
1839
|
+
// Show critical/high priority details
|
|
1840
|
+
const allCritical = modules.flatMap(m => m.insights.filter(i => i.priority === 'critical' || i.priority === 'high'));
|
|
1841
|
+
if (allCritical.length > 0) {
|
|
1842
|
+
console.log(chalk.red.bold(` Critical/High Priority (${allCritical.length}):\n`));
|
|
1843
|
+
for (const insight of allCritical.slice(0, 20)) {
|
|
1844
|
+
const color = insight.priority === 'critical' ? 'red' : 'yellow';
|
|
1845
|
+
console.log(chalk ` {${color}.bold [${insight.priority.toUpperCase()}]} ${insight.title}`);
|
|
1846
|
+
console.log(chalk.dim(` Files: ${insight.files?.join(', ') || 'none'}`));
|
|
1847
|
+
console.log();
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
catch (err) {
|
|
1852
|
+
console.error(chalk.red(' Error:'), err.message);
|
|
1853
|
+
process.exit(1);
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1463
1856
|
// ─── MAIN ─────────────────────────────────────────────────────────────────────
|
|
1464
1857
|
const program = new Command();
|
|
1465
1858
|
program
|
|
1466
1859
|
.name('shadow-brain')
|
|
1467
|
-
.description('Shadow Brain
|
|
1860
|
+
.description('Shadow Brain v3.0.0 — Hyper-Intelligence Layer for AI Coding Agents with Quantum Neural Mesh')
|
|
1468
1861
|
.version(VERSION);
|
|
1469
1862
|
program.addCommand(startCmd);
|
|
1470
1863
|
program.addCommand(reviewCmd);
|
|
@@ -1497,5 +1890,17 @@ program.addCommand(contextCmd);
|
|
|
1497
1890
|
program.addCommand(learnCmd);
|
|
1498
1891
|
// v2.1.0 commands
|
|
1499
1892
|
program.addCommand(meshCmd);
|
|
1893
|
+
// v3.0.0 hyper-intelligence commands
|
|
1894
|
+
program.addCommand(astCmd);
|
|
1895
|
+
program.addCommand(a11yCmd);
|
|
1896
|
+
program.addCommand(i18nCmd);
|
|
1897
|
+
program.addCommand(deadCodeCmd);
|
|
1898
|
+
program.addCommand(mutationCmd);
|
|
1899
|
+
program.addCommand(codeAgeCmd);
|
|
1900
|
+
program.addCommand(apiCmd);
|
|
1901
|
+
program.addCommand(envCmd);
|
|
1902
|
+
program.addCommand(licenseCmd);
|
|
1903
|
+
program.addCommand(configDriftCmd);
|
|
1904
|
+
program.addCommand(hyperCmd);
|
|
1500
1905
|
program.parse();
|
|
1501
1906
|
//# sourceMappingURL=cli.js.map
|