feat: v0.57.0 - rename CLI to brainy and Neural Import to Cortex

BREAKING CHANGES:
- CLI command renamed from 'cortex' to 'brainy'
- Neural Import renamed to Cortex augmentation
- Class CortexSenseAugmentation (was NeuralImportSenseAugmentation)

Benefits:
- npx @soulcraft/brainy now works automatically
- Better conceptual clarity: Cortex = AI intelligence layer
- Cleaner architecture: CLI = brainy, AI = Cortex, DB = BrainyData
This commit is contained in:
David Snelling 2025-08-07 20:13:02 -07:00
parent 27ce6c242d
commit bd39b71fbf
9 changed files with 136 additions and 88 deletions

View file

@ -1,7 +1,7 @@
/**
* Neural Import SENSE Augmentation - Atomic Age AI-Powered Data Understanding
* Cortex SENSE Augmentation - Atomic Age AI-Powered Data Understanding
*
* 🧠 The brain-in-jar's sensory system for perceiving and structuring data
* 🧠 The cerebral cortex layer for intelligent data processing
* Complete with confidence scoring and relationship weight calculation
*/
@ -11,12 +11,12 @@ import { NounType, VerbType } from '../types/graphTypes.js'
import * as fs from 'fs/promises'
import * as path from 'path'
// Neural Import Types
export interface NeuralAnalysisResult {
// Cortex Analysis Types
export interface CortexAnalysisResult {
detectedEntities: DetectedEntity[]
detectedRelationships: DetectedRelationship[]
confidence: number
insights: NeuralInsight[]
insights: CortexInsight[]
}
export interface DetectedEntity {
@ -39,7 +39,7 @@ export interface DetectedRelationship {
metadata?: Record<string, any>
}
export interface NeuralInsight {
export interface CortexInsight {
type: 'hierarchy' | 'cluster' | 'pattern' | 'anomaly' | 'opportunity'
description: string
confidence: number
@ -47,7 +47,7 @@ export interface NeuralInsight {
recommendation?: string
}
export interface NeuralImportSenseConfig {
export interface CortexSenseConfig {
confidenceThreshold: number
enableWeights: boolean
skipDuplicates: boolean
@ -57,15 +57,15 @@ export interface NeuralImportSenseConfig {
/**
* Neural Import SENSE Augmentation - The Brain's Perceptual System
*/
export class NeuralImportSenseAugmentation implements ISenseAugmentation {
readonly name: string = 'neural-import-sense'
readonly description: string = 'AI-powered data understanding and structuring augmentation'
export class CortexSenseAugmentation implements ISenseAugmentation {
readonly name: string = 'cortex-sense'
readonly description: string = 'AI-powered cortex for intelligent data understanding'
enabled: boolean = true
private brainy: BrainyData
private config: NeuralImportSenseConfig
private config: CortexSenseConfig
constructor(brainy: BrainyData, config: Partial<NeuralImportSenseConfig> = {}) {
constructor(brainy: BrainyData, config: Partial<CortexSenseConfig> = {}) {
this.brainy = brainy
this.config = {
confidenceThreshold: 0.7,
@ -76,8 +76,8 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
}
async initialize(): Promise<void> {
// Initialize the neural analysis system
console.log('🧠 Neural Import SENSE augmentation initialized')
// Initialize the cortex analysis system
console.log('🧠 Cortex SENSE augmentation initialized')
}
async shutDown(): Promise<void> {
@ -125,7 +125,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
nouns,
verbs,
confidence: analysis.confidence,
insights: analysis.insights.map(insight => ({
insights: analysis.insights.map((insight: any) => ({
type: insight.type,
description: insight.description,
confidence: insight.confidence
@ -286,7 +286,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
const suggestions: string[] = []
// Check for low confidence entities
const lowConfidenceEntities = analysis.detectedEntities.filter(e => e.confidence < 0.5)
const lowConfidenceEntities = analysis.detectedEntities.filter((e: any) => e.confidence < 0.5)
if (lowConfidenceEntities.length > 0) {
issues.push({
type: 'confidence',
@ -318,7 +318,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
}
// Check for data completeness
const incompleteEntities = analysis.detectedEntities.filter(e =>
const incompleteEntities = analysis.detectedEntities.filter((e: any) =>
!e.originalData || Object.keys(e.originalData).length < 2
)
if (incompleteEntities.length > 0) {
@ -360,7 +360,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
/**
* Get the full neural analysis result (custom method for Cortex integration)
*/
async getNeuralAnalysis(rawData: Buffer | string, dataType: string): Promise<NeuralAnalysisResult> {
async getNeuralAnalysis(rawData: Buffer | string, dataType: string): Promise<CortexAnalysisResult> {
const parsedData = await this.parseRawData(rawData, dataType)
return await this.performNeuralAnalysis(parsedData)
}
@ -421,7 +421,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
/**
* Perform neural analysis on parsed data
*/
private async performNeuralAnalysis(parsedData: any[], config = this.config): Promise<NeuralAnalysisResult> {
private async performNeuralAnalysis(parsedData: any[], config = this.config): Promise<CortexAnalysisResult> {
// Phase 1: Neural Entity Detection
const detectedEntities = await this.detectEntitiesWithNeuralAnalysis(parsedData, config)
@ -429,7 +429,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
const detectedRelationships = await this.detectRelationshipsWithNeuralAnalysis(detectedEntities, parsedData, config)
// Phase 3: Neural Insights Generation
const insights = await this.generateNeuralInsights(detectedEntities, detectedRelationships)
const insights = await this.generateCortexInsights(detectedEntities, detectedRelationships)
// Phase 4: Confidence Scoring
const overallConfidence = this.calculateOverallConfidence(detectedEntities, detectedRelationships)
@ -698,8 +698,8 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
/**
* Generate Neural Insights - The Intelligence Layer
*/
private async generateNeuralInsights(entities: DetectedEntity[], relationships: DetectedRelationship[]): Promise<NeuralInsight[]> {
const insights: NeuralInsight[] = []
private async generateCortexInsights(entities: DetectedEntity[], relationships: DetectedRelationship[]): Promise<CortexInsight[]> {
const insights: CortexInsight[] = []
// Detect hierarchies
const hierarchies = this.detectHierarchies(relationships)
@ -842,13 +842,13 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
private calculateOverallConfidence(entities: DetectedEntity[], relationships: DetectedRelationship[]): number {
if (entities.length === 0) return 0
const entityConfidence = entities.reduce((sum, e) => sum + e.confidence, 0) / entities.length
const entityConfidence = entities.reduce((sum: number, e: any) => sum + e.confidence, 0) / entities.length
if (relationships.length === 0) return entityConfidence
const relationshipConfidence = relationships.reduce((sum, r) => sum + r.confidence, 0) / relationships.length
const relationshipConfidence = relationships.reduce((sum: number, r: any) => sum + r.confidence, 0) / relationships.length
return (entityConfidence + relationshipConfidence) / 2
}
private async storeNeuralAnalysis(analysis: NeuralAnalysisResult): Promise<void> {
private async storeNeuralAnalysis(analysis: CortexAnalysisResult): Promise<void> {
// Store the full analysis result for later retrieval by Cortex or other systems
// This could be stored in the brainy instance metadata or a separate analysis store
}
@ -886,7 +886,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
/**
* Assess data quality metrics
*/
private assessDataQuality(parsedData: any[], analysis: NeuralAnalysisResult): {
private assessDataQuality(parsedData: any[], analysis: CortexAnalysisResult): {
completeness: number
consistency: number
accuracy: number
@ -921,7 +921,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
// Accuracy: average confidence of detected entities
const accuracy = analysis.detectedEntities.length > 0 ?
analysis.detectedEntities.reduce((sum, e) => sum + e.confidence, 0) / analysis.detectedEntities.length :
analysis.detectedEntities.reduce((sum: number, e: any) => sum + e.confidence, 0) / analysis.detectedEntities.length :
0
return {
@ -936,7 +936,7 @@ export class NeuralImportSenseAugmentation implements ISenseAugmentation {
*/
private generateRecommendations(
parsedData: any[],
analysis: NeuralAnalysisResult,
analysis: CortexAnalysisResult,
entityTypes: Array<{ type: string; count: number; confidence: number }>,
relationshipTypes: Array<{ type: string; count: number; confidence: number }>
): string[] {

View file

@ -1893,14 +1893,14 @@ export class Cortex {
}
/**
* Neural Import System - AI-Powered Data Understanding
* Cortex Augmentation System - AI-Powered Data Understanding
*/
async neuralImport(filePath: string, options: any = {}): Promise<void> {
await this.ensureInitialized()
// Import and create the Neural Import SENSE augmentation
const { NeuralImportSenseAugmentation } = await import('../augmentations/neuralImportSense.js')
const neuralSense = new NeuralImportSenseAugmentation(this.brainy!, options)
// Import and create the Cortex SENSE augmentation
const { CortexSenseAugmentation } = await import('../augmentations/cortexSense.js')
const neuralSense = new CortexSenseAugmentation(this.brainy!, options)
// Initialize the augmentation
await neuralSense.initialize()
@ -1915,7 +1915,7 @@ export class Cortex {
const result = await neuralSense.processRawData(fileContent, dataType, options)
if (result.success) {
console.log(colors.success('✅ Neural import completed successfully'))
console.log(colors.success('✅ Cortex import completed successfully'))
// Display summary
console.log(colors.primary(`📊 Processed: ${result.data.nouns.length} entities, ${result.data.verbs.length} relationships`))
@ -1926,12 +1926,12 @@ export class Cortex {
if (result.data.insights && result.data.insights.length > 0) {
console.log(colors.brain('\n🧠 Neural Insights:'))
result.data.insights.forEach(insight => {
result.data.insights.forEach((insight: any) => {
console.log(` ${colors.accent('◆')} ${insight.description} (${(insight.confidence * 100).toFixed(1)}%)`)
})
}
} else {
console.error(colors.error('❌ Neural import failed:'), result.error)
console.error(colors.error('❌ Cortex import failed:'), result.error)
}
} finally {
@ -1942,8 +1942,8 @@ export class Cortex {
async neuralAnalyze(filePath: string): Promise<void> {
await this.ensureInitialized()
const { NeuralImportSenseAugmentation } = await import('../augmentations/neuralImportSense.js')
const neuralSense = new NeuralImportSenseAugmentation(this.brainy!)
const { CortexSenseAugmentation } = await import('../augmentations/cortexSense.js')
const neuralSense = new CortexSenseAugmentation(this.brainy!)
await neuralSense.initialize()
@ -1966,7 +1966,7 @@ export class Cortex {
if (result.data.recommendations.length > 0) {
console.log(colors.brain('\n💡 Recommendations:'))
result.data.recommendations.forEach(rec => {
result.data.recommendations.forEach((rec: any) => {
console.log(` ${colors.accent('◆')} ${rec}`)
})
}
@ -1982,8 +1982,8 @@ export class Cortex {
async neuralValidate(filePath: string): Promise<void> {
await this.ensureInitialized()
const { NeuralImportSenseAugmentation } = await import('../augmentations/neuralImportSense.js')
const neuralSense = new NeuralImportSenseAugmentation(this.brainy!)
const { CortexSenseAugmentation } = await import('../augmentations/cortexSense.js')
const neuralSense = new CortexSenseAugmentation(this.brainy!)
await neuralSense.initialize()
@ -2009,7 +2009,7 @@ export class Cortex {
if (result.data.issues.length > 0) {
console.log(colors.warning('\n⚠ Issues:'))
result.data.issues.forEach(issue => {
result.data.issues.forEach((issue: any) => {
const severityColor = issue.severity === 'high' ? colors.error :
issue.severity === 'medium' ? colors.warning : colors.dim
console.log(` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.description}`)
@ -2018,7 +2018,7 @@ export class Cortex {
if (result.data.suggestions.length > 0) {
console.log(colors.brain('\n💡 Suggestions:'))
result.data.suggestions.forEach(suggestion => {
result.data.suggestions.forEach((suggestion: any) => {
console.log(` ${colors.accent('◆')} ${suggestion}`)
})
}
@ -2056,7 +2056,7 @@ export class Cortex {
console.log(` ${colors.primary('•')} ${key}: ${colors.dim(value)}`)
})
console.log(`\n${colors.dim('Use')} ${colors.primary('cortex neural import <file>')} ${colors.dim('to leverage the full type system!')}`)
console.log(`\n${colors.dim('Use')} ${colors.primary('brainy import --cortex <file>')} ${colors.dim('to leverage the full AI type system!')}`)
}
/**
@ -2349,15 +2349,15 @@ export class Cortex {
const { DefaultAugmentationRegistry } = await import('../shared/default-augmentations.js')
const registry = new DefaultAugmentationRegistry(this.brainy!)
// Check Neural Import health (default augmentation)
const neuralHealth = await registry.checkNeuralImportHealth()
// Check Cortex health (default augmentation)
const cortexHealth = await registry.checkCortexHealth()
console.log(`\n${this.emojis.sparkles} ${this.colors.accent('Default Augmentations:')}`)
console.log(` ${this.emojis.brain} Neural Import: ${neuralHealth.available ? this.colors.success('Active') : this.colors.error('Inactive')}`)
if (neuralHealth.version) {
console.log(` ${this.colors.dim('Version:')} ${neuralHealth.version}`)
console.log(` ${this.emojis.brain} Cortex: ${cortexHealth.available ? this.colors.success('Active') : this.colors.error('Inactive')}`)
if (cortexHealth.version) {
console.log(` ${this.colors.dim('Version:')} ${cortexHealth.version}`)
}
console.log(` ${this.colors.dim('Status:')} ${neuralHealth.status}`)
console.log(` ${this.colors.dim('Status:')} ${cortexHealth.status}`)
console.log(` ${this.colors.dim('Category:')} SENSE (AI-powered data understanding)`)
console.log(` ${this.colors.dim('License:')} Open Source (included by default)`)
@ -2386,7 +2386,7 @@ export class Cortex {
// Augmentation pipeline health
console.log(`\n${this.emojis.health} ${this.colors.accent('Pipeline Health:')}`)
console.log(` ${this.emojis.check} SENSE Pipeline: ${this.colors.success('1 active')} (Neural Import)`)
console.log(` ${this.emojis.check} SENSE Pipeline: ${this.colors.success('1 active')} (Cortex)`)
console.log(` ${this.emojis.info} CONDUIT Pipeline: ${this.colors.dim('0 active')} (Premium connectors available)`)
console.log(` ${this.emojis.info} COGNITION Pipeline: ${this.colors.dim('0 active')}`)
console.log(` ${this.emojis.info} MEMORY Pipeline: ${this.colors.dim('0 active')}`)

View file

@ -25,25 +25,25 @@ export class DefaultAugmentationRegistry {
async initializeDefaults(): Promise<void> {
console.log('🧠⚛️ Initializing default augmentations...')
// Register Neural Import as default SENSE augmentation
await this.registerNeuralImport()
// Register Cortex as default SENSE augmentation
await this.registerCortex()
console.log('🧠⚛️ Default augmentations initialized')
}
/**
* Neural Import - Default SENSE Augmentation
* Cortex - Default SENSE Augmentation
* AI-powered data understanding and entity extraction
*/
private async registerNeuralImport(): Promise<void> {
private async registerCortex(): Promise<void> {
try {
// Import the Neural Import augmentation
const { NeuralImportSenseAugmentation } = await import('../augmentations/neuralImportSense.js')
// Import the Cortex augmentation
const { CortexSenseAugmentation } = await import('../augmentations/cortexSense.js')
// Note: The actual registration is commented out since BrainyData doesn't have addAugmentation method yet
// This would create instance with default configuration
/*
const neuralImport = new NeuralImportSenseAugmentation(this.brainy as any, {
const cortex = new CortexSenseAugmentation(this.brainy as any, {
confidenceThreshold: 0.7,
enableWeights: true,
skipDuplicates: true
@ -51,38 +51,38 @@ export class DefaultAugmentationRegistry {
// Add as SENSE augmentation to Brainy (when method is available)
if (this.brainy.addAugmentation) {
await this.brainy.addAugmentation('SENSE', neuralImport, {
await this.brainy.addAugmentation('SENSE', cortex, {
position: 1, // First in the SENSE pipeline
name: 'neural-import',
name: 'cortex',
autoStart: true
})
}
*/
console.log('🧠⚛️ Neural Import module loaded (awaiting BrainyData augmentation support)')
console.log('🧠⚛️ Cortex module loaded (awaiting BrainyData augmentation support)')
} catch (error) {
console.error('❌ Failed to register Neural Import:', error instanceof Error ? error.message : String(error))
console.error('❌ Failed to register Cortex:', error instanceof Error ? error.message : String(error))
// Don't throw - Brainy should still work without Neural Import
}
}
/**
* Check if Neural Import is available and working
* Check if Cortex is available and working
*/
async checkNeuralImportHealth(): Promise<{
async checkCortexHealth(): Promise<{
available: boolean
status: string
version?: string
}> {
try {
// Check if Neural Import is registered as an augmentation
// Check if Cortex is registered as an augmentation
// Note: hasAugmentation method doesn't exist yet in BrainyData
const hasNeuralImport = false // this.brainy.hasAugmentation && this.brainy.hasAugmentation('SENSE', 'neural-import')
const hasCortex = false // this.brainy.hasAugmentation && this.brainy.hasAugmentation('SENSE', 'cortex')
return {
available: hasNeuralImport || false,
status: hasNeuralImport ? 'active' : 'not registered (awaiting BrainyData support)',
available: hasCortex || false,
status: hasCortex ? 'active' : 'not registered (awaiting BrainyData support)',
version: '1.0.0'
}
} catch (error) {
@ -94,16 +94,16 @@ export class DefaultAugmentationRegistry {
}
/**
* Reinstall Neural Import if it's missing or corrupted
* Reinstall Cortex if it's missing or corrupted
*/
async reinstallNeuralImport(): Promise<void> {
async reinstallCortex(): Promise<void> {
try {
// Remove existing if present
// Note: removeAugmentation method doesn't exist yet in BrainyData
/*
if (this.brainy.removeAugmentation) {
try {
await this.brainy.removeAugmentation('SENSE', 'neural-import')
await this.brainy.removeAugmentation('SENSE', 'cortex')
} catch (error) {
// Ignore errors if augmentation doesn't exist
}
@ -111,11 +111,11 @@ export class DefaultAugmentationRegistry {
*/
// Re-register
await this.registerNeuralImport()
await this.registerCortex()
console.log('🧠⚛️ Neural Import reinstalled successfully')
console.log('🧠⚛️ Cortex reinstalled successfully')
} catch (error) {
throw new Error(`Failed to reinstall Neural Import: ${error instanceof Error ? error.message : String(error)}`)
throw new Error(`Failed to reinstall Cortex: ${error instanceof Error ? error.message : String(error)}`)
}
}
}