Skip to content

AIT-376: set and verify the alert phone from the CLI - #52

Merged
ord669 merged 9 commits into
mainfrom
ait-376-cli-alert-phone
Aug 11, 2026
Merged

AIT-376: set and verify the alert phone from the CLI#52
ord669 merged 9 commits into
mainfrom
ait-376-cli-alert-phone

Conversation

@ord669

@ord669 ord669 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The alert phone (AIT-370) could be set from the web launchpad dialog or through
MCP (set_alert_phone / verify_alert_phone / get_alert_phone_status), but
not from the terminal. A CLI-first user had to open a browser or drive an agent
to opt into breakage alerts.

Commands

hookmyapp alerts phone status          # masked number, delivery channel, what it receives
hookmyapp alerts phone set <phone>     # sends the code, prompts for it, verifies
hookmyapp alerts phone verify <code>   # finish a verification started earlier

set flags: --sms (deliver by SMS instead of WhatsApp), --product,
--marketing, --code <code> (skip the prompt, for scripts).

$ hookmyapp alerts phone status
No alert phone verified.
Run `hookmyapp alerts phone set +14155552671` so we can reach you when something breaks.

$ hookmyapp alerts phone set +14155552671
We sent a 6-digit code to +14155552671.
? Enter the code: ******
Verified. Alerts go to +141•••2671.

All three hit the existing user-scoped /auth/phone routes — no new API surface.

Three decisions worth review

Consents follow MCP, not the web dialog. Operational is on; product and
marketing are opt-in behind flags. A bare set must not silently consent
someone to marketing. Note this leaves the web dialog inconsistent — it
currently sends all three true after its consent checkboxes were removed.
That mismatch is tracked on AIT-366 and is not resolved here.

--json cannot prompt. set --json returns
{delivery:"sent", verified:false, next:"alerts phone verify <code>"} and the
caller finishes with verify — the same two-step shape MCP uses. Codes are
never echoed into --json output or logs.

A failed delivery does not ask for a code. If delivery is not sent, the
command says so and stops rather than prompting for something that was never
sent. This is the CLI-side counterpart of hookmyapp#196, which stopped the
backend reporting sent for messages the provider had rejected.

Tests

6 new tests: national-format numbers rejected before any API call, consent
defaults, failed-delivery path making no verify call, --code skipping the
prompt, and local code-shape validation. Full suite: 1075 pass.

Summary by CodeRabbit

  • New Features
    • Added CLI commands to view, register, verify, and remove an alert phone number.
    • Added SMS or WhatsApp preferences and consent options for product, marketing, and operational alerts.
    • Added interactive and JSON output modes, input validation, and guidance for failed or undelivered verification codes.
  • Documentation
    • Updated CLI help, README guidance, and changelog information for alert phone management.

The alert phone could be set from the web dialog or through MCP, but not
from the terminal — so a CLI-first user had to open a browser or drive an
agent to opt into breakage alerts.

`alerts phone status | set <phone> | verify <code>`, mirroring the MCP
tools against the same user-scoped /auth/phone routes.

Consents follow MCP rather than the web dialog: operational on, product
and marketing behind --product / --marketing. A bare `set` must not
silently consent someone to marketing.

--json cannot prompt, so `set --json` reports the code is out and points
at `verify`; the interactive path prompts inline. A delivery that did not
report `sent` says so and stops instead of asking for a code that was
never sent.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds CLI commands to view, register, verify, and remove an authenticated user’s alert phone. The commands validate inputs, manage consent and delivery preferences, support JSON output, and integrate with the root CLI. Tests cover status, validation, delivery, consent, verification, and removal behavior.

Changes

Alert phone commands

Layer / File(s) Summary
Phone status handling
src/commands/alerts.ts
Adds /auth/phone status retrieval with formatted and JSON output for verification, delivery, consent, and channel settings.
Phone registration and verification
src/commands/alerts.ts, src/commands/__tests__/alerts.test.ts
Adds phone-number and verification-code validation, consent and channel options, verification prompts, delivery-failure handling, API submission, and tests for the command flows.
Phone removal and CLI integration
src/commands/alerts.ts, src/commands/__tests__/alerts.test.ts, src/index.ts, README.md, CHANGELOG.md
Adds phone removal, registers the alerts phone command hierarchy, exposes global options, and documents the workflow.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant AlertCommands
  participant AuthPhoneAPI
  CLI->>AlertCommands: run alerts phone set
  AlertCommands->>AuthPhoneAPI: submit phone and preferences
  AuthPhoneAPI-->>AlertCommands: return verification challenge
  AlertCommands->>AuthPhoneAPI: submit six-digit code
  AuthPhoneAPI-->>CLI: return verification result
Loading

Possibly related PRs

  • hookmyapp/cli#51: Implements overlapping alert-phone status, registration, verification, consent, channel, and validation functionality.

