Skip to content

Core API

The core module provides the fundamental functionality of JiraGen.

JiraGen Class

The main class that orchestrates all functionality.

from jiragen import JiraGen


class JiraGen:
    def __init__(self, config_path: Optional[str] = None):
        """Initialize JiraGen with optional custom config path."""

    def generate(
        self,
        title: str,
        template: Optional[str] = None,
        model: Optional[str] = None,
        temperature: float = 0.7,
        max_tokens: int = 2000,
    ) -> Issue:
        """Generate a JIRA issue with AI assistance."""

    def upload(self, issue: Issue) -> str:
        """Upload an issue to JIRA and return the issue key."""

    def add_files(self, paths: List[str]) -> int:
        """Add files to the vector store."""

Generator Class

Handles AI-powered issue generation.

from jiragen.core import Generator


class Generator:
    def __init__(
        self, model: str = "gpt-4", temperature: float = 0.7, max_tokens: int = 2000
    ):
        """Initialize the generator with model settings."""

    def generate(
        self, title: str, context: List[str], template: Optional[str] = None
    ) -> Dict[str, Any]:
        """Generate issue content using AI."""

Issue Class

Represents a JIRA issue with all its metadata.

from jiragen.core import Issue


class Issue:
    def __init__(
        self,
        title: str,
        description: str,
        issue_type: str = "Story",
        priority: Optional[str] = None,
        labels: Optional[List[str]] = None,
        components: Optional[List[str]] = None,
    ):
        """Initialize an issue with its metadata."""

    def to_dict(self) -> Dict[str, Any]:
        """Convert issue to JIRA API format."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "Issue":
        """Create issue from JIRA API response."""

Config Class

Manages application configuration.

from jiragen.core import Config


class Config:
    @classmethod
    def load(cls, path: Optional[str] = None) -> "Config":
        """Load configuration from file."""

    def save(self, path: Optional[str] = None) -> None:
        """Save configuration to file."""

    @property
    def jira(self) -> JiraConfig:
        """Get JIRA configuration section."""

    @property
    def llm(self) -> LLMConfig:
        """Get LLM configuration section."""

Exceptions

Custom exceptions for error handling.

from jiragen.core.exceptions import (
    JiraGenError,
    ConfigError,
    JiraError,
    GenerationError,
    VectorStoreError,
)


class JiraGenError(Exception):
    """Base exception for all JiraGen errors."""


class ConfigError(JiraGenError):
    """Configuration related errors."""


class JiraError(JiraGenError):
    """JIRA API related errors."""


class GenerationError(JiraGenError):
    """AI generation related errors."""


class VectorStoreError(JiraGenError):
    """Vector store related errors."""

Vector Store

Overview

The Vector Store module handles the storage and retrieval of code embeddings, enabling semantic search over your codebase.

VectorStoreConfig

jiragen.core.client.VectorStoreConfig

VectorStoreConfig(**data)

Bases: BaseModel

Configuration for the vector store client and service.

Attributes:

  • collection_name (str) –

    Default collection name

  • embedding_model (str) –

    Name of the sentence transformer model to use

  • device (str) –

    Device to run embeddings on ('cpu' or 'cuda')

  • socket_path (Optional[Path]) –

    Unix socket path for client-service communication

  • db_path (Optional[Path]) –

    Path to the vector store database

VectorStoreClient

jiragen.core.client.VectorStoreClient

VectorStoreClient(config: VectorStoreConfig)

Functions

ensure_service_running
ensure_service_running() -> None

Ensure the vector store service is running

start_service
start_service() -> None

Start the vector store service

restart
restart() -> None

Restart the vector store service.

kill
kill() -> None

Kill the vector store service.

send_command
send_command(command: str, params: Dict[str, Any] = None, timeout: int = SOCKET_TIMEOUT, retries: int = MAX_RETRIES) -> Dict[str, Any]

Send command to service with retries

initialize_store
initialize_store() -> None

Initialize the vector store with initialization state verification.

The initialization process: 1. Send initialize command with config 2. Verify store accessibility through get_stored_files 3. Confirm data structure integrity

get_stored_files
get_stored_files() -> Dict[str, Set[Path]]

Get stored files with robust validation and error handling.

Returns:

  • Dict[str, Set[Path]]

    Dict[str, Set[Path]]: Dictionary containing: - 'files': Set of file paths - 'directories': Set of directory paths

add_files
add_files(paths: List[Path]) -> Set[Path]

Add files to vector store

remove_files
remove_files(paths: List[Path]) -> Set[Path]

Remove files from vector store

query_similar
query_similar(text: str, n_results: int = 5) -> List[Dict[str, Any]]

Query similar documents

VectorStoreService

jiragen.services.vector_store.VectorStoreService

VectorStoreService(socket_path: Path, runtime_dir: Path)

Functions

initialize_store
initialize_store(config: Dict[str, Any]) -> None

Initialize the vector store with the given configuration

handle_add_files
handle_add_files(params: Dict[str, Any]) -> Dict[str, Any]

Handle adding files to the vector store

handle_remove_files
handle_remove_files(params: Dict[str, Any]) -> Dict[str, Any]

Handle removing files from the vector store

handle_get_stored_files
handle_get_stored_files(params: Dict[str, Any]) -> Dict[str, Any]

Handle retrieving stored files information

handle_query_similar
handle_query_similar(params: Dict[str, Any]) -> Dict[str, Any]

Handle querying similar documents

handle_client
handle_client(conn: socket.socket) -> None

Handle a client connection

handle_shutdown
handle_shutdown(signum, frame) -> None

Handle shutdown signal

cleanup
cleanup() -> None

Clean up resources

start
start() -> None

Start the service

Generator

Overview

The Generator module is responsible for generating ticket content using AI models and managing the generation process.

LLMConfig

jiragen.core.generator.LLMConfig

Bases: BaseModel

Functions

set_api_base
set_api_base() -> LLMConfig

Set default API base if not provided, based on model provider

LiteLLMClient

jiragen.core.generator.LiteLLMClient

LiteLLMClient(config: LLMConfig)

IssueGenerator

jiragen.core.generator.IssueGenerator

IssueGenerator(vector_store: VectorStoreClient, config: GeneratorConfig)

Generator for creating JIRA tickets using both JIRA and codebase context.

Uses RAG (Retrieval Augmented Generation) to find relevant context from both JIRA history and codebase, then generates a ticket following a template.

Attributes:

  • vector_store

    Vector store client for retrieving similar documents

  • config

    Generator configuration

Functions

generate
generate(message: str) -> str

Generate a JIRA ticket using RAG and template-guided generation.

Retrieves relevant context from both JIRA history and codebase, then uses an LLM to generate a ticket following the template.

Parameters:

  • message (str) –

    User's request for the ticket

Returns:

  • str

    Generated ticket content following the template

Raises:

  • RuntimeError

    If ticket generation fails

Metadata

Overview

The Metadata module handles JIRA issue metadata, including issue types, priorities, and field validation.

Usage Example

from jiragen.core.metadata import IssueMetadata, IssueType, IssuePriority

# Create metadata for a new feature
metadata = IssueMetadata(
    issue_type=IssueType.STORY,
    priority=IssuePriority.HIGH,
    labels=["feature", "ui"],
    components=["frontend"],
    story_points=5,
)

IssueType

jiragen.core.metadata.IssueType

Bases: str, Enum

IssuePriority

jiragen.core.metadata.IssuePriority

Bases: str, Enum

IssueMetadata

jiragen.core.metadata.IssueMetadata

Bases: BaseModel

Represents the metadata extracted from an issue's content.

IssueMetadataExtractor

jiragen.core.metadata.IssueMetadataExtractor

IssueMetadataExtractor(llm_config: LLMConfig)

Extracts metadata from issue content using LLM analysis.

Functions

extract_metadata
extract_metadata(content: str) -> IssueMetadata

Analyzes the issue content and extracts relevant metadata.

Parameters:

  • content (str) –

    The generated issue content to analyze

Returns:

  • IssueMetadata

    IssueMetadata object containing the extracted metadata

Config

Overview

The Config module manages application configuration, including JIRA credentials and default settings.

Environment Variables

Configuration can also be set using environment variables:

export JIRA_URL=https://your-domain.atlassian.net
export JIRA_USERNAME=your-email@example.com
export JIRA_API_TOKEN=your-api-token

ConfigManager

jiragen.core.config.ConfigManager

ConfigManager(config_path: Optional[Path] = None)

Manages jiragen configuration.

Parameters:

  • config_path (Optional[Path], default: None ) –

    Optional path to config file. If not provided, defaults to standard config location based on OS.

Functions

create_default_config
create_default_config() -> None

Create default configuration file.

load_config
load_config() -> None

Load configuration from file.

update_config
update_config(section: str, **kwargs) -> None

Update configuration values.