Skip to content

feat: add list-wallets command#35

Merged
rolznz merged 3 commits into
masterfrom
worktree-list-wallets
May 28, 2026
Merged

feat: add list-wallets command#35
rolznz merged 3 commits into
masterfrom
worktree-list-wallets

Conversation

@rolznz
Copy link
Copy Markdown
Member

@rolznz rolznz commented May 25, 2026

Closes #24

Adds a list-wallets command for users managing multiple NWC wallets. It scans ~/.alby-cli for configured wallets and reports each wallet's name and connection status.

Behaviour

  • Lists the default (unnamed) wallet and any --wallet-name wallets.
  • Reports status as connected or pending (awaiting wallet approval). When both files exist for a name, connected wins.
  • Default wallet sorts first; named wallets are sorted alphabetically.
  • Only wallet names and status are reported — secret file contents are never read or exposed.

Example

{
  "directory": "/home/user/.alby-cli",
  "wallets": [
    { "name": null, "isDefault": true, "status": "connected" },
    { "name": "personal", "isDefault": false, "status": "connected" },
    { "name": "test", "isDefault": false, "status": "pending" }
  ]
}

Changes

  • src/utils.ts — new listWallets() and getAlbyCliDir() helpers; refactored existing ~/.alby-cli path construction to use getAlbyCliDir().
  • src/commands/list-wallets.ts — new command, registered in the Setup group.
  • src/commands/auth.ts — use getAlbyCliDir() helper.
  • src/index.ts — wire up the command.
  • src/test/list-wallets.test.ts — 7 tests.
  • README.md — documented under "Multiple wallets".

Verification

  • tsc --noEmit clean, build succeeds.
  • All 7 new tests pass.
  • Command appears correctly in help under Setup.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added list-wallets CLI command to display configured wallets and their connection status (connected or pending).
  • Documentation

    • Updated README with list-wallets command usage example and description.

Review Change Stack

Closes #24

Adds a `list-wallets` command that scans ~/.alby-cli for configured
wallets and reports their name and connection status. Useful for users
managing multiple NWC wallets via --wallet-name.

Only wallet names and status (connected/pending) are reported; secret
file contents are never read or exposed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@rolznz, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 10 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0cb32000-6abe-43e4-9181-4552b1ed20d2

📥 Commits

Reviewing files that changed from the base of the PR and between ee4f722 and 26a04d5.

📒 Files selected for processing (5)
  • .claude/worktrees/fix-already-connected-msg
  • README.md
  • src/commands/auth.ts
  • src/index.ts
  • src/utils.ts
📝 Walkthrough

Walkthrough

This PR adds a list-wallets CLI command to enumerate configured wallets by scanning the .alby-cli directory. It introduces centralized directory path utilities (getAlbyCliDir()) and wallet discovery logic (listWallets()), refactors existing code to use them, wires the command into the CLI, and includes comprehensive tests and documentation.

Changes

Add list-wallets CLI command with centralized directory utilities

Layer / File(s) Summary
Wallet discovery infrastructure
src/utils.ts
getAlbyCliDir() centralizes .alby-cli path resolution; WalletInfo interface and listWallets() scan the directory for connection/pending secret files, classify wallet status, ensure connected takes precedence, handle missing directories, and sort with default wallet first.
Centralize directory path usage
src/commands/auth.ts, src/utils.ts
auth.ts and saveConnectionSecret() switch from duplicating path construction to calling getAlbyCliDir() for pending connection storage and directory creation.
List-wallets CLI command
src/commands/list-wallets.ts, src/index.ts
New command module registers the list-wallets CLI entry point under the "Setup" group, fetches wallets via listWallets(), wraps with error handling, and renders output.
Tests and documentation
src/test/list-wallets.test.ts, README.md
Test suite covers empty state, default/named wallet sorting, status classification, secret non-disclosure, and file filtering; README documents the command with usage example.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • getAlby/cli#6: Both PRs modify src/utils.ts's connection-secret file-location logic under the ~/.alby-cli directory (main PR centralizes paths via getAlbyCliDir, retrieved PR adds a default fallback connection-secret key there).
  • getAlby/cli#12: The main PR's new list-wallets feature scans/labels wallet connection-secret files in ~/.alby-cli (via getAlbyCliDir()/listWallets()), which is the same directory and secret file that the retrieved PR's connect command writes (connection-secret.key).

Suggested reviewers

  • reneaaron
  • bumi

Poem

🐰 A bunny hops through CLI halls,
Listing wallets at her calls,
No secrets leaked, just status shown,
Connected wallets, all well-known! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add list-wallets command' clearly and concisely describes the main change: addition of a new CLI command for listing wallets.
Linked Issues check ✅ Passed The pull request successfully implements the list-wallets command [#24], enabling users to list configured NWC wallets and view their connection status.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the list-wallets command. The refactoring of path construction via getAlbyCliDir() is a supporting change for the feature.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-list-wallets

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.

❤️ Share

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

@rolznz
Copy link
Copy Markdown
Member Author

rolznz commented May 25, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
src/test/list-wallets.test.ts (1)

7-16: ⚡ Quick win

Import types from source to prevent type drift.

These interface definitions duplicate types that exist in src/utils.ts (per the PR summary). Duplicating types creates a maintenance risk: if the source types evolve, the test types won't automatically update, potentially masking type incompatibilities.

♻️ Proposed refactor to import types from source
+import type { WalletInfo, ListWalletsOutput } from "../utils.js";
 import { describe, test, expect, beforeEach, afterEach } from "vitest";
 import { runCli } from "./helpers.js";
 import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
 import { tmpdir } from "node:os";
 import { join } from "node:path";
-
-interface WalletInfo {
-  name: string | null;
-  isDefault: boolean;
-  status: "connected" | "pending";
-}
-
-interface ListWalletsOutput {
-  directory: string;
-  wallets: WalletInfo[];
-}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/list-wallets.test.ts` around lines 7 - 16, Replace the duplicated
test interfaces by importing the canonical types instead of redefining them:
remove the local WalletInfo and ListWalletsOutput interface declarations and add
an import-type for WalletInfo and ListWalletsOutput from the utils module where
they are defined; update any references in the test to use those imported types
so the test stays in sync with the source types.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/test/list-wallets.test.ts`:
- Around line 7-16: Replace the duplicated test interfaces by importing the
canonical types instead of redefining them: remove the local WalletInfo and
ListWalletsOutput interface declarations and add an import-type for WalletInfo
and ListWalletsOutput from the utils module where they are defined; update any
references in the test to use those imported types so the test stays in sync
with the source types.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc6fd7b8-9d08-4189-8338-989da7425f41

📥 Commits

Reviewing files that changed from the base of the PR and between d14bdc9 and ee4f722.

📒 Files selected for processing (6)
  • README.md
  • src/commands/auth.ts
  • src/commands/list-wallets.ts
  • src/index.ts
  • src/test/list-wallets.test.ts
  • src/utils.ts

@rolznz rolznz merged commit 91066d1 into master May 28, 2026
0 of 2 checks passed
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.

Add list-wallets command

1 participant