gflows 0.1.18 → 1.0.1

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 (49) hide show
  1. package/AGENTS.md +78 -0
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +279 -505
  4. package/llms.txt +22 -0
  5. package/package.json +29 -23
  6. package/src/cli.ts +21 -367
  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 -21
  16. package/src/commands/init.ts +99 -18
  17. package/src/commands/list.ts +6 -1
  18. package/src/commands/mcp.ts +239 -0
  19. package/src/commands/pr.ts +120 -0
  20. package/src/commands/schema.ts +99 -0
  21. package/src/commands/start.ts +33 -31
  22. package/src/commands/status.ts +70 -51
  23. package/src/commands/switch.ts +14 -19
  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 +391 -0
  41. package/src/tui/HubShell.tsx +193 -0
  42. package/src/tui/flows.tsx +229 -0
  43. package/src/tui/hub.ts +114 -0
  44. package/src/tui/prompts.tsx +207 -0
  45. package/src/tui/slash.ts +63 -0
  46. package/src/types.ts +62 -3
  47. package/src/ui.ts +132 -0
  48. package/src/version.ts +24 -0
  49. package/src/viz.ts +294 -0
package/README.md CHANGED
@@ -1,556 +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` / `--destroy` / `--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
- | **Destroy** | Delete current branch and switch to the target branch (cannot destroy main or dev). |
408
- | **Cancel** | Abort switching. |
409
143
 
410
- 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`).
411
144
 
412
- **Examples:**
145
+ ### 1. Set up the repo (once)
413
146
 
414
147
  ```bash
415
- bun gflows switch
416
- bun gflows switch feature/auth-refactor
417
- bun gflows switch dev --restore
418
- bun gflows switch main --clean
419
- bun gflows switch dev --destroy
420
- bun gflows -W feature/auth-refactor
148
+ cd your-repo # must already be a git repo with main
149
+ # Hub: g → select “Initialize repo”
421
150
  ```
422
151
 
423
- **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` |
424
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 `--`).
425
159
 
426
- | Flag | Short | Description |
427
- | -------------- | ----- | --------------------------------------------------------------------------- |
428
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
429
- | `--branch <name>` | `-B` | Branch to switch to (alternative to positional). |
430
- | `--move` | — | Move current changes to the target branch; no prompt. |
431
- | `--restore` | — | Save for this branch; restore target's saved state (if any); no prompt. |
432
- | `--clean` | — | Discard changes and switch clean at HEAD; no prompt. |
433
- | `--destroy` | — | Delete current branch and switch to target; no prompt (not main/dev). |
434
- | `--cancel` | — | Abort switching; no prompt. |
435
- | `--verbose` | `-v` | Verbose output. |
436
- | `--quiet` | `-q` | Minimal output (suppresses Clean warning about saved changes on target). |
160
+ ### 2. Ship a feature
437
161
 
162
+ **Easiest — hub (select + prompts):**
438
163
 
439
- ---
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
+ ```
440
170
 
441
- ### delete
171
+ **Or type it** (`alias g=gflows`):
442
172
 
443
- 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` |
444
177
 
445
- **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.
446
180
 
447
181
  ```bash
448
- bun gflows delete
449
- bun gflows delete feature/old-spike
450
- bun gflows delete feature/one feature/two
182
+ gflows viz # branch map in the scrollback (no fullscreen menu)
451
183
  ```
452
184
 
453
- **Flags:**
454
-
185
+ ---
455
186
 
456
- | Flag | Short | Description |
457
- | -------------- | ----- | --------------------- |
458
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
459
- | `--verbose` | `-v` | Verbose output. |
460
- | `--quiet` | `-q` | Minimal output. |
461
187
 
462
188
 
463
- ---
189
+ ## Everyday recipes
464
190
 
465
- ### list
191
+ Hub: `g` → select the action. Typed short form assumes `alias g=gflows`.
466
192
 
467
- List workflow branches (one per line). Filter by type; use `-r` to include remote (may run `git fetch`).
193
+ **Feature dev**
468
194
 
469
- **Examples:**
470
195
 
