Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions dev/pi-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Worktrunk activity tracking hook for Pi / oh-my-pi.
//
// Tracks agent activity per branch, showing status markers in `wt list`:
// 🤖 — agent is working
// 💬 — agent is waiting for input
//
// Installed globally via: wt config plugins pi install

import type { HookAPI } from "@oh-my-pi/pi-coding-agent/extensibility/hooks";

export default function worktrunkActivity(pi: HookAPI): void {
const run = async (
ctx: { cwd: string },
args: ["set", string] | ["clear"],
): Promise<void> => {
try {
await pi.exec("wt", ["config", "state", "marker", ...args], {
cwd: ctx.cwd,
});
} catch {
// Activity tracking must never interrupt the host Pi session.
}
};

pi.on("agent_start", async (_event, ctx) => {
await run(ctx, ["set", "🤖"]);
});

pi.on("agent_end", async (_event, ctx) => {
await run(ctx, ["set", "💬"]);
});

pi.on("session_shutdown", async (_event, ctx) => {
await run(ctx, ["clear"]);
});
}
2 changes: 1 addition & 1 deletion docs/public/llms.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 17 additions & 9 deletions docs/src/content/docs/claude-code.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
title: "Agent Integration"
description: "Worktrunk plugins for Claude Code, Codex, OpenCode, and Gemini CLI: a configuration skill, wt list activity tracking, and Claude-only worktree isolation."
description: "Worktrunk plugins for Claude Code, Codex, OpenCode, Pi, and Gemini CLI: a configuration skill, wt list activity tracking, and Claude-only worktree isolation."
sidebar:
order: 23
---
Worktrunk ships a plugin for each supported agent CLI. What a plugin provides depends on the hooks that CLI exposes:

| Capability | Claude Code | Codex | OpenCode | Gemini CLI |
|---|:-:|:-:|:-:|:-:|
| Configuration skill | ✓ | ✓ | | ✓ |
| Activity tracking (🤖/💬 in `wt list`) | ✓ | ✓ | ✓ | ✓ |
| Worktree isolation | ✓ | | | |
| `/wt-switch-create` command | ✓ | | | |
| Capability | Claude Code | Codex | OpenCode | Pi | Gemini CLI |
|---|:-:|:-:|:-:|:-:|:-:|
| Configuration skill | ✓ | ✓ | | | ✓ |
| Activity tracking (🤖/💬 in `wt list`) | ✓ | ✓ | ✓ | ✓ | ✓ |
| Worktree isolation | ✓ | | | | |
| `/wt-switch-create` command | ✓ | | | | |

The configuration skill is documentation the agent reads to help set up LLM commits, hooks, and troubleshooting. Activity tracking shows which worktrees have running sessions. Worktree isolation needs worktree-lifecycle hooks and `/wt-switch-create` needs session working-directory switching — both Claude Code-only, so Codex, OpenCode, and Gemini users invoke `wt switch --create` and `wt remove` directly. Codex tracks activity through its own `Stop` and `SessionEnd` hooks.
The configuration skill is documentation the agent reads to help set up LLM commits, hooks, and troubleshooting. Activity tracking shows which worktrees have running sessions. Worktree isolation needs worktree-lifecycle hooks and `/wt-switch-create` needs session working-directory switching — both Claude Code-only, so Codex, OpenCode, Pi, and Gemini users invoke `wt switch --create` and `wt remove` directly. Codex tracks activity through its own `Stop` and `SessionEnd` hooks.

## Installation

Expand Down Expand Up @@ -52,6 +52,14 @@ wt config plugins opencode install

This writes the activity-tracking plugin to OpenCode's global plugins directory, `~/.config/opencode/plugins/worktrunk.ts` (honoring `$OPENCODE_CONFIG_DIR` and `$XDG_CONFIG_HOME`). `wt config plugins opencode uninstall` removes it.

### Pi

```bash
wt config plugins pi install
```

This writes the activity hook to `~/.omp/agent/hooks/pre/worktrunk.ts`. Named `$OMP_PROFILE` or `$PI_PROFILE` profiles use `~/.omp/profiles/<profile>/agent`, `$PI_CONFIG_DIR` changes the `.omp` config root, and `$PI_CODING_AGENT_DIR` overrides the agent directory for the default profile. `wt config plugins pi uninstall` removes the hook.

