Repository navigation
fix(migrate): resolve pointer templates at call time, not module load (#355) - #381
Merged
Merged
Conversation
…#355) adf-migrate built POINTER_TEMPLATES when it loaded, but the CLI loads it through index -> doctor -> adf -> adf-migrate while adf.ts is still initialising, so every template was undefined and `adf migrate --replace` wrote the generic pointer to GEMINI.md, AGENTS.md and the rest. Look the template up when the pointer is written, as restoreTemplate does. The new test imports ../index first so it sees the same cycle the binary does. No other module in the cycle reads adf.ts constants at load time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st default mode Review of #381: the generic pointer was written in migrate's default (coexist) mode and by bootstrap's migrate step too, not only under --replace. Correct the entry and cover default mode in the cycle test. 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 #355
Problem
adf-migrate.tsbuiltPOINTER_TEMPLATESat module load, from constants thatadf.tsexports. The CLI loadsindex→doctor→adf→adf-migrate, soadf.tswas only half-initialised at that point and every template wasundefined. As a result the CLI wrote the generic "This project uses [ADF]…" pointer instead of the named template:charter adf migratein the default mode:GEMINI.md,AGENTS.md,.cursorrules,copilot-instructions.mdcharter adf migrate --replace: the same files, plusCLAUDE.mdUnit tests that import
adf-migratedirectly never hit the cycle, so they passed.Fix
The module-level table is replaced with
pointerTemplateFor(baseName), which looks the template up when the pointer is written. This is the same approach asrestoreTemplateinadf-vendor.ts,getPointerTemplatesinadf-tidy.tsandpointerTemplatesForinadf-compile.ts.I checked every module that imports from
./adf(adf-compile,adf-migrate,adf-populate,adf-tidy,adf-vendor,bootstrap,doctor,score) for reads of its constants at module scope.adf-migratewas the only one. The review confirmed this with an AST scan ofdist/.Tests
adf-migrate-pointer-cycle.test.tsimports../indexfirst. For bothGEMINI.mdandAGENTS.md, in the default mode and with--replace, it checks that the output starts with the named template and contains no generic pointer line. These cases fail onorigin/mainand pass with the fix.adf migrate --source GEMINI.mdand--source AGENTS.mdnow write the named templates.🤖 Generated with Claude Code