refactor: remove augmentation system and semantic type matching
Remove the entire augmentation pipeline infrastructure (52 files, ~15,000 lines) and the semantic type matching system. These were unused middleware layers adding complexity without value. What was removed: - src/augmentations/ directory (all augmentation implementations) - src/augmentationManager.ts (pipeline orchestrator) - src/types/augmentations.ts, src/types/pipelineTypes.ts - src/shared/default-augmentations.ts - Semantic type suggestion (BrainyTypes.suggestNoun/suggestVerb) - src/utils/typeMatching/ (embedding-based type matcher) What was preserved by relocating: - Import handlers (CSV, PDF, Excel) -> src/importers/handlers/ - NeuralImportAugmentation -> src/cortex/neuralImportAugmentation.ts - Type matching utilities -> heuristic inference in consumers What was simplified: - brainy.ts: operations call storage directly (no execute() wrapper) - IntegrationBase: standalone class (no BaseAugmentation parent) - BrainyTypes: validation-only (nouns, verbs, isValid*, get*) - Pipeline: direct execution (no augmentation interception) - index.ts: removed TypeSuggestion, suggestType exports - package.json: removed stale types/augmentations export Build passes, 1176 tests pass, 0 failures.
This commit is contained in:
parent
ac7a1f772c
commit
d1db3510be
97 changed files with 349 additions and 19705 deletions
|
|
@ -148,21 +148,9 @@ export const coreCommands = {
|
|||
}
|
||||
nounType = options.type as NounType
|
||||
} else {
|
||||
// Use AI to suggest type
|
||||
spinner.text = 'Detecting type with AI...'
|
||||
const suggestion = await BrainyTypes.suggestNoun(
|
||||
typeof text === 'string' ? { content: text, ...metadata } : text
|
||||
)
|
||||
|
||||
if (suggestion.confidence < 0.6) {
|
||||
spinner.fail('Could not determine type with confidence')
|
||||
console.log(chalk.yellow(`Suggestion: ${suggestion.type} (${(suggestion.confidence * 100).toFixed(1)}%)`))
|
||||
console.log(chalk.dim('Use --type flag to specify explicitly'))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
nounType = suggestion.type as NounType
|
||||
spinner.text = `Using detected type: ${nounType}`
|
||||
// Default to Thing when no type specified
|
||||
nounType = NounType.Thing
|
||||
spinner.text = `No type specified, using default: ${nounType}`
|
||||
}
|
||||
|
||||
// Add with explicit type
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
/**
|
||||
* CLI Commands for Type Management
|
||||
* Consistent with BrainyTypes public API
|
||||
*/
|
||||
|
||||
import chalk from 'chalk'
|
||||
import ora from 'ora'
|
||||
import inquirer from 'inquirer'
|
||||
import Table from 'cli-table3'
|
||||
import { BrainyTypes, NounType, VerbType } from '../../index.js'
|
||||
|
||||
/**
|
||||
|
|
@ -18,7 +15,7 @@ export async function types(options: { json?: boolean, noun?: boolean, verb?: bo
|
|||
// Default to showing both if neither flag specified
|
||||
const showNouns = options.noun || (!options.noun && !options.verb)
|
||||
const showVerbs = options.verb || (!options.noun && !options.verb)
|
||||
|
||||
|
||||
const result: any = {}
|
||||
if (showNouns) result.nouns = BrainyTypes.nouns
|
||||
if (showVerbs) result.verbs = BrainyTypes.verbs
|
||||
|
|
@ -30,12 +27,12 @@ export async function types(options: { json?: boolean, noun?: boolean, verb?: bo
|
|||
|
||||
// Display nouns
|
||||
if (showNouns) {
|
||||
console.log(chalk.bold.cyan('\n📚 Noun Types (42):\n'))
|
||||
console.log(chalk.bold.cyan(`\nNoun Types (${BrainyTypes.nouns.length}):\n`))
|
||||
const nounChunks = []
|
||||
for (let i = 0; i < BrainyTypes.nouns.length; i += 3) {
|
||||
nounChunks.push(BrainyTypes.nouns.slice(i, i + 3))
|
||||
}
|
||||
|
||||
|
||||
for (const chunk of nounChunks) {
|
||||
console.log(' ' + chunk.map(n => chalk.green(n.padEnd(20))).join(''))
|
||||
}
|
||||
|
|
@ -43,110 +40,17 @@ export async function types(options: { json?: boolean, noun?: boolean, verb?: bo
|
|||
|
||||
// Display verbs
|
||||
if (showVerbs) {
|
||||
console.log(chalk.bold.cyan('\n🔗 Verb Types (127):\n'))
|
||||
console.log(chalk.bold.cyan(`\nVerb Types (${BrainyTypes.verbs.length}):\n`))
|
||||
const verbChunks = []
|
||||
for (let i = 0; i < BrainyTypes.verbs.length; i += 3) {
|
||||
verbChunks.push(BrainyTypes.verbs.slice(i, i + 3))
|
||||
}
|
||||
|
||||
|
||||
for (const chunk of verbChunks) {
|
||||
console.log(' ' + chunk.map(v => chalk.blue(v.padEnd(20))).join(''))
|
||||
}
|
||||
}
|
||||
|
||||
console.log(chalk.dim('\n💡 Use "brainy suggest <data>" to get AI-powered type suggestions'))
|
||||
|
||||
} catch (error: any) {
|
||||
console.error(chalk.red('Error:', error.message))
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest type - matches BrainyTypes.suggestNoun() and suggestVerb()
|
||||
* Usage: brainy suggest <data>
|
||||
* Interactive if data not provided
|
||||
*/
|
||||
export async function suggest(
|
||||
data?: string,
|
||||
options: {
|
||||
verb?: boolean,
|
||||
json?: boolean
|
||||
} = {}
|
||||
) {
|
||||
try {
|
||||
// Interactive mode if no data provided
|
||||
if (!data) {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'kind',
|
||||
message: 'What type do you want to suggest?',
|
||||
choices: ['Noun', 'Verb'],
|
||||
default: 'Noun'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'data',
|
||||
message: 'Enter data (JSON or text):',
|
||||
validate: (input) => input.length > 0 || 'Data is required'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'hint',
|
||||
message: 'Relationship hint (optional):',
|
||||
when: (answers) => answers.kind === 'Verb'
|
||||
}
|
||||
])
|
||||
|
||||
data = answers.data
|
||||
options.verb = answers.kind === 'Verb'
|
||||
|
||||
// For verbs, parse source/target if provided as JSON
|
||||
if (options.verb && answers.hint) {
|
||||
data = JSON.stringify({ hint: answers.hint })
|
||||
}
|
||||
}
|
||||
|
||||
const spinner = ora('Analyzing with AI...').start()
|
||||
|
||||
let parsedData: any
|
||||
try {
|
||||
parsedData = JSON.parse(data)
|
||||
} catch {
|
||||
parsedData = { content: data }
|
||||
}
|
||||
|
||||
let suggestion
|
||||
if (options.verb) {
|
||||
// For verb suggestions, need source and target
|
||||
const source = parsedData.source || { type: 'unknown' }
|
||||
const target = parsedData.target || { type: 'unknown' }
|
||||
const hint = parsedData.hint || parsedData.relationship || parsedData.verb
|
||||
|
||||
suggestion = await BrainyTypes.suggestVerb(source, target, hint)
|
||||
spinner.succeed('Verb type analyzed')
|
||||
} else {
|
||||
suggestion = await BrainyTypes.suggestNoun(parsedData)
|
||||
spinner.succeed('Noun type analyzed')
|
||||
}
|
||||
|
||||
if (options.json) {
|
||||
console.log(JSON.stringify(suggestion, null, 2))
|
||||
return
|
||||
}
|
||||
|
||||
// Display results
|
||||
console.log(chalk.bold.green(`\n✨ Suggested: ${suggestion.type}`))
|
||||
console.log(chalk.cyan(`Confidence: ${(suggestion.confidence * 100).toFixed(1)}%`))
|
||||
|
||||
if (suggestion.alternatives && suggestion.alternatives.length > 0) {
|
||||
console.log(chalk.yellow('\nAlternatives:'))
|
||||
for (const alt of suggestion.alternatives.slice(0, 3)) {
|
||||
console.log(` ${alt.type} (${(alt.confidence * 100).toFixed(1)}%)`)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
console.error(chalk.red('Error:', error.message))
|
||||
process.exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue