@dongowu/git-ai-cli 1.0.21 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +200 -157
  2. package/bin/git-ai.cjs +57 -0
  3. package/install.cjs +107 -0
  4. package/package.json +27 -28
  5. package/.claude/settings.local.json +0 -17
  6. package/CHANGELOG.md +0 -46
  7. package/README_EN.md +0 -264
  8. package/dist/cli.d.ts +0 -3
  9. package/dist/cli.d.ts.map +0 -1
  10. package/dist/cli.js +0 -17
  11. package/dist/cli.js.map +0 -1
  12. package/dist/cli_main.d.ts +0 -2
  13. package/dist/cli_main.d.ts.map +0 -1
  14. package/dist/cli_main.js +0 -255
  15. package/dist/cli_main.js.map +0 -1
  16. package/dist/commands/branch.d.ts +0 -11
  17. package/dist/commands/branch.d.ts.map +0 -1
  18. package/dist/commands/branch.js +0 -279
  19. package/dist/commands/branch.js.map +0 -1
  20. package/dist/commands/commit.d.ts +0 -9
  21. package/dist/commands/commit.d.ts.map +0 -1
  22. package/dist/commands/commit.js +0 -326
  23. package/dist/commands/commit.js.map +0 -1
  24. package/dist/commands/config.d.ts +0 -2
  25. package/dist/commands/config.d.ts.map +0 -1
  26. package/dist/commands/config.js +0 -164
  27. package/dist/commands/config.js.map +0 -1
  28. package/dist/commands/config_manage.d.ts +0 -14
  29. package/dist/commands/config_manage.d.ts.map +0 -1
  30. package/dist/commands/config_manage.js +0 -394
  31. package/dist/commands/config_manage.js.map +0 -1
  32. package/dist/commands/hook.d.ts +0 -5
  33. package/dist/commands/hook.d.ts.map +0 -1
  34. package/dist/commands/hook.js +0 -528
  35. package/dist/commands/hook.js.map +0 -1
  36. package/dist/commands/msg.d.ts +0 -20
  37. package/dist/commands/msg.d.ts.map +0 -1
  38. package/dist/commands/msg.js +0 -148
  39. package/dist/commands/msg.js.map +0 -1
  40. package/dist/commands/pr.d.ts +0 -8
  41. package/dist/commands/pr.d.ts.map +0 -1
  42. package/dist/commands/pr.js +0 -96
  43. package/dist/commands/pr.js.map +0 -1
  44. package/dist/commands/release.d.ts +0 -8
  45. package/dist/commands/release.d.ts.map +0 -1
  46. package/dist/commands/release.js +0 -95
  47. package/dist/commands/release.js.map +0 -1
  48. package/dist/commands/report.d.ts +0 -9
  49. package/dist/commands/report.d.ts.map +0 -1
  50. package/dist/commands/report.js +0 -162
  51. package/dist/commands/report.js.map +0 -1
  52. package/dist/types.d.ts +0 -46
  53. package/dist/types.d.ts.map +0 -1
  54. package/dist/types.js +0 -86
  55. package/dist/types.js.map +0 -1
  56. package/dist/utils/agent.d.ts +0 -5
  57. package/dist/utils/agent.d.ts.map +0 -1
  58. package/dist/utils/agent.js +0 -308
  59. package/dist/utils/agent.js.map +0 -1
  60. package/dist/utils/agent_lite.d.ts +0 -5
  61. package/dist/utils/agent_lite.d.ts.map +0 -1
  62. package/dist/utils/agent_lite.js +0 -263
  63. package/dist/utils/agent_lite.js.map +0 -1
  64. package/dist/utils/ai.d.ts +0 -43
  65. package/dist/utils/ai.d.ts.map +0 -1
  66. package/dist/utils/ai.js +0 -1103
  67. package/dist/utils/ai.js.map +0 -1
  68. package/dist/utils/config.d.ts +0 -11
  69. package/dist/utils/config.d.ts.map +0 -1
  70. package/dist/utils/config.js +0 -239
  71. package/dist/utils/config.js.map +0 -1
  72. package/dist/utils/git.d.ts +0 -42
  73. package/dist/utils/git.d.ts.map +0 -1
  74. package/dist/utils/git.js +0 -456
  75. package/dist/utils/git.js.map +0 -1
  76. package/dist/utils/update.d.ts +0 -4
  77. package/dist/utils/update.d.ts.map +0 -1
  78. package/dist/utils/update.js +0 -122
  79. package/dist/utils/update.js.map +0 -1
  80. package/release_notes.md +0 -9
  81. package/scripts/release.sh +0 -34
  82. package/test_agent_feature.ts +0 -1
