@principal-ai/codebase-composition 0.2.7 → 0.2.9
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.
|
@@ -17,12 +17,11 @@ export declare class QualityMetricsCalculator {
|
|
|
17
17
|
private static applyFallbackDetection;
|
|
18
18
|
/**
|
|
19
19
|
* Calculate quality metrics from detected lenses
|
|
20
|
+
* @param detectedLenses - Map of detected lens IDs to lens info
|
|
21
|
+
* @param lensScores - Optional map of lens IDs to real quality scores (0-100)
|
|
22
|
+
* @returns Partial quality metrics hexagon with scores for available lenses
|
|
20
23
|
*/
|
|
21
|
-
static calculateMetrics(detectedLenses: Map<string, DetectedLens>): Partial<QualityMetrics>;
|
|
22
|
-
/**
|
|
23
|
-
* Calculate a mock score for a lens (placeholder for real implementation)
|
|
24
|
-
*/
|
|
25
|
-
private static calculateMockScore;
|
|
24
|
+
static calculateMetrics(detectedLenses: Map<string, DetectedLens>, lensScores?: Map<string, number>): Partial<QualityMetrics>;
|
|
26
25
|
/**
|
|
27
26
|
* Get list of available lenses
|
|
28
27
|
*/
|
|
@@ -33,8 +32,11 @@ export declare class QualityMetricsCalculator {
|
|
|
33
32
|
static getMissingLenses(detectedLenses: Map<string, DetectedLens>): string[];
|
|
34
33
|
/**
|
|
35
34
|
* Full calculation - convenience method
|
|
35
|
+
* @param commands - Package commands to analyze
|
|
36
|
+
* @param lensScores - Optional map of lens IDs to real quality scores (0-100)
|
|
37
|
+
* @returns Quality profile with hexagon, available lenses, and missing lenses
|
|
36
38
|
*/
|
|
37
|
-
static calculateQualityProfile(commands: PackageCommand[]): {
|
|
39
|
+
static calculateQualityProfile(commands: PackageCommand[], lensScores?: Map<string, number>): {
|
|
38
40
|
hexagon: Partial<QualityMetrics>;
|
|
39
41
|
availableLenses: string[];
|
|
40
42
|
missingLenses: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QualityMetricsCalculator.d.ts","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"QualityMetricsCalculator.d.ts","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAmE1F,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAChC;AAED,qBAAa,wBAAwB;IACnC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC;IAoChF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA0BrC;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CACrB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EACzC,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,cAAc,CAAC;IAkB1B;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,EAAE;IAI9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,EAAE;IAK5E;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAC5B,QAAQ,EAAE,cAAc,EAAE,EAC1B,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;CAanC"}
|
|
@@ -25,9 +25,10 @@ const LENS_TO_METRIC_MAP = {
|
|
|
25
25
|
// Documentation
|
|
26
26
|
'typedoc': 'documentation',
|
|
27
27
|
'jsdoc': 'documentation',
|
|
28
|
+
'alexandria': 'documentation',
|
|
28
29
|
};
|
|
29
30
|
// Standard lenses we expect to find
|
|
30
|
-
const STANDARD_LENSES = ['eslint', 'typescript', 'test', 'prettier', 'knip', 'typedoc'];
|
|
31
|
+
const STANDARD_LENSES = ['eslint', 'typescript', 'test', 'prettier', 'knip', 'typedoc', 'alexandria'];
|
|
31
32
|
// Fallback patterns for common script names
|
|
32
33
|
const SCRIPT_TO_LENS_MAP = {
|
|
33
34
|
// Linting
|
|
@@ -48,7 +49,8 @@ const SCRIPT_TO_LENS_MAP = {
|
|
|
48
49
|
'knip': 'knip',
|
|
49
50
|
'unused': 'knip',
|
|
50
51
|
// Documentation
|
|
51
|
-
'docs': '
|
|
52
|
+
'docs': 'alexandria',
|
|
53
|
+
'alexandria': 'alexandria',
|
|
52
54
|
'typedoc': 'typedoc',
|
|
53
55
|
};
|
|
54
56
|
export class QualityMetricsCalculator {
|
|
@@ -109,36 +111,24 @@ export class QualityMetricsCalculator {
|
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
113
|
* Calculate quality metrics from detected lenses
|
|
114
|
+
* @param detectedLenses - Map of detected lens IDs to lens info
|
|
115
|
+
* @param lensScores - Optional map of lens IDs to real quality scores (0-100)
|
|
116
|
+
* @returns Partial quality metrics hexagon with scores for available lenses
|
|
112
117
|
*/
|
|
113
|
-
static calculateMetrics(detectedLenses) {
|
|
118
|
+
static calculateMetrics(detectedLenses, lensScores) {
|
|
114
119
|
const metrics = {};
|
|
115
|
-
for (const [lensId
|
|
120
|
+
for (const [lensId] of detectedLenses) {
|
|
116
121
|
const metricKey = LENS_TO_METRIC_MAP[lensId];
|
|
117
122
|
if (metricKey) {
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
// Use real score if provided
|
|
124
|
+
const score = lensScores?.get(lensId);
|
|
125
|
+
if (score !== undefined) {
|
|
126
|
+
metrics[metricKey] = score;
|
|
127
|
+
}
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
130
|
return metrics;
|
|
124
131
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Calculate a mock score for a lens (placeholder for real implementation)
|
|
127
|
-
*/
|
|
128
|
-
static calculateMockScore(lens) {
|
|
129
|
-
// Mock scoring logic:
|
|
130
|
-
// - Has check operation: base score of 75
|
|
131
|
-
// - Has coverage operation: +15 points
|
|
132
|
-
// - Max score: 90 (reserve 100 for perfect real scores)
|
|
133
|
-
let score = 0;
|
|
134
|
-
if (lens.operations.has('check')) {
|
|
135
|
-
score += 75;
|
|
136
|
-
}
|
|
137
|
-
if (lens.operations.has('coverage')) {
|
|
138
|
-
score += 15;
|
|
139
|
-
}
|
|
140
|
-
return Math.min(score, 90);
|
|
141
|
-
}
|
|
142
132
|
/**
|
|
143
133
|
* Get list of available lenses
|
|
144
134
|
*/
|
|
@@ -154,10 +144,13 @@ export class QualityMetricsCalculator {
|
|
|
154
144
|
}
|
|
155
145
|
/**
|
|
156
146
|
* Full calculation - convenience method
|
|
147
|
+
* @param commands - Package commands to analyze
|
|
148
|
+
* @param lensScores - Optional map of lens IDs to real quality scores (0-100)
|
|
149
|
+
* @returns Quality profile with hexagon, available lenses, and missing lenses
|
|
157
150
|
*/
|
|
158
|
-
static calculateQualityProfile(commands) {
|
|
151
|
+
static calculateQualityProfile(commands, lensScores) {
|
|
159
152
|
const detectedLenses = this.detectLensCommands(commands);
|
|
160
|
-
const hexagon = this.calculateMetrics(detectedLenses);
|
|
153
|
+
const hexagon = this.calculateMetrics(detectedLenses, lensScores);
|
|
161
154
|
const availableLenses = this.getAvailableLenses(detectedLenses);
|
|
162
155
|
const missingLenses = this.getMissingLenses(detectedLenses);
|
|
163
156
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QualityMetricsCalculator.js","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,4DAA4D;AAC5D,MAAM,kBAAkB,GAAyC;IAC/D,gBAAgB;IAChB,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IAEnB,sBAAsB;IACtB,YAAY,EAAE,OAAO;IACrB,MAAM,EAAE,OAAO;IAEf,gBAAgB;IAChB,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,OAAO;IACrB,SAAS,EAAE,OAAO;IAElB,mBAAmB;IACnB,UAAU,EAAE,YAAY;IAExB,sBAAsB;IACtB,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,UAAU;IAEtB,gBAAgB;IAChB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"QualityMetricsCalculator.js","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,4DAA4D;AAC5D,MAAM,kBAAkB,GAAyC;IAC/D,gBAAgB;IAChB,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IAEnB,sBAAsB;IACtB,YAAY,EAAE,OAAO;IACrB,MAAM,EAAE,OAAO;IAEf,gBAAgB;IAChB,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,OAAO;IACrB,SAAS,EAAE,OAAO;IAElB,mBAAmB;IACnB,UAAU,EAAE,YAAY;IAExB,sBAAsB;IACtB,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,UAAU;IAEtB,gBAAgB;IAChB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,eAAe;CAC9B,CAAC;AAEF,oCAAoC;AACpC,M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UAAU,CAAC,CAAC;QAClE,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAChE,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAE5D,OAAO;YACL,OAAO;YACP,eAAe;YACf,aAAa;SACd,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principal-ai/codebase-composition",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Codebase decomposition into semantic layers",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"typecheck": "tsc --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@principal-ai/repository-abstraction": "^0.2.
|
|
22
|
+
"@principal-ai/repository-abstraction": "^0.2.2",
|
|
23
23
|
"ignore": "^5.3.0",
|
|
24
24
|
"js-toml": "^1.0.0",
|
|
25
25
|
"pip-requirements-js": "^0.2.1",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/principal-ai/
|
|
35
|
+
"url": "git+https://github.com/principal-ai/codebase-composition.git",
|
|
36
36
|
"directory": "packages/codebase-composition"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|