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

enhanced-prompts.mddocs/

Enhanced Inquirer Prompts

Extended inquirer prompts with search and filtering capabilities for better user experience.

Capabilities

Search List Prompt

Searchable list selection with fuzzy search capabilities.

/**
 * Enhanced list prompt with search functionality
 * Provides fuzzy search across list items for quick selection
 */
class SearchList {
  constructor(questions: any, rl: any, answers: any);
  
  /** Run the prompt and return selected value */
  run(): Promise<any>;
  
  /** Filter choices based on search input */
  search(input: string): any[];
  
  /** Render the current prompt state */
  render(): string;
}

Usage Examples:

// Automatically registered by cz-git prompter
cz.registerPrompt('search-list', SearchList);

// Used in question configuration
const questions = [{
  type: 'search-list',
  name: 'type',
  message: 'Select the type of change:',
  choices: [
    { name: 'feat: A new feature', value: 'feat' },
    { name: 'fix: A bug fix', value: 'fix' },
    { name: 'docs: Documentation changes', value: 'docs' },
    // ... more choices
  ]
}];

Search Checkbox Prompt

Searchable multi-selection checkbox with filtering.

/**
 * Enhanced checkbox prompt with search functionality
 * Allows multiple selections with fuzzy search filtering
 */
class SearchCheckbox {
  constructor(questions: any, rl: any, answers: any);
  
  /** Run the prompt and return selected values array */
  run(): Promise<any[]>;
  
  /** Filter choices based on search input */
  search(input: string): any[];
  
  /** Toggle selection state of an item */
  toggle(index: number): void;
  
  /** Render the current prompt state with selections */
  render(): string;
}

Usage Examples:

// Used for multiple scope selection
cz.registerPrompt('search-checkbox', SearchCheckbox);

const questions = [{
  type: 'search-checkbox',
  name: 'scope',
  message: 'Select affected scopes:',
  choices: [
    { name: 'core', value: 'core' },
    { name: 'ui', value: 'ui' },
    { name: 'api', value: 'api' },
    { name: 'auth', value: 'auth' },
    // ... more scopes
  ]
}];

Complete Input Prompt

Input prompt with auto-completion and template support.

/**
 * Enhanced input prompt with auto-completion
 * Supports tab completion and default value templates
 */
class CompleteInput {
  constructor(questions: any, rl: any, answers: any);
  
  /** Run the prompt and return input value */
  run(): Promise<string>;
  
  /** Handle tab completion */
  complete(): void;
  
  /** Apply default template */
  applyTemplate(): void;
  
  /** Validate input according to rules */
  validate(input: string): boolean | string;
  
  /** Render the current prompt state */
  render(): string;
}

Usage Examples:

// Used for subject input with auto-completion
cz.registerPrompt('complete-input', CompleteInput);

const questions = [{
  type: 'complete-input',
  name: 'subject',
  message: 'Write a short description:',
  default: 'add new feature',
  validate: (input) => input.length > 0 || 'Subject is required'
}];

Styling Utilities

Terminal styling functions for consistent theming and colors.

interface StyleUtilities {
  /** Apply RGB color styling */
  rgb(colorCode: string): (text: string) => string;
  
  /** Apply cyan color (default theme) */
  cyan(text: string): string;
  
  /** Apply other color utilities */
  red(text: string): string;
  green(text: string): string;
  yellow(text: string): string;
  blue(text: string): string;
  magenta(text: string): string;
  white(text: string): string;
  gray(text: string): string;
  
  /** Text styling */
  bold(text: string): string;
  dim(text: string): string;
  italic(text: string): string;
  underline(text: string): string;
  
  /** Reset all styling */
  reset(text: string): string;
}

const style: StyleUtilities;

Usage Examples:

import { style } from "cz-git";

// Apply theme color or default cyan
function useThemeCode(input: string, themeColorCode?: string): string {
  return themeColorCode 
    ? style.rgb(themeColorCode)(input) 
    : style.cyan(input);
}

// Style validation messages
const errorMessage = style.red('✗ Subject is required');
const successMessage = style.green('✓ Valid commit message');
const warningMessage = style.yellow('⚠ Subject is too long');

Prompt Registration

Functions for registering custom prompts with commitizen.

interface PromptRegistration {
  /** Register enhanced search list prompt */
  registerSearchList(cz: CommitizenType): void;
  
  /** Register enhanced search checkbox prompt */
  registerSearchCheckbox(cz: CommitizenType): void;
  
  /** Register enhanced complete input prompt */
  registerCompleteInput(cz: CommitizenType): void;
  
  /** Register all enhanced prompts */
  registerAllPrompts(cz: CommitizenType): void;
}

Usage Examples:

