@gitset-dev/cli 1.0.0 → 1.1.0

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 (3) hide show
  1. package/README.md +158 -1
  2. package/package.json +1 -1
  3. package/src/index.js +28 -7
package/README.md CHANGED
@@ -1 +1,158 @@
1
- # gitset-cli
1
+ # @gitset-dev/cli
2
+
3
+ <div align="center">
4
+ <img src="https://github.com/imprvhub/gitset/blob/main/public/favicon-192.png" alt="Gitset" />
5
+ <br>
6
+ <a href="https://badge.fury.io/js/@gitset-dev%2Fcli">
7
+ <img src="https://img.shields.io/npm/v/@gitset-dev/cli?color=%237BFEF5" alt="npm version" />
8
+ </a>
9
+ <a href="https://opensource.org/licenses/MPL-2.0">
10
+ <img src="https://img.shields.io/badge/License-MPL_2.0-%237BFEF5" alt="License: MPL 2.0" />
11
+ </a>
12
+ <br>
13
+ <br>
14
+ <p><em>Generate commit messages using AI-driven analysis - now with style adaptation!</em></p>
15
+ </div>
16
+
17
+ ## Features
18
+
19
+ - 🤖 AI-powered commit message generation
20
+ - 📝 Semantic commit message formatting
21
+ - 🎨 Personal style adaptation (New!)
22
+ - 🔍 Smart analysis of staged changes
23
+ - 🚀 Fast and lightweight
24
+ - 💻 Cross-platform support
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install -g @gitset-dev/cli
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ 1. Stage your changes:
35
+ ```bash
36
+ git add .
37
+ ```
38
+
39
+ 2. Generate a commit message:
40
+ ```bash
41
+ # Semantic mode (default)
42
+ gitset suggest
43
+
44
+ # Custom style mode
45
+ gitset suggest --mode custom
46
+ ```
47
+
48
+ 3. Review and use the generated message:
49
+ ```bash
50
+ git commit -m "your generated message"
51
+ ```
52
+
53
+ ## Examples
54
+
55
+ ```bash
56
+ # Semantic mode (default)
57
+ $ gitset suggest
58
+ ✨ Suggested message:
59
+ ------------------
60
+ feat: Add user authentication feature with JWT support
61
+
62
+ - Implement JWT token generation and validation
63
+ - Add login and signup endpoints
64
+ - Create middleware for route protection
65
+
66
+ # Custom style mode
67
+ $ gitset suggest --mode custom
68
+ ✨ Suggested message:
69
+ ------------------
70
+ [Auth] Added JWT user authentication 🔐
71
+
72
+ Implemented token system, added login/signup routes,
73
+ and set up protection middleware! Ready for testing.
74
+ ```
75
+
76
+ ## Requirements
77
+
78
+ - Node.js >= 18.0.0
79
+ - Git installed and configured
80
+
81
+ ## Commit Message Modes
82
+
83
+ ### Semantic Mode (Default)
84
+ The default mode follows conventional commit standards to generate structured, semantic commit messages. Perfect for maintaining a clean and standard Git history in professional projects.
85
+
86
+ ### Custom Mode
87
+ Custom mode analyzes your previous commit messages and adapts to your personal writing style:
88
+ - Studies your last commits (default: 20) to understand your patterns
89
+ - Learns from your formatting, tone, and structure
90
+ - Maintains your sequential patterns if you use them
91
+ - Adapts emoji usage based on your style
92
+ - Preserves your capitalization and punctuation preferences
93
+ - Keeps descriptive content while matching your style
94
+
95
+ Example of style adaptation:
96
+ ```bash
97
+ # If your commits look like this:
98
+ FEATURE_123: added login page 🚀
99
+ FEATURE_124: updated navbar design ✨
100
+ FEATURE_125: fixed routing issues 🔧
101
+
102
+ # Custom mode will generate similar style:
103
+ FEATURE_126: implemented user settings 🎯
104
+ ```
105
+
106
+ ## Configuration
107
+
108
+ No additional configuration needed. The CLI automatically detects your Git repository and staged changes.
109
+
110
+ ## API Reference
111
+
112
+ ### Commands
113
+
114
+ - `gitset suggest` - Generate a commit message based on staged changes
115
+
116
+ ### Options
117
+
118
+ - `--mode <mode>` - Choose between 'semantic' (default) or 'custom' style
119
+ - `--commit-count <count>` - Number of previous commits to analyze (default: 20)
120
+ - `--version` - Show CLI version
121
+ - `--help` - Show help information
122
+
123
+ ## Contributing
124
+
125
+ We love your input! We want to make contributing to @gitset-dev/cli as easy and transparent as possible.
126
+
127
+ 1. Fork the repo
128
+ 2. Create your feature branch:
129
+ ```bash
130
+ git checkout -b feature/amazing-feature
131
+ ```
132
+ 3. Commit your changes:
133
+ ```bash
134
+ git commit -m 'feat: Add some amazing feature'
135
+ ```
136
+ 4. Push to the branch:
137
+ ```bash
138
+ git push origin feature/amazing-feature
139
+ ```
140
+ 5. Open a Pull Request
141
+
142
+ ## License
143
+
144
+ This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE.md](LICENSE.md) file for details.
145
+
146
+ ## Support
147
+
148
+ - Email: support@gitset.dev
149
+ - Contact Form: https://gitset.dev/contact
150
+ - Issues: https://github.com/gitset-dev/gitset-cli/issues
151
+
152
+ ## Acknowledgments
153
+
154
+ - Thanks to all our contributors
155
+ - Built with [Commander.js](https://github.com/tj/commander.js)
156
+ - Powered by Google's Gemini Pro
157
+
158
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitset-dev/cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Generate semantic commit messages using AI-driven analysis of staged code changes.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -27,6 +27,19 @@ function log(step, message, isError = false) {
27
27
  console.log(`${prefix} ${colors.reset}[${timestamp}] ${stepColor}${step}${colors.reset}: ${message}`);
28
28
  }
29
29
 
30
+ async function getLastCommits(count = 20) {
31
+ try {
32
+ log('History', `Fetching last ${count} commits...`);
33
+ const { stdout } = await execAsync(`git log -${count} --pretty=format:"%s"`);
34
+ const commits = stdout.split('\n');
35
+ log('History', `✓ Retrieved ${commits.length} commits`);
36
+ return commits;
37
+ } catch (error) {
38
+ log('History', `Error fetching commit history: ${error.message}`, true);
39
+ return [];
40
+ }
41
+ }
42
+
30
43
  async function getGitDiff(file) {
31
44
  try {
32
45
  log('Diff', `Getting differences for ${file}...`);
@@ -80,7 +93,6 @@ async function getRepoInfo() {
80
93
  }
81
94
  }
82
95
 
83
- // Files that should typically be ignored
84
96
  const IGNORED_FILES = [
85
97
  'package-lock.json',
86
98
  'yarn.lock',
@@ -129,9 +141,10 @@ async function getStagedFiles() {
129
141
  }
130
142
  }
131
143
 
132
- async function generateCommitMessage() {
144
+ async function generateCommitMessage(options) {
133
145
  try {
134
146
  log('Start', 'Starting commit message generation process...');
147
+ const { mode = 'semantic', commitCount = 20 } = options;
135
148
 
136
149
  const files = await getStagedFiles();
137
150
  if (files.length === 0) {
@@ -171,14 +184,20 @@ async function generateCommitMessage() {
171
184
  )).filter(change => change !== null);
172
185
 
173
186
  const repoName = await getRepoInfo();
174
- log('API', 'Processing diffs with AI...');
187
+
188
+ const commitHistory = mode === 'custom' ? await getLastCommits(parseInt(commitCount)) : [];
189
+
190
+ log('API', `Processing diffs with AI using ${mode} mode...`);
175
191
  log('NOTE', `The following commit message is a general reference and may not be fully accurate. If it doesn't meet your expectations, try again or suggest improvements here: https://gitset.dev/contact`)
192
+
176
193
  const response = await fetch('https://gitset-commit-messages.vercel.app/generate-commit-message', {
177
194
  method: 'POST',
178
195
  headers: { 'Content-Type': 'application/json' },
179
196
  body: JSON.stringify({
180
197
  repo_name: repoName,
181
- file_changes: fileChanges
198
+ file_changes: fileChanges,
199
+ mode: mode,
200
+ commit_history: commitHistory
182
201
  })
183
202
  });
184
203
 
@@ -208,7 +227,7 @@ async function generateCommitMessage() {
208
227
  return `${colors.bright}${colors.customCyan}${title}${colors.reset}${description ? `\n${colors.darkCyan}${description}${colors.reset}` : ''}`;
209
228
  }
210
229
 
211
- console.log(`${colors.bright}📝 Suggested message:${colors.reset}`);
230
+ console.log(`${colors.bright}📝 Suggested message (${mode} mode):${colors.reset}`);
212
231
  console.log(`${colors.yellow}------------------${colors.reset}`);
213
232
  console.log(formatCommitMessage(commit_message));
214
233
 
@@ -221,11 +240,13 @@ async function generateCommitMessage() {
221
240
  program
222
241
  .name('gitset')
223
242
  .description('Smart AI Docs & Versioning for GitHub Repositories.')
224
- .version('1.0.0');
243
+ .version('1.1.0');
225
244
 
226
245
  program
227
246
  .command('suggest')
228
- .description('Generate semantic commit messages using AI-driven analysis of staged code changes.')
247
+ .description('Generate commit messages using AI-driven analysis of staged code changes.')
248
+ .option('-m, --mode <mode>', 'Commit message mode (semantic or custom)', 'semantic')
249
+ .option('-c, --commit-count <count>', 'Number of previous commits to analyze for custom mode', '20')
229
250
  .action(generateCommitMessage);
230
251
 
231
252
  program.parse();