Metadata-Version: 2.4
Name: ai-pr-cost-guard
Version: 0.3.0
Summary: Diff-aware Python AST and JS/TS static FinOps gate, 2026 token pricing & caching calculator, SARIF exporter, and FinOps MCP server.
Author-email: Andrey Pimenov <carl@mcpshieldwall.dpdns.org>
License: MIT
Keywords: llm,finops,openai,anthropic,gemini,static-analysis,ast,pre-commit,cost-guard
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Security
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 💸 AI PR Cost & Secret Guard (GitHub Action + CLI)

**Prevent surprise $5,000 LLM API bills and leaked keys before merge.**

Try the live interactive demo on Hugging Face Spaces:
👉 **[https://huggingface.co/spaces/snsnshnwh/ai-pr-cost-guard](https://huggingface.co/spaces/snsnshnwh/ai-pr-cost-guard)**

## Zero-Install Quickstart (`uvx`)

Run directly against your repo or staged git changes with [`uvx`](https://docs.astral.sh/uv/) — no installation required:

```bash
# Scan a directory or file
uvx ai-pr-cost-guard ./src

# Scan staged git changes before committing
uvx ai-pr-cost-guard --git-diff --format text

# Emit a Markdown summary report
uvx ai-pr-cost-guard --git-diff --markdown
```

## GitHub Action

Drop this 6-line GitHub Action into any repository using OpenAI, Anthropic, or Gemini SDKs:

```yaml
name: AI Cost Guard
on: [pull_request]
jobs:
  cost-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: andrejpimenov122-lab444/ai-pr-cost-guard@v1
```

## Pre-commit Hook

Add to `.pre-commit-config.yaml` to scan staged Python, TypeScript, and JavaScript files:

```yaml
repos:
  - repo: https://github.com/andrejpimenov122-lab444/ai-pr-cost-guard
    rev: v0.2.1
    hooks:
      - id: ai-pr-cost-guard
```

## What It Catches
- **`COST-001` (HIGH)**: Exposed OpenAI, Anthropic, and Google Gemini API keys (redacted; including `.env` and `.ipynb` outputs).
- **`COST-002` (HIGH)**: LLM SDK calls inside unbounded `while`/`for` loops or unbounded retry decorators.
- **`COST-003` (MEDIUM)**: Endpoint-aware missing, invalid, or policy-exceeding output token caps (`max_tokens` / `max_output_tokens`).
- **`COST-004` (LOW)**: Missing finite `timeout` on SDK client or per-request calls.

## Local CLI Usage
```bash
python3 cost_guard.py ./src
```

## License
MIT