// Automatically done by prompter function
import { prompter } from "cz-git";

function setupCommitizen(cz, commit) {
  // These are registered automatically:
  // cz.registerPrompt('search-list', SearchList);
  // cz.registerPrompt('search-checkbox', SearchCheckbox);  
  // cz.registerPrompt('complete-input', CompleteInput);
  
  prompter(cz, commit);
}

Search Configuration

Options for configuring search behavior in enhanced prompts.

interface SearchConfiguration {
  /** Search by value field instead of name field */
  typesSearchValue?: boolean;
  
  /** Search by value field for scopes */
  scopesSearchValue?: boolean;
  
  /** Enable fuzzy search matching */
  fuzzySearch?: boolean;
  
  /** Case-sensitive search */
  caseSensitive?: boolean;
  
  /** Minimum characters before search activates */
  searchThreshold?: number;
}

Usage Examples:

export default definePrompt({
  // Search commit types by their value (e.g., 'feat') instead of display name
  typesSearchValue: true,
  
  // Search scopes by display name for better UX with long descriptions
  scopesSearchValue: false,
  
  types: [
    { value: 'feat', name: 'feat: A new feature that adds functionality' },
    { value: 'fix', name: 'fix: A bug fix that resolves an issue' },
  ],
  
  scopes: [
    { name: 'Core Authentication System', value: 'auth' },
    { name: 'User Interface Components', value: 'ui' },
    { name: 'API Endpoints and Routes', value: 'api' },
  ]
});

Keyboard Shortcuts

Enhanced prompts support additional keyboard shortcuts for improved productivity:

  • Tab / Right Arrow: Auto-complete input or apply template
  • Ctrl+Space: Trigger search mode in list prompts
  • Enter: Select current item or confirm input
  • Escape: Cancel current operation
  • Up/Down Arrows: Navigate through filtered results
  • Page Up/Down: Navigate through long lists quickly
  • Home/End: Jump to first/last item in lists
  • Ctrl+A: Select all in checkbox prompts
  • Ctrl+D: Deselect all in checkbox prompts

Fuzzy Search Utilities

Core fuzzy search functions that power the search functionality in enhanced prompts.

/**
 * Fuzzy match algorithm for scoring input against target strings
 * @param input - User input string to match
 * @param target - Target string to match against
 * @param caseSensitive - Whether matching should be case sensitive
 * @returns Match score (higher = better match) or null if no match
 */
function fuzzyMatch(
  input: string,
  target: string,
  caseSensitive?: boolean
): number | null;

/**
 * Filter and sort array items using fuzzy matching
 * @param input - Search input string
 * @param arr - Array of items to filter
 * @param targetKey - Property to search within ('name' or 'value')
 * @returns Filtered and sorted array with match scores
 */
function fuzzyFilter(
  input: string,
  arr: Array<FilterArrayItemType>,
  targetKey?: 'name' | 'value'
): Array<FilterArrayItemType>;

interface FilterArrayItemType {
  name: string;
  value: string;
  score?: number;
  index?: number;
}

Usage Examples:

import { fuzzyFilter, fuzzyMatch } from "cz-git";

// Basic fuzzy matching
const score = fuzzyMatch('fx', 'fix: Bug fix', false);
// Returns positive score for match

// Filter choices with fuzzy search
const choices = [
  { name: 'feat: New feature', value: 'feat' },
  { name: 'fix: Bug fix', value: 'fix' },
  { name: 'docs: Documentation', value: 'docs' }
];

const filtered = fuzzyFilter('fx', choices, 'name');
// Returns [{ name: 'fix: Bug fix', value: 'fix', score: 10, index: 1 }]

List Template Processing

Enhanced prompts automatically handle custom list templates with proper alignment and separators.

/**
 * Process custom list templates with separators and alignment
 * @param target - Array of choices to process
 * @param cz - Commitizen instance for separator creation
 * @param align - Position of custom/empty options
 * @param emptyAlias - Label for empty option
 * @param customAlias - Label for custom option
 * @param allowCustom - Whether to show custom option
 * @param allowEmpty - Whether to show empty option
 * @param defaultValue - Default selection to pin to top
 * @param scopeFilters - Values to filter out
 * @returns Processed choice array with separators and special options
 */
function resovleCustomListTemplate(
  target: Array<{ name: string, value: string }>,
  cz: any,
  align?: 'top' | 'bottom' | 'top-bottom' | 'bottom-top',
  emptyAlias?: string,
  customAlias?: string,
  allowCustom?: boolean,
  allowEmpty?: boolean,
  defaultValue?: string | string[],
  scopeFilters?: string[]
): Array<{ name: string, value: any }>;

This system provides a rich, interactive experience that significantly improves the efficiency and user experience of commit message creation.