@equilateral_ai/mindmeld 3.5.3 → 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 (139) hide show
  1. package/hooks/session-start.js +312 -85
  2. package/package.json +20 -14
  3. package/scripts/init-project.js +9 -23
  4. package/src/client/dbShim.js +16 -0
  5. package/src/core/AuthManager.js +3 -2
  6. package/src/handlers/helpers/dbOperations.js +9 -46
  7. package/src/index.js +2 -217
  8. package/src/utils/piiMask.js +16 -0
  9. package/scripts/harvest.js +0 -601
  10. package/scripts/inject.js +0 -409
  11. package/scripts/mcp-bridge.js +0 -220
  12. package/scripts/repo-analyzer.js +0 -870
  13. package/scripts/standards.js +0 -285
  14. package/src/collaboration/CollaborationPrompt.js +0 -460
  15. package/src/core/AlertEngine.js +0 -813
  16. package/src/core/AlertNotifier.js +0 -363
  17. package/src/core/CorrelationAnalyzer.js +0 -931
  18. package/src/core/CrossReferenceEngine.js +0 -624
  19. package/src/core/CurationEngine.js +0 -688
  20. package/src/core/DeprecationScheduler.js +0 -183
  21. package/src/core/LoadBearingDetector.js +0 -242
  22. package/src/core/NotificationService.js +0 -1032
  23. package/src/core/RapportOrchestrator.js +0 -632
  24. package/src/core/RelevanceDetector.js +0 -694
  25. package/src/core/StandardLifecycle.js +0 -244
  26. package/src/core/StandardsIngestion.js +0 -991
  27. package/src/core/TeamLoadBearingDetector.js +0 -431
  28. package/src/core/parsers/adrParser.js +0 -479
  29. package/src/core/parsers/cursorRulesParser.js +0 -564
  30. package/src/core/parsers/eslintParser.js +0 -439
  31. package/src/database/dbOperations.js +0 -105
  32. package/src/handlers/activity/activityGetMe.js +0 -98
  33. package/src/handlers/activity/activityGetTeam.js +0 -175
  34. package/src/handlers/admin/adminSetup.js +0 -216
  35. package/src/handlers/alerts/alertsAcknowledge.js +0 -92
  36. package/src/handlers/alerts/alertsGet.js +0 -250
  37. package/src/handlers/analytics/activitySummaryGet.js +0 -234
  38. package/src/handlers/analytics/coachingGet.js +0 -361
  39. package/src/handlers/analytics/convergenceGet.js +0 -236
  40. package/src/handlers/analytics/developerScoreGet.js +0 -137
  41. package/src/handlers/collaborators/collaboratorAdd.js +0 -200
  42. package/src/handlers/collaborators/collaboratorInvite.js +0 -219
  43. package/src/handlers/collaborators/collaboratorList.js +0 -82
  44. package/src/handlers/collaborators/collaboratorRemove.js +0 -128
  45. package/src/handlers/collaborators/inviteAccept.js +0 -122
  46. package/src/handlers/company/companyUsersDelete.js +0 -141
  47. package/src/handlers/company/companyUsersGet.js +0 -90
  48. package/src/handlers/company/companyUsersPost.js +0 -267
  49. package/src/handlers/company/companyUsersPut.js +0 -76
  50. package/src/handlers/context/contextGet.js +0 -57
  51. package/src/handlers/context/invariantsGet.js +0 -74
  52. package/src/handlers/context/loopsGet.js +0 -82
  53. package/src/handlers/context/notesCreate.js +0 -74
  54. package/src/handlers/context/purposeGet.js +0 -78
  55. package/src/handlers/correlations/correlationsDeveloperGet.js +0 -227
  56. package/src/handlers/correlations/correlationsGet.js +0 -93
  57. package/src/handlers/correlations/correlationsProjectGet.js +0 -153
  58. package/src/handlers/enterprise/controlTowerGet.js +0 -224
  59. package/src/handlers/enterprise/enterpriseAuditGet.js +0 -108
  60. package/src/handlers/enterprise/enterpriseContributorsGet.js +0 -85
  61. package/src/handlers/enterprise/enterpriseKnowledgeCategoriesGet.js +0 -53
  62. package/src/handlers/enterprise/enterpriseKnowledgeCreate.js +0 -77
  63. package/src/handlers/enterprise/enterpriseKnowledgeDelete.js +0 -71
  64. package/src/handlers/enterprise/enterpriseKnowledgeGet.js +0 -87
  65. package/src/handlers/enterprise/enterpriseKnowledgeUpdate.js +0 -122
  66. package/src/handlers/enterprise/enterpriseOnboardingComplete.js +0 -77
  67. package/src/handlers/enterprise/enterpriseOnboardingInvite.js +0 -138
  68. package/src/handlers/enterprise/enterpriseOnboardingSetup.js +0 -128
  69. package/src/handlers/enterprise/enterpriseOnboardingStatus.js +0 -88
  70. package/src/handlers/github/githubConnectionStatus.js +0 -49
  71. package/src/handlers/github/githubDiscoverPatterns.js +0 -621
  72. package/src/handlers/github/githubOAuthCallback.js +0 -178
  73. package/src/handlers/github/githubOAuthStart.js +0 -59
  74. package/src/handlers/github/githubPatternsReview.js +0 -76
  75. package/src/handlers/github/githubReposList.js +0 -105
  76. package/src/handlers/health/healthGet.js +0 -55
  77. package/src/handlers/helpers/auditLogger.js +0 -201
  78. package/src/handlers/helpers/checkSuperAdmin.js +0 -84
  79. package/src/handlers/helpers/decisionFrames.js +0 -29
  80. package/src/handlers/helpers/errorHandler.js +0 -49
  81. package/src/handlers/helpers/index.js +0 -138
  82. package/src/handlers/helpers/lambdaWrapper.js +0 -60
  83. package/src/handlers/helpers/mindmeldMcpCore.js +0 -1103
  84. package/src/handlers/helpers/predictiveCache.js +0 -51
  85. package/src/handlers/helpers/projectAccess.js +0 -88
  86. package/src/handlers/helpers/responseUtil.js +0 -55
  87. package/src/handlers/helpers/subscriptionTiers.js +0 -1168
  88. package/src/handlers/mcp/mcpHandler.js +0 -569
  89. package/src/handlers/mcp/mindmeldMcpHandler.js +0 -124
  90. package/src/handlers/mcp/mindmeldMcpStreamHandler.js +0 -342
  91. package/src/handlers/notifications/getPreferences.js +0 -84
  92. package/src/handlers/notifications/sendNotification.js +0 -170
  93. package/src/handlers/notifications/updatePreferences.js +0 -316
  94. package/src/handlers/patterns/patternEvaluatePromotionPost.js +0 -173
  95. package/src/handlers/patterns/patternUsagePost.js +0 -182
  96. package/src/handlers/patterns/patternViolationPost.js +0 -185
  97. package/src/handlers/projects/projectCreate.js +0 -248
  98. package/src/handlers/projects/projectDelete.js +0 -82
  99. package/src/handlers/projects/projectGet.js +0 -95
  100. package/src/handlers/projects/projectUpdate.js +0 -117
  101. package/src/handlers/reports/aiLeverage.js +0 -210
  102. package/src/handlers/reports/engineeringInvestment.js +0 -132
  103. package/src/handlers/reports/riskForecast.js +0 -206
  104. package/src/handlers/reports/standardsRoi.js +0 -254
  105. package/src/handlers/scheduled/analyzeCorrelations.js +0 -178
  106. package/src/handlers/scheduled/analyzeGitHistory.js +0 -510
  107. package/src/handlers/scheduled/generateAlerts.js +0 -135
  108. package/src/handlers/scheduled/maturityUpdateJob.js +0 -166
  109. package/src/handlers/scheduled/refreshActivity.js +0 -21
  110. package/src/handlers/scheduled/scanCompliance.js +0 -334
  111. package/src/handlers/sessions/sessionEndPost.js +0 -180
  112. package/src/handlers/sessions/sessionStandardsPost.js +0 -171
  113. package/src/handlers/standards/catalogGet.js +0 -185
  114. package/src/handlers/standards/catalogSync.js +0 -120
  115. package/src/handlers/standards/discoveriesGet.js +0 -89
  116. package/src/handlers/standards/projectStandardsGet.js +0 -129
  117. package/src/handlers/standards/projectStandardsPut.js +0 -151
  118. package/src/handlers/standards/standardsAuditGet.js +0 -65
  119. package/src/handlers/standards/standardsParseUpload.js +0 -149
  120. package/src/handlers/standards/standardsRelevantPost.js +0 -405
  121. package/src/handlers/standards/standardsTransition.js +0 -161
  122. package/src/handlers/stripe/addonManagePost.js +0 -240
  123. package/src/handlers/stripe/billingPortalPost.js +0 -93
  124. package/src/handlers/stripe/enterpriseCheckoutPost.js +0 -272
  125. package/src/handlers/stripe/seatsUpdatePost.js +0 -185
  126. package/src/handlers/stripe/subscriptionCancelDelete.js +0 -169
  127. package/src/handlers/stripe/subscriptionCreatePost.js +0 -221
  128. package/src/handlers/stripe/subscriptionUpdatePut.js +0 -163
  129. package/src/handlers/stripe/webhookPost.js +0 -482
  130. package/src/handlers/user/apiTokenCreate.js +0 -71
  131. package/src/handlers/user/apiTokenList.js +0 -64
  132. package/src/handlers/user/userSplashAck.js +0 -91
  133. package/src/handlers/user/userSplashGet.js +0 -211
  134. package/src/handlers/users/cognitoPostConfirmation.js +0 -186
  135. package/src/handlers/users/cognitoPreSignUp.js +0 -114
  136. package/src/handlers/users/userEntitlementsGet.js +0 -89
  137. package/src/handlers/users/userGet.js +0 -118
  138. package/src/handlers/users/userProfilePut.js +0 -77
  139. package/src/handlers/webhooks/githubWebhook.js +0 -215
