# @elsikora/commitizen-plugin-commitlint-ai 中文文档

规范地址：https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/

版本：3\.0\.1
npm 元数据更新时间：2026-05-21T00:07:45.329Z
中文译文更新时间：2026-11-13T14:09:44.042Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40elsikora/commitizen-plugin-commitlint-ai
原文对照：https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/?lang=original
项目主页：https://github.com/ElsiKora/Commitizen-Plugin-Commitlint-AI#readme
源码仓库：https://github.com/ElsiKora/Commitizen-Plugin-Commitlint-AI

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：356 kB，142 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：15 个
- peer 依赖：commitizen ^4\.0\.3
- 首次发布：2025-03-03T00:55:35.773Z
- 最新版本发布：2026-05-21T00:07:45.128Z
- 近 30 天下载量：12661（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：38（近 12 个月 28 个）

## 中文简介

Contlint 集成的 AI 动力Contizen 适配器

## 安装

```sh
npm install @elsikora/commitizen-plugin-commitlint-ai
```

也可以使用：`pnpm add @elsikora/commitizen-plugin-commitlint-ai`、`yarn add @elsikora/commitizen-plugin-commitlint-ai`、`bun add @elsikora/commitizen-plugin-commitlint-ai`

## README

![project-logo](https://6jft62zmy9nx2oea.public.blob.vercel-storage.com/commitizen-plugin-commitlint-ai-5z2uE7Wo3HXxhEkaeQQmNYyl3eWvjM.png)

# \* 提交插件

_变换你的 用 AI 驱动的 Git 工作流程传输符合常规标准的信息, 每次通过 Commontlint 验证_

 [![ElsiKora](https://img.shields.io/badge/MADE%20BY%20ElsiKora-333333.svg?style=for-the-badge)](https://elsikora.com/)![TypeScript](https://img.shields.io/badge/TypeScript-3178C6.svg?style=for-the-badge&logo=typescript&logoColor=white) ![Node.js](https://img.shields.io/badge/Node.js-339933.svg?style=for-the-badge&logo=node.js&logoColor=white) ![npm](https://img.shields.io/badge/npm-CB3837.svg?style=for-the-badge&logo=npm&logoColor=white) ![Git](https://img.shields.io/badge/Git-F05032.svg?style=for-the-badge&logo=git&logoColor=white) ![OpenAI](https://img.shields.io/badge/OpenAI-412991.svg?style=for-the-badge&logo=openai&logoColor=white) ![ESLint](https://img.shields.io/badge/ESLint-4B32C3.svg?style=for-the-badge&logo=eslint&logoColor=white) ![Prettier](https://img.shields.io/badge/Prettier-F7B93E.svg?style=for-the-badge&logo=prettier&logoColor=black) ![Vitest](https://img.shields.io/badge/Vitest-6E9F18.svg?style=for-the-badge&logo=vitest&logoColor=white) ![Rollup](https://img.shields.io/badge/Rollup-EC4A3F.svg?style=for-the-badge&logo=rollup&logoColor=white)

## 目录

-   [说明](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--description)
-   [特征](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--features)
-   [安装](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--installation)
-   [使用量](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--usage)
-   [路线图](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--roadmap)
-   [财务问题](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--faq)
-   [许可证](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/#readme--license)

## 说明

Commiteden 插件 Contlint AI通过将人工智能的力量与严格的常规承诺标准相结合,使开发者撰写消息的方式发生革命化. 这个插件以干净的建筑原理为基础, 与您现有的Comtizen工作流程无缝地融合, 生成有意义的, 具有上下文意识的信息, 以遵守您的项目 Cottlint 规则 .

无论是在独奏项目上工作,还是在大型团队中合作,这个工具都消除了在保持连贯,高品质的吉特历史的同时,巧妙地完成承诺信息的制作的认知上浮. 提供者访问、模型目录、证书分辨率和运行时间生成通过集中 `@elsikora/ai-core`。 。 。 .

插件明智地分析您的已上演的修改,理解您的修改的背景,并生成不仅遵循常规格式,而且为修改提供了有意义的描述的传输消息. 通过自动验证和智能重试机制,它确保每个承诺信息都符合您项目的标准.

## \* 特性

-   ✨ **🤖 **AI 权力生成** - 利用AI-Core供应商和模型目录,以创建与背景相关的承诺信息**
-   ✨ **✅ **Cotlint 整合** - 自动验证和修正消息,以遵守项目中的Comtlint规则**
-   ✨ **🔄 **智能重试机制** - 明智地进行再造和验证,进行可塑尝试**
-   ✨ **🎯 **清洁建筑** - 以SOLID原则、依赖性注射和明确区分关切为基础**
-   ✨ **🌐 **多服务支持** - 选择任何被曝光的提供者 `@elsikora/ai-core`,包括OpenAI,Anthropic,Google,Azure,AWS Bedrock, Cerebras,Vercel AI Gateway,或本地Ollama模型**
-   ✨ **🛡️ **类型安全** - 用TypeScript完全打入,以提高开发者的经验和可靠性**
-   ✨ **⚡ **弹性配置** - 通过 JSON、YAML 或 JavaScript 支持简单设置**
-   ✨ **🔐 **安全 API 密钥处理** - 环境变量支持,采用基于会话的关键输入选项**
-   ✨ **📝 **手动模式倒置** - 必要时无缝地切换到指南手册输入**
-   ✨ **🚀 **中断更改检测** - 自动识别和记录更改**

## \* 安装

```bash
# Install the plugin as a dev dependency
npm install --save-dev @elsikora/commitizen-plugin-commitlint-ai

# Initialize Commitizen with this adapter
npx commitizen init @elsikora/commitizen-plugin-commitlint-ai --save-dev --save-exact

# Install Commitlint (if not already installed)
npm install --save-dev @commitlint/cli @commitlint/config-conventional

# Create a commitlint config file
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
```

## 使用量

## 基本用途

### 快速启动

```bash
# Stage your changes
git add .

# Run the AI-powered commit wizard
git cz
# or
npm run commit
```

### 配置方法

插件支持多种配置方法 :

#### 1\. 环境变量(建议)

全权证书由AI-Core解决. 为选定的提供者使用环境变量 :

```bash
# .env file
OPENAI_API_KEY=sk-...
# or
ANTHROPIC_API_KEY=sk-ant-...
# or
GOOGLE_API_KEY=AIza...
# or (Azure OpenAI)
AZURE_OPENAI_API_KEY=https://your-resource.openai.azure.com|your-api-key|your-deployment-name
# or (AWS Bedrock)
AWS_BEDROCK_API_KEY=us-east-1|access-key-id|secret-access-key
# or (Ollama)
OLLAMA_API_KEY=localhost:11434|llama3.2
# or (Cerebras)
CEREBRAS_API_KEY=...
# or (Vercel AI Gateway)
AI_GATEWAY_API_KEY=...
```

#### 2\. 配置文件

AI 提供者/模型配置在 `.elsikora/ai-core.config.js`数字 :

```javascript
export default {
    modules: {
        "commitlint-plugin-commitlint-ai": {
            provider: "openai",
            model: "gpt-4o",
            retries: 3,
            validationRetries: 3,
        },
    },
};
```

提交模式和取票设置 `.elsikora/commitlint-ai.config.js`数字 :

```javascript
export default {
    mode: "auto",
    maxRetries: 3,
    validationMaxRetries: 3,
    ticket: {
        // auto | branch-lint | pattern | none
        source: "auto",
        // Used in "pattern" mode, and as fallback when configured
        pattern: "[a-z]{2,}-[0-9]+",
        patternFlags: "i",
        // preserve | lower | upper
        normalization: "preserve",
        // fallback | error (only for source: "branch-lint")
        missingBranchLintBehavior: "fallback",
    },
};
```

#### 出票源配置

您可以控制从哪里提取出票证 :

-   `source: "branch-lint"` - 分析票从 `git-branch-lint` 模板 (`branch-pattern`(中文(简体) )
-   `source: "pattern"` - 当地regex的票价(`ticket.pattern`(中文(简体) )
-   `source: "auto"` -试试看 `git-branch-lint` 首先,然后回到本地正则
-   `source: "none"` - 完全禁止取票

使用时 `source: "branch-lint"` 且没有分支林特配置 :

-   `missingBranchLintBehavior: "fallback"` - 回归当地监管
-   `missingBranchLintBehavior: "error"` - 扔出一个错误并停止

#### 3\. 软件包.json

```json
{
    "elsikora": {
        "commitlint-ai": {
            "mode": "auto"
        },
        "ai-core": {
            "modules": {
                "commitlint-plugin-commitlint-ai": {
                    "provider": "anthropic",
                    "model": "claude-sonnet-4-5"
                }
            }
        }
    }
}
```

### 提交模式

#### 自动模式( AI- Powered)

AI分析您的更改并生成适当的承诺消息:

```bash
$ git cz
✔ Using AI-powered commit mode...
✔ AI generated initial commit message
✔ AI generated commit message successfully!

┌─────────────────────────────────┐
│ Generated commit message:        │
├─────────────────────────────────┤
│ feat(auth): implement OAuth2    │
│                                 │
│ Added OAuth2 authentication     │
│ flow with JWT token support.    │
│ Includes refresh token logic    │
│ and secure session management.  │
│                                 │
│ BREAKING CHANGE: Auth API       │
│ endpoints have been updated     │
└─────────────────────────────────┘

✔ Do you want to proceed with this commit message? (Y/n)
```

#### 手动模式

以验证方式输入信件创建 :

```bash
$ git cz
✔ Using manual commit mode...
? Select commit type: (Use arrow keys)
❯ feat: A new feature ✨
  fix: A bug fix 🐛
  docs: Documentation only changes 📚
  style: Code style changes 🎨
  refactor: Code refactoring 📦
  perf: Performance improvements 🚀
  test: Adding tests 🚨

? Enter scope (optional): auth
? Enter commit subject: add login functionality
? Enter commit body (optional):
? Is this a breaking change? No
```

### 高级特性

#### 重试配置

```javascript
export default {
    maxRetries: 5, // AI generation retries
    validationMaxRetries: 3, // Validation fix attempts
};
```

#### 提供者特定设置

**Azure OpenAI : (英语)**

```bash
AZURE_OPENAI_API_KEY=https://myresource.openai.azure.com|api-key|gpt-4-deployment
```

**AWS 贝德洛克:**

```bash
AWS_BEDROCK_API_KEY=us-west-2|AKIAIOSFODNN7EXAMPLE|wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```

**奥拉马(当地雇员):**

```bash
# Default setup
OLLAMA_API_KEY=localhost:11434

# Custom model
OLLAMA_API_KEY=localhost:11434|codellama
```

### Cotlint 整合

插件尊重您的全部 Cotlint 规则 :

```javascript
// commitlint.config.js
export default {
    extends: ["@commitlint/config-conventional"],
    rules: {
        "type-enum": [2, "always", ["feat", "fix", "docs", "style", "refactor"]],
        "scope-case": [2, "always", "lower-case"],
        "subject-max-length": [2, "always", 72],
        "body-max-line-length": [2, "always", 100],
    },
};
```

### 解决问题

#### 强制手册模式

```bash
# Create manual mode marker
mkdir -p .elsikora
touch .elsikora/manual
```

#### 清除配置缓存

```bash
rm -rf .elsikora/commitlint-ai.config.*
rm -rf .elsikora/ai-core.config.*
```

## \* 路线图

| 任务/ 特性 | 状态 |
| --- | --- |
| 核心AI动力承诺生成 | 完毕 |
| 通过AI-Core提供的多供应商支助 | 完毕 |
| Countlint 规则集成 | 完毕 |
| 清洁建筑的实施 | 完毕 |
| 自动验证和修复 | 完毕 |
| 环境变量支持 | 完毕 |
| Cosmiconfig 整合 | 完毕 |
| 交互式模式切换 | 完毕 |
| 破解更改检测 | 完毕 |
| AWS 贝德洛克和 Azure OpenAI 支持 | 完毕 |
| 本地 Ollama 模型支持 | 完毕 |
| 自定义快捷模板 | 执行中 |
| 多语种承诺信息 | 执行中 |
| Git 钩子集成 | 执行中 |
| VS 代码扩展 | 执行中 |
| 团队合作特点 | 执行中 |
| 提交信件分析 | 执行中 |
| GitHub 副驾驶集成 | 执行中 |
| 单重机的性能优化 | 执行中 |

## 问 题

**问:支持哪些AI提供者?** 答复:供应商和模型支持来自 `@elsikora/ai-core`目前的AI-Core目录包括OpenAI,Anthropic,Google,Azure OpenAI,AWS Bedrock,Cerebras,Vercel AI Gateway,以及当地Ollama模型.

**问:AI如何理解我的代码变化?** 答:插件分析您的 git diff, 设置文件, 文件路径以了解上下文 。 然后,它利用这些信息以及您的 Countlint 规则生成适当的常规承诺信息 .

**问:我的密码是发给人工智能服务的吗?** 答:只发送了git diff和文件名以生成准确的承诺消息. 完整源代码文件除非在diff中出现,否则不会传输. 对于敏感项目,考虑使用Ollama进行本地处理.

**问:如果人工智能服务不可用,怎么办?** A:插件具有可配置的重试机制,实时状态更新. 如果全部重试失败, 它会自动回到引导手动模式, 确保您总是可以创建承诺 .

**问:我可以自定义承诺消息格式吗?** 答:对! 插件完全尊重您的Comtlint配置 。 您可以定义自定义类型、范围和规则.

**问:我如何在AI模式和手动模式之间切换?** 答:当你逃跑时 `git cz`中,将提示您选择您的模式。 您也可以在配置中设置默认模式或创建 `.elsikora/manual` 文件为强制手动模式.

**问:存储API密钥安全吗?** 甲:证书分辨率由AI-Core处理. 密钥从提供者环境变量读取或请求用于当前会话,而不存储在Contlint AI配置文件中.

**问:我可以用我现有的Contizen设置吗?** A:当然! 这是其他Contizen适配器的倒置替换. 它与您现有的 Contlint 配置和 Git 工作流程无缝.

**问:出产与验证重试有何不同?** A: 世代重试(`maxRetries`)处理AI服务故障,同时验证重试(`validationMaxRetries`试图修正不通过Contlint规则的承诺信息.

**问曰:用取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取?** A:插件本身是免费和开源的. 需要用你选择的 AI 提供商支付API的使用费,或者使用 Ollama 的免费本地模型.

## 许可证

这个项目的许可证根据 **麻省理工学院执照 - 看 [自由主义](https://npmcn.com/package/%40elsikora/commitizen-plugin-commitlint-ai/LICENSE) 详细文件**。 。 。 .

## 常见问题

### @elsikora/commitizen-plugin-commitlint-ai 是什么？

Contlint 集成的 AI 动力Contizen 适配器

### 如何安装 @elsikora/commitizen-plugin-commitlint-ai？

在项目目录运行 npm install @elsikora/commitizen-plugin-commitlint-ai，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：commitizen（^4\.0\.3）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @elsikora/commitizen-plugin-commitlint-ai 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @elsikora/commitizen-plugin-commitlint-ai 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @elsikora/commitizen-plugin-commitlint-ai 可以商用吗？

@elsikora/commitizen-plugin-commitlint-ai 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @elsikora/commitizen-plugin-commitlint-ai 的下载量有多少？

根据 npm 官方下载统计，@elsikora/commitizen-plugin-commitlint-ai 在 2026/10/14 – 2026/11/12 这 30 天内被下载 12,661 次，日均约 422 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @elsikora/commitizen-plugin-commitlint-ai 还在维护吗？

最新版本 3\.0\.1 发布于 2026/05/21（5 个月前）；至今共发布 38 个版本，其中过去 12 个月发布了 28 个；首次发布于 2025/03/03。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

