Skip to content

Commit 782b51f

Browse files
committed
update
1 parent 126698e commit 782b51f

4 files changed

Lines changed: 224 additions & 59 deletions

File tree

build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
go fmt ./...
2-
go build -o git-genius ./cmd/genius
2+
CGO_ENABLED=0 go build -o git-genius ./cmd/genius

git-genius

-203 KB
Binary file not shown.

internal/setup/setup.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
package setup
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"os"
67
"path/filepath"
8+
"time"
79

810
"git-genius/internal/config"
911
"git-genius/internal/github"
1012
"git-genius/internal/system"
1113
"git-genius/internal/ui"
1214
)
1315

16+
const debugLogPath = "/home/mohan/coding/gitcli/.cursor/debug-bc08dd.log"
17+
18+
func debugLog(runID, hypothesisID, location, message string, data map[string]interface{}) {
19+
entry := map[string]interface{}{
20+
"sessionId": "bc08dd",
21+
"runId": runID,
22+
"hypothesisId": hypothesisID,
23+
"location": location,
24+
"message": message,
25+
"data": data,
26+
"timestamp": time.Now().UnixMilli(),
27+
}
28+
29+
b, err := json.Marshal(entry)
30+
if err != nil {
31+
return
32+
}
33+
34+
_ = os.MkdirAll(filepath.Dir(debugLogPath), 0700)
35+
f, err := os.OpenFile(debugLogPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
36+
if err != nil {
37+
return
38+
}
39+
defer f.Close()
40+
_, _ = f.Write(append(b, '\n'))
41+
}
42+
1443
/*
1544
Stable Production Setup Flow
1645
- No offline mode
@@ -24,12 +53,27 @@ func Run() {
2453
ui.Header("Git Genius Setup")
2554

2655
cfg := config.Load()
56+
// #region agent log
57+
debugLog("pre-fix", "H1", "internal/setup/setup.go:Run", "setup started", map[string]interface{}{
58+
"initialWorkDir": cfg.WorkDir,
59+
"initialBranch": cfg.Branch,
60+
"initialRemote": cfg.Remote,
61+
})
62+
// #endregion
2763

2864
// STEP 0 — Select project directory
2965
if !selectWorkDir(&cfg) {
66+
// #region agent log
67+
debugLog("pre-fix", "H1", "internal/setup/setup.go:Run", "selectWorkDir returned false", map[string]interface{}{})
68+
// #endregion
3069
return
3170
}
3271
config.Save(cfg)
72+
// #region agent log
73+
debugLog("pre-fix", "H1", "internal/setup/setup.go:Run", "workdir saved", map[string]interface{}{
74+
"savedWorkDir": cfg.WorkDir,
75+
})
76+
// #endregion
3377

3478
// STEP 1 — Ensure git installed
3579
if err := system.EnsureGitInstalled(); err != nil {
@@ -39,8 +83,18 @@ func Run() {
3983

4084
// STEP 2 — Ensure git repo
4185
if !system.EnsureGitRepo() {
86+
// #region agent log
87+
debugLog("pre-fix", "H2", "internal/setup/setup.go:Run", "EnsureGitRepo returned false", map[string]interface{}{
88+
"workDir": cfg.WorkDir,
89+
})
90+
// #endregion
4291
return
4392
}
93+
// #region agent log
94+
debugLog("pre-fix", "H2", "internal/setup/setup.go:Run", "EnsureGitRepo succeeded", map[string]interface{}{
95+
"workDir": cfg.WorkDir,
96+
})
97+
// #endregion
4498

4599
// STEP 3 — Safe directory
46100
system.EnsureSafeDirectory(cfg.WorkDir)
@@ -50,6 +104,11 @@ func Run() {
50104

51105
// STEP 5 — Git identity
52106
if !ensureGitIdentity(cfg.WorkDir) {
107+
// #region agent log
108+
debugLog("pre-fix", "H3", "internal/setup/setup.go:Run", "ensureGitIdentity returned false", map[string]interface{}{
109+
"workDir": cfg.WorkDir,
110+
})
111+
// #endregion
53112
return
54113
}
55114

@@ -58,8 +117,20 @@ func Run() {
58117

59118
// STEP 7 — Repo info
60119
if !setupRepo(&cfg) {
120+
// #region agent log
121+
debugLog("pre-fix", "H4", "internal/setup/setup.go:Run", "setupRepo returned false", map[string]interface{}{
122+
"owner": cfg.Owner,
123+
"repo": cfg.Repo,
124+
})
125+
// #endregion
61126
return
62127
}
128+
// #region agent log
129+
debugLog("pre-fix", "H4", "internal/setup/setup.go:Run", "setupRepo succeeded", map[string]interface{}{
130+
"owner": cfg.Owner,
131+
"repo": cfg.Repo,
132+
})
133+
// #endregion
63134

64135
// STEP 8 — Token
65136
if !setupGitHubToken() {
@@ -71,12 +142,33 @@ func Run() {
71142

72143
// STEP 10 — Configure remote
73144
if err := configureRemote(&cfg); err != nil {
145+
// #region agent log
146+
debugLog("pre-fix", "H5", "internal/setup/setup.go:Run", "configureRemote failed", map[string]interface{}{
147+
"remote": cfg.Remote,
148+
"owner": cfg.Owner,
149+
"repo": cfg.Repo,
150+
"error": err.Error(),
151+
})
152+
// #endregion
74153
ui.Error("Failed to configure git remote")
75154
return
76155
}
156+
// #region agent log
157+
debugLog("pre-fix", "H5", "internal/setup/setup.go:Run", "configureRemote succeeded", map[string]interface{}{
158+
"remote": cfg.Remote,
159+
"owner": cfg.Owner,
160+
"repo": cfg.Repo,
161+
})
162+
// #endregion
77163

78164
// STEP 11 — Optional first push
79165
offerFirstPush(&cfg)
166+
// #region agent log
167+
debugLog("pre-fix", "H5", "internal/setup/setup.go:Run", "offerFirstPush completed", map[string]interface{}{
168+
"remote": cfg.Remote,
169+
"branch": cfg.Branch,
170+
})
171+
// #endregion
80172

81173
config.Save(cfg)
82174

readme.md

Lines changed: 131 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,169 @@
1-
# 🧠 Git Genius
1+
# Git Genius (gitcli)
22

3-
**Git without the "Grit."** Git Genius is a beginner-friendly, interactive CLI tool that helps you manage your repositories **without memorizing commands.**
3+
Beginner-friendly interactive Git assistant for daily workflows, setup, and recovery.
44

55
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
77

8-
---
8+
## What It Solves
99

10-
## 🚀 Why Git Genius?
10+
- Removes command memorization with guided terminal menus
11+
- Handles common Git mistakes with safer defaults and confirmations
12+
- Helps first-time setup for repo, branch, remote, and GitHub token
13+
- Includes health diagnostics via built-in Doctor checks
1114

12-
Git is powerful, but the command-line workflow can be a maze of cryptic flags and accidental "detached HEAD" nightmares. Git Genius acts as your **intelligent navigator**, providing a menu-driven interface that handles the heavy lifting while you focus on your code.
15+
## Features
1316

14-
* **Safe for Beginners:** Built-in guardrails and explicit confirmations.
15-
* **Smart Workflows:** Automated stashing and recovery during pulls.
16-
* **Built-in Doctor:** One-click health checks for your local environment.
17+
- **Daily Git Operations:** push, pull, smart pull, fetch, status
18+
- **Branch and Remote Management:** switch branch and remote safely
19+
- **Recovery Tools:** stash save/list/pop and undo last commit (keep changes)
20+
- **Guided Setup:** configure work dir, repo, branch, remote, identity, token
21+
- **GitHub Linking:** create or link remote repository
22+
- **Doctor:** validates git install, project state, token, remote, repo status
1723

18-
---
24+
## Installation
1925

20-
## 🛠 Installation
26+
### Quick install (recommended)
2127

22-
Get up and running in seconds. This one-liner ensures a fresh installation by clearing previous versions.
28+
```bash
29+
curl -fsSL https://raw.githubusercontent.com/Smthbig/gitcli/main/install.sh | bash
30+
```
31+
32+
Then run:
33+
34+
```bash
35+
git-genius
36+
```
37+
38+
### Fresh reinstall
2339

2440
```bash
25-
# Uninstall old version & Install fresh
2641
curl -fsSL https://raw.githubusercontent.com/Smthbig/gitcli/main/uninstall.sh | bash
2742
curl -fsSL https://raw.githubusercontent.com/Smthbig/gitcli/main/install.sh | bash
43+
```
2844

29-
# Launch the tool
30-
git-genius
45+
### Update to latest version
46+
47+
The installer is update-aware and exits when already up to date.
48+
49+
```bash
50+
curl -fsSL https://raw.githubusercontent.com/Smthbig/gitcli/main/install.sh | bash
51+
```
52+
53+
### Uninstall
54+
55+
```bash
56+
curl -fsSL https://raw.githubusercontent.com/Smthbig/gitcli/main/uninstall.sh | bash
3157
```
3258

33-
---
59+
## Commands
3460

35-
## ✨ Core Features
61+
- Primary command: `git-genius`
62+
- Project/repo name: `gitcli` (this repository)
3663

37-
### 📂 Project & Repo Management
38-
* **Smart Init:** Initialize Git if a repository doesn't exist.
39-
* **Multi-Project Support:** Switch between project directories easily.
40-
* **Safety First:** Destructive actions always require a confirmation.
64+
If you prefer `gitcli` as command, add an alias:
4165

42-
### 🔄 Daily Operations (Simplified)
43-
* **Push/Pull:** Handle remotes with clear, guided prompts.
44-
* **Smart Pull:** Automatically stash -> pull -> pop to prevent merge conflicts on uncommitted work.
45-
* **Branch/Remote Switching:** No more typing long branch names; just select from a list.
66+
```bash
67+
echo "alias gitcli='git-genius'" >> ~/.zshrc
68+
source ~/.zshrc
69+
```
4670

47-
### 🩺 Git Doctor (Health Check)
48-
The Doctor diagnostic tool checks:
49-
- [x] Git installation & Internet connectivity.
50-
- [x] Valid user.name and user.email configuration.
51-
- [x] GitHub Token validation & API status.
52-
- [x] Repository integrity and error log detection.
71+
## In-App "Update" Actions
5372

54-
### ⏪ Recovery Features
55-
* **Stash Manager:** Visually save, list, and restore stashes.
56-
* **Undo Last Commit:** Safely revert your last commit while **keeping your changes** in the workspace.
73+
Git Genius has two update paths inside the app:
5774

58-
---
75+
- **Tools -> Setup / Reconfigure**
76+
- Re-runs complete setup and updates branch/remote/token/workdir settings
77+
- **Tools -> Create / Link GitHub Repository**
78+
- Creates or relinks GitHub repository and updates remote URL
5979

60-
## 🖥 Interface Preview
80+
## Interface Map
6181

62-
Git Genius transforms your terminal into a guided command center:
82+
```text
83+
Main Menu
84+
1) Daily Git Operations
85+
2) Branch / Remote
86+
3) Stash & Undo
87+
4) Tools
88+
5) Help / About
89+
6) Exit
90+
```
91+
92+
```text
93+
Daily Git Operations
94+
1) Push changes (commit + push)
95+
2) Pull changes
96+
3) Smart Pull (auto-stash + pull)
97+
4) Fetch all remotes
98+
5) Git status
99+
6) Back
100+
```
63101

64102
```text
65-
Main Menu:
66-
[1] 📋 Status & Changes
67-
[2] 🚀 Push to Remote
68-
[3] 📥 Smart Pull (Auto-stash)
69-
[4] 🌿 Branch Manager
70-
[5] 🩺 Run Git Doctor (Health Check)
71-
[6] ⚙️ Setup/Configuration
72-
[Q] Exit
103+
Tools
104+
1) Setup / Reconfigure
105+
2) Create / Link GitHub Repository
106+
3) Change Project Directory
107+
4) Doctor (health check)
108+
5) Back
73109
```
74110

75-
---
111+
## Build From Source
112+
113+
Requirements:
114+
115+
- Go 1.21+
116+
- Git installed
117+
118+
Build:
119+
120+
```bash
121+
go fmt ./...
122+
go build -o git-genius ./cmd/genius
123+
./git-genius
124+
```
125+
126+
## Project Design (Codebase Overview)
127+
128+
Your project is modular and cleanly separated by responsibility:
129+
130+
- `cmd/genius/main.go`
131+
- Entry point, runtime safety env setup, app bootstrap
132+
- `internal/menu`
133+
- Top-level interactive navigation and section routing
134+
- `internal/setup`
135+
- First-time setup, reconfiguration, directory changes, GitHub repo linking
136+
- `internal/gitops`
137+
- Daily operations: push/pull/fetch/smart pull/branch/remote/stash/undo
138+
- `internal/doctor`
139+
- System and repository diagnostics
140+
- `internal/system`
141+
- Git command execution, environment checks, runtime helpers
142+
- `internal/github`
143+
- Token persistence and GitHub API interactions
144+
- `internal/config`
145+
- `.git/.genius/config.json` load/save/default behavior
146+
- `internal/ui`
147+
- Terminal prompts, confirmations, rendering, help strings
76148

77-
## 🗺 Roadmap (Future-Ready)
149+
Design strengths:
78150

79-
Git Genius is built with a modular architecture, ready for these upcoming features:
80-
- [ ] History Viewer: A scrollable log of your recent commits.
81-
- [ ] Diff Visualizer: See exactly what changed line-by-line.
82-
- [ ] GitHub API Integration: Create repositories directly from the CLI.
83-
- [ ] CI/CD Helper: Quick-start templates for GitHub Actions.
151+
- Clear separation between UI flow and Git/system logic
152+
- Safe defaults for first-run and restricted environments
153+
- Config-driven operations across multiple working directories
154+
- Good extensibility for future sections/features
84155

85-
---
156+
## Roadmap Ideas
86157

87-
## ⚖️ Disclaimer & License
158+
- Commit history viewer and better log UX
159+
- Rich diff summaries for staged/unstaged changes
160+
- Non-interactive flags for scripting/automation mode
161+
- Optional shell autocompletion for command shortcuts
88162

89-
**Use Responsibly.** Git Genius is a helper tool, not a replacement for Git knowledge. It wraps Git commands to make them approachable, but you are still the captain of your code. Always review actions before confirming.
163+
## License
90164

91-
Distributed under the **MIT License**.
165+
MIT License.
92166

93-
---
167+
## Note
94168

95-
### 💡 Final Note
96-
If you understand Git better after using this tool, **it has done its job.**
169+
Git Genius is a helper layer on top of Git. It improves flow and safety, but understanding core Git concepts is still important.

0 commit comments

Comments
 (0)