Interactive Commitizen CLI that generates standardized git commit messages
npx @tessl/cli install tessl/npm-czg@1.12.0czg is a lightweight and beautiful interactive Commitizen CLI replacement that generates standardized git commit messages. It provides an interactive interface for creating conventional commits with customizable prompts, emoji support, AI-powered commit message generation, and integration with various git workflows.
npm install -g czg or npx czgFor programmatic configuration:
import { defineConfig, definePrompt } from "czg";
import type { UserConfig, CommitizenGitOptions } from "czg";CommonJS:
const { defineConfig, definePrompt } = require("czg");# Basic interactive commit
czg
# With subcommands for enhanced features
czg emoji
czg ai
czg checkbox
# With configuration
czg --config="./config/cz.json"
# Direct alias commit
czg :feat
# AI-powered commit generation
czg ai -N=3 -M="gpt-4o"import { defineConfig } from "czg";
export default defineConfig({
types: [
{ value: "feat", name: "feat: A new feature" },
{ value: "fix", name: "fix: A bug fix" },
{ value: "docs", name: "docs: Documentation changes" },
],
scopes: ["api", "ui", "db"],
allowEmptyScopes: true,
skipQuestions: ["body", "footer"],
});czg is built around several key components:
.czrc files and direct config parametersComplete command-line interface for generating commit messages with various modes and options. The primary way most users interact with czg.
// Main CLI function
function main(environment?: any, argv?: string[]): void;
// Core commit generation function
function czg(version: string, argvs: CzgitParseArgs, environment?: any): void;Helper functions and types for creating programmatic configuration for czg and cz-git integration.
// Configuration helper functions
function defineConfig<T extends UserConfig>(config: T): T;
function definePrompt<T extends UserConfig>(config: T): T;
// Core configuration types
interface UserConfig {
// Configuration options from cz-git
}
interface CommitizenGitOptions {
// Commitizen options from cz-git
}
// Parsed CLI arguments structure
interface CzgitParseArgs {
czgitArgs: {
flag: (CzgitCommonFlag & CzgitFlag & InitFlag) | null;
subCommand: CzgitSubCommand | null;
};
gitArgs: string[];
}interface CzgitCommonFlag {
/** Show version */
version?: boolean;
/** Show help */
help?: boolean;
/** Turn off AI mode */
ai?: boolean;
}
interface CzgitFlag {
/** Configuration file path */
config?: string;
/** Direct commit alias */
alias?: string;
/** OpenAI API key */
"api-key"?: string;
/** AI model name */
"ai-model"?: string;
/** AI number of suggestions */
"ai-num"?: string;
/** API proxy URL */
"api-proxy"?: string;
/** API endpoint URL */
"api-endpoint"?: string;
/** Unset proxy */
"unset-proxy"?: boolean;
/** Retry last commit */
retry?: boolean;
/** Reback last commit */
reback?: boolean;
/** Hook mode */
hook?: boolean;
}
interface CzgitSubCommand {
/** Initialize mode */
init?: boolean;
/** AI mode */
ai?: boolean;
/** Emoji mode */
emoji?: boolean;
/** Checkbox mode */
checkbox?: boolean;
/** Breaking change mode */
break?: boolean;
/** GPG signing mode */
gpg?: boolean;
}type CallBackFn = (err: Error | null, data?: any) => void;
interface CommitOptions {
args: string[];
disableAppendPaths: boolean;
emitData: boolean;
quiet: boolean;
retryLastCommit: boolean;
rebackLastCommit: boolean;
hookMode: boolean;
environment: any;
configPath?: string;
}