@cakemail-org/cakemail-cli 1.5.0 → 2.0.0

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.
Files changed (234) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.env.example +40 -0
  3. package/.env.test.example +45 -0
  4. package/CHANGELOG.md +1031 -0
  5. package/README.md +319 -15
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/cli.js +27 -10
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client.d.ts +2 -0
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +16 -6
  13. package/dist/client.js.map +1 -1
  14. package/dist/commands/account.js +1 -1
  15. package/dist/commands/account.js.map +1 -1
  16. package/dist/commands/attributes.js +1 -1
  17. package/dist/commands/attributes.js.map +1 -1
  18. package/dist/commands/campaigns.d.ts.map +1 -1
  19. package/dist/commands/campaigns.js +103 -8
  20. package/dist/commands/campaigns.js.map +1 -1
  21. package/dist/commands/config.d.ts.map +1 -1
  22. package/dist/commands/config.js +63 -4
  23. package/dist/commands/config.js.map +1 -1
  24. package/dist/commands/contacts.d.ts.map +1 -1
  25. package/dist/commands/contacts.js +91 -12
  26. package/dist/commands/contacts.js.map +1 -1
  27. package/dist/commands/emails.js +1 -1
  28. package/dist/commands/emails.js.map +1 -1
  29. package/dist/commands/interests.d.ts +5 -0
  30. package/dist/commands/interests.d.ts.map +1 -0
  31. package/dist/commands/interests.js +172 -0
  32. package/dist/commands/interests.js.map +1 -0
  33. package/dist/commands/lists.d.ts.map +1 -1
  34. package/dist/commands/lists.js +6 -8
  35. package/dist/commands/lists.js.map +1 -1
  36. package/dist/commands/logs.d.ts +5 -0
  37. package/dist/commands/logs.d.ts.map +1 -0
  38. package/dist/commands/logs.js +237 -0
  39. package/dist/commands/logs.js.map +1 -0
  40. package/dist/commands/reports.js +1 -1
  41. package/dist/commands/reports.js.map +1 -1
  42. package/dist/commands/segments.js +1 -1
  43. package/dist/commands/segments.js.map +1 -1
  44. package/dist/commands/senders.d.ts.map +1 -1
  45. package/dist/commands/senders.js +11 -8
  46. package/dist/commands/senders.js.map +1 -1
  47. package/dist/commands/suppressed.js +1 -1
  48. package/dist/commands/suppressed.js.map +1 -1
  49. package/dist/commands/tags.d.ts +5 -0
  50. package/dist/commands/tags.d.ts.map +1 -0
  51. package/dist/commands/tags.js +124 -0
  52. package/dist/commands/tags.js.map +1 -0
  53. package/dist/commands/templates.js +1 -1
  54. package/dist/commands/templates.js.map +1 -1
  55. package/dist/commands/transactional-templates.d.ts +5 -0
  56. package/dist/commands/transactional-templates.d.ts.map +1 -0
  57. package/dist/commands/transactional-templates.js +354 -0
  58. package/dist/commands/transactional-templates.js.map +1 -0
  59. package/dist/commands/webhooks.js +1 -1
  60. package/dist/commands/webhooks.js.map +1 -1
  61. package/dist/utils/auth.d.ts +8 -1
  62. package/dist/utils/auth.d.ts.map +1 -1
  63. package/dist/utils/auth.js +39 -11
  64. package/dist/utils/auth.js.map +1 -1
  65. package/dist/utils/config-file.d.ts +7 -0
  66. package/dist/utils/config-file.d.ts.map +1 -1
  67. package/dist/utils/config-file.js +15 -0
  68. package/dist/utils/config-file.js.map +1 -1
  69. package/dist/utils/config.d.ts +2 -0
  70. package/dist/utils/config.d.ts.map +1 -1
  71. package/dist/utils/config.js +12 -4
  72. package/dist/utils/config.js.map +1 -1
  73. package/dist/utils/errors.js +1 -1
  74. package/dist/utils/errors.js.map +1 -1
  75. package/dist/utils/list-defaults.d.ts +33 -0
  76. package/dist/utils/list-defaults.d.ts.map +1 -0
  77. package/dist/utils/list-defaults.js +52 -0
  78. package/dist/utils/list-defaults.js.map +1 -0
  79. package/dist/utils/output.d.ts.map +1 -1
  80. package/dist/utils/output.js +36 -13
  81. package/dist/utils/output.js.map +1 -1
  82. package/dist/utils/progress.d.ts.map +1 -1
  83. package/dist/utils/progress.js +32 -4
  84. package/dist/utils/progress.js.map +1 -1
  85. package/dist/utils/spinner.d.ts +17 -0
  86. package/dist/utils/spinner.d.ts.map +1 -0
  87. package/dist/utils/spinner.js +43 -0
  88. package/dist/utils/spinner.js.map +1 -0
  89. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  90. package/docs/README.md +161 -0
  91. package/docs/developer/ARCHITECTURE.md +516 -0
  92. package/docs/developer/AUTH.md +204 -0
  93. package/docs/developer/CONTRIBUTING.md +227 -0
  94. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  95. package/docs/developer/PROJECT_INDEX.md +365 -0
  96. package/docs/planning/API_COVERAGE.md +1045 -0
  97. package/docs/planning/BACKLOG.md +1159 -0
  98. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  99. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  100. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  101. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  102. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  103. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  104. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  105. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  106. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  107. package/docs/user-manual/.obsidian/app.json +1 -0
  108. package/docs/user-manual/.obsidian/appearance.json +1 -0
  109. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  110. package/docs/user-manual/.obsidian/workspace.json +167 -0
  111. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  112. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  113. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  114. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  115. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  116. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  117. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  118. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  119. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  120. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  121. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  122. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  123. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  124. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  125. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  126. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  127. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  128. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  129. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  130. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  131. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  132. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  133. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  134. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  135. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  136. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  137. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  138. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  139. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  140. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  141. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  142. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  143. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  144. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  145. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  146. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  147. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  148. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  149. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  150. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  151. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  152. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  153. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  154. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  155. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  156. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  157. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  158. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  159. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  160. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  161. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  162. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  163. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  164. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  165. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  166. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  167. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  168. package/docs/user-manual/README.md +0 -0
  169. package/package.json +13 -47
  170. package/src/cli.ts +125 -0
  171. package/src/client.ts +16 -0
  172. package/src/commands/account.ts +267 -0
  173. package/src/commands/accounts.ts +78 -0
  174. package/src/commands/actions.ts +249 -0
  175. package/src/commands/attributes.ts +139 -0
  176. package/src/commands/campaign-blueprints.ts +106 -0
  177. package/src/commands/campaigns.ts +469 -0
  178. package/src/commands/config.ts +77 -0
  179. package/src/commands/contacts.ts +612 -0
  180. package/src/commands/custom-attributes.ts +127 -0
  181. package/src/commands/dkims.ts +117 -0
  182. package/src/commands/domains.ts +82 -0
  183. package/src/commands/email-apis.ts +569 -0
  184. package/src/commands/emails.ts +197 -0
  185. package/src/commands/forms.ts +283 -0
  186. package/src/commands/interests.ts +155 -0
  187. package/src/commands/links.ts +38 -0
  188. package/src/commands/lists.ts +406 -0
  189. package/src/commands/logos.ts +71 -0
  190. package/src/commands/logs.ts +386 -0
  191. package/src/commands/reports.ts +306 -0
  192. package/src/commands/segments.ts +158 -0
  193. package/src/commands/senders.ts +204 -0
  194. package/src/commands/sub-accounts.ts +271 -0
  195. package/src/commands/suppressed-emails.ts +234 -0
  196. package/src/commands/suppressed.ts +198 -0
  197. package/src/commands/system-emails.ts +85 -0
  198. package/src/commands/tags.ts +146 -0
  199. package/src/commands/tasks.ts +116 -0
  200. package/src/commands/templates.ts +189 -0
  201. package/src/commands/tokens.ts +83 -0
  202. package/src/commands/transactional-emails.ts +374 -0
  203. package/src/commands/transactional-templates.ts +385 -0
  204. package/src/commands/users.ts +506 -0
  205. package/src/commands/webhooks.ts +172 -0
  206. package/src/commands/workflow-blueprints.ts +123 -0
  207. package/src/commands/workflows.ts +265 -0
  208. package/src/types/profile.ts +93 -0
  209. package/src/utils/auth.ts +272 -0
  210. package/src/utils/config-file.ts +96 -0
  211. package/src/utils/config.ts +134 -0
  212. package/src/utils/confirm.ts +32 -0
  213. package/src/utils/defaults.ts +99 -0
  214. package/src/utils/errors.ts +116 -0
  215. package/src/utils/interactive.ts +91 -0
  216. package/src/utils/list-defaults.ts +74 -0
  217. package/src/utils/output.ts +190 -0
  218. package/src/utils/progress.ts +320 -0
  219. package/src/utils/spinner.ts +22 -0
  220. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  221. package/tests/PTY_SETUP.md +118 -0
  222. package/tests/PTY_TESTING_GUIDE.md +507 -0
  223. package/tests/README.md +244 -0
  224. package/tests/fixtures/api-responses/campaigns.json +34 -0
  225. package/tests/fixtures/test-config.json +13 -0
  226. package/tests/helpers/cli-runner.ts +128 -0
  227. package/tests/helpers/mock-server.ts +301 -0
  228. package/tests/helpers/pty-runner.ts +181 -0
  229. package/tests/integration/campaigns-real-api.test.ts +196 -0
  230. package/tests/integration/setup-integration.ts +50 -0
  231. package/tests/pty/campaigns.test.ts +241 -0
  232. package/tests/setup.ts +34 -0
  233. package/tsconfig.json +15 -0
  234. package/vitest.config.ts +28 -0