package/package.json CHANGED
@@ -1,23 +1,18 @@
1
1
  {
2
2
  "name": "@dongowu/git-ai-cli",
3
- "version": "1.0.21",
4
- "description": "Fast, privacy-first, bring-your-own-model Git commit message generator",
5
- "type": "module",
6
- "main": "dist/cli.js",
3
+ "version": "2.0.1",
4
+ "description": "Generate git commit messages using AI - Rust Edition",
5
+ "main": "bin/git-ai.cjs",
7
6
  "bin": {
8
- "git-ai": "dist/cli.js"
7
+ "git-ai": "bin/git-ai.cjs"
9
8
  },
10
9
  "scripts": {
11
- "build": "tsc",
12
- "dev": "tsc --watch",
13
- "start": "NODE_NO_WARNINGS=1 node dist/cli.js",
14
- "prepublishOnly": "npm run build",
10
+ "postinstall": "node install.cjs",
11
+ "build:rust": "cargo build --release",
12
+ "test": "cargo test",
15
13
  "release": "npm version patch && git push --follow-tags",
16
14
  "release:minor": "npm version minor && git push --follow-tags",
17
- "release:major": "npm version major && git push --follow-tags",
18
- "tag": "npm version patch && git push && git push --tags",
19
- "tag:minor": "npm version minor && git push && git push --tags",
20
- "tag:major": "npm version major && git push && git push --tags"
15
+ "release:major": "npm version major && git push --follow-tags"
21
16
  },
22
17
  "keywords": [
23
18
  "git",
@@ -27,27 +22,31 @@
27
22
  "openai",
28
23
  "deepseek",
29
24
  "ollama",
25
+ "rust",
30
26
  "style-learning",
31
27
  "git-hook",
32
28
  "productivity"
33
29
  ],
34
- "author": "",
30
+ "author": "dongowu <dongowu@gmail.com>",
35
31
  "license": "MIT",
36
- "engines": {
37
- "node": ">=18.0.0"
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/dongowu/git-ai-cli"
38
35
  },
39
- "dependencies": {
40
- "cac": "^6.7.14",
41
- "chalk": "^5.3.0",
42
- "conf": "^12.0.0",
43
- "execa": "^8.0.1",
44
- "inquirer": "^9.2.12",
45
- "openai": "^4.28.0",
46
- "ora": "^8.0.1"
36
+ "engines": {
37
+ "node": ">=14.0.0"
47
38
  },
48
- "devDependencies": {
49
- "@types/inquirer": "^9.0.7",
50
- "@types/node": "^20.11.0",
51
- "typescript": "^5.3.3"
39
+ "files": [
40
+ "bin/git-ai.cjs",
41
+ "install.cjs",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "optionalDependencies": {
46
+ "@dongowu/git-ai-cli-linux-x64": "2.0.1",
47
+ "@dongowu/git-ai-cli-linux-arm64": "2.0.1",
48
+ "@dongowu/git-ai-cli-darwin-x64": "2.0.1",
49
+ "@dongowu/git-ai-cli-darwin-arm64": "2.0.1",
50
+ "@dongowu/git-ai-cli-win32-x64": "2.0.1"
52
51
  }
53
52
  }
@@ -1,17 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(git-ai msg:*)",
5
- "Bash(git-ai hook:*)",
6
- "Bash(npm run build:*)",
7
- "Bash(npm install:*)",
8
- "Bash(node dist/cli.js hook status:*)",
9
- "Bash(node dist/cli.js:*)",
10
- "Bash(git config:*)",
11
- "Bash(git add:*)",
12
- "Bash(where:*)",
13
- "Bash(GIT_EDITOR=\"cat\" git commit:*)",
14
- "Bash(git reset:*)"
15
- ]
16
- }
17
- }
package/CHANGELOG.md DELETED
@@ -1,46 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## [1.1.0] - 2026-01-16
6
-
7
- ### 🚀 Agent & Intelligence (Major Update)
8
-
9
- - **🤖 Agent Mode**: Introduced a powerful Agent Loop capable of using tools.
10
- - **Smart Diff**: No more truncated diffs! If a change is too large, the Agent automatically requests specific file contents to understand the core logic.
11
- - **Impact Analysis**: The Agent can now search the codebase (`git grep`) to find usages of changed functions/APIs, actively looking for potential breaking changes.
12
- - **Auto-Activation**: Automatically triggers Agent Mode when diffs are truncated or when working on critical branches (`release/*`, `hotfix/*`, `main`).
13
- - **cli**: Added `-a, --agent` flag to manually force Agent Mode for deep analysis.
14
-
15
- ### ✨ Features
16
-
17
- - **Git Flow Integration**: Enhanced logic to perform stricter checks on production-bound branches.
18
- - **Hook Stability**: Improved Git Hook performance with "Quiet Agent" mode, ensuring no console noise during `git commit`.
19
-
20
- ### ⚡ Improvements
21
-
22
- - **Reliability**: Better handling of large repositories and massive refactors.
23
-
24
- ---
25
-
26
- ## [1.0.16] - 2026-01-14
27
-
28
- ### ✨ Features
29
-
30
- - **Style Learning**: Automatically analyzes your recent 10 commits to mimic your personal style (emojis, casing, format).
31
- - **Project Config**: Added support for `.git-ai.json` in project root for team-wide configuration.
32
- - **Smart Ignore**: Added support for `.git-aiignore` to exclude specific files from AI analysis.
33
- - **Batch Optimization**: Optimized `git-ai -n <count>` to use a single API request for multiple choices, reducing token usage.
34
-
35
- ### ⚡ Improvements
36
-
37
- - **Performance**: Reduced API latency for multi-choice generation.
38
- - **Docs**: Updated README with comprehensive guides for new features.
39
-
40
- ---
41
-
42
- ## [1.0.15]
43
-
44
- - Initial release of stable features.
45
- - Support for DeepSeek, OpenAI, and Ollama.
46
- - Interactive mode and Git Hook integration.
package/README_EN.md DELETED
@@ -1,264 +0,0 @@
1
- <p align="center">
2
- <h1 align="center">git-ai-cli</h1>
3
- <p align="center">
4
- <strong>🤖 AI-Powered Git Assistant: Commit, Context & Report</strong>
5
- </p>
6
- <p align="center">
7
- 🚀 <strong>DeepSeek</strong> Optimized | 🏠 <strong>Ollama</strong> Privacy First | 🧠 <strong>Context Aware</strong> | 📊 <strong>AI Reports</strong>
8
- </p>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://www.npmjs.com/package/@dongowu/git-ai-cli"><img src="https://img.shields.io/npm/v/@dongowu/git-ai-cli.svg?style=flat-square" alt="npm version"></a>
13
- <a href="https://www.npmjs.com/package/@dongowu/git-ai-cli"><img src="https://img.shields.io/npm/dm/@dongowu/git-ai-cli.svg?style=flat-square" alt="npm downloads"></a>
14
- <a href="https://github.com/dongowu/git-ai-cli/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@dongowu/git-ai-cli.svg?style=flat-square" alt="license"></a>
15
- <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/@dongowu/git-ai-cli.svg?style=flat-square" alt="node version"></a>
16
- </p>
17
-
18
- <p align="center">
19
- <a href="./README.md">中文文档</a> •
20
- <a href="#-quick-start">Quick Start</a> •
21
- <a href="#-usage-guide-recommended">Usage</a> •
22
- <a href="#-configuration">Configuration</a> •
23
- <a href="#-command-reference">Commands</a>
24
- </p>
25
-
26
- ---
27
-
28
- **git-ai-cli** is more than a commit message generator. It understands diffs, enforces team rules, and generates reports, PR descriptions, and release notes.
29
-
30
- ---
31
-
32
- ## 🚀 Quick Start
33
-
34
- ```bash
35
- # 1) Install
36
- npm install -g @dongowu/git-ai-cli
37
-
38
- # 2) Initialize (auto-detect local models or configure API)
39
- git-ai init
40
-
41
- # 3) Use
42
- git add .
43
- git-ai
44
- ```
45
-
46
- ---
47
-
48
- ## ✅ Usage Guide (Recommended)
49
-
50
- 1) **Install & Init**
51
- ```bash
52
- npm install -g @dongowu/git-ai-cli
53
- git-ai init
54
- ```
55
-
56
- 2) **Team config (recommended)**: create `.git-ai.json` in project root
57
- ```json
58
- {
59
- "provider": "deepseek",
60
- "baseUrl": "https://api.deepseek.com/v1",
61
- "model": "deepseek-reasoner",
62
- "agentModel": "deepseek-chat",
63
- "locale": "en",
64
- "enableFooter": false,
65
- "rulesPreset": "conventional",
66
- "fallbackModels": ["deepseek-chat", "qwen-turbo"],
67
- "policy": { "strict": true },
68
- "rules": {
69
- "types": ["feat", "fix", "docs", "refactor", "perf", "test", "chore", "build", "ci"],
70
- "maxSubjectLength": 50,
71
- "requireScope": false,
72
- "issuePattern": "[A-Z]+-\\d+",
73
- "issuePlacement": "footer",
74
- "issueFooterPrefix": "Refs",
75
- "requireIssue": false
76
- },
77
- "branch": {
78
- "types": ["feat", "fix", "docs"],
79
- "pattern": "{type}/{issue?}{name}",
80
- "issueSeparator": "-",
81
- "nameMaxLength": 50
82
- }
83
- }
84
- ```
85
-
86
- 3) **Daily commit**
87
- ```bash
88
- git add .
89
- git-ai
90
- ```
91
-
92
- 4) **Hook (recommended)**
93
- ```bash
94
- git-ai hook install
95
- # Block commit on failure (optional)
96
- GIT_AI_HOOK_STRICT=1 git commit
97
- # Disable fallback message (optional)
98
- GIT_AI_HOOK_FALLBACK=0 git commit
99
- ```
100
-
101
- 5) **Scripts / CI**
102
- ```bash
103
- git-ai msg --json
104
- ```
105
-
106
- 6) **Create branch (interactive)**
107
- ```bash
108
- git-ai branch
109
- ```
110
-
111
- 7) **PR / Release / Report**
112
- ```bash
113
- # PR description
114
- git-ai pr --base main --head HEAD
115
-
116
- # Release notes
117
- git-ai release --from v1.0.0 --to HEAD
118
-
119
- # Weekly report
120
- git-ai report --days 7
121
- ```
122
-
123
- ---
124
-
125
- ## ✨ Features
126
-
127
- - **DeepSeek/Qwen optimized**: intent-focused prompts
128
- - **Local privacy**: Ollama / LM Studio support
129
- - **Context aware**: branch rules, style learning, smart scope
130
- - **Agent mode**: impact analysis for large diffs
131
- - **Team rules**: presets + strict policy
132
- - **Git hooks**: zero-friction commits
133
- - **AI reports**: weekly report / PR / release notes
134
-
135
- ---
136
-
137
- ## ⚙️ Configuration
138
-
139
- ### Project-level config `.git-ai.json`
140
- - `provider / baseUrl / model / agentModel`
141
- - `locale`: `zh` / `en`
142
- - `outputFormat`: `text` / `json`
143
- - `rulesPreset`: `conventional` / `angular` / `minimal`
144
- - `fallbackModels`: fallback list when the primary model fails
145
- - `policy.strict`: block commit when rules are violated
146
- - `rules`: types/scopes/length/issue rules
147
- - `branch`: branch naming rules (types/pattern/length)
148
-
149
- ### Rules & Policy
150
- - `issuePattern`: regex for issue IDs
151
- - `issuePlacement`: `scope | subject | footer`
152
- - `requireIssue`: enforce issue id
153
- - `policy.strict`: block commit when invalid
154
- - `branch.pattern`: branch template (e.g., `{type}/{issue?}{name}`)
155
- - `branch.types`: branch type list
156
- - `branch.issueSeparator`: issue separator (default `-`)
157
- - `branch.nameMaxLength`: max length for name
158
-
159
- ### CLI config
160
- ```bash
161
- # Show effective config
162
- git-ai config get --json
163
-
164
- # Preset / policy / fallback
165
- git-ai config set rulesPreset conventional
166
- git-ai config set policy '{"strict":true}'
167
- git-ai config set fallbackModels "deepseek-chat,qwen-turbo"
168
-
169
- # Rules (JSON or @file)
170
- git-ai config set rules '{"types":["feat","fix"]}'
171
- git-ai config set rules @rules.json --local
172
-
173
- # Branch rules
174
- git-ai config set branch '{"types":["feat","fix"],"pattern":"{type}/{issue?}{name}"}'
175
- ```
176
-
177
- ---
178
-
179
- ## 🛠 Command Reference
180
-
181
- | Command | Description |
182
- |--------|-------------|
183
- | `git-ai init` | Initialize config |
184
- | `git-ai config get/set/describe` | Config management |
185
- | `git-ai` / `git-ai commit` | Interactive commit |
186
- | `git-ai -a` | Agent mode |
187
- | `git-ai msg` | Message only (scripts/hooks) |
188
- | `git-ai branch` | Create branch interactively |
189
- | `git-ai hook install/remove` | Hook management |
190
- | `git-ai report` | Weekly report |
191
- | `git-ai pr` | PR description |
192
- | `git-ai release` | Release notes |
193
-
194
- ---
195
-
196
- ## ⚡ Environment Variables
197
-
198
- - `GIT_AI_PROVIDER` / `GIT_AI_BASE_URL` / `GIT_AI_MODEL` / `GIT_AI_AGENT_MODEL`
199
- - `GIT_AI_API_KEY` (also `DEEPSEEK_API_KEY`, `OPENAI_API_KEY`)
200
- - `GIT_AI_TIMEOUT_MS`
201
- - `GIT_AI_MAX_DIFF_CHARS` / `GIT_AI_MAX_OUTPUT_TOKENS`
202
- - `GIT_AI_RULES_PRESET`
203
- - `GIT_AI_FALLBACK_MODELS`
204
- - `GIT_AI_POLICY_STRICT`
205
- - `GIT_AI_ISSUE_PATTERN` / `GIT_AI_ISSUE_PLACEMENT` / `GIT_AI_REQUIRE_ISSUE`
206
- - `GIT_AI_OUTPUT_FORMAT=json`
207
- - `GIT_AI_MSG_DELIM=<<<GIT_AI_END>>>`
208
- - `GIT_AI_HOOK_STRICT=1` / `GIT_AI_HOOK_FALLBACK=0`
209
- - `GIT_AI_BRANCH_PATTERN` / `GIT_AI_BRANCH_TYPES`
210
- - `GIT_AI_BRANCH_ISSUE_SEPARATOR` / `GIT_AI_BRANCH_NAME_MAXLEN`
211
-
212
- ---
213
-
214
- ## 🧩 Ignore File `.git-aiignore`
215
-
216
- ```text
217
- package-lock.json
218
- dist/
219
- *.min.js
220
- ```
221
-
222
- Also compatible with `.opencommitignore`.
223
-
224
- ---
225
-
226
- ## ❓Troubleshooting
227
-
228
- **1) 401 / Invalid API key**
229
- - `git-ai config get --json --local`
230
- - Check env overrides
231
-
232
- **2) Diff truncated**
233
- - Ignore large files via `.git-aiignore`
234
- - Or set `GIT_AI_MAX_DIFF_CHARS`
235
-
236
- **3) Agent falls back**
237
- - Set `GIT_AI_DEBUG=1` to see reasons
238
-
239
- ---
240
-
241
- ## 🤖 Supported Models
242
-
243
- | Type | Provider | Notes | Setup |
244
- |------|----------|------|-------|
245
- | **Local** | **Ollama** | Offline & private | `git-ai init` auto-detect |
246
- | | **LM Studio** | Good compatibility | Manual URL |
247
- | **CN** | **DeepSeek** | High value | API Key |
248
- | | **Qwen** | Long context | API Key |
249
- | | **Zhipu/Moonshot** | Popular in CN | API Key |
250
- | **Global** | **OpenAI** | Baseline GPT-4o | API Key |
251
-
252
- ---
253
-
254
- ## 📄 License
255
-
256
- [MIT](LICENSE)
257
-
258
- ---
259
-
260
- <p align="center">
261
- Made with ❤️ by git-ai team
262
- <br>
263
- <sub>🤖 Generated by git-ai 🚀</sub>
264
- </p>
package/dist/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- // Suppress punycode deprecation warning (node 21+)
3
- const originalEmit = process.emit;
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- process.emit = function (name, data, ...args) {
6
- if (name === 'warning' &&
7
- typeof data === 'object' &&
8
- data?.name === 'DeprecationWarning' &&
9
- data?.message?.includes('punycode')) {
10
- return false;
11
- }
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- return originalEmit.apply(process, [name, data, ...args]);
14
- };
15
- void import('./cli_main.js');
16
- export {};
17
- //# sourceMappingURL=cli.js.map
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,mDAAmD;AACnD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;AAClC,8DAA8D;AAC9D,OAAO,CAAC,IAAI,GAAG,UAAU,IAAS,EAAE,IAAS,EAAE,GAAG,IAAW;IAC3D,IACE,IAAI,KAAK,SAAS;QAClB,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,EAAE,IAAI,KAAK,oBAAoB;QACnC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,EACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,8DAA8D;IAC9D,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAQ,CAAC,CAAC;AACnE,CAAQ,CAAC;AAET,KAAK,MAAM,CAAC,eAAe,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cli_main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli_main.d.ts","sourceRoot":"","sources":["../src/cli_main.ts"],"names":[],"mappings":""}