@redaksjon/brennpunkt 0.0.1

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/guide/index.md ADDED
@@ -0,0 +1,177 @@
1
+ # Brennpunkt AI Guide
2
+
3
+ This directory contains comprehensive documentation designed to help AI assistants and developers understand and use Brennpunkt - a coverage priority analyzer that identifies where to focus testing efforts.
4
+
5
+ ## What is Brennpunkt?
6
+
7
+ Brennpunkt parses `lcov.info` coverage reports and ranks files by testing priority. It answers the question: **"Where should I focus my testing efforts to have the biggest impact on coverage?"**
8
+
9
+ **Core Problem Solved**: When a CI build fails with "Coverage: 85.2% < 90%", traditional reports show raw percentages but don't tell you which files will have the most impact. Brennpunkt calculates a priority score that weighs coverage gaps against file importance.
10
+
11
+ ## Guide Contents
12
+
13
+ ### Getting Started
14
+ - [**Quick Start**](./quickstart.md): Get brennpunkt working in 2 minutes
15
+ - [**Configuration**](./configuration.md): Config file options
16
+
17
+ ### Understanding Brennpunkt
18
+ - [**Usage**](./usage.md): Complete CLI reference
19
+ - [**Scoring**](./scoring.md): How priority scores are calculated
20
+ - [**Integration**](./integration.md): CI/CD and workflow integration
21
+
22
+ ### AI & Automation
23
+ - [**AI Integration**](./ai-integration.md): Using Brennpunkt with AI coding assistants and MCP
24
+
25
+ ### Development
26
+ - [**API**](./api.md): Programmatic usage as a library
27
+
28
+ ## Quick Reference for AI Assistants
29
+
30
+ ### Essential Commands
31
+
32
+ ```bash
33
+ # Basic analysis (auto-discovers coverage file)
34
+ brennpunkt
35
+
36
+ # Show top 10 priority files
37
+ brennpunkt --top 10
38
+
39
+ # JSON output for processing
40
+ brennpunkt --json
41
+
42
+ # Analyze specific coverage file
43
+ brennpunkt path/to/lcov.info
44
+ ```
45
+
46
+ ### Common Tasks
47
+
48
+ | Task | Command |
49
+ |------|---------|
50
+ | Find highest priority files | `brennpunkt --top 5` |
51
+ | Get JSON for automation | `brennpunkt --json --top 10` |
52
+ | Exclude tiny files | `brennpunkt --min-lines 50` |
53
+ | Prioritize branch coverage | `brennpunkt --weights 0.7,0.2,0.1` |
54
+ | Check configuration | `brennpunkt --check-config` |
55
+ | Create config file | `brennpunkt --init-config` |
56
+
57
+ ### Coverage File Discovery
58
+
59
+ Brennpunkt automatically searches these locations (in order):
60
+
61
+ 1. `coverage/lcov.info` - Jest, Vitest, c8 (most common)
62
+ 2. `.coverage/lcov.info` - Some configurations
63
+ 3. `coverage/lcov/lcov.info` - Karma
64
+ 4. `lcov.info` - Project root
65
+ 5. `.nyc_output/lcov.info` - NYC legacy
66
+ 6. `test-results/lcov.info` - Some CI configs
67
+
68
+ ### Key Options
69
+
70
+ | Option | Description | Default |
71
+ |--------|-------------|---------|
72
+ | `[coverage-path]` | Path to lcov.info | Auto-discovered |
73
+ | `-w, --weights` | Weights for branches,functions,lines | `0.5,0.3,0.2` |
74
+ | `-m, --min-lines` | Exclude files with fewer lines | `10` |
75
+ | `-t, --top` | Show only top N files | (all) |
76
+ | `-j, --json` | Output as JSON | `false` |
77
+ | `-c, --config` | Path to config file | `brennpunkt.yaml` |
78
+
79
+ ### Priority Score Formula
80
+
81
+ ```
82
+ score = (branchGap × 0.5 + functionGap × 0.3 + lineGap × 0.2) × log₁₀(lines + 1)
83
+ ```
84
+
85
+ Where:
86
+ - `branchGap` = 100 - branch coverage %
87
+ - `functionGap` = 100 - function coverage %
88
+ - `lineGap` = 100 - line coverage %
89
+ - `lines` = total lines in file
90
+
91
+ **Higher score = Higher priority for testing**
92
+
93
+ ## For AI Assistants
94
+
95
+ If you're an AI helping someone improve test coverage:
96
+
97
+ 1. **Run brennpunkt first**: `brennpunkt --json --top 5` to get prioritized targets
98
+ 2. **Focus on high-score files**: Files with scores > 50 need attention
99
+ 3. **Check branch coverage**: It's weighted highest (50%) because untested branches hide bugs
100
+ 4. **Use JSON output**: Parse the structured data for precise guidance
101
+ 5. **Respect project config**: Projects may have custom `brennpunkt.yaml` with different weights
102
+
103
+ > **MCP Server**: Run `brennpunkt-mcp` to start an MCP server that allows AI tools to query coverage data directly without running tests. See [AI Integration](./ai-integration.md) for details.
104
+
105
+ ### Cursor Rule (Recommended)
106
+
107
+ Add this to your project's `.cursorrules` file for automatic coverage analysis:
108
+
109
+ ```markdown
110
+ # Coverage Priority Analysis
111
+
112
+ When working on test coverage improvements:
113
+
114
+ 1. Run `npx @redaksjon/brennpunkt --json --top 5` to get prioritized files
115
+ 2. Focus on the highest priority file first (highest priorityScore)
116
+ 3. Pay special attention to:
117
+ - Files with low branch coverage (untested conditionals hide bugs)
118
+ - Files with high uncoveredLines count
119
+ 4. After writing tests, re-run brennpunkt to see updated priorities
120
+
121
+ When I ask about test coverage, run brennpunkt and interpret the results.
122
+ Suggest specific test cases based on the uncovered branches and functions.
123
+ ```
124
+
125
+ Then just ask: "What files need test coverage?" or "Help me improve test coverage"
126
+
127
+ ### Example Workflow
128
+
129
+ ```bash
130
+ # Step 1: Get priority list
131
+ brennpunkt --json --top 3
132
+
133
+ # Step 2: AI receives structured data like:
134
+ {
135
+ "files": [
136
+ {
137
+ "file": "src/auth/login.ts",
138
+ "priorityScore": 156.3,
139
+ "uncoveredBranches": 13,
140
+ "uncoveredLines": 45
141
+ }
142
+ ]
143
+ }
144
+
145
+ # Step 3: Write tests for src/auth/login.ts focusing on the 13 untested branches
146
+ ```
147
+
148
+ ## Configuration File
149
+
150
+ Create `brennpunkt.yaml` in your project root:
151
+
152
+ ```yaml
153
+ # Priority weights (branches, functions, lines)
154
+ weights: "0.5,0.3,0.2"
155
+
156
+ # Minimum lines for inclusion
157
+ minLines: 10
158
+
159
+ # Limit results
160
+ top: 20
161
+
162
+ # Output format
163
+ json: false
164
+ ```
165
+
166
+ ## npm Post-Test Integration
167
+
168
+ Add to `package.json` for automatic analysis:
169
+
170
+ ```json
171
+ {
172
+ "scripts": {
173
+ "test": "vitest run --coverage",
174
+ "posttest": "brennpunkt --top 10"
175
+ }
176
+ }
177
+ ```
@@ -0,0 +1,283 @@
1
+ # CI/CD Integration
2
+
3
+ How to integrate brennpunkt into your development workflow and CI pipelines.
4
+
5
+ ## npm Post-Test Hook
6
+
7
+ The simplest integration - run brennpunkt automatically after every test:
8
+
9
+ ```json
10
+ {
11
+ "scripts": {
12
+ "test": "vitest run --coverage",
13
+ "posttest": "brennpunkt --top 10"
14
+ }
15
+ }
16
+ ```
17
+
18
+ Now `npm test` automatically shows coverage priorities:
19
+
20
+ ```bash
21
+ $ npm test
22
+
23
+ ✓ tests/auth.test.ts (15 tests)
24
+ ✓ tests/api.test.ts (23 tests)
25
+
26
+ Coverage: 85.2%
27
+
28
+ Using coverage file: coverage/lcov.info
29
+
30
+ 📊 Coverage Priority Report
31
+ ...
32
+ 🎯 Recommended Focus (Top 3):
33
+ 1. src/auth/login.ts - 13 untested branches
34
+ ```
35
+
36
+ ## GitHub Actions
37
+
38
+ ### Basic Integration
39
+
40
+ Add to your test workflow:
41
+
42
+ ```yaml
43
+ name: Test & Coverage
44
+
45
+ on: [push, pull_request]
46
+
47
+ jobs:
48
+ test:
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+ - uses: actions/setup-node@v4
53
+ with:
54
+ node-version: '20'
55
+
56
+ - run: npm ci
57
+ - run: npm test -- --coverage
58
+
59
+ # Add coverage priority analysis
60
+ - name: Coverage Priority Analysis
61
+ run: npx @redaksjon/brennpunkt --top 10
62
+ ```
63
+
64
+ ### Save JSON Artifact
65
+
66
+ Store the priority report for later analysis:
67
+
68
+ ```yaml
69
+ - name: Generate Priority Report
70
+ run: npx @redaksjon/brennpunkt --json > coverage-priority.json
71
+
72
+ - uses: actions/upload-artifact@v4
73
+ with:
74
+ name: coverage-priority
75
+ path: coverage-priority.json
76
+ ```
77
+
78
+ ### PR Comment
79
+
80
+ Post coverage priorities as a PR comment:
81
+
82
+ ```yaml
83
+ - name: Coverage Priority Analysis
84
+ id: coverage
85
+ run: |
86
+ OUTPUT=$(npx @redaksjon/brennpunkt --top 5 2>&1)
87
+ echo "report<<EOF" >> $GITHUB_OUTPUT
88
+ echo "$OUTPUT" >> $GITHUB_OUTPUT
89
+ echo "EOF" >> $GITHUB_OUTPUT
90
+
91
+ - name: Comment on PR
92
+ uses: actions/github-script@v7
93
+ if: github.event_name == 'pull_request'
94
+ with:
95
+ script: |
96
+ github.rest.issues.createComment({
97
+ issue_number: context.issue.number,
98
+ owner: context.repo.owner,
99
+ repo: context.repo.repo,
100
+ body: '## Coverage Priority Analysis\n\n```\n${{ steps.coverage.outputs.report }}\n```'
101
+ })
102
+ ```
103
+
104
+ ## GitLab CI
105
+
106
+ ```yaml
107
+ test:
108
+ stage: test
109
+ script:
110
+ - npm ci
111
+ - npm test -- --coverage
112
+ - npx @redaksjon/brennpunkt --top 10
113
+ artifacts:
114
+ reports:
115
+ coverage_report:
116
+ coverage_format: cobertura
117
+ path: coverage/cobertura-coverage.xml
118
+ paths:
119
+ - coverage-priority.json
120
+ when: always
121
+ ```
122
+
123
+ ## Jenkins
124
+
125
+ ```groovy
126
+ pipeline {
127
+ agent any
128
+ stages {
129
+ stage('Test') {
130
+ steps {
131
+ sh 'npm ci'
132
+ sh 'npm test -- --coverage'
133
+ sh 'npx @redaksjon/brennpunkt --top 10'
134
+ }
135
+ }
136
+ stage('Coverage Report') {
137
+ steps {
138
+ sh 'npx @redaksjon/brennpunkt --json > coverage-priority.json'
139
+ archiveArtifacts artifacts: 'coverage-priority.json'
140
+ }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ ## CircleCI
147
+
148
+ ```yaml
149
+ version: 2.1
150
+ jobs:
151
+ test:
152
+ docker:
153
+ - image: cimg/node:20.0
154
+ steps:
155
+ - checkout
156
+ - run: npm ci
157
+ - run: npm test -- --coverage
158
+ - run: npx @redaksjon/brennpunkt --top 10
159
+ - store_artifacts:
160
+ path: coverage
161
+ destination: coverage
162
+ ```
163
+
164
+ ## Quality Gates
165
+
166
+ ### Fail on High-Priority Gaps
167
+
168
+ Block builds when critical files have unacceptable coverage:
169
+
170
+ ```bash
171
+ #!/bin/bash
172
+ # scripts/coverage-gate.sh
173
+
174
+ # Get the highest priority score
175
+ TOP_SCORE=$(npx @redaksjon/brennpunkt --json --top 1 | jq '.files[0].priorityScore // 0')
176
+
177
+ echo "Top priority score: $TOP_SCORE"
178
+
179
+ # Fail if score exceeds threshold
180
+ if (( $(echo "$TOP_SCORE > 100" | bc -l) )); then
181
+ echo "❌ High-priority coverage gap detected (score: $TOP_SCORE)"
182
+ echo ""
183
+ echo "Files needing attention:"
184
+ npx @redaksjon/brennpunkt --top 5
185
+ exit 1
186
+ fi
187
+
188
+ echo "✅ Coverage priorities within acceptable range"
189
+ ```
190
+
191
+ ### Multiple Thresholds
192
+
193
+ ```bash
194
+ #!/bin/bash
195
+ # scripts/coverage-gate.sh
196
+
197
+ CRITICAL_THRESHOLD=150
198
+ WARNING_THRESHOLD=75
199
+
200
+ TOP_SCORE=$(npx @redaksjon/brennpunkt --json --top 1 | jq '.files[0].priorityScore // 0')
201
+
202
+ if (( $(echo "$TOP_SCORE > $CRITICAL_THRESHOLD" | bc -l) )); then
203
+ echo "❌ CRITICAL: Coverage gap too high (score: $TOP_SCORE > $CRITICAL_THRESHOLD)"
204
+ npx @redaksjon/brennpunkt --top 5
205
+ exit 1
206
+ elif (( $(echo "$TOP_SCORE > $WARNING_THRESHOLD" | bc -l) )); then
207
+ echo "⚠️ WARNING: Coverage gap detected (score: $TOP_SCORE > $WARNING_THRESHOLD)"
208
+ npx @redaksjon/brennpunkt --top 5
209
+ # Don't fail, just warn
210
+ fi
211
+
212
+ echo "✅ Coverage priorities acceptable"
213
+ ```
214
+
215
+ ## Pre-Commit Hook
216
+
217
+ Run brennpunkt before committing:
218
+
219
+ ```bash
220
+ # .husky/pre-commit
221
+ npm test -- --coverage
222
+ npx @redaksjon/brennpunkt --top 5
223
+ ```
224
+
225
+ ## Scheduled Reports
226
+
227
+ Generate weekly coverage priority reports:
228
+
229
+ ```yaml
230
+ # .github/workflows/weekly-coverage.yml
231
+ name: Weekly Coverage Report
232
+
233
+ on:
234
+ schedule:
235
+ - cron: '0 9 * * 1' # Every Monday at 9am
236
+
237
+ jobs:
238
+ report:
239
+ runs-on: ubuntu-latest
240
+ steps:
241
+ - uses: actions/checkout@v4
242
+ - uses: actions/setup-node@v4
243
+ with:
244
+ node-version: '20'
245
+
246
+ - run: npm ci
247
+ - run: npm test -- --coverage
248
+
249
+ - name: Generate Report
250
+ run: |
251
+ echo "# Weekly Coverage Priority Report" > report.md
252
+ echo "" >> report.md
253
+ echo "Generated: $(date)" >> report.md
254
+ echo "" >> report.md
255
+ echo '```' >> report.md
256
+ npx @redaksjon/brennpunkt --top 20 >> report.md
257
+ echo '```' >> report.md
258
+
259
+ - name: Create Issue
260
+ uses: peter-evans/create-issue-from-file@v4
261
+ with:
262
+ title: Weekly Coverage Priority Report
263
+ content-filepath: report.md
264
+ labels: coverage,automated
265
+ ```
266
+
267
+ ## Makefile Integration
268
+
269
+ ```makefile
270
+ .PHONY: test coverage priority
271
+
272
+ test:
273
+ npm test -- --coverage
274
+
275
+ coverage: test
276
+ npx @redaksjon/brennpunkt --top 10
277
+
278
+ priority:
279
+ npx @redaksjon/brennpunkt --json > coverage-priority.json
280
+
281
+ check: test
282
+ @./scripts/coverage-gate.sh
283
+ ```
@@ -0,0 +1,119 @@
1
+ # Quick Start Guide
2
+
3
+ Get brennpunkt working in 2 minutes.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js 20+
8
+ - A project with lcov.info coverage output
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install -g @redaksjon/brennpunkt
14
+ ```
15
+
16
+ Or use directly with npx:
17
+
18
+ ```bash
19
+ npx @redaksjon/brennpunkt
20
+ ```
21
+
22
+ ## First Analysis
23
+
24
+ ### 1. Generate Coverage
25
+
26
+ Run your tests with coverage enabled:
27
+
28
+ ```bash
29
+ # Vitest
30
+ npm test -- --coverage
31
+
32
+ # Jest
33
+ npm test -- --coverage
34
+
35
+ # c8/NYC
36
+ npx c8 npm test
37
+ ```
38
+
39
+ ### 2. Run Brennpunkt
40
+
41
+ ```bash
42
+ # Auto-discovers coverage file
43
+ brennpunkt
44
+
45
+ # Or specify path explicitly
46
+ brennpunkt coverage/lcov.info
47
+ ```
48
+
49
+ ### 3. View Results
50
+
51
+ ```
52
+ 📊 Coverage Priority Report
53
+
54
+ ┌─────────────────────────────────────────────────────────────────┐
55
+ │ OVERALL COVERAGE │
56
+ ├─────────────────┬─────────────────┬─────────────────────────────┤
57
+ │ Lines: 85.20% │ Functions: 90.00% │ Branches: 72.50% │
58
+ └─────────────────┴─────────────────┴─────────────────────────────┘
59
+
60
+ Priority File Lines Funcs Branch Score
61
+ ────────────────────────────────────────────────────────────────────────
62
+ #1 src/auth/login.ts 45.2% 50.0% 35.0% 156.3
63
+ #2 src/api/handler.ts 62.5% 70.0% 55.0% 98.7
64
+ #3 src/utils/parser.ts 78.3% 85.0% 68.2% 67.2
65
+
66
+ 🎯 Recommended Focus (Top 3):
67
+ 1. src/auth/login.ts - 13 untested branches, 5 untested functions
68
+ ```
69
+
70
+ ## Common Options
71
+
72
+ ```bash
73
+ # Show only top 10 priority files
74
+ brennpunkt --top 10
75
+
76
+ # JSON output for automation
77
+ brennpunkt --json
78
+
79
+ # Custom weights (prioritize branch coverage)
80
+ brennpunkt --weights 0.7,0.2,0.1
81
+
82
+ # Exclude small files
83
+ brennpunkt --min-lines 50
84
+
85
+ # Verbose output
86
+ brennpunkt --verbose
87
+ ```
88
+
89
+ ## Automatic Post-Test Analysis
90
+
91
+ Add to your `package.json`:
92
+
93
+ ```json
94
+ {
95
+ "scripts": {
96
+ "test": "vitest run --coverage",
97
+ "posttest": "brennpunkt --top 10"
98
+ }
99
+ }
100
+ ```
101
+
102
+ Now every `npm test` automatically shows coverage priorities.
103
+
104
+ ## Create Configuration File
105
+
106
+ ```bash
107
+ # Generate default config
108
+ brennpunkt --init-config
109
+
110
+ # View resolved config
111
+ brennpunkt --check-config
112
+ ```
113
+
114
+ ## Next Steps
115
+
116
+ - [Usage Reference](./usage.md): All CLI options
117
+ - [Scoring](./scoring.md): Understand priority scores
118
+ - [Integration](./integration.md): CI/CD setup
119
+ - [Configuration](./configuration.md): Config file options