/** * brainbank context — DEPRECATED, use `brainbank query` instead. * * Kept as fallback. Subcommands (add/list) remain here since they are * context-metadata specific, not query-related. */ import { c, args, stripFlags, findDocsPlugin } from '@/cli/utils.ts'; import { createBrain } from '@/cli/factory/index.ts'; import { cmdQuery } from './query.ts'; export async function cmdContext(): Promise { const pos = stripFlags(args); const sub = pos[1]; // brainbank context add if (sub === 'add') { const collection = pos[2]; const path = pos[3]; const desc = pos.slice(4).join(' '); if (!collection || !path || !desc) { console.log(c.red('Usage: brainbank context add ')); process.exit(1); } const brain = await createBrain(); await brain.initialize(); const docsPlugin = findDocsPlugin(brain); if (!docsPlugin) { console.log(c.red('Docs plugin not loaded.')); process.exit(1); } docsPlugin.addContext(collection, path, desc); console.log(c.green(`✓ Context added: ${collection}:${path} → "${desc}"`)); brain.close(); return; } // brainbank context list if (sub === 'list') { const brain = await createBrain(); await brain.initialize(); const docsPlugin = findDocsPlugin(brain); if (!docsPlugin) { console.log(c.yellow(' Docs plugin not loaded.')); brain.close(); return; } const contexts = docsPlugin.listContexts(); if (contexts.length === 0) { console.log(c.yellow(' No contexts configured.')); } else { console.log(c.bold('\n━━━ Contexts ━━━\n')); for (const ctx of contexts) { console.log(` ${c.cyan(ctx.collection)}:${ctx.path} → ${c.dim(ctx.context)}`); } } brain.close(); return; } // brainbank context → delegate to query (deprecated) console.error(c.yellow('⚠ `brainbank context` is deprecated — use `brainbank query` instead.\n')); return cmdQuery(); }