@hpreet/gitpilot 0.1.0 β 0.1.2
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 +122 -0
- package/bin/gitpilot.js +6 -0
- package/package.json +2 -2
- package/src/commands/enable-wrapper.js +68 -0
package/README.md
CHANGED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# GitPilot π
|
|
2
|
+
|
|
3
|
+
**AI-powered Git commit assistant** β generate meaningful, concise commit messages effortlessly. Designed to **fit seamlessly into your workflow** while keeping you productive and in control.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## π Features
|
|
8
|
+
|
|
9
|
+
* Generate commit messages with AI (OpenAI by default)
|
|
10
|
+
* Supports **local LLMs** (Ollama, LLaMA, etc.)
|
|
11
|
+
* Interactive mode: approve or edit AI-generated messages
|
|
12
|
+
* Optional **Git wrapper mode** (`git commit -ai`)
|
|
13
|
+
* Minimal setup: works out-of-the-box with `gitpilot setup`
|
|
14
|
+
* Configurable via **`~/.gitpilotrc`** or environment variables
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## β‘ Quick Start
|
|
19
|
+
|
|
20
|
+
### 1. Install GitPilot globally
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @hpreet/git-pilot
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 2. Setup your AI provider
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
gitpilot setup
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
* Follow the prompts:
|
|
33
|
+
|
|
34
|
+
* Choose provider (OpenAI or local LLM)
|
|
35
|
+
* Enter your API key if needed
|
|
36
|
+
* This creates your `~/.gitpilotrc` with defaults
|
|
37
|
+
|
|
38
|
+
### 3. Stage your changes
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
git add .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 4. Generate a commit message automatically
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
gitpilot commit
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
* The AI will suggest a commit message
|
|
51
|
+
* You can approve or edit it (interactive mode)
|
|
52
|
+
|
|
53
|
+
### 5. Optional: provide your own message
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
gitpilot commit -m "Your commit message here"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 6. Advanced: Git wrapper mode
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git commit -ai
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
* Uses GitPilot as a drop-in replacement for `git commit`
|
|
66
|
+
* Only enable if youβre comfortable replacing Git binary
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## β Configuration
|
|
71
|
+
|
|
72
|
+
GitPilot stores user preferences in:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
~/.gitpilotrc
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"provider": "openai",
|
|
83
|
+
"apiKey": "YOUR_API_KEY_HERE",
|
|
84
|
+
"defaultCommitStyle": "concise"
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You can override settings using environment variables:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
export GITPILOT_API_KEY="YOUR_API_KEY"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## π§ Supported Providers
|
|
97
|
+
|
|
98
|
+
* **OpenAI** (default)
|
|
99
|
+
* **Local LLMs** (stub included; future support for Claude, GPT-4 local models)
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## π Contribution
|
|
104
|
+
|
|
105
|
+
GitPilot is open source!
|
|
106
|
+
|
|
107
|
+
* Report issues, suggest features, or contribute via PRs
|
|
108
|
+
* Code style: ESLint + Prettier
|
|
109
|
+
* Follow standard Git workflow: `git clone`, `npm install`, `npm link`
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## π License
|
|
114
|
+
|
|
115
|
+
MIT Β© Harpreet Singh
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## π¬ Contact
|
|
120
|
+
|
|
121
|
+
* GitHub: [https://github.com/singhhrpreet/git-pilot](https://github.com/singhhrpreet/git-pilot)
|
|
122
|
+
* Email: [thesinghharpreet@gmail.com](mailto:thesinghharpreet@example.com)
|
package/bin/gitpilot.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { commitCommand } from "../src/commands/commit.js";
|
|
4
4
|
import { setupCommand } from "../src/commands/setup.js";
|
|
5
|
+
import { enableWrapper } from "../src/commands/enable-wrapper.js";
|
|
5
6
|
|
|
6
7
|
const program = new Command();
|
|
7
8
|
|
|
@@ -22,4 +23,9 @@ program
|
|
|
22
23
|
.description("Configure your API provider and keys")
|
|
23
24
|
.action(setupCommand);
|
|
24
25
|
|
|
26
|
+
program
|
|
27
|
+
.command("enable-wrapper")
|
|
28
|
+
.description("Enable gitpilot git wrapper")
|
|
29
|
+
.action(enableWrapper);
|
|
30
|
+
|
|
25
31
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpreet/gitpilot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "AI-powered Git commit assistant β generates commit messages intelligently and fits seamlessly into your workflow.",
|
|
5
5
|
"main": "bin/gitpilot.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@google/generative-ai": "^0.24.1",
|
|
26
26
|
"commander": "^14.0.2",
|
|
27
27
|
"inquirer": "^12.11.1",
|
|
28
|
-
"openai": "^6.9.
|
|
28
|
+
"openai": "^6.9.1",
|
|
29
29
|
"simple-git": "^3.30.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
|
|
6
|
+
export function enableWrapper() {
|
|
7
|
+
const HOME = os.homedir();
|
|
8
|
+
const BIN_DIR = path.join(HOME, 'bin');
|
|
9
|
+
|
|
10
|
+
// 1. Ensure ~/bin exists
|
|
11
|
+
if (!fs.existsSync(BIN_DIR)) {
|
|
12
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
13
|
+
console.log(`Created ${BIN_DIR}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 2. Write git wrapper script
|
|
17
|
+
const wrapperPath = path.join(BIN_DIR, 'git');
|
|
18
|
+
|
|
19
|
+
// Detect platform for wrapper script shebang
|
|
20
|
+
const isWindows = process.platform === 'win32';
|
|
21
|
+
const wrapperScript = isWindows
|
|
22
|
+
? `#!/usr/bin/env bash
|
|
23
|
+
ORIGINAL_GIT="$(which git)"
|
|
24
|
+
if [[ "$1" == "commit" && "$2" == "-ai" ]]; then
|
|
25
|
+
gitpilot commit
|
|
26
|
+
else
|
|
27
|
+
"$ORIGINAL_GIT" "$@"
|
|
28
|
+
fi`
|
|
29
|
+
: `#!/usr/bin/env bash
|
|
30
|
+
ORIGINAL_GIT="$(which git)"
|
|
31
|
+
if [[ "$1" == "commit" && "$2" == "-ai" ]]; then
|
|
32
|
+
gitpilot commit
|
|
33
|
+
else
|
|
34
|
+
"$ORIGINAL_GIT" "$@"
|
|
35
|
+
fi`;
|
|
36
|
+
|
|
37
|
+
fs.writeFileSync(wrapperPath, wrapperScript, { mode: 0o755 });
|
|
38
|
+
console.log(`Installed git wrapper at ${wrapperPath}`);
|
|
39
|
+
|
|
40
|
+
// 3. Detect shell rc file
|
|
41
|
+
let shellRc;
|
|
42
|
+
const userShell = process.env.SHELL || '';
|
|
43
|
+
if (isWindows) {
|
|
44
|
+
// Git Bash / WSL
|
|
45
|
+
shellRc = path.join(HOME, '.bashrc');
|
|
46
|
+
console.log(`Using ${shellRc} for PATH configuration (Git Bash/WSL)`);
|
|
47
|
+
} else if (userShell.includes('zsh')) {
|
|
48
|
+
shellRc = path.join(HOME, '.zshrc');
|
|
49
|
+
} else if (userShell.includes('bash')) {
|
|
50
|
+
shellRc = path.join(HOME, '.bashrc');
|
|
51
|
+
} else {
|
|
52
|
+
shellRc = path.join(HOME, '.profile'); // fallback
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 4. Add ~/bin to PATH if not already present
|
|
56
|
+
const pathLine = `export PATH="$HOME/bin:$PATH"`;
|
|
57
|
+
const rcContent = fs.existsSync(shellRc) ? fs.readFileSync(shellRc, 'utf-8') : '';
|
|
58
|
+
if (!rcContent.includes(pathLine)) {
|
|
59
|
+
fs.appendFileSync(shellRc, `\n# Added by GitPilot enable-wrapper\n${pathLine}\n`);
|
|
60
|
+
console.log(`Added ~/bin to PATH in ${shellRc}`);
|
|
61
|
+
} else {
|
|
62
|
+
console.log(`~/bin is already in PATH in ${shellRc}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log(`\nβ
GitPilot wrapper enabled!`);
|
|
66
|
+
console.log(`Please restart your terminal or run:`);
|
|
67
|
+
console.log(`source ${shellRc}`);
|
|
68
|
+
}
|