Files
claude-hud/dist/render/session-line.js
Jarrod Watts 7ce11b1ea9 fix: add marketplace.json and correct plugin installation flow
The previous installation command didn't work because Claude Code
plugins require a marketplace manifest. This adds the marketplace.json
and updates install instructions to the correct two-step flow:

1. /plugin marketplace add jarrodwatts/claude-hud
2. /plugin install claude-hud@claude-hud

Also commits dist/ for plugin distribution since users can't run
npm build when installing via marketplace.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 21:51:51 +11:00

47 lines
1.6 KiB
JavaScript

import { getContextPercent, getModelName } from '../stdin.js';
import { coloredBar, cyan, dim, red, getContextColor, RESET } from './colors.js';
export function renderSessionLine(ctx) {
const model = getModelName(ctx.stdin);
const percent = getContextPercent(ctx.stdin);
const bar = coloredBar(percent);
const parts = [];
parts.push(`${cyan(`[${model}]`)} ${bar} ${getContextColor(percent)}${percent}%${RESET}`);
if (ctx.claudeMdCount > 0) {
parts.push(dim(`${ctx.claudeMdCount} CLAUDE.md`));
}
if (ctx.rulesCount > 0) {
parts.push(dim(`${ctx.rulesCount} rules`));
}
if (ctx.mcpCount > 0) {
parts.push(dim(`${ctx.mcpCount} MCPs`));
}
if (ctx.hooksCount > 0) {
parts.push(dim(`${ctx.hooksCount} hooks`));
}
if (ctx.sessionDuration) {
parts.push(dim(`⏱️ ${ctx.sessionDuration}`));
}
let line = parts.join(' | ');
if (percent >= 85) {
const usage = ctx.stdin.context_window?.current_usage;
if (usage) {
const input = formatTokens(usage.input_tokens ?? 0);
const cache = formatTokens((usage.cache_creation_input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0));
line += dim(` (in: ${input}, cache: ${cache})`);
}
}
if (percent >= 95) {
line += ` ${red('⚠️ COMPACT')}`;
}
return line;
}
function formatTokens(n) {
if (n >= 1000000) {
return `${(n / 1000000).toFixed(1)}M`;
}
if (n >= 1000) {
return `${(n / 1000).toFixed(0)}k`;
}
return n.toString();
}
//# sourceMappingURL=session-line.js.map