mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-04-16 06:32:39 +00:00
build: compile dist/ [auto]
This commit is contained in:
3
dist/config.d.ts
vendored
3
dist/config.d.ts
vendored
@@ -1,10 +1,13 @@
|
||||
export type LineLayoutType = 'compact' | 'expanded';
|
||||
export type AutocompactBufferMode = 'enabled' | 'disabled';
|
||||
export type ContextValueMode = 'percent' | 'tokens' | 'remaining';
|
||||
export type HudElement = 'project' | 'context' | 'usage' | 'environment' | 'tools' | 'agents' | 'todos';
|
||||
export declare const DEFAULT_ELEMENT_ORDER: HudElement[];
|
||||
export interface HudConfig {
|
||||
lineLayout: LineLayoutType;
|
||||
showSeparators: boolean;
|
||||
pathLevels: 1 | 2 | 3;
|
||||
elementOrder: HudElement[];
|
||||
gitStatus: {
|
||||
enabled: boolean;
|
||||
showDirty: boolean;
|
||||
|
||||
2
dist/config.d.ts.map
vendored
2
dist/config.d.ts.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,UAAU,CAAC;AAC3D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,cAAc,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,SAAS,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,eAAe,EAAE,OAAO,CAAC;QACzB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;IACF,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,OAAO,CA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AU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,SAAS,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,eAAe,EAAE,OAAO,CAAC;QACzB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;IACF,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,gBAAgB,CAAC;QAC/B,gBAAgB,EAAE,OAAO,CAAC;QAC1B,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,SAAS,EAAE,OAAO,CAAC;QACnB,eAAe,EAAE,OAAO,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;QACnB,eAAe,EAAE,OAAO,CAAC;QACzB,iBAAiB,EAAE,qBAAqB,CAAC;QACzC,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,SA+B5B,CAAC;AAEF,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AA8ED,wBAAgB,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAoFrE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAcrD"}
|
||||
33
dist/config.js
vendored
33
dist/config.js
vendored
@@ -2,10 +2,21 @@ import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import * as os from 'node:os';
|
||||
import { getHudPluginDir } from './claude-config-dir.js';
|
||||
export const DEFAULT_ELEMENT_ORDER = [
|
||||
'project',
|
||||
'context',
|
||||
'usage',
|
||||
'environment',
|
||||
'tools',
|
||||
'agents',
|
||||
'todos',
|
||||
];
|
||||
const KNOWN_ELEMENTS = new Set(DEFAULT_ELEMENT_ORDER);
|
||||
export const DEFAULT_CONFIG = {
|
||||
lineLayout: 'expanded',
|
||||
showSeparators: false,
|
||||
pathLevels: 1,
|
||||
elementOrder: [...DEFAULT_ELEMENT_ORDER],
|
||||
gitStatus: {
|
||||
enabled: true,
|
||||
showDirty: true,
|
||||
@@ -49,6 +60,25 @@ function validateAutocompactBuffer(value) {
|
||||
function validateContextValue(value) {
|
||||
return value === 'percent' || value === 'tokens' || value === 'remaining';
|
||||
}
|
||||
function validateElementOrder(value) {
|
||||
if (!Array.isArray(value) || value.length === 0) {
|
||||
return [...DEFAULT_ELEMENT_ORDER];
|
||||
}
|
||||
const seen = new Set();
|
||||
const elementOrder = [];
|
||||
for (const item of value) {
|
||||
if (typeof item !== 'string' || !KNOWN_ELEMENTS.has(item)) {
|
||||
continue;
|
||||
}
|
||||
const element = item;
|
||||
if (seen.has(element)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(element);
|
||||
elementOrder.push(element);
|
||||
}
|
||||
return elementOrder.length > 0 ? elementOrder : [...DEFAULT_ELEMENT_ORDER];
|
||||
}
|
||||
function migrateConfig(userConfig) {
|
||||
const migrated = { ...userConfig };
|
||||
if ('layout' in userConfig && !('lineLayout' in userConfig)) {
|
||||
@@ -93,6 +123,7 @@ export function mergeConfig(userConfig) {
|
||||
const pathLevels = validatePathLevels(migrated.pathLevels)
|
||||
? migrated.pathLevels
|
||||
: DEFAULT_CONFIG.pathLevels;
|
||||
const elementOrder = validateElementOrder(migrated.elementOrder);
|
||||
const gitStatus = {
|
||||
enabled: typeof migrated.gitStatus?.enabled === 'boolean'
|
||||
? migrated.gitStatus.enabled
|
||||
@@ -157,7 +188,7 @@ export function mergeConfig(userConfig) {
|
||||
sevenDayThreshold: validateThreshold(migrated.display?.sevenDayThreshold, 100),
|
||||
environmentThreshold: validateThreshold(migrated.display?.environmentThreshold, 100),
|
||||
};
|
||||
return { lineLayout, showSeparators, pathLevels, gitStatus, display };
|
||||
return { lineLayout, showSeparators, pathLevels, elementOrder, gitStatus, display };
|
||||
}
|
||||
export async function loadConfig() {
|
||||
const configPath = getConfigPath();
|
||||
|
||||
2
dist/config.js.map
vendored
2
dist/config.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/render/index.d.ts.map
vendored
2
dist/render/index.d.ts.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwWjD,wBAAgB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA8B/C"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwZjD,wBAAgB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAiD/C"}
|
||||
107
dist/render/index.js
vendored
107
dist/render/index.js
vendored
@@ -1,3 +1,4 @@
|
||||
import { DEFAULT_ELEMENT_ORDER } from '../config.js';
|
||||
import { renderSessionLine } from './session-line.js';
|
||||
import { renderToolsLine } from './tools-line.js';
|
||||
import { renderAgentsLine } from './agents-line.js';
|
||||
@@ -244,6 +245,7 @@ function wrapLineToWidth(line, maxWidth) {
|
||||
function makeSeparator(length) {
|
||||
return dim('─'.repeat(Math.max(length, 1)));
|
||||
}
|
||||
const ACTIVITY_ELEMENTS = new Set(['tools', 'agents', 'todos']);
|
||||
function collectActivityLines(ctx) {
|
||||
const activityLines = [];
|
||||
const display = ctx.config?.display;
|
||||
@@ -267,6 +269,25 @@ function collectActivityLines(ctx) {
|
||||
}
|
||||
return activityLines;
|
||||
}
|
||||
function renderElementLine(ctx, element) {
|
||||
const display = ctx.config?.display;
|
||||
switch (element) {
|
||||
case 'project':
|
||||
return renderProjectLine(ctx);
|
||||
case 'context':
|
||||
return renderIdentityLine(ctx);
|
||||
case 'usage':
|
||||
return renderUsageLine(ctx);
|
||||
case 'environment':
|
||||
return renderEnvironmentLine(ctx);
|
||||
case 'tools':
|
||||
return display?.showTools === false ? null : renderToolsLine(ctx);
|
||||
case 'agents':
|
||||
return display?.showAgents === false ? null : renderAgentsLine(ctx);
|
||||
case 'todos':
|
||||
return display?.showTodos === false ? null : renderTodosLine(ctx);
|
||||
}
|
||||
}
|
||||
function renderCompact(ctx) {
|
||||
const lines = [];
|
||||
const sessionLine = renderSessionLine(ctx);
|
||||
@@ -276,22 +297,41 @@ function renderCompact(ctx) {
|
||||
return lines;
|
||||
}
|
||||
function renderExpanded(ctx) {
|
||||
const elementOrder = ctx.config?.elementOrder ?? DEFAULT_ELEMENT_ORDER;
|
||||
const seen = new Set();
|
||||
const lines = [];
|
||||
const projectLine = renderProjectLine(ctx);
|
||||
if (projectLine) {
|
||||
lines.push(projectLine);
|
||||
}
|
||||
const identityLine = renderIdentityLine(ctx);
|
||||
const usageLine = renderUsageLine(ctx);
|
||||
if (identityLine && usageLine) {
|
||||
lines.push(`${identityLine} \u2502 ${usageLine}`);
|
||||
}
|
||||
else if (identityLine) {
|
||||
lines.push(identityLine);
|
||||
}
|
||||
const environmentLine = renderEnvironmentLine(ctx);
|
||||
if (environmentLine) {
|
||||
lines.push(environmentLine);
|
||||
for (let index = 0; index < elementOrder.length; index += 1) {
|
||||
const element = elementOrder[index];
|
||||
if (seen.has(element)) {
|
||||
continue;
|
||||
}
|
||||
const nextElement = elementOrder[index + 1];
|
||||
if ((element === 'context' && nextElement === 'usage' && !seen.has('usage'))
|
||||
|| (element === 'usage' && nextElement === 'context' && !seen.has('context'))) {
|
||||
seen.add(element);
|
||||
seen.add(nextElement);
|
||||
const firstLine = renderElementLine(ctx, element);
|
||||
const secondLine = renderElementLine(ctx, nextElement);
|
||||
if (firstLine && secondLine) {
|
||||
lines.push({ line: `${firstLine} │ ${secondLine}`, isActivity: false });
|
||||
}
|
||||
else if (firstLine) {
|
||||
lines.push({ line: firstLine, isActivity: false });
|
||||
}
|
||||
else if (secondLine) {
|
||||
lines.push({ line: secondLine, isActivity: false });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
seen.add(element);
|
||||
const line = renderElementLine(ctx, element);
|
||||
if (!line) {
|
||||
continue;
|
||||
}
|
||||
lines.push({
|
||||
line,
|
||||
isActivity: ACTIVITY_ELEMENTS.has(element),
|
||||
});
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@@ -299,17 +339,34 @@ export function render(ctx) {
|
||||
const lineLayout = ctx.config?.lineLayout ?? 'expanded';
|
||||
const showSeparators = ctx.config?.showSeparators ?? false;
|
||||
const terminalWidth = getTerminalWidth();
|
||||
const headerLines = lineLayout === 'expanded'
|
||||
? renderExpanded(ctx)
|
||||
: renderCompact(ctx);
|
||||
const activityLines = collectActivityLines(ctx);
|
||||
const lines = [...headerLines];
|
||||
if (showSeparators && activityLines.length > 0) {
|
||||
const maxWidth = Math.max(...headerLines.map(visualLength), 20);
|
||||
const separatorWidth = terminalWidth ? Math.min(maxWidth, terminalWidth) : maxWidth;
|
||||
lines.push(makeSeparator(separatorWidth));
|
||||
let lines;
|
||||
if (lineLayout === 'expanded') {
|
||||
const renderedLines = renderExpanded(ctx);
|
||||
lines = renderedLines.map(({ line }) => line);
|
||||
if (showSeparators) {
|
||||
const firstActivityIndex = renderedLines.findIndex(({ isActivity }) => isActivity);
|
||||
if (firstActivityIndex > 0) {
|
||||
const separatorBaseWidth = Math.max(...renderedLines
|
||||
.slice(0, firstActivityIndex)
|
||||
.map(({ line }) => visualLength(line)), 20);
|
||||
const separatorWidth = terminalWidth
|
||||
? Math.min(separatorBaseWidth, terminalWidth)
|
||||
: separatorBaseWidth;
|
||||
lines.splice(firstActivityIndex, 0, makeSeparator(separatorWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const headerLines = renderCompact(ctx);
|
||||
const activityLines = collectActivityLines(ctx);
|
||||
lines = [...headerLines];
|
||||
if (showSeparators && activityLines.length > 0) {
|
||||
const maxWidth = Math.max(...headerLines.map(visualLength), 20);
|
||||
const separatorWidth = terminalWidth ? Math.min(maxWidth, terminalWidth) : maxWidth;
|
||||
lines.push(makeSeparator(separatorWidth));
|
||||
}
|
||||
lines.push(...activityLines);
|
||||
}
|
||||
lines.push(...activityLines);
|
||||
const physicalLines = lines.flatMap(line => line.split('\n'));
|
||||
const visibleLines = terminalWidth
|
||||
? physicalLines.flatMap(line => wrapLineToWidth(line, terminalWidth))
|
||||
|
||||
2
dist/render/index.js.map
vendored
2
dist/render/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user