git-coco 0.22.9 → 0.22.11
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.
- package/README.md +276 -31
- package/dist/index.esm.mjs +52 -8
- package/dist/index.js +52 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,11 +12,20 @@
|
|
|
12
12
|
|
|
13
13
|
Spawned by the dream to automate away the tedium of writing commit messages, `coco` has grown into a multi-facetted git assistant to expedite any developer git workflow.
|
|
14
14
|
|
|
15
|
-
Currently `coco` generates commit messages
|
|
15
|
+
Currently `coco` generates commit messages with **first-class Conventional Commits support**, creates changelogs, summarizes code changes, performs code reviews, and more - with new features being added regularly!
|
|
16
|
+
|
|
17
|
+
**✨ Key Features:**
|
|
18
|
+
|
|
19
|
+
- 🤖 **AI-Powered Commit Messages** - Generate contextual commits from your staged changes
|
|
20
|
+
- 📋 **Conventional Commits** - Full support with automatic validation and formatting
|
|
21
|
+
- 🔧 **Commitlint Integration** - Seamless integration with your existing commitlint configuration
|
|
22
|
+
- 📦 **Package Manager Friendly** - Works with npm, yarn, and pnpm (with automatic compatibility handling)
|
|
23
|
+
- 🛠️ **Robust Error Recovery** - Advanced JSON parsing with automatic repair capabilities
|
|
24
|
+
- 🏠 **Local AI Support** - Run completely offline with Ollama (no API costs, full privacy)
|
|
16
25
|
|
|
17
26
|
## Commands
|
|
18
27
|
|
|
19
|
-
- **`commit`**: generates commit messages based on staged changes.
|
|
28
|
+
- **`commit`**: generates commit messages based on staged changes with intelligent conventional commits support and robust error handling.
|
|
20
29
|
|
|
21
30
|
- **`changelog`**: create changelogs for the current branch or a range of commits.
|
|
22
31
|
|
|
@@ -54,67 +63,190 @@ coco
|
|
|
54
63
|
coco commit
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
#### Commitlint Integration
|
|
66
|
+
#### Conventional Commits & Commitlint Integration
|
|
67
|
+
|
|
68
|
+
`coco` provides first-class support for Conventional Commits with intelligent commitlint integration:
|
|
69
|
+
|
|
70
|
+
**Conventional Commits Support:**
|
|
58
71
|
|
|
59
|
-
|
|
72
|
+
- **Automatic Detection**: Enables conventional commits mode when commitlint config is detected
|
|
73
|
+
- **Smart Formatting**: Generates properly formatted conventional commits (feat, fix, docs, etc.)
|
|
74
|
+
- **Breaking Changes**: Supports breaking change syntax (`feat!:` and `feat(scope)!:`)
|
|
75
|
+
- **Scoped Commits**: Intelligent scope detection and formatting
|
|
76
|
+
- **Robust Parsing**: Advanced JSON parsing with automatic error recovery
|
|
77
|
+
|
|
78
|
+
**Commitlint Integration:**
|
|
60
79
|
|
|
61
80
|
- **Smart Detection**: Automatically finds commitlint config files (`.commitlintrc.*`, `commitlint.config.*`, or `package.json` with commitlint field)
|
|
62
81
|
- **AI-Aware Rules**: Passes your commitlint rules to the AI for better compliance from the start
|
|
63
82
|
- **Automatic Retry**: When validation fails, `coco` automatically retries generation with error feedback (up to 2 attempts)
|
|
83
|
+
- **Package Manager Compatibility**: Works seamlessly with npm, yarn, and pnpm (with automatic fallback for ES module issues)
|
|
64
84
|
- **User-Friendly Flow**: After auto-retries, offers options to try 2 more times or edit manually
|
|
65
85
|
- **Full Validation**: Both AI-generated and manually edited commit messages are validated against your rules
|
|
66
86
|
|
|
67
|
-
####
|
|
87
|
+
#### Command Options
|
|
88
|
+
|
|
89
|
+
**Basic Options:**
|
|
68
90
|
|
|
69
91
|
```bash
|
|
70
|
-
#
|
|
71
|
-
|
|
92
|
+
# Interactive mode - opens editor for review and editing
|
|
93
|
+
coco -i, --interactive
|
|
94
|
+
|
|
95
|
+
# Verbose output - shows detailed processing information
|
|
96
|
+
coco --verbose
|
|
97
|
+
|
|
98
|
+
# Help - display command help
|
|
99
|
+
coco --help
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Commit Enhancement Options:**
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Add content to the end of the generated commit message
|
|
72
106
|
coco --append "Resolves #128"
|
|
73
107
|
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
coco --append-ticket
|
|
108
|
+
# Automatically append Jira/Linear ticket ID from branch name
|
|
109
|
+
coco -t, --append-ticket
|
|
77
110
|
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
coco --additional "Resolves UX bug with sign up button"
|
|
111
|
+
# Add extra context to guide commit generation
|
|
112
|
+
coco -a, --additional "Resolves UX bug with sign up button"
|
|
81
113
|
|
|
82
|
-
#
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
# Include previous commits for context (specify number)
|
|
115
|
+
coco -p, --with-previous-commits 3
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Conventional Commits Options:**
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Force conventional commits mode
|
|
122
|
+
coco -c, --conventional
|
|
123
|
+
|
|
124
|
+
# Include/exclude branch name in context (default: true)
|
|
125
|
+
coco --include-branch-name
|
|
126
|
+
coco --no-include-branch-name
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Processing Options:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Ignore specific files (can be used multiple times)
|
|
133
|
+
coco --ignored-files "*.lock" --ignored-files "dist/*"
|
|
134
|
+
|
|
135
|
+
# Ignore file extensions (can be used multiple times)
|
|
136
|
+
coco --ignored-extensions ".map" --ignored-extensions ".min.js"
|
|
137
|
+
|
|
138
|
+
# Use basic git status instead of full diff (faster for large changes)
|
|
139
|
+
coco --no-diff
|
|
140
|
+
|
|
141
|
+
# Open commit message in editor before proceeding
|
|
142
|
+
coco --open-in-editor
|
|
85
143
|
```
|
|
86
144
|
|
|
87
145
|
### **`coco changelog`**
|
|
88
146
|
|
|
89
|
-
Creates changelogs.
|
|
147
|
+
Creates changelogs from commit history.
|
|
90
148
|
|
|
91
149
|
```bash
|
|
92
|
-
#
|
|
150
|
+
# Basic changelog for current branch
|
|
93
151
|
coco changelog
|
|
94
152
|
|
|
95
|
-
#
|
|
153
|
+
# Interactive mode
|
|
154
|
+
coco changelog -i, --interactive
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### Changelog Options
|
|
158
|
+
|
|
159
|
+
**Range Selection:**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Specific commit range (HEAD references)
|
|
96
163
|
coco changelog -r HEAD~5:HEAD
|
|
97
164
|
|
|
98
|
-
#
|
|
165
|
+
# Specific commit range (commit hashes)
|
|
99
166
|
coco changelog -r abc1234:def5678
|
|
100
167
|
|
|
101
|
-
#
|
|
102
|
-
coco changelog -b
|
|
168
|
+
# Compare against target branch
|
|
169
|
+
coco changelog -b main, --branch main
|
|
103
170
|
|
|
104
|
-
#
|
|
105
|
-
coco changelog -t
|
|
171
|
+
# All commits since last tag
|
|
172
|
+
coco changelog -t, --since-last-tag
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Content Options:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Include diff for each commit in analysis
|
|
179
|
+
coco changelog --with-diff
|
|
180
|
+
|
|
181
|
+
# Generate changelog based only on branch diff
|
|
182
|
+
coco changelog --only-diff
|
|
183
|
+
|
|
184
|
+
# Include author attribution
|
|
185
|
+
coco changelog --author
|
|
186
|
+
|
|
187
|
+
# Add extra context to guide generation
|
|
188
|
+
coco changelog -a "Focus on user-facing changes" --additional "Focus on user-facing changes"
|
|
106
189
|
```
|
|
107
190
|
|
|
108
191
|
### **`coco recap`**
|
|
109
192
|
|
|
110
|
-
Summarize
|
|
193
|
+
Summarize changes across different time periods.
|
|
111
194
|
|
|
112
195
|
```bash
|
|
113
|
-
# Summarize
|
|
196
|
+
# Summarize current working directory changes
|
|
114
197
|
coco recap
|
|
115
198
|
|
|
116
|
-
#
|
|
117
|
-
coco recap
|
|
199
|
+
# Interactive mode
|
|
200
|
+
coco recap -i, --interactive
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Recap Time Periods
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Yesterday's changes
|
|
207
|
+
coco recap --yesterday
|
|
208
|
+
|
|
209
|
+
# Last week's changes
|
|
210
|
+
coco recap --last-week, --week
|
|
211
|
+
|
|
212
|
+
# Last month's changes
|
|
213
|
+
coco recap --last-month, --month
|
|
214
|
+
|
|
215
|
+
# Changes since last git tag
|
|
216
|
+
coco recap --last-tag, --tag
|
|
217
|
+
|
|
218
|
+
# Current branch changes
|
|
219
|
+
coco recap --current-branch
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### **`coco review`**
|
|
223
|
+
|
|
224
|
+
Perform AI-powered code review on your changes.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Review current working directory changes
|
|
228
|
+
coco review
|
|
229
|
+
|
|
230
|
+
# Interactive mode
|
|
231
|
+
coco review -i, --interactive
|
|
232
|
+
|
|
233
|
+
# Review specific branch
|
|
234
|
+
coco review -b feature-branch, --branch feature-branch
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### **`coco init`**
|
|
238
|
+
|
|
239
|
+
Interactive setup wizard for configuring coco.
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Setup wizard (will prompt for scope)
|
|
243
|
+
coco init
|
|
244
|
+
|
|
245
|
+
# Configure for current project only
|
|
246
|
+
coco init --scope project
|
|
247
|
+
|
|
248
|
+
# Configure globally for current user
|
|
249
|
+
coco init --scope global
|
|
118
250
|
```
|
|
119
251
|
|
|
120
252
|
### Stdout vs. Interactive Mode
|
|
@@ -137,13 +269,126 @@ coco -i
|
|
|
137
269
|
coco -s
|
|
138
270
|
```
|
|
139
271
|
|
|
272
|
+
### **Conventional Commits Examples**
|
|
273
|
+
|
|
274
|
+
`coco` excels at generating properly formatted conventional commits:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Basic conventional commit
|
|
278
|
+
coco --conventional
|
|
279
|
+
# Output: feat: add user authentication system
|
|
280
|
+
|
|
281
|
+
# With scope
|
|
282
|
+
coco --conventional -a 'fixes login timeout'
|
|
283
|
+
# Output: fix(auth): resolve login timeout issue
|
|
284
|
+
|
|
285
|
+
# With additional context and ticket
|
|
286
|
+
coco --conventional --additional "Resolves login issues" --append-ticket
|
|
287
|
+
# Output: feat(auth): add OAuth2 integration
|
|
288
|
+
#
|
|
289
|
+
# Implement OAuth2 flow with Google and GitHub providers.
|
|
290
|
+
# Resolves login issues
|
|
291
|
+
#
|
|
292
|
+
# Part of **PROJ-123**
|
|
293
|
+
```
|
|
294
|
+
|
|
140
295
|
## Configuration
|
|
141
296
|
|
|
142
|
-
|
|
297
|
+
`coco` offers flexible configuration through multiple methods with a clear priority system. See the complete [Configuration Overview](CONFIG_OVERVIEW.md) for detailed setup instructions, all available options, and examples.
|
|
298
|
+
|
|
299
|
+
**Quick Start:**
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Interactive setup wizard
|
|
303
|
+
coco init
|
|
304
|
+
|
|
305
|
+
# Project-specific configuration
|
|
306
|
+
coco init --scope project
|
|
307
|
+
|
|
308
|
+
# Global user configuration
|
|
309
|
+
coco init --scope global
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Configuration Methods (in priority order):**
|
|
313
|
+
|
|
314
|
+
1. Command line flags (highest priority)
|
|
315
|
+
2. Environment variables
|
|
316
|
+
3. Project config (`.coco.config.json`)
|
|
317
|
+
4. Git config (`.gitconfig`)
|
|
318
|
+
5. XDG config directory (lowest priority)
|
|
319
|
+
|
|
320
|
+
**AI Providers:**
|
|
321
|
+
|
|
322
|
+
- **OpenAI**: GPT-4o, GPT-4o-mini, GPT-4 Turbo (API key required)
|
|
323
|
+
- **Anthropic**: Claude 3.5 Sonnet, Claude 3 Haiku (API key required)
|
|
324
|
+
- **Ollama**: Local models, no API costs, full privacy - [Setup Guide](USING_OLLAMA.md)
|
|
325
|
+
|
|
326
|
+
### **Ignoring Files & Extensions**
|
|
327
|
+
|
|
328
|
+
`coco` can ignore specific files and extensions to focus on meaningful changes. See the complete [Ignoring Files & Extensions Guide](IGNORING_FILES_EXTENSIONS.md) for detailed configuration options and examples.
|
|
329
|
+
|
|
330
|
+
**Quick Examples:**
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Command line flags
|
|
334
|
+
coco --ignored-files "*.lock" --ignored-extensions ".map"
|
|
335
|
+
|
|
336
|
+
# Config file
|
|
337
|
+
{
|
|
338
|
+
"ignoredFiles": ["package-lock.json", "dist/*"],
|
|
339
|
+
"ignoredExtensions": [".map", ".min.js"]
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Default Ignores:**
|
|
344
|
+
|
|
345
|
+
- Files: `package-lock.json` + contents of `.gitignore`
|
|
346
|
+
- Extensions: `.map`, `.lock`
|
|
347
|
+
|
|
348
|
+
## Troubleshooting
|
|
349
|
+
|
|
350
|
+
### **pnpm Compatibility**
|
|
351
|
+
|
|
352
|
+
If you encounter ES module errors with pnpm and commitlint:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Update commitlint packages to latest versions
|
|
356
|
+
pnpm add -D @commitlint/config-conventional@latest @commitlint/cli@latest
|
|
357
|
+
|
|
358
|
+
# Or continue without commitlint validation
|
|
359
|
+
# coco will automatically fall back to built-in conventional commit rules
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### **Conventional Commits Issues**
|
|
363
|
+
|
|
364
|
+
- **JSON Parsing Errors**: `coco` automatically repairs common JSON formatting issues from AI responses
|
|
365
|
+
- **Commitlint Validation**: If validation fails, `coco` provides clear error messages and retry options
|
|
366
|
+
- **Missing Dependencies**: `coco` gracefully handles missing commitlint packages with helpful installation guidance
|
|
367
|
+
|
|
368
|
+
## Documentation
|
|
369
|
+
|
|
370
|
+
For comprehensive guides, advanced usage, and detailed configuration options, visit our complete documentation:
|
|
371
|
+
|
|
372
|
+
### 📚 **[Coco Wiki](https://github.com/gfargo/coco/wiki)**
|
|
373
|
+
|
|
374
|
+
**Essential Guides:**
|
|
375
|
+
|
|
376
|
+
- **[Getting Started](https://github.com/gfargo/coco/wiki/Getting-Started)** - Complete beginner's guide from installation to first commit
|
|
377
|
+
- **[Configuration Overview](https://github.com/gfargo/coco/wiki/Config-Overview)** - All configuration options and setup methods
|
|
378
|
+
- **[Team Collaboration](https://github.com/gfargo/coco/wiki/Team-Collaboration)** - Enterprise deployment and team adoption strategies
|
|
379
|
+
- **[Using Ollama](https://github.com/gfargo/coco/wiki/Using-Ollama)** - Local AI setup for privacy and cost control
|
|
380
|
+
|
|
381
|
+
**Advanced Resources:**
|
|
382
|
+
|
|
383
|
+
- **[Advanced Usage](https://github.com/gfargo/coco/wiki/Advanced-Usage)** - Custom prompts, automation, and power-user features
|
|
384
|
+
- **[Troubleshooting](https://github.com/gfargo/coco/wiki/Troubleshooting)** - Solutions for common issues and debugging
|
|
385
|
+
- **[Ignoring Files & Extensions](https://github.com/gfargo/coco/wiki/Ignoring-Files-&-Extensions)** - Advanced file filtering and pattern matching
|
|
143
386
|
|
|
144
|
-
### **
|
|
387
|
+
### 🆘 **Need Help?**
|
|
145
388
|
|
|
146
|
-
|
|
389
|
+
- **[Troubleshooting Guide](https://github.com/gfargo/coco/wiki/Troubleshooting)** - Comprehensive problem-solving resource
|
|
390
|
+
- **[GitHub Issues](https://github.com/gfargo/coco/issues)** - Bug reports and feature requests
|
|
391
|
+
- **[Discord Community](https://discord.gg/KGu9nE9Ejx)** - Real-time help and discussion
|
|
147
392
|
|
|
148
393
|
## Contribution
|
|
149
394
|
|
package/dist/index.esm.mjs
CHANGED
|
@@ -47,7 +47,7 @@ import { pathToFileURL } from 'url';
|
|
|
47
47
|
/**
|
|
48
48
|
* Current build version from package.json
|
|
49
49
|
*/
|
|
50
|
-
const BUILD_VERSION = "0.22.
|
|
50
|
+
const BUILD_VERSION = "0.22.11";
|
|
51
51
|
|
|
52
52
|
const isInteractive = (config) => {
|
|
53
53
|
return config?.mode === 'interactive' || !!config?.interactive;
|
|
@@ -7840,7 +7840,7 @@ var changelog = {
|
|
|
7840
7840
|
options: options$4,
|
|
7841
7841
|
};
|
|
7842
7842
|
|
|
7843
|
-
const conventionalTypeRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))
|
|
7843
|
+
const conventionalTypeRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?!?:/;
|
|
7844
7844
|
// Regular commit message schema with basic validation
|
|
7845
7845
|
const CommitMessageResponseSchema = objectType({
|
|
7846
7846
|
title: stringType().describe("Title of the commit message"),
|
|
@@ -13025,6 +13025,18 @@ function checkCommitlintAvailability() {
|
|
|
13025
13025
|
try {
|
|
13026
13026
|
// Try to resolve the package from the current working directory
|
|
13027
13027
|
require.resolve(pkg, { paths: [process.cwd(), ...module.paths] });
|
|
13028
|
+
// Additional check: try to actually load the config to catch ES module issues
|
|
13029
|
+
try {
|
|
13030
|
+
require(pkg);
|
|
13031
|
+
}
|
|
13032
|
+
catch (loadError) {
|
|
13033
|
+
const loadErrorMessage = loadError instanceof Error ? loadError.message : String(loadError);
|
|
13034
|
+
// If we can resolve but can't load due to ES module issues, treat as missing
|
|
13035
|
+
if (loadErrorMessage.includes('Directory import') ||
|
|
13036
|
+
loadErrorMessage.includes('is not supported resolving ES modules')) {
|
|
13037
|
+
missingPackages.push(pkg);
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13028
13040
|
}
|
|
13029
13041
|
catch (error) {
|
|
13030
13042
|
missingPackages.push(pkg);
|
|
@@ -13039,6 +13051,15 @@ function checkCommitlintAvailability() {
|
|
|
13039
13051
|
missingPackages,
|
|
13040
13052
|
};
|
|
13041
13053
|
}
|
|
13054
|
+
/**
|
|
13055
|
+
* Check if we're in a pnpm environment with ES module issues
|
|
13056
|
+
*/
|
|
13057
|
+
function isPnpmEsModuleIssue(error) {
|
|
13058
|
+
const message = error.message;
|
|
13059
|
+
return (message.includes('Directory import') &&
|
|
13060
|
+
message.includes('is not supported resolving ES modules') &&
|
|
13061
|
+
message.includes('@commitlint/config-conventional'));
|
|
13062
|
+
}
|
|
13042
13063
|
/**
|
|
13043
13064
|
* Load commitlint configuration
|
|
13044
13065
|
*/
|
|
@@ -13085,8 +13106,14 @@ async function loadCommitlintConfig() {
|
|
|
13085
13106
|
});
|
|
13086
13107
|
}
|
|
13087
13108
|
catch (error) {
|
|
13088
|
-
|
|
13089
|
-
|
|
13109
|
+
if (!(error instanceof Error)) {
|
|
13110
|
+
throw error;
|
|
13111
|
+
}
|
|
13112
|
+
// Handle various types of config-conventional loading errors
|
|
13113
|
+
const isConfigConventionalError = error.message.includes('Cannot find module "@commitlint/config-conventional"') ||
|
|
13114
|
+
isPnpmEsModuleIssue(error);
|
|
13115
|
+
if (isConfigConventionalError) {
|
|
13116
|
+
// Return a basic conventional config that matches @commitlint/config-conventional rules
|
|
13090
13117
|
return await load({
|
|
13091
13118
|
rules: {
|
|
13092
13119
|
'header-max-length': [2, 'always', 72],
|
|
@@ -13215,9 +13242,26 @@ async function validateCommitMessage(message, options = {}) {
|
|
|
13215
13242
|
};
|
|
13216
13243
|
}
|
|
13217
13244
|
catch (error) {
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13245
|
+
if (!(error instanceof Error)) {
|
|
13246
|
+
return {
|
|
13247
|
+
valid: false,
|
|
13248
|
+
errors: [String(error)],
|
|
13249
|
+
warnings: [],
|
|
13250
|
+
};
|
|
13251
|
+
}
|
|
13252
|
+
// Check if this is a config-conventional related error (including pnpm ES module issues)
|
|
13253
|
+
const isConfigConventionalError = error.message.includes('Cannot find module "@commitlint/config-conventional"') ||
|
|
13254
|
+
isPnpmEsModuleIssue(error);
|
|
13255
|
+
if (isConfigConventionalError) {
|
|
13256
|
+
// For pnpm ES module issues, we should have already fallen back to built-in rules
|
|
13257
|
+
// during config loading, so this shouldn't happen. But if it does, provide helpful info.
|
|
13258
|
+
if (isPnpmEsModuleIssue(error)) {
|
|
13259
|
+
return {
|
|
13260
|
+
valid: false,
|
|
13261
|
+
errors: ['pnpm ES module compatibility issue with @commitlint/config-conventional'],
|
|
13262
|
+
warnings: ['Try: pnpm add -D @commitlint/config-conventional@latest @commitlint/cli@latest'],
|
|
13263
|
+
};
|
|
13264
|
+
}
|
|
13221
13265
|
return {
|
|
13222
13266
|
valid: false,
|
|
13223
13267
|
errors: ['Commitlint configuration requires @commitlint/config-conventional to be installed'],
|
|
@@ -13227,7 +13271,7 @@ async function validateCommitMessage(message, options = {}) {
|
|
|
13227
13271
|
}
|
|
13228
13272
|
return {
|
|
13229
13273
|
valid: false,
|
|
13230
|
-
errors: [
|
|
13274
|
+
errors: [error.message],
|
|
13231
13275
|
warnings: [],
|
|
13232
13276
|
};
|
|
13233
13277
|
}
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline);
|
|
|
69
69
|
/**
|
|
70
70
|
* Current build version from package.json
|
|
71
71
|
*/
|
|
72
|
-
const BUILD_VERSION = "0.22.
|
|
72
|
+
const BUILD_VERSION = "0.22.11";
|
|
73
73
|
|
|
74
74
|
const isInteractive = (config) => {
|
|
75
75
|
return config?.mode === 'interactive' || !!config?.interactive;
|
|
@@ -7862,7 +7862,7 @@ var changelog = {
|
|
|
7862
7862
|
options: options$4,
|
|
7863
7863
|
};
|
|
7864
7864
|
|
|
7865
|
-
const conventionalTypeRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))
|
|
7865
|
+
const conventionalTypeRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?!?:/;
|
|
7866
7866
|
// Regular commit message schema with basic validation
|
|
7867
7867
|
const CommitMessageResponseSchema = objectType({
|
|
7868
7868
|
title: stringType().describe("Title of the commit message"),
|
|
@@ -13047,6 +13047,18 @@ function checkCommitlintAvailability() {
|
|
|
13047
13047
|
try {
|
|
13048
13048
|
// Try to resolve the package from the current working directory
|
|
13049
13049
|
require.resolve(pkg, { paths: [process.cwd(), ...module.paths] });
|
|
13050
|
+
// Additional check: try to actually load the config to catch ES module issues
|
|
13051
|
+
try {
|
|
13052
|
+
require(pkg);
|
|
13053
|
+
}
|
|
13054
|
+
catch (loadError) {
|
|
13055
|
+
const loadErrorMessage = loadError instanceof Error ? loadError.message : String(loadError);
|
|
13056
|
+
// If we can resolve but can't load due to ES module issues, treat as missing
|
|
13057
|
+
if (loadErrorMessage.includes('Directory import') ||
|
|
13058
|
+
loadErrorMessage.includes('is not supported resolving ES modules')) {
|
|
13059
|
+
missingPackages.push(pkg);
|
|
13060
|
+
}
|
|
13061
|
+
}
|
|
13050
13062
|
}
|
|
13051
13063
|
catch (error) {
|
|
13052
13064
|
missingPackages.push(pkg);
|
|
@@ -13061,6 +13073,15 @@ function checkCommitlintAvailability() {
|
|
|
13061
13073
|
missingPackages,
|
|
13062
13074
|
};
|
|
13063
13075
|
}
|
|
13076
|
+
/**
|
|
13077
|
+
* Check if we're in a pnpm environment with ES module issues
|
|
13078
|
+
*/
|
|
13079
|
+
function isPnpmEsModuleIssue(error) {
|
|
13080
|
+
const message = error.message;
|
|
13081
|
+
return (message.includes('Directory import') &&
|
|
13082
|
+
message.includes('is not supported resolving ES modules') &&
|
|
13083
|
+
message.includes('@commitlint/config-conventional'));
|
|
13084
|
+
}
|
|
13064
13085
|
/**
|
|
13065
13086
|
* Load commitlint configuration
|
|
13066
13087
|
*/
|
|
@@ -13107,8 +13128,14 @@ async function loadCommitlintConfig() {
|
|
|
13107
13128
|
});
|
|
13108
13129
|
}
|
|
13109
13130
|
catch (error) {
|
|
13110
|
-
|
|
13111
|
-
|
|
13131
|
+
if (!(error instanceof Error)) {
|
|
13132
|
+
throw error;
|
|
13133
|
+
}
|
|
13134
|
+
// Handle various types of config-conventional loading errors
|
|
13135
|
+
const isConfigConventionalError = error.message.includes('Cannot find module "@commitlint/config-conventional"') ||
|
|
13136
|
+
isPnpmEsModuleIssue(error);
|
|
13137
|
+
if (isConfigConventionalError) {
|
|
13138
|
+
// Return a basic conventional config that matches @commitlint/config-conventional rules
|
|
13112
13139
|
return await load({
|
|
13113
13140
|
rules: {
|
|
13114
13141
|
'header-max-length': [2, 'always', 72],
|
|
@@ -13237,9 +13264,26 @@ async function validateCommitMessage(message, options = {}) {
|
|
|
13237
13264
|
};
|
|
13238
13265
|
}
|
|
13239
13266
|
catch (error) {
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13267
|
+
if (!(error instanceof Error)) {
|
|
13268
|
+
return {
|
|
13269
|
+
valid: false,
|
|
13270
|
+
errors: [String(error)],
|
|
13271
|
+
warnings: [],
|
|
13272
|
+
};
|
|
13273
|
+
}
|
|
13274
|
+
// Check if this is a config-conventional related error (including pnpm ES module issues)
|
|
13275
|
+
const isConfigConventionalError = error.message.includes('Cannot find module "@commitlint/config-conventional"') ||
|
|
13276
|
+
isPnpmEsModuleIssue(error);
|
|
13277
|
+
if (isConfigConventionalError) {
|
|
13278
|
+
// For pnpm ES module issues, we should have already fallen back to built-in rules
|
|
13279
|
+
// during config loading, so this shouldn't happen. But if it does, provide helpful info.
|
|
13280
|
+
if (isPnpmEsModuleIssue(error)) {
|
|
13281
|
+
return {
|
|
13282
|
+
valid: false,
|
|
13283
|
+
errors: ['pnpm ES module compatibility issue with @commitlint/config-conventional'],
|
|
13284
|
+
warnings: ['Try: pnpm add -D @commitlint/config-conventional@latest @commitlint/cli@latest'],
|
|
13285
|
+
};
|
|
13286
|
+
}
|
|
13243
13287
|
return {
|
|
13244
13288
|
valid: false,
|
|
13245
13289
|
errors: ['Commitlint configuration requires @commitlint/config-conventional to be installed'],
|
|
@@ -13249,7 +13293,7 @@ async function validateCommitMessage(message, options = {}) {
|
|
|
13249
13293
|
}
|
|
13250
13294
|
return {
|
|
13251
13295
|
valid: false,
|
|
13252
|
-
errors: [
|
|
13296
|
+
errors: [error.message],
|
|
13253
13297
|
warnings: [],
|
|
13254
13298
|
};
|
|
13255
13299
|
}
|