@equilateral_ai/mindmeld 3.5.3 → 4.0.2

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 (138) hide show
  1. package/hooks/session-start.js +312 -85
  2. package/package.json +21 -13
  3. package/scripts/init-project.js +9 -23
  4. package/scripts/repo-analyzer.js +118 -2
  5. package/src/client/dbShim.js +16 -0
  6. package/src/core/AuthManager.js +3 -2
  7. package/src/handlers/helpers/dbOperations.js +9 -46
  8. package/src/index.js +2 -217
  9. package/src/utils/piiMask.js +16 -0
  10. package/scripts/inject.js +0 -409
  11. package/scripts/mcp-bridge.js +0 -220
  12. package/scripts/standards.js +0 -285
  13. package/src/collaboration/CollaborationPrompt.js +0 -460
  14. package/src/core/AlertEngine.js +0 -813
  15. package/src/core/AlertNotifier.js +0 -363
  16. package/src/core/CorrelationAnalyzer.js +0 -931
  17. package/src/core/CrossReferenceEngine.js +0 -624
  18. package/src/core/CurationEngine.js +0 -688
  19. package/src/core/DeprecationScheduler.js +0 -183
  20. package/src/core/LoadBearingDetector.js +0 -242
  21. package/src/core/NotificationService.js +0 -1032
  22. package/src/core/RapportOrchestrator.js +0 -632
  23. package/src/core/RelevanceDetector.js +0 -694
  24. package/src/core/StandardLifecycle.js +0 -244
  25. package/src/core/StandardsIngestion.js +0 -991
  26. package/src/core/TeamLoadBearingDetector.js +0 -431
  27. package/src/core/parsers/adrParser.js +0 -479
  28. package/src/core/parsers/cursorRulesParser.js +0 -564
  29. package/src/core/parsers/eslintParser.js +0 -439
  30. package/src/database/dbOperations.js +0 -105
  31. package/src/handlers/activity/activityGetMe.js +0 -98
  32. package/src/handlers/activity/activityGetTeam.js +0 -175
  33. package/src/handlers/admin/adminSetup.js +0 -216
  34. package/src/handlers/alerts/alertsAcknowledge.js +0 -92
  35. package/src/handlers/alerts/alertsGet.js +0 -250
  36. package/src/handlers/analytics/activitySummaryGet.js +0 -234
  37. package/src/handlers/analytics/coachingGet.js +0 -361
  38. package/src/handlers/analytics/convergenceGet.js +0 -236
  39. package/src/handlers/analytics/developerScoreGet.js +0 -137
  40. package/src/handlers/collaborators/collaboratorAdd.js +0 -200
  41. package/src/handlers/collaborators/collaboratorInvite.js +0 -219
  42. package/src/handlers/collaborators/collaboratorList.js +0 -82
  43. package/src/handlers/collaborators/collaboratorRemove.js +0 -128
  44. package/src/handlers/collaborators/inviteAccept.js +0 -122
  45. package/src/handlers/company/companyUsersDelete.js +0 -141
  46. package/src/handlers/company/companyUsersGet.js +0 -90
  47. package/src/handlers/company/companyUsersPost.js +0 -267
  48. package/src/handlers/company/companyUsersPut.js +0 -76
  49. package/src/handlers/context/contextGet.js +0 -57
  50. package/src/handlers/context/invariantsGet.js +0 -74
  51. package/src/handlers/context/loopsGet.js +0 -82
  52. package/src/handlers/context/notesCreate.js +0 -74
  53. package/src/handlers/context/purposeGet.js +0 -78
  54. package/src/handlers/correlations/correlationsDeveloperGet.js +0 -227
  55. package/src/handlers/correlations/correlationsGet.js +0 -93
  56. package/src/handlers/correlations/correlationsProjectGet.js +0 -153
  57. package/src/handlers/enterprise/controlTowerGet.js +0 -224
  58. package/src/handlers/enterprise/enterpriseAuditGet.js +0 -108
  59. package/src/handlers/enterprise/enterpriseContributorsGet.js +0 -85
  60. package/src/handlers/enterprise/enterpriseKnowledgeCategoriesGet.js +0 -53
  61. package/src/handlers/enterprise/enterpriseKnowledgeCreate.js +0 -77
  62. package/src/handlers/enterprise/enterpriseKnowledgeDelete.js +0 -71
  63. package/src/handlers/enterprise/enterpriseKnowledgeGet.js +0 -87
  64. package/src/handlers/enterprise/enterpriseKnowledgeUpdate.js +0 -122
  65. package/src/handlers/enterprise/enterpriseOnboardingComplete.js +0 -77
  66. package/src/handlers/enterprise/enterpriseOnboardingInvite.js +0 -138
  67. package/src/handlers/enterprise/enterpriseOnboardingSetup.js +0 -128
  68. package/src/handlers/enterprise/enterpriseOnboardingStatus.js +0 -88
  69. package/src/handlers/github/githubConnectionStatus.js +0 -49
  70. package/src/handlers/github/githubDiscoverPatterns.js +0 -621
  71. package/src/handlers/github/githubOAuthCallback.js +0 -178
  72. package/src/handlers/github/githubOAuthStart.js +0 -59
  73. package/src/handlers/github/githubPatternsReview.js +0 -76
  74. package/src/handlers/github/githubReposList.js +0 -105
  75. package/src/handlers/health/healthGet.js +0 -55
  76. package/src/handlers/helpers/auditLogger.js +0 -201
  77. package/src/handlers/helpers/checkSuperAdmin.js +0 -84
  78. package/src/handlers/helpers/decisionFrames.js +0 -29
  79. package/src/handlers/helpers/errorHandler.js +0 -49
  80. package/src/handlers/helpers/index.js +0 -138
  81. package/src/handlers/helpers/lambdaWrapper.js +0 -60
  82. package/src/handlers/helpers/mindmeldMcpCore.js +0 -1103
  83. package/src/handlers/helpers/predictiveCache.js +0 -51
  84. package/src/handlers/helpers/projectAccess.js +0 -88
  85. package/src/handlers/helpers/responseUtil.js +0 -55
  86. package/src/handlers/helpers/subscriptionTiers.js +0 -1168
  87. package/src/handlers/mcp/mcpHandler.js +0 -569
  88. package/src/handlers/mcp/mindmeldMcpHandler.js +0 -124
  89. package/src/handlers/mcp/mindmeldMcpStreamHandler.js +0 -342
  90. package/src/handlers/notifications/getPreferences.js +0 -84
  91. package/src/handlers/notifications/sendNotification.js +0 -170
  92. package/src/handlers/notifications/updatePreferences.js +0 -316
  93. package/src/handlers/patterns/patternEvaluatePromotionPost.js +0 -173
  94. package/src/handlers/patterns/patternUsagePost.js +0 -182
  95. package/src/handlers/patterns/patternViolationPost.js +0 -185
  96. package/src/handlers/projects/projectCreate.js +0 -248
  97. package/src/handlers/projects/projectDelete.js +0 -82
  98. package/src/handlers/projects/projectGet.js +0 -95
  99. package/src/handlers/projects/projectUpdate.js +0 -117
  100. package/src/handlers/reports/aiLeverage.js +0 -210
  101. package/src/handlers/reports/engineeringInvestment.js +0 -132
  102. package/src/handlers/reports/riskForecast.js +0 -206
  103. package/src/handlers/reports/standardsRoi.js +0 -254
  104. package/src/handlers/scheduled/analyzeCorrelations.js +0 -178
  105. package/src/handlers/scheduled/analyzeGitHistory.js +0 -510
  106. package/src/handlers/scheduled/generateAlerts.js +0 -135
  107. package/src/handlers/scheduled/maturityUpdateJob.js +0 -166
  108. package/src/handlers/scheduled/refreshActivity.js +0 -21
  109. package/src/handlers/scheduled/scanCompliance.js +0 -334
  110. package/src/handlers/sessions/sessionEndPost.js +0 -180
  111. package/src/handlers/sessions/sessionStandardsPost.js +0 -171
  112. package/src/handlers/standards/catalogGet.js +0 -185
  113. package/src/handlers/standards/catalogSync.js +0 -120
  114. package/src/handlers/standards/discoveriesGet.js +0 -89
  115. package/src/handlers/standards/projectStandardsGet.js +0 -129
  116. package/src/handlers/standards/projectStandardsPut.js +0 -151
  117. package/src/handlers/standards/standardsAuditGet.js +0 -65
  118. package/src/handlers/standards/standardsParseUpload.js +0 -149
  119. package/src/handlers/standards/standardsRelevantPost.js +0 -405
  120. package/src/handlers/standards/standardsTransition.js +0 -161
  121. package/src/handlers/stripe/addonManagePost.js +0 -240
  122. package/src/handlers/stripe/billingPortalPost.js +0 -93
  123. package/src/handlers/stripe/enterpriseCheckoutPost.js +0 -272
  124. package/src/handlers/stripe/seatsUpdatePost.js +0 -185
  125. package/src/handlers/stripe/subscriptionCancelDelete.js +0 -169
  126. package/src/handlers/stripe/subscriptionCreatePost.js +0 -221
  127. package/src/handlers/stripe/subscriptionUpdatePut.js +0 -163
  128. package/src/handlers/stripe/webhookPost.js +0 -482
  129. package/src/handlers/user/apiTokenCreate.js +0 -71
  130. package/src/handlers/user/apiTokenList.js +0 -64
  131. package/src/handlers/user/userSplashAck.js +0 -91
  132. package/src/handlers/user/userSplashGet.js +0 -211
  133. package/src/handlers/users/cognitoPostConfirmation.js +0 -186
  134. package/src/handlers/users/cognitoPreSignUp.js +0 -114
  135. package/src/handlers/users/userEntitlementsGet.js +0 -89
  136. package/src/handlers/users/userGet.js +0 -118
  137. package/src/handlers/users/userProfilePut.js +0 -77
  138. package/src/handlers/webhooks/githubWebhook.js +0 -215
