gitpanic 1.0.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +258 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +111 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/core.d.ts +20 -0
  8. package/dist/core.d.ts.map +1 -0
  9. package/dist/core.js +55 -0
  10. package/dist/core.js.map +1 -0
  11. package/dist/detectors/index.d.ts +41 -0
  12. package/dist/detectors/index.d.ts.map +1 -0
  13. package/dist/detectors/index.js +258 -0
  14. package/dist/detectors/index.js.map +1 -0
  15. package/dist/git/executor.d.ts +15 -0
  16. package/dist/git/executor.d.ts.map +1 -0
  17. package/dist/git/executor.js +62 -0
  18. package/dist/git/executor.js.map +1 -0
  19. package/dist/git/reflog.d.ts +18 -0
  20. package/dist/git/reflog.d.ts.map +1 -0
  21. package/dist/git/reflog.js +58 -0
  22. package/dist/git/reflog.js.map +1 -0
  23. package/dist/git/status.d.ts +22 -0
  24. package/dist/git/status.d.ts.map +1 -0
  25. package/dist/git/status.js +72 -0
  26. package/dist/git/status.js.map +1 -0
  27. package/dist/recoveries/index.d.ts +50 -0
  28. package/dist/recoveries/index.d.ts.map +1 -0
  29. package/dist/recoveries/index.js +422 -0
  30. package/dist/recoveries/index.js.map +1 -0
  31. package/dist/src/core.d.ts +20 -0
  32. package/dist/src/core.d.ts.map +1 -0
  33. package/dist/src/core.js +55 -0
  34. package/dist/src/core.js.map +1 -0
  35. package/dist/src/detectors/index.d.ts +41 -0
  36. package/dist/src/detectors/index.d.ts.map +1 -0
  37. package/dist/src/detectors/index.js +258 -0
  38. package/dist/src/detectors/index.js.map +1 -0
  39. package/dist/src/git/executor.d.ts +15 -0
  40. package/dist/src/git/executor.d.ts.map +1 -0
  41. package/dist/src/git/executor.js +62 -0
  42. package/dist/src/git/executor.js.map +1 -0
  43. package/dist/src/git/reflog.d.ts +18 -0
  44. package/dist/src/git/reflog.d.ts.map +1 -0
  45. package/dist/src/git/reflog.js +58 -0
  46. package/dist/src/git/reflog.js.map +1 -0
  47. package/dist/src/git/status.d.ts +22 -0
  48. package/dist/src/git/status.d.ts.map +1 -0
  49. package/dist/src/git/status.js +72 -0
  50. package/dist/src/git/status.js.map +1 -0
  51. package/dist/src/recoveries/index.d.ts +50 -0
  52. package/dist/src/recoveries/index.d.ts.map +1 -0
  53. package/dist/src/recoveries/index.js +422 -0
  54. package/dist/src/recoveries/index.js.map +1 -0
  55. package/package.json +42 -0
