Skip to main content

Offline AI QA Assistant

Project description

CodeGuardian

An Offline AI QA Assistant that tests applications automatically and explains failures.

No internet. No API keys. No cloud services.

Architecture & Features

  • CLI Automation: Built with Typer and Rich for a premium terminal experience.
  • API Testing: Uses HTTPX to validate JSON endpoints.
  • UI Testing: Uses Playwright for headless browser automation and UI validation.
  • Static Analysis: Hooks into Semgrep and Ruff.
  • RAG & Knowledge Base: Parses source code with Tree-sitter, embeds it using SentenceTransformers, and stores it in ChromaDB.
  • Local AI Explanations: Queries your local Ollama (qwen2.5-coder recommended) to explain test failures by correlating test errors with the relevant source code.

Installation

Ensure you have Python 3.10+ installed.

CodeGuardian uses optional dependencies so you only install what you need.

git clone <repository>
cd CodeGuardian
python -m venv venv

# On Windows:
.\venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate

Install CodeGuardian with the features you need:

Use case Command Approx size
API testing only pip install -e . ~50MB
+ UI testing pip install -e .[ui] ~200MB
+ AI explanations pip install -e .[ai] ~3GB
+ Code scanning pip install -e .[scan] ~100MB
Everything pip install -e .[full] ~3.5GB

(Note: AI explanations require PyTorch which is ~2GB. Playwright requires an extra step: playwright install chromium).

Install Ollama

Install Ollama on your local machine if you plan to use AI features. CodeGuardian will automatically pull the recommended model (qwen2.5-coder) when you first use the ask command.

Usage

1. Initialize

Initialize the CodeGuardian database and pre-compile any language grammars:

cd /path/to/your/project
codeguardian init

2. Configure Tests

Create a codeguardian-api.json or codeguardian-ui.json in your project root. CodeGuardian will validate your config using Pydantic before running.

codeguardian-api.json

{
  "base_url": "https://httpbin.org",
  "tests": [
    {"name": "Get Request", "url": "/get", "method": "GET", "expected_status": 200},
    {"name": "Not Found", "url": "/status/404", "method": "GET", "expected_status": 404}
  ]
}

codeguardian-ui.json

{
  "browser": "chromium",
  "headless": true,
  "tests": [
    {
      "name": "Check Example Domain",
      "steps": [
        {"action": "navigate", "url": "http://example.com"},
        {"action": "assert_visible", "selector": "h1"}
      ]
    }
  ]
}

3. Run Tests

Run both API and UI tests (results will be logged to SQLite):

codeguardian test
# Or target specific suites:
# codeguardian test --api-only
# codeguardian test --ui-only

4. Build Knowledge Base

Scan the project to run static analysis and build the ChromaDB vector index:

codeguardian scan .

5. Ask the AI

If tests fail, query the AI. CodeGuardian will fetch the latest failures, pull relevant source code from ChromaDB, and ask Ollama to explain what went wrong:

codeguardian ask "Why did the API tests fail?"

6. Generate Reports

Export beautiful HTML reports or JUnit XML for CI/CD integrations:

codeguardian report --format html
codeguardian report --format junit
codeguardian report --format both

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codeguardian_offline-0.1.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codeguardian_offline-0.1.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file codeguardian_offline-0.1.0.tar.gz.

File metadata

  • Download URL: codeguardian_offline-0.1.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for codeguardian_offline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ae7439cb9c60f69c6d6365cc93733a2625eb49139fb1b329adfdf2c67a708e0
MD5 082409d7fb0409fda8cc2572ca5e5e67
BLAKE2b-256 812bed641c3a21c2926de96bbad3a661a974093c23a58c132008c990250b14ff

See more details on using hashes here.

File details

Details for the file codeguardian_offline-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codeguardian_offline-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64d4c946d2f65b2ef5d33b95df773bb1a2d06d763655b566143b940c25cfb150
MD5 31629f6aac83f45ae95ee574314a554b
BLAKE2b-256 d4e9acbd080c482db170822c6a59cdfd6e304382793dd7b5aecf649395bc1309

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page