@@ -1,151 +0,0 @@
1
- /**
2
- * Project Standards Put Handler
3
- * Updates standards preferences for a project
4
- *
5
- * PUT /api/projects/standards
6
- * Body: { project_id, enabled_categories, standard_overrides, critical_overrides }
7
- * Auth: Cognito JWT required
8
- */
9
-
10
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, verifyProjectRole } = require('./helpers');
11
-
12
- async function updateProjectStandards({ body, pathParameters, requestContext }) {
13
- try {
14
- const email = requestContext.authorizer?.claims?.email || requestContext.authorizer?.jwt?.claims?.email;
15
-
16
- if (!email) {
17
- return createErrorResponse(401, 'Authentication required');
18
- }
19
-
20
- const projectId = pathParameters?.projectId || (body || {}).project_id;
21
-
22
- if (!projectId) {
23
- return createErrorResponse(400, 'projectId is required');
24
- }
25
-
26
- const {
27
- enabled_categories,
28
- standard_overrides,
29
- critical_overrides,
30
- catalog_id = 'equilateral-v1',
31
- standard_id,
32
- load_bearing
33
- } = body || {};
34
-
35
- // Verify user has admin access to project (project owner/admin or company admin)
36
- const projectAccess = await verifyProjectRole(projectId, email, ['owner', 'admin']);
37
- if (!projectAccess) {
38
- return createErrorResponse(403, 'Admin access required to modify standards preferences');
39
- }
40
-
41
- // Verify catalog exists
42
- const catalogResult = await executeQuery(`
43
- SELECT catalog_id, categories FROM rapport.standards_catalog
44
- WHERE catalog_id = $1
45
- `, [catalog_id]);
46
-
47
- if (catalogResult.rowCount === 0) {
48
- return createErrorResponse(404, 'Standards catalog not found', { catalog_id });
49
- }
50
-
51
- const availableCategories = Object.keys(catalogResult.rows[0].categories || {});
52
-
53
- // Validate enabled_categories keys
54
- if (enabled_categories) {
55
- const invalidCategories = Object.keys(enabled_categories).filter(
56
- cat => !availableCategories.includes(cat)
57
- );
58
- if (invalidCategories.length > 0) {
59
- return createErrorResponse(400, 'Invalid category names', {
60
- invalid: invalidCategories,
61
- valid: availableCategories
62
- });
63
- }
64
- }
65
-
66
- // Update load_bearing flag on a specific standard if provided
67
- if (standard_id && typeof load_bearing === 'boolean') {
68
- const userCompany = await executeQuery(`
69
- SELECT company_id FROM rapport.user_entitlements WHERE email_address = $1 LIMIT 1
70
- `, [email]);
71
- const companyId = userCompany.rows[0]?.company_id;
72
-
73
- // Try base standards first
74
- const baseResult = await executeQuery(`
75
- UPDATE rapport.standards_patterns
76
- SET load_bearing = $1
77
- WHERE pattern_id = $2
78
- AND (company_id IS NULL OR company_id = $3)
79
- `, [load_bearing, standard_id, companyId]);
80
-
81
- // If no base standard matched, try company overrides
82
- if (baseResult.rowCount === 0 && companyId) {
83
- await executeQuery(`
84
- UPDATE rapport.company_standard_overrides
85
- SET load_bearing = $1
86
- WHERE (base_standard_id = $2 OR override_id::text = $3)
87
- AND company_id = $4
88
- AND active = TRUE
89
- `, [load_bearing, standard_id, standard_id.replace('company-add-', ''), companyId]);
90
- }
91
- }
92
-
93
- // Upsert project standards
94
- const result = await executeQuery(`
95
- INSERT INTO rapport.project_standards (
96
- project_id,
97
- catalog_id,
98
- enabled_categories,
99
- standard_overrides,
100
- critical_overrides,
101
- created_by,
102
- modified_by
103
- ) VALUES ($1, $2, $3, $4, $5, $6, $6)
104
- ON CONFLICT (project_id, catalog_id) DO UPDATE SET
105
- enabled_categories = COALESCE($3, rapport.project_standards.enabled_categories),
106
- standard_overrides = COALESCE($4, rapport.project_standards.standard_overrides),
107
- critical_overrides = COALESCE($5, rapport.project_standards.critical_overrides),
108
- modified_by = $6,
109
- modified_at = NOW()
110
- RETURNING *
111
- `, [
112
- projectId,
113
- catalog_id,
114
- enabled_categories ? JSON.stringify(enabled_categories) : null,
115
- standard_overrides ? JSON.stringify(standard_overrides) : null,
116
- critical_overrides ? JSON.stringify(critical_overrides) : null,
117
- email
118
- ]);
119
-
120
- const updated = result.rows[0];
121
-
122
- // Count enabled standards
123
- const enabledCats = updated.enabled_categories || {};
124
- const enabledCount = Object.values(enabledCats).filter(v => v === true).length;
125
- const disabledCount = Object.values(enabledCats).filter(v => v === false).length;
126
-
127
- return createSuccessResponse({
128
- project_id: projectId,
129
- catalog_id: updated.catalog_id,
130
- preferences: {
131
- enabled_categories: updated.enabled_categories,
132
- standard_overrides: updated.standard_overrides,
133
- critical_overrides: updated.critical_overrides
134
- },
135
- summary: {
136
- categories_enabled: enabledCount,
137
- categories_disabled: disabledCount,
138
- standard_overrides: Object.keys(updated.standard_overrides || {}).length,
139
- critical_overrides: Object.keys(updated.critical_overrides || {}).length
140
- },
141
- modified_by: updated.modified_by,
142
- modified_at: updated.modified_at
143
- }, 'Standards preferences updated');
144
-
145
- } catch (error) {
146
- console.error('Project Standards Put Error:', error);
147
- return createErrorResponse(500, 'Failed to update project standards');
148
- }
149
- }
150
-
151
- exports.handler = wrapHandler(updateProjectStandards);
@@ -1,65 +0,0 @@
1
- /**
2
- * Standards Audit Get Handler
3
- * Returns the audit trail for a standard's lifecycle transitions
4
- *
5
- * GET /api/standards/audit?standard_id=xxx
6
- * Query params: standard_id (required), cursor (string), limit (number, default 50, max 200)
7
- * Returns: { audit_trail, total_transitions, current_state }
8
- * Auth: Cognito JWT required
9
- */
10
-
11
- const { wrapHandler, createSuccessResponse, createErrorResponse } = require('./helpers');
12
- const { StandardLifecycle } = require('./core/StandardLifecycle');
13
-
14
- const lifecycle = new StandardLifecycle();
15
-
16
- async function getStandardsAudit({ queryStringParameters, requestContext }) {
17
- try {
18
- const email = requestContext.authorizer?.claims?.email || requestContext.authorizer?.jwt?.claims?.email;
19
-
20
- if (!email) {
21
- return createErrorResponse(401, 'Authentication required');
22
- }
23
-
24
- const id = (queryStringParameters || {}).standard_id;
25
-
26
- if (!id) {
27
- return createErrorResponse(400, 'standard_id is required');
28
- }
29
-
30
- // Verify the standard exists
31
- const currentState = await lifecycle.getCurrentState(id);
32
-
33
- if (!currentState) {
34
- return createErrorResponse(404, 'Standard not found', { standard_id: id });
35
- }
36
-
37
- // Get valid transitions from the current state
38
- const validTransitions = lifecycle.getValidTransitions(currentState);
39
-
40
- // Get audit history with pagination
41
- const cursor = queryStringParameters?.cursor || null;
42
- const limit = queryStringParameters?.limit ? parseInt(queryStringParameters.limit) : 50;
43
-
44
- const history = await lifecycle.getHistory(id, { cursor, limit });
45
-
46
- return createSuccessResponse({
47
- standard_id: id,
48
- current_state: currentState,
49
- valid_transitions: validTransitions,
50
- audit_trail: history.entries,
51
- total_transitions: history.total_transitions,
52
- pagination: {
53
- has_more: history.has_more,
54
- next_cursor: history.next_cursor,
55
- limit: limit
56
- }
57
- }, 'Audit trail retrieved');
58
-
59
- } catch (error) {
60
- console.error('Standards Audit Get Error:', error);
61
- return createErrorResponse(500, 'Failed to retrieve audit trail');
62
- }
63
- }
64
-
65
- exports.handler = wrapHandler(getStandardsAudit);
@@ -1,149 +0,0 @@
1
- /**
2
- * Standards Parse Upload Handler
3
- * Parses uploaded standards files into YAML-compatible format
4
- *
5
- * POST /api/standards/parse-upload
6
- * Body: { project_id, content, format: 'adr'|'eslint'|'cursorrules'|'markdown', filename }
7
- * Auth: Cognito JWT required
8
- *
9
- * Uses the appropriate parser based on the specified format and returns
10
- * parsed YAML-compatible standards ready for storage or review.
11
- */
12
-
13
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, verifyProjectAccess } = require('./helpers');
14
-
15
- const { parseAdr } = require('./core/parsers/adrParser');
16
- const { parseEslint } = require('./core/parsers/eslintParser');
17
- const { parseCursorRules } = require('./core/parsers/cursorRulesParser');
18
-
19
- const SUPPORTED_FORMATS = ['adr', 'eslint', 'cursorrules', 'markdown'];
20
-
21
- async function parseUploadStandards({ body, requestContext }) {
22
- try {
23
- const email = requestContext.authorizer?.claims?.email || requestContext.authorizer?.jwt?.claims?.email;
24
-
25
- if (!email) {
26
- return createErrorResponse(401, 'Authentication required');
27
- }
28
-
29
- const { project_id, content, format, filename } = body || {};
30
-
31
- // Validate required fields
32
- if (!project_id) {
33
- return createErrorResponse(400, 'project_id is required');
34
- }
35
-
36
- if (!content) {
37
- return createErrorResponse(400, 'content is required');
38
- }
39
-
40
- if (!format) {
41
- return createErrorResponse(400, 'format is required', {
42
- supported: SUPPORTED_FORMATS
43
- });
44
- }
45
-
46
- if (!SUPPORTED_FORMATS.includes(format)) {
47
- return createErrorResponse(400, `Unsupported format: ${format}`, {
48
- supported: SUPPORTED_FORMATS
49
- });
50
- }
51
-
52
- // Verify user has access to the project (collaborator or company member)
53
- const projectAccess = await verifyProjectAccess(project_id, email);
54
- if (!projectAccess) {
55
- return createErrorResponse(403, 'Access denied to project');
56
- }
57
-
58
- // Parse the content using the appropriate parser
59
- const parserOptions = {
60
- filename: filename || `uploaded-${format}`,
61
- category: undefined // Let parser infer category
62
- };
63
-
64
- let parsed;
65
- try {
66
- parsed = parseContent(content, format, parserOptions);
67
- } catch (parseError) {
68
- return createErrorResponse(422, `Failed to parse ${format} content: ${parseError.message}`, {
69
- format,
70
- filename: parserOptions.filename
71
- });
72
- }
73
-
74
- // Record the upload activity
75
- await executeQuery(`
76
- INSERT INTO rapport.activity_log (
77
- email_address,
78
- project_id,
79
- activity_type,
80
- activity_data,
81
- created_at
82
- ) VALUES ($1, $2, 'standards_upload', $3, NOW())
83
- `, [
84
- email,
85
- project_id,
86
- JSON.stringify({
87
- format,
88
- filename: filename || null,
89
- rules_count: parsed.rules ? parsed.rules.length : 0,
90
- anti_patterns_count: parsed.anti_patterns ? parsed.anti_patterns.length : 0,
91
- category: parsed.category,
92
- id: parsed.id
93
- })
94
- ]);
95
-
96
- return createSuccessResponse({
97
- project_id,
98
- format,
99
- filename: filename || null,
100
- parsed,
101
- summary: {
102
- id: parsed.id,
103
- category: parsed.category,
104
- priority: parsed.priority,
105
- rules_count: parsed.rules ? parsed.rules.length : 0,
106
- anti_patterns_count: parsed.anti_patterns ? parsed.anti_patterns.length : 0,
107
- tags: parsed.tags || []
108
- }
109
- }, `Successfully parsed ${format} content`);
110
-
111
- } catch (error) {
112
- console.error('Standards Parse Upload Error:', error);
113
- return createErrorResponse(500, 'Failed to parse uploaded standards');
114
- }
115
- }
116
-
117
- /**
118
- * Route content to the appropriate parser based on format
119
- *
120
- * @param {string} content - Raw content to parse
121
- * @param {string} format - Format identifier
122
- * @param {Object} options - Parser options
123
- * @returns {Object} Parsed YAML-compatible standards object
124
- */
125
- function parseContent(content, format, options) {
126
- switch (format) {
127
- case 'adr':
128
- return parseAdr(content, options);
129
-
130
- case 'eslint':
131
- return parseEslint(content, options);
132
-
133
- case 'cursorrules':
134
- return parseCursorRules(content, options);
135
-
136
- case 'markdown':
137
- // Markdown format uses the cursor rules parser since it handles
138
- // generic markdown with rule sections effectively
139
- return parseCursorRules(content, {
140
- ...options,
141
- filename: options.filename || 'standards.md'
142
- });
143
-
144
- default:
145
- throw new Error(`Unsupported format: ${format}`);
146
- }
147
- }
148
-
149
- exports.handler = wrapHandler(parseUploadStandards);