mo3ta-coverage 1.0.20 → 1.0.21

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/AGENT.md CHANGED
@@ -57,7 +57,8 @@ There is no lint/typecheck/format script. `npm run build` currently outputs
57
57
  index.js
58
58
  └─ main(options) src/cli.js
59
59
  ├─ verifyGitRepoExists() src/gitUtils.js
60
- ├─ getChangedFiles(base) git log/diff/diff --cached, sort -u
60
+ ├─ getExplicitFiles(options) --files / --filesFrom, or
61
+ ├─ getChangedFiles(base) merge-base diff + working tree, all authors
61
62
  ├─ runRelatedTests(files, mode, depth)
62
63
  │ └─ npx jest ... --coverage
63
64
  └─ reportUncoveredChangedLines(...)
@@ -71,14 +72,18 @@ index.js
71
72
 
72
73
  `getChangedFiles()` unions:
73
74
 
74
- - files from commits authored by the current git user between
75
- `merge-base HEAD <base>` and `HEAD`,
75
+ - files changed between `merge-base HEAD <base>` and `HEAD` (all authors),
76
76
  - unstaged changes,
77
77
  - staged changes.
78
78
 
79
79
  It keeps only `.js/.ts/.jsx/.tsx` and drops `node_modules`, `coverage`, `dist`,
80
80
  `build`, and `.git` paths. Paths are relative to `process.cwd()`.
81
81
 
82
+ When `--files` or `--filesFrom` is provided, `getExplicitFiles()` normalizes the
83
+ list (comma/space separated, relative or absolute, de-duplicated) and auto
84
+ detection is skipped. Changed lines for those files are still computed against
85
+ `--base`, because `git diff -U0 <base> -- <file>` drives the coverage check.
86
+
82
87
  ### Modes
83
88
 
84
89
  - `fast`: naming-convention matches only (plus changed test files), with the
package/README.md CHANGED
@@ -1,10 +1,19 @@
1
1
  # mo3ta-coverage ![NPM Version](https://img.shields.io/npm/v/mo3ta-coverage)
2
2
 
3
+ ![mo3ta-coverage modes and features](docs/poster.png)
4
+
3
5
  mo3ta-coverage checks coverage for changed lines in a pull request. It finds changed source files, maps them to likely test files, runs Jest in a selected execution mode, and validates changed-line coverage against a threshold.
4
6
 
7
+ ## Demo
8
+
9
+ https://github.com/user-attachments/assets/5241bfa7-ba66-4405-bf42-fd6522be56a6
10
+
11
+ A quick walkthrough of changed-file detection, related-test selection, and changed-line coverage.
12
+
5
13
  ## Features
6
14
 
7
- - Detects changed JS/TS files from git history and working tree
15
+ - Detects changed JS/TS files from git history and working tree, for all authors
16
+ - Accepts an explicit file list (`--files` / `--filesFrom`) to control what gets scanned
8
17
  - Maps changed source files to related test files, even when names differ
9
18
  - Supports three execution modes: `fast`, `smart`, and `full`
10
19
  - Walks reverse imports in `smart` mode to a configurable depth (default `2`)
@@ -33,6 +42,30 @@ mo3ta-coverage --mode smart --base origin/main --limit 80
33
42
  | `--showCovered <bool>` | Show covered changed lines in output | `false` |
34
43
  | `--mode <mode>` | Execution mode: `fast`, `smart`, or `full` | `smart` |
35
44
  | `--depth <number>` | Max reverse-import depth used by `smart` (`1` or `2` recommended) | `2` |
45
+ | `--files <files...>` | Scan only these files instead of auto-detecting changed files (space- or comma-separated) | – |
46
+ | `--filesFrom <path>` | Read the file list to scan from a newline-separated file | – |
47
+
48
+ ## Scanning Selected Files
49
+
50
+ Changed files are detected from git for **all authors**, not just the current
51
+ git user. If you want to control exactly which files are scanned, pass them
52
+ directly. The library still maps them to tests and checks changed-line coverage.
53
+
54
+ ```sh
55
+ # Explicit list (space-separated)
56
+ mo3ta-coverage --files src/a.js src/b.ts --base origin/main
57
+
58
+ # Explicit list (comma-separated)
59
+ mo3ta-coverage --files src/a.js,src/b.ts --base origin/main
60
+
61
+ # From a file containing one path per line
62
+ git diff --name-only origin/main > changed.txt
63
+ mo3ta-coverage --filesFrom changed.txt --base origin/main
64
+ ```
65
+
66
+ Explicitly provided files skip git changed-file detection. Their changed lines
67
+ are still computed against `--base`, so only lines that differ from the base
68
+ branch are counted toward coverage.
36
69
 
37
70
  ## Modes
38
71
 
