@equilateral_ai/mindmeld 3.5.0 → 3.5.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.
@@ -6,7 +6,9 @@
6
6
  * when no auth token is found. Opens browser for Cognito PKCE login,
7
7
  * waits for callback, saves tokens to ~/.mindmeld/auth.json.
8
8
  *
9
- * Reads .myworld.json from CWD to detect dev vs prod Cognito pool.
9
+ * Uses .mindmeld/config.json or .myworld.json (consumer projects only) for
10
+ * Cognito config. When running inside the MindMeld source repo, skips
11
+ * .myworld.json dev config and uses production defaults.
10
12
  *
11
13
  * Usage:
12
14
  * node scripts/auth-login.js
@@ -19,23 +21,58 @@ const path = require('path');
19
21
  const { AuthManager } = require('../src/core/AuthManager');
20
22
 
21
23
  /**
22
- * Load Cognito config from .myworld.json if present
24
+ * Detect if we're running inside the MindMeld source repository
23
25
  */
24
- function loadCognitoConfig() {
26
+ function isMindMeldSourceRepo() {
25
27
  try {
26
28
  const configPath = path.join(process.cwd(), '.myworld.json');
27
29
  const content = fs.readFileSync(configPath, 'utf-8');
28
30
  const config = JSON.parse(content);
29
- const auth = config.deployments?.backend?.auth;
30
- if (auth?.domain && auth?.client_id) {
31
+ return (config.project?.product || '').toLowerCase() === 'mindmeld';
32
+ } catch (error) {
33
+ return false;
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Load Cognito config — .mindmeld/config.json first, then .myworld.json
39
+ * for consumer projects only. MindMeld source repo uses production defaults.
40
+ */
41
+ function loadCognitoConfig() {
42
+ // 1. Explicit project config (always wins)
43
+ try {
44
+ const mindmeldConfigPath = path.join(process.cwd(), '.mindmeld', 'config.json');
45
+ const content = fs.readFileSync(mindmeldConfigPath, 'utf-8');
46
+ const config = JSON.parse(content);
47
+ if (config.auth?.cognitoDomain && config.auth?.cognitoClientId) {
31
48
  return {
32
- cognitoDomain: `${auth.domain}.auth.us-east-2.amazoncognito.com`,
33
- cognitoClientId: auth.client_id
49
+ cognitoDomain: config.auth.cognitoDomain,
50
+ cognitoClientId: config.auth.cognitoClientId
34
51
  };
35
52
  }
36
53
  } catch (error) {
37
- // No .myworld.json use production defaults
54
+ // No .mindmeld/config.json or no auth section
38
55
  }
56
+
57
+ // 2. .myworld.json — only for consumer projects
58
+ if (!isMindMeldSourceRepo()) {
59
+ try {
60
+ const configPath = path.join(process.cwd(), '.myworld.json');
61
+ const content = fs.readFileSync(configPath, 'utf-8');
62
+ const config = JSON.parse(content);
63
+ const auth = config.deployments?.backend?.auth;
64
+ if (auth?.domain && auth?.client_id) {
65
+ return {
66
+ cognitoDomain: `${auth.domain}.auth.us-east-2.amazoncognito.com`,
67
+ cognitoClientId: auth.client_id
68
+ };
69
+ }
70
+ } catch (error) {
71
+ // No .myworld.json
72
+ }
73
+ }
74
+
75
+ // 3. Production defaults (AuthManager has these built-in)
39
76
  return {};
40
77
  }
41
78
 
@@ -921,7 +921,9 @@ class StandardsIngestion {
921
921
  examples = EXCLUDED.examples,
922
922
  cost_impact = EXCLUDED.cost_impact,
923
923
  keywords = EXCLUDED.keywords,
924
- last_updated = NOW()
924
+ last_updated = NOW(),
925
+ last_seen_at = NOW(),
926
+ occurrence_count = COALESCE(rapport.standards_patterns.occurrence_count, 0) + 1
925
927
  `, [
926
928
  pattern.pattern_id,
927
929
  pattern.file_name,
@@ -6,7 +6,7 @@
6
6
  * Auth: Cognito JWT required
7
7
  */
8
8
 
9
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, handleError } = require('./helpers');
9
+ const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, handleError, verifyProjectAccess } = require('./helpers');
10
10
 
11
11
  /**
12
12
  * List project collaborators
@@ -26,15 +26,9 @@ async function listCollaborators({ queryStringParameters: queryParams = {}, requ
26
26
  return createErrorResponse(400, 'projectId is required');
27
27
  }
28
28
 
29
- // Check user has access to project
30
- const accessQuery = `
31
- SELECT pc.role
32
- FROM rapport.project_collaborators pc
33
- WHERE pc.project_id = $1 AND pc.email_address = $2
34
- `;
35
- const accessCheck = await executeQuery(accessQuery, [projectId, email]);
36
-
37
- if (accessCheck.rowCount === 0) {
29
+ // Verify user has access to project (collaborator or company member)
30
+ const projectAccess = await verifyProjectAccess(projectId, email);
31
+ if (!projectAccess) {
38
32
  return createErrorResponse(403, 'You do not have access to this project');
39
33
  }
40
34
 
@@ -13,7 +13,7 @@
13
13
  * - Pattern effectiveness for project
14
14
  */
15
15
 
16
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse } = require('./helpers');
16
+ const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, verifyProjectAccess } = require('./helpers');
17
17
  const { CorrelationAnalyzer } = require('./core/CorrelationAnalyzer');
18
18
 
19
19
  exports.handler = wrapHandler(async (event, context) => {
@@ -33,21 +33,12 @@ exports.handler = wrapHandler(async (event, context) => {
33
33
  const queryParams = event.queryStringParameters || {};
34
34
  const lookbackDays = parseInt(queryParams.lookbackDays) || 30;
35
35
 
36
- // Verify user has access to this project
37
- const accessResult = await executeQuery(`
38
- SELECT p.project_id, p.project_name, p.company_id
39
- FROM rapport.projects p
40
- JOIN rapport.project_collaborators pc ON p.project_id = pc.project_id
41
- WHERE p.project_id = $1
42
- AND pc.email_address = $2
43
- `, [projectId, email]);
44
-
45
- if (accessResult.rows.length === 0) {
36
+ // Verify user has access to this project (collaborator or company member)
37
+ const project = await verifyProjectAccess(projectId, email);
38
+ if (!project) {
46
39
  return createErrorResponse(403, 'Access denied to this project');
47
40
  }
48
41
 
49
- const project = accessResult.rows[0];
50
-
51
42
  // Initialize analyzer
52
43
  const analyzer = new CorrelationAnalyzer();
53
44
 
@@ -12,7 +12,7 @@
12
12
  * - Maps tech stack to relevant YAML standards categories
13
13
  */
14
14
 
15
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse } = require('./helpers');
15
+ const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, verifyProjectAccess } = require('./helpers');
16
16
  const { LLMPatternDetector } = require('./core/LLMPatternDetector');
17
17
  const crypto = require('crypto');
18
18
  const https = require('https');
@@ -247,13 +247,9 @@ async function githubDiscoverPatterns({ body, requestContext }) {
247
247
 
248
248
  const targetBranch = branch || 'main';
249
249
 
250
- // Verify user has access to project
251
- const accessResult = await executeQuery(`
252
- SELECT role FROM rapport.project_collaborators
253
- WHERE project_id = $1 AND email_address = $2
254
- `, [project_id, email]);
255
-
256
- if (accessResult.rowCount === 0) {
250
+ // Verify user has access to project (collaborator or company member)
251
+ const projectAccess = await verifyProjectAccess(project_id, email);
252
+ if (!projectAccess) {
257
253
  return createErrorResponse(403, 'Access denied to project');
258
254
  }
259
255
 
@@ -6,7 +6,7 @@
6
6
  * Body: { project_id, approvals: [{ discovery_id, approved }] }
7
7
  */
8
8
 
9
- const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse } = require('./helpers');
9
+ const { wrapHandler, executeQuery, createSuccessResponse, createErrorResponse, verifyProjectAccess } = require('./helpers');
10
10
 
11
11
  async function githubPatternsReview({ body, requestContext }) {
12
12
  try {
@@ -21,13 +21,9 @@ async function githubPatternsReview({ body, requestContext }) {
21
21
  return createErrorResponse(400, 'project_id and approvals array are required');
22
22
  }
23
23
 
24
- // Verify user has access to project
25
- const accessResult = await executeQuery(`
26
- SELECT role FROM rapport.project_collaborators
27
- WHERE project_id = $1 AND email_address = $2
28
- `, [project_id, email]);
29
-
30
- if (accessResult.rowCount === 0) {
24
+ // Verify user has access to project (collaborator or company member)
25
+ const projectAccess = await verifyProjectAccess(project_id, email);
26
+ if (!projectAccess) {
31
27
  return createErrorResponse(403, 'Access denied to project');
32
28
  }
33
29
 
@@ -0,0 +1,29 @@
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 };
@@ -44,6 +44,9 @@ const {
44
44
  getAddonPriceId
45
45
  } = require('./subscriptionTiers');
46
46
  const checkSuperAdmin = require('./checkSuperAdmin');
47
+ const { verifyProjectAccess, verifyProjectRole } = require('./projectAccess');
48
+ const { getPredictedStandards, logStandardsActivation } = require('./predictiveCache');
49
+ const { createFrame, getFrame, getProjectFrames } = require('./decisionFrames');
47
50
  const {
48
51
  AuditEventType,
49
52
  EntityType,
@@ -112,6 +115,17 @@ module.exports = {
112
115
 
113
116
  // Authorization
114
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,
115
129
 
116
130
  // Audit logging
117
131
  AuditEventType,