UNPKG

@fromsvenwithlove/devops-issues-cli

Version:

AI-powered CLI tool and library for Azure DevOps work item management with Claude agents

84 lines (73 loc) โ€ข 1.89 kB
import Table from 'cli-table3'; import chalk from 'chalk'; export function formatWorkItemsAsTable(workItems) { const table = new Table({ head: [ chalk.cyan('ID'), chalk.cyan('Title'), chalk.cyan('Type'), chalk.cyan('State') ], colWidths: [10, 60, 15, 15], wordWrap: true }); workItems.forEach(item => { table.push([ chalk.yellow(`#${item.id}`), item.title, getTypeIcon(item.type) + ' ' + item.type, getStateColor(item.state)(item.state) ]); }); return table.toString(); } export function formatWorkItemsAsJson(workItems) { return JSON.stringify(workItems, null, 2); } export function formatWorkItemsMinimal(workItems) { return workItems .map(item => `#${item.id} ${item.title}`) .join('\n'); } export function formatSummary(workItems) { const summary = workItems.reduce((acc, item) => { acc[item.state] = (acc[item.state] || 0) + 1; return acc; }, {}); const summaryLines = [ '', chalk.bold('Summary:'), `Total: ${chalk.yellow(workItems.length)} work item${workItems.length !== 1 ? 's' : ''}` ]; Object.entries(summary) .sort(([, a], [, b]) => b - a) .forEach(([state, count]) => { summaryLines.push(` ${getStateColor(state)(state)}: ${count}`); }); return summaryLines.join('\n'); } function getTypeIcon(type) { const icons = { 'Bug': '๐Ÿ›', 'Task': '๐Ÿ“‹', 'User Story': '๐Ÿ“–', 'Feature': 'โœจ', 'Epic': '๐ŸŽฏ', 'Issue': 'โ—', 'Test Case': '๐Ÿงช' }; return icons[type] || '๐Ÿ“„'; } function getStateColor(state) { const colors = { 'New': chalk.blue, 'Active': chalk.yellow, 'Resolved': chalk.green, 'Closed': chalk.gray, 'Removed': chalk.red, 'Done': chalk.green, 'In Progress': chalk.yellow, 'To Do': chalk.blue }; return colors[state] || chalk.white; }