or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-commands.mdconfiguration-api.mdindex.md
tile.json

cli-commands.mddocs/

CLI Commands

Complete command-line interface for czg providing interactive commit message generation with extensive customization options.

Capabilities

Main CLI Function

Entry point for the czg CLI that handles argument parsing and command routing.

/**
 * Main CLI Entry Point - processes command line arguments and starts interactive commit
 * @param environment - Optional environment configuration object
 * @param argv - Command line arguments array (defaults to process.argv)
 */
function main(environment?: any, argv?: string[]): void;

Usage Examples:

# Basic usage - starts interactive commit process
czg

# With specific git arguments passed through
czg --amend
czg --no-verify

Core Commit Generator

The main function that starts the interactive commit process after argument parsing.

/**
 * Start inquirer prompts to generate commit message
 * @param version - Current czg version string
 * @param argvs - Parsed CLI arguments structure
 * @param environment - Optional environment configuration
 */
function czg(version: string, argvs: CzgitParseArgs, environment?: any): void;

Argument Parser

Parses command line arguments into structured format for processing.

/**
 * Parse CLI arguments using minimist into structured format
 * @param argv - Raw command line arguments
 * @returns Structured parsed arguments with czg and git sections
 */
function resovleArgs(argv: string[]): CzgitParseArgs;

Subcommands

AI Mode

Turn on OpenAI-powered commit message generation.

# Basic AI mode
czg ai

# AI mode with multiple suggestions
czg ai -N=3

# AI mode with specific model
czg ai -M="gpt-4o"

# Combined AI options
czg ai -N=5 -M="gpt-3.5-turbo"

Emoji Mode

Enable emoji output in commit messages.

czg emoji

Checkbox Mode

Turn on scope selection via checkboxes instead of list.

czg checkbox

Breaking Change Mode

Automatically append ! after type/scope to indicate breaking changes.

czg break

GPG Signing Mode

Enable GPG signing for the commit.

czg gpg

Initialize Mode

Configure czg settings (currently not implemented).

czg init

Flags and Options

Configuration Options

# Use specific configuration file
czg --config="./config/cz.json"
czg --config="/path/to/custom.config.js"

# Direct commit with predefined alias
czg --alias="feat: add new feature"
czg :feat  # Shorthand alias syntax

AI Configuration

# Set OpenAI API key
czg --api-key="sk-xxx"

# Configure API model
czg --api-model="gpt-4o"

# Set API endpoint
czg --api-endpoint="https://api.openai.com/v1"

# Configure proxy
czg --api-proxy="http://proxy.example.com:8080"

# Remove proxy configuration
czg --unset-proxy

# Disable AI for this session
czg --no-ai

# AI options for current session
czg -N=3 -M="gpt-4o"  # 3 suggestions, gpt-4o model

Commit Control

# Retry last commit attempt
czg --retry
czg -r

# Hook mode (for git hooks integration)
czg --hook

# Reback last commit (not implemented)
czg --reback
czg -b

Help and Version

# Show help information
czg --help
czg -h

# Show version
czg --version
czg -v

Git Integration

Git Arguments Passthrough

All unrecognized arguments are passed through to git commit:

# These git flags are passed through to git commit
czg --amend
czg --no-verify
czg --author="John Doe <john@example.com>"
czg -a  # Stage all files before commit
czg --allow-empty

Git Repository Functions

Internal functions for git operations:

/**
 * Check if git working directory is clean
 * @param repoPath - Path to git repository
 * @param done - Callback function receiving (error, isClean)
 * @param stageAllFiles - Whether to check for unstaged files too
 */
function isGitClean(repoPath: string, done: CallBackFn, stageAllFiles: boolean): void;

/**
 * Get the root path of the current git repository
 * @returns Git repository root path
 */
function getGitRootPath(): string;

/**
 * Get the absolute path to the .git directory
 * @param pwd - Current working directory
 * @returns Absolute path to .git directory
 */
function getGitDirPath(pwd: string): string;

/**
 * Execute git commit with the provided message and options
 * @param repoPath - Path to git repository
 * @param message - Commit message to use
 * @param options - Commit configuration options
 * @param done - Callback function for completion
 */
function gitCommit(repoPath: string, message: string, options: CommitOptions, done: CallBackFn): void;

Help System

Help Generator

Built-in help system with comprehensive usage information.

/**
 * Generate and display help documentation
 * @param version - Current czg version
 * @param code - Exit code (default: 0)
 */
function generateHelp(version: string, code?: number): void;

The help system displays:

  • Command syntax and usage patterns
  • All available subcommands with descriptions
  • Complete flag and option reference
  • OpenAI configuration options
  • Practical usage examples
  • Integration with git commit options

Configuration Management

AI Configuration Setup

/**
 * Setup OpenAI API configuration in user's home directory
 * @param token - OpenAI API token/key
 * @param apiProxy - API proxy URL
 * @param unsetProxy - Whether to remove proxy configuration
 * @param apiEndpoint - Custom API endpoint
 * @param apiModel - Default AI model to use
 */
function setupAIConfig(
  token?: string,
  apiProxy?: string,
  unsetProxy?: boolean,
  apiEndpoint?: string,
  apiModel?: string
): void;

Configuration is stored in ~/.config/.czrc as JSON:

{
  "openAIToken": "sk-xxx",
  "apiProxy": "http://proxy.example.com:8080",
  "apiEndpoint": "https://api.openai.com/v1",
  "apiModel": "gpt-4o"
}

Error Handling

czg includes comprehensive error handling:

  • Git configuration validation (user.name, user.email)
  • Repository state validation (staged files check)
  • OpenAI API configuration validation
  • Process signal handling (SIGINT for graceful exit)
  • Uncaught exception handling with user-friendly messages

Environment Variables

czg recognizes several environment variables:

  • CZ_ALL_CHANGE_MODE: Set to '1' when using -a or --all flags
  • CZCommitSignGPG: Set to '1' to enable GPG signing
  • Various cz-git environment variables for configuration