@mailmodo/cli 0.0.58 → 0.0.59-beta.pr62.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,125 +1,784 @@
1
- # mailmodo-cli
1
+ # @mailmodo/cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@mailmodo/cli.svg)](https://www.npmjs.com/package/@mailmodo/cli)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@mailmodo/cli.svg)](https://www.npmjs.com/package/@mailmodo/cli)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
7
+
8
+ **Email lifecycle automation for the AI-native builder generation.**
9
+
10
+ `@mailmodo/cli` is a command-line tool that analyzes your product, generates a full onboarding and lifecycle email sequence using AI, and deploys it — all from your terminal. It manages everything from domain setup and HTML template generation to live deployment, performance monitoring, and contact management.
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ - [Installation](#installation)
17
+ - [Quick Start](#quick-start)
18
+ - [Commands Reference](#commands-reference)
19
+ - [login](#login)
20
+ - [logout](#logout)
21
+ - [init](#init)
22
+ - [emails](#emails)
23
+ - [edit](#edit)
24
+ - [preview](#preview)
25
+ - [deploy](#deploy)
26
+ - [deployments](#deployments)
27
+ - [sdk](#sdk)
28
+ - [domain](#domain)
29
+ - [settings](#settings)
30
+ - [status](#status)
31
+ - [logs](#logs)
32
+ - [contacts](#contacts)
33
+ - [billing](#billing)
34
+ - [report](#report)
35
+ - [SDK / App Integration](#sdk--app-integration)
36
+ - [Configuration](#configuration)
37
+ - [AI Agent Support](#ai-agent-support)
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install -g @mailmodo/cli
45
+ ```
46
+
47
+ Requires **Node.js >= 18**.
48
+
49
+ Verify the installation:
50
+
51
+ ```bash
52
+ mailmodo --version
53
+ mailmodo --help
54
+ ```
55
+
56
+ ---
2
57
 
3
- Email lifecycle automation for the AI-native builder generation.
58
+ ## Quick Start
4
59
 
5
- ## Prerequisites
60
+ The primary workflow from zero to deployed email sequence:
6
61
 
7
- - **Node.js** v24.14.1
62
+ **1. Authenticate**
8
63
 
9
- ## Setup
64
+ ```bash
65
+ mailmodo login
66
+ ```
67
+
68
+ You will be prompted to enter your Mailmodo API key. Get one at [app.mailmodo.dev](https://app.mailmodo.dev).
69
+
70
+ **2. Analyze your product and generate emails**
10
71
 
11
- ```sh
12
- git clone https://github.com/Mailmodo/mailmodo-cli.git
13
- cd mailmodo-cli
14
- npm install
72
+ ```bash
73
+ mailmodo init --url https://yourapp.com
15
74
  ```
16
75
 
17
- ## Development
76
+ The CLI scrapes your product URL, detects your business model, and generates a full email sequence with HTML templates. A `mailmodo.yaml` config file and a `mailmodo/` directory of HTML templates are created in your current working directory.
18
77
 
19
- ### Run in dev mode (without building)
78
+ **3. Preview an email**
20
79
 
21
- ```sh
22
- node ./bin/run.js <command>
80
+ ```bash
81
+ mailmodo preview welcome
23
82
  ```
24
83
 
25
- Example:
84
+ Opens a local preview server in your browser. Use `--send me@example.com` to send yourself a test.
26
85
 
27
- ```sh
28
- node ./bin/run.js signup
86
+ **4. Set up your sending domain**
87
+
88
+ ```bash
89
+ mailmodo domain
29
90
  ```
30
91
 
31
- ### Build the project
92
+ Follow the prompts to register your domain and sender details. The CLI displays the DNS records you need to add. Verify once propagated:
32
93
 
33
- ```sh
34
- npm run build
94
+ ```bash
95
+ mailmodo domain --verify
35
96
  ```
36
97
 
37
- ### Run after build
98
+ **5. Deploy**
38
99
 
39
- ```sh
40
- ./bin/run.js <command>
100
+ ```bash
101
+ mailmodo deploy
41
102
  ```
42
103
 
43
- ### Link globally for local testing
104
+ Validates your configuration, deploys all email sequences, and prints the `track()` and `identify()` SDK snippets to wire into your app.
44
105
 
45
- This registers the `mailmodo` binary on your system so you can use it from anywhere:
106
+ **6. Monitor**
46
107
 
47
- ```sh
48
- npm link
108
+ ```bash
109
+ mailmodo status # quota usage and per-email metrics
110
+ mailmodo logs # delivery event log
49
111
  ```
50
112
 
51
- Then run commands directly:
113
+ ---
114
+
115
+ ## Commands Reference
116
+
117
+ All commands support two universal flags:
52
118
 
53
- ```sh
54
- mailmodo signup
119
+ | Flag | Alias | Description |
120
+ | -------- | ----- | -------------------------------------------------------------- |
121
+ | `--json` | | Output as machine-readable JSON instead of formatted text |
122
+ | `--yes` | `-y` | Skip all confirmation prompts (non-interactive / scripted use) |
123
+
124
+ ---
125
+
126
+ ### login
127
+
128
+ Authenticate with Mailmodo using your API key.
129
+
130
+ ```bash
131
+ mailmodo login
55
132
  ```
56
133
 
57
- To unlink:
134
+ Validates your API key against the Mailmodo API, saves credentials to `~/.mailmodo/config`, and performs a silent cloud backup of any existing `mailmodo.yaml`. If credentials are already saved, displays current account status.
135
+
136
+ **Environment variable shortcut (for CI/CD):**
137
+
138
+ ```bash
139
+ # Linux / macOS
140
+ MAILMODO_API_KEY=your_key mailmodo login
58
141
 
59
- ```sh
60
- npm unlink -g @mailmodo/cli
142
+ # Windows PowerShell
143
+ $env:MAILMODO_API_KEY="your_key"; mailmodo login
144
+
145
+ # Windows CMD
146
+ set MAILMODO_API_KEY=your_key && mailmodo login
147
+ ```
148
+
149
+ **JSON output shape:**
150
+
151
+ ```json
152
+ {
153
+ "status": "logged_in",
154
+ "email": "you@example.com",
155
+ "plan": "free",
156
+ "totalFreeRemaining": 500,
157
+ "paidEmailsRemaining": 0,
158
+ "yamlRestored": false
159
+ }
61
160
  ```
62
161
 
63
- ## Commands
162
+ ---
64
163
 
65
- ### `mailmodo signup`
164
+ ### logout
66
165
 
67
- Sign up for Mailmodo. Prompts for an email address interactively.
166
+ Remove saved credentials from this machine.
68
167
 
69
- ```sh
70
- mailmodo signup
168
+ ```bash
169
+ mailmodo logout
71
170
  ```
72
171
 
73
- ### `mailmodo help [COMMAND]`
172
+ Deletes `~/.mailmodo/config`. Does not affect the server-side account.
74
173
 
75
- Display help for any command.
174
+ **JSON output shape:**
76
175
 
77
- ```sh
78
- mailmodo help
79
- mailmodo help signup
176
+ ```json
177
+ { "status": "logged_out" }
80
178
  ```
81
179
 
82
- ## Scripts
180
+ ---
181
+
182
+ ### init
183
+
184
+ Analyze your product and generate a full email sequence.
185
+
186
+ ```bash
187
+ mailmodo init
188
+ mailmodo init --url https://yourapp.com
189
+ mailmodo init --url https://yourapp.com --yes
190
+ ```
191
+
192
+ | Flag | Type | Description |
193
+ | ------- | ------ | ---------------------------------------------------------- |
194
+ | `--url` | string | Product URL to analyze (prompted interactively if omitted) |
195
+
196
+ What `init` does:
197
+
198
+ 1. Calls the Mailmodo AI to analyze your product URL and detect business model, target user, SaaS model, and brand details.
199
+ 2. Generates email copy and HTML templates for a complete lifecycle sequence (welcome, onboarding, trial expiry, etc.).
200
+ 3. Writes `mailmodo.yaml` to the current directory.
201
+ 4. Creates a `mailmodo/` directory containing one `.html` file per email.
202
+ 5. Silently backs up the config and templates to the cloud.
203
+
204
+ **JSON output shape:**
205
+
206
+ ```json
207
+ {
208
+ "brand": { "name": "...", "color": "...", "url": "..." },
209
+ "emailConfigs": [...],
210
+ "emailStyle": "branded",
211
+ "monthlyCap": 5
212
+ }
213
+ ```
214
+
215
+ ---
216
+
217
+ ### emails
218
+
219
+ List and inspect your configured email sequences.
220
+
221
+ ```bash
222
+ mailmodo emails
223
+ mailmodo emails --json
224
+ ```
225
+
226
+ Reads `mailmodo.yaml` locally and displays a table of all configured emails: ID, trigger event, delay, and subject. In interactive mode, you can select any email to view its full details or open the template in your editor.
227
+
228
+ **JSON output shape:**
229
+
230
+ ```json
231
+ {
232
+ "emails": [
233
+ {
234
+ "id": "welcome",
235
+ "trigger": "user.signup",
236
+ "delay": 0,
237
+ "subject": "Welcome to MyApp"
238
+ }
239
+ ],
240
+ "total": 4
241
+ }
242
+ ```
243
+
244
+ ---
245
+
246
+ ### edit
247
+
248
+ Edit an email using AI-assisted natural language changes.
249
+
250
+ ```bash
251
+ mailmodo edit <id>
252
+ mailmodo edit welcome
253
+ mailmodo edit welcome --change "make the subject more urgent"
254
+ mailmodo edit welcome --change "rewrite the body focusing on onboarding" --yes
255
+ ```
256
+
257
+ | Argument | Description |
258
+ | -------- | ------------------------------------ |
259
+ | `id` | Email template ID to edit (required) |
260
+
261
+ | Flag | Type | Description |
262
+ | ---------- | ------ | ---------------------------------------------------------------------------------- |
263
+ | `--change` | string | Natural language description of what to change (prompted interactively if omitted) |
264
+
265
+ The CLI sends the current template and your change description to the Mailmodo AI, previews the diff (changed vs. unchanged fields), and lets you accept, retry, or skip.
266
+
267
+ **JSON output shape:**
83
268
 
84
- | Script | Description |
85
- | --------------- | ------------------------------------ |
86
- | `npm run build` | Clean `dist/` and compile TypeScript |
87
- | `npm run lint` | Run ESLint |
88
- | `npm test` | Run tests with Mocha |
269
+ Returns the updated email object with a `diff` property showing which fields changed and which were preserved.
89
270
 
90
- ## CI/CD & Release Automation
271
+ ---
91
272
 
92
- ### Beta releases (on PR)
273
+ ### preview
93
274
 
94
- Every time a pull request targeting `main` is opened or updated, a **beta version** is automatically published to npm. A comment is posted on the PR with install instructions:
275
+ Preview an email in the browser, as plain text, or send a test.
95
276
 
96
- ```sh
97
- npm install -g @mailmodo/cli@beta
277
+ ```bash
278
+ mailmodo preview
279
+ mailmodo preview <id>
280
+ mailmodo preview welcome --text
281
+ mailmodo preview welcome --send me@example.com
98
282
  ```
99
283
 
100
- This lets anyone on the team test the PR changes without checking out the branch locally.
284
+ | Argument | Description |
285
+ | -------- | ---------------------------------------------------------------------------- |
286
+ | `id` | Email template ID (optional; defaults to the first email in `mailmodo.yaml`) |
101
287
 
102
- > **Note:** npm publishing requires the `NPM_AUTH_TOKEN_WRITE` secret to be configured in the repo settings. Until then, the publish step will be skipped but all other steps (build, version bump, release) still work.
288
+ | Flag | Type | Description |
289
+ | -------- | ------- | ---------------------------------------------------------------- |
290
+ | `--text` | boolean | Print a plain-text rendering of the email (useful for AI agents) |
291
+ | `--send` | string | Send a test email to the specified address |
103
292
 
104
- ### Automatic versioning (on merge)
293
+ In browser mode (default), a local server starts at `http://localhost:3421` and opens your browser.
294
+
295
+ ---
296
+
297
+ ### deploy
298
+
299
+ Deploy, pause, or resume an email sequence.
300
+
301
+ ```bash
302
+ # Deploy all configured sequences
303
+ mailmodo deploy
304
+ mailmodo deploy --yes
305
+
306
+ # Pause a live sequence
307
+ mailmodo deploy --pause <sequenceId>
308
+
309
+ # Resume a paused sequence
310
+ mailmodo deploy --resume <sequenceId>
311
+ mailmodo deploy --resume <sequenceId> --json
312
+ ```
313
+
314
+ | Flag | Type | Description |
315
+ | ---------- | ------ | ------------------------------------------------------------------------- |
316
+ | `--pause` | string | Pause a deployed sequence by ID (stops all scheduled and triggered sends) |
317
+ | `--resume` | string | Resume a paused sequence by ID |
318
+
319
+ `--pause` and `--resume` are mutually exclusive.
320
+
321
+ **Deploy flow:**
322
+
323
+ 1. Checks domain verification status; runs domain setup if needed.
324
+ 2. Validates your email sequence configuration.
325
+ 3. Shows a pre-deploy summary: domain, sender, email count, and a diff of changes since the last deploy.
326
+ 4. Prompts for confirmation (skipped with `--yes`).
327
+ 5. Deploys and prints the `@mailmodo/sdk` code snippets to add to your app.
328
+
329
+ **Deploy JSON output shape:**
330
+
331
+ ```json
332
+ {
333
+ "deployed": true,
334
+ "emailsLive": 4,
335
+ "sequenceId": "seq_abc123",
336
+ "diff": { "added": [], "changed": [], "removed": [] },
337
+ "sdkSnippet": "..."
338
+ }
339
+ ```
340
+
341
+ **Pause/Resume JSON output shape:**
342
+
343
+ ```json
344
+ {
345
+ "sequenceId": "seq_abc123",
346
+ "status": "paused",
347
+ "alreadyInStatus": false
348
+ }
349
+ ```
350
+
351
+ ---
352
+
353
+ ### deployments
354
+
355
+ List every deployed sequence on this account.
356
+
357
+ ```bash
358
+ mailmodo deployments
359
+ mailmodo deployments --json
360
+ ```
361
+
362
+ Displays a table with product name, status (`active` / `paused`), email count, sequence ID, and last-updated date. The sequence IDs shown here are the values to pass to `deploy --pause` and `deploy --resume`.
363
+
364
+ **JSON output shape:**
365
+
366
+ ```json
367
+ {
368
+ "sequences": [
369
+ {
370
+ "sequenceId": "seq_abc123",
371
+ "product": "MyApp",
372
+ "status": "active",
373
+ "emailCount": 4,
374
+ "updatedAt": "2025-06-01T10:00:00Z"
375
+ }
376
+ ],
377
+ "total": 1
378
+ }
379
+ ```
380
+
381
+ ---
382
+
383
+ ### sdk
384
+
385
+ Show SDK `track()` and `identify()` reference for your deployed sequences.
386
+
387
+ ```bash
388
+ mailmodo sdk
389
+ mailmodo sdk --sequence-id seq_abc123
390
+ mailmodo sdk --json
391
+ ```
392
+
393
+ | Flag | Type | Description |
394
+ | --------------- | ------ | ------------------------------------------------------------------------- |
395
+ | `--sequence-id` | string | Limit output to a specific sequence by ID (default: all active sequences) |
396
+
397
+ Displays the install command, import line, and copy-ready `track()` / `identify()` function calls for each active sequence. See [SDK / App Integration](#sdk--app-integration) for details on using these in your app.
398
+
399
+ ---
400
+
401
+ ### domain
402
+
403
+ Set up and verify your sending domain.
404
+
405
+ ```bash
406
+ # Interactive setup (register domain and get DNS records)
407
+ mailmodo domain
408
+
409
+ # Verify DNS records after adding them
410
+ mailmodo domain --verify
411
+
412
+ # Show domain health metrics
413
+ mailmodo domain --status
414
+ ```
415
+
416
+ | Flag | Type | Description |
417
+ | ---------- | ------- | ----------------------------------------------------------------------- |
418
+ | `--verify` | boolean | Check SPF, DKIM, and DMARC record status |
419
+ | `--status` | boolean | Display domain health metrics (bounce rate, spam rate, verified status) |
420
+
421
+ During setup, you are prompted for: domain, sender email (must be `@<domain>`), from name, reply-to address, and physical business address (required by CAN-SPAM). The CLI outputs the exact DNS records to add to your registrar.
422
+
423
+ > **Note:** DNS changes take 5–30 minutes to propagate before verification will pass.
424
+
425
+ ---
426
+
427
+ ### settings
428
+
429
+ View and update project settings.
430
+
431
+ ```bash
432
+ mailmodo settings
433
+ mailmodo settings --set brand_color=#0F3460
434
+ mailmodo settings --json
435
+ ```
105
436
 
106
- When a PR is merged into `main`, the version in `package.json` is bumped automatically, a GitHub Release is created, and the new version is published to npm.
437
+ | Flag | Type | Description |
438
+ | ------- | ------ | --------------------------------------------- |
439
+ | `--set` | string | Set a single setting using `key=value` syntax |
107
440
 
108
- The bump type is determined by a tag in the **PR title**:
441
+ In interactive mode (no flags), displays all settings grouped by category and prompts to edit each one. With `--set`, updates the specified key directly without prompting.
109
442
 
110
- | PR title contains | Bump type | Example |
111
- | ----------------- | --------- | ----------------- |
112
- | `[major]` | major | `1.2.3` → `2.0.0` |
113
- | `[minor]` | minor | `1.2.3` → `1.3.0` |
114
- | `[patch]` | patch | `1.2.3` → `1.2.4` |
115
- | _(nothing)_ | patch | `1.2.3` → `1.2.4` |
443
+ **Settable keys:**
116
444
 
117
- **Examples of PR titles:**
445
+ | Category | Keys |
446
+ | ---------------- | ------------------------------------------------------------------------------- |
447
+ | Project Info | `name`, `url`, `description`, `type`, `targetUser`, `saasModel`, `pricingModel` |
448
+ | Branding | `brand_color`, `email_style` (`plain` \| `branded`), `logo_url`, `logo_file` |
449
+ | Domain / Sending | `domain`, `from_email`, `from_name`, `reply_to`, `address` |
450
+ | Billing | `monthly_cap` (paid tier only), `webhook_url` |
118
451
 
119
- - `[minor] Add email validation` → minor bump
120
- - `[major] Rewrite auth flow` → major bump
121
- - `Fix typo in help text` → patch bump (default)
452
+ ---
453
+
454
+ ### status
455
+
456
+ View email performance metrics and quota usage.
457
+
458
+ ```bash
459
+ mailmodo status
460
+ mailmodo status --json
461
+ ```
462
+
463
+ Displays per-email metrics (sent, open rate, click rate, conversion rate), total monthly sends, and current quota status (free emails remaining or paid blocks consumed).
464
+
465
+ **JSON output shape:**
466
+
467
+ ```json
468
+ {
469
+ "emails": [
470
+ {
471
+ "id": "welcome",
472
+ "sent": 120,
473
+ "openRate": 0.42,
474
+ "clickRate": 0.15,
475
+ "conversionRate": 0.08
476
+ }
477
+ ],
478
+ "monthlySent": 480,
479
+ "quota": { "free": 20, "paidBlocksUsed": 0 }
480
+ }
481
+ ```
482
+
483
+ ---
484
+
485
+ ### logs
486
+
487
+ View email send logs and delivery events.
488
+
489
+ ```bash
490
+ mailmodo logs
491
+ mailmodo logs --email sarah@example.com
492
+ mailmodo logs --failed
493
+ mailmodo logs --limit 100 --page 2
494
+ mailmodo logs --json
495
+ ```
496
+
497
+ | Flag | Type | Default | Description |
498
+ | ---------- | ------- | ------- | -------------------------------------- |
499
+ | `--email` | string | | Filter events by contact email address |
500
+ | `--failed` | boolean | false | Show only failed or bounced events |
501
+ | `--limit` | integer | 50 | Entries per page (max 200) |
502
+ | `--page` | integer | 1 | Page number for pagination |
503
+
504
+ **JSON output shape:**
505
+
506
+ ```json
507
+ {
508
+ "entries": [
509
+ {
510
+ "timestamp": "2025-06-01T10:00:00Z",
511
+ "emailId": "welcome",
512
+ "status": "delivered",
513
+ "contact": "sarah@example.com",
514
+ "reason": null
515
+ }
516
+ ],
517
+ "total": 480,
518
+ "page": 1,
519
+ "limit": 50
520
+ }
521
+ ```
522
+
523
+ ---
524
+
525
+ ### contacts
526
+
527
+ Manage contacts — search, export, or delete.
528
+
529
+ ```bash
530
+ # Show summary counts
531
+ mailmodo contacts
532
+
533
+ # Search for a specific contact
534
+ mailmodo contacts --search sarah@example.com
535
+
536
+ # Export all contacts as GDPR-compliant CSV
537
+ mailmodo contacts --export
538
+
539
+ # Hard-delete a contact (GDPR right to erasure)
540
+ mailmodo contacts --delete sarah@example.com
541
+ ```
542
+
543
+ | Flag | Type | Description |
544
+ | ---------- | ------- | --------------------------------------- |
545
+ | `--search` | string | Look up a contact by email address |
546
+ | `--export` | boolean | Download all contacts to `contacts.csv` |
547
+ | `--delete` | string | Permanently delete a contact by email |
548
+
549
+ Without any flags, displays total, active, unsubscribed, and bounced contact counts.
550
+
551
+ ---
552
+
553
+ ### billing
554
+
555
+ View billing status, purchase email blocks, set a monthly cap, or add a payment method.
556
+
557
+ ```bash
558
+ # View current billing status
559
+ mailmodo billing
560
+ mailmodo billing --status
561
+
562
+ # Open Stripe checkout to add or update a payment method
563
+ mailmodo billing --checkout
564
+
565
+ # Purchase email blocks immediately
566
+ mailmodo billing --purchase 3
567
+
568
+ # Set a monthly sending cap (paid tier)
569
+ mailmodo billing --cap 5
570
+
571
+ # Set cap with auto-refill when quota runs low
572
+ mailmodo billing --cap 5 --auto-charge-block-count 2
573
+ ```
574
+
575
+ | Flag | Type | Description |
576
+ | --------------------------- | ------- | ------------------------------------------------------------------- |
577
+ | `--status` | boolean | Show billing status only (tier, cap, spending) |
578
+ | `--checkout` | boolean | Open Stripe checkout to add or update a payment method |
579
+ | `--purchase` | integer | Manually purchase the specified number of email blocks |
580
+ | `--cap` | integer | Set monthly sending cap in blocks |
581
+ | `--auto-charge-block-count` | integer | Blocks to auto-purchase when quota runs low (use alongside `--cap`) |
582
+
583
+ Each block = 1,000 emails. `--monthly-cap` and `--auto-charge-block-count` require a saved payment method.
584
+
585
+ ---
586
+
587
+ ### report
588
+
589
+ Fetch a detailed analytics report with flexible filtering and grouping.
590
+
591
+ ```bash
592
+ # Quick report for the last 7 days
593
+ mailmodo report --preset last7d
594
+
595
+ # Group by email template
596
+ mailmodo report --preset last30d --group-by emailId
597
+
598
+ # Custom date range, raw event entries
599
+ mailmodo report --from 2025-05-01 --to 2025-06-01 --output entries
600
+
601
+ # Filter to a specific sequence and event type
602
+ mailmodo report --preset last30d --sequence seq_abc123 --event opened
603
+
604
+ # Paginate through entries
605
+ mailmodo report --preset last7d --output entries --page 2 --limit 100
606
+
607
+ mailmodo report --preset last7d --json
608
+ ```
609
+
610
+ | Flag | Type | Default | Description |
611
+ | ------------ | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------- |
612
+ | `--preset` | string | | Relative time range: `today`, `yesterday`, `last7d`, `last30d`, `last90d`, `thisMonth`, `lastMonth` |
613
+ | `--from` | string | | Start of range inclusive (YYYY-MM-DD). Exclusive with `--preset` |
614
+ | `--to` | string | | End of range exclusive (YYYY-MM-DD). Exclusive with `--preset` |
615
+ | `--group-by` | string | `none` | Group results by: `none`, `emailId`, `sequenceId`, `day`, `hour`, `contact`, `status` |
616
+ | `--output` | string | `summary` | Output shape: `summary`, `entries`, `timeseries` |
617
+ | `--email-id` | string[] | | Filter by one or more email template IDs (repeatable) |
618
+ | `--contact` | string[] | | Filter by one or more contact emails (repeatable) |
619
+ | `--sequence` | string[] | | Filter by one or more sequence IDs (repeatable) |
620
+ | `--event` | string[] | | Filter by event type: `sent`, `delivered`, `opened`, `clicked`, `bounced`, `complained`, `skipped`, `unsubscribed` (repeatable) |
621
+ | `--limit` | integer | 50 | Entries per page, max 200 (applies to `entries` output only) |
622
+ | `--page` | integer | 1 | Page number (applies to `entries` output only) |
623
+
624
+ `--preset` and `--from`/`--to` are mutually exclusive.
625
+
626
+ ---
627
+
628
+ ## SDK / App Integration
629
+
630
+ After deploying a sequence, the CLI prints the exact code to add to your application. You can always retrieve it with:
631
+
632
+ ```bash
633
+ npm install @mailmodo/sdk
634
+ ```
635
+
636
+ ```javascript
637
+ import { track, identify } from '@mailmodo/sdk';
638
+ ```
639
+
640
+ ### `track(event, properties)`
641
+
642
+ Called when a lifecycle event happens in your app. This triggers the email configured for that event.
643
+
644
+ ```javascript
645
+ // Example: trigger the "welcome" email on sign-up
646
+ track('myApp$user.signup', {
647
+ contactEmailId: user.email,
648
+ first_name: user.firstName,
649
+ onboarding_url: `https://app.example.com/onboard/${user.id}`,
650
+ });
651
+ ```
652
+
653
+ ### `identify(email, properties)`
654
+
655
+ Updates contact properties used by conditional send logic.
656
+
657
+ ```javascript
658
+ // Example: update onboarding status to conditionally suppress follow-up emails
659
+ identify(user.email, {
660
+ onboarding_not_completed: user.onboardingStep < 3,
661
+ });
662
+ ```
663
+
664
+ The `mailmodo sdk` command (or the post-deploy output) shows the exact event names and properties for each sequence in your account.
665
+
666
+ ---
667
+
668
+ ## Configuration
669
+
670
+ ### Credentials — `~/.mailmodo/config`
671
+
672
+ Stores your API key and account metadata. Written by `mailmodo login`, deleted by `mailmodo logout`. Never commit this file.
673
+
674
+ ```json
675
+ {
676
+ "apiKey": "mk_...",
677
+ "email": "you@example.com",
678
+ "totalFreeRemaining": 500
679
+ }
680
+ ```
681
+
682
+ **Environment variable override:** Set `MAILMODO_API_KEY` to bypass the config file entirely — useful in CI/CD pipelines and Docker containers.
683
+
684
+ ### Project Config — `mailmodo.yaml`
685
+
686
+ Created by `mailmodo init` in your current working directory. This is the source of truth for your email sequence. Commit it to version control.
687
+
688
+ ```yaml
689
+ project:
690
+ name: MyApp
691
+ url: https://myapp.com
692
+ description: Project management for remote teams
693
+ type: b2b_saas
694
+ targetUser: engineering managers
695
+ saasModel: subscription
696
+ pricingModel: per_seat
697
+
698
+ domain: myapp.com
699
+ fromEmail: hello@myapp.com
700
+ fromName: MyApp
701
+ replyTo: support@myapp.com
702
+ address: 123 Main St, San Francisco, CA 94105, US
703
+
704
+ emailStyle: branded # branded | plain
705
+ brandColor: '#1A56DB'
706
+ logoUrl: https://cdn.myapp.com/logo.png
707
+
708
+ monthlyCap: 5 # paid tier — blocks per month (1 block = 1,000 emails)
709
+ webhookUrl: https://myapp.com/webhooks/mailmodo
710
+
711
+ emails:
712
+ - id: welcome
713
+ trigger: user.signup
714
+ delay: 0
715
+ subject: 'Welcome to MyApp, {{first_name}}!'
716
+ template: welcome.html
717
+ style: branded
718
+ previewText: 'Your account is ready.'
719
+ goal: Drive user to complete the first key action
720
+ ctaText: Get Started
721
+
722
+ - id: day3-nudge
723
+ trigger: user.signup
724
+ delay: '3d'
725
+ subject: 'Quick tip for getting started'
726
+ template: day3-nudge.html
727
+ condition: 'onboarding_not_completed == true'
728
+ ```
729
+
730
+ ### HTML Templates — `mailmodo/`
731
+
732
+ Each email in `mailmodo.yaml` maps to an HTML file in the `mailmodo/` directory:
733
+
734
+ ```
735
+ mailmodo/
736
+ welcome.html
737
+ day3-nudge.html
738
+ trial-expiry.html
739
+ ```
740
+
741
+ Templates are generated by `mailmodo init` and editable directly or via `mailmodo edit`. They are automatically synced to the Mailmodo cloud as a backup on every modifying command and restored automatically if the local file is missing.
742
+
743
+ ---
744
+
745
+ ## AI Agent Support
746
+
747
+ All commands support two flags designed for headless and automated environments:
748
+
749
+ | Flag | Description |
750
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
751
+ | `--json` | All output is valid JSON on stdout. Spinners and progress text go to stderr, keeping stdout clean for piping and parsing. |
752
+ | `--yes` / `-y` | Skips all interactive confirmation prompts. The CLI proceeds with the inferred defaults, making it safe to run in scripts and CI pipelines. |
753
+
754
+ ### API key via environment variable
755
+
756
+ Set `MAILMODO_API_KEY` to authenticate without a config file:
757
+
758
+ ```bash
759
+ MAILMODO_API_KEY=mk_... mailmodo deploy --yes --json
760
+ ```
761
+
762
+ ### Example: fully non-interactive deploy in CI
763
+
764
+ ```bash
765
+ MAILMODO_API_KEY=$MAILMODO_API_KEY \
766
+ mailmodo deploy --yes --json | jq '.sequenceId'
767
+ ```
768
+
769
+ ### Example: AI agent loop
770
+
771
+ ```bash
772
+ # Generate emails, skip all prompts, get structured output
773
+ mailmodo init --url https://yourapp.com --yes --json
774
+
775
+ # Edit with a specific instruction, no confirmation
776
+ mailmodo edit welcome --change "add a P.S. with the link to our docs" --yes --json
777
+
778
+ # Deploy immediately
779
+ mailmodo deploy --yes --json
780
+ ```
122
781
 
123
782
  ## License
124
783
 
125
- MIT
784
+ MIT © [Mailmodo](https://github.com/Mailmodo)
@@ -39,9 +39,11 @@ export async function loadConfig() {
39
39
  export async function saveConfig(config) {
40
40
  const dir = configDir();
41
41
  if (!existsSync(dir)) {
42
- await mkdir(dir, { recursive: true });
42
+ await mkdir(dir, { recursive: true, mode: 0o700 });
43
43
  }
44
- await writeFile(configFile(), JSON.stringify(config, null, 2));
44
+ await writeFile(configFile(), JSON.stringify(config, null, 2), {
45
+ mode: 0o600,
46
+ });
45
47
  }
46
48
  /**
47
49
  * Deletes the saved CLI config file (~/.mailmodo/config), removing the stored API key.
@@ -631,139 +631,6 @@
631
631
  "index.js"
632
632
  ]
633
633
  },
634
- "sdk": {
635
- "aliases": [],
636
- "args": {},
637
- "description": "Show the SDK track() / identify() reference for deployed sequences",
638
- "examples": [
639
- "<%= config.bin %> sdk",
640
- "<%= config.bin %> sdk --sequence-id a1b2c3d4",
641
- "<%= config.bin %> sdk --json"
642
- ],
643
- "flags": {
644
- "json": {
645
- "description": "Output as JSON",
646
- "name": "json",
647
- "allowNo": false,
648
- "type": "boolean"
649
- },
650
- "yes": {
651
- "char": "y",
652
- "description": "Skip confirmation prompts",
653
- "name": "yes",
654
- "allowNo": false,
655
- "type": "boolean"
656
- },
657
- "sequence-id": {
658
- "description": "Limit output to a single active sequence by ID (default: all active sequences)",
659
- "name": "sequence-id",
660
- "hasDynamicHelp": false,
661
- "multiple": false,
662
- "type": "option"
663
- }
664
- },
665
- "hasDynamicHelp": false,
666
- "hiddenAliases": [],
667
- "id": "sdk",
668
- "pluginAlias": "@mailmodo/cli",
669
- "pluginName": "@mailmodo/cli",
670
- "pluginType": "core",
671
- "strict": true,
672
- "enableJsonFlag": false,
673
- "isESM": true,
674
- "relativePath": [
675
- "dist",
676
- "commands",
677
- "sdk",
678
- "index.js"
679
- ]
680
- },
681
- "settings": {
682
- "aliases": [],
683
- "args": {},
684
- "description": "View and update project settings",
685
- "examples": [
686
- "<%= config.bin %> settings",
687
- "<%= config.bin %> settings --set brand_color=#0F3460",
688
- "<%= config.bin %> settings --json"
689
- ],
690
- "flags": {
691
- "json": {
692
- "description": "Output as JSON",
693
- "name": "json",
694
- "allowNo": false,
695
- "type": "boolean"
696
- },
697
- "yes": {
698
- "char": "y",
699
- "description": "Skip confirmation prompts",
700
- "name": "yes",
701
- "allowNo": false,
702
- "type": "boolean"
703
- },
704
- "set": {
705
- "description": "Set a setting (format: key=value)",
706
- "name": "set",
707
- "hasDynamicHelp": false,
708
- "multiple": false,
709
- "type": "option"
710
- }
711
- },
712
- "hasDynamicHelp": false,
713
- "hiddenAliases": [],
714
- "id": "settings",
715
- "pluginAlias": "@mailmodo/cli",
716
- "pluginName": "@mailmodo/cli",
717
- "pluginType": "core",
718
- "strict": true,
719
- "enableJsonFlag": false,
720
- "isESM": true,
721
- "relativePath": [
722
- "dist",
723
- "commands",
724
- "settings",
725
- "index.js"
726
- ]
727
- },
728
- "status": {
729
- "aliases": [],
730
- "args": {},
731
- "description": "View email performance metrics and quota usage",
732
- "examples": [
733
- "<%= config.bin %> status",
734
- "<%= config.bin %> status --json"
735
- ],
736
- "flags": {
737
- "json": {
738
- "description": "Output as JSON",
739
- "name": "json",
740
- "allowNo": false,
741
- "type": "boolean"
742
- },
743
- "yes": {
744
- "char": "y",
745
- "description": "Skip confirmation prompts",
746
- "name": "yes",
747
- "allowNo": false,
748
- "type": "boolean"
749
- }
750
- },
751
- "hasDynamicHelp": false,
752
- "hiddenAliases": [],
753
- "id": "status",
754
- "pluginAlias": "@mailmodo/cli",
755
- "pluginName": "@mailmodo/cli",
756
- "pluginType": "core",
757
- "strict": true,
758
- "enableJsonFlag": false,
759
- "isESM": true,
760
- "relativePath": [
761
- "dist",
762
- "commands",
763
- "status",
764
- "index.js"
765
- ]
766
- },
767
634
  "report": {
768
635
  "aliases": [],
769
636
  "args": {},
@@ -930,7 +797,140 @@
930
797
  "report",
931
798
  "index.js"
932
799
  ]
800
+ },
801
+ "sdk": {
802
+ "aliases": [],
803
+ "args": {},
804
+ "description": "Show the SDK track() / identify() reference for deployed sequences",
805
+ "examples": [
806
+ "<%= config.bin %> sdk",
807
+ "<%= config.bin %> sdk --sequence-id a1b2c3d4",
808
+ "<%= config.bin %> sdk --json"
809
+ ],
810
+ "flags": {
811
+ "json": {
812
+ "description": "Output as JSON",
813
+ "name": "json",
814
+ "allowNo": false,
815
+ "type": "boolean"
816
+ },
817
+ "yes": {
818
+ "char": "y",
819
+ "description": "Skip confirmation prompts",
820
+ "name": "yes",
821
+ "allowNo": false,
822
+ "type": "boolean"
823
+ },
824
+ "sequence-id": {
825
+ "description": "Limit output to a single active sequence by ID (default: all active sequences)",
826
+ "name": "sequence-id",
827
+ "hasDynamicHelp": false,
828
+ "multiple": false,
829
+ "type": "option"
830
+ }
831
+ },
832
+ "hasDynamicHelp": false,
833
+ "hiddenAliases": [],
834
+ "id": "sdk",
835
+ "pluginAlias": "@mailmodo/cli",
836
+ "pluginName": "@mailmodo/cli",
837
+ "pluginType": "core",
838
+ "strict": true,
839
+ "enableJsonFlag": false,
840
+ "isESM": true,
841
+ "relativePath": [
842
+ "dist",
843
+ "commands",
844
+ "sdk",
845
+ "index.js"
846
+ ]
847
+ },
848
+ "settings": {
849
+ "aliases": [],
850
+ "args": {},
851
+ "description": "View and update project settings",
852
+ "examples": [
853
+ "<%= config.bin %> settings",
854
+ "<%= config.bin %> settings --set brand_color=#0F3460",
855
+ "<%= config.bin %> settings --json"
856
+ ],
857
+ "flags": {
858
+ "json": {
859
+ "description": "Output as JSON",
860
+ "name": "json",
861
+ "allowNo": false,
862
+ "type": "boolean"
863
+ },
864
+ "yes": {
865
+ "char": "y",
866
+ "description": "Skip confirmation prompts",
867
+ "name": "yes",
868
+ "allowNo": false,
869
+ "type": "boolean"
870
+ },
871
+ "set": {
872
+ "description": "Set a setting (format: key=value)",
873
+ "name": "set",
874
+ "hasDynamicHelp": false,
875
+ "multiple": false,
876
+ "type": "option"
877
+ }
878
+ },
879
+ "hasDynamicHelp": false,
880
+ "hiddenAliases": [],
881
+ "id": "settings",
882
+ "pluginAlias": "@mailmodo/cli",
883
+ "pluginName": "@mailmodo/cli",
884
+ "pluginType": "core",
885
+ "strict": true,
886
+ "enableJsonFlag": false,
887
+ "isESM": true,
888
+ "relativePath": [
889
+ "dist",
890
+ "commands",
891
+ "settings",
892
+ "index.js"
893
+ ]
894
+ },
895
+ "status": {
896
+ "aliases": [],
897
+ "args": {},
898
+ "description": "View email performance metrics and quota usage",
899
+ "examples": [
900
+ "<%= config.bin %> status",
901
+ "<%= config.bin %> status --json"
902
+ ],
903
+ "flags": {
904
+ "json": {
905
+ "description": "Output as JSON",
906
+ "name": "json",
907
+ "allowNo": false,
908
+ "type": "boolean"
909
+ },
910
+ "yes": {
911
+ "char": "y",
912
+ "description": "Skip confirmation prompts",
913
+ "name": "yes",
914
+ "allowNo": false,
915
+ "type": "boolean"
916
+ }
917
+ },
918
+ "hasDynamicHelp": false,
919
+ "hiddenAliases": [],
920
+ "id": "status",
921
+ "pluginAlias": "@mailmodo/cli",
922
+ "pluginName": "@mailmodo/cli",
923
+ "pluginType": "core",
924
+ "strict": true,
925
+ "enableJsonFlag": false,
926
+ "isESM": true,
927
+ "relativePath": [
928
+ "dist",
929
+ "commands",
930
+ "status",
931
+ "index.js"
932
+ ]
933
933
  }
934
934
  },
935
- "version": "0.0.58"
935
+ "version": "0.0.59-beta.pr62.112"
936
936
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mailmodo/cli",
3
3
  "description": "Email lifecycle automation for the AI-native builder generation.",
4
- "version": "0.0.58",
4
+ "version": "0.0.59-beta.pr62.112",
5
5
  "author": "provishalk",
6
6
  "bin": {
7
7
  "mailmodo": "bin/run.js"
@@ -51,8 +51,20 @@
51
51
  ],
52
52
  "homepage": "https://github.com/Mailmodo/mailmodo-cli",
53
53
  "keywords": [
54
- "oclif"
54
+ "email",
55
+ "email-automation",
56
+ "lifecycle-emails",
57
+ "onboarding",
58
+ "transactional-email",
59
+ "cli",
60
+ "ai",
61
+ "mailmodo",
62
+ "sdk",
63
+ "saas"
55
64
  ],
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
56
68
  "license": "MIT",
57
69
  "main": "dist/index.js",
58
70
  "type": "module",
@@ -73,9 +85,9 @@
73
85
  "lint": "eslint",
74
86
  "postpack": "shx rm -f oclif.manifest.json",
75
87
  "posttest": "npm run lint",
76
- "prepack": "oclif manifest && oclif readme",
88
+ "prepack": "oclif manifest",
77
89
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
78
- "version": "oclif readme && git add README.md",
90
+ "version": "git add README.md",
79
91
  "prepare": "husky"
80
92
  },
81
93
  "types": "dist/index.d.ts",