Metadata-Version: 2.4
Name: recheck-ai
Version: 0.1.0
Summary: Re-fetch AI source URLs live and verify quoted claims still appear on the page.
Author-email: Joshua Almeida <192924532+fitzyracing1@users.noreply.github.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/fitzyracing1/recheck
Project-URL: Issues, https://github.com/fitzyracing1/recheck/issues
Project-URL: PyPI, https://pypi.org/project/recheck-ai/
Keywords: ai,citations,sources,verification,mcp
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Requires-Dist: respx>=0.21; extra == "dev"
Dynamic: license-file

# recheck

Re-fetch every URL an AI looked at and check that the quotes in its answer still appear on the live page.

Built after stale cached copies of a changelog produced bad drafts: the model quoted a page that had already changed (or a cached snapshot that no longer matched production). `recheck` is meant to be called *while an answer is still being written* so those misses get flagged before anyone ships the draft.

## 30-second example

```bash
pip install recheck-ai
# or: pip install git+https://github.com/fitzyracing1/recheck

recheck https://fitzyracing1.github.io/x-algorithm-changelog/ \
  --quote 'VideoOpenWeight' \
  --quote 'this-quote-is-definitely-not-here-xyz'
```

The PyPI package is named `recheck-ai` because the name `recheck` is already taken. The commands remain `recheck` and `recheck-mcp`.

You should see the first quote marked found (`✓`, exact or compact, score `1.00`) and the second marked missing (`✗`). Exit status is `1` whenever any source failed or any quote was not found; pass `--json` for a machine-readable report.

JSON input (what a bot should send mid-answer):

```bash
recheck examples/sources.json
recheck examples/sources.json --json
```

```json
[
  {
    "url": "https://fitzyracing1.github.io/x-algorithm-changelog/",
    "quotes": ["VideoOpenWeight", "this-quote-is-definitely-not-here-xyz"],
    "snapshot_hash": "optional-sha256-of-the-body-you-already-fetched",
    "fetched_at": "2026-11-26T08:00:00Z"
  }
]
```

`snapshot_hash` is the SHA-256 hex digest of the raw response body (optionally prefixed with `sha256:`). If you pass one and the live body hashes differently, the source is flagged `changed` even when the quotes are still present.

## Statuses

| Status     | Meaning                                              |
|------------|------------------------------------------------------|
| `ok`       | Fetched, optional snapshot matches                   |
| `changed`  | Fetched, but `snapshot_hash` does not match the live body |
| `gone`     | HTTP 404 or 410                                      |
| `blocked`  | HTTP 401, 403, 407, or 429                           |
| `timeout`  | The request exceeded `--timeout` (default 15s)       |
| `error`    | Other network or HTTP failures                       |

Each quote is checked against the live body after normalizing whitespace and case. If that misses, a compact alphanumeric comparison runs (so `Video Open Weight` still matches `VideoOpenWeight`). If that also misses, a windowed fuzzy score is reported; scores at or above `--fuzzy-threshold` (default `0.8`) count as found.

## MCP

A tiny stdio MCP server is included so any bot can call this mid-answer. It has no dependency beyond `httpx`.

```bash
recheck-mcp
# or: python -m recheck.mcp_server
```

The server exposes one tool, `recheck_sources`, with the same JSON shape as the CLI. Point your MCP client at the `recheck-mcp` command on stdio.

Example Cursor / Claude-style config:

```json
{
  "mcpServers": {
    "recheck": {
      "command": "recheck-mcp"
    }
  }
}
```

## Library

```python
from recheck import SourceInput, recheck_sources_sync

report = recheck_sources_sync([
    SourceInput(
        url="https://fitzyracing1.github.io/x-algorithm-changelog/",
        quotes=["VideoOpenWeight"],
    )
])
print(report.ok, report.to_dict())
```

Async callers can `await recheck_sources(...)` instead.

## Install / develop

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
```

Requires Python 3.11+.

## Limits (v0)

- Fetches the raw HTTP response. It does not execute JavaScript, so quotes that exist only in a client-rendered app will look missing.
- Bodies are capped at 5 MB.
- `snapshot_hash` is a hash of the raw bytes. Pages with dynamic ads, timestamps, or CSRF tokens will show up as `changed` even when the quoted text is unchanged.
- Fuzzy matching samples windows on long pages, so it can miss a near-match or report a softer score than a full scan.
- No cookies, auth, or robots-txt handling. This is a verifier for URLs the model already opened, not a crawler.
- Concurrent fetches are capped (default 8) so a long source list cannot hammer a site.

## License

MIT.
