pf 0.0.2 → 0.0.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pullfrog, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # `pf` — Human- and agent-friendly Git multitasking
2
+
3
+ <br/><br/>
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i -g pf
9
+ ```
10
+
11
+ <br/><br/>
12
+
13
+ ## How does it work
14
+
15
+ There have been many attempts to nail a DX for parallel work in the agentic coding era. Most are thin wrappers over `git worktree`. That's not what `pf` is (though worktrees are used internally).
16
+
17
+ Instead `pf` introduces a new paradigm: the *workshell*. A workshell is **an ephemeral worktree whose lifecycle is bound to a subshell**. Here's how it works (key points in **bold**).
18
+
19
+ - You open a Git branch with `pf open <branch>` or create a new one with `pf new <branch>`.
20
+ - An ephemeral worktree is created for this branch (in `.git/pf/worktrees`) and **opened in a fresh subshell**.
21
+ - You are now in an fresh checkout of your repo that is isolated on disk. Make changes with your agent/editor of choice and commit them.
22
+ - You close the subshell with `pf close`, which **auto-prunes the associated worktree**.
23
+ - Your changes still exist on the associated branch.
24
+
25
+ That's it. **Ephemeral worktrees whose lifecycle is bound to a subshell.** When the subshell exits, the worktree is destroyed—but your commits aren't.
26
+
27
+ <!--
28
+ ## How does it work
29
+
30
+ There have been many attempts to nail a DX for parallel work in the agentic coding era. Most are thin wrappers over `git worktree`. That's not what `pf` is (though worktrees are used internally).
31
+
32
+ Here's how it works (key points in **bold**).
33
+
34
+ - **A fresh worktree is created** — The `pf` utility a) creates a new worktree in `.git/pf/worktrees` and b) opens it in a *subshell*.
35
+ - **Make edits and commit** — From the worksh your preferred IDE/agent.
36
+ - **Commit your changes** — Though your file system is isolated, Git commit history (including branches) is still shared among all worktrees.
37
+ - **Exit the subshell** — Run `pf close` to exit the subshell. As with `git switch`, `pf close` won't let you close the subshell if you have unstaged/uncommitted changes.
38
+ - **The worktree is auto-pruned** — This is key. The lifecycle of the worktree is tied to the subshell. When the subshell is closed, the worktree is destroyed. But *the commits you made inside the subshell* still exist.
39
+ - **Merge in your changes** — Merge/rebase your branch as you normally would, or push to GitHub to open a PR. -->
40
+
41
+ This approach has some nice properties.
42
+
43
+ 🙅‍♂️ **Never stash again** — You can `pf open` a branch even with uncommitted changes. When you exit the subshell, things will be exactly the same as they were. ☕️
44
+
45
+ 🖥️ **Tab-local checkouts** — Normally a `git checkout`/`git switch` changes your active branch for all terminals. With workshells, you can functionality open branches *in the current tab only*.
46
+
47
+ 🌳 **Isolated workspaces** — Each workshell is isolated on disk, so the changes you make don't affect anything else you're doing.
48
+
49
+ 🪾 **Maintains branch semantics** — As with regular `git checkout`, `pf close` won't let you close the subshell if you have unstaged/uncommitted changes. Vanilla worktrees are too forgiving in this regard; it makes it far too easy to leave half-finished work in a forgotten corner of your file system.
50
+
51
+ 🤖 **Agent-ready** — Spin up parallel workshells so multiple agents can work simultaneously without conflicts.
52
+
53
+ <br/><br/>
54
+
55
+ ## Quickstart
56
+
57
+ This section is entirely linear and self-contained. You can run all these commands in order to get a feel for how `pf` works.
58
+
59
+ First, install `pf`.
60
+
61
+ ```bash
62
+ $ npm i -g pf
63
+ ```
64
+
65
+ Then clone a repo (any repo works):
66
+
67
+ ```bash
68
+ $ git clone git@github.com:colinhacks/zod.git
69
+ $ cd zod
70
+ ```
71
+
72
+ After cloning, the `main` branch is checked out. Let's say we want to start work on a new feature:
73
+
74
+ ```bash
75
+ $ pf new feat-1
76
+
77
+ ✓ feat-1 (from main)
78
+ Opened branch in ephemeral subshell at .git/pf/worktrees/zod@feat-1
79
+ Type 'pf close' to return.
80
+ ```
81
+
82
+ You're now in a workshell. Check where you are:
83
+
84
+ ```bash
85
+ $ pwd
86
+ /Users/colinmcd94/Documents/repos/zod/.git/pf/worktrees/zod@feat-1
87
+
88
+ $ git branch --show-current
89
+ feat-1
90
+ ```
91
+
92
+ Now let's make some changes. (You can also open the repo in an IDE, start an agent run, etc.)
93
+
94
+ ```bash
95
+ $ touch a.txt
96
+ ```
97
+
98
+ Now let's try to close the workshell.
99
+
100
+ ```bash
101
+ $ pf close
102
+ ⚠ Uncommitted changes found. Commit, stash, or reset your changes first.
103
+ Or use --force/-f to discard changes
104
+ pf close -f
105
+ ```
106
+
107
+ We aren't able to close because we have uncommitted changes. Let's commit them.
108
+
109
+ ```bash
110
+ $ git add -A && git commit -am "Add a.txt"
111
+ ```
112
+
113
+ Now we can close again. On a successful close, you'll be prompted to merge your changes into the base branch.
114
+
115
+ ```bash
116
+ $ pf close
117
+ ✓ Back in main
118
+ Pruned worktree. Your changes are still in the 'feat-1' branch.
119
+ To merge your changes:
120
+ git merge feat-1
121
+
122
+ Auto-merge? (y/n/never) y
123
+
124
+ ✓ Merged 'feat-1' into 'main'
125
+ ```
126
+
127
+ If you type `n`, you can manually handle your own merging logic. The changes you made are still available in the `feat-1` branch.
128
+
129
+ If you type `never`, you can permanently disable the auto-merge prompt.
130
+
131
+ <br/><br/>
132
+
133
+ ## CLI
134
+
135
+ ```
136
+ pf v0.x.y - Open branches in workshells
137
+
138
+ Usage: pf <command> [options]
139
+
140
+ Commands:
141
+ new [branch] Create a branch and open it [--from <branch>]
142
+ open <branch> Open a branch in a workshell
143
+ close Exit current workshell
144
+ ls List orphaned worktrees
145
+ status Show current branch
146
+ rm <branch> Delete a branch and its worktree
147
+
148
+ Options:
149
+ --help, -h Show help
150
+ --version, -v Show version
151
+ ```
152
+
153
+ ### List orphaned worktrees
154
+
155
+ Normally the worktree will be auto-pruned when you close its associated workshell. If a worktree is left behind for some reason, you can list them with `pf ls`.
156
+
157
+ ```sh
158
+ $ pf ls
159
+ ┌──────────────────────┬────────┬─────────────────┐
160
+ │ branch │ status │ created │
161
+ ├──────────────────────┼────────┼─────────────────┤
162
+ │ main │ clean │ - │
163
+ │ feat-1 * │ clean │ 5 minutes ago │
164
+ └──────────────────────┴────────┴─────────────────┘
165
+ ```
166
+
167
+ ### Open a branch
168
+
169
+ You can open any existing Git branch in a workshell.
170
+
171
+ ```sh
172
+ $ pf open feat-1
173
+
174
+ ✓ feat-1 (existing worktree)
175
+ Type 'pf close' to return.
176
+ ```
177
+
178
+ ### Show current branch status
179
+
180
+ ```sh
181
+ $ pf status
182
+ branch: main (root)
183
+ worktree: /path/to/zod
184
+ status: clean
185
+ ```
186
+
187
+ ### Remove a branch
188
+
189
+ ```sh
190
+ $ pf rm feat-1
191
+
192
+ ✓ Deleted feat-1
193
+ ```
194
+
195
+ ### Closing a workshell
196
+
197
+ This closes the current workshell and auto-prunes the associated worktree. Your changes survive in your branch commits.
198
+
199
+ ```sh
200
+ pf close
201
+ ```
202
+
203
+
204
+ That command will fail if you have unstaged/uncommited changes. Use the `--force`/`-f` flag to force close the workshell; **this will discard your changes**.
205
+
206
+ ```sh
207
+ pf close --force
208
+ ```