Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| Rule( |
| 9 | id="git.not_repository", |
| 10 | tool="git", |
| 11 | title="Not inside a Git repository", |
| 12 | why="The current directory is not part of a Git working tree.", |
| 13 | checks=( |
| 14 | "Are you in the correct project directory?", |
| 15 | "Has `git init` been run for this project?", |
| 16 | ), |
| 17 | fixes=( |
| 18 | "cd into your project root, or run: git init", |
| 19 | ), |
| 20 | patterns=( |
| 21 | Pattern("not a git repository", kind="exact", required=True), |
| 22 | Pattern("fatal:", kind="generic"), |
| 23 | ), |
| 24 | confidence="high", |
| 25 | secondary=("git",), |
| 26 | ), |
| 27 | Rule( |
| 28 | id="git.nothing_to_commit", |
| 29 | tool="git", |
| 30 | title="Nothing to commit", |
| 31 | why="There are no staged or unstaged changes for Git to commit.", |
| 32 | checks=( |
| 33 | "Did you modify any files?", |
| 34 | "Are changes already committed?", |
| 35 | "Are files ignored by .gitignore?", |
| 36 | ), |
| 37 | fixes=( |
| 38 | "git status", |
| 39 | "git add <files> && git commit -m \"message\"", |
| 40 | ), |
| 41 | patterns=( |
| 42 | Pattern("nothing to commit", kind="exact", required=True), |
| 43 | ), |
| 44 | confidence="high", |
| 45 | secondary=("working tree clean", "git"), |
| 46 | ), |
| 47 | Rule( |
| 48 | id="git.merge_conflict", |
| 49 | tool="git", |
| 50 | title="Merge conflict", |
| 51 | why="Git could not automatically merge divergent changes in the same lines.", |
| 52 | checks=( |
| 53 | "Which files are listed as both modified?", |
| 54 | "Have conflict markers (<<<<<<) been resolved?", |
| 55 | ), |
| 56 | fixes=( |
| 57 | "git status", |
| 58 | "Resolve conflicts in the listed files, then: git add <file> && git commit", |
| 59 | ), |
| 60 | patterns=( |
| 61 | Pattern( |
| 62 | r"CONFLICT \(|Automatic merge failed|fix conflicts|Merge conflict", |
| 63 | kind="regex", |
| 64 | required=True, |
| 65 | ), |
| 66 | ), |
| 67 | confidence="high", |
| 68 | secondary=("git",), |
| 69 | ), |
| 70 | Rule( |
| 71 | id="git.non_fast_forward", |
| 72 | tool="git", |
| 73 | title="Non-fast-forward push rejected", |
| 74 | why="The remote branch has commits you do not have locally, so a plain push was refused.", |
| 75 | checks=( |
| 76 | "Have others pushed to this branch?", |
| 77 | "Do you need to pull or rebase first?", |
| 78 | ), |
| 79 | fixes=( |
| 80 | "git pull --rebase", |
| 81 | "Then: git push", |
| 82 | ), |
| 83 | patterns=( |
| 84 | Pattern("non-fast-forward", kind="exact", required=True), |
| 85 | ), |
| 86 | confidence="high", |
| 87 | secondary=("rejected", "failed to push", "git"), |
| 88 | ), |
| 89 | Rule( |
| 90 | id="git.authentication_failed", |
| 91 | tool="git", |
| 92 | title="Git authentication failed", |
| 93 | why="The remote rejected your credentials when fetching or pushing.", |
| 94 | checks=( |
| 95 | "Are your credentials or token still valid?", |
| 96 | "Are you using the correct remote URL (HTTPS vs SSH)?", |
| 97 | "Has 2FA or a personal access token been required?", |
| 98 | ), |
| 99 | fixes=( |
| 100 | "Update credentials via git credential manager or SSH keys", |
| 101 | "For HTTPS: use a personal access token instead of a password", |
| 102 | ), |
| 103 | patterns=( |
| 104 | Pattern( |
| 105 | r"Authentication failed|could not read Username|Invalid username or password|" |
| 106 | r"Permission denied \(publickey\)|fatal: Authentication failed", |
| 107 | kind="regex", |
| 108 | required=True, |
| 109 | ), |
| 110 | ), |
| 111 | confidence="high", |
| 112 | secondary=("git", "remote"), |
| 113 | ), |
| 114 | Rule( |
| 115 | id="git.permission_denied", |
| 116 | tool="git", |
| 117 | title="Git permission denied", |
| 118 | why="Git could not read or write a file or path due to filesystem permissions.", |
| 119 | checks=( |
| 120 | "Do you own the repository files?", |
| 121 | "Is another process locking the files?", |
| 122 | ), |
| 123 | fixes=( |
| 124 | "Check file ownership and permissions on the repository path", |
| 125 | "Avoid running git as root unless the repo is owned by root", |
| 126 | ), |
| 127 | patterns=( |
| 128 | Pattern("Permission denied", kind="exact", required=True), |
| 129 | Pattern("git", kind="tool", required=True), |
| 130 | ), |
| 131 | confidence="medium", |
| 132 | secondary=("unable to", "fatal"), |
| 133 | ), |
| 134 | Rule( |
| 135 | id="git.remote_not_found", |
| 136 | tool="git", |
| 137 | title="Remote repository not found", |
| 138 | why="The remote URL points to a repository that does not exist or you cannot access.", |
| 139 | checks=( |
| 140 | "Is the remote URL correct?", |
| 141 | "Do you have access to this repository?", |
| 142 | "Was the repository renamed or deleted?", |
| 143 | ), |
| 144 | fixes=( |
| 145 | "git remote -v", |
| 146 | "git remote set-url origin <correct-url>", |
| 147 | ), |
| 148 | patterns=( |
| 149 | Pattern( |
| 150 | r"Repository not found|remote: Repository not found|" |
| 151 | r"fatal: repository .+ does not exist", |
| 152 | kind="regex", |
| 153 | required=True, |
| 154 | ), |
| 155 | ), |
| 156 | confidence="high", |
| 157 | secondary=("git",), |
| 158 | ), |
| 159 | Rule( |
| 160 | id="git.detached_head", |
| 161 | tool="git", |
| 162 | title="Detached HEAD state", |
| 163 | why="HEAD points at a commit instead of a branch, so new commits are not on a named branch.", |
| 164 | checks=( |
| 165 | "Did you check out a tag or specific commit?", |
| 166 | "Do you need a branch for your work?", |
| 167 | ), |
| 168 | fixes=( |
| 169 | "git switch -c <new-branch-name>", |
| 170 | "Or return to a branch: git switch main", |
| 171 | ), |
| 172 | patterns=( |
| 173 | Pattern( |
| 174 | r"You are in 'detached HEAD' state|HEAD detached", |
| 175 | kind="regex", |
| 176 | required=True, |
| 177 | ), |
| 178 | ), |
| 179 | confidence="high", |
| 180 | secondary=("git",), |
| 181 | ), |
| 182 | Rule( |
| 183 | id="git.uncommitted_changes", |
| 184 | tool="git", |
| 185 | title="Uncommitted local changes block the operation", |
| 186 | why="Git refused to switch branches or pull because local changes would be overwritten.", |
| 187 | checks=( |
| 188 | "Which files have local modifications?", |
| 189 | "Should you commit, stash, or discard them?", |
| 190 | ), |
| 191 | fixes=( |
| 192 | "git stash", |
| 193 | "Or: git commit -am \"wip\"", |
| 194 | "Then retry the original command", |
| 195 | ), |
| 196 | patterns=( |
| 197 | Pattern( |
| 198 | r"Your local changes .+ would be overwritten|" |
| 199 | r"Please commit your changes or stash them|" |
| 200 | r"uncommitted changes", |
| 201 | kind="regex", |
| 202 | required=True, |
| 203 | ), |
| 204 | ), |
| 205 | confidence="high", |
| 206 | secondary=("git",), |
| 207 | ), |
| 208 | Rule( |
| 209 | id="git.failed_to_push", |
| 210 | tool="git", |
| 211 | title="Failed to push to remote", |
| 212 | why="Git could not update the remote branch (rejected update, network, or permissions).", |
| 213 | checks=( |
| 214 | "Does the remote have newer commits?", |
| 215 | "Do you have push permission?", |
| 216 | "Is the remote reachable?", |
| 217 | ), |
| 218 | fixes=( |
| 219 | "git pull --rebase && git push", |
| 220 | "git remote -v", |
| 221 | ), |
| 222 | patterns=( |
| 223 | Pattern( |
| 224 | r"failed to push|error: failed to push some refs|" |
| 225 | r"Updates were rejected", |
| 226 | kind="regex", |
| 227 | required=True, |
| 228 | ), |
| 229 | ), |
| 230 | confidence="medium", |
| 231 | secondary=("git", "remote"), |
| 232 | ), |
| 233 | Rule( |
| 234 | id="git.branch_already_exists", |
| 235 | tool="git", |
| 236 | title="Branch already exists", |
| 237 | why="A branch with that name already exists locally or remotely.", |
| 238 | checks=( |
| 239 | "Do you want to switch to the existing branch?", |
| 240 | "Should you choose a different name?", |
| 241 | ), |
| 242 | fixes=( |
| 243 | "git switch <branch>", |
| 244 | "Or create with a new name: git switch -c <other-name>", |
| 245 | ), |
| 246 | patterns=( |
| 247 | Pattern( |
| 248 | r"a branch named .+ already exists|fatal: A branch named", |
| 249 | kind="regex", |
| 250 | required=True, |
| 251 | ), |
| 252 | ), |
| 253 | confidence="high", |
| 254 | ), |
| 255 | Rule( |
| 256 | id="git.diverged_branches", |
| 257 | tool="git", |
| 258 | title="Local and remote branches have diverged", |
| 259 | why="Local and remote histories both have unique commits and need a merge or rebase.", |
| 260 | checks=( |
| 261 | "Do you prefer rebase or merge?", |
| 262 | "Have you reviewed the divergent commits?", |
| 263 | ), |
| 264 | fixes=( |
| 265 | "git pull --rebase", |
| 266 | "Or: git pull --no-rebase", |
| 267 | ), |
| 268 | patterns=( |
| 269 | Pattern( |
| 270 | r"have diverged|divergent branches", |
| 271 | kind="regex", |
| 272 | required=True, |
| 273 | ), |
| 274 | ), |
| 275 | confidence="high", |
| 276 | secondary=("git",), |
| 277 | ), |
| 278 | ] |