fraim-framework 2.0.27 → 2.0.30

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 (98) hide show
  1. package/.github/workflows/deploy-fraim.yml +1 -1
  2. package/dist/registry/scripts/build-scripts-generator.js +205 -0
  3. package/dist/registry/scripts/cleanup-branch.js +258 -0
  4. package/dist/registry/scripts/evaluate-code-quality.js +66 -0
  5. package/dist/registry/scripts/exec-with-timeout.js +142 -0
  6. package/dist/registry/scripts/fraim-config.js +61 -0
  7. package/dist/registry/scripts/generate-engagement-emails.js +630 -0
  8. package/dist/registry/scripts/generic-issues-api.js +100 -0
  9. package/dist/registry/scripts/newsletter-helpers.js +731 -0
  10. package/dist/registry/scripts/openapi-generator.js +664 -0
  11. package/dist/registry/scripts/performance/profile-server.js +390 -0
  12. package/dist/registry/scripts/run-thank-you-workflow.js +92 -0
  13. package/dist/registry/scripts/send-newsletter-simple.js +85 -0
  14. package/dist/registry/scripts/send-thank-you-emails.js +54 -0
  15. package/dist/registry/scripts/validate-openapi-limits.js +311 -0
  16. package/dist/registry/scripts/validate-test-coverage.js +262 -0
  17. package/dist/registry/scripts/verify-test-coverage.js +66 -0
  18. package/dist/src/cli/commands/init.js +14 -14
  19. package/dist/src/cli/commands/sync.js +4 -4
  20. package/dist/src/cli/fraim.js +24 -22
  21. package/dist/src/cli/setup/first-run.js +13 -6
  22. package/dist/src/fraim/db-service.js +26 -15
  23. package/dist/src/fraim/issues.js +67 -0
  24. package/dist/src/fraim-mcp-server.js +272 -18
  25. package/dist/src/utils/git-utils.js +1 -1
  26. package/dist/tests/debug-tools.js +79 -0
  27. package/dist/tests/esm-compat.js +11 -0
  28. package/dist/tests/test-chalk-esm-issue.js +159 -0
  29. package/dist/tests/test-chalk-real-world.js +265 -0
  30. package/dist/tests/test-chalk-regression.js +327 -0
  31. package/dist/tests/test-chalk-resolution-issue.js +304 -0
  32. package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
  33. package/dist/tests/test-fraim-issues.js +59 -0
  34. package/dist/tests/test-genericization.js +1 -1
  35. package/dist/tests/test-mcp-connection.js +166 -0
  36. package/dist/tests/test-mcp-issue-integration.js +144 -0
  37. package/dist/tests/test-mcp-lifecycle-methods.js +312 -0
  38. package/dist/tests/test-node-compatibility.js +71 -0
  39. package/dist/tests/test-npm-install.js +66 -0
  40. package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
  41. package/dist/tests/test-session-rehydration.js +145 -0
  42. package/dist/tests/test-standalone.js +2 -8
  43. package/dist/tests/test-telemetry.js +190 -0
  44. package/package.json +10 -8
  45. package/registry/agent-guardrails.md +62 -54
  46. package/registry/rules/agent-success-criteria.md +52 -0
  47. package/registry/rules/agent-testing-guidelines.md +502 -502
  48. package/registry/rules/communication.md +121 -121
  49. package/registry/rules/continuous-learning.md +54 -54
  50. package/registry/rules/ephemeral-execution.md +10 -5
  51. package/registry/rules/hitl-ppe-record-analysis.md +302 -302
  52. package/registry/rules/local-development.md +251 -251
  53. package/registry/rules/software-development-lifecycle.md +104 -104
  54. package/registry/rules/successful-debugging-patterns.md +482 -478
  55. package/registry/rules/telemetry.md +67 -0
  56. package/registry/scripts/build-scripts-generator.ts +216 -215
  57. package/registry/scripts/cleanup-branch.ts +303 -284
  58. package/registry/scripts/code-quality-check.sh +559 -559
  59. package/registry/scripts/detect-tautological-tests.sh +38 -38
  60. package/registry/scripts/evaluate-code-quality.ts +1 -1
  61. package/registry/scripts/generate-engagement-emails.ts +744 -744
  62. package/registry/scripts/generic-issues-api.ts +110 -150
  63. package/registry/scripts/newsletter-helpers.ts +874 -874
  64. package/registry/scripts/openapi-generator.ts +695 -693
  65. package/registry/scripts/performance/profile-server.ts +5 -3
  66. package/registry/scripts/prep-issue.sh +468 -455
  67. package/registry/scripts/validate-openapi-limits.ts +366 -365
  68. package/registry/scripts/validate-test-coverage.ts +280 -280
  69. package/registry/scripts/verify-pr-comments.sh +70 -70
  70. package/registry/scripts/verify-test-coverage.ts +1 -1
  71. package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +53 -53
  72. package/registry/templates/evidence/Implementation-BugEvidence.md +85 -85
  73. package/registry/templates/evidence/Implementation-FeatureEvidence.md +120 -120
  74. package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +66 -0
  75. package/registry/workflows/bootstrap/create-architecture.md +2 -2
  76. package/registry/workflows/bootstrap/evaluate-code-quality.md +3 -3
  77. package/registry/workflows/bootstrap/verify-test-coverage.md +2 -2
  78. package/registry/workflows/customer-development/insight-analysis.md +156 -156
  79. package/registry/workflows/customer-development/interview-preparation.md +421 -421
  80. package/registry/workflows/customer-development/strategic-brainstorming.md +146 -146
  81. package/registry/workflows/customer-development/thank-customers.md +193 -191
  82. package/registry/workflows/customer-development/weekly-newsletter.md +362 -352
  83. package/registry/workflows/improve-fraim/contribute.md +32 -0
  84. package/registry/workflows/improve-fraim/file-issue.md +32 -0
  85. package/registry/workflows/marketing/hbr-article.md +73 -0
  86. package/registry/workflows/performance/analyze-performance.md +63 -59
  87. package/registry/workflows/product-building/design.md +3 -2
  88. package/registry/workflows/product-building/implement.md +4 -3
  89. package/registry/workflows/product-building/prep-issue.md +28 -17
  90. package/registry/workflows/product-building/resolve.md +3 -2
  91. package/registry/workflows/product-building/retrospect.md +3 -2
  92. package/registry/workflows/product-building/spec.md +5 -4
  93. package/registry/workflows/product-building/test.md +3 -2
  94. package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +562 -562
  95. package/registry/workflows/replicate/website-discovery-analysis.md +3 -3
  96. package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +632 -632
  97. package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +669 -669
  98. package/tsconfig.json +2 -1
