Skip to content

feat(cli): add update command and stop init from overwriting existing installs#26

Open
leonardobuares wants to merge 1 commit into
mmilanez:mainfrom
leonardobuares:feat-cli-update
Open

feat(cli): add update command and stop init from overwriting existing installs#26
leonardobuares wants to merge 1 commit into
mmilanez:mainfrom
leonardobuares:feat-cli-update

Conversation

@leonardobuares

Copy link
Copy Markdown
Contributor

Summary

Adds lead-protocol update, a safe upgrade path for existing installations,
and closes the destructive path where re-running init replaced the whole
.agents/ tree with blank templates, wiping project-layer files
(PROJECT_RULES.md, JOURNAL.md, decisions.jsonl, ...). The new command
implements 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): the update
    command. 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 in CLAUDE.md / AGENTS.md and re-checks the
    .gitignore entries. Supports --yes and --dry-run, reports every file
    as updated / created / unchanged, and lists framework-dir files
    absent from the bundled release as warnings without deleting them.
  • cli/src/commands/init.ts: with the protocol already installed, init now
    refuses (exit code 1) and points to update. A full reinstall stays
    available behind init --force, with an explicit warning listing the
    project-layer files that will be lost. Fresh installs are unchanged.
  • cli/src/lib/scaffold.ts (new): generateGuidelines and
    ensureGitignoreEntries moved out of init.ts so both commands share them.
  • cli/test/updater.test.mjs (new): 8 unit tests via native node --test
    (no new runtime dependencies) covering layer classification, overwrite,
    seed creation, project-layer skip and orphan reporting. New npm test
    script; tsup builds lib/updater.ts as its own entry so the suite
    imports the exact code that ships.
  • cli/scripts/test-pack.mjs: new end-to-end scenarios against the real
    packed tarball: update --dry-run writes nothing, update --yes refreshes
    the framework layer while preserving a customized PROJECT_RULES.md and an
    orphan module, plain init refuses on an existing install, and
    init --force --yes reinstalls from scratch.
  • cli/README.md: documents update and the new init behavior.
  • CHANGELOG.md: [2.2.0] entry; cli/package.json bumped 2.0.3 to
    2.2.0. Numbered 2.2.0 assuming feat: add first-run setup interview gate (PROTOCOL_RULES §P10) #22 ships as 2.1.0; if feat: add first-run setup interview gate (PROTOCOL_RULES §P10) #22 does not
    land first, this can be renumbered to 2.1.0.
  • @types/node added to the CLI dev dependencies: npm run typecheck
    previously failed on a clean checkout because the Node type definitions
    were never declared.

Testing

  • npm run typecheck passes (after the @types/node addition).
  • npm test: 8/8 unit tests pass against the built dist/lib/updater.js.
  • npm run test:pack passes 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.
  • Manual update --dry-run against a live installation correctly reported
    all framework files unchanged and all project-layer files untouched, and
    wrote nothing.

Checklist

  • Code follows project conventions
  • Tests added/updated (if applicable)
  • Documentation updated (if applicable)
  • Protocol files follow defined schemas (.agents/ was not modified)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add an update command; re-running init overwrites project-layer files

1 participant