Repository navigation
fix(adf): adf fmt keeps the U+FE0F form of standard decorations (#351) - #383
Merged
Merged
Conversation
parseAdf drops U+FE0F after a decoration, and formatAdf emitted the parsed form, so adf fmt --write rewrote the scaffolds'⚠️ CONSTRAINTS (and 🗂️ FILES, 🛠️ TOOLS) to the text-style glyph. The formatter now emits the section's standard decoration whenever the parsed one equals it modulo U+FE0F. The text-patch writer (#371) uses the same canonicalDecoration helper, so the headers populate adds are byte-identical to adf fmt output. This repo's .ai/*.adf headers are rewritten to⚠️ CONSTRAINTS; .adf.lock refreshed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use an own-property lookup so a prototype key such as 'constructor' cannot reach String.replace on a non-string; spell U+FE0F as an escape instead of a literal invisible character; correct the VENDORS comment; and correct the CHANGELOG claim about adf sync (it hashes raw bytes, not the AST). Co-Authored-By: Claude Opus 5.5 <[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.
Closes #351
Problem
parseAdfdrops the U+FE0F variation selector after a section decoration, andformatAdfemitted the parsed form. The standard decorations forCONSTRAINTS(FILES(🗂️) andTOOLS(🛠️) include U+FE0F, soadf fmt --writerewrote every scaffold's⚠️ CONSTRAINTSheader to the text-style⚠, andadf fmt --checkflagged freshly scaffolded files.Fix (formatter side; the parser and AST are unchanged)
canonicalDecoration(key, decoration)in@stackbilt/adf(types/decorations.ts): it returnsSTANDARD_DECORATIONS[key]when the given decoration equals it apart from U+FE0F, and otherwise the decoration as given.formatAdfruns every explicit decoration through it. A null decoration still gets the standard one.adf-text-patch.ts(the adf populate re-adds deleted default CONSTRAINTS bullets on every bootstrap #371/fix(populate): leave an edited CONSTRAINTS section alone (#371) #378 workaround) now calls the same helper, so the headers thatpopulateadds are byte-identical to whatadf fmtemits. The re-parse guard is unaffected because both sides parse without U+FE0F. One behaviour change: a non-standard text-style decoration (e.g.⚙ NOTES) no longer gets a U+FE0F thatadf fmtwould then strip..ai/*.adf⚠ CONSTRAINTSheaders are rewritten to⚠️, and.ai/.adf.lockis refreshed (adf sync --checkpasses).Preserving a non-standard U+FE0F decoration exactly as the user wrote it would mean changing the parser/AST (parser_loc is capped), and every decoration comparison downstream would see the change. I left that out of scope.
Tests
formatter.test.ts: round-trip over everySTANDARD_DECORATIONSentry, checked byte for byte. Each entry is also tested written both with and without U+FE0F and must format to the standard form. Further cases: non-standard decorations are kept, a decoration that is standard for a different key is not rewritten, and unit tests forcanonicalDecoration.adf-populate.test.ts:ADD_SECTIONheaders written by text-patch are fixed points offormatAdf(parseAdf(...)).Checks
adf fmt --checkon.ai/*.adf: adf-dev, analysis, core, governance and state are clean. classifier.adf and manifest.adf still differ, but only in section order. typed-data-access.adf still differs because of a non-standard multi-word keySENSITIVITY TIERS. All three were non-canonical before this change, and none of the remaining differences involves a decoration.adf fmtoutput has the same lines as the file once order is ignored, so no decoration changes remain.--checkstill fails because the scaffold templates are not in canonical section order (CONSTRAINTS comes after CONTEXT/GUIDE, SYNC after ON_DEMAND). That was already the case before this PR, and the templates live in files other work is touching, so I left them alone.CHANGELOG
Under
[Unreleased] / Changed, with a note thatadf fmt --writeoutput changes for files with a bare⚠ CONSTRAINTS,🗂 FILESor🛠 TOOLSheader.🤖 Generated with Claude Code