@cniska/agent-worktree 0.0.0-stage → 0.2.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,82 @@
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 in its result.
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 on that remote: its upstream or, with none, the branch of the same name on `origin`, other than `origin`'s default branch. When the remote branch 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
+ Install the `agent-worktree` command for macOS on Apple silicon or Linux on x64 through one of these channels.
16
+
17
+ With the release's installer:
18
+
19
+ ```bash
20
+ curl -fsSL https://github.com/cniska/agent-worktree/releases/latest/download/install.sh | sh
21
+ ```
22
+
23
+ With Homebrew:
24
+
25
+ ```bash
26
+ brew install cniska/tap/agent-worktree
27
+ ```
28
+
29
+ With npm:
30
+
31
+ ```bash
32
+ npm install -g @cniska/agent-worktree
33
+ ```
34
+
35
+ With Bun:
36
+
37
+ ```bash
38
+ bun add -g @cniska/agent-worktree
39
+ ```
40
+
41
+ The curl line installs `~/.local/bin/agent-worktree` and, when that directory is not on your `PATH`, adds it to `~/.zshrc` for zsh or to an existing `~/.bashrc` or `~/.bash_profile` for bash, and otherwise asks you to add it. Each channel updates the way it installed: `brew upgrade agent-worktree`, `npm update -g @cniska/agent-worktree`, `bun update -g @cniska/agent-worktree`, or the curl line run again.
42
+
43
+ Then install the Claude Code plugin:
44
+
45
+ ```bash
46
+ claude plugin install cniska-worktree@cniska
47
+ ```
48
+
49
+ ## Why
50
+
51
+ 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.
52
+
53
+ 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.
54
+
55
+ ## Commands
56
+
57
+ | Command | Does |
58
+ | --- | --- |
59
+ | `agent-worktree install [--local] [--setup <command>] [--teardown <command>] [--ports <n>]` | Write the project's hooks |
60
+ | `agent-worktree create [--from <ref>] <name>` | Create the worktree, run setup, print the path |
61
+ | `agent-worktree remove [--force] <name>` | Run teardown, remove the worktree and settle its branch |
62
+ | `agent-worktree prune` | Tear down gone worktrees and remove those whose branch landed |
63
+ | `agent-worktree ls [--full]` | Count the worktrees in each state and list them; also what `agent-worktree` alone prints |
64
+ | `agent-worktree path <name>` | Print the worktree's path |
65
+
66
+ Each command prints its result, or its error, as one [TOON](https://toonformat.dev) document. [Commands](docs/commands.md) lists every command and its output, where `create` cuts a branch and how `remove` settles one.
67
+
68
+ ## Docs
69
+
70
+ - [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.
71
+ - [Commands](docs/commands.md): every command, its output and its branch rules.
72
+ - [Claude Code plugin](docs/plugin.md): what the plugin does and what it needs.
73
+ - [Development](docs/development.md): setup, checks, layout and rules, for working on this repo.
74
+ - [Releasing](docs/releasing.md): the release workflow, the owner's one-time setup and each release's steps.
75
+
76
+ ## Related
77
+
78
+ agent-worktree works on its own in any agent workflow, and is one of the optional add-ons to [agent-skills](https://github.com/cniska/agent-skills), engineering skills for coding agents. The other add-ons:
79
+
80
+ - [agent-task](https://github.com/cniska/agent-task): task tracking for coding agents, the tasks running, in review and waiting to run
81
+ - [agent-record](https://github.com/cniska/agent-record): a session record for coding agents, every past session queryable and joined to its commits
82
+ - [agent-gates](https://github.com/cniska/agent-gates): commit gates for coding agents, git hooks and CI checks that refuse a bad commit
@@ -0,0 +1,60 @@
1
+ #!/bin/sh
2
+ set -u
3
+
4
+ builds='darwin-arm64 linux-x64'
5
+ name=agent-worktree
6
+ scope=@cniska
7
+
8
+ quoted() {
9
+ printf '"%s"' "$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"
10
+ }
11
+
12
+ refuse() {
13
+ printf 'command: %s\nok: false\nerror:\n kind: refusal\n code: %s\n message: %s\n meta:\n resolve: %s\n' \
14
+ "$name" "$1" "$(quoted "$2")" "$(quoted "$3")" >&2
15
+ exit 1
16
+ }
17
+
18
+ self=$0
19
+ while [ -L "$self" ]; do
20
+ link=$(readlink "$self")
21
+ case $link in
22
+ /*) self=$link ;;
23
+ *) self=$(dirname "$self")/$link ;;
24
+ esac
25
+ done
26
+ bin=$(cd "$(dirname "$self")" && pwd -P)
27
+
28
+ case $(uname -s) in
29
+ Darwin) os=darwin ;;
30
+ Linux) os=linux ;;
31
+ *) os=$(uname -s) ;;
32
+ esac
33
+ case $(uname -m) in
34
+ arm64 | aarch64) cpu=arm64 ;;
35
+ x86_64) cpu=x64 ;;
36
+ *) cpu=$(uname -m) ;;
37
+ esac
38
+ target=$os-$cpu
39
+
40
+ case " $builds " in
41
+ *" $target "*) ;;
42
+ *) refuse no_build_for_platform \
43
+ "$name ships no build for $target, only $(printf '%s' "$builds" | sed 's/ / and /g')" \
44
+ "build $name from source with Bun, as its docs/development.md says" ;;
45
+ esac
46
+
47
+ package=$scope/$name-$target
48
+ binary=
49
+ for dir in "$bin/../node_modules/$package" "$bin/../../$name-$target"; do
50
+ if [ -e "$dir/$name" ]; then
51
+ binary=$dir/$name
52
+ break
53
+ fi
54
+ done
55
+ [ -n "$binary" ] || refuse platform_package_missing \
56
+ "$package is not installed beside $scope/$name" \
57
+ "reinstall $scope/$name with optional dependencies enabled"
58
+ [ -x "$binary" ] || refuse binary_not_executable "$binary is not executable" "reinstall $scope/$name"
59
+
60
+ 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.2.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.2.0",
29
+ "@cniska/agent-worktree-linux-x64": "0.2.0"
30
+ }
31
+ }