@@ -0,0 +1,422 @@
1
+ export class BaseRecovery {
2
+ git;
3
+ constructor(git) {
4
+ this.git = git;
5
+ }
6
+ async execute(optionId, disaster, dryRun = false) {
7
+ throw new Error('Not implemented');
8
+ }
9
+ }
10
+ export class DetachedHeadRecovery extends BaseRecovery {
11
+ getOptions(disaster) {
12
+ const { lastBranch, lastBranchSha } = disaster.metadata;
13
+ return [
14
+ {
15
+ id: 'reattach',
16
+ title: 'Reattach to previous branch',
17
+ description: `Switch back to ${lastBranch || 'the last branch'}`,
18
+ riskLevel: 'safe',
19
+ steps: [
20
+ {
21
+ command: `git checkout ${lastBranch || '-'}`,
22
+ description: 'Checkout the branch you were on',
23
+ riskLevel: 'safe'
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ id: 'new-branch',
29
+ title: 'Create new branch from this commit',
30
+ description: 'Save your work as a new branch',
31
+ riskLevel: 'safe',
32
+ steps: [
33
+ {
34
+ command: `git checkout -b fix-$(date +%s)`,
35
+ description: 'Create and checkout a new branch',
36
+ riskLevel: 'safe'
37
+ }
38
+ ]
39
+ }
40
+ ];
41
+ }
42
+ async execute(optionId, disaster, dryRun = false) {
43
+ const { lastBranch } = disaster.metadata;
44
+ if (optionId === 'reattach') {
45
+ const result = await this.git.exec(['checkout', lastBranch || '-'], dryRun);
46
+ return result.code === 0;
47
+ }
48
+ if (optionId === 'new-branch') {
49
+ const timestamp = Math.floor(Date.now() / 1000);
50
+ const branchName = `fix-${timestamp}`;
51
+ const result = await this.git.exec(['checkout', '-b', branchName], dryRun);
52
+ return result.code === 0;
53
+ }
54
+ return false;
55
+ }
56
+ }
57
+ export class DeletedBranchRecovery extends BaseRecovery {
58
+ getOptions(disaster) {
59
+ const { branchName, deletedSha } = disaster.metadata;
60
+ return [
61
+ {
62
+ id: 'restore',
63
+ title: `Restore branch "${branchName}"`,
64
+ description: 'Recreate the branch from the deleted commit',
65
+ riskLevel: 'safe',
66
+ steps: [
67
+ {
68
+ command: `git branch ${branchName} ${deletedSha}`,
69
+ description: `Recreate ${branchName} at the deleted commit`,
70
+ riskLevel: 'safe'
71
+ },
72
+ {
73
+ command: `git checkout ${branchName}`,
74
+ description: 'Switch to the restored branch',
75
+ riskLevel: 'safe'
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ id: 'cherry-pick',
81
+ title: 'Cherry-pick commits to current branch',
82
+ description: 'Move commits from deleted branch to current branch',
83
+ riskLevel: 'medium',
84
+ steps: [
85
+ {
86
+ command: `git cherry-pick ${deletedSha}`,
87
+ description: 'Apply the deleted commit to current branch',
88
+ riskLevel: 'medium'
89
+ }
90
+ ]
91
+ }
92
+ ];
93
+ }
94
+ async execute(optionId, disaster, dryRun = false) {
95
+ const { branchName, deletedSha } = disaster.metadata;
96
+ if (optionId === 'restore') {
97
+ const result1 = await this.git.exec(['branch', branchName, deletedSha], dryRun);
98
+ if (result1.code !== 0)
99
+ return false;
100
+ const result2 = await this.git.exec(['checkout', branchName], dryRun);
101
+ return result2.code === 0;
102
+ }
103
+ if (optionId === 'cherry-pick') {
104
+ const result = await this.git.exec(['cherry-pick', deletedSha], dryRun);
105
+ return result.code === 0;
106
+ }
107
+ return false;
108
+ }
109
+ }
110
+ export class ForcePushRecovery extends BaseRecovery {
111
+ getOptions(disaster) {
112
+ const { branch } = disaster.metadata;
113
+ return [
114
+ {
115
+ id: 'reflog-reset',
116
+ title: 'Reset to pre-force-push state',
117
+ description: 'Use reflog to find the state before force push',
118
+ riskLevel: 'high',
119
+ steps: [
120
+ {
121
+ command: 'git reflog',
122
+ description: 'Review reflog to find the correct commit',
123
+ riskLevel: 'safe'
124
+ },
125
+ {
126
+ command: 'git reset --hard HEAD@{1}',
127
+ description: 'Reset to the state before the force push',
128
+ riskLevel: 'high'
129
+ },
130
+ {
131
+ command: `git push --force-with-lease origin ${branch}`,
132
+ description: 'Force push again with --force-with-lease',
133
+ riskLevel: 'high'
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ id: 'manual-review',
139
+ title: 'Review and cherry-pick manually',
140
+ description: 'Carefully review and restore lost commits',
141
+ riskLevel: 'medium',
142
+ steps: [
143
+ {
144
+ command: 'git reflog',
145
+ description: 'Find the commits that were lost',
146
+ riskLevel: 'safe'
147
+ },
148
+ {
149
+ command: 'git cherry-pick <commit-sha>',
150
+ description: 'Manually cherry-pick needed commits',
151
+ riskLevel: 'medium'
152
+ }
153
+ ]
154
+ }
155
+ ];
156
+ }
157
+ async execute(optionId, disaster, dryRun = false) {
158
+ if (optionId === 'reflog-reset') {
159
+ const result = await this.git.exec(['reset', '--hard', 'HEAD@{1}'], dryRun);
160
+ return result.code === 0;
161
+ }
162
+ return false; // Manual options need user guidance
163
+ }
164
+ }
165
+ export class BotchedMergeRecovery extends BaseRecovery {
166
+ getOptions(disaster) {
167
+ return [
168
+ {
169
+ id: 'abort',
170
+ title: 'Abort the merge',
171
+ description: 'Cancel the merge and return to pre-merge state',
172
+ riskLevel: 'safe',
173
+ steps: [
174
+ {
175
+ command: 'git merge --abort',
176
+ description: 'Abort the merge and clean up',
177
+ riskLevel: 'safe'
178
+ }
179
+ ]
180
+ },
181
+ {
182
+ id: 'resolve',
183
+ title: 'Resolve conflicts manually',
184
+ description: 'Edit conflicted files and complete the merge',
185
+ riskLevel: 'safe',
186
+ steps: [
187
+ {
188
+ command: 'git status',
189
+ description: 'See which files have conflicts',
190
+ riskLevel: 'safe'
191
+ },
192
+ {
193
+ command: 'git add <resolved-files>',
194
+ description: 'Stage resolved files',
195
+ riskLevel: 'safe'
196
+ },
197
+ {
198
+ command: 'git commit',
199
+ description: 'Complete the merge',
200
+ riskLevel: 'safe'
201
+ }
202
+ ]
203
+ }
204
+ ];
205
+ }
206
+ async execute(optionId, disaster, dryRun = false) {
207
+ if (optionId === 'abort') {
208
+ const result = await this.git.exec(['merge', '--abort'], dryRun);
209
+ return result.code === 0;
210
+ }
211
+ return false; // Manual resolution
212
+ }
213
+ }
214
+ export class AccidentalCommitRecovery extends BaseRecovery {
215
+ getOptions(disaster) {
216
+ const { commitSha, commitMessage, branch } = disaster.metadata;
217
+ return [
218
+ {
219
+ id: 'soft-reset',
220
+ title: 'Undo commit, keep changes staged',
221
+ description: 'Remove the commit but keep your changes ready to commit',
222
+ riskLevel: 'safe',
223
+ steps: [
224
+ {
225
+ command: 'git reset --soft HEAD~1',
226
+ description: 'Undo the last commit, keep changes staged',
227
+ riskLevel: 'safe'
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ id: 'hard-reset',
233
+ title: 'Undo commit completely',
234
+ description: 'Remove the commit and all changes (DANGEROUS)',
235
+ riskLevel: 'high',
236
+ steps: [
237
+ {
238
+ command: 'git reset --hard HEAD~1',
239
+ description: 'Remove the commit and all changes',
240
+ riskLevel: 'high'
241
+ }
242
+ ]
243
+ },
244
+ {
245
+ id: 'amend',
246
+ title: 'Edit the commit message',
247
+ description: 'Keep the commit but change its message',
248
+ riskLevel: 'safe',
249
+ steps: [
250
+ {
251
+ command: 'git commit --amend',
252
+ description: 'Edit the last commit message',
253
+ riskLevel: 'safe'
254
+ }
255
+ ]
256
+ }
257
+ ];
258
+ }
259
+ async execute(optionId, disaster, dryRun = false) {
260
+ if (optionId === 'soft-reset') {
261
+ const result = await this.git.exec(['reset', '--soft', 'HEAD~1'], dryRun);
262
+ return result.code === 0;
263
+ }
264
+ if (optionId === 'hard-reset') {
265
+ const result = await this.git.exec(['reset', '--hard', 'HEAD~1'], dryRun);
266
+ return result.code === 0;
267
+ }
268
+ if (optionId === 'amend') {
269
+ const result = await this.git.exec(['commit', '--amend'], dryRun);
270
+ return result.code === 0;
271
+ }
272
+ return false;
273
+ }
274
+ }
275
+ export class UncommittedChangesRecovery extends BaseRecovery {
276
+ getOptions(disaster) {
277
+ const { stagedCount, unstagedCount } = disaster.metadata;
278
+ return [
279
+ {
280
+ id: 'stash',
281
+ title: 'Stash changes',
282
+ description: 'Save your changes to apply later',
283
+ riskLevel: 'safe',
284
+ steps: [
285
+ {
286
+ command: 'git stash push -m "WIP"',
287
+ description: 'Stash all changes with a message',
288
+ riskLevel: 'safe'
289
+ }
290
+ ]
291
+ },
292
+ {
293
+ id: 'commit',
294
+ title: 'Commit changes',
295
+ description: 'Create a commit with your changes',
296
+ riskLevel: 'safe',
297
+ steps: [
298
+ {
299
+ command: 'git add .',
300
+ description: 'Stage all changes',
301
+ riskLevel: 'safe'
302
+ },
303
+ {
304
+ command: 'git commit -m "WIP"',
305
+ description: 'Commit the changes',
306
+ riskLevel: 'safe'
307
+ }
308
+ ]
309
+ },
310
+ {
311
+ id: 'discard',
312
+ title: 'Discard all changes',
313
+ description: 'Remove all uncommitted changes (DANGEROUS)',
314
+ riskLevel: 'high',
315
+ steps: [
316
+ {
317
+ command: 'git reset --hard HEAD',
318
+ description: 'Discard all changes',
319
+ riskLevel: 'high'
320
+ },
321
+ {
322
+ command: 'git clean -fd',
323
+ description: 'Remove untracked files',
324
+ riskLevel: 'high'
325
+ }
326
+ ]
327
+ }
328
+ ];
329
+ }
330
+ async execute(optionId, disaster, dryRun = false) {
331
+ if (optionId === 'stash') {
332
+ const result = await this.git.exec(['stash', 'push', '-m', 'WIP'], dryRun);
333
+ return result.code === 0;
334
+ }
335
+ if (optionId === 'commit') {
336
+ const result1 = await this.git.exec(['add', '.'], dryRun);
337
+ if (result1.code !== 0)
338
+ return false;
339
+ const result2 = await this.git.exec(['commit', '-m', 'WIP'], dryRun);
340
+ return result2.code === 0;
341
+ }
342
+ if (optionId === 'discard') {
343
+ const result1 = await this.git.exec(['reset', '--hard', 'HEAD'], dryRun);
344
+ if (result1.code !== 0)
345
+ return false;
346
+ const result2 = await this.git.exec(['clean', '-fd'], dryRun);
347
+ return result2.code === 0;
348
+ }
349
+ return false;
350
+ }
351
+ }
352
+ export class WrongBranchCommitRecovery extends BaseRecovery {
353
+ getOptions(disaster) {
354
+ const { commitSha, commitMessage, branch } = disaster.metadata;
355
+ return [
356
+ {
357
+ id: 'cherry-pick',
358
+ title: `Move commit to correct branch`,
359
+ description: 'Cherry-pick this commit to main/master',
360
+ riskLevel: 'medium',
361
+ steps: [
362
+ {
363
+ command: 'git checkout main',
364
+ description: 'Switch to the correct branch',
365
+ riskLevel: 'safe'
366
+ },
367
+ {
368
+ command: `git cherry-pick ${commitSha}`,
369
+ description: 'Apply the commit to the correct branch',
370
+ riskLevel: 'medium'
371
+ },
372
+ {
373
+ command: `git checkout ${branch}`,
374
+ description: 'Return to original branch',
375
+ riskLevel: 'safe'
376
+ },
377
+ {
378
+ command: 'git reset --hard HEAD~1',
379
+ description: 'Remove the commit from wrong branch',
380
+ riskLevel: 'medium'
381
+ }
382
+ ]
383
+ },
384
+ {
385
+ id: 'ignore',
386
+ title: 'Keep it here',
387
+ description: 'This commit belongs on this branch after all',
388
+ riskLevel: 'safe',
389
+ steps: []
390
+ }
391
+ ];
392
+ }
393
+ async execute(optionId, disaster, dryRun = false) {
394
+ const { commitSha, branch } = disaster.metadata;
395
+ if (optionId === 'cherry-pick') {
396
+ // This requires multiple steps, we'll handle step by step
397
+ return false; // Need interactive handling
398
+ }
399
+ return true; // Ignore is always successful
400
+ }
401
+ }
402
+ export function getRecoveryForDisaster(disaster, git) {
403
+ switch (disaster.id) {
404
+ case 'detached-head':
405
+ return new DetachedHeadRecovery(git);
406
+ case 'deleted-branch':
407
+ return new DeletedBranchRecovery(git);
408
+ case 'force-push':
409
+ return new ForcePushRecovery(git);
410
+ case 'botched-merge':
411
+ return new BotchedMergeRecovery(git);
412
+ case 'accidental-commit':
413
+ return new AccidentalCommitRecovery(git);
414
+ case 'uncommitted-changes':
415
+ return new UncommittedChangesRecovery(git);
416
+ case 'wrong-branch-commit':
417
+ return new WrongBranchCommitRecovery(git);
418
+ default:
419
+ throw new Error(`Unknown disaster type: ${disaster.id}`);
420
+ }
421
+ }
422
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/recoveries/index.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAgB,YAAY;IACV;IAAtB,YAAsB,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;IAAG,CAAC;IAI1C,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,QAAkB,EAAE,MAAM,GAAG,KAAK;QAChE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IACpD,UAAU,CAAC,QAAkB;QAC3B,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAExD,OAAO;YACL;gBACE,EAAE,EAAE,UAAU;gBACd,KAAK,EAAE,6BAA6B;gBACpC,WAAW,EAAE,kBAAkB,UAAU,IAAI,iBAAiB,EAAE;gBAChE,SAAS,EAAE,MAAM;gBACjB,KAAK,EAAE;oBACL;wBACE,OAAO,EAAE,gBAAgB,UAAU,IAAI,GAAG,EAAE;wBAC5C,WAAW,EAAE,iCAAiC;wBAC9C,SAAS,EAAE,MAAM;qBAClB;iBACF;aACF;YACD;gBACE,EAAE,EAAE,YAAY;gBAChB,KAAK,EAAE,oCAAoC;gBAC3C,WAAW,EAAE,gCAAgC;gBAC7C,SAAS,EAAE,MAAM;gBACjB,KAAK,EAAE;oBACL;wBACE,OAAO,EAAE,iCAAiC;wBAC1C,WAAW,EAAE,kCAAkC;wBAC/C,SAAS,EAAE,MAAM;qBAClB;i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QAEhD,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;YAC/B,0DAA0D;YAC1D,OAAO,KAAK,CAAC,CAAC,4BAA4B;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,CAAC,8BAA8B;IAC7C,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAkB,EAAE,GAAgB;IACzE,QAAQ,QAAQ,CAAC,EAAE,EAAE,CAAC;QACpB,KAAK,eAAe;YAClB,OAAO,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACvC,KAAK,gBAAgB;YACnB,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAC;QACxC,KAAK,YAAY;YACf,OAAO,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACpC,KAAK,eAAe;YAClB,OAAO,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACvC,KAAK,mBAAmB;YACtB,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAC;QAC3C,KAAK,qBAAqB;YACxB,OAAO,IAAI,0BAA0B,CAAC,GAAG,CAAC,CAAC;QAC7C,KAAK,qBAAqB;YACxB,OAAO,IAAI,yBAAyB,CAAC,GAAG,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "gitpanic",
3
+ "version": "1.0.0",
4
+ "description": "Interactive CLI that diagnoses git mistakes and guides you through recovery",
5
+ "type": "module",
6
+ "bin": {
7
+ "gitpanic": "./dist/cli.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "test": "npm run build && node --test tests/**/*.test.ts",
12
+ "lint": "tsc --noEmit",
13
+ "typecheck": "tsc --noEmit",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "keywords": [
22
+ "git",
23
+ "recovery",
24
+ "undo",
25
+ "reflog",
26
+ "cli",
27
+ "terminal",
28
+ "wizard"
29
+ ],
30
+ "author": "sulthonzh",
31
+ "license": "MIT",
32
+ "dependencies": {
33
+ "ink": "^4.4.1",
34
+ "react": "^18.2.0",
35
+ "ink-select-input": "^5.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^20.10.0",
39
+ "@types/react": "^18.2.0",
40
+ "typescript": "^5.3.0"
41
+ }
42
+ }