CLI API Reference¶
This section documents the command-line interface components of JiraGen. These components provide the user-facing functionality for ticket generation, metadata handling, and JIRA integration.
Generate Command¶
Overview
The Generate command creates JIRA tickets using AI, with support for interactive editing and metadata modification.
Usage Example
from jiragen.cli.generate import generate_issue
from jiragen.core.client import VectorStoreClient
# Initialize vector store
store = VectorStoreClient()
# Generate a ticket
result = generate_issue(
store=store,
message="Add dark mode support",
model="openai/gpt-4o",
upload=True,
yes=False, # Enable interactive mode
)
generate_issue¶
jiragen.cli.generate.generate_issue ¶
generate_issue(store: VectorStoreClient, message: str, template_path: str, model: Optional[str] = None, temperature: Optional[float] = None, max_tokens: Optional[int] = None, upload: bool = False, yes: bool = False) -> Optional[Dict[str, Any]]
Generate JIRA issue content and metadata using AI.
open_in_neovim¶
Editor Integration
The open_in_neovim
function provides seamless integration with Neovim for content editing. Make sure Neovim is installed and configured properly.
jiragen.cli.nvim.open_in_neovim ¶
Open content in Neovim with markdown preview if available.
Parameters:
-
content
(str
) –Initial content to edit
Returns:
-
Optional[str]
–Optional[str]: Modified content if saved, None if canceled
Add Command¶
Overview
The Add command indexes your codebase into the vector store for context-aware ticket generation. It supports recursive directory scanning and respects .gitignore patterns.
Large Codebases
For large codebases, the indexing process may take some time. The command shows a progress bar and provides detailed statistics upon completion.
Gitignore Support
The command automatically respects .gitignore patterns in your repository. This includes: - Standard .gitignore patterns - Custom patterns in your repository's .gitignore - Common version control directories (.git)
add_files_command¶
The main function that handles adding files to the vector store. It provides: - Recursive directory scanning - .gitignore pattern support - Progress tracking - File processing statistics - Tree view of added files
def add_files_command(store, paths: List[str]) -> None:
"""Add files to the vector database, respecting .gitignore patterns.
Args:
store: The vector store client instance
paths: List of file paths to add. Can include:
- Individual files
- Directories (will be scanned recursively)
- Glob patterns ("*", "**", etc.)
"""
Usage Examples¶
from jiragen.cli.add import add_files_command
from jiragen.core.client import VectorStoreClient
# Initialize vector store
store = VectorStoreClient()
# Add all files in current directory (respects .gitignore)
add_files_command(store, ["."])
# Add specific files
add_files_command(store, ["src/main.py", "tests/test_api.py"])
# Add all files in a directory
add_files_command(store, ["src/"])
Init Command¶
Overview
The Init command sets up JiraGen's configuration and creates necessary directories.
Configuration
The init process will:
1. Create the .jiragen
directory
2. Initialize the configuration file
3. Set up the vector store
4. Configure JIRA credentials
init_command¶
jiragen.cli.init.init_command ¶
Initialize jiragen configuration.
Parameters:
-
template_config_path
(Path
, default:None
) –Path to the template configuration file. If provided, will be used as a template for the default config at ~/.config/jiragen/config.ini
Upload Command¶
Overview
The Upload command handles the creation of JIRA issues with proper metadata and content formatting.
Usage Example
from jiragen.cli.upload import upload_command
# Upload a new feature request
issue_key = upload_command(
title="Add Dark Mode Support",
description="# Feature Request\n\nImplement dark mode...",
issue_type="Story",
priority="High",
labels="frontend,ui,dark-mode",
component_name="UI",
)
print(f"Created issue: {issue_key}")
upload_command¶
jiragen.cli.upload.upload_command ¶
upload_command(title: str, description: Optional[str] = None, issue_type: str = 'Story', epic_key: Optional[str] = None, component_name: Optional[str] = None, priority: Optional[str] = None, labels: Optional[str] = None, assignee: Optional[str] = None, reporter: Optional[str] = None, custom_fields: Optional[Dict[str, Any]] = None) -> Optional[str]
Upload a Jira issue with the provided content and options.
Parameters:
-
title
(str
) –Issue summary/title
-
description
(Optional[str]
, default:None
) –Issue description (can be in markdown format)
-
issue_type
(str
, default:'Story'
) –Type of issue (Story, Bug, Task, Epic, etc.)
-
epic_key
(Optional[str]
, default:None
) –Key of the epic to link the issue to (not applicable for epics)
-
component_name
(Optional[str]
, default:None
) –Name of the component to assign
-
priority
(Optional[str]
, default:None
) –Priority level (Highest, High, Medium, Low, Lowest)
-
labels
(Optional[str]
, default:None
) –Comma-separated list of labels
-
assignee
(Optional[str]
, default:None
) –Username of the assignee
-
reporter
(Optional[str]
, default:None
) –Username of the reporter
-
custom_fields
(Optional[Dict[str, Any]]
, default:None
) –Dictionary of custom field IDs and values
Returns:
-
str
(Optional[str]
) –The key of the created issue, or None if creation failed
JIRA Integration Utilities¶
Helper Functions
The following functions help validate and format data for JIRA:
read_config¶
jiragen.cli.upload.read_config ¶
Read Jira configuration from config file.
get_project_key¶
jiragen.cli.upload.get_project_key ¶
Get project key from project name.
validate_component¶
jiragen.cli.upload.validate_component ¶
Validate component exists and return its ID.
validate_epic¶
jiragen.cli.upload.validate_epic ¶
Validate epic exists and return its key.
validate_priority¶
jiragen.cli.upload.validate_priority ¶
Validate priority exists and return its name.
validate_labels¶
jiragen.cli.upload.validate_labels ¶
Validate and format labels.
convert_md_to_jira¶
jiragen.cli.upload.convert_md_to_jira ¶
Convert markdown text to Jira markup.