@principal-ai/codebase-composition 0.2.24 → 0.2.27
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/helpers/QualityMetricsCalculator.d.ts +26 -7
- package/dist/helpers/QualityMetricsCalculator.d.ts.map +1 -1
- package/dist/helpers/QualityMetricsCalculator.js +129 -131
- package/dist/helpers/QualityMetricsCalculator.js.map +1 -1
- package/dist/helpers/WorkspaceCommandHelper.d.ts +140 -0
- package/dist/helpers/WorkspaceCommandHelper.d.ts.map +1 -0
- package/dist/helpers/WorkspaceCommandHelper.js +298 -0
- package/dist/helpers/WorkspaceCommandHelper.js.map +1 -0
- package/dist/helpers/packageLayerHelpers.d.ts.map +1 -1
- package/dist/helpers/packageLayerHelpers.js +50 -24
- package/dist/helpers/packageLayerHelpers.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/PackageLayerModule.d.ts.map +1 -1
- package/dist/modules/PackageLayerModule.js +169 -3
- package/dist/modules/PackageLayerModule.js.map +1 -1
- package/dist/strategies/go-tools.d.ts +27 -0
- package/dist/strategies/go-tools.d.ts.map +1 -0
- package/dist/strategies/go-tools.js +185 -0
- package/dist/strategies/go-tools.js.map +1 -0
- package/dist/strategies/index.d.ts +37 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +73 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/node-tools.d.ts +21 -0
- package/dist/strategies/node-tools.d.ts.map +1 -0
- package/dist/strategies/node-tools.js +142 -0
- package/dist/strategies/node-tools.js.map +1 -0
- package/dist/strategies/python-tools.d.ts +25 -0
- package/dist/strategies/python-tools.d.ts.map +1 -0
- package/dist/strategies/python-tools.js +192 -0
- package/dist/strategies/python-tools.js.map +1 -0
- package/dist/strategies/rust-tools.d.ts +23 -0
- package/dist/strategies/rust-tools.d.ts.map +1 -0
- package/dist/strategies/rust-tools.js +177 -0
- package/dist/strategies/rust-tools.js.map +1 -0
- package/dist/strategies/tool-detection.d.ts +137 -0
- package/dist/strategies/tool-detection.d.ts.map +1 -0
- package/dist/strategies/tool-detection.js +13 -0
- package/dist/strategies/tool-detection.js.map +1 -0
- package/package.json +2 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { PackageCommand, QualityMetrics, LensOperation, ConfigFile } from '../types/layer-types';
|
|
5
5
|
import { type LensReadiness } from '@principal-ai/codebase-quality-lenses';
|
|
6
|
+
import { type Ecosystem, type PackageData, type ToolAvailability, type InstallInstruction } from '../strategies';
|
|
6
7
|
interface DetectedLens {
|
|
7
8
|
lensId: string;
|
|
8
9
|
operations: Set<LensOperation>;
|
|
@@ -48,18 +49,36 @@ export declare class QualityMetricsCalculator {
|
|
|
48
49
|
missingLenses: string[];
|
|
49
50
|
};
|
|
50
51
|
/**
|
|
51
|
-
*
|
|
52
|
-
* Checks package data against lens requirements
|
|
52
|
+
* Extended lens readiness result with ecosystem-aware install instructions
|
|
53
53
|
*/
|
|
54
|
-
static calculateLensReadiness(
|
|
54
|
+
static calculateLensReadiness(packageType: 'package' | 'node' | 'python' | 'cargo' | 'go', packageData: PackageData, configFiles: Record<string, ConfigFile | undefined>, lensIds?: string[]): Record<string, LensReadinessExtended>;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Get install instructions for a tool in a specific ecosystem
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
static getToolInstallInstructions(toolId: string, packageType: 'package' | 'node' | 'python' | 'cargo' | 'go', packageManager?: string): InstallInstruction;
|
|
59
59
|
/**
|
|
60
|
-
* Check if a
|
|
60
|
+
* Check if a tool is available in a package using ecosystem-specific detection
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
static checkToolAvailability(toolId: string, packageType: 'package' | 'node' | 'python' | 'cargo' | 'go', packageData: PackageData, configFiles: Record<string, ConfigFile | undefined>): ToolAvailability;
|
|
63
|
+
/**
|
|
64
|
+
* Get the default command to run a tool
|
|
65
|
+
*/
|
|
66
|
+
static getToolDefaultCommand(toolId: string, packageType: 'package' | 'node' | 'python' | 'cargo' | 'go'): string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extended lens readiness with ecosystem-specific information
|
|
70
|
+
*/
|
|
71
|
+
export interface LensReadinessExtended extends LensReadiness {
|
|
72
|
+
/** The ecosystem this tool belongs to */
|
|
73
|
+
ecosystem: Ecosystem;
|
|
74
|
+
/** Detailed tool availability information */
|
|
75
|
+
toolAvailability: ToolAvailability;
|
|
76
|
+
/** Ecosystem-appropriate install instructions */
|
|
77
|
+
installInstructions: InstallInstruction;
|
|
78
|
+
/** Default command to run the tool */
|
|
79
|
+
defaultCommand: string;
|
|
80
|
+
/** Whether this is a built-in toolchain tool */
|
|
81
|
+
isToolchainTool: boolean;
|
|
63
82
|
}
|
|
64
83
|
export {};
|
|
65
84
|
//# sourceMappingURL=QualityMetricsCalculator.d.ts.map
|
|
@@ -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,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,
|
|
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,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,uCAAuC,CAAC;AAM/C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAA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EG;IACH,MAAM,CAAC,0BAA0B,CAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,EAC3D,cAAc,CAAC,EAAE,MAAM,GACtB,kBAAkB;IAMrB;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,EAC3D,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC,GAClD,gBAAgB;IAMnB;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,GAC1D,MAAM;CAKV;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,yCAAyC;IACzC,SAAS,EAAE,SAAS,CAAC;IAErB,6CAA6C;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,iDAAiD;IACjD,mBAAmB,EAAE,kBAAkB,CAAC;IAExC,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;IAEvB,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -2,35 +2,26 @@
|
|
|
2
2
|
* Calculate quality metrics from lens commands
|
|
3
3
|
*/
|
|
4
4
|
import { ALL_LENS_REQUIREMENTS, } from '@principal-ai/codebase-quality-lenses';
|
|
5
|
+
import { getLensDisplayName, getHexagonMetricForCategory, LENS_REGISTRY, } from '@principal-ai/quality-lens-registry';
|
|
6
|
+
import { getToolDetectionStrategy, packageTypeToEcosystem, } from '../strategies/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build lens-to-metric map from registry
|
|
9
|
+
*/
|
|
10
|
+
function buildLensToMetricMap() {
|
|
11
|
+
const map = {};
|
|
12
|
+
// Build from registry
|
|
13
|
+
for (const lens of LENS_REGISTRY) {
|
|
14
|
+
const hexagonKey = getHexagonMetricForCategory(lens.category);
|
|
15
|
+
if (hexagonKey) {
|
|
16
|
+
map[lens.id] = hexagonKey;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Alias for generic 'test' script name
|
|
20
|
+
map['test'] = 'tests';
|
|
21
|
+
return map;
|
|
22
|
+
}
|
|
5
23
|
// Standard lens IDs and their corresponding hexagon metrics
|
|
6
|
-
const LENS_TO_METRIC_MAP =
|
|
7
|
-
// Linting tools
|
|
8
|
-
'eslint': 'linting',
|
|
9
|
-
'biome': 'linting',
|
|
10
|
-
'biome-lint': 'linting',
|
|
11
|
-
'oxlint': 'linting',
|
|
12
|
-
// Type checking tools
|
|
13
|
-
'typescript': 'types',
|
|
14
|
-
'flow': 'types',
|
|
15
|
-
// Testing tools
|
|
16
|
-
'test': 'tests',
|
|
17
|
-
'jest': 'tests',
|
|
18
|
-
'vitest': 'tests',
|
|
19
|
-
'bun-test': 'tests',
|
|
20
|
-
'mocha': 'tests',
|
|
21
|
-
'playwright': 'tests',
|
|
22
|
-
'cypress': 'tests',
|
|
23
|
-
// Formatting tools
|
|
24
|
-
'prettier': 'formatting',
|
|
25
|
-
'biome-format': 'formatting',
|
|
26
|
-
// Dead code detection
|
|
27
|
-
'knip': 'deadCode',
|
|
28
|
-
'depcheck': 'deadCode',
|
|
29
|
-
// Documentation
|
|
30
|
-
'typedoc': 'documentation',
|
|
31
|
-
'jsdoc': 'documentation',
|
|
32
|
-
'alexandria': 'documentation',
|
|
33
|
-
};
|
|
24
|
+
const LENS_TO_METRIC_MAP = buildLensToMetricMap();
|
|
34
25
|
// Patterns to detect specific tools from script content
|
|
35
26
|
// Maps regex patterns to lens IDs
|
|
36
27
|
const SCRIPT_CONTENT_PATTERNS = [
|
|
@@ -44,25 +35,48 @@ const SCRIPT_CONTENT_PATTERNS = [
|
|
|
44
35
|
{ pattern: /\bvitest\b/, lensId: 'vitest' },
|
|
45
36
|
// Jest
|
|
46
37
|
{ pattern: /\bjest\b/, lensId: 'jest' },
|
|
38
|
+
// Python tools
|
|
39
|
+
{ pattern: /\bruff\s+(check|lint)\b/, lensId: 'ruff' },
|
|
40
|
+
{ pattern: /\bruff\s+format\b/, lensId: 'ruff-format' },
|
|
41
|
+
{ pattern: /\bmypy\b/, lensId: 'mypy' },
|
|
42
|
+
{ pattern: /\bpytest\b/, lensId: 'pytest' },
|
|
43
|
+
{ pattern: /\bpython\s+-m\s+pytest\b/, lensId: 'pytest' },
|
|
44
|
+
{ pattern: /\bblack\b/, lensId: 'black' },
|
|
45
|
+
{ pattern: /\bisort\b/, lensId: 'isort' },
|
|
46
|
+
{ pattern: /\bflake8\b/, lensId: 'flake8' },
|
|
47
|
+
{ pattern: /\bpylint\b/, lensId: 'pylint' },
|
|
48
|
+
{ pattern: /\bpyright\b/, lensId: 'pyright' },
|
|
47
49
|
];
|
|
48
50
|
// Standard lenses we expect to find
|
|
49
51
|
const STANDARD_LENSES = ['eslint', 'typescript', 'test', 'prettier', 'knip', 'typedoc', 'alexandria'];
|
|
50
52
|
// Fallback patterns for common script names
|
|
51
53
|
const SCRIPT_TO_LENS_MAP = {
|
|
52
|
-
// Linting
|
|
54
|
+
// Linting (JavaScript/TypeScript)
|
|
53
55
|
'lint': 'eslint',
|
|
54
56
|
'eslint': 'eslint',
|
|
55
|
-
//
|
|
57
|
+
// Linting (Python)
|
|
58
|
+
'ruff': 'ruff',
|
|
59
|
+
'flake8': 'flake8',
|
|
60
|
+
'pylint': 'pylint',
|
|
61
|
+
// Type checking (JavaScript/TypeScript)
|
|
56
62
|
'typecheck': 'typescript',
|
|
57
63
|
'type-check': 'typescript',
|
|
58
64
|
'tsc': 'typescript',
|
|
59
|
-
//
|
|
65
|
+
// Type checking (Python)
|
|
66
|
+
'mypy': 'mypy',
|
|
67
|
+
'pyright': 'pyright',
|
|
68
|
+
// Testing (JavaScript/TypeScript)
|
|
60
69
|
'test': 'test',
|
|
61
70
|
'jest': 'jest',
|
|
62
71
|
'vitest': 'vitest',
|
|
63
|
-
//
|
|
72
|
+
// Testing (Python)
|
|
73
|
+
'pytest': 'pytest',
|
|
74
|
+
// Formatting (JavaScript/TypeScript)
|
|
64
75
|
'format': 'prettier',
|
|
65
76
|
'prettier': 'prettier',
|
|
77
|
+
// Formatting (Python)
|
|
78
|
+
'black': 'black',
|
|
79
|
+
'isort': 'isort',
|
|
66
80
|
// Dead code
|
|
67
81
|
'knip': 'knip',
|
|
68
82
|
'unused': 'knip',
|
|
@@ -128,7 +142,9 @@ export class QualityMetricsCalculator {
|
|
|
128
142
|
let lensId = this.detectLensFromScriptContent(command.description);
|
|
129
143
|
// Fall back to script name mapping
|
|
130
144
|
if (!lensId) {
|
|
131
|
-
|
|
145
|
+
// Try exact match first, then base name (before colon suffix like :ci, :coverage)
|
|
146
|
+
const baseName = command.name.split(':')[0];
|
|
147
|
+
lensId = SCRIPT_TO_LENS_MAP[command.name] || SCRIPT_TO_LENS_MAP[baseName] || null;
|
|
132
148
|
}
|
|
133
149
|
if (lensId) {
|
|
134
150
|
if (!detectedLenses.has(lensId)) {
|
|
@@ -197,116 +213,98 @@ export class QualityMetricsCalculator {
|
|
|
197
213
|
missingLenses
|
|
198
214
|
};
|
|
199
215
|
}
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Strategy-based tool detection (multi-ecosystem support)
|
|
218
|
+
// ============================================================================
|
|
200
219
|
/**
|
|
201
|
-
*
|
|
202
|
-
* Checks package data against lens requirements
|
|
220
|
+
* Extended lens readiness result with ecosystem-aware install instructions
|
|
203
221
|
*/
|
|
204
|
-
static calculateLensReadiness(
|
|
222
|
+
static calculateLensReadiness(packageType, packageData, configFiles, lensIds) {
|
|
223
|
+
const ecosystem = packageTypeToEcosystem(packageType);
|
|
224
|
+
const strategy = getToolDetectionStrategy(ecosystem);
|
|
205
225
|
const result = {};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const missing = [];
|
|
217
|
-
const allDeps = { ...dependencies, ...devDependencies };
|
|
218
|
-
// Check devDependencies
|
|
219
|
-
for (const req of requirements.devDependencies) {
|
|
220
|
-
const version = devDependencies[req.name] || dependencies[req.name];
|
|
221
|
-
const satisfied = !!version;
|
|
226
|
+
// Get tools to check - either specified or all from ALL_LENS_REQUIREMENTS
|
|
227
|
+
const toolsToCheck = lensIds ?? Object.keys(ALL_LENS_REQUIREMENTS);
|
|
228
|
+
for (const lensId of toolsToCheck) {
|
|
229
|
+
const availability = strategy.detectToolAvailability(lensId, packageData, configFiles);
|
|
230
|
+
const installInstructions = strategy.getInstallInstructions(lensId, packageData.packageManager);
|
|
231
|
+
const defaultCommand = strategy.getDefaultCommand(lensId);
|
|
232
|
+
const isToolchain = strategy.isToolchainTool(lensId);
|
|
233
|
+
// Build checks array from availability
|
|
234
|
+
const checks = [];
|
|
235
|
+
// Check for tool installation
|
|
222
236
|
checks.push({
|
|
223
|
-
requirement:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
// Check scripts - strict matching by script name only
|
|
232
|
-
// The commandPattern is used for validation, not discovery
|
|
233
|
-
for (const req of requirements.scripts) {
|
|
234
|
-
const matchingCommand = commands.find(cmd => {
|
|
235
|
-
// Only match by exact script name
|
|
236
|
-
return cmd.name === req.name;
|
|
237
|
+
requirement: {
|
|
238
|
+
type: 'devDependency',
|
|
239
|
+
name: lensId,
|
|
240
|
+
critical: true,
|
|
241
|
+
},
|
|
242
|
+
satisfied: availability.installed,
|
|
243
|
+
foundValue: availability.version,
|
|
237
244
|
});
|
|
238
|
-
|
|
245
|
+
// Check for configuration
|
|
239
246
|
checks.push({
|
|
240
|
-
requirement:
|
|
241
|
-
|
|
242
|
-
|
|
247
|
+
requirement: {
|
|
248
|
+
type: 'config',
|
|
249
|
+
name: `${lensId} config`,
|
|
250
|
+
critical: false,
|
|
251
|
+
},
|
|
252
|
+
satisfied: availability.configured,
|
|
253
|
+
foundValue: configFiles[lensId]?.path,
|
|
243
254
|
});
|
|
244
|
-
|
|
245
|
-
|
|
255
|
+
// Determine missing requirements
|
|
256
|
+
const missing = [];
|
|
257
|
+
if (!availability.installed && !isToolchain) {
|
|
258
|
+
missing.push({
|
|
259
|
+
type: 'devDependency',
|
|
260
|
+
name: lensId,
|
|
261
|
+
critical: true,
|
|
262
|
+
suggestedFix: installInstructions.command,
|
|
263
|
+
});
|
|
246
264
|
}
|
|
265
|
+
// Overall readiness
|
|
266
|
+
const ready = availability.installed || isToolchain;
|
|
267
|
+
const partial = !ready && availability.configured;
|
|
268
|
+
result[lensId] = {
|
|
269
|
+
lensId,
|
|
270
|
+
displayName: getLensDisplayName(lensId) ?? lensId,
|
|
271
|
+
ready,
|
|
272
|
+
partial,
|
|
273
|
+
checks,
|
|
274
|
+
missing,
|
|
275
|
+
// Extended fields
|
|
276
|
+
ecosystem,
|
|
277
|
+
toolAvailability: availability,
|
|
278
|
+
installInstructions,
|
|
279
|
+
defaultCommand,
|
|
280
|
+
isToolchainTool: isToolchain,
|
|
281
|
+
};
|
|
247
282
|
}
|
|
248
|
-
|
|
249
|
-
for (const req of requirements.configs) {
|
|
250
|
-
let satisfied = false;
|
|
251
|
-
let foundValue;
|
|
252
|
-
// Check against configFiles object
|
|
253
|
-
if (configFiles) {
|
|
254
|
-
// Try the primary config name (e.g., 'eslint' for eslint.config.js)
|
|
255
|
-
const lensConfigKey = requirements.lensId;
|
|
256
|
-
const configFile = configFiles[lensConfigKey];
|
|
257
|
-
if (configFile?.exists) {
|
|
258
|
-
satisfied = true;
|
|
259
|
-
foundValue = configFile.path;
|
|
260
|
-
}
|
|
261
|
-
// Check alternatives if not found
|
|
262
|
-
if (!satisfied && req.alternatives) {
|
|
263
|
-
for (const alt of req.alternatives) {
|
|
264
|
-
// Check if any config file matches the alternative pattern
|
|
265
|
-
for (const [, cf] of Object.entries(configFiles)) {
|
|
266
|
-
if (cf?.exists && cf.path && this.matchesConfigPattern(cf.path, alt)) {
|
|
267
|
-
satisfied = true;
|
|
268
|
-
foundValue = cf.path;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (satisfied)
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
checks.push({
|
|
278
|
-
requirement: req,
|
|
279
|
-
satisfied,
|
|
280
|
-
foundValue,
|
|
281
|
-
});
|
|
282
|
-
if (!satisfied && req.critical !== false) {
|
|
283
|
-
missing.push(req);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
// Determine overall readiness
|
|
287
|
-
const criticalMissing = missing.filter(m => m.critical !== false);
|
|
288
|
-
const ready = criticalMissing.length === 0;
|
|
289
|
-
const partial = !ready && checks.some(c => c.satisfied);
|
|
290
|
-
return {
|
|
291
|
-
lensId: requirements.lensId,
|
|
292
|
-
displayName: requirements.displayName,
|
|
293
|
-
ready,
|
|
294
|
-
partial,
|
|
295
|
-
checks,
|
|
296
|
-
missing,
|
|
297
|
-
};
|
|
283
|
+
return result;
|
|
298
284
|
}
|
|
299
285
|
/**
|
|
300
|
-
*
|
|
286
|
+
* Get install instructions for a tool in a specific ecosystem
|
|
301
287
|
*/
|
|
302
|
-
static
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
288
|
+
static getToolInstallInstructions(toolId, packageType, packageManager) {
|
|
289
|
+
const ecosystem = packageTypeToEcosystem(packageType);
|
|
290
|
+
const strategy = getToolDetectionStrategy(ecosystem);
|
|
291
|
+
return strategy.getInstallInstructions(toolId, packageManager);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Check if a tool is available in a package using ecosystem-specific detection
|
|
295
|
+
*/
|
|
296
|
+
static checkToolAvailability(toolId, packageType, packageData, configFiles) {
|
|
297
|
+
const ecosystem = packageTypeToEcosystem(packageType);
|
|
298
|
+
const strategy = getToolDetectionStrategy(ecosystem);
|
|
299
|
+
return strategy.detectToolAvailability(toolId, packageData, configFiles);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get the default command to run a tool
|
|
303
|
+
*/
|
|
304
|
+
static getToolDefaultCommand(toolId, packageType) {
|
|
305
|
+
const ecosystem = packageTypeToEcosystem(packageType);
|
|
306
|
+
const strategy = getToolDetectionStrategy(ecosystem);
|
|
307
|
+
return strategy.getDefaultCommand(toolId);
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
310
|
//# sourceMappingURL=QualityMetricsCalculator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QualityMetricsCalculator.js","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"QualityMetricsCalculator.js","sourceRoot":"","sources":["../../src/helpers/QualityMetricsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,qBAAqB,GAItB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAKL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAyC,EAAE,CAAC;IAErD,sBAAsB;IACtB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,CAAC,IAA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D,EAC3D,WAAwB,EACxB,WAAmD;QAEnD,MAAM,SAAS,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAC1B,MAAc,EACd,WAA2D;QAE3D,MAAM,SAAS,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Command Helper
|
|
3
|
+
*
|
|
4
|
+
* Handles workspace-aware command execution for monorepos.
|
|
5
|
+
* Detects workspace commands, groups packages by workspace,
|
|
6
|
+
* and provides utilities for distributing results to packages.
|
|
7
|
+
*
|
|
8
|
+
* Supports:
|
|
9
|
+
* - Cargo workspaces (--workspace, --manifest-path)
|
|
10
|
+
* - npm/pnpm workspaces (--workspaces, -w, --recursive)
|
|
11
|
+
* - Yarn workspaces
|
|
12
|
+
*/
|
|
13
|
+
import type { PackageLayer } from '../types/layer-types';
|
|
14
|
+
/**
|
|
15
|
+
* Ecosystem types for workspace detection
|
|
16
|
+
*/
|
|
17
|
+
export type WorkspaceEcosystem = 'rust' | 'node' | 'python' | 'go';
|
|
18
|
+
/**
|
|
19
|
+
* Information about a workspace command
|
|
20
|
+
*/
|
|
21
|
+
export interface WorkspaceCommandInfo {
|
|
22
|
+
/** Whether this command targets an entire workspace */
|
|
23
|
+
isWorkspaceCommand: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The workspace root directory extracted from the command
|
|
26
|
+
* e.g., "codex-rs" from "--manifest-path codex-rs/Cargo.toml"
|
|
27
|
+
*/
|
|
28
|
+
workspaceRoot?: string;
|
|
29
|
+
/** The ecosystem this command belongs to */
|
|
30
|
+
ecosystem?: WorkspaceEcosystem;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A group of packages that belong to the same workspace
|
|
34
|
+
*/
|
|
35
|
+
export interface WorkspaceGroup {
|
|
36
|
+
/** The workspace root directory (relative to repo root) */
|
|
37
|
+
workspaceRoot: string;
|
|
38
|
+
/** Path to the workspace manifest file */
|
|
39
|
+
manifestPath: string;
|
|
40
|
+
/** The ecosystem (rust, node, etc.) */
|
|
41
|
+
ecosystem: WorkspaceEcosystem;
|
|
42
|
+
/** Packages that are members of this workspace */
|
|
43
|
+
memberPackages: PackageLayer[];
|
|
44
|
+
/** The root package of the workspace (if it exists as a package) */
|
|
45
|
+
rootPackage?: PackageLayer;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Detect if a command is a workspace-wide command and extract workspace info.
|
|
49
|
+
*
|
|
50
|
+
* Detects:
|
|
51
|
+
* - Cargo: --workspace, --manifest-path
|
|
52
|
+
* - pnpm: -r, --recursive, -w, --workspace-root, --filter
|
|
53
|
+
* - npm: --workspaces, -ws
|
|
54
|
+
* - yarn: workspaces foreach
|
|
55
|
+
*
|
|
56
|
+
* @param command - The command being executed (e.g., "cargo", "pnpm")
|
|
57
|
+
* @param args - Command arguments as an array
|
|
58
|
+
* @returns WorkspaceCommandInfo with detection results
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // Cargo workspace command
|
|
63
|
+
* detectWorkspaceCommand('cargo', ['clippy', '--manifest-path', 'codex-rs/Cargo.toml', '--workspace'])
|
|
64
|
+
* // => { isWorkspaceCommand: true, workspaceRoot: 'codex-rs', ecosystem: 'rust' }
|
|
65
|
+
*
|
|
66
|
+
* // pnpm recursive command
|
|
67
|
+
* detectWorkspaceCommand('pnpm', ['-r', 'run', 'lint'])
|
|
68
|
+
* // => { isWorkspaceCommand: true, ecosystem: 'node' }
|
|
69
|
+
*
|
|
70
|
+
* // Regular command (not workspace-wide)
|
|
71
|
+
* detectWorkspaceCommand('cargo', ['clippy'])
|
|
72
|
+
* // => { isWorkspaceCommand: false }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function detectWorkspaceCommand(command: string, args: string[]): WorkspaceCommandInfo;
|
|
76
|
+
/**
|
|
77
|
+
* Group discovered packages by their workspace.
|
|
78
|
+
*
|
|
79
|
+
* Uses the package's `isWorkspace`, `parentPackage`, and `isMonorepoRoot`
|
|
80
|
+
* fields to determine workspace membership.
|
|
81
|
+
*
|
|
82
|
+
* @param packages - Array of discovered packages
|
|
83
|
+
* @returns Array of workspace groups
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const packages = await packageModule.discoverPackages(fileTree);
|
|
88
|
+
* const workspaceGroups = groupPackagesByWorkspace(packages);
|
|
89
|
+
*
|
|
90
|
+
* for (const group of workspaceGroups) {
|
|
91
|
+
* console.log(`Workspace: ${group.workspaceRoot}`);
|
|
92
|
+
* console.log(`Members: ${group.memberPackages.map(p => p.packageData.name)}`);
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function groupPackagesByWorkspace(packages: PackageLayer[]): WorkspaceGroup[];
|
|
97
|
+
/**
|
|
98
|
+
* Match a file path to its package within a workspace.
|
|
99
|
+
*
|
|
100
|
+
* Used to distribute lens results to the correct packages.
|
|
101
|
+
* Takes a file path (relative to workspace root) and finds
|
|
102
|
+
* which package it belongs to.
|
|
103
|
+
*
|
|
104
|
+
* @param filePath - File path relative to workspace root (e.g., "protocol/src/lib.rs")
|
|
105
|
+
* @param workspaceRoot - Workspace root directory (e.g., "codex-rs")
|
|
106
|
+
* @param packages - Array of packages to search
|
|
107
|
+
* @returns The matching package, or undefined if not found
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* // Clippy outputs: "protocol/src/lib.rs" (relative to codex-rs/)
|
|
112
|
+
* // We need to find which package this belongs to
|
|
113
|
+
*
|
|
114
|
+
* const pkg = matchPathToPackage(
|
|
115
|
+
* 'protocol/src/lib.rs',
|
|
116
|
+
* 'codex-rs',
|
|
117
|
+
* packages
|
|
118
|
+
* );
|
|
119
|
+
* // => PackageLayer for "codex-rs/protocol"
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function matchPathToPackage(filePath: string, workspaceRoot: string, packages: PackageLayer[]): PackageLayer | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Prefix a file path with the workspace root.
|
|
125
|
+
*
|
|
126
|
+
* Utility function to convert paths from workspace-relative
|
|
127
|
+
* to repo-relative.
|
|
128
|
+
*
|
|
129
|
+
* @param filePath - File path relative to workspace root
|
|
130
|
+
* @param workspaceRoot - Workspace root directory
|
|
131
|
+
* @returns Full path relative to repo root
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* prefixWithWorkspaceRoot('protocol/src/lib.rs', 'codex-rs')
|
|
136
|
+
* // => 'codex-rs/protocol/src/lib.rs'
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function prefixWithWorkspaceRoot(filePath: string, workspaceRoot: string): string;
|
|
140
|
+
//# sourceMappingURL=WorkspaceCommandHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceCommandHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/WorkspaceCommandHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW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