Files
claude-hud/tests/config.test.js

453 lines
17 KiB
JavaScript
Raw Normal View History

import { test } from 'node:test';
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
import assert from 'node:assert/strict';
import {
loadConfig,
getConfigPath,
mergeConfig,
DEFAULT_CONFIG,
DEFAULT_ELEMENT_ORDER,
} from '../dist/config.js';
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
import * as path from 'node:path';
import * as os from 'node:os';
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
function restoreEnvVar(name, value) {
if (value === undefined) {
delete process.env[name];
return;
}
process.env[name] = value;
}
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
test('loadConfig returns valid config structure', async () => {
const config = await loadConfig();
// pathLevels must be 1, 2, or 3
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
assert.ok([1, 2, 3].includes(config.pathLevels), 'pathLevels should be 1, 2, or 3');
feat(layout): add expanded multi-line layout mode (#76) * feat(layout): add expanded multi-line layout mode Split the overloaded session line into semantic lines for better readability: - Identity line: model, plan, context bar, duration - Project line: path, git status - Environment line: config counts (CLAUDE.md, rules, MCPs, hooks) - Usage line: rate limits with reset times New config options: - `lineLayout`: 'compact' | 'expanded' (default: expanded for new users) - `showSeparators`: boolean (orthogonal to layout) - `usageThreshold`: show usage line only when >= N% - `environmentThreshold`: show env line only when counts >= N Backward compatible: old `layout` config is automatically migrated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address code review feedback - Fix usage threshold to use max(5h, 7d) so high 7d usage isn't hidden when 5h is null - Update stale comment in session-line.ts (now compact layout only) - Remove non-null assertions in identity.ts by hoisting planName Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: apply thresholds to compact layout for consistency - Add environmentThreshold gating to config counts in compact mode - Add usageThreshold with max(5h, 7d) logic to usage in compact mode - Remove non-null assertion for planName (same fix as identity.ts) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: update tests for new lineLayout config schema - Update config.test.js to validate lineLayout instead of layout - Update render.test.js to use lineLayout and showSeparators - Update index.test.js mock config with new schema - Update integration test expected output for expanded default Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:17:36 +11:00
// lineLayout must be valid
const validLineLayouts = ['compact', 'expanded'];
assert.ok(validLineLayouts.includes(config.lineLayout), 'lineLayout should be valid');
// showSeparators must be boolean
assert.equal(typeof config.showSeparators, 'boolean', 'showSeparators should be boolean');
assert.ok(Array.isArray(config.elementOrder), 'elementOrder should be an array');
assert.ok(config.elementOrder.length > 0, 'elementOrder should not be empty');
assert.deepEqual(config.elementOrder, DEFAULT_ELEMENT_ORDER, 'elementOrder should default to the full expanded layout');
// gitStatus object with expected properties
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
assert.equal(typeof config.gitStatus, 'object');
assert.equal(typeof config.gitStatus.enabled, 'boolean');
assert.equal(typeof config.gitStatus.showDirty, 'boolean');
assert.equal(typeof config.gitStatus.showAheadBehind, 'boolean');
// display object with expected properties
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
assert.equal(typeof config.display, 'object');
assert.equal(typeof config.display.showModel, 'boolean');
assert.equal(typeof config.display.showContextBar, 'boolean');
assert.ok(['percent', 'tokens', 'remaining', 'both'].includes(config.display.contextValue), 'contextValue should be valid');
assert.equal(typeof config.display.showConfigCounts, 'boolean');
assert.equal(typeof config.display.showDuration, 'boolean');
assert.equal(typeof config.display.showSpeed, 'boolean');
assert.equal(typeof config.display.showTokenBreakdown, 'boolean');
assert.equal(typeof config.display.showUsage, 'boolean');
assert.equal(typeof config.display.showTools, 'boolean');
assert.equal(typeof config.display.showAgents, 'boolean');
assert.equal(typeof config.display.showTodos, 'boolean');
assert.equal(typeof config.display.showSessionName, 'boolean');
assert.equal(typeof config.display.showClaudeCodeVersion, 'boolean');
assert.equal(typeof config.display.showMemoryUsage, 'boolean');
assert.ok(['full', 'compact', 'short'].includes(config.display.modelFormat), 'modelFormat should be valid');
assert.equal(typeof config.display.modelOverride, 'string', 'modelOverride should be string');
assert.equal(typeof config.colors, 'object');
2026-03-23 15:04:40 +11:00
for (const key of ['context', 'usage', 'warning', 'usageWarning', 'critical', 'model', 'project', 'git', 'gitBranch', 'label', 'custom']) {
const t = typeof config.colors[key];
assert.ok(t === 'string' || t === 'number', `colors.${key} should be string or number, got ${t}`);
}
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
});
test('getConfigPath returns correct path', () => {
const originalConfigDir = process.env.CLAUDE_CONFIG_DIR;
delete process.env.CLAUDE_CONFIG_DIR;
try {
const configPath = getConfigPath();
const homeDir = os.homedir();
assert.equal(configPath, path.join(homeDir, '.claude', 'plugins', 'claude-hud', 'config.json'));
} finally {
restoreEnvVar('CLAUDE_CONFIG_DIR', originalConfigDir);
}
});
test('mergeConfig defaults showSessionName to false', () => {
const config = mergeConfig({});
assert.equal(config.display.showSessionName, false);
assert.equal(DEFAULT_CONFIG.display.showSessionName, false);
});
test('mergeConfig preserves explicit showSessionName=true', () => {
const config = mergeConfig({ display: { showSessionName: true } });
assert.equal(config.display.showSessionName, true);
});
test('mergeConfig defaults showClaudeCodeVersion to false', () => {
const config = mergeConfig({});
assert.equal(config.display.showClaudeCodeVersion, false);
assert.equal(DEFAULT_CONFIG.display.showClaudeCodeVersion, false);
});
test('mergeConfig preserves explicit showClaudeCodeVersion=true', () => {
const config = mergeConfig({ display: { showClaudeCodeVersion: true } });
assert.equal(config.display.showClaudeCodeVersion, true);
});
test('mergeConfig defaults showMemoryUsage to false', () => {
const config = mergeConfig({});
assert.equal(config.display.showMemoryUsage, false);
assert.equal(DEFAULT_CONFIG.display.showMemoryUsage, false);
});
test('mergeConfig preserves explicit showMemoryUsage=true', () => {
const config = mergeConfig({ display: { showMemoryUsage: true } });
assert.equal(config.display.showMemoryUsage, true);
});
test('mergeConfig preserves customLine and truncates long values', () => {
const customLine = 'x'.repeat(120);
const config = mergeConfig({ display: { customLine } });
assert.equal(config.display.customLine.length, 80);
assert.equal(config.display.customLine, customLine.slice(0, 80));
});
test('mergeConfig defaults modelFormat to full', () => {
const config = mergeConfig({});
assert.equal(config.display.modelFormat, 'full');
});
test('mergeConfig preserves valid modelFormat values', () => {
assert.equal(mergeConfig({ display: { modelFormat: 'compact' } }).display.modelFormat, 'compact');
assert.equal(mergeConfig({ display: { modelFormat: 'short' } }).display.modelFormat, 'short');
assert.equal(mergeConfig({ display: { modelFormat: 'full' } }).display.modelFormat, 'full');
});
test('mergeConfig falls back to full for invalid modelFormat', () => {
assert.equal(mergeConfig({ display: { modelFormat: 'invalid' } }).display.modelFormat, 'full');
assert.equal(mergeConfig({ display: { modelFormat: 123 } }).display.modelFormat, 'full');
assert.equal(mergeConfig({ display: { modelFormat: null } }).display.modelFormat, 'full');
});
test('mergeConfig defaults modelOverride to empty string', () => {
const config = mergeConfig({});
assert.equal(config.display.modelOverride, '');
});
test('mergeConfig preserves modelOverride and truncates long values', () => {
const override = 'x'.repeat(120);
const config = mergeConfig({ display: { modelOverride: override } });
assert.equal(config.display.modelOverride.length, 80);
assert.equal(config.display.modelOverride, override.slice(0, 80));
});
test('mergeConfig falls back to empty for non-string modelOverride', () => {
assert.equal(mergeConfig({ display: { modelOverride: 123 } }).display.modelOverride, '');
assert.equal(mergeConfig({ display: { modelOverride: null } }).display.modelOverride, '');
assert.equal(mergeConfig({ display: { modelOverride: true } }).display.modelOverride, '');
});
test('getConfigPath respects CLAUDE_CONFIG_DIR', async () => {
const originalConfigDir = process.env.CLAUDE_CONFIG_DIR;
const customConfigDir = await mkdtemp(path.join(tmpdir(), 'claude-hud-config-dir-'));
try {
process.env.CLAUDE_CONFIG_DIR = customConfigDir;
const configPath = getConfigPath();
assert.equal(configPath, path.join(customConfigDir, 'plugins', 'claude-hud', 'config.json'));
} finally {
restoreEnvVar('CLAUDE_CONFIG_DIR', originalConfigDir);
await rm(customConfigDir, { recursive: true, force: true });
}
});
test('loadConfig reads user config from CLAUDE_CONFIG_DIR', async () => {
const originalConfigDir = process.env.CLAUDE_CONFIG_DIR;
const customConfigDir = await mkdtemp(path.join(tmpdir(), 'claude-hud-config-load-'));
try {
process.env.CLAUDE_CONFIG_DIR = customConfigDir;
const pluginDir = path.join(customConfigDir, 'plugins', 'claude-hud');
await mkdir(pluginDir, { recursive: true });
await writeFile(
path.join(pluginDir, 'config.json'),
JSON.stringify({
lineLayout: 'compact',
pathLevels: 2,
display: { showSpeed: true },
}),
'utf8'
);
const config = await loadConfig();
assert.equal(config.lineLayout, 'compact');
assert.equal(config.pathLevels, 2);
assert.equal(config.display.showSpeed, true);
} finally {
restoreEnvVar('CLAUDE_CONFIG_DIR', originalConfigDir);
await rm(customConfigDir, { recursive: true, force: true });
}
feat: config system + usage API + bug fixes (supersedes #32) (#35) * feat: display last 3 path segments first in session line Shows the last 3 segments of the working directory path at the beginning of the session line for quick project identification. Before: [Opus 4.5] ████░░░░░░ 19% | my-project git:(main) | ... After: dev/apps/my-project git:(main) | [Opus 4.5] ████░░░░░░ 19% | ... This helps distinguish between projects with similar names in different locations and puts the most relevant info first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable path levels (1-3) and git status toggle - Add config system at ~/.claude/plugins/claude-hud/config.json - Default path display to 1 level (was hardcoded at 3) - Add pathLevels option: 1, 2, or 3 directory segments - Add gitStatus.enabled toggle to show/hide git branch - Add interactive CLI: npx claude-hud-configure - Add comprehensive tests for config and path levels - Update README with configuration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle cross-platform path separators - Split paths by both / and \ for Windows compatibility - Always output forward slashes for consistent display - Add tests for Windows paths, UNC paths, and mixed separators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show existing config when reconfiguring - Display current values when config file exists - Prompt user that Enter keeps current values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: interactive CLI with arrow-key selection - Add @inquirer/prompts for better UX - Arrow keys to select path levels - Visual feedback with checkmarks - Cleaner, more compact output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dirty indicator and ahead/behind git status - Add gitStatus.showDirty option (default: true) - Add gitStatus.showAheadBehind option (default: false) - Update getGitStatus to return isDirty, ahead, behind - Update CLI to configure new options with preview - Add tests for dirty and ahead/behind display - Update README with new options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable display options for all HUD elements - Add display configuration object with 8 boolean options: - showModel: Toggle model name display [Opus] - showContextBar: Toggle visual context bar ████░░░░░░ - showConfigCounts: Toggle CLAUDE.md, rules, MCPs, hooks counts - showDuration: Toggle session duration display - showTokenBreakdown: Toggle token details at high context (85%+) - showTools: Toggle tools activity line - showAgents: Toggle agents activity line - showTodos: Toggle todos progress line - All options default to true for backward compatibility - Enhanced CLI preview with colors matching actual HUD output - Added 5 new tests for display configuration (87 total) - Updated README with complete configuration reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add configurable layout options (default, condensed, separators) - Add layout config option with three styles: - default: All info on first line (original behavior) - condensed: Model/context top, project bottom - separators: Condensed with visual separator lines - Create project-line.ts for rendering project path in split layouts - Add renderSessionLineMinimal for condensed/separators layouts - Interactive CLI preview shows selected layout style - All 87 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add interactive HUD preview and folder icon - Add live preview that updates as config options are selected - Show initial preview on startup based on existing/default config - Add folder icon (📁) in front of project path - Extract preview generation to separate module for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README with folder icon and live preview - Add folder icon (📁) to all path examples - Document live preview feature in interactive CLI section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add menu-based navigation to configure CLI - Replace linear flow with main menu loop - Show current values in menu (layout, path levels, git status, etc.) - Users can edit any section and return to menu - Preview updates after each section change - Save & Exit or Exit without saving options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update tests for folder icon and config structure - Update integration test expected output with folder icon - Make config test environment-independent (validates structure, not specific values) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive config loading tests Add 23 new tests for config system validation: - DEFAULT_CONFIG structure (layout, gitStatus, 8 display options) - Layout validation (default, condensed, separators) - PathLevels validation (1, 2, or 3) - Git status configuration defaults - Display configuration (booleans, defaults to true, count) - loadConfig behavior (complete fields, valid values) - getConfigPath structure tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add usage API, config enhancements, and bug fixes This PR combines and enhances the config system from PR #32 with new features and bug fixes addressing the owner's review feedback. ## New Features - Usage API integration showing 5h/7d limits for Pro/Max/Team users - Interactive `/claude-hud:configure` skill for in-Claude-Code configuration - Hybrid showUsage toggle (env var + config for privacy control) ## Bug Fixes (addressing #32 review feedback) - Fix git status spacing: `main*↑2↓1` → `main* ↑2 ↓1` - Fix root path rendering: show `/` instead of empty folder icon - Fix Windows path normalization in truncatePath - Fix duplicate dependencies key in package.json - Fix multiSelect for mutually exclusive options in configure skill ## Credits - Config system, layouts, path levels, git toggle, CLI by @Tsopic (PR #32) - Usage API, configure skill, bug fixes by @melon-hub 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-Authored-By: Tsopic <Tsopic@users.noreply.github.com> * fix: move configure command to correct location - Move configure.md from .claude-plugin/skills/ to commands/ - Remove skills array from plugin.json (commands are auto-discovered) Commands must be in the commands/ directory at plugin root, not inside .claude-plugin/. This matches the existing setup.md pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: layout order, remove condensed, redesign configure flow Render fixes (per PR feedback): - Fix element order: model first, project second - Remove condensed layout (only default/separators remain) - Separators: single line below header only when activity exists - Delete project-line.ts (no longer needed) - Remove renderSessionLineMinimal() function Configure skill redesign: - Context-aware tab order (returning users start on Turn Off) - Explicit Turn Off/Turn On questions (no toggle ambiguity) - Git Style question for dirty/ahead-behind options - Combined Layout/Reset tab for returning users - Duration now toggleable - Guards against empty submissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: rename 'Returning User' to 'Update Config' in configure flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix tests for new element order and removed function - Update render-basic.txt expected output (model first, project second) - Remove renderSessionLineMinimal import and test (function was deleted) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for usage API, config flow, and troubleshooting - Remove stale CLAUDE_HUD_SHOW_USAGE env var references (now config-based) - Add usage API data sources to CLAUDE.md - Add new source files to file structure (config.ts, git.ts, usage-api.ts) - Update README with usage limits section and requirements - Add troubleshooting sections for config, git, and usage issues - Standardize output examples across all documentation files - Remove condensed layout references (only default/separators now) - Update configure skill reference (npx CLI → /claude-hud:configure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove dist/ from PR and update outdated comment - Reset dist/ to main branch (dist will be built by CI after merge) - Update comment: "requires env var opt-in AND config" → "shown when enabled in config" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove internal design doc from release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove CLI and runtime dependency - Remove src/bin/configure.ts and src/bin/preview.ts - Remove @inquirer/prompts dependency (plugins don't run npm install) - Remove bin field from package.json - Users configure via /claude-hud:configure skill instead 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: bump version to 0.0.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use file-based cache for usage API HUD runs as a new process every ~300ms, so in-memory cache was useless. Now caches to ~/.claude/plugins/claude-hud/.usage-cache.json. This reduces API calls from ~10,800/hour to max 60/hour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use consistent homeDir/now in getUsage Avoids potential divergence if deps functions are non-deterministic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add real tests for usage API file cache - Test credential parsing with mock HOME directory - Test cache TTL behavior (success and failure) - Test apiUnavailable flag handling - Replace placeholder assert.ok(true) with actual assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Martin Kask <martin@industrial.ninja> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Tsopic <Tsopic@users.noreply.github.com> Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-01-07 16:00:32 +11:00
});
// --- migrateConfig tests (via mergeConfig) ---
test('migrate legacy layout: "default" -> compact, no separators', () => {
const config = mergeConfig({ layout: 'default' });
assert.equal(config.lineLayout, 'compact');
assert.equal(config.showSeparators, false);
});
test('migrate legacy layout: "separators" -> compact, with separators', () => {
const config = mergeConfig({ layout: 'separators' });
assert.equal(config.lineLayout, 'compact');
assert.equal(config.showSeparators, true);
});
test('migrate object layout: extracts nested fields to top level', () => {
const config = mergeConfig({
layout: { lineLayout: 'expanded', showSeparators: true, pathLevels: 2 },
});
assert.equal(config.lineLayout, 'expanded');
assert.equal(config.showSeparators, true);
assert.equal(config.pathLevels, 2);
});
test('migrate object layout: empty object does not crash', () => {
const config = mergeConfig({ layout: {} });
// Should fall back to defaults since no fields were extracted
assert.equal(config.lineLayout, DEFAULT_CONFIG.lineLayout);
assert.equal(config.showSeparators, DEFAULT_CONFIG.showSeparators);
assert.equal(config.pathLevels, DEFAULT_CONFIG.pathLevels);
});
test('no layout key -> no migration, uses defaults', () => {
const config = mergeConfig({});
assert.equal(config.lineLayout, DEFAULT_CONFIG.lineLayout);
assert.equal(config.showSeparators, DEFAULT_CONFIG.showSeparators);
});
test('both layout and lineLayout present -> layout ignored', () => {
const config = mergeConfig({ layout: 'separators', lineLayout: 'expanded' });
// When lineLayout is already present, migration should not run
assert.equal(config.lineLayout, 'expanded');
assert.equal(config.showSeparators, DEFAULT_CONFIG.showSeparators);
});
test('mergeConfig accepts contextValue=remaining', () => {
const config = mergeConfig({
display: {
contextValue: 'remaining',
},
});
assert.equal(config.display.contextValue, 'remaining');
});
test('mergeConfig accepts contextValue=both', () => {
const config = mergeConfig({
display: {
contextValue: 'both',
},
});
assert.equal(config.display.contextValue, 'both');
});
test('mergeConfig falls back to default for invalid contextValue', () => {
const config = mergeConfig({
display: {
contextValue: 'invalid-mode',
},
});
assert.equal(config.display.contextValue, DEFAULT_CONFIG.display.contextValue);
});
test('mergeConfig defaults elementOrder to the full expanded layout', () => {
const config = mergeConfig({});
assert.deepEqual(config.elementOrder, DEFAULT_ELEMENT_ORDER);
});
test('mergeConfig preserves valid custom elementOrder including activity elements', () => {
const config = mergeConfig({
elementOrder: ['tools', 'project', 'usage', 'memory', 'context', 'agents', 'todos', 'environment'],
});
assert.deepEqual(
config.elementOrder,
['tools', 'project', 'usage', 'memory', 'context', 'agents', 'todos', 'environment']
);
});
test('mergeConfig filters unknown entries and de-duplicates elementOrder', () => {
const config = mergeConfig({
elementOrder: ['project', 'agents', 'project', 'banana', 'usage', 'memory', 'agents', 'context'],
});
assert.deepEqual(config.elementOrder, ['project', 'agents', 'usage', 'memory', 'context']);
});
test('mergeConfig treats elementOrder as an explicit expanded-mode filter', () => {
const config = mergeConfig({
elementOrder: ['usage', 'project'],
});
assert.deepEqual(config.elementOrder, ['usage', 'project']);
});
test('mergeConfig falls back to default when elementOrder is empty or invalid', () => {
assert.deepEqual(mergeConfig({ elementOrder: [] }).elementOrder, DEFAULT_ELEMENT_ORDER);
assert.deepEqual(mergeConfig({ elementOrder: ['unknown'] }).elementOrder, DEFAULT_ELEMENT_ORDER);
assert.deepEqual(mergeConfig({ elementOrder: 'project' }).elementOrder, DEFAULT_ELEMENT_ORDER);
});
test('mergeConfig defaults colors to expected semantic palette', () => {
const config = mergeConfig({});
assert.equal(config.colors.context, 'green');
assert.equal(config.colors.usage, 'brightBlue');
assert.equal(config.colors.warning, 'yellow');
assert.equal(config.colors.usageWarning, 'brightMagenta');
assert.equal(config.colors.critical, 'red');
2026-03-23 15:04:40 +11:00
assert.equal(config.colors.model, 'cyan');
assert.equal(config.colors.project, 'yellow');
assert.equal(config.colors.git, 'magenta');
assert.equal(config.colors.gitBranch, 'cyan');
assert.equal(config.colors.label, 'dim');
assert.equal(config.colors.custom, 208);
});
test('mergeConfig accepts valid color overrides and filters invalid values', () => {
const config = mergeConfig({
colors: {
context: 'cyan',
usage: 'magenta',
warning: 'brightBlue',
usageWarning: 'yellow',
critical: 'not-a-color',
2026-03-23 15:04:40 +11:00
model: 214,
project: '#33ff00',
git: 'cyan',
gitBranch: 'not-a-color',
label: 'dim',
custom: '#ff6600',
},
});
assert.equal(config.colors.context, 'cyan');
assert.equal(config.colors.usage, 'magenta');
assert.equal(config.colors.warning, 'brightBlue');
assert.equal(config.colors.usageWarning, 'yellow');
assert.equal(config.colors.critical, DEFAULT_CONFIG.colors.critical);
2026-03-23 15:04:40 +11:00
assert.equal(config.colors.model, 214);
assert.equal(config.colors.project, '#33ff00');
assert.equal(config.colors.git, 'cyan');
assert.equal(config.colors.gitBranch, DEFAULT_CONFIG.colors.gitBranch);
assert.equal(config.colors.label, 'dim');
assert.equal(config.colors.custom, '#ff6600');
});
// --- Custom color value tests (256-color and hex) ---
test('mergeConfig accepts 256-color index values', () => {
const config = mergeConfig({
colors: {
context: 82,
usage: 214,
warning: 220,
usageWarning: 97,
critical: 196,
2026-03-23 15:04:40 +11:00
model: 214,
project: 82,
git: 220,
gitBranch: 45,
label: 250,
custom: 208,
},
});
assert.equal(config.colors.context, 82);
assert.equal(config.colors.usage, 214);
assert.equal(config.colors.warning, 220);
assert.equal(config.colors.usageWarning, 97);
assert.equal(config.colors.critical, 196);
2026-03-23 15:04:40 +11:00
assert.equal(config.colors.model, 214);
assert.equal(config.colors.project, 82);
assert.equal(config.colors.git, 220);
assert.equal(config.colors.gitBranch, 45);
assert.equal(config.colors.label, 250);
assert.equal(config.colors.custom, 208);
});
test('mergeConfig accepts hex color strings', () => {
const config = mergeConfig({
colors: {
context: '#33ff00',
usage: '#FFB000',
warning: '#ff87d7',
2026-03-23 15:04:40 +11:00
label: '#abcdef',
custom: '#ff6600',
},
});
assert.equal(config.colors.context, '#33ff00');
assert.equal(config.colors.usage, '#FFB000');
assert.equal(config.colors.warning, '#ff87d7');
2026-03-23 15:04:40 +11:00
assert.equal(config.colors.label, '#abcdef');
assert.equal(config.colors.custom, '#ff6600');
});
test('mergeConfig accepts mixed named, 256-color, and hex values', () => {
const config = mergeConfig({
colors: {
context: '#33ff00',
usage: 214,
warning: 'yellow',
usageWarning: '#af87ff',
critical: 'red',
2026-03-23 15:04:40 +11:00
model: 214,
project: '#33ff00',
git: 'magenta',
gitBranch: '#abcdef',
label: 'dim',
custom: 208,
},
});
assert.equal(config.colors.context, '#33ff00');
assert.equal(config.colors.usage, 214);
assert.equal(config.colors.warning, 'yellow');
assert.equal(config.colors.usageWarning, '#af87ff');
assert.equal(config.colors.critical, 'red');
2026-03-23 15:04:40 +11:00
assert.equal(config.colors.model, 214);
assert.equal(config.colors.project, '#33ff00');
assert.equal(config.colors.git, 'magenta');
assert.equal(config.colors.gitBranch, '#abcdef');
assert.equal(config.colors.label, 'dim');
assert.equal(config.colors.custom, 208);
});
test('mergeConfig rejects invalid 256-color indices', () => {
const config = mergeConfig({
colors: {
context: 256,
usage: -1,
warning: 1.5,
},
});
assert.equal(config.colors.context, DEFAULT_CONFIG.colors.context);
assert.equal(config.colors.usage, DEFAULT_CONFIG.colors.usage);
assert.equal(config.colors.warning, DEFAULT_CONFIG.colors.warning);
});
test('mergeConfig rejects invalid hex strings', () => {
const config = mergeConfig({
colors: {
context: '#fff',
usage: '#gggggg',
warning: 'ff0000',
},
});
assert.equal(config.colors.context, DEFAULT_CONFIG.colors.context);
assert.equal(config.colors.usage, DEFAULT_CONFIG.colors.usage);
assert.equal(config.colors.warning, DEFAULT_CONFIG.colors.warning);
});