@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/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # @principal-ai/quality-lens-registry
2
+
3
+ Centralized registry of quality lens metadata for the Principal AI quality toolchain.
4
+
5
+ ## Purpose
6
+
7
+ This package provides a **single source of truth** for quality lens metadata across the entire quality toolchain:
8
+
9
+ - **CLI** (`@principal-ai/quality-lens-cli`) - Uses registry to validate lens outputs
10
+ - **Lens implementations** (`@principal-ai/codebase-quality-lenses`) - References registry for lens IDs
11
+ - **Quality Hexagon** (`@principal-ade/code-quality-panels`) - Uses registry for category→lens mapping
12
+ - **File City** (`@industry-theme/file-city-panel`) - Uses registry for lens display names
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @principal-ai/quality-lens-registry
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Get Lens Metadata
23
+
24
+ ```typescript
25
+ import { getLensById, getLensesByCategory } from '@principal-ai/quality-lens-registry';
26
+
27
+ // Get metadata for a specific lens
28
+ const eslint = getLensById('eslint');
29
+ // { id: 'eslint', name: 'ESLint', category: 'linting', languages: ['typescript', 'javascript'], ... }
30
+
31
+ // Get all linting tools
32
+ const linters = getLensesByCategory('linting');
33
+ // [{ id: 'eslint', ... }, { id: 'biome-lint', ... }, { id: 'ruff', ... }]
34
+ ```
35
+
36
+ ### Color Mode Selection (for File City)
37
+
38
+ ```typescript
39
+ import { getColorModeForCategory } from '@principal-ai/quality-lens-registry';
40
+
41
+ // Determine which color mode to use based on lenses that ran
42
+ const lensesRan = ['biome-lint', 'biome-format', 'typescript'];
43
+
44
+ const lintingMode = getColorModeForCategory('linting', lensesRan);
45
+ // Returns 'biome-lint' (not 'eslint' because it didn't run)
46
+
47
+ const formattingMode = getColorModeForCategory('formatting', lensesRan);
48
+ // Returns 'biome-format' (not 'prettier' because it didn't run)
49
+ ```
50
+
51
+ ### Language Support
52
+
53
+ ```typescript
54
+ import { getLensesByLanguage, detectLanguageFromExtension } from '@principal-ai/quality-lens-registry';
55
+
56
+ // Get all lenses that support Python
57
+ const pythonLenses = getLensesByLanguage('python');
58
+ // [{ id: 'ruff', ... }, { id: 'mypy', ... }, { id: 'pytest', ... }]
59
+
60
+ // Detect language from file extension
61
+ const lang = detectLanguageFromExtension('.py');
62
+ // 'python'
63
+ ```
64
+
65
+ ### Validation
66
+
67
+ ```typescript
68
+ import { isValidLensId, findCategoryConflicts, validateLensOutputs } from '@principal-ai/quality-lens-registry';
69
+
70
+ // Check if a lens ID is valid
71
+ isValidLensId('biome-lint'); // true
72
+ isValidLensId('unknown'); // false
73
+
74
+ // Find potential conflicts (multiple lenses for same category)
75
+ const conflicts = findCategoryConflicts(['eslint', 'biome-lint', 'typescript']);
76
+ // [{ category: 'linting', lenses: ['eslint', 'biome-lint'] }]
77
+
78
+ // Validate that lenses produced expected outputs
79
+ const issues = validateLensOutputs(
80
+ ['eslint', 'typescript'],
81
+ ['typescript'], // fileMetrics produced
82
+ ['eslint', 'typescript'] // aggregates produced
83
+ );
84
+ // [{ lensId: 'eslint', missing: ['fileMetrics'] }]
85
+ ```
86
+
87
+ ## Adding a New Lens
88
+
89
+ 1. **Add to registry** (`src/registry.ts`):
90
+
91
+ ```typescript
92
+ {
93
+ id: 'my-lens',
94
+ name: 'My Lens',
95
+ category: 'linting',
96
+ languages: ['typescript', 'javascript'],
97
+ alternativeTo: ['eslint'], // Optional: if it's an alternative
98
+ outputsFileMetrics: true,
99
+ outputsAggregate: true,
100
+ colorScheme: 'issues',
101
+ description: 'My custom linting tool',
102
+ command: 'my-lens check',
103
+ }
104
+ ```
105
+
106
+ 2. **Implement lens** in `@principal-ai/codebase-quality-lenses`
107
+
108
+ 3. **Done!** - UI packages automatically discover and support it
109
+
110
+ ## Available Lenses
111
+
112
+ ### Linting
113
+ - `eslint` - ESLint (TypeScript/JavaScript)
114
+ - `biome-lint` - Biome Lint (TypeScript/JavaScript)
115
+ - `oxlint` - OxLint (TypeScript/JavaScript)
116
+ - `ruff` - Ruff (Python)
117
+ - `pylint` - Pylint (Python)
118
+ - `golangci-lint` - golangci-lint (Go)
119
+ - `clippy` - Clippy (Rust)
120
+
121
+ ### Formatting
122
+ - `prettier` - Prettier (TypeScript/JavaScript)
123
+ - `biome-format` - Biome Format (TypeScript/JavaScript)
124
+ - `black` - Black (Python)
125
+ - `ruff-format` - Ruff Format (Python)
126
+ - `gofmt` - gofmt (Go)
127
+ - `rustfmt` - rustfmt (Rust)
128
+
129
+ ### Types
130
+ - `typescript` - TypeScript
131
+ - `mypy` - MyPy (Python)
132
+ - `pyright` - Pyright (Python)
133
+ - `go-vet` - Go Vet (Go)
134
+
135
+ ### Tests
136
+ - `jest` - Jest (TypeScript/JavaScript)
137
+ - `vitest` - Vitest (TypeScript/JavaScript)
138
+ - `bun-test` - Bun Test (TypeScript/JavaScript)
139
+ - `pytest` - Pytest (Python)
140
+ - `go-test` - Go Test (Go)
141
+ - `cargo-test` - Cargo Test (Rust)
142
+
143
+ ### Dead Code
144
+ - `knip` - Knip (TypeScript/JavaScript)
145
+ - `vulture` - Vulture (Python)
146
+
147
+ ### Documentation
148
+ - `alexandria` - Alexandria (TypeScript/JavaScript)
149
+ - `typedoc` - TypeDoc (TypeScript)
150
+
151
+ ### Security
152
+ - `npm-audit` - npm audit (TypeScript/JavaScript)
153
+ - `bandit` - Bandit (Python)
154
+
155
+ ## License
156
+
157
+ MIT