Analyze entire directory recursively

January 28, 2026 Β· View on GitHub

Hambugsy Logo

Hambugsy

The CLI tool that tells you WHO is wrong: your test or your code.

npm version npm downloads License: MIT Built with GitHub Copilot CLI Node.js 18+ Tests

πŸ“¦ View on npm β€’ 🌐 Website β€’ ⚑ Quick Start


Quick Install

npm install -g hambugsy
hambugsy analyze ./src

Demo

asciicast


The Problem

Every developer knows this pain:

❌ FAILED: testCalculateDiscount
   Expected: 90
   Actual: 85

Now what? Is the test wrong? Is the code wrong? Did someone change the business logic? Is the test outdated?

You spend 30 minutes investigating only to find the test was written for the OLD discount logic.


The Solution

$ hambugsy analyze ./src/OrderService.java

πŸ” HAMBUGSY - Test Failure Diagnostics πŸ”
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ“ Method: calculateDiscount() @ line 32                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ❌ FAILING TEST: testPremiumDiscount                              β”‚
β”‚                                                                    β”‚
β”‚  πŸ”¬ ANALYSIS:                                                      β”‚
β”‚  β”œβ”€β”€ Test expects: 10% discount (written: 2024-03-15)              β”‚
β”‚  └── Code applies: 15% discount (changed: 2024-11-22)              β”‚
β”‚                                                                    β”‚
β”‚  🎯 VERDICT: πŸ“œ OUTDATED TEST (96%)                                β”‚
β”‚                                                                    β”‚
β”‚  πŸ’‘ RECOMMENDATION:                                                β”‚
β”‚  - assertEquals(90.0, result);                                     β”‚
β”‚  + assertEquals(85.0, result);                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“Š SUMMARY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  πŸ› Code bugs:        0
  πŸ“œ Outdated tests:   1
  βœ… Passed:           5

  πŸš€ Estimated time saved: ~15 minutes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

How It Works

Hambugsy uses GitHub Copilot CLI to perform intelligent analysis:

  1. Parse - Extracts test assertions and code logic
  2. Compare - Analyzes intent of test vs. implementation
  3. Investigate - Checks git history for recent changes
  4. Diagnose - Determines which side diverged from expected behavior
  5. Recommend - Suggests specific fixes with line numbers
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Test File  β”‚    β”‚  Source Code β”‚    β”‚  Git History β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚                   β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  GitHub Copilot β”‚
         β”‚       CLI       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚    VERDICT:     β”‚
         β”‚  Test or Code?  β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation

Prerequisites

1. GitHub CLI (gh)

First, install the GitHub CLI if you haven't already:

# macOS (Homebrew)
brew install gh

# Windows (winget)
winget install --id GitHub.cli

# Ubuntu/Debian
sudo apt install gh

# Or download from: https://cli.github.com/

2. GitHub Copilot CLI Extension

Hambugsy leverages GitHub Copilot CLI for AI-powered analysis. Here's how to set it up:

# Step 1: Authenticate with GitHub
gh auth login
# Follow the prompts to authenticate via browser or token

# Step 2: Install the Copilot CLI extension
gh extension install github/gh-copilot

# Step 3: Verify installation
gh copilot --help

Requirements for GitHub Copilot CLI:

  • Active GitHub Copilot subscription (Individual, Business, or Enterprise)
  • GitHub CLI version 2.0.0 or higher
  • Authenticated GitHub session with Copilot access

Troubleshooting:

# If you get permission errors, ensure you're logged in
gh auth status

# If Copilot CLI is not found, try reinstalling
gh extension remove gh-copilot
gh extension install github/gh-copilot

# To upgrade to the latest version
gh extension upgrade gh-copilot

Note: Hambugsy works without GitHub Copilot CLI but with limited functionality. The AI-powered semantic analysis and intelligent fix suggestions require Copilot CLI to be installed and authenticated.


Install Hambugsy

# Option 1: Install globally from npm
npm install -g hambugsy

# Option 2: Clone and build locally
git clone https://github.com/APorkolab/hambugsy.git
cd hambugsy
npm install
npm run build
npm link

Usage

Analyze Command

Analyze test failures and determine if the test or code is buggy.

# Analyze a specific file
hambugsy analyze ./src/OrderService.java

# Analyze entire directory recursively
hambugsy analyze ./src --recursive

# Filter results
hambugsy analyze ./src --filter=bugs      # Only show code bugs
hambugsy analyze ./src --filter=tests     # Only show outdated tests

# Output formats
hambugsy analyze ./src --format=console   # Pretty terminal output (default)
hambugsy analyze ./src --format=json      # JSON for CI/CD integration
hambugsy analyze ./src --format=github    # GitHub Actions annotations
hambugsy analyze ./src --format=markdown  # Markdown report

# Filter by test name
hambugsy analyze ./src --test=testDiscount  # Only analyze tests matching name

# Interactive mode
hambugsy analyze ./src --interactive      # Confirm each step

# Verbose output
hambugsy analyze ./src --verbose

Suggest Command

Find missing tests and generate test suggestions.

# Find missing tests in a file/directory
hambugsy suggest ./src/OrderService.java

# Generate test files
hambugsy suggest ./src --generate

# Filter by priority
hambugsy suggest ./src --priority=critical  # Only CRITICAL issues
hambugsy suggest ./src --priority=high      # CRITICAL + HIGH
hambugsy suggest ./src --priority=medium    # All except LOW

Fix Command

Automatically fix detected issues.

# Auto-fix all detected issues
hambugsy fix ./src

# Dry run - see what would change without modifying files
hambugsy fix ./src --dry-run

# Skip confirmation prompts
hambugsy fix ./src --yes

# Fix only code bugs or only tests
hambugsy fix ./src --filter=bugs   # Only fix code bugs
hambugsy fix ./src --filter=tests  # Only fix outdated tests

Init Command

Initialize Hambugsy configuration in your project.

hambugsy init
hambugsy init --language=java
hambugsy init --force  # Overwrite existing config

Supported Languages

LanguageTest FrameworkStatus
JavaJUnit 4/5, TestNGβœ… Supported
TypeScript/JavaScriptJest, Vitest, Mochaβœ… Supported
Pythonpytest, unittestβœ… Supported
Gogo test, testifyβœ… Supported
Rust#[test], tokio::testβœ… Supported
C#NUnit, xUnit, MSTestβœ… Supported

The Verdict System

Hambugsy classifies every failing test into one of four verdicts:

VerdictMeaningIcon
Code BugTest is correct, code has a defectπŸ›
Outdated TestCode changed intentionally, test needs updateπŸ“œ
Flaky TestTest passes/fails inconsistently🎲
Environment IssueExternal dependency problem🌐

How Verdicts Are Determined

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Divergence Found  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ Is code newer than  β”‚
              β”Œβ”€YES──      the test?      β”œβ”€NO──┐
              β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
              β–Ό                                 β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Was the commit  β”‚               β”‚                 β”‚
    β”‚  intentional?   β”‚               β”‚    CODE BUG     β”‚
    β”‚ (feat:, refac:) β”‚               β”‚                 β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
      β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
      β”‚             β”‚
     YES            NO
      β”‚             β”‚
      β–Ό             β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚OUTDATED β”‚   β”‚CODE BUG β”‚
 β”‚  TEST   β”‚   β”‚(regress)β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Missing Test Detection

Hambugsy proactively identifies untested code paths:

$ hambugsy suggest ./src/OrderService.java

πŸ” HAMBUGSY - Missing Test Suggestions πŸ”
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

=== Test Coverage Analysis ===

Total methods:     8
Fully covered:     3
Partially covered: 3
Uncovered:         2

=== Missing Tests ===

πŸ“ validateOrder() @ OrderService.java:42
β”œβ”€β”€ βœ… TESTED: Basic functionality test
β”œβ”€β”€ ❌ MISSING: No test for null input (CRITICAL)
└── ❌ MISSING: No test for empty collection (HIGH)

└── πŸ’‘ SUGGESTED TEST:
    @Test
    void testValidateOrder_null_check() {
        OrderService instance = new OrderService();

        assertThrows(NullPointerException.class, () -> {
            instance.validateOrder(null);
        });
    }

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“Š MISSING TEST SUMMARY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  πŸ”₯ CRITICAL:  2
  ⚠️ HIGH:      3
  πŸ’‘ MEDIUM:    1
  βœ… LOW:       0

Detected Patterns

PatternDescriptionPriority
NULL_CHECKMethod has parameter but no null testCRITICAL
EXCEPTIONMethod can throw but no assertThrows testCRITICAL
EMPTY_COLLECTIONMethod takes List/Array but no empty testHIGH
BOUNDARYMethod has numeric param but no 0/-1/MAX testMEDIUM

Configuration

Create .hambugsy.yml in your project root:

# .hambugsy.yml
language: java
sourceDir: src/main
testDir: src/test
excludePatterns:
  - "**/node_modules/**"
  - "**/build/**"
  - "**/target/**"
outputFormat: console
copilotEnabled: true

CI/CD Integration

GitHub Actions

name: Test Analysis
on: [push, pull_request]

jobs:
  hambugsy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Full history for git analysis

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install GitHub Copilot CLI
        run: gh extension install github/gh-copilot
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Install Hambugsy
        run: npm install -g hambugsy

      - name: Run Analysis
        run: hambugsy analyze ./src --format=github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Examples

Example 1: Outdated Test After Business Logic Change

// OrderService.java - Updated 2024-11-22
public double calculateDiscount(double price, boolean isPremium) {
    return isPremium ? price * 0.85 : price * 0.95;  // 15%/5% discount
}

// OrderServiceTest.java - Written 2024-03-15
@Test
void testPremiumDiscount() {
    assertEquals(90.0, service.calculateDiscount(100, true));  // Expects 10%!
}
🎯 VERDICT: πŸ“œ OUTDATED TEST (96%)

The source code was intentionally updated but the test was not updated to match.
Commit: a1b2c3d - "feat: increase premium discount to 15%"

πŸ’‘ RECOMMENDATION:
Update the test in OrderServiceTest.java to match the new behavior.

Example 2: Actual Code Bug (Regression)

// UserService.java - Recently changed
public User getUser(String id) {
    User user = db.findById(id);
    return user;  // Missing null check - should throw!
}

// UserServiceTest.java
@Test
void testGetUser_NotFound() {
    assertThrows(UserNotFoundException.class,
        () -> service.getUser("invalid-id"));
}
🎯 VERDICT: πŸ› CODE BUG (92%)

Regression detected: recent code change broke existing functionality.
Commit: def5678 - "fix: typo in user lookup"

πŸ’‘ RECOMMENDATION:
Fix the code in UserService.java - add null check and throw UserNotFoundException.

Try It Yourself

Check out the included example project with intentional bugs:

git clone https://github.com/APorkolab/hambugsy.git
cd hambugsy/examples/buggy-discount-service
hambugsy analyze .

This will detect the discount rate mismatch (test expects 10%, code applies 15%).


Why "Hambugsy"?

Ham + Bug + Bugsy (the gangster)

  • πŸ” Ham - Like a hamburger with layers (test layer, code layer)
  • πŸ› Bug - What we're hunting
  • 🎩 Bugsy - Like Bugsy Siegel, we find who's guilty

"Finding the bug in your stack" - because bugs hide between layers, just like in a hamburger.


VS Code Extension

Hambugsy comes with a full VS Code extension for seamless integration.

Installation

# Build and install the extension
cd vscode-extension
npm install
npm run compile
npm run package
# Then install the .vsix file in VS Code

Features

  • CodeLens Integration - Inline verdict display directly on test methods
  • Quick Fix Actions - One-click fixes for detected issues
  • Problems Panel - Full diagnostic integration with VS Code
  • Results Tree View - Dedicated sidebar panel for analysis results
  • Context Menu - Right-click on any test file to analyze
  • Auto-analyze on Save - Optional real-time analysis
  • Multi-language Support - Java, TypeScript, JavaScript, Python, Go, Rust, C#
  • Detailed Webview Panel - Rich HTML view for analysis results

See vscode-extension/README.md for full documentation.


Roadmap

  • Core verdict engine
  • Java/JUnit 5 support
  • Git history analysis
  • Beautiful console output
  • Missing test detection (suggest command)
  • JSON output format
  • GitHub Actions format
  • Markdown output format
  • TypeScript/Jest/Vitest support
  • Python/pytest/unittest support
  • Auto-fix mode (fix command)
  • Interactive mode (--interactive)
  • Test name filter (--test)
  • VS Code extension
  • Go language support (go test, testify)
  • Rust language support (#[test], tokio::test)
  • C# language support (NUnit, xUnit, MSTest)
  • Real test execution integration
  • AST-based code analysis
  • Mutation testing for value mismatch detection
  • Advanced divergence detection
  • VS Code CodeLens and Quick Fix support

Contributing

We welcome contributions!

# Development setup
git clone https://github.com/APorkolab/hambugsy.git
cd hambugsy
npm install
npm run dev -- --help

# Run tests
npm test

# Type check
npm run typecheck

# Build
npm run build

License

MIT License - see LICENSE for details.


Acknowledgments

Built with ❀️ using GitHub Copilot CLI

Created for the GitHub Copilot CLI Challenge on DEV.to


πŸ” Stop blaming. Start fixing. πŸ”