mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-21 07:22:44 +00:00
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>
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
import { readStdin } from './stdin.js';
|
|
import { parseTranscript } from './transcript.js';
|
|
import { render } from './render/index.js';
|
|
import { countConfigs } from './config-reader.js';
|
|
import { fileURLToPath } from 'node:url';
|
|
export async function main(overrides = {}) {
|
|
const deps = {
|
|
readStdin,
|
|
parseTranscript,
|
|
countConfigs,
|
|
render,
|
|
now: () => Date.now(),
|
|
log: console.log,
|
|
...overrides,
|
|
};
|
|
try {
|
|
const stdin = await deps.readStdin();
|
|
if (!stdin) {
|
|
deps.log('[claude-hud] Initializing...');
|
|
return;
|
|
}
|
|
const transcriptPath = stdin.transcript_path ?? '';
|
|
const transcript = await deps.parseTranscript(transcriptPath);
|
|
const { claudeMdCount, rulesCount, mcpCount, hooksCount } = await deps.countConfigs(stdin.cwd);
|
|
const sessionDuration = formatSessionDuration(transcript.sessionStart, deps.now);
|
|
const ctx = {
|
|
stdin,
|
|
transcript,
|
|
claudeMdCount,
|
|
rulesCount,
|
|
mcpCount,
|
|
hooksCount,
|
|
sessionDuration,
|
|
};
|
|
deps.render(ctx);
|
|
}
|
|
catch (error) {
|
|
deps.log('[claude-hud] Error:', error instanceof Error ? error.message : 'Unknown error');
|
|
}
|
|
}
|
|
export function formatSessionDuration(sessionStart, now = () => Date.now()) {
|
|
if (!sessionStart) {
|
|
return '';
|
|
}
|
|
const ms = now() - sessionStart.getTime();
|
|
const mins = Math.floor(ms / 60000);
|
|
if (mins < 1)
|
|
return '<1m';
|
|
if (mins < 60)
|
|
return `${mins}m`;
|
|
const hours = Math.floor(mins / 60);
|
|
const remainingMins = mins % 60;
|
|
return `${hours}h ${remainingMins}m`;
|
|
}
|
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
void main();
|
|
}
|
|
//# sourceMappingURL=index.js.map
|