Repository navigation
feat(comments): the codemod for the mechanical sweep tiers, and two fixes it exposed - #105
Merged
Merged
Conversation
…ixes it exposed `comment-sweep.mjs` does the three tiers of a comment sweep that need no judgement: collapse a three-line banner to one line keeping its label, collapse a one-line JSDoc block to a one-line JSDoc, and delete a comment whose every word the next line already says. Tier 5 — compressing a bloated *why* — stays with a model that has read the code, and is deliberately not here. Proven on SahajCloud: 90 files, 1,347 deletions, 426 insertions, and `comment-fingerprint.mjs` reports all 90 codeHash-identical with every protected count unchanged. Two defects in the already-merged tools, both found by running them: **`leafTokens` treated JSDoc as code.** TypeScript hangs a `JSDoc` node off the declaration it documents and `getChildren()` returns it, so a doc comment entered the token stream. Every JSDoc edit then looked like it moved the next comment: collapsing one block reported `// --- Constants ---` below it as DISPLACED in a file whose code was untouched. Six false positives on one run. The walk now skips the JSDoc subtree. **`--repo` refused a relative path.** `createRequire` needs an absolute one, so `--repo .` threw. Fixed in all three tools. The sweep rules each earned a guard by damaging something real first, and each guard is named in its own comment: - banners are exempt, because a label repeats the identifiers below it — the unguarded rule deleted the banners tier 1 had just written - trailing comments are exempt, because they carry what a literal cannot say about itself (`width: 0, // Dimension extraction disabled`) - only an isolated comment is eligible, because a `//` run is one comment wearing several line markers — scoring its last line alone deleted `// listing.` off a four-line rationale - tier 2 takes only a block whose prose is exactly one line, after splitting on sentence punctuation joined two facts into a run-on Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge this before the SahajCloud sweep PR — that PR's diff is this tool's output.
What it does
comment-sweep.mjsruns the three sweep tiers that need no judgement:Tier 5 is deliberately absent. Compressing a bloated why down to the fact a reader needs requires a model that has read the surrounding code. The point of this tool is that the model spends its attention there instead of on scaffolding.
Two defects in the already-merged tools, both found by running them
leafTokenstreated JSDoc as code. TypeScript hangs aJSDocnode off the declaration it documents, andgetChildren()returns it — so a doc comment entered the token stream the anchor check compares. Every JSDoc edit then looked like it had moved the next comment. Collapsing one block reported// --- Constants ---below it asDISPLACED, in a file whose code was provably untouched. Six false positives in one run. The walk now skips the JSDoc subtree.--reporefused a relative path.createRequireneeds an absolute one, so--repo .threw. Fixed in all three tools.Every sweep rule earned its guard by breaking something first
This is the part worth reviewing. Each guard exists because the unguarded rule damaged real comments on a real run, and each is documented in its own comment:
width: 0, // Dimension extraction disabledandmeditationTitleMap: Map<…> // meditation title → Meditation IDboth died to the unguarded rule.//run is one comment wearing several line markers. Scoring its last line alone deleted// listing.off the end of a four-line rationale, leaving "a region manager cannot act on the".Admin password for seed scripts authenticationtoMinimum 8 charactersproduced a run-on with two facts and no punctuation between them.The pattern is the asymmetry the cleanup rule already states: wrongly deleting a real comment costs far more than leaving a mediocre one, so every ambiguous case reports a candidate instead of acting. Tier 3 surfaced 294 candidates on SahajCloud and deleted 17 files' worth.
Verification
comment-fingerprint.mjs --selftest— 9/9, both directionscomment-lint.mjs --selftest— 11/11, catching and sparingclaude plugin validate ./workflow --strict— passesVersion
2.1.0→2.2.0.🤖 Generated with Claude Code