npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

axium-cli

v1.0.6

Published

AI-powered test generation for Next.js & NestJS applications with auto-fix

Readme

Axium CLI v1.0.6

🚀 AI-Powered Test Generation with Auto-Fix for Next.js & NestJS

✨ New Feature: Auto-Fix 🔧

Axium can now automatically fix failing tests until they pass!

axium auto-fix src/users/users.service.ts

The CLI will:

  1. ✅ Generate the test
  2. ✅ Run it
  3. ✅ Detect errors
  4. ✅ Fix them with AI
  5. ✅ Retry until all tests pass

📦 Installation

npm install -g axium-cli

🚀 Quick Start

# Initialize
axium init

# Generate and auto-fix a test
axium auto-fix src/users/users.service.ts

# Regular generation
axium generate src/users/users.service.ts

# Scan directory
axium scan src/

🎯 Commands

axium auto-fix <file> 🆕

Automatically generate and fix tests until they pass!

# Basic usage
axium auto-fix src/users/users.service.ts

# With options
axium auto-fix src/users/users.service.ts \
  --max-retries 5 \
  --verbose \
  --test-framework jest

# Options:
  --max-retries <number>    Maximum fix attempts (default: 5)
  --timeout <ms>            Test execution timeout (default: 60000)
  --test-framework <name>   jest or vitest
  --dry-run                 Preview without saving
  --no-save-report          Don't save the report
  --verbose                 Show detailed output

What it does:

Step 1: Generate test
   ↓
Step 2: Run test → ✅ Pass? → Done!
   ↓                ❌ Fail?
Step 3: Analyze errors
   ↓
Step 4: Fix with AI
   ↓
Step 5: Save fixed test
   ↓
Back to Step 2 (max 5 iterations)

Example output:

╔════════════════════════════════════════════════════════════╗
║                    🎯 AUTO-FIX REPORT                      ║
╠════════════════════════════════════════════════════════════╣
║ 📁 Source File: src/users/users.service.ts                 ║
║ 🧪 Test File:   src/users/users.service.spec.ts           ║
║                                                            ║
║ Status: ✅ SUCCESS                                         ║
║                                                            ║
║ 📊 Statistics:                                             ║
║   • Attempts:        3                                     ║
║   • Errors Solved:   4                                     ║
║   • Errors Remaining: 0                                    ║
║   • Total Duration:  12500ms                               ║
║                                                            ║
║ 🔄 Attempts:                                               ║
║   ❌ Iteration 1: 0/3 passed                               ║
║   ❌ Iteration 2: 1/3 passed                               ║
║   ✅ Iteration 3: 3/3 passed                               ║
╚════════════════════════════════════════════════════════════╝

🎉 All tests are now passing!

axium generate <file>

Generate tests for a specific file.

axium generate src/users/users.service.ts
axium generate src/users/users.service.ts --test-framework vitest
axium generate src/users/users.controller.ts --type e2e

axium scan <directory>

Scan and generate tests for all files.

axium scan src/
axium scan src/ --test-framework vitest --parallel

axium analyze <directory>

Analyze test coverage.

axium analyze src/ --report --suggest

axium watch [directory]

Watch and auto-generate on changes.

axium watch src/

⚙️ Configuration

axium.config.js:

module.exports = {
  model: {
    provider: 'ollama',
    name: 'codellama:13b',
    baseUrl: 'http://localhost:11434',
  },
  framework: {
    type: 'nestjs',
  },
  test: {
    framework: 'jest',
    parallel: true,
    maxConcurrency: 5,
  },
};

🎯 Auto-Fix Features

Smart Error Detection

  • ✅ Import errors
  • ✅ Syntax errors
  • ✅ Mock errors
  • ✅ Assertion failures
  • ✅ Runtime errors
  • ✅ Timeout issues

Intelligent Fixing

  • 🧠 AI analyzes the error context
  • 🔧 Generates targeted fixes
  • 📊 Prioritizes critical errors
  • 🔄 Iterates until success
  • 💾 Saves detailed reports

Error Examples Fixed Automatically

Import Error:

❌ Cannot find module '@nestjs/testing'
✅ Fixed: Added missing import

Mock Error:

❌ TypeError: mockRepository.find is not a function
✅ Fixed: Added jest.fn() to mock

Assertion Error:

❌ Expected: [Array], Received: undefined
✅ Fixed: Added proper mock return value

📊 Comparison

| Feature | generate | auto-fix 🆕 | |---------|-----------|--------------| | Generate test | ✅ | ✅ | | Run test | ❌ | ✅ | | Detect errors | ❌ | ✅ | | Fix automatically | ❌ | ✅ | | Retry loop | ❌ | ✅ | | Detailed report | ❌ | ✅ |


🎬 Workflow Examples

Example 1: NestJS Service

# Create a service
cat > src/users/users.service.ts << 'EOF'
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './user.entity';

@Injectable()
export class UsersService {
  constructor(
    @InjectRepository(User)
    private userRepository: Repository<User>,
  ) {}

  async findAll(): Promise<User[]> {
    return this.userRepository.find();
  }
}
EOF

# Auto-fix it!
axium auto-fix src/users/users.service.ts

# Output:
# 🚀 Starting auto-fix for: users.service.ts
# 🔍 Analyzing source code...
# 🤖 Generating initial test...
# ✅ Test file created: src/users/users.service.spec.ts
# 
# 🔄 Attempt 1/5
# 🧪 Running test...
# ❌ Tests failed: 1/3
# 📊 Analyzing errors...
# 🔧 Generating fix with AI...
# 💾 Fixed test saved
# 
# 🔄 Attempt 2/5
# 🧪 Running test...
# ✅ All tests passed! (3/3)
# 
# 🎉 All tests are now passing!

Example 2: Next.js API Route

# Auto-fix Next.js route
axium auto-fix src/app/api/users/route.ts --test-framework vitest

# The CLI will:
# 1. Detect it's Next.js
# 2. Generate route.test.ts (not .spec.ts)
# 3. Run vitest
# 4. Fix errors
# 5. Until all pass

🐛 Troubleshooting

"jest is not installed"

npm install --save-dev jest @types/jest ts-jest

"Test execution timed out"

axium auto-fix file.ts --timeout 120000  # 2 minutes

"Max retries reached"

# Increase retries
axium auto-fix file.ts --max-retries 10

# Or check the report
cat .axium-reports/autofix-*.json

📈 Roadmap

v1.1.0 (Current)

  • ✅ Auto-fix for single files
  • ✅ Error detection and analysis
  • ✅ AI-powered fixes
  • ✅ Detailed reports

v1.2.0 (Next)

  • 🔄 axium auto-fix-scan - Auto-fix entire directories
  • 📊 Coverage-driven test generation
  • 🎨 Interactive mode
  • 🔔 Watch mode with auto-fix

v1.3.0 (Future)

  • 🧬 Mutation testing
  • 🤖 Smart test suggestions
  • 📈 Quality metrics
  • 🔌 Plugin system

🤝 Contributing

Contributions welcome! Please read CONTRIBUTING.md.

📄 License

MIT


Made with ❤️ by Armel Dakayao

NPM# axium-cli