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

@srobroek/pi-worktrunk-merge-policy

v0.8.0

Published

Worktrunk (wt) skills: work in linked worktrees and run deterministic preflight checks before an agent run or merge.

Readme

worktrunk

Worktrunk (wt) support for OpenCode V2. Ported from the omp-plugins worktrunk package. The omp isolation precheck is not ported: OpenCode has no native checkout-cloning isolation to refuse.

It does three things:

  • Registers wt as OpenCode's worktree strategy.
  • Gates wt merge shell calls so worker-to-epic merges keep their history.
  • Ships two skills: worktrunk-preflight and worktrunk-worktrees.

Install

Install the Pi package from npm:

pi install npm:@srobroek/pi-worktrunk-merge-policy
opencode plugin add 'github:srobroek/harness-plugins::path:plugins/worktrunk/opencode'

Claude Code install the skills from this repository's marketplace:

claude plugin marketplace add srobroek/harness-plugins
claude plugin install worktrunk@harness-plugins

Claude Code get the two skills only; the worktree strategy and merge gate are OpenCode code.

Needs wt and git on PATH. The preflight skill also needs python3 (3.11 or later).

Options

| Option | Default | Effect | | --- | --- | --- | | strategy | true | false keeps OpenCode's bundled Git strategy. The merge gate and the skills stay on. |

{ "plugins": [{ "package": "...", "options": { "strategy": false } }] }

Worktree strategy

Strategy id worktrunk. Adding it makes it OpenCode's default strategy; disposing the plugin restores the previous one. Worktrees created before the plugin loaded keep their recorded owner.

| Operation | Command | | --- | --- | | create | wt -C <source> switch -y --create --no-cd --base <ref> --format json <name> | | remove | wt -C <directory> remove -y [--force] --foreground | | list | wt -C <source> list --format json |

  • <name> is the last component of the directory OpenCode suggests, and becomes the new branch. wt picks the directory from its worktree-path template, and the strategy returns that path, so the worktree may not sit where OpenCode suggested. OpenCode's worktree.directory setting has no effect on this strategy.
  • <ref> is the requested starting ref. Without one it is the source checkout's HEAD commit.
  • Worktrunk hooks run as usual: pre-start hooks block creation, post-start hooks run in the background.
  • remove deletes the branch only when wt considers it merged, and never deletes unmerged commits. A dirty worktree is refused with forceRequired, so OpenCode asks before forcing. Removing a directory that no longer exists does nothing.
  • list reports the main worktree as root and every linked worktree as worktree.

Merge policy gate

execute.before on the shell tool. It refuses:

  • wt merge <target> to a target other than the default branch without both --no-squash and --no-ff;
  • such a merge run from the target worktree, or from a detached HEAD, because wt merge merges the current branch;
  • a merge it cannot check: the default branch cannot be resolved, a probe times out, or the command is unterminated or runs a merge stored in a variable (cmd="wt merge x"; eval "$cmd").

wt merge with no target and merges to the default branch pass. The gate reads the default branch from wt config state default-branch, then origin/HEAD, in the call's directory: the shell workdir (resolved against the session directory), a leading cd DIR &&, or wt -C DIR. It finds merges behind wrappers (env, sudo, timeout, ...), in $(...), backticks, process substitutions, eval and sh -c. git merge and gh pr merge are not gated.

Skills

Registered with ctx.skill.transform from skills/<name>/SKILL.md in this package, so no copy step is needed. skills/ ships with the package (files), and both src/ and the bundled dist/ resolve it as ../skills. A skill with the same id that the host already has wins.

  • worktrunk-preflight: preflight.py checks wt, hook approvals, ignored project-config keys, the default branch, merge evidence, provisioning hooks and node_modules. Read-only unless --apply. Python tests: skills/worktrunk-preflight/test_preflight.py, run by bun test. On pi the skill calls the worktrunk_preflight tool instead (below).
  • worktrunk-worktrees: the worktree discipline from the omp rule worktrunk-worktree-required: create with wt switch, cut from the recorded base commit, use absolute paths, wait for provisioning, merge from the source worktree.

pi

One extension, pi/extensions/worktrunk.js (source pi-src/worktrunk.ts). The merge gate and the wt switch timeout share shared/merge-gate.ts and shared/switch-timeout.ts with OpenCode.

| Feature | pi hook | Behavior | | --- | --- | --- | | Merge policy gate | tool_call on bash | Returns { block: true, reason } for every merge the OpenCode gate refuses, checked in ctx.cwd. A handler error blocks the call, as pi treats a throwing tool_call handler. | | wt switch timeout | tool_call on bash | Raises a timeout shorter than 600 s to 600 s on a wt switch call, so foreground hooks are not killed mid-provisioning. pi's bash tool has no default timeout, so a call without one is left alone. | | worktrunk_preflight tool | registerTool | The checks of preflight.py, ported to TypeScript in shared/preflight.ts with the same ids, statuses and { ok, summary, checks } JSON. Parameters: path (default: the session directory), only (check ids), apply. apply writes .config/wt.toml under pi's file-mutation queue. |

The worktree strategy has no pi counterpart: pi has no worktree-strategy hook. pi-subagents allocates its child worktrees itself, running wt -C <root> switch --create <branch> --base <commit> --no-cd --no-hooks --format json with spawnSync from its extension process, not through the bash tool. pi fires tool_call only for tool calls, so neither gate sees that allocation.

pi-subagents' foreground children do not load the parent's extensions (required host extensions). List this extension for every child in ~/.pi/agent/settings.json, with the path where pi installed this repository:

{
  "subagents": {
    "defaultSubagentOnlyExtensions": ["<harness-plugins>/plugins/worktrunk/pi/extensions/worktrunk.js"]
  }
}

An agent that sets its own subagentOnlyExtensions replaces this default, so it must list the path too. The Python script stays for OpenCode and Claude Code; the two implementations must change together.

Smoke test

bun plugins/worktrunk/opencode/scripts/smoke.ts

Creates a scratch repository, then creates, lists, refuses to remove while dirty, force-removes and lists again through the strategy with real wt. It runs your Worktrunk config and hooks.