Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ Devflow: IMPLEMENT/ORCHESTRATED

**Everything is composable.** 17 plugins (8 core + 9 language/ecosystem). Install only what you need. Six commands cover the entire development lifecycle.

**HUD.** A persistent status line updates on every prompt — project, branch, diff stats, context usage, model, session duration, cost, and configuration counts at a glance.
**HUD.** A persistent status line updates on every prompt — project, branch, diff stats, context usage, model, cost with weekly/monthly totals, quota reset timers, and configuration counts at a glance.

```
devflow · feat/auth-middleware* · 3↑ · v1.8.3 +5 · 12 files · +234 -56
Current Session ████░░░░ 42% · Session 5h ██░░░░░░ 18% · 7d █░░░░░░░ 8%
Opus 4.6 [1m] · 23m · $1.24 · 2 CLAUDE.md · 4 MCPs · 8 hooks · 41 skills
~/devflow · main · +2 -1 · v2.0.0+3
Context ████░░░░ 42% · 5h ████░░░░ 45% (2h 15m) · 7d ████████ 70% (3d 12h)
Opus 4.6 (1M) · 3 MCPs 2 rules · $1.42 · $18.50/wk · $62.30/mo
```

**Security.** Deny lists block dangerous tool patterns out of the box — configurable during init.
Expand Down
4 changes: 2 additions & 2 deletions src/cli/hud/components/context-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default async function contextUsage(
suffix = ` (in: ${inK}k)`;
}

const raw = `Current Session ${filledBar}${emptyBar} ${pct}%${suffix}`;
const raw = `Context ${filledBar}${emptyBar} ${pct}%${suffix}`;
const text =
dim('Current Session ') +
dim('Context ') +
colorFn(filledBar) +
dim(emptyBar) +
' ' +
Expand Down
16 changes: 14 additions & 2 deletions src/cli/hud/components/session-cost.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import type { ComponentResult, GatherContext } from '../types.js';
import { dim } from '../colors.js';

/** Session cost with optional rolling 7-day (/wk) and 30-day (/mo) totals. */
export default async function sessionCost(
ctx: GatherContext,
): Promise<ComponentResult | null> {
const cost = ctx.stdin.cost?.total_cost_usd;
if (cost == null) return null;
const formatted = `$${cost.toFixed(2)}`;
return { text: dim(formatted), raw: formatted };

const parts: string[] = [`$${cost.toFixed(2)}`];

if (ctx.costHistory?.weeklyCost != null && ctx.costHistory.weeklyCost > 0) {
parts.push(`$${ctx.costHistory.weeklyCost.toFixed(2)}/wk`);
}

if (ctx.costHistory?.monthlyCost != null && ctx.costHistory.monthlyCost > 0) {
parts.push(`$${ctx.costHistory.monthlyCost.toFixed(2)}/mo`);
}

const raw = parts.join(' \u00B7 ');
return { text: dim(raw), raw };
}
61 changes: 53 additions & 8 deletions src/cli/hud/components/usage-quota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,72 @@ function renderBar(percent: number): { text: string; raw: string } {
return { text, raw };
}

/**
* Format seconds remaining until a reset timestamp into compact form.
* Returns '' if the timestamp is in the past or not provided.
* Format: '2h 15m', '3d 12h', '45m'
*/
export function formatCountdown(resetsAtEpoch: number): string {
const nowMs = Date.now();
const resetsAtMs = resetsAtEpoch * 1000;
const remainingMs = resetsAtMs - nowMs;

if (remainingMs <= 0) return '';

const totalSeconds = Math.floor(remainingMs / 1000);
const totalMinutes = Math.floor(totalSeconds / 60);
const totalHours = Math.floor(totalMinutes / 60);
const days = Math.floor(totalHours / 24);

if (days > 0) {
const hours = totalHours % 24;
return hours > 0 ? `${days}d ${hours}h` : `${days}d`;
}

if (totalHours > 0) {
const minutes = totalMinutes % 60;
return minutes > 0 ? `${totalHours}h ${minutes}m` : `${totalHours}h`;
}

return `${totalMinutes}m`;
}

/** Render a single quota window: "5h ████░░░░ 45% (2h 15m)" */
function renderQuotaWindow(
label: string,
percent: number,
resetsAt: number | null,
): { text: string; raw: string } {
const bar = renderBar(Math.round(percent));
const countdown = resetsAt != null ? formatCountdown(resetsAt) : '';
const countdownText = countdown ? dim(` (${countdown})`) : '';
const countdownRaw = countdown ? ` (${countdown})` : '';
return {
text: dim(label + ' ') + bar.text + countdownText,
raw: `${label} ${bar.raw}${countdownRaw}`,
};
}

export default async function usageQuota(
ctx: GatherContext,
): Promise<ComponentResult | null> {
if (!ctx.usage) return null;

const { fiveHourPercent, sevenDayPercent } = ctx.usage;
const { fiveHourPercent, sevenDayPercent, fiveHourResetsAt, sevenDayResetsAt } = ctx.usage;
const parts: { text: string; raw: string }[] = [];

if (fiveHourPercent !== null) {
const bar = renderBar(Math.round(fiveHourPercent));
parts.push({ text: dim('5h ') + bar.text, raw: `5h ${bar.raw}` });
parts.push(renderQuotaWindow('5h', fiveHourPercent, fiveHourResetsAt));
}
if (sevenDayPercent !== null) {
const bar = renderBar(Math.round(sevenDayPercent));
parts.push({ text: dim('7d ') + bar.text, raw: `7d ${bar.raw}` });
parts.push(renderQuotaWindow('7d', sevenDayPercent, sevenDayResetsAt));
}

if (parts.length === 0) return null;

const sep = dim(' \u00B7 ');
const text = dim('Session ') + parts.map((p) => p.text).join(sep);
const raw = 'Session ' + parts.map((p) => p.raw).join(' \u00B7 ');
return { text, raw };
return {
text: parts.map((p) => p.text).join(sep),
raw: parts.map((p) => p.raw).join(' \u00B7 '),
};
}
5 changes: 3 additions & 2 deletions src/cli/hud/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { homedir } from 'node:os';
import type { HudConfig, ComponentId } from './types.js';

/**
* All 16 HUD components in display order.
* Default HUD components in display order.
* sessionDuration is intentionally omitted — the component is retained
* in the type system and render map but excluded from display by default.
*/
export const HUD_COMPONENTS: readonly ComponentId[] = [
'directory',
Expand All @@ -16,7 +18,6 @@ export const HUD_COMPONENTS: readonly ComponentId[] = [
'model',
'contextUsage',
'versionBadge',
'sessionDuration',
'sessionCost',
'usageQuota',
'todoProgress',
Expand Down
Loading
Loading