or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ai-integration.mdconfiguration-loading.mdconfiguration.mdenhanced-prompts.mdindex.mdmessage-generation.mdprompter.mdtypes.md
tile.json

prompter.mddocs/

Main Prompter Function

The core function that initializes the commitizen adapter with configuration loading and interactive prompts.

Capabilities

Prompter Function

Main entry point for the commitizen adapter that orchestrates the entire commit message generation flow.

/**
 * Main entry point for commitizen adapter
 * @param cz - Commitizen instance providing prompt registration and execution
 * @param commit - Callback function to execute the commit with generated message
 * @param configPath - Optional path to configuration file
 */
function prompter(
  cz: CommitizenType,
  commit: (message: string) => void,
  configPath?: string
): void;

interface CommitizenType {
  /** Register custom prompt types */
  registerPrompt: (type: string, plugin: unknown) => void;
  /** Execute interactive prompts */
  prompt: (qs: QuestionsType) => Promise<Answers>;
}

Usage Examples:

import { prompter } from "cz-git";

// Basic usage as commitizen adapter
function setupCommitizen(cz, commit) {
  prompter(cz, commit);
}

// With custom configuration path
function setupWithConfig(cz, commit) {
  prompter(cz, commit, './custom-cz.config.js');
}

Internal Flow Functions

Functions that handle the internal flow of the prompter after configuration is loaded.

/**
 * Generate confirmation prompt for commit message
 * @param options - Configuration options
 * @param cz - Commitizen instance
 * @param answers - Current answers from prompts
 * @returns Updated answers with confirmation
 */
function generateConfirmPrompt(
  options: CommitizenGitOptions,
  cz: CommitizenType,
  answers: Answers
): Promise<Answers>;

/**
 * Handle final commit message confirmation and execution
 * @param options - Configuration options
 * @param cz - Commitizen instance  
 * @param answers - All collected answers
 * @param commit - Commit callback function
 */
function confirmMessage(
  options: CommitizenGitOptions,
  cz: CommitizenType,
  answers: Answers,
  commit: (message: string) => void
): Promise<void>;

Environment Variables

Environment variables that affect prompter behavior:

interface EnvironmentVariables {
  /** Set to '1' to enable GPG signing */
  CZCommitSignGPG?: string;
  /** Alias for direct commit message generation */
  cz_alias?: string;
  /** Enable debug logging */
  CZ_DEBUG?: string;
}

Usage Examples:

# Use alias for quick commits
cz_alias=fd cz

# Enable GPG signing
CZCommitSignGPG=1 cz

# Enable debug mode
CZ_DEBUG=1 cz

Confirmation Options

The confirmation prompt provides multiple options for handling the generated commit message:

  • yes - Proceed with the commit using the generated message
  • no - Abort the commit process
  • edit - Open the message in an editor for manual modification
  • ai-modify - (AI mode only) Modify the message with additional AI prompts
interface ConfirmationChoices {
  yes: 'yes';
  no: 'no'; 
  edit: 'edit';
  'ai-modify': 'ai-modify'; // Only available when useAI is enabled
}

Integration with Commitizen

The prompter function integrates seamlessly with commitizen by:

  1. Registering Custom Prompts: Registers enhanced prompts (search-list, search-checkbox, complete-input)
  2. Loading Configuration: Automatically loads configuration from various sources
  3. Generating Questions: Creates dynamic prompts based on configuration
  4. Processing Answers: Validates and processes user responses
  5. Formatting Messages: Generates final commit message following Conventional Commits
  6. Executing Commit: Calls the provided commit callback with the final message

The entire process is asynchronous and handles errors gracefully, providing user feedback throughout the interaction.