471
- ```bash
472
- bun gflows list
473
- bun gflows list feature
474
- bun gflows list -r
475
- ```
196
+ | Long | Short |
197
+ | ------------------------------- | ------------------ |
198
+ | `gflows start feature payments` | `g -S -f payments` |
199
+ | `gflows finish feature -y -P` | `g -F -f -y -P` |
476
200
 
477
- **Flags:**
478
201
 
479
202
 
480
- | Flag | Short | Description |
481
- | ------------------ | ----- | ------------------------------------------------------- |
482
- | `--include-remote` | `-r` | Include remote-tracking branches (may run `git fetch`). |
483
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
484
- | `--dry-run` | `-d` | Log intended actions only. |
485
- | `--verbose` | `-v` | Verbose output. |
486
- | `--quiet` | `-q` | Minimal output. |
487
203
 
204
+ **Production bugfix (from main)** — merges **main**, then **main → dev**
488
205
 
489
- ---
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` |
490
210
 
491
- ### bump
211
+ **Release** — tag on finish; merges **main**, then **main → dev**
492
212
 
493
- 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` |
494
218
 
495
- **Examples:**
219
+ **Hotfix**
496
220
 
497
- ```bash
498
- bun gflows bump up patch
499
- bun gflows bump down minor
500
- bun gflows bump --dry-run
501
- ```
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` |
502
225
 
503
- **Flags:**
226
+ **Stuck after a conflict** — fix files and `git add` before `continue`
504
227
 
228
+ | Long | Short |
229
+ |------|-------|
230
+ | `gflows continue` | — |
231
+ | `gflows abort` | — |
232
+ | `gflows undo` | — |
233
+ | `gflows doctor` | — |
505
234
 
506
- | Flag | Short | Description |
507
- | -------------- | ----- | --------------------------------------------- |
508
- | `--dry-run` | `-d` | Print old → new version only; no file writes. |
509
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
510
- | `--verbose` | `-v` | Verbose output. |
511
- | `--quiet` | `-q` | Minimal output. |
512
235
 
513
236
 
514
237
  ---
515
238
 
516
- ### status
517
239
 
518
- Shows current branch, type, base, merge target(s), ahead/behind. Read-only.
519
240
 
520
- **Examples:**
241
+ ## Hub controls
521
242
 
522
- ```bash
523
- bun gflows status
524
- bun gflows -t
525
- ```
243
+ Bare `gflows` / `g` in a **TTY** opens the Ink hub (see [Way 1](#way-1--hub-recommended-for-humans)).
526
244
 
527
- **Flags:**
528
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 |
529
252
 
530
- | Flag | Short | Description |
531
- | -------------- | ----- | --------------------- |
532
- | `--path <dir>` | `-C` | Run as if in `<dir>`. |
533
- | `--verbose` | `-v` | Verbose output. |
534
- | `--quiet` | `-q` | Minimal output. |
535
253
 
254
+ **Non-TTY never opens the hub** — pass full args (CI/agents).
536
255
 
537
256
  ---
538
257
 
539
- ### completion
540
258
 
541
- Prints completion script for bash/zsh/fish. See [Shell completion](#shell-completion).
542
259
 
543
- ### help & version
544
-
545
- `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`.
546
347
 
547
348
  ---
548
349
 
549
- ## Configuration
550
350
 
551
- Optional. Override main, dev, remote, prefixes. Resolution: defaults → `.gflows.json` or `package.json` "gflows" key → CLI flags. Invalid config is ignored (`-v` for warning).
552
351
 
553
- ### 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`):
554
355
 
555
356
  ```json
556
357
  {
@@ -568,125 +369,98 @@ Optional. Override main, dev, remote, prefixes. Resolution: defaults → `.gflow
568
369
  }
569
370
  ```
570
371
 
571
- ### Example: minimal
572
-
573
- ```json
574
- { "main": "master", "dev": "develop" }
372
+ ```bash
373
+ gflows config get main
374
+ gflows config set dev develop
575
375
  ```
576
376
 
577
- Or in `package.json`: `"gflows": { "main": "main", "dev": "development", "remote": "upstream" }`
377
+ CLI `--main` / `--dev` / `-R` override for a single run.
578
378
 
579
379
  ---
580
380
 
581
- ## Scripting and CI
582
381
 
583
- 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.
584
382
 
