@principal-ai/quality-lens-registry 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,677 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CATEGORY_CONFIGS: () => CATEGORY_CONFIGS,
24
+ LANGUAGE_CONFIGS: () => LANGUAGE_CONFIGS,
25
+ LENS_REGISTRY: () => LENS_REGISTRY,
26
+ areLensesAlternatives: () => areLensesAlternatives,
27
+ detectLanguageFromExtension: () => detectLanguageFromExtension,
28
+ findCategoryConflicts: () => findCategoryConflicts,
29
+ getAlternatives: () => getAlternatives,
30
+ getCategoryConfig: () => getCategoryConfig,
31
+ getCategoryDisplayName: () => getCategoryDisplayName,
32
+ getCategoryForLens: () => getCategoryForLens,
33
+ getColorModeForCategory: () => getColorModeForCategory,
34
+ getLanguageConfig: () => getLanguageConfig,
35
+ getLanguagesForCategory: () => getLanguagesForCategory,
36
+ getLensById: () => getLensById,
37
+ getLensColorScheme: () => getLensColorScheme,
38
+ getLensDisplayName: () => getLensDisplayName,
39
+ getLensesByCategory: () => getLensesByCategory,
40
+ getLensesByCategoryAndLanguage: () => getLensesByCategoryAndLanguage,
41
+ getLensesByLanguage: () => getLensesByLanguage,
42
+ getLensesWithAggregates: () => getLensesWithAggregates,
43
+ getLensesWithFileMetrics: () => getLensesWithFileMetrics,
44
+ isCategoryInverted: () => isCategoryInverted,
45
+ isValidLensId: () => isValidLensId,
46
+ validateLensOutputs: () => validateLensOutputs
47
+ });
48
+ module.exports = __toCommonJS(index_exports);
49
+
50
+ // src/registry.ts
51
+ var LENS_REGISTRY = [
52
+ // ============================================================
53
+ // LINTING - Code style and bug detection
54
+ // ============================================================
55
+ // TypeScript/JavaScript linting
56
+ {
57
+ id: "eslint",
58
+ name: "ESLint",
59
+ category: "linting",
60
+ languages: ["typescript", "javascript"],
61
+ outputsFileMetrics: true,
62
+ outputsAggregate: true,
63
+ colorScheme: "issues",
64
+ description: "Pluggable linting utility for JavaScript and TypeScript",
65
+ command: "eslint"
66
+ },
67
+ {
68
+ id: "biome-lint",
69
+ name: "Biome Lint",
70
+ category: "linting",
71
+ languages: ["typescript", "javascript"],
72
+ alternativeTo: ["eslint"],
73
+ outputsFileMetrics: true,
74
+ outputsAggregate: true,
75
+ colorScheme: "issues",
76
+ description: "Fast linter for JavaScript and TypeScript",
77
+ command: "biome lint"
78
+ },
79
+ {
80
+ id: "oxlint",
81
+ name: "OxLint",
82
+ category: "linting",
83
+ languages: ["typescript", "javascript"],
84
+ alternativeTo: ["eslint", "biome-lint"],
85
+ outputsFileMetrics: true,
86
+ outputsAggregate: true,
87
+ colorScheme: "issues",
88
+ description: "Blazing fast JavaScript/TypeScript linter",
89
+ command: "oxlint"
90
+ },
91
+ // Python linting
92
+ {
93
+ id: "ruff",
94
+ name: "Ruff",
95
+ category: "linting",
96
+ languages: ["python"],
97
+ alternativeTo: ["pylint", "flake8"],
98
+ outputsFileMetrics: true,
99
+ outputsAggregate: true,
100
+ colorScheme: "issues",
101
+ description: "Extremely fast Python linter",
102
+ command: "ruff check"
103
+ },
104
+ {
105
+ id: "pylint",
106
+ name: "Pylint",
107
+ category: "linting",
108
+ languages: ["python"],
109
+ outputsFileMetrics: true,
110
+ outputsAggregate: true,
111
+ colorScheme: "issues",
112
+ description: "Python static code analyzer",
113
+ command: "pylint"
114
+ },
115
+ // Go linting
116
+ {
117
+ id: "golangci-lint",
118
+ name: "golangci-lint",
119
+ category: "linting",
120
+ languages: ["go"],
121
+ outputsFileMetrics: true,
122
+ outputsAggregate: true,
123
+ colorScheme: "issues",
124
+ description: "Fast linters runner for Go",
125
+ command: "golangci-lint run"
126
+ },
127
+ // Rust linting
128
+ {
129
+ id: "clippy",
130
+ name: "Clippy",
131
+ category: "linting",
132
+ languages: ["rust"],
133
+ outputsFileMetrics: true,
134
+ outputsAggregate: true,
135
+ colorScheme: "issues",
136
+ description: "Rust linter",
137
+ command: "cargo clippy"
138
+ },
139
+ // ============================================================
140
+ // FORMATTING - Code formatting
141
+ // ============================================================
142
+ // TypeScript/JavaScript formatting
143
+ {
144
+ id: "prettier",
145
+ name: "Prettier",
146
+ category: "formatting",
147
+ languages: ["typescript", "javascript"],
148
+ outputsFileMetrics: true,
149
+ outputsAggregate: true,
150
+ colorScheme: "binary",
151
+ description: "Opinionated code formatter",
152
+ command: "prettier --check"
153
+ },
154
+ {
155
+ id: "biome-format",
156
+ name: "Biome Format",
157
+ category: "formatting",
158
+ languages: ["typescript", "javascript"],
159
+ alternativeTo: ["prettier"],
160
+ outputsFileMetrics: true,
161
+ outputsAggregate: true,
162
+ colorScheme: "binary",
163
+ description: "Fast code formatter for JavaScript and TypeScript",
164
+ command: "biome format"
165
+ },
166
+ // Python formatting
167
+ {
168
+ id: "black",
169
+ name: "Black",
170
+ category: "formatting",
171
+ languages: ["python"],
172
+ outputsFileMetrics: true,
173
+ outputsAggregate: true,
174
+ colorScheme: "binary",
175
+ description: "The uncompromising Python code formatter",
176
+ command: "black --check"
177
+ },
178
+ {
179
+ id: "ruff-format",
180
+ name: "Ruff Format",
181
+ category: "formatting",
182
+ languages: ["python"],
183
+ alternativeTo: ["black"],
184
+ outputsFileMetrics: true,
185
+ outputsAggregate: true,
186
+ colorScheme: "binary",
187
+ description: "Fast Python formatter (Ruff)",
188
+ command: "ruff format --check"
189
+ },
190
+ // Go formatting
191
+ {
192
+ id: "gofmt",
193
+ name: "gofmt",
194
+ category: "formatting",
195
+ languages: ["go"],
196
+ outputsFileMetrics: true,
197
+ outputsAggregate: true,
198
+ colorScheme: "binary",
199
+ description: "Go code formatter",
200
+ command: "gofmt -l"
201
+ },
202
+ // Rust formatting
203
+ {
204
+ id: "rustfmt",
205
+ name: "rustfmt",
206
+ category: "formatting",
207
+ languages: ["rust"],
208
+ outputsFileMetrics: true,
209
+ outputsAggregate: true,
210
+ colorScheme: "binary",
211
+ description: "Rust code formatter",
212
+ command: "cargo fmt --check"
213
+ },
214
+ // ============================================================
215
+ // TYPES - Type checking
216
+ // ============================================================
217
+ // TypeScript
218
+ {
219
+ id: "typescript",
220
+ name: "TypeScript",
221
+ category: "types",
222
+ languages: ["typescript"],
223
+ outputsFileMetrics: true,
224
+ outputsAggregate: true,
225
+ colorScheme: "issues",
226
+ description: "TypeScript type checker",
227
+ command: "tsc --noEmit"
228
+ },
229
+ // Python type checking
230
+ {
231
+ id: "mypy",
232
+ name: "MyPy",
233
+ category: "types",
234
+ languages: ["python"],
235
+ outputsFileMetrics: true,
236
+ outputsAggregate: true,
237
+ colorScheme: "issues",
238
+ description: "Static type checker for Python",
239
+ command: "mypy"
240
+ },
241
+ {
242
+ id: "pyright",
243
+ name: "Pyright",
244
+ category: "types",
245
+ languages: ["python"],
246
+ alternativeTo: ["mypy"],
247
+ outputsFileMetrics: true,
248
+ outputsAggregate: true,
249
+ colorScheme: "issues",
250
+ description: "Static type checker for Python",
251
+ command: "pyright"
252
+ },
253
+ // Go type checking (built into compiler)
254
+ {
255
+ id: "go-vet",
256
+ name: "Go Vet",
257
+ category: "types",
258
+ languages: ["go"],
259
+ outputsFileMetrics: true,
260
+ outputsAggregate: true,
261
+ colorScheme: "issues",
262
+ description: "Go static analyzer",
263
+ command: "go vet"
264
+ },
265
+ // ============================================================
266
+ // TESTS - Test coverage and results
267
+ // ============================================================
268
+ // JavaScript/TypeScript testing
269
+ {
270
+ id: "jest",
271
+ name: "Jest",
272
+ category: "tests",
273
+ languages: ["typescript", "javascript"],
274
+ outputsFileMetrics: true,
275
+ outputsAggregate: true,
276
+ colorScheme: "coverage",
277
+ description: "JavaScript testing framework",
278
+ command: "jest --coverage"
279
+ },
280
+ {
281
+ id: "vitest",
282
+ name: "Vitest",
283
+ category: "tests",
284
+ languages: ["typescript", "javascript"],
285
+ alternativeTo: ["jest"],
286
+ outputsFileMetrics: true,
287
+ outputsAggregate: true,
288
+ colorScheme: "coverage",
289
+ description: "Vite-native testing framework",
290
+ command: "vitest run --coverage"
291
+ },
292
+ {
293
+ id: "bun-test",
294
+ name: "Bun Test",
295
+ category: "tests",
296
+ languages: ["typescript", "javascript"],
297
+ alternativeTo: ["jest", "vitest"],
298
+ outputsFileMetrics: true,
299
+ outputsAggregate: true,
300
+ colorScheme: "coverage",
301
+ description: "Bun native test runner",
302
+ command: "bun test"
303
+ },
304
+ // Python testing
305
+ {
306
+ id: "pytest",
307
+ name: "Pytest",
308
+ category: "tests",
309
+ languages: ["python"],
310
+ outputsFileMetrics: true,
311
+ outputsAggregate: true,
312
+ colorScheme: "coverage",
313
+ description: "Python testing framework",
314
+ command: "pytest --cov"
315
+ },
316
+ // Go testing
317
+ {
318
+ id: "go-test",
319
+ name: "Go Test",
320
+ category: "tests",
321
+ languages: ["go"],
322
+ outputsFileMetrics: true,
323
+ outputsAggregate: true,
324
+ colorScheme: "coverage",
325
+ description: "Go test runner",
326
+ command: "go test -cover"
327
+ },
328
+ // Rust testing
329
+ {
330
+ id: "cargo-test",
331
+ name: "Cargo Test",
332
+ category: "tests",
333
+ languages: ["rust"],
334
+ outputsFileMetrics: true,
335
+ outputsAggregate: true,
336
+ colorScheme: "coverage",
337
+ description: "Rust test runner",
338
+ command: "cargo test"
339
+ },
340
+ // ============================================================
341
+ // DEAD CODE - Unused code detection
342
+ // ============================================================
343
+ // TypeScript/JavaScript
344
+ {
345
+ id: "knip",
346
+ name: "Knip",
347
+ category: "dead-code",
348
+ languages: ["typescript", "javascript"],
349
+ outputsFileMetrics: true,
350
+ outputsAggregate: true,
351
+ colorScheme: "issues",
352
+ description: "Find unused files, dependencies and exports",
353
+ command: "knip"
354
+ },
355
+ // Python
356
+ {
357
+ id: "vulture",
358
+ name: "Vulture",
359
+ category: "dead-code",
360
+ languages: ["python"],
361
+ outputsFileMetrics: true,
362
+ outputsAggregate: true,
363
+ colorScheme: "issues",
364
+ description: "Find dead Python code",
365
+ command: "vulture"
366
+ },
367
+ // ============================================================
368
+ // DOCUMENTATION - Documentation coverage
369
+ // ============================================================
370
+ {
371
+ id: "alexandria",
372
+ name: "Alexandria",
373
+ category: "documentation",
374
+ languages: ["typescript", "javascript"],
375
+ outputsFileMetrics: true,
376
+ outputsAggregate: true,
377
+ colorScheme: "binary",
378
+ description: "Documentation coverage checker",
379
+ command: "alexandria lint"
380
+ },
381
+ {
382
+ id: "typedoc",
383
+ name: "TypeDoc",
384
+ category: "documentation",
385
+ languages: ["typescript"],
386
+ outputsFileMetrics: false,
387
+ outputsAggregate: true,
388
+ colorScheme: "coverage",
389
+ description: "TypeScript documentation generator",
390
+ command: "typedoc"
391
+ },
392
+ // ============================================================
393
+ // SECURITY - Security scanning
394
+ // ============================================================
395
+ {
396
+ id: "npm-audit",
397
+ name: "npm audit",
398
+ category: "security",
399
+ languages: ["typescript", "javascript"],
400
+ outputsFileMetrics: false,
401
+ outputsAggregate: true,
402
+ colorScheme: "issues",
403
+ description: "Check for known vulnerabilities in dependencies",
404
+ command: "npm audit"
405
+ },
406
+ {
407
+ id: "bandit",
408
+ name: "Bandit",
409
+ category: "security",
410
+ languages: ["python"],
411
+ outputsFileMetrics: true,
412
+ outputsAggregate: true,
413
+ colorScheme: "issues",
414
+ description: "Python security linter",
415
+ command: "bandit -r"
416
+ }
417
+ ];
418
+ var CATEGORY_CONFIGS = [
419
+ {
420
+ id: "linting",
421
+ name: "Linting",
422
+ description: "Code style and bug detection",
423
+ icon: "AlertCircle"
424
+ },
425
+ {
426
+ id: "formatting",
427
+ name: "Formatting",
428
+ description: "Code formatting consistency",
429
+ icon: "AlignLeft"
430
+ },
431
+ {
432
+ id: "types",
433
+ name: "Types",
434
+ description: "Type safety and checking",
435
+ icon: "FileType"
436
+ },
437
+ {
438
+ id: "tests",
439
+ name: "Tests",
440
+ description: "Test coverage and results",
441
+ icon: "TestTube"
442
+ },
443
+ {
444
+ id: "dead-code",
445
+ name: "Dead Code",
446
+ description: "Unused code detection",
447
+ icon: "Trash2",
448
+ invertedScale: true
449
+ },
450
+ {
451
+ id: "documentation",
452
+ name: "Documentation",
453
+ description: "Documentation coverage",
454
+ icon: "FileText"
455
+ },
456
+ {
457
+ id: "security",
458
+ name: "Security",
459
+ description: "Security vulnerability scanning",
460
+ icon: "Shield"
461
+ },
462
+ {
463
+ id: "complexity",
464
+ name: "Complexity",
465
+ description: "Code complexity metrics",
466
+ icon: "GitBranch"
467
+ }
468
+ ];
469
+ var LANGUAGE_CONFIGS = [
470
+ {
471
+ id: "typescript",
472
+ name: "TypeScript",
473
+ extensions: [".ts", ".tsx", ".mts", ".cts"],
474
+ icon: "TS"
475
+ },
476
+ {
477
+ id: "javascript",
478
+ name: "JavaScript",
479
+ extensions: [".js", ".jsx", ".mjs", ".cjs"],
480
+ icon: "JS"
481
+ },
482
+ {
483
+ id: "python",
484
+ name: "Python",
485
+ extensions: [".py", ".pyi"],
486
+ icon: "PY"
487
+ },
488
+ {
489
+ id: "go",
490
+ name: "Go",
491
+ extensions: [".go"],
492
+ icon: "GO"
493
+ },
494
+ {
495
+ id: "rust",
496
+ name: "Rust",
497
+ extensions: [".rs"],
498
+ icon: "RS"
499
+ },
500
+ {
501
+ id: "java",
502
+ name: "Java",
503
+ extensions: [".java"],
504
+ icon: "JV"
505
+ },
506
+ {
507
+ id: "csharp",
508
+ name: "C#",
509
+ extensions: [".cs"],
510
+ icon: "C#"
511
+ },
512
+ {
513
+ id: "ruby",
514
+ name: "Ruby",
515
+ extensions: [".rb"],
516
+ icon: "RB"
517
+ },
518
+ {
519
+ id: "php",
520
+ name: "PHP",
521
+ extensions: [".php"],
522
+ icon: "PHP"
523
+ }
524
+ ];
525
+
526
+ // src/helpers.ts
527
+ function getLensById(id) {
528
+ return LENS_REGISTRY.find((lens) => lens.id === id);
529
+ }
530
+ function getLensesByCategory(category) {
531
+ return LENS_REGISTRY.filter((lens) => lens.category === category);
532
+ }
533
+ function getLensesByLanguage(language) {
534
+ return LENS_REGISTRY.filter((lens) => lens.languages.includes(language));
535
+ }
536
+ function getLensesByCategoryAndLanguage(category, language) {
537
+ return LENS_REGISTRY.filter(
538
+ (lens) => lens.category === category && lens.languages.includes(language)
539
+ );
540
+ }
541
+ function getCategoryForLens(lensId) {
542
+ return getLensById(lensId)?.category;
543
+ }
544
+ function getAlternatives(lensId) {
545
+ const lens = getLensById(lensId);
546
+ if (!lens) return [];
547
+ const listedAsAlternative = LENS_REGISTRY.filter(
548
+ (other) => other.alternativeTo?.includes(lensId)
549
+ );
550
+ const thisListsAsAlternative = lens.alternativeTo ? LENS_REGISTRY.filter((other) => lens.alternativeTo.includes(other.id)) : [];
551
+ const all = [...listedAsAlternative, ...thisListsAsAlternative];
552
+ return Array.from(new Map(all.map((l) => [l.id, l])).values());
553
+ }
554
+ function areLensesAlternatives(lensId1, lensId2) {
555
+ const lens1 = getLensById(lensId1);
556
+ const lens2 = getLensById(lensId2);
557
+ if (!lens1 || !lens2) return false;
558
+ if (lens1.category !== lens2.category) return false;
559
+ return lens1.alternativeTo?.includes(lensId2) || lens2.alternativeTo?.includes(lensId1) || false;
560
+ }
561
+ function getLensesWithFileMetrics() {
562
+ return LENS_REGISTRY.filter((lens) => lens.outputsFileMetrics);
563
+ }
564
+ function getLensesWithAggregates() {
565
+ return LENS_REGISTRY.filter((lens) => lens.outputsAggregate);
566
+ }
567
+ function getColorModeForCategory(category, lensesRan) {
568
+ const lensesInCategory = getLensesByCategory(category);
569
+ for (const lensId of lensesRan) {
570
+ if (lensesInCategory.some((lens) => lens.id === lensId)) {
571
+ return lensId;
572
+ }
573
+ }
574
+ return null;
575
+ }
576
+ function getLensDisplayName(lensId) {
577
+ return getLensById(lensId)?.name ?? lensId;
578
+ }
579
+ function getLensColorScheme(lensId) {
580
+ return getLensById(lensId)?.colorScheme ?? "issues";
581
+ }
582
+ function getCategoryConfig(category) {
583
+ return CATEGORY_CONFIGS.find((c) => c.id === category);
584
+ }
585
+ function getCategoryDisplayName(category) {
586
+ return getCategoryConfig(category)?.name ?? category;
587
+ }
588
+ function isCategoryInverted(category) {
589
+ return getCategoryConfig(category)?.invertedScale ?? false;
590
+ }
591
+ function getLanguageConfig(language) {
592
+ return LANGUAGE_CONFIGS.find((l) => l.id === language);
593
+ }
594
+ function detectLanguageFromExtension(extension) {
595
+ const normalizedExt = extension.startsWith(".") ? extension : `.${extension}`;
596
+ const config = LANGUAGE_CONFIGS.find(
597
+ (l) => l.extensions.includes(normalizedExt.toLowerCase())
598
+ );
599
+ return config?.id;
600
+ }
601
+ function getLanguagesForCategory(category) {
602
+ const lenses = getLensesByCategory(category);
603
+ const languages = /* @__PURE__ */ new Set();
604
+ for (const lens of lenses) {
605
+ for (const lang of lens.languages) {
606
+ languages.add(lang);
607
+ }
608
+ }
609
+ return Array.from(languages);
610
+ }
611
+ function isValidLensId(lensId) {
612
+ return getLensById(lensId) !== void 0;
613
+ }
614
+ function findCategoryConflicts(lensesRan) {
615
+ const byCategory = /* @__PURE__ */ new Map();
616
+ for (const lensId of lensesRan) {
617
+ const category = getCategoryForLens(lensId);
618
+ if (category) {
619
+ const existing = byCategory.get(category) || [];
620
+ existing.push(lensId);
621
+ byCategory.set(category, existing);
622
+ }
623
+ }
624
+ const conflicts = [];
625
+ for (const [category, lenses] of byCategory) {
626
+ if (lenses.length > 1) {
627
+ conflicts.push({ category, lenses });
628
+ }
629
+ }
630
+ return conflicts;
631
+ }
632
+ function validateLensOutputs(lensesRan, fileMetricsProduced, aggregatesProduced) {
633
+ const issues = [];
634
+ for (const lensId of lensesRan) {
635
+ const lens = getLensById(lensId);
636
+ if (!lens) continue;
637
+ const missing = [];
638
+ if (lens.outputsFileMetrics && !fileMetricsProduced.includes(lensId)) {
639
+ missing.push("fileMetrics");
640
+ }
641
+ if (lens.outputsAggregate && !aggregatesProduced.includes(lensId)) {
642
+ missing.push("aggregate");
643
+ }
644
+ if (missing.length > 0) {
645
+ issues.push({ lensId, missing });
646
+ }
647
+ }
648
+ return issues;
649
+ }
650
+ // Annotate the CommonJS export names for ESM import in node:
651
+ 0 && (module.exports = {
652
+ CATEGORY_CONFIGS,
653
+ LANGUAGE_CONFIGS,
654
+ LENS_REGISTRY,
655
+ areLensesAlternatives,
656
+ detectLanguageFromExtension,
657
+ findCategoryConflicts,
658
+ getAlternatives,
659
+ getCategoryConfig,
660
+ getCategoryDisplayName,
661
+ getCategoryForLens,
662
+ getColorModeForCategory,
663
+ getLanguageConfig,
664
+ getLanguagesForCategory,
665
+ getLensById,
666
+ getLensColorScheme,
667
+ getLensDisplayName,
668
+ getLensesByCategory,
669
+ getLensesByCategoryAndLanguage,
670
+ getLensesByLanguage,
671
+ getLensesWithAggregates,
672
+ getLensesWithFileMetrics,
673
+ isCategoryInverted,
674
+ isValidLensId,
675
+ validateLensOutputs
676
+ });
677
+ //# sourceMappingURL=index.cjs.map