alnilam-cli
Version:
Git-native AI career coach that converts multi-year ambitions into weekly execution
61 lines (60 loc) • 6.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MomentumGauge = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const ink_1 = require("ink");
const Theme_js_1 = require("../shared/Theme.js");
const MomentumGauge = ({ score, evaluation, size = 'medium' }) => {
// Ensure score is between 0-100
const normalizedScore = Math.max(0, Math.min(100, score));
// Determine color based on score ranges
const getScoreColor = (score) => {
if (score >= 80)
return 'green';
if (score >= 60)
return 'yellow';
if (score >= 40)
return 'blue';
return 'red';
};
const scoreColor = getScoreColor(normalizedScore);
// Create circular progress indicator
const createGauge = () => {
const barLength = size === 'small' ? 20 : size === 'large' ? 40 : 30;
const filled = Math.round((normalizedScore / 100) * barLength);
// Create visual gauge
const gauge = '█'.repeat(filled) + '░'.repeat(barLength - filled);
return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(ink_1.Box, { flexDirection: "row", alignItems: "center", marginBottom: 1, children: (0, jsx_runtime_1.jsxs)(Theme_js_1.ThemedText.bold, { color: scoreColor, children: [normalizedScore, "/100"] }) }), (0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: "[" }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: scoreColor, children: gauge }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: "]" })] }), (0, jsx_runtime_1.jsx)(ink_1.Box, { marginTop: 1, children: (0, jsx_runtime_1.jsx)(ink_1.Text, { color: scoreColor, children: getScoreLabel(normalizedScore) }) })] }));
};
// Get descriptive label for score
const getScoreLabel = (score) => {
if (score >= 90)
return '🚀 Exceptional';
if (score >= 80)
return '⭐ Excellent';
if (score >= 70)
return '👍 Good';
if (score >= 60)
return '👌 Fair';
if (score >= 40)
return '⚠️ Below Average';
if (score >= 20)
return '🔄 Needs Attention';
return '🆘 Critical';
};
// Create ASCII art gauge for larger displays
const createAsciiGauge = () => {
const segments = 10;
const filledSegments = Math.round((normalizedScore / 100) * segments);
return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", alignItems: "center", marginBottom: 1, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: " 100" }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: " \u2502" }), Array.from({ length: segments }, (_, i) => {
const segmentIndex = segments - 1 - i;
const isFilled = segmentIndex < filledSegments;
const segmentColor = isFilled ? scoreColor : 'gray';
const segmentChar = isFilled ? '█' : '░';
return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: ' ' }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: segmentColor, children: segmentChar.repeat(6) }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: ' ' }), i === 0 && (0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "gray", children: ["\u2190 ", normalizedScore] })] }, i));
}), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: " \u2502" }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: " 0" })] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: scoreColor, bold: true, children: getScoreLabel(normalizedScore) })] }));
};
return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", children: [size === 'large' ? createAsciiGauge() : createGauge(), evaluation && size !== 'small' && ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", marginTop: 2, children: [(0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "gray", dimColor: true, children: ["Week of ", evaluation.week_start] }), evaluation.summary && ((0, jsx_runtime_1.jsx)(ink_1.Box, { marginTop: 1, width: 60, children: (0, jsx_runtime_1.jsxs)(ink_1.Text, { children: [evaluation.summary.substring(0, 120), evaluation.summary.length > 120 ? '...' : ''] }) })), evaluation.metadata?.accomplishments && evaluation.metadata.accomplishments.length > 0 && ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", marginTop: 1, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "green", bold: true, children: "\u2705 Key Accomplishments:" }), evaluation.metadata.accomplishments.slice(0, 2).map((accomplishment, i) => ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", marginTop: 0, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "green", children: "\u2022 " }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { children: [accomplishment.substring(0, 80), accomplishment.length > 80 ? '...' : ''] })] }, i)))] })), evaluation.risks && evaluation.risks.length > 0 && ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", marginTop: 1, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "red", bold: true, children: "\u26A0\uFE0F Key Risks:" }), evaluation.risks.slice(0, 2).map((risk, i) => ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", marginTop: 0, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: "red", children: "\u2022 " }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { children: [risk.substring(0, 80), risk.length > 80 ? '...' : ''] })] }, i)))] }))] }))] }));
};
exports.MomentumGauge = MomentumGauge;
exports.default = exports.MomentumGauge;