fix(init): a re-run init backs up your edits and keeps your manual adds (PHARN-11) - #205
Merged
Merged
Conversation
…ds (PHARN-11) Reproduced: init, `pharn add a11y`, edit pharn-spec.md, init again, confirm -> the prompt listed 10 of 417 paths, no backup was made, the edit was lost, and a11y vanished from the config while its files stayed. The CLI itself points users at `init` as a repair, so this is a reachable path. - The overwrite prompt lists the files that differ from upstream first, marked "(edited)", and says they will be backed up. - runInstallArchetype re-scans right before the copy and copies every edited file to .pharn-backup/<ts>/ (the scanDest + createBackup pair `add` uses), naming the directory at creation. - init reads the config it replaces tolerantly and carries over its `source: manual` capabilities that upstream still ships — installed again and recorded `manual`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merged
8 of 11 tasks
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.
What this changes
Running
pharn initagain on a project that already has PHARN installed lost local edits and dropped capabilities the user had added by hand. Reproduced:init, thenpharn add a11y, then editpharn-spec.md.initagain and confirm the overwrite prompt.The prompt listed only 10 of the 417 existing paths ("…and 407 more"). No
.pharn-backup/was created, the edit was lost, anda11ydisappeared from the config while its files stayed on disk. This path is easy to reach, because the CLI itself tells users to runinitto recover from a legacy or broken config.steps/overwrite-check.ts): files that differ from upstream are listed first and marked(edited). The prompt also says how many there are and that they will be copied to.pharn-backup/first.steps/install-archetype.ts): immediately before copying,initscans the project again and copies each edited file to.pharn-backup/<ts>/. It prints the backup directory as soon as it is created. This uses the same scan and backup functions asadd(scanDest+createBackup).commands/init.ts):initreads the config it is about to replace and keeps everysource: "manual"capability that upstream still ships: it installs it again and records it asmanual. An unreadable or invalid old config never blocksinit; in that case nothing is carried over.docs/commands/init.mdandCLAUDE.mdupdated.Built with
/pharn-dev-ship; stage artifacts are in.dev/features/reinit-preserve-edits/. Results:no-regressionsPASSType of change
feat— new stack option, wizard step, or command capabilityfix— bug fixdocs— docs-only changechore/refactor— tooling or internal restructure, no behavior changeArea(s) touched
commands/init | steps/overwrite-check | steps/install-archetype | docs
Checklist
.js-extension import convention.manual;initcarries a manual capability over.(edited)when files are byte-identical; a corrupt old config does not blockinit.docs/commands/init.md.Quality gates
npm run check+npm run test:coveragepass locally (1360/1360; non-root user, node 22).npm run build(left to CI).Notes for the reviewer
pharn.config.jsonis not part of the filesinitinstalls, so it is not backed up. Hand-added capabilities are carried over instead. Hand-editedmodels/seamblocks are still reset to defaults wheninitruns again; that was already the case before this PR, and the existingConfigParseErrormessage warns about it.🤖 Generated with Claude Code
https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
Generated by Claude Code