gflows 0.1.17 → 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 (48) hide show
  1. package/AGENTS.md +78 -0
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +279 -502
  4. package/llms.txt +22 -0
  5. package/package.json +30 -23
  6. package/src/cli.ts +21 -364
  7. package/src/commands/abort.ts +39 -0
  8. package/src/commands/bump.ts +10 -10
  9. package/src/commands/completion.ts +14 -4
  10. package/src/commands/config.ts +123 -0
  11. package/src/commands/continue.ts +40 -0
  12. package/src/commands/delete.ts +4 -4
  13. package/src/commands/doctor.ts +143 -0
  14. package/src/commands/finish.ts +363 -137
  15. package/src/commands/help.ts +29 -20
  16. package/src/commands/init.ts +99 -18
  17. package/src/commands/list.ts +6 -1
  18. package/src/commands/mcp.ts +238 -0
  19. package/src/commands/pr.ts +120 -0
  20. package/src/commands/schema.ts +98 -0
  21. package/src/commands/start.ts +33 -31
  22. package/src/commands/status.ts +70 -51
  23. package/src/commands/switch.ts +50 -20
  24. package/src/commands/sync.ts +160 -0
  25. package/src/commands/undo.ts +78 -0
  26. package/src/commands/version.ts +3 -15
  27. package/src/commands/viz.ts +18 -0
  28. package/src/dispatch.ts +21 -0
  29. package/src/errors.ts +55 -12
  30. package/src/flow.ts +157 -0
  31. package/src/git.ts +135 -8
  32. package/src/index.ts +24 -1
  33. package/src/interactive.ts +209 -0
  34. package/src/out.ts +11 -4
  35. package/src/package-scripts.ts +73 -0
  36. package/src/parse.ts +430 -0
  37. package/src/prompts.ts +89 -0
  38. package/src/recommend.ts +132 -0
  39. package/src/run-state.ts +165 -0
  40. package/src/tui/HubHome.tsx +343 -0
  41. package/src/tui/HubShell.tsx +186 -0
  42. package/src/tui/flows.tsx +140 -0
  43. package/src/tui/hub.ts +89 -0
  44. package/src/tui/prompts.tsx +207 -0
  45. package/src/types.ts +63 -4
  46. package/src/ui.ts +132 -0
  47. package/src/version.ts +24 -0
  48. package/src/viz.ts +294 -0
package/README.md CHANGED
@@ -1,553 +1,357 @@
1
- # gFlows
1
+ # gflows
2
2
 
