Merge branch 'cw/radar-screen-performance' into cw-merge-1772829950184

This commit is contained in:
Lukas May
2026-03-06 21:45:50 +01:00
16 changed files with 3684 additions and 233 deletions

View File

@@ -13,6 +13,8 @@ import { createDefaultTrpcClient } from './trpc-client.js';
import { createContainer } from '../container.js';
import { findWorkspaceRoot, writeCwrc, defaultCwConfig } from '../config/index.js';
import { createModuleLogger } from '../logger/index.js';
import { backfillMetricsFromPath } from '../scripts/backfill-metrics.js';
import { getDbPath } from '../db/index.js';
/** Environment variable for custom port */
const CW_PORT_ENV = 'CW_PORT';
@@ -134,6 +136,22 @@ export function createCli(serverHandler?: (port?: number) => Promise<void>): Com
}
});
// Backfill metrics command (standalone — no server, no tRPC)
program
.command('backfill-metrics')
.description('Populate agent_metrics table from existing agent_log_chunks (run once after upgrading)')
.option('--db <path>', 'Path to the SQLite database file (defaults to configured DB path)')
.action(async (options: { db?: string }) => {
const dbPath = options.db ?? getDbPath();
console.log(`Backfilling metrics from ${dbPath}...`);
try {
await backfillMetricsFromPath(dbPath);
} catch (error) {
console.error('Backfill failed:', (error as Error).message);
process.exit(1);
}
});
// Agent command group
const agentCommand = program
.command('agent')