preguito 0.2.2 → 0.2.4

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/README.md ADDED
@@ -0,0 +1,516 @@
1
+ # 🦄 preguito
2
+
3
+ > 🌐 **[Landing Page](https://jacodoisdois.github.io/preguito)** | šŸ“¦ **[npm](https://www.npmjs.com/package/preguito)** | šŸ“š **[Docs](./docs/)**
4
+
5
+ > A lazy git CLI with commit templates and shortcuts.
6
+
7
+ Typing the same commit prefix, squad name, and ticket number over and over is tedious. preguito lets you define a commit template once and reuse it on every commit — single-letter shortcodes replace verbose flags, so you only type what matters.
8
+
9
+ - šŸ”¤ **Single-letter shortcodes** — `f` for feat, `x` for fix, `p` for prd
10
+ - šŸ“ **Template-based commits** — define once, reuse forever
11
+ - ⚔ **Git shortcuts** — commit, push, rebase, stash, undo in 2-3 chars
12
+ - šŸ“ **Per-project config** — `.preguitorc` in your repo for team conventions
13
+ - šŸ“¦ **One dependency** — just [Commander.js](https://github.com/tj/commander.js), nothing else
14
+ - šŸ–„ļø **Standalone binary** — works without Node.js via SEA
15
+
16
+ ---
17
+
18
+ ## Table of Contents
19
+
20
+ - [Quick Demo](#-quick-demo)
21
+ - [Installation](#-installation)
22
+ - [Getting Started](#-getting-started)
23
+ - [Cheat Sheet](#-cheat-sheet)
24
+ - [Template System](#-template-system)
25
+ - [Commands](#-commands)
26
+ - [Common Workflows](#-common-workflows)
27
+ - [Configuration](#%EF%B8%8F-configuration)
28
+ - [Programmatic API](#-programmatic-api)
29
+ - [FAQ](#-faq)
30
+ - [Claude Code Integration](#-claude-code-integration)
31
+ - [Contributing](#-contributing)
32
+ - [License](#-license)
33
+
34
+ ---
35
+
36
+ ## šŸŽ¬ Quick Demo
37
+
38
+ **Without preguito:**
39
+
40
+ ```bash
41
+ git add -A && git commit -m "[PAYMENTS-42] feat(prd): add login endpoint" && git push
42
+ ```
43
+
44
+ **With preguito:**
45
+
46
+ ```bash
47
+ guito c 42 fp "add login endpoint" -p
48
+ # → Committing: [PAYMENTS-42] feat(prd): add login endpoint
49
+ # āœ” Committed.
50
+ # ā ‹ Pushing...
51
+ # āœ” Pushed.
52
+ ```
53
+
54
+ `42` is the card ID, `f` = feat, `p` = prd — everything else comes from your config.
55
+
56
+ ---
57
+
58
+ ## šŸ“¦ Installation
59
+
60
+ ### npm (requires Node.js >= 20)
61
+
62
+ ```bash
63
+ npm install -g preguito
64
+ ```
65
+
66
+ ### Standalone binary (.deb)
67
+
68
+ Download the `.deb` from [GitHub Releases](https://github.com/jacodoisdois/preguito/releases) and install:
69
+
70
+ ```bash
71
+ sudo dpkg -i preguito_0.2.2_amd64.deb
72
+ ```
73
+
74
+ No Node.js required — the binary bundles everything via Node.js SEA.
75
+
76
+ ---
77
+
78
+ ## šŸš€ Getting Started
79
+
80
+ ### 1. Run the setup wizard
81
+
82
+ ```bash
83
+ guito i
84
+ ```
85
+
86
+ The wizard walks you through picking features, shortcodes, and creating your config:
87
+
88
+ ```
89
+ ✨ Welcome to preguito setup!
90
+
91
+ šŸ“‹ Choose which features to enable:
92
+
93
+ šŸŽ« Include card/ticket ID in commits? (y/n): y
94
+ šŸ·ļø Include commit type (feat, fix, chore...)? (y/n): y
95
+ šŸŒ Include environment (prd, uat, dev...)? (y/n): y
96
+
97
+ šŸ”¤ Project prefix/sigla (e.g. PROJ): PAYMENTS
98
+
99
+ ─────────────────────────────────────
100
+ āœ… Setup complete!
101
+
102
+ šŸ“„ Config saved to /home/you/.config/preguito/config.json
103
+ šŸ“ Template: [PAYMENTS-{{card_id}}] {{type}}({{environment}}): <message>
104
+
105
+ šŸ”‘ Your shortcodes:
106
+ Types: f=feat, x=fix, c=chore, t=test, r=refactor, d=docs
107
+ Envs: p=prd, u=uat, d=dev, s=stg, l=local
108
+ ─────────────────────────────────────
109
+ ```
110
+
111
+ Or skip the wizard and use the default template:
112
+
113
+ ```bash
114
+ guito i --default
115
+ # āœ… Config written to ~/.config/preguito/config.json
116
+ # Template: {{type}}: <message> (type defaults to feat)
117
+ ```
118
+
119
+ ### 2. Make your first commit
120
+
121
+ ```bash
122
+ guito c 42 f "add login endpoint"
123
+ # → Committing: [PAYMENTS-42] feat: add login endpoint
124
+ # āœ” Committed.
125
+ ```
126
+
127
+ With environment shortcode:
128
+
129
+ ```bash
130
+ guito c 42 fp "add login endpoint"
131
+ # f = feat, p = prd
132
+ # → Committing: [PAYMENTS-42] feat(prd): add login endpoint
133
+ # āœ” Committed.
134
+ ```
135
+
136
+ Commit and push in one go:
137
+
138
+ ```bash
139
+ guito c 42 f "add login endpoint" -p
140
+ # → Committing: [PAYMENTS-42] feat: add login endpoint
141
+ # āœ” Committed.
142
+ # ā ‹ Pushing...
143
+ # āœ” Pushed.
144
+ ```
145
+
146
+ Preview without committing:
147
+
148
+ ```bash
149
+ guito c 42 f "test message" -d
150
+ # [PAYMENTS-42] feat: test message
151
+ ```
152
+
153
+ ---
154
+
155
+ ## šŸ“‹ Cheat Sheet
156
+
157
+ ### Commits
158
+
159
+ ```bash
160
+ guito c 42 f "message" # Templated commit
161
+ guito c 42 fp "message" # With type + environment
162
+ guito c 42 f "message" -p # Commit + push
163
+ guito c 42 f "message" -f # Commit + force push (lease)
164
+ guito c 42 f "message" -d # Dry run (preview only)
165
+ guito c 42 f "message" -S # Skip auto-staging
166
+ ```
167
+
168
+ ### Fixup
169
+
170
+ ```bash
171
+ guito cf abc123 # Fixup commit for abc123
172
+ guito cf abc123 -f # Fixup + force push (lease)
173
+ ```
174
+
175
+ ### Amend & Undo
176
+
177
+ ```bash
178
+ guito ap # Amend + force push
179
+ guito apl # Amend + force push (lease)
180
+ guito u # Undo last commit (soft reset)
181
+ guito u 3 # Undo last 3 commits
182
+ ```
183
+
184
+ ### Branches & Stash
185
+
186
+ ```bash
187
+ guito sw main # Switch branch
188
+ guito sw -n feature/login # Create + switch
189
+ guito st # Stash changes
190
+ guito st -m "WIP login" # Stash with message
191
+ guito stp # Stash pop
192
+ guito stl # List all stashes
193
+ ```
194
+
195
+ ### Rebase
196
+
197
+ ```bash
198
+ guito r main # Quick rebase on main
199
+ guito ri 3 # Interactive rebase last 3
200
+ guito re abc123 # Edit rebase at commit
201
+ ```
202
+
203
+ ### Push
204
+
205
+ ```bash
206
+ guito p # Simple push (git push)
207
+ guito pu # Push + set upstream
208
+ ```
209
+
210
+ ### Diff
211
+
212
+ ```bash
213
+ guito d # Show all changes
214
+ guito d -s # Show staged changes only
215
+ guito d --stat # Show diffstat summary
216
+ guito d -n # Show only changed file names
217
+ ```
218
+
219
+ ### Inspect
220
+
221
+ ```bash
222
+ guito s # Short status
223
+ guito l # Last 10 commits
224
+ guito l 20 # Last 20 commits
225
+ guito f "login" # Search commits by message
226
+ guito t v1.0.0 # Commits since tag
227
+ guito t v1.0.0 -a # All commits reachable from tag
228
+ ```
229
+
230
+ ### Config
231
+
232
+ ```bash
233
+ guito i # Setup wizard
234
+ guito i --default # Use default config
235
+ guito cfg # View current config
236
+ guito cfg --path # Show config file path
237
+ guito cfg --template # Show template only
238
+ ```
239
+
240
+ ---
241
+
242
+ ## šŸ”¤ Template System
243
+
244
+ Templates use `{{variable}}` for named parameters and `<placeholder>` for the commit message body.
245
+
246
+ ```
247
+ [{{prefix}}-{{card_id}}] {{type}}({{environment}}): <message>
248
+ ```
249
+
250
+ Variables are resolved from **shortcodes** first, then **config defaults**:
251
+
252
+ ```bash
253
+ guito c 42 fp "add login"
254
+ # 42 → card_id
255
+ # f → type = feat
256
+ # p → environment = prd
257
+ # "add..." → message
258
+ # → [PAYMENTS-42] feat(prd): add login
259
+ ```
260
+
261
+ Shortcodes are single letters you define during `guito i` setup:
262
+
263
+ | Letter | Type | Letter | Environment |
264
+ |--------|------|--------|-------------|
265
+ | `f` | feat | `p` | prd |
266
+ | `x` | fix | `u` | uat |
267
+ | `c` | chore | `d` | dev |
268
+ | `t` | test | `s` | stg |
269
+ | `r` | refactor | `l` | local |
270
+ | `d` | docs | | |
271
+
272
+ See [template-system.md](docs/template-system.md) for full syntax, resolution order, and more examples.
273
+
274
+ ---
275
+
276
+ ## šŸ”§ Commands
277
+
278
+ | Command | Alias | Description |
279
+ |---------|-------|-------------|
280
+ | `guito c [id] [codes] "msg"` | `commit` | Templated commit with auto-stage |
281
+ | `guito cf <hash>` | — | Create a fixup commit |
282
+ | `guito ap` | — | Amend + force push |
283
+ | `guito apl` | — | Amend + force push with lease |
284
+ | `guito u [count]` | `undo` | Undo last N commits (soft reset) |
285
+ | `guito p` | `push` | Simple push (git push) |
286
+ | `guito pu` | — | Push with --set-upstream |
287
+ | `guito r <branch>` | `rebase` | Quick rebase on branch |
288
+ | `guito re <hash>` | — | Edit rebase at commit |
289
+ | `guito ri <count>` | — | Interactive rebase last N commits |
290
+ | `guito sw <branch>` | `switch` | Switch/create branch (`-n` to create) |
291
+ | `guito st` | — | Stash changes (`-m` for message) |
292
+ | `guito stp` | — | Pop latest stash |
293
+ | `guito stl` | — | List all stashes |
294
+ | `guito d` | `diff` | Show changes (`-s` staged, `--stat`, `-n` names) |
295
+ | `guito s` | `status` | Short status |
296
+ | `guito l [count]` | `log` | Compact log (default: 10) |
297
+ | `guito f <keyword>` | `find` | Search commits by message |
298
+ | `guito t <tag>` | `tag` | Commits since/from a tag |
299
+ | `guito i` | `init` | Setup wizard |
300
+ | `guito cfg` | `config` | View configuration |
301
+
302
+ See the [full command reference](docs/README.md) for detailed usage, flags, and examples.
303
+
304
+ ---
305
+
306
+ ## šŸ”„ Common Workflows
307
+
308
+ ### Start a new feature
309
+
310
+ ```bash
311
+ guito sw -n feature/login # Create branch
312
+ # ... make changes ...
313
+ guito c 42 f "add login" -p # Commit + push
314
+ ```
315
+
316
+ ### Quick fix on current branch
317
+
318
+ ```bash
319
+ # ... fix the bug ...
320
+ guito c 99 x "fix timeout" -p # x = fix, push immediately
321
+ ```
322
+
323
+ ### Oops, need to change the last commit
324
+
325
+ ```bash
326
+ # ... make more changes ...
327
+ guito apl # Amend + force push (safe)
328
+ ```
329
+
330
+ ### Rebase before opening a PR
331
+
332
+ ```bash
333
+ guito r main # Pull main, rebase on top
334
+ guito pu # Push with upstream
335
+ ```
336
+
337
+ ### Clean up commit history
338
+
339
+ ```bash
340
+ guito ri 5 # Interactive rebase last 5 commits
341
+ # or create fixup commits:
342
+ guito cf abc123 -f # Fixup + force push
343
+ ```
344
+
345
+ ### Review changes before committing
346
+
347
+ ```bash
348
+ guito d # See all unstaged changes
349
+ guito d -s # See what's staged
350
+ guito d --stat # Quick summary of changed files
351
+ guito c 42 f "add feature" -p # Commit + push
352
+ ```
353
+
354
+ ### Stash work in progress
355
+
356
+ ```bash
357
+ guito st -m "WIP: login page" # Stash with a descriptive message
358
+ guito sw hotfix/urgent-fix # Switch to another branch
359
+ # ... do urgent work ...
360
+ guito sw - # Switch back
361
+ guito stl # List stashes to find yours
362
+ guito stp # Restore your WIP
363
+ ```
364
+
365
+ ---
366
+
367
+ ## āš™ļø Configuration
368
+
369
+ ### Config File Locations
370
+
371
+ preguito searches for config files in this order:
372
+
373
+ 1. `.preguitorc` (project root)
374
+ 2. `.preguitorc.json` (project root)
375
+ 3. `~/.preguitorc`
376
+ 4. `~/.preguitorc.json`
377
+ 5. `~/.config/preguito/config.json`
378
+ 6. Built-in default: `{{type}}: <message>` with `type=feat`
379
+
380
+ Project-local configs take priority, so different repos can use different templates.
381
+
382
+ ### Config Schema
383
+
384
+ ```json
385
+ {
386
+ "template": "[PAYMENTS-{{card_id}}] {{type}}({{environment}}): <message>",
387
+ "features": {
388
+ "cardId": true,
389
+ "type": true,
390
+ "environment": true
391
+ },
392
+ "types": [
393
+ { "key": "f", "label": "feat" },
394
+ { "key": "x", "label": "fix" }
395
+ ],
396
+ "environments": [
397
+ { "key": "p", "label": "prd" },
398
+ { "key": "u", "label": "uat" }
399
+ ],
400
+ "defaults": {
401
+ "prefix": "PAYMENTS"
402
+ }
403
+ }
404
+ ```
405
+
406
+ ### Per-Project Config
407
+
408
+ Place a `.preguitorc` or `.preguitorc.json` at your project root to share a commit convention with your team:
409
+
410
+ ```json
411
+ {
412
+ "template": "[CHECKOUT-{{card_id}}] {{type}}: <message>",
413
+ "features": { "cardId": true, "type": true, "environment": false },
414
+ "types": [
415
+ { "key": "f", "label": "feat" },
416
+ { "key": "x", "label": "fix" },
417
+ { "key": "c", "label": "chore" }
418
+ ],
419
+ "environments": [],
420
+ "defaults": { "prefix": "CHECKOUT" }
421
+ }
422
+ ```
423
+
424
+ The global config at `~/.config/preguito/config.json` serves as your personal fallback.
425
+
426
+ ---
427
+
428
+ ## šŸ“š Programmatic API
429
+
430
+ preguito exports its core functions for use in other tools:
431
+
432
+ ```typescript
433
+ import {
434
+ parseTemplate,
435
+ renderTemplate,
436
+ mergeContext,
437
+ loadConfig,
438
+ loadConfigOrDefault,
439
+ writeConfig,
440
+ } from "preguito";
441
+
442
+ const parsed = parseTemplate("[{{squad}}] {{type}}: <message>");
443
+ // { variables: ["squad", "type"], messagePlaceholder: "message" }
444
+
445
+ const context = mergeContext({ type: "feat" }, { type: "fix" });
446
+ // { type: "fix" }
447
+
448
+ const msg = renderTemplate(
449
+ "[{{squad}}] {{type}}: <message>",
450
+ { squad: "TEAM", type: "fix" },
451
+ "resolve timeout"
452
+ );
453
+ // "[TEAM] fix: resolve timeout"
454
+ ```
455
+
456
+ ---
457
+
458
+ ## ā“ FAQ
459
+
460
+ **Can I use preguito without running `guito i` first?**
461
+ Yes. Without a config, preguito uses the built-in default template `{{type}}: <message>` with `type=feat`. Just run `guito c f "your message"`.
462
+
463
+ **Can my team share a config?**
464
+ Yes. Place a `.preguitorc` or `.preguitorc.json` in your project root and commit it. Everyone on the team will use the same template and shortcodes.
465
+
466
+ **Does it work without Node.js?**
467
+ Yes. Download the standalone `.deb` binary from GitHub Releases — it bundles everything via Node.js SEA.
468
+
469
+ **What if I need different templates per project?**
470
+ Project-local config (`.preguitorc` in repo root) takes priority over global config. Each repo can have its own template, types, and environments.
471
+
472
+ **Can I customize the shortcode letters?**
473
+ Yes. During `guito i` setup, you can reassign any letter to any type or environment. Run `guito i` again to reconfigure.
474
+
475
+ ---
476
+
477
+ ## šŸ¤– Claude Code Integration
478
+
479
+ preguito has an official [Claude Code skill](https://github.com/jacodoisdois/preguito-skill) that teaches Claude the full `guito` command syntax, template system, and shortcodes.
480
+
481
+ ```bash
482
+ npx skills add jacodoisdois/preguito-skill -g
483
+ ```
484
+
485
+ Once installed, Claude Code will:
486
+
487
+ - Automatically use `guito c` instead of `git commit` in preguito projects
488
+ - Read your `.preguitorc` config to determine the correct shortcodes and card ID format
489
+ - Offer a `/guito-commit` slash command for interactive commit crafting with dry-run preview
490
+
491
+ ---
492
+
493
+ ## šŸ¤ Contributing
494
+
495
+ ```bash
496
+ git clone https://github.com/jacodoisdois/preguito.git
497
+ cd preguito/packages/preguito
498
+ npm install
499
+ ```
500
+
501
+ | Script | Description |
502
+ |--------|-------------|
503
+ | `npm run dev` | Watch mode (tsdown) |
504
+ | `npm test` | Run tests (vitest) |
505
+ | `npm run lint` | Type check (tsc --noEmit) |
506
+ | `npm run build` | Production build |
507
+ | `npm run build:sea` | Build standalone binary (Node.js SEA) |
508
+ | `npm run build:deb` | Build .deb package |
509
+
510
+ **Tech stack:** TypeScript, Commander.js, tsdown (Rolldown-based bundler), Vitest.
511
+
512
+ ---
513
+
514
+ ## šŸ“„ License
515
+
516
+ MIT
package/dist/cli-sea.cjs CHANGED
@@ -4121,7 +4121,7 @@ function registerDiffCommand(program) {
4121
4121
  //#endregion
4122
4122
  //#region src/cli.ts
4123
4123
  const program = new Command();
4124
- program.name("guito").description("preguito - a lazy git CLI with commit templates and shortcuts").version("0.2.2").addHelpText("before", "\n🦄 preguito v0.1.0\n A lazy git CLI with commit templates and shortcuts.\n");
4124
+ program.name("guito").description("preguito - a lazy git CLI with commit templates and shortcuts").version("0.2.3").addHelpText("before", "\n🦄 preguito v0.1.0\n A lazy git CLI with commit templates and shortcuts.\n");
4125
4125
  registerCommitCommand(program);
4126
4126
  registerAmendPushCommands(program);
4127
4127
  registerRebaseCommands(program);
package/dist/cli.mjs CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env node
2
- #!/usr/bin/env node
3
1
  import { Command } from "commander";
4
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
5
3
  import { existsSync } from "node:fs";
@@ -1190,7 +1188,7 @@ function registerDiffCommand(program) {
1190
1188
  //#endregion
1191
1189
  //#region src/cli.ts
1192
1190
  const program = new Command();
1193
- program.name("guito").description("preguito - a lazy git CLI with commit templates and shortcuts").version("0.2.2").addHelpText("before", "\n🦄 preguito v0.1.0\n A lazy git CLI with commit templates and shortcuts.\n");
1191
+ program.name("guito").description("preguito - a lazy git CLI with commit templates and shortcuts").version("0.2.3").addHelpText("before", "\n🦄 preguito v0.1.0\n A lazy git CLI with commit templates and shortcuts.\n");
1194
1192
  registerCommitCommand(program);
1195
1193
  registerAmendPushCommands(program);
1196
1194
  registerRebaseCommands(program);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "preguito",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A lazy git CLI tool with commit templates and shortcuts",
5
5
  "type": "module",
6
6
  "bin": {
7
- "guito": "./dist/cli.mjs"
7
+ "guito": "./dist/cli-sea.cjs"
8
8
  },
9
9
  "files": [
10
10
  "dist"