@ace-sdk/cli
Version:
ACE CLI - Command-line tool for intelligent pattern learning and playbook management
56 lines • 2.35 kB
JavaScript
/**
* Playbook output formatter
*/
import chalk from 'chalk';
/**
* Format playbook for human-readable output
*/
export function formatPlaybook(playbook, options = {}) {
const sections = [
{ key: 'strategies_and_hard_rules', label: 'Strategies & Hard Rules', color: chalk.green },
{ key: 'useful_code_snippets', label: 'Useful Code Snippets', color: chalk.blue },
{ key: 'troubleshooting_and_pitfalls', label: 'Troubleshooting & Pitfalls', color: chalk.yellow },
{ key: 'apis_to_use', label: 'APIs to Use', color: chalk.magenta }
];
console.log(chalk.bold('\n📚 ACE Playbook\n'));
for (const { key, label, color } of sections) {
// Skip if filtering by section
if (options.section && options.section !== key) {
continue;
}
const bullets = playbook[key] || [];
// Filter by helpful score if requested
let filteredBullets = bullets;
if (options.minHelpful !== undefined) {
filteredBullets = bullets.filter((b) => (b.helpful || 0) >= options.minHelpful);
}
if (filteredBullets.length === 0) {
continue;
}
console.log(color.bold(`▸ ${label} (${filteredBullets.length})\n`));
filteredBullets.forEach((bullet, index) => {
const score = bullet.helpful ? chalk.green(`+${bullet.helpful}`) :
bullet.harmful ? chalk.red(`-${bullet.harmful}`) :
chalk.dim('0');
console.log(` ${chalk.dim(`${index + 1}.`)} ${score} ${bullet.content}`);
if (options.verbose && bullet.evidence && bullet.evidence.length > 0) {
console.log(chalk.dim(` Evidence: ${bullet.evidence.join(', ')}`));
}
if (options.verbose && bullet.id) {
console.log(chalk.dim(` ID: ${bullet.id}`));
}
console.log('');
});
}
}
/**
* Format a single pattern/bullet
*/
export function formatBullet(bullet, index) {
const score = bullet.helpful ? chalk.green(`+${bullet.helpful}`) :
bullet.harmful ? chalk.red(`-${bullet.harmful}`) :
chalk.dim('0');
const prefix = index !== undefined ? chalk.dim(`${index}.`) : '';
return ` ${prefix} ${score} ${bullet.content}`;
}
//# sourceMappingURL=playbook-formatter.js.map