AI-powered Python environment doctor — diagnose, research, resolve.
Project description
FixEnv — AI-Powered Python Environment Doctor
A production-grade CLI that diagnoses Python/Conda environment errors, researches fixes against current docs, and proposes safe shell commands — always behind a mandatory Human-in-the-Loop (HITL) approval gate. Works with any OpenAI-compatible LLM endpoint, ships a Textual TUI, an undo system, a plugin API, dependency auditing, environment diffing, and more.
$ fixenv diagnose "ModuleNotFoundError: No module named 'nltk'"
① Diagnostic → ② Research → ③ Resolution → ⛔ HITL approve → ✓ execute
Highlights
- 3-agent pipeline — Diagnostic → Research → Resolution, with validated Pydantic JSON handoffs (inspectable, loggable, cacheable).
- Grounded in your actual project — reads the real pin/constraint for the
affected package straight from
pyproject.toml/requirements.txtwhen relevant, instead of letting the model guess at what's installed vs. pinned. - Honest execution — a fix is only ever reported as successful if every
command's exit code was 0 and the Resolution agent's own
post_fix_verificationcommands actually pass when run for real — not just displayed. A failed step is reported as failed, every time. - Any OpenAI-compatible provider — OpenAI, Groq, OpenRouter, aicredits-style gateways, local vLLM / LM Studio / Ollama. Per-model fallback chain, with automatic retry on transient errors and on malformed model output.
- HITL safety gate — never runs a command without explicit
y; dangerous commands get an extra confirmation. A live PyPI check flags any version pin in the plan that doesn't actually exist before you approve it. - Undo —
fixenv undoreverses what a session executed, through the same gate. - Textual TUI —
fixenv tui: health dashboard, sessions, stats, cache. - Fingerprint + fuzzy cache — same error never costs two API calls.
- Dependency audit —
fixenv audit(CVEs via real version comparison, unpinned deps) with--fixauto-pin and optional Tavily/SerpAPI-backed research. - Env diff & doctor — compare environments; proactive health scan with a score.
- Plugins — add commands and health checks via entry points.
- Scriptable —
--jsonon every reporting command; structured logging; CI-friendly.
Install
pip install -e ".[all]" # everything (TUI + dev tooling)
# or minimal:
pip install -e . # core CLI
pip install -e ".[tui]" # core + Textual TUI
fixenv --help
Configure the LLM provider
FixEnv speaks the OpenAI Chat Completions API, so it works with any compatible endpoint. Run the wizard:
fixenv config init
…or set it directly. For an aicredits / OpenAI-compatible gateway:
fixenv config set llm.provider openai_compatible
fixenv config set llm.base_url https://your-gateway/v1
fixenv config set llm.model your-model-id
export FIXENV_LLM_API_KEY=sk-... # or FIXENV_LLM_BASE_URL, OPENAI_API_KEY
fixenv providers test # ping the endpoint, show latency
fixenv providers models # list available models
For Groq (default): export GROQ_API_KEY=gsk_...
Config lives in ~/.fixenv/config.toml; secrets only ever come from env vars
(the wizard writes them to ~/.fixenv/.env, which is loaded automatically —
never committed, never stored in config.toml). Enable --research for a
grounded fix by setting a research provider and key in the wizard, or
directly:
fixenv config set research.provider tavily # or: serpapi
export TAVILY_API_KEY=tvly-... # or SERPAPI_KEY
A project may override llm / research / output via a .fixenv.toml file.
Switch between setups with profiles:
fixenv config save-profile work
fixenv config use personal
Commands
| Command | What it does |
|---|---|
fixenv diagnose <err> |
Full pipeline; --dry-run, --research, --interactive, --json |
fixenv undo [id] |
Reverse the commands a session executed |
fixenv replay <id> |
Re-run a saved fix (skip diagnosis) |
fixenv doctor |
Proactive health scan with a 0–100 score; --json, --fix |
fixenv explain <code> |
Plain-English explanation + bug/risk flags |
fixenv ask [q] |
Conversational follow-up grounded in your last session |
fixenv audit [path] |
Dependency CVE / pinning audit; --deep, --fix, --json |
fixenv diff <a> <b> |
Compare two environments (conda envs, venvs, freeze files) |
fixenv export <id> |
Render a session as Markdown / HTML / JSON |
fixenv stats |
Analytics dashboard over saved sessions |
fixenv watch <log> |
Tail a log file and auto-diagnose new tracebacks |
fixenv tui |
Full-screen interactive dashboard |
fixenv providers |
list / test / models for the configured endpoint |
fixenv plugins |
List discovered plugins |
fixenv completion |
Shell tab-completion instructions |
fixenv cache · sessions · config |
Manage cache, sessions, configuration |
Examples:
fixenv diagnose --file traceback.txt --interactive
cat error.log | fixenv diagnose -
fixenv diagnose "..." --json | jq .status # CI
fixenv audit requirements.txt --fix # pin unpinned deps (with backup)
fixenv diff base ml-env # two conda envs
fixenv export abc123 --format html -o report.html
fixenv --debug doctor # verbose logging → ~/.fixenv/fixenv.log
Architecture
User error ─▶ Diagnostic agent ─▶ Research agent ─▶ Resolution agent ─▶ HITL gate ─▶ execute ─▶ verify
(read-only env (provider + web (exact shell (y/n/copy) (live (real exit
snapshot + git) research + real commands + risk) output) codes +
dependency pins) post_fix_
verification)
│
providers.py ──┘ any OpenAI-compatible endpoint, fallback chain,
retries on transient errors AND malformed model output
providers.py— LLM abstraction (LLMProvider,build_provider, fallback chain, JSON mode).agents.py/models.py— the three agents and their Pydantic contracts.orchestrator.py— pipeline, HITL gate, executor + verification, caching, undo recording.tools.py/envmanagers.py— read-only environment inspection (conda, venv, poetry, uv, pipenv, pyenv).audit.py— dependency file parsing/scanning; also backsfind_dependency_pin(), which grounds the Research agent in the project's realpyproject.toml/requirements.txtconstraints.cache.py— fingerprint + opt-in fuzzy cache.rollback.py— undo.report.py— exports.tui/— Textual dashboard.plugins.py— entry-point discovery.
Safety model
- The HITL gate (
safety.require_approval, default on) is sacred — no command runs withouty. Dangerous commands (rm -rf,mkfs, …) require a second confirm. - A live PyPI check (
safety.check_pypi_versions, default on) flags anypip install pkg==X.Y.Zin the plan whose exact version doesn't exist on PyPI — before you approve it. tools.pyperforms read-only inspection only — no installs, no mutations.- Every executed command records a
revert_commandsofixenv undocan reverse it. - Success is never assumed: every command's real exit code is checked, and
post_fix_verificationis executed and checked too — a session is only markedcompletedif everything genuinely passed.
Plugins
Register external commands or health checks via entry points:
[project.entry-points."fixenv.plugins"]
myext = "my_pkg.fixenv_ext:register" # register(app: typer.Typer) -> None
[project.entry-points."fixenv.health_checks"]
gpu = "my_pkg.checks:check_gpu" # check(report) -> None
Development
make dev # install with all extras
make check # ruff + mypy + pytest
make tui # launch the TUI
CI runs ruff, mypy, and pytest (150+ tests) across Python 3.10–3.13 on Linux and Windows — ruff and mypy are both hard gates (a lint or type error fails the build).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fixenv_cli-0.2.0.tar.gz.
File metadata
- Download URL: fixenv_cli-0.2.0.tar.gz
- Upload date:
- Size: 101.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc651528785938d3c77a9f12e1e44851f9409992225adc522ad9dc1bd9685a2
|
|
| MD5 |
dc426901b1ac9d4b0e6289f72a6e30f5
|
|
| BLAKE2b-256 |
207092ec2c9795885d2832810928cc0e232791ac0f5dc339aa770386a933a317
|
File details
Details for the file fixenv_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fixenv_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 90.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15d8af11aebdb2b8863bb79b2a8e6904818c66c0711f1fabdca4a763d68ca4e1
|
|
| MD5 |
96b4f3c66043254b86c166eaffc797f0
|
|
| BLAKE2b-256 |
0271e1d6c68ad8cdf0ea9701a2b024a20f979f03c597a0a4b7ede734b3b3e18f
|