@equilateral_ai/mindmeld 3.5.2 → 4.0.1

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 (140) hide show
  1. package/hooks/session-end.js +25 -0
  2. package/hooks/session-start.js +363 -83
  3. package/hooks/session-watcher.js +585 -0
  4. package/package.json +19 -13
  5. package/scripts/init-project.js +9 -23
  6. package/src/client/dbShim.js +16 -0
  7. package/src/core/AuthManager.js +3 -2
  8. package/src/handlers/helpers/dbOperations.js +9 -46
  9. package/src/index.js +2 -217
  10. package/src/utils/piiMask.js +16 -0
  11. package/scripts/harvest.js +0 -601
  12. package/scripts/inject.js +0 -409
  13. package/scripts/mcp-bridge.js +0 -220
  14. package/scripts/repo-analyzer.js +0 -870
  15. package/src/collaboration/CollaborationPrompt.js +0 -460
  16. package/src/core/AlertEngine.js +0 -813
  17. package/src/core/AlertNotifier.js +0 -363
  18. package/src/core/CorrelationAnalyzer.js +0 -931
  19. package/src/core/CrossReferenceEngine.js +0 -624
  20. package/src/core/CurationEngine.js +0 -688
  21. package/src/core/DeprecationScheduler.js +0 -183
  22. package/src/core/LoadBearingDetector.js +0 -242
  23. package/src/core/NotificationService.js +0 -1032
  24. package/src/core/RapportOrchestrator.js +0 -632
  25. package/src/core/RelevanceDetector.js +0 -694
  26. package/src/core/StandardLifecycle.js +0 -244
  27. package/src/core/StandardsIngestion.js +0 -991
  28. package/src/core/TeamLoadBearingDetector.js +0 -431
  29. package/src/core/parsers/adrParser.js +0 -479
  30. package/src/core/parsers/cursorRulesParser.js +0 -564
  31. package/src/core/parsers/eslintParser.js +0 -439
  32. package/src/database/dbOperations.js +0 -105
  33. package/src/handlers/activity/activityGetMe.js +0 -98
  34. package/src/handlers/activity/activityGetTeam.js +0 -175
  35. package/src/handlers/admin/adminSetup.js +0 -216
  36. package/src/handlers/alerts/alertsAcknowledge.js +0 -92
  37. package/src/handlers/alerts/alertsGet.js +0 -250
  38. package/src/handlers/analytics/activitySummaryGet.js +0 -234
  39. package/src/handlers/analytics/coachingGet.js +0 -361
  40. package/src/handlers/analytics/convergenceGet.js +0 -236
  41. package/src/handlers/analytics/developerScoreGet.js +0 -137
  42. package/src/handlers/collaborators/collaboratorAdd.js +0 -200
  43. package/src/handlers/collaborators/collaboratorInvite.js +0 -219
  44. package/src/handlers/collaborators/collaboratorList.js +0 -82
  45. package/src/handlers/collaborators/collaboratorRemove.js +0 -128
  46. package/src/handlers/collaborators/inviteAccept.js +0 -122
  47. package/src/handlers/company/companyUsersDelete.js +0 -141
  48. package/src/handlers/company/companyUsersGet.js +0 -90
  49. package/src/handlers/company/companyUsersPost.js +0 -267
  50. package/src/handlers/company/companyUsersPut.js +0 -76
  51. package/src/handlers/context/contextGet.js +0 -57
  52. package/src/handlers/context/invariantsGet.js +0 -74
  53. package/src/handlers/context/loopsGet.js +0 -82
  54. package/src/handlers/context/notesCreate.js +0 -74
  55. package/src/handlers/context/purposeGet.js +0 -78
  56. package/src/handlers/correlations/correlationsDeveloperGet.js +0 -227
  57. package/src/handlers/correlations/correlationsGet.js +0 -93
  58. package/src/handlers/correlations/correlationsProjectGet.js +0 -153
  59. package/src/handlers/enterprise/controlTowerGet.js +0 -224
  60. package/src/handlers/enterprise/enterpriseAuditGet.js +0 -108
  61. package/src/handlers/enterprise/enterpriseContributorsGet.js +0 -85
  62. package/src/handlers/enterprise/enterpriseKnowledgeCategoriesGet.js +0 -53
  63. package/src/handlers/enterprise/enterpriseKnowledgeCreate.js +0 -77
  64. package/src/handlers/enterprise/enterpriseKnowledgeDelete.js +0 -71
  65. package/src/handlers/enterprise/enterpriseKnowledgeGet.js +0 -87
  66. package/src/handlers/enterprise/enterpriseKnowledgeUpdate.js +0 -122
  67. package/src/handlers/enterprise/enterpriseOnboardingComplete.js +0 -77
  68. package/src/handlers/enterprise/enterpriseOnboardingInvite.js +0 -138
  69. package/src/handlers/enterprise/enterpriseOnboardingSetup.js +0 -128
  70. package/src/handlers/enterprise/enterpriseOnboardingStatus.js +0 -88
  71. package/src/handlers/github/githubConnectionStatus.js +0 -49
  72. package/src/handlers/github/githubDiscoverPatterns.js +0 -621
  73. package/src/handlers/github/githubOAuthCallback.js +0 -178
  74. package/src/handlers/github/githubOAuthStart.js +0 -59
  75. package/src/handlers/github/githubPatternsReview.js +0 -76
  76. package/src/handlers/github/githubReposList.js +0 -105
  77. package/src/handlers/health/healthGet.js +0 -55
  78. package/src/handlers/helpers/auditLogger.js +0 -201
  79. package/src/handlers/helpers/checkSuperAdmin.js +0 -84
  80. package/src/handlers/helpers/decisionFrames.js +0 -29
  81. package/src/handlers/helpers/errorHandler.js +0 -49
  82. package/src/handlers/helpers/index.js +0 -138
  83. package/src/handlers/helpers/lambdaWrapper.js +0 -60
  84. package/src/handlers/helpers/mindmeldMcpCore.js +0 -1103
  85. package/src/handlers/helpers/predictiveCache.js +0 -51
  86. package/src/handlers/helpers/projectAccess.js +0 -88
  87. package/src/handlers/helpers/responseUtil.js +0 -55
  88. package/src/handlers/helpers/subscriptionTiers.js +0 -1168
  89. package/src/handlers/mcp/mcpHandler.js +0 -569
  90. package/src/handlers/mcp/mindmeldMcpHandler.js +0 -124
  91. package/src/handlers/mcp/mindmeldMcpStreamHandler.js +0 -342
  92. package/src/handlers/notifications/getPreferences.js +0 -84
  93. package/src/handlers/notifications/sendNotification.js +0 -170
  94. package/src/handlers/notifications/updatePreferences.js +0 -316
  95. package/src/handlers/patterns/patternEvaluatePromotionPost.js +0 -173
  96. package/src/handlers/patterns/patternUsagePost.js +0 -182
  97. package/src/handlers/patterns/patternViolationPost.js +0 -185
  98. package/src/handlers/projects/projectCreate.js +0 -248
  99. package/src/handlers/projects/projectDelete.js +0 -82
  100. package/src/handlers/projects/projectGet.js +0 -95
  101. package/src/handlers/projects/projectUpdate.js +0 -117
  102. package/src/handlers/reports/aiLeverage.js +0 -210
  103. package/src/handlers/reports/engineeringInvestment.js +0 -132
  104. package/src/handlers/reports/riskForecast.js +0 -206
  105. package/src/handlers/reports/standardsRoi.js +0 -254
  106. package/src/handlers/scheduled/analyzeCorrelations.js +0 -178
  107. package/src/handlers/scheduled/analyzeGitHistory.js +0 -510
  108. package/src/handlers/scheduled/generateAlerts.js +0 -135
  109. package/src/handlers/scheduled/maturityUpdateJob.js +0 -166
  110. package/src/handlers/scheduled/refreshActivity.js +0 -21
  111. package/src/handlers/scheduled/scanCompliance.js +0 -334
  112. package/src/handlers/sessions/sessionEndPost.js +0 -180
  113. package/src/handlers/sessions/sessionStandardsPost.js +0 -171
  114. package/src/handlers/standards/catalogGet.js +0 -185
  115. package/src/handlers/standards/catalogSync.js +0 -120
  116. package/src/handlers/standards/discoveriesGet.js +0 -89
  117. package/src/handlers/standards/projectStandardsGet.js +0 -129
  118. package/src/handlers/standards/projectStandardsPut.js +0 -151
  119. package/src/handlers/standards/standardsAuditGet.js +0 -65
  120. package/src/handlers/standards/standardsParseUpload.js +0 -149
  121. package/src/handlers/standards/standardsRelevantPost.js +0 -405
  122. package/src/handlers/standards/standardsTransition.js +0 -161
  123. package/src/handlers/stripe/addonManagePost.js +0 -240
  124. package/src/handlers/stripe/billingPortalPost.js +0 -93
  125. package/src/handlers/stripe/enterpriseCheckoutPost.js +0 -272
  126. package/src/handlers/stripe/seatsUpdatePost.js +0 -185
  127. package/src/handlers/stripe/subscriptionCancelDelete.js +0 -169
  128. package/src/handlers/stripe/subscriptionCreatePost.js +0 -221
  129. package/src/handlers/stripe/subscriptionUpdatePut.js +0 -163
  130. package/src/handlers/stripe/webhookPost.js +0 -482
  131. package/src/handlers/user/apiTokenCreate.js +0 -71
  132. package/src/handlers/user/apiTokenList.js +0 -64
  133. package/src/handlers/user/userSplashAck.js +0 -91
  134. package/src/handlers/user/userSplashGet.js +0 -211
  135. package/src/handlers/users/cognitoPostConfirmation.js +0 -186
  136. package/src/handlers/users/cognitoPreSignUp.js +0 -114
  137. package/src/handlers/users/userEntitlementsGet.js +0 -89
  138. package/src/handlers/users/userGet.js +0 -118
  139. package/src/handlers/users/userProfilePut.js +0 -77
  140. package/src/handlers/webhooks/githubWebhook.js +0 -215
