fraim-framework 2.0.36 → 2.0.38

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 (192) hide show
  1. package/bin/fraim.js +5 -52
  2. package/dist/registry/scripts/build-scripts-generator.js +205 -0
  3. package/dist/registry/scripts/fraim-config.js +61 -0
  4. package/dist/registry/scripts/generic-issues-api.js +100 -0
  5. package/dist/registry/scripts/openapi-generator.js +664 -0
  6. package/dist/registry/scripts/performance/profile-server.js +390 -0
  7. package/dist/scripts/build-stub-registry.js +108 -0
  8. package/dist/src/cli/commands/doctor.js +5 -5
  9. package/dist/src/cli/commands/init-project.js +74 -0
  10. package/dist/src/cli/commands/setup.js +176 -0
  11. package/dist/src/cli/commands/sync.js +33 -19
  12. package/dist/src/cli/commands/test-mcp.js +135 -0
  13. package/dist/src/cli/fraim.js +6 -0
  14. package/dist/src/cli/setup/auto-mcp-setup.js +367 -0
  15. package/dist/src/cli/setup/ide-detector.js +163 -0
  16. package/dist/src/cli/setup/mcp-config-generator.js +115 -0
  17. package/dist/src/cli/setup/token-validator.js +49 -0
  18. package/dist/test-utils.js +96 -0
  19. package/dist/tests/debug-tools.js +2 -2
  20. package/dist/tests/esm-compat.js +11 -0
  21. package/dist/tests/shared-server-utils.js +57 -0
  22. package/dist/tests/test-chalk-esm-issue.js +159 -0
  23. package/dist/tests/test-chalk-real-world.js +265 -0
  24. package/dist/tests/test-chalk-regression.js +2 -18
  25. package/dist/tests/test-chalk-resolution-issue.js +304 -0
  26. package/dist/tests/test-client-scripts-validation.js +27 -5
  27. package/dist/tests/test-complete-setup-flow.js +110 -0
  28. package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
  29. package/dist/tests/test-ide-detector.js +46 -0
  30. package/dist/tests/test-improved-setup.js +121 -0
  31. package/dist/tests/test-mcp-config-generator.js +70 -0
  32. package/dist/tests/test-mcp-connection.js +58 -117
  33. package/dist/tests/test-mcp-issue-integration.js +2 -2
  34. package/dist/tests/test-mcp-lifecycle-methods.js +34 -100
  35. package/dist/tests/test-mcp-shared-server.js +308 -0
  36. package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
  37. package/dist/tests/test-package-size.js +101 -0
  38. package/dist/tests/test-prep-issue.js +34 -1
  39. package/dist/tests/test-script-location-independence.js +39 -62
  40. package/dist/tests/test-server-utils.js +32 -0
  41. package/dist/tests/test-session-rehydration.js +2 -2
  42. package/dist/tests/test-setup-integration.js +98 -0
  43. package/dist/tests/test-standalone.js +2 -2
  44. package/dist/tests/test-stub-registry.js +136 -0
  45. package/dist/tests/test-sync-stubs.js +143 -0
  46. package/dist/tests/test-telemetry.js +2 -2
  47. package/dist/tests/test-token-validator.js +30 -0
  48. package/dist/tests/test-user-journey.js +2 -1
  49. package/package.json +7 -9
  50. package/registry/agent-guardrails.md +62 -62
  51. package/registry/scripts/code-quality-check.sh +559 -559
  52. package/registry/scripts/detect-tautological-tests.sh +38 -38
  53. package/registry/scripts/prep-issue.sh +61 -30
  54. package/registry/scripts/validate-openapi-limits.ts +366 -366
  55. package/registry/scripts/validate-test-coverage.ts +280 -280
  56. package/registry/scripts/verify-pr-comments.sh +70 -70
  57. package/registry/stubs/workflows/bootstrap/create-architecture.md +11 -0
  58. package/registry/stubs/workflows/bootstrap/detect-broken-windows.md +11 -0
  59. package/registry/stubs/workflows/bootstrap/evaluate-code-quality.md +11 -0
  60. package/registry/stubs/workflows/bootstrap/verify-test-coverage.md +11 -0
  61. package/registry/stubs/workflows/business-development/create-business-plan.md +11 -0
  62. package/registry/stubs/workflows/business-development/ideate-business-opportunity.md +11 -0
  63. package/registry/stubs/workflows/business-development/price-product.md +18 -0
  64. package/registry/stubs/workflows/convert-to-pdf.md +11 -0
  65. package/registry/stubs/workflows/customer-development/insight-analysis.md +11 -0
  66. package/registry/stubs/workflows/customer-development/insight-triage.md +11 -0
  67. package/registry/stubs/workflows/customer-development/interview-preparation.md +11 -0
  68. package/registry/stubs/workflows/customer-development/linkedin-outreach.md +11 -0
  69. package/registry/stubs/workflows/customer-development/strategic-brainstorming.md +11 -0
  70. package/registry/stubs/workflows/customer-development/thank-customers.md +11 -0
  71. package/registry/stubs/workflows/customer-development/weekly-newsletter.md +11 -0
  72. package/registry/stubs/workflows/deploy/cloud-deployment.md +11 -0
  73. package/registry/stubs/workflows/improve-fraim/contribute.md +11 -0
  74. package/registry/stubs/workflows/improve-fraim/file-issue.md +11 -0
  75. package/registry/stubs/workflows/marketing/content-creation.md +11 -0
  76. package/registry/stubs/workflows/marketing/hbr-article.md +11 -0
  77. package/registry/stubs/workflows/marketing/launch-checklist.md +11 -0
  78. package/registry/stubs/workflows/marketing/marketing-strategy.md +11 -0
  79. package/registry/stubs/workflows/marketing/storytelling.md +11 -0
  80. package/registry/stubs/workflows/performance/analyze-performance.md +11 -0
  81. package/registry/stubs/workflows/product-building/design.md +11 -0
  82. package/registry/stubs/workflows/product-building/implement.md +12 -0
  83. package/registry/stubs/workflows/product-building/iterate-on-pr-comments.md +11 -0
  84. package/registry/stubs/workflows/product-building/prep-issue.md +11 -0
  85. package/registry/stubs/workflows/product-building/prototype.md +11 -0
  86. package/registry/stubs/workflows/product-building/resolve.md +11 -0
  87. package/registry/stubs/workflows/product-building/retrospect.md +11 -0
  88. package/registry/stubs/workflows/product-building/spec.md +11 -0
  89. package/registry/stubs/workflows/product-building/test.md +11 -0
  90. package/registry/stubs/workflows/quality-assurance/browser-validation.md +11 -0
  91. package/registry/stubs/workflows/quality-assurance/iterative-improvement-cycle.md +11 -0
  92. package/registry/stubs/workflows/replicate/replicate-discovery.md +11 -0
  93. package/registry/stubs/workflows/replicate/replicate-to-issues.md +11 -0
  94. package/registry/stubs/workflows/reviewer/review-implementation-vs-design-spec.md +11 -0
  95. package/registry/stubs/workflows/reviewer/review-implementation-vs-feature-spec.md +11 -0
  96. package/registry/stubs/workflows/startup-credits/aws-activate-application.md +11 -0
  97. package/registry/stubs/workflows/startup-credits/google-cloud-application.md +11 -0
  98. package/registry/stubs/workflows/startup-credits/microsoft-azure-application.md +11 -0
  99. package/.github/workflows/ci.yml +0 -65
  100. package/.github/workflows/deploy-fraim.yml +0 -87
  101. package/.github/workflows/phase-change.yml +0 -251
  102. package/.github/workflows/status-change.yml +0 -68
  103. package/.github/workflows/sync-on-pr-review.yml +0 -66
  104. package/examples/simple-webapp/TESTING.md +0 -62
  105. package/examples/simple-webapp/example-test.ts +0 -186
  106. package/registry/github/workflows/ci.yml +0 -51
  107. package/registry/github/workflows/phase-change.yml +0 -251
  108. package/registry/github/workflows/status-change.yml +0 -68
  109. package/registry/github/workflows/sync-on-pr-review.yml +0 -66
  110. package/registry/mcp-template.jsonc +0 -29
  111. package/registry/rules/agent-success-criteria.md +0 -52
  112. package/registry/rules/agent-testing-guidelines.md +0 -502
  113. package/registry/rules/architecture.md +0 -52
  114. package/registry/rules/communication.md +0 -122
  115. package/registry/rules/continuous-learning.md +0 -55
  116. package/registry/rules/debugging-multitenancy-issues.md +0 -85
  117. package/registry/rules/ephemeral-execution.md +0 -57
  118. package/registry/rules/git-safe-commands.md +0 -34
  119. package/registry/rules/hitl-ppe-record-analysis.md +0 -302
  120. package/registry/rules/integrity-and-test-ethics.md +0 -275
  121. package/registry/rules/local-development.md +0 -254
  122. package/registry/rules/merge-requirements.md +0 -231
  123. package/registry/rules/simplicity.md +0 -118
  124. package/registry/rules/software-development-lifecycle.md +0 -105
  125. package/registry/rules/spike-first-development.md +0 -205
  126. package/registry/rules/successful-debugging-patterns.md +0 -491
  127. package/registry/rules/telemetry.md +0 -67
  128. package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +0 -53
  129. package/registry/templates/bootstrap/CODE-QUALITY-REPORT-TEMPLATE.md +0 -37
  130. package/registry/templates/bootstrap/TEST-COVERAGE-REPORT-TEMPLATE.md +0 -35
  131. package/registry/templates/business-development/IDEATION-REPORT-TEMPLATE.md +0 -29
  132. package/registry/templates/business-development/PRICING-STRATEGY-TEMPLATE.md +0 -126
  133. package/registry/templates/customer-development/customer-interview-template.md +0 -99
  134. package/registry/templates/customer-development/follow-up-email-templates.md +0 -132
  135. package/registry/templates/customer-development/insight-analysis-template.md +0 -74
  136. package/registry/templates/customer-development/strategic-recommendations-template.md +0 -53
  137. package/registry/templates/customer-development/thank-you-email-template.html +0 -124
  138. package/registry/templates/customer-development/thank-you-note-template.md +0 -16
  139. package/registry/templates/customer-development/triage-log-template.md +0 -278
  140. package/registry/templates/customer-development/weekly-newsletter-template.html +0 -204
  141. package/registry/templates/evidence/Design-Evidence.md +0 -30
  142. package/registry/templates/evidence/Implementation-BugEvidence.md +0 -86
  143. package/registry/templates/evidence/Implementation-FeatureEvidence.md +0 -121
  144. package/registry/templates/evidence/Spec-Evidence.md +0 -19
  145. package/registry/templates/help/HelpNeeded.md +0 -14
  146. package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +0 -66
  147. package/registry/templates/replicate/implementation-checklist.md +0 -39
  148. package/registry/templates/replicate/use-cases-template.md +0 -88
  149. package/registry/templates/retrospective/RETROSPECTIVE-TEMPLATE.md +0 -55
  150. package/registry/templates/specs/BUGSPEC-TEMPLATE.md +0 -37
  151. package/registry/templates/specs/FEATURESPEC-TEMPLATE.md +0 -29
  152. package/registry/templates/specs/TECHSPEC-TEMPLATE.md +0 -39
  153. package/registry/workflows/bootstrap/create-architecture.md +0 -38
  154. package/registry/workflows/bootstrap/evaluate-code-quality.md +0 -36
  155. package/registry/workflows/bootstrap/verify-test-coverage.md +0 -37
  156. package/registry/workflows/business-development/create-business-plan.md +0 -737
  157. package/registry/workflows/business-development/ideate-business-opportunity.md +0 -55
  158. package/registry/workflows/business-development/price-product.md +0 -325
  159. package/registry/workflows/convert-to-pdf.md +0 -235
  160. package/registry/workflows/customer-development/insight-analysis.md +0 -156
  161. package/registry/workflows/customer-development/insight-triage.md +0 -933
  162. package/registry/workflows/customer-development/interview-preparation.md +0 -421
  163. package/registry/workflows/customer-development/linkedin-outreach.md +0 -593
  164. package/registry/workflows/customer-development/strategic-brainstorming.md +0 -146
  165. package/registry/workflows/customer-development/thank-customers.md +0 -203
  166. package/registry/workflows/customer-development/weekly-newsletter.md +0 -366
  167. package/registry/workflows/deploy/cloud-deployment.md +0 -310
  168. package/registry/workflows/improve-fraim/contribute.md +0 -32
  169. package/registry/workflows/improve-fraim/file-issue.md +0 -32
  170. package/registry/workflows/marketing/content-creation.md +0 -37
  171. package/registry/workflows/marketing/hbr-article.md +0 -73
  172. package/registry/workflows/marketing/launch-checklist.md +0 -37
  173. package/registry/workflows/marketing/marketing-strategy.md +0 -45
  174. package/registry/workflows/performance/analyze-performance.md +0 -65
  175. package/registry/workflows/product-building/design.md +0 -130
  176. package/registry/workflows/product-building/implement.md +0 -315
  177. package/registry/workflows/product-building/iterate-on-pr-comments.md +0 -70
  178. package/registry/workflows/product-building/prep-issue.md +0 -43
  179. package/registry/workflows/product-building/prototype.md +0 -60
  180. package/registry/workflows/product-building/resolve.md +0 -164
  181. package/registry/workflows/product-building/retrospect.md +0 -86
  182. package/registry/workflows/product-building/spec.md +0 -117
  183. package/registry/workflows/product-building/test.md +0 -120
  184. package/registry/workflows/quality-assurance/browser-validation.md +0 -221
  185. package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +0 -562
  186. package/registry/workflows/replicate/replicate-discovery.md +0 -336
  187. package/registry/workflows/replicate/replicate-to-issues.md +0 -319
  188. package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +0 -632
  189. package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +0 -669
  190. package/registry/workflows/startup-credits/aws-activate-application.md +0 -535
  191. package/registry/workflows/startup-credits/google-cloud-application.md +0 -647
  192. package/registry/workflows/startup-credits/microsoft-azure-application.md +0 -538
