@manthank/mgit 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mgit contributors
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.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # mgit ๐ŸŒ†
2
+
3
+ **A friendly, animated terminal UI that teaches beginners git & GitHub.**
4
+
5
+ `mgit` wraps every common git command in a colourful, guided interface built with
6
+ [Ink](https://github.com/vadimdemedes/ink). Every action shows the **real command
7
+ it runs** and a plain-English explanation, so you *learn git while you use it*.
8
+ Dangerous actions are highlighted and ask for confirmation.
9
+
10
+ ```
11
+ โ–ˆโ–€โ–„โ–€โ–ˆ โ–ˆโ–€โ–€ โ–ˆ โ–€โ–ˆโ–€
12
+ โ–ˆ โ–€ โ–ˆ โ–ˆโ–„โ–ˆ โ–ˆ โ–ˆ
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - ๐ŸŽฌ **Animated UI** โ€” shimmering gradient wordmark, travelling pulses, animated pointers.
18
+ - ๐ŸŽจ **6 themes + customisation** โ€” Neon, Ocean, Sunset, Forest, Monochrome, Candy Pop.
19
+ Toggle animations, danger-confirmations and hints. Preferences persist in `~/.mgit/config.json`.
20
+ - ๐Ÿ“Š **Chart-style visualisations**
21
+ - **Status dashboard** โ€” colour-coded staged / changed / untracked files.
22
+ - **Branch map** โ€” every branch as a node, current one marked with โ˜….
23
+ - **Commit graph** โ€” commits across all branches with branch/tag badges.
24
+ - **Contributions chart** โ€” a bar chart of commits per author.
25
+ - ๐Ÿงญ **Everything explained** โ€” a beginner hint for every one of the ~50 actions.
26
+ - ๐Ÿณ **Guided recipes** โ€” multi-step workflows (publish to GitHub, feature branch, sync main)
27
+ walked through one command at a time.
28
+ - โŒจ๏ธ **Keyboard driven** โ€” arrows, Enter, Esc, plus quick shortcuts (`t` theme, `s` settings, `?` help).
29
+
30
+ ## Covered commands
31
+
32
+ All 35 topic areas from the classic git cheat-sheet are covered, grouped into:
33
+
34
+ | Menu | Includes |
35
+ |------|----------|
36
+ | ๐Ÿš€ Get Started | setup wizard (name/email/default branch), config list, `init`, `clone` |
37
+ | ๐Ÿ”Ž See What Changed | `status`, `diff`, `diff --staged`, `diff --name-only`, `show`, `blame`, `grep` |
38
+ | ๐Ÿ“ˆ History & Graph | commit graph, contributions chart, `log --oneline`, `reflog`, `shortlog` |
39
+ | ๐Ÿ“ฆ Stage & Commit | `add .`, `add <file>`, `add -u`, `commit -m`, `commit -am` |
40
+ | ๐ŸŒฟ Branches | branch map, create/switch/merge/delete (safe & force) |
41
+ | ๐Ÿ›ฐ๏ธ Remotes, Push & Pull | `remote -v/add/set-url/remove`, `push -u`, `push`, `pull`, `fetch`, force push |
42
+ | โช Undo & Recover | `restore`, unstage, `reset` (soft/mixed/hard), `revert`, `clean` |
43
+ | ๐Ÿงฐ Stash | save, list, pop, apply, drop, clear |
44
+ | ๐Ÿท๏ธ Files & Tags | `rm`, `mv`, `.gitignore` generator, `ls-files`, tags |
45
+ | ๐Ÿงช Advanced | `cherry-pick`, `rebase`, `rev-parse HEAD` |
46
+ | ๐Ÿณ Guided Recipes | GitHub first-push, feature-branch flow, sync main |
47
+
48
+ ## Install & run
49
+
50
+ ### As a global CLI tool (npm)
51
+
52
+ ```bash
53
+ npm install -g mgit
54
+ mgit # launch from any folder
55
+ ```
56
+
57
+ Or run without installing:
58
+
59
+ ```bash
60
+ npx mgit
61
+ ```
62
+
63
+ ### From source (development)
64
+
65
+ ```bash
66
+ git clone <repo-url> && cd mgit
67
+ npm install # installs deps and builds to dist/
68
+ npm link # makes the `mgit` command available everywhere
69
+ mgit # launch from any folder
70
+ ```
71
+
72
+ During development:
73
+
74
+ ```bash
75
+ npm run dev # build + run
76
+ npm run build # compile source/ -> dist/ with Babel
77
+ ```
78
+
79
+ ## How it works
80
+
81
+ - `source/` is written in JSX and compiled to `dist/` by Babel (`@babel/preset-react`).
82
+ - `source/git.js` is a thin, never-throwing wrapper around the `git` binary (via `execa`)
83
+ plus parsers that turn raw output into the data the visual components render.
84
+ - `source/catalog.js` is a data-driven list of every action (label, beginner hint,
85
+ the git args to run, and safety flags) โ€” the single source of truth for the menus.
86
+ - `source/app.jsx` owns navigation (a simple screen stack), theming and global shortcuts.
87
+
88
+ ## Requirements
89
+
90
+ - Node.js โ‰ฅ 18
91
+ - git installed and on your PATH
92
+ - An interactive terminal (TTY)
93
+
94
+ ## License
95
+
96
+ MIT
package/dist/app.js ADDED
@@ -0,0 +1,468 @@
1
+ // mgit root component: owns navigation, theme/config, and renders the active screen.
2
+ import React, { useState, useEffect, useCallback } from 'react';
3
+ import { Box, Text, useApp, useInput } from 'ink';
4
+ import Header from './components/Header.js';
5
+ import Footer from './components/Footer.js';
6
+ import Menu from './components/Menu.js';
7
+ import { categories } from './catalog.js';
8
+ import { getTheme, themeOrder } from './themes.js';
9
+ import { saveConfig } from './config.js';
10
+ import { isGitRepo } from './git.js';
11
+ import StatusView from './views/StatusView.js';
12
+ import BranchView from './views/BranchView.js';
13
+ import LogGraphView from './views/LogGraphView.js';
14
+ import ContribView from './views/ContribView.js';
15
+ import ConfigView from './views/ConfigView.js';
16
+ import SetupWizard from './views/SetupWizard.js';
17
+ import GitignoreView from './views/GitignoreView.js';
18
+ import ActionRunner from './views/ActionRunner.js';
19
+ import RecipeView from './views/RecipeView.js';
20
+ import SettingsView from './views/SettingsView.js';
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ const HOME = {
23
+ type: 'home'
24
+ };
25
+
26
+ // Screens that are pure menus/read-only (safe to attach letter shortcuts to,
27
+ // because they never mount a TextInput or single-key confirm).
28
+ const MENU_TYPES = new Set(['home', 'category', 'settings', 'help', 'readview']);
29
+ export default function App({
30
+ initialConfig
31
+ }) {
32
+ const {
33
+ exit
34
+ } = useApp();
35
+ const [config, setConfig] = useState(initialConfig);
36
+ const [stack, setStack] = useState([HOME]);
37
+ const [repo, setRepo] = useState(false);
38
+ const theme = getTheme(config.theme);
39
+ const screen = stack[stack.length - 1];
40
+ const updateConfig = useCallback(next => {
41
+ setConfig(next);
42
+ saveConfig(next);
43
+ }, []);
44
+ const push = useCallback(s => setStack(st => [...st, s]), []);
45
+ const back = useCallback(() => setStack(st => st.length > 1 ? st.slice(0, -1) : st), []);
46
+
47
+ // Refresh "is this a repo?" whenever we land back on a menu screen.
48
+ useEffect(() => {
49
+ if (MENU_TYPES.has(screen.type)) {
50
+ isGitRepo().then(setRepo);
51
+ }
52
+ }, [stack.length, screen.type]);
53
+
54
+ // Global navigation. Esc always goes back (TextInput ignores Esc, so this is safe).
55
+ // Letter shortcuts only on menu-type screens so they don't hijack text entry.
56
+ useInput((input, key) => {
57
+ if (key.escape) {
58
+ if (stack.length > 1) back();else exit();
59
+ return;
60
+ }
61
+ if (!MENU_TYPES.has(screen.type)) return;
62
+ if (input === 'q') exit();else if (input === 't') cycleTheme();else if (input === 's') push({
63
+ type: 'settings'
64
+ });else if (input === '?') push({
65
+ type: 'help'
66
+ });else if (input === 'h') setStack([HOME]);else if (key.leftArrow && stack.length > 1) back();
67
+ });
68
+ function cycleTheme() {
69
+ const i = themeOrder.indexOf(config.theme);
70
+ updateConfig({
71
+ ...config,
72
+ theme: themeOrder[(i + 1) % themeOrder.length]
73
+ });
74
+ }
75
+ function openAction(action) {
76
+ if (action.needsRepo !== false && !repo && action.view !== 'setup' && action.view !== 'config') {
77
+ push({
78
+ type: 'norepo',
79
+ action
80
+ });
81
+ return;
82
+ }
83
+ switch (action.view) {
84
+ case 'status':
85
+ case 'branches':
86
+ case 'log':
87
+ case 'contrib':
88
+ case 'config':
89
+ push({
90
+ type: 'readview',
91
+ view: action.view,
92
+ action
93
+ });
94
+ break;
95
+ case 'setup':
96
+ push({
97
+ type: 'setup',
98
+ action
99
+ });
100
+ break;
101
+ case 'gitignore':
102
+ push({
103
+ type: 'gitignore',
104
+ action
105
+ });
106
+ break;
107
+ case 'recipe':
108
+ push({
109
+ type: 'recipe',
110
+ recipe: action.recipe,
111
+ action
112
+ });
113
+ break;
114
+ default:
115
+ push({
116
+ type: 'action',
117
+ action
118
+ });
119
+ }
120
+ }
121
+ const hints = buildHints(screen, stack.length);
122
+ return /*#__PURE__*/_jsxs(Box, {
123
+ flexDirection: "column",
124
+ paddingX: 1,
125
+ children: [/*#__PURE__*/_jsx(Header, {
126
+ theme: theme,
127
+ animations: config.animations,
128
+ subtitle: titleFor(screen)
129
+ }), /*#__PURE__*/_jsx(Breadcrumb, {
130
+ theme: theme,
131
+ stack: stack
132
+ }), /*#__PURE__*/_jsx(Box, {
133
+ flexDirection: "column",
134
+ marginTop: 1,
135
+ minHeight: 3,
136
+ children: renderScreen({
137
+ screen,
138
+ theme,
139
+ config,
140
+ repo,
141
+ push,
142
+ openAction,
143
+ updateConfig,
144
+ cycleTheme
145
+ })
146
+ }), /*#__PURE__*/_jsx(Footer, {
147
+ theme: theme,
148
+ hints: hints,
149
+ repo: repo
150
+ })]
151
+ });
152
+ }
153
+ function renderScreen(ctx) {
154
+ const {
155
+ screen,
156
+ theme,
157
+ config,
158
+ repo,
159
+ openAction,
160
+ updateConfig
161
+ } = ctx;
162
+ switch (screen.type) {
163
+ case 'home':
164
+ return /*#__PURE__*/_jsx(HomeMenu, {
165
+ theme: theme,
166
+ config: config,
167
+ onSelect: openAction,
168
+ ctx: ctx
169
+ });
170
+ case 'category':
171
+ return /*#__PURE__*/_jsx(CategoryMenu, {
172
+ theme: theme,
173
+ config: config,
174
+ categoryId: screen.categoryId,
175
+ onSelect: openAction
176
+ });
177
+ case 'readview':
178
+ if (screen.view === 'status') return /*#__PURE__*/_jsx(StatusView, {
179
+ theme: theme
180
+ });
181
+ if (screen.view === 'branches') return /*#__PURE__*/_jsx(BranchView, {
182
+ theme: theme,
183
+ animations: config.animations
184
+ });
185
+ if (screen.view === 'log') return /*#__PURE__*/_jsx(LogGraphView, {
186
+ theme: theme,
187
+ animations: config.animations
188
+ });
189
+ if (screen.view === 'contrib') return /*#__PURE__*/_jsx(ContribView, {
190
+ theme: theme,
191
+ animations: config.animations
192
+ });
193
+ if (screen.view === 'config') return /*#__PURE__*/_jsx(ConfigView, {
194
+ theme: theme
195
+ });
196
+ return null;
197
+ case 'setup':
198
+ return /*#__PURE__*/_jsx(SetupWizard, {
199
+ theme: theme
200
+ });
201
+ case 'gitignore':
202
+ return /*#__PURE__*/_jsx(GitignoreView, {
203
+ theme: theme
204
+ });
205
+ case 'action':
206
+ return /*#__PURE__*/_jsx(ActionRunner, {
207
+ action: screen.action,
208
+ theme: theme,
209
+ config: config
210
+ });
211
+ case 'recipe':
212
+ return /*#__PURE__*/_jsx(RecipeView, {
213
+ recipeId: screen.recipe,
214
+ theme: theme,
215
+ config: config
216
+ });
217
+ case 'settings':
218
+ return /*#__PURE__*/_jsx(SettingsView, {
219
+ theme: theme,
220
+ config: config,
221
+ onChange: updateConfig
222
+ });
223
+ case 'help':
224
+ return /*#__PURE__*/_jsx(HelpView, {
225
+ theme: theme
226
+ });
227
+ case 'norepo':
228
+ return /*#__PURE__*/_jsx(NoRepo, {
229
+ theme: theme,
230
+ action: screen.action
231
+ });
232
+ default:
233
+ return null;
234
+ }
235
+ }
236
+ function HomeMenu({
237
+ theme,
238
+ config,
239
+ onSelect,
240
+ ctx
241
+ }) {
242
+ const items = [...categories.map(c => ({
243
+ label: `${c.emoji} ${c.label.padEnd(22)} ${c.blurb}`,
244
+ value: 'cat:' + c.id
245
+ })), {
246
+ label: 'โš™๏ธ Settings & Themes',
247
+ value: 'nav:settings'
248
+ }, {
249
+ label: 'โ“ Help & shortcuts',
250
+ value: 'nav:help'
251
+ }, {
252
+ label: '๐Ÿšช Quit',
253
+ value: 'nav:quit'
254
+ }];
255
+ function handle({
256
+ value
257
+ }) {
258
+ const [kind, id] = value.split(':');
259
+ if (kind === 'cat') ctx.push({
260
+ type: 'category',
261
+ categoryId: id
262
+ });else if (id === 'settings') ctx.push({
263
+ type: 'settings'
264
+ });else if (id === 'help') ctx.push({
265
+ type: 'help'
266
+ });else if (id === 'quit') process.exit(0);
267
+ }
268
+ return /*#__PURE__*/_jsxs(Box, {
269
+ flexDirection: "column",
270
+ children: [/*#__PURE__*/_jsx(Text, {
271
+ color: theme.muted,
272
+ children: "What would you like to do? Use \u2191 \u2193 and Enter."
273
+ }), /*#__PURE__*/_jsx(Box, {
274
+ marginTop: 1,
275
+ children: /*#__PURE__*/_jsx(Menu, {
276
+ items: items,
277
+ onSelect: handle,
278
+ theme: theme,
279
+ animations: config.animations,
280
+ limit: 14
281
+ })
282
+ })]
283
+ });
284
+ }
285
+ function CategoryMenu({
286
+ theme,
287
+ config,
288
+ categoryId,
289
+ onSelect
290
+ }) {
291
+ const cat = categories.find(c => c.id === categoryId);
292
+ if (!cat) return /*#__PURE__*/_jsx(Text, {
293
+ color: theme.danger,
294
+ children: "Unknown category."
295
+ });
296
+ const items = cat.actions.map(a => ({
297
+ label: `${a.danger ? 'โš  ' : ''}${a.label}`,
298
+ value: a.id
299
+ }));
300
+ const [hi, setHi] = useState(cat.actions[0]);
301
+ return /*#__PURE__*/_jsxs(Box, {
302
+ flexDirection: "column",
303
+ children: [/*#__PURE__*/_jsxs(Text, {
304
+ color: theme.secondary,
305
+ children: [cat.emoji, " ", cat.blurb]
306
+ }), /*#__PURE__*/_jsx(Box, {
307
+ marginTop: 1,
308
+ children: /*#__PURE__*/_jsx(Menu, {
309
+ items: items,
310
+ theme: theme,
311
+ animations: config.animations,
312
+ limit: 14,
313
+ onHighlight: item => setHi(cat.actions.find(a => a.id === item.value)),
314
+ onSelect: item => onSelect(cat.actions.find(a => a.id === item.value))
315
+ })
316
+ }), config.showHints && hi && /*#__PURE__*/_jsx(Box, {
317
+ marginTop: 1,
318
+ borderStyle: "round",
319
+ borderColor: theme.muted,
320
+ paddingX: 1,
321
+ children: /*#__PURE__*/_jsxs(Text, {
322
+ color: theme.muted,
323
+ children: ["\uD83D\uDCA1 ", hi.hint]
324
+ })
325
+ })]
326
+ });
327
+ }
328
+ function HelpView({
329
+ theme
330
+ }) {
331
+ const rows = [['โ†‘ โ†“', 'Move through menus'], ['Enter', 'Select / run'], ['Esc', 'Go back (or quit from home)'], ['t', 'Cycle theme instantly'], ['s', 'Open Settings & Themes'], ['h', 'Jump home'], ['?', 'This help screen'], ['q', 'Quit mgit'], ['Y', 'Confirm a dangerous action']];
332
+ return /*#__PURE__*/_jsxs(Box, {
333
+ flexDirection: "column",
334
+ children: [/*#__PURE__*/_jsx(Text, {
335
+ color: theme.accent,
336
+ bold: true,
337
+ children: "Keyboard shortcuts"
338
+ }), /*#__PURE__*/_jsx(Box, {
339
+ marginTop: 1,
340
+ flexDirection: "column",
341
+ children: rows.map(([k, d]) => /*#__PURE__*/_jsxs(Text, {
342
+ children: [/*#__PURE__*/_jsx(Text, {
343
+ color: theme.accent,
344
+ bold: true,
345
+ children: k.padEnd(8)
346
+ }), /*#__PURE__*/_jsx(Text, {
347
+ color: "white",
348
+ children: d
349
+ })]
350
+ }, k))
351
+ }), /*#__PURE__*/_jsxs(Box, {
352
+ marginTop: 1,
353
+ flexDirection: "column",
354
+ children: [/*#__PURE__*/_jsx(Text, {
355
+ color: theme.secondary,
356
+ bold: true,
357
+ children: "About"
358
+ }), /*#__PURE__*/_jsx(Text, {
359
+ color: theme.muted,
360
+ children: "mgit is a guided, colourful front-end for git. Every action shows the real command it runs, so you learn git while you use it. Dangerous actions are highlighted and ask for confirmation."
361
+ })]
362
+ })]
363
+ });
364
+ }
365
+ function NoRepo({
366
+ theme,
367
+ action
368
+ }) {
369
+ return /*#__PURE__*/_jsxs(Box, {
370
+ flexDirection: "column",
371
+ children: [/*#__PURE__*/_jsx(Text, {
372
+ color: theme.warn,
373
+ bold: true,
374
+ children: "This folder isn't a git repository yet."
375
+ }), /*#__PURE__*/_jsxs(Text, {
376
+ color: theme.muted,
377
+ children: ["\"", action.label, "\" needs a repo. Go to \uD83D\uDE80 Get Started \u2192 \"Initialize a repo here\", or open a folder that already contains one."]
378
+ }), /*#__PURE__*/_jsx(Box, {
379
+ marginTop: 1,
380
+ children: /*#__PURE__*/_jsxs(Text, {
381
+ color: theme.muted,
382
+ children: ["Current folder: ", process.cwd()]
383
+ })
384
+ }), /*#__PURE__*/_jsx(Box, {
385
+ marginTop: 1,
386
+ children: /*#__PURE__*/_jsx(Text, {
387
+ color: theme.accent,
388
+ children: "Press Esc / \u2190 to go back."
389
+ })
390
+ })]
391
+ });
392
+ }
393
+ function Breadcrumb({
394
+ theme,
395
+ stack
396
+ }) {
397
+ const trail = stack.map(s => titleFor(s)).filter(Boolean);
398
+ return /*#__PURE__*/_jsx(Box, {
399
+ children: /*#__PURE__*/_jsx(Text, {
400
+ color: theme.muted,
401
+ children: trail.map((t, i) => /*#__PURE__*/_jsxs(Text, {
402
+ children: [i > 0 && /*#__PURE__*/_jsx(Text, {
403
+ color: theme.muted,
404
+ children: " \u203A "
405
+ }), /*#__PURE__*/_jsx(Text, {
406
+ color: i === trail.length - 1 ? theme.accent : theme.muted,
407
+ children: t
408
+ })]
409
+ }, i))
410
+ })
411
+ });
412
+ }
413
+ function titleFor(screen) {
414
+ switch (screen.type) {
415
+ case 'home':
416
+ return 'Home';
417
+ case 'category':
418
+ {
419
+ const c = categories.find(x => x.id === screen.categoryId);
420
+ return c ? c.label : 'Category';
421
+ }
422
+ case 'readview':
423
+ return screen.action ? screen.action.label : 'View';
424
+ case 'setup':
425
+ return 'Setup wizard';
426
+ case 'gitignore':
427
+ return '.gitignore';
428
+ case 'action':
429
+ return screen.action ? screen.action.label : 'Run';
430
+ case 'recipe':
431
+ return screen.action ? screen.action.label : 'Recipe';
432
+ case 'settings':
433
+ return 'Settings';
434
+ case 'help':
435
+ return 'Help';
436
+ case 'norepo':
437
+ return 'No repo';
438
+ default:
439
+ return '';
440
+ }
441
+ }
442
+ function buildHints(screen, depth) {
443
+ if (MENU_TYPES.has(screen.type)) {
444
+ return [{
445
+ key: 'โ†‘โ†“',
446
+ label: 'move'
447
+ }, {
448
+ key: 'โŽ',
449
+ label: 'select'
450
+ }, {
451
+ key: 't',
452
+ label: 'theme'
453
+ }, {
454
+ key: 'esc',
455
+ label: depth > 1 ? 'back' : 'quit'
456
+ }, {
457
+ key: 'q',
458
+ label: 'quit'
459
+ }];
460
+ }
461
+ return [{
462
+ key: 'โŽ',
463
+ label: 'confirm'
464
+ }, {
465
+ key: 'esc',
466
+ label: 'back'
467
+ }];
468
+ }