@@ -1,352 +1,362 @@
1
- # Weekly Newsletter Workflow
2
-
3
- ## INTENT
4
- To generate and distribute a compelling weekly newsletter that showcases the AI Agent's amazing new features and improvements, creating excitement among current users and FOMO for subscribers who haven't joined yet.
5
-
6
- ## PRINCIPLES
7
- - **Value-Focused**: Highlight features and improvements that deliver real value to users
8
- - **User-Facing Only**: Do NOT include internal features (admin dashboards, monitoring, backups, devops)
9
- - **Authentic Testimonials**: Only use real testimonials from actual users - NO fake quotes
10
- - **FOMO-Inducing**: Create urgency and excitement about missing out
11
- - **Visually Stunning**: Beautiful design that catches the eye
12
- - **Concise**: Scannable format with clear sections
13
- - **AI Creativity**: AI agent makes all editorial decisions - what's a feature vs bug, what's worth highlighting
14
-
15
- ## WORKFLOW TRIGGER
16
- **User triggers this workflow manually**:
17
- - Weekly, typically Monday morning
18
- - User says: "Generate this week's newsletter" or similar
19
-
20
- ## AI AGENT PROCESS
21
-
22
- ### Step 1: Issue Retrieval
23
- **AI Agent calls function**:
24
- ```typescript
25
- import { getResolvedIssuesForNewsletter } from '.ai-agents/scripts/newsletter-helpers.ts';
26
-
27
- // Get issues resolved since last newsletter (automatic) or user-specified date
28
- const resolvedIssues = await getResolvedIssuesForNewsletter(); // Automatically uses latest newsletter date
29
- // OR with explicit date:
30
- const resolvedIssues = await getResolvedIssuesForNewsletter('2025-10-25'); // Optional: user-specified date
31
- ```
32
-
33
- **Note**: The `getResolvedIssuesForNewsletter()` function automatically:
34
- - Finds the most recent newsletter date from existing files
35
- - Uses that date as the starting point to fetch issues resolved AFTER that date
36
- - If no newsletter files exist, falls back to last 7 days
37
- - Returns ALL closed issues - AI agent decides what to include
38
-
39
- ### Step 2: Intelligent Categorization & Filtering
40
- **AI Agent does creative analysis**:
41
-
42
- 1. **Go through each resolved issue** and make editorial decisions:
43
- - Is this user-facing or internal?
44
- - Is this a feature, improvement, or bug fix?
45
- - Is this worth highlighting to users?
46
- - How should this be described to non-technical users?
47
-
48
- 2. **Filter out internal-only issues**:
49
- - Admin dashboards, monitoring, analytics (internal tools)
50
- - Database backups, devops improvements
51
- - CI/CD, deployment automation
52
- - Developer tools, debugging features
53
- - Documentation updates, dependency updates
54
- - **API route fixes, endpoint refactoring, code structure changes**
55
- - **Environment variable updates, configuration file changes**
56
- - **Developer setup improvements, build process updates**
57
- - **Internal bug fixes that don't impact user experience**
58
- - Any change without user-facing impact
59
-
60
- 3. **Categorize remaining issues**:
61
- - **Features**: Adds NEW capability users didn't have before
62
- - **Improvements**: Makes existing functionality better/faster/easier
63
- - **Bug Fixes**: Fixes something that was broken
64
-
65
- 4. **Select hero feature** (optional):
66
- - Pick the MOST impactful feature or improvement
67
- - Must have clear user value and ideally a quantifiable impact statement
68
-
69
- ### Step 3: Write Compelling Content
70
- **AI Agent writes newsletter content** - be creative, exciting, and user-focused!
71
-
72
- **Guidelines**:
73
- - **NO TECHNICAL JARGON**: Don't mention internal systems, code, or technical details
74
- - **USER VALUE FOCUS**: Describe what the user can now do, not how it works
75
- - **ACTIVE, EXCITING LANGUAGE**: "You can now...", "The AI Agent now automatically...", "Your calendar finally..."
76
- - **QUANTIFY IMPACT**: "85% reduction in...", "5 hours saved per week", "3x faster"
77
- - **CREATE FOMO**: "Current users are already...", "Join 500+ executives who..."
78
-
79
- **For each item, write**:
80
- - **Title**: Short, benefit-focused (e.g., "Smart Timezone Detection" not "Implement timezone handling")
81
- - **Description**: What the user can do now, why it matters (2-3 sentences)
82
- - **Impact** (optional): Quantified benefit or user testimonial
83
-
84
- **Example**:
85
- ```json
86
- {
87
- "title": "Work Hours & Focus Blocks on Your Calendar",
88
- "description": "Your work hours and focus blocks now automatically appear as visual blocks on your calendar! No more scheduling conflicts during your protected time. The AI creates beautiful calendar events that sync across all your devices, making it crystal clear when you're available and when you're in deep work mode.",
89
- "impact": "Users report 85% reduction in meeting conflicts during focus time. Your calendar finally shows the complete picture of your day!"
90
- }
91
- ```
92
-
93
- ### Step 4: Generate Newsletter JSON
94
- **AI Agent creates ONE file**:
95
- - File: `docs/customer-development/newsletters/newsletter-YYYY-MM-DD.json`
96
- - Format: Structured JSON for deterministic rendering
97
- - Contains ALL content ready for user review
98
-
99
- **File format** (JSON):
100
- ```json
101
- {
102
- "metadata": {
103
- "generatedOn": "2025-11-01T00:00:00.000Z",
104
- "weekStart": "2025-10-25",
105
- "weekEnd": "2025-11-01",
106
- ...
107
- },
108
- "content": {
109
- "weekTitle": "Work Hours & Focus Blocks Now on Your Calendar! 🎯",
110
- "weekSubtitle": "8 powerful updates that supercharge your productivity",
111
- "weekDate": "Oct 25 - Nov 1, 2025",
112
- "openingMessage": "This week has been HUGE! We've shipped game-changing features that make the AI Agent even more powerful at protecting your time and managing your schedule. Current users are already saving hours every week - here's what you've been missing! 🚀",
113
- "heroFeature": { ... },
114
- "newFeatures": [ ... ],
115
- "improvements": [ ... ],
116
- "bugFixes": [ ... ],
117
- "testimonial": {
118
- "text": "The AI saved me 5 hours this week just by protecting my focus blocks...",
119
- "author": "Sid Mathur",
120
- "role": "Founder"
121
- },
122
- "comingNext": "Next week: Voice commands for calendar management, smart meeting summaries...",
123
- "ctaLink": "https://example.com/wellness/ai-agent",
124
- "ctaText": "Start Your Free Trial"
125
- }
126
- }
127
- ```
128
-
129
- ### Step 5: Generate HTML
130
- **AI Agent calls function**:
131
- ```typescript
132
- import { saveNewsletter } from '.ai-agents/scripts/newsletter-helpers.ts';
133
-
134
- // Save newsletter JSON and generate HTML
135
- const savedPath = saveNewsletter(newsletter);
136
- ```
137
-
138
- **This function will**:
139
- - Save the JSON file
140
- - Generate beautiful HTML from the template
141
- - Save the HTML file
142
- - Return path to JSON file
143
-
144
- ### Step 6: User Review
145
- **AI Agent**:
146
- 1. **Points user to the generated file**: `docs/customer-development/newsletters/newsletter-YYYY-MM-DD.json`
147
- 2. **Shows preview**: Points to HTML file for browser preview
148
- 3. **Requests review** and any edits needed (user can edit JSON directly)
149
- 4. **Waits for user approval** before proceeding
150
-
151
- **Note**: User can:
152
- - Edit titles to be more compelling
153
- - Add/remove items
154
- - Adjust descriptions
155
- - Add real testimonials (verify authenticity!)
156
- - Add "coming next" teaser
157
-
158
- ### Step 7: Send Newsletter (Separate Command)
159
- **When user says "Send the newsletter" or similar**:
160
-
161
- **User runs deterministic script**:
162
- ```bash
163
- npm run send-newsletter
164
- ```
165
-
166
- **OR AI Agent can call function**:
167
- ```typescript
168
- import { sendNewsletterToExecutives } from '.ai-agents/scripts/newsletter-helpers.ts';
169
-
170
- // Send newsletter to all active executives
171
- await sendNewsletterToExecutives('docs/customer-development/newsletters/newsletter-2025-11-01.json');
172
- ```
173
-
174
- **This function will**:
175
- - Load the approved newsletter JSON
176
- - Get all active executives from database
177
- - For each executive:
178
- - Get their AI Agent email address
179
- - Get their OAuth tokens
180
- - Send personalized newsletter from their AI identity
181
- - Log results and exit
182
-
183
- ## NEWSLETTER STRUCTURE
184
-
185
- ### Hero Section
186
- - **Week Title**: Catchy title based on hero feature or main theme
187
- - **Subtitle**: Count of updates
188
- - **Stats Banner**: Features | Improvements | Bug Fixes counters
189
-
190
- ### Content Sections
191
- 1. **Opening Message**: Exciting intro about what shipped (AI agent writes this)
192
- 2. **Hero Feature** (optional): Spotlights the most impactful change with red "HERO FEATURE" badge
193
- 3. **New Capabilities**: Major new features added
194
- 4. **Major Improvements**: Significant enhancements
195
- 5. **Fixes & Polish**: Bug fixes and minor improvements
196
- 6. **Testimonial** (optional): Real user quote about impact (VERIFY AUTHENTICITY)
197
- 7. **Coming Next** (optional): Preview of upcoming features
198
-
199
- ### Call-to-Actions
200
- - **FOMO CTA**: "Don't Miss Out!" with signup link
201
- - **Feedback CTA**: Link to ChatGPT interface
202
-
203
- ## EDITORIAL GUIDELINES
204
-
205
- ### What to Include
206
- - New features that add capability for users
207
- - Improvements that save time or improve UX
208
- - Bug fixes that had user impact
209
- - Real user testimonials (ONLY - verify authenticity)
210
- - Quantified benefits (time saved, conflicts reduced, etc.)
211
-
212
- ### What to Exclude ❌
213
- - Internal infrastructure changes
214
- - **Admin dashboards, monitoring, analytics (internal-only)**
215
- - **Backups, database operations, devops**
216
- - **API route fixes, duplicate endpoint resolution**
217
- - **Environment configuration, .env file updates**
218
- - **Developer setup scripts, build configuration**
219
- - CI/CD improvements
220
- - Documentation updates
221
- - Dependency updates
222
- - Technical debt cleanup
223
- - Developer tools and debugging features
224
- - **Internal bug fixes (code structure, not user experience)**
225
- - Issues without user-facing impact
226
- - **FAKE TESTIMONIALS - authenticity is critical**
227
-
228
- **Rule of thumb**: If the user wouldn't notice the change in their daily use of the AI Assistant, don't include it.
229
-
230
- ### Writing Style
231
-
232
- **Titles:**
233
- - Short, punchy, benefit-focused
234
- - "Implement timezone handling in calendar service"
235
- - "Smart Timezone Detection"
236
-
237
- **Descriptions:**
238
- - Start with the benefit to the user
239
- - Use "you" and "your" to make it personal
240
- - Be specific about what changed
241
- - ❌ "Fixed bug where calendar events weren't syncing correctly"
242
- - ✅ "Your calendar now stays perfectly in sync across all devices, no more mysterious missing meetings!"
243
-
244
- **Impact Statements:**
245
- - Quantify whenever possible
246
- - Include real user feedback
247
- - ❌ "Improved performance"
248
- - "Calendar loads 3x faster, getting you to your day in seconds instead of minutes"
249
-
250
- ### Creating FOMO
251
-
252
- - **Quantify Success**: "500+ executives already using this feature"
253
- - **Show Savings**: "Don't miss out on 5 hours saved per week"
254
- - **Create Urgency**: "Limited spots available"
255
- - **Social Proof**: Real testimonials, growth stats, company names (with permission)
256
-
257
- ## EXAMPLES
258
-
259
- ### Example 1: Feature-Rich Week
260
- ```
261
- User: "Generate this week's newsletter"
262
-
263
- AI Agent:
264
- 1. Calls getResolvedIssuesForNewsletter() gets 15 issues
265
- 2. Analyzes each issue:
266
- - 3 user-facing features
267
- - 5 improvements
268
- - 2 bugs
269
- - 5 internal/devops (FILTERED OUT)
270
- 3. Writes compelling content for each item
271
- 4. Selects "Voice Commands for Calendar" as hero feature
272
- 5. Writes exciting opening: "This week has been HUGE!..."
273
- 6. Creates newsletter JSON with all content
274
- 7. Calls saveNewsletter() → generates HTML
275
- 8. Shows preview: "Newsletter ready! docs/customer-development/newsletters/newsletter-2025-11-01.html"
276
-
277
- User: "Looks great, send it"
278
-
279
- AI Agent or User:
280
- Runs: npm run send-newsletter
281
- OR
282
- Calls: sendNewsletterToExecutives('newsletter-2025-11-01.json')
283
- ```
284
-
285
- ### Example 2: User Adds Testimonial
286
- ```
287
- User: "Generate newsletter"
288
-
289
- AI Agent:
290
- [Creates newsletter with 5 improvements, no testimonial]
291
-
292
- User: "Add a testimonial from me - I saved 5 hours this week thanks to focus blocks"
293
-
294
- AI Agent:
295
- [Edits JSON to add testimonial with user's name]
296
- [Regenerates HTML]
297
- Shows: "Updated! Ready to send?"
298
-
299
- User: "Yes, send it"
300
-
301
- User runs: npm run send-newsletter
302
- ```
303
-
304
- ## TIPS FOR COMPELLING NEWSLETTERS
305
-
306
- ### Highlight User Value
307
- - Focus on what users can DO, not how it works
308
- - "You can now..." not "We implemented..."
309
- - "Your calendar automatically..." not "The system now..."
310
-
311
- ### Use Concrete Examples
312
- - "Schedule meetings in seconds" not "Faster scheduling"
313
- - "85% fewer conflicts" not "Better conflict detection"
314
- - "Save 5 hours per week" not "More efficient"
315
-
316
- ### Create Narrative
317
- - Opening: "This week has been incredible!"
318
- - Hero feature: Build excitement around main change
319
- - Coming next: Build anticipation for next week
320
-
321
- ### Make it Scannable
322
- - Short paragraphs (2-3 sentences max)
323
- - Clear section headers
324
- - Visual hierarchy with emojis and formatting
325
- - Impact callouts that stand out
326
-
327
- ## QUALITY CHECKLIST
328
-
329
- Before approving newsletter, verify:
330
- - [ ] All items are user-facing (no internal/devops features)
331
- - [ ] Testimonials are real and verified
332
- - [ ] Impact statements are accurate and quantified
333
- - [ ] Descriptions focus on user value, not implementation
334
- - [ ] Opening message is exciting and FOMO-inducing
335
- - [ ] Links are correct (Azure signup URL)
336
- - [ ] No mention of API credits or costs (the service is free)
337
- - [ ] Grammar and spelling are perfect
338
- - [ ] Preview HTML looks beautiful in browser
339
-
340
- ## FREQUENCY
341
-
342
- **Recommended**: Weekly, sent Monday morning
343
- - Catches people starting their week
344
- - Fresh in mind for decision-making
345
- - Consistent schedule builds anticipation
346
-
347
- **Alternative**: Bi-weekly if weekly feels too frequent
348
-
349
- **Special editions**:
350
- - Major feature launches
351
- - Milestone celebrations (e.g., "100 users!")
352
- - Holiday/end-of-year roundups
1
+ # Weekly Newsletter Workflow
2
+
3
+ ## INTENT
4
+ To generate and distribute a compelling weekly newsletter that showcases the AI Agent's amazing new features and improvements, creating excitement among current users and FOMO for subscribers who haven't joined yet.
5
+
6
+ ## PRINCIPLES
7
+ - **Value-Focused**: Highlight features and improvements that deliver real value to users
8
+ - **User-Facing Only**: Do NOT include internal features (admin dashboards, monitoring, backups, devops)
9
+ - **Authentic Testimonials**: Only use real testimonials from actual users - NO fake quotes
10
+ - **FOMO-Inducing**: Create urgency and excitement about missing out
11
+ - **Visually Stunning**: Beautiful design that catches the eye
12
+ - **Concise**: Scannable format with clear sections
13
+ - **AI Creativity**: AI agent makes all editorial decisions - what's a feature vs bug, what's worth highlighting
14
+
15
+ ## WORKFLOW TRIGGER
16
+ **User triggers this workflow manually**:
17
+ - Weekly, typically Monday morning
18
+ - User says: "Generate this week's newsletter" or similar
19
+
20
+ ## AI AGENT PROCESS
21
+
22
+ ### Step 1: Issue Retrieval
23
+ **AI Agent calls function**:
24
+ ```typescript
25
+ // 1. Fetch the helper script
26
+ const scriptContent = await get_fraim_file({ path: "scripts/newsletter-helpers.ts" });
27
+
28
+ // 2. Save it to a temporary file (e.g. machine temp dir)
29
+ const os = require('os');
30
+ const path = require('path');
31
+ const tempScriptPath = path.join(os.tmpdir(), 'newsletter-helpers.ts');
32
+ const fs = require('fs');
33
+ fs.writeFileSync(tempScriptPath, scriptContent);
34
+
35
+ // 3. Import from the temporary file
36
+ const { getResolvedIssuesForNewsletter } = await import(tempScriptPath);
37
+
38
+ // 4. Use the function
39
+ const resolvedIssues = await getResolvedIssuesForNewsletter();
40
+ ```
41
+
42
+ **Note**: The `getResolvedIssuesForNewsletter()` function automatically:
43
+ - Finds the most recent newsletter date from existing files
44
+ - Uses that date as the starting point to fetch issues resolved AFTER that date
45
+ - If no newsletter files exist, falls back to last 7 days
46
+ - Returns ALL closed issues - AI agent decides what to include
47
+
48
+ ### Step 2: Intelligent Categorization & Filtering
49
+ **AI Agent does creative analysis**:
50
+
51
+ 1. **Go through each resolved issue** and make editorial decisions:
52
+ - Is this user-facing or internal?
53
+ - Is this a feature, improvement, or bug fix?
54
+ - Is this worth highlighting to users?
55
+ - How should this be described to non-technical users?
56
+
57
+ 2. **Filter out internal-only issues**:
58
+ - Admin dashboards, monitoring, analytics (internal tools)
59
+ - Database backups, devops improvements
60
+ - CI/CD, deployment automation
61
+ - Developer tools, debugging features
62
+ - Documentation updates, dependency updates
63
+ - **API route fixes, endpoint refactoring, code structure changes**
64
+ - **Environment variable updates, configuration file changes**
65
+ - **Developer setup improvements, build process updates**
66
+ - **Internal bug fixes that don't impact user experience**
67
+ - Any change without user-facing impact
68
+
69
+ 3. **Categorize remaining issues**:
70
+ - **Features**: Adds NEW capability users didn't have before
71
+ - **Improvements**: Makes existing functionality better/faster/easier
72
+ - **Bug Fixes**: Fixes something that was broken
73
+
74
+ 4. **Select hero feature** (optional):
75
+ - Pick the MOST impactful feature or improvement
76
+ - Must have clear user value and ideally a quantifiable impact statement
77
+
78
+ ### Step 3: Write Compelling Content
79
+ **AI Agent writes newsletter content** - be creative, exciting, and user-focused!
80
+
81
+ **Guidelines**:
82
+ - **NO TECHNICAL JARGON**: Don't mention internal systems, code, or technical details
83
+ - **USER VALUE FOCUS**: Describe what the user can now do, not how it works
84
+ - **ACTIVE, EXCITING LANGUAGE**: "You can now...", "The AI Agent now automatically...", "Your calendar finally..."
85
+ - **QUANTIFY IMPACT**: "85% reduction in...", "5 hours saved per week", "3x faster"
86
+ - **CREATE FOMO**: "Current users are already...", "Join 500+ executives who..."
87
+
88
+ **For each item, write**:
89
+ - **Title**: Short, benefit-focused (e.g., "Smart Timezone Detection" not "Implement timezone handling")
90
+ - **Description**: What the user can do now, why it matters (2-3 sentences)
91
+ - **Impact** (optional): Quantified benefit or user testimonial
92
+
93
+ **Example**:
94
+ ```json
95
+ {
96
+ "title": "Work Hours & Focus Blocks on Your Calendar",
97
+ "description": "Your work hours and focus blocks now automatically appear as visual blocks on your calendar! No more scheduling conflicts during your protected time. The AI creates beautiful calendar events that sync across all your devices, making it crystal clear when you're available and when you're in deep work mode.",
98
+ "impact": "Users report 85% reduction in meeting conflicts during focus time. Your calendar finally shows the complete picture of your day!"
99
+ }
100
+ ```
101
+
102
+ ### Step 4: Generate Newsletter JSON
103
+ **AI Agent creates ONE file**:
104
+ - File: `docs/customer-development/newsletters/newsletter-YYYY-MM-DD.json`
105
+ - Format: Structured JSON for deterministic rendering
106
+ - Contains ALL content ready for user review
107
+
108
+ **File format** (JSON):
109
+ ```json
110
+ {
111
+ "metadata": {
112
+ "generatedOn": "2025-11-01T00:00:00.000Z",
113
+ "weekStart": "2025-10-25",
114
+ "weekEnd": "2025-11-01",
115
+ ...
116
+ },
117
+ "content": {
118
+ "weekTitle": "Work Hours & Focus Blocks Now on Your Calendar! 🎯",
119
+ "weekSubtitle": "8 powerful updates that supercharge your productivity",
120
+ "weekDate": "Oct 25 - Nov 1, 2025",
121
+ "openingMessage": "This week has been HUGE! We've shipped game-changing features that make the AI Agent even more powerful at protecting your time and managing your schedule. Current users are already saving hours every week - here's what you've been missing! 🚀",
122
+ "heroFeature": { ... },
123
+ "newFeatures": [ ... ],
124
+ "improvements": [ ... ],
125
+ "bugFixes": [ ... ],
126
+ "testimonial": {
127
+ "text": "The AI saved me 5 hours this week just by protecting my focus blocks...",
128
+ "author": "Sid Mathur",
129
+ "role": "Founder"
130
+ },
131
+ "comingNext": "Next week: Voice commands for calendar management, smart meeting summaries...",
132
+ "ctaLink": "https://example.com/wellness/ai-agent",
133
+ "ctaText": "Start Your Free Trial"
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### Step 5: Generate HTML
139
+ // 1. Fetch helper script and save to temp (if not already done)
140
+ // const scriptContent = await get_fraim_file({ path: "scripts/newsletter-helpers.ts" });
141
+ // ... (save to tempScriptPath) ...
142
+ const { saveNewsletter } = await import(tempScriptPath);
143
+
144
+ // 2. Save newsletter JSON and generate HTML
145
+ const savedPath = saveNewsletter(newsletter);
146
+ ```
147
+
148
+ **This function will**:
149
+ - Save the JSON file
150
+ - Generate beautiful HTML from the template
151
+ - Save the HTML file
152
+ - Return path to JSON file
153
+
154
+ ### Step 6: User Review
155
+ **AI Agent**:
156
+ 1. **Points user to the generated file**: `docs/customer-development/newsletters/newsletter-YYYY-MM-DD.json`
157
+ 2. **Shows preview**: Points to HTML file for browser preview
158
+ 3. **Requests review** and any edits needed (user can edit JSON directly)
159
+ 4. **Waits for user approval** before proceeding
160
+
161
+ **Note**: User can:
162
+ - Edit titles to be more compelling
163
+ - Add/remove items
164
+ - Adjust descriptions
165
+ - Add real testimonials (verify authenticity!)
166
+ - Add "coming next" teaser
167
+
168
+ ### Step 7: Send Newsletter (Separate Command)
169
+ **When user says "Send the newsletter" or similar**:
170
+
171
+ **User runs deterministic script**:
172
+ ```bash
173
+ npm run send-newsletter
174
+ ```
175
+
176
+ // 1. Fetch helper script and save to temp (if not already done)
177
+ // ...
178
+ const { sendNewsletterToExecutives } = await import(tempScriptPath);
179
+
180
+ // 2. Send newsletter to all active executives
181
+ await sendNewsletterToExecutives('docs/customer-development/newsletters/newsletter-2025-11-01.json');
182
+ ```
183
+
184
+ **This function will**:
185
+ - Load the approved newsletter JSON
186
+ - Get all active executives from database
187
+ - For each executive:
188
+ - Get their AI Agent email address
189
+ - Get their OAuth tokens
190
+ - Send personalized newsletter from their AI identity
191
+ - Log results and exit
192
+
193
+ ## NEWSLETTER STRUCTURE
194
+
195
+ ### Hero Section
196
+ - **Week Title**: Catchy title based on hero feature or main theme
197
+ - **Subtitle**: Count of updates
198
+ - **Stats Banner**: Features | Improvements | Bug Fixes counters
199
+
200
+ ### Content Sections
201
+ 1. **Opening Message**: Exciting intro about what shipped (AI agent writes this)
202
+ 2. **Hero Feature** (optional): Spotlights the most impactful change with red "HERO FEATURE" badge
203
+ 3. **New Capabilities**: Major new features added
204
+ 4. **Major Improvements**: Significant enhancements
205
+ 5. **Fixes & Polish**: Bug fixes and minor improvements
206
+ 6. **Testimonial** (optional): Real user quote about impact (VERIFY AUTHENTICITY)
207
+ 7. **Coming Next** (optional): Preview of upcoming features
208
+
209
+ ### Call-to-Actions
210
+ - **FOMO CTA**: "Don't Miss Out!" with signup link
211
+ - **Feedback CTA**: Link to ChatGPT interface
212
+
213
+ ## EDITORIAL GUIDELINES
214
+
215
+ ### What to Include
216
+ - New features that add capability for users
217
+ - Improvements that save time or improve UX
218
+ - Bug fixes that had user impact
219
+ - Real user testimonials (ONLY - verify authenticity)
220
+ - Quantified benefits (time saved, conflicts reduced, etc.)
221
+
222
+ ### What to Exclude ❌
223
+ - Internal infrastructure changes
224
+ - **Admin dashboards, monitoring, analytics (internal-only)**
225
+ - **Backups, database operations, devops**
226
+ - **API route fixes, duplicate endpoint resolution**
227
+ - **Environment configuration, .env file updates**
228
+ - **Developer setup scripts, build configuration**
229
+ - CI/CD improvements
230
+ - Documentation updates
231
+ - Dependency updates
232
+ - Technical debt cleanup
233
+ - Developer tools and debugging features
234
+ - **Internal bug fixes (code structure, not user experience)**
235
+ - Issues without user-facing impact
236
+ - **FAKE TESTIMONIALS - authenticity is critical**
237
+
238
+ **Rule of thumb**: If the user wouldn't notice the change in their daily use of the AI Assistant, don't include it.
239
+
240
+ ### Writing Style
241
+
242
+ **Titles:**
243
+ - Short, punchy, benefit-focused
244
+ - ❌ "Implement timezone handling in calendar service"
245
+ - "Smart Timezone Detection"
246
+
247
+ **Descriptions:**
248
+ - Start with the benefit to the user
249
+ - Use "you" and "your" to make it personal
250
+ - Be specific about what changed
251
+ - ❌ "Fixed bug where calendar events weren't syncing correctly"
252
+ - "Your calendar now stays perfectly in sync across all devices, no more mysterious missing meetings!"
253
+
254
+ **Impact Statements:**
255
+ - Quantify whenever possible
256
+ - Include real user feedback
257
+ - ❌ "Improved performance"
258
+ - ✅ "Calendar loads 3x faster, getting you to your day in seconds instead of minutes"
259
+
260
+ ### Creating FOMO
261
+
262
+ - **Quantify Success**: "500+ executives already using this feature"
263
+ - **Show Savings**: "Don't miss out on 5 hours saved per week"
264
+ - **Create Urgency**: "Limited spots available"
265
+ - **Social Proof**: Real testimonials, growth stats, company names (with permission)
266
+
267
+ ## EXAMPLES
268
+
269
+ ### Example 1: Feature-Rich Week
270
+ ```
271
+ User: "Generate this week's newsletter"
272
+
273
+ AI Agent:
274
+ 1. Calls getResolvedIssuesForNewsletter() → gets 15 issues
275
+ 2. Analyzes each issue:
276
+ - 3 user-facing features
277
+ - 5 improvements
278
+ - 2 bugs
279
+ - 5 internal/devops (FILTERED OUT)
280
+ 3. Writes compelling content for each item
281
+ 4. Selects "Voice Commands for Calendar" as hero feature
282
+ 5. Writes exciting opening: "This week has been HUGE!..."
283
+ 6. Creates newsletter JSON with all content
284
+ 7. Calls saveNewsletter() → generates HTML
285
+ 8. Shows preview: "Newsletter ready! docs/customer-development/newsletters/newsletter-2025-11-01.html"
286
+
287
+ User: "Looks great, send it"
288
+
289
+ AI Agent or User:
290
+ Runs: npm run send-newsletter
291
+ OR
292
+ Calls: sendNewsletterToExecutives('newsletter-2025-11-01.json')
293
+ ```
294
+
295
+ ### Example 2: User Adds Testimonial
296
+ ```
297
+ User: "Generate newsletter"
298
+
299
+ AI Agent:
300
+ [Creates newsletter with 5 improvements, no testimonial]
301
+
302
+ User: "Add a testimonial from me - I saved 5 hours this week thanks to focus blocks"
303
+
304
+ AI Agent:
305
+ [Edits JSON to add testimonial with user's name]
306
+ [Regenerates HTML]
307
+ Shows: "Updated! Ready to send?"
308
+
309
+ User: "Yes, send it"
310
+
311
+ User runs: npm run send-newsletter
312
+ ```
313
+
314
+ ## TIPS FOR COMPELLING NEWSLETTERS
315
+
316
+ ### Highlight User Value
317
+ - Focus on what users can DO, not how it works
318
+ - "You can now..." not "We implemented..."
319
+ - "Your calendar automatically..." not "The system now..."
320
+
321
+ ### Use Concrete Examples
322
+ - "Schedule meetings in seconds" not "Faster scheduling"
323
+ - "85% fewer conflicts" not "Better conflict detection"
324
+ - "Save 5 hours per week" not "More efficient"
325
+
326
+ ### Create Narrative
327
+ - Opening: "This week has been incredible!"
328
+ - Hero feature: Build excitement around main change
329
+ - Coming next: Build anticipation for next week
330
+
331
+ ### Make it Scannable
332
+ - Short paragraphs (2-3 sentences max)
333
+ - Clear section headers
334
+ - Visual hierarchy with emojis and formatting
335
+ - Impact callouts that stand out
336
+
337
+ ## QUALITY CHECKLIST
338
+
339
+ Before approving newsletter, verify:
340
+ - [ ] All items are user-facing (no internal/devops features)
341
+ - [ ] Testimonials are real and verified
342
+ - [ ] Impact statements are accurate and quantified
343
+ - [ ] Descriptions focus on user value, not implementation
344
+ - [ ] Opening message is exciting and FOMO-inducing
345
+ - [ ] Links are correct (Azure signup URL)
346
+ - [ ] No mention of API credits or costs (the service is free)
347
+ - [ ] Grammar and spelling are perfect
348
+ - [ ] Preview HTML looks beautiful in browser
349
+
350
+ ## FREQUENCY
351
+
352
+ **Recommended**: Weekly, sent Monday morning
353
+ - Catches people starting their week
354
+ - Fresh in mind for decision-making
355
+ - Consistent schedule builds anticipation
356
+
357
+ **Alternative**: Bi-weekly if weekly feels too frequent
358
+
359
+ **Special editions**:
360
+ - Major feature launches
361
+ - Milestone celebrations (e.g., "100 users!")
362
+ - Holiday/end-of-year roundups