# Codebase Quality Lenses

Universal library for executing code quality tools (linters, test runners, static analyzers) and normalizing their output for visualization systems.

## Features

- 🔧 Execute quality tools across any programming language
- 📊 Normalize output to a consistent format
- 🌐 Environment agnostic (works in Node.js and Electron)
- 🎯 Clean separation from codebase analysis logic
- 🧪 Comprehensive test coverage for each lens
- 🚀 Built with TypeScript and Bun for performance

## Supported Tools (v1.0)

- **ESLint** - JavaScript/TypeScript linting
- **TypeScript** - Type checking
- **Jest** - Test runner and coverage
- **Git** - Version control status
- **Knip** - Find unused files, exports, and dependencies

## Installation

```bash
bun add codebase-quality-lenses
```

## Usage

```typescript
import { LensManager } from 'codebase-quality-lenses';

// Configuration comes from codebase-composition or your analysis tool
const config = {
  tools: [
    {
      name: 'eslint',
      command: 'npx',
      args: ['eslint', '--format', 'json', 'src/'],
      cwd: '/path/to/project'
    },
    {
      name: 'typescript',
      command: 'npx',
      args: ['tsc', '--noEmit'],
      cwd: '/path/to/project'
    }
  ]
};

const manager = new LensManager(config);
const results = await manager.runAll();

console.log(results.issues);
// [{ file: 'src/index.ts', line: 10, severity: 'error', message: '...' }]
```

## Development

```bash
# Install dependencies
bun install

# Build
bun run build

# Run tests
bun test

# Type check
bun run typecheck

# Lint
bun run lint
```

## Architecture

This library focuses on:
1. **Executing** quality tool commands
2. **Parsing** tool output
3. **Normalizing** results to a standard format

Tool detection and configuration analysis is handled by separate libraries like `codebase-composition`.

### Core Components

- **BaseLens** - Abstract base class for all quality lenses
- **Executors** - Environment-specific command execution (Node.js, Electron, Mock)
- **PathMapper** - Cross-platform path normalization
- **Lenses** - Tool-specific implementations (ESLint, TypeScript, Jest, Git, Knip)

## Current Status

✅ **Milestone 1: Core Infrastructure** (Complete)
- TypeScript project setup with Bun
- Base types and interfaces defined
- Executor pattern with environment detection
- Path mapping utilities

✅ **Milestone 2: JavaScript Quality Lenses** (Complete)
- ✅ Test infrastructure setup
- ✅ ESLintLens - JavaScript/TypeScript linting (100% test coverage)
- ✅ GitLens - Version control insights (Complete with tests)
- ✅ KnipLens - Find unused files, exports, and dependencies (Complete with tests)
- ✅ TypeScriptLens - Type checking (Complete with tests)
- ✅ JestLens - Test runner and coverage (Complete with tests)

## License

MIT