Files
claude-hud/dist/render/lines/project.js
Jarrod Watts 10193cc94a Bump marketplace version to 0.0.7 (#117)
* feat: show API billing indicator in model badge

When ANTHROPIC_API_KEY is present in the environment, display
[Opus | API] in red instead of [Opus | Max]. This helps users
who manage both Max plan and API key access (e.g., work vs personal)
immediately see when they're running on API billing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Bump marketplace version to 0.0.7

---------

Co-authored-by: Fielding Johnston <fielding@justfielding.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:53:01 +11:00

60 lines
2.6 KiB
JavaScript

import { getModelName, getProviderLabel } from '../../stdin.js';
import { cyan, magenta, yellow, red } from '../colors.js';
export function renderProjectLine(ctx) {
const display = ctx.config?.display;
const parts = [];
if (display?.showModel !== false) {
const model = getModelName(ctx.stdin);
const providerLabel = getProviderLabel(ctx.stdin);
const planName = display?.showUsage !== false ? ctx.usageData?.planName : undefined;
const hasApiKey = !!process.env.ANTHROPIC_API_KEY;
const billingLabel = hasApiKey ? red('API') : planName;
const planDisplay = providerLabel ?? billingLabel;
const modelDisplay = planDisplay ? `${model} | ${planDisplay}` : model;
parts.push(cyan(`[${modelDisplay}]`));
}
if (ctx.stdin.cwd) {
const segments = ctx.stdin.cwd.split(/[/\\]/).filter(Boolean);
const pathLevels = ctx.config?.pathLevels ?? 1;
const projectPath = segments.length > 0 ? segments.slice(-pathLevels).join('/') : '/';
let gitPart = '';
const gitConfig = ctx.config?.gitStatus;
const showGit = gitConfig?.enabled ?? true;
if (showGit && ctx.gitStatus) {
const gitParts = [ctx.gitStatus.branch];
if ((gitConfig?.showDirty ?? true) && ctx.gitStatus.isDirty) {
gitParts.push('*');
}
if (gitConfig?.showAheadBehind) {
if (ctx.gitStatus.ahead > 0) {
gitParts.push(`${ctx.gitStatus.ahead}`);
}
if (ctx.gitStatus.behind > 0) {
gitParts.push(`${ctx.gitStatus.behind}`);
}
}
if (gitConfig?.showFileStats && ctx.gitStatus.fileStats) {
const { modified, added, deleted, untracked } = ctx.gitStatus.fileStats;
const statParts = [];
if (modified > 0)
statParts.push(`!${modified}`);
if (added > 0)
statParts.push(`+${added}`);
if (deleted > 0)
statParts.push(`${deleted}`);
if (untracked > 0)
statParts.push(`?${untracked}`);
if (statParts.length > 0) {
gitParts.push(` ${statParts.join(' ')}`);
}
}
gitPart = ` ${magenta('git:(')}${cyan(gitParts.join(''))}${magenta(')')}`;
}
parts.push(`${yellow(projectPath)}${gitPart}`);
}
if (parts.length === 0) {
return null;
}
return parts.join(' \u2502 ');
}
//# sourceMappingURL=project.js.map