package/VIDEO_PLAN.md ADDED
@@ -0,0 +1,316 @@
1
+ # mo3ta-coverage — Video Production Plan
2
+
3
+ Status: **in progress** · Owner: next agent · Last updated: 2026-11-19
4
+
5
+ Goal: produce two local MP4 promo videos for `mo3ta-coverage` using the
6
+ OpenMontage / HyperFrames skill:
7
+
8
+ 1. **5s teaser** — first deliverable.
9
+ 2. **15s explainer** — full story, built only after the 5s cut is approved.
10
+
11
+ No API keys, TTS, stock footage, or music are required. Everything is authored
12
+ as HTML/CSS/GSAP and rendered locally with HyperFrames + FFmpeg.
13
+
14
+ ---
15
+
16
+ ## 1. Inputs and environment
17
+
18
+ | Item | Value |
19
+ | --- | --- |
20
+ | Video skill / vendor | `/Users/appleworld/Documents/Diff/vendor/OpenMontage` |
21
+ | HyperFrames guide | `OpenMontage/skills/core/hyperframes.md` |
22
+ | Authoring contract | `OpenMontage/.agents/skills/hyperframes-core/SKILL.md` |
23
+ | Reference composition | `OpenMontage/projects/json-change-explainer/hyperframes/index.html` |
24
+ | Cached HyperFrames CLI | `/Users/appleworld/.npm/_npx/702923228c2ce1e6/node_modules/.bin/hyperframes` (v0.9.23) |
25
+ | Fallback CLI | `npx --yes hyperframes@0.9.23` |
26
+ | Node | v24.14.1 |
27
+ | FFmpeg / FFprobe | 8.1.1 (`/opt/homebrew/bin`) |
28
+ | Chrome headless | cached at `~/.cache/hyperframes/chrome` |
29
+
30
+ Do **not** use `npx @hyperframes/cli` (404). The public package is `hyperframes`.
31
+
32
+ Convenience for every command below:
33
+
34
+ ```bash
35
+ export HF=/Users/appleworld/.npm/_npx/702923228c2ce1e6/node_modules/.bin/hyperframes
36
+ export REPO=/Users/appleworld/Documents/mo3ta-coverage
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 2. Deliverables
42
+
43
+ ```text
44
+ /Users/appleworld/Documents/mo3ta-coverage/
45
+ ├── VIDEO_PLAN.md <- this file
46
+ └── video/
47
+ ├── .gitignore <- ignores .hyperframes/ and renders/
48
+ ├── mo3ta-coverage-5s/
49
+ │ ├── index.html <- HyperFrames composition
50
+ │ ├── gsap.min.js <- local GSAP (offline render)
51
+ │ └── hyperframes.json
52
+ ├── mo3ta-coverage-15s/
53
+ │ ├── index.html
54
+ │ ├── gsap.min.js
55
+ │ └── hyperframes.json
56
+ └── renders/
57
+ ├── mo3ta-coverage-5s.mp4
58
+ └── mo3ta-coverage-15s.mp4
59
+ ```
60
+
61
+ Output spec: **1920×1080, 30 fps, H.264 MP4, no audio track**.
62
+
63
+ If `video/` is committed later, add `/video/renders/` (or all of `/video/`) to
64
+ `.npmignore` so MP4s are not published to npm.
65
+
66
+ ---
67
+
68
+ ## 3. Product story
69
+
70
+ `mo3ta-coverage` runs only the tests related to the lines changed in a PR, then
71
+ checks coverage for those changed lines.
72
+
73
+ Key message:
74
+
75
+ > **Changed code. Related specs. Real coverage.**
76
+
77
+ Supporting points:
78
+
79
+ - Finds changed JS/TS files against a base branch.
80
+ - `smart` mode finds related spec files even when names differ.
81
+ - Uses a depth-limited reverse-import graph (`--depth 1` or `2`) to catch
82
+ barrel/re-export layers without running the whole suite.
83
+ - Reports uncovered changed lines and fails below a coverage limit.
84
+ - Works locally and in CI.
85
+
86
+ Example command to show on screen:
87
+
88
+ ```bash
89
+ npx mo3ta-coverage --mode smart --base origin/main --limit 80
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 4. Creative direction
95
+
96
+ **Look:** dark developer tool, editorial motion graphics, no people, no stock
97
+ footage. Crisp mono labels, syntax-colored diff lines, subtle grid and glow.
98
+
99
+ | Token | Value | Use |
100
+ | --- | --- | --- |
101
+ | `--bg` | `#0F1115` | canvas |
102
+ | `--card` | `#1A1C22` | terminal / report panels |
103
+ | `--border` | `#2A2D35` | panel borders |
104
+ | `--text` | `#E6E6E6` | body |
105
+ | `--bright` | `#F4F7FB` | headlines |
106
+ | `--muted` | `#9AA0A6` | secondary copy |
107
+ | `--accent` | `#60A5FA` | brand / CTA |
108
+ | `--pass` | `#22C55E` | covered lines, pass |
109
+ | `--fail` | `#F87171` | uncovered lines |
110
+ | `--warn` | `#FB923C` | attention |
111
+
112
+ Fonts: **Inter** for UI/headlines, **JetBrains Mono** for code. Both are
113
+ supported by the HyperFrames deterministic font compiler.
114
+
115
+ Motion: 0.4–0.8s power2/power3 eases, 18–42px rise, small staggers. No infinite
116
+ loops, no unseeded randomness, no clocks.
117
+
118
+ ---
119
+
120
+ ## 5. Storyboard — 5s teaser
121
+
122
+ Duration: **5.0s**. One continuous dark stage.
123
+
124
+ | Time | Scene | Content | Motion |
125
+ | --- | --- | --- | --- |
126
+ | 0.0–1.2 | Hook | Pill `PR COVERAGE · SMART MODE` + wordmark `mo3ta-coverage` + line `Changed code. Related specs.` | fade-up cascade |
127
+ | 1.2–2.6 | Command | Terminal card, types `npx mo3ta-coverage --mode smart` then `--base origin/main` | caret blink via finite steps, prompt glow |
128
+ | 2.6–3.9 | Smart graph | Left: `src/utils/helper.js` changed. Right: `specs/custom-name.spec.js`. Arrow/label `related spec · depth 1` | nodes pop, link draws, label fades |
129
+ | 3.9–5.0 | Result | Report card: `100% changed-line coverage`, green check, `limit 80%` | count-up, check draws, hold |
130
+
131
+ Copy:
132
+
133
+ - `Changed code. Related specs.`
134
+ - `Even when the test name doesn't match.`
135
+ - `100% changed-line coverage`
136
+
137
+ ---
138
+
139
+ ## 6. Storyboard — 15s explainer
140
+
141
+ Duration: **15.0s**.
142
+
143
+ | Time | Scene | Content | Motion |
144
+ | --- | --- | --- | --- |
145
+ | 0.0–2.0 | Hook | Pill, wordmark, `Changed code. Related specs. Real coverage.` | title cascade |
146
+ | 2.0–4.8 | Problem | Mini PR diff: 3 changed lines. Text `Running the whole suite is slow.` | diff rows slide in, muted clock motif |
147
+ | 4.8–8.0 | Smart mode | Command types; graph builds: changed file → barrel → differently named spec, labels `depth 1` / `depth 2` | graph nodes + link draw, depth badges pulse once |
148
+ | 8.0–11.0 | Coverage | Jest result panel: `PASS specs/custom-name.spec.js`, coverage table, changed lines turn green/red | rows cascade, line markers pop |
149
+ | 11.0–13.0 | Verdict | `Overall changed-line coverage 100%` vs `limit 80%`, `Not covered: 0 of 3` | counter + progress bar fill |
150
+ | 13.0–15.0 | CTA | End card: wordmark, `Changed code. Related specs. Real coverage.`, command pill | fade-up, hold |
151
+
152
+ Narrative copy:
153
+
154
+ 1. `Every PR changes a few lines.`
155
+ 2. `But CI runs the whole suite.`
156
+ 3. `mo3ta-coverage starts from changed files.`
157
+ 4. `Smart mode walks imports to depth 1 or 2.`
158
+ 5. `It finds the right spec — even with a different name.`
159
+ 6. `Then checks coverage for changed lines only.`
160
+ 7. `Fail the build only when the diff is under-covered.`
161
+
162
+ ---
163
+
164
+ ## 7. HyperFrames authoring rules
165
+
166
+ - Root is a standalone `<div data-composition-id="..." data-width="1920"
167
+ data-height="1080" data-start="0" data-duration="5">` (or `15`).
168
+ - Add `data-fps="30"` on the root if supported; otherwise pass `-f 30` at render.
169
+ - Scene wrappers use `class="clip"` with `data-start`, `data-duration`,
170
+ `data-track-index`.
171
+ - Register exactly one timeline synchronously:
172
+ `window.__timelines["<composition-id>"] = gsap.timeline({ paused: true })`.
173
+ - Animate only transform/opacity/color/filter/clip-path properties.
174
+ - No `repeat: -1`; use finite repeats for caret blink.
175
+ - Put the full-bleed background on a child `position:absolute; inset:0`, not on
176
+ the root element.
177
+ - Keep all IDs unique.
178
+ - No `<br>` inside paragraph copy.
179
+
180
+ Minimal root shape:
181
+
182
+ ```html
183
+ <div id="root" data-composition-id="mo3ta-5s"
184
+ data-width="1920" data-height="1080"
185
+ data-start="0" data-duration="5" data-fps="30">
186
+ <div class="stage clip" data-start="0" data-duration="5" data-track-index="0">
187
+ <!-- scenes -->
188
+ </div>
189
+ </div>
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 8. Build and verification commands
195
+
196
+ Run from the workspace directory:
197
+
198
+ ```bash
199
+ cd "$REPO/video/mo3ta-coverage-5s"
200
+ $HF lint .
201
+ $HF check . --at 0.5,1.5,3.0,4.5 --no-contrast
202
+ $HF snapshot . --at 0.5,1.5,3.0,4.5
203
+ $HF render . -o "$REPO/video/renders/mo3ta-coverage-5s.mp4" -q standard -f 30
204
+ ```
205
+
206
+ Repeat for `mo3ta-coverage-15s` with sample times `1,3,6,9,12,14.5`.
207
+
208
+ Verify every render:
209
+
210
+ ```bash
211
+ ffprobe -v error \
212
+ -show_entries format=duration,size:stream=codec_name,width,height,r_frame_rate \
213
+ -of default=noprint_wrappers=1 \
214
+ "$REPO/video/renders/mo3ta-coverage-5s.mp4"
215
+ ```
216
+
217
+ Acceptance:
218
+
219
+ - 5s file duration `5.0 ± 0.05s`.
220
+ - 15s file duration `15.0 ± 0.05s`.
221
+ - 1920×1080, ~30 fps, `h264`, sensible file size.
222
+ - `lint` has 0 errors. `check` has no errors (contrast may be deferred during
223
+ iteration, but should be re-run before calling the cut final).
224
+ - Keyframe snapshots readable at 100% zoom: no clipped text, no overlapping
225
+ cards, no black frames.
226
+ - CTA command is legible and correctly spelled.
227
+
228
+ ---
229
+
230
+ ## 9. Checklist
231
+
232
+ ### Discovery
233
+ - [x] Locate the OpenMontage vendor/skill.
234
+ - [x] Read HyperFrames core contract and OpenMontage HyperFrames guide.
235
+ - [x] Verify Node 24, FFmpeg 8.1.1, cached Chrome, cached HyperFrames CLI.
236
+ - [x] Pick 16:9 / 1080p / 30 fps / no-audio delivery.
237
+ - [x] Lock the storyboard, copy, and visual tokens above.
238
+
239
+ ### 5s teaser
240
+ - [x] Create `video/mo3ta-coverage-5s/` + `hyperframes.json`.
241
+ - [x] Author `index.html` (hook → command → smart graph → result).
242
+ - [x] `lint` passes with 0 errors.
243
+ - [x] `check` / snapshots reviewed at 0.5s, 1.5s, 3.0s, 4.5s.
244
+ - [x] Render `video/renders/mo3ta-coverage-5s.mp4`.
245
+ - [x] Verify duration / resolution / fps with `ffprobe`.
246
+ - [x] Share the 5s cut for approval before starting the 15s.
247
+
248
+ ### 15s explainer
249
+ - [x] Create `video/mo3ta-coverage-15s/` + `hyperframes.json`.
250
+ - [x] Author `index.html` (hook → problem → smart graph → coverage → verdict → CTA).
251
+ - [x] `lint` passes with 0 errors.
252
+ - [x] `check` / snapshots reviewed across all six beats.
253
+ - [x] Render `video/renders/mo3ta-coverage-15s.mp4`.
254
+ - [x] Verify duration / resolution / fps with `ffprobe`.
255
+
256
+ ### Wrap-up
257
+ - [x] Add `/video/renders/` to `.gitignore`; add `/video` to `.npmignore`.
258
+ - [ ] Link both MP4s from `README.md` (optional).
259
+ - [ ] Commit the plan and workspaces (renders stay local).
260
+ - [x] Share final paths with the user.
261
+
262
+ ---
263
+
264
+ ## 10. Handoff notes
265
+
266
+ ### Status (2026-11-19)
267
+
268
+ Both cuts are **rendered and verified**:
269
+
270
+ | Output | Duration | Resolution | FPS | Codec | Size |
271
+ | --- | --- | --- | --- | --- | --- |
272
+ | `video/renders/mo3ta-coverage-5s.mp4` | 5.000s | 1920×1080 | 30 | h264 | 578 KB |
273
+ | `video/renders/mo3ta-coverage-15s.mp4` | 15.000s | 1920×1080 | 30 | h264 | 1.1 MB |
274
+
275
+ `lint` → 0 errors on both. `check` → 0 errors on both; remaining items are
276
+ advisory warnings only (`nested_structure_needs_subcomposition` for the single
277
+ `#stage` clip, small-UI-type floor, and `line_unread` on transitional captions).
278
+ No blocking errors.
279
+
280
+ Implementation details worth knowing:
281
+
282
+ - Both workspaces load a local `gsap.min.js` (copied beside `index.html`), so
283
+ rendering works offline. Fonts still come from the Google Fonts `@import`
284
+ and are cached in `~/.cache/hyperframes/fonts`.
285
+ - `hyperframes check` flagged an over-short final hold on the 15s end card, so
286
+ the end card was pulled forward and the CTA command shortened to
287
+ `npx mo3ta-coverage --mode smart`. The full command with `--base origin/main`
288
+ still appears in the 5s teaser's typing beat.
289
+ - Frame 0 was intentionally made non-empty in both cuts by keeping the hook
290
+ visible and animating only transforms (no initial opacity 0 on `#hook`).
291
+ - Snapshot contact sheets live under each workspace's
292
+ `.hyperframes/artifacts/snapshots/` (git-ignored along with the rest of
293
+ `.hyperframes/`).
294
+ - `video/renders/` is git-ignored; `/video` is npm-ignored so MP4s and
295
+ workspaces never ship in the published package.
296
+
297
+ ### Optional next steps
298
+
299
+ - Add a short README section linking the MP4s.
300
+ - Commit `VIDEO_PLAN.md` and both `video/mo3ta-coverage-*/` workspaces
301
+ (leave `video/renders/` local).
302
+ - If a voiceover or music bed is wanted later, add it in HyperFrames/FFmpeg;
303
+ current cuts are intentionally silent and caption-free so they loop cleanly
304
+ in a README or social post.
305
+
306
+ ### Product references
307
+
308
+ - Source of truth for the product behavior is `src/fileUtils.js` and
309
+ `src/cli.js`; smart mode = naming matches + reverse-import walk to
310
+ `--depth` (default 2).
311
+ - The 5s piece stands alone without narration.
312
+ - If the cached CLI is missing on another machine, use
313
+ `npx --yes hyperframes@0.9.23`; `doctor` must pass Node/FFmpeg/Chrome before
314
+ rendering.
315
+ - Do not switch to Remotion or FFmpeg silently. If HyperFrames fails, report the
316
+ blocker and get approval before downgrading runtime.
Binary file
@@ -0,0 +1,131 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900" viewBox="0 0 1600 900" role="img" aria-labelledby="title desc">
2
+ <title id="title">mo3ta-coverage — modes and features</title>
3
+ <desc id="desc">Poster listing the fast, smart, and full execution modes and the main features of mo3ta-coverage.</desc>
4
+
5
+ <defs>
6
+ <linearGradient id="bgGlow" x1="0" y1="0" x2="0" y2="1">
7
+ <stop offset="0%" stop-color="#10131a"/>
8
+ <stop offset="100%" stop-color="#0f1115"/>
9
+ </linearGradient>
10
+ <radialGradient id="topGlow" cx="50%" cy="0%" r="70%">
11
+ <stop offset="0%" stop-color="#60a5fa" stop-opacity="0.20"/>
12
+ <stop offset="100%" stop-color="#60a5fa" stop-opacity="0"/>
13
+ </radialGradient>
14
+ <radialGradient id="greenGlow" cx="100%" cy="100%" r="60%">
15
+ <stop offset="0%" stop-color="#22c55e" stop-opacity="0.10"/>
16
+ <stop offset="100%" stop-color="#22c55e" stop-opacity="0"/>
17
+ </radialGradient>
18
+ <pattern id="grid" width="52" height="52" patternUnits="userSpaceOnUse">
19
+ <path d="M52 0H0V52" fill="none" stroke="#ffffff" stroke-opacity="0.035" stroke-width="1"/>
20
+ </pattern>
21
+ <filter id="cardShadow" x="-20%" y="-20%" width="140%" height="160%">
22
+ <feDropShadow dx="0" dy="18" stdDeviation="24" flood-color="#000000" flood-opacity="0.45"/>
23
+ </filter>
24
+ <style>
25
+ .sans { font-family: Inter, -apple-system, "Helvetica Neue", Arial, sans-serif; }
26
+ .mono { font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; }
27
+ .muted { fill: #9aa0a6; }
28
+ .bright { fill: #f4f7fb; }
29
+ .accent { fill: #60a5fa; }
30
+ </style>
31
+ </defs>
32
+
33
+ <!-- background -->
34
+ <rect width="1600" height="900" fill="url(#bgGlow)"/>
35
+ <rect width="1600" height="900" fill="url(#grid)"/>
36
+ <rect width="1600" height="900" fill="url(#topGlow)"/>
37
+ <rect width="1600" height="900" fill="url(#greenGlow)"/>
38
+
39
+ <!-- header -->
40
+ <g class="sans">
41
+ <g transform="translate(72, 78)">
42
+ <rect x="0" y="-26" width="286" height="46" rx="23" fill="#60a5fa" fill-opacity="0.09" stroke="#60a5fa" stroke-opacity="0.42"/>
43
+ <circle cx="28" cy="-3" r="5" fill="#22c55e"/>
44
+ <text x="46" y="4" class="mono" font-size="15" letter-spacing="3.2" fill="#60a5fa">PR COVERAGE · SMART MODE</text>
45
+ </g>
46
+
47
+ <text x="72" y="188" class="bright" font-size="76" font-weight="800" letter-spacing="-3.2">mo3ta-coverage</text>
48
+ <text x="74" y="238" class="muted" font-size="28" letter-spacing="-0.4">Changed code. Related specs. Real coverage.</text>
49
+ </g>
50
+
51
+ <!-- modes -->
52
+ <g class="sans">
53
+ <text x="72" y="308" class="mono" font-size="15" letter-spacing="3.4" fill="#60a5fa">MODES</text>
54
+
55
+ <!-- fast -->
56
+ <g filter="url(#cardShadow)">
57
+ <rect x="72" y="330" width="460" height="196" rx="18" fill="#1a1c22" stroke="#2a2d35"/>
58
+ </g>
59
+ <text x="102" y="382" class="mono" font-size="15" letter-spacing="2.4" fill="#38bdf8">FAST</text>
60
+ <text x="102" y="425" class="bright" font-size="26" font-weight="700">Direct mapped tests</text>
61
+ <text x="102" y="461" class="muted" font-size="18">Naming convention + direct import scan.</text>
62
+ <text x="102" y="489" class="muted" font-size="18">No dependency traversal.</text>
63
+ <text x="102" y="518" class="mono" font-size="15" fill="#7dd3fc">--mode fast</text>
64
+
65
+ <!-- smart -->
66
+ <g filter="url(#cardShadow)">
67
+ <rect x="562" y="330" width="460" height="196" rx="18" fill="#1a1c22" stroke="#60a5fa" stroke-opacity="0.85"/>
68
+ </g>
69
+ <rect x="878" y="352" width="118" height="30" rx="15" fill="#60a5fa" fill-opacity="0.14" stroke="#60a5fa" stroke-opacity="0.45"/>
70
+ <text x="895" y="372" class="mono" font-size="12" letter-spacing="1.6" fill="#60a5fa">DEFAULT</text>
71
+ <text x="592" y="382" class="mono" font-size="15" letter-spacing="2.4" fill="#60a5fa">SMART</text>
72
+ <text x="592" y="425" class="bright" font-size="26" font-weight="700">Naming + reverse imports</text>
73
+ <text x="592" y="461" class="muted" font-size="18">Finds specs through barrels and wrappers.</text>
74
+ <text x="592" y="489" class="muted" font-size="18">Depth-limited by --depth (default 2).</text>
75
+ <text x="592" y="518" class="mono" font-size="15" fill="#93c5fd">--mode smart --depth 2</text>
76
+
77
+ <!-- full -->
78
+ <g filter="url(#cardShadow)">
79
+ <rect x="1052" y="330" width="460" height="196" rx="18" fill="#1a1c22" stroke="#2a2d35"/>
80
+ </g>
81
+ <text x="1082" y="382" class="mono" font-size="15" letter-spacing="2.4" fill="#a78bfa">FULL</text>
82
+ <text x="1082" y="425" class="bright" font-size="26" font-weight="700">Jest finds related tests</text>
83
+ <text x="1082" y="461" class="muted" font-size="18">Passes changed files to Jest directly.</text>
84
+ <text x="1082" y="489" class="muted" font-size="18">Unbounded --findRelatedTests walk.</text>
85
+ <text x="1082" y="518" class="mono" font-size="15" fill="#c4b5fd">--mode full</text>
86
+ </g>
87
+
88
+ <!-- features -->
89
+ <g class="sans">
90
+ <text x="72" y="598" class="mono" font-size="15" letter-spacing="3.4" fill="#60a5fa">FEATURES</text>
91
+
92
+ <!-- column 1 -->
93
+ <g transform="translate(72, 638)">
94
+ <circle cx="6" cy="-6" r="4" fill="#22c55e"/>
95
+ <text x="26" y="0" font-size="21" class="bright">Detects changed JS/TS files for all authors</text>
96
+
97
+ <circle cx="6" cy="42" r="4" fill="#22c55e"/>
98
+ <text x="26" y="48" font-size="21" class="bright">Runs only the tests related to the change</text>
99
+
100
+ <circle cx="6" cy="90" r="4" fill="#22c55e"/>
101
+ <text x="26" y="96" font-size="21" class="bright">Maps specs by name and by import graph</text>
102
+
103
+ <circle cx="6" cy="138" r="4" fill="#22c55e"/>
104
+ <text x="26" y="144" font-size="21" class="bright">Scans selected files with --files</text>
105
+ </g>
106
+
107
+ <!-- column 2 -->
108
+ <g transform="translate(876, 638)">
109
+ <circle cx="6" cy="-6" r="4" fill="#22c55e"/>
110
+ <text x="26" y="0" font-size="21" class="bright">Checks changed-line coverage from lcov.info</text>
111
+
112
+ <circle cx="6" cy="42" r="4" fill="#22c55e"/>
113
+ <text x="26" y="48" font-size="21" class="bright">Fails below the --limit threshold</text>
114
+
115
+ <circle cx="6" cy="90" r="4" fill="#22c55e"/>
116
+ <text x="26" y="96" font-size="21" class="bright">Reports every uncovered changed line</text>
117
+
118
+ <circle cx="6" cy="138" r="4" fill="#22c55e"/>
119
+ <text x="26" y="144" font-size="21" class="bright">Works locally and in CI</text>
120
+ </g>
121
+ </g>
122
+
123
+ <!-- footer command -->
124
+ <rect x="72" y="790" width="1456" height="62" rx="14" fill="#14161c" stroke="#2a2d35"/>
125
+ <text x="102" y="829" class="mono" font-size="19" fill="#9aa0a6">$</text>
126
+ <text x="124" y="829" class="mono" font-size="19" fill="#e6e6e6">npx mo3ta-coverage</text>
127
+ <text x="334" y="829" class="mono" font-size="19" fill="#60a5fa">--mode smart</text>
128
+ <text x="482" y="829" class="mono" font-size="19" fill="#9aa0a6">--base origin/main</text>
129
+ <text x="706" y="829" class="mono" font-size="19" fill="#9aa0a6">--limit 80</text>
130
+ <text x="1476" y="829" class="mono" font-size="14" fill="#22c55e" text-anchor="end">changed lines only</text>
131
+ </svg>
package/index.js CHANGED
@@ -36,6 +36,8 @@ program
36
36
  .option('--showCovered <bool>', 'Show covered changed lines in the output', false)
37
37
  .option('--mode <mode>', 'Execution mode: fast, smart, or full', 'smart')
38
38
  .option('--depth <number>', 'Smart mode max reverse-dependency depth (1 = direct importers, 2 = also importers of importers)', '2')
39
+ .option('--files <files...>', 'Scan only these files instead of detecting changed files (space- or comma-separated)')
40
+ .option('--filesFrom <path>', 'Read the list of files to scan from a newline-separated file')
39
41
  .enablePositionalOptions(); // used to allow using same options in subcommands
40
42
 
41
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mo3ta-coverage",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Run tests and report uncovered changed lines in a PR",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -25,7 +25,18 @@ export function main(options) {
25
25
 
26
26
  console.log(`Options:\nBase Branch: ${BASE_BRANCH} \nLCOV Path: ${LCOV_PATH} \nCoverage Limit: ${COVERAGE_LIMIT} \nShow Covered Lines: ${SHOW_COVERED} \nMode: ${MODE} \nDepth: ${DEPTH}`);
27
27
 
28
- const changedFiles = getChangedFiles(BASE_BRANCH);
28
+ const explicitFiles = getExplicitFiles(options);
29
+ let changedFiles;
30
+
31
+ if (explicitFiles.length > 0) {
32
+ // A base branch is still needed to compute the changed lines of each file.
33
+ verifyBaseBranchExists(BASE_BRANCH);
34
+ console.log(`Scanning ${explicitFiles.length} explicitly provided file(s) (git changed-file detection skipped):\n${explicitFiles.join('\n')}`);
35
+ changedFiles = explicitFiles;
36
+ } else {
37
+ changedFiles = getChangedFiles(BASE_BRANCH);
38
+ }
39
+
29
40
  runRelatedTests(changedFiles, MODE, DEPTH);
30
41
  reportUncoveredChangedLines(changedFiles, LCOV_PATH, BASE_BRANCH, COVERAGE_LIMIT, SHOW_COVERED);
31
42
  } catch (error) {
@@ -35,17 +46,83 @@ export function main(options) {
35
46
  }
36
47
 
37
48
 
38
- function getChangedFiles(BASE_BRANCH) {
49
+ /**
50
+ * Normalizes a user-provided file list into repo-relative paths.
51
+ * Accepts an array or a comma-separated string, trims entries, removes
52
+ * duplicates, converts absolute paths under `root` to relative ones, and
53
+ * drops dependency/build artifacts.
54
+ * @param {string|string[]} input
55
+ * @param {string} [root]
56
+ * @returns {string[]}
57
+ */
58
+ export function normalizeExplicitFiles(input, root = process.cwd()) {
59
+ const values = Array.isArray(input) ? input : [input];
60
+
61
+ const files = values
62
+ .flatMap(value => String(value ?? '').split(','))
63
+ .map(file => file.trim())
64
+ .filter(Boolean)
65
+ .map(file => {
66
+ const absolute = path.resolve(root, file);
67
+ const relative = path.relative(root, absolute);
68
+ // Keep paths outside the repo root as provided.
69
+ if (relative.startsWith('..') || path.isAbsolute(relative)) return file;
70
+ return relative;
71
+ })
72
+ .map(file => file.replace(/\\/g, '/'))
73
+ .filter(file => !file.match(/(^|\/)(node_modules|coverage|dist|build)\/|(^|\/)\.git\//));
74
+
75
+ return Array.from(new Set(files));
76
+ }
77
+
78
+ /**
79
+ * Reads a newline-separated list of files (for example the output of
80
+ * `git diff --name-only`) from disk.
81
+ * @param {string} listPath
82
+ * @param {string} [root]
83
+ * @returns {string[]}
84
+ */
85
+ export function readExplicitFilesFromFile(listPath, root = process.cwd()) {
86
+ const absolute = path.resolve(root, listPath);
87
+ const content = fs.readFileSync(absolute, 'utf8');
88
+ return normalizeExplicitFiles(content.split(/\r?\n/), root);
89
+ }
90
+
91
+ /**
92
+ * Resolves the files to scan from CLI options. Returns an empty array when
93
+ * the user did not provide an explicit list.
94
+ * @param {{files?: string|string[], filesFrom?: string}} options
95
+ * @returns {string[]}
96
+ */
97
+ export function getExplicitFiles(options = {}) {
98
+ const files = [];
99
+
100
+ if (options.files !== undefined && options.files !== null && options.files !== false) {
101
+ files.push(...normalizeExplicitFiles(options.files));
102
+ }
103
+
104
+ if (options.filesFrom) {
105
+ files.push(...readExplicitFilesFromFile(options.filesFrom));
106
+ }
107
+
108
+ return Array.from(new Set(files));
109
+ }
110
+
111
+ export function getChangedFiles(BASE_BRANCH) {
39
112
  // Check if BASE_BRANCH exists
40
113
  verifyBaseBranchExists(BASE_BRANCH);
41
114
 
42
- const command = `(
43
- git log --pretty=format: --name-only --diff-filter=AM --author="$(git config user.name)" $(git merge-base HEAD ${BASE_BRANCH})..HEAD
44
- git diff --name-only --diff-filter=AM
45
- git diff --cached --name-only --diff-filter=AM
46
- ) | sort -u`;
47
-
115
+ // Compare the merge base with HEAD so every file changed on this branch is
116
+ // included, regardless of which author committed it.
48
117
  try {
118
+ const mergeBase = execSync(`git merge-base HEAD ${BASE_BRANCH}`).toString().trim();
119
+
120
+ const command = `(
121
+ git diff --name-only --diff-filter=AM ${mergeBase}..HEAD
122
+ git diff --name-only --diff-filter=AM
123
+ git diff --cached --name-only --diff-filter=AM
124
+ ) | sort -u`;
125
+
49
126
  const output = execSync(command).toString();
50
127
  const changedFiles = output
51
128
  .split('\n')
package/src/cli.test.js CHANGED
@@ -1,10 +1,15 @@
1
1
  import fs from 'fs';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
+ import { execSync } from 'child_process';
4
5
  import {
5
6
  classifyChangedLineCoverage,
6
7
  formatMissedLinesSummary,
8
+ getChangedFiles,
9
+ getExplicitFiles,
10
+ normalizeExplicitFiles,
7
11
  parseLcov,
12
+ readExplicitFilesFromFile,
8
13
  summarizeCoverageResult
9
14
  } from './cli.js';
10
15
 
@@ -111,3 +116,125 @@ describe('formatMissedLinesSummary', () => {
111
116
  expect(formatMissedLinesSummary([])).toEqual([]);
112
117
  });
113
118
  });
119
+
120
+ describe('normalizeExplicitFiles', () => {
121
+ it('accepts a comma-separated string', () => {
122
+ expect(normalizeExplicitFiles('src/a.js,src/b.ts')).toEqual([
123
+ 'src/a.js',
124
+ 'src/b.ts'
125
+ ]);
126
+ });
127
+
128
+ it('accepts an array of paths', () => {
129
+ expect(normalizeExplicitFiles(['src/a.js', 'src/b.ts'])).toEqual([
130
+ 'src/a.js',
131
+ 'src/b.ts'
132
+ ]);
133
+ });
134
+
135
+ it('trims, drops empty entries, and removes duplicates', () => {
136
+ expect(normalizeExplicitFiles([' src/a.js ', '', 'src/a.js', 'src/b.js'])).toEqual([
137
+ 'src/a.js',
138
+ 'src/b.js'
139
+ ]);
140
+ });
141
+
142
+ it('converts absolute paths under the root to relative paths', () => {
143
+ const root = path.resolve('/tmp/project');
144
+
145
+ expect(normalizeExplicitFiles([path.join(root, 'src/a.js')], root)).toEqual([
146
+ 'src/a.js'
147
+ ]);
148
+ });
149
+
150
+ it('drops dependency and build artifacts', () => {
151
+ expect(normalizeExplicitFiles([
152
+ 'src/a.js',
153
+ 'node_modules/pkg/index.js',
154
+ 'coverage/lcov-report/x.js',
155
+ 'dist/bundle.js',
156
+ 'build/out.js'
157
+ ])).toEqual(['src/a.js']);
158
+ });
159
+ });
160
+
161
+ describe('readExplicitFilesFromFile', () => {
162
+ it('reads a newline-separated list from disk', () => {
163
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mo3ta-files-'));
164
+ const listPath = path.join(tempDir, 'files.txt');
165
+ fs.writeFileSync(listPath, 'src/a.js\nsrc/b.ts\n\n');
166
+
167
+ expect(readExplicitFilesFromFile(listPath, tempDir)).toEqual([
168
+ 'src/a.js',
169
+ 'src/b.ts'
170
+ ]);
171
+
172
+ fs.rmSync(tempDir, { recursive: true, force: true });
173
+ });
174
+ });
175
+
176
+ describe('getExplicitFiles', () => {
177
+ it('returns an empty list when no explicit options are provided', () => {
178
+ expect(getExplicitFiles({})).toEqual([]);
179
+ });
180
+
181
+ it('combines --files and --filesFrom, removing duplicates', () => {
182
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mo3ta-files-'));
183
+ const listPath = path.join(tempDir, 'files.txt');
184
+ fs.writeFileSync(listPath, 'src/b.js\nsrc/a.js\n');
185
+
186
+ expect(getExplicitFiles({
187
+ files: ['src/a.js'],
188
+ filesFrom: listPath
189
+ })).toEqual(['src/a.js', 'src/b.js']);
190
+
191
+ fs.rmSync(tempDir, { recursive: true, force: true });
192
+ });
193
+ });
194
+
195
+ describe('getChangedFiles', () => {
196
+ let tempDir;
197
+ let originalCwd;
198
+
199
+ beforeEach(() => {
200
+ originalCwd = process.cwd();
201
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mo3ta-git-'));
202
+
203
+ execSync('git init -b main -q', { cwd: tempDir });
204
+ execSync('git config user.name "Base Author"', { cwd: tempDir });
205
+ execSync('git config user.email "base@example.com"', { cwd: tempDir });
206
+
207
+ fs.writeFileSync(path.join(tempDir, 'base.js'), 'export const base = 1;\n');
208
+ execSync('git add base.js && git commit -q -m "base"', { cwd: tempDir });
209
+ execSync('git checkout -q -b feature', { cwd: tempDir });
210
+
211
+ process.chdir(tempDir);
212
+ });
213
+
214
+ afterEach(() => {
215
+ process.chdir(originalCwd);
216
+ fs.rmSync(tempDir, { recursive: true, force: true });
217
+ });
218
+
219
+ it('includes changed files regardless of the commit author', () => {
220
+ fs.writeFileSync(path.join(tempDir, 'by-other.js'), 'export const other = 1;\n');
221
+ execSync('git add by-other.js && git -c user.name="Other Dev" -c user.email="other@example.com" commit -q -m "other author"', { cwd: tempDir });
222
+
223
+ fs.writeFileSync(path.join(tempDir, 'by-me.js'), 'export const me = 1;\n');
224
+ execSync('git add by-me.js && git commit -q -m "current author"', { cwd: tempDir });
225
+
226
+ const result = getChangedFiles('main');
227
+
228
+ expect(result).toEqual(['by-me.js', 'by-other.js']);
229
+ });
230
+
231
+ it('includes uncommitted and staged changes', () => {
232
+ fs.writeFileSync(path.join(tempDir, 'base.js'), 'export const base = 2;\n');
233
+ fs.writeFileSync(path.join(tempDir, 'staged.js'), 'export const b = 1;\n');
234
+ execSync('git add staged.js', { cwd: tempDir });
235
+
236
+ const result = getChangedFiles('main');
237
+
238
+ expect(result).toEqual(['base.js', 'staged.js']);
239
+ });
240
+ });