"""Help dialogs for CmdForge GUI.""" from PySide6.QtWidgets import ( QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QTextBrowser ) from PySide6.QtCore import Qt # Help content for quick guides HELP_CONTENT = { "getting_started": { "title": "Getting Started with CmdForge", "content": """

Welcome to CmdForge!

CmdForge lets you create AI-powered command-line tools that work like any Unix command.

Quick Start Steps:

  1. Configure a Provider - Go to Providers in the sidebar and add an AI backend (like Claude or GPT). This is required before running AI tools.
  2. Browse the Registry - Check out the Registry to discover tools shared by the community.
  3. Install Tools - Click on any tool and hit Install to add it to your system.
  4. Create Your Own - Use the Tool Builder to create custom AI-powered commands.
  5. Use in Terminal - Run your tools like any command: my-tool < input.txt

Key Concepts:

Keyboard Shortcuts:

Ctrl+NCreate new tool
Ctrl+SSave current tool
Ctrl+RRefresh current page
Ctrl+1-4Navigate to pages
Ctrl+QQuit
EscapeClose tool builder
""" }, "create_tool": { "title": "How to Create a Tool", "content": """

Creating a New Tool

Step 1: Start the Tool Builder

Click Create Tool on the Welcome page, or press Ctrl+N from anywhere.

Step 2: Fill in Basic Info

Step 3: Add Arguments (Optional)

Arguments let users customize tool behavior:

Step 4: Add Steps

Steps define what your tool does:

Step 5: Set Output Template

The output template defines what your tool prints. Use {variable} to include step outputs.

Example: {response} prints the last AI response.

Step 6: Save

Press Ctrl+S or click Save. Your tool is now available as a command!

Example: Simple Summarizer

Name: summarize
Steps:
  1. Prompt [claude] -> response
     "Summarize this text: {input}"
Output: {response}

Run it: echo "Long text..." | summarize

""" }, "install_tools": { "title": "How to Install Tools", "content": """

Installing Tools from the Registry

Step 1: Open the Registry

Click Registry in the sidebar to browse community tools.

Step 2: Find a Tool

Step 3: Review Tool Details

Click on a tool to see:

Step 4: Install

Step 5: Use the Tool

Installed tools are available immediately in your terminal:

echo "text" | tool-name
cat file.txt | tool-name --flag value
tool-name --help

Updates

Tools with available updates show a green arrow (↑) in the list. Click Update to get the latest version.

Managing Installed Tools

Go to Tools in the sidebar to see all your installed tools, edit them, or delete ones you no longer need.

""" }, "publish_tools": { "title": "How to Publish Tools", "content": """

Publishing Your Tools

Prerequisites

Step 1: Connect Your Account

  1. Go to the Providers page
  2. Click Connect to Registry
  3. Log in or register

Step 2: Prepare Your Tool

Step 3: Publish

  1. Go to the Tools page
  2. Select the tool you want to publish
  3. Click Publish
  4. Add tags to help users find it
  5. Set the initial version number
  6. Click Submit

Versioning

When you update a published tool:

Best Practices

""" }, "keyboard_shortcuts": { "title": "Keyboard Shortcuts", "content": """

Keyboard Shortcuts

Global

Ctrl+NCreate new tool
Ctrl+SSave current tool
Ctrl+RRefresh current page
Ctrl+QQuit application
F1Show help

Navigation

Ctrl+1Go to Welcome page
Ctrl+2Go to Tools page
Ctrl+3Go to Registry page
Ctrl+4Go to Providers page

Tool Builder

EscapeClose builder / cancel
Ctrl+SSave tool

Lists and Tables

Double-clickEdit selected item
Drag & DropReorder steps
""" } } class QuickGuideDialog(QDialog): """Dialog showing a quick guide on a topic.""" def __init__(self, guide_key: str, parent=None): super().__init__(parent) guide = HELP_CONTENT.get(guide_key, {}) self.setWindowTitle(guide.get("title", "Help")) self.setMinimumSize(550, 450) self.resize(600, 500) self.setModal(True) self._setup_ui(guide) def _setup_ui(self, guide: dict): """Set up the dialog UI.""" layout = QVBoxLayout(self) layout.setContentsMargins(24, 24, 24, 24) layout.setSpacing(16) # Content browser with styled HTML browser = QTextBrowser() browser.setOpenExternalLinks(True) browser.setStyleSheet(""" QTextBrowser { border: none; background-color: transparent; font-size: 13px; } """) # Build styled content content = f""" {guide.get("content", "")} """ browser.setHtml(content) layout.addWidget(browser, 1) # Close button btn_layout = QHBoxLayout() btn_layout.addStretch() btn_close = QPushButton("Close") btn_close.setMinimumWidth(100) btn_close.clicked.connect(self.accept) btn_layout.addWidget(btn_close) layout.addLayout(btn_layout) class AboutDialog(QDialog): """About CmdForge dialog.""" def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("About CmdForge") self.setFixedSize(400, 300) self.setModal(True) self._setup_ui() def _setup_ui(self): """Set up the dialog UI.""" layout = QVBoxLayout(self) layout.setContentsMargins(32, 32, 32, 32) layout.setSpacing(16) # Logo/title title = QLabel("CmdForge") title.setStyleSheet(""" font-size: 32px; font-weight: bold; color: #667eea; """) title.setAlignment(Qt.AlignCenter) layout.addWidget(title) # Tagline tagline = QLabel("AI-Powered CLI Tool Builder") tagline.setStyleSheet("font-size: 14px; color: #718096;") tagline.setAlignment(Qt.AlignCenter) layout.addWidget(tagline) layout.addSpacing(16) # Version info try: from cmdforge import __version__ version = __version__ except ImportError: version = "unknown" version_label = QLabel(f"Version {version}") version_label.setStyleSheet("color: #4a5568;") version_label.setAlignment(Qt.AlignCenter) layout.addWidget(version_label) # Description desc = QLabel( "Create custom terminal commands that call AI providers,\n" "chain prompts with Python code, and use them like\n" "any Unix pipe command." ) desc.setStyleSheet("color: #718096; font-size: 12px;") desc.setAlignment(Qt.AlignCenter) layout.addWidget(desc) layout.addStretch() # Links links = QLabel( 'Website' ) links.setOpenExternalLinks(True) links.setAlignment(Qt.AlignCenter) layout.addWidget(links) # Close button btn_close = QPushButton("Close") btn_close.clicked.connect(self.accept) layout.addWidget(btn_close)