@cniska/agent-worktree 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christoffer Niska
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 CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # agent-worktree
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Task worktrees for coding agents: one checkout per task, set up and torn down by the project's own commands
4
+
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/cniska/agent-worktree/check.yml?branch=main&style=flat&label=ci)](https://github.com/cniska/agent-worktree/actions/workflows/check.yml) [![License](https://img.shields.io/badge/license-MIT-blue?style=flat)](LICENSE)
6
+
7
+ agent-worktree never works out what a checkout needs: `agent-worktree install` writes the setup and teardown commands and the port count the project gives it into hooks, and agent-worktree runs those.
8
+
9
+ - `agent-worktree create <name>` makes a git worktree outside the repository, on a new branch cut from `origin`'s default branch as `origin` has it now, runs the project's setup hook in it, and prints its path.
10
+ - `agent-worktree remove <name>` runs the project's teardown hook, removes the worktree, and once its remote's default branch has the branch, deletes it locally and, when it was pushed with an upstream, on that remote. When the upstream holds a commit the branch lacks, it keeps both copies.
11
+ - The `cniska-worktree` Claude Code plugin sends Claude Code's own worktrees through the same commands.
12
+
13
+ ## Install
14
+
15
+ agent-worktree runs on [Bun](https://bun.sh), which [mise](https://mise.jdx.dev) installs for it. With mise installed:
16
+
17
+ ```bash
18
+ git clone https://github.com/cniska/agent-worktree.git
19
+ cd agent-worktree
20
+ mise trust && mise install
21
+ ```
22
+
23
+ `mise install` installs Bun and the dependencies. In the clone, never in a worktree, it puts `agent-worktree` in `~/.bun/bin` with `bun link`, so removing a worktree never leaves the command pointing at a deleted checkout. Add that directory to your `PATH` if it is not there yet.
24
+
25
+ Then install the Claude Code plugin:
26
+
27
+ ```bash
28
+ claude plugin install cniska-worktree@cniska
29
+ ```
30
+
31
+ ## Why
32
+
33
+ Two agents in one checkout overwrite each other's files, so parallel work needs a checkout per task. A bare `git worktree add` gives one that is not ready to work in, and whatever it started outside its directory, such as a database, is left running when the work is done.
34
+
35
+ Claude Code makes worktrees of its own, for EnterWorktree and for subagents, without the project's setup, and repoints git's `core.hooksPath` when it does, so a `post-checkout` hook cannot do the setup either. agent-worktree owns the whole lifecycle: it creates the worktree, runs the setup, records whether it finished, and runs the teardown before the worktree goes.
36
+
37
+ ## Commands
38
+
39
+ | Command | Does |
40
+ | --- | --- |
41
+ | `agent-worktree install [--local] [--setup <command>] [--teardown <command>] [--ports <n>]` | Write the project's hooks |
42
+ | `agent-worktree create [--from <ref>] <name>` | Create the worktree, run setup, print the path |
43
+ | `agent-worktree remove [--force] <name>` | Run teardown, remove the worktree and settle its branch |
44
+ | `agent-worktree prune` | Tear down gone worktrees and remove those whose branch landed |
45
+ | `agent-worktree ls` | One line per worktree |
46
+ | `agent-worktree path <name>` | Print the worktree's path |
47
+
48
+ [Commands](docs/commands.md) lists every command, where `create` cuts a branch and how `remove` settles one.
49
+
50
+ ## Docs
51
+
52
+ - [Project contract](docs/contract.md): the hooks a project installs, keeping them in your clone, where worktrees live, ports, and running the hooks without the CLI.
53
+ - [Commands](docs/commands.md): every command, its output and its branch rules.
54
+ - [Claude Code plugin](docs/plugin.md): what the plugin does and what it needs.
55
+ - [Development](docs/development.md): setup, checks, layout and rules, for working on this repo.
56
+ - [Releasing](docs/releasing.md): the release workflow, the owner's one-time setup and each release's steps.
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ set -u
3
+
4
+ builds='darwin-arm64 linux-x64'
5
+ name=agent-worktree
6
+ scope=@cniska
7
+
8
+ refuse() {
9
+ printf '%s: %s\n %s\n' "$name" "$1" "$2" >&2
10
+ exit 1
11
+ }
12
+
13
+ self=$0
14
+ while [ -L "$self" ]; do
15
+ link=$(readlink "$self")
16
+ case $link in
17
+ /*) self=$link ;;
18
+ *) self=$(dirname "$self")/$link ;;
19
+ esac
20
+ done
21
+ bin=$(cd "$(dirname "$self")" && pwd -P)
22
+
23
+ case $(uname -s) in
24
+ Darwin) os=darwin ;;
25
+ Linux) os=linux ;;
26
+ *) os=$(uname -s) ;;
27
+ esac
28
+ case $(uname -m) in
29
+ arm64 | aarch64) cpu=arm64 ;;
30
+ x86_64) cpu=x64 ;;
31
+ *) cpu=$(uname -m) ;;
32
+ esac
33
+ target=$os-$cpu
34
+
35
+ case " $builds " in
36
+ *" $target "*) ;;
37
+ *) refuse \
38
+ "$name ships no build for $target, only $(printf '%s' "$builds" | sed 's/ / and /g')" \
39
+ "build $name from source with Bun, as its README says" ;;
40
+ esac
41
+
42
+ package=$scope/$name-$target
43
+ binary=
44
+ for dir in "$bin/../node_modules/$package" "$bin/../../$name-$target"; do
45
+ if [ -e "$dir/$name" ]; then
46
+ binary=$dir/$name
47
+ break
48
+ fi
49
+ done
50
+ [ -n "$binary" ] || refuse \
51
+ "$package is not installed beside $scope/$name" \
52
+ "reinstall $scope/$name with optional dependencies enabled"
53
+ [ -x "$binary" ] || refuse "$binary is not executable" "reinstall $scope/$name"
54
+
55
+ exec "$binary" "$@"
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@cniska/agent-worktree",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Task worktrees for coding agents: one checkout per task, set up and torn down by the project's own commands.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/cniska/agent-worktree",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/cniska/agent-worktree.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/cniska/agent-worktree/issues"
13
+ },
14
+ "keywords": [
15
+ "agent",
16
+ "claude-code",
17
+ "git",
18
+ "worktree",
19
+ "cli"
20
+ ],
21
+ "bin": {
22
+ "agent-worktree": "bin/agent-worktree"
23
+ },
24
+ "files": [
25
+ "bin/agent-worktree"
26
+ ],
27
+ "optionalDependencies": {
28
+ "@cniska/agent-worktree-darwin-arm64": "0.1.0",
29
+ "@cniska/agent-worktree-linux-x64": "0.1.0"
30
+ }
31
+ }