Skip to content

setup wizardry#109

Open
jaythegeek wants to merge 4 commits into
mainfrom
setup-wizard
Open

setup wizardry#109
jaythegeek wants to merge 4 commits into
mainfrom
setup-wizard

Conversation

@jaythegeek
Copy link
Copy Markdown
Contributor

@jaythegeek jaythegeek commented Apr 3, 2026

Summary by CodeRabbit

  • New Features

    • New setup command: guided project initialisation with agent discovery, skill adoption, health checks and machine-readable JSON output.
    • Added --canonicalise option to standardise adopted skills/packages.
  • Migration

    • Migration now supports single-file package types (agents/commands), a silent mode, and improved single-file handling.
  • Tests

    • Extensive new tests covering setup, adopt (including --canonicalise) and migrate behaviours.
  • Documentation

    • Guide for building and linking the CLI from source.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Adds a new interactive/non‑interactive setup CLI command (discovery, adoption, optional canonicalisation, health checks), wires it into the CLI, extends migrate/adopt for single‑file packages and canonicalisation, exports doctor helpers and new CLI result schemas, updates tests, and simplifies the dashboard storage provider switch.

Changes

Cohort / File(s) Summary
Setup command & tests
packages/cli/src/commands/setup.ts, packages/cli/src/__tests__/commands/setup.test.ts
New setup command with discovery, adoption, optional canonicalisation, health checks and comprehensive tests covering JSON, interactive, dry‑run, global scope and idempotency.
CLI registration
packages/cli/bin/agentver.ts
Registered the setup command by importing and calling registerSetupCommand(program).
Adopt command & tests
packages/cli/src/commands/adopt.ts, packages/cli/src/__tests__/commands/adopt.test.ts
Added --canonicalise option; call migrateSkills per newly adopted skill when enabled; exported helper types/functions formerly internal; tests updated to assert migration behaviour.
Migrate command & tests
packages/cli/src/commands/migrate.ts, packages/cli/src/__tests__/commands/migrate.test.ts
Expanded to handle single‑file package types (AGENT/COMMAND) with copy+unlink and file symlink logic, stricter placement checks, silent option, returns MigrationResult, and updated tests/mocks.
Doctor exports
packages/cli/src/commands/doctor.ts
Exported FixableDoctorCheck and several check/format functions; normalised JSON file writes to include trailing newline.
Shared CLI output schemas
packages/shared/src/cli-output.ts, packages/shared/src/index.ts
Added setupResultSchema and exported SetupResult type; barrel export updated.
Storage provider switch
apps/dashboard/src/lib/storage/index.ts
Removed explicit case 'local' branch so 'local' falls through to the default provider require('./providers/local') path.
Docs/plan
plans/2026-04-02-install-cli-locally-v1.md
New doc describing how to build and link the CLI locally (tsup/turbo/bun instructions and verification).

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as "agentver (CLI)"
    participant Setup as "setup command"
    participant Scanner as "Agent/Skill Scanner"
    participant Manifest as "Manifest/Lockfile (Storage)"
    participant Migrator as "migrateSkills"
    participant Doctor as "Doctor Checks"

    User->>CLI: run `agentver setup`
    CLI->>Setup: invoke setup handler
    Setup->>Scanner: detect agents & discover skills (project/global)
    Scanner-->>Setup: return agents & discovered items
    Setup->>Manifest: read manifest & lockfile
    Manifest-->>Setup: current managed items
    Setup->>User: display or emit discovered items (interactive or JSON)
    alt Adopt selected
        Setup->>Manifest: compute integrity & prepare entries
        Manifest-->>Setup: confirm writes
        Setup->>Manifest: write manifest & lockfile (unless dry‑run)
    end
    alt Canonicalise enabled
        Setup->>Migrator: call migrateSkills(...)
        Migrator-->>Setup: migration result
    end
    Setup->>Doctor: run health checks against manifest/storage
    Doctor-->>Setup: health check results
    Setup->>User: output final summary (JSON or formatted)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'setup wizardry' is vague and generic, using non-descriptive language that does not convey meaningful information about the substantial changes in the changeset. Consider a more specific title that describes the main change, such as 'Add setup command with per-package canonicalisation and silent migration mode' or 'Introduce setup wizard for automated skill discovery and adoption'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

…migration logic

