@sooneocean/claude-hud 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +20 -0
- package/LICENSE +21 -0
- package/README.md +379 -0
- package/commands/configure.md +361 -0
- package/commands/export.md +43 -0
- package/commands/health.md +61 -0
- package/commands/setup.md +287 -0
- package/commands/theme.md +31 -0
- package/dist/alert.d.ts +31 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +53 -0
- package/dist/alert.js.map +1 -0
- package/dist/burn-rate.d.ts +4 -0
- package/dist/burn-rate.d.ts.map +1 -0
- package/dist/burn-rate.js +36 -0
- package/dist/burn-rate.js.map +1 -0
- package/dist/cache.d.ts +6 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +47 -0
- package/dist/cache.js.map +1 -0
- package/dist/claude-config-dir.d.ts +4 -0
- package/dist/claude-config-dir.d.ts.map +1 -0
- package/dist/claude-config-dir.js +24 -0
- package/dist/claude-config-dir.js.map +1 -0
- package/dist/config-io.d.ts +6 -0
- package/dist/config-io.d.ts.map +1 -0
- package/dist/config-io.js +27 -0
- package/dist/config-io.js.map +1 -0
- package/dist/config-reader.d.ts +8 -0
- package/dist/config-reader.d.ts.map +1 -0
- package/dist/config-reader.js +204 -0
- package/dist/config-reader.js.map +1 -0
- package/dist/config.d.ts +94 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +358 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/constants.js.map +1 -0
- package/dist/cost-tracker.d.ts +9 -0
- package/dist/cost-tracker.d.ts.map +1 -0
- package/dist/cost-tracker.js +46 -0
- package/dist/cost-tracker.js.map +1 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +15 -0
- package/dist/debug.js.map +1 -0
- package/dist/extra-cmd.d.ts +20 -0
- package/dist/extra-cmd.d.ts.map +1 -0
- package/dist/extra-cmd.js +112 -0
- package/dist/extra-cmd.js.map +1 -0
- package/dist/git.d.ts +16 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +94 -0
- package/dist/git.js.map +1 -0
- package/dist/health-check.d.ts +12 -0
- package/dist/health-check.d.ts.map +1 -0
- package/dist/health-check.js +37 -0
- package/dist/health-check.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +198 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/agent-teams-provider.d.ts +10 -0
- package/dist/providers/agent-teams-provider.d.ts.map +1 -0
- package/dist/providers/agent-teams-provider.js +57 -0
- package/dist/providers/agent-teams-provider.js.map +1 -0
- package/dist/providers/agw-provider.d.ts +10 -0
- package/dist/providers/agw-provider.d.ts.map +1 -0
- package/dist/providers/agw-provider.js +49 -0
- package/dist/providers/agw-provider.js.map +1 -0
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +25 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/render/agents-line.d.ts +3 -0
- package/dist/render/agents-line.d.ts.map +1 -0
- package/dist/render/agents-line.js +40 -0
- package/dist/render/agents-line.js.map +1 -0
- package/dist/render/alert-line.d.ts +3 -0
- package/dist/render/alert-line.d.ts.map +1 -0
- package/dist/render/alert-line.js +11 -0
- package/dist/render/alert-line.js.map +1 -0
- package/dist/render/colors.d.ts +39 -0
- package/dist/render/colors.d.ts.map +1 -0
- package/dist/render/colors.js +109 -0
- package/dist/render/colors.js.map +1 -0
- package/dist/render/framework-line.d.ts +3 -0
- package/dist/render/framework-line.d.ts.map +1 -0
- package/dist/render/framework-line.js +32 -0
- package/dist/render/framework-line.js.map +1 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +435 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/lines/environment.d.ts +3 -0
- package/dist/render/lines/environment.d.ts.map +1 -0
- package/dist/render/lines/environment.js +30 -0
- package/dist/render/lines/environment.js.map +1 -0
- package/dist/render/lines/identity.d.ts +3 -0
- package/dist/render/lines/identity.d.ts.map +1 -0
- package/dist/render/lines/identity.js +93 -0
- package/dist/render/lines/identity.js.map +1 -0
- package/dist/render/lines/index.d.ts +5 -0
- package/dist/render/lines/index.d.ts.map +1 -0
- package/dist/render/lines/index.js +5 -0
- package/dist/render/lines/index.js.map +1 -0
- package/dist/render/lines/project.d.ts +3 -0
- package/dist/render/lines/project.d.ts.map +1 -0
- package/dist/render/lines/project.js +100 -0
- package/dist/render/lines/project.js.map +1 -0
- package/dist/render/lines/usage.d.ts +3 -0
- package/dist/render/lines/usage.d.ts.map +1 -0
- package/dist/render/lines/usage.js +65 -0
- package/dist/render/lines/usage.js.map +1 -0
- package/dist/render/session-line.d.ts +7 -0
- package/dist/render/session-line.d.ts.map +1 -0
- package/dist/render/session-line.js +227 -0
- package/dist/render/session-line.js.map +1 -0
- package/dist/render/todos-line.d.ts +3 -0
- package/dist/render/todos-line.d.ts.map +1 -0
- package/dist/render/todos-line.js +29 -0
- package/dist/render/todos-line.js.map +1 -0
- package/dist/render/tools-line.d.ts +3 -0
- package/dist/render/tools-line.d.ts.map +1 -0
- package/dist/render/tools-line.js +45 -0
- package/dist/render/tools-line.js.map +1 -0
- package/dist/session-history.d.ts +15 -0
- package/dist/session-history.d.ts.map +1 -0
- package/dist/session-history.js +46 -0
- package/dist/session-history.js.map +1 -0
- package/dist/session-stats.d.ts +11 -0
- package/dist/session-stats.d.ts.map +1 -0
- package/dist/session-stats.js +48 -0
- package/dist/session-stats.js.map +1 -0
- package/dist/speed-tracker.d.ts +7 -0
- package/dist/speed-tracker.d.ts.map +1 -0
- package/dist/speed-tracker.js +34 -0
- package/dist/speed-tracker.js.map +1 -0
- package/dist/stdin.d.ts +9 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +142 -0
- package/dist/stdin.js.map +1 -0
- package/dist/themes.d.ts +10 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +81 -0
- package/dist/themes.js.map +1 -0
- package/dist/transcript.d.ts +3 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/transcript.js +221 -0
- package/dist/transcript.js.map +1 -0
- package/dist/types.d.ts +124 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/usage-api.d.ts +62 -0
- package/dist/usage-api.d.ts.map +1 -0
- package/dist/usage-api.js +908 -0
- package/dist/usage-api.js.map +1 -0
- package/dist/utils/format.d.ts +9 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +75 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/terminal.d.ts +5 -0
- package/dist/utils/terminal.d.ts.map +1 -0
- package/dist/utils/terminal.js +42 -0
- package/dist/utils/terminal.js.map +1 -0
- package/package.json +36 -0
- package/src/alert.ts +75 -0
- package/src/burn-rate.ts +45 -0
- package/src/cache.ts +57 -0
- package/src/claude-config-dir.ts +27 -0
- package/src/config-io.ts +26 -0
- package/src/config-reader.ts +236 -0
- package/src/config.ts +496 -0
- package/src/constants.ts +10 -0
- package/src/cost-tracker.ts +53 -0
- package/src/debug.ts +16 -0
- package/src/extra-cmd.ts +125 -0
- package/src/git.ts +126 -0
- package/src/health-check.ts +50 -0
- package/src/index.ts +234 -0
- package/src/providers/agent-teams-provider.ts +56 -0
- package/src/providers/agw-provider.ts +47 -0
- package/src/providers/index.ts +27 -0
- package/src/render/agents-line.ts +51 -0
- package/src/render/alert-line.ts +11 -0
- package/src/render/colors.ts +145 -0
- package/src/render/framework-line.ts +34 -0
- package/src/render/index.ts +512 -0
- package/src/render/lines/environment.ts +41 -0
- package/src/render/lines/identity.ts +109 -0
- package/src/render/lines/index.ts +4 -0
- package/src/render/lines/project.ts +113 -0
- package/src/render/lines/usage.ts +79 -0
- package/src/render/session-line.ts +253 -0
- package/src/render/todos-line.ts +35 -0
- package/src/render/tools-line.ts +58 -0
- package/src/session-history.ts +62 -0
- package/src/session-stats.ts +65 -0
- package/src/speed-tracker.ts +51 -0
- package/src/stdin.ts +169 -0
- package/src/themes.ts +90 -0
- package/src/transcript.ts +268 -0
- package/src/types.ts +146 -0
- package/src/usage-api.ts +1090 -0
- package/src/utils/format.ts +79 -0
- package/src/utils/terminal.ts +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { readStdin, getContextPercent } from './stdin.js';
|
|
2
|
+
import { parseTranscript } from './transcript.js';
|
|
3
|
+
import { render } from './render/index.js';
|
|
4
|
+
import { countConfigs } from './config-reader.js';
|
|
5
|
+
import { getGitStatus } from './git.js';
|
|
6
|
+
import { getUsage } from './usage-api.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
8
|
+
import { parseExtraCmdArg, runExtraCmd } from './extra-cmd.js';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { realpathSync } from 'node:fs';
|
|
11
|
+
import { getDefaultCacheDir, readCache, writeCache, readLatency, writeLatency } from './cache.js';
|
|
12
|
+
import { loadProviders, fetchAllProviders } from './providers/index.js';
|
|
13
|
+
import { evaluateAlerts, shouldBell, sendNotification } from './alert.js';
|
|
14
|
+
import { calculateBurnRate, recordTokenSnapshot } from './burn-rate.js';
|
|
15
|
+
import { updateSessionStats, getSessionStats, getSparkline } from './session-stats.js';
|
|
16
|
+
import { getTerminalWidth } from './utils/terminal.js';
|
|
17
|
+
import { estimateCost } from './cost-tracker.js';
|
|
18
|
+
import { saveCurrentSession, getLastSession, formatSessionSummary } from './session-history.js';
|
|
19
|
+
import { formatResetTime } from './utils/format.js';
|
|
20
|
+
export async function main(overrides = {}) {
|
|
21
|
+
const deps = {
|
|
22
|
+
readStdin,
|
|
23
|
+
parseTranscript,
|
|
24
|
+
countConfigs,
|
|
25
|
+
getGitStatus,
|
|
26
|
+
getUsage,
|
|
27
|
+
loadConfig,
|
|
28
|
+
parseExtraCmdArg,
|
|
29
|
+
runExtraCmd,
|
|
30
|
+
render,
|
|
31
|
+
now: () => Date.now(),
|
|
32
|
+
log: console.log,
|
|
33
|
+
...overrides,
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
const stdin = await deps.readStdin();
|
|
37
|
+
if (!stdin) {
|
|
38
|
+
// Running without stdin - this happens during setup verification
|
|
39
|
+
const isMacOS = process.platform === 'darwin';
|
|
40
|
+
deps.log('[claude-hud] Initializing...');
|
|
41
|
+
if (isMacOS) {
|
|
42
|
+
deps.log('[claude-hud] Note: On macOS, you may need to restart Claude Code for the HUD to appear.');
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const transcriptPath = stdin.transcript_path ?? '';
|
|
47
|
+
const transcript = await deps.parseTranscript(transcriptPath);
|
|
48
|
+
const { claudeMdCount, rulesCount, mcpCount, hooksCount } = await deps.countConfigs(stdin.cwd);
|
|
49
|
+
const config = await deps.loadConfig();
|
|
50
|
+
const gitStatus = config.gitStatus.enabled
|
|
51
|
+
? await deps.getGitStatus(stdin.cwd)
|
|
52
|
+
: null;
|
|
53
|
+
const cacheDir = getDefaultCacheDir();
|
|
54
|
+
// Only fetch usage if enabled in config (replaces env var requirement)
|
|
55
|
+
const usageStart = Date.now();
|
|
56
|
+
const usageData = config.display.showUsage !== false
|
|
57
|
+
? await deps.getUsage({
|
|
58
|
+
ttls: {
|
|
59
|
+
cacheTtlMs: config.usage.cacheTtlSeconds * 1000,
|
|
60
|
+
failureCacheTtlMs: config.usage.failureCacheTtlSeconds * 1000,
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
: null;
|
|
64
|
+
if (config.display.showUsage !== false && usageData !== null) {
|
|
65
|
+
writeLatency(Date.now() - usageStart, cacheDir);
|
|
66
|
+
}
|
|
67
|
+
const apiLatency = readLatency(cacheDir);
|
|
68
|
+
const extraCmd = deps.parseExtraCmdArg();
|
|
69
|
+
const extraLabel = extraCmd ? await deps.runExtraCmd(extraCmd) : null;
|
|
70
|
+
const sessionDuration = formatSessionDuration(transcript.sessionStart, deps.now);
|
|
71
|
+
// Framework providers
|
|
72
|
+
let frameworkStatus = [];
|
|
73
|
+
if (config.display.showFrameworks) {
|
|
74
|
+
const providers = loadProviders(config.frameworks, cacheDir);
|
|
75
|
+
frameworkStatus = await fetchAllProviders(providers);
|
|
76
|
+
}
|
|
77
|
+
// Burn rate
|
|
78
|
+
let burnRate = null;
|
|
79
|
+
const inputTokens = stdin.context_window?.current_usage?.input_tokens;
|
|
80
|
+
const contextSize = stdin.context_window?.context_window_size;
|
|
81
|
+
if (config.display.showBurnRate && inputTokens != null && contextSize != null) {
|
|
82
|
+
recordTokenSnapshot(inputTokens, cacheDir);
|
|
83
|
+
burnRate = calculateBurnRate(inputTokens, contextSize, cacheDir);
|
|
84
|
+
}
|
|
85
|
+
// Context percent
|
|
86
|
+
const contextPercent = getContextPercent(stdin);
|
|
87
|
+
// Session stats
|
|
88
|
+
updateSessionStats(cacheDir, {
|
|
89
|
+
contextPercent,
|
|
90
|
+
toolCount: transcript.tools.length,
|
|
91
|
+
agentCount: transcript.agents.length,
|
|
92
|
+
});
|
|
93
|
+
const sessionStats = getSessionStats(cacheDir);
|
|
94
|
+
const sparkline = getSparkline(cacheDir);
|
|
95
|
+
// Alerts
|
|
96
|
+
let alerts = [];
|
|
97
|
+
if (config.display.showAlerts) {
|
|
98
|
+
alerts = evaluateAlerts({
|
|
99
|
+
contextPercent,
|
|
100
|
+
usage5hPercent: usageData?.fiveHour ?? 0,
|
|
101
|
+
usage7dPercent: usageData?.sevenDay ?? 0,
|
|
102
|
+
estimatedCallsRemaining: burnRate?.estimatedCallsRemaining ?? null,
|
|
103
|
+
usageResetTime: usageData?.fiveHourResetAt
|
|
104
|
+
? formatResetTime(usageData.fiveHourResetAt)
|
|
105
|
+
: null,
|
|
106
|
+
alertConfig: config.alerts,
|
|
107
|
+
cacheDir,
|
|
108
|
+
});
|
|
109
|
+
if (shouldBell(alerts, cacheDir)) {
|
|
110
|
+
process.stderr.write('\x07');
|
|
111
|
+
if (config.display.showNotifications) {
|
|
112
|
+
const criticalAlert = alerts.find(a => a.type.includes('critical'));
|
|
113
|
+
if (criticalAlert) {
|
|
114
|
+
sendNotification('Claude HUD', criticalAlert.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const costEstimate = config.display.showCost ? estimateCost(stdin, cacheDir) : null;
|
|
120
|
+
// Session history — only save when stats have changed
|
|
121
|
+
const prevStatsHash = readCache('prev-session-hash', 60000, cacheDir);
|
|
122
|
+
const currentHash = `${sessionStats.totalToolCalls}-${sessionStats.autocompactCount}-${sessionStats.peakContextPercent}`;
|
|
123
|
+
if (prevStatsHash !== currentHash) {
|
|
124
|
+
writeCache('prev-session-hash', currentHash, cacheDir);
|
|
125
|
+
saveCurrentSession({
|
|
126
|
+
startTime: transcript.sessionStart?.toISOString() || new Date().toISOString(),
|
|
127
|
+
duration: sessionDuration,
|
|
128
|
+
model: stdin.model?.display_name || 'unknown',
|
|
129
|
+
peakContextPercent: sessionStats.peakContextPercent,
|
|
130
|
+
autocompactCount: sessionStats.autocompactCount,
|
|
131
|
+
totalToolCalls: sessionStats.totalToolCalls,
|
|
132
|
+
totalAgentRuns: sessionStats.totalAgentRuns,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// Last session summary — show once at session start
|
|
136
|
+
const shownLastSession = readCache('shown-last-session', 24 * 60 * 60 * 1000, cacheDir);
|
|
137
|
+
if (!shownLastSession && transcript.tools.length === 0) {
|
|
138
|
+
const lastSession = getLastSession();
|
|
139
|
+
if (lastSession) {
|
|
140
|
+
console.error(`[claude-hud] ${formatSessionSummary(lastSession)}`);
|
|
141
|
+
writeCache('shown-last-session', true, cacheDir);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const ctx = {
|
|
145
|
+
stdin,
|
|
146
|
+
transcript,
|
|
147
|
+
claudeMdCount,
|
|
148
|
+
rulesCount,
|
|
149
|
+
mcpCount,
|
|
150
|
+
hooksCount,
|
|
151
|
+
sessionDuration,
|
|
152
|
+
gitStatus,
|
|
153
|
+
usageData,
|
|
154
|
+
config,
|
|
155
|
+
extraLabel,
|
|
156
|
+
frameworkStatus,
|
|
157
|
+
alerts,
|
|
158
|
+
burnRate,
|
|
159
|
+
sessionStats,
|
|
160
|
+
sparkline,
|
|
161
|
+
terminalWidth: getTerminalWidth(),
|
|
162
|
+
costEstimate,
|
|
163
|
+
apiLatency,
|
|
164
|
+
};
|
|
165
|
+
deps.render(ctx);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
deps.log('[claude-hud] Error:', error instanceof Error ? error.message : 'Unknown error');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export function formatSessionDuration(sessionStart, now = () => Date.now()) {
|
|
172
|
+
if (!sessionStart) {
|
|
173
|
+
return '';
|
|
174
|
+
}
|
|
175
|
+
const ms = now() - sessionStart.getTime();
|
|
176
|
+
const mins = Math.floor(ms / 60000);
|
|
177
|
+
if (mins < 1)
|
|
178
|
+
return '<1m';
|
|
179
|
+
if (mins < 60)
|
|
180
|
+
return `${mins}m`;
|
|
181
|
+
const hours = Math.floor(mins / 60);
|
|
182
|
+
const remainingMins = mins % 60;
|
|
183
|
+
return `${hours}h ${remainingMins}m`;
|
|
184
|
+
}
|
|
185
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
186
|
+
const argvPath = process.argv[1];
|
|
187
|
+
const isSamePath = (a, b) => {
|
|
188
|
+
try {
|
|
189
|
+
return realpathSync(a) === realpathSync(b);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return a === b;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
if (argvPath && isSamePath(argvPath, scriptPath)) {
|
|
196
|
+
void main();
|
|
197
|
+
}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EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;IAEpC,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,IAAI,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,GAAG,CAAC;IAEjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IAChC,OAAO,GAAG,KAAK,KAAK,aAAa,GAAG,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAW,EAAE;IACnD,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AACF,IAAI,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;IACjD,KAAK,IAAI,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FrameworkProvider, FrameworkStatus } from '../types.js';
|
|
2
|
+
export declare class AgentTeamsProvider implements FrameworkProvider {
|
|
3
|
+
private cacheDir;
|
|
4
|
+
name: string;
|
|
5
|
+
constructor(cacheDir: string);
|
|
6
|
+
isAvailable(): boolean;
|
|
7
|
+
fetch(): Promise<FrameworkStatus | null>;
|
|
8
|
+
private parseWorktrees;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=agent-teams-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-teams-provider.d.ts","sourceRoot":"","sources":["../../src/providers/agent-teams-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAStF,qBAAa,kBAAmB,YAAW,iBAAiB;IAE9C,OAAO,CAAC,QAAQ;IAD5B,IAAI,SAAiB;gBACD,QAAQ,EAAE,MAAM;IAEpC,WAAW,IAAI,OAAO;IAEhB,KAAK,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAwB9C,OAAO,CAAC,cAAc;CAcvB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { readCache, writeCache } from '../cache.js';
|
|
4
|
+
const DEBUG = process.env.DEBUG?.includes('claude-hud') || process.env.DEBUG === '*';
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
const CACHE_KEY = 'agent-teams-status';
|
|
7
|
+
const SUCCESS_TTL = 5000;
|
|
8
|
+
export class AgentTeamsProvider {
|
|
9
|
+
cacheDir;
|
|
10
|
+
name = 'agent-teams';
|
|
11
|
+
constructor(cacheDir) {
|
|
12
|
+
this.cacheDir = cacheDir;
|
|
13
|
+
}
|
|
14
|
+
isAvailable() { return !!process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS; }
|
|
15
|
+
async fetch() {
|
|
16
|
+
const cached = readCache(CACHE_KEY, SUCCESS_TTL, this.cacheDir);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
try {
|
|
20
|
+
const { stdout } = await execFileAsync('git', ['worktree', 'list', '--porcelain'], { timeout: 1000 });
|
|
21
|
+
const worktrees = this.parseWorktrees(stdout);
|
|
22
|
+
if (worktrees.length <= 1)
|
|
23
|
+
return null;
|
|
24
|
+
const entries = worktrees.slice(1).map(wt => ({
|
|
25
|
+
label: wt.branch?.replace('refs/heads/', '') || 'detached',
|
|
26
|
+
status: 'running',
|
|
27
|
+
detail: wt.path,
|
|
28
|
+
}));
|
|
29
|
+
const status = { provider: 'Teams', entries };
|
|
30
|
+
writeCache(CACHE_KEY, status, this.cacheDir);
|
|
31
|
+
return status;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (DEBUG)
|
|
35
|
+
console.error('[claude-hud:agent-teams-provider] git worktree error:', err);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
parseWorktrees(output) {
|
|
40
|
+
const worktrees = [];
|
|
41
|
+
let current = null;
|
|
42
|
+
for (const line of output.split('\n')) {
|
|
43
|
+
if (line.startsWith('worktree ')) {
|
|
44
|
+
if (current)
|
|
45
|
+
worktrees.push(current);
|
|
46
|
+
current = { path: line.slice(9) };
|
|
47
|
+
}
|
|
48
|
+
else if (line.startsWith('branch ') && current) {
|
|
49
|
+
current.branch = line.slice(7);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (current)
|
|
53
|
+
worktrees.push(current);
|
|
54
|
+
return worktrees;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=agent-teams-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-teams-provider.js","sourceRoot":"","sources":["../../src/providers/agent-teams-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAA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AM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7C,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,KAAK;gBAAE,OAAO,CAAC,KAAK,CAAC,uDAAuD,EAAE,GAAG,CAAC,CAAC;YACvF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,MAAc;QACnC,MAAM,SAAS,GAA6C,EAAE,CAAC;QAC/D,IAAI,OAAO,GAA6C,IAAI,CAAC;QAC7D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBACjC,IAAI,OAAO;oBAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,CAAC;iBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;gBACjD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QACD,IAAI,OAAO;YAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FrameworkProvider, FrameworkStatus } from '../types.js';
|
|
2
|
+
export declare class AgwProvider implements FrameworkProvider {
|
|
3
|
+
private endpoint;
|
|
4
|
+
private cacheDir;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(endpoint: string, cacheDir: string);
|
|
7
|
+
isAvailable(): boolean;
|
|
8
|
+
fetch(): Promise<FrameworkStatus | null>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=agw-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agw-provider.d.ts","sourceRoot":"","sources":["../../src/providers/agw-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAStF,qBAAa,WAAY,YAAW,iBAAiB;IAEvC,OAAO,CAAC,QAAQ;IAAU,OAAO,CAAC,QAAQ;IADtD,IAAI,SAAS;gBACO,QAAQ,EAAE,MAAM,EAAU,QAAQ,EAAE,MAAM;IAE9D,WAAW,IAAI,OAAO;IAEhB,KAAK,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;CA+B/C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readCache, writeCache } from '../cache.js';
|
|
2
|
+
const DEBUG = process.env.DEBUG?.includes('claude-hud') || process.env.DEBUG === '*';
|
|
3
|
+
const CACHE_KEY = 'agw-status';
|
|
4
|
+
const SUCCESS_TTL = 3000;
|
|
5
|
+
const FAILURE_TTL = 10000;
|
|
6
|
+
export class AgwProvider {
|
|
7
|
+
endpoint;
|
|
8
|
+
cacheDir;
|
|
9
|
+
name = 'agw';
|
|
10
|
+
constructor(endpoint, cacheDir) {
|
|
11
|
+
this.endpoint = endpoint;
|
|
12
|
+
this.cacheDir = cacheDir;
|
|
13
|
+
}
|
|
14
|
+
isAvailable() { return true; }
|
|
15
|
+
async fetch() {
|
|
16
|
+
const failCached = readCache('agw-failure', FAILURE_TTL, this.cacheDir);
|
|
17
|
+
if (failCached === true)
|
|
18
|
+
return null;
|
|
19
|
+
const cached = readCache(CACHE_KEY, SUCCESS_TTL, this.cacheDir);
|
|
20
|
+
if (cached)
|
|
21
|
+
return cached;
|
|
22
|
+
try {
|
|
23
|
+
const controller = new AbortController();
|
|
24
|
+
const timeout = setTimeout(() => controller.abort(), 200);
|
|
25
|
+
const res = await fetch(`${this.endpoint}/combos`, { signal: controller.signal });
|
|
26
|
+
clearTimeout(timeout);
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
writeCache('agw-failure', true, this.cacheDir);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const combos = await res.json();
|
|
32
|
+
const entries = combos.map(c => ({
|
|
33
|
+
label: c.id,
|
|
34
|
+
status: c.status === 'running' ? 'running' : c.status === 'error' ? 'error' : 'completed',
|
|
35
|
+
progress: c.progress,
|
|
36
|
+
}));
|
|
37
|
+
const status = { provider: 'AGW', entries };
|
|
38
|
+
writeCache(CACHE_KEY, status, this.cacheDir);
|
|
39
|
+
return status;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (DEBUG)
|
|
43
|
+
console.error('[claude-hud:agw-provider] connection error:', err);
|
|
44
|
+
writeCache('agw-failure', true, this.cacheDir);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=agw-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agw-provider.js","sourceRoot":"","sources":["../../src/providers/agw-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC;AAErF,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B,MAAM,OAAO,WAAW;IAEF;IAA0B;IAD9C,IAAI,GAAG,KAAK,CAAC;IACb,YAAoB,QAAgB,EAAU,QAAgB;QAA1C,aAAQ,GAAR,QAAQ,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAElE,WAAW,KAAc,OAAO,IAA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CAAC;YAEJ,MAAM,MAAM,GAAoB,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAC7D,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7C,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,KAAK;gBAAE,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,GAAG,CAAC,CAAC;YAC7E,UAAU,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FrameworkProvider, FrameworkStatus } from '../types.js';
|
|
2
|
+
interface FrameworksConfig {
|
|
3
|
+
agw: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
};
|
|
7
|
+
agentTeams: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function loadProviders(config: FrameworksConfig, cacheDir: string): FrameworkProvider[];
|
|
12
|
+
export declare function fetchAllProviders(providers: FrameworkProvider[]): Promise<FrameworkStatus[]>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAItE,UAAU,gBAAgB;IACxB,GAAG,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,UAAU,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAClC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAK7F;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAUlG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AgwProvider } from './agw-provider.js';
|
|
2
|
+
import { AgentTeamsProvider } from './agent-teams-provider.js';
|
|
3
|
+
export function loadProviders(config, cacheDir) {
|
|
4
|
+
const providers = [];
|
|
5
|
+
if (config.agw.enabled)
|
|
6
|
+
providers.push(new AgwProvider(config.agw.endpoint, cacheDir));
|
|
7
|
+
if (config.agentTeams.enabled)
|
|
8
|
+
providers.push(new AgentTeamsProvider(cacheDir));
|
|
9
|
+
return providers;
|
|
10
|
+
}
|
|
11
|
+
export async function fetchAllProviders(providers) {
|
|
12
|
+
const results = [];
|
|
13
|
+
for (const provider of providers) {
|
|
14
|
+
if (!provider.isAvailable())
|
|
15
|
+
continue;
|
|
16
|
+
try {
|
|
17
|
+
const status = await provider.fetch();
|
|
18
|
+
if (status && status.entries.length > 0)
|
|
19
|
+
results.push(status);
|
|
20
|
+
}
|
|
21
|
+
catch { /* Silent skip — error boundary */ }
|
|
22
|
+
}
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAO/D,MAAM,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAgB;IACtE,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO;QAAE,SAAS,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvF,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO;QAAE,SAAS,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAA8B;IACpE,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;YAAE,SAAS;QACtC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;YACtC,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;QAAC,MAAM,CAAC,CAAC,kCAAkC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-line.d.ts","sourceRoot":"","sources":["../../src/render/agents-line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,aAAa,CAAC;AAI7D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAqBlE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { yellow, green, magenta, dim } from './colors.js';
|
|
2
|
+
import { truncateString } from '../utils/format.js';
|
|
3
|
+
export function renderAgentsLine(ctx) {
|
|
4
|
+
const { agents } = ctx.transcript;
|
|
5
|
+
const runningAgents = agents.filter((a) => a.status === 'running');
|
|
6
|
+
const recentCompleted = agents
|
|
7
|
+
.filter((a) => a.status === 'completed')
|
|
8
|
+
.slice(-2);
|
|
9
|
+
const toShow = [...runningAgents, ...recentCompleted].slice(-3);
|
|
10
|
+
if (toShow.length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const lines = [];
|
|
14
|
+
for (const agent of toShow) {
|
|
15
|
+
lines.push(formatAgent(agent));
|
|
16
|
+
}
|
|
17
|
+
return lines.join('\n');
|
|
18
|
+
}
|
|
19
|
+
function formatAgent(agent) {
|
|
20
|
+
const statusIcon = agent.status === 'running' ? yellow('◐') : green('✓');
|
|
21
|
+
const type = magenta(agent.type);
|
|
22
|
+
const model = agent.model ? dim(`[${agent.model}]`) : '';
|
|
23
|
+
const desc = agent.description ? dim(`: ${truncateString(agent.description, 40)}`) : '';
|
|
24
|
+
const elapsed = formatElapsed(agent);
|
|
25
|
+
return `${statusIcon} ${type}${model ? ` ${model}` : ''}${desc} ${dim(`(${elapsed})`)}`;
|
|
26
|
+
}
|
|
27
|
+
function formatElapsed(agent) {
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
const start = agent.startTime.getTime();
|
|
30
|
+
const end = agent.endTime?.getTime() ?? now;
|
|
31
|
+
const ms = end - start;
|
|
32
|
+
if (ms < 1000)
|
|
33
|
+
return '<1s';
|
|
34
|
+
if (ms < 60000)
|
|
35
|
+
return `${Math.round(ms / 1000)}s`;
|
|
36
|
+
const mins = Math.floor(ms / 60000);
|
|
37
|
+
const secs = Math.round((ms % 60000) / 1000);
|
|
38
|
+
return `${mins}m ${secs}s`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=agents-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-line.js","sourceRoot":"","sources":["../../src/render/agents-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,UAAU,gB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E,KAAK,EAAE,GAAG,MAAM,GAAG,IAAI,CAO9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { red, dim } from './colors.js';
|
|
2
|
+
export function renderAlertLine(alerts) {
|
|
3
|
+
if (alerts.length === 0)
|
|
4
|
+
return null;
|
|
5
|
+
const parts = alerts.map(alert => {
|
|
6
|
+
const icon = alert.type.includes('critical') ? '⚠' : '⚡';
|
|
7
|
+
return red(`${icon} ${alert.message}`);
|
|
8
|
+
});
|
|
9
|
+
return parts.join(` ${dim('│')} `);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=alert-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-line.js","sourceRoot":"","sources":["../../src/render/alert-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QACzD,OAAO,GAAG,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HudColorOverrides } from '../config.js';
|
|
2
|
+
export declare const RESET = "\u001B[0m";
|
|
3
|
+
export declare const BAR_CHARS: {
|
|
4
|
+
readonly classic: {
|
|
5
|
+
readonly filled: "█";
|
|
6
|
+
readonly empty: "░";
|
|
7
|
+
};
|
|
8
|
+
readonly modern: {
|
|
9
|
+
readonly filled: "▰";
|
|
10
|
+
readonly empty: "▱";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function colorize(text: string, color: string): string;
|
|
14
|
+
export declare function green(text: string): string;
|
|
15
|
+
export declare function yellow(text: string): string;
|
|
16
|
+
export declare function red(text: string): string;
|
|
17
|
+
export declare function cyan(text: string): string;
|
|
18
|
+
export declare function magenta(text: string): string;
|
|
19
|
+
export declare function dim(text: string): string;
|
|
20
|
+
export declare function claudeOrange(text: string): string;
|
|
21
|
+
export declare function warning(text: string, colors?: Partial<HudColorOverrides>): string;
|
|
22
|
+
export declare function critical(text: string, colors?: Partial<HudColorOverrides>): string;
|
|
23
|
+
export declare function getContextColor(percent: number, colors?: Partial<HudColorOverrides>, thresholds?: {
|
|
24
|
+
warningThreshold: number;
|
|
25
|
+
criticalThreshold: number;
|
|
26
|
+
}): string;
|
|
27
|
+
export declare function getQuotaColor(percent: number, colors?: Partial<HudColorOverrides>, thresholds?: {
|
|
28
|
+
warningThreshold: number;
|
|
29
|
+
criticalThreshold: number;
|
|
30
|
+
}): string;
|
|
31
|
+
export declare function quotaBar(percent: number, width?: number, colors?: Partial<HudColorOverrides>, barStyle?: 'classic' | 'modern', thresholds?: {
|
|
32
|
+
warningThreshold: number;
|
|
33
|
+
criticalThreshold: number;
|
|
34
|
+
}): string;
|
|
35
|
+
export declare function coloredBar(percent: number, width?: number, colors?: Partial<HudColorOverrides>, barStyle?: 'classic' | 'modern', thresholds?: {
|
|
36
|
+
warningThreshold: number;
|
|
37
|
+
criticalThreshold: number;
|
|
38
|
+
}): string;
|
|
39
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/render/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,iBAAiB,EAAE,MAAM,cA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AAA;CAAE,GACnE,MAAM,CAIR;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,EACnC,QAAQ,GAAE,SAAS,GAAG,QAAoB,EAC1C,UAAU,CAAC,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACnE,MAAM,CAQR;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,EACnC,QAAQ,GAAE,SAAS,GAAG,QAAoB,EAC1C,UAAU,CAAC,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACnE,MAAM,CAQR"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export const RESET = '\x1b[0m';
|
|
2
|
+
export const BAR_CHARS = {
|
|
3
|
+
classic: { filled: '█', empty: '░' },
|
|
4
|
+
modern: { filled: '▰', empty: '▱' },
|
|
5
|
+
};
|
|
6
|
+
const DIM = '\x1b[2m';
|
|
7
|
+
const RED = '\x1b[31m';
|
|
8
|
+
const GREEN = '\x1b[32m';
|
|
9
|
+
const YELLOW = '\x1b[33m';
|
|
10
|
+
const MAGENTA = '\x1b[35m';
|
|
11
|
+
const CYAN = '\x1b[36m';
|
|
12
|
+
const BRIGHT_BLUE = '\x1b[94m';
|
|
13
|
+
const BRIGHT_MAGENTA = '\x1b[95m';
|
|
14
|
+
const CLAUDE_ORANGE = '\x1b[38;5;208m';
|
|
15
|
+
const ANSI_BY_NAME = {
|
|
16
|
+
red: RED,
|
|
17
|
+
green: GREEN,
|
|
18
|
+
yellow: YELLOW,
|
|
19
|
+
magenta: MAGENTA,
|
|
20
|
+
cyan: CYAN,
|
|
21
|
+
brightBlue: BRIGHT_BLUE,
|
|
22
|
+
brightMagenta: BRIGHT_MAGENTA,
|
|
23
|
+
};
|
|
24
|
+
/** Convert a hex color string (#rrggbb) to a truecolor ANSI escape sequence. */
|
|
25
|
+
function hexToAnsi(hex) {
|
|
26
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
27
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
28
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
29
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a color value to an ANSI escape sequence.
|
|
33
|
+
* Accepts named presets, 256-color indices (0-255), or hex strings (#rrggbb).
|
|
34
|
+
*/
|
|
35
|
+
function resolveAnsi(value, fallback) {
|
|
36
|
+
if (value === undefined || value === null) {
|
|
37
|
+
return fallback;
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
return `\x1b[38;5;${value}m`;
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === 'string' && value.startsWith('#') && value.length === 7) {
|
|
43
|
+
return hexToAnsi(value);
|
|
44
|
+
}
|
|
45
|
+
return ANSI_BY_NAME[value] ?? fallback;
|
|
46
|
+
}
|
|
47
|
+
export function colorize(text, color) {
|
|
48
|
+
return `${color}${text}${RESET}`;
|
|
49
|
+
}
|
|
50
|
+
export function green(text) {
|
|
51
|
+
return colorize(text, GREEN);
|
|
52
|
+
}
|
|
53
|
+
export function yellow(text) {
|
|
54
|
+
return colorize(text, YELLOW);
|
|
55
|
+
}
|
|
56
|
+
export function red(text) {
|
|
57
|
+
return colorize(text, RED);
|
|
58
|
+
}
|
|
59
|
+
export function cyan(text) {
|
|
60
|
+
return colorize(text, CYAN);
|
|
61
|
+
}
|
|
62
|
+
export function magenta(text) {
|
|
63
|
+
return colorize(text, MAGENTA);
|
|
64
|
+
}
|
|
65
|
+
export function dim(text) {
|
|
66
|
+
return colorize(text, DIM);
|
|
67
|
+
}
|
|
68
|
+
export function claudeOrange(text) {
|
|
69
|
+
return colorize(text, CLAUDE_ORANGE);
|
|
70
|
+
}
|
|
71
|
+
export function warning(text, colors) {
|
|
72
|
+
return colorize(text, resolveAnsi(colors?.warning, YELLOW));
|
|
73
|
+
}
|
|
74
|
+
export function critical(text, colors) {
|
|
75
|
+
return colorize(text, resolveAnsi(colors?.critical, RED));
|
|
76
|
+
}
|
|
77
|
+
export function getContextColor(percent, colors, thresholds) {
|
|
78
|
+
if (percent >= (thresholds?.criticalThreshold ?? 85))
|
|
79
|
+
return resolveAnsi(colors?.critical, RED);
|
|
80
|
+
if (percent >= (thresholds?.warningThreshold ?? 70))
|
|
81
|
+
return resolveAnsi(colors?.warning, YELLOW);
|
|
82
|
+
return resolveAnsi(colors?.context, GREEN);
|
|
83
|
+
}
|
|
84
|
+
export function getQuotaColor(percent, colors, thresholds) {
|
|
85
|
+
if (percent >= (thresholds?.criticalThreshold ?? 90))
|
|
86
|
+
return resolveAnsi(colors?.critical, RED);
|
|
87
|
+
if (percent >= (thresholds?.warningThreshold ?? 75))
|
|
88
|
+
return resolveAnsi(colors?.usageWarning, BRIGHT_MAGENTA);
|
|
89
|
+
return resolveAnsi(colors?.usage, BRIGHT_BLUE);
|
|
90
|
+
}
|
|
91
|
+
export function quotaBar(percent, width = 10, colors, barStyle = 'classic', thresholds) {
|
|
92
|
+
const safeWidth = Number.isFinite(width) ? Math.max(0, Math.round(width)) : 0;
|
|
93
|
+
const safePercent = Number.isFinite(percent) ? Math.min(100, Math.max(0, percent)) : 0;
|
|
94
|
+
const filled = Math.round((safePercent / 100) * safeWidth);
|
|
95
|
+
const empty = safeWidth - filled;
|
|
96
|
+
const color = getQuotaColor(safePercent, colors, thresholds);
|
|
97
|
+
const chars = BAR_CHARS[barStyle];
|
|
98
|
+
return `${color}${chars.filled.repeat(filled)}${DIM}${chars.empty.repeat(empty)}${RESET}`;
|
|
99
|
+
}
|
|
100
|
+
export function coloredBar(percent, width = 10, colors, barStyle = 'classic', thresholds) {
|
|
101
|
+
const safeWidth = Number.isFinite(width) ? Math.max(0, Math.round(width)) : 0;
|
|
102
|
+
const safePercent = Number.isFinite(percent) ? Math.min(100, Math.max(0, percent)) : 0;
|
|
103
|
+
const filled = Math.round((safePercent / 100) * safeWidth);
|
|
104
|
+
const empty = safeWidth - filled;
|
|
105
|
+
const color = getContextColor(safePercent, colors, thresholds);
|
|
106
|
+
const chars = BAR_CHARS[barStyle];
|
|
107
|
+
return `${color}${chars.filled.repeat(filled)}${DIM}${chars.empty.repeat(empty)}${RESET}`;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=colors.js.map
|