feat: implement comprehensive type safety system with BrainyTypes API

Major enhancements for type safety and developer experience:

- Add BrainyTypes static API for type management and AI-powered suggestions
- Implement strict type validation for all 31 NounType categories
- Remove dangerous generic add() method that bypassed type safety
- Add intelligent type inference with confidence scoring
- Provide helpful error messages with typo suggestions using Levenshtein distance
- Update all internal code, examples, and documentation to use typed methods
- Enhance CLI with new type management commands (types, suggest, validate)

Breaking changes:
- Remove deprecated add() method - use addNoun() with explicit type parameter
- All addNoun() calls now require explicit type as second parameter

This release significantly improves type safety across the entire system while
maintaining backward compatibility for properly typed method calls.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
David Snelling 2025-09-01 09:37:36 -07:00
parent d7d2d749b6
commit 6c62bc4e9d
40 changed files with 1704 additions and 497 deletions

View file

@ -110,8 +110,8 @@ export class BrainyChat {
}
}
// Store session using BrainyData add() method
await this.brainy.add(
// Store session using BrainyData addNoun() method
await this.brainy.addNoun(
{
sessionType: 'chat',
title: title || `Chat Session ${new Date().toLocaleDateString()}`,
@ -120,9 +120,9 @@ export class BrainyChat {
messageCount: session.messageCount,
participants: session.participants
},
NounType.Concept, // Chat sessions are concepts
{
id: sessionId,
nounType: NounType.Concept,
sessionType: 'chat'
}
)
@ -157,8 +157,8 @@ export class BrainyChat {
metadata
}
// Store message using BrainyData add() method
await this.brainy.add(
// Store message using BrainyData addNoun() method
await this.brainy.addNoun(
{
messageType: 'chat',
content,
@ -167,9 +167,9 @@ export class BrainyChat {
timestamp: timestamp.toISOString(),
...metadata
},
NounType.Message, // Chat messages are Message type
{
id: messageId,
nounType: NounType.Message,
messageType: 'chat',
sessionId: this.currentSessionId!,
speaker
@ -352,14 +352,14 @@ export class BrainyChat {
try {
// Since BrainyData doesn't have update, add an archive marker
await this.brainy.add(
await this.brainy.addNoun(
{
archivedSessionId: sessionId,
archivedAt: new Date().toISOString(),
action: 'archive'
},
NounType.State, // Archive markers are State
{
nounType: NounType.State,
sessionId,
archived: true
}