feat(cli): add update command and stop init from overwriting existing installs#26
Open
leonardobuares wants to merge 1 commit into
Open
feat(cli): add update command and stop init from overwriting existing installs#26leonardobuares wants to merge 1 commit into
leonardobuares wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
4 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.
Summary
Adds
lead-protocol update, a safe upgrade path for existing installations,and closes the destructive path where re-running
initreplaced the whole.agents/tree with blank templates, wiping project-layer files(
PROJECT_RULES.md,JOURNAL.md,decisions.jsonl, ...). The new commandimplements the three-layer state model the protocol already defines: the
framework layer is always refreshed, the project layer is never overwritten,
and per-pair state is never touched.
Closes #25.
Changes
cli/src/commands/update.ts+cli/src/lib/updater.ts(new): theupdatecommand. Framework layer (
CORE_RULES.md,PROTOCOL_RULES.md,modules/,schemas/,scripts/) is always refreshed to the bundled release;project-layer files are never overwritten, but missing project-layer seeds
are created;
.agents/local/is never touched. Refreshes the<lead-protocol>blocks inCLAUDE.md/AGENTS.mdand re-checks the.gitignoreentries. Supports--yesand--dry-run, reports every fileas
updated/created/unchanged, and lists framework-dir filesabsent from the bundled release as warnings without deleting them.
cli/src/commands/init.ts: with the protocol already installed,initnowrefuses (exit code 1) and points to
update. A full reinstall staysavailable behind
init --force, with an explicit warning listing theproject-layer files that will be lost. Fresh installs are unchanged.
cli/src/lib/scaffold.ts(new):generateGuidelinesandensureGitignoreEntriesmoved out ofinit.tsso both commands share them.cli/test/updater.test.mjs(new): 8 unit tests via nativenode --test(no new runtime dependencies) covering layer classification, overwrite,
seed creation, project-layer skip and orphan reporting. New
npm testscript;
tsupbuildslib/updater.tsas its own entry so the suiteimports the exact code that ships.
cli/scripts/test-pack.mjs: new end-to-end scenarios against the realpacked tarball:
update --dry-runwrites nothing,update --yesrefreshesthe framework layer while preserving a customized
PROJECT_RULES.mdand anorphan module, plain
initrefuses on an existing install, andinit --force --yesreinstalls from scratch.cli/README.md: documentsupdateand the newinitbehavior.CHANGELOG.md:[2.2.0]entry;cli/package.jsonbumped2.0.3to2.2.0. Numbered2.2.0assuming feat: add first-run setup interview gate (PROTOCOL_RULES §P10) #22 ships as2.1.0; if feat: add first-run setup interview gate (PROTOCOL_RULES §P10) #22 does notland first, this can be renumbered to
2.1.0.@types/nodeadded to the CLI dev dependencies:npm run typecheckpreviously failed on a clean checkout because the Node type definitions
were never declared.
Testing
npm run typecheckpasses (after the@types/nodeaddition).npm test: 8/8 unit tests pass against the builtdist/lib/updater.js.npm run test:packpasses end to end: builds, packs the exact npm tarball,installs it into a throwaway consumer and exercises
init / validate / status / update (dry-run and apply) / init guard /
init --force.
update --dry-runagainst a live installation correctly reportedall framework files unchanged and all project-layer files untouched, and
wrote nothing.
Checklist
.agents/was not modified)