@@ -1,491 +0,0 @@
1
- # Successful Debugging Patterns for Complex Integrations
2
-
3
- ## INTENT
4
- To provide agents with proven patterns for debugging complex integrations, especially OAuth flows, API integrations, and multi-layer systems that require both UI automation and backend validation.
5
-
6
- ## PRINCIPLES
7
- - **Multi-Layer Validation**: Always validate at UI, API, and Database layers
8
- - **Iterative Enhancement**: Continuously refine approaches based on real-time feedback
9
- - **Appropriate Timeout Management**: Use different timeouts for different operation types
10
- - **Real-Time Monitoring**: Monitor logs and database state during complex operations
11
- - **Visual Debugging**: Use screenshots and visual feedback to understand UI state
12
- - **Prefer User-Visible Truth**: For UI flows, validate what the user sees/does (DOM + persisted state), not the order/timing of background requests
13
-
14
- ## CORE DEBUGGING PATTERN
15
-
16
- ### The "Repro -> Analyze → Implement → Test → Validate → Document → VERIFY COMPLETENESS" Pattern
17
-
18
- ```
19
- 1. REPRO: Reproduce the issue in a controlled environment. This can be manual using Playwright for UI issues, Curl for API issues, etc; or it can be through existing test cases. Run only the test case that fails. Mark it with tag `failing`, then run `npm run test-failing <test-suite>`
20
- 2. ANALYZE: Use tools to examine actual codebase (grep_search, Read)
21
- 3. IMPLEMENT: Make targeted changes based on real code analysis
22
- 4. TEST: Run the single test and ensure it passes. Then run comprehensive tests for evidence
23
- 5. VALIDATE: Verify functionality works end-to-end
24
- 6. DOCUMENT: Create test cases that replicate the flow and validate end state
25
- 7. VERIFY COMPLETENESS: Run comprehensive verification checklist (NEW CRITICAL STEP)
26
- 8. ITERATE: Refine based on real feedback and evidence
27
- ```
28
-
29
- ### **NEW: Mandatory Completeness Verification Pattern**
30
-
31
- Before declaring ANY work complete, **MUST** follow this systematic verification:
32
-
33
- ```bash
34
- # Step 1: Compilation Verification
35
- timeout 30s npx tsc --noEmit --skipLibCheck
36
- # MUST show 0 errors - fix any errors before proceeding
37
-
38
- # Step 2: Build Verification (if build script exists)
39
- timeout 60s npm run build
40
- # MUST complete successfully
41
-
42
- # Step 3: Comprehensive Search Verification
43
- # Search for ALL possible references using multiple patterns:
44
- grep_search --SearchPath . --Query "OldClassName" --MatchPerLine true
45
- grep_search --SearchPath . --Query "import.*OldClassName" --IsRegex true --MatchPerLine true
46
- grep_search --SearchPath . --Query "old-filename" --MatchPerLine true
47
- grep_search --SearchPath . --Query "oldMethodName" --MatchPerLine true
48
-
49
- # Step 4: Test Execution with Timeout
50
- timeout 30s npx tsx --test --test-reporter tap test-relevant-file.ts
51
-
52
- # Step 5: End-to-End Functionality Check
53
- # Verify main application workflows still work
54
- ```
55
-
56
- ### Enhanced Multi-Layer Debugging Pattern
57
-
58
- ```
59
- 1. Code Analysis (grep_search, find_by_name to understand current state)
60
- 2. UI Action (Playwright automation with screenshots)
61
- 3. Database Check (verify persistence and state changes)
62
- 4. Log Analysis (check server logs for errors/success)
63
- 5. API Testing (verify endpoints work correctly)
64
- 6. Integration Testing (test full workflows)
65
- 7. Evidence Collection (screenshots, logs, test results)
66
- 8. Refine Approach (improve based on findings)
67
- 9. Repeat (iterate until success with evidence)
68
- ```
69
-
70
- ## UI DEBUGGING WITH PLAYWRIGHT (AND PLAYWRIGHT MCP)
71
-
72
- When the bug is user-visible (empty UI, wrong modal opens, buttons do nothing), treat the browser as the source of truth.
73
-
74
- ### Evidence-first UI debugging loop
75
- 1. **Reproduce in the browser** (manual or Playwright).
76
- 2. **Capture evidence**:
77
- - Browser console output (errors + warnings)
78
- - DOM snapshot (preferred) and/or screenshot
79
- - The exact URL + the exact click sequence
80
- 3. **Instrument to make failures obvious**:
81
- - Log `requestfailed` URLs and error text
82
- - Log HTTP >= 400 responses (method + URL)
83
- 4. **Fix the root cause** (DOM wiring, event binding, auth headers, data mapping).
84
- 5. **Re-run the same click path** to prove the UI behaves correctly.
85
-
86
- ### Playwright MCP usage (required when asked to "pop the browser")
87
- If you are asked to confirm a fix visually:
88
- - Use Playwright MCP tools to `navigate`, `click`, and capture a `browser_snapshot`.
89
- - Validate the specific UI element/state changed (e.g., form opens, list renders, “No meetings” disappears).
90
-
91
- ### E2E test stabilization checklist (when tests time out)
92
- - Prefer waiting on UI state (`waitForSelector`, text visible, DOM class changes) over `waitForResponse` predicates.
93
- - Avoid coupling to background requests that can vary (telemetry, analysis triggers, service worker, polling).
94
- - If UI is optional/feature-flagged, **do not re-enable product UI just to satisfy tests**; gate the test sub-flow or validate via API/DB.
95
- - Ensure the server is up (or auto-start it) and clean up reliably (use `after()` hooks).
96
-
97
- ## SPECIFIC SCRIPTS AND COMMANDS
98
-
99
- > [!NOTE]
100
- > Self-contained scripts are available directly from `~/.fraim/scripts/` (synced during `fraim init`).
101
- > Scripts with FRAIM dependencies require ephemeral execution via `get_fraim_file`.
102
- >
103
- > **Self-contained scripts** (direct execution):
104
- > - `prep-issue.sh`, `code-quality-check.sh`, `evaluate-code-quality.ts`, `exec-with-timeout.ts`
105
- >
106
- > **Dependent scripts** (ephemeral execution):
107
- > - `fraim-config.ts`, `build-scripts-generator.ts`, `cleanup-branch.ts`
108
-
109
- ### 1. Long-Running Server Management
110
-
111
- **Start Server with Proper Timeout:**
112
- ```bash
113
- # Use exec-with-timeout.ts directly from synced location
114
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 3600 -- npm run dev &
115
-
116
- # On Windows:
117
- # npx tsx %USERPROFILE%\.fraim\scripts\exec-with-timeout.ts --timeout 3600 -- npm run dev &
118
- ```
119
-
120
- **Monitor Server Logs in Real-Time:**
121
- ```bash
122
- # Real-time monitoring
123
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- tail -f server.log
124
-
125
- # Historical log analysis
126
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- tail -100 server.log
127
-
128
- # Look for errors in logs
129
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- grep error server.log
130
- ```
131
-
132
- **Check Server Status:**
133
- ```bash
134
- # Verify server is running on correct port
135
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- netstat -ano | findstr :<port>
136
-
137
- # Test API endpoints
138
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- curl -s "http://localhost:<port>/<endpoint>"
139
- ```
140
-
141
- ### 2. Code Analysis and Understanding
142
-
143
- **CRITICAL: Always Analyze Before Implementing**
144
- Before making any changes, use tools to understand the current codebase:
145
-
146
- ```bash
147
- # Find all files that import a specific module
148
- grep_search --SearchPath src --Query "import.*GmailService" --IsRegex true --MatchPerLine true
149
-
150
- # Find files by pattern
151
- find_by_name --SearchDirectory src --Pattern "*email*" --Type file
152
-
153
- # Read specific files to understand implementation
154
- Read --file_path src/email/email-service.ts
155
- ```
156
-
157
- **Pattern Analysis Requirements:**
158
- 1. **Examine existing patterns** in the codebase (e.g., CalendarService pattern)
159
- 2. **Use grep_search** to find all dependencies and usage
160
- 3. **Read actual implementations** to understand current architecture
161
- 4. **Document findings** with real code examples and line numbers
162
-
163
- ### 3. Playwright UI Automation with Visual Debugging
164
-
165
- **IMPORTANT: Tool Troubleshooting Pattern**
166
- When MCP Playwright tools fail with errors like `TypeError: (0 , import_server2.firstRootPath) is not a function`:
167
-
168
- 1. **Check for existing working Playwright tests** in the project
169
- 2. **Use direct Playwright library** instead of MCP tools
170
- 3. **Look for test files** like `test-dashboard-ui.ts`, `test-hitl-ui.ts` as templates
171
- 4. **Create custom test scripts** using the direct library approach
172
-
173
- **Basic Playwright Script Template:**
174
- ```typescript
175
- import { chromium } from 'playwright';
176
-
177
- async function debugUIFlow() {
178
- const browser = await chromium.launch({
179
- headless: false,
180
- slowMo: 2000 // Human-like delays
181
- });
182
-
183
- try {
184
- const page = await browser.newPage();
185
-
186
- // Step 1: Navigate
187
- await page.goto(targetUrl);
188
- await page.waitForLoadState('networkidle');
189
-
190
- // Step 2: Take screenshot for debugging
191
- await page.screenshot({ path: 'debug-step-1.png' });
192
- console.log('📸 Screenshot saved: debug-step-1.png');
193
-
194
- // Step 3: Perform action
195
- await page.fill('input[type="email"]', 'test@example.com');
196
- await page.click('button:has-text("Next")');
197
-
198
- // Step 4: Take another screenshot
199
- await page.screenshot({ path: 'debug-step-2.png' });
200
- console.log('📸 Screenshot saved: debug-step-2.png');
201
-
202
- // Step 5-N: Iterate on above until scenario is fully validated
203
-
204
-
205
- } catch (error) {
206
- console.error('❌ UI flow failed:', error);
207
- await page.screenshot({ path: 'error-state.png' });
208
- } finally {
209
- await browser.close();
210
- }
211
- }
212
- ```
213
-
214
- **Advanced Playwright with Multiple Button Selectors:**
215
- ```typescript
216
- // Look for multiple possible button selectors
217
- const buttonSelectors = [
218
- 'button:has-text("Continue")',
219
- 'button:has-text("Allow")',
220
- 'button:has-text("Accept")',
221
- 'button:has-text("Authorize")',
222
- 'button[type="submit"]',
223
- 'button[jsname="LgbsSe"]:has-text("Continue")'
224
- ];
225
-
226
- let buttonClicked = false;
227
- for (const selector of buttonSelectors) {
228
- try {
229
- const button = await page.waitForSelector(selector, { timeout: 3000 });
230
- if (button && await button.isVisible()) {
231
- console.log(`🎯 Clicking button: ${selector}`);
232
- await button.click();
233
- buttonClicked = true;
234
- break;
235
- }
236
- } catch (e) {
237
- // Continue to next selector
238
- }
239
- }
240
- ```
241
-
242
- ### 3. Database Validation Scripts
243
-
244
- **MongoDB Token Validation:**
245
- ```typescript
246
- const { DatabaseFactory } = require('./src/databases/database-factory');
247
-
248
- async function checkDatabaseState() {
249
- console.log('🔍 Checking database state...');
250
- const dbService = await DatabaseFactory.createCalendarDatabaseService();
251
- await dbService.initialize();
252
-
253
- try {
254
- // Check for tokens
255
- const tokens = await dbService.loadCalendarTokens('primary');
256
- console.log('📋 Tokens found:', !!tokens);
257
-
258
- // Check for calendars
259
- const calendars = await dbService.getAllCalendars();
260
- console.log('📅 Calendars found:', calendars.length);
261
-
262
- // Check for specific data
263
- const credentials = await dbService.loadCredential('APP_CLIENT_ID');
264
- console.log('🔑 Credentials found:', !!credentials);
265
-
266
- } catch (error) {
267
- console.error('❌ Database check failed:', error);
268
- } finally {
269
- await dbService.close();
270
- }
271
- }
272
- ```
273
-
274
- **API Endpoint Testing:**
275
- ```typescript
276
- async function testAPIEndpoints() {
277
- const baseUrl = 'http://localhost:8333';
278
-
279
- // Test calendar API
280
- try {
281
- const response = await fetch(`${baseUrl}/calendar/events?timerange_start=2024-01-01T00:00:00.000Z&timerange_end=2024-01-02T00:00:00.000Z`);
282
- const data = await response.json();
283
- console.log('📅 Calendar API:', response.status, data);
284
- } catch (error) {
285
- console.error('❌ Calendar API failed:', error);
286
- }
287
-
288
- // Test conversation API
289
- try {
290
- const response = await fetch(`${baseUrl}/conversation/threads`);
291
- const data = await response.json();
292
- console.log('💬 Conversation API:', response.status, data);
293
- } catch (error) {
294
- console.error('❌ Conversation API failed:', error);
295
- }
296
- }
297
- ```
298
-
299
- ### 4. OAuth Flow Debugging Scripts
300
-
301
- **Complete OAuth Flow with Debugging:**
302
- ```typescript
303
- async function debugOAuthFlow() {
304
- const browser = await chromium.launch({ headless: false, slowMo: 3000 });
305
-
306
- try {
307
- const page = await browser.newPage();
308
- const oauthUrl = 'https://accounts.google.com/o/oauth2/v2/auth?client_id=...';
309
-
310
- // Step 1: Navigate and take screenshot
311
- await page.goto(oauthUrl);
312
- await page.waitForLoadState('networkidle');
313
- await page.screenshot({ path: 'oauth-step-1.png' });
314
-
315
- // Step 2: Email
316
- await page.fill('input[type="email"]', 'test@example.com');
317
- await page.click('button:has-text("Next")');
318
- await page.screenshot({ path: 'oauth-step-2.png' });
319
-
320
- // Step 3: Password
321
- await page.waitForSelector('input[type="password"]');
322
- await page.fill('input[type="password"]', 'password');
323
- await page.click('button:has-text("Next")');
324
- await page.screenshot({ path: 'oauth-step-3.png' });
325
-
326
- // Step 4: Consent page
327
- await page.waitForLoadState('networkidle');
328
- await page.screenshot({ path: 'consent-page.png' });
329
-
330
- // Step 5: Click continue with multiple selectors
331
- const continueSelectors = [
332
- 'button:has-text("Continue")',
333
- 'button:has-text("Allow")',
334
- 'button[type="submit"]'
335
- ];
336
-
337
- for (const selector of continueSelectors) {
338
- try {
339
- const button = await page.waitForSelector(selector, { timeout: 3000 });
340
- if (button && await button.isVisible()) {
341
- await button.click();
342
- break;
343
- }
344
- } catch (e) {}
345
- }
346
-
347
- // Step 6: Wait for callback
348
- await page.waitForURL('**/oauth/callback**', { timeout: 20000 });
349
- console.log('✅ OAuth flow completed!');
350
-
351
- } catch (error) {
352
- console.error('❌ OAuth flow failed:', error);
353
- await page.screenshot({ path: 'oauth-error.png' });
354
- } finally {
355
- await browser.close();
356
- }
357
- }
358
- ```
359
-
360
- ### 5. Timeout Management Commands
361
-
362
- **CRITICAL: Always Use Timeouts for Test Execution**
363
- Following the established pattern from memory, ALWAYS use timeout commands to prevent hanging:
364
-
365
- **Quick Operations (30s timeout):**
366
- ```bash
367
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- <command>
368
- ```
369
-
370
- **Medium Operations (120s timeout):**
371
- ```bash
372
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 120 -- <command>
373
- ```
374
-
375
- **Always run tests with timeout**
376
- ```
377
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- npm run test <test-suite>
378
- ```
379
-
380
- **Always examine test results after running tests**
381
- ```
382
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- cat test.log
383
- ```
384
-
385
- ## DEBUGGING WORKFLOW
386
-
387
- ### 1. **Initial Setup**
388
- ```bash
389
- # Start server with long timeout
390
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 3600 -- npm run dev &
391
-
392
- # Wait for startup
393
- sleep 3
394
-
395
- # Check server logs
396
- tail -20 server.log
397
- ```
398
-
399
- ### 2. **UI Automation with Visual Debugging**
400
- ```bash
401
- # Run Playwright script with medium timeout
402
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 120 -- npx tsx debug-ui-flow.ts
403
- ```
404
-
405
- ### 3. **Database Validation**
406
- ```bash
407
- # Check database state
408
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- npx tsx check-database-state.ts
409
- ```
410
-
411
- ### 4. **API Testing**
412
- ```bash
413
- # Test API endpoints
414
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- npx tsx test-api-endpoints.ts
415
- ```
416
-
417
- ### 5. **Log Analysis**
418
- ```bash
419
- # Check recent logs
420
- npx tsx ~/.fraim/scripts/exec-with-timeout.ts --timeout 30 -- tail -30 server.log
421
- ```
422
-
423
- ## COMMON PATTERNS
424
-
425
- ### Pattern 1: OAuth Flow Debugging
426
- 1. Start server with long timeout
427
- 2. Create Playwright script with screenshots
428
- 3. Run OAuth flow with visual debugging
429
- 4. Check database for token storage
430
- 5. Test API with stored tokens
431
- 6. Analyze logs for any errors
432
-
433
- ### Pattern 2: API Integration Debugging
434
- 1. Start server and verify it's running
435
- 2. Test API endpoints with curl
436
- 3. Check database for data persistence
437
- 4. Monitor server logs for errors
438
- 5. Fix issues and retest
439
-
440
- ### Pattern 3: UI Feature Debugging
441
- 1. Navigate to feature in browser
442
- 2. Take screenshots at each step
443
- 3. Perform actions and capture results
444
- 4. Check backend state changes
445
- 5. Verify end-to-end functionality
446
-
447
- ## ERROR DETECTION
448
-
449
- ### Server Log Errors to Watch For:
450
- - `OAuth callback error:`
451
- - `Database connection failed`
452
- - `Missing credentials`
453
- - `Port conflict errors`
454
- - `TypeScript compilation errors`
455
- - `API endpoint errors`
456
-
457
- ### Database State Validation:
458
- - Check for expected data after operations
459
- - Verify token storage and expiration
460
- - Confirm calendar/thread creation
461
- - Validate credential loading
462
-
463
- ### API Response Validation:
464
- - Check HTTP status codes
465
- - Verify response data structure
466
- - Test error handling
467
- - Confirm authentication
468
-
469
- ## SUCCESS INDICATORS
470
-
471
- ### OAuth Flow Success:
472
- - Screenshots show successful page transitions
473
- - Database contains valid tokens
474
- - API calls return 200 OK with real data
475
- - Server logs show successful token exchange
476
-
477
- ### API Integration Success:
478
- - All endpoints return expected status codes
479
- - Database contains persisted data
480
- - No errors in server logs
481
- - End-to-end functionality works
482
-
483
- ### UI Feature Success:
484
- - Screenshots show correct UI state
485
- - Actions produce expected results
486
- - Backend state changes correctly
487
- - No JavaScript errors in browser console
488
-
489
- ## CONCLUSION
490
-
491
- These patterns provide a systematic approach to debugging complex integrations. The key is combining multiple validation layers (UI, API, Database) with appropriate timeout management and real-time monitoring. Always take screenshots, check database state, and monitor logs to get a complete picture of what's happening.
@@ -1,67 +0,0 @@
1
- # Telemetry & Session Management
2
-
3
- ## Protocol Overview
4
-
5
- FRAIM enforces a strict **Session Handshake** protocol to ensure proper environment tracking and implicit activity monitoring. All Agents interacting with a FRAIM server MUST adhere to this protocol.
6
-
7
- ### 1. Mandatory Handshake (`fraim_connect`)
8
-
9
- At the start of **every** session (i.e., when the agent starts up or connects to a new workspace), you MUST call the `fraim_connect` tool immediately.
10
-
11
- **Tool**: `fraim_connect`
12
- **Arguments**:
13
- - `machine`: Object containing hardware specs.
14
- - `hostname`: (string) e.g., "dev-box-1"
15
- - `platform`: (string) e.g., "win32", "darwin"
16
- - `arch`: (string) e.g., "x64"
17
- - `cpus`: (string/number) CPU details
18
- - `memory`: (string/number) Total RAM
19
- - `repo`: Object containing repository context.
20
- - `url`: (string) **Required**. The git remote URL.
21
- - `owner`: (string) e.g., "user-or-org"
22
- - `name`: (string) e.g., "my-repo"
23
-
24
- **Example Call**:
25
- ```json
26
- {
27
- "name": "fraim_connect",
28
- "arguments": {
29
- "machine": {
30
- "hostname": "azure-vm-01",
31
- "platform": "linux",
32
- "arch": "x64"
33
- },
34
- "repo": {
35
- "url": "https://github.com/fraim/framework.git",
36
- "owner": "fraim",
37
- "name": "framework"
38
- }
39
- }
40
- }
41
- ```
42
-
43
- **Failure Consequence**:
44
- If you attempt to call other tools (e.g., `get_fraim_workflow`, `get_fraim_file`) *without* first establishing a session via `fraim_connect`, the server will reject your request with a **400 Bad Request** error:
45
-
46
- > "⛔ Session Not Started. Please call the 'fraim_connect' tool first to register your environment and begin the session."
47
-
48
- ### 2. Implicit Activity Tracking
49
-
50
- Once a session is established, you do **not** need to manually report usage. The FRAIM server automatically tracks your activity based on the API calls you make.
51
-
52
- - **Keep-Alive**: Every tool call acts as a "heartbeat", updating your session's `lastActive` timestamp.
53
- - **Efficiency**: The server uses write-behind caching to minimize database writes, so you can make frequent calls without performance penalty.
54
- - **Persistence**: Usage data is persisted across server restarts.
55
-
56
- ### 3. Data Collection Policy
57
-
58
- We collect minimal metadata to improve the FRAIM system and validate startup credits:
59
- - **Hardware**: To optimize resource allocation recommendations.
60
- - **Repository**: To map work to specific projects/organizations.
61
- - **Duration**: Calculated as `lastActive - startTime` to measure session length.
62
- - **Tool Usage**: Which tools are used (implicitly derived).
63
-
64
- **We do NOT collect**:
65
- - Source code content (except what is explicitly passed in specific tool arguments like reviews).
66
- - Environment variables.
67
- - Personal files.
@@ -1,53 +0,0 @@
1
- # Architecture Documentation: <project-name>
2
-
3
- ## 1. Overview
4
- <Briefly describe the purpose and goals of the project.>
5
-
6
- ## 2. Tech Stack Choices
7
-
8
- | Category | Choice | Rationale |
9
- | :--- | :--- | :--- |
10
- | **Language** | <e.g. TypeScript> | <e.g. Type safety and developer productivity> |
11
- | **Runtime** | <e.g. Node.js> | <e.g. Ubiquity and ecosystem> |
12
- | **Frameworks** | <e.g. Express, Fastify, React> | <e.g. Robustness and community support> |
13
- | **Database** | <e.g. MongoDB, PostgreSQL> | <e.g. Data structure requirements> |
14
- | **Testing** | <e.g. Vitest, Playwright> | <e.g. Modern toolchain and speed> |
15
-
16
- ## 3. Architectural Layers
17
-
18
- Describe the layers of the system and their responsibilities.
19
-
20
- ### 3.1. [Layer Name, e.g., API/Interface Layer]
21
- - **Responsibility**: <e.g., Handling HTTP requests, validation, and CLI entry points.>
22
- - **Key Modules**: <e.g., `src/server.ts`, `src/cli/`>
23
-
24
- ### 3.2. [Layer Name, e.g., Application/Business Logic Layer]
25
- - **Responsibility**: <e.g., Core business rules and orchestrating domain services.>
26
- - **Key Modules**: <e.g., `src/services/`, `src/orchestrator/`>
27
-
28
- ### 3.3. [Layer Name, e.g., Data/Infrastructure Layer]
29
- - **Responsibility**: <e.g., Persistence, external API integrations, and low-level utilities.>
30
- - **Key Modules**: <e.g., `src/db/`, `src/clients/`>
31
-
32
- ## 4. Key Components & Modules
33
-
34
- <mermaid>
35
- graph TD
36
- A[Component A] --> B[Component B]
37
- B --> C[External API]
38
- B --> D[Database]
39
- </mermaid>
40
-
41
- ### 4.1 [Component Name]
42
- <Description of the component's role and internal structure.>
43
-
44
- ## 5. Data Flow
45
- <Describe how information moves through the system from an input (e.g., user request) to output/persistence.>
46
-
47
- ## 6. Design Patterns & Principles
48
- - **Pattern 1**: <e.g., Dependency Injection for testability.>
49
- - **Pattern 2**: <e.g., Event-driven architecture for async processing.>
50
-
51
- ## 7. Configuration & Environment
52
- - **FRAIM Config**: Located at `config.json`.
53
- - **Environment Variables**: <List critical variables here.>
@@ -1,37 +0,0 @@
1
- # Code Quality Evaluation Report
2
-
3
- ## Summary
4
- - **Evaluation Date**: <date>
5
- - **Project Name**: <project-name>
6
- - **Overall Quality Grade**: <grade> (A/B/C/D/F)
7
-
8
- ## Key Characteristics
9
-
10
- ### 1. Type Safety
11
- - **Gate 1 Status**: <status>
12
- - **Issues Found**:
13
- - <issue-1>
14
- - <issue-2>
15
- - **Recommendation**: <recommendation>
16
-
17
- ### 2. Linting & Style
18
- - **Status**: <status>
19
- - **Warnings/Errors**: <count>
20
- - **Recommendation**: <recommendation>
21
-
22
- ### 3. FRAIM Patterns & Architecture
23
- - **Architecture Alignment**: <status>
24
- - **Missing Documentation**: <list>
25
- - **Rule Violations**:
26
- - <violation-1>
27
-
28
- ### 4. Technical Debt
29
- - **Estimated Effort to Fix**: <hours>
30
- - **Top 3 Critical Issues**:
31
- 1. <issue-1>
32
- 2. <issue-2>
33
- 3. <issue-3>
34
-
35
- ## Recommendations
36
- - [ ] <next-step-1>
37
- - [ ] <next-step-2>
@@ -1,35 +0,0 @@
1
- # Test Coverage & Effectiveness Report
2
-
3
- ## Summary
4
- - **Evaluation Date**: <date>
5
- - **Total Scenarios Found**: <total>
6
- - **Scenario Coverage**: <percentage>%
7
- - **Line Coverage**: <percentage>%
8
-
9
- ## Coverage Breakdown
10
-
11
- ### 1. Scenario Coverage (Gate 9)
12
- - **Status**: <status>
13
- - **Covered Scenarios**:
14
- - [x] <scenario-1>
15
- - [x] <scenario-2>
16
- - **Missing Scenarios**:
17
- - [ ] <missing-scenario-1>
18
- - [ ] <missing-scenario-2>
19
-
20
- ### 2. Code Coverage
21
- - **Lines**: <covered>/<total> (<percentage>%)
22
- - **Branches**: <covered>/<total> (<percentage>%)
23
- - **Functions**: <covered>/<total> (<percentage>%)
24
-
25
- ### 3. Test Quality
26
- - **Tautological Tests (Gate 1.5)**: <count> found
27
- - **Mocking Health**: <assessment>
28
-
29
- ## Risk Areas
30
- - **Unverified Critical Paths**: <list>
31
- - **Complexity without Tests**: <list>
32
-
33
- ## Recommendations
34
- - [ ] <recommendation-1>
35
- - [ ] <recommendation-2>