The `pkg.packageType` index narrowing wasn't tracked by TS across variable
assignments, causing a TS2538 error. The migrate test for non-skill types
was asserting old skip-all behaviour instead of the new single-file
migration path for AGENT/COMMAND types.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/cli/src/__tests__/commands/migrate.test.ts (1)

831-854: ⚠️ Potential issue | 🟠 Major

Pipeline failure: Missing mock setup for AGENT package type.

The test fails because the getCanonicalSkillPath mock in beforeEach returns a hardcoded path for 'test-skill', but this test uses 'test-agent'. The mock needs to handle the skill name dynamically or be overridden for this test case.

The error "path" argument must be of type string. Received undefined indicates resolveReadPath or getCanonicalSkillPath returned undefined for 'test-agent'.

🐛 Proposed fix
   describe('non-skill package types', () => {
     it('skips AGENT type packages with a descriptive reason', async () => {
       vi.mocked(outputModule.isJSONMode).mockReturnValue(true)
       manifest = createManifest({
         packages: {
           'test-agent': createManifestPackage({
             source: { type: 'local', path: '/project/.claude/agents/test-agent' },
             packageType: 'AGENT',
           }),
         },
       })
+      vi.mocked(canonicalModule.getCanonicalSkillPath).mockReturnValue(
+        '/project/.agents/skills/test-agent'
+      )
+      vi.mocked(canonicalModule.resolveReadPath).mockReturnValue(
+        '/project/.claude/agents/test-agent'
+      )

       await migrateSkills(undefined, { yes: true })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/__tests__/commands/migrate.test.ts` around lines 831 - 854,
The failing test lacks a mock for getCanonicalSkillPath/resolveReadPath for the
package name 'test-agent', so update the test setup to return a valid path for
that name (or make the mock dynamic) before calling migrateSkills; specifically,
modify the mocked getCanonicalSkillPath used in the beforeEach (or override it
within this test) so that when migrateSkills inspects the manifest package
'test-agent' it receives a proper string path (e.g., map any input name to a
valid path or handle both 'test-skill' and 'test-agent'), ensuring
resolveReadPath/getCanonicalSkillPath do not return undefined.
packages/cli/src/commands/migrate.ts (1)

255-266: ⚠️ Potential issue | 🟠 Major

Local single-file packages keep a stale source.path.

For AGENT/COMMAND entries adopted via packages/cli/src/commands/setup.ts (Lines 249-263), the local source is stored as the parent directory and the filename lives in entryFile. readPath here is the entry file, so the source.path === readPath check never matches and the manifest/lockfile keep pointing at the pre-migration location.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/migrate.ts` around lines 255 - 266, The
manifest/lockfile update only checks if source.path === readPath, but
AGENT/COMMAND single-file packages store the local source as the parent
directory with the filename in entryFile, so the equality never matches; update
the checks in the migrate logic around manifestEntry and lockfileEntry to also
consider the parent directory form (e.g., treat source.path as matching if it
equals readPath OR equals path.dirname(readPath)), and when matched assign
source.path = canonicalPath (keeping the existing spread behavior) for both
manifestEntry and lockfileEntry so single-file local packages get their
source.path rewritten to the canonical location.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/__tests__/commands/setup.test.ts`:
- Around line 145-613: Add tests covering the canonicalisation and file-based
package code paths by calling runSetup with the --canonicalise flag (and
--yes/--json as needed), creating scanned files via createScannedFile that set
detectedType to 'AGENT' or 'COMMAND' and include file-based package paths, and
asserting outputModule.outputSuccess contains a canonicalised array and that
manifestModule.readManifest / pairModule.updateManifestAndLockfile are exercised
for AGENT/COMMAND adoption; also add at least one JSON-mode test verifying the
canonicalised entries appear in the JSON envelope and one interactive-mode test
that simulates prompts for canonicalisation choices so the branches in setup.ts
handling canonicalise and file-based packages are executed.

In `@packages/cli/src/commands/adopt.ts`:
- Around line 377-383: The adopt command calls migrateSkills when
options.canonicalise is set which causes duplicate JSON because migrateSkills
itself calls outputSuccess; add a new boolean flag (e.g., suppressOutput or
emitOutput) to the MigrateOptions type checked by migrateSkills, update
migrateSkills to skip calling outputSuccess when that flag is set, and from the
adopt implementation where migrateSkills is invoked (the block that checks
options.canonicalise and calls migrateSkills) pass suppressOutput: true so adopt
alone emits the final JSON via its outputSuccess call; ensure the new option is
optional and defaults to existing behavior to avoid breaking other callers.

In `@packages/cli/src/commands/migrate.ts`:
- Around line 241-244: The rollback logic for the single-file migration doesn't
remove partial symlinks created by createFileSymlinks(), so failed migrations
leave broken links; update the migration rollback to track and remove any
symlinks created before the error (or make createFileSymlinks() return the list
of created links and perform cleanup on failure); specifically modify the block
that calls createFileSymlinks(projectRoot, shortName, category, pkg.agents,
scope) (and the equivalent call around lines 275-277) so that on exception it
iterates the returned/recorded agent link paths and unlinkSync()s them before
restoring readPath and removing canonicalPath, ensuring no partial links remain.

In `@packages/cli/src/commands/setup.ts`:
- Around line 502-516: The setup command currently calls
migrateSkills(undefined, ...) which triggers a full-scope, command-level
migration and its own output/exit behavior; instead, invoke the lower-level
migration routine for only the adopted packages and suppress duplicate command
output. Replace the migrateSkills(undefined, { yes: true, global:
options.global, dryRun: false }) call from the setup flow (after
offerCanonicalisation) with a call that targets adopted (adopted.map(a =>
a.path) or similar) or use the internal per-package migration function used by
migrateSkills, and pass a flag/option to disable its standalone logging/JSON
emission so setup can build the canonicalised array accurately (ensure you
update the call site in setup.ts and use the same unique symbols migrateSkills,
offerCanonicalisation, and the adopted array).

In `@plans/2026-04-02-install-cli-locally-v1.md`:
- Line 64: The phrase "Stale build artifacts" and its later mention of `dist/`
use American spelling; update the wording to British English by replacing
"artifacts" with "artefacts" (e.g., change the bullet to "Stale build artefacts
— If `dist/` contains an older build, the linked binary will be outdated.") and
ensure any other occurrences of "artifact(s)" in this document use "artefact(s)"
consistently.
- Line 40: Replace the hardcoded developer-specific path
"/home/jaythegeek/code/agentver/agentver" in the
plans/2026-04-02-install-cli-locally-v1.md document with a generic placeholder
(for example "<monorepo-root>" or "your local clone of the repository") and
update the surrounding explanatory text to instruct users to substitute their
own clone path; ensure the literal string is replaced wherever it appears in
this file and adjust the heading/comment "# From monorepo root: ..." to read
something like "# From your local clone of the monorepo: <monorepo-root>" so the
document is portable for other contributors.

---

Outside diff comments:
In `@packages/cli/src/__tests__/commands/migrate.test.ts`:
- Around line 831-854: The failing test lacks a mock for
getCanonicalSkillPath/resolveReadPath for the package name 'test-agent', so
update the test setup to return a valid path for that name (or make the mock
dynamic) before calling migrateSkills; specifically, modify the mocked
getCanonicalSkillPath used in the beforeEach (or override it within this test)
so that when migrateSkills inspects the manifest package 'test-agent' it
receives a proper string path (e.g., map any input name to a valid path or
handle both 'test-skill' and 'test-agent'), ensuring
resolveReadPath/getCanonicalSkillPath do not return undefined.

In `@packages/cli/src/commands/migrate.ts`:
- Around line 255-266: The manifest/lockfile update only checks if source.path
=== readPath, but AGENT/COMMAND single-file packages store the local source as
the parent directory with the filename in entryFile, so the equality never
matches; update the checks in the migrate logic around manifestEntry and
lockfileEntry to also consider the parent directory form (e.g., treat
source.path as matching if it equals readPath OR equals path.dirname(readPath)),
and when matched assign source.path = canonicalPath (keeping the existing spread
behavior) for both manifestEntry and lockfileEntry so single-file local packages
get their source.path rewritten to the canonical location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 871a9a1a-e341-48be-8dee-1f36fe98c250

📥 Commits

Reviewing files that changed from the base of the PR and between ad37bc6 and 299d8fe.

⛔ Files ignored due to path filters (1)
  • packages/github-action/dist/index.js is excluded by !**/dist/**, !**/dist/**
📒 Files selected for processing (12)
  • apps/dashboard/src/lib/storage/index.ts
  • packages/cli/bin/agentver.ts
  • packages/cli/src/__tests__/commands/adopt.test.ts
  • packages/cli/src/__tests__/commands/migrate.test.ts
  • packages/cli/src/__tests__/commands/setup.test.ts
  • packages/cli/src/commands/adopt.ts
  • packages/cli/src/commands/doctor.ts
  • packages/cli/src/commands/migrate.ts
  • packages/cli/src/commands/setup.ts
  • packages/shared/src/cli-output.ts
  • packages/shared/src/index.ts
  • plans/2026-04-02-install-cli-locally-v1.md
💤 Files with no reviewable changes (1)
  • apps/dashboard/src/lib/storage/index.ts

Comment thread packages/cli/src/__tests__/commands/setup.test.ts
Comment thread packages/cli/src/commands/adopt.ts
Comment thread packages/cli/src/commands/migrate.ts
Comment thread packages/cli/src/commands/setup.ts Outdated
Comment thread plans/2026-04-02-install-cli-locally-v1.md Outdated
Comment thread plans/2026-04-02-install-cli-locally-v1.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/__tests__/commands/migrate.test.ts (1)

832-853: ⚠️ Potential issue | 🟡 Minor

Test update is correct, but missing coverage for AGENT/COMMAND migration paths.

The updated test correctly validates that PLUGIN (and other non-migratable types) are skipped with a descriptive reason. However, the implementation now supports migrating AGENT and COMMAND package types via copyFileSync/unlinkSync/createFileSymlinks, but there are no tests exercising this happy path.

Consider adding test cases that:

  1. Migrate an AGENT package using the single-file flow
  2. Verify copyFileSync and unlinkSync are called (not cpSync/rmSync)
  3. Verify createFileSymlinks is called instead of createAgentSymlinks
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/__tests__/commands/migrate.test.ts` around lines 832 - 853,
Add tests for the AGENT and COMMAND migration flows to exercise the new
single-file path: in the test file add a case that creates a manifest with
packageType 'AGENT' (and another for 'COMMAND') and calls migrateSkills(...),
then assert that fs.copyFileSync and fs.unlinkSync were invoked (and not
fs.cpSync or fs.rmSync), and assert that createFileSymlinks was called while
createAgentSymlinks was not; reference the migrateSkills function and the helper
functions copyFileSync, unlinkSync, cpSync, rmSync, createFileSymlinks,
createAgentSymlinks when locating where to add these assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/cli/src/__tests__/commands/migrate.test.ts`:
- Around line 832-853: Add tests for the AGENT and COMMAND migration flows to
exercise the new single-file path: in the test file add a case that creates a
manifest with packageType 'AGENT' (and another for 'COMMAND') and calls
migrateSkills(...), then assert that fs.copyFileSync and fs.unlinkSync were
invoked (and not fs.cpSync or fs.rmSync), and assert that createFileSymlinks was
called while createAgentSymlinks was not; reference the migrateSkills function
and the helper functions copyFileSync, unlinkSync, cpSync, rmSync,
createFileSymlinks, createAgentSymlinks when locating where to add these
assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e4e01a3d-f9f6-434e-9ddb-2d9d6e8eb029

📥 Commits

Reviewing files that changed from the base of the PR and between 299d8fe and 7b96949.

📒 Files selected for processing (2)
  • packages/cli/src/__tests__/commands/migrate.test.ts
  • packages/cli/src/commands/migrate.ts

…, and test coverage

- Add silent mode to migrateSkills to prevent duplicate JSON output when
  called from adopt/setup (fixes critical duplicate output bug)
- Change adopt/setup to migrate per-adopted-package instead of all packages
- Clean up partial file symlinks on rollback in migrate single-file path
- Fix stale source.path for single-file local packages (dirname comparison)
- Add test coverage for AGENT/COMMAND single-file migration paths
- Add test coverage for setup --canonicalise flag
- Fix British English spelling and hardcoded path in plan doc
@jaythegeek
Copy link
Copy Markdown
Contributor Author

Addressing all review feedback

All 8 review findings have been addressed in commits 7b96949 and 1792f32:

Critical fixes

  • Duplicate JSON output (adopt.ts, setup.ts) — Added silent mode to migrateSkills which suppresses all output. Both adopt and setup now call it with silent: true per-adopted-package instead of migrating everything in scope.
  • Setup migrates all packages (setup.ts) — Changed from migrateSkills(undefined, ...) to per-package calls, using actual migration results instead of guessed paths.

Major fixes

  • Symlink rollback (migrate.ts) — Catch block now calls removeFileSymlinks/removeAgentSymlinks to clean up partial symlinks on failure.
  • Stale source.path (migrate.ts) — Added dirname(readPath) comparison for single-file packages where source stores the directory, not the full path. Updates use dirname(canonicalPath) accordingly.
  • migrate.test.ts AGENT type — Already fixed in prior commit (changed test to use PLUGIN for skip-path, since AGENT is now a migratable single-file type).

Test coverage

  • AGENT/COMMAND migration — 2 new tests verifying copyFileSync/unlinkSync are used (not cpSync/rmSync), and createFileSymlinks is called with correct category.
  • Setup --canonicalise — 4 new tests covering silent migration calls, JSON output, no-canonicalise default, and dry-run guard.

Trivial

  • British English — "artifacts" → "artefacts"
  • Hardcoded path — Replaced with <monorepo-root> placeholder

All 2440 tests pass, types and lint clean.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
packages/cli/src/__tests__/commands/setup.test.ts (1)

619-712: ⚠️ Potential issue | 🟡 Minor

Add a file-based package case to the setup canonicalisation tests.

These cases still only drive detectedType: 'SKILL', so the new AGENT/COMMAND branch in setup.ts that sets entryFile/packageType is never exercised through runSetup(). A regression there would still pass this suite even though setup now owns file-based adoption as well as the migration hand-off. As per coding guidelines, "If new code paths were added (functions, endpoints, branches) but no corresponding tests exist, flag as SHOULD_FIX."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/__tests__/commands/setup.test.ts` around lines 619 - 712,
The tests only exercise SKILL-detected files so the new file-based adoption
branch in setup.ts (the AGENT/COMMAND branch that sets entryFile and
packageType) isn't covered; add a unit test in
packages/cli/src/__tests__/commands/setup.test.ts that uses
vi.mocked(agentDefs.scanForSkillFiles) to return a scanned file with
detectedType: 'AGENT' (or 'COMMAND') and a populated entryFile, then call
runSetup('--yes', '--canonicalise') and assert the code path runs by checking
migrateModule.migrateSkills was invoked and/or outputModule.outputSuccess
contains the canonicalised entry including packageType and entryFile; this will
exercise the branch in setup.ts that assigns entryFile/packageType and prevent
regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/adopt.ts`:
- Around line 377-385: adoptSkills() is calling migrateSkills() with global:
options.global which is the scan scope, not the write scope, causing migrate to
read the wrong manifest after adoption; change the calls to migrateSkills() to
use the actual scope where each entry was written (e.g., pass global: false for
entries written to the project manifest or true for entries written to the
global manifest) by either (A) tracking scope on each adopted entry (e.g.,
entry.scope or entry.isGlobal) and passing that as the global option to
migrateSkills(entry.name, { yes: true, global: entryScope, dryRun:
options.dryRun, silent: true }), or (B) decoupling the scan flag from migration
and always using the write-target scope (project) when adopt committed to the
project; apply the same fix to the other migrateSkills() calls referenced (lines
~425-435).

In `@packages/cli/src/commands/setup.ts`:
- Around line 424-448: The setupProject function incorrectly uses a single
shared scope variable for both scanning and persisting, causing --global to
still scan project-local files and potentially write project paths into the
global manifest; change the flow so scanning and persistence are done with
explicit scopes per source: keep discovery calls separate for project and global
(e.g., call discoverAgents/discoverSkills twice or add a source flag) or add
per-entry scope metadata when building the skills list, and ensure readManifest
is called with the matching scope for each pass; update any write/persist logic
to use the corresponding scope instead of the shared scope variable so
project-local entries are not added to the global manifest.

In `@plans/2026-04-02-install-cli-locally-v1.md`:
- Line 35: Update the verification checklist so the `agentver --help` output
explicitly includes the new `setup` command; specifically, change the bullet
that reads "`agentver --help` lists all registered commands (adopt, agents,
audit, backup, etc.)" to explicitly enumerate `setup` (e.g., include "setup" in
the list) and confirm the plan text mentions verifying `setup` appears when
running `agentver --help`.

---

Duplicate comments:
In `@packages/cli/src/__tests__/commands/setup.test.ts`:
- Around line 619-712: The tests only exercise SKILL-detected files so the new
file-based adoption branch in setup.ts (the AGENT/COMMAND branch that sets
entryFile and packageType) isn't covered; add a unit test in
packages/cli/src/__tests__/commands/setup.test.ts that uses
vi.mocked(agentDefs.scanForSkillFiles) to return a scanned file with
detectedType: 'AGENT' (or 'COMMAND') and a populated entryFile, then call
runSetup('--yes', '--canonicalise') and assert the code path runs by checking
migrateModule.migrateSkills was invoked and/or outputModule.outputSuccess
contains the canonicalised entry including packageType and entryFile; this will
exercise the branch in setup.ts that assigns entryFile/packageType and prevent
regressions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7780daef-1bb3-42df-9cbf-209b355ce299

📥 Commits

Reviewing files that changed from the base of the PR and between 7b96949 and 1792f32.

📒 Files selected for processing (7)
  • packages/cli/src/__tests__/commands/adopt.test.ts
  • packages/cli/src/__tests__/commands/migrate.test.ts
  • packages/cli/src/__tests__/commands/setup.test.ts
  • packages/cli/src/commands/adopt.ts
  • packages/cli/src/commands/migrate.ts
  • packages/cli/src/commands/setup.ts
  • plans/2026-04-02-install-cli-locally-v1.md

Comment thread packages/cli/src/commands/adopt.ts
Comment thread packages/cli/src/commands/setup.ts Outdated
Comment thread plans/2026-04-02-install-cli-locally-v1.md Outdated
…lisation

adopt always writes to project manifest, so migrateSkills must read from
project scope — passing global: false prevents NOT_FOUND on --global
--canonicalise. setup now scopes discovery to match the write target:
--global only scans global paths, preventing project-local files from
leaking into the global manifest.
Comment thread packages/cli/src/commands/adopt.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/adopt.ts`:
- Around line 377-385: The canonicalisation step currently runs
migrateSkills(...) for entries in the adopted array even during dry-run, causing
preview-only adoptions to be processed incorrectly; update both canonicalisation
blocks that check options.canonicalise (the one iterating over adopted and the
later block around 425-435) to first ensure !options.dryRun before calling
migrateSkills, i.e., only call migrateSkills(entry.name, {...}) when
options.canonicalise && !options.dryRun (preserving the existing flags
yes/global/dryRun/silent).

In `@packages/cli/src/commands/setup.ts`:
- Around line 427-430: Update the help text for the --global flag and any
related user-facing messages so they accurately reflect that options.global
toggles the entire setup flow to operate on the global Agentver state only (it
scans and writes the global state and does not leave any project-scoped entries
untouched); locate the flag usage and help strings referenced by the
setupProject function and the strings around where scope is computed (the scope
variable and any messages describing “project detection plus global extras”) and
change wording to explicitly state “scans and writes global Agentver state only”
or similar unambiguous text.

In `@plans/2026-04-02-install-cli-locally-v1.md`:
- Around line 28-35: Make the Step 4 text consistent with the Verification
Criteria by making `agentver --help` mandatory: update Step 4 so it reads that
you must run `agentver --version` and `agentver --help` (not optional) and
confirm `--help` lists all registered commands (including `setup`); ensure the
checklist and the earlier bullet that references `packages/cli/dist/agentver.js`
and `packages/cli/package.json` remain unchanged so the verification criteria
(`agentver --version` outputs 0.3.3 and `agentver --help` lists adopt, agents,
audit, backup, setup, etc.) align with the step.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0df521be-3920-41ac-8589-16d2b53f16ba

📥 Commits

Reviewing files that changed from the base of the PR and between 1792f32 and e9dd72c.

📒 Files selected for processing (4)
  • packages/cli/src/__tests__/commands/adopt.test.ts
  • packages/cli/src/commands/adopt.ts
  • packages/cli/src/commands/setup.ts
  • plans/2026-04-02-install-cli-locally-v1.md

Comment on lines +377 to +385
if (options.canonicalise && adopted.length > 0) {
for (const entry of adopted) {
await migrateSkills(entry.name, {
yes: true,
global: false,
dryRun: options.dryRun,
silent: true,
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Do not canonicalise preview-only adoptions.

Because adopted is populated before the write gate, Lines 379 and 429 still call migrateSkills() when options.dryRun is true. Those packages were never written to the manifest, so adopt --dry-run --canonicalise cannot produce a truthful preview and can fail on lookup. Guard both canonicalisation blocks behind !options.dryRun instead.

🩹 Suggested fix
-      if (options.canonicalise && adopted.length > 0) {
+      if (!options.dryRun && options.canonicalise && adopted.length > 0) {
         for (const entry of adopted) {
           await migrateSkills(entry.name, {
             yes: true,
             global: false,
             dryRun: options.dryRun,
             silent: true,
           })
         }
       }
...
-    if (options.canonicalise && adopted.length > 0) {
+    if (!options.dryRun && options.canonicalise && adopted.length > 0) {
       process.stdout.write(chalk.bold('\nCanonicalising adopted skills...\n'))
       for (const entry of adopted) {
         await migrateSkills(entry.name, {
           yes: true,
           global: false,
           dryRun: options.dryRun,
           silent: true,
         })
       }
     }

Also applies to: 425-435

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/adopt.ts` around lines 377 - 385, The
canonicalisation step currently runs migrateSkills(...) for entries in the
adopted array even during dry-run, causing preview-only adoptions to be
processed incorrectly; update both canonicalisation blocks that check
options.canonicalise (the one iterating over adopted and the later block around
425-435) to first ensure !options.dryRun before calling migrateSkills, i.e.,
only call migrateSkills(entry.name, {...}) when options.canonicalise &&
!options.dryRun (preserving the existing flags yes/global/dryRun/silent).

Comment on lines +427 to +430
async function setupProject(options: SetupOptions): Promise<void> {
const jsonMode = isJSONMode()
const projectRoot = process.cwd()
const scope: Scope = options.global ? 'global' : 'project'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Make the --global help text match the actual behaviour.

Line 430 switches the whole setup flow into global scope, but Line 580 still reads like “project detection plus global extras”. Please say explicitly that this flag scans and writes the global Agentver state only, otherwise users will expect project entries to stay in scope.

✏️ Suggested wording
-    .option('--global', 'Include global agent paths in detection')
+    .option(
+      '--global',
+      'Use the global scope only (scan global paths and use the global manifest/lockfile)'
+    )

Also applies to: 579-580

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/setup.ts` around lines 427 - 430, Update the help
text for the --global flag and any related user-facing messages so they
accurately reflect that options.global toggles the entire setup flow to operate
on the global Agentver state only (it scans and writes the global state and does
not leave any project-scoped entries untouched); locate the flag usage and help
strings referenced by the setupProject function and the strings around where
scope is computed (the scope variable and any messages describing “project
detection plus global extras”) and change wording to explicitly state “scans and
writes global Agentver state only” or similar unambiguous text.

Comment on lines +28 to +35
- [ ] **Step 4: Verify the installation** — Run `agentver --version` and confirm it outputs `0.3.3` (the current version in `packages/cli/package.json:3`). Optionally run `agentver --help` to verify all commands are registered correctly.

## Verification Criteria

- `bun install` completes without errors
- `packages/cli/dist/agentver.js` exists and starts with `#!/usr/bin/env node`
- `agentver --version` outputs `0.3.3`
- `agentver --help` lists all registered commands, including `setup` (adopt, agents, audit, backup, setup, etc.)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Align Step 4 with the verification criteria (don’t mark --help as optional).

Line 28 says agentver --help is optional, but Line 35 requires it as a pass condition (including setup). Make this mandatory in Step 4 to avoid ambiguous execution of the plan.

Suggested doc fix
-- [ ] **Step 4: Verify the installation** — Run `agentver --version` and confirm it outputs `0.3.3` (the current version in `packages/cli/package.json:3`). Optionally run `agentver --help` to verify all commands are registered correctly.
+- [ ] **Step 4: Verify the installation** — Run `agentver --version` and confirm it outputs `0.3.3` (the current version in `packages/cli/package.json:3`). Run `agentver --help` and confirm `setup` is listed with the other registered commands.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plans/2026-04-02-install-cli-locally-v1.md` around lines 28 - 35, Make the
Step 4 text consistent with the Verification Criteria by making `agentver
--help` mandatory: update Step 4 so it reads that you must run `agentver
--version` and `agentver --help` (not optional) and confirm `--help` lists all
registered commands (including `setup`); ensure the checklist and the earlier
bullet that references `packages/cli/dist/agentver.js` and
`packages/cli/package.json` remain unchanged so the verification criteria
(`agentver --version` outputs 0.3.3 and `agentver --help` lists adopt, agents,
audit, backup, setup, etc.) align with the step.

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.

1 participant