- VERIFICATION.md: 3/3 must-haves verified, 124/124 tests green - ROADMAP.md: Phase 15 marked complete - STATE.md: advanced to post-phase state Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commands
Run tests:
pytest tests/
pytest tests/unit/test_inf_parser.py # single test file
pytest tests/ -k "test_name" # single test by name
Run dev server:
export DATA_DIR=/tmp/imptune_data
uvicorn imptune.main:app --reload --port 8000
Docker:
docker-compose up
docker build -t imptune .
Install deps:
pip install -r requirements.txt -r requirements-dev.txt
Architecture
ImpTune generates printer deployment packages (.intunewin for Microsoft Intune, .zip for NinjaRMM) from Windows driver ZIPs and a web UI form. No external services — single FastAPI app + SQLite + Docker volume.
Request flow:
- Driver upload →
api/drivers.py→services/inf_parser.pyparses INF →storage/driver_store.pystores by SHA256 → PeeweeDriverrecord - Printer config →
api/printers.py→db/models.pyPrinterrecord (links Driver FK) - Icon upload →
api/icons.py→ Pillow validates PNG 256×256 → SHA256 storage →Iconrecord - Package export →
api/packages.py→generators/script_generator.pyrenders Jinja2 PS1 templates →generators/intunewin_builder.pyencrypts ZIP (AES-256-CBC + HMAC-SHA256)
Key modules:
imptune/config.py—DATA_DIR,DB_PATH,DRIVERS_DIR,ICONS_DIRfrom envimptune/db/database.py— SQLite WAL mode +foreign_keys=1; all models inheritBaseModelimptune/services/inf_parser.py— auto-detects encoding (UTF-16/UTF-8/cp1252), resolves%TOKEN%from[Strings], handles multi-model INFsimptune/generators/intunewin_builder.py— Python-native.intunewin(ZIP-in-ZIP); IV is 16 bytes (not 32); matches reference tool1.8.6.0outputimptune/templates/scripts/— Jinja2 templates forinstall.ps1,uninstall.ps1,detect.ps1
UI stack: Pico CSS + HTMX 2 + Alpine.js 3 + Jinja2 server-side templates.
HTMX pattern: Forms hx-post and swap #driver-list / #printer-list / #client-list targets. Error responses return inline HTML fragments (HTTP 400/409) via _error_response(). Success returns rendered partials from templates/partials/.
PowerShell install script notes:
- WOW64 64-bit relaunch guard (Intune runs 32-bit,
pnputilneeds 64-bit) - UAC self-elevation for user context (SYSTEM context skips)
- Two-step:
pnputil /add-driverthenAdd-PrinterDriver+Add-PrinterPort+Add-Printer - All idempotent (
-ErrorAction SilentlyContinue)
Test Setup
conftest.py monkeypatches config.DATA_DIR and config.DB_PATH to a temp dir per test. client fixture yields TestClient(app) with isolated SQLite. E2E tests in tests/e2e/ use Playwright.
Environment Variables
| Var | Default | Purpose |
|---|---|---|
DATA_DIR |
/data |
Storage root (DB + drivers + icons) |
PORT |
8000 |
Server port |