feat: add doctor and status commands to CLI
- Implemented the `doctor` command to run health checks on the claude-mem installation, with an option to output results as JSON. - Implemented the `status` command to display the system status of claude-mem. - Updated the `doctor` command to use `HooksDatabase` for SQLite connectivity checks. - Removed unused session management code from the `status` command for cleaner output.
This commit is contained in:
Vendored
+75
-74
File diff suppressed because one or more lines are too long
@@ -14,6 +14,8 @@ import { trash } from '../commands/trash.js';
|
||||
import { viewTrash } from '../commands/trash-view.js';
|
||||
import { emptyTrash } from '../commands/trash-empty.js';
|
||||
import { restore } from '../commands/restore.js';
|
||||
import { doctor } from '../commands/doctor.js';
|
||||
import { status } from '../commands/status.js';
|
||||
|
||||
const program = new Command();
|
||||
// </Block> =======================================
|
||||
@@ -117,6 +119,19 @@ program
|
||||
.command('restore')
|
||||
.description('Restore files from trash interactively')
|
||||
.action(restore);
|
||||
|
||||
// Doctor command
|
||||
program
|
||||
.command('doctor')
|
||||
.description('Run health checks on claude-mem installation')
|
||||
.option('--json', 'Output results as JSON')
|
||||
.action(doctor);
|
||||
|
||||
// Status command
|
||||
program
|
||||
.command('status')
|
||||
.description('Show claude-mem system status')
|
||||
.action(status);
|
||||
// </Block> =======================================
|
||||
|
||||
// <Block> 1.9 ====================================
|
||||
|
||||
@@ -2,7 +2,7 @@ import { OptionValues } from 'commander';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { PathDiscovery } from '../services/path-discovery.js';
|
||||
import { createStores } from '../services/sqlite/index.js';
|
||||
import { HooksDatabase } from '../services/sqlite/index.js';
|
||||
|
||||
type CheckStatus = 'pass' | 'fail' | 'warn';
|
||||
|
||||
@@ -51,14 +51,12 @@ export async function doctor(options: OptionValues = {}): Promise<void> {
|
||||
}
|
||||
|
||||
// SQLite connectivity
|
||||
let stores; // reuse for queue check
|
||||
try {
|
||||
stores = await createStores();
|
||||
const sessionCount = stores.sessions.count();
|
||||
const db = new HooksDatabase();
|
||||
checks.push({
|
||||
name: 'SQLite database',
|
||||
status: 'pass',
|
||||
details: `${sessionCount} session${sessionCount === 1 ? '' : 's'} present`
|
||||
details: 'connected'
|
||||
});
|
||||
} catch (error: any) {
|
||||
checks.push({
|
||||
|
||||
+1
-27
@@ -3,8 +3,7 @@ import { join, resolve, dirname } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { PathDiscovery } from '../services/path-discovery.js';
|
||||
import { DatabaseManager } from '../services/sqlite/Database.js';
|
||||
import { SessionStore } from '../services/sqlite/SessionStore.js';
|
||||
import { HooksDatabase } from '../services/sqlite/index.js';
|
||||
import chalk from 'chalk';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
@@ -120,31 +119,6 @@ export async function status(): Promise<void> {
|
||||
console.log(` 📍 Data location: ${pathDiscovery.getChromaDirectory()}`);
|
||||
console.log(' 🔍 Features: Vector search, semantic similarity, document storage');
|
||||
|
||||
console.log('');
|
||||
|
||||
console.log('🤖 Claude Agent SDK Sessions:');
|
||||
try {
|
||||
const dbManager = DatabaseManager.getInstance();
|
||||
await dbManager.initialize();
|
||||
const sessionStore = new SessionStore();
|
||||
const sessions = sessionStore.getAll();
|
||||
|
||||
if (sessions.length === 0) {
|
||||
console.log(chalk.gray(' No active sessions'));
|
||||
} else {
|
||||
const activeCount = sessions.filter(s => {
|
||||
const daysSinceUse = (Date.now() - s.last_used_epoch) / (1000 * 60 * 60 * 24);
|
||||
return daysSinceUse < 7;
|
||||
}).length;
|
||||
|
||||
console.log(` 📊 Total sessions: ${sessions.length}`);
|
||||
console.log(` ✅ Active (< 7 days): ${activeCount}`);
|
||||
console.log(chalk.dim(` 💡 View details: claude-mem sessions list`));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(chalk.gray(' ⚠️ Could not load session info'));
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
console.log('📊 Summary:');
|
||||
|
||||
Reference in New Issue
Block a user