Commit Graph

14 Commits

Author SHA1 Message Date
Adam Ladachowski 87ec0bef6a Phase 4: Configuration (config.py)
Add ComfyUI configuration functions:
- `get_comfyui_url()` - URL resolution (env var -> config -> default)
- `get_comfyui_defaults()` - Default generation parameters from config

Config section in config.toml:
    [comfyui]
    url = "http://127.0.0.1:8188"
    default_model = "flux1-dev-fp8.safetensors"
    width = 1024
    height = 1024
    steps = 20
    cfg = 7.0
    sampler = "euler"
    scheduler = "normal"

Updated comfyui.py to use config functions instead of hardcoded values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-16 16:20:25 +01:00
Adam Ladachowski 484c52faf3 Phase 3: Server API Routes (/api/comfyui/*)
Add FastAPI routes for ComfyUI programmatic API:

Query endpoints:
- GET /api/comfyui/status - System stats (GPU, RAM, etc.)
- GET /api/comfyui/queue - Queue status (running/pending)
- DELETE /api/comfyui/queue - Clear the queue
- GET /api/comfyui/models - List available models
- GET /api/comfyui/history - List generation history
- GET /api/comfyui/history/{prompt_id} - Get specific result

Generation endpoints:
- POST /api/comfyui/generate - Text-to-image with full params
- POST /api/comfyui/workflow - Queue arbitrary API-format workflow

All endpoints protected with API key auth (X-API-Key header).
Pydantic models for request/response validation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-16 16:11:19 +01:00
Adam Ladachowski c8c93596c8 Phase 2: CLI Commands (tsr comfy)
Add ComfyUI CLI subcommand group with:
- `tsr comfy status` - System stats (GPU, RAM, PyTorch, queue)
- `tsr comfy queue` - Show queue status (running/pending)
- `tsr comfy queue --clear` - Clear the queue
- `tsr comfy models` - List available checkpoints, LoRAs, VAE, etc.
- `tsr comfy history [ID]` - View generation history
- `tsr comfy generate` - Text-to-image with full parameter control
  - prompt, negative, model, width, height, steps, cfg, seed
  - sampler, scheduler selection
  - optional --output to save locally
- `tsr comfy run workflow.json` - Run arbitrary API-format workflows

All commands support --json output and --url for custom server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-16 16:07:49 +01:00
Adam Ladachowski e776f9846e Phase 1: Core Client (tensors/comfyui.py)
Add ComfyUI API client module with:
- Basic query functions: get_system_stats(), get_queue_status(),
  get_loaded_models(), get_history(), clear_queue(), get_object_info()
- Workflow execution: queue_prompt(), run_workflow() with progress tracking
- Text-to-image: generate_image() with embedded SDXL/Flux workflow template
- Data classes: GenerationResult, WorkflowResult
- Helper: get_image() to download generated images

Follows existing api.py patterns with console: Console | None for optional
Rich progress output, httpx for HTTP requests, and proper error handling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-16 16:03:49 +01:00
Adam Ladachowski e9d1745c62 💬 Commit message: Update 2026-02-16 16:00:31, 1 files, 126 lines
📁 Files changed: 1
📝 Lines changed: 126

  • TODO.md
2026-02-16 16:00:31 +01:00
Adam Ladachowski e257a029da Phase 6: Tests for database, server, and client modules
- Add tests/test_db.py with 33 tests for Database class:
  - Schema initialization and migrations
  - Local file CRUD operations (scan, list, link)
  - CivitAI model caching (cache_model, tags, versions, files)
  - Query operations (search, get_model, get_triggers)
  - Statistics and context manager

- Extend tests/test_server.py with 27 tests for API endpoints:
  - Gallery endpoints (list, get, meta, edit, delete, stats)
  - Database endpoints (files, models, stats)
  - Gallery class unit tests

- Add tests/test_client.py with 33 tests for TsrClient:
  - Server status operations
  - Gallery image operations (list, get, delete, edit, download)
  - Model management (list, active, switch, loras)
  - Image generation
  - CivitAI download operations
  - Database query operations
  - Error handling and context manager

Total: 191 tests passing with 61% coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:54:00 +01:00
Adam Ladachowski 7efec1a033 Phase 4: Client Mode for tsr CLI
- Create tensors/client.py with TsrClient HTTP wrapper for all server APIs
- Add remote server configuration to config.py (get_remotes, resolve_remote, save_remote, set_default_remote)
- Add images command group: list, show, delete, download
- Add models command group: list, active, switch, loras
- Add remote command group: list, add, default
- Update generate command with --remote support
- Update dl command with --remote support
- Update status command with --remote support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:47:32 +01:00
Adam Ladachowski 11a289ebd0 Phase 3: Enhanced Server API
Add comprehensive server API for remote operations:

Step 3.1 - Gallery endpoints:
- GET /api/images - List images (paginated, newest first)
- GET /api/images/{id} - Get image file
- GET /api/images/{id}/meta - Get generation metadata
- POST /api/images/{id}/edit - Update metadata (tags, notes)
- DELETE /api/images/{id} - Delete image + sidecar
- Gallery module with image management and sidecar JSON support

Step 3.2 - Model management:
- GET /api/models - List available checkpoints
- GET /api/models/active - Current loaded model info
- POST /api/models/switch - Switch model (hot reload)
- GET /api/models/loras - List available LoRAs
- GET /api/models/scan - Scan all model directories

Step 3.3 - Download proxy:
- POST /api/download - Start background download from CivitAI
- GET /api/download/status/{id} - Check download progress
- GET /api/download/active - List active downloads
- Auto-scan and link files after download

Step 3.4 - Enhanced generation:
- POST /api/generate - Generate with gallery integration
- Saves images to gallery with metadata sidecar
- Supports all sd-server params
- GET /api/samplers, /api/schedulers - List options

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:40:25 +01:00
Adam Ladachowski 18b3268738 Phase 2.3: Add /api/db/* endpoints
Add database REST API endpoints to FastAPI server:
- GET /api/db/files - List local files with CivitAI info
- GET /api/db/files/{id} - Get file by ID
- GET /api/db/models - Search cached models
- GET /api/db/models/{civitai_id} - Get model by CivitAI ID
- GET /api/db/triggers - Get triggers by file path
- GET /api/db/triggers/{version_id} - Get triggers by version ID
- GET /api/db/stats - Database statistics
- POST /api/db/scan - Scan directory for safetensors
- POST /api/db/link - Link unlinked files to CivitAI
- POST /api/db/cache - Fetch and cache CivitAI model data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:35:26 +01:00
Adam Ladachowski a92c9fb83a Phase 2.2: Add tsr db CLI commands
Add database management commands to CLI:
- tsr db scan <directory> - Scan safetensors, compute hashes, store metadata
- tsr db link - Match unlinked files to CivitAI by hash lookup
- tsr db cache <model_id> - Fetch and cache full CivitAI model data
- tsr db list - List local files with CivitAI info
- tsr db search - Search cached models offline
- tsr db triggers <file> - Show trigger words for a LoRA
- tsr db stats - Show database statistics

Update API functions to accept optional console for quiet/batch operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:33:56 +01:00
Adam Ladachowski c7c5a4a995 Phase 2.1: Add SQLite database module for models metadata
Create database infrastructure for local model file tracking and CivitAI cache:
- schema.sql: Full schema with local_files, CivitAI cache tables, and views
- db.py: Database class with CRUD operations for file scanning, CivitAI linking,
  model caching, search, and trigger word retrieval
- Update compute_sha256 to support optional console for silent batch operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 01:31:32 +01:00
Adam Ladachowski 100d31ba86 💬 Commit message: Update 2026-02-14 01:24:45, 2 files, 439 lines
📁 Files changed: 2
📝 Lines changed: 439

  • PLAN.md
  • TODO.md
2026-02-14 01:24:45 +01:00
Adam Ladachowski 0d278faab2 Update 2026-02-12 16:40:49 +00:00
Adam Ladachowski 243176e89c 💬 Commit message: Update 2026-02-03 21:08:58, 1 files 2026-02-03 21:08:58 +01:00