@abhaydesu/git-pilot 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -1,104 +1,84 @@
1
1
  <div align="center" display="inline">
2
- <img width="30" height="30" alt="logo" src="./public/logo-pilot.png" />
2
+ <img width="40" height="40" alt="logo" src="./public/logo-dark-new.png" />
3
3
  </div>
4
4
 
5
- # Git Pilot API
5
+ # Git Pilot
6
6
 
7
- This is the backend API server that powers the <a href="https://www.npmjs.com/package/@abhaydesu/git-pilot">`git-pilot`</a> CLI tool. It handles the secure communication with AI models to generate Git commands, commit messages, undo actions, and branch names.
7
+ [![NPM Version](https://img.shields.io/npm/v/@abhaydesu/git-pilot)](https://www.npmjs.com/package/@abhaydesu/git-pilot)
8
8
 
9
- ## ◼️ Purpose
9
+ An AI-powered assistant that lives in your command line to streamline your Git workflow. Never write a commit message or look up a command again.
10
10
 
11
- The primary role of this API is to act as a secure intermediary between the <a href="https://github.com/abhaydesu/git-pilot-cli">`git-pilot-cli` </a> and the AI service (Google Gemini). This architecture ensures that the AI API keys are never exposed on a user's local machine.
11
+ ---
12
12
 
13
- ## ◼️ Technology Stack
13
+ ## The Problem
14
+ Remembering complex commands like interactive rebase can be a pain. Writing well-formatted commit messages is a chore. Git is powerful, but its interface can sometimes get in the way of a fast workflow.
14
15
 
15
- * **Runtime:** Node.js
16
- * **Framework:** Express.js
17
- * **AI Service:** Google Gemini API
18
- * **Deployment:** Vercel
16
+ **Git Pilot** solves this by acting as your intelligent copilot, translating your natural language intent into the exact commands and messages you need.
19
17
 
20
- ## ◼️ API Endpoints
18
+ ## Features
19
+ * **AI-Powered Commit Messages:** Analyzes your staged changes (`git diff`) and generates a perfect commit message following the Conventional Commits specification. Just run `git pilot commit <your_intent>`
20
+ * **Natural Language to Git Command:** Translate plain English requests like "squash the last 3 commits" into the precise Git command. One simple `git pilot run <your_request>`
21
+ * **Magic Undo:** Made a mistake? `git pilot undo` analyzes your recent history and suggests the exact command to reverse your last action.
22
+ * **Intelligent Branching:** Describe your goal, and `git pilot branch` will create a clean, conventional branch name for you.
23
+ * **Interactive & Safe:** Always asks for your confirmation before executing any command. You can also **edit** any AI suggestion to get it just right.
21
24
 
22
- The API exposes the following endpoints:
25
+ ## Installation
26
+ Make sure you have Node.js (v18+) and Git installed. Then, run the following command to install Git Pilot globally:
23
27
 
24
- ### 1. Generate Commit Message
28
+ ```bash
29
+ npm install -g @abhaydesu/git-pilot
30
+ ```
25
31
 
26
- * **Route:** `POST /api/pilot-commit`
27
- * **Description:** Analyzes a Git diff and a user's intent to generate a conventional commit message.
28
- * **Request Body (JSON):**
32
+ ### ◾ Usage
29
33
 
30
- ```json
31
- {
32
- "intent": "string",
33
- "diff": "string"
34
- }
35
- ```
36
- * **Success Response (200 - JSON):**
34
+ #### *Generating a Commit Message*
35
+ Stage your files (git add .), then run git pilot commit. This command analyzes your staged changes and generates a conventional commit message.
37
36
 
38
- ```json
39
- {
40
- "message": "string"
41
- }
42
- ```
37
+ ##### With an Intent
38
+ Provide a brief description of your changes, and the AI will use it to write the commit message.
43
39
 
44
- ### 2. Generate Git Command
40
+ ```Bash
45
41
 
46
- * **Route:** `POST /api/pilot-run`
47
- * **Description:** Translates a user's natural language request into an executable, safe Git command.
48
- * **Request Body (JSON):**
42
+ git pilot commit "add new user profile page"
43
+ ```
49
44
 
50
- ```json
51
- {
52
- "request": "string"
53
- }
54
- ```
55
- * **Success Response (200 - JSON):**
45
+ ##### Without an Intent
46
+ If you don't provide an intent, the AI will analyze the diff of your staged files and generate a message automatically.
56
47
 
57
- ```json
58
- {
59
- "command": "string"
60
- }
61
- ```
48
+ ```Bash
62
49
 
63
- ### 3. Undo Last Action
50
+ git pilot commit
51
+ ```
52
+ After running, you can accept, edit, or abort the suggested commit.
64
53
 
65
- * **Route:** `POST /api/pilot-undo`
66
- * **Description:** Suggests a safe Git command to undo the most recent significant action (merge, rebase, commit).
67
- * **Request Body (JSON):**
68
54
 
69
- ```json
70
- {
71
- "reflog": "string"
72
- }
73
- ```
74
- * **Success Response (200 - JSON):**
55
+ #### *Running a Git Command*
56
+ Run the run command with the task you want to perform. The tool will suggest a command and ask for confirmation.
75
57
 
76
- ```json
77
- {
78
- "command": "string",
79
- "explanation": "string"
80
- }
81
- ```
58
+ ```Bash
82
59
 
83
- ### 4. Generate Branch Name
60
+ git pilot run "cherry-pick the last commit from the main branch"
61
+ ```
84
62
 
85
- * **Route:** `POST /api/pilot-branch`
86
- * **Description:** Converts a natural language description into a conventional, kebab-case Git branch name.
87
- * **Request Body (JSON):**
63
+ #### *Creating a New Branch*
64
+ Describe the purpose of your new branch, and let the AI generate a conventional name.
88
65
 
89
- ```json
90
- {
91
- "description": "string"
92
- }
93
- ```
94
- * **Success Response (200 - JSON):**
66
+ ```Bash
95
67
 
96
- ```json
97
- {
98
- "branchName": "string"
99
- }
100
- ```
68
+ git pilot branch "create a new feature for the auth system"
69
+ ```
101
70
 
102
- ### ◾ Deployment
71
+ #### *Undoing a Mistake*
103
72
 
104
- This API is designed for and deployed on Vercel.
73
+ If you've made a mistake (like a bad commit or merge), this command will analyze your history and suggest the safest way to undo it.
74
+
75
+ ```Bash
76
+
77
+ git pilot undo
78
+ ```
79
+
80
+ ### ◾ How It Works
81
+ Git Pilot is a CLI tool that communicates with a secure backend API. This API uses Google's Gemini models to understand your intent and analyze code, keeping your API keys safe and off your local machine.
82
+
83
+ ### ◾ License
84
+ This project is licensed under the MIT License.
package/index.js CHANGED
@@ -33,8 +33,8 @@ program
33
33
  .command("commit")
34
34
  .description("Generate an AI-powered commit message.")
35
35
  .argument(
36
- "<string>",
37
- 'The user\'s intent for the commit (e.g., "add a new feature")'
36
+ "[intent]",
37
+ 'Optional: The user\'s intent for the commit (e.g., "add a new feature")'
38
38
  )
39
39
  .action(async (intent) => {
40
40
  const spinner = ora("Analyzing your staged changes...").start();
@@ -48,12 +48,25 @@ program
48
48
  process.exit(0);
49
49
  }
50
50
 
51
+ const MAX_PAYLOAD_SIZE = 4 * 1024 * 1024;
52
+ const diffSize = Buffer.byteLength(diff, 'utf8');
53
+ let diffToSend = diff;
54
+
55
+ if (diffSize > MAX_PAYLOAD_SIZE) {
56
+
57
+ const { stdout: diffSummary } = await execa("git", ["diff", "--staged", "--name-status"]);
58
+
59
+ diffToSend = "The staged changes are too large to display the full diff. " +
60
+ "Please generate a commit message based on the user's intent and this summary of changed files:\n\n" +
61
+ diffSummary;
62
+ }
63
+
51
64
  try {
52
65
  spinner.text = "Generating commit message...";
53
66
 
54
67
  const response = await axios.post(
55
68
  API_COMMIT_URL,
56
- { intent, diff },
69
+ { intent, diff: diffToSend },
57
70
  { timeout: 30000 }
58
71
  );
59
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhaydesu/git-pilot",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
Binary file
Binary file