CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cz-git

A better customizable and git support commitizen adapter

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

cz-git

cz-git is a customizable commitizen adapter that provides an enhanced, interactive command-line tool for generating standardized git commit messages following the Conventional Commits specification. It features OpenAI integration for AI-generated commit descriptions, comprehensive customization options, lightweight architecture, and specialized support for monorepo engineering workflows.

Package Information

  • Package Name: cz-git
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install -D cz-git

Core Imports

import { prompter } from "cz-git";

For configuration and type helpers:

import { defineConfig, definePrompt } from "cz-git";
import type { CommitizenGitOptions, UserConfig } from "cz-git";

CommonJS:

const { prompter } = require("cz-git");

Basic Usage

As Commitizen Adapter

Configure in package.json:

{
  "config": {
    "commitizen": {
      "path": "cz-git"
    }
  }
}

Then use with commitizen:

npx cz

Programmatic Usage

import { prompter } from "cz-git";

// Initialize commitizen adapter
prompter(
  cz,           // commitizen instance
  commit,       // commit callback function
  configPath    // optional config path
);

Architecture

cz-git is built around several key components:

  • Prompter Function: Main entry point that orchestrates the commit message generation flow
  • Configuration System: Comprehensive options for customizing behavior, appearance, and validation
  • Question Generation: Dynamic prompt creation based on configuration and context
  • Message Generation: Commit message formatting following Conventional Commits specification
  • AI Integration: OpenAI-powered commit message suggestions and modifications
  • Inquirer Extensions: Enhanced prompts with search and filtering capabilities

Capabilities

Main Prompter Function

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

function prompter(
  cz: CommitizenType,
  commit: (message: string) => void,
  configPath?: string
): void;

interface CommitizenType {
  registerPrompt: (type: string, plugin: unknown) => void;
  prompt: (qs: QuestionsType) => Promise<Answers>;
}

Main Prompter

Configuration System

Comprehensive configuration options with over 40 customizable settings for types, scopes, validation, AI integration, and appearance.

interface CommitizenGitOptions {
  alias?: Record<string, string>;
  messages?: Answers;
  themeColorCode?: string;
  types?: TypesOption[];
  useAI?: boolean;
  aiModel?: string;
  useEmoji?: boolean;
  scopes?: ScopesType;
  // ... 30+ additional options
}

function defineConfig(config: UserConfig): UserConfig;
function definePrompt(config: UserConfig['prompt']): UserConfig['prompt'];

Configuration

Type Definitions

Complete type system for answers, configuration options, and message formatting.

interface Answers {
  type?: string;
  scope?: string | string[];
  subject?: string;
  body?: string;
  breaking?: string;
  footer?: string;
  confirmCommit?: string;
  // ... additional answer fields
}

interface TypesOption extends Option {
  emoji?: string;
}

interface Option {
  name: string;
  value: string;
}

Types

Message Generation

Functions for generating and formatting commit messages according to Conventional Commits specification.

function generateMessage(
  answers: Answers,
  options: CommitizenGitOptions,
  colorize?: boolean
): string;

function getAliasMessage(
  options: CommitizenGitOptions,
  alias: string
): string;

interface CommitMessageOptions {
  type: string;
  scope: string;
  emoji: string;
  markBreaking: string;
  subject: string;
  defaultHeader: string;
  body: string;
  breaking: string;
  footer: string;
  defaultMessage: string;
}

Message Generation

AI Integration

OpenAI-powered commit message generation with customizable prompts and model selection.

function generateAIPrompt(
  options: CommitizenGitOptions,
  cz: CommitizenType
): Promise<Answers>;

interface GenerateAIPromptType {
  type?: string;
  defaultScope?: string | string[];
  maxSubjectLength?: number;
  upperCaseSubject?: boolean | null;
  diff?: string;
}

AI Integration

Enhanced Inquirer Prompts

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

class CompleteInput {
  // Enhanced input with auto-completion
}

class SearchList {
  // Searchable list selection
}

class SearchCheckbox {
  // Searchable checkbox selection
}

function fuzzyFilter(
  input: string,
  arr: Array<FilterArrayItemType>,
  targetKey?: 'name' | 'value'
): Array<FilterArrayItemType>;

function fuzzyMatch(
  input: string,
  target: string,
  caseSensitive?: boolean
): number | null;

const style: {
  rgb: (colorCode?: string) => (text: string) => string;
  cyan: (text: string) => string;
  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;
  bold: (text: string) => string;
  dim: (text: string) => string;
  italic: (text: string) => string;
  underline: (text: string) => string;
  inverse: (text: string) => string;
  strikethrough: (text: string) => string;
  isColorSupported: boolean;
  reset: (text: string) => string;
};

Enhanced Prompts

Configuration Loading

Flexible configuration loading system supporting multiple file formats and locations.

function configLoader(options?: UserOptions): Promise<{
  rules?: Partial<RulesConfig>;
  prompt?: CommitizenGitOptions;
}>;

interface UserOptions {
  cwd?: string;
  configPath?: string;
}

Configuration Loading

Types

interface UserConfig extends CommitlintUserConfig {
  prompt?: CommitizenGitOptions;
}

type ScopesType = string[] | Array<{ name: string, value?: string }>;

type QuestionsType = Array<{
  type: string;
  name: string;
  message: string | (() => string);
  choices?: Array<any>;
  default?: any;
  validate?: (input: any) => boolean | string;
  filter?: (input: any) => any;
  when?: (answers: any) => boolean;
}>;

Install with Tessl CLI

npx tessl i tessl/npm-cz-git
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/cz-git@1.12.x
Publish Source
CLI
Badge
tessl/npm-cz-git badge