Repository navigation
fix: no silent overwrite in bootstrap/init (.charter/, .mcp.json) and adf init --force (#369, #370) - #373
Merged
Conversation
… adf init --force (#369, #370) #369: bootstrap never overwrites an existing .charter/ file (or SECURITY.md), whatever --yes/--force/--reset-adf say, and creates each missing file individually (a missing blessed-stack.json is recreated). .mcp.json's mcpServers.charter is replaced only under bootstrap --force, after backing .mcp.json up to .charter/.backup/mcp.json.<timestamp>; a failed backup leaves it as is with a warning. charter init --yes no longer overwrites; init --force (and setup --force) back each replaced file up to a gitignored .charter/.backup/ first, print "Replaced <file> (backup: <path>)", and add createdFiles/kept/replaced/notReplaced to JSON. #370: adf init --force merges the preset template exactly like bootstrap --force; new adf init --reset-adf replaces with confirmation, backups to .ai/.backup/ and a loss report. The scaffold write engine moved from bootstrap.ts to commands/adf-scaffold-write.ts, shared by both commands. adf init's fresh-directory output is byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed exits) - adf init --force / --reset-adf --yes on an empty .ai/ print exactly what plain adf init prints (text and JSON with nextActions); --emit-pointers lines follow the merge/reset report. - Replace the three /\/+$/ trailing-slash regexes (CodeQL js/polynomial-redos) with one loop-based dirLabel helper. - setup --force and init --guided --force exit 1 when every backup failed, like init --force; setup text names created/kept files. - A .backup/.gitignore that cannot be written is a warning everywhere (tryEnsureBackupGitignore), never a failed step. - init JSON: files stays [] for an existing .charter/ without --force. - Bootstrap phase 2 keeps platform separators in Created/kept paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…set-adf) - blessed-stack.json is compared as JSON with generatedAt ignored, so an untouched copy is never reported kept or backed up and replaced. - setup JSON includes init warnings; init text on an existing .charter/ always prints warnings; a fresh adf init --force/--reset-adf prints engine warnings (stderr under JSON) instead of dropping them. - --reset-adf with nothing to replace (empty or absent .ai/) needs no confirmation in adf init and bootstrap alike (resetAdf kind nothing-to-replace). - init / init --guided print the "Created .charter/ directory" banner only on success. - dirLabel keeps "/" for a root dir; tests for dirLabel, phase-3 gitignore failure, phase-2 separators and setup JSON warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When every backup fails and init / init --guided exit 1 without the success banner, the files the run did create are now still listed as Created. Docs: the nothing-to-replace rule also covers an .ai/ whose files all still match the template. Tests: exit-1 Created lines (plain and guided), whitespace-only differences count as nothing to replace, and bootstrap --reset-adf without --yes and no .ai/ keeps a hand-edited .charter/. 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 #369
Closes #370
#369:
--yesnever overwrites.charter/or.mcp.jsonbootstrap(no flag,--yes,--forceor--reset-adf) never overwrites an existing.charter/*file orSECURITY.md. It creates each missing file on its own: before,initializeCharterreturned early whenconfig.jsonexisted, so a deletedblessed-stack.jsonwas never recreated. No JSON key-merge:loadConfigalready fills defaults.Createdonly for files it actually wrote, and oneKept existing …line for files it left as is.setup.details.keptis added to JSON..mcp.jsonmcpServers.charteris replaced only underbootstrap --force(not--yes). Before it replaces an existing, differing entry, bootstrap copies.mcp.jsonto.charter/.backup/mcp.json.<timestamp>, using bootstrap --force replaces a hand-edited manifest.adf with the template (custom triggers, RULES, METRICS lost) #354's timestamp style. If the backup fails, the entry is not replaced and a warning is printed. Output:Updated .mcp.json (backup: …), plussetup.details.mcpBackupin JSON. The skip warning now says--yes alone never doesand mentions the backup.charter init --yesno longer overwrites.charter init --force, andsetup --forcefor consistency, is the explicit replace path:.charter/.backup/<name-with-slashes-flattened>.<timestamp>, for examplepatterns-blessed-stack.json.<ts>.Replaced <file> (backup: <path>).createdFiles,kept,replaced,notReplaced. setup's JSON gainsreplacedandnotReplacedwhen they are non-empty..charter/.backup/is gitignored by the existingensureBackupGitignore, which now takes a parent dir.GITIGNORE_CONTENTis unchanged.init --guidedappends its auth policy only to agovernance.mdthat this run wrote.#370:
adf init --forcemerges; newadf init --reset-adf.adf.lockhandling, the VENDORS carry-over and the reset confirmation/refusal moved out ofbootstrap.tsintocommands/adf-scaffold-write.ts. The new module is parameterized by scaffold list, manifest template, command name used in hints, and lock mode.bootstrapandadfInitboth call it. Bootstrap's phase-3 behavior and output are unchanged, and all existing bootstrap tests pass unmodified.adf init --forceuses exactly bootstrap's merge semantics:MANIFEST_EXCLUDED_KEYS)charter adf init --reset-adf --yesadf init --reset-adfneeds--yesor a y at the TTY prompt. Otherwise it exits 1 and writes nothing..ai/.backup/first. A failed backup means that file is not replaced, and exit 1 if none could be.Replaced .ai/x (backup: …)followed by theformatLossLinesreport.mode,scaffolds,replaced,warnings, and under reset alsonotReset,backupGitignore,resetAdf.{}lock, so rust-wasm still gets frontend+backend. Fresh-dir output is byte-identical: I snapshotted stdout plus every file for 19 preset/format/flag combinations before and after the change, and they match apart from telemetry timestamps. A test also pins the exact output.--emit-pointersand--moduleare unchanged. The no-op hint names--force(merge) and--reset-adf(replace).adf.tsis 1029/1041 measured lines (base 1027). No ceiling was changed.Docs
index.tsandadf --help.docs/cli-reference.md: bootstrap, setup, init and adf init sections, plus the global flag table. The telemetry-untracking note no longer claims that a re-run rewrites.charter/.gitignore.docs/upgrading-to-2.0.md,docs-snippets/charter-cli-reference.md.CHANGELOG.md[Unreleased]: a lead paragraph with the migration, plus Changed and Fixed entries next to the bootstrap --force replaces a hand-edited manifest.adf with the template (custom triggers, RULES, METRICS lost) #354 ones.Tests
New
no-silent-overwrite.test.ts, 30 tests:--yes/--forcekeeps hand-edited.charter/files byte-for-byte, recreates a deletedblessed-stack.json, and keepsSECURITY.md.--yesleaves the entry unchanged and warns.--forcereplaces it with a gitignored backup and keeps other keys. A failed backup leaves it unchanged.--reset-adf --yesalone does not replace it.init --yesdoes not overwrite.init --forcewrites backups, printsReplacedand fills the JSON field. A backup failure leaves files unchanged with exit 1; this is simulated with a regular file at.charter/.backup.setup --forcebacks up before replacing.--reset-adf: non-TTY and JSON refusals, TTY n/y,--yeswith backups and the loss report, JSON fields, and a total backup failure exits 1.adf-init.test.ts: the old "overwrites with--force" test now covers--force(keeps the file) and--reset-adf --yes(replaces it with a backup).Full suite: 1560 pass, 3 fail. The 3 failures are Windows-host-only path assertions in
bootstrap.test.ts(#307 premisepath.isAbsolute),context-refresh.test.tsandserve-context.test.ts, all expecting/separators. They are unrelated to this change.🤖 Generated with Claude Code