feat: Complete the 9 Unified Methods with augment() and export()! 🎯

BREAKING CHANGE: Brainy 1.0 now has 9 unified methods (odd numbers FTW!)

THE 9 UNIFIED METHODS:
1. add() - Smart data addition
2. search() - Unified search
3. import() - Bulk import
4. addNoun() - Typed entities
5. addVerb() - Relationships
6. update() - Smart updates
7. delete() - Soft delete
8. augment() - Complete augmentation management 
9. export() - Universal data export 

Key improvements:
- Renamed register() to augment() for consistency
- Made augment() super flexible - handles ALL operations:
  - augment(new MyAugmentation()) - Register
  - augment('list') - List all with status
  - augment('enable', 'name') - Enable
  - augment('disable', 'name') - Disable
  - augment('unregister', 'name') - Remove
  - augment('enable-type', 'sense') - Bulk enable
- Added export() as 9th method for data portability:
  - Export as JSON, CSV, Graph, or Embeddings
  - Filter, limit, include/exclude options
  - Perfect for backups, migrations, integrations

Documentation:
- Created AUGMENTATION-GUIDE.md - Super simple guide
- Updated UNIFIED-API.md for all 9 methods
- Fixed misleading community package references
- Updated README with 9 methods everywhere

CLI commands now perfectly mirror the API:
- brainy augment <action> - Matches augment() method
- brainy export - Matches export() method

From 40+ methods → 9 unified methods (78% reduction!)
'Make the simple things simple, and the complex things possible'
This commit is contained in:
David Snelling 2025-08-14 12:29:47 -07:00
parent c93df7ee8e
commit 98bf98a228
5 changed files with 795 additions and 57 deletions

View file

@ -1006,7 +1006,67 @@ program
}
}))
// Command 7: CLOUD - Premium features connection
// Command 7: EXPORT - Export your data
program
.command('export')
.description('Export your brain data in various formats')
.option('-f, --format <format>', 'Export format (json, csv, graph, embeddings)', 'json')
.option('-o, --output <file>', 'Output file path')
.option('--vectors', 'Include vector embeddings')
.option('--no-metadata', 'Exclude metadata')
.option('--no-relationships', 'Exclude relationships')
.option('--filter <json>', 'Filter by metadata')
.option('-l, --limit <number>', 'Limit number of items')
.action(wrapAction(async (options) => {
const brainy = await initBrainy()
console.log(colors.brain('📤 Exporting Brain Data'))
const spinner = ora('Exporting data...').start()
try {
const exportOptions = {
format: options.format,
includeVectors: options.vectors || false,
includeMetadata: options.metadata !== false,
includeRelationships: options.relationships !== false,
filter: options.filter ? JSON.parse(options.filter) : {},
limit: options.limit ? parseInt(options.limit) : undefined
}
const data = await brainy.export(exportOptions)
spinner.succeed('Export complete')
if (options.output) {
// Write to file
const fs = require('fs')
const content = typeof data === 'string' ? data : JSON.stringify(data, null, 2)
fs.writeFileSync(options.output, content)
console.log(colors.success(`✅ Exported to: ${options.output}`))
// Show summary
const items = Array.isArray(data) ? data.length : (data.nodes ? data.nodes.length : 1)
console.log(colors.info(`📊 Format: ${options.format}`))
console.log(colors.info(`📁 Items: ${items}`))
if (options.vectors) {
console.log(colors.info(`🔢 Vectors: Included`))
}
} else {
// Output to console
if (typeof data === 'string') {
console.log(data)
} else {
console.log(JSON.stringify(data, null, 2))
}
}
} catch (error) {
spinner.fail('Export failed')
console.error(colors.error(error.message))
process.exit(1)
}
}))
// Command 8: CLOUD - Premium features connection
program
.command('cloud <action>')
.description('Connect to Brain Cloud premium features')