@soulcraft/brainy 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/brainy.js +340 -62
- package/dist/augmentations/brainyAugmentation.d.ts +41 -0
- package/dist/augmentations/defaultAugmentations.d.ts +6 -0
- package/dist/augmentations/defaultAugmentations.js +12 -0
- package/dist/augmentations/display/cache.d.ts +130 -0
- package/dist/augmentations/display/cache.js +319 -0
- package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
- package/dist/augmentations/display/fieldPatterns.js +393 -0
- package/dist/augmentations/display/iconMappings.d.ts +57 -0
- package/dist/augmentations/display/iconMappings.js +68 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
- package/dist/augmentations/display/intelligentComputation.js +462 -0
- package/dist/augmentations/display/types.d.ts +203 -0
- package/dist/augmentations/display/types.js +7 -0
- package/dist/augmentations/universalDisplayAugmentation.d.ts +189 -0
- package/dist/augmentations/universalDisplayAugmentation.js +368 -0
- package/package.json +1 -1
package/bin/brainy.js
CHANGED
|
@@ -61,6 +61,200 @@ const initBrainy = async () => {
|
|
|
61
61
|
return new BrainyData()
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Enhanced result formatting using display augmentation
|
|
66
|
+
* @param {any} result - The result object from search/get/find
|
|
67
|
+
* @param {number} index - Result index for numbering
|
|
68
|
+
* @returns {Promise<string>} Formatted result string
|
|
69
|
+
*/
|
|
70
|
+
const formatResultWithDisplay = async (result, index) => {
|
|
71
|
+
try {
|
|
72
|
+
// Check if result has display capabilities (enhanced by display augmentation)
|
|
73
|
+
if (result.getDisplay && typeof result.getDisplay === 'function') {
|
|
74
|
+
const displayFields = await result.getDisplay()
|
|
75
|
+
|
|
76
|
+
// Format with enhanced display fields (clean, no icons)
|
|
77
|
+
let output = colors.primary(`\n${index + 1}. ${displayFields.title}`)
|
|
78
|
+
|
|
79
|
+
if (displayFields.type) {
|
|
80
|
+
output += colors.dim(` (${displayFields.type})`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (result.score) {
|
|
84
|
+
output += colors.info(`\n 🎯 Relevance: ${(result.score * 100).toFixed(1)}%`)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (result.fusionScore) {
|
|
88
|
+
output += colors.info(`\n 🧠 AI Score: ${(result.fusionScore * 100).toFixed(1)}%`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (displayFields.description && displayFields.description !== displayFields.title) {
|
|
92
|
+
output += colors.info(`\n 📄 ${displayFields.description}`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
96
|
+
output += colors.cyan(`\n 🏷️ ${displayFields.tags.join(', ')}`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Show relationship info for verbs
|
|
100
|
+
if (displayFields.relationship) {
|
|
101
|
+
output += colors.yellow(`\n 🔗 ${displayFields.relationship}`)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Show metadata only if there's additional useful info
|
|
105
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
106
|
+
const filteredMetadata = Object.fromEntries(
|
|
107
|
+
Object.entries(result.metadata).filter(([key]) =>
|
|
108
|
+
!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
if (Object.keys(filteredMetadata).length > 0) {
|
|
112
|
+
output += colors.dim(`\n 📝 ${JSON.stringify(filteredMetadata)}`)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return output
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
// Fallback silently to basic formatting if display augmentation fails
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Fallback: Basic formatting without display augmentation
|
|
123
|
+
let output = colors.primary(`\n${index + 1}. ${result.content || result.id}`)
|
|
124
|
+
|
|
125
|
+
if (result.score) {
|
|
126
|
+
output += colors.info(`\n Relevance: ${(result.score * 100).toFixed(1)}%`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (result.fusionScore) {
|
|
130
|
+
output += colors.info(`\n AI Score: ${(result.fusionScore * 100).toFixed(1)}%`)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (result.type) {
|
|
134
|
+
output += colors.info(`\n Type: ${result.type}`)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
138
|
+
output += colors.dim(`\n Metadata: ${JSON.stringify(result.metadata)}`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return output
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Enhanced single item formatting for get command
|
|
146
|
+
* @param {any} item - The item object
|
|
147
|
+
* @param {string} format - Output format (json, table, plain)
|
|
148
|
+
* @returns {Promise<string>} Formatted item string
|
|
149
|
+
*/
|
|
150
|
+
const formatItemWithDisplay = async (item, format = 'plain') => {
|
|
151
|
+
if (format === 'json') {
|
|
152
|
+
return JSON.stringify(item, null, 2)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
// Check if item has display capabilities
|
|
157
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
158
|
+
const displayFields = await item.getDisplay()
|
|
159
|
+
|
|
160
|
+
if (format === 'table') {
|
|
161
|
+
const table = new Table({
|
|
162
|
+
head: [colors.brain('Property'), colors.brain('Value')],
|
|
163
|
+
style: { head: [], border: [] }
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
table.push(['ID', colors.primary(item.id)])
|
|
167
|
+
table.push(['Title', colors.primary(displayFields.title)])
|
|
168
|
+
table.push(['Type', colors.info(displayFields.type)])
|
|
169
|
+
table.push(['Description', colors.info(displayFields.description)])
|
|
170
|
+
|
|
171
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
172
|
+
table.push(['Tags', colors.cyan(displayFields.tags.join(', '))])
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (displayFields.relationship) {
|
|
176
|
+
table.push(['Relationship', colors.yellow(displayFields.relationship)])
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (item.content && item.content !== displayFields.title) {
|
|
180
|
+
table.push(['Content', colors.dim(item.content)])
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Add non-internal metadata
|
|
184
|
+
if (item.metadata) {
|
|
185
|
+
Object.entries(item.metadata).forEach(([key, value]) => {
|
|
186
|
+
if (!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)) {
|
|
187
|
+
table.push([key, colors.dim(JSON.stringify(value))])
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return table.toString()
|
|
193
|
+
} else {
|
|
194
|
+
// Plain format with display enhancement
|
|
195
|
+
let output = colors.primary(`ID: ${item.id}`)
|
|
196
|
+
output += colors.primary(`\nTitle: ${displayFields.title}`)
|
|
197
|
+
output += colors.info(`\nType: ${displayFields.type}`)
|
|
198
|
+
output += colors.info(`\nDescription: ${displayFields.description}`)
|
|
199
|
+
|
|
200
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
201
|
+
output += colors.cyan(`\nTags: ${displayFields.tags.join(', ')}`)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (displayFields.relationship) {
|
|
205
|
+
output += colors.yellow(`\nRelationship: ${displayFields.relationship}`)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (item.content && item.content !== displayFields.title) {
|
|
209
|
+
output += colors.dim(`\nOriginal Content: ${item.content}`)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Show additional metadata
|
|
213
|
+
if (item.metadata) {
|
|
214
|
+
const additionalMetadata = Object.fromEntries(
|
|
215
|
+
Object.entries(item.metadata).filter(([key]) =>
|
|
216
|
+
!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
if (Object.keys(additionalMetadata).length > 0) {
|
|
220
|
+
output += colors.dim(`\nAdditional Metadata: ${JSON.stringify(additionalMetadata, null, 2)}`)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return output
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
// Fallback silently to basic formatting
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Fallback: Basic formatting
|
|
232
|
+
if (format === 'table') {
|
|
233
|
+
const table = new Table({
|
|
234
|
+
head: [colors.brain('Property'), colors.brain('Value')],
|
|
235
|
+
style: { head: [], border: [] }
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
table.push(['ID', colors.primary(item.id)])
|
|
239
|
+
table.push(['Content', colors.info(item.content || 'N/A')])
|
|
240
|
+
if (item.metadata) {
|
|
241
|
+
Object.entries(item.metadata).forEach(([key, value]) => {
|
|
242
|
+
table.push([key, colors.dim(JSON.stringify(value))])
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
return table.toString()
|
|
246
|
+
} else {
|
|
247
|
+
let output = colors.primary(`ID: ${item.id}`)
|
|
248
|
+
if (item.content) {
|
|
249
|
+
output += colors.info(`\nContent: ${item.content}`)
|
|
250
|
+
}
|
|
251
|
+
if (item.metadata && Object.keys(item.metadata).length > 0) {
|
|
252
|
+
output += colors.info(`\nMetadata: ${JSON.stringify(item.metadata, null, 2)}`)
|
|
253
|
+
}
|
|
254
|
+
return output
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
64
258
|
const wrapAction = (fn) => {
|
|
65
259
|
return async (...args) => {
|
|
66
260
|
try {
|
|
@@ -675,18 +869,12 @@ program
|
|
|
675
869
|
}
|
|
676
870
|
|
|
677
871
|
console.log(colors.success(`✅ Found ${results.length} intelligent results:`))
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
console.log(colors.info(` AI Score: ${(result.fusionScore * 100).toFixed(1)}%`))
|
|
685
|
-
}
|
|
686
|
-
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
687
|
-
console.log(colors.dim(` Metadata: ${JSON.stringify(result.metadata)}`))
|
|
688
|
-
}
|
|
689
|
-
})
|
|
872
|
+
|
|
873
|
+
// Use enhanced formatting with display augmentation
|
|
874
|
+
for (let i = 0; i < results.length; i++) {
|
|
875
|
+
const formattedResult = await formatResultWithDisplay(results[i], i)
|
|
876
|
+
console.log(formattedResult)
|
|
877
|
+
}
|
|
690
878
|
}))
|
|
691
879
|
|
|
692
880
|
// Command 4: SEARCH - Triple-power search
|
|
@@ -777,15 +965,12 @@ program
|
|
|
777
965
|
}
|
|
778
966
|
|
|
779
967
|
console.log(colors.success(`✅ Found ${results.length} results:`))
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
console.log(colors.info(` Type: ${result.type}`))
|
|
787
|
-
}
|
|
788
|
-
})
|
|
968
|
+
|
|
969
|
+
// Use enhanced formatting with display augmentation
|
|
970
|
+
for (let i = 0; i < results.length; i++) {
|
|
971
|
+
const formattedResult = await formatResultWithDisplay(results[i], i)
|
|
972
|
+
console.log(formattedResult)
|
|
973
|
+
}
|
|
789
974
|
}))
|
|
790
975
|
|
|
791
976
|
// Command 4: GET - Retrieve specific data by ID
|
|
@@ -793,6 +978,7 @@ program
|
|
|
793
978
|
.command('get [id]')
|
|
794
979
|
.description('Get a specific item by ID')
|
|
795
980
|
.option('-f, --format <format>', 'Output format (json, table, plain)', 'plain')
|
|
981
|
+
.option('--display-debug', 'Show debug information about display augmentation')
|
|
796
982
|
.action(wrapAction(async (id, options) => {
|
|
797
983
|
if (!id) {
|
|
798
984
|
console.log(colors.primary('🔍 Interactive Get Mode'))
|
|
@@ -826,31 +1012,52 @@ program
|
|
|
826
1012
|
return
|
|
827
1013
|
}
|
|
828
1014
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
head: [colors.brain('Property'), colors.brain('Value')],
|
|
834
|
-
style: { head: [], border: [] }
|
|
835
|
-
})
|
|
1015
|
+
// Show display debug information if requested
|
|
1016
|
+
if (options.displayDebug) {
|
|
1017
|
+
console.log(colors.primary('🔍 Display Augmentation Debug Information'))
|
|
1018
|
+
console.log('=' .repeat(50))
|
|
836
1019
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1020
|
+
try {
|
|
1021
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1022
|
+
console.log(colors.success('✅ Display augmentation active'))
|
|
1023
|
+
|
|
1024
|
+
const displayFields = await item.getDisplay()
|
|
1025
|
+
console.log(colors.info('\n🎨 Computed Display Fields:'))
|
|
1026
|
+
Object.entries(displayFields).forEach(([key, value]) => {
|
|
1027
|
+
console.log(colors.cyan(` ${key}: ${JSON.stringify(value)}`))
|
|
1028
|
+
})
|
|
1029
|
+
|
|
1030
|
+
// Show available fields
|
|
1031
|
+
if (item.getAvailableFields && typeof item.getAvailableFields === 'function') {
|
|
1032
|
+
const availableFields = item.getAvailableFields('display')
|
|
1033
|
+
console.log(colors.info('\n📋 Available Display Fields:'))
|
|
1034
|
+
availableFields.forEach(field => {
|
|
1035
|
+
console.log(colors.dim(` - ${field}`))
|
|
1036
|
+
})
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Show augmentation info
|
|
1040
|
+
if (item.getAvailableAugmentations && typeof item.getAvailableAugmentations === 'function') {
|
|
1041
|
+
const augs = item.getAvailableAugmentations()
|
|
1042
|
+
console.log(colors.info('\n🔌 Available Augmentations:'))
|
|
1043
|
+
augs.forEach(aug => {
|
|
1044
|
+
console.log(colors.dim(` - ${aug}`))
|
|
1045
|
+
})
|
|
1046
|
+
}
|
|
1047
|
+
} else {
|
|
1048
|
+
console.log(colors.warning('⚠️ Display augmentation not active or not enhanced'))
|
|
1049
|
+
console.log(colors.dim(' Item does not have getDisplay() method'))
|
|
1050
|
+
}
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
console.log(colors.error(`❌ Display debug error: ${error.message}`))
|
|
852
1053
|
}
|
|
1054
|
+
|
|
1055
|
+
console.log('\n' + '=' .repeat(50))
|
|
853
1056
|
}
|
|
1057
|
+
|
|
1058
|
+
// Use enhanced formatting with display augmentation
|
|
1059
|
+
const formattedItem = await formatItemWithDisplay(item, options.format)
|
|
1060
|
+
console.log(formattedItem)
|
|
854
1061
|
}))
|
|
855
1062
|
|
|
856
1063
|
// Command 5: UPDATE - Update existing data
|
|
@@ -875,9 +1082,21 @@ program
|
|
|
875
1082
|
|
|
876
1083
|
if (recent.length > 0) {
|
|
877
1084
|
console.log(colors.cyan('Recent items:'))
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1085
|
+
|
|
1086
|
+
// Enhanced display for recent items
|
|
1087
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1088
|
+
const item = recent[i]
|
|
1089
|
+
try {
|
|
1090
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1091
|
+
const displayFields = await item.getDisplay()
|
|
1092
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${displayFields.title}`))
|
|
1093
|
+
} else {
|
|
1094
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1095
|
+
}
|
|
1096
|
+
} catch {
|
|
1097
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
881
1100
|
console.log()
|
|
882
1101
|
}
|
|
883
1102
|
|
|
@@ -953,9 +1172,21 @@ program
|
|
|
953
1172
|
|
|
954
1173
|
if (recent.length > 0) {
|
|
955
1174
|
console.log(colors.cyan('Recent items:'))
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1175
|
+
|
|
1176
|
+
// Enhanced display for recent items
|
|
1177
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1178
|
+
const item = recent[i]
|
|
1179
|
+
try {
|
|
1180
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1181
|
+
const displayFields = await item.getDisplay()
|
|
1182
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${displayFields.title}`))
|
|
1183
|
+
} else {
|
|
1184
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1185
|
+
}
|
|
1186
|
+
} catch {
|
|
1187
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
959
1190
|
console.log()
|
|
960
1191
|
}
|
|
961
1192
|
|
|
@@ -1150,9 +1381,21 @@ program
|
|
|
1150
1381
|
const recent = await brainyInstance.search('*', { limit: 10, sortBy: 'timestamp' })
|
|
1151
1382
|
if (recent.length > 0) {
|
|
1152
1383
|
console.log(colors.cyan('Recent items (source):'))
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1384
|
+
|
|
1385
|
+
// Enhanced display for recent items
|
|
1386
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1387
|
+
const item = recent[i]
|
|
1388
|
+
try {
|
|
1389
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1390
|
+
const displayFields = await item.getDisplay()
|
|
1391
|
+
console.log(colors.info(` ${i + 1}. ${displayFields.icon} ${item.id} - ${displayFields.title}`))
|
|
1392
|
+
} else {
|
|
1393
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1394
|
+
}
|
|
1395
|
+
} catch {
|
|
1396
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1156
1399
|
console.log()
|
|
1157
1400
|
}
|
|
1158
1401
|
|
|
@@ -1202,9 +1445,21 @@ program
|
|
|
1202
1445
|
const recent = await brainyInstance.search('*', { limit: 10, sortBy: 'timestamp' })
|
|
1203
1446
|
if (recent.length > 0) {
|
|
1204
1447
|
console.log(colors.cyan('\nRecent items (target):'))
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1448
|
+
|
|
1449
|
+
// Enhanced display for recent items
|
|
1450
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1451
|
+
const item = recent[i]
|
|
1452
|
+
try {
|
|
1453
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1454
|
+
const displayFields = await item.getDisplay()
|
|
1455
|
+
console.log(colors.info(` ${i + 1}. ${displayFields.icon} ${item.id} - ${displayFields.title}`))
|
|
1456
|
+
} else {
|
|
1457
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1458
|
+
}
|
|
1459
|
+
} catch {
|
|
1460
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1208
1463
|
console.log()
|
|
1209
1464
|
}
|
|
1210
1465
|
|
|
@@ -1365,16 +1620,39 @@ program
|
|
|
1365
1620
|
|
|
1366
1621
|
// Active Augmentations
|
|
1367
1622
|
console.log(colors.primary('🔌 Active Augmentations'))
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1623
|
+
try {
|
|
1624
|
+
// Check for display augmentation specifically
|
|
1625
|
+
const displayAugmentation = (brainy as any).augmentations?.get('display')
|
|
1626
|
+
if (displayAugmentation) {
|
|
1627
|
+
console.log(colors.success(` ✅ display - Universal Display Augmentation`))
|
|
1628
|
+
console.log(colors.info(` 🎨 AI-powered titles and descriptions`))
|
|
1629
|
+
|
|
1630
|
+
// Get display augmentation stats if available
|
|
1631
|
+
if (displayAugmentation.getStats) {
|
|
1632
|
+
const stats = displayAugmentation.getStats()
|
|
1633
|
+
if (stats.totalComputations > 0) {
|
|
1634
|
+
console.log(colors.dim(` 📊 ${stats.totalComputations} computations, ${(stats.cacheHitRatio * 100).toFixed(1)}% cache hit rate`))
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// Show other augmentations
|
|
1640
|
+
const otherAugs = (brainy as any).augmentations ?
|
|
1641
|
+
Array.from((brainy as any).augmentations.values()).filter((aug: any) => aug.name !== 'display') :
|
|
1642
|
+
[]
|
|
1643
|
+
|
|
1644
|
+
otherAugs.forEach((aug: any) => {
|
|
1373
1645
|
console.log(colors.success(` ✅ ${aug.name}`))
|
|
1374
|
-
if (aug.
|
|
1375
|
-
console.log(colors.info(` ${aug.description}`))
|
|
1646
|
+
if (aug.version) {
|
|
1647
|
+
console.log(colors.info(` v${aug.version} - ${aug.description || 'No description'}`))
|
|
1376
1648
|
}
|
|
1377
1649
|
})
|
|
1650
|
+
|
|
1651
|
+
if (!displayAugmentation && otherAugs.length === 0) {
|
|
1652
|
+
console.log(colors.warning(' No augmentations currently active'))
|
|
1653
|
+
}
|
|
1654
|
+
} catch (error) {
|
|
1655
|
+
console.log(colors.warning(' Augmentation status unavailable'))
|
|
1378
1656
|
}
|
|
1379
1657
|
console.log()
|
|
1380
1658
|
|
|
@@ -77,6 +77,28 @@ export interface BrainyAugmentation {
|
|
|
77
77
|
* Optional: Cleanup when BrainyData is destroyed
|
|
78
78
|
*/
|
|
79
79
|
shutdown?(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Optional: Computed fields this augmentation provides
|
|
82
|
+
* Used for discovery, TypeScript support, and API documentation
|
|
83
|
+
*/
|
|
84
|
+
computedFields?: {
|
|
85
|
+
[namespace: string]: {
|
|
86
|
+
[field: string]: {
|
|
87
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
88
|
+
description: string;
|
|
89
|
+
confidence?: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Optional: Compute fields for a result entity
|
|
95
|
+
* Called when user accesses getDisplay(), getSchema(), etc.
|
|
96
|
+
*
|
|
97
|
+
* @param result - The result entity (VectorDocument, GraphVerb, etc.)
|
|
98
|
+
* @param namespace - The namespace being requested ('display', 'schema', etc.)
|
|
99
|
+
* @returns Computed fields for the namespace
|
|
100
|
+
*/
|
|
101
|
+
computeFields?(result: any, namespace: string): Promise<Record<string, any>> | Record<string, any>;
|
|
80
102
|
}
|
|
81
103
|
/**
|
|
82
104
|
* Context provided to augmentations
|
|
@@ -122,6 +144,25 @@ export declare abstract class BaseAugmentation implements BrainyAugmentation {
|
|
|
122
144
|
* Override this in subclasses for cleanup logic
|
|
123
145
|
*/
|
|
124
146
|
protected onShutdown(): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Optional computed fields declaration (override in subclasses)
|
|
149
|
+
*/
|
|
150
|
+
computedFields?: {
|
|
151
|
+
[namespace: string]: {
|
|
152
|
+
[field: string]: {
|
|
153
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
154
|
+
description: string;
|
|
155
|
+
confidence?: number;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Optional computed fields implementation (override in subclasses)
|
|
161
|
+
* @param result The result entity
|
|
162
|
+
* @param namespace The requested namespace
|
|
163
|
+
* @returns Computed fields for the namespace
|
|
164
|
+
*/
|
|
165
|
+
computeFields?(result: any, namespace: string): Promise<Record<string, any>> | Record<string, any>;
|
|
125
166
|
/**
|
|
126
167
|
* Log a message with the augmentation name
|
|
127
168
|
*/
|
|
@@ -13,6 +13,7 @@ import { CacheAugmentation } from './cacheAugmentation.js';
|
|
|
13
13
|
import { IndexAugmentation } from './indexAugmentation.js';
|
|
14
14
|
import { MetricsAugmentation } from './metricsAugmentation.js';
|
|
15
15
|
import { MonitoringAugmentation } from './monitoringAugmentation.js';
|
|
16
|
+
import { UniversalDisplayAugmentation } from './universalDisplayAugmentation.js';
|
|
16
17
|
/**
|
|
17
18
|
* Create default augmentations for zero-config operation
|
|
18
19
|
* Returns an array of augmentations to be registered
|
|
@@ -25,6 +26,7 @@ export declare function createDefaultAugmentations(config?: {
|
|
|
25
26
|
index?: boolean | Record<string, any>;
|
|
26
27
|
metrics?: boolean | Record<string, any>;
|
|
27
28
|
monitoring?: boolean | Record<string, any>;
|
|
29
|
+
display?: boolean | Record<string, any>;
|
|
28
30
|
}): BaseAugmentation[];
|
|
29
31
|
/**
|
|
30
32
|
* Get augmentation by name with type safety
|
|
@@ -50,4 +52,8 @@ export declare const AugmentationHelpers: {
|
|
|
50
52
|
* Get monitoring augmentation
|
|
51
53
|
*/
|
|
52
54
|
getMonitoring(brain: BrainyData): MonitoringAugmentation | null;
|
|
55
|
+
/**
|
|
56
|
+
* Get display augmentation
|
|
57
|
+
*/
|
|
58
|
+
getDisplay(brain: BrainyData): UniversalDisplayAugmentation | null;
|
|
53
59
|
};
|
|
@@ -11,6 +11,7 @@ import { CacheAugmentation } from './cacheAugmentation.js';
|
|
|
11
11
|
import { IndexAugmentation } from './indexAugmentation.js';
|
|
12
12
|
import { MetricsAugmentation } from './metricsAugmentation.js';
|
|
13
13
|
import { MonitoringAugmentation } from './monitoringAugmentation.js';
|
|
14
|
+
import { UniversalDisplayAugmentation } from './universalDisplayAugmentation.js';
|
|
14
15
|
/**
|
|
15
16
|
* Create default augmentations for zero-config operation
|
|
16
17
|
* Returns an array of augmentations to be registered
|
|
@@ -35,6 +36,11 @@ export function createDefaultAugmentations(config = {}) {
|
|
|
35
36
|
const metricsConfig = typeof config.metrics === 'object' ? config.metrics : {};
|
|
36
37
|
augmentations.push(new MetricsAugmentation(metricsConfig));
|
|
37
38
|
}
|
|
39
|
+
// Display augmentation (AI-powered intelligent display fields)
|
|
40
|
+
if (config.display !== false) {
|
|
41
|
+
const displayConfig = typeof config.display === 'object' ? config.display : {};
|
|
42
|
+
augmentations.push(new UniversalDisplayAugmentation(displayConfig));
|
|
43
|
+
}
|
|
38
44
|
// Monitoring augmentation (was HealthMonitor)
|
|
39
45
|
// Only enable by default in distributed mode
|
|
40
46
|
const isDistributed = process.env.BRAINY_MODE === 'distributed' ||
|
|
@@ -83,6 +89,12 @@ export const AugmentationHelpers = {
|
|
|
83
89
|
*/
|
|
84
90
|
getMonitoring(brain) {
|
|
85
91
|
return getAugmentation(brain, 'monitoring');
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Get display augmentation
|
|
95
|
+
*/
|
|
96
|
+
getDisplay(brain) {
|
|
97
|
+
return getAugmentation(brain, 'display');
|
|
86
98
|
}
|
|
87
99
|
};
|
|
88
100
|
//# sourceMappingURL=defaultAugmentations.js.map
|