@@ -1,431 +0,0 @@
1
- /**
2
- * Team Load-Bearing Detector
3
- *
4
- * Extends LoadBearingDetector to aggregate across multiple team members.
5
- *
6
- * Key insight: Load-bearing context detection is more accurate when analyzing
7
- * patterns across the entire team, not just individual users.
8
- *
9
- * Example:
10
- * - User A: coordinate_system present = 90% success (10 handoffs)
11
- * - User B: coordinate_system present = 92% success (15 handoffs)
12
- * - Team aggregate: coordinate_system present = 91.2% success (25 handoffs)
13
- * → Higher confidence in load-bearing classification
14
- */
15
-
16
- const LoadBearingDetector = require('./LoadBearingDetector');
17
-
18
- class TeamLoadBearingDetector {
19
- constructor(config = {}) {
20
- // Configuration
21
- this.config = {
22
- correlationThreshold: config.correlationThreshold || 0.7,
23
- minObservations: config.minObservations || 10, // Higher threshold for team
24
- minTeamMembers: config.minTeamMembers || 2, // Need 2+ users for team analysis
25
- ...config
26
- };
27
-
28
- // Per-user detectors
29
- this.userDetectors = new Map(); // userId -> LoadBearingDetector
30
-
31
- // Team-wide aggregation
32
- this.teamLoadBearing = new Map(); // element key -> team statistics
33
-
34
- // Team members
35
- this.teamMembers = new Set();
36
- }
37
-
38
- /**
39
- * Get or create detector for user
40
- */
41
- getDetectorForUser(userId) {
42
- if (!this.userDetectors.has(userId)) {
43
- this.userDetectors.set(userId, new LoadBearingDetector());
44
- this.teamMembers.add(userId);
45
- }
46
-
47
- return this.userDetectors.get(userId);
48
- }
49
-
50
- /**
51
- * Analyze handoff for specific user
52
- */
53
- analyzeHandoff(userId, handoff, outcome) {
54
- const detector = this.getDetectorForUser(userId);
55
-
56
- // Analyze for individual user
57
- const result = detector.analyzeHandoff(handoff, outcome);
58
-
59
- // Update team-wide aggregation
60
- this.aggregateTeamStatistics();
61
-
62
- return {
63
- ...result,
64
- teamLoadBearing: this.getTeamLoadBearing()
65
- };
66
- }
67
-
68
- /**
69
- * Aggregate load-bearing statistics across all team members
70
- */
71
- aggregateTeamStatistics() {
72
- this.teamLoadBearing.clear();
73
-
74
- // Collect all context elements from all users
75
- for (const [userId, detector] of this.userDetectors.entries()) {
76
- for (const [key, stats] of detector.contextElements.entries()) {
77
- // Get or create team stats for this element
78
- if (!this.teamLoadBearing.has(key)) {
79
- this.teamLoadBearing.set(key, {
80
- element: stats.element,
81
- userStats: new Map(), // userId -> user's stats for this element
82
- aggregated: {
83
- observations: 0,
84
- presentAndSuccess: 0,
85
- presentAndFailure: 0,
86
- totalPresent: 0,
87
- userCount: 0
88
- }
89
- });
90
- }
91
-
92
- const teamStats = this.teamLoadBearing.get(key);
93
-
94
- // Store user's stats
95
- teamStats.userStats.set(userId, stats);
96
-
97
- // Aggregate across team
98
- teamStats.aggregated.observations += stats.observations;
99
- teamStats.aggregated.presentAndSuccess += stats.presentAndSuccess || 0;
100
- teamStats.aggregated.presentAndFailure += stats.presentAndFailure || 0;
101
- teamStats.aggregated.totalPresent += stats.totalPresent || 0;
102
- teamStats.aggregated.userCount = teamStats.userStats.size;
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * Get team-wide load-bearing elements
109
- */
110
- getTeamLoadBearing() {
111
- const loadBearing = [];
112
-
113
- for (const [key, teamStats] of this.teamLoadBearing.entries()) {
114
- const agg = teamStats.aggregated;
115
-
116
- // Check minimum observations
117
- if (agg.observations < this.config.minObservations) {
118
- continue;
119
- }
120
-
121
- // Check minimum team members
122
- if (agg.userCount < this.config.minTeamMembers) {
123
- continue;
124
- }
125
-
126
- // Calculate team correlation
127
- const correlation = agg.totalPresent > 0
128
- ? agg.presentAndSuccess / agg.totalPresent
129
- : 0;
130
-
131
- if (correlation >= this.config.correlationThreshold) {
132
- loadBearing.push({
133
- element: teamStats.element,
134
- correlation,
135
- observations: agg.observations,
136
- teamSize: agg.userCount,
137
- confidence: this.calculateTeamConfidence(teamStats),
138
- userBreakdown: this.getUserBreakdown(teamStats),
139
- recommendation: 'LOAD_BEARING'
140
- });
141
- }
142
- }
143
-
144
- return loadBearing.sort((a, b) => b.correlation - a.correlation);
145
- }
146
-
147
- /**
148
- * Calculate confidence in load-bearing classification based on team agreement
149
- */
150
- calculateTeamConfidence(teamStats) {
151
- const agg = teamStats.aggregated;
152
-
153
- // Factor 1: Observation count (more = higher confidence)
154
- const observationConfidence = Math.min(agg.observations / 50, 1.0);
155
-
156
- // Factor 2: Team size (more users = higher confidence)
157
- const teamSizeConfidence = Math.min(agg.userCount / 5, 1.0);
158
-
159
- // Factor 3: User agreement (all users see similar correlation)
160
- const agreementConfidence = this.calculateUserAgreement(teamStats);
161
-
162
- // Factor 4: Correlation strength
163
- const correlation = agg.totalPresent > 0
164
- ? agg.presentAndSuccess / agg.totalPresent
165
- : 0;
166
-
167
- // Weighted average
168
- return (
169
- observationConfidence * 0.2 +
170
- teamSizeConfidence * 0.2 +
171
- agreementConfidence * 0.3 +
172
- correlation * 0.3
173
- );
174
- }
175
-
176
- /**
177
- * Calculate agreement across team members
178
- *
179
- * High agreement = all users see similar correlation
180
- * Low agreement = users see different results
181
- */
182
- calculateUserAgreement(teamStats) {
183
- const userCorrelations = [];
184
-
185
- for (const [userId, stats] of teamStats.userStats.entries()) {
186
- if (stats.totalPresent > 0) {
187
- const correlation = stats.presentAndSuccess / stats.totalPresent;
188
- userCorrelations.push(correlation);
189
- }
190
- }
191
-
192
- if (userCorrelations.length < 2) {
193
- return 0.5; // Not enough data for agreement
194
- }
195
-
196
- // Calculate standard deviation
197
- const mean = userCorrelations.reduce((a, b) => a + b, 0) / userCorrelations.length;
198
- const variance = userCorrelations.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / userCorrelations.length;
199
- const stdDev = Math.sqrt(variance);
200
-
201
- // Low std dev = high agreement
202
- // Agreement score: 1.0 - stdDev (capped at 0)
203
- return Math.max(0, 1.0 - stdDev);
204
- }
205
-
206
- /**
207
- * Get breakdown by user
208
- */
209
- getUserBreakdown(teamStats) {
210
- const breakdown = [];
211
-
212
- for (const [userId, stats] of teamStats.userStats.entries()) {
213
- const correlation = stats.totalPresent > 0
214
- ? stats.presentAndSuccess / stats.totalPresent
215
- : 0;
216
-
217
- breakdown.push({
218
- userId,
219
- observations: stats.observations,
220
- correlation,
221
- presentAndSuccess: stats.presentAndSuccess,
222
- presentAndFailure: stats.presentAndFailure
223
- });
224
- }
225
-
226
- return breakdown.sort((a, b) => b.correlation - a.correlation);
227
- }
228
-
229
- /**
230
- * Apply team recommendations to decision frame
231
- */
232
- applyTeamRecommendations(decisionFrame, userId) {
233
- const loadBearing = this.getTeamLoadBearing();
234
- const recommendations = this.generateTeamRecommendations(loadBearing);
235
-
236
- // Use individual user's detector to apply
237
- const detector = this.getDetectorForUser(userId);
238
- return detector.applyRecommendations(decisionFrame, recommendations);
239
- }
240
-
241
- /**
242
- * Generate recommendations with team context
243
- */
244
- generateTeamRecommendations(loadBearing) {
245
- const recommendations = [];
246
-
247
- for (const lb of loadBearing) {
248
- if (lb.element.type === 'constraint') {
249
- recommendations.push({
250
- type: 'mark_constraint_load_bearing',
251
- constraint: lb.element.value,
252
- reason: `Team-wide: ${(lb.correlation * 100).toFixed(1)}% success rate across ${lb.teamSize} users (${lb.observations} observations)`,
253
- confidence: lb.confidence,
254
- teamSize: lb.teamSize
255
- });
256
- }
257
-
258
- if (lb.element.type === 'context_key') {
259
- recommendations.push({
260
- type: 'always_include_context',
261
- key: lb.element.key,
262
- reason: `Team-wide: ${(lb.correlation * 100).toFixed(1)}% success rate across ${lb.teamSize} users (${lb.observations} observations)`,
263
- confidence: lb.confidence,
264
- teamSize: lb.teamSize
265
- });
266
- }
267
-
268
- if (lb.element.type === 'missing') {
269
- recommendations.push({
270
- type: 'prevent_missing_context',
271
- key: lb.element.key,
272
- reason: `Team-wide: ${(lb.correlation * 100).toFixed(1)}% failure rate when missing across ${lb.teamSize} users (${lb.observations} observations)`,
273
- confidence: lb.confidence,
274
- teamSize: lb.teamSize
275
- });
276
- }
277
- }
278
-
279
- return recommendations;
280
- }
281
-
282
- /**
283
- * Get patterns shared across team
284
- */
285
- getSharedPatterns() {
286
- const shared = [];
287
-
288
- for (const [key, teamStats] of this.teamLoadBearing.entries()) {
289
- if (teamStats.aggregated.userCount >= 2) {
290
- const agg = teamStats.aggregated;
291
- const correlation = agg.totalPresent > 0
292
- ? agg.presentAndSuccess / agg.totalPresent
293
- : 0;
294
-
295
- if (correlation >= this.config.correlationThreshold) {
296
- shared.push({
297
- element: teamStats.element,
298
- sharedBy: Array.from(teamStats.userStats.keys()),
299
- correlation,
300
- observations: agg.observations
301
- });
302
- }
303
- }
304
- }
305
-
306
- return shared.sort((a, b) => b.sharedBy.length - a.sharedBy.length);
307
- }
308
-
309
- /**
310
- * Get load-bearing elements discovered by one user but applicable to all
311
- */
312
- getCrossPollination() {
313
- const crossPollinated = [];
314
-
315
- for (const [key, teamStats] of this.teamLoadBearing.entries()) {
316
- // Found by one user, but high correlation
317
- if (teamStats.aggregated.userCount === 1) {
318
- const userId = Array.from(teamStats.userStats.keys())[0];
319
- const stats = teamStats.userStats.get(userId);
320
-
321
- const correlation = stats.totalPresent > 0
322
- ? stats.presentAndSuccess / stats.totalPresent
323
- : 0;
324
-
325
- if (correlation >= this.config.correlationThreshold && stats.observations >= 5) {
326
- crossPollinated.push({
327
- element: teamStats.element,
328
- discoveredBy: userId,
329
- correlation,
330
- observations: stats.observations,
331
- potentialForTeam: true,
332
- recommendation: 'Share with team - high correlation in solo use'
333
- });
334
- }
335
- }
336
- }
337
-
338
- return crossPollinated.sort((a, b) => b.correlation - a.correlation);
339
- }
340
-
341
- /**
342
- * Get team summary
343
- */
344
- getTeamSummary() {
345
- const summary = {
346
- teamSize: this.teamMembers.size,
347
- totalHandoffs: 0,
348
- successfulHandoffs: 0,
349
- teamLoadBearingElements: this.getTeamLoadBearing().length,
350
- sharedPatterns: this.getSharedPatterns().length,
351
- crossPollination: this.getCrossPollination().length,
352
- byUser: {}
353
- };
354
-
355
- // Aggregate by user
356
- for (const [userId, detector] of this.userDetectors.entries()) {
357
- const userSummary = detector.getSummary();
358
- summary.totalHandoffs += userSummary.totalHandoffs;
359
- summary.successfulHandoffs += userSummary.successfulHandoffs;
360
-
361
- summary.byUser[userId] = {
362
- handoffs: userSummary.totalHandoffs,
363
- successRate: userSummary.totalHandoffs > 0
364
- ? userSummary.successfulHandoffs / userSummary.totalHandoffs
365
- : 0,
366
- loadBearingDetected: userSummary.loadBearingDetected
367
- };
368
- }
369
-
370
- return summary;
371
- }
372
-
373
- /**
374
- * Export team data
375
- */
376
- exportTeamData() {
377
- return {
378
- teamMembers: Array.from(this.teamMembers),
379
- userDetectors: Object.fromEntries(
380
- Array.from(this.userDetectors.entries()).map(([userId, detector]) => [
381
- userId,
382
- detector.exportData()
383
- ])
384
- ),
385
- teamLoadBearing: Array.from(this.teamLoadBearing.entries()).map(([key, stats]) => ({
386
- key,
387
- element: stats.element,
388
- aggregated: stats.aggregated,
389
- userBreakdown: this.getUserBreakdown(stats)
390
- }))
391
- };
392
- }
393
-
394
- /**
395
- * Import team data
396
- */
397
- importTeamData(exported) {
398
- // Import team members
399
- if (exported.teamMembers) {
400
- for (const userId of exported.teamMembers) {
401
- this.teamMembers.add(userId);
402
- }
403
- }
404
-
405
- // Import user detectors
406
- if (exported.userDetectors) {
407
- for (const [userId, detectorData] of Object.entries(exported.userDetectors)) {
408
- const detector = new LoadBearingDetector();
409
-
410
- // Import handoff analysis
411
- if (detectorData.handoffAnalysis) {
412
- detector.handoffAnalysis = detectorData.handoffAnalysis;
413
- }
414
-
415
- // Import context elements
416
- if (detectorData.contextElements) {
417
- for (const elem of detectorData.contextElements) {
418
- detector.contextElements.set(elem.key, elem);
419
- }
420
- }
421
-
422
- this.userDetectors.set(userId, detector);
423
- }
424
- }
425
-
426
- // Re-aggregate
427
- this.aggregateTeamStatistics();
428
- }
429
- }
430
-
431
- module.exports = TeamLoadBearingDetector;