feat(cli,mcp): extract @moemail/core and add MCP server; release 1.0.0

Extract the HTTP client and config into a new @moemail/core package shared
by the CLI and a new @moemail/mcp server, so both frontends talk to the same
MoeMail API through one code path.

- core: api client (now throws typed ConfigError/AuthError/PermissionError/
  QuotaError instead of process.exit), config, msToIso, and a transport-
  agnostic pollForNewMessage helper.
- cli: consume @moemail/core; route command errors through a shared fail()
  that preserves exit codes (config/auth = 2, else = 1). Bump to 1.0.0.
- mcp: new stdio MCP server exposing 8 tools (create/list/read/wait/send/
  delete); wait_for_email is bounded and returns a timeout status to retry.
  Configured via MOEMAIL_API_KEY / MOEMAIL_API_URL env. Release 1.0.0.

Docs:
- Fix packages/cli/README.md (config set, send --content not --body, full
  flag table).
- Add MCP section to both root READMEs; complete the CLI command list
  (send, list, message-level delete).
- SKILL.md: --json works before or after the subcommand.
- Ignore bun.lock in package gitignores.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ty
2026-06-15 23:52:35 +08:00
parent bf51e843ee
commit b99b872791
31 changed files with 771 additions and 115 deletions

View File

@@ -62,10 +62,10 @@ moemail --json read --email-id "$ID" --message-id "$MSG_ID"
| `send` | `--email-id`, `--to`, `--subject`, `--content` | — |
| `delete` | `--email-id` | — |
**Always put `--json` before the subcommand:**
**`--json` is a global flag — it works before or after the subcommand:**
```bash
moemail --json create --expiry 24h # ✅ correct
moemail create --expiry 24h --json # ❌ wrong position
moemail --json create --expiry 24h # both work
moemail create --expiry 24h --json
```
## JSON Output Shapes
@@ -83,7 +83,6 @@ moemail create --expiry 24h --json # ❌ wrong position
| Mistake | Fix |
|---------|-----|
| Calling `create` twice to get id + address | Call once, save to variable, parse both fields |
| `--json` after subcommand | Move `--json` before the subcommand |
| Timeout too short for slow services | Use `--timeout 300` for unreliable senders |
| Inbox expired mid-test | Use `--expiry permanent` for long-running workflows |
| Using `content` field for HTML emails | Check both `content` (plain text) and `html` fields |