Repository navigation
Description
Problem
sampleOutput: true currently gives consumers, per changed file (src/core/fix-headers.mjs's FixHeadersResult.changes[].sample):
previousValue/newValue— the full header text blob, before and afterdetectedValues— the resolved fields fix-headers computed (authorName,authorEmail,companyName,copyrightStartYear,createdAt/lastModifiedAt, etc.)
There's no field-level comparison anywhere — changed is a single boolean rolled up across the whole header, and detectedValues only shows the new resolved values with nothing to say what the previous header actually had per field, or which specific field(s) differed.
This surfaced while onboarding @cldmv/droidsock's tools/fix-headers.mjs CLI wrapper: it advertised --verbose ("show per-file issue details") and --diff ("show unified diff output"), neither of which it actually implemented — both flags just print the list of changed filenames. Looking at what the library exposes, there's no reasonable way for a consumer to build either feature properly:
- A diff could technically be hand-rolled by a consumer running a diff algorithm over
previousValue/newValue, but that's reinventing the same computation in every consumer of a tool whose entire job is comparing old-vs-new header text. It belongs in the library that already holds both strings. - Per-file issue details (e.g. "author differs: found
X, expectedY", "copyright year stale") can't be built by a consumer at all — there's no structured previous-vs-detected comparison to reconstruct without re-parsingpreviousValueand guessing which text corresponds to which field.
Ask
Extend FixHeadersResult.changes[].sample (behind the existing sampleOutput option, so it stays opt-in/zero-cost by default) with:
- A ready-to-print unified diff string (
previousValuevsnewValue), so consumers don't each need their own diff dependency for this. - A structured per-field issues list, e.g.
{ field: "authorName", previous: "Foo", detected: "Bar" }[]— the comparison logic infix-headers.mjsaroundcomparisonReplacement/needsUpdate(src/core/fix-headers.mjs:~325) already has both the existing-header parse and the newly-detected values in scope at the point it decideschanged; this would be surfacing that existing internal comparison rather than computing something new.
Why here and not in the consumer
Filed against fix-headers rather than fixed in droidsock's wrapper: the raw data needed to build a real diff/per-field breakdown either already exists internally (previous vs. detected per field, at decision time) or is squarely this library's own domain (diffing header text it authored). A consumer-side workaround would either duplicate that internal comparison via fragile text-diffing, or require running a hand-rolled diff algorithm.
Activity
Shinrai commentedon Sep 27, 2026
Triage note: not implemented yet. The per-field half is a bit bigger than "surface an existing comparison" — the current code (
src/core/fix-headers.mjs) only parses the author identity, last-modified identity,@Dateand@Last modified timeout of the existing header. Project name, company and copyright year aren't parsed back, so those fields need new extractors. Also, the author/last-modified fields preserve the existing value unless forced, so they won't show "found X, expected Y" in a normal run.Open decision for the unified diff: pull in a runtime diff dependency (fix-headers currently depends only on
ignore) or hand-roll a small line-level diff for the header block.Shinrai commentedon Sep 28, 2026
Implementation started on
feat/sample-field-diff(offnext). The open decision is settled as a hand-rolled line-level diff of the header block, soignorestays the only runtime dependency.Behind
sampleOutputonly:sample.diff: a unified diff (---/+++/@@) of the previous vs new header; a file with no previous header shows the whole new header as added.sample.issues:{ field, previous, detected }[]for every header field whose written value differs from the existing one, with new extractors for project name, company and copyright. Author and last-modified identity are compared against what is actually written, so they only appear when they really change (i.e. when forced).--diffprints each changed file's diff;--verbose --sample-outputprints the per-field issues.fix: parse last-modified and copyright header fields without polynomi…
release: v2.0.0 - re-cut the release notes as v2.0.0