# Red Hat Oracle

AI-powered knowledge assistant for Red Hat engineering teams. Ingests GitHub/GitLab repositories, Jira issues, GitLab Pages, public web docs, and Slack conversations, indexes them in a ChromaDB vector store, and provides RAG-based chat via local or cloud LLMs.

## Prerequisites

- Python 3.11+
- [Ollama](https://ollama.com/) running locally (recommended LLM backend)
- Git (for cloning source repos)

## Installation

```bash
# Clone the repo
git clone git@github.com:dmzoneill/redhat-oracle.git
cd redhat-oracle

# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install in development mode (with dev dependencies)
pip install -e ".[dev]"

# Or install without dev dependencies
pip install -e .
```

## Configuration

Copy and edit the sample config:

```bash
cp oracle.yaml ~/.config/redhat-oracle/oracle.yaml
```

Config files are loaded and merged in order (higher precedence wins):

1. `/etc/redhat-oracle/oracle.yaml` (system)
2. `~/.config/redhat-oracle/oracle.yaml` (user)
3. `./oracle.yaml` (project)

### Secrets

Tokens are **never** stored in config files. Set them as environment variables:

```bash
export ORACLE_GITHUB_TOKEN="ghp_..."
export ORACLE_GITLAB_TOKEN="glpat-..."
export ORACLE_SLACK_TOKEN="xoxb-..."
export ORACLE_JIRA_TOKEN="..."
export OPENAI_API_KEY="sk-..."        # optional, if using OpenAI
export ANTHROPIC_API_KEY="sk-ant-..." # optional, if using Anthropic
```

## Usage

### CLI

```bash
oracle            # Start interactive chat
oracle sync       # Sync all configured sources
oracle status     # Show index status
```

### GUI (optional)

```bash
pip install -e ".[gui]"
oracle --gui
```

## Development

```bash
# Run tests
make test

# Lint
make lint

# Type check
make typecheck

# Build distribution
make build
```

Or run commands directly:

```bash
pytest tests/
ruff check src/ tests/
mypy src/
```

## Architecture

| Module | Purpose |
|---|---|
| `core/config.py` | YAML config loading with Pydantic validation |
| `core/sources/` | Data source connectors (GitHub, GitLab, Slack, Jira, Pages, Web) |
| `core/vectordb/` | ChromaDB vector store, AST-aware chunking, change tracking |
| `core/rag.py` | RAG pipeline: embed query, search, assemble context, stream LLM |
| `core/cache.py` | Response caching |
| `cli/app.py` | Click + prompt-toolkit + Rich terminal UI |
| `gui/app.py` | PySide6 (Qt) desktop GUI |

## License

MIT
