Hunk classification: suggest evolution, value or block for every hunk - #13
Merged
Merged
Conversation
A saved plan may carry the suggested class per hunk; --plan never reads it, and a hand-mangled one is dropped instead of failing the plan.
One LCS for lines and for words, with the same tie-break; diffOps behaves as before.
A pure heuristic over the real hunk shapes: one-sided lines are blocks, a swap of identifier-like tokens is a value with a param.<slug>, and anything else is evolution.
diffIngredients is the single place hunks are classified, so forge diff, forge variants and --save-plan agree; a one-sided file counts as a block, keeping the sum at distance.hunks.
Each hunk header gains its class and reason (and the suggested params for a value), and each variant its counts by class, after the unchanged prefixes.
Nothing compared the committed plan with a fresh --save-plan; now it does, and the regenerated golden gains only the three suggestion lines.
The README rows and the --help texts of forge variants, forge diff and --save-plan name the suggested class and say it never decides anything.
A suffixed name could equal another token's own slug (acme_api_2); the suffix now grows until the name is free. The contract test covers every suggestion the corpus produces.
The README row said so; the option text did not.
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.
Summary
craftar@0.4.0to npm after approval in thenpmenvironment.evolution(one side is newer text),value(identifier-like tokens swapped inside shared prose, with a suggestedparam.<slug>) orblock(lines only one side has) — plus a reason from a closed set. A pure, deterministic heuristic insrc/core/classify.ts; a suggestion never decides anything.forge diffprints<class>: <reason>after the unchanged hunk header (and→ param.…for a value); its--jsonhunks gainsuggestion: {class, reason, tokens?}next tokind.forge variantsappends counts by class ([1 evolution · 2 block]) and its--jsongainsclasses, which add up todistance.hunks.--save-planannotates each hunk;--planignores the annotation (a mangled one is dropped).lcsOps);diffOpsbehaves as before.Emitted bytes
None change. No emitter, importer,
sync,statusorresolvecode is touched, so no workspace seesupdate. The only changed committed file outsidesrc//test/code is the golden unify plan, regenerated by its script: it gains exactly threesuggestionlines; the golden expected tree is unchanged.Test plan
npm run typecheck— passesnpm run build— passesnpx vitest run --exclude test/ci.test.ts(Linux) — 398 passed / 5 skippednode-cli-revieweranddocs-author: clean after one correction round (parameter names made unique within a hunk even when a suffix meets another token's slug; AC 2 contract test over the whole corpus;--save-planhelp text)