Files
Sam Kumar 21105b5e05 feat/Resource monitor/CU 86b7mzbtx (#33)
* docs(AGENTS.md): add guidance on using Chrome DevTools MCP tool for UI changes to improve development process and ensure accuracy in modifications

* feat(docs): add Resource Monitor documentation and initial implementation details for the restart button feature
docs(docs): update README.md to include Resource Monitor link and overview

feat(resource_monitor.js): add resource monitor extension with restart button to ComfyUI top bar

This extension enhances the user interface by integrating a resource
monitor similar to Crystools, allowing for future CPU/RAM/GPU/VRAM
monitoring capabilities.

* feat: remove restart button extension and associated styles from Swiss Army Knife

* feat(resource_monitor.js): implement restart functionality for ComfyUI server with user notification and error handling

* fix(resource_monitor.js): change reload timeout from 2 seconds to 5 seconds to allow more time for reconnection
feat(resource_monitor.js): use hard reload to bypass cache when reloading the page for better resource updates

* feat(monitor): add resource monitor service and API endpoints for hardware monitoring
feat(monitor): initialize resource monitor service in __init__.py and register API routes
chore(monitor): create utility modules for hardware and GPU information handling

feat(gpu_info.py): add GPU information collector to monitor VRAM, utilization, and temperature

This new module collects GPU metrics using pynvml and torch, providing detailed information about available GPUs and their performance. It enhances monitoring capabilities for applications utilizing GPU resources.

feat(monitoring): add hardware information collector and monitoring service to gather and broadcast system metrics

- Introduce `hardware_info.py` to collect CPU, RAM, and disk usage metrics.
- Implement `monitor_service.py` to periodically collect and broadcast hardware metrics.
- Update `requirements.txt` to include necessary dependencies: psutil, pynvml, and py-cpuinfo.

feat(tests): add test script for resource monitor backend to verify hardware monitoring functionality

* docs(Resource Monitor Testing): add comprehensive testing guide for resource monitor implementation to ensure proper functionality and user experience

feat(resource_monitor.js): enhance resource monitoring with dynamic display and color coding for CPU, RAM, and GPU metrics

- Add styles for resource monitor display and labels.
- Create functions to format and update monitor values.
- Implement dynamic creation of monitor elements based on available hardware.
- Fetch initial status and listen for updates via WebSocket to keep metrics current.

* refactor(resource_monitor.js): move restart button to be added after monitors for better UI flow

* feat(resource_monitor.js): enhance server restart process with health checks and user feedback
style(resource_monitor.js): improve button styles and layout for better UX
refactor(resource_monitor.js): extract GPU model name for clearer display in UI
fix(resource_monitor.js): update formatting for memory and CPU display values

* feat(resource_monitor): update UI to a floating HUD with live telemetry and inline restart workflow

* docs(RESOURCE_MONITOR): update roadmap section with near-term enhancements and ProfilerX parity plan

* style(resource_monitor.js): enhance restart button styles for improved UI aesthetics and usability

* style(resource_monitor.js): update font size and line height for better readability in the restart button styles

* style(resource_monitor.js): update CSS styles for swissarmyknife-monitor class to enhance layout and readability

* docs(RESOURCE_MONITOR.md): update the ProfilerX Parity Plan section to include detailed implementation hooks and phases for better clarity and guidance
style(resource_monitor.js): improve CSS styles for monitor content and labels to enhance readability and layout consistency

* feat(resource_monitor.js): add background progress bar to monitor display for better visual feedback
refactor(resource_monitor.js): update percentage thresholds for color changes in progress bar for improved clarity

* style(resource_monitor.js): adjust divider styles for better alignment and visibility in resource monitor UI

* style(resource_monitor.js): update styles for the restart button to enhance appearance and usability

* style(resource_monitor.js): update styles for restart button to use flexbox for better alignment
refactor(resource_monitor.js): simplify GPU and VRAM display labels for consistency and clarity

* style(resource_monitor.js): update button styles to center content and adjust padding for better layout

* style(resource_monitor.js): update restart button class for consistent styling

* feat(profiler): implement profiling hooks and API for workflow performance tracking

* feat(profiler): add workflow profiling functionality with UI integration

- Implemented NodeProfile and WorkflowProfile classes for tracking execution time, VRAM/RAM usage, and cache hits.
- Created ProfilerManager as a singleton to manage profiling sessions and history.
- Added methods for starting and ending workflows and nodes, including VRAM and RAM tracking.
- Introduced a new button in the resource monitor UI to access the profiler.
- Developed a popup interface to display profiling statistics and node performance.
- Implemented fetching and displaying of profiler data with retry logic.
- Styled the profiler UI components for better user experience.
- Added functionality to clear profiler history and view full history in a modal.

* feat(prompt_builder): add Prompt Builder node for custom prompt composition
feat(resource_monitor): enhance resource monitor UI with action button group and improved button styles

* feat(profiler): enhance workflow profiling with console logging and data fetching improvements

* feat(profiler): add execution time logging for node profiling and adjust popup positioning

* feat(prompt_builder): add Prompt Builder node documentation and quick reference guide
feat(media_describe): update override fields for backward compatibility and clarity

* feat(media_describe): rename 'override_movement' to 'override_action' for consistency

* feat(prompt_builder): update MediaDescribeOverrides documentation and add Prompt Builder node details

* feat(prompt_builder): import Prompt Builder node and update mappings

* feat(profiler): enhance profiling with VRAM tracking and execution timing for nodes

* feat(prompt_builder): update Prompt Builder node to streamline input parameters and enhance documentation

* feat(lora_info_extractor): add LoRA Info Extractor node for enriched metadata extraction and CivitAI lookup

* feat(lora_info_extractor): integrate LoRA Info Extractor node and update documentation

* refactor(civit_metadata_helper.py): improve code readability and structure by reformatting input types and updating docstrings

feat(civit_metadata_helper.py): enhance metadata collection with structured outputs for better CivitAI submissions

refactor(civit_metadata_helper.py): restructure collect_metadata method for better readability and maintainability
feat(civit_metadata_helper.py): add type hints to method signatures for improved clarity and type safety
chore(civit_metadata_helper.py): clean up code by removing commented-out sections and improving prompt handling

* feat(civit_metadata_helper): add input normalization for metadata collection to handle various data types

* feat(config_api.py): add profiler_enabled setting to configuration for enhanced performance tracking
feat(prestartup.py): integrate profiler_enabled check to conditionally enable profiling functionality
feat(swiss-army-knife.js): add UI option for enabling/disabling workflow profiler and sync with backend settings

* feat(resource_monitor.js): enhance hard reload functionality with multiple methods for better browser compatibility
style(resource_monitor.js): adjust popup positioning and styles for improved layout and user experience
style(resource_monitor.js): update action button group to a vertical layout for better accessibility

* feat(resource_monitor.js): refactor style injection to load external CSS for resource monitor and update monitor display logic

* feat(resource_monitor): enhance documentation with known limitations and troubleshooting tips for profiling features

* feat(profiler): add GPU model tracking and tooltip display for loaded models

* feat(resource_monitor): add execution glow effect to monitor during workflow execution

* feat(resource_monitor): enhance workflow execution glow effect with dual pseudo-elements for improved visual feedback

* feat(resource_monitor): enhance duration formatting for total execution time in profiler stats

* feat(resource_monitor): enhance monitor layout with inner wrapper for improved telemetry display

* feat: Implement GPU memory scanning and enhanced model detection

- Added direct GPU memory scanning in `profiler_core.py` to track loaded models using Python's garbage collector.
- Removed fragile node-name tracking and implemented a caching mechanism for model scans.
- Introduced comprehensive debug logging in `resource_monitor.js` for better troubleshooting.
- Enhanced model grouping by extracting metadata from safetensors files, allowing for user-friendly model names and accurate VRAM reporting.
- Implemented a five-phase approach to identify top-level models, calculate VRAM, and match with metadata.
- Improved performance with caching strategies and optimized scanning logic to limit results to top 10 models per GPU.
- Added tests and validation steps to ensure accurate model detection and reporting.

* feat(resource_monitor): enhance logging with color-coded messages and improve VRAM tooltip functionality

* feat(resource_monitor): implement OOM diagnosis and prevention features with enhanced logging and tooltip updates

* feat(prestartup.py): implement OOM detection and logging for PyTorch errors to enhance error handling and debugging capabilities

feat(profiler_core.py): add out-of-memory (OOM) detection and tracking fields to NodeProfile and WorkflowProfile for better resource management
feat(profiler_core.py): implement OOM statistics update logic in ProfilerManager to track OOM occurrences and their details
fix(profiler_core.py): ensure VRAM usage is monitored before node execution to prevent OOM issues

feat(profiler_core.py): add OOM statistics and analytics to ProfilerManager for better monitoring and recommendations
fix(profiler_core.py): include OOM summary in archived workflows to enhance data insights

* fix(profiler_core.py): update OOM event to calculate execution time from start and end times for better performance tracking

* feat(resource_monitor): add OOM analysis UI with detailed statistics and recommendations

* feat(resource_monitor): implement comprehensive OOM detection and analysis features with frontend UI enhancements

* feat(profiler): enhance profiler popup interaction with hover and timeout logic

* fix(prompt_builder.py): change join delimiter from single newline to double newline for better prompt formatting

* feat(docs): add detailed character analysis system prompt to structured output documentation for clarity and usage guidance
feat(llm_studio_structured.py): update system prompt to reflect character analysis focus and improve output consistency
docs(LLMStudioStructuredDescribe.md): create new documentation file for structured description node with usage tips and input/output details

* feat(docs): add comprehensive guidelines for custom node documentation using Markdown

* refactor: Remove retired Media Describe, LLM Studio Describe Nodes

* refactor: rename docs to dev-docs

* docs: update developer documentation for clarity and structure

* refactor: remove filename generator, update video metadata, show text and control panel overview nodes

* feat: add NSFW field to schemas and prompts for structured output nodes

* ♻️ (llm_studio_structured.py): refactor nsfw field type from boolean to string for better clarity and flexibility in handling NSFW content descriptions.

* ♻️ (llm_studio_structured.py): refactor max_tokens configuration to increase max limit and change step size for better granularity in token generation settings

* ✨ (prompt_builder.py): add support for NSFW text override in PromptBuilder to enhance prompt customization options

* feat(media-selection): enhance media source options to include Redgifs and Gfycat URLs for better media retrieval
fix(media-selection): update error messages to reflect new media source options for clarity
fix(llm_studio_structured.py): increase max_tokens default value to accommodate larger inputs
test(redgifs): add unit tests for downloading media from Redgifs to ensure functionality and error handling

test: add tests for direct download functionality from Redgifs to ensure reliability and correctness of media selection
docs: update MediaSelection documentation to include support for direct Redgifs URLs in media sourcing options

* feat: add script to fix ComfyUI base64 payloads by locating JPEG start and writing preview

* feat(nodes): add ParseStringToBBox node to parse JSON-style bbox strings into float coordinates
feat(nodes): update NODE_CLASS_MAPPINGS and NODE_DISPLAY_NAME_MAPPINGS to include ParseStringToBBox
test: add unit tests for ParseStringToBBox to validate correct parsing and error handling

* feat(parse_string_to_bbox): update bbox parsing to return integer coordinates and dimensions for better usability
test(parse_string_to_bbox): update tests to validate new integer output format and add new test for rounding behavior
test(parse_string_to_bbox_ints): add new tests for parsing bbox strings to integer coordinates and validate error handling

* feat(docs): add detailed documentation for ParseStringToBBox node including inputs, outputs, and usage tips

* ✨ (llm_studio_structured.py): introduce new structured description features for subject appearance and video frames
📝 (llm_studio_structured.py): update documentation for new input types and prompts
♻️ (llm_studio_structured.py): refactor node registration to include new combined structured describe class

* ✨ (llm_studio_structured.py): introduce new SUBJECT_APPEARANCE_SCHEMA and VIDEO_FRAME_ARCHITECT_SCHEMA to enhance media description capabilities with detailed attributes for subject appearance and video frame analysis.

* ✨ (media_describe): add LMStudioCombinedStructuredDescribe to exports for enhanced functionality
✨ (nodes): include LMStudioCombinedStructuredDescribe in mappings for improved node support

* 📝 (llm_studio_structured.py): update prompts for clarity and detail to enhance user guidance and output structure
♻️ (llm_studio_structured.py): refactor combined text generation to improve readability and maintainability by using list comprehension

* ✨ (llm_studio_structured.py): update schema presets and default values to enhance functionality
♻️ (llm_studio_structured.py): refactor frame extraction to return metadata instead of paths for better data handling
💡 (llm_studio_structured.py): improve content building logic to allow custom content for structured output
📝 (llm_studio_structured.py): update comments for clarity and maintainability of the code

* ✨ (llm_studio_structured.py): add 'subject' field to VIDEO_FRAME_ARCHITECT_SCHEMA for better video description
♻️ (llm_studio_structured.py): update required fields in schema to include 'subject' and 'summary' for improved validation
♻️ (llm_studio_structured.py): refactor conditionals to handle new schema preset 'video_frame_architect' for enhanced functionality

* ♻️ (llm_studio_structured.py): remove subject field from VIDEO_FRAME_ARCHITECT_SCHEMA to simplify schema requirements
♻️ (llm_studio_structured.py): update field assignments in LLMStudioStructuredDescribe to reflect schema changes

* ✨ (llm_studio_structured.py): enhance NSFW summary handling by adding support for structured notes and summaries to improve content description clarity

* ✨ (llm_studio_structured.py): add formatted_response to return types and names for improved output structure
♻️ (llm_studio_structured.py): refactor NSFW handling to separate plain and formatted responses for better clarity
💡 (llm_studio_structured.py): enhance response formatting for better readability and organization of output sections

* ✨ (llm_studio_structured.py): add minItems and maxItems constraints to frames array to enforce validation rules on video frame data

* 📝 (llm_studio_structured.py): add 'subject' property to VIDEO_FRAME_ARCHITECT_SCHEMA for better metadata representation
📝 (llm_studio_structured.py): update descriptions for NSFW analysis and frame metadata for clarity
📝 (llm_studio_structured.py): modify required fields in schema to include 'subject' and adjust 'has_nsfw' to 'summary'

* ✨ (llm_studio_structured.py): add 'timestamp_seconds' and 'frames' to required fields to ensure necessary data is provided for video frame descriptions

* ♻️ (llm_studio_structured.py): refactor frame index calculation to improve handling of invalid fps and ensure proper frame extraction
✨ (llm_studio_structured.py): add fallback for fps and enhance frame index tracking for better frame management

* 💡 (llm_studio_structured.py): add debug logging for frame indices and file details to assist in troubleshooting
🐛 (llm_studio_structured.py): improve verbose logging for base64 encoding to catch potential issues with short encodings

* ✨ (azure_queue_publisher.py, .env.example, config_api.py, nodes.py, swiss-army-knife.js): introduce Azure Queue Publisher node to publish job events to Azure Storage Queue for event-driven architecture
📝 (requirements.txt): add azure-storage-queue dependency to support Azure Queue operations
🔧 (config_api.py): update config API to include Azure job events queue in settings
💡 (swiss-army-knife.js): add function to retrieve Azure job events queue from settings for better integration
♻️ (various files): refactor code for improved readability and maintainability, including consistent formatting and logging updates

* ✨ (routes): add event routes for emitting events and health check to enhance API functionality
🐛 (azure_queue_publisher.py): add prompt_id as an optional parameter to improve event data structure
♻️ (azure_queue_publisher.py): change character_index condition to allow zero value for better logic
📝 (init.py): register new event routes in the application to ensure proper routing

* ✨ (events.py): enhance event route registration to prefer PromptServer API
🐛 (events.py): add fallback to aiohttp router and improve error handling
💡 (events.py): add diagnostics logging for registered routes in debug mode

* ✨ (events.py): enhance event route registration with best-effort fallbacks
to improve reliability and diagnostics in case of registration failures

* ✨ (routes/events.py): refactor event route registration to use ComfyUI's
recommended pattern for better maintainability and clarity
📝 (init.py): update event route registration to auto-import events module
for automatic route initialization and improve error handling

* ♻️ (events.py): refactor to remove os dependency and use Swiss Army Knife config system for connection string and queue name retrieval to improve maintainability and flexibility

* ✨ (execution_hooks): add execution hooks for automatic event publishing
to Azure Queue during workflow execution

📝 (init.py): import execution hooks to register them into ComfyUI
execution lifecycle and handle import exceptions gracefully

* ✨ (execution_hooks.py): refactor execution hooks to integrate with PromptServer's message bus for improved event handling
🐛 (execution_hooks.py): update event handling methods to manage prompt lifecycle and error messages more effectively
📝 (execution_hooks.py): enhance module documentation for clarity on functionality and usage

* 💡 (execution_hooks.py): add comments to clarify the behavior of execution events and their handling

* ✨ (events.py): optimize JSON serialization by using custom separators for smaller payloads
💡 (events.py): add logging for published queue payload to improve traceability

* ✨ (media_selection.py): add support for Azure Blob Storage as a media source with validation and downloading functionality

* ✨ (docs, config_api, media_describe): add support for configurable LM Studio base URL to enhance flexibility and usability
📝 (docs): update documentation to reflect changes in base_url input and its usage
♻️ (config_api, media_describe): refactor code to resolve LM Studio base URL from settings or environment variables for better maintainability

* 📝 (STRUCTURED_OUTPUT_IMPLEMENTATION.md): update documentation to clarify
LM Studio endpoint usage and remove base_url parameter from input
definitions for consistency

♻️ (llm_studio_structured.py): refactor code to remove base_url parameter
from describe_image and describe_video methods, relying on global
LM Studio endpoint configuration

✨ (swiss-army-knife.js): add debug logging for model dropdown interactions
to enhance traceability and debugging capabilities in the UI

* ✨ (azure_queue_publisher.py, execution_hooks.py, events.py): add audit logging for event publishing to track success and failure
💡 (execution_hooks.py): refactor logging logic into a separate method for clarity and reuse
📝 (azure_queue_publisher.py, execution_hooks.py, events.py): improve code comments for better understanding of audit logging functionality

* ♻️ (init.py, azure_queue_publisher.py, execution_hooks.py, events.py): refactor import paths to ensure package root is discoverable for modules
💡 (init.py, azure_queue_publisher.py, execution_hooks.py, events.py): add comments to clarify the purpose of modifying sys.path for module loading

* ♻️ (init.py, azure_queue_publisher.py, execution_hooks.py, events.py): refactor import statements to use relative imports for better module organization and maintainability

* ✨ (audit_logger_loader.py): introduce a helper module to load audit_logger
🐛 (azure_queue_publisher.py, execution_hooks.py, events.py): update import paths to use the new audit_logger_loader for better module management

* ✨ (init.py): introduce dynamic loading of the lib package to handle
hyphenated module names and improve import reliability
♻️ (audit_logger_loader.py): remove redundant audit logger loader module
as its functionality is now integrated into __init__.py
🔧 (azure_queue_publisher.py, execution_hooks.py, events.py): update
imports to reference the new lib package structure for audit logger

* ✨ (audit_logger): introduce AuditLogger class for structured logging of job audit events
♻️ (imports): refactor import statements to use relative imports for consistency
📝 (gitignore): update .gitignore to exclude specific directories and files
🔧 (pyproject.toml): update package configuration to include "routes" package
📝 (init.py): remove unused code and clean up __init__.py for better readability

* ✨ (app_insights.py): add Application Insights logging and tracing support to monitor application performance and errors
♻️ (events.py): integrate Application Insights logger into event emission process for better observability of events and errors

* ♻️ (azure_queue_publisher.py, execution_hooks.py, audit_logger.py, events.py): refactor timestamp formatting to use 'Z' instead of '+00:00' for better compatibility with ISO 8601
♻️ (azure_queue_publisher.py, execution_hooks.py, audit_logger.py): refactor JSON serialization to use custom separators for more compact output

* ♻️ (execution_hooks.py, events.py): refactor queue name retrieval to use a fallback with or operator for better clarity and consistency

* ✨ (azure_queue_publisher.py, execution_hooks.py, audit_logger.py, events.py): add TextBase64EncodePolicy to QueueClient initialization for better message encoding
💡 (azure_queue_publisher.py, execution_hooks.py, audit_logger.py, events.py): update timestamp formatting to include seconds for improved precision

* ✨ (civit_metadata_helper.py): add optional JSON fields for subject and video prompts to enhance metadata collection

* ✨ (civit_metadata_helper.py): add JSON parsing for subject and video prompts to handle structured data inputs
📝 (civit_metadata_helper.py): update return structure to include parsed subject and video prompts for better data handling

* ✨ (init.py, config_api.py, upload_job_to_azure.py): introduce Upload Job to Azure node to upload files to Azure Blob Storage and create job documents in CosmosDB
♻️ (init.py): rename Azure Storage Upload node to Upload Job to Azure for clarity
📝 (upload-job-to-azure.md): add documentation for Upload Job to Azure node detailing its purpose, inputs, outputs, and configuration
🔧 (config_api.py): add configuration settings for Azure Cosmos DB connection and job container
🐛 (azure_storage_upload.py): remove obsolete Azure Storage Upload node code as it is replaced by the new Upload Job to Azure node

* ✨ (execution_hooks.py, llm_studio_structured.py, cosmos_utils.py): add functionality to push structured analysis results to CosmosDB for job tracking
📝 (execution_hooks.py): add get_current_prompt_id function to retrieve the current job ID
♻️ (llm_studio_structured.py): refactor code to utilize current job ID for metadata updates in CosmosDB
📝 (cosmos_utils.py): add utility functions for interacting with Azure CosmosDB and Blob Storage

* ♻️ (cosmos_utils.py): refactor container name from "media" to "media-files" for better clarity and organization

* ✨ (llm_studio_structured.py): update keys in cosmos_meta to use snake_case for consistency
📝 (cosmos_utils.py): replace logger.debug with print statements for better visibility of errors and status messages

* ✨ (Dockerfile, requirements.txt, swiss-army-knife.js): add Azure Cosmos DB support to enhance data storage capabilities and improve integration with Azure services.

* 💡 (cosmos_utils.py): add comments to clarify the use of 'id' as partition key
✅ (cosmos_utils.py): update replace_item method to include partition_key for consistency

* 💡 (cosmos_utils.py): update comments to clarify the use of jobId field as partition key
🐛 (cosmos_utils.py): fix partition key usage in replace_item to use jobId field value for consistency

* ✨ (cosmos_utils.py): add support for PartitionKey to handle undefined partition keys in CosmosDB
🐛 (cosmos_utils.py): improve error handling and logging for document queries and updates
💡 (cosmos_utils.py): clarify comments regarding partition key discrepancies and operations
2026-01-13 07:23:51 -06:00

37 KiB
Raw Permalink Blame History

ComfyUI-SwissArmyKnife - ComfyUI Extension Development Guide

ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.

Official ComfyUI Documentation

For technical implementation details, reference these official ComfyUI custom node development guides:

Note: These are the official JavaScript widget docs, not React-based extensions.

Project Overview

ComfyUI-SwissArmyKnife is a ComfyUI extension that consists of two essential components that work together:

Backend (Python Custom Nodes)

  • Python custom nodes in nodes/*.py for Gemini AI video analysis and processing
  • Core business logic and AI integration
  • Requires ComfyUI server restart when modified

CRITICAL: Auto-Restart Development Server After Python Changes

After modifying ANY Python files in this repository (.py files in nodes/, __init__.py, etc.), you MUST automatically restart the development ComfyUI server:

# Run this command after ANY Python file modification
cd /mnt/nfs_share/gen-ai-image/comfyui-containers && docker compose restart dev-comfyui

When to restart:

  • After editing Python node files in nodes/
  • After modifying __init__.py or any Python configuration
  • After installing new Python packages with pip
  • After any Python code change that needs to take effect

Example workflow:

  1. Edit Python file (e.g., nodes/media_describe/llm_studio_structured.py)
  2. Verify syntax with ruff check .
  3. Immediately restart server: cd /mnt/nfs_share/gen-ai-image/comfyui-containers && docker compose restart dev-comfyui
  4. Wait for server to restart (~5-10 seconds)
  5. Test changes in ComfyUI web interface

Web Extension (JavaScript Widgets)

  • Plain JavaScript widgets in ./web/js/ for enhanced ComfyUI interaction
  • UI components and client-side functionality
  • Requires browser cache refresh when modified
  • Chrome DevTools MCP Tool (Required for UI changes): Whenever you work on anything that touches the ComfyUI browser experience or files under web/, spin up the Chrome DevTools MCP tool and inspect DOM/layout changes through it instead of guessing from memory. Use it to capture screenshots, review network logs, and confirm widget wiring before writing or modifying code. Treat any UI-oriented task (CSS tweaks, widget bugs, layout fixes) as blocked until you have gathered evidence via the dev tools call.

Additional Components

  • React/TypeScript UI extension with internationalization DISABLED FOR NOW
  • GitHub Actions for automated building and publishing
  • Playwright tests in ./web/tests/ for testing against hosted ComfyUI server
  • Documentation in dev-docs/ directory - organized into categorized folders (see Documentation Organization section)

IMPORTANT: Both backend and web extension components are required for the custom node to function properly. Changes to backend Python files require restarting the ComfyUI server, while changes to web JavaScript files require refreshing the browser cache.

DOCUMENTATION REQUIREMENT: The project maintains TWO distinct documentation systems with different audiences:

  1. Developer Documentation (dev-docs/) - Technical implementation details for contributors
  2. User Help Pages (web/docs/) - End-user reference displayed in ComfyUI UI

Never document directly in code comments when a separate documentation file would be more appropriate. Always attempt to update documentation for existing markdown files before creating new ones.

Note: The React UI component (ui-react_backup/) is currently disabled and not in active development.

Documentation Organization

The project maintains TWO distinct documentation layers with different audiences:

1. Developer Documentation (dev-docs/)

Audience: Internal developers and contributors
Purpose: Technical implementation details, architecture decisions, troubleshooting guides

dev-docs/
├── README.md                    # Developer documentation index
│
├── nodes/                       # Node-specific documentation (ONE file per node)
│   ├── lm-studio-describe/     # LM Studio structured describe nodes
│   ├── reddit-media/           # Reddit Media Extraction
│   ├── media-selection/        # Media Selection node
│   └── control-panel/          # Control Panel Display
│
├── infrastructure/              # Infrastructure & system components
│   ├── caching/                # Caching system
│   ├── debug/                  # Debug & logging
│   ├── docker/                 # Docker setup
│   └── build-deploy/           # Build & deployment
│
├── integrations/                # External service integrations
│   ├── civitai/                # CivitAI API integration
│   └── reddit/                 # Reddit API integration
│
├── web-js/                      # Web JavaScript widget documentation
├── examples/                    # Example workflows
└── comfyui/                     # ComfyUI-specific documentation
    └── custom-nodes_documentation_guidelines.md

2. User-Facing Help Pages (web/docs/)

Audience: End users who install and use your nodes in ComfyUI workflows
Purpose: In-UI reference documentation displayed in ComfyUI's help panel

For complete ComfyUI help page guidelines, see: dev-docs/comfyui/custom-nodes_documentation_guidelines.md

web/
└── docs/
    ├── NodeName.md        # Default help page (required for each registered node)
    └── NodeName/          # Optional: Multi-language support
        ├── en.md
        └── zh.md

Documentation Rules

Two-tier documentation system:

Layer 1: Developer Documentation (dev-docs/) - Technical implementation details

  1. Node-specific docs → dev-docs/nodes/[node-name]/ - ONE comprehensive file per node
  2. Infrastructure docs → dev-docs/infrastructure/[category]/
  3. Integration docs → dev-docs/integrations/[service]/
  4. Web JavaScript widget docs → dev-docs/web-js/
  5. Examples → dev-docs/examples/

Layer 2: User Help Pages (web/docs/) - MANDATORY for all registered nodes 6. ComfyUI help pages → every registered node must have a matching help markdown file inside web/docs/. The filename must match the node key from NODE_CLASS_MAPPINGS (e.g., web/docs/VACEScribbleAnnotator.md). Use the help page template described at https://docs.comfy.org/custom-nodes/help_page and keep its content in sync with the canonical node doc under dev-docs/nodes/....

ComfyUI Help Page Structure

web/
└── docs/
    ├── NodeName.md        # Default help page loaded in ComfyUI
    ├── NodeName/en.md     # (Optional) locale-specific overrides
    └── NodeName/zh.md
  • At minimum provide headings for Summary, Inputs, Outputs, Usage Tips, and link back to the full documentation under dev-docs/.
  • If you update a node’s behavior, update both the canonical doc (dev-docs/nodes/...) and the corresponding web/docs/NodeName.md help file in the same PR.

Finding Documentation

For Developers:

  • Start here: dev-docs/README.md - Technical documentation index
  • Category indexes: Each folder has a README.md listing all files
  • By node: dev-docs/nodes/[node-name]/README.md for quick reference
  • Complete node docs: dev-docs/nodes/[node-name]/[NODE_NAME].md for comprehensive documentation
  • By topic: Browse appropriate category folder

For End Users:

  • In ComfyUI: Right-click node → View Help (displays web/docs/NodeName.md)
  • Fallback: Browse web/docs/NodeName.md files for concise user documentation

Working Effectively

Virtual Environment Activation

CRITICAL: Always activate the virtual environment before running any Python commands:

# Activate virtual environment (REQUIRED for all Python operations)
source /Users/samkumar/Development/dev-lab-hq/ai-image-hub/apps/comfyui-swiss-army-knife/.venv/bin/activate

# Or use relative path if in project root:
source .venv/bin/activate

# Verify activation (you should see (.venv) in your prompt)
which python3  # Should show path inside .venv directory

IMPORTANT: Run the activation command before:

  • Installing Python packages (pip3 install)
  • Running Python scripts or commands
  • Running tests (pytest)
  • Linting Python code (ruff check)
  • Any other Python-related terminal operations

Essential System Dependencies

Install these system dependencies first:

# FFmpeg is REQUIRED for video processing functionality
sudo apt-get update && sudo apt-get install -y ffmpeg

# Verify installation
ffmpeg -version  # Should show version 6.1.1 or newer

Bootstrap React UI Development (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# Navigate to React UI directory
# cd ui-react_backup/ui

# Install Node.js dependencies - takes ~40 seconds
# npm install  # NEVER CANCEL: Takes 40 seconds. Set timeout to 60+ seconds.

# Build React extension - takes ~5 seconds
# npm run build  # NEVER CANCEL: Takes 5 seconds. Set timeout to 30+ seconds.

Bootstrap Python Development

# ALWAYS activate virtual environment first
source .venv/bin/activate

# Install Python package and dependencies
pip3 install -e .  # Takes ~12 seconds for basic dependencies

# Install essential Python dependencies for full functionality
# NEVER CANCEL: Takes 2-3 minutes for torch/opencv. Set timeout to 300+ seconds.
pip3 install torch opencv-python

# Install development tools
pip3 install pytest mypy coverage ruff pre-commit

# Verify Python modules work
python3 -c "from nodes.nodes import NODE_CLASS_MAPPINGS; print('Available nodes:', list(NODE_CLASS_MAPPINGS.keys()))"
# Should output: Available nodes: ['GeminiUtilVideoDescribe']

Development Workflows

Documentation Workflow

When modifying a node, you MUST update BOTH documentation layers:

  1. Technical documentation (dev-docs/) - Implementation details, architecture
  2. User help page (web/docs/) - User-facing parameters, usage
# Example workflow for modifying a node
vim nodes/media_selection/media_selection.py    # Edit node implementation

# Update technical documentation
vim dev-docs/nodes/media-selection/MEDIA_SELECTION.md

# Update user help page
vim web/docs/MediaSelection.md

# Commit both together
git add nodes/media_selection/ dev-docs/nodes/media-selection/ web/docs/MediaSelection.md
git commit -m "feat: Add duration_threshold parameter to MediaSelection

- Added duration_threshold parameter
- Updated technical docs with implementation details
- Updated help page with user-facing parameter description"

Developer documentation structure:

dev-docs/
├── README.md                    # Developer documentation index
├── nodes/                       # Node-specific documentation (ONE file per node)
│   ├── lm-studio-describe/     # LM Studio structured describe docs
│   ├── reddit-media/           # Reddit Media Extraction docs
│   ├── media-selection/        # Media Selection node docs
│   └── control-panel/          # Control Panel Display docs
├── infrastructure/              # Infrastructure components
│   ├── caching/                # Caching system docs
│   ├── debug/                  # Debug & logging docs
│   ├── docker/                 # Docker setup docs
│   └── build-deploy/           # Build & deployment docs
├── integrations/                # External service integrations
│   ├── civitai/                # CivitAI API integration docs
│   └── reddit/                 # Reddit API integration docs
├── web-js/                      # Web JavaScript widget documentation
└── examples/                    # Example workflows

Adding New Documentation:

# For new nodes - create BOTH documentation layers
# 1. Technical documentation (developer-focused)
mkdir -p dev-docs/nodes/[node-name]
touch dev-docs/nodes/[node-name]/README.md
touch dev-docs/nodes/[node-name]/[NODE_NAME].md

# 2. User help page (MANDATORY - must match NODE_CLASS_MAPPINGS key)
touch web/docs/NodeName.md

# Update existing node documentation
vim dev-docs/nodes/[node-name]/[NODE_NAME].md
vim web/docs/NodeName.md

# For infrastructure documentation
touch dev-docs/infrastructure/[category]/NEW_SYSTEM.md

# For web JavaScript widgets
touch dev-docs/web-js/NEW_WIDGET.md

# For integrations
touch dev-docs/integrations/[service]/NEW_INTEGRATION.md

Documentation file naming convention:

Developer docs (dev-docs/):

  • Nodes: Use descriptive all-caps names: MEDIA_SELECTION.md, MEDIA_DESCRIBE.md
  • ONE file per node: Consolidate all information about a node into a single comprehensive file
  • Node docs go in dev-docs/nodes/[node-name]/
  • Infrastructure docs go in dev-docs/infrastructure/[category]/
  • Web JavaScript widget docs go in dev-docs/web-js/

User help pages (web/docs/):

  • MUST match NODE_CLASS_MAPPINGS key exactly (case-sensitive)
  • Example: NODE_CLASS_MAPPINGS = {"MediaSelection": ...} → web/docs/MediaSelection.md

CRITICAL: Whenever you implement a new feature, fix a bug, or solve a technical problem:

  1. Identify the correct documentation layer(s):

    • Node changes → Update BOTH layers:
      • dev-docs/nodes/[node-name]/[NODE_NAME].md (technical)
      • web/docs/NodeName.md (user help - see dev-docs/comfyui/custom-nodes_documentation_guidelines.md for guidelines)
    • System changes → dev-docs/infrastructure/[category]/
    • Widget changes → dev-docs/web-js/
    • Integration work → dev-docs/integrations/[service]/
  2. For nodes:

    • Update the existing comprehensive file in dev-docs/ or create one if it doesn't exist
    • Update or create the matching help page in web/docs/ (refer to dev-docs/comfyui/custom-nodes_documentation_guidelines.md)
    • Ensure filename in web/docs/ matches NODE_CLASS_MAPPINGS key exactly
  3. For other components: Create or update documentation with descriptive names

  4. Include implementation details, gotchas, and future considerations in dev-docs/

  5. Update the folder's README.md index if needed

  6. Reference both documentation files in commit messages

  7. Cross-reference:

    • Link from help page to technical docs: See ../../dev-docs/nodes/...
    • Link related documentation in other folders

React UI Development (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# cd ui-react_backup/ui

# Development with auto-reload (watches for changes)
# npm run watch

# Build for production
# npm run build  # NEVER CANCEL: Takes 5 seconds. Set timeout to 30+ seconds.

# TypeScript type checking
# npm run typecheck

Backend (Python) Development

# ALWAYS activate virtual environment first
source .venv/bin/activate

# Import and test Python nodes
python3 -c "from nodes.nodes import NODE_CLASS_MAPPINGS; print(list(NODE_CLASS_MAPPINGS.keys()))"

# Run Python linting (fast, < 1 second)
ruff check .

# Fix auto-fixable linting issues
ruff check --fix .

# CRITICAL: After ANY Python file modification, restart the dev server
cd /mnt/nfs_share/gen-ai-image/comfyui-containers && docker compose restart dev-comfyui

Web Extension (JavaScript) Development

Chrome DevTools MCP requirement: UI bugs or enhancements must start with a Chrome DevTools MCP call. Launch the tool, capture screenshots/DOM details, and confirm widget behavior before editing anything under web/. Repeat after code changes to validate the actual ComfyUI UI instead of guessing.

# JavaScript widgets are located in ./web/js/
# No build step required - plain JavaScript files

# Verify web extension files exist
ls -la web/js/gemini_widgets.js
ls -la web/css/gemini_widgets.css

# After making changes to JavaScript widgets:
# 1. No compilation needed (plain JS)
# 2. Browser cache refresh required for changes to take effect

Testing

Backend (Python) Testing

# ALWAYS activate virtual environment first
source .venv/bin/activate

# Run pytest (currently no tests exist)
pytest  # NEVER CANCEL: Takes < 30 seconds. Set timeout to 60+ seconds.
# Expected: "no tests ran" - this is normal, no tests exist yet

# When adding tests, create them in a tests/ directory

Web Extension Testing

# Playwright tests for testing against hosted ComfyUI server
cd web/tests/

# Install Playwright dependencies (if not already installed)
npm install

# Run Playwright tests against hosted ComfyUI server
npm test

# Note: Tests require a running ComfyUI server with the custom node installed

React UI Testing (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# cd ui-react_backup/ui

# This command WILL FAIL with ES module errors
# npm test
# Error: "Jest encountered an unexpected token" - this is a known issue

# To add working tests, fix jest.config.js ES module configuration first

Linting and Code Quality

Python Linting (Works)

# ALWAYS activate virtual environment first
source .venv/bin/activate

# Fast linting check (< 1 second)
ruff check .

# Fix automatically fixable issues
ruff check --fix .

# Note: Some unused import warnings are expected and can be ignored
# The code functions correctly despite these warnings

React UI Linting (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# cd ui-react_backup/ui

# This will show configuration errors but runs
# npm run lint  # Shows ESLint TypeScript project configuration issues

# Auto-fix formatting issues
# npm run lint:fix

# Format code
# npm run format

Build and Publish Workflow

Local Build Process (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# Complete build from scratch
# cd ui-react_backup/ui
# npm install  # 40 seconds
# npm run build  # 5 seconds

# Verify built files exist
# ls -la ../dist/example_ext/  # Should show main.js, main.css, etc.

GitHub Actions Publishing

The repository includes automated publishing via .github/workflows/react-build.yml:

  • Triggers on pyproject.toml changes pushed to main branch
  • Requires REGISTRY_ACCESS_TOKEN secret in repository settings
  • Automatically builds React UI and publishes to ComfyUI Registry

pyproject.toml Specifications

Reference: https://docs.comfy.org/registry/specifications

The pyproject.toml file contains two main sections for ComfyUI custom nodes: [project] and [tool.comfy].

[project] Section

name (required)

The node id uniquely identifies the custom node and will be used in URLs from the registry. Users can install the node by referencing this name:

comfy node install <node-id>

Requirements:

  • Must be less than 100 characters
  • Can only contain alphanumeric characters, hyphens, underscores, and periods
  • Cannot have consecutive special characters
  • Cannot start with a number or special character
  • Case-insensitive comparison

Best Practices:

  • Use a short, descriptive name
  • Don't include "ComfyUI" in the name
  • Make it memorable and easy to type

Examples:

name = "image-processor"      # ✅ Good: Simple and clear
name = "super-resolution"     # ✅ Good: Describes functionality
name = "ComfyUI-enhancer"    # ❌ Bad: Includes ComfyUI
name = "123-tool"            # ❌ Bad: Starts with number

version (required)

Uses semantic versioning with a three-digit version number X.Y.Z:

  • X (MAJOR): Breaking changes
  • Y (MINOR): New features (backwards compatible)
  • Z (PATCH): Bug fixes

Examples:

version = "1.0.0"    # Initial release
version = "1.1.0"    # Added new features
version = "1.1.1"    # Bug fix
version = "2.0.0"    # Breaking changes

license (optional)

Specifies the license for your custom node. Can be specified in two ways:

  1. File Reference:
license = { file = "LICENSE" }     # ✅ Points to LICENSE file
license = { file = "LICENSE.txt" } # ✅ Points to LICENSE.txt
license = "LICENSE"                # ❌ Incorrect format
  1. License Name:
license = { text = "MIT License" }  # ✅ Correct format
license = { text = "Apache-2.0" }   # ✅ Correct format
license = "MIT LICENSE"             # ❌ Incorrect format

Common licenses: MIT, GPL, Apache

A brief description of what your custom node does.

description = "A super resolution node for enhancing image quality"

repository (required)

Links to the repository:

[project.urls]
Repository = "https://github.com/username/repository"

Links to related resources:

[project.urls]
Documentation = "https://github.com/username/repository/wiki"
"Bug Tracker" = "https://github.com/username/repository/issues"

Specifies the Python versions that your node supports:

requires-python = ">=3.8"        # Python 3.8 or higher
requires-python = ">=3.8,<3.11"  # Python 3.8 up to (but not including) 3.11

Frontend Version Compatibility (optional)

If your node has specific requirements for which ComfyUI frontend versions it supports, you can specify this using the comfyui-frontend-package dependency. This package is published on PyPI.

Use this field when:

  • Your custom node uses frontend APIs that were introduced in a specific version
  • You've identified incompatibilities between your node and certain frontend versions
  • Your node requires specific UI features only available in newer frontend versions
[project]
dependencies = [
    "comfyui-frontend-package>=1.20.0"       # Requires frontend 1.20.0 or newer
    "comfyui-frontend-package<=1.21.6"       # Restricts to frontend versions up to 1.21.6
    "comfyui-frontend-package>=1.19,<1.22"   # Works with frontend 1.19 to 1.21.x
    "comfyui-frontend-package~=1.20.0"       # Compatible with 1.20.x but not 1.21.0
    "comfyui-frontend-package!=1.21.3"       # Works with any version except 1.21.3
]

Use classifiers to specify operating system compatibility and GPU accelerators. This information is used to help users find the right node for their system.

[project]
classifiers = [
    # For OS-independent nodes (works on all operating systems)
    "Operating System :: OS Independent",

    # OR for OS-specific nodes, specify the supported systems:
    "Operating System :: Microsoft :: Windows",  # Windows specific
    "Operating System :: POSIX :: Linux",        # Linux specific
    "Operating System :: MacOS",                 # macOS specific

    # GPU Accelerator support
    "Environment :: GPU :: NVIDIA CUDA",    # NVIDIA CUDA support
    "Environment :: GPU :: AMD ROCm",       # AMD ROCm support
    "Environment :: GPU :: Intel Arc",      # Intel Arc support
    "Environment :: NPU :: Huawei Ascend",  # Huawei Ascend support
    "Environment :: GPU :: Apple Metal",    # Apple Metal support
]

[tool.comfy] Section

PublisherId (required)

Your unique publisher identifier, typically matching your GitHub username.

Examples:

PublisherId = "john-doe"        # ✅ Matches GitHub username
PublisherId = "image-wizard"    # ✅ Unique identifier

DisplayName (optional)

A user-friendly name for your custom node.

DisplayName = "Super Resolution Node"

Icon (optional)

URL to your custom node's icon that will be displayed on the ComfyUI Registry and ComfyUI-Manager.

Requirements:

  • File types: SVG, PNG, JPG, or GIF
  • Maximum resolution: 400px × 400px
  • Aspect ratio should be square
Icon = "https://raw.githubusercontent.com/username/repo/main/icon.png"

Banner (optional)

URL to a larger banner image that will be displayed on the ComfyUI Registry and ComfyUI-Manager.

Requirements:

  • File types: SVG, PNG, JPG, or GIF
  • Aspect ratio: 21:9
Banner = "https://raw.githubusercontent.com/username/repo/main/banner.png"

requires-comfyui (optional)

Specifies which version of ComfyUI your node is compatible with. This helps users ensure they have the correct version of ComfyUI installed.

Supported operators: <, >, <=, >=, ~=, <>, != and ranges

Examples:

requires-comfyui = ">=1.0.0"        # ComfyUI 1.0.0 or higher
requires-comfyui = ">=1.0.0,<2.0.0"  # ComfyUI 1.0.0 up to (but not including) 2.0.0
requires-comfyui = "~=1.0.0"         # Compatible release: version 1.0.0 or newer, but not version 2.0.0
requires-comfyui = "!=1.2.3"         # Any version except 1.2.3
requires-comfyui = ">0.1.3,<1.0.0"   # Greater than 0.1.3 and less than 1.0.0

includes (optional)

Specifies whether to force include certain specific folders. For some situations, such as custom nodes in frontend projects, the final packaged output folder might be included in .gitignore. In such cases, we need to force include it for registry use.

includes = ['dist']

Complete Example

[project]
name = "super-resolution-node"
version = "1.0.0"
description = "Enhance image quality using advanced super resolution techniques"
license = { file = "LICENSE" }
requires-python = ">=3.8"
dependencies = [
    "comfyui-frontend-package<=1.21.6"  # Frontend version compatibility
]
classifiers = [
    "Operating System :: OS Independent"  # Works on all operating systems
]
dynamic = ["dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[project.urls]
Repository = "https://github.com/username/super-resolution-node"
Documentation = "https://github.com/username/super-resolution-node/wiki"
"Bug Tracker" = "https://github.com/username/super-resolution-node/issues"

[tool.comfy]
PublisherId = "image-wizard"
DisplayName = "Super Resolution Node"
Icon = "https://raw.githubusercontent.com/username/super-resolution-node/main/icon.png"
Banner = "https://raw.githubusercontent.com/username/super-resolution-node/main/banner.png"
requires-comfyui = ">=1.0.0"  # ComfyUI version compatibility

Validation Scenarios

Always validate changes by running these verification steps:

Documentation Validation

# 1. Verify all changes are documented (both layers)
ls -la dev-docs/  # Check for relevant technical documentation
ls -la web/docs/  # Check for user help pages

# 2. Ensure documentation is up-to-date
grep -r "TODO\|FIXME\|OUTDATED" dev-docs/  # Should return no results

# 3. Validate markdown formatting
# (Optional: install markdownlint if available)
# markdownlint dev-docs/*.md web/docs/*.md

# 4. CRITICAL: Verify all registered nodes have help pages
python3 -c "
from nodes.nodes import NODE_CLASS_MAPPINGS
import os

print('\n=== Checking Help Pages for All Registered Nodes ===\n')

missing = []
found = []

for node_name in sorted(NODE_CLASS_MAPPINGS.keys()):
    help_file = f'web/docs/{node_name}.md'
    if not os.path.exists(help_file):
        missing.append(f'❌ Missing: {help_file}')
    else:
        found.append(f'✅ Found: {help_file}')

for item in found:
    print(item)

if missing:
    print('\n=== MISSING HELP PAGES ===\n')
    for item in missing:
        print(item)
    print(f'\n⚠️  {len(missing)} help page(s) missing out of {len(NODE_CLASS_MAPPINGS)} registered nodes')
    exit(1)
else:
    print(f'\n✅ All {len(NODE_CLASS_MAPPINGS)} registered nodes have help pages!')
"

# Example output:
# ✅ Found: web/docs/MediaSelection.md
# ❌ Missing: web/docs/GeminiUtilVideoDescribe.md

Python Node Validation

# ALWAYS activate virtual environment first
source .venv/bin/activate

# 1. Import test
python3 -c "from nodes.nodes import NODE_CLASS_MAPPINGS; print('✓ Python imports work')"

# 2. Linting
ruff check .  # Accept unused import warnings as normal

# 3. Verify system dependencies
ffmpeg -version | head -1  # Should show FFmpeg version

# 4. CRITICAL: Restart dev server after Python modifications
cd /mnt/nfs_share/gen-ai-image/comfyui-containers && docker compose restart dev-comfyui

React UI Validation (DISABLED)

⚠️ The React UI component is currently disabled and not in active development.

# THESE COMMANDS ARE CURRENTLY DISABLED
# cd ui-react_backup/ui

# 1. Build test
# npm run build  # Should complete in ~5 seconds

# 2. Verify outputs
# ls -la ../dist/example_ext/main.js  # Should exist
# ls -la ../dist/locales/  # Should contain en/ and zh/ directories

# 3. TypeScript check
# npm run typecheck  # Should pass without errors

Full Integration Test (PARTIALLY DISABLED)

⚠️ React UI components are disabled, but JavaScript widgets remain active.

# 1. Clean build (DISABLED - React components only)
# cd ui-react_backup/ui
# rm -rf ../dist/
# npm run build

# 2. Verify ComfyUI integration files
# ls -la ../dist/example_ext/  # React build outputs (DISABLED)
ls -la ../../web/js/  # JavaScript widgets (ACTIVE)
ls -la ../../__init__.py  # Python entry point (ACTIVE)

Known Issues and Limitations

Jest Testing Configuration

  • Jest tests fail due to ES module configuration issues
  • Example test exists in src/__tests__/dummy.test.tsx but won't run
  • Fix requires updating jest.config.js and jest.setup.js for ESM support

ESLint Configuration

  • ESLint shows TypeScript project configuration warnings
  • Code builds and runs correctly despite these warnings
  • Focus on functional validation rather than linting perfection

Python Import Warnings

  • Ruff reports unused imports in __init__.py files
  • These imports are intentional for ComfyUI integration
  • The warnings can be safely ignored

System Dependencies

  • FFmpeg is required for video processing features
  • Without FFmpeg, video-related functionality will fail at runtime
  • Always verify FFmpeg is installed in your environment

Common Tasks

Documentation Tasks

# Update node documentation - BOTH layers required
vim dev-docs/nodes/[node-name]/[NODE_NAME].md   # Technical docs
vim web/docs/NodeName.md                         # User help page

# Create new node documentation - BOTH layers
mkdir -p dev-docs/nodes/[node-name]
touch dev-docs/nodes/[node-name]/README.md
touch dev-docs/nodes/[node-name]/[NODE_NAME].md
touch web/docs/NodeName.md                       # MUST match NODE_CLASS_MAPPINGS key

# Document infrastructure changes
touch dev-docs/infrastructure/[category]/SYSTEM_NAME.md

# Document web JavaScript widget
touch dev-docs/web-js/WIDGET_NAME.md

# Search for documentation gaps
grep -r "TODO\|FIXME\|INCOMPLETE" dev-docs/

# Browse documentation by category
ls -la dev-docs/nodes/           # Node-specific docs (ONE file per node)
ls -la dev-docs/infrastructure/  # System/infrastructure docs
ls -la dev-docs/integrations/    # External service integrations
ls -la dev-docs/web-js/          # Web JavaScript widget documentation
ls -la dev-docs/examples/        # Example workflows
ls -la web/docs/                 # User help pages (MANDATORY for all nodes)

# View node documentation
cat dev-docs/nodes/media-selection/MEDIA_SELECTION.md   # Complete technical docs
cat web/docs/MediaSelection.md                         # User help page

# Common documentation patterns:
# Developer docs (dev-docs/):
# - dev-docs/nodes/[node-name]/[NODE_NAME].md - Single comprehensive node documentation
# - dev-docs/nodes/[node-name]/README.md - Quick reference for the node
# - dev-docs/infrastructure/[category]/SYSTEM_NAME.md - Infrastructure documentation
# - dev-docs/integrations/[service]/INTEGRATION_GUIDE.md - Integration guides
# - dev-docs/web-js/WIDGET_NAME.md - Web JavaScript widget documentation
# - dev-docs/comfyui/custom-nodes_documentation_guidelines.md - Help page guidelines
#
# User help pages (web/docs/):
# - web/docs/NodeName.md - User-facing help (MUST match NODE_CLASS_MAPPINGS)

File Structure Overview

comfyui_swissarmyknife/
├── .github/workflows/react-build.yml  # CI/CD automation
├── __init__.py                         # Python entry point
├── pyproject.toml                      # Project metadata & publishing config
│
├── dev-docs/                          # DEVELOPER DOCUMENTATION (Technical)
│   ├── README.md                      # Developer documentation index
│   ├── nodes/                         # Node-specific documentation (ONE file per node)
│   │   ├── lm-studio-describe/       # LM Studio structured describe docs
│   │   ├── reddit-media/             # Reddit Media Extraction docs
│   │   ├── media-selection/          # Media Selection node docs
│   │   └── control-panel/            # Control Panel Display docs
│   ├── infrastructure/                # Infrastructure components
│   │   ├── caching/                  # Caching system docs
│   │   ├── debug/                    # Debug & logging docs
│   │   ├── docker/                   # Docker setup docs
│   │   └── build-deploy/             # Build & deployment docs
│   ├── integrations/                  # External service integrations
│   │   ├── civitai/                  # CivitAI API integration docs
│   │   └── reddit/                   # Reddit API integration docs
│   ├── web-js/                        # Web JavaScript widget documentation
│   ├── examples/                      # Example workflows
│   └── comfyui/                       # ComfyUI-specific documentation
│       └── custom-nodes_documentation_guidelines.md
│
├── nodes/nodes.py                      # Main Python custom nodes
│
├── web/                               # Web extension components
│   ├── js/                            # JavaScript widgets
│   │   ├── gemini_widgets.js         # Gemini widgets
│   │   └── ...
│   ├── css/                           # Stylesheets
│   └── docs/                          # USER HELP PAGES (In-UI reference)
│       ├── MediaSelection.md         # Help page for MediaSelection node
│       ├── ControlPanelPromptBreakdown.md   # Help page for Control Panel output node
│       └── ...                       # (MUST match NODE_CLASS_MAPPINGS keys)
│
└── ui-react_backup/                   # React UI extension (DISABLED)
    ├── ui/src/                        # React source code
    ├── ui/package.json                # Node.js dependencies
    └── dist/                          # Built React outputs

Package Management

# React dependencies
cd ui-react_backup/ui
npm install  # Install from package.json

# Python dependencies (ALWAYS activate venv first)
source .venv/bin/activate
pip3 install -e .  # Install from pyproject.toml
pip3 install torch opencv-python  # Additional ML dependencies

Environment Verification

# Verify tool versions
node --version    # Should be v20.19.4+
npm --version     # Should be 10.8.2+
python3 --version # Should be 3.12.3+
ffmpeg -version   # Should be 6.1.1+

# Verify Python dependencies (activate venv first)
source .venv/bin/activate
which python3     # Should point to .venv/bin/python3
pip3 list | grep -E "(torch|opencv|google-genai)"  # Show Python ML deps

# Verify Node dependencies
npm list --prefix ui-react_backup/ui  # Show React dependencies

Timing Expectations

NEVER CANCEL these operations - they may appear to hang but are working:

  • npm install: 40 seconds (normal)
  • npm run build: 5 seconds (very fast)
  • pip3 install torch opencv-python: 2-3 minutes (downloads large binaries)
  • npm run watch: Runs continuously until stopped
  • ruff check: < 1 second (very fast)
  • pytest: < 30 seconds (but no tests exist currently)

Set appropriate timeouts: 60+ seconds for npm install, 300+ seconds for Python ML dependencies.

Development Tips

  • Backend changes: Restart ComfyUI server after modifying Python files in nodes/ using: cd /mnt/nfs_share/gen-ai-image/comfyui-containers && docker compose restart dev-comfyui
  • Web extension changes: Refresh browser cache after modifying JavaScript files in web/js/
  • JavaScript widgets require no build step (plain JS files)
  • Use Playwright tests in web/tests/ to validate functionality against hosted ComfyUI server
  • Focus on functional testing since automated tests have configuration issues
  • FFmpeg must be available in PATH for video processing features to work