whygit 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: whygit
3
+ Version: 0.1.0
4
+ Summary: Explains what state your Git repository is in and how to fix it, in plain English. CLI and MCP server; read-only.
5
+ Keywords: git,education,mcp,cli,merge-conflict,beginners
6
+ Author: Kameswara Sai Srikar Manda
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Education
23
+ Classifier: Topic :: Software Development :: Version Control :: Git
24
+ Requires-Dist: mcp>=2.3,<3
25
+ Requires-Python: >=3.10
26
+ Project-URL: Homepage, https://github.com/Srikarmk/whygit
27
+ Project-URL: Source, https://github.com/Srikarmk/whygit
28
+ Project-URL: Issues, https://github.com/Srikarmk/whygit/issues
29
+ Description-Content-Type: text/markdown
30
+
31
+ # whygit
32
+
33
+ **What just happened to my Git repository, and how do I fix it?**
34
+
35
+ whygit looks at a Git repository and tells you, in plain English, what state it is in and
36
+ which commands will get you out of it: a merge conflict, a rebase stopped halfway, a detached
37
+ HEAD, a rejected push, a login GitHub won't accept, a 120 MB CSV that GitHub will refuse.
38
+ Paste it an error message and it explains that too.
39
+
40
+ It is written for people meeting Git for the first time. Git's own messages are accurate
41
+ but hard to read; whygit turns them into a short explanation and the exact fix.
42
+
43
+ It only ever **reads** your repository. It never runs the fixes it suggests, so you stay in
44
+ control and learn the commands as you go.
45
+
46
+ There are two ways to use it, built on the same engine:
47
+
48
+ - **On the command line**, with no AI tools involved: `whygit`.
49
+ - **As an MCP server**, so an assistant such as Claude Code, Claude Desktop or Cursor gets a
50
+ reliable diagnosis instead of guessing from `git status`.
51
+
52
+ ## Install
53
+
54
+ whygit needs Python 3.10 or newer and Git. Pick one:
55
+
56
+ ```
57
+ uv tool install whygit # with uv (https://docs.astral.sh/uv/)
58
+ pipx install whygit # with pipx
59
+ uvx whygit # run once without installing
60
+ ```
61
+
62
+ This works the same on macOS, Windows and Linux.
63
+
64
+ ## Use it from the terminal
65
+
66
+ Run it inside your project folder:
67
+
68
+ ```
69
+ whygit # what's wrong here, most urgent first
70
+ whygit status # a plain summary: branch, upstream, what's changed
71
+ whygit explain "fatal: refusing to merge unrelated histories"
72
+ git push 2>&1 | whygit explain -
73
+ ```
74
+
75
+ Options: `--path <folder>` (or `-C`) to look at another folder, `--json` for machine-readable
76
+ output, `--no-color` to turn off colour. Colour is only used in a real terminal and never
77
+ when `NO_COLOR` is set.
78
+
79
+ Exit codes: `0` nothing blocking, `1` something blocking was found, `2` bad usage (for example
80
+ the folder does not exist), `3` `explain` did not recognise the message.
81
+
82
+ ### Example
83
+
84
+ ```
85
+ $ whygit
86
+ whygit: /Users/sam/ds3500/hw2 (branch main)
87
+
88
+ [BLOCKING] Merge in progress with conflicts in 1 file
89
+ Git tried to combine two lines of work, but both changed the same part of these
90
+ files, so it stopped and is waiting for you to choose what the result should be.
91
+ Nothing is lost while you decide.
92
+ Conflicted files:
93
+ - analysis.py (both changed)
94
+ How to fix:
95
+ Finish the merge:
96
+ 1. Open each file and find the blocks between <<<<<<< and >>>>>>>. The part
97
+ above ======= is one version, the part below is the other. Keep what you
98
+ want, and delete the three marker lines.
99
+ 2. git add analysis.py
100
+ Marks the files as resolved
101
+ 3. git commit --no-edit
102
+ Records the merge and finishes it
103
+ Or cancel the merge:
104
+ 1. git merge --abort
105
+ Puts everything back the way it was before the merge started
106
+ Learn more: https://git-scm.com/docs/git-merge#_how_to_resolve_conflicts
107
+
108
+ 1 blocking. whygit never runs these commands for you; copy the ones you want.
109
+ ```
110
+
111
+ Commands that can lose work (`git restore`, `git rebase --skip`, `git push --force-with-lease`
112
+ and so on) are always marked with a warning, and a safer option is listed first when one
113
+ exists.
114
+
115
+ ## Use it with an AI assistant (MCP)
116
+
117
+ `whygit mcp` runs a Model Context Protocol server over stdio with three read-only tools:
118
+
119
+ | Tool | Use it when | Returns |
120
+ |---|---|---|
121
+ | `diagnose_repo(path=".")` | something seems stuck or broken | every problem found, most urgent first, with explanation and fix |
122
+ | `explain_git_error(error_text, path=None)` | a git command printed an error | what the error means and the fix, using the repository's state if `path` is given |
123
+ | `explain_state(path=".")` | you want a neutral summary | branch, upstream, ahead/behind, remotes, staged and changed files, operations in progress |
124
+
125
+ Results are small JSON objects. Pass an absolute path: relative paths resolve against the
126
+ server's working directory, which for desktop apps is usually not your project. `~` works.
127
+
128
+ ### Claude Code
129
+
130
+ ```
131
+ claude mcp add --scope user whygit -- uvx whygit mcp
132
+ ```
133
+
134
+ `--scope user` makes it available in every project; leave it out to add it to the current
135
+ project only. Check it with `claude mcp list`.
136
+
137
+ ### Claude Desktop
138
+
139
+ Open Settings > Developer > Edit Config, and add whygit to
140
+ `claude_desktop_config.json` (on macOS `~/Library/Application Support/Claude/`, on Windows
141
+ `%APPDATA%\Claude\`):
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "whygit": {
147
+ "command": "uvx",
148
+ "args": ["whygit", "mcp"]
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ Restart Claude Desktop. If it can't find `uvx`, use the full path that `which uvx` (macOS)
155
+ or `where uvx` (Windows) prints as the `command`.
156
+
157
+ ### Cursor
158
+
159
+ Add the same block to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` in a project:
160
+
161
+ ```json
162
+ {
163
+ "mcpServers": {
164
+ "whygit": {
165
+ "command": "uvx",
166
+ "args": ["whygit", "mcp"]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ If you installed whygit with `uv tool install` or `pipx`, you can use `"command": "whygit"`
173
+ with `"args": ["mcp"]` instead.
174
+
175
+ ## What it recognises
176
+
177
+ Repository states: merge conflicts (and a merge that is resolved but not committed, including
178
+ leftover `<<<<<<<` markers), a rebase stopped on a conflict or an `edit`, cherry-pick, revert,
179
+ `git am` and bisect in progress, detached HEAD (and commits that no branch points to),
180
+ diverged / behind / ahead of the upstream, no upstream yet (the first `git push -u`), no
181
+ remote, upstream branch deleted, no commits yet, not a repository (including being one folder
182
+ too high, and your home folder), a home folder that was accidentally turned into a
183
+ repository, nested repositories (common with downloaded starter code), files over GitHub's
184
+ 100 MB limit (and over 50 MB) staged or in unpushed commits, files that usually hold secrets
185
+ (`.env`, `id_rsa`, `*.pem`, `kaggle.json`, credentials JSON), notebooks with large saved
186
+ outputs, Jupyter notebook conflicts, missing `user.name` / `user.email`, a leftover
187
+ `index.lock`, and folders Git refuses because of "dubious ownership".
188
+
189
+ Error messages: rejected pushes, "You have divergent branches", "refusing to merge unrelated
190
+ histories", GitHub login failures (passwords no longer work; it explains tokens, SSH and
191
+ `gh auth login`, and never asks for your token), `Permission denied (publickey)`, repository
192
+ not found, 403, "Your local changes would be overwritten", untracked files in the way,
193
+ "not a git repository", "src refspec main does not match any", "pathspec did not match",
194
+ "remote origin already exists", missing upstream, "couldn't find remote ref", GitHub's
195
+ large-file rejection (GH001), "detected dubious ownership", "Please tell me who you are",
196
+ `index.lock` exists, line-ending warnings, network errors, and more. If it doesn't recognise
197
+ a message, it says so and shows what it can see in the repository instead.
198
+
199
+ ## The read-only promise
200
+
201
+ whygit never changes your repository, and this is enforced in code rather than left to good
202
+ intentions:
203
+
204
+ - Every Git command goes through a single function that only accepts read-only subcommands
205
+ (`status`, `rev-parse`, `for-each-ref`, `rev-list`, `diff`, `log`, `ls-files`, `cat-file`,
206
+ `config --get`, `remote -v`, ...) and refuses anything else, including the writing forms of
207
+ `config`, `remote` and `symbolic-ref`.
208
+ - It sets `GIT_OPTIONAL_LOCKS=0`, so even `git status` doesn't refresh the index, and turns off
209
+ external diff programs and the fsmonitor hook.
210
+ - It never runs `git fetch`. Ahead/behind counts are "as of your last fetch", and whygit tells
211
+ you to run `git fetch` yourself when that matters.
212
+ - The test suite builds each state in a real repository, snapshots every file under `.git`
213
+ (names, timestamps and contents) before and after diagnosing, and checks nothing changed. It
214
+ also checks that no other module in the package can start a process or write a file.
215
+
216
+ Credentials are never printed: a remote address like `https://name:token@github.com/...`
217
+ is shown as `https://***@github.com/...`, in every output.
218
+
219
+ ## Privacy
220
+
221
+ whygit collects nothing and makes no network calls. It reads your repository on your own
222
+ computer and prints the result. That's all.
223
+
224
+ ## Licence
225
+
226
+ MIT. Copyright (c) 2026 Kameswara Sai Srikar Manda.
@@ -0,0 +1,16 @@
1
+ whygit/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ whygit/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
3
+ whygit/cli.py,sha256=-_u8gS2ltE0CJ6ULJ0lU2cikuRP1Lbx5Shku1wyA6Bs,4373
4
+ whygit/engine.py,sha256=ruvn8IdQSbkjVvr6GPqzBJgnjvbwyn9PY6qRfVTge6Q,7117
5
+ whygit/errors.py,sha256=VcEbQcOaIR7U4nG1Qv8pnSxOjHvj4KKmlg4kBmDaV6w,42286
6
+ whygit/findings.py,sha256=AN-jbDneY8JeepT2A75dCqbAHM4muDY0aIPOg7KYMEg,2673
7
+ whygit/gitcmd.py,sha256=cZ7FUd_OxgY3zIqnTJ79kXxc1JoYTWzE7CYGqRSz9OA,6068
8
+ whygit/render.py,sha256=B62TFQifQAm8WuE61H6KfoB_MAKPe7vFcW8S1flnYgQ,6343
9
+ whygit/rules.py,sha256=_zhAOtZBJQbzffbljnlG16GpXRIX3PnXnHEHVT9tPC4,49841
10
+ whygit/server.py,sha256=JTWRo0EvIVhb69Jy1VwLa1LqX60b0ATiPFeo4B9qD1E,3269
11
+ whygit/state.py,sha256=YqmO978ByCYvokyGe_DkHhqa-8zaEipiOaAHll0D0yI,16842
12
+ whygit-0.1.0.dist-info/licenses/LICENSE,sha256=KbGgOtv_tGSCYXuA_XcavgNuMxNxAOZ3YXtnz2HOKNM,1083
13
+ whygit-0.1.0.dist-info/WHEEL,sha256=9IUYslYuG_asT4WlWvfk_K76nveuLvSTKDoLeL0cV-Q,80
14
+ whygit-0.1.0.dist-info/entry_points.txt,sha256=89gs3R-Sw-62mENz2gTYdT08QZmEF2nf93G5KbP6fO0,44
15
+ whygit-0.1.0.dist-info/METADATA,sha256=7-ZCMYdjb6v3mAXMMJkO9BfFrj94NdFq97XmCncwFfE,9482
16
+ whygit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ whygit = whygit.cli:main
3
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kameswara Sai Srikar Manda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.