@hpreet/gitpilot 0.1.1 → 0.1.3

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 CHANGED
@@ -7,6 +7,7 @@
7
7
  ## šŸš€ Features
8
8
 
9
9
  * Generate commit messages with AI (OpenAI by default)
10
+ * Supports hosted providers: **OpenAI**, **Claude**, and **Gemini**
10
11
  * Supports **local LLMs** (Ollama, LLaMA, etc.)
11
12
  * Interactive mode: approve or edit AI-generated messages
12
13
  * Optional **Git wrapper mode** (`git commit -ai`)
@@ -20,7 +21,7 @@
20
21
  ### 1. Install GitPilot globally
21
22
 
22
23
  ```bash
23
- npm install -g @hpreet/git-pilot
24
+ npm install -g @hpreet/gitpilot
24
25
  ```
25
26
 
26
27
  ### 2. Setup your AI provider
@@ -31,7 +32,7 @@ gitpilot setup
31
32
 
32
33
  * Follow the prompts:
33
34
 
34
- * Choose provider (OpenAI or local LLM)
35
+ * Choose provider (OpenAI, Claude, Gemini, or local LLM)
35
36
  * Enter your API key if needed
36
37
  * This creates your `~/.gitpilotrc` with defaults
37
38
 
@@ -96,7 +97,9 @@ export GITPILOT_API_KEY="YOUR_API_KEY"
96
97
  ## šŸ§‰ Supported Providers
97
98
 
98
99
  * **OpenAI** (default)
99
- * **Local LLMs** (stub included; future support for Claude, GPT-4 local models)
100
+ * **Claude**
101
+ * **Gemini**
102
+ * **Local LLMs** (stub included)
100
103
 
101
104
  ---
102
105
 
package/bin/gitpilot.js CHANGED
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
+ import { readFileSync } from "node:fs";
3
4
  import { commitCommand } from "../src/commands/commit.js";
4
5
  import { setupCommand } from "../src/commands/setup.js";
6
+ import { enableWrapper } from "../src/commands/enable-wrapper.js";
5
7
 
6
8
  const program = new Command();
7
9
 
8
10
  program
9
11
  .name("gitpilot")
10
12
  .description("Your AI copilot for git commits")
11
- .version("0.1.0");
13
+ .version(JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version);
12
14
 
13
15
  program
14
16
  .command("commit")
@@ -22,4 +24,9 @@ program
22
24
  .description("Configure your API provider and keys")
23
25
  .action(setupCommand);
24
26
 
27
+ program
28
+ .command("enable-wrapper")
29
+ .description("Enable gitpilot git wrapper")
30
+ .action(enableWrapper);
31
+
25
32
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpreet/gitpilot",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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",
@@ -22,10 +22,11 @@
22
22
  "author": "Harpreet Singh <thesinghharpreet@gmail.com>",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
+ "@anthropic-ai/sdk": "^0.90.0",
25
26
  "@google/generative-ai": "^0.24.1",
26
27
  "commander": "^14.0.2",
27
28
  "inquirer": "^12.11.1",
28
- "openai": "^6.9.0",
29
+ "openai": "^6.9.1",
29
30
  "simple-git": "^3.30.0"
30
31
  }
31
32
  }
@@ -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
+ }
@@ -7,13 +7,16 @@ export async function setupCommand() {
7
7
  type: "list",
8
8
  name: "provider",
9
9
  message: "Choose your AI provider:",
10
- choices: ["openai", "local", "gemini"]
10
+ choices: ["openai", "claude", "gemini", "local"]
11
11
  },
12
12
  {
13
13
  type: "input",
14
14
  name: "apiKey",
15
- message: "Enter your OpenAI/Gemini API key (leave blank for local models):",
16
- when: (answers) => answers.provider === "openai" || answers.provider === "gemini"
15
+ message: "Enter your OpenAI/Claude/Gemini API key (leave blank for local models):",
16
+ when: (answers) =>
17
+ answers.provider === "openai" ||
18
+ answers.provider === "claude" ||
19
+ answers.provider === "gemini"
17
20
  },
18
21
  {
19
22
  type: "list",
@@ -0,0 +1,21 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+
3
+ export class ClaudeProvider {
4
+ constructor(config) {
5
+ this.client = new Anthropic({ apiKey: config.apiKey });
6
+ }
7
+
8
+ async generateCommitMessage(prompt) {
9
+ const message = await this.client.messages.create({
10
+ model: "claude-opus-4-1",
11
+ max_tokens: 256,
12
+ messages: [{ role: "user", content: prompt }]
13
+ });
14
+
15
+ return message.content
16
+ .filter((item) => item.type === "text")
17
+ .map((item) => item.text)
18
+ .join("\n")
19
+ .trim();
20
+ }
21
+ }
@@ -1,11 +1,14 @@
1
1
  import { OpenAIProvider } from "./openaiProvider.js";
2
2
  import { LocalProvider } from "./localProvider.js";
3
3
  import { GeminiProvider } from "./geminiProvider.js";
4
+ import { ClaudeProvider } from "./claudeProvider.js";
4
5
 
5
6
  export function getProvider(name, config) {
6
7
  switch (name) {
7
8
  case "openai":
8
9
  return new OpenAIProvider(config);
10
+ case "claude":
11
+ return new ClaudeProvider(config);
9
12
  case "gemini":
10
13
  return new GeminiProvider(config);
11
14
  case "local":
package/.editorconfig DELETED
@@ -1,22 +0,0 @@
1
- # top-most EditorConfig file
2
- root = true
3
-
4
- [*]
5
- # Use spaces instead of tabs
6
- indent_style = space
7
- # 2 spaces per indent
8
- indent_size = 2
9
- # Trim trailing whitespace on save
10
- trim_trailing_whitespace = true
11
- # Insert final newline at end of file
12
- insert_final_newline = true
13
- # File encoding
14
- charset = utf-8
15
-
16
- [*.md]
17
- # Markdown files usually need trailing whitespace (for line breaks)
18
- trim_trailing_whitespace = false
19
-
20
- [*.json]
21
- # JSON files usually 2-space indentation
22
- indent_size = 2