Skip to main content

ai-context-cli

PyPI version Python versions License

HTTP(S) → clean Markdown for LLM context: httpx fetch → Readability → markdownify; optional LiteLLM summary with --summary (lazy-loaded — no LLM stack until you opt in).

# Markdown only (stdout stays pipe-clean; errors → stderr)
ai-context-cli "https://example.com/article"

# Same + LLM summary (loads .env from cwd for API keys)
ai-context-cli "https://example.com/article" --summary

# Verbose pipeline logs on stderr
ai-context-cli "https://example.com/article" --summary -v

Architecture and conventions: SPEC.md.

⚡ Why

Raw HTML wastes tokens. ai-context-cli is a small preprocessing step: one URL in, readable Markdown (and optionally a short summary) out.

🧩 What you get

  • Readability-based main content extraction (readability-lxml)
  • Markdown via markdownify
  • Optional LLM summary via LiteLLM (--summary, --model)
  • Typed errors → stable CLI exit codes (see SPEC.md §7)

Scope today: SOURCE is an http(s) URL or a local file or directory (UTF-8 text; see SPEC §5). --structure and --version are available.

Quick Start

# 1) Install
pip install ai-context-cli

# 2) Convert a page to Markdown
ai-context-cli "https://example.com/article"

# 3) Show installed version
ai-context-cli --version

# 4) Add a summary block
ai-context-cli "https://example.com/article" --summary

📦 Install

From a clone (dev):

python3 -m venv .venv
source .venv/bin/activate   # Windows: .\.venv\Scripts\Activate.ps1
pip install -U pip
pip install -e ".[dev]"
ai-context-cli --help

From PyPI: pip install ai-context-cli

Requires Python 3.11+.

🤖 LLM providers (LiteLLM)

--summary uses LiteLLM model ids. Set the provider’s native env vars (also read from a .env in the working directory when --summary is used).

Provider Example --model Credentials
OpenAI gpt-4o-mini (default if --model omitted) OPENAI_API_KEY
Anthropic anthropic/claude-3-5-sonnet-latest ANTHROPIC_API_KEY
OpenRouter openrouter/openai/gpt-4o-mini (pick any model slug OpenRouter exposes) OPENROUTER_API_KEY
Ollama (local) ollama/llama3 Optional: OLLAMA_API_BASE (default http://localhost:11434)
ai-context-cli "https://example.com/article" --summary --model "openrouter/openai/gpt-4o-mini"
ai-context-cli "https://example.com/article" --summary --model "ollama/llama3"

See .env.example for other keys (MISTRAL_API_KEY, timeouts, etc.).

🧪 Tests & lint

pytest
ruff check .
ruff format --check .
mypy src

🤝 Contributing

See CONTRIBUTING.md (layers, ports/adapters, where to put code).

📝 Changelog

Release notes are tracked in CHANGELOG.md.

📄 License

MIT — see LICENSE.

Metadata

Release files for ai-context-cli 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-context-cli 1.0.0
File Size Uploaded Provenance
ai_context_cli-1.0.0.tar.gz 38.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-context-cli 1.0.0
File Interpreter ABI Platform
ai_context_cli-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 69.7 kB

Release files / ai_context_cli-1.0.0.tar.gz

Download URL ai_context_cli-1.0.0.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1fb4ca5e00ec62ff380e871f083271e1d9ce16de22f9bc40f93388d143d8bdc3
BLAKE2b-256 checksum
How to use checksums
d12748e0a982afc47b692f16f1adeb6d22c6ea1f4c492bb97776e933ea5640af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.2 HTTPX/0.28.1

Release files / ai_context_cli-1.0.0-py3-none-any.whl

Download URL ai_context_cli-1.0.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc6a81481ea24ddfbe00687d47478c33fdae38f5eed3324e33c3ca63fefd5748
BLAKE2b-256 checksum
How to use checksums
5fb28e704a0864e01c0cd9efe0ff27ee3a3a8933629c24366889bc91975edf49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.2 HTTPX/0.28.1

Security for ai-context-cli 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page