@@ -0,0 +1,438 @@
1
+ # Cakemail CLI UX Improvements - Implementation Plan
2
+
3
+ ## Context
4
+ The Cakemail CLI is built on the official SDK with 100% API coverage (232 operations). Current implementation uses environment variables for auth and supports JSON/table/compact output formats. Goal is to widen the audience by improving UX for both technical and non-technical users.
5
+
6
+ ## Priority 1: Critical for User Adoption
7
+
8
+ ### 1.1 Interactive Auth Setup
9
+ **Problem:** Environment variable-only auth intimidates non-technical users
10
+ **Solution:** Add interactive auth configuration
11
+
12
+ ```bash
13
+ cakemail auth setup
14
+ # Interactive prompts:
15
+ # - Choose auth method (email/password or access token)
16
+ # - Save to ~/.cakemail/config.json
17
+ # - Validate credentials immediately
18
+ # - Show success with user info
19
+
20
+ cakemail auth status
21
+ # Display: current auth method, authenticated user, token expiry
22
+
23
+ cakemail auth logout
24
+ # Clear stored credentials, confirm action
25
+ ```
26
+
27
+ **Implementation Notes:**
28
+ - Store config in `~/.cakemail/config.json`
29
+ - Encrypt sensitive data (password/token)
30
+ - Support project-local `.cakemail/config.json` (overrides global)
31
+ - Priority: Auth flag > Project config > Global config > Env vars
32
+
33
+ ### 1.2 Actionable Error Messages
34
+ **Problem:** Raw API errors aren't helpful
35
+ **Solution:** Translate API errors to actionable messages
36
+
37
+ **Examples:**
38
+ ```
39
+ ❌ Current: "403 Forbidden"
40
+ ✅ Improved: "Sender 'john@example.com' is not verified.
41
+ Run: cakemail senders resend-confirmation 789"
42
+
43
+ ❌ Current: "422 Validation Error"
44
+ ✅ Improved: "Campaign missing required field 'subject'.
45
+ Add with: --subject 'Your Subject'"
46
+
47
+ ❌ Current: "401 Unauthorized"
48
+ ✅ Improved: "Authentication failed. Your credentials may be expired.
49
+ Run: cakemail auth setup"
50
+ ```
51
+
52
+ **Implementation Notes:**
53
+ - Create error translator middleware
54
+ - Map common API error codes to user-friendly messages
55
+ - Include suggested fix commands
56
+ - Show full error with `--debug` flag
57
+
58
+ ### 1.3 Email Preview (--preview flag)
59
+ **Problem:** No way to see email before sending
60
+ **Solution:** Preview rendered HTML in browser
61
+
62
+ ```bash
63
+ cakemail emails send -t user@example.com --html-file email.html --preview
64
+ # → Opens rendered HTML in default browser
65
+ # → Shows variables, personalization
66
+ # → Does NOT send email
67
+
68
+ cakemail campaigns test 123 --preview
69
+ # → Render campaign without sending test
70
+ ```
71
+
72
+ **Implementation Notes:**
73
+ - Create temp HTML file with styles inlined
74
+ - Open with system default browser
75
+ - Clean up temp file after viewing
76
+ - Support `--preview-only` (preview without other actions)
77
+
78
+ ### 1.4 Natural Date Parsing
79
+ **Problem:** ISO 8601 timestamps are hard to remember
80
+ **Solution:** Accept human-friendly date formats
81
+
82
+ ```bash
83
+ # Current (still supported):
84
+ cakemail campaigns schedule 123 -d "2025-10-15T10:00:00Z"
85
+
86
+ # New options:
87
+ cakemail campaigns schedule 123 -d "tomorrow 10am"
88
+ cakemail campaigns schedule 123 -d "Oct 15 10:00"
89
+ cakemail campaigns schedule 123 -d "next monday 2pm"
90
+ cakemail campaigns schedule 123 -d "+2 days"
91
+ cakemail campaigns schedule 123 -d "2025-10-15 10:00" # Simpler format
92
+ ```
93
+
94
+ **Implementation Notes:**
95
+ - Use library like `chrono-node` or `date-fns` for parsing
96
+ - Default to user's timezone, show what was parsed
97
+ - Validate parsed date is in future for scheduling
98
+ - Show parsed datetime before confirming: "Scheduling for Oct 15, 2025 10:00 AM EDT"
99
+
100
+ ### 1.5 Quickstart Wizard
101
+ **Problem:** New users don't know where to start
102
+ **Solution:** Guided onboarding flow
103
+
104
+ ```bash
105
+ cakemail quickstart
106
+ # Interactive wizard:
107
+ # 1. Check auth (or run auth setup)
108
+ # 2. "Let's send your first email"
109
+ # 3. Create/select sender → verify email
110
+ # 4. Create/select list
111
+ # 5. Add test contact
112
+ # 6. Create simple template or use HTML
113
+ # 7. Send test email
114
+ # 8. "Success! 🎉 Next steps: [suggestions]"
115
+ ```
116
+
117
+ **Implementation Notes:**
118
+ - Skip completed steps (if sender exists, don't recreate)
119
+ - Save progress (can resume if interrupted)
120
+ - Offer "skip" option at each step
121
+ - End with summary of created resources and next steps
122
+
123
+ ## Priority 2: High Value, Medium Effort
124
+
125
+ ### 2.1 Interactive Mode for Missing Required Fields
126
+ **Problem:** Users must remember all required flags
127
+ **Solution:** Prompt for missing required fields
128
+
129
+ ```bash
130
+ # User runs:
131
+ cakemail campaigns create -n "My Campaign"
132
+
133
+ # CLI prompts:
134
+ # → "Which list? (showing your 5 most recent)"
135
+ # 1. Newsletter Subscribers (123) - 5,234 contacts
136
+ # 2. Customers (456) - 1,847 contacts
137
+ # ...
138
+ # → "Which sender? (showing verified senders)"
139
+ # → "Which template? (or press Enter to skip)"
140
+ ```
141
+
142
+ **Implementation Notes:**
143
+ - Only prompt in TTY (skip if piped/scripted)
144
+ - Show most relevant options (recent, frequently used)
145
+ - Allow typing to search/filter
146
+ - Support `--no-interactive` to disable prompts
147
+
148
+ ### 2.2 Confirmation for Dangerous Operations
149
+ **Problem:** Easy to accidentally delete/cancel
150
+ **Solution:** Add confirmation prompts (without --force)
151
+
152
+ ```bash
153
+ cakemail campaigns delete 123
154
+ # → "Delete campaign 'Black Friday Sale' (123)?
155
+ # This cannot be undone. [y/N]"
156
+
157
+ cakemail campaigns cancel 456
158
+ # → "Cancel scheduled campaign 'Newsletter' (456)?
159
+ # This will stop delivery to 10,234 remaining contacts. [y/N]"
160
+ ```
161
+
162
+ **Implementation Notes:**
163
+ - Skip confirmation with `--force` or `-y`
164
+ - Skip in non-interactive mode
165
+ - Show impact (e.g., "5,234 contacts", "scheduled for tomorrow")
166
+ - Require typing full resource name for very dangerous ops
167
+
168
+ ### 2.3 Rich Table Output
169
+ **Problem:** Table output lacks visual hierarchy
170
+ **Solution:** Enhance table with colors, better formatting
171
+
172
+ **Features:**
173
+ - Color-code status (green=delivered/active, yellow=scheduled/pending, red=failed/bounced)
174
+ - Show relative dates ("2 hours ago" vs "2025-10-11T14:30:00Z")
175
+ - Truncate long fields intelligently (hover/expand in supported terminals)
176
+ - Add `--watch` for live updates
177
+
178
+ ```bash
179
+ cakemail campaigns list -f table
180
+ # Shows colorized status, relative dates
181
+
182
+ cakemail campaigns get 123 --watch
183
+ # Live updates: delivered count, opens, clicks (refresh every 5s)
184
+ ```
185
+
186
+ **Implementation Notes:**
187
+ - Use `chalk` for colors
188
+ - Respect `NO_COLOR` env var
189
+ - Use `date-fns` for relative dates
190
+ - Implement watch with setInterval, clear screen between updates
191
+
192
+ ### 2.4 Search/Find Commands
193
+ **Problem:** List + grep is clunky
194
+ **Solution:** Built-in fuzzy search
195
+
196
+ ```bash
197
+ cakemail campaigns find "black friday"
198
+ # Searches: name, subject, tags
199
+ # Returns ranked results
200
+
201
+ cakemail templates find "newsletter"
202
+ cakemail senders find "john"
203
+
204
+ # Shorthand for recent:
205
+ cakemail campaigns list --recent # last 10
206
+ cakemail campaigns list --recent 25 # last 25
207
+ ```
208
+
209
+ **Implementation Notes:**
210
+ - Use fuzzy matching (fuzzysort or similar)
211
+ - Search across multiple fields (name, subject, tags, etc.)
212
+ - Rank results by relevance
213
+ - Support `--exact` for non-fuzzy search
214
+
215
+ ### 2.5 Smart File Handling
216
+ **Problem:** Must specify file type and all details
217
+ **Solution:** Auto-detect and infer from files
218
+
219
+ ```bash
220
+ # Auto-detect HTML vs text:
221
+ cakemail emails send -t user@example.com email.html
222
+ # → Infers subject from <title>
223
+ # → Detects HTML content type
224
+
225
+ # Support stdin:
226
+ cat newsletter.html | cakemail emails send -t user@example.com -s "Newsletter"
227
+
228
+ # Read subject from file:
229
+ cakemail emails send -t user@example.com email.html
230
+ # If email.html has <title>Weekly Newsletter</title>
231
+ # → Uses as subject (can override with -s)
232
+ ```
233
+
234
+ **Implementation Notes:**
235
+ - Detect file extension (.html, .txt, .md)
236
+ - Parse HTML for `<title>` tag as default subject
237
+ - Support stdin with `process.stdin`
238
+ - Show what was inferred: "Using subject from HTML: 'Weekly Newsletter'"
239
+
240
+ ## Priority 3: Power User Features
241
+
242
+ ### 3.1 Configuration Management
243
+ ```bash
244
+ cakemail config set default.sender-id 456
245
+ cakemail config set default.list-id 123
246
+ cakemail config set default.format compact
247
+ cakemail config get default.sender-id
248
+ cakemail config list # Show all settings
249
+
250
+ # Now creates campaign with defaults:
251
+ cakemail campaigns create -n "Weekly Newsletter"
252
+ ```
253
+
254
+ ### 3.2 Shell Completion
255
+ ```bash
256
+ # Generate completions:
257
+ cakemail completion bash > /etc/bash_completion.d/cakemail
258
+ cakemail completion zsh > ~/.zsh/completions/_cakemail
259
+ cakemail completion fish > ~/.config/fish/completions/cakemail.fish
260
+
261
+ # Autocomplete:
262
+ # - Commands and subcommands
263
+ # - Flag names
264
+ # - Dynamic values (campaign names, list IDs from recent items)
265
+ ```
266
+
267
+ ### 3.3 Bulk Operations
268
+ ```bash
269
+ # Import from CSV:
270
+ cakemail contacts import 123 contacts.csv
271
+ # → Smart column mapping (auto-detect email, first_name, etc.)
272
+ # → Prompt for custom field mapping
273
+ # → Show progress bar
274
+
275
+ # Export to CSV:
276
+ cakemail contacts export 123 contacts.csv
277
+
278
+ # Bulk actions:
279
+ cakemail campaigns list --status scheduled | cakemail campaigns pause --stdin
280
+ ```
281
+
282
+ ### 3.4 Dry Run Mode
283
+ ```bash
284
+ cakemail emails send -t user@example.com --html email.html --dry-run
285
+ # → "Would send email to user@example.com with subject: 'Newsletter'"
286
+
287
+ cakemail campaigns schedule 123 -d "tomorrow 10am" --dry-run
288
+ # → "Would schedule campaign 'Black Friday' for Oct 12, 2025 10:00 AM EDT"
289
+
290
+ cakemail contacts import 123 contacts.csv --dry-run
291
+ # → "Would import 5,234 contacts (2 duplicates, 3 invalid emails)"
292
+ ```
293
+
294
+ ### 3.5 Built-in Aliases & Custom Aliases
295
+ ```bash
296
+ # Built-in shortcuts:
297
+ cakemail c list # campaigns list
298
+ cakemail t list # templates list
299
+ cakemail s list # senders list
300
+ cakemail l list # lists list
301
+
302
+ # User-defined aliases:
303
+ cakemail alias add send-newsletter "campaigns create -n 'Newsletter' -l 123 -s 456"
304
+ cakemail alias list
305
+ cakemail alias remove send-newsletter
306
+
307
+ # Use alias:
308
+ cakemail send-newsletter --subject "Weekly Update"
309
+ ```
310
+
311
+ ### 3.6 Template Scaffolding
312
+ ```bash
313
+ cakemail templates scaffold newsletter
314
+ # → Generates newsletter.html with boilerplate
315
+
316
+ cakemail templates scaffold transactional --type order-confirmation
317
+ # → Generates order-confirmation.html
318
+
319
+ cakemail init campaign
320
+ # → Creates campaign.yaml with commented examples
321
+
322
+ cakemail init workflow
323
+ # → Creates workflow.yaml template
324
+ ```
325
+
326
+ ## Priority 4: Nice to Have
327
+
328
+ ### 4.1 Enhanced Help & Examples
329
+ ```bash
330
+ cakemail campaigns create --help
331
+ # Show flags AND 2-3 real examples at bottom
332
+
333
+ cakemail examples campaigns
334
+ # List common campaign operations with copy-paste commands
335
+
336
+ cakemail examples emails
337
+ # List common email scenarios
338
+ ```
339
+
340
+ ### 4.2 Improved Default Output (no args)
341
+ ```bash
342
+ cakemail # No arguments
343
+ # → "Welcome to Cakemail CLI! 👋
344
+ #
345
+ # Not configured yet? Run: cakemail auth setup
346
+ # First time? Run: cakemail quickstart
347
+ # Need help? Run: cakemail --help
348
+ #
349
+ # Quick commands:
350
+ # cakemail campaigns list - View campaigns
351
+ # cakemail emails send - Send an email
352
+ # cakemail templates list - View templates"
353
+ ```
354
+
355
+ ### 4.3 Better Scripting Support
356
+ ```bash
357
+ # Compact JSON for jq:
358
+ cakemail campaigns list -f json --no-pretty
359
+
360
+ # Exit codes:
361
+ # 0 = success
362
+ # 1 = validation error
363
+ # 2 = auth error
364
+ # 3 = not found
365
+ # 4 = rate limit
366
+ # 5 = API error
367
+
368
+ # Quiet mode (only output ID/result):
369
+ cakemail campaigns create -n "Test" --quiet
370
+ # Output: 123
371
+
372
+ # Verbose mode:
373
+ cakemail campaigns create -n "Test" --verbose
374
+ # Shows: API requests, response times, full responses
375
+ ```
376
+
377
+ ### 4.4 Update Notifications
378
+ ```bash
379
+ # Check for updates on command run (max once per day)
380
+ # → "Update available: 1.2.3 → 1.3.0
381
+ # Run: npm update -g @cakemail-org/cakemail-cli"
382
+
383
+ cakemail update check
384
+ cakemail update install # If possible for installation method
385
+ ```
386
+
387
+ ## Implementation Guidelines
388
+
389
+ ### Project Structure
390
+ ```
391
+ src/
392
+ ├── commands/ # Command implementations
393
+ ├── utils/
394
+ │ ├── auth.ts # Auth management
395
+ │ ├── config.ts # Config management
396
+ │ ├── errors.ts # Error translation
397
+ │ ├── prompts.ts # Interactive prompts
398
+ │ ├── parsers.ts # Date parsing, etc.
399
+ │ └── formatters.ts # Output formatting
400
+ ├── middleware/ # CLI middleware (auth, validation, etc.)
401
+ └── cli.ts # Main entry point
402
+ ```
403
+
404
+ ### Key Libraries to Consider
405
+ - `inquirer` or `prompts` - Interactive prompts
406
+ - `chalk` - Terminal colors
407
+ - `ora` - Spinners/loading
408
+ - `cli-table3` - Tables
409
+ - `date-fns` or `chrono-node` - Date parsing
410
+ - `fuzzysort` - Fuzzy search
411
+ - `conf` - Config management
412
+ - `update-notifier` - Update checks
413
+ - `open` - Open browser for preview
414
+
415
+ ### Testing Strategy
416
+ - Unit tests for utilities (date parsing, error translation)
417
+ - Integration tests for commands
418
+ - E2E tests for critical flows (auth setup, quickstart)
419
+ - Manual testing for interactive features
420
+
421
+ ### Backwards Compatibility
422
+ - Keep all existing commands/flags working
423
+ - New features opt-in where possible
424
+ - Document breaking changes clearly
425
+ - Provide migration guide if needed
426
+
427
+ ## Success Metrics
428
+ - Reduction in "how do I" support questions
429
+ - Increase in CLI adoption vs API direct usage
430
+ - User feedback on ease of use
431
+ - Time to first successful email send for new users
432
+
433
+ ## Next Steps
434
+ 1. Review and prioritize features with team
435
+ 2. Create GitHub issues for each priority tier
436
+ 3. Implement Priority 1 features first (biggest impact)
437
+ 4. Gather user feedback after each release
438
+ 5. Iterate based on usage analytics and feedback