@noyrax/5d-database-plugin 0.1.13-beta.1 → 0.1.14-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/out/api/adr-api.d.ts +0 -6
- package/out/api/adr-api.d.ts.map +1 -1
- package/out/api/adr-api.js +14 -49
- package/out/api/adr-api.js.map +1 -1
- package/out/api/bootstrap-api.d.ts +4 -1
- package/out/api/bootstrap-api.d.ts.map +1 -1
- package/out/api/bootstrap-api.js +27 -4
- package/out/api/bootstrap-api.js.map +1 -1
- package/out/api/context-builder.d.ts.map +1 -1
- package/out/api/context-builder.js +21 -5
- package/out/api/context-builder.js.map +1 -1
- package/out/api/evidence-grader.d.ts +83 -0
- package/out/api/evidence-grader.d.ts.map +1 -0
- package/out/api/evidence-grader.js +161 -0
- package/out/api/evidence-grader.js.map +1 -0
- package/out/api/index.d.ts +5 -0
- package/out/api/index.d.ts.map +1 -1
- package/out/api/index.js +11 -1
- package/out/api/index.js.map +1 -1
- package/out/api/learning-path-api.d.ts +3 -0
- package/out/api/learning-path-api.d.ts.map +1 -1
- package/out/api/learning-path-api.js +15 -2
- package/out/api/learning-path-api.js.map +1 -1
- package/out/api/module-api.d.ts +0 -1
- package/out/api/module-api.d.ts.map +1 -1
- package/out/api/module-api.js +4 -38
- package/out/api/module-api.js.map +1 -1
- package/out/api/self-explanation-api.d.ts +11 -1
- package/out/api/self-explanation-api.d.ts.map +1 -1
- package/out/api/self-explanation-api.js +285 -19
- package/out/api/self-explanation-api.js.map +1 -1
- package/out/api/semantic-search-api.d.ts +3 -0
- package/out/api/semantic-search-api.d.ts.map +1 -1
- package/out/api/semantic-search-api.js +41 -4
- package/out/api/semantic-search-api.js.map +1 -1
- package/out/api/source-access-contract-api.d.ts +60 -0
- package/out/api/source-access-contract-api.d.ts.map +1 -0
- package/out/api/source-access-contract-api.js +231 -0
- package/out/api/source-access-contract-api.js.map +1 -0
- package/out/api/source-snippet-api.d.ts +58 -0
- package/out/api/source-snippet-api.d.ts.map +1 -0
- package/out/api/source-snippet-api.js +187 -0
- package/out/api/source-snippet-api.js.map +1 -0
- package/out/api/vector-backend-status-api.d.ts +68 -0
- package/out/api/vector-backend-status-api.d.ts.map +1 -0
- package/out/api/vector-backend-status-api.js +241 -0
- package/out/api/vector-backend-status-api.js.map +1 -0
- package/out/cli/debug-embedding-strategies.d.ts +3 -0
- package/out/cli/debug-embedding-strategies.d.ts.map +1 -0
- package/out/cli/debug-embedding-strategies.js +255 -0
- package/out/cli/debug-embedding-strategies.js.map +1 -0
- package/out/cli/debug-plugin-id.d.ts +9 -0
- package/out/cli/debug-plugin-id.d.ts.map +1 -0
- package/out/cli/debug-plugin-id.js +188 -0
- package/out/cli/debug-plugin-id.js.map +1 -0
- package/out/cli/ingest-cli.js +44 -5
- package/out/cli/ingest-cli.js.map +1 -1
- package/out/cli/tool-cli.js +1 -1
- package/out/cli/tool-cli.js.map +1 -1
- package/out/core/chromadb-vector-database.d.ts.map +1 -1
- package/out/core/chromadb-vector-database.js +10 -12
- package/out/core/chromadb-vector-database.js.map +1 -1
- package/out/core/migration-manager.d.ts.map +1 -1
- package/out/core/migration-manager.js +61 -32
- package/out/core/migration-manager.js.map +1 -1
- package/out/core/multi-db-manager.d.ts +26 -0
- package/out/core/multi-db-manager.d.ts.map +1 -1
- package/out/core/multi-db-manager.js +143 -2
- package/out/core/multi-db-manager.js.map +1 -1
- package/out/core/path-normalizer.d.ts +46 -0
- package/out/core/path-normalizer.d.ts.map +1 -0
- package/out/core/path-normalizer.js +152 -0
- package/out/core/path-normalizer.js.map +1 -0
- package/out/core/vector-database-factory.js +5 -5
- package/out/core/vector-database-factory.js.map +1 -1
- package/out/core/vss-vector-database.js +8 -8
- package/out/core/vss-vector-database.js.map +1 -1
- package/out/embedding/embedding-pipeline.d.ts +18 -0
- package/out/embedding/embedding-pipeline.d.ts.map +1 -1
- package/out/embedding/embedding-pipeline.js +192 -3
- package/out/embedding/embedding-pipeline.js.map +1 -1
- package/out/embedding/module-summarizer.d.ts +25 -0
- package/out/embedding/module-summarizer.d.ts.map +1 -0
- package/out/embedding/module-summarizer.js +104 -0
- package/out/embedding/module-summarizer.js.map +1 -0
- package/out/ingestors/adr-ingestor.d.ts.map +1 -1
- package/out/ingestors/adr-ingestor.js +7 -8
- package/out/ingestors/adr-ingestor.js.map +1 -1
- package/out/ingestors/module-ingestor.d.ts.map +1 -1
- package/out/ingestors/module-ingestor.js +17 -0
- package/out/ingestors/module-ingestor.js.map +1 -1
- package/out/ingestors/symbol-ingestor.d.ts.map +1 -1
- package/out/ingestors/symbol-ingestor.js +24 -2
- package/out/ingestors/symbol-ingestor.js.map +1 -1
- package/out/mcp/tools/gap-analysis.d.ts +21 -2
- package/out/mcp/tools/gap-analysis.d.ts.map +1 -1
- package/out/mcp/tools/gap-analysis.js +326 -27
- package/out/mcp/tools/gap-analysis.js.map +1 -1
- package/out/mcp/tools/learning-path.d.ts.map +1 -1
- package/out/mcp/tools/learning-path.js +19 -5
- package/out/mcp/tools/learning-path.js.map +1 -1
- package/out/mcp/tools/semantic-discovery.d.ts.map +1 -1
- package/out/mcp/tools/semantic-discovery.js +110 -22
- package/out/mcp/tools/semantic-discovery.js.map +1 -1
- package/out/mcp/tools/source-access-contract.d.ts +26 -0
- package/out/mcp/tools/source-access-contract.d.ts.map +1 -0
- package/out/mcp/tools/source-access-contract.js +45 -0
- package/out/mcp/tools/source-access-contract.js.map +1 -0
- package/out/mcp/tools/source-snippet.d.ts +71 -0
- package/out/mcp/tools/source-snippet.d.ts.map +1 -0
- package/out/mcp/tools/source-snippet.js +82 -0
- package/out/mcp/tools/source-snippet.js.map +1 -0
- package/out/models/action-hint.d.ts +36 -0
- package/out/models/action-hint.d.ts.map +1 -0
- package/out/models/action-hint.js +38 -0
- package/out/models/action-hint.js.map +1 -0
- package/out/models/evidence.d.ts +68 -0
- package/out/models/evidence.d.ts.map +1 -0
- package/out/models/evidence.js +91 -0
- package/out/models/evidence.js.map +1 -0
- package/out/models/module.d.ts +2 -0
- package/out/models/module.d.ts.map +1 -1
- package/out/models/reason-codes.d.ts +52 -0
- package/out/models/reason-codes.d.ts.map +1 -0
- package/out/models/reason-codes.js +83 -0
- package/out/models/reason-codes.js.map +1 -0
- package/out/models/symbol.d.ts +6 -0
- package/out/models/symbol.d.ts.map +1 -1
- package/out/repositories/adr-repository.d.ts.map +1 -1
- package/out/repositories/adr-repository.js +2 -1
- package/out/repositories/adr-repository.js.map +1 -1
- package/out/repositories/module-repository.d.ts.map +1 -1
- package/out/repositories/module-repository.js +9 -3
- package/out/repositories/module-repository.js.map +1 -1
- package/out/repositories/symbol-repository.d.ts.map +1 -1
- package/out/repositories/symbol-repository.js +22 -4
- package/out/repositories/symbol-repository.js.map +1 -1
- package/out/services/cross-dimension-linker.d.ts.map +1 -1
- package/out/services/cross-dimension-linker.js +27 -3
- package/out/services/cross-dimension-linker.js.map +1 -1
- package/package.json +196 -195
- package/schemas/sqlite/001_add_source_code_spans_modules.sql +7 -0
- package/schemas/sqlite/001_z_add_source_code_spans_modules.sql +13 -0
- package/schemas/sqlite/002_add_source_code_spans_symbols.sql +15 -0
- package/schemas/sqlite/002_z_add_source_code_spans_symbols.sql +21 -0
- package/schemas/sqlite/006_add_source_access_config.sql +33 -0
|
@@ -99,6 +99,21 @@ class ModuleIngestor {
|
|
|
99
99
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
100
100
|
const contentHash = this.computeContentHash(content);
|
|
101
101
|
const sourceFilePath = this.extractSourceFilePath(path.basename(filePath), workspaceRoot);
|
|
102
|
+
// NEW: Capture file metadata from source file
|
|
103
|
+
let lineCount = null;
|
|
104
|
+
let byteSize = null;
|
|
105
|
+
try {
|
|
106
|
+
const sourceFileFullPath = path.join(workspaceRoot, sourceFilePath);
|
|
107
|
+
if (fs.existsSync(sourceFileFullPath)) {
|
|
108
|
+
const sourceContent = fs.readFileSync(sourceFileFullPath, 'utf-8');
|
|
109
|
+
const lines = sourceContent.split('\n');
|
|
110
|
+
lineCount = lines.length;
|
|
111
|
+
byteSize = Buffer.byteLength(sourceContent, 'utf-8');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// If source file not found or error reading, leave as null
|
|
116
|
+
}
|
|
102
117
|
const existing = await repository.getByFilePath(sourceFilePath, pluginId);
|
|
103
118
|
const now = new Date();
|
|
104
119
|
const module = {
|
|
@@ -107,6 +122,8 @@ class ModuleIngestor {
|
|
|
107
122
|
file_path: sourceFilePath,
|
|
108
123
|
content_hash: contentHash,
|
|
109
124
|
content_markdown: content,
|
|
125
|
+
line_count: lineCount,
|
|
126
|
+
byte_size: byteSize,
|
|
110
127
|
deleted_at: null,
|
|
111
128
|
created_at: existing?.created_at || now,
|
|
112
129
|
updated_at: now
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-ingestor.js","sourceRoot":"","sources":["../../src/ingestors/module-ingestor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AACjC,+BAAoC;AAIpC,yEAAqE;AAGrE;;GAEG;AACH,MAAa,cAAc;IAGvB,YAAY,SAAyB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAEM,YAAY;QACf,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,aAAqB,EAAE,QAAgB,EAAE,QAAgB;QAC7E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,C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CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,OAAe;QACtC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;CACJ;AAxID,wCAwIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-ingestor.d.ts","sourceRoot":"","sources":["../../src/ingestors/symbol-ingestor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D;;GAEG;AACH,qBAAa,cAAe,YAAW,YAAY;IAC/C,OAAO,CAAC,SAAS,CAAiB;gBAEtB,SAAS,EAAE,cAAc;IAI9B,YAAY,IAAI,SAAS;IAInB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BpF,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCxG;;OAEG;YACW,YAAY;
|
|
1
|
+
{"version":3,"file":"symbol-ingestor.d.ts","sourceRoot":"","sources":["../../src/ingestors/symbol-ingestor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D;;GAEG;AACH,qBAAa,cAAe,YAAW,YAAY;IAC/C,OAAO,CAAC,SAAS,CAAiB;gBAEtB,SAAS,EAAE,cAAc;IAI9B,YAAY,IAAI,SAAS;IAInB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BpF,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCxG;;OAEG;YACW,YAAY;IA8E1B;;OAEG;YACW,sBAAsB;IAiBpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAS/B"}
|
|
@@ -93,7 +93,7 @@ class SymbolIngestor {
|
|
|
93
93
|
continue;
|
|
94
94
|
}
|
|
95
95
|
const existing = await repository.getBySymbolId(symbolId, pluginId);
|
|
96
|
-
const signatureHash = this.computeSignatureHash(symbolData);
|
|
96
|
+
const signatureHash = symbolData.signature_hash || this.computeSignatureHash(symbolData);
|
|
97
97
|
if (existing && existing.signature_hash === signatureHash) {
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
@@ -123,8 +123,24 @@ class SymbolIngestor {
|
|
|
123
123
|
if (!symbolData.name) {
|
|
124
124
|
throw new Error(`Symbol missing required field 'name': ${JSON.stringify(symbolData)}`);
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
// Use signature_hash from symbolData if provided, otherwise compute it
|
|
127
|
+
const signatureHash = symbolData.signature_hash || this.computeSignatureHash(symbolData);
|
|
127
128
|
const existing = await repository.getBySymbolId(symbolId, pluginId);
|
|
129
|
+
// Legacy Cleanup: If ingesting a ts:// symbol, delete the corresponding unknown:// duplicate
|
|
130
|
+
if (symbolId.startsWith('ts://')) {
|
|
131
|
+
const legacySymbolId = symbolId.replace('ts://', 'unknown://');
|
|
132
|
+
const legacySymbol = await repository.getBySymbolId(legacySymbolId, pluginId);
|
|
133
|
+
if (legacySymbol) {
|
|
134
|
+
// Check if it's a true duplicate (same path + name + signature hash)
|
|
135
|
+
const isDuplicate = legacySymbol.path === symbolData.path &&
|
|
136
|
+
legacySymbol.name === symbolData.name &&
|
|
137
|
+
legacySymbol.signature_hash === signatureHash;
|
|
138
|
+
if (isDuplicate) {
|
|
139
|
+
await repository.delete(legacySymbol.id, pluginId);
|
|
140
|
+
console.log(`[SymbolIngestor] Cleaned up legacy symbol: ${legacySymbolId} (replaced by ${symbolId})`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
128
144
|
const now = new Date();
|
|
129
145
|
const symbol = {
|
|
130
146
|
id: existing?.id || (0, uuid_1.v4)(),
|
|
@@ -136,6 +152,12 @@ class SymbolIngestor {
|
|
|
136
152
|
signature_json: JSON.stringify(symbolData.signature || {}),
|
|
137
153
|
signature_hash: signatureHash,
|
|
138
154
|
summary: symbolData.summary || null,
|
|
155
|
+
start_line: symbolData.startLine ?? symbolData.start_line ?? null,
|
|
156
|
+
end_line: symbolData.endLine ?? symbolData.end_line ?? null,
|
|
157
|
+
start_col: symbolData.startCol ?? symbolData.start_col ?? null,
|
|
158
|
+
end_col: symbolData.endCol ?? symbolData.end_col ?? null,
|
|
159
|
+
byte_offset_start: symbolData.byteOffsetStart ?? symbolData.byte_offset_start ?? null,
|
|
160
|
+
byte_offset_end: symbolData.byteOffsetEnd ?? symbolData.byte_offset_end ?? null,
|
|
139
161
|
deleted_at: null,
|
|
140
162
|
created_at: existing?.created_at || now,
|
|
141
163
|
updated_at: now
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-ingestor.js","sourceRoot":"","sources":["../../src/ingestors/symbol-ingestor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AACjC,+BAAoC;AAIpC,yEAAqE;AAGrE;;GAEG;AACH,MAAa,cAAc;IAGvB,YAAY,SAAyB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CA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|
6
6
|
*/
|
|
7
7
|
export declare class GapAnalysisTool {
|
|
8
8
|
private crossDimensionApi;
|
|
9
|
+
private dependencyApi;
|
|
10
|
+
private adrApi;
|
|
11
|
+
private moduleApi;
|
|
9
12
|
private dbManager;
|
|
10
13
|
private idMapper;
|
|
11
14
|
private workspaceRoot;
|
|
@@ -14,7 +17,11 @@ export declare class GapAnalysisTool {
|
|
|
14
17
|
* Executes the gap_analysis tool.
|
|
15
18
|
*
|
|
16
19
|
* @param args Arguments: minDependencies (default: 5), pluginId, limit (default: 50), autoGenerateAdrs (default: false)
|
|
17
|
-
* @returns JSON string with gap analysis results
|
|
20
|
+
* @returns JSON string with gap analysis results including context information for ADR generation by KI-Agent
|
|
21
|
+
*
|
|
22
|
+
* Note: autoGenerateAdrs is false by default. When false, the tool provides context information
|
|
23
|
+
* (similar modules with ADRs, dependency details, cross-dimension context) to help the KI-Agent
|
|
24
|
+
* create ADRs according to the schema defined in .cursor/rules/022-adr-workflow.mdc
|
|
18
25
|
*/
|
|
19
26
|
execute(args: {
|
|
20
27
|
minDependencies?: number;
|
|
@@ -22,17 +29,29 @@ export declare class GapAnalysisTool {
|
|
|
22
29
|
limit?: number;
|
|
23
30
|
autoGenerateAdrs?: boolean;
|
|
24
31
|
}): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Builds context information for ADR generation by KI-Agent.
|
|
34
|
+
* Includes similar modules with ADRs, existing patterns, and cross-dimension context.
|
|
35
|
+
*/
|
|
36
|
+
private buildAdrGenerationContext;
|
|
25
37
|
/**
|
|
26
38
|
* Calculates a gap score for prioritization.
|
|
27
39
|
* Higher score = more urgent to document.
|
|
28
40
|
*
|
|
29
|
-
* Formula: (dependency_count * 2) - (adr_count * 10)
|
|
41
|
+
* Formula: (dependency_count * 2) - (adr_count * 10) - (hasApiDocs ? 50 : 0)
|
|
30
42
|
* This prioritizes modules with many dependencies but few ADRs.
|
|
43
|
+
* Module mit API-Docs sind bereits dokumentiert, daher großer Penalty (-50).
|
|
44
|
+
* Da buildArchitecturalView nur Module aus X-Dimension zurückgibt, haben alle Module API-Docs.
|
|
31
45
|
*/
|
|
32
46
|
private calculateGapScore;
|
|
33
47
|
/**
|
|
34
48
|
* Generates recommendations based on gaps.
|
|
35
49
|
*/
|
|
36
50
|
private generateRecommendations;
|
|
51
|
+
/**
|
|
52
|
+
* Fallback: Direct database queries when buildArchitecturalView returns empty.
|
|
53
|
+
* This handles cases where pluginId might not match or data structure differs.
|
|
54
|
+
*/
|
|
55
|
+
private fallbackDirectQuery;
|
|
37
56
|
}
|
|
38
57
|
//# sourceMappingURL=gap-analysis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gap-analysis.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/gap-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"gap-analysis.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/gap-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAK7D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;GAGG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,aAAa,CAAS;gBAElB,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM;IAUjF;;;;;;;;;OASG;IACU,OAAO,CAAC,IAAI,EAAE;QACvB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;IAgJnB;;;OAGG;YACW,yBAAyB;IAiHvC;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA0C/B;;;OAGG;YACW,mBAAmB;CAuHpC"}
|
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.GapAnalysisTool = void 0;
|
|
4
37
|
const cross_dimension_api_1 = require("../../api/cross-dimension-api");
|
|
38
|
+
const dependency_api_1 = require("../../api/dependency-api");
|
|
39
|
+
const adr_api_1 = require("../../api/adr-api");
|
|
40
|
+
const module_api_1 = require("../../api/module-api");
|
|
5
41
|
const adr_generator_1 = require("./adr-generator");
|
|
42
|
+
const path = __importStar(require("path"));
|
|
6
43
|
/**
|
|
7
44
|
* MCP Tool: gap_analysis
|
|
8
45
|
* Finds documentation gaps by analyzing modules with many dependencies but few/no ADRs.
|
|
@@ -10,6 +47,9 @@ const adr_generator_1 = require("./adr-generator");
|
|
|
10
47
|
class GapAnalysisTool {
|
|
11
48
|
constructor(dbManager, idMapper, workspaceRoot) {
|
|
12
49
|
this.crossDimensionApi = new cross_dimension_api_1.CrossDimensionApi(dbManager, idMapper);
|
|
50
|
+
this.dependencyApi = new dependency_api_1.DependencyApi(dbManager);
|
|
51
|
+
this.adrApi = new adr_api_1.AdrApi(dbManager);
|
|
52
|
+
this.moduleApi = new module_api_1.ModuleApi(dbManager);
|
|
13
53
|
this.dbManager = dbManager;
|
|
14
54
|
this.idMapper = idMapper;
|
|
15
55
|
this.workspaceRoot = workspaceRoot || process.cwd();
|
|
@@ -18,45 +58,108 @@ class GapAnalysisTool {
|
|
|
18
58
|
* Executes the gap_analysis tool.
|
|
19
59
|
*
|
|
20
60
|
* @param args Arguments: minDependencies (default: 5), pluginId, limit (default: 50), autoGenerateAdrs (default: false)
|
|
21
|
-
* @returns JSON string with gap analysis results
|
|
61
|
+
* @returns JSON string with gap analysis results including context information for ADR generation by KI-Agent
|
|
62
|
+
*
|
|
63
|
+
* Note: autoGenerateAdrs is false by default. When false, the tool provides context information
|
|
64
|
+
* (similar modules with ADRs, dependency details, cross-dimension context) to help the KI-Agent
|
|
65
|
+
* create ADRs according to the schema defined in .cursor/rules/022-adr-workflow.mdc
|
|
22
66
|
*/
|
|
23
67
|
async execute(args) {
|
|
24
68
|
const minDeps = args.minDependencies || 5;
|
|
25
69
|
const limit = args.limit || 50;
|
|
26
70
|
// Build architectural view (combines X, W, Z dimensions)
|
|
27
|
-
|
|
71
|
+
let architecturalView;
|
|
72
|
+
try {
|
|
73
|
+
architecturalView = await this.crossDimensionApi.buildArchitecturalView(args.pluginId);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(`[GapAnalysisTool] Failed to build architectural view: ${error?.message || String(error)}`);
|
|
77
|
+
// Return empty result with error info
|
|
78
|
+
return JSON.stringify({
|
|
79
|
+
summary: {
|
|
80
|
+
min_dependencies_threshold: minDeps,
|
|
81
|
+
analysis_date: new Date().toISOString(),
|
|
82
|
+
statistics: {
|
|
83
|
+
total_modules_analyzed: 0,
|
|
84
|
+
modules_with_many_deps: 0,
|
|
85
|
+
modules_without_adrs: 0,
|
|
86
|
+
modules_with_few_adrs: 0,
|
|
87
|
+
well_documented_modules: 0,
|
|
88
|
+
avg_dependencies: 0,
|
|
89
|
+
avg_adrs: 0
|
|
90
|
+
},
|
|
91
|
+
auto_generated_adrs: 0,
|
|
92
|
+
error: `Failed to build architectural view: ${error?.message || String(error)}`
|
|
93
|
+
},
|
|
94
|
+
gaps: {
|
|
95
|
+
without_adrs: [],
|
|
96
|
+
with_few_adrs: [],
|
|
97
|
+
well_documented: []
|
|
98
|
+
},
|
|
99
|
+
generated_adrs: [],
|
|
100
|
+
recommendations: [
|
|
101
|
+
`❌ Gap-Analyse fehlgeschlagen: ${error?.message || String(error)}`,
|
|
102
|
+
'Prüfe ob Datenbanken existieren und Ingestion ausgeführt wurde.',
|
|
103
|
+
'Führe `workflow/generate_and_ingest` aus, um Datenbanken zu aktualisieren.'
|
|
104
|
+
]
|
|
105
|
+
}, null, 2);
|
|
106
|
+
}
|
|
107
|
+
// Fallback: If architectural view is empty, try direct database queries
|
|
108
|
+
if (architecturalView.length === 0) {
|
|
109
|
+
return await this.fallbackDirectQuery(args.pluginId, minDeps, limit);
|
|
110
|
+
}
|
|
28
111
|
// Analyze gaps
|
|
29
|
-
const gaps = architecturalView
|
|
112
|
+
const gaps = await Promise.all(architecturalView
|
|
30
113
|
.filter(view => view.dependencies.length >= minDeps)
|
|
31
|
-
.map(view =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
114
|
+
.map(async (view) => {
|
|
115
|
+
// WICHTIG: buildArchitecturalView gibt nur Module aus X-Dimension zurück
|
|
116
|
+
// X-Dimension = docs/modules/ = alle Module haben bereits API-Docs
|
|
117
|
+
const hasApiDocs = true; // buildArchitecturalView gibt nur Module aus X-Dimension zurück
|
|
118
|
+
const baseGap = {
|
|
119
|
+
module: {
|
|
120
|
+
file_path: view.module.file_path,
|
|
121
|
+
content_hash: view.module.content_hash
|
|
122
|
+
},
|
|
123
|
+
dependency_count: view.dependencies.length,
|
|
124
|
+
adr_count: view.adrs.length,
|
|
125
|
+
adr_numbers: view.adrs.map(adr => adr.adr_number),
|
|
126
|
+
has_api_docs: hasApiDocs, // Immer true für Module in buildArchitecturalView
|
|
127
|
+
gap_score: this.calculateGapScore(view.dependencies.length, view.adrs.length, hasApiDocs),
|
|
128
|
+
has_adrs: view.adrs.length > 0,
|
|
129
|
+
// Modul ist dokumentiert wenn es API-Docs ODER ADRs hat
|
|
130
|
+
// Da alle Module API-Docs haben, sind alle dokumentiert
|
|
131
|
+
// ADRs sind nur für architektonische Entscheidungen nötig
|
|
132
|
+
is_documented: hasApiDocs || view.adrs.length > 0
|
|
133
|
+
};
|
|
134
|
+
// Add context information for modules without ADRs (for KI-Agent ADR generation)
|
|
135
|
+
if (!baseGap.has_adrs) {
|
|
136
|
+
const context = await this.buildAdrGenerationContext(view.module, view.dependencies, args.pluginId);
|
|
137
|
+
return {
|
|
138
|
+
...baseGap,
|
|
139
|
+
context_for_adr_generation: context
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return baseGap;
|
|
143
|
+
}));
|
|
144
|
+
// Sort by gap score (highest first) and limit
|
|
145
|
+
gaps.sort((a, b) => b.gap_score - a.gap_score);
|
|
146
|
+
const limitedGaps = gaps.slice(0, limit);
|
|
44
147
|
// Separate into categories
|
|
45
|
-
const withoutAdrs =
|
|
46
|
-
const withFewAdrs =
|
|
47
|
-
const wellDocumented =
|
|
148
|
+
const withoutAdrs = limitedGaps.filter(g => !g.has_adrs);
|
|
149
|
+
const withFewAdrs = limitedGaps.filter(g => g.has_adrs && g.adr_count < 2);
|
|
150
|
+
const wellDocumented = limitedGaps.filter(g => g.has_adrs && g.adr_count >= 2);
|
|
48
151
|
// Calculate statistics
|
|
49
152
|
const stats = {
|
|
50
153
|
total_modules_analyzed: architecturalView.length,
|
|
51
|
-
modules_with_many_deps:
|
|
154
|
+
modules_with_many_deps: limitedGaps.length,
|
|
52
155
|
modules_without_adrs: withoutAdrs.length,
|
|
53
156
|
modules_with_few_adrs: withFewAdrs.length,
|
|
54
157
|
well_documented_modules: wellDocumented.length,
|
|
55
|
-
avg_dependencies:
|
|
56
|
-
? Math.round(
|
|
158
|
+
avg_dependencies: limitedGaps.length > 0
|
|
159
|
+
? Math.round(limitedGaps.reduce((sum, g) => sum + g.dependency_count, 0) / limitedGaps.length)
|
|
57
160
|
: 0,
|
|
58
|
-
avg_adrs:
|
|
59
|
-
? Math.round(
|
|
161
|
+
avg_adrs: limitedGaps.length > 0 && limitedGaps.filter(g => g.has_adrs).length > 0
|
|
162
|
+
? Math.round(limitedGaps.filter(g => g.has_adrs).reduce((sum, g) => sum + g.adr_count, 0) / limitedGaps.filter(g => g.has_adrs).length)
|
|
60
163
|
: 0
|
|
61
164
|
};
|
|
62
165
|
// Auto-generate ADRs if requested
|
|
@@ -93,15 +196,109 @@ class GapAnalysisTool {
|
|
|
93
196
|
recommendations: this.generateRecommendations(withoutAdrs, withFewAdrs, generatedAdrs.length)
|
|
94
197
|
}, null, 2);
|
|
95
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Builds context information for ADR generation by KI-Agent.
|
|
201
|
+
* Includes similar modules with ADRs, existing patterns, and cross-dimension context.
|
|
202
|
+
*/
|
|
203
|
+
async buildAdrGenerationContext(module, dependencies, pluginId) {
|
|
204
|
+
const context = {
|
|
205
|
+
similar_modules_with_adrs: [],
|
|
206
|
+
existing_adr_patterns: [],
|
|
207
|
+
dependencies_details: [],
|
|
208
|
+
cross_dimension_context: {
|
|
209
|
+
symbols: [],
|
|
210
|
+
incoming_dependencies: 0,
|
|
211
|
+
outgoing_dependencies: dependencies.length
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
// 1. Find similar modules with ADRs (same directory or similar path structure)
|
|
216
|
+
const moduleDir = path.dirname(module.file_path);
|
|
217
|
+
const allModules = await this.moduleApi.getAllModules(pluginId);
|
|
218
|
+
// Get all ADRs and their file mappings
|
|
219
|
+
const adrDb = await this.dbManager.getDatabase('W');
|
|
220
|
+
const { AdrRepository } = await Promise.resolve().then(() => __importStar(require('../../repositories/adr-repository')));
|
|
221
|
+
const adrRepo = new AdrRepository(adrDb);
|
|
222
|
+
const allAdrs = await adrRepo.getAll(pluginId);
|
|
223
|
+
// Build map of file_path -> ADR numbers using file mappings
|
|
224
|
+
const adrsByPath = new Map();
|
|
225
|
+
for (const adr of allAdrs) {
|
|
226
|
+
const fileMappings = await adrRepo.getAdrFileMappings(adr.id);
|
|
227
|
+
for (const mapping of fileMappings) {
|
|
228
|
+
if (!adrsByPath.has(mapping.file_path)) {
|
|
229
|
+
adrsByPath.set(mapping.file_path, []);
|
|
230
|
+
}
|
|
231
|
+
adrsByPath.get(mapping.file_path).push(adr.adr_number);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Find modules in same directory or similar path structure with ADRs
|
|
235
|
+
for (const otherModule of allModules) {
|
|
236
|
+
if (otherModule.file_path === module.file_path)
|
|
237
|
+
continue;
|
|
238
|
+
const otherModuleDir = path.dirname(otherModule.file_path);
|
|
239
|
+
const hasAdrs = adrsByPath.has(otherModule.file_path);
|
|
240
|
+
// Similar if same directory or similar path depth
|
|
241
|
+
if (hasAdrs && (otherModuleDir === moduleDir ||
|
|
242
|
+
otherModuleDir.split(path.sep).length === moduleDir.split(path.sep).length)) {
|
|
243
|
+
context.similar_modules_with_adrs.push({
|
|
244
|
+
file_path: otherModule.file_path,
|
|
245
|
+
adr_numbers: adrsByPath.get(otherModule.file_path) || []
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Limit to top 5 similar modules
|
|
250
|
+
context.similar_modules_with_adrs = context.similar_modules_with_adrs.slice(0, 5);
|
|
251
|
+
// 2. Extract ADR patterns from similar modules
|
|
252
|
+
for (const similar of context.similar_modules_with_adrs) {
|
|
253
|
+
for (const adrNumber of similar.adr_numbers) {
|
|
254
|
+
const adr = await this.adrApi.getAdrByNumber(adrNumber, pluginId);
|
|
255
|
+
if (adr) {
|
|
256
|
+
// Extract pattern: first line of decision or context
|
|
257
|
+
const pattern = adr.content_markdown?.split('\n').find((line) => line.trim().startsWith('## Entscheidung') ||
|
|
258
|
+
line.trim().startsWith('## Kontext')) || 'ADR pattern';
|
|
259
|
+
context.existing_adr_patterns.push({
|
|
260
|
+
adr_number: adrNumber,
|
|
261
|
+
pattern: pattern.substring(0, 100) // Limit length
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Limit to top 10 patterns
|
|
267
|
+
context.existing_adr_patterns = context.existing_adr_patterns.slice(0, 10);
|
|
268
|
+
// 3. Get detailed dependencies information
|
|
269
|
+
context.dependencies_details = dependencies.map(dep => ({
|
|
270
|
+
to_module: dep.to_module || dep.toModule || '',
|
|
271
|
+
dependency_type: dep.dependency_type || dep.dependencyType || 'import'
|
|
272
|
+
}));
|
|
273
|
+
// 4. Get incoming dependencies count
|
|
274
|
+
const incomingDeps = await this.dependencyApi.getDependenciesByToModule(module.file_path, pluginId);
|
|
275
|
+
context.cross_dimension_context.incoming_dependencies = incomingDeps.length;
|
|
276
|
+
// 5. Get symbols for cross-dimension context
|
|
277
|
+
const symbols = await this.crossDimensionApi.getSymbolsForModule(module.file_path, pluginId);
|
|
278
|
+
context.cross_dimension_context.symbols = symbols.slice(0, 20).map((sym) => ({
|
|
279
|
+
name: sym.name || sym.symbol_name || '',
|
|
280
|
+
type: sym.type || sym.symbol_type || ''
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
console.warn(`[GapAnalysisTool] Failed to build ADR generation context for ${module.file_path}: ${error?.message || String(error)}`);
|
|
285
|
+
}
|
|
286
|
+
return context;
|
|
287
|
+
}
|
|
96
288
|
/**
|
|
97
289
|
* Calculates a gap score for prioritization.
|
|
98
290
|
* Higher score = more urgent to document.
|
|
99
291
|
*
|
|
100
|
-
* Formula: (dependency_count * 2) - (adr_count * 10)
|
|
292
|
+
* Formula: (dependency_count * 2) - (adr_count * 10) - (hasApiDocs ? 50 : 0)
|
|
101
293
|
* This prioritizes modules with many dependencies but few ADRs.
|
|
294
|
+
* Module mit API-Docs sind bereits dokumentiert, daher großer Penalty (-50).
|
|
295
|
+
* Da buildArchitecturalView nur Module aus X-Dimension zurückgibt, haben alle Module API-Docs.
|
|
102
296
|
*/
|
|
103
|
-
calculateGapScore(dependencyCount, adrCount) {
|
|
104
|
-
|
|
297
|
+
calculateGapScore(dependencyCount, adrCount, hasApiDocs = false) {
|
|
298
|
+
const baseScore = (dependencyCount * 2) - (adrCount * 10);
|
|
299
|
+
// Module mit API-Docs sind dokumentiert, großer Penalty
|
|
300
|
+
// Da alle Module in buildArchitecturalView API-Docs haben, wird dieser Penalty immer angewendet
|
|
301
|
+
return hasApiDocs ? baseScore - 50 : baseScore;
|
|
105
302
|
}
|
|
106
303
|
/**
|
|
107
304
|
* Generates recommendations based on gaps.
|
|
@@ -123,11 +320,113 @@ class GapAnalysisTool {
|
|
|
123
320
|
if (generatedCount > 0) {
|
|
124
321
|
recommendations.push(`\n✅ ${generatedCount} ADR(s) wurden automatisch generiert.`);
|
|
125
322
|
}
|
|
323
|
+
else if (withoutAdrs.length > 0) {
|
|
324
|
+
recommendations.push(`\n💡 Nutze die Kontext-Informationen (context_for_adr_generation) für jedes Modul, um ADRs nach Schema zu erstellen (siehe .cursor/rules/022-adr-workflow.mdc).`);
|
|
325
|
+
}
|
|
126
326
|
if (recommendations.length === 0) {
|
|
127
327
|
recommendations.push('✅ Alle Module mit vielen Dependencies sind gut dokumentiert!');
|
|
128
328
|
}
|
|
129
329
|
return recommendations;
|
|
130
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Fallback: Direct database queries when buildArchitecturalView returns empty.
|
|
333
|
+
* This handles cases where pluginId might not match or data structure differs.
|
|
334
|
+
*/
|
|
335
|
+
async fallbackDirectQuery(pluginId, minDeps, limit) {
|
|
336
|
+
const moduleDb = await this.dbManager.getDatabase('X');
|
|
337
|
+
const depDb = await this.dbManager.getDatabase('Z');
|
|
338
|
+
const adrDb = await this.dbManager.getDatabase('W');
|
|
339
|
+
const { ModuleRepository } = await Promise.resolve().then(() => __importStar(require('../../repositories/module-repository')));
|
|
340
|
+
const { DependencyRepository } = await Promise.resolve().then(() => __importStar(require('../../repositories/dependency-repository')));
|
|
341
|
+
const { AdrRepository } = await Promise.resolve().then(() => __importStar(require('../../repositories/adr-repository')));
|
|
342
|
+
const moduleRepo = new ModuleRepository(moduleDb);
|
|
343
|
+
const depRepo = new DependencyRepository(depDb);
|
|
344
|
+
const adrRepo = new AdrRepository(adrDb);
|
|
345
|
+
// Get all modules
|
|
346
|
+
const modules = await moduleRepo.getAll(pluginId);
|
|
347
|
+
// Get dependency counts per module
|
|
348
|
+
const depCounts = new Map();
|
|
349
|
+
const allDeps = await depRepo.getAll(pluginId);
|
|
350
|
+
for (const dep of allDeps) {
|
|
351
|
+
const count = depCounts.get(dep.from_module) || 0;
|
|
352
|
+
depCounts.set(dep.from_module, count + 1);
|
|
353
|
+
}
|
|
354
|
+
// Build gaps with context information
|
|
355
|
+
const gaps = [];
|
|
356
|
+
for (const module of modules) {
|
|
357
|
+
const depCount = depCounts.get(module.file_path) || 0;
|
|
358
|
+
if (depCount >= minDeps) {
|
|
359
|
+
const adrs = await adrRepo.findByFilePath(module.file_path, pluginId);
|
|
360
|
+
const dependencies = await depRepo.findByFromModule(module.file_path, pluginId);
|
|
361
|
+
// WICHTIG: Module aus X-Dimension haben bereits API-Docs
|
|
362
|
+
// X-Dimension = docs/modules/ = alle Module haben bereits API-Docs
|
|
363
|
+
const hasApiDocs = true; // Module aus X-Dimension haben immer API-Docs
|
|
364
|
+
const baseGap = {
|
|
365
|
+
module: {
|
|
366
|
+
file_path: module.file_path,
|
|
367
|
+
content_hash: module.content_hash
|
|
368
|
+
},
|
|
369
|
+
dependency_count: depCount,
|
|
370
|
+
adr_count: adrs.length,
|
|
371
|
+
adr_numbers: adrs.map(adr => adr.adr_number),
|
|
372
|
+
has_api_docs: hasApiDocs, // Immer true für Module aus X-Dimension
|
|
373
|
+
gap_score: this.calculateGapScore(depCount, adrs.length, hasApiDocs),
|
|
374
|
+
has_adrs: adrs.length > 0,
|
|
375
|
+
// Modul ist dokumentiert wenn es API-Docs ODER ADRs hat
|
|
376
|
+
is_documented: hasApiDocs || adrs.length > 0
|
|
377
|
+
};
|
|
378
|
+
// Add context information for modules without ADRs
|
|
379
|
+
if (!baseGap.has_adrs) {
|
|
380
|
+
const context = await this.buildAdrGenerationContext(module, dependencies, pluginId);
|
|
381
|
+
gaps.push({
|
|
382
|
+
...baseGap,
|
|
383
|
+
context_for_adr_generation: context
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
gaps.push(baseGap);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Sort by gap score
|
|
392
|
+
gaps.sort((a, b) => b.gap_score - a.gap_score);
|
|
393
|
+
const limitedGaps = gaps.slice(0, limit);
|
|
394
|
+
// Separate into categories
|
|
395
|
+
const withoutAdrs = limitedGaps.filter(g => !g.has_adrs);
|
|
396
|
+
const withFewAdrs = limitedGaps.filter(g => g.has_adrs && g.adr_count < 2);
|
|
397
|
+
const wellDocumented = limitedGaps.filter(g => g.has_adrs && g.adr_count >= 2);
|
|
398
|
+
// Calculate statistics
|
|
399
|
+
const stats = {
|
|
400
|
+
total_modules_analyzed: modules.length,
|
|
401
|
+
modules_with_many_deps: limitedGaps.length,
|
|
402
|
+
modules_without_adrs: withoutAdrs.length,
|
|
403
|
+
modules_with_few_adrs: withFewAdrs.length,
|
|
404
|
+
well_documented_modules: wellDocumented.length,
|
|
405
|
+
avg_dependencies: limitedGaps.length > 0
|
|
406
|
+
? Math.round(limitedGaps.reduce((sum, g) => sum + g.dependency_count, 0) / limitedGaps.length)
|
|
407
|
+
: 0,
|
|
408
|
+
avg_adrs: limitedGaps.length > 0 && limitedGaps.filter(g => g.has_adrs).length > 0
|
|
409
|
+
? Math.round(limitedGaps.filter(g => g.has_adrs).reduce((sum, g) => sum + g.adr_count, 0) / limitedGaps.filter(g => g.has_adrs).length)
|
|
410
|
+
: 0
|
|
411
|
+
};
|
|
412
|
+
return JSON.stringify({
|
|
413
|
+
summary: {
|
|
414
|
+
min_dependencies_threshold: minDeps,
|
|
415
|
+
analysis_date: new Date().toISOString(),
|
|
416
|
+
statistics: stats,
|
|
417
|
+
auto_generated_adrs: 0,
|
|
418
|
+
fallback_used: true,
|
|
419
|
+
note: 'Fallback direct database queries used (buildArchitecturalView returned empty)'
|
|
420
|
+
},
|
|
421
|
+
gaps: {
|
|
422
|
+
without_adrs: withoutAdrs,
|
|
423
|
+
with_few_adrs: withFewAdrs,
|
|
424
|
+
well_documented: wellDocumented
|
|
425
|
+
},
|
|
426
|
+
generated_adrs: [],
|
|
427
|
+
recommendations: this.generateRecommendations(withoutAdrs, withFewAdrs, 0)
|
|
428
|
+
}, null, 2);
|
|
429
|
+
}
|
|
131
430
|
}
|
|
132
431
|
exports.GapAnalysisTool = GapAnalysisTool;
|
|
133
432
|
//# sourceMappingURL=gap-analysis.js.map
|