git-workspace-bare 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,27 @@ Manage Git worktrees as development workspaces.
4
4
 
5
5
  The CLI can clone GitHub repositories or initialize them locally, create branch worktrees, list registered checkouts, and unregister them.
6
6
 
7
+ ## Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Manual page](#manual-page)
11
+ - [Bash completion](#bash-completion)
12
+ - [Usage](#usage)
13
+ - [Initialize a manifest repository](#initialize-a-manifest-repository)
14
+ - [Synchronize from the manifest](#synchronize-from-the-manifest)
15
+ - [Add a repository](#add-a-repository)
16
+ - [Add a branch worktree](#add-a-branch-worktree)
17
+ - [Rename commits](#rename-commits)
18
+ - [Rename a root repository](#rename-a-root-repository)
19
+ - [Rename a branch worktree](#rename-a-branch-worktree)
20
+ - [List repositories](#list-repositories)
21
+ - [Check workspace status](#check-workspace-status)
22
+ - [Remove a repository or worktree](#remove-a-repository-or-worktree)
23
+ - [Command hooks](#command-hooks)
24
+ - [Available hooks](#available-hooks)
25
+ - [Errors](#errors)
26
+ - [Development](#development)
27
+
7
28
  ## Installation
8
29
 
9
30
  The CLI runs on [Bare](https://github.com/holepunchto/bare). Install both globally using npm:
@@ -14,6 +35,33 @@ npm install -g bare git-workspace-bare
14
35
 
15
36
  This makes the `git-workspace` command available in your shell. Git also discovers it on your `PATH`, so you can run it as `git workspace`. Bare must be on your `PATH`; Node.js and npm are used for package installation and development tooling.
16
37
 
38
+ For optional integrations such as tmux session management, see [available hooks](#available-hooks).
39
+
40
+ ### Manual page
41
+
42
+ The package includes a `git-workspace(1)` manual covering commands, options,
43
+ manifest synchronization, and hooks:
44
+
45
+ ```sh
46
+ git workspace --help
47
+ git help workspace
48
+ man git-workspace
49
+ ```
50
+
51
+ Global installation (or `npm link` during development) registers the page with npm
52
+ versions that support man-page linking. If your system cannot find it, add this line
53
+ to your shell startup file to include the packaged manual in its search path:
54
+
55
+ ```sh
56
+ export MANPATH="$(npm root -g)/git-workspace-bare/man:${MANPATH:-}"
57
+ ```
58
+
59
+ The trailing empty entry preserves your system's default manual paths. This also
60
+ works with npm 12, which no longer registers man pages automatically.
61
+
62
+ If a shell wrapper intercepts `git workspace --help` and shows CLI usage instead,
63
+ use `git help workspace` or `man git-workspace` to open the manual directly.
64
+
17
65
  ### Bash completion
18
66
 
19
67
  Add this line to `~/.bashrc` (or the startup file your interactive Bash shell loads):
@@ -51,7 +99,7 @@ git workspace rename holepunchto/brittle@jobs holepunchto/brittle@fixes
51
99
  git workspace remove holepunchto/brittle
52
100
  ```
53
101
 
54
- - `--help` (or `-h`) shows the available options.
102
+ - `-h` shows the available options; `git workspace --help` opens the manual page.
55
103
  - `--version` prints the package version.
56
104
 
57
105
  You can also invoke the executable directly, for example `git-workspace list`. Use `git workspace -h` or `git-workspace --help` for CLI help; Git handles `git workspace --help` as a manual-page request.
@@ -412,9 +460,8 @@ Successful removal is silent. Existing checkouts can also be removed if previous
412
460
  ### Command hooks
413
461
 
414
462
  Executables on `PATH` named `git-workspace-hook-<command>-post-<name>` run after
415
- `add`, `remove`, and `rename`, including those operations performed by `pull`. For example,
416
- a separate tmux package could expose `git-workspace-hook-add-post-tmux` and
417
- `git-workspace-hook-remove-post-tmux`. Installing the executables on `PATH` enables them;
463
+ `add`, `remove`, and `rename`, including those operations performed by `pull`.
464
+ Installing the executables on `PATH` enables them;
418
465
  there is no hook directory, registration command, or hook configuration in the manifest.
419
466
 
420
467
  ```sh
@@ -433,6 +480,20 @@ See [Writing command hooks](docs/hooks.md) for the full protocol, npm packaging
433
480
  partial failures, and pull recovery semantics. Hooks must tolerate repeated delivery after
434
481
  an interrupted pull. There are no pre hooks, fetch hooks, or prune hooks in this version.
435
482
 
483
+ #### Available hooks
484
+
485
+ [git-workspace-hook-tmux](https://github.com/nicolasfont/git-workspace-hook-tmux) creates
486
+ detached tmux sessions when checkouts are added, preserves running panes across renames,
487
+ and closes managed sessions when checkouts are removed. Requires tmux on `PATH`.
488
+
489
+ ```sh
490
+ npm install -g git-workspace-hook-tmux
491
+ ```
492
+
493
+ Installation enables its add, remove, and rename hooks automatically. Sessions are never
494
+ attached or switched automatically. Removing a checkout terminates its managed session
495
+ and all programs running in its panes.
496
+
436
497
  ### Errors
437
498
 
438
499
  Failures print an `error:` message to stderr and exit with status 1. The label is red when stderr is a terminal; redirected output stays plain. When available, a separate `hint:` explains the next step:
@@ -0,0 +1,240 @@
1
+ .TH GIT-WORKSPACE 1 "November 8, 2026" "git-workspace-bare" "Git Workspace Manual"
2
+ .SH NAME
3
+ git-workspace \- manage Git repositories and branch worktrees
4
+ .SH SYNOPSIS
5
+ .B git workspace init
6
+ .I owner/repo
7
+ .br
8
+ .B git workspace add
9
+ .RB [ --no-hooks ]
10
+ .I owner/repo[@branch]
11
+ .br
12
+ .B git workspace remove
13
+ .RB [ --no-hooks ]
14
+ .I owner/repo[@branch]
15
+ .br
16
+ .B git workspace rename
17
+ .RB [ --no-hooks ]
18
+ .I from to
19
+ .br
20
+ .B git workspace list
21
+ .br
22
+ .B git workspace status
23
+ .br
24
+ .B git workspace pull
25
+ .RB [ --dry-run ] " [" --no-hooks ]
26
+ .br
27
+ .B git workspace hook list
28
+ .br
29
+ .B git workspace completion bash
30
+ .br
31
+ .B git workspace
32
+ .RB [ -h " | " --version ]
33
+ .SH DESCRIPTION
34
+ .B git workspace
35
+ manages root repositories under
36
+ .I ~/workspace/owner/repo
37
+ and linked worktrees under
38
+ .IR ~/workspace/owner/repo@branch .
39
+ Use an at sign to separate the repository name from its branch name.
40
+ Branches can contain slashes, for example
41
+ .IR owner/repo@feature/jobs .
42
+ .PP
43
+ A Git repository containing
44
+ .I workspace.json
45
+ stores the portable workspace manifest.
46
+ Repositories and worktrees have stable IDs so that renames can be applied on
47
+ other machines without reserving old names.
48
+ Run
49
+ .B init
50
+ before managing checkouts.
51
+ .PP
52
+ The executable can also be invoked directly as
53
+ .BR git-workspace .
54
+ Bare and Git must be available on
55
+ .BR PATH .
56
+ .SH COMMANDS
57
+ .TP
58
+ .BI "init " owner/repo
59
+ Clone the manifest repository from GitHub over SSH.
60
+ If cloning fails and the destination is absent or empty, initialize it locally
61
+ and configure its origin URL instead.
62
+ Creating the repository on GitHub remains manual.
63
+ Create and commit an empty version-1 manifest when none exists, save the local
64
+ configuration, and record the applied workspace state.
65
+ An existing manifest is validated and preserved; its checkouts are not created.
66
+ .TP
67
+ .BI "add " owner/repo[@branch]
68
+ Clone or initialize a root repository, or create a linked branch worktree.
69
+ Adding a worktree also registers its root.
70
+ Reuse an existing local branch, track a matching origin branch, or create a new
71
+ branch from the root's HEAD without tracking another branch.
72
+ An empty root needs its first commit before a worktree can be created.
73
+ Existing destinations must belong to the requested repository and branch.
74
+ Repeating add does not fetch, switch branches, or duplicate registrations.
75
+ .TP
76
+ .BI "remove " owner/repo[@branch]
77
+ Remove the checkout and its manifest entry.
78
+ A root must have the expected origin, no local changes or untracked files, and
79
+ no linked worktrees.
80
+ The active manifest repository cannot be removed.
81
+ Worktree removal deletes its actual checked-out branch, even if unmerged;
82
+ a detached worktree has no branch to delete.
83
+ Dirty and locked worktrees are refused.
84
+ Ignored files are deleted with the checkout.
85
+ Remote project branches and repositories are not deleted.
86
+ .TP
87
+ .BI "rename " "from to"
88
+ Rename a root repository or a branch worktree and retain its stable ID.
89
+ A root rename moves its linked worktrees, repairs Git links, and updates
90
+ matching
91
+ origin URLs to the new owner/repository name.
92
+ A branch worktree rename also renames its local branch.
93
+ Running work and uncommitted files are preserved.
94
+ The repository is not renamed or transferred on GitHub; do that separately.
95
+ .TP
96
+ .B list
97
+ Print registered repository and worktree names, one per line.
98
+ .TP
99
+ .B status
100
+ Show each registered checkout as clean, modified, or missing.
101
+ .TP
102
+ .B pull
103
+ Fetch and fast-forward the manifest from its configured upstream, then apply
104
+ additions, renames, and clean removals to this machine's layout.
105
+ Without an upstream, use the current branch name on origin.
106
+ Require a clean manifest checkout and refuse divergent manifest histories.
107
+ Preserve dirty work in retained checkouts; refuse unsafe removals and occupied
108
+ destinations.
109
+ Existing project repositories are not fetched or pulled.
110
+ Interrupted operations are recorded locally and resumed by the next pull.
111
+ Other manifest mutations are blocked while a pull is pending.
112
+ Pull creates no manifest commits and pushes nothing.
113
+ .TP
114
+ .B hook list
115
+ List discovered post hooks with their command, name, and resolved executable
116
+ path.
117
+ This command works before workspace initialization and does not execute hooks.
118
+ .TP
119
+ .B completion bash
120
+ Print the Bash completion script.
121
+ Load it in an interactive shell with:
122
+ .PP
123
+ .RS
124
+ .nf
125
+ eval "$(git-workspace completion bash)"
126
+ .fi
127
+ .RE
128
+ .PP
129
+ Also load Git's Bash completion for completion of the
130
+ .B git workspace
131
+ form.
132
+ .SH OPTIONS
133
+ .TP
134
+ .B \-\-no-hooks
135
+ Skip post hooks for add, remove, rename, or pull.
136
+ During pull, also discard pending hook delivery from an interrupted operation.
137
+ This does not disable manifest commits or pushes.
138
+ .TP
139
+ .B \-\-dry-run
140
+ With pull, fetch the manifest and preview layout changes and blockers without
141
+ applying them, advancing the applied checkpoint, or executing hooks.
142
+ .TP
143
+ .B \-h
144
+ Print command-line usage.
145
+ Use it after a command for that command's options.
146
+ .TP
147
+ .B \-\-help
148
+ Git handles
149
+ .B git workspace --help
150
+ as a request for this manual page.
151
+ .B git-workspace --help
152
+ prints command-line usage instead.
153
+ .TP
154
+ .B \-\-version
155
+ Print the package version.
156
+ .SH MANIFEST COMMITS AND PUSHES
157
+ Init commits newly created manifests.
158
+ Successful add, remove, and rename operations commit the current
159
+ .I workspace.json
160
+ and attempt to push the manifest branch.
161
+ Pending manual edits to the manifest are included; unrelated staged files remain
162
+ staged.
163
+ No empty commit is created when the manifest is unchanged.
164
+ .PP
165
+ Push to the configured upstream, or to the same branch name on origin when no
166
+ upstream is configured, and establish tracking on success.
167
+ Only the manifest branch is pushed, including its existing local commits.
168
+ Project branches and tags are not published.
169
+ Pushes never force, fetch, or merge remote history.
170
+ .PP
171
+ A push failure warns but retains the local commit and completed checkout
172
+ operation, allows post hooks and local applied tracking, and does not turn a
173
+ successful command into an error.
174
+ Repeat add for a registered checkout to retry pushing without another commit,
175
+ or push the manifest branch manually.
176
+ .PP
177
+ A commit failure reports an error and retains the local changes.
178
+ Add can be repeated after fixing the Git error.
179
+ After remove or rename, commit the manifest manually; the filesystem operation
180
+ is already complete.
181
+ .SH HOOKS
182
+ Executable files on PATH named
183
+ .I git-workspace-hook-<command>-post-<name>
184
+ run after add, remove, and rename, including operations performed by pull.
185
+ Installation on PATH enables hooks without registration or manifest
186
+ configuration.
187
+ Hooks receive the command and post as arguments and version-1 JSON on standard
188
+ input, including stable IDs, before/after checkout paths, and the operation
189
+ result.
190
+ Hooks also run for attempted operations that partially fail.
191
+ .PP
192
+ Hooks run sequentially and are awaited.
193
+ Failures warn without changing the workspace command's exit status or rolling
194
+ back its work.
195
+ Repeated delivery is possible after an interrupted pull; hooks must be
196
+ idempotent.
197
+ Help, completion, and dry runs do not execute hooks.
198
+ .PP
199
+ The optional
200
+ .B git-workspace-hook-tmux
201
+ package creates detached sessions, preserves running panes across renames, and
202
+ terminates managed sessions and their programs when checkouts are removed.
203
+ Install it with
204
+ .BR "npm install -g git-workspace-hook-tmux" .
205
+ .SH FILES
206
+ .TP
207
+ .I ~/.config/git-workspace/config.json
208
+ Local configuration identifying the absolute manifest repository path.
209
+ .TP
210
+ .I <manifest-repository>/workspace.json
211
+ Version-1 manifest containing repository names, branch worktrees, and stable
212
+ IDs.
213
+ .TP
214
+ .I <manifest-repository>/.git/refs/git-workspace/applied
215
+ Local Git ref recording the last verified applied manifest commit.
216
+ .TP
217
+ .I <manifest-repository>/.git/workspace-pull.json
218
+ Local progress journal used to resume an interrupted pull.
219
+ .SH EXAMPLES
220
+ .nf
221
+ git workspace init me/workspace
222
+ git workspace add holepunchto/brittle
223
+ git workspace add holepunchto/brittle@feature/jobs
224
+ git workspace rename holepunchto/brittle@feature/jobs holepunchto/brittle@fixes
225
+ git workspace pull --dry-run
226
+ git workspace pull
227
+ git workspace remove holepunchto/brittle@fixes
228
+ git workspace hook list
229
+ .fi
230
+ .SH EXIT STATUS
231
+ Exit 0 on success and 1 on command failure, including blockers found by pull.
232
+ Push failures and post-hook failures are warnings and preserve the command's
233
+ original exit status.
234
+ .SH SEE ALSO
235
+ .BR git (1),
236
+ .BR git-worktree (1)
237
+ .PP
238
+ Project documentation:
239
+ .UR https://github.com/nicolasfont/git-workspace-bare
240
+ .UE
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "git-workspace-bare",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Manage Git worktrees as development workspaces",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "git-workspace": "./bin/git-workspace.js"
8
8
  },
9
+ "man": [
10
+ "./man/man1/git-workspace.1"
11
+ ],
9
12
  "scripts": {
10
13
  "test": "bare test/lifecycle.js",
11
14
  "format": "prettier . --write",