workshell 0.2.0 β 0.5.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 +94 -15
- package/dist/index.js +1683 -29
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
```bash
|
|
23
23
|
$ npm i -g workshell # aliases to `wk`
|
|
24
24
|
$ wk --help
|
|
25
|
-
wk v0.0
|
|
25
|
+
wk v0.5.0 - Open branches in ephemeral subshells
|
|
26
26
|
|
|
27
27
|
Usage: wk <command> [options]
|
|
28
28
|
# ...
|
|
@@ -40,7 +40,7 @@ Here's how it works (key points in **bold**).
|
|
|
40
40
|
|
|
41
41
|
- You open a Git branch with `wk open <branch>` or create a new one with `wk new <branch>`.
|
|
42
42
|
- An ephemeral worktree is created for this branch (in `~/.workshell/worktrees`) and **opened in a fresh subshell**.
|
|
43
|
-
- You are now in
|
|
43
|
+
- You are now in a fresh checkout of your repo that is isolated on disk. Make changes with your agent/editor of choice and commit them.
|
|
44
44
|
- You close the subshell with `wk close`. **The associated worktree is auto-pruned**.
|
|
45
45
|
- Your changes still exist on the associated branch, as Git commits/branches are shared among all worktrees. The worktree is destroyedβbut your commits aren't.
|
|
46
46
|
|
|
@@ -66,8 +66,9 @@ Here's how it works (key points in **bold**).
|
|
|
66
66
|
|
|
67
67
|
This approach has some nice properties.
|
|
68
68
|
|
|
69
|
-
- π₯οΈ **Tab-local workspaces** β Normally a `git checkout`/`git switch` changes your active branch for all terminals. With workshells, you can
|
|
70
|
-
- π³ **Full isolation** β Each workshell is isolated on disk, so the changes you make don't interfere anything else you're doing.
|
|
69
|
+
- π₯οΈ **Tab-local workspaces** β Normally a `git checkout`/`git switch` changes your active branch for all terminals. With workshells, you can open branches *in the current tab only*.
|
|
70
|
+
- π³ **Full isolation** β Each workshell is isolated on disk, so the changes you make don't interfere with anything else you're doing.
|
|
71
|
+
- π¦ **Instant setup** β Common config files are automatically copied using [copy-on-write](https://notes.billmill.org/blog/2024/03/How_I_use_git_worktrees.html), and your package manager is auto-detected so `npm`/`yarn`/`pnpm`/`bun` install runs automatically.
|
|
71
72
|
- π
ββοΈ **Never stash again** β You can `wk open` a branch even with uncommitted changes. When you exit the subshell, things will be exactly the same as they were. βοΈ
|
|
72
73
|
- πͺΎ **Consistent with branch semantics** β As with regular `git switch`, `wk close` won't let you close the subshell if you have unstaged/uncommitted changes. This is a feature, not a bug! Regular worktrees make it easy to lose your work in a forgotten corner of your file system.
|
|
73
74
|
- π€ **Agent-ready** β Spin up parallel workshells so multiple agents can work simultaneously without conflicts.
|
|
@@ -181,7 +182,7 @@ Usage: wk <command> [options]
|
|
|
181
182
|
|
|
182
183
|
Commands:
|
|
183
184
|
new [branch] Create a branch and open it [--from <branch>]
|
|
184
|
-
open <
|
|
185
|
+
open <ref> Open a branch or PR in a workshell
|
|
185
186
|
close Exit current workshell
|
|
186
187
|
ls List orphaned worktrees
|
|
187
188
|
status Show current branch
|
|
@@ -212,7 +213,7 @@ $ wk ls
|
|
|
212
213
|
<br />
|
|
213
214
|
|
|
214
215
|
|
|
215
|
-
### Open a branch in a workshell
|
|
216
|
+
### Open a branch or PR in a workshell
|
|
216
217
|
|
|
217
218
|
You can open any existing Git branch in a workshell.
|
|
218
219
|
|
|
@@ -223,6 +224,19 @@ $ wk open feat-1
|
|
|
223
224
|
Type 'wk close' to return.
|
|
224
225
|
```
|
|
225
226
|
|
|
227
|
+
You can also open GitHub pull requests directly. `wk open` accepts anything that `gh pr view` understands β PR numbers, URLs, or branch names. The PR branch is automatically fetched if it doesn't exist locally. Requires [GitHub CLI](https://cli.github.com/) (`gh`).
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
# by PR number
|
|
231
|
+
$ wk open 42
|
|
232
|
+
|
|
233
|
+
# by GitHub URL
|
|
234
|
+
$ wk open https://github.com/org/repo/pull/42
|
|
235
|
+
|
|
236
|
+
# by branch name (tries local branch first, then GitHub PR)
|
|
237
|
+
$ wk open feature/auth
|
|
238
|
+
```
|
|
239
|
+
|
|
226
240
|
<br />
|
|
227
241
|
|
|
228
242
|
### Show current branch status
|
|
@@ -270,7 +284,7 @@ If the branch hasn't been pushed to a remote, you'll be prompted to auto-merge:
|
|
|
270
284
|
- `n` β skip (branch is kept, merge manually later)
|
|
271
285
|
- `never` β permanently disable auto-merge prompt
|
|
272
286
|
|
|
273
|
-
That command will fail if you have unstaged/
|
|
287
|
+
That command will fail if you have unstaged/uncommitted changes. Use the `--force`/`-f` flag to force close the workshell; **this will discard uncommitted changes**.
|
|
274
288
|
|
|
275
289
|
```sh
|
|
276
290
|
$ wk close --force
|
|
@@ -310,9 +324,70 @@ Choice (1/2): 1
|
|
|
310
324
|
|
|
311
325
|
<br />
|
|
312
326
|
|
|
327
|
+
## Automatic file copying
|
|
328
|
+
|
|
329
|
+
When you create a workshell, `wk` automatically copies common config files from your repo to the new worktree using **copy-on-write**. This includes env files, package manager config, version manager config (`asdf`, `mise`, `nvm`), and editor overrides.
|
|
330
|
+
|
|
331
|
+
<details>
|
|
332
|
+
<summary>Default copy patterns (click to expand)</summary>
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
.env*
|
|
336
|
+
.npmrc*
|
|
337
|
+
.yarnrc*
|
|
338
|
+
.pnpmfile.*
|
|
339
|
+
.pnpmrc*
|
|
340
|
+
.tool-versions
|
|
341
|
+
.node-version
|
|
342
|
+
.nvmrc
|
|
343
|
+
.ruby-version
|
|
344
|
+
.python-version
|
|
345
|
+
.mise*.toml
|
|
346
|
+
.dir-locals.el
|
|
347
|
+
.editorconfig.local
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
</details>
|
|
351
|
+
|
|
352
|
+
Copy-on-write is near-instant and uses zero extra disk space (until files are modified). This works automatically on macOS (APFS) and Linux (Btrfs/XFS). On other filesystems, files are copied normally.
|
|
353
|
+
|
|
354
|
+
You can override which gitignored files get copied with the `copy` option in `workshell.toml`:
|
|
355
|
+
|
|
356
|
+
```toml
|
|
357
|
+
# override default patterns (default: .env*, .npmrc*, .nvmrc, .tool-versions, etc.)
|
|
358
|
+
copy = [".env*", ".secret*", "data/fixtures/**"]
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Patterns without `/` match at any depth (e.g. `.env*` matches both `.env` and `packages/api/.env.local`). Patterns with `/` are anchored to the repo root. Full glob syntax is supported (`*`, `**`, `?`, `[abc]`, etc.).
|
|
362
|
+
|
|
363
|
+
### Package manager detection
|
|
364
|
+
|
|
365
|
+
`wk` auto-detects your package manager and runs install automatically:
|
|
366
|
+
|
|
367
|
+
| Lockfile | Command |
|
|
368
|
+
|----------|---------|
|
|
369
|
+
| `pnpm-lock.yaml` | `pnpm install` |
|
|
370
|
+
| `yarn.lock` | `yarn install` |
|
|
371
|
+
| `bun.lockb` / `bun.lock` | `bun install` |
|
|
372
|
+
| `package-lock.json` | `npm install` |
|
|
373
|
+
| `uv.lock` | `uv sync` |
|
|
374
|
+
| `poetry.lock` | `poetry install` |
|
|
375
|
+
| `Pipfile.lock` | `pipenv install` |
|
|
376
|
+
| `pdm.lock` | `pdm install` |
|
|
377
|
+
|
|
378
|
+
Detection requires the binary to be installed. If the install command fails, a warning is printed and setup continues. Mixed JS+Python projects are supported.
|
|
379
|
+
|
|
380
|
+
Setting a `setup` script in `workshell.toml` disables automatic package manager detection. Include the install command in your setup script if you want both:
|
|
381
|
+
|
|
382
|
+
```toml
|
|
383
|
+
setup = "pnpm install && nvm use"
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
<br />
|
|
387
|
+
|
|
313
388
|
## `workshell.toml`
|
|
314
389
|
|
|
315
|
-
You can configure `wk` with a `workshell.toml` file.
|
|
390
|
+
You can optionally configure `wk` with a `workshell.toml` file.
|
|
316
391
|
|
|
317
392
|
`wk` looks for config files in the following order:
|
|
318
393
|
|
|
@@ -323,13 +398,17 @@ You can configure `wk` with a `workshell.toml` file. This is useful for running
|
|
|
323
398
|
|
|
324
399
|
<br />
|
|
325
400
|
|
|
326
|
-
|
|
401
|
+
### Options
|
|
327
402
|
|
|
328
403
|
```toml
|
|
329
|
-
#
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
#
|
|
333
|
-
#
|
|
334
|
-
|
|
404
|
+
# optional: override which gitignored files get copied (default: .env*, .npmrc*, .nvmrc, etc.)
|
|
405
|
+
copy = [".env*", ".secret*"]
|
|
406
|
+
|
|
407
|
+
# optional: setup script executed in subshell after initialization
|
|
408
|
+
# disables automatic package manager detection (see above)
|
|
409
|
+
# variable substitutions:
|
|
410
|
+
# `{{ branch }}` β name of opened branch, e.g. `feature/auth`
|
|
411
|
+
# `{{ repo_path }}` β absolute path to main repo, e.g. `/path/to/repo`
|
|
412
|
+
# `{{ worktree_path }}` β absolute path to worktree, e.g. `~/.workshell/worktrees/.../repo@feat`
|
|
413
|
+
setup = "nvm use"
|
|
335
414
|
```
|