feat: rename notifications command to emails (re-point to POST /api/emails)#24
Conversation
POST /api/notifications is being removed (chat#1815); /api/emails now defaults `to` to the account's own email when omitted (api#710), so the notifications command keeps its self-send behavior by posting to /api/emails with no `to`. Renames the --room-id flag to --chat-id and sends `chat_id` to match the /api/emails contract (docs#252). Requires api#710 to be live. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe PR replaces the notifications CLI command with an emails command, updates its options and request payload, changes the API endpoint and success message, registers the new command in the CLI entrypoint, and updates the command tests to match the new behavior. ChangesEmails command switch
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Per review on the docs/api alignment (chat#1815): the command now matches the
renamed docs (`recoup emails`) and the shipped /api/emails contract.
- Rename `notifications` command → `emails` (src/commands/emails.ts,
emailsCommand, Command("emails"), bin.ts registration, test file). No alias.
- `--subject` is now optional (.option, not .requiredOption) — api#710 made it
optional (defaults from the body); only set it in the body when provided.
- Endpoint already re-pointed to /api/emails; --chat-id already maps to chat_id.
75 tests green (incl. a new subject-omitted case); build succeeds.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed
75 tests green (incl. a new "subject omitted" case);
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/emails.ts (1)
5-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExport a command factory instead of a singleton
Command.This file now exports a configured
Commandinstance. Prefer exporting something likecreateEmailsCommand()and constructing the command inside it so the file matches the repo contract forsrc/**/*.ts.Suggested refactor
-export const emailsCommand = new Command("emails") - .description("Send an email to the account owner. The recipient is automatically resolved from your API key — no --to flag needed. --subject is optional (defaults from the body).") - .option("--subject <text>", "Email subject line (optional; defaults from the body)") - .option("--text <body>", "Plain text or Markdown body") - .option("--html <body>", "Raw HTML body (takes precedence over --text)") - .option("--cc <email>", "CC recipient (repeatable)", (val: string, prev: string[]) => prev.concat(val), [] as string[]) - .option("--chat-id <id>", "Chat ID for chat link in footer") - .option("--account <accountId>", "Send to a specific account (org keys only)") - .option("--json", "Output as JSON") - .action(async (opts) => { - try { - const body: Record<string, unknown> = {}; - if (opts.subject) body.subject = opts.subject; - if (opts.text) body.text = opts.text; - if (opts.html) body.html = opts.html; - if (opts.cc && opts.cc.length > 0) body.cc = opts.cc; - if (opts.chatId) body.chat_id = opts.chatId; - if (opts.account) body.account_id = opts.account; - - const data = await post("/api/emails", body); - - if (opts.json) { - printJson(data); - } else { - console.log(data.message || "Email sent."); - } - } catch (err) { - printError((err as Error).message); - } - }); +export function createEmailsCommand(): Command { + return new Command("emails") + .description("Send an email to the account owner. The recipient is automatically resolved from your API key — no --to flag needed. --subject is optional (defaults from the body).") + .option("--subject <text>", "Email subject line (optional; defaults from the body)") + .option("--text <body>", "Plain text or Markdown body") + .option("--html <body>", "Raw HTML body (takes precedence over --text)") + .option("--cc <email>", "CC recipient (repeatable)", (val: string, prev: string[]) => prev.concat(val), [] as string[]) + .option("--chat-id <id>", "Chat ID for chat link in footer") + .option("--account <accountId>", "Send to a specific account (org keys only)") + .option("--json", "Output as JSON") + .action(async (opts) => { + try { + const body: Record<string, unknown> = {}; + if (opts.subject) body.subject = opts.subject; + if (opts.text) body.text = opts.text; + if (opts.html) body.html = opts.html; + if (opts.cc && opts.cc.length > 0) body.cc = opts.cc; + if (opts.chatId) body.chat_id = opts.chatId; + if (opts.account) body.account_id = opts.account; + + const data = await post("/api/emails", body); + + if (opts.json) { + printJson(data); + } else { + console.log(data.message || "Email sent."); + } + } catch (err) { + printError((err as Error).message); + } + }); +}-import { emailsCommand } from "./commands/emails.js"; +import { createEmailsCommand } from "./commands/emails.js"; -program.addCommand(emailsCommand); +program.addCommand(createEmailsCommand());As per coding guidelines,
src/**/*.ts: Follow Single Responsibility Principle with one exported function per file.🤖 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/commands/emails.ts` around lines 5 - 29, The module currently exports a prebuilt emailsCommand singleton, but the repo expects one exported factory function per src/**/*.ts file. Refactor this file to export a createEmailsCommand() function that constructs and configures the Command inside the function, and update the existing command setup and .action handler to live within that factory while preserving the current emails behavior.Source: Coding guidelines
🤖 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/commands/emails.ts`:
- Around line 5-29: The module currently exports a prebuilt emailsCommand
singleton, but the repo expects one exported factory function per src/**/*.ts
file. Refactor this file to export a createEmailsCommand() function that
constructs and configures the Command inside the function, and update the
existing command setup and .action handler to live within that factory while
preserving the current emails behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e92f4b4f-0bf5-42fe-a8c3-64e51ec8eceb
📒 Files selected for processing (3)
__tests__/commands/emails.test.tssrc/bin.tssrc/commands/emails.ts
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/bin.ts">
<violation number="1" location="src/bin.ts:28">
P1: Custom agent: **Flag AI Slop and Fabricated Changes**
PR description claims the `notifications` command name is unchanged, but the code actually renames it to `emails`, contradicting the documented behavior and breaking existing users of `recoup notifications`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| program.addCommand(chatsCommand); | ||
| program.addCommand(songsCommand); | ||
| program.addCommand(notificationsCommand); | ||
| program.addCommand(emailsCommand); |
There was a problem hiding this comment.
P1: Custom agent: Flag AI Slop and Fabricated Changes
PR description claims the notifications command name is unchanged, but the code actually renames it to emails, contradicting the documented behavior and breaking existing users of recoup notifications.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/bin.ts, line 28:
<comment>PR description claims the `notifications` command name is unchanged, but the code actually renames it to `emails`, contradicting the documented behavior and breaking existing users of `recoup notifications`.</comment>
<file context>
@@ -25,7 +25,7 @@ program.addCommand(whoamiCommand);
program.addCommand(chatsCommand);
program.addCommand(songsCommand);
-program.addCommand(notificationsCommand);
+program.addCommand(emailsCommand);
program.addCommand(sandboxesCommand);
program.addCommand(orgsCommand);
</file context>
Re-points the CLI
notificationscommand from the soon-to-be-removedPOST /api/notificationstoPOST /api/emails, as part of the chat#1815 cleanup.Why
POST /api/notificationsis being deleted (api#711 / docs#253). Withtonow optional onPOST /api/emails— defaulting to the account's own email when omitted (api#710 / docs#252) — thenotificationscommand keeps its exact self-send behavior by posting to/api/emailswith noto.What changed (
src/commands/notifications.ts)post("/api/notifications", body)→post("/api/emails", body).--room-idflag →--chat-id; body keyroom_id→chat_id(matches the/api/emailscontract).--toflag — omittingtotriggers the account-own-email default, preserving "send to the account owner".The command name (
notifications) and all other flags (--subject,--text,--html,--cc,--account,--json) are unchanged.Tests (TDD, RED→GREEN)
Updated
__tests__/commands/notifications.test.tsto expect/api/emails+chat_id.pnpm test→ 74 passed (12 files);pnpm build(tsup) succeeds; grep forroom_id/api/notificationsinsrcis clean.Sequencing
Requires api#710 (
to-optional) live, and should merge before/with api#711 (the/api/notificationsdeletion) so the command never breaks.🤖 Generated with Claude Code
Summary by cubic
Renames the CLI command to emails and switches it from POST /api/notifications to POST /api/emails to keep self-send behavior. Also renames --room-id to --chat-id and makes --subject optional to match the emails API.
recoup emailsinstead ofrecoup notifications(no alias).--room-idwith--chat-idin any scripts.to.Written for commit e086785. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests