@equilateral_ai/mindmeld 3.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 (86) hide show
  1. package/README.md +300 -0
  2. package/hooks/README.md +494 -0
  3. package/hooks/pre-compact.js +392 -0
  4. package/hooks/session-start.js +264 -0
  5. package/package.json +90 -0
  6. package/scripts/harvest.js +561 -0
  7. package/scripts/init-project.js +437 -0
  8. package/scripts/inject.js +388 -0
  9. package/src/collaboration/CollaborationPrompt.js +460 -0
  10. package/src/core/AlertEngine.js +813 -0
  11. package/src/core/AlertNotifier.js +363 -0
  12. package/src/core/CorrelationAnalyzer.js +774 -0
  13. package/src/core/CurationEngine.js +688 -0
  14. package/src/core/LLMPatternDetector.js +508 -0
  15. package/src/core/LoadBearingDetector.js +242 -0
  16. package/src/core/NotificationService.js +1032 -0
  17. package/src/core/PatternValidator.js +355 -0
  18. package/src/core/README.md +160 -0
  19. package/src/core/RapportOrchestrator.js +446 -0
  20. package/src/core/RelevanceDetector.js +577 -0
  21. package/src/core/StandardsIngestion.js +575 -0
  22. package/src/core/TeamLoadBearingDetector.js +431 -0
  23. package/src/database/dbOperations.js +105 -0
  24. package/src/handlers/activity/activityGetMe.js +98 -0
  25. package/src/handlers/activity/activityGetTeam.js +130 -0
  26. package/src/handlers/alerts/alertsAcknowledge.js +91 -0
  27. package/src/handlers/alerts/alertsGet.js +250 -0
  28. package/src/handlers/collaborators/collaboratorAdd.js +201 -0
  29. package/src/handlers/collaborators/collaboratorInvite.js +218 -0
  30. package/src/handlers/collaborators/collaboratorList.js +88 -0
  31. package/src/handlers/collaborators/collaboratorRemove.js +127 -0
  32. package/src/handlers/collaborators/inviteAccept.js +122 -0
  33. package/src/handlers/context/contextGet.js +57 -0
  34. package/src/handlers/context/invariantsGet.js +74 -0
  35. package/src/handlers/context/loopsGet.js +82 -0
  36. package/src/handlers/context/notesCreate.js +74 -0
  37. package/src/handlers/context/purposeGet.js +78 -0
  38. package/src/handlers/correlations/correlationsDeveloperGet.js +226 -0
  39. package/src/handlers/correlations/correlationsGet.js +93 -0
  40. package/src/handlers/correlations/correlationsProjectGet.js +161 -0
  41. package/src/handlers/github/githubConnectionStatus.js +49 -0
  42. package/src/handlers/github/githubDiscoverPatterns.js +364 -0
  43. package/src/handlers/github/githubOAuthCallback.js +166 -0
  44. package/src/handlers/github/githubOAuthStart.js +59 -0
  45. package/src/handlers/github/githubPatternsReview.js +109 -0
  46. package/src/handlers/github/githubReposList.js +105 -0
  47. package/src/handlers/helpers/checkSuperAdmin.js +85 -0
  48. package/src/handlers/helpers/dbOperations.js +53 -0
  49. package/src/handlers/helpers/errorHandler.js +49 -0
  50. package/src/handlers/helpers/index.js +106 -0
  51. package/src/handlers/helpers/lambdaWrapper.js +60 -0
  52. package/src/handlers/helpers/responseUtil.js +55 -0
  53. package/src/handlers/helpers/subscriptionTiers.js +1168 -0
  54. package/src/handlers/notifications/getPreferences.js +84 -0
  55. package/src/handlers/notifications/sendNotification.js +170 -0
  56. package/src/handlers/notifications/updatePreferences.js +316 -0
  57. package/src/handlers/patterns/patternUsagePost.js +182 -0
  58. package/src/handlers/patterns/patternViolationPost.js +185 -0
  59. package/src/handlers/projects/projectCreate.js +107 -0
  60. package/src/handlers/projects/projectDelete.js +82 -0
  61. package/src/handlers/projects/projectGet.js +95 -0
  62. package/src/handlers/projects/projectUpdate.js +118 -0
  63. package/src/handlers/reports/aiLeverage.js +206 -0
  64. package/src/handlers/reports/engineeringInvestment.js +132 -0
  65. package/src/handlers/reports/riskForecast.js +186 -0
  66. package/src/handlers/reports/standardsRoi.js +162 -0
  67. package/src/handlers/scheduled/analyzeCorrelations.js +178 -0
  68. package/src/handlers/scheduled/analyzeGitHistory.js +510 -0
  69. package/src/handlers/scheduled/generateAlerts.js +135 -0
  70. package/src/handlers/scheduled/refreshActivity.js +21 -0
  71. package/src/handlers/scheduled/scanCompliance.js +334 -0
  72. package/src/handlers/sessions/sessionEndPost.js +180 -0
  73. package/src/handlers/sessions/sessionStandardsPost.js +135 -0
  74. package/src/handlers/stripe/addonManagePost.js +240 -0
  75. package/src/handlers/stripe/billingPortalPost.js +93 -0
  76. package/src/handlers/stripe/enterpriseCheckoutPost.js +272 -0
  77. package/src/handlers/stripe/seatsUpdatePost.js +185 -0
  78. package/src/handlers/stripe/subscriptionCancelDelete.js +169 -0
  79. package/src/handlers/stripe/subscriptionCreatePost.js +221 -0
  80. package/src/handlers/stripe/subscriptionUpdatePut.js +163 -0
  81. package/src/handlers/stripe/webhookPost.js +454 -0
  82. package/src/handlers/users/cognitoPostConfirmation.js +150 -0
  83. package/src/handlers/users/userEntitlementsGet.js +89 -0
  84. package/src/handlers/users/userGet.js +114 -0
  85. package/src/handlers/webhooks/githubWebhook.js +223 -0
  86. package/src/index.js +969 -0
package/README.md ADDED
@@ -0,0 +1,300 @@
1
+ # Rapport v3 - mindmeld.dev
2
+
3
+ **Collaboration memory that compounds.**
4
+
5
+ Rapport is a project-scoped collaboration memory system that enables teams to share critical context, accelerate learning, and avoid repeated mistakes.
6
+
7
+ **Integration**: Claude Code CLI (terminal/IDE) - NOT web browser
8
+ **Architecture**: Lambda + API Gateway + PostgreSQL (Tim-Combo pattern)
9
+
10
+ ## Quick Start
11
+
12
+ ### For Developers (CLI Integration)
13
+
14
+ ```bash
15
+ # Install Rapport CLI package
16
+ npm install -g @mindmeld/rapport
17
+
18
+ # Setup Claude Code hook
19
+ # Add to .claude/hooks/session-start.js:
20
+ const { RapportClient } = require('@mindmeld/rapport');
21
+ const rapport = new RapportClient({ projectPath: process.cwd() });
22
+ const context = await rapport.detectProject();
23
+
24
+ # Start Claude Code (Rapport auto-detects project)
25
+ cd ~/Source/your-project
26
+ claude
27
+ ```
28
+
29
+ ### For Team Admins (Web Dashboard)
30
+
31
+ ```bash
32
+ # Visit web dashboard
33
+ open https://mindmeld.dev/login
34
+
35
+ # View team analytics, manage projects
36
+ ```
37
+
38
+ ## Core Concept
39
+
40
+ **Traditional team context** (isolated learning):
41
+ - Developer A learns pattern -> uses successfully
42
+ - Developer B encounters same problem -> learns independently
43
+ - Developer C makes mistake A avoided -> repeats failure
44
+
45
+ **Rapport v3** (compound learning):
46
+ - Developer A learns pattern -> uses successfully -> stored as reinforced
47
+ - Developer B encounters problem -> sees A's pattern -> applies immediately
48
+ - Developer C gets pattern auto-suggested -> avoids mistake entirely
49
+
50
+ **Result**: Team learns 3-5x faster, avoids 80% of repeated mistakes, generates 30x ROI.
51
+
52
+ ## Features
53
+
54
+ ### 1. Claude Code Integration
55
+ - Session start hooks inject relevant context
56
+ - Pre-compact hooks detect and store patterns
57
+ - Standards validation during development
58
+ - < 500ms hook execution target
59
+
60
+ ### 2. Standards Ingestion (Phase 1)
61
+ - Ingests 100+ patterns from .equilateral-standards/
62
+ - Extracts enforcement rules, anti-patterns, examples, cost impacts
63
+ - Stores in `rapport.standards_patterns` database table
64
+ - Enables intelligent context injection (only relevant standards)
65
+
66
+ ### 3. Relevance Detection (Phase 2)
67
+ - Analyzes project context (files, git history, current work)
68
+ - Identifies applicable standards for current session
69
+ - Prioritizes top 10 most relevant standards for injection
70
+
71
+ ### 4. Pattern Validation (Phase 3)
72
+ - Validates patterns against known standards
73
+ - Detects anti-pattern usage
74
+ - Records violations for team learning
75
+
76
+ ### 5. Curation Engine (Phase 4)
77
+ - Aggregates patterns across projects and teams
78
+ - Detects patterns ready for promotion to standards
79
+ - Tracks pattern metrics (usage, success rate, project count)
80
+
81
+ ### 6. Team Load-Bearing Detection
82
+ - Aggregates context across all team members
83
+ - Auto-detects critical patterns (>70% correlation with success)
84
+ - Higher confidence through team agreement
85
+
86
+ ### 7. Team Learning Metrics
87
+ - Learning velocity (how much faster than solo)
88
+ - Shared patterns (learned by one, used by all)
89
+ - Avoided mistakes (failures prevented by shared learning)
90
+ - ROI calculation (savings vs cost)
91
+
92
+ ## Architecture
93
+
94
+ **Integration Model**: CLI-first, Web-optional
95
+
96
+ ```
97
+ Claude Code CLI (Terminal/IDE)
98
+ | (hooks: SessionStart, PreCompact)
99
+ RapportClient (npm package)
100
+ | (API calls)
101
+ Lambda + API Gateway
102
+ | (queries)
103
+ PostgreSQL (Tim-Combo schema)
104
+ ```
105
+
106
+ **Project Structure**:
107
+ ```
108
+ rapport/
109
+ ├── src/
110
+ │ ├── index.js # RapportClient (npm package)
111
+ │ ├── handlers/ # Lambda handlers (method-specific)
112
+ │ │ ├── helpers/ # Standard helpers (flattened in build)
113
+ │ │ ├── projects/ # Project CRUD
114
+ │ │ ├── sessions/ # Session tracking
115
+ │ │ ├── patterns/ # Pattern storage
116
+ │ │ ├── users/ # User profile + entitlements
117
+ │ │ └── stripe/ # Subscription management
118
+ │ └── core/
119
+ │ ├── CurationEngine.js # Pattern promotion
120
+ │ ├── PatternValidator.js # Standards validation
121
+ │ ├── RelevanceDetector.js # Context-aware detection
122
+ │ ├── StandardsIngestion.js # Standards parsing
123
+ │ └── TeamLoadBearingDetector.js
124
+ ├── hooks/
125
+ │ ├── session-start.js # Claude Code session hook
126
+ │ └── pre-compact.js # Pre-compact hook
127
+ ├── frontend/
128
+ │ ├── index.html # Landing page
129
+ │ ├── dashboard.html # User dashboard
130
+ │ └── admin/ # React admin panel
131
+ ├── database/
132
+ │ └── schema.sql # PostgreSQL schema
133
+ ├── scripts/
134
+ │ └── build-handlers.sh # Lambda build script
135
+ ├── template.yaml # SAM template
136
+ └── docs/ # Documentation
137
+ ```
138
+
139
+ **See**: `docs/INTEGRATION_ARCHITECTURE.md` for detailed explanation of CLI vs Web model
140
+
141
+ ## API
142
+
143
+ ### Project Management
144
+ ```
145
+ GET /api/projects # List user's projects
146
+ POST /api/projects # Create project
147
+ PUT /api/projects/:projectId # Update project
148
+ DELETE /api/projects/:projectId # Archive project
149
+ ```
150
+
151
+ ### User Management
152
+ ```
153
+ GET /api/users/me # Get current user profile
154
+ GET /api/users/entitlements # Get user entitlements
155
+ ```
156
+
157
+ ### Subscriptions (Stripe)
158
+ ```
159
+ POST /api/stripe/subscription/create # Create checkout session
160
+ PUT /api/stripe/subscription/update # Upgrade/downgrade
161
+ DELETE /api/stripe/subscription/cancel # Cancel subscription
162
+ POST /api/stripe/webhook # Stripe webhooks
163
+ ```
164
+
165
+ ## Subscription Tiers (Proof-of-Contribution Model)
166
+
167
+ Contributing teams receive a $50/month discount at every tier. This creates a knowledge flywheel where shared patterns become community standards.
168
+
169
+ ### Solo (Free)
170
+ - OSS adoption funnel
171
+ - 3 projects, 1 collaborator
172
+ - Basic invariants only
173
+ - "Powered by MindMeld" attribution
174
+
175
+ ### Team ($99/user or $49/user Contributing)
176
+ - 5 projects, 5 collaborators
177
+ - Community standards (~25 curated patterns)
178
+ - Cross-platform sync, team memory
179
+ - **Contributing**: Patterns flow to community pool
180
+
181
+ ### Professional ($199/user or $149/user Contributing)
182
+ - Unlimited projects, 10 collaborators
183
+ - Full standards library (100+ patterns)
184
+ - Standards picker (choose what to enable)
185
+ - Analytics
186
+ - **Contributing**: Selection signals inform curation
187
+
188
+ ### Enterprise ($990/user)
189
+ - Unlimited everything
190
+ - Custom standards packs
191
+ - SSO integration, audit trail
192
+ - SOC 2 Type II, dedicated isolation
193
+ - Private standards (no contribution option)
194
+
195
+ **The $50 Contribution Credit**: Not a discount—payment for strengthening the platform. Your anonymized patterns help all teams learn faster.
196
+
197
+ ## Development
198
+
199
+ ### Commands
200
+ ```bash
201
+ # Build Lambda handlers
202
+ npm run build
203
+
204
+ # Deploy to AWS (dev)
205
+ npm run deploy:dev
206
+
207
+ # Test hooks
208
+ npm run test:hooks
209
+ npm run test:session-start
210
+ npm run test:pre-compact
211
+
212
+ # Test standards parsing (no database)
213
+ node scripts/demo-standards-parsing.js
214
+
215
+ # Test standards ingestion (requires database)
216
+ node scripts/test-standards-ingestion.js
217
+ ```
218
+
219
+ ### Prerequisites
220
+ - Node.js >= 18
221
+ - AWS SAM CLI
222
+ - PostgreSQL database
223
+ - AWS account with appropriate permissions
224
+
225
+ ### Environment Variables
226
+ ```bash
227
+ # Database (SSM resolved at deploy)
228
+ DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT
229
+
230
+ # Stripe
231
+ STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET
232
+
233
+ # Application
234
+ NODE_ENV, APP_URL
235
+ ```
236
+
237
+ ## Standards Integration
238
+
239
+ Rapport integrates with `.equilateral-standards/` to provide context-aware standards injection:
240
+
241
+ **What it does**:
242
+ - Ingests 100+ patterns from .equilateral-standards/ markdown files
243
+ - Extracts enforcement rules, anti-patterns, examples, cost impacts
244
+ - Stores in `rapport.standards_patterns` database table
245
+ - Enables intelligent context injection (only relevant standards)
246
+
247
+ **Test it**:
248
+ ```bash
249
+ # Demo parsing (no database required)
250
+ node scripts/demo-standards-parsing.js
251
+
252
+ # Full ingestion test (requires database)
253
+ node scripts/test-standards-ingestion.js
254
+ ```
255
+
256
+ ## Value Proposition
257
+
258
+ **Junior → Mid-Level Arbitrage**: With battle-tested standards injected at every AI session, junior developers perform like mid-level engineers.
259
+
260
+ | Role | Annual Salary | With MindMeld |
261
+ |------|---------------|---------------|
262
+ | Junior ($75K) | Performs like mid-level | +$44,652 value |
263
+ | Mid-Level ($120K) | Performs like senior | +$45,000 value |
264
+ | Senior ($165K) | Stops doing KT, does architecture | Leverage multiplied |
265
+
266
+ **For 10-person engineering team (Professional Contributing)**:
267
+ - Value created: $44,652/dev × 10 devs = $446,520/year
268
+ - Cost: $149/user × 10 users × 12 months = $17,880/year
269
+ - **ROI: 25x** (and your patterns strengthen the platform)
270
+
271
+ **Knowledge Transfer Elimination**: Traditional KT costs $3,840-$7,680 per junior onboarded. MindMeld eliminates this through automated standards injection.
272
+
273
+ **Institutional Knowledge Insurance**: When a senior leaves, 6-12 months of institutional knowledge walks out. MindMeld captures and hardens this automatically.
274
+
275
+ ## Domain
276
+
277
+ **Production**: https://mindmeld.dev
278
+ **API**: https://api.mindmeld.dev
279
+ **Dashboard**: https://mindmeld.dev/dashboard.html
280
+
281
+ ## Documentation
282
+
283
+ - [Integration Architecture](./docs/INTEGRATION_ARCHITECTURE.md) - CLI vs Web model
284
+ - [API Architecture](./docs/API_ARCHITECTURE.md) - Lambda patterns
285
+ - [Deployment Guide](./docs/DEPLOYMENT.md) - AWS deployment
286
+ - [Standards Integration](./docs/PHASE_1_STANDARDS_INGESTION.md) - Phase 1 details
287
+ - [Relevance Detection](./docs/PHASE_2_RELEVANCE_DETECTION.md) - Phase 2 details
288
+ - [Pattern Validation](./docs/PHASE_3_PATTERN_VALIDATION.md) - Phase 3 details
289
+ - [Curation Engine](./docs/PHASE_4_CURATION_ENGINE.md) - Phase 4 details
290
+ - [Claude Code Integration](./docs/PHASE_5_CLAUDE_CODE_INTEGRATION.md) - Hooks
291
+
292
+ ## License
293
+
294
+ Proprietary - Equilateral AI (Pareidolia LLC)
295
+
296
+ ## Contact
297
+
298
+ **Author**: Jim Ford (jim@equilateral.ai)
299
+ **Website**: https://equilateral.ai
300
+ **Product**: https://mindmeld.dev