@10kdevs/matha
Advanced tools
+63
-10
@@ -6,3 +6,3 @@ import * as fs from 'fs/promises'; | ||
| import { getRules, getDangerZones, getDecisions, recordDecision, recordDangerZone, } from '../brain/hippocampus.js'; | ||
| import { refreshFromGit, getStability, getSnapshot, } from '../brain/cortex.js'; | ||
| import { refreshFromGit, getSnapshot, } from '../brain/cortex.js'; | ||
| import { matchAll } from '../analysis/contract-matcher.js'; | ||
@@ -61,10 +61,31 @@ import { analyseDeltas, persistAnalysis, getRecommendation } from '../brain/dopamine.js'; | ||
| try { | ||
| const stability = await getStability(mathaDir, files); | ||
| const snapshot = await getSnapshot(mathaDir); | ||
| const allRecords = snapshot?.stability || []; | ||
| const stability = {}; | ||
| for (const file of files) { | ||
| const cleanFile = file.replace(/^\/+/, '').toLowerCase(); | ||
| const match = allRecords.find((r) => r.filepath.replace(/^\/+/, '').toLowerCase() === cleanFile); | ||
| if (match) { | ||
| stability[file] = match; | ||
| } | ||
| else { | ||
| stability[file] = { | ||
| filepath: file, | ||
| stability: 'unknown', | ||
| confidence: 'low', | ||
| reason: 'No git history found for this file' | ||
| }; | ||
| } | ||
| } | ||
| return JSON.stringify({ stability }); | ||
| } | ||
| catch (err) { | ||
| // On any error, return null for all | ||
| const stability = {}; | ||
| for (const file of files) { | ||
| stability[file] = null; | ||
| stability[file] = { | ||
| filepath: file, | ||
| stability: 'unknown', | ||
| confidence: 'low', | ||
| reason: 'No git history found for this file' | ||
| }; | ||
| } | ||
@@ -173,4 +194,3 @@ return JSON.stringify({ stability }); | ||
| const intent = await readJsonOrNull(intentPath); | ||
| const rules = await getRules(mathaDir).catch(() => []); | ||
| const parsedRules = typeof rules === 'string' ? JSON.parse(rules).rules : []; | ||
| const parsedRules = await getRules(mathaDir).catch(() => []); | ||
| baseResponse = { | ||
@@ -182,7 +202,8 @@ why: intent?.why ?? '', | ||
| // Augment with matchAll | ||
| const usedScope = baseResponse.scope || scope || ''; | ||
| const matchContext = { | ||
| scope: baseResponse.scope || '', | ||
| intent: baseResponse.operation_description || baseResponse.why || '', | ||
| scope: usedScope, | ||
| intent: baseResponse.operation_description || baseResponse.why || ('reviewing project context for ' + (usedScope || 'general work')), | ||
| operationType: baseResponse.operationType || 'unknown', | ||
| filepaths: (baseResponse.scope || '').split(',').map((s) => s.trim()).filter(Boolean), | ||
| filepaths: usedScope ? usedScope.split(',').map((s) => s.trim()).filter(Boolean) : [], | ||
| }; | ||
@@ -322,5 +343,37 @@ let matchResults = []; | ||
| catch (err) { | ||
| return JSON.stringify({ error: `Failed to run contract matcher: ${err.message}`, results: [], hasCritical: false }); | ||
| return JSON.stringify({ | ||
| error: `Failed to run contract matcher: ${err.message}`, | ||
| results: [], | ||
| hasCritical: false, | ||
| summary: { critical: 0, warning: 0, info: 0, total: 0 } | ||
| }); | ||
| } | ||
| } | ||
| export const mathaMatchToolDefinition = { | ||
| name: 'matha_match', | ||
| description: 'Matches current operation context against all known danger zones, contracts, frozen files, and prior decisions. Call this before making any changes to understand what the brain knows about this area. Returns critical warnings, prior findings, and contract context.', | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| scope: { | ||
| type: 'string', | ||
| description: 'Files or components being changed (comma-separated)' | ||
| }, | ||
| intent: { | ||
| type: 'string', | ||
| description: 'What you are trying to do' | ||
| }, | ||
| operationType: { | ||
| type: 'string', | ||
| description: 'Operation type: rename/crud, business_logic, architecture, frozen_component, unknown' | ||
| }, | ||
| filepaths: { | ||
| type: 'array', | ||
| items: { type: 'string' }, | ||
| description: 'Specific files that will be modified' | ||
| } | ||
| }, | ||
| required: ['scope', 'intent'] | ||
| } | ||
| }; | ||
| /** | ||
@@ -327,0 +380,0 @@ * matha_get_routing: Close the Dopamine Loop. |
+1
-1
| { | ||
| "name": "@10kdevs/matha", | ||
| "version": "0.1.6", | ||
| "version": "0.1.7", | ||
| "description": "The persistent cognitive layer for AI-assisted development. Gives AI agents the project context that currently only exists inside a senior engineer's head.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
156003
1.32%3640
1.48%