Initial commit: Cortex — AI project memory & knowledge graph
SQLite-backed knowledge graph with CLI interface. Supports nodes (memory, component, task, decision) connected by typed edges, with hybrid search (BM25 + Ollama embeddings).
This commit is contained in:
23
src/cli/commands/remove.ts
Normal file
23
src/cli/commands/remove.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Command } from 'commander';
|
||||
import chalk from 'chalk';
|
||||
import { findNodeByPrefix, removeNode } from '../../core/store';
|
||||
|
||||
export const removeCommand = new Command('remove')
|
||||
.argument('<id>', 'Node ID (or prefix)')
|
||||
.option('--hard', 'Permanently delete (default: soft delete / mark stale)')
|
||||
.description('Remove a node')
|
||||
.action(async (idRaw: string, opts) => {
|
||||
const node = findNodeByPrefix(idRaw);
|
||||
if (!node) {
|
||||
console.error(chalk.red(`Node not found: ${idRaw}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const success = removeNode(node.id, opts.hard);
|
||||
if (success) {
|
||||
const method = opts.hard ? 'Deleted' : 'Marked stale';
|
||||
console.log(chalk.green(`✓ ${method}: [${node.kind}] ${node.title}`));
|
||||
} else {
|
||||
console.error(chalk.red('Remove failed.'));
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user