2025-08-26 12:32:21 -07:00
|
|
|
/**
|
refactor(8.0): delete DataAPI — superseded by Db persist/restore + import API + stats
The legacy backup/import/export/stats facade (src/api/DataAPI.ts) drifted
from the modern entity shape and every job it did now has a first-class
surface. Delete it and brain.data(), and rewire the CLI:
- data-stats → brain.stats() (full BrainyStats report: per-type breakdowns,
indexed fields, index health, storage backend, writer lock, version)
- clean → brain.clear()
- export → alias of snapshot; a db.persist() snapshot is the full-fidelity
export format (open with Brainy.load, load wholesale with brainy restore);
external data ingestion remains brainy import (UniversalImportAPI)
Rewiring clean onto brain.clear() exposed two real bugs, both fixed:
- clear() left this.graphIndex undefined forever — any graph-touching call
afterwards (relate, getNeighbors, stats) crashed. clear() now re-resolves
the graph index exactly as init() does and re-wires the shared UUID↔int
resolver, and re-resolves the metadata index with the same provider
fallback as init().
- storage.clear() reset the legacy totals but not the per-type/subtype
count rollups or id→type caches, so stats() reported phantom counts for
deleted entities. Both adapters now delegate derived-state reset to
reloadDerivedState(), the same path restore-from-snapshot uses.
One-shot CLI commands (data-stats, clean, snapshot/export, restore,
history, generation) now close the brain and exit explicitly — global
cache timers otherwise keep the process alive holding the writer lock.
Verified: build clean, 1383/1383 unit tests, 24/24 db-mvcc integration,
plus an end-to-end CLI smoke (add → data-stats → export → clean →
data-stats).
2026-06-11 09:05:12 -07:00
|
|
|
* @module cli/commands/core
|
|
|
|
|
* @description Essential database CLI commands: add, search, get, update,
|
|
|
|
|
* delete, relate, unrelate, and diagnostics. Database export lives under
|
|
|
|
|
* `brainy snapshot` (aliased as `brainy export`) — a `db.persist()` snapshot
|
|
|
|
|
* is the full-fidelity export format.
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import chalk from 'chalk'
|
|
|
|
|
import ora from 'ora'
|
2025-10-17 14:47:53 -07:00
|
|
|
import inquirer from 'inquirer'
|
2025-09-11 16:23:32 -07:00
|
|
|
import { Brainy } from '../../brainy.js'
|
2025-09-01 09:37:36 -07:00
|
|
|
import { BrainyTypes, NounType, VerbType } from '../../index.js'
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
interface CoreOptions {
|
|
|
|
|
verbose?: boolean
|
|
|
|
|
json?: boolean
|
|
|
|
|
pretty?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface AddOptions extends CoreOptions {
|
|
|
|
|
id?: string
|
|
|
|
|
metadata?: string
|
|
|
|
|
type?: string
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
/**
|
|
|
|
|
* Sub-classification within the noun type. Defaults to `'cli-add'` when not
|
|
|
|
|
* supplied so the CLI works against strict-mode brains; production-style
|
|
|
|
|
* ingestion should pass `--subtype` explicitly to use the consumer's
|
|
|
|
|
* registered vocabulary. Added 7.30.1.
|
|
|
|
|
*/
|
|
|
|
|
subtype?: string
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
confidence?: string
|
|
|
|
|
weight?: string
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface SearchOptions extends CoreOptions {
|
|
|
|
|
limit?: string
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
offset?: string
|
2025-08-26 12:32:21 -07:00
|
|
|
threshold?: string
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
type?: string
|
|
|
|
|
where?: string
|
|
|
|
|
near?: string
|
|
|
|
|
connectedTo?: string
|
|
|
|
|
connectedFrom?: string
|
|
|
|
|
via?: string
|
|
|
|
|
explain?: boolean
|
|
|
|
|
includeRelations?: boolean
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
includeVfs?: boolean
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
fusion?: string
|
|
|
|
|
vectorWeight?: string
|
|
|
|
|
graphWeight?: string
|
|
|
|
|
fieldWeight?: string
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GetOptions extends CoreOptions {
|
|
|
|
|
withConnections?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface RelateOptions extends CoreOptions {
|
|
|
|
|
weight?: string
|
|
|
|
|
metadata?: string
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
/**
|
|
|
|
|
* Sub-classification within the verb type. Defaults to `'cli-relate'` when
|
|
|
|
|
* not supplied so the CLI works against strict-mode brains; production-style
|
|
|
|
|
* ingestion should pass `--subtype` explicitly. Added 7.30.1.
|
|
|
|
|
*/
|
|
|
|
|
subtype?: string
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
let brainyInstance: Brainy | null = null
|
2025-08-26 12:32:21 -07:00
|
|
|
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const getBrainy = (): Brainy => {
|
2025-08-26 12:32:21 -07:00
|
|
|
if (!brainyInstance) {
|
2025-09-11 16:23:32 -07:00
|
|
|
brainyInstance = new Brainy()
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
return brainyInstance
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatOutput = (data: any, options: CoreOptions): void => {
|
|
|
|
|
if (options.json) {
|
|
|
|
|
console.log(options.pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const coreCommands = {
|
|
|
|
|
/**
|
|
|
|
|
* Add data to the neural database
|
|
|
|
|
*/
|
2025-10-17 14:47:53 -07:00
|
|
|
async add(text: string | undefined, options: AddOptions) {
|
|
|
|
|
let spinner: any = null
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
2025-10-17 14:47:53 -07:00
|
|
|
// Interactive mode if no text provided
|
|
|
|
|
if (!text) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'content',
|
|
|
|
|
message: 'Enter content:',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'Content cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'nounType',
|
|
|
|
|
message: 'Noun type (optional, press Enter to auto-detect):',
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'metadata',
|
|
|
|
|
message: 'Metadata (JSON, optional):',
|
|
|
|
|
default: '',
|
|
|
|
|
validate: (input: string) => {
|
|
|
|
|
if (!input.trim()) return true
|
|
|
|
|
try {
|
|
|
|
|
JSON.parse(input)
|
|
|
|
|
return true
|
|
|
|
|
} catch {
|
|
|
|
|
return 'Invalid JSON format'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
text = answers.content
|
|
|
|
|
if (answers.nounType) {
|
|
|
|
|
options.type = answers.nounType
|
|
|
|
|
}
|
|
|
|
|
if (answers.metadata) {
|
|
|
|
|
options.metadata = answers.metadata
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const spinner = ora('Adding to neural database...').start()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
let metadata: any = {}
|
|
|
|
|
if (options.metadata) {
|
|
|
|
|
try {
|
|
|
|
|
metadata = JSON.parse(options.metadata)
|
|
|
|
|
} catch {
|
|
|
|
|
spinner.fail('Invalid metadata JSON')
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 14:47:53 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
if (options.id) {
|
|
|
|
|
metadata.id = options.id
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
// Determine noun type
|
|
|
|
|
let nounType: NounType
|
2025-08-26 12:32:21 -07:00
|
|
|
if (options.type) {
|
2025-09-01 09:37:36 -07:00
|
|
|
// Validate provided type
|
|
|
|
|
if (!BrainyTypes.isValidNoun(options.type)) {
|
|
|
|
|
spinner.fail(`Invalid noun type: ${options.type}`)
|
|
|
|
|
console.log(chalk.dim('Run "brainy types --noun" to see valid types'))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
nounType = options.type as NounType
|
|
|
|
|
} else {
|
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.
2026-02-01 10:48:56 -08:00
|
|
|
// Default to Thing when no type specified
|
|
|
|
|
nounType = NounType.Thing
|
|
|
|
|
spinner.text = `No type specified, using default: ${nounType}`
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
// Add with explicit type. Subtype precedence: caller-supplied
|
|
|
|
|
// `--subtype <value>` → Brainy default `'cli-add'`. The default ensures
|
|
|
|
|
// CLI invocations against a strict-mode brain succeed without the user
|
|
|
|
|
// needing to know the vocabulary in advance — for production-style
|
|
|
|
|
// ingestion, pass `--subtype` explicitly (added 7.30.1).
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
const addParams: any = {
|
2025-09-11 16:23:32 -07:00
|
|
|
data: text,
|
|
|
|
|
type: nounType,
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
subtype: options.subtype ?? 'cli-add',
|
2025-09-11 16:23:32 -07:00
|
|
|
metadata
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
}
|
|
|
|
|
|
2026-01-27 15:38:21 -08:00
|
|
|
// Add confidence and weight if provided
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
if (options.confidence) {
|
|
|
|
|
addParams.confidence = parseFloat(options.confidence)
|
|
|
|
|
}
|
|
|
|
|
if (options.weight) {
|
|
|
|
|
addParams.weight = parseFloat(options.weight)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const result = await brain.add(addParams)
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
spinner.succeed('Added successfully')
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
if (!options.json) {
|
|
|
|
|
console.log(chalk.green(`✓ Added with ID: ${result}`))
|
|
|
|
|
if (options.type) {
|
|
|
|
|
console.log(chalk.dim(` Type: ${options.type}`))
|
|
|
|
|
}
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
if (options.confidence) {
|
|
|
|
|
console.log(chalk.dim(` Confidence: ${options.confidence}`))
|
|
|
|
|
}
|
|
|
|
|
if (options.weight) {
|
|
|
|
|
console.log(chalk.dim(` Weight: ${options.weight}`))
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
if (Object.keys(metadata).length > 0) {
|
|
|
|
|
console.log(chalk.dim(` Metadata: ${JSON.stringify(metadata)}`))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
formatOutput({ id: result, metadata, confidence: addParams.confidence, weight: addParams.weight }, options)
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// close() releases the writer lock and indexes, but global timers
|
|
|
|
|
// (UnifiedCache bookkeeping, PathResolver stats) keep the event loop
|
|
|
|
|
// alive. CLI commands are one-shot — exit explicitly.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch (error: any) {
|
2025-10-17 14:47:53 -07:00
|
|
|
if (spinner) spinner.fail('Failed to add data')
|
|
|
|
|
console.error(chalk.red('Failed to add data:', error.message))
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
* Search the neural database with Triple Intelligence™
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-10-17 14:47:53 -07:00
|
|
|
async search(query: string | undefined, options: SearchOptions) {
|
|
|
|
|
let spinner: any = null
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
2025-10-17 14:47:53 -07:00
|
|
|
// Interactive mode if no query provided
|
|
|
|
|
if (!query) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'query',
|
|
|
|
|
message: 'What are you looking for?',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'Query cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'number',
|
|
|
|
|
name: 'limit',
|
|
|
|
|
message: 'Number of results:',
|
|
|
|
|
default: 10
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'useAdvanced',
|
|
|
|
|
message: 'Use advanced filters?',
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
query = answers.query
|
|
|
|
|
if (!options.limit) {
|
|
|
|
|
options.limit = answers.limit.toString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Advanced filters
|
|
|
|
|
if (answers.useAdvanced) {
|
|
|
|
|
const advancedAnswers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'type',
|
|
|
|
|
message: 'Filter by type (optional):',
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'threshold',
|
|
|
|
|
message: 'Similarity threshold (0-1, default 0.7):',
|
|
|
|
|
default: '0.7',
|
|
|
|
|
validate: (input: string) => {
|
|
|
|
|
const num = parseFloat(input)
|
|
|
|
|
return (num >= 0 && num <= 1) || 'Must be between 0 and 1'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'explain',
|
|
|
|
|
message: 'Show scoring breakdown?',
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
if (advancedAnswers.type) options.type = advancedAnswers.type
|
|
|
|
|
if (advancedAnswers.threshold) options.threshold = advancedAnswers.threshold
|
|
|
|
|
options.explain = advancedAnswers.explain
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const spinner = ora('Searching with Triple Intelligence™...').start()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
|
|
|
|
// Build comprehensive search params
|
|
|
|
|
const searchParams: any = {
|
|
|
|
|
query,
|
2025-08-26 12:32:21 -07:00
|
|
|
limit: options.limit ? parseInt(options.limit) : 10
|
|
|
|
|
}
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
|
|
|
|
// Pagination
|
|
|
|
|
if (options.offset) {
|
|
|
|
|
searchParams.offset = parseInt(options.offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Metadata Intelligence - type filtering
|
|
|
|
|
if (options.type) {
|
|
|
|
|
const types = options.type.split(',').map(t => t.trim())
|
|
|
|
|
searchParams.type = types.length === 1 ? types[0] : types
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Metadata Intelligence - field filtering
|
|
|
|
|
if (options.where) {
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
searchParams.where = JSON.parse(options.where)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
spinner.fail('Invalid --where JSON')
|
|
|
|
|
console.log(chalk.dim('Example: --where \'{"status":"active","priority":{"$gte":5}}\''))
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
2026-06-11 10:42:34 -07:00
|
|
|
// Vector Intelligence - proximity search around an anchor entity.
|
|
|
|
|
// `near` requires an id; a bare --threshold (no --near) is applied as a
|
|
|
|
|
// plain score floor on the fused results after find() returns.
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
if (options.near) {
|
|
|
|
|
searchParams.near = {
|
|
|
|
|
id: options.near,
|
|
|
|
|
threshold: options.threshold ? parseFloat(options.threshold) : 0.7
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Graph Intelligence - connection constraints
|
|
|
|
|
if (options.connectedTo || options.connectedFrom || options.via) {
|
|
|
|
|
searchParams.connected = {}
|
|
|
|
|
|
|
|
|
|
if (options.connectedTo) {
|
|
|
|
|
searchParams.connected.to = options.connectedTo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.connectedFrom) {
|
|
|
|
|
searchParams.connected.from = options.connectedFrom
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.via) {
|
|
|
|
|
const vias = options.via.split(',').map(v => v.trim())
|
|
|
|
|
searchParams.connected.via = vias.length === 1 ? vias[0] : vias
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Explanation
|
|
|
|
|
if (options.explain) {
|
|
|
|
|
searchParams.explain = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Include relationships
|
|
|
|
|
if (options.includeRelations) {
|
|
|
|
|
searchParams.includeRelations = true
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 15:38:21 -08:00
|
|
|
// VFS is now part of the knowledge graph (included by default)
|
2025-10-27 10:44:06 -07:00
|
|
|
// Users can exclude VFS with --where vfsType exists:false if needed
|
feat: comprehensive import progress tracking for all 7 formats
Add real-time progress reporting throughout the entire import pipeline
with a standardized API that works across all supported formats.
Workshop Team Feature Request:
- Eliminates "0% complete" hangs during AI extraction
- Shows continuous progress with entities/sec, throughput, ETA
- Reports contextual messages ("Processing page 5 of 23")
- Standardized progress API for CSV, PDF, Excel, JSON, Markdown, YAML, DOCX
Core Changes:
- Add FormatHandlerProgressHooks interface for extensible progress
- Wire up all 3 binary format handlers (CSV, PDF, Excel) with 7+ progress points
- Wire up all 4 text format importers (JSON, Markdown, YAML, DOCX)
- Add ImportProgress interface with stage, message, counts, throughput, ETA
- ImportCoordinator normalizes all format progress to standard interface
CLI Improvements:
- Import command now uses brain.import() directly with full progress
- Add --include-vfs flag to find command (v4.4.0 compatibility)
- Add --confidence and --weight options to add command
Documentation:
- docs/guides/standard-import-progress.md - Universal API guide
- docs/guides/import-progress-implementation.md - Developer guide
- docs/guides/import-progress-examples.md - Practical examples
- JSDoc on brain.import() with universal handler examples
Result: ONE progress handler works for ALL 7 formats with zero format-specific code!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 14:45:46 -07:00
|
|
|
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
// Triple Intelligence Fusion - custom weighting
|
|
|
|
|
if (options.fusion || options.vectorWeight || options.graphWeight || options.fieldWeight) {
|
|
|
|
|
searchParams.fusion = {
|
|
|
|
|
strategy: options.fusion || 'adaptive',
|
|
|
|
|
weights: {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.vectorWeight) {
|
|
|
|
|
searchParams.fusion.weights.vector = parseFloat(options.vectorWeight)
|
|
|
|
|
}
|
|
|
|
|
if (options.graphWeight) {
|
|
|
|
|
searchParams.fusion.weights.graph = parseFloat(options.graphWeight)
|
|
|
|
|
}
|
|
|
|
|
if (options.fieldWeight) {
|
|
|
|
|
searchParams.fusion.weights.field = parseFloat(options.fieldWeight)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 10:42:34 -07:00
|
|
|
let results = await brain.find(searchParams)
|
|
|
|
|
|
|
|
|
|
// Without --near there is no proximity anchor; apply --threshold as a
|
|
|
|
|
// minimum-score filter on the fused results instead.
|
|
|
|
|
if (!options.near && options.threshold) {
|
|
|
|
|
const minScore = parseFloat(options.threshold)
|
|
|
|
|
results = results.filter((r) => r.score === undefined || r.score >= minScore)
|
|
|
|
|
}
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
spinner.succeed(`Found ${results.length} results`)
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
if (!options.json) {
|
|
|
|
|
if (results.length === 0) {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
console.log(chalk.yellow('\nNo results found'))
|
|
|
|
|
|
|
|
|
|
// Show helpful hints
|
|
|
|
|
console.log(chalk.dim('\nTips:'))
|
|
|
|
|
console.log(chalk.dim(' • Try different search terms'))
|
|
|
|
|
console.log(chalk.dim(' • Remove filters (--type, --where, --connected-to)'))
|
|
|
|
|
console.log(chalk.dim(' • Lower the --threshold value'))
|
2025-08-26 12:32:21 -07:00
|
|
|
} else {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
console.log(chalk.cyan(`\n📊 Triple Intelligence Results:\n`))
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
results.forEach((result, i) => {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const entity = result.entity || result
|
|
|
|
|
console.log(chalk.bold(`${i + 1}. ${entity.id}`))
|
|
|
|
|
|
|
|
|
|
// Show score with breakdown
|
2025-08-26 12:32:21 -07:00
|
|
|
if (result.score !== undefined) {
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
console.log(chalk.green(` Score: ${(result.score * 100).toFixed(1)}%`))
|
|
|
|
|
|
|
|
|
|
if (options.explain && (result as any).scores) {
|
|
|
|
|
const scores = (result as any).scores
|
|
|
|
|
if (scores.vector !== undefined) {
|
|
|
|
|
console.log(chalk.dim(` Vector: ${(scores.vector * 100).toFixed(1)}%`))
|
|
|
|
|
}
|
|
|
|
|
if (scores.graph !== undefined) {
|
|
|
|
|
console.log(chalk.dim(` Graph: ${(scores.graph * 100).toFixed(1)}%`))
|
|
|
|
|
}
|
|
|
|
|
if (scores.field !== undefined) {
|
|
|
|
|
console.log(chalk.dim(` Field: ${(scores.field * 100).toFixed(1)}%`))
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
|
|
|
|
// Show type
|
|
|
|
|
if ((entity as any).type) {
|
|
|
|
|
console.log(chalk.dim(` Type: ${(entity as any).type}`))
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
|
|
|
|
// Show content preview
|
|
|
|
|
if ((entity as any).content) {
|
|
|
|
|
const preview = (entity as any).content.substring(0, 80)
|
|
|
|
|
console.log(chalk.dim(` Content: ${preview}${(entity as any).content.length > 80 ? '...' : ''}`))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show metadata
|
|
|
|
|
if ((entity as any).metadata && Object.keys((entity as any).metadata).length > 0) {
|
|
|
|
|
console.log(chalk.dim(` Metadata: ${JSON.stringify((entity as any).metadata)}`))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show relationships
|
|
|
|
|
if (options.includeRelations && (result as any).relations) {
|
|
|
|
|
const relations = (result as any).relations
|
|
|
|
|
if (relations.length > 0) {
|
|
|
|
|
console.log(chalk.dim(` Relations: ${relations.length} connections`))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log()
|
2025-08-26 12:32:21 -07:00
|
|
|
})
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
|
|
|
|
|
// Show search summary
|
|
|
|
|
console.log(chalk.cyan('Search Configuration:'))
|
|
|
|
|
if (searchParams.type) {
|
|
|
|
|
console.log(chalk.dim(` Type filter: ${Array.isArray(searchParams.type) ? searchParams.type.join(', ') : searchParams.type}`))
|
|
|
|
|
}
|
|
|
|
|
if (searchParams.where) {
|
|
|
|
|
console.log(chalk.dim(` Field filter: ${JSON.stringify(searchParams.where)}`))
|
|
|
|
|
}
|
|
|
|
|
if (searchParams.connected) {
|
|
|
|
|
console.log(chalk.dim(` Graph filter: ${JSON.stringify(searchParams.connected)}`))
|
|
|
|
|
}
|
|
|
|
|
if (searchParams.fusion) {
|
|
|
|
|
console.log(chalk.dim(` Fusion: ${searchParams.fusion.strategy}`))
|
|
|
|
|
if (searchParams.fusion.weights && Object.keys(searchParams.fusion.weights).length > 0) {
|
|
|
|
|
console.log(chalk.dim(` Weights: ${JSON.stringify(searchParams.fusion.weights)}`))
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
formatOutput(results, options)
|
|
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch (error: any) {
|
2025-10-17 14:47:53 -07:00
|
|
|
if (spinner) spinner.fail('Search failed')
|
|
|
|
|
console.error(chalk.red('Search failed:', error.message))
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
if (options.verbose) {
|
|
|
|
|
console.error(chalk.dim(error.stack))
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get item by ID
|
|
|
|
|
*/
|
2025-10-17 14:47:53 -07:00
|
|
|
async get(id: string | undefined, options: GetOptions) {
|
|
|
|
|
let spinner: any = null
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
2025-10-17 14:47:53 -07:00
|
|
|
// Interactive mode if no ID provided
|
|
|
|
|
if (!id) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'id',
|
|
|
|
|
message: 'Enter item ID:',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'withConnections',
|
|
|
|
|
message: 'Include connections?',
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
id = answers.id
|
|
|
|
|
options.withConnections = answers.withConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const spinner = ora('Fetching item...').start()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
// Try to get the item
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const item = await brain.get(id)
|
|
|
|
|
|
|
|
|
|
if (!item) {
|
2025-08-26 12:32:21 -07:00
|
|
|
spinner.fail('Item not found')
|
|
|
|
|
console.log(chalk.yellow(`No item found with ID: ${id}`))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
spinner.succeed('Item found')
|
|
|
|
|
|
|
|
|
|
if (!options.json) {
|
|
|
|
|
console.log(chalk.cyan('\nItem Details:'))
|
|
|
|
|
console.log(` ID: ${item.id}`)
|
|
|
|
|
console.log(` Content: ${(item as any).content || 'N/A'}`)
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
if (item.metadata) {
|
|
|
|
|
console.log(` Metadata: ${JSON.stringify(item.metadata, null, 2)}`)
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.withConnections) {
|
|
|
|
|
// Get verbs/relationships
|
|
|
|
|
// Get connections if method exists
|
|
|
|
|
const connections = (brain as any).getConnections ? await (brain as any).getConnections(id) : []
|
|
|
|
|
if (connections && connections.length > 0) {
|
|
|
|
|
console.log(chalk.cyan('\nConnections:'))
|
|
|
|
|
connections.forEach((conn: any) => {
|
|
|
|
|
console.log(` ${conn.source} --[${conn.type}]--> ${conn.target}`)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
formatOutput(item, options)
|
|
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch (error: any) {
|
2025-10-17 14:47:53 -07:00
|
|
|
if (spinner) spinner.fail('Failed to get item')
|
|
|
|
|
console.error(chalk.red('Failed to get item:', error.message))
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create relationship between items
|
|
|
|
|
*/
|
2025-10-17 14:47:53 -07:00
|
|
|
async relate(source: string | undefined, verb: string | undefined, target: string | undefined, options: RelateOptions) {
|
|
|
|
|
let spinner: any = null
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
2025-10-17 14:47:53 -07:00
|
|
|
// Interactive mode if parameters missing
|
|
|
|
|
if (!source || !verb || !target) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'source',
|
|
|
|
|
message: 'Source entity ID:',
|
|
|
|
|
default: source || '',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'Source ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'verb',
|
|
|
|
|
message: 'Relationship type (verb):',
|
|
|
|
|
default: verb || '',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'Verb cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'target',
|
|
|
|
|
message: 'Target entity ID:',
|
|
|
|
|
default: target || '',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'Target ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'weight',
|
|
|
|
|
message: 'Relationship weight (0-1, optional):',
|
|
|
|
|
default: '',
|
|
|
|
|
validate: (input: string) => {
|
|
|
|
|
if (!input.trim()) return true
|
|
|
|
|
const num = parseFloat(input)
|
|
|
|
|
return (num >= 0 && num <= 1) || 'Must be between 0 and 1'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
source = answers.source
|
|
|
|
|
verb = answers.verb
|
|
|
|
|
target = answers.target
|
|
|
|
|
if (answers.weight) {
|
|
|
|
|
options.weight = answers.weight
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const spinner = ora('Creating relationship...').start()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
let metadata: any = {}
|
|
|
|
|
if (options.metadata) {
|
|
|
|
|
try {
|
|
|
|
|
metadata = JSON.parse(options.metadata)
|
|
|
|
|
} catch {
|
|
|
|
|
spinner.fail('Invalid metadata JSON')
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.weight) {
|
|
|
|
|
metadata.weight = parseFloat(options.weight)
|
|
|
|
|
}
|
|
|
|
|
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
// Create the relationship. Subtype precedence: caller-supplied
|
|
|
|
|
// `--subtype <value>` → Brainy default `'cli-relate'`. Same rationale
|
|
|
|
|
// as `brainy add` — guarantees CLI works under strict-mode brains
|
|
|
|
|
// (added 7.30.1).
|
2025-09-11 16:23:32 -07:00
|
|
|
const result = await brain.relate({
|
|
|
|
|
from: source,
|
|
|
|
|
to: target,
|
|
|
|
|
type: verb as any,
|
fix: internal subtype consistency + brain.audit() diagnostic + improved enforcement errors
Brainy 7.30 shipped opt-in subtype enforcement; SDK 3.20.0 then registered
SDK_CORE_VOCABULARY on every consumer's brain (Event, Collection, Message,
Contract, Media, Document NounTypes). On 2026-06-08 Venue's /book flow went 500
because their brain.add({ type: NounType.Event, ... }) call sites lacked
subtype. An audit of Brainy's OWN source revealed 14 HIGH-risk internal write
paths that also omit subtype — any consumer running the same vocabulary would
have hit Brainy's infrastructure paths next. 7.30.1 closes both gaps before
8.0 makes strict mode the default.
Additive across the board. Zero behavior change for consumers not using strict
mode. Every change is JS-side — Cortex needs no work for 7.30.1.
NEW — brain.audit() diagnostic
- Read-only method walking storage.getNouns() / getVerbs() pagination
- Returns { entitiesWithoutSubtype: { type: count }, relationshipsWithoutSubtype,
total, scanned, recommendation }
- VFS infrastructure entities excluded by default (they bypass enforcement via
isVFSEntity marker); pass { includeVFS: true } to surface them
- The companion to migrateField (7.x) and fillSubtypes (8.0): tells consumers
exactly what would break under strict enforcement, deterministically
NEW — Improved enforcement error messages
- Caller's source location extracted from Error().stack so users see their own
call site, not a Brainy internal frame
- Specific guidance branches: registered vocabulary → "Pass one of: a, b, c";
brain-wide strict mode → mentions the except clause; otherwise → registration
recipe via brain.requireSubtype()
- Documentation link to the canonical migration recipe
- Same shape for noun and verb enforcement
NEW — CLI --subtype flag
- brainy add and brainy relate gain -s/--subtype <value>
- Defaults to 'cli-add' / 'cli-relate' so the CLI works against strict-mode
brains without the user needing to know the vocabulary in advance
INTERNAL — every Brainy write path now sets subtype
- VFS Contains edges (5 sites at lines 503/905/1694/1772/1886) → 'vfs-contains'
- VFS symlink entity → 'vfs-symlink' (NEW — distinct from 'vfs-file')
- VFS copy-file → preserves source subtype, falls back to 'vfs-file'
- VFS symlink also adopts the isVFSEntity infrastructure marker so it bypasses
enforcement in strict mode
- Aggregation materializer (Measurement entities) → 'materialized-aggregate'
- ImportCoordinator (3 sites): document → 'import-source'; entities →
options.defaultSubtype ?? 'imported'; placeholder → 'import-placeholder'
- SmartImportOrchestrator (4 entity sites + 2 batch relate sites): same
precedence (extractor → options.defaultSubtype → 'imported')
- EntityDeduplicator → candidate.subtype ?? 'imported'
- UniversalImportAPI → extractor → 'extracted' for both entities and relations
- NeuralImport → adds defaultSubtype to NeuralImportOptions; precedence same
- GoogleSheetsIntegration → request body 'subtype' ?? 'imported-from-sheets'
- ODataIntegration → request body 'Subtype' ?? 'imported-from-odata'
- MCP client message storage → 'mcp-message' (also fixes pre-existing missing
data field and missing type by aliasing from the prior text field)
Side-effect fix: storage.getNouns() paginated now surfaces subtype to top-level
- Single-noun getNoun() already did this in 7.30; the paginated path was missed
- Without this fix brain.audit() saw missing subtype on entities that actually
had one (caught by the strict-mode self-test before release)
NEW — tests/integration/strict-mode-self-test.test.ts (13 tests)
- Creates a brain under the exact SDK_CORE_VOCABULARY shape Venue hit + brain-
wide strict mode
- Exercises every internal Brainy path: VFS root + mkdir + writeFile + cp + mv
+ ln + symlink; aggregation engine; audit diagnostic with includeVFS toggle
- Validates error message UX: caller location, vocabulary guidance, brain-wide
strict mode guidance, off-vocabulary value reporting
Docs
- New "Strict mode in practice" section in docs/guides/subtypes-and-facets.md
covering the SDK_CORE_VOCABULARY pattern, 4-step migration recipe
(audit → migrateField → hand-fix → re-audit), the Brainy-internal label
reference table, and an 8.0 forward-look on fillSubtypes()
- docs/api/README.md: new audit() entry, strict-mode tips on add() and relate()
- RELEASES.md: full 7.30.1 entry
Cortex parity (forward-looking, not blocking 7.30.1)
- 6th open question added to .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md: native
fast path for audit() and fillSubtypes() via column-store null-subtype
bitmap for billion-scale brains
- Cortex should add a parity test mirroring strict-mode-self-test.test.ts
against their native paths to catch any latent bug where native writes
bypass JS validation
- Brainy-internal subtype labels become a documented part of the 8.0 contract
(useful for Cortex telemetry surfacing Brainy-managed infrastructure %)
Verification
- npx tsc --noEmit: clean
- npm test: 1468/1468 unit
- 7.29 noun integration suite: 26/26 (no regression)
- 7.30 verb subtype + enforcement integration suite: 30/30 (no regression)
- New strict-mode-self-test integration suite: 13/13
- npm run build: clean
- Closed-source product reference audit: clean
Addresses VE-SUBTYPE-MIGRATION (Venue's reported request) and ships internal
labels Venue did NOT ask for but that would have broken them next under their
own vocabulary registration.
2026-06-08 11:31:47 -07:00
|
|
|
subtype: options.subtype ?? 'cli-relate',
|
2025-09-11 16:23:32 -07:00
|
|
|
metadata
|
|
|
|
|
})
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
spinner.succeed('Relationship created')
|
|
|
|
|
|
|
|
|
|
if (!options.json) {
|
|
|
|
|
console.log(chalk.green(`✓ Created relationship with ID: ${result}`))
|
|
|
|
|
console.log(chalk.dim(` ${source} --[${verb}]--> ${target}`))
|
|
|
|
|
if (metadata.weight) {
|
|
|
|
|
console.log(chalk.dim(` Weight: ${metadata.weight}`))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
formatOutput({ id: result, source, verb, target, metadata }, options)
|
|
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch (error: any) {
|
2025-10-17 14:47:53 -07:00
|
|
|
if (spinner) spinner.fail('Failed to create relationship')
|
|
|
|
|
console.error(chalk.red('Failed to create relationship:', error.message))
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-17 14:47:53 -07:00
|
|
|
* Update an existing entity
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-10-17 14:47:53 -07:00
|
|
|
async update(id: string | undefined, options: AddOptions & { content?: string }) {
|
|
|
|
|
let spinner: any = null
|
2025-08-26 12:32:21 -07:00
|
|
|
try {
|
2025-10-17 14:47:53 -07:00
|
|
|
// Interactive mode if no ID provided
|
|
|
|
|
if (!id) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'id',
|
|
|
|
|
message: 'Entity ID to update:',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'content',
|
|
|
|
|
message: 'New content (optional, press Enter to skip):',
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'metadata',
|
|
|
|
|
message: 'Metadata to merge (JSON, optional):',
|
|
|
|
|
default: '',
|
|
|
|
|
validate: (input: string) => {
|
|
|
|
|
if (!input.trim()) return true
|
|
|
|
|
try {
|
|
|
|
|
JSON.parse(input)
|
|
|
|
|
return true
|
|
|
|
|
} catch {
|
|
|
|
|
return 'Invalid JSON format'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
id = answers.id
|
|
|
|
|
if (answers.content) {
|
|
|
|
|
options.content = answers.content
|
|
|
|
|
}
|
|
|
|
|
if (answers.metadata) {
|
|
|
|
|
options.metadata = answers.metadata
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spinner = ora('Updating entity...').start()
|
feat: complete CLI with VFS, data management, and Triple Intelligence search
Comprehensive CLI enhancements bringing full Brainy functionality to command line:
- Add complete VFS operations (read, write, ls, stat, mkdir, rm, search, similar, tree)
- Migrate VFS to clean subcommand pattern (brainy vfs read vs brainy vfs-read)
- Add backward compatibility with deprecation warnings for vfs-* commands
- Expose full Triple Intelligence™ search capabilities (vector + graph + field)
- Add simple "find" command mirroring code usage: brain.find("query")
- Add data management commands (backup, restore, detailed stats)
- Remove all fake/mock/stub code from CLI commands
- Fix VFS initialization (add await vfs.init() to all commands)
- Fix utility clean() to use real DataAPI.clear()
- Mark semantic path finding as coming in v3.21.0
CLI now covers 75%+ of Brainy capabilities with production-ready implementations.
2025-09-29 16:57:14 -07:00
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
|
|
|
|
// Get existing entity first
|
|
|
|
|
const existing = await brain.get(id)
|
|
|
|
|
if (!existing) {
|
|
|
|
|
spinner.fail('Entity not found')
|
|
|
|
|
console.log(chalk.yellow(`No entity found with ID: ${id}`))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build update params
|
|
|
|
|
const updateParams: any = { id }
|
|
|
|
|
|
|
|
|
|
if (options.content) {
|
|
|
|
|
updateParams.data = options.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.metadata) {
|
|
|
|
|
try {
|
|
|
|
|
const newMetadata = JSON.parse(options.metadata)
|
|
|
|
|
updateParams.metadata = {
|
|
|
|
|
...existing.metadata,
|
|
|
|
|
...newMetadata
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
2025-10-17 14:47:53 -07:00
|
|
|
} catch {
|
|
|
|
|
spinner.fail('Invalid metadata JSON')
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
2025-10-17 14:47:53 -07:00
|
|
|
|
|
|
|
|
if (options.type) {
|
|
|
|
|
updateParams.type = options.type
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await brain.update(updateParams)
|
|
|
|
|
|
|
|
|
|
spinner.succeed('Entity updated successfully')
|
|
|
|
|
|
|
|
|
|
if (!options.json) {
|
|
|
|
|
console.log(chalk.green(`✓ Updated entity: ${id}`))
|
|
|
|
|
if (options.content) {
|
|
|
|
|
console.log(chalk.dim(` New content: ${options.content.substring(0, 80)}...`))
|
|
|
|
|
}
|
|
|
|
|
if (updateParams.metadata) {
|
|
|
|
|
console.log(chalk.dim(` Metadata: ${JSON.stringify(updateParams.metadata)}`))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
formatOutput({ id, updated: true }, options)
|
|
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-10-17 14:47:53 -07:00
|
|
|
} catch (error: any) {
|
|
|
|
|
if (spinner) spinner.fail('Failed to update entity')
|
|
|
|
|
console.error(chalk.red('Update failed:', error.message))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete an entity
|
|
|
|
|
*/
|
|
|
|
|
async deleteEntity(id: string | undefined, options: CoreOptions & { force?: boolean }) {
|
|
|
|
|
let spinner: any = null
|
|
|
|
|
try {
|
|
|
|
|
// Interactive mode if no ID provided
|
|
|
|
|
if (!id) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'id',
|
|
|
|
|
message: 'Entity ID to delete:',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'confirm',
|
|
|
|
|
message: 'Are you sure? This cannot be undone.',
|
|
|
|
|
default: false
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
2025-10-17 14:47:53 -07:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
if (!answers.confirm) {
|
|
|
|
|
console.log(chalk.yellow('Delete cancelled'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id = answers.id
|
|
|
|
|
} else if (!options.force) {
|
|
|
|
|
// Confirmation for non-interactive mode
|
|
|
|
|
const answer = await inquirer.prompt([{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'confirm',
|
|
|
|
|
message: `Delete entity ${id}? This cannot be undone.`,
|
|
|
|
|
default: false
|
|
|
|
|
}])
|
|
|
|
|
|
|
|
|
|
if (!answer.confirm) {
|
|
|
|
|
console.log(chalk.yellow('Delete cancelled'))
|
|
|
|
|
return
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 14:47:53 -07:00
|
|
|
|
|
|
|
|
spinner = ora('Deleting entity...').start()
|
|
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
|
|
|
|
await brain.delete(id)
|
|
|
|
|
|
|
|
|
|
spinner.succeed('Entity deleted successfully')
|
|
|
|
|
|
|
|
|
|
if (!options.json) {
|
|
|
|
|
console.log(chalk.green(`✓ Deleted entity: ${id}`))
|
|
|
|
|
} else {
|
|
|
|
|
formatOutput({ id, deleted: true }, options)
|
|
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-10-17 14:47:53 -07:00
|
|
|
} catch (error: any) {
|
|
|
|
|
if (spinner) spinner.fail('Failed to delete entity')
|
|
|
|
|
console.error(chalk.red('Delete failed:', error.message))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove a relationship
|
|
|
|
|
*/
|
|
|
|
|
async unrelate(id: string | undefined, options: CoreOptions & { force?: boolean }) {
|
|
|
|
|
let spinner: any = null
|
|
|
|
|
try {
|
|
|
|
|
// Interactive mode if no ID provided
|
|
|
|
|
if (!id) {
|
|
|
|
|
const answers = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'input',
|
|
|
|
|
name: 'id',
|
|
|
|
|
message: 'Relationship ID to remove:',
|
|
|
|
|
validate: (input: string) => input.trim().length > 0 || 'ID cannot be empty'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'confirm',
|
|
|
|
|
message: 'Remove this relationship?',
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
if (!answers.confirm) {
|
|
|
|
|
console.log(chalk.yellow('Operation cancelled'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id = answers.id
|
|
|
|
|
} else if (!options.force) {
|
|
|
|
|
const answer = await inquirer.prompt([{
|
|
|
|
|
type: 'confirm',
|
|
|
|
|
name: 'confirm',
|
|
|
|
|
message: `Remove relationship ${id}?`,
|
|
|
|
|
default: false
|
|
|
|
|
}])
|
|
|
|
|
|
|
|
|
|
if (!answer.confirm) {
|
|
|
|
|
console.log(chalk.yellow('Operation cancelled'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spinner = ora('Removing relationship...').start()
|
|
|
|
|
const brain = getBrainy()
|
2026-06-11 10:42:34 -07:00
|
|
|
await brain.init()
|
2025-10-17 14:47:53 -07:00
|
|
|
|
|
|
|
|
await brain.unrelate(id)
|
|
|
|
|
|
|
|
|
|
spinner.succeed('Relationship removed successfully')
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
if (!options.json) {
|
2025-10-17 14:47:53 -07:00
|
|
|
console.log(chalk.green(`✓ Removed relationship: ${id}`))
|
2025-08-26 12:32:21 -07:00
|
|
|
} else {
|
2025-10-17 14:47:53 -07:00
|
|
|
formatOutput({ id, removed: true }, options)
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2025-08-26 12:32:21 -07:00
|
|
|
} catch (error: any) {
|
2025-10-17 14:47:53 -07:00
|
|
|
if (spinner) spinner.fail('Failed to remove relationship')
|
|
|
|
|
console.error(chalk.red('Unrelate failed:', error.message))
|
2025-08-26 12:32:21 -07:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-02-01 13:03:15 -08:00
|
|
|
/**
|
|
|
|
|
* Show plugin and provider diagnostics
|
|
|
|
|
*/
|
|
|
|
|
async diagnostics(options: CoreOptions) {
|
|
|
|
|
try {
|
|
|
|
|
const brain = getBrainy()
|
|
|
|
|
await brain.init()
|
|
|
|
|
|
|
|
|
|
const diag = brain.diagnostics()
|
|
|
|
|
|
|
|
|
|
if (options.json) {
|
|
|
|
|
formatOutput(diag, options)
|
2026-06-11 10:42:34 -07:00
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2026-02-01 13:03:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(chalk.bold('\nBrainy Diagnostics'))
|
|
|
|
|
console.log(chalk.dim(`Version: ${diag.version}`))
|
|
|
|
|
console.log()
|
|
|
|
|
|
|
|
|
|
// Plugins
|
|
|
|
|
console.log(chalk.bold('Plugins:'))
|
|
|
|
|
if (diag.plugins.count === 0) {
|
|
|
|
|
console.log(chalk.dim(' (none active)'))
|
|
|
|
|
} else {
|
|
|
|
|
for (const name of diag.plugins.active) {
|
|
|
|
|
console.log(chalk.green(` ✓ ${name}`))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log()
|
|
|
|
|
|
|
|
|
|
// Providers
|
|
|
|
|
console.log(chalk.bold('Providers:'))
|
|
|
|
|
for (const [key, info] of Object.entries(diag.providers)) {
|
|
|
|
|
const icon = info.source === 'plugin' ? chalk.green('✓ plugin') : chalk.dim('default')
|
|
|
|
|
console.log(` ${key.padEnd(16)} ${icon}`)
|
|
|
|
|
}
|
|
|
|
|
console.log()
|
|
|
|
|
|
|
|
|
|
// Indexes
|
|
|
|
|
console.log(chalk.bold('Indexes:'))
|
|
|
|
|
console.log(` HNSW: ${diag.indexes.hnsw.type} (${diag.indexes.hnsw.size} vectors)`)
|
|
|
|
|
console.log(` Metadata: ${diag.indexes.metadata.type} (initialized: ${diag.indexes.metadata.initialized})`)
|
|
|
|
|
console.log(` Graph: ${diag.indexes.graph.type} (initialized: ${diag.indexes.graph.initialized}, wired: ${diag.indexes.graph.wiredToStorage})`)
|
|
|
|
|
console.log()
|
2026-06-11 10:42:34 -07:00
|
|
|
|
|
|
|
|
// One-shot command — see add() for why the explicit close + exit.
|
|
|
|
|
await brain.close()
|
|
|
|
|
process.exit(0)
|
2026-02-01 13:03:15 -08:00
|
|
|
} catch (error: any) {
|
|
|
|
|
console.error(chalk.red('Diagnostics failed: ' + error.message))
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
}
|