cortxt
Version:
AI-friendly CLI to share project context or file code easily. The fastest way to provide project context to AI intelligence like ChatGPT, Claude, and other AI assistants.
92 lines (74 loc) ⢠2.85 kB
JavaScript
import chalk from "chalk";
// Brand colors and styles
export const colors = {
// Brand
brand: chalk.hex("#6366f1"),
logo: chalk.hex("#6366f1").bold,
// Success states
success: chalk.green.bold,
checkmark: chalk.green("ā
"),
// Info states
info: chalk.cyan,
scanning: chalk.cyan("š"),
folder: chalk.blue("š"),
file: chalk.gray("š"),
// Warning states
warning: chalk.yellow.bold,
warningIcon: chalk.yellow("ā ļø"),
// Error states
error: chalk.red.bold,
errorIcon: chalk.red("ā"),
// Stats and numbers
number: chalk.magenta.bold,
size: chalk.cyan,
percentage: chalk.yellow,
// Code and paths
code: chalk.gray,
path: chalk.dim,
filename: chalk.white.bold,
// Decorative
separator: chalk.gray("ā".repeat(20)),
bullet: chalk.dim("ā¢"),
arrow: chalk.dim("ā"),
// Dropdown selection symbols
symbols: {
cursor: chalk.cyan("ā¶"), // current cursor
dot: chalk.yellow("ā¢"), // not selected
dotSelected: chalk.green("ā"), // selected
},
// Progress
progressFilled: chalk.green("ā"),
progressEmpty: chalk.gray("ā"),
};
// Helper functions for common UI patterns
export const ui = {
header: (text) => colors.brand.bold(`\nš§ ${text}\n`),
success: (text) => `${colors.checkmark} ${colors.success(text)}`,
info: (text) => `${colors.scanning} ${colors.info(text)}`,
warning: (text) => `${colors.warningIcon} ${colors.warning(text)}`,
error: (text) => `${colors.errorIcon} ${colors.error(text)}`,
fileCount: (count) => `${colors.file} ${colors.number(count)} files`,
fileSize: (size) => colors.size(`(${size})`),
progress: (current, total, width = 20) => {
const progress = current / total;
const filled = Math.round(progress * width);
const empty = width - filled;
const percentage = Math.round(progress * 100);
return `[${colors.progressFilled.repeat(filled)}${colors.progressEmpty.repeat(empty)}] ${colors.percentage(percentage + "%")}`;
},
separator: () => colors.separator,
tip: (text) => colors.info(`š” ${text}`),
treeItem: (icon, name, isLast = false) => {
const connector = isLast ? "āāā " : "āāā ";
return `${colors.path(connector)}${icon} ${colors.filename(name)}`;
},
stat: (label, value, unit = "") => {
return `${colors.path(" ")}${colors.code(label.padEnd(15))} ${colors.number(value)} ${colors.dim(unit)}`;
},
dropdownItem: (text, isHighlighted, isSelected) => {
const symbol = isSelected ? colors.symbols.dotSelected : colors.symbols.dot;
const cursor = isHighlighted ? colors.symbols.cursor : " ";
const color = isSelected ? chalk.green.bold : chalk.yellow;
return `${cursor} ${symbol} ${color(text)}`;
},
};