feat(cli): infer --provider from mailbox domain#42
Merged
stevenobiajulu merged 1 commit intomainfrom Apr 20, 2026
Merged
Conversation
When --mailbox is a consumer Gmail/Microsoft address and --provider is not passed, infer the provider from the domain suffix instead of silently defaulting to microsoft. Custom business domains still fall back to the microsoft default since either provider is plausible. Adds a stderr log line (with the matched domain) so the inference is transparent. Closes #41
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #41. When
--provideris not passed,setup/configurenow infers the provider from the--mailboxdomain instead of silently defaulting to Microsoft for Gmail addresses.Priority order:
--provider— always wins.--mailboxdomain (exact match).'microsoft'default (preserves behavior for corporate/custom domains).Domain map (exact match only, case-insensitive):
gmail.com,googlemail.com→gmailoutlook.com,hotmail.com,live.com,msn.com→microsoft(Microsoft Support groups these four as Outlook.com-family consumer domains)
undefined(falls through tomicrosoftdefault)When inference fires, we log once to stderr (matching the existing
[email-agent-mcp] Configuring mailbox …pattern) with the matched domain so the behavior is transparent:Pattern matching (e.g.,
hotmail.*) was intentionally rejected — false-positive risk for corporate domains is not worth the marginal coverage of regional variants.Diff scope
packages/email-mcp/src/cli.ts— new exported helperinferProviderFromMailbox(reuses the existingnormalizeMailboxValueso whitespace-padded inputs still infer); two-line change to provider resolution inrunConfigure; one new stderr log line.packages/email-mcp/src/cli.test.ts— newdescribe('cli/Provider Inference')with 8 unit tests covering the domain map, case-insensitivity, whitespace, non-matching domains, and explicit non-pattern-matching (hotmail.co.uk→ undefined); one new integration scenario inside the existingcli/Gmail Configureblock that runsconfigure --mailbox test@gmail.comwith no--providerand asserts both the Gmail path was taken and the inference log was emitted.No other files touched. No package-version bump (release is batched separately).
Peer-reviewed by Gemini CLI and Codex CLI before implementation. Codex caught two issues that shaped the final plan: (1) the helper reuses
normalizeMailboxValuefor input trimming, and (2) the "explicit Microsoft wins" runtime test was intentionally omitted — the Microsoft mock incli.test.tsonly activates for watcher tests (viawatcherMockState.mailboxes.length > 0), not configure. The precedence logic is still covered by the unit??chain.Test plan
npm run buildnpm run test:run -w @usejunior/email-mcp— 150/150 passing (9 new tests)npm run lint