npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pnvdev/wt-agent

v1.0.1

Published

Agentic CLI for managing Git Worktrees deterministically

Readme

🤖 wt-agent (Worktree Agent)

wt-agent is an advanced, deterministic CLI tool designed to empower autonomous AI agents (like gemini-cli, Cursor, or Devin) to manage Git worktrees safely and concurrently.

By leveraging Git worktrees under the hood, wt-agent allows multiple agents to work on different features or bug fixes in parallel, fully isolated folders (.worktrees/<feature>) without stepping on each other's toes, avoiding merge conflicts on the host repository, and eliminating the need for slow, heavy full repository clones.

🌟 Key Features

  • Agent-First Output: Native structured JSON output for seamless integration and parsing by LLMs and agentic loops.
  • Idempotency: Re-running commands will gracefully handle existing states instead of throwing destructive errors.
  • Agent Locking System: Lock (lock) and Handoff (handoff) worktrees to prevent other agents or cleanup scripts from deleting in-progress work.
  • Dependency Sandboxing (--isolate-deps): Automatically scopes node_modules installation inside the worktree so branch-specific dependencies don't break the main repository.
  • Dynamic Port Leasing: Agents can dynamically request an exclusive port (e.g., 8001) via port-request, which is automatically written to .env.local, preventing server collisions during automated E2E testing.
  • Structured Conflict API: Automatically parses git status during a rebase or merge conflict into a clean JSON so agents know exactly what files need manual intervention before calling resolve-continue.
  • System Checkpoints: Fast, lightweight checkpoint-save and checkpoint-restore commands for agents to perform safe "Trial & Error" loops without polluting the global Git stash.
  • Garbage Collection (gc): Automatically finds and deletes worktrees whose branches have already been merged into main.
  • Interactive Mode: Includes a human-friendly interactive prompt interface using wt-agent interactive (wt-agent i).

🚀 Quick Start (npx)

You can run the CLI directly without any installation using npx via the @pnvdev scope:

npx --yes @pnvdev/wt-agent --help

🛠️ Local Installation & Build

Ensure you have Node.js (>= 18) installed.

# Clone the repository
git clone <repository-url>
cd wt-agent

# Install dependencies
npm install

# Build the TypeScript project
npm run build

💻 Usage (Agentic CLI)

wt-agent is primarily designed to be invoked by other programs using sub-processes. By default, it returns JSON.

Creating a Worktree

npx @pnvdev/wt-agent create feature/auth-login --base main --isolate-deps

Output:

{
  "success": true,
  "data": {
    "path": "/absolute/path/to/repo/.worktrees/feature-auth-login"
  }
}

Checking Status (Conflict Resolution)

npx @pnvdev/wt-agent status feature/auth-login

Output:

{
  "success": true,
  "data": {
    "isClean": false,
    "conflicts": ["src/auth.ts"],
    "modified": [],
    "added": [],
    "deleted": []
  }
}

System Checkpoints (Trial & Error)

Agents can snapshot their work before a risky refactor.

npx @pnvdev/wt-agent checkpoint-save feature/auth-login "Before updating React router"

If the refactor fails the tests:

npx @pnvdev/wt-agent checkpoint-restore feature/auth-login

Agent Handoff & Context

Agents can leave context for other agents taking over the task.

npx @pnvdev/wt-agent context-set feature/auth-login "Goal: Fix UI padding"
npx @pnvdev/wt-agent handoff feature/auth-login frontend-agent-id-123

Dynamic Port Leasing

Allocate a unique port for a dev server to avoid collisions with other agents.

npx @pnvdev/wt-agent port-request feature/auth-login

Output:

{
  "success": true,
  "data": {
    "port": 8000
  }
}

Garbage Collection

Clean up disk space by removing worktrees that are already merged.

npx @pnvdev/wt-agent gc --base main

🧑‍💻 Usage (Interactive Mode for Humans)

If you want to use the tool as a human developer without typing the commands, simply run:

npx @pnvdev/wt-agent interactive
# or
npx @pnvdev/wt-agent i

This will launch a prompt interface allowing you to navigate, create, sync, and delete worktrees easily.

🛠️ Testing

The project uses vitest with fully isolated temporary Git repositories to ensure deterministic testing without altering your local git config.

npm run test

🏗️ Architecture

  • src/index.ts: The presentation layer using commander. It parses arguments and handles the standard JSON output wrapper (src/utils/output.ts).
  • src/services/git.ts: The core engine. It interacts with the local git binary via child_process.execSync. By using the host's git, it naturally inherits all SSH keys, global configs, and credential helpers without needing heavy native bindings like nodegit.
  • Metadata (metadata.json): State (locks, assigned ports, context messages, checkpoint SHAs) is stored locally within each .worktrees/<feature>/metadata.json file.

Built for the Agentic future of Software Engineering.