<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Detection Metrics Tracking

## Agent Tools

| Tool | Description |
|---|---|
| Coverage Calculator | `calculate_coverage_metrics(covered, total)` — Coverage percentage |
| Quality Measurer | `measure_rule_quality(rules)` — Rule quality analysis |
| Health Reporter | `generate_health_report(metrics)` — Program health summary |

## CLI Usage

```bash
# Coverage metrics
node agent.js coverage --covered 127 --total 201

# Rule quality
node agent.js quality --rules '[{"has_test": true, "fp_rate": 0.1}]'

# Health report
node agent.js health --metrics '{"coverage": {"pct": 63}}'
```

## Output Format

All commands return JSON with the following structure:

```json
{
  "action": "<command_name>",
  "...": "command-specific fields"
}
```

## Error Handling

- Invalid input returns `{"error": "description"}` with non-zero exit code
- JSON parsing errors are caught and reported with context
- Missing required arguments trigger argparse help display