585
- ```bash
586
- bun gflows finish feature -B feature/add-login --push -y
587
- bun gflows list feature | while read -r b; do echo "$b"; done
588
- bun gflows -C ./packages/api list
589
- ```
383
+ ## Scripting & CI
590
384
 
591
- ---
385
+ Rules of thumb:
592
386
 
593
- ## 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**.
594
390
 
595
- | Code | Meaning | Typical causes |
596
- | ----- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
597
- | **0** | Success | Command completed without error. |
598
- | **1** | Usage / validation | Missing type or name for `start`; invalid branch name or version; wrong/missing positionals when not TTY. |
599
- | **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` | — |
600
398
 
601
- ---
399
+ **Exit codes:** `0` ok · `1` usage/validation · `2` git/system (conflict, dirty tree, empty finish, …)
602
400
 
603
- ## Troubleshooting
401
+ **Agents:** [AGENTS.md](AGENTS.md) · `gflows schema` · `gflows mcp`
604
402
 
605
- | Situation | What to do |
606
- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
607
- | **"Not a Git repository"** | Run from a directory that contains `.git`, or use `-C <path>` to point to the repo root. |
608
- | **"Working tree has uncommitted changes"** | Commit or stash changes before `start`, or use `--force` (only when you intend to carry uncommitted work). |
609
- | **"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. |
610
- | **"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. |
611
- | **"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. |
612
- | **"HEAD is detached"** | Checkout a branch (e.g. `git checkout dev`) before running `start` or `finish`. |
613
- | **"A rebase or merge is in progress"** | Run `git rebase --abort` or `git merge --abort`, or complete the operation, then retry gflows. |
614
- | **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`). |
615
- | **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
+ ---
616
404
 
617
405
 
618
- Use `-v` for verbose git commands and diagnostics.
619
406
 
620
- ---
407
+ ## Troubleshooting
621
408
 
622
- ## Shell completion
623
409
 
624
- **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
+
625
421
 
626
422
  ```bash
627
- source <(bun gflows completion bash)
628
- echo 'source <(bun gflows completion bash)' >> ~/.bashrc
423
+ gflows doctor
424
+ gflows viz
629
425
  ```
630
426
 
631
- **Zsh:**
427
+ ---
428
+
632
429
 
633
- ```bash
634
- source <(bun gflows completion zsh)
635
- echo 'source <(bun gflows completion zsh)' >> ~/.zshrc
636
- ```
637
430
 
638
- **Fish:**
431
+ ## Shell completion
639
432
 
640
433
  ```bash
641
- bun gflows completion fish | source
642
- 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
643
442
  ```
644
443
 
645
444
  ---
646
445
 
446
+
447
+
647
448
  ## Publishing (maintainers)
648
449
 
649
- 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`.
650
451
 
651
452
  ```bash
652
- bun run publish:all
653
- bun run publish:all -- --dry-run
654
- bun run publish:npm
655
- bun run publish:jsr
656
- bun run publish:all -- --force
453
+ bun run publish:all # or publish:npm / publish:jsr
657
454
  ```
658
455
 
659
- ### Typical release workflow
456
+ Link the JSR package to this GitHub repo for provenance; set `NPM_TOKEN` in Actions secrets.
660
457
 
661
- 1. Ensure you’re on **main** with a clean working tree (or use `--force` when intentional).
662
- 2. Bump version and tag in Git yourself, or use gflows bump + your own commit:
663
- ```bash
664
- gflows bump up minor --dry-run # confirm
665
- gflows bump up minor
666
- git add package.json jsr.json && git commit -m "chore: bump to 1.4.0"
667
- ```
668
- 3. Run the publish script:
669
- ```bash
670
- bun run publish:all -- --dry-run # verify
671
- bun run publish:all
672
- ```
673
- 4. Optionally push main and tags:
674
- ```bash
675
- git push origin main --tags
676
- ```
677
-
678
- **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.
679
-
680
- ### JSR score (100%)
681
-
682
- To get a 100% score on [JSR](https://jsr.io/@alialnaghmoush/gflows/score):
458
+ ---
683
459
 
684
- 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.
685
- 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**.
686
- 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.
687
460
 
688
- ---
689
461
 
690
462
  ## License
691
463
 
692
- 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)