@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,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 };