3
- A lightweight CLI for consistent Git branching workflows: long-lived **main** (production) and **dev** (integration), plus short-lived workflow branches with clear merge targets. Built for [Bun](https://bun.sh) and TypeScript; **scriptable** and **safe by default**—no history rewriting, predictable exit codes, and optional interactive pickers only when running in a TTY.
3
+ [![npm](https://img.shields.io/npm/v/gflows.svg)](https://www.npmjs.com/package/gflows)
4
+ [![JSR](https://jsr.io/badges/@alialnaghmoush/gflows)](https://jsr.io/@alialnaghmoush/gflows)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![Bun](https://img.shields.io/badge/runtime-Bun-fbf0df?logo=bun&logoColor=black)](https://bun.sh)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
+ [![Ink](https://img.shields.io/badge/UI-Ink-E88C4A)](https://term.ink)
4
9
 
5
- **Author:** [Ali AlNaghmoush](https://github.com/alialnaghmoush) · **Repository:** [github.com/alialnaghmoush/gflows](https://github.com/alialnaghmoush/gflows)
10
+ **Git branching that stays simple.**
11
+ Long-lived `main` + `dev`, short-lived typed branches, clear merge targets — as a Bun/TypeScript CLI.
6
12
 
7
- ---
8
-
9
- ## Table of contents
10
-
11
- **Get started**
12
-
13
- - [Prerequisites](#prerequisites)
14
- - [Installation](#installation)
15
- - [Quick start](#quick-start)
16
-
17
- **Understand**
18
-
19
- - [Concepts](#concepts)
20
- - [Flowcharts](#flowcharts)
21
- - [Branch types in detail](#branch-types-in-detail)
22
-
23
- **Reference**
24
13
 
25
- - [Command reference](#command-reference)
14
+ | You want… | Do this |
15
+ | --------------------- | ---------------------------------------------------------------------- |
16
+ | Just pick from a menu | `gflows` or `g` → [hub](#three-ways-to-run-gflows) |
17
+ | Type commands | [5-minute path](#5-minute-path) · [cheat sheet](#command-cheat-sheet) |
18
+ | Agents / CI | [AGENTS.md](AGENTS.md) · `gflows schema` · [Scripting](#scripting--ci) |
26
19
 
27
- **Configure & operate**
28
-
29
- - [Configuration](#configuration)
30
- - [Scripting and CI](#scripting-and-ci)
31
- - [Exit codes](#exit-codes)
32
- - [Troubleshooting](#troubleshooting)
33
-
34
- **More**
35
-
36
- - [Shell completion](#shell-completion)
37
- - [Publishing (maintainers)](#publishing-maintainers)
38
- - [License](#license)
39
20
 
40
21
  ---
41
22
 
42
- ## Prerequisites
43
23
 
44
- - **Bun** ≥ 1.0 (recommended). The CLI runs TypeScript directly.
45
- - **Git** for repository operations.
46
24
 
47
- Check versions:
25
+ ## Three ways to run gflows
48
26
 
49
- ```bash
50
- bun --version
51
- git --version
52
- ```
53
27
 
54
- ---
28
+ | Way | When | Example |
29
+ | -------------------- | -------------------- | -------------------------------------------------------------- |
30
+ | **1. Hub (select)** | Daily, in a terminal | `gflows` / `g` → select or `/start` — wizards stay in Ink |
31
+ | **2. Long commands** | Scripts, clarity | `gflows start feature payments` |
32
+ | **3. Short flags** | Fast typing | `g -S -f payments` |
55
33
 
56
- ## Installation
57
34
 
58
- **Dev dependency (recommended):** `bun add --dev gflows` or `npm install --save-dev gflows`.
59
- **JSR:** `npx jsr add --dev @alialnaghmoush/gflows` or `deno add --dev jsr:@alialnaghmoush/gflows`.
60
35
 
61
- Run with `bunx gflows ...` or `npx gflows ...`. [npm](https://www.npmjs.com/package/gflows) · [JSR](https://jsr.io/@alialnaghmoush/gflows)
62
36
 
63
- **Global:** `bun add --global gflows` or `npm install --global gflows`
64
-
65
- ---
66
-
67
- ## Quick start
68
-
69
- **1. One-time setup** — In your repo, ensure `main` exists and create `dev`:
37
+ ### Way 1 Hub (recommended for humans)
70
38
 
71
39
  ```bash
72
- bun gflows init
40
+ # optional, once — put in ~/.zshrc or ~/.bashrc
41
+ alias g=gflows
42
+ # or if gflows is only a project dependency:
43
+ alias g='bunx gflows'
73
44
  ```
74
45
 
75
- Use `--no-push` to skip push, `--dry-run` to preview. Pass `--main`, `--dev`, `--remote` to persist to `.gflows.json`.
46
+ Then:
76
47
 
77
48
  ```bash
78
- bun gflows init --main main --dev develop --remote origin
49
+ g # or: gflows
79
50
  ```
80
51
 
81
- **2. Daily development** (feature dev):
52
+ You get a fullscreen menu: what’s next, branch map, actions. **Select** an item (or type `/start`, `/finish`, `/sync`, …). Follow-up questions (type, name, push, rebase) stay **inside the Ink UI** — no drop-out to a separate prompt tool. Only the git command itself runs on the main screen, then you press enter to return.
82
53
 
83
- ```bash
84
- bun gflows start feature add-login
85
- # ... code, commit ...
86
- bun gflows finish feature
87
- bun gflows finish feature --push
88
- bun gflows finish feature --push -D
89
54
  ```
90
-
91
- **3. Release** (dev → main, then tag):
92
-
93
- ```bash
94
- bun gflows bump up minor
95
- bun gflows start release v1.3.0
96
- # ... update CHANGELOG, commit ...
97
- bun gflows finish release --push
55
+ ❯ ★ Start new work
56
+ Sync with base
57
+ Open pull request
58
+ Finish / merge branch
59
+
98
60
  ```
99
61
 
100
- **4. Hotfix** (main → fix → main + dev):
101
62
 
102
- ```bash
103
- bun gflows start hotfix v1.3.1
104
- # ... fix, commit ...
105
- bun gflows finish hotfix --push
106
- ```
107
63
 
108
- ---
64
+ ### Way 2 & 3 — Type it yourself
109
65
 
110
- ## Concepts
66
+ Same job, no menu (`alias g=gflows`):
111
67
 
112
- - **main** Production branch. Only release and hotfix merge here.
113
- - **dev** — Integration branch. Feature, bugfix, chore, spike merge here. Created by `gflows init` from main.
114
- - **Workflow branches** Short-lived branches with a type prefix; each has a base and merge target(s). No history rewriting.
115
- - **Merge targets:** feature/chore/spike dev; bugfix dev (or main with `-o main`); release/hotfix → main then dev + tag.
68
+ | Long | Short |
69
+ |------|-------|
70
+ | `gflows start feature payments` | `g -S -f payments` |
71
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
116
72
 
117
- Override names and prefixes via [configuration](#configuration).
73
+ CI and agents should always use **typed** commands (never the hub). See [Scripting & CI](#scripting--ci).
118
74
 
119
75
  ---
120
76
 
121
- ## Flowcharts
122
-
123
- ### Lifecycle (init → start → finish)
124
-
125
- ```mermaid
126
- flowchart LR
127
- subgraph setup["One-time setup"]
128
- A[main exists] --> B["bun gflows init"]
129
- B --> C[dev created]
130
- C --> D[optional: push dev]
131
- end
132
- subgraph daily["Daily workflow"]
133
- E["bun gflows start<br/>type name"] --> F[work & commit]
134
- F --> G["bun gflows finish<br/>type"]
135
- G --> H{type?}
136
- H -->|feature/bugfix/chore/spike| I[merged to dev]
137
- H -->|release/hotfix| J[merged to main → dev + tag]
138
- end
139
- setup --> daily
140
- ```
141
77
 
142
- ### init
143
-
144
- ```mermaid
145
- flowchart TD
146
- Start([bun gflows init]) --> Repo{In git repo?}
147
- Repo -->|no| ErrRepo[Exit: Not a repo]
148
- Repo -->|yes| MainExists{main branch exists?}
149
- MainExists -->|no| ErrMain[Exit: Create main first]
150
- MainExists -->|yes| DevExists{dev branch exists?}
151
- DevExists -->|yes| DoneNoOp[Done: nothing to do]
152
- DevExists -->|no| CreateDev[Create dev from main]
153
- CreateDev --> Push{--no-push?}
154
- Push -->|no| DoPush[Push dev to remote]
155
- Push -->|yes| SkipPush[Skip push]
156
- DoPush --> Done[Done]
157
- SkipPush --> Done
158
- DoneNoOp --> Done
159
- ```
160
78
 
161
- ### start
162
-
163
- ```mermaid
164
- flowchart TD
165
- Start([bun gflows start type name]) --> Repo{In git repo?}
166
- Repo -->|no| ErrRepo[Exit: Not a repo]
167
- Repo -->|yes| Clean{Tree clean or --force?}
168
- Clean -->|no| ErrDirty[Exit: Uncommitted changes]
169
- Clean -->|yes| Base[Resolve base branch for type]
170
- Base --> BaseExists{Base exists locally or remote?}
171
- BaseExists -->|no| ErrBase[Exit: Base not found]
172
- BaseExists -->|yes| Create[Create workflow branch from base]
173
- Create --> PushOpt{--push?}
174
- PushOpt -->|yes| Push[Push new branch to remote]
175
- PushOpt -->|no| Done[Done]
176
- Push --> Done
177
- ```
79
+ ## Why gflows?
178
80
 
179
- ### finish (merge targets by branch type)
180
-
181
- ```mermaid
182
- flowchart TD
183
- Start([bun gflows finish type]) --> Resolve[Resolve branch to finish]
184
- Resolve --> T{type}
185
- T -->|feature / chore / spike| M1[Merge → dev]
186
- T -->|bugfix from dev| M1
187
- T -->|bugfix from main| M2[Merge → main]
188
- T -->|release| M3[Merge → main]
189
- M3 --> M3b[Merge main → dev]
190
- M3b --> Tag1[Create tag]
191
- T -->|hotfix| M4[Merge → main]
192
- M4 --> M4b[Merge main → dev]
193
- M4b --> Tag2[Create tag]
194
- M2 --> M2b[Merge main → dev]
195
- M1 --> Opt[Optional: delete branch, push]
196
- M2b --> Opt
197
- Tag1 --> Opt
198
- Tag2 --> Opt
199
- Opt --> Done([Done])
200
- ```
201
-
202
- ### Branch types and merge targets
203
-
204
- ```mermaid
205
- flowchart TB
206
- subgraph longlived["Long-lived branches"]
207
- main[main]
208
- dev[dev]
209
- end
210
- subgraph workflow["Workflow branches"]
211
- feature[feature/...]
212
- bugfix[bugfix/...]
213
- chore[chore/...]
214
- release[release/...]
215
- hotfix[hotfix/...]
216
- spike[spike/...]
217
- end
218
- feature --> dev
219
- chore --> dev
220
- spike --> dev
221
- bugfix --> dev
222
- bugfix -.->|"-o main"| main
223
- release --> main
224
- main --> dev
225
- release -.-> dev
226
- hotfix --> main
227
- main --> dev
228
- hotfix -.-> dev
229
- ```
81
+ Most teams reinvent the same rules: features go to `dev`, releases hit `main`, hotfixes sync back. gflows encodes that so you stop typing fragile git-flow by hand.
230
82
 
231
- ### bump (version)
232
-
233
- ```mermaid
234
- flowchart LR
235
- Start([bun gflows bump direction type]) --> Discover[Discover package.json, jsr.json]
236
- Discover --> Read[Read version from primary root]
237
- Read --> Calc[Compute new version]
238
- Calc --> Write[Write to all roots]
239
- Write --> Done([Done])
240
- ```
83
+ - **Safe defaults** — no history rewrite; finish refuses empty/dirty work; delete-after-finish is on (opt out with `-N`)
84
+ - **Human + machine** — Ink hub in a TTY; explicit flags in CI; JSON + MCP for agents
85
+ - **Recoverable** — `continue` / `abort` / `undo` after conflicts
241
86
 
242
87
  ---
243
88
 
244
- ## Branch types in detail
245
-
246
- | Type | Short | Base (default) | With `-o main` | Merge target(s) | Tag |
247
- | ------- | ----- | -------------- | -------------- | -------------------------- | --- |
248
- | feature | `-f` | dev | — | dev | no |
249
- | bugfix | `-b` | dev | main | dev (or main if from main) | no |
250
- | chore | `-c` | dev | — | dev | no |
251
- | release | `-r` | dev | — | main, then dev | yes |
252
- | hotfix | `-x` | main | — | main, then dev | yes |
253
- | spike | `-e` | dev | — | dev | no |
254
-
255
- Release and hotfix names must be a version (`vX.Y.Z` or `X.Y.Z`). Branch names use default prefixes (e.g. `feature/add-login`); override in [configuration](#configuration). Invalid names (e.g. `..`, `*`, spaces) → exit 1.
256
-
257
- ---
258
-
259
- ## Command reference
260
-
261
- ### Summary table
262
-
263
- | Command | Short | Description |
264
- | ------------ | ----- | ------------------------------------------------------------------------- |
265
- | `init` | `-I` | Ensure main exists; create dev from main. |
266
- | `start` | `-S` | Create a workflow branch (requires type + name). |
267
- | `finish` | `-F` | Merge branch into target(s), optional tag (release/hotfix), delete, push. |
268
- | `switch` | `-W` | Switch to a workflow branch (picker or name); with uncommitted changes: prompt or `--move` / `--restore` / `--clean` / `--cancel`. |
269
- | `delete` | `-L` | Delete local workflow branch(es). Never main/dev. |
270
- | `list` | `-l` | List workflow branches; optional type filter and remote. |
271
- | `bump` | — | Bump or rollback package version (patch/minor/major). |
272
- | `completion` | — | Print shell completion script (bash/zsh/fish). |
273
- | `status` | `-t` | Show current branch, type, base, merge target(s), ahead/behind. |
274
- | `help` | `-h` | Show usage and quick reference. |
275
- | `version` | `-V` | Show version. |
276
-
277
89
 
278
- **Common flags:**
279
90
 
91
+ ## Install
280
92
 
281
- | Flag | Short | Description |
282
- | ----------------- | ----- | ------------------------------------- |
283
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
284
- | `--dry-run` | `-d` | Log intended actions only; no writes. |
285
- | `--verbose` | `-v` | Verbose output. |
286
- | `--quiet` | `-q` | Minimal output. |
287
- | `--push` | `-p` | Push after init/start/finish. |
288
- | `--no-push` | `-P` | Do not push. |
289
- | `--main <name>` | — | Main branch override. |
290
- | `--dev <name>` | — | Dev branch override. |
291
- | `--remote <name>` | `-R` | Remote for push. |
292
- | `--from <branch>` | `-o` | Base branch override (start). |
293
- | `--branch <name>` | `-B` | Branch name (finish). |
294
- | `--yes` | `-y` | Skip confirmations. |
295
-
296
-
297
- ---
298
-
299
- ### init
300
-
301
- Ensures main exists; creates dev from main if missing. Use `--main`, `--dev`, `-R` to persist to `.gflows.json`.
302
-
303
- **Examples:**
93
+ **Needs:** [Bun](https://bun.sh) 1.0 and Git.
304
94
 
305
95
  ```bash
306
- bun gflows init
307
- bun gflows init --main main --dev develop --remote origin
308
- bun gflows init -C ../other-repo --dry-run
309
- ```
310
-
311
- **Flags:**
312
-
313
-
314
- | Flag | Short | Description |
315
- | ----------------- | ----- | ------------------------------------------------------------- |
316
- | `--push` | `-p` | Push dev to remote after creating (default). |
317
- | `--main <name>` | — | Main branch name (persisted to `.gflows.json` when provided). |
318
- | `--dev <name>` | — | Dev branch name (persisted to `.gflows.json` when provided). |
319
- | `--remote <name>` | `-R` | Remote name (persisted to `.gflows.json` when provided). |
320
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
321
- | `--dry-run` | `-d` | Log intended actions only; no writes. |
322
- | `--verbose` | `-v` | Verbose output. |
323
- | `--quiet` | `-q` | Minimal output. |
324
-
325
-
326
- ---
96
+ # project (recommended)
97
+ bun add --dev gflows
327
98
 
328
- ### start
99
+ # or global
100
+ bun add --global gflows
329
101
 
330
- Creates a workflow branch from the correct base. Requires type + name; release/hotfix name must be a version. Pre-checks: git repo, clean tree (or `--force`), base exists.
102
+ # npm / npx also work
103
+ npm install --save-dev gflows
104
+ ```
331
105
 
332
- **Examples:**
106
+ **JSR:** `[@alialnaghmoush/gflows](https://jsr.io/@alialnaghmoush/gflows)`
333
107
 
334
108
  ```bash
335
- bun gflows start feature auth-refactor
336
- bun gflows start bugfix fix-login --from main
337
- bun gflows start release v2.0.0
338
- bun gflows start hotfix 1.2.1
339
- bun gflows start feature wip --force --push
109
+ bunx gflows version # sanity check
340
110
  ```
341
111
 
342
- **Flags:**
343
-
344
-
345
- | Flag | Short | Description |
346
- | ----------------- | ----- | ------------------------------------------------- |
347
- | `--force` | — | Allow dirty working tree. |
348
- | `--push` | `-p` | Push new branch to remote after creating. |
349
- | `--from <branch>` | `-o` | Base branch override (e.g. `-o main` for bugfix). |
350
- | `--remote <name>` | `-R` | Remote for push. |
351
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
352
- | `--dry-run` | `-d` | Log intended actions only; no writes. |
353
- | `--verbose` | `-v` | Verbose output. |
354
- | `--quiet` | `-q` | Minimal output. |
355
-
356
-
357
112
  ---
358
113
 
359
- ### finish
360
114
 
361
- Merges the branch (current or `-B`) into its target(s). Release/hotfix: merge to main, then main → dev, create tag. Use `--no-ff` for a merge commit. On conflict, resolve then `git merge --continue` or re-run finish.
362
115
 
363
- **Examples:**
116
+ ## Mental model (2 minutes)
364
117
 
365
- ```bash
366
- bun gflows finish feature
367
- bun gflows finish feature -B feature/auth --push -D
368
- bun gflows finish release --push
369
- bun gflows finish hotfix -s -T -y
118
+ ```
119
+ main ← release / hotfix only (production)
120
+
121
+ └──→ dev ← feature / bugfix / chore / spike (integration)
122
+
123
+ short-lived workflow branches
370
124
  ```
371
125
 
372
- **Flags:**
373
126
 
127
+ | Branch | Role |
128
+ | ------------------------------------ | ----------------------------------------------------------- |
129
+ | **main** | Production |
130
+ | **dev** | Integration (created by `init` from main) |
131
+ | **feature / bugfix / chore / spike** | Day-to-day work → merge to **dev** |
132
+ | **release / hotfix** | Versioned (`vX.Y.Z`) → **main**, then **main → dev**, + tag |
374
133
 
375
- | Flag | Short | Description |
376
- | --------------------- | ----- | ------------------------------------------------------------------------------------ |
377
- | `--branch <name>` | `-B` | Branch to finish (current branch if omitted; picker in TTY when `-B` with no value). |
378
- | `--no-ff` | — | Always create a merge commit. |
379
- | `--delete` | `-D` | Delete branch after finish. |
380
- | `--no-delete` | `-N` | Do not delete branch after finish. |
381
- | `--push` | `-p` | Push after merge (finish prompts "Do you want to push?" when neither `-p` nor `-P`). |
382
- | `--no-push` | `-P` | Do not push. |
383
- | `--sign` | `-s` | Sign the tag (release/hotfix; GPG). |
384
- | `--no-tag` | `-T` | Do not create tag (release/hotfix). |
385
- | `--tag-message <msg>` | `-M` | Tag message. |
386
- | `--message <msg>` | `-m` | Merge message. |
387
- | `--yes` | `-y` | Skip confirmations (e.g. "Delete branch after finish?"). |
388
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
389
- | `--dry-run` | `-d` | Log intended actions only; no writes. |
390
- | `--verbose` | `-v` | Verbose output. |
391
- | `--quiet` | `-q` | Minimal output. |
392
134
 
135
+ **Lifecycle:** `init` → `start` → commit → (`sync`) → (`pr`) → `finish`
393
136
 
394
137
  ---
395
138
 
396
- ### switch
397
139
 
398
- Switch to a workflow branch. With TTY and no branch name, shows a picker; otherwise pass the branch name (e.g. `gflows switch dev` or `-B dev`).
399
140
 
400
- **Uncommitted changes:** If the working tree is dirty and stdin is a TTY, you are prompted to choose:
141
+ ## 5-minute path
401
142
 
402
- | Option | Description |
403
- | ------ | ----------- |
404
- | **Move** | Move current changes to the target branch. |
405
- | **Restore** | Save changes for this branch; restore target's saved state (if any). |
406
- | **Clean** | Discard changes and switch clean at HEAD. |
407
- | **Cancel** | Abort switching. |
408
143
 
409
- You can skip the prompt by passing exactly one of the flags below. If the target branch has saved changes and you use **Clean**, a warning is shown (unless `-q`).
410
144
 
411
- **Examples:**
145
+ ### 1. Set up the repo (once)
412
146
 
413
147
  ```bash
414
- bun gflows switch
415
- bun gflows switch feature/auth-refactor
416
- bun gflows switch dev --restore
417
- bun gflows switch main --clean
418
- bun gflows -W feature/auth-refactor
148
+ cd your-repo # must already be a git repo with main
149
+ # Hub: g → select “Initialize repo”
419
150
  ```
420
151
 
421
- **Flags:**
152
+ | Long | Short |
153
+ |------|-------|
154
+ | `gflows init` | `g -I` |
155
+ | `gflows init --no-push -y --script-alias g` | `g -I -P -y --script-alias g` |
422
156
 
157
+ Creates `dev` from `main`. Optional: `--main`, `--dev`, `--remote` → writes `.gflows.json`.
158
+ `--script-alias g` adds `"g": "gflows"` to `package.json` (then `bun run g -- …` — note the `--`).
423
159
 
424
- | Flag | Short | Description |
425
- | -------------- | ----- | --------------------------------------------------------------------------- |
426
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
427
- | `--branch <name>` | `-B` | Branch to switch to (alternative to positional). |
428
- | `--move` | — | Move current changes to the target branch; no prompt. |
429
- | `--restore` | — | Save for this branch; restore target's saved state (if any); no prompt. |
430
- | `--clean` | — | Discard changes and switch clean at HEAD; no prompt. |
431
- | `--cancel` | — | Abort switching; no prompt. |
432
- | `--verbose` | `-v` | Verbose output. |
433
- | `--quiet` | `-q` | Minimal output (suppresses Clean warning about saved changes on target). |
160
+ ### 2. Ship a feature
434
161
 
162
+ **Easiest — hub (select + prompts):**
435
163
 
436
- ---
164
+ ```bash
165
+ g # or gflows
166
+ # select ★ Start new work → answer type / name / push?
167
+ # … edit, git commit …
168
+ g # select Sync / Open PR / Finish when ready
169
+ ```
437
170
 
438
- ### delete
171
+ **Or type it** (`alias g=gflows`):
439
172
 
440
- Delete local workflow branch(es). Never deletes main/dev. TTY: picker; otherwise pass branch name(s).
173
+ | Long | Short |
174
+ |------|-------|
175
+ | `gflows start feature add-login` | `g -S -f add-login` |
176
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
441
177
 
442
- **Examples:**
178
+ Optional: `gflows sync --force` · `gflows pr`
179
+ Finish **deletes** the branch by default (`-N` to keep). Use `-p` instead of `-P` to push.
443
180
 
444
181
  ```bash
445
- bun gflows delete
446
- bun gflows delete feature/old-spike
447
- bun gflows delete feature/one feature/two
182
+ gflows viz # branch map in the scrollback (no fullscreen menu)
448
183
  ```
449
184
 
450
- **Flags:**
451
-
185
+ ---
452
186
 
453
- | Flag | Short | Description |
454
- | -------------- | ----- | --------------------- |
455
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
456
- | `--verbose` | `-v` | Verbose output. |
457
- | `--quiet` | `-q` | Minimal output. |
458
187
 
459
188
 
460
- ---
189
+ ## Everyday recipes
461
190
 
462
- ### list
191
+ Hub: `g` → select the action. Typed short form assumes `alias g=gflows`.
463
192
 
464
- List workflow branches (one per line). Filter by type; use `-r` to include remote (may run `git fetch`).
193
+ **Feature dev**
465
194
 
466
- **Examples:**
467
195
 
468
- ```bash
469
- bun gflows list
470
- bun gflows list feature
471
- bun gflows list -r
472
- ```
196
+ | Long | Short |
197
+ | ------------------------------- | ------------------ |
198
+ | `gflows start feature payments` | `g -S -f payments` |
199
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
473
200
 
474
- **Flags:**
475
201
 
476
202
 
477
- | Flag | Short | Description |
478
- | ------------------ | ----- | ------------------------------------------------------- |
479
- | `--include-remote` | `-r` | Include remote-tracking branches (may run `git fetch`). |
480
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
481
- | `--dry-run` | `-d` | Log intended actions only. |
482
- | `--verbose` | `-v` | Verbose output. |
483
- | `--quiet` | `-q` | Minimal output. |
484
203
 
204
+ **Production bugfix (from main)** — merges **main**, then **main → dev**
485
205
 
486
- ---
206
+ | Long | Short |
207
+ |------|-------|
208
+ | `gflows start bugfix login-crash -o main` | `g -S -b login-crash -o main` |
209
+ | `gflows finish bugfix -y -p` | `g -F -b -y -p` |
487
210
 
488
- ### bump
211
+ **Release** — tag on finish; merges **main**, then **main → dev**
489
212
 
490
- Bump or rollback version in `package.json` and `jsr.json` (monorepo: all discovered roots). No git operations. Direction: `up`|`down`; type: `patch`|`minor`|`major`. TTY: interactive; non-TTY: both required.
213
+ | Long | Short |
214
+ |------|-------|
215
+ | `gflows bump up minor` | `g -U up minor` |
216
+ | `gflows start release v1.4.0` | `g -S -r v1.4.0` |
217
+ | `gflows finish release -y -p` | `g -F -r -y -p` |
491
218
 
492
- **Examples:**
219
+ **Hotfix**
493
220
 
494
- ```bash
495
- bun gflows bump up patch
496
- bun gflows bump down minor
497
- bun gflows bump --dry-run
498
- ```
221
+ | Long | Short |
222
+ |------|-------|
223
+ | `gflows start hotfix v1.4.1` | `g -S -x v1.4.1` |
224
+ | `gflows finish hotfix -y -p` | `g -F -x -y -p` |
499
225
 
500
- **Flags:**
226
+ **Stuck after a conflict** — fix files and `git add` before `continue`
501
227
 
228
+ | Long | Short |
229
+ |------|-------|
230
+ | `gflows continue` | — |
231
+ | `gflows abort` | — |
232
+ | `gflows undo` | — |
233
+ | `gflows doctor` | — |
502
234
 
503
- | Flag | Short | Description |
504
- | -------------- | ----- | --------------------------------------------- |
505
- | `--dry-run` | `-d` | Print old → new version only; no file writes. |
506
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
507
- | `--verbose` | `-v` | Verbose output. |
508
- | `--quiet` | `-q` | Minimal output. |
509
235
 
510
236
 
511
237
  ---
512
238
 
513
- ### status
514
239
 
515
- Shows current branch, type, base, merge target(s), ahead/behind. Read-only.
516
240
 
517
- **Examples:**
241
+ ## Hub controls
518
242
 
519
- ```bash
520
- bun gflows status
521
- bun gflows -t
522
- ```
243
+ Bare `gflows` / `g` in a **TTY** opens the Ink hub (see [Way 1](#way-1--hub-recommended-for-humans)).
523
244
 
524
- **Flags:**
525
245
 
246
+ | Input | Action |
247
+ | ------------------------------------------ | -------------------------------------- |
248
+ | ↑↓ Enter | Select an action — Ink wizard if needed |
249
+ | `/start` `/finish` `/sync` … | Slash command; wizards stay in the hub |
250
+ | `?` | Shortcut help |
251
+ | `q` / Esc / Ctrl+C | Quit |
526
252
 
527
- | Flag | Short | Description |
528
- | -------------- | ----- | --------------------- |
529
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
530
- | `--verbose` | `-v` | Verbose output. |
531
- | `--quiet` | `-q` | Minimal output. |
532
253
 
254
+ **Non-TTY never opens the hub** — pass full args (CI/agents).
533
255
 
534
256
  ---
535
257
 
536
- ### completion
537
258
 
538
- Prints completion script for bash/zsh/fish. See [Shell completion](#shell-completion).
539
259
 
540
- ### help & version
541
-
542
- `bun gflows help` · `bun gflows -V`
260
+ ## Command cheat sheet
261
+
262
+
263
+ | Command | What it does |
264
+ | ----------------------------- | ------------------------------------------- |
265
+ | *(bare)* | Fullscreen hub (TTY only) |
266
+ | `init` `-I` | Ensure main; create dev |
267
+ | `start` `-S` | Create typed branch |
268
+ | `finish` `-F` | Merge + close (plan; delete default **on**) |
269
+ | `sync` | Update branch from its base |
270
+ | `pr` | Open PR/MR (`gh` / `glab`) |
271
+ | `switch` `-W` | Switch branch |
272
+ | `delete` `-L` | Delete local workflow branch(es) |
273
+ | `list` `-l` | List workflow branches |
274
+ | `status` `-t` | Current branch flow info |
275
+ | `viz` | Scrollback visual map |
276
+ | `doctor` | Health checks |
277
+ | `config` | `get` / `set` `.gflows.json` |
278
+ | `bump` `-U` | Version bump/rollback in package files |
279
+ | `continue` / `abort` / `undo` | Recovery |
280
+ | `schema` / `mcp` | Agents & tooling |
281
+ | `completion` | bash / zsh / fish |
282
+ | `help` `-h` · `version` `-V` | Meta |
283
+
284
+
285
+
286
+
287
+ ### Short form (flags)
288
+
289
+ With `alias g=gflows`, replace the words with flags:
290
+
291
+ | Long | Short |
292
+ |------|-------|
293
+ | `init` | `-I` |
294
+ | `start` | `-S` |
295
+ | `finish` | `-F` |
296
+ | `switch` | `-W` |
297
+ | `delete` | `-L` |
298
+ | `list` | `-l` |
299
+ | `status` | `-t` |
300
+ | `bump` | `-U` |
301
+ | `feature` | `-f` |
302
+ | `bugfix` | `-b` |
303
+ | `chore` | `-c` |
304
+ | `release` | `-r` |
305
+ | `hotfix` | `-x` |
306
+ | `spike` | `-e` |
307
+
308
+ | Long | Short |
309
+ |------|-------|
310
+ | `gflows start feature payments` | `g -S -f payments` |
311
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
312
+ | `gflows start bugfix x -o main` | `g -S -b x -o main` |
313
+ | `gflows start release v1.4.0` | `g -S -r v1.4.0` |
314
+ | `gflows start hotfix v1.4.1` | `g -S -x v1.4.1` |
315
+ | `gflows init -y -P` | `g -I -y -P` |
316
+ | `gflows bump up minor` | `g -U up minor` |
317
+ | `gflows bump down patch` | `g -U down patch` |
318
+
319
+ ### Flags you’ll use most
320
+
321
+ | Long | Short |
322
+ |------|-------|
323
+ | `--yes` | `-y` |
324
+ | `--push` | `-p` |
325
+ | `--no-push` | `-P` |
326
+ | `--no-delete` | `-N` |
327
+ | `--delete` | `-D` |
328
+ | `--from <branch>` | `-o <branch>` |
329
+ | `--branch <name>` | `-B <name>` |
330
+ | `--dry-run` | `-d` |
331
+ | `--path <dir>` | `-C <dir>` |
332
+
333
+ Also: `--json` · `--rebase` · `--squash` · `--preview` · `--bump`
334
+ Full list: `gflows help`.
335
+
336
+ ### Finish in one glance
337
+
338
+ | Long | Short |
339
+ |------|-------|
340
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
341
+ | `gflows finish feature -y -p` | `g -F -f -y -p` |
342
+ | `gflows finish feature -y -P -N` | `g -F -f -y -P -N` |
343
+ | `gflows finish feature --preview` | — |
344
+
345
+ `-P` = no push · `-p` = push · `-N` = keep branch
346
+ Non-interactive finish **must** include `-p` or `-P`. Empty branch → exit `2`.
543
347
 
544
348
  ---
545
349
 
546
- ## Configuration
547
350
 
548
- Optional. Override main, dev, remote, prefixes. Resolution: defaults → `.gflows.json` or `package.json` "gflows" key → CLI flags. Invalid config is ignored (`-v` for warning).
549
351
 
550
- ### Example: `.gflows.json` (full)
352
+ ## Configuration
353
+
354
+ Optional `.gflows.json` in the repo root (written by `init` when you pass names, or `gflows config set`):
551
355
 
552
356
  ```json
553
357
  {
@@ -565,125 +369,98 @@ Optional. Override main, dev, remote, prefixes. Resolution: defaults → `.gflow
565
369
  }
566
370
  ```
567
371
 
568
- ### Example: minimal
569
-
570
- ```json
571
- { "main": "master", "dev": "develop" }
372
+ ```bash
373
+ gflows config get main
374
+ gflows config set dev develop
572
375
  ```
573
376
 
574
- Or in `package.json`: `"gflows": { "main": "main", "dev": "development", "remote": "upstream" }`
377
+ CLI `--main` / `--dev` / `-R` override for a single run.
575
378
 
576
379
  ---
577
380
 
578
- ## Scripting and CI
579
381
 
580
- Non-TTY: no pickers; pass branch names explicitly. Use `-y` to skip confirmations. Exit codes: 0 success, 1 validation, 2 Git/state. Use `-C <dir>` to run in another directory.
581
382
 
582
- ```bash
583
- bun gflows finish feature -B feature/add-login --push -y
584
- bun gflows list feature | while read -r b; do echo "$b"; done
585
- bun gflows -C ./packages/api list
586
- ```
383
+ ## Scripting & CI
587
384
 
588
- ---
385
+ Rules of thumb:
589
386
 
590
- ## Exit codes
387
+ 1. Always pass a **command** (no bare hub).
388
+ 2. Finish: `-y` and `-p` **or** `-P`.
389
+ 3. Prefer `--json` for parsers; hints go to **stderr**.
591
390
 
592
- | Code | Meaning | Typical causes |
593
- | ----- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
594
- | **0** | Success | Command completed without error. |
595
- | **1** | Usage / validation | Missing type or name for `start`; invalid branch name or version; wrong/missing positionals when not TTY. |
596
- | **2** | Git / system | Not a repo; branch not found; dirty tree; merge conflict; rebase/merge in progress; detached HEAD; finish on main/dev; tag exists; push failed. |
391
+ | Long | Short |
392
+ |------|-------|
393
+ | `gflows init --no-push -y` | `g -I -P -y` |
394
+ | `gflows start feature ci-check` | `g -S -f ci-check` |
395
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
396
+ | `gflows status --json` | `g -t --json` |
397
+ | `gflows doctor --json` | — |
597
398
 
598
- ---
399
+ **Exit codes:** `0` ok · `1` usage/validation · `2` git/system (conflict, dirty tree, empty finish, …)
599
400
 
600
- ## Troubleshooting
401
+ **Agents:** [AGENTS.md](AGENTS.md) · `gflows schema` · `gflows mcp`
601
402
 
602
- | Situation | What to do |
603
- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
604
- | **"Not a Git repository"** | Run from a directory that contains `.git`, or use `-C <path>` to point to the repo root. |
605
- | **"Working tree has uncommitted changes"** | Commit or stash changes before `start`, or use `--force` (only when you intend to carry uncommitted work). |
606
- | **"Merge conflict while merging into …"** | Resolve conflicts in your working tree, then run `git add` and `git merge --continue` (or `git merge --abort` to cancel). Re-run `gflows finish` after resolving if needed. |
607
- | **"Tag v1.2.3 already exists"** | Use a new version for the release/hotfix, or delete/move the tag if you know what you’re doing. gflows does not overwrite tags. |
608
- | **"Cannot finish the long-lived branch main/dev"** | You’re on main or dev. Checkout a workflow branch first, or use `-B <branch>` to finish another branch. |
609
- | **"HEAD is detached"** | Checkout a branch (e.g. `git checkout dev`) before running `start` or `finish`. |
610
- | **"A rebase or merge is in progress"** | Run `git rebase --abort` or `git merge --abort`, or complete the operation, then retry gflows. |
611
- | **Picker not showing / "requires branch name"** | Without a TTY, gflows does not show interactive pickers. Pass the branch name explicitly (e.g. `-B feature/xyz` or `gflows switch feature/xyz`). |
612
- | **Wrong remote or branch names** | Use `.gflows.json` or `package.json` "gflows" key, or `gflows init --main … --dev … --remote …`. Use `-R` for one-off remote override. |
403
+ ---
613
404
 
614
405
 
615
- Use `-v` for verbose git commands and diagnostics.
616
406
 
617
- ---
407
+ ## Troubleshooting
618
408
 
619
- ## Shell completion
620
409
 
621
- **Bash:**
410
+ | Symptom | Fix |
411
+ | ---------------------- | ------------------------------------------------------ |
412
+ | Hub / pickers missing | Not a TTY — pass branch names and flags explicitly |
413
+ | Finish wants push flag | Add `-p` or `-P` |
414
+ | “Nothing to finish” | Commit on the branch first (ahead of base must be > 0) |
415
+ | Merge conflict | Fix → `git add` → `gflows continue` |
416
+ | Tag already exists | Bump the version; gflows won’t overwrite tags |
417
+ | Can’t finish main/dev | Finish a **workflow** branch (`-B feature/…`) |
418
+ | Detached HEAD | `git checkout dev` (or another branch) first |
419
+ | Wrong base for bugfix | `gflows start bugfix name -o main` |
420
+
622
421
 
623
422
  ```bash
624
- source <(bun gflows completion bash)
625
- echo 'source <(bun gflows completion bash)' >> ~/.bashrc
423
+ gflows doctor
424
+ gflows viz
626
425
  ```
627
426
 
628
- **Zsh:**
427
+ ---
428
+
629
429
 
630
- ```bash
631
- source <(bun gflows completion zsh)
632
- echo 'source <(bun gflows completion zsh)' >> ~/.zshrc
633
- ```
634
430
 
635
- **Fish:**
431
+ ## Shell completion
636
432
 
637
433
  ```bash
638
- bun gflows completion fish | source
639
- bun gflows completion fish > ~/.config/fish/completions/gflows.fish
434
+ # bash
435
+ eval "$(gflows completion bash)"
436
+
437
+ # zsh
438
+ eval "$(gflows completion zsh)"
439
+
440
+ # fish
441
+ gflows completion fish | source
640
442
  ```
641
443
 
642
444
  ---
643
445
 
446
+
447
+
644
448
  ## Publishing (maintainers)
645
449
 
646
- Internal script `scripts/publish.ts`: syncs version from package.json to jsr.json, then publishes to npm and/or JSR. Not in published package.
450
+ CI: `[.github/workflows/publish.yml](.github/workflows/publish.yml)` test, lint, publish npm + JSR on `main`.
647
451
 
648
452
  ```bash
649
- bun run publish:all
650
- bun run publish:all -- --dry-run
651
- bun run publish:npm
652
- bun run publish:jsr
653
- bun run publish:all -- --force
453
+ bun run publish:all # or publish:npm / publish:jsr
654
454
  ```
655
455
 
656
- ### Typical release workflow
456
+ Link the JSR package to this GitHub repo for provenance; set `NPM_TOKEN` in Actions secrets.
657
457
 
658
- 1. Ensure you’re on **main** with a clean working tree (or use `--force` when intentional).
659
- 2. Bump version and tag in Git yourself, or use gflows bump + your own commit:
660
- ```bash
661
- gflows bump up minor --dry-run # confirm
662
- gflows bump up minor
663
- git add package.json jsr.json && git commit -m "chore: bump to 1.4.0"
664
- ```
665
- 3. Run the publish script:
666
- ```bash
667
- bun run publish:all -- --dry-run # verify
668
- bun run publish:all
669
- ```
670
- 4. Optionally push main and tags:
671
- ```bash
672
- git push origin main --tags
673
- ```
674
-
675
- **Version sync:** The script reads `version` from **package.json** and writes it to **jsr.json** before publishing so the two registries never drift. Use `**gflows bump`** to change the version; the script does not bump for you.
676
-
677
- ### JSR score (100%)
678
-
679
- To get a 100% score on [JSR](https://jsr.io/@alialnaghmoush/gflows/score):
458
+ ---
680
459
 
681
- 1. **Description** — Set in `jsr.json` (already added). If the score still shows 0/1, set the description in [package settings](https://jsr.io/@alialnaghmoush/gflows/settings) on JSR.
682
- 2. **Runtime compatibility** — In [package settings](https://jsr.io/@alialnaghmoush/gflows/settings), open “Runtime compatibility” and mark at least **Bun** and **Node.js** (or others) as **Supported**.
683
- 3. **Provenance** — The repo includes `[.github/workflows/publish.yml](.github/workflows/publish.yml)` (test, lint, then publish to npm and JSR). In JSR package settings, **link** the package to this GitHub repository. Add `NPM_TOKEN` in repo Secrets for npm. After that, pushes to `main` run CI and publish both registries; JSR records provenance.
684
460
 
685
- ---
686
461
 
687
462
  ## License
688
463
 
689
- See [LICENSE](LICENSE) in this repository.
464
+ [MIT](LICENSE) · [Ali AlNaghmoush](https://github.com/alialnaghmoush) · [github.com/alialnaghmoush/gflows](https://github.com/alialnaghmoush/gflows)
465
+
466
+ Changelog: [CHANGELOG.md](CHANGELOG.md)