### Gemini CLI

```bash
Expand All @@ -73,7 +81,7 @@ Claude Code is designed to load the skill automatically when it detects worktrun

## Activity tracking

The Claude Code, Codex, OpenCode, and Gemini plugins track agent sessions with status markers in `wt list`:
The Claude Code, Codex, OpenCode, Pi, and Gemini plugins track agent sessions with status markers in `wt list`:

<!-- ⚠️ AUTO-GENERATED from tests/snapshots/integration__integration_tests__list__list_with_user_marker.snap — edit source to update -->

Expand Down
2 changes: 1 addition & 1 deletion docs/tests/built-site.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ test('short wide tables become labeled records without capturing dense tables',
/\bwt-responsive-records\b/,
);
assert.doesNotMatch(
findTable('/claude-code/', ['Capability', 'Claude Code', 'Codex', 'OpenCode', 'Gemini CLI']).attributes,
findTable('/claude-code/', ['Capability', 'Claude Code', 'Codex', 'OpenCode', 'Pi', 'Gemini CLI']).attributes,
/\bwt-responsive-records\b/,
);
assert.doesNotMatch(
Expand Down
24 changes: 16 additions & 8 deletions plugins/worktrunk/skills/worktrunk/reference/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

Worktrunk ships a plugin for each supported agent CLI. What a plugin provides depends on the hooks that CLI exposes:

| Capability | Claude Code | Codex | OpenCode | Gemini CLI |
|---|:-:|:-:|:-:|:-:|
| Configuration skill | ✓ | ✓ | | ✓ |
| Activity tracking (🤖/💬 in `wt list`) | ✓ | ✓ | ✓ | ✓ |
| Worktree isolation | ✓ | | | |
| `/wt-switch-create` command | ✓ | | | |
| Capability | Claude Code | Codex | OpenCode | Pi | Gemini CLI |
|---|:-:|:-:|:-:|:-:|:-:|
| Configuration skill | ✓ | ✓ | | | ✓ |
| Activity tracking (🤖/💬 in `wt list`) | ✓ | ✓ | ✓ | ✓ | ✓ |
| Worktree isolation | ✓ | | | | |
| `/wt-switch-create` command | ✓ | | | | |

The configuration skill is documentation the agent reads to help set up LLM commits, hooks, and troubleshooting. Activity tracking shows which worktrees have running sessions. Worktree isolation needs worktree-lifecycle hooks and `/wt-switch-create` needs session working-directory switching — both Claude Code-only, so Codex, OpenCode, and Gemini users invoke `wt switch --create` and `wt remove` directly. Codex tracks activity through its own `Stop` and `SessionEnd` hooks.
The configuration skill is documentation the agent reads to help set up LLM commits, hooks, and troubleshooting. Activity tracking shows which worktrees have running sessions. Worktree isolation needs worktree-lifecycle hooks and `/wt-switch-create` needs session working-directory switching — both Claude Code-only, so Codex, OpenCode, Pi, and Gemini users invoke `wt switch --create` and `wt remove` directly. Codex tracks activity through its own `Stop` and `SessionEnd` hooks.

## Installation

Expand Down Expand Up @@ -48,6 +48,14 @@ wt config plugins opencode install

This writes the activity-tracking plugin to OpenCode's global plugins directory, `~/.config/opencode/plugins/worktrunk.ts` (honoring `$OPENCODE_CONFIG_DIR` and `$XDG_CONFIG_HOME`). `wt config plugins opencode uninstall` removes it.

### Pi

```bash
wt config plugins pi install
```

This writes the activity hook to `~/.omp/agent/hooks/pre/worktrunk.ts`. Named `$OMP_PROFILE` or `$PI_PROFILE` profiles use `~/.omp/profiles/<profile>/agent`, `$PI_CONFIG_DIR` changes the `.omp` config root, and `$PI_CODING_AGENT_DIR` overrides the agent directory for the default profile. `wt config plugins pi uninstall` removes the hook.

### Gemini CLI

```bash
Expand All @@ -69,7 +77,7 @@ Claude Code is designed to load the skill automatically when it detects worktrun

## Activity tracking

The Claude Code, Codex, OpenCode, and Gemini plugins track agent sessions with status markers in `wt list`:
The Claude Code, Codex, OpenCode, Pi, and Gemini plugins track agent sessions with status markers in `wt list`:

```console
$ wt list
Expand Down
24 changes: 16 additions & 8 deletions skills/worktrunk/reference/claude-code.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,42 @@ $ wt config plugins opencode uninstall
Uninstall,
}

// Ordering: action + inverse adjacent (install, uninstall).
#[derive(Subcommand)]
pub enum ConfigPluginsPiCommand {
/// Install the activity tracking hook
#[command(
after_long_help = r#"Writes the Worktrunk hook to Pi's profile-aware user hook directory.

## Examples

```console
$ wt config plugins pi install
$ wt config plugins pi install --yes
```

## Plugin location

The default location is `~/.omp/agent/hooks/pre/worktrunk.ts`. The installer
honors `$PI_CONFIG_DIR` and active `$OMP_PROFILE` / `$PI_PROFILE` profiles.
`$PI_CODING_AGENT_DIR` overrides the agent directory for the default profile
only — named profiles ignore it, matching Pi's own resolution."#
)]
Install,

/// Remove the activity tracking hook
#[command(
after_long_help = r#"Removes the Worktrunk hook from Pi's active user hook directory.

## Examples

```console
$ wt config plugins pi uninstall
```"#
)]
Uninstall,
}

// Ordering: action + inverse adjacent (install, uninstall).
#[derive(Subcommand)]
pub enum ConfigPluginsCodexCommand {
Expand Down Expand Up @@ -361,6 +397,26 @@ config precedence: `$OPENCODE_CONFIG_DIR` > `$XDG_CONFIG_HOME/opencode` >
#[command(subcommand)]
action: ConfigPluginsOpencodeCommand,
},

/// Pi / oh-my-pi activity hook
#[command(
after_long_help = r#"Activity tracking hook — shows status markers in `wt list`:
- 🤖 — agent is working
- 💬 — agent is waiting for input

Pi's `session_shutdown` event clears the marker when the session exits.

## Examples

```console
$ wt config plugins pi install
$ wt config plugins pi uninstall
```"#
)]
Pi {
#[command(subcommand)]
action: ConfigPluginsPiCommand,
},
}

// Ordering: action + inverse adjacent (install, uninstall), then related
Expand Down Expand Up @@ -670,13 +726,15 @@ $ wt config alias dry-run deploy -- --env=staging
- **claude** — Claude Code plugin (activity tracking + statusline)
- **codex** — Codex plugin (Worktrunk configuration skill)
- **opencode** — OpenCode plugin (activity tracking)
- **pi** — Pi / oh-my-pi plugin (activity tracking)

## Examples

```console
$ wt config plugins claude install
$ wt config plugins codex install
$ wt config plugins opencode install
$ wt config plugins pi install
```"#
)]
Plugins {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod step;
pub(crate) use config::{
ApprovalsCommand, CacheAction, CiStatusAction, ConfigAliasCommand, ConfigCommand,
ConfigPluginsClaudeCommand, ConfigPluginsCodexCommand, ConfigPluginsCommand,
ConfigPluginsOpencodeCommand, ConfigShellCommand, DefaultBranchAction, GlobalFormatFlag,
HintsAction, LogsAction, MarkerAction, PreviousBranchAction, StateCommand, StateWrite,
VarsAction,
ConfigPluginsOpencodeCommand, ConfigPluginsPiCommand, ConfigShellCommand, DefaultBranchAction,
GlobalFormatFlag, HintsAction, LogsAction, MarkerAction, PreviousBranchAction, StateCommand,
StateWrite, VarsAction,
};
pub(crate) use hook::{HOOK_TYPE_NAMES, HookCommand, HookOptions, parse_hook_type};
pub(crate) use list::ListSubcommand;
Expand Down
Loading
Loading