@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,84 +0,0 @@
1
- /**
2
- * Super Admin Check Helper
3
- */
4
-
5
- const { executeQuery } = require('./dbOperations');
6
-
7
- /**
8
- * Check if user is a superadmin
9
- * @param {string} email - User email
10
- * @returns {Promise<boolean>}
11
- */
12
- async function isSuperAdmin(email) {
13
- const query = `
14
- SELECT super_admin
15
- FROM rapport.users
16
- WHERE email_address = $1
17
- `;
18
- const result = await executeQuery(query, [email]);
19
- return result.rows.length > 0 && result.rows[0].super_admin === true;
20
- }
21
-
22
- /**
23
- * Require superadmin access - throws 403 if not superadmin
24
- * @param {string} email - User email
25
- * @throws {Error} 403 Forbidden if not superadmin
26
- */
27
- async function requireSuperAdmin(email) {
28
- const isAdmin = await isSuperAdmin(email);
29
- if (!isAdmin) {
30
- const error = new Error('Superadmin access required');
31
- error.statusCode = 403;
32
- throw error;
33
- }
34
- }
35
-
36
- /**
37
- * Get user with superadmin status
38
- * @param {string} email - User email
39
- * @returns {Promise<Object|null>}
40
- */
41
- async function getUserWithSuperAdminStatus(email) {
42
- const query = `
43
- SELECT
44
- email_address,
45
- client_id,
46
- CONCAT(first_name, ' ', last_name) as user_display_name,
47
- first_name,
48
- last_name,
49
- super_admin,
50
- user_status
51
- FROM rapport.users
52
- WHERE email_address = $1
53
- `;
54
- const result = await executeQuery(query, [email]);
55
- return result.rows.length > 0 ? result.rows[0] : null;
56
- }
57
-
58
- /**
59
- * Log superadmin action to audit trail
60
- * @param {Object} params - Audit parameters
61
- */
62
- async function logSuperAdminAction({ email, action, targetType, targetId, details, ipAddress, userAgent }) {
63
- const query = `
64
- INSERT INTO superadmin_audit_log (
65
- email, action, target_type, target_id, details, ip_address, user_agent
66
- ) VALUES ($1, $2, $3, $4, $5, $6, $7)
67
- `;
68
- await executeQuery(query, [
69
- email,
70
- action,
71
- targetType || null,
72
- targetId || null,
73
- details ? JSON.stringify(details) : null,
74
- ipAddress || null,
75
- userAgent || null
76
- ]);
77
- }
78
-
79
- module.exports = {
80
- isSuperAdmin,
81
- requireSuperAdmin,
82
- getUserWithSuperAdminStatus,
83
- logSuperAdminAction
84
- };
@@ -1,29 +0,0 @@
1
- const { executeQuery } = require('./index');
2
-
3
- async function createFrame({ projectId, sessionId, standardIds, confidence, context }) {
4
- const result = await executeQuery(`
5
- INSERT INTO rapport.decision_frames (project_id, session_id, standard_ids, confidence, context)
6
- VALUES ($1, $2, $3, $4, $5)
7
- RETURNING frame_id, created_at
8
- `, [projectId, sessionId || null, standardIds, confidence || 0, JSON.stringify(context || {})]);
9
- return result.rows[0];
10
- }
11
-
12
- async function getFrame(frameId) {
13
- const result = await executeQuery(`
14
- SELECT * FROM rapport.decision_frames WHERE frame_id = $1
15
- `, [frameId]);
16
- return result.rows[0] || null;
17
- }
18
-
19
- async function getProjectFrames(projectId, limit = 20) {
20
- const result = await executeQuery(`
21
- SELECT * FROM rapport.decision_frames
22
- WHERE project_id = $1
23
- ORDER BY created_at DESC
24
- LIMIT $2
25
- `, [projectId, limit]);
26
- return result.rows;
27
- }
28
-
29
- module.exports = { createFrame, getFrame, getProjectFrames };
@@ -1,49 +0,0 @@
1
- /**
2
- * Error Handler Helper
3
- * Standard error handling and logging for all Rapport handlers
4
- */
5
-
6
- /**
7
- * Handle error with standard response
8
- * @param {Error} error - Error object
9
- * @returns {object} Lambda error response
10
- */
11
- function handleError(error) {
12
- console.error('Error:', error);
13
-
14
- // Determine status code
15
- const statusCode = error.statusCode || 500;
16
-
17
- // Determine message
18
- let message = 'Internal server error';
19
- if (error.statusCode) {
20
- message = error.message;
21
- } else if (error.code === '23505') {
22
- message = 'Resource already exists';
23
- } else if (error.code === '23503') {
24
- message = 'Referenced resource not found';
25
- } else if (error.code === '23502') {
26
- message = 'Required field missing';
27
- }
28
-
29
- return {
30
- statusCode,
31
- headers: {
32
- 'Content-Type': 'application/json',
33
- 'Access-Control-Allow-Origin': '*',
34
- 'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
35
- 'Access-Control-Allow-Headers': 'Content-Type,Authorization'
36
- },
37
- body: JSON.stringify({
38
- success: false,
39
- message,
40
- error: process.env.NODE_ENV === 'dev' ? {
41
- code: error.code,
42
- detail: error.detail,
43
- stack: error.stack
44
- } : undefined
45
- })
46
- };
47
- }
48
-
49
- module.exports = { handleError };
@@ -1,138 +0,0 @@
1
- /**
2
- * Helpers Index
3
- * Tim-Combo pattern: Re-export all helpers from single entry point
4
- *
5
- * Usage: const { wrapHandler, executeQuery, createSuccessResponse, handleError } = require('./helpers');
6
- */
7
-
8
- const { wrapHandler } = require('./lambdaWrapper');
9
- const { executeQuery } = require('./dbOperations');
10
- const { createSuccessResponse, createErrorResponse } = require('./responseUtil');
11
- const { handleError } = require('./errorHandler');
12
- const {
13
- getTierConfig,
14
- SUBSCRIPTION_TIERS,
15
- getStripePriceId,
16
- checkEarlyAdopterEligibility,
17
- getEarlyAdopterDiscount,
18
- calculateEarlyAdopterPrice,
19
- requiresCommunityContribution,
20
- getPrivateTierVariant,
21
- calculateTierCost,
22
- checkSubscriptionLimits,
23
- // Billing type functions
24
- BILLING_TYPES,
25
- usesStripeBilling,
26
- usesInvoiceBilling,
27
- isInternalClient,
28
- checkCollaboratorBillingLimits,
29
- getBillingTypeDisplayName,
30
- // Enterprise subscription functions
31
- ENTERPRISE_PACKAGES,
32
- ENTERPRISE_ADDONS,
33
- VOLUME_DISCOUNTS,
34
- getVolumeDiscount,
35
- validateSeatCount,
36
- calculateEnterpriseCost,
37
- getEnterprisePackage,
38
- getEnterpriseAddon,
39
- getAllEnterpriseAddons,
40
- hasEnterpriseFeature,
41
- getEnterpriseFeatures,
42
- checkEnterpriseSeatLimits,
43
- getEnterprisePriceId,
44
- getAddonPriceId
45
- } = require('./subscriptionTiers');
46
- const checkSuperAdmin = require('./checkSuperAdmin');
47
- const { verifyProjectAccess, verifyProjectRole } = require('./projectAccess');
48
- const { getPredictedStandards, logStandardsActivation } = require('./predictiveCache');
49
- const { createFrame, getFrame, getProjectFrames } = require('./decisionFrames');
50
- const {
51
- AuditEventType,
52
- EntityType,
53
- logAuditEvent,
54
- logModificationEvent,
55
- logAccessEvent,
56
- extractRequestContext,
57
- generateCorrelationId,
58
- } = require('./auditLogger');
59
-
60
- module.exports = {
61
- // Lambda wrapper
62
- wrapHandler,
63
-
64
- // Database operations
65
- executeQuery,
66
-
67
- // Response utilities
68
- createSuccessResponse,
69
- createErrorResponse,
70
-
71
- // Error handling
72
- handleError,
73
-
74
- // Subscription tiers
75
- getTierConfig,
76
- SUBSCRIPTION_TIERS,
77
- getStripePriceId,
78
- calculateTierCost,
79
-
80
- // Early adopter discount
81
- checkEarlyAdopterEligibility,
82
- getEarlyAdopterDiscount,
83
- calculateEarlyAdopterPrice,
84
-
85
- // Community vs Private tiers
86
- requiresCommunityContribution,
87
- getPrivateTierVariant,
88
-
89
- // Subscription limits
90
- checkSubscriptionLimits,
91
-
92
- // Billing type functions
93
- BILLING_TYPES,
94
- usesStripeBilling,
95
- usesInvoiceBilling,
96
- isInternalClient,
97
- checkCollaboratorBillingLimits,
98
- getBillingTypeDisplayName,
99
-
100
- // Enterprise subscription functions
101
- ENTERPRISE_PACKAGES,
102
- ENTERPRISE_ADDONS,
103
- VOLUME_DISCOUNTS,
104
- getVolumeDiscount,
105
- validateSeatCount,
106
- calculateEnterpriseCost,
107
- getEnterprisePackage,
108
- getEnterpriseAddon,
109
- getAllEnterpriseAddons,
110
- hasEnterpriseFeature,
111
- getEnterpriseFeatures,
112
- checkEnterpriseSeatLimits,
113
- getEnterprisePriceId,
114
- getAddonPriceId,
115
-
116
- // Authorization
117
- checkSuperAdmin,
118
- verifyProjectAccess,
119
- verifyProjectRole,
120
-
121
- // Predictive standards caching
122
- getPredictedStandards,
123
- logStandardsActivation,
124
-
125
- // Decision frames
126
- createFrame,
127
- getFrame,
128
- getProjectFrames,
129
-
130
- // Audit logging
131
- AuditEventType,
132
- EntityType,
133
- logAuditEvent,
134
- logModificationEvent,
135
- logAccessEvent,
136
- extractRequestContext,
137
- generateCorrelationId
138
- };
@@ -1,60 +0,0 @@
1
- /**
2
- * Lambda Wrapper Helper
3
- * Standardizes request/response handling for all Rapport handlers
4
- */
5
-
6
- function wrapHandler(handler) {
7
- return async (event, context) => {
8
- try {
9
- // Parse body if present
10
- let body = {};
11
- if (event.body) {
12
- try {
13
- body = JSON.parse(event.body);
14
- } catch (e) {
15
- console.error('Failed to parse body:', e);
16
- return {
17
- statusCode: 400,
18
- headers: {
19
- 'Content-Type': 'application/json',
20
- 'Access-Control-Allow-Origin': '*'
21
- },
22
- body: JSON.stringify({
23
- success: false,
24
- message: 'Invalid JSON in request body'
25
- })
26
- };
27
- }
28
- }
29
-
30
- // Call handler with standardized parameters
31
- const result = await handler({
32
- queryStringParameters: event.queryStringParameters || {},
33
- pathParameters: event.pathParameters || {}, // Legacy — all params now in query/body
34
- body: body,
35
- requestContext: event.requestContext,
36
- headers: event.headers || {},
37
- httpMethod: event.httpMethod
38
- });
39
-
40
- return result;
41
-
42
- } catch (error) {
43
- console.error('Wrapper Error:', error);
44
- return {
45
- statusCode: 500,
46
- headers: {
47
- 'Content-Type': 'application/json',
48
- 'Access-Control-Allow-Origin': '*'
49
- },
50
- body: JSON.stringify({
51
- success: false,
52
- message: 'Internal server error',
53
- error: process.env.NODE_ENV === 'dev' ? error.message : undefined
54
- })
55
- };
56
- }
57
- };
58
- }
59
-
60
- module.exports = { wrapHandler };