Suggested reviewers: ordvir

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 clearly and concisely describes the primary CLI changes for setting and verifying the alert phone.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ait-376-cli-alert-phone

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@src/commands/alerts.ts`:
- Around line 61-76: Update the phone validation before the /auth/phone request
in the alerts command to require a complete E.164-shaped value: a leading plus
followed by 1–15 digits, rejecting “+”, non-digit suffixes, and overlong
numbers. Preserve the existing ValidationError behavior and add tests covering
malformed plus-prefixed inputs.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: aac4d592-a9bd-432d-a88c-54e62d860cd1

📥 Commits

Reviewing files that changed from the base of the PR and between ccbeed8 and 1359030.

📒 Files selected for processing (3)
  • src/commands/__tests__/alerts.test.ts
  • src/commands/alerts.ts
  • src/index.ts

Comment thread src/commands/alerts.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13590300e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/alerts.ts
- Validate a full E.164 shape (^\+[1-9]\d{1,14}$) instead of a bare leading
  '+', so '+', '+abc', and over-length values are rejected before any
  registration request (CodeRabbit).
- Refuse to start a verification when there is no TTY and neither --json nor
  --code is given, before the code is sent — otherwise a CI/redirected caller
  spends a code and quota, then blocks on a prompt that never reads (Codex P2).
  Interactivity is injectable for tests.
@ord669

ord669 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@ord669

ord669 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29fbb30fbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/alerts.ts Outdated
A malformed --code could only be rejected locally, but the send already went
out first — burning delivery quota and superseding any live challenge.
@ord669

ord669 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@ord669

ord669 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ac54c4c78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/alerts.ts
ord669 added 2 commits August 10, 2026 18:10
Drops the --product/--marketing opt-in flags (unreleased) and the
consent mechanics from README and changelog. The set call now sends all
three consents true; opt-out lives in the web app.

1078 tests green.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@README.md`:
- Line 242: Update the README sentence describing the 6-digit confirmation code
and `set` so it states that the prompt occurs only after successful delivery;
also explain that when delivery fails or no code arrives, `alertPhoneSet` exits
and users should retry, while preserving the existing `--json`, verification,
and `--code` guidance.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 131aed40-02c8-4597-8b1b-844ce2004258

📥 Commits

Reviewing files that changed from the base of the PR and between 29fbb30 and 5202c39.

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

Comment thread README.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/commands/alerts.ts (1)

204-211: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add help examples for remove.

The new command has no addExamples(removeCmd, ...) block. Add examples for interactive removal and the --yes and --json paths so users can discover the confirmation behavior.

Proposed addition
+  addExamples(
+    removeCmd,
+    `
+EXAMPLES:
+  $ hookmyapp alerts phone remove
+  $ hookmyapp alerts phone remove --yes
+  $ hookmyapp alerts phone remove --json
+`,
+  );
🤖 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/alerts.ts` around lines 204 - 211, Add an addExamples(removeCmd,
...) block alongside the phone remove command, covering interactive removal,
non-interactive removal with --yes, and JSON output with --json. Follow the
existing alert command example conventions and ensure the examples clearly
expose the confirmation behavior.
🤖 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.

Inline comments:
In `@src/commands/alerts.ts`:
- Around line 174-176: Update the JSON-mode branch in the alert phone DELETE
flow to pass null to output when status is undefined, while preserving the
existing status output for non-empty responses.

---

Nitpick comments:
In `@src/commands/alerts.ts`:
- Around line 204-211: Add an addExamples(removeCmd, ...) block alongside the
phone remove command, covering interactive removal, non-interactive removal with
--yes, and JSON output with --json. Follow the existing alert command example
conventions and ensure the examples clearly expose the confirmation behavior.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 46ae0fc8-3dc9-4b9b-948c-c1ed25cd9db2

📥 Commits

Reviewing files that changed from the base of the PR and between 63decc0 and d837b0e.

📒 Files selected for processing (3)
  • README.md
  • src/commands/__tests__/alerts.test.ts
  • src/commands/alerts.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • src/commands/tests/alerts.test.ts

Comment thread src/commands/alerts.ts Outdated
A supplied code belongs to an already-sent challenge, so starting a new
one superseded it and rejected the very code the caller was handed —
--code now routes straight to verify with a single API call. DELETE
prints null instead of undefined under --json on an empty response.
README describes the failed-delivery path.
@ord669
ord669 merged commit 612ac17 into main Aug 11, 2026
3 checks passed
@ord669
ord669 deleted the ait-376-cli-alert-phone branch August 11, 2026 14:18
ord669 added a commit that referenced this pull request Aug 12, 2026
- Validate a full E.164 shape (^\+[1-9]\d{1,14}$) instead of a bare leading
  '+', so '+', '+abc', and over-length values are rejected before any
  registration request (CodeRabbit).
- Refuse to start a verification when there is no TTY and neither --json nor
  --code is given, before the code is sent — otherwise a CI/redirected caller
  spends a code and quota, then blocks on a prompt that never reads (Codex P2).
  Interactivity is injectable for tests.
ord669 added a commit that referenced this pull request Aug 12, 2026
AIT-376: set and verify the alert phone from the CLI
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