Skip to content

agent: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgra#18

Open
sweetmantech wants to merge 2 commits intomainfrom
agent/-u0ajm7x8fbr-cli---add-the-abi-1774105595692
Open

agent: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgra#18
sweetmantech wants to merge 2 commits intomainfrom
agent/-u0ajm7x8fbr-cli---add-the-abi-1774105595692

Conversation

@sweetmantech
Copy link
Copy Markdown
Contributor

@sweetmantech sweetmantech commented Mar 21, 2026

Automated PR from coding agent.

Prompt: @U0AJM7X8FBR CLI - add the ability for users to create an account, upgrade to pro, and create and delete their api keys

Summary by CodeRabbit

  • New Features

    • Added accounts command with create and upgrade subcommands for managing accounts (prints upgrade URL).
    • Added keys command with list, create, and delete subcommands for managing API keys (list shows table-like output).
    • Both commands support --json for JSON-formatted output.
    • Added HTTP DELETE capability for API requests.
  • Tests

    • Added comprehensive tests covering create/upgrade and keys list/create/delete flows, success/error handling, and JSON output.

- Add `recoup accounts create --email/--wallet` — creates or retrieves account via POST /api/accounts
- Add `recoup accounts upgrade` — prints the Pro upgrade URL
- Add `recoup keys list` — lists API keys via GET /api/keys
- Add `recoup keys create --name` — creates an API key via POST /api/keys
- Add `recoup keys delete --id` — deletes an API key via DELETE /api/keys
- Add `del()` to client.ts for DELETE requests with body
- 18 new tests, all passing (92 total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1465848a-76dd-452e-a970-fcc12e226a5f

📥 Commits

Reviewing files that changed from the base of the PR and between 8b090df and 7581abd.

📒 Files selected for processing (4)
  • __tests__/commands/accounts.test.ts
  • __tests__/commands/keys.test.ts
  • src/commands/accounts.ts
  • src/commands/keys.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/commands/accounts.test.ts
  • src/commands/accounts.ts
  • src/commands/keys.ts
  • tests/commands/keys.test.ts

📝 Walkthrough

Walkthrough

Adds two new CLI commands—accounts and keys—plus a new del HTTP client function, registers the commands in the CLI entrypoint, and introduces Vitest suites covering both command modules and their behaviors.

Changes

Cohort / File(s) Summary
HTTP Client
src/client.ts
Added exported del(path: string, body: Record<string, unknown>) to perform DELETE requests, parse JSON, and surface API errors.
Accounts command
src/commands/accounts.ts
New accountsCommand with create (requires --email or --wallet, posts to /api/accounts, supports --json) and upgrade (prints upgrade URL); uses post and printError/printJson.
Keys command
src/commands/keys.ts
New keysCommand with list (GET /api/keys, table or --json), create (requires --name, posts { key_name }, expects data.key), and delete (requires --id, uses del); all operations handle errors via printError.
CLI registration
src/bin.ts
Imported and registered accountsCommand and keysCommand with the commander program.
Tests
__tests__/commands/accounts.test.ts, __tests__/commands/keys.test.ts
Added Vitest test suites that mock the HTTP client (get/post/del), spy on console and process.exit, and verify success, JSON output, validation errors, and API failure handling.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as "accounts/keys Command"
    participant Client as "HTTP Client (get/post/del)"
    participant API as "Remote API"

    User->>CLI: Run command with flags
    CLI->>CLI: Validate options
    alt validation fails
        CLI->>User: print error & exit(1)
    else
        CLI->>Client: call get/post/del(endpoint, body?)
        Client->>API: send HTTP request (GET/POST/DELETE)
        API-->>Client: return JSON response
        alt API indicates error
            Client->>CLI: throw/error
            CLI->>User: print error & exit(1)
        else
            CLI->>CLI: format output (table or JSON)
            CLI->>User: print result
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hooray! I hopped and wrote a test,

Accounts and keys now work their best.
DELETEs performed and JSON gleams,
CLI hums along in rabbit dreams. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is truncated and incomplete—it ends with 'upgra' instead of finishing the thought about account creation and upgrades. Complete the title to clearly describe the feature. Consider: 'Add accounts and keys CLI commands for account creation, upgrade, and API key management' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/-u0ajm7x8fbr-cli---add-the-abi-1774105595692

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.

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 `@src/commands/accounts.ts`:
- Around line 26-28: The code prints account?.account_id directly, which yields
"undefined" when the API response lacks account_id; update the handling around
the account variable (the Record<string, unknown> named account and the
console.log(account?.account_id) call) to check for the presence of account and
account.account_id and output a clear fallback or error message instead (e.g.,
"Account ID not found" or return a non-zero exit/error), so users don't see an
ambiguous "undefined".

In `@src/commands/keys.ts`:
- Around line 66-68: The current else branch prints console.log(data.message)
which can output "undefined" if message is missing; update the handler in
src/commands/keys.ts that contains the console.log(data.message) to safely fall
back to a meaningful string (e.g., data.error, data.detail, or
JSON.stringify(data)) when data.message is undefined; ensure you check for data
&& data.message first and then print the chosen fallback so the command never
prints "undefined".
- Around line 43-45: The current else branch prints data.key directly, which can
output "undefined" if the API response lacks a key; update the logic in the keys
command (the block that currently does "console.log(data.key)") to validate the
response by checking that data and data.key are present and non-empty, and if
not, print a clear explanatory message (e.g., "No key returned from API") and
exit with a non-zero status or return an error; ensure you reference and update
the same branch that currently logs data.key so callers get explicit feedback
instead of undefined.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eab26a55-85c0-44b2-8635-fd0c75876938

📥 Commits

Reviewing files that changed from the base of the PR and between a09929a and 8b090df.

📒 Files selected for processing (6)
  • __tests__/commands/accounts.test.ts
  • __tests__/commands/keys.test.ts
  • src/bin.ts
  • src/client.ts
  • src/commands/accounts.ts
  • src/commands/keys.ts

- accounts create: print error if account_id missing from API response
- keys create: print error if key missing from API response
- keys delete: fallback to data.error or JSON.stringify(data) if message is missing
- add tests for all three new error cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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