@vee-stack/delta-cli 2.0.4 → 2.0.5
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/analyzer/commands/analyze.js +260 -0
- package/dist/analyzer/commands/config.js +83 -0
- package/dist/analyzer/commands/report.js +38 -0
- package/dist/analyzer/generators/report.generator.js +123 -0
- package/dist/analyzer/index.js +44 -0
- package/dist/analyzer/scanners/project.scanner.js +92 -0
- package/dist/analyzer/validators/contracts.validator.js +42 -0
- package/dist/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/analyzer/validators/observability.validator.js +39 -0
- package/dist/analyzer/validators/performance.validator.js +42 -0
- package/dist/analyzer/validators/security.validator.js +66 -0
- package/dist/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/analyzer/commands/analyze.js +256 -0
- package/dist/apps/cli/src/analyzer/commands/config.js +83 -0
- package/dist/apps/cli/src/analyzer/commands/report.js +38 -0
- package/dist/apps/cli/src/analyzer/generators/report.generator.js +123 -0
- package/dist/apps/cli/src/analyzer/index.js +44 -0
- package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +92 -0
- package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/apps/cli/src/analyzer/validators/observability.validator.js +39 -0
- package/dist/apps/cli/src/analyzer/validators/performance.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/security.validator.js +66 -0
- package/dist/apps/cli/src/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/auth/secure-auth.js +312 -0
- package/dist/apps/cli/src/commands/analyze.js +286 -0
- package/dist/apps/cli/src/commands/auth-new.js +37 -0
- package/dist/apps/cli/src/commands/auth.js +122 -0
- package/dist/apps/cli/src/commands/config.js +49 -0
- package/dist/apps/cli/src/commands/deploy.js +6 -0
- package/dist/apps/cli/src/commands/init.js +47 -0
- package/dist/apps/cli/src/commands/logout.js +23 -0
- package/dist/apps/cli/src/commands/plugins.js +21 -0
- package/dist/apps/cli/src/commands/status.js +80 -0
- package/dist/apps/cli/src/commands/sync.js +6 -0
- package/dist/apps/cli/src/commands/whoami.js +115 -0
- package/dist/apps/cli/src/components/Dashboard.js +168 -0
- package/dist/apps/cli/src/components/DeltaApp.js +56 -0
- package/dist/apps/cli/src/components/UnifiedManager.js +324 -0
- package/dist/apps/cli/src/core/audit.js +184 -0
- package/dist/apps/cli/src/core/completion.js +294 -0
- package/dist/apps/cli/src/core/contracts.js +6 -0
- package/dist/apps/cli/src/core/engine.js +124 -0
- package/dist/apps/cli/src/core/exit-codes.js +71 -0
- package/dist/apps/cli/src/core/hooks.js +181 -0
- package/dist/apps/cli/src/core/index.js +7 -0
- package/dist/apps/cli/src/core/policy.js +115 -0
- package/dist/apps/cli/src/core/profiles.js +161 -0
- package/dist/apps/cli/src/core/wizard.js +203 -0
- package/dist/apps/cli/src/index.js +636 -0
- package/dist/apps/cli/src/interactive/index.js +11 -0
- package/dist/apps/cli/src/plugins/GitStatusPlugin.js +99 -0
- package/dist/apps/cli/src/providers/ai-provider.js +74 -0
- package/dist/apps/cli/src/providers/local-provider.js +302 -0
- package/dist/apps/cli/src/providers/remote-provider.js +100 -0
- package/dist/apps/cli/src/types/api.js +3 -0
- package/dist/apps/cli/src/ui.js +219 -0
- package/dist/apps/cli/src/welcome.js +81 -0
- package/dist/auth/secure-auth.js +418 -0
- package/dist/bundle.js +45 -45
- package/dist/commands/analyze.js +363 -0
- package/dist/commands/auth-new.js +37 -0
- package/dist/commands/auth.js +133 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/deploy.js +6 -0
- package/dist/commands/init.js +47 -0
- package/dist/commands/logout.js +30 -0
- package/dist/commands/plugins.js +21 -0
- package/dist/commands/status.js +82 -0
- package/dist/commands/sync.js +6 -0
- package/dist/commands/whoami.js +71 -0
- package/dist/components/Dashboard.js +169 -0
- package/dist/components/DeltaApp.js +57 -0
- package/dist/components/UnifiedManager.js +344 -0
- package/dist/core/audit.js +184 -0
- package/dist/core/completion.js +294 -0
- package/dist/core/contracts.js +6 -0
- package/dist/core/engine.js +124 -0
- package/dist/core/exit-codes.js +71 -0
- package/dist/core/hooks.js +181 -0
- package/dist/core/index.js +7 -0
- package/dist/core/policy.js +115 -0
- package/dist/core/profiles.js +161 -0
- package/dist/core/wizard.js +203 -0
- package/dist/index.js +387 -0
- package/dist/interactive/index.js +11 -0
- package/dist/packages/domain/src/constitution/contracts/index.js +43 -0
- package/dist/packages/domain/src/constitution/contracts/ts.rules.js +268 -0
- package/dist/packages/domain/src/constitution/index.js +139 -0
- package/dist/packages/domain/src/constitution/maintainability/index.js +43 -0
- package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +344 -0
- package/dist/packages/domain/src/constitution/observability/index.js +43 -0
- package/dist/packages/domain/src/constitution/observability/ts.rules.js +307 -0
- package/dist/packages/domain/src/constitution/performance/index.js +43 -0
- package/dist/packages/domain/src/constitution/performance/ts.rules.js +325 -0
- package/dist/packages/domain/src/constitution/security/index.js +50 -0
- package/dist/packages/domain/src/constitution/security/ts.rules.js +267 -0
- package/dist/packages/domain/src/constitution/soc/index.js +43 -0
- package/dist/packages/domain/src/constitution/soc/ts.rules.js +360 -0
- package/dist/packages/domain/src/contracts/analysis.contract.js +18 -0
- package/dist/packages/domain/src/contracts/index.js +7 -0
- package/dist/packages/domain/src/contracts/projects.contract.js +18 -0
- package/dist/packages/domain/src/control/registry/rules.registry.js +29 -0
- package/dist/packages/domain/src/control/schemas/policies.js +6 -0
- package/dist/packages/domain/src/core/analysis/discovery.js +163 -0
- package/dist/packages/domain/src/core/analysis/engine.contract.js +298 -0
- package/dist/packages/domain/src/core/analysis/engine.js +77 -0
- package/dist/packages/domain/src/core/analysis/index.js +14 -0
- package/dist/packages/domain/src/core/analysis/orchestrator.js +242 -0
- package/dist/packages/domain/src/core/comparison/engine.js +29 -0
- package/dist/packages/domain/src/core/comparison/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/pipeline.js +41 -0
- package/dist/packages/domain/src/core/fs/adapter.js +111 -0
- package/dist/packages/domain/src/core/fs/index.js +5 -0
- package/dist/packages/domain/src/core/parser/unified-parser.js +166 -0
- package/dist/packages/domain/src/index.js +33 -0
- package/dist/packages/domain/src/plugin/registry.js +195 -0
- package/dist/packages/domain/src/plugin/types.js +6 -0
- package/dist/packages/domain/src/ports/analysis.engine.js +7 -0
- package/dist/packages/domain/src/ports/audit.logger.js +7 -0
- package/dist/packages/domain/src/ports/project.repository.js +7 -0
- package/dist/packages/domain/src/rules/index.js +134 -0
- package/dist/packages/domain/src/types/analysis.js +6 -0
- package/dist/packages/domain/src/types/errors.js +53 -0
- package/dist/packages/domain/src/types/fs.js +6 -0
- package/dist/packages/domain/src/types/index.js +7 -0
- package/dist/plugins/GitStatusPlugin.js +93 -0
- package/dist/providers/ai-provider.js +74 -0
- package/dist/providers/local-provider.js +304 -0
- package/dist/providers/remote-provider.js +100 -0
- package/dist/types/api.js +3 -0
- package/dist/ui.js +219 -0
- package/dist/welcome.js +81 -0
- package/package.json +18 -18
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation pipeline - Core domain logic for documentation generation
|
|
3
|
+
* @see docs/architecture/OVERVIEW.md#data-flow
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Documentation generator
|
|
7
|
+
* Transforms analysis results into various documentation formats
|
|
8
|
+
*/
|
|
9
|
+
export class DocumentationPipeline {
|
|
10
|
+
/**
|
|
11
|
+
* Generate documentation from analysis result
|
|
12
|
+
* @param result - Analysis result
|
|
13
|
+
* @param format - Output format
|
|
14
|
+
* @returns Generated documentation content
|
|
15
|
+
*/
|
|
16
|
+
async generate(result, format) {
|
|
17
|
+
switch (format) {
|
|
18
|
+
case 'md':
|
|
19
|
+
return this.generateMarkdown(result);
|
|
20
|
+
case 'html':
|
|
21
|
+
return this.generateHtml(result);
|
|
22
|
+
case 'pdf':
|
|
23
|
+
return this.generatePdf(result);
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
generateMarkdown(_result) {
|
|
29
|
+
// Implementation placeholder
|
|
30
|
+
return '# Analysis Report\n\nDocumentation placeholder.';
|
|
31
|
+
}
|
|
32
|
+
generateHtml(_result) {
|
|
33
|
+
// Implementation placeholder
|
|
34
|
+
return '<html><body><h1>Analysis Report</h1><p>Documentation placeholder.</p></body></html>';
|
|
35
|
+
}
|
|
36
|
+
generatePdf(_result) {
|
|
37
|
+
// Implementation placeholder
|
|
38
|
+
return Buffer.from('PDF placeholder');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File system adapter - Local FS implementation
|
|
3
|
+
* Uses fs-extra for enhanced FS operations and fast-glob for efficient file matching
|
|
4
|
+
* @see docs/architecture/OVERVIEW.md#file-system-abstraction
|
|
5
|
+
*/
|
|
6
|
+
import fse from 'fs-extra';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fg from 'fast-glob';
|
|
9
|
+
import { FileSystemError } from '../../types/errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* Local file system adapter
|
|
12
|
+
* Implements FileSystemAdapter for local disk access
|
|
13
|
+
*/
|
|
14
|
+
export class LocalFSAdapter {
|
|
15
|
+
basePath;
|
|
16
|
+
constructor(basePath) {
|
|
17
|
+
this.basePath = path.resolve(basePath);
|
|
18
|
+
}
|
|
19
|
+
async readFile(filePath) {
|
|
20
|
+
const fullPath = this.resolvePath(filePath);
|
|
21
|
+
try {
|
|
22
|
+
return await fse.readFile(fullPath);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new FileSystemError(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async readDir(dirPath) {
|
|
29
|
+
const fullPath = this.resolvePath(dirPath);
|
|
30
|
+
try {
|
|
31
|
+
const entries = await fse.readdir(fullPath, { withFileTypes: true });
|
|
32
|
+
return entries.map(entry => entry.name);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new FileSystemError(`Failed to read directory ${dirPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async exists(filePath) {
|
|
39
|
+
const fullPath = this.resolvePath(filePath);
|
|
40
|
+
return await fse.pathExists(fullPath);
|
|
41
|
+
}
|
|
42
|
+
async stat(filePath) {
|
|
43
|
+
const fullPath = this.resolvePath(filePath);
|
|
44
|
+
try {
|
|
45
|
+
const stats = await fse.stat(fullPath);
|
|
46
|
+
return {
|
|
47
|
+
size: stats.size,
|
|
48
|
+
isFile: stats.isFile(),
|
|
49
|
+
isDirectory: stats.isDirectory(),
|
|
50
|
+
modifiedTime: stats.mtime,
|
|
51
|
+
createdTime: stats.birthtime,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new FileSystemError(`Failed to stat ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Collect file information using fast-glob
|
|
60
|
+
* @param dirPath - Directory to scan
|
|
61
|
+
* @param patterns - Glob patterns to include/exclude
|
|
62
|
+
* @returns Array of file info objects
|
|
63
|
+
*/
|
|
64
|
+
async collectFiles(dirPath, patterns = {}) {
|
|
65
|
+
const fullPath = this.resolvePath(dirPath);
|
|
66
|
+
const include = patterns.include || ['**/*'];
|
|
67
|
+
const exclude = patterns.exclude || ['**/node_modules/**', '**/.git/**'];
|
|
68
|
+
const entries = await fg.glob(include, {
|
|
69
|
+
cwd: fullPath,
|
|
70
|
+
ignore: exclude,
|
|
71
|
+
absolute: true,
|
|
72
|
+
onlyFiles: true,
|
|
73
|
+
stats: true,
|
|
74
|
+
});
|
|
75
|
+
return entries.map(entry => {
|
|
76
|
+
const stats = entry.stats;
|
|
77
|
+
return {
|
|
78
|
+
path: entry.path,
|
|
79
|
+
relativePath: path.relative(fullPath, entry.path),
|
|
80
|
+
size: stats.size,
|
|
81
|
+
extension: path.extname(entry.path),
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Ensure directory exists (create if not)
|
|
87
|
+
* @param dirPath - Directory path
|
|
88
|
+
*/
|
|
89
|
+
async ensureDir(dirPath) {
|
|
90
|
+
const fullPath = this.resolvePath(dirPath);
|
|
91
|
+
await fse.ensureDir(fullPath);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Write file (create directory if not exists)
|
|
95
|
+
* @param filePath - File path
|
|
96
|
+
* @param content - File content
|
|
97
|
+
*/
|
|
98
|
+
async writeFile(filePath, content) {
|
|
99
|
+
const fullPath = this.resolvePath(filePath);
|
|
100
|
+
await fse.outputFile(fullPath, content);
|
|
101
|
+
}
|
|
102
|
+
resolvePath(filePath) {
|
|
103
|
+
const resolved = path.resolve(this.basePath, filePath);
|
|
104
|
+
// Security: ensure path doesn't escape basePath
|
|
105
|
+
if (!resolved.startsWith(this.basePath)) {
|
|
106
|
+
throw new FileSystemError(`Path escapes jail: ${filePath}`);
|
|
107
|
+
}
|
|
108
|
+
return resolved;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Parser Module
|
|
3
|
+
* Unified AST parsing with error isolation per file
|
|
4
|
+
*/
|
|
5
|
+
// Temporarily commented out for build
|
|
6
|
+
// import * as tsEstree from '@typescript-eslint/typescript-estree';
|
|
7
|
+
// import * as babel from '@babel/parser';
|
|
8
|
+
// TODO: Fix parser imports
|
|
9
|
+
const parseTS = (_code, _options) => null;
|
|
10
|
+
const parseBabel = (_code, _options) => null;
|
|
11
|
+
const EXT_TO_LANGUAGE = {
|
|
12
|
+
'.js': 'js',
|
|
13
|
+
'.jsx': 'jsx',
|
|
14
|
+
'.ts': 'ts',
|
|
15
|
+
'.tsx': 'tsx',
|
|
16
|
+
'.mjs': 'mjs',
|
|
17
|
+
'.cjs': 'cjs',
|
|
18
|
+
'.mts': 'mts',
|
|
19
|
+
'.cts': 'cts',
|
|
20
|
+
};
|
|
21
|
+
export function detectLanguage(filePath) {
|
|
22
|
+
const ext = filePath.slice(filePath.lastIndexOf('.')).toLowerCase();
|
|
23
|
+
return EXT_TO_LANGUAGE[ext] || 'unknown';
|
|
24
|
+
}
|
|
25
|
+
export function detectModuleType(source) {
|
|
26
|
+
if (/^\s*import\s+/m.test(source) || /^\s*export\s+/m.test(source))
|
|
27
|
+
return 'esm';
|
|
28
|
+
if (/\brequire\s*\(/m.test(source) || /\bmodule\.exports\b/m.test(source))
|
|
29
|
+
return 'cjs';
|
|
30
|
+
return 'unknown';
|
|
31
|
+
}
|
|
32
|
+
function calculateMetrics(ast) {
|
|
33
|
+
const metrics = {
|
|
34
|
+
loc: 0,
|
|
35
|
+
functions: 0,
|
|
36
|
+
classes: 0,
|
|
37
|
+
imports: 0,
|
|
38
|
+
exports: 0,
|
|
39
|
+
complexity: 1,
|
|
40
|
+
};
|
|
41
|
+
function visit(node) {
|
|
42
|
+
if (!node || typeof node !== 'object')
|
|
43
|
+
return;
|
|
44
|
+
const n = node;
|
|
45
|
+
switch (n.type) {
|
|
46
|
+
case 'FunctionDeclaration':
|
|
47
|
+
case 'FunctionExpression':
|
|
48
|
+
case 'ArrowFunctionExpression':
|
|
49
|
+
metrics.functions++;
|
|
50
|
+
break;
|
|
51
|
+
case 'ClassDeclaration':
|
|
52
|
+
case 'ClassExpression':
|
|
53
|
+
metrics.classes++;
|
|
54
|
+
break;
|
|
55
|
+
case 'ImportDeclaration':
|
|
56
|
+
metrics.imports++;
|
|
57
|
+
break;
|
|
58
|
+
case 'ExportNamedDeclaration':
|
|
59
|
+
case 'ExportDefaultDeclaration':
|
|
60
|
+
case 'ExportAllDeclaration':
|
|
61
|
+
metrics.exports++;
|
|
62
|
+
break;
|
|
63
|
+
case 'IfStatement':
|
|
64
|
+
case 'ConditionalExpression':
|
|
65
|
+
case 'SwitchCase':
|
|
66
|
+
case 'ForStatement':
|
|
67
|
+
case 'ForInStatement':
|
|
68
|
+
case 'ForOfStatement':
|
|
69
|
+
case 'WhileStatement':
|
|
70
|
+
case 'DoWhileStatement':
|
|
71
|
+
metrics.complexity++;
|
|
72
|
+
break;
|
|
73
|
+
case 'LogicalExpression':
|
|
74
|
+
if (n.operator === '&&' || n.operator === '||')
|
|
75
|
+
metrics.complexity++;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
// Visit children
|
|
79
|
+
for (const key of Object.keys(n)) {
|
|
80
|
+
const val = n[key];
|
|
81
|
+
if (Array.isArray(val))
|
|
82
|
+
val.forEach(visit);
|
|
83
|
+
else if (val && typeof val === 'object')
|
|
84
|
+
visit(val);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
visit(ast);
|
|
88
|
+
return metrics;
|
|
89
|
+
}
|
|
90
|
+
export function parseSource(source, options) {
|
|
91
|
+
const start = Date.now();
|
|
92
|
+
const detectedLang = options.language || detectLanguage(options.filePath);
|
|
93
|
+
// Skip non-JS/TS files
|
|
94
|
+
if (detectedLang === 'unknown') {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
errors: [{ message: 'Unsupported file type', code: 'UNSUPPORTED' }],
|
|
98
|
+
language: 'unknown',
|
|
99
|
+
moduleType: 'unknown',
|
|
100
|
+
metrics: { loc: 0, functions: 0, classes: 0, imports: 0, exports: 0, complexity: 0 },
|
|
101
|
+
duration: Date.now() - start,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const isTypeScript = detectedLang.startsWith('t') || detectedLang === 'mts' || detectedLang === 'cts';
|
|
105
|
+
const isJSX = detectedLang === 'jsx' || detectedLang === 'tsx';
|
|
106
|
+
try {
|
|
107
|
+
let ast;
|
|
108
|
+
if (isTypeScript) {
|
|
109
|
+
ast = parseTS(source, {
|
|
110
|
+
loc: true,
|
|
111
|
+
range: true,
|
|
112
|
+
comment: true,
|
|
113
|
+
jsx: isJSX,
|
|
114
|
+
errorOnUnknownASTType: false,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
ast = parseBabel(source, {
|
|
119
|
+
sourceType: 'unambiguous',
|
|
120
|
+
allowImportExportEverywhere: true,
|
|
121
|
+
plugins: [
|
|
122
|
+
'jsx',
|
|
123
|
+
'typescript',
|
|
124
|
+
'decorators-legacy',
|
|
125
|
+
'classProperties',
|
|
126
|
+
'dynamicImport',
|
|
127
|
+
'optionalChaining',
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const metrics = calculateMetrics(ast);
|
|
132
|
+
metrics.loc = source.split('\n').length;
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
ast,
|
|
136
|
+
errors: [],
|
|
137
|
+
language: detectedLang,
|
|
138
|
+
moduleType: detectModuleType(source),
|
|
139
|
+
metrics,
|
|
140
|
+
duration: Date.now() - start,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
errors: [
|
|
147
|
+
{
|
|
148
|
+
message: err instanceof Error ? err.message : 'Parse failed',
|
|
149
|
+
code: 'PARSE_ERROR',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
language: detectedLang,
|
|
153
|
+
moduleType: detectModuleType(source),
|
|
154
|
+
metrics: {
|
|
155
|
+
loc: source.split('\n').length,
|
|
156
|
+
functions: 0,
|
|
157
|
+
classes: 0,
|
|
158
|
+
imports: 0,
|
|
159
|
+
exports: 0,
|
|
160
|
+
complexity: 0,
|
|
161
|
+
},
|
|
162
|
+
duration: Date.now() - start,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=unified-parser.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delta Domain Package
|
|
3
|
+
* @description Pure business logic, constitution, rules, and core engine
|
|
4
|
+
* @package @delta/domain
|
|
5
|
+
*/
|
|
6
|
+
// Constitution - explicit exports to avoid conflicts
|
|
7
|
+
export { SevenAxes, SupportedLanguages, ConstitutionVersion, calculateOverallScore, getRulesForLanguage, isLanguageSupported, } from './constitution/index.js';
|
|
8
|
+
// Export constitution axes as namespaces
|
|
9
|
+
export * as Security from './constitution/security/index.js';
|
|
10
|
+
export * as Performance from './constitution/performance/index.js';
|
|
11
|
+
export * as Soc from './constitution/soc/index.js';
|
|
12
|
+
export * as Contracts from './constitution/contracts/index.js';
|
|
13
|
+
export * as Maintainability from './constitution/maintainability/index.js';
|
|
14
|
+
export * as Observability from './constitution/observability/index.js';
|
|
15
|
+
// Core Engine - selective exports
|
|
16
|
+
export { AnalysisEngineV1 } from './core/analysis/engine.contract.js';
|
|
17
|
+
export { analyze, createSession } from './core/analysis/engine.js';
|
|
18
|
+
export { discoverFiles, isValidProjectRoot, analyzeProjectTypes, } from './core/analysis/discovery.js';
|
|
19
|
+
export { runAnalysis, generateReport, saveReport, } from './core/analysis/orchestrator.js';
|
|
20
|
+
// Other core modules
|
|
21
|
+
export * from './core/documentation/index.js';
|
|
22
|
+
export * from './core/comparison/index.js';
|
|
23
|
+
export * from './core/fs/index.js';
|
|
24
|
+
// Rules
|
|
25
|
+
export * from './rules/index.js';
|
|
26
|
+
// Types
|
|
27
|
+
export * from './types/index.js';
|
|
28
|
+
// Contracts
|
|
29
|
+
export * from './contracts/index.js';
|
|
30
|
+
export { rulesRegistry } from './control/registry/rules.registry.js';
|
|
31
|
+
// Plugin System
|
|
32
|
+
export { PluginRegistry, } from './plugin/registry.js';
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delta Plugin Registry
|
|
3
|
+
* Central management for all plugins
|
|
4
|
+
*/
|
|
5
|
+
export class PluginRegistry {
|
|
6
|
+
plugins = new Map();
|
|
7
|
+
commands = new Map();
|
|
8
|
+
widgets = new Map();
|
|
9
|
+
logHandlers = new Map();
|
|
10
|
+
listeners = [];
|
|
11
|
+
pluginStates = new Map();
|
|
12
|
+
constructor(_context) {
|
|
13
|
+
// _context stored for future use
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Register a new plugin
|
|
17
|
+
*/
|
|
18
|
+
async register(plugin) {
|
|
19
|
+
if (this.plugins.has(plugin.id)) {
|
|
20
|
+
throw new Error(`Plugin ${plugin.id} is already registered`);
|
|
21
|
+
}
|
|
22
|
+
// Store plugin
|
|
23
|
+
this.plugins.set(plugin.id, plugin);
|
|
24
|
+
// Register commands
|
|
25
|
+
const commands = plugin.registerCommands?.() || [];
|
|
26
|
+
commands.forEach((cmd) => {
|
|
27
|
+
const key = `${plugin.id}:${cmd.id}`;
|
|
28
|
+
this.commands.set(key, { plugin, command: cmd });
|
|
29
|
+
});
|
|
30
|
+
// Register widgets
|
|
31
|
+
const widgets = plugin.registerDashboardWidgets?.() || [];
|
|
32
|
+
widgets.forEach((widget) => {
|
|
33
|
+
const key = `${plugin.id}:${widget.id}`;
|
|
34
|
+
this.widgets.set(key, { plugin, widget });
|
|
35
|
+
});
|
|
36
|
+
// Register log handlers
|
|
37
|
+
const handlers = plugin.registerLogHandlers?.() || [];
|
|
38
|
+
if (handlers.length > 0) {
|
|
39
|
+
this.logHandlers.set(plugin.id, handlers.map((h) => ({ plugin, handler: h })));
|
|
40
|
+
}
|
|
41
|
+
// Initialize state
|
|
42
|
+
this.pluginStates.set(plugin.id, {
|
|
43
|
+
id: plugin.id,
|
|
44
|
+
enabled: true,
|
|
45
|
+
settings: {},
|
|
46
|
+
});
|
|
47
|
+
// Activate plugin
|
|
48
|
+
await plugin.onActivate();
|
|
49
|
+
this.emit({ type: 'plugin:registered', pluginId: plugin.id });
|
|
50
|
+
this.emit({ type: 'plugin:activated', pluginId: plugin.id });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Unregister a plugin
|
|
54
|
+
*/
|
|
55
|
+
async unregister(pluginId) {
|
|
56
|
+
const plugin = this.plugins.get(pluginId);
|
|
57
|
+
if (!plugin)
|
|
58
|
+
return;
|
|
59
|
+
// Deactivate
|
|
60
|
+
await plugin.onDeactivate?.();
|
|
61
|
+
// Remove commands
|
|
62
|
+
for (const [key, { plugin: p }] of this.commands) {
|
|
63
|
+
if (p.id === pluginId)
|
|
64
|
+
this.commands.delete(key);
|
|
65
|
+
}
|
|
66
|
+
// Remove widgets
|
|
67
|
+
for (const [key, { plugin: p }] of this.widgets) {
|
|
68
|
+
if (p.id === pluginId)
|
|
69
|
+
this.widgets.delete(key);
|
|
70
|
+
}
|
|
71
|
+
// Remove log handlers
|
|
72
|
+
this.logHandlers.delete(pluginId);
|
|
73
|
+
// Remove plugin
|
|
74
|
+
this.plugins.delete(pluginId);
|
|
75
|
+
this.pluginStates.delete(pluginId);
|
|
76
|
+
this.emit({ type: 'plugin:deactivated', pluginId });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Execute a plugin command
|
|
80
|
+
*/
|
|
81
|
+
async executeCommand(pluginId, commandId) {
|
|
82
|
+
const key = `${pluginId}:${commandId}`;
|
|
83
|
+
const entry = this.commands.get(key);
|
|
84
|
+
if (!entry)
|
|
85
|
+
throw new Error(`Command ${commandId} not found in plugin ${pluginId}`);
|
|
86
|
+
await entry.command.execute();
|
|
87
|
+
this.emit({ type: 'command:executed', pluginId, commandId });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get all registered commands with their plugins
|
|
91
|
+
*/
|
|
92
|
+
getAllCommands() {
|
|
93
|
+
return Array.from(this.commands.entries()).map(([key, { command }]) => {
|
|
94
|
+
const [pluginId] = key.split(':');
|
|
95
|
+
return { pluginId, command };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get commands for menu display (with shortcuts)
|
|
100
|
+
*/
|
|
101
|
+
getMenuCommands() {
|
|
102
|
+
const all = this.getAllCommands();
|
|
103
|
+
let counter = 9; // Start after built-in 1-8
|
|
104
|
+
return all.map(({ pluginId, command }) => ({
|
|
105
|
+
pluginId,
|
|
106
|
+
command,
|
|
107
|
+
num: command.shortcut || String(counter++),
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get all widgets grouped by position
|
|
112
|
+
*/
|
|
113
|
+
getWidgetsByPosition() {
|
|
114
|
+
const result = {
|
|
115
|
+
sidebar: [],
|
|
116
|
+
main: [],
|
|
117
|
+
'status-bar': [],
|
|
118
|
+
};
|
|
119
|
+
for (const { widget } of this.widgets.values()) {
|
|
120
|
+
result[widget.position].push(widget);
|
|
121
|
+
}
|
|
122
|
+
// Sort by priority (higher first)
|
|
123
|
+
Object.keys(result).forEach((pos) => {
|
|
124
|
+
result[pos].sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Process a log entry through all handlers
|
|
130
|
+
*/
|
|
131
|
+
processLog(entry) {
|
|
132
|
+
let result = entry;
|
|
133
|
+
for (const handlers of this.logHandlers.values()) {
|
|
134
|
+
for (const { handler } of handlers) {
|
|
135
|
+
// Check patterns
|
|
136
|
+
if (handler.servicePattern && !handler.servicePattern.test(result.service)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (handler.messagePattern && !handler.messagePattern.test(result.message)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
// Apply transform
|
|
143
|
+
if (handler.transform) {
|
|
144
|
+
result = handler.transform(result);
|
|
145
|
+
if (result === null)
|
|
146
|
+
return null; // Filtered out
|
|
147
|
+
}
|
|
148
|
+
// Apply enrich
|
|
149
|
+
if (handler.enrich) {
|
|
150
|
+
result = handler.enrich(result);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get plugin state
|
|
158
|
+
*/
|
|
159
|
+
getPluginState(pluginId) {
|
|
160
|
+
return this.pluginStates.get(pluginId);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Update plugin settings
|
|
164
|
+
*/
|
|
165
|
+
updatePluginSettings(pluginId, settings) {
|
|
166
|
+
const state = this.pluginStates.get(pluginId);
|
|
167
|
+
if (state) {
|
|
168
|
+
state.settings = { ...state.settings, ...settings };
|
|
169
|
+
this.pluginStates.set(pluginId, state);
|
|
170
|
+
const plugin = this.plugins.get(pluginId);
|
|
171
|
+
plugin?.onSettingsChange?.(state.settings);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Subscribe to plugin events
|
|
176
|
+
*/
|
|
177
|
+
subscribe(listener) {
|
|
178
|
+
this.listeners.push(listener);
|
|
179
|
+
return () => {
|
|
180
|
+
const index = this.listeners.indexOf(listener);
|
|
181
|
+
if (index > -1)
|
|
182
|
+
this.listeners.splice(index, 1);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get all registered plugin IDs
|
|
187
|
+
*/
|
|
188
|
+
getRegisteredPlugins() {
|
|
189
|
+
return Array.from(this.plugins.keys());
|
|
190
|
+
}
|
|
191
|
+
emit(event) {
|
|
192
|
+
this.listeners.forEach((listener) => listener(event));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=registry.js.map
|