context-forge
Version:
AI orchestration platform with autonomous teams, enhancement planning, migration tools, 25+ slash commands, checkpoints & hooks. Multi-IDE: Claude, Cursor, Windsurf, Cline, Copilot
218 lines โข 10.2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dashboardCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const progressTracker_1 = require("../../services/progressTracker");
const projectAnalyzer_1 = require("../../services/projectAnalyzer");
exports.dashboardCommand = new commander_1.Command('dashboard')
.description('Show progress dashboard and project status')
.option('-w, --watch', 'watch mode - continuously update dashboard')
.option('-h, --history', 'show full operation history')
.option('-s, --summary', 'show summary statistics only')
.option('--clear-old [days]', 'clear operations older than specified days (default: 30)', '30')
.action(async (options) => {
const tracker = new progressTracker_1.ProgressTracker();
if (options.clearOld) {
const days = parseInt(options.clearOld);
const removed = await tracker.clearHistory(days);
console.log(chalk_1.default.green(`โ
Cleared ${removed} operations older than ${days} days\n`));
return;
}
if (options.watch) {
await watchDashboard(tracker);
}
else if (options.history) {
await showFullHistory(tracker);
}
else if (options.summary) {
await showSummary(tracker);
}
else {
await showDashboard(tracker);
}
});
async function showDashboard(tracker) {
console.clear();
console.log(chalk_1.default.blue.bold('๐ Context Forge Dashboard\n'));
// Current operation
const currentOp = await tracker.getCurrentOperation();
if (currentOp) {
console.log(chalk_1.default.yellow.bold('๐ Current Operation'));
displayOperation(currentOp, true);
console.log('');
}
// Summary statistics
const summary = await tracker.getProgressSummary();
console.log(chalk_1.default.cyan.bold('๐ Summary Statistics'));
displaySummaryStats(summary);
console.log('');
// Recent activity
if (summary.recentActivity.length > 0) {
console.log(chalk_1.default.cyan.bold('๐
Recent Activity (Last 7 days)'));
summary.recentActivity.slice(0, 5).forEach((op) => {
displayOperation(op, false);
});
console.log('');
}
// Project status
await showProjectStatus();
console.log(chalk_1.default.gray('๐ก Use --watch for real-time updates, --history for full history'));
}
async function watchDashboard(tracker) {
console.log(chalk_1.default.blue.bold('๐ Watch Mode - Press Ctrl+C to exit\n'));
const updateInterval = 2000; // 2 seconds
const update = async () => {
console.clear();
console.log(chalk_1.default.blue.bold('๐ Context Forge Dashboard (Live)\n'));
console.log(chalk_1.default.gray(`Last updated: ${new Date().toLocaleTimeString()}\n`));
const currentOp = await tracker.getCurrentOperation();
if (currentOp) {
console.log(chalk_1.default.yellow.bold('๐ Current Operation'));
displayOperation(currentOp, true);
console.log('');
}
else {
console.log(chalk_1.default.gray('๐ค No operations in progress\n'));
}
const summary = await tracker.getProgressSummary();
console.log(chalk_1.default.cyan.bold('๐ Quick Stats'));
console.log(`Total: ${summary.totalOperations} | Completed: ${chalk_1.default.green(summary.completedOperations)} | Failed: ${chalk_1.default.red(summary.failedOperations)} | Success Rate: ${chalk_1.default.yellow(summary.successRate.toFixed(1))}%\n`);
if (summary.recentActivity.length > 0) {
console.log(chalk_1.default.cyan.bold('๐
Recent (Last 3)'));
summary.recentActivity.slice(0, 3).forEach((op) => {
displayOperation(op, false);
});
}
console.log(chalk_1.default.gray('\n๐ Updating every 2 seconds... Press Ctrl+C to exit'));
};
// Initial update
await update();
// Set up interval
const interval = setInterval(update, updateInterval);
// Handle Ctrl+C
process.on('SIGINT', () => {
clearInterval(interval);
console.log(chalk_1.default.yellow('\n๐ Dashboard watch stopped'));
process.exit(0);
});
}
async function showFullHistory(tracker) {
console.log(chalk_1.default.blue.bold('๐ Full Operation History\n'));
const progress = await tracker.getProgress();
if (progress.length === 0) {
console.log(chalk_1.default.gray('No operations found'));
return;
}
// Group by date
const groupedByDate = progress.reduce((groups, op) => {
const date = op.startTime.toDateString();
if (!groups[date])
groups[date] = [];
groups[date].push(op);
return groups;
}, {});
Object.entries(groupedByDate)
.sort(([a], [b]) => new Date(b).getTime() - new Date(a).getTime())
.forEach(([date, ops]) => {
console.log(chalk_1.default.cyan.bold(`๐
${date}`));
ops.forEach((op) => displayOperation(op, false));
console.log('');
});
}
async function showSummary(tracker) {
console.log(chalk_1.default.blue.bold('๐ Summary Statistics\n'));
const summary = await tracker.getProgressSummary();
displaySummaryStats(summary);
}
function displayOperation(op, detailed = false) {
const icon = new progressTracker_1.ProgressTracker().getStatusIcon(op.status);
const color = new progressTracker_1.ProgressTracker().getStatusColor(op.status);
const duration = op.duration ? new progressTracker_1.ProgressTracker().formatDuration(op.duration) : 'ongoing';
console.log(`${icon} ${chalk_1.default[color](op.command)} - ${op.operation}`);
console.log(` ${chalk_1.default.gray(`Started: ${op.startTime.toLocaleString()}`)} ${op.duration ? chalk_1.default.gray(`โข Duration: ${duration}`) : ''}`);
if (op.metadata) {
const details = [];
if (op.metadata.filesGenerated)
details.push(`${op.metadata.filesGenerated} files`);
if (op.metadata.targetIDEs)
details.push(`IDEs: ${op.metadata.targetIDEs.join(', ')}`);
if (op.metadata.features)
details.push(`${op.metadata.features.length} features`);
if (op.metadata.phases)
details.push(`${op.metadata.phases} phases`);
if (op.metadata.aiEnabled !== undefined)
details.push(`AI: ${op.metadata.aiEnabled ? 'enabled' : 'disabled'}`);
if (details.length > 0) {
console.log(` ${chalk_1.default.gray(details.join(' โข '))}`);
}
}
if (detailed && op.steps && op.steps.length > 0) {
console.log(chalk_1.default.gray(' Steps:'));
op.steps.forEach((step) => {
const stepIcon = step.status === 'completed'
? 'โ'
: step.status === 'failed'
? 'โ'
: step.status === 'in_progress'
? 'โ'
: 'โ';
const stepColor = step.status === 'completed'
? 'green'
: step.status === 'failed'
? 'red'
: step.status === 'in_progress'
? 'yellow'
: 'gray';
console.log(` ${chalk_1.default[stepColor](stepIcon)} ${step.name}`);
});
}
if (op.metadata?.errors && op.metadata.errors.length > 0) {
console.log(` ${chalk_1.default.red('Errors:')} ${op.metadata.errors.join(', ')}`);
}
if (op.metadata?.warnings && op.metadata.warnings.length > 0) {
console.log(` ${chalk_1.default.yellow('Warnings:')} ${op.metadata.warnings.join(', ')}`);
}
}
function displaySummaryStats(summary) {
const successRate = summary.successRate;
const avgDuration = summary.averageDuration;
console.log(`๐ Total Operations: ${chalk_1.default.white.bold(summary.totalOperations)}`);
console.log(`โ
Completed: ${chalk_1.default.green.bold(summary.completedOperations)}`);
console.log(`โ Failed: ${chalk_1.default.red.bold(summary.failedOperations)}`);
console.log(`๐ In Progress: ${chalk_1.default.yellow.bold(summary.inProgressOperations)}`);
console.log(`๐ฏ Success Rate: ${chalk_1.default[successRate >= 90 ? 'green' : successRate >= 70 ? 'yellow' : 'red'].bold(successRate.toFixed(1))}%`);
if (avgDuration > 0) {
const formattedDuration = new progressTracker_1.ProgressTracker().formatDuration(avgDuration);
console.log(`โฑ๏ธ Average Duration: ${chalk_1.default.cyan.bold(formattedDuration)}`);
}
}
async function showProjectStatus() {
try {
console.log(chalk_1.default.cyan.bold('๐๏ธ Project Status'));
const analyzer = new projectAnalyzer_1.ProjectAnalyzer(process.cwd());
const analysis = await analyzer.analyzeBasic();
console.log(`๐ Project Type: ${chalk_1.default.white(analysis.projectType)}`);
console.log(`๐ ๏ธ Tech Stack: ${chalk_1.default.white(analysis.techStack.join(', '))}`);
console.log(`๐ Files: ${chalk_1.default.white(analysis.fileStats.total)} total, ${chalk_1.default.white(analysis.fileStats.components)} components, ${chalk_1.default.white(analysis.fileStats.routes)} routes`);
if (analysis.fileStats.tests > 0) {
console.log(`๐งช Tests: ${chalk_1.default.green(analysis.fileStats.tests)} test files`);
}
else {
console.log(`๐งช Tests: ${chalk_1.default.red('No test files found')}`);
}
if (analysis.existingDocs.length > 0) {
console.log(`๐ Documentation: ${chalk_1.default.green(analysis.existingDocs.join(', '))}`);
}
else {
console.log(`๐ Documentation: ${chalk_1.default.yellow('No docs found')}`);
}
}
catch {
console.log(chalk_1.default.gray('๐๏ธ Project Status: Unable to analyze current directory'));
}
}
//# sourceMappingURL=dashboard.js.map