@@ -1,244 +0,0 @@
1
- /**
2
- * StandardLifecycle.js - State Machine for Standard Lifecycle
3
- *
4
- * Manages the full lifecycle of standards from discovery through deletion.
5
- *
6
- * States: discovery -> proposed -> active -> disabled -> deprecated -> deleted
7
- *
8
- * Valid transitions:
9
- * discovery -> proposed (when confidence > threshold)
10
- * proposed -> active (user approves)
11
- * proposed -> deleted (user rejects)
12
- * active -> disabled (user disables temporarily)
13
- * active -> deprecated (scheduled for removal)
14
- * disabled -> active (user re-enables)
15
- * deprecated -> deleted (after grace period)
16
- * deprecated -> active (user cancels deprecation)
17
- *
18
- * Records every transition in standards_audit_trail table.
19
- */
20
-
21
- const { executeQuery } = require('../handlers/helpers/dbOperations');
22
-
23
- /**
24
- * All valid lifecycle states
25
- */
26
- const STATES = {
27
- DISCOVERY: 'discovery',
28
- PROPOSED: 'proposed',
29
- ACTIVE: 'active',
30
- DISABLED: 'disabled',
31
- DEPRECATED: 'deprecated',
32
- DELETED: 'deleted'
33
- };
34
-
35
- /**
36
- * All valid transition actions and their from -> to mappings
37
- */
38
- const TRANSITIONS = {
39
- propose: { from: STATES.DISCOVERY, to: STATES.PROPOSED },
40
- approve: { from: STATES.PROPOSED, to: STATES.ACTIVE },
41
- reject: { from: STATES.PROPOSED, to: STATES.DELETED },
42
- disable: { from: STATES.ACTIVE, to: STATES.DISABLED },
43
- deprecate: { from: STATES.ACTIVE, to: STATES.DEPRECATED },
44
- enable: { from: STATES.DISABLED, to: STATES.ACTIVE },
45
- delete: { from: STATES.DEPRECATED, to: STATES.DELETED },
46
- cancel_deprecation: { from: STATES.DEPRECATED, to: STATES.ACTIVE }
47
- };
48
-
49
- class StandardLifecycle {
50
- constructor(config = {}) {
51
- this.config = {
52
- confidenceThreshold: config.confidenceThreshold || 0.80,
53
- ...config
54
- };
55
- }
56
-
57
- /**
58
- * Execute a state transition for a standard
59
- *
60
- * @param {string} standardId - The standard identifier
61
- * @param {string} action - The transition action to perform
62
- * @param {string} userId - Email of the user performing the action
63
- * @param {string} reason - Optional reason for the transition
64
- * @returns {Promise<Object>} The transition result with new state and audit entry
65
- */
66
- async transition(standardId, action, userId, reason) {
67
- // Validate action exists
68
- const transitionDef = TRANSITIONS[action];
69
- if (!transitionDef) {
70
- const validActions = Object.keys(TRANSITIONS);
71
- throw new Error(`Invalid action '${action}'. Valid actions: ${validActions.join(', ')}`);
72
- }
73
-
74
- // Get current state of the standard
75
- const currentState = await this.getCurrentState(standardId);
76
-
77
- if (!currentState) {
78
- throw new Error(`Standard '${standardId}' not found`);
79
- }
80
-
81
- // Validate the transition is allowed from the current state
82
- if (currentState !== transitionDef.from) {
83
- throw new Error(
84
- `Cannot perform '${action}' on standard in '${currentState}' state. ` +
85
- `Action '${action}' requires state '${transitionDef.from}'.`
86
- );
87
- }
88
-
89
- const oldState = currentState;
90
- const newState = transitionDef.to;
91
-
92
- // Update the standard's lifecycle state
93
- await executeQuery(`
94
- UPDATE rapport.patterns
95
- SET lifecycle_state = $2
96
- WHERE pattern_id = $1
97
- `, [standardId, newState]);
98
-
99
- // Record the transition in the audit trail
100
- const auditResult = await executeQuery(`
101
- INSERT INTO rapport.standards_audit_trail (
102
- standard_id,
103
- project_id,
104
- action,
105
- old_state,
106
- new_state,
107
- user_email,
108
- reason,
109
- metadata,
110
- created_at
111
- ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW())
112
- RETURNING id, standard_id, action, old_state, new_state, user_email, reason, created_at
113
- `, [
114
- standardId,
115
- null,
116
- action,
117
- oldState,
118
- newState,
119
- userId,
120
- reason || null,
121
- JSON.stringify({})
122
- ]);
123
-
124
- const auditEntry = auditResult.rows[0];
125
-
126
- console.log(`[StandardLifecycle] ${standardId}: ${oldState} -> ${newState} (${action}) by ${userId}`);
127
-
128
- return {
129
- standard_id: standardId,
130
- old_state: oldState,
131
- new_state: newState,
132
- action: action,
133
- audit_entry: auditEntry
134
- };
135
- }
136
-
137
- /**
138
- * Get valid transitions available from the current state
139
- *
140
- * @param {string} currentState - The current lifecycle state
141
- * @returns {Array<Object>} Available actions with their target states
142
- */
143
- getValidTransitions(currentState) {
144
- const valid = [];
145
-
146
- for (const [action, def] of Object.entries(TRANSITIONS)) {
147
- if (def.from === currentState) {
148
- valid.push({
149
- action: action,
150
- from: def.from,
151
- to: def.to
152
- });
153
- }
154
- }
155
-
156
- return valid;
157
- }
158
-
159
- /**
160
- * Get the full audit trail for a standard
161
- *
162
- * @param {string} standardId - The standard identifier
163
- * @param {Object} options - Pagination options
164
- * @param {string} options.cursor - Cursor for pagination (audit trail id)
165
- * @param {number} options.limit - Number of records to return (default 50)
166
- * @returns {Promise<Object>} Audit trail with entries and pagination info
167
- */
168
- async getHistory(standardId, options = {}) {
169
- const limit = Math.min(parseInt(options.limit) || 50, 200);
170
- const cursor = options.cursor ? parseInt(options.cursor) : null;
171
-
172
- let query = `
173
- SELECT
174
- id,
175
- standard_id,
176
- project_id,
177
- action,
178
- old_state,
179
- new_state,
180
- user_email,
181
- reason,
182
- metadata,
183
- created_at
184
- FROM rapport.standards_audit_trail
185
- WHERE standard_id = $1
186
- `;
187
-
188
- const params = [standardId];
189
- let paramIndex = 2;
190
-
191
- if (cursor) {
192
- query += ` AND id < $${paramIndex}`;
193
- params.push(cursor);
194
- paramIndex++;
195
- }
196
-
197
- query += ` ORDER BY created_at DESC, id DESC LIMIT $${paramIndex}`;
198
- params.push(limit + 1); // Fetch one extra to determine if there are more
199
-
200
- const result = await executeQuery(query, params);
201
-
202
- const hasMore = result.rows.length > limit;
203
- const entries = hasMore ? result.rows.slice(0, limit) : result.rows;
204
- const nextCursor = hasMore ? entries[entries.length - 1].id : null;
205
-
206
- // Get total count
207
- const countResult = await executeQuery(`
208
- SELECT COUNT(*) as total
209
- FROM rapport.standards_audit_trail
210
- WHERE standard_id = $1
211
- `, [standardId]);
212
-
213
- const totalTransitions = parseInt(countResult.rows[0].total);
214
-
215
- return {
216
- entries: entries,
217
- total_transitions: totalTransitions,
218
- has_more: hasMore,
219
- next_cursor: nextCursor ? String(nextCursor) : null
220
- };
221
- }
222
-
223
- /**
224
- * Get the current lifecycle state of a standard
225
- *
226
- * @param {string} standardId - The standard identifier
227
- * @returns {Promise<string|null>} Current state or null if not found
228
- */
229
- async getCurrentState(standardId) {
230
- const result = await executeQuery(`
231
- SELECT lifecycle_state
232
- FROM rapport.patterns
233
- WHERE pattern_id = $1
234
- `, [standardId]);
235
-
236
- if (result.rowCount === 0) {
237
- return null;
238
- }
239
-
240
- return result.rows[0].lifecycle_state || STATES.ACTIVE;
241
- }
242
- }
243
-
244
- module.exports = { StandardLifecycle, STATES, TRANSITIONS };