Files
paseo/plugin-examples/lifecycle-logger
Josh BendavidandClaude Opus 5.5 9bf0a0d9f3 feat(plugins): hooks for terminal creation and worktree commands
Adds two waiting lifecycle hooks and the workspace id on agent creation:

- terminal.create.before runs for every terminal the daemon starts in a
  workspace (app, CLI, SDK, plugins, agent tools, paseo.json scripts,
  services and worktree terminals). A plugin may replace command, args
  and env, or throw to refuse. It runs in a wrapper around the daemon's
  terminal manager, so adopted terminals don't run it again.
- command.run.before runs before each paseo.json worktree setup and
  teardown command. A plugin may replace the command and env, or throw
  to refuse, which fails setup or teardown like a failing command.
- agent.create.before receives the target workspaceId, read-only. A
  plugin result that omits it keeps it, so older plugins still work.

Setup and archive dependencies take the lifecycle as a required field so
a new caller can't skip the command hook by omission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 23:54:32 +01:00
..

Lifecycle logger

Registers agent, workspace, worktree, terminal, and command hooks and logs their data as JSON. It observes agent creation, session opening, turns, permissions, archive, workspace creation/archive, terminal creation, and worktree setup and teardown commands. Before hooks return the request unchanged. Environment values are redacted; prompts and timeline content are logged.

Install it on a daemon where plugins are enabled:

paseo plugin install /absolute/path/to/plugin-examples/lifecycle-logger
paseo plugin logs lifecycle-logger

The same entries appear in the target daemon's daemon.log. The plugin log viewer retains a bounded tail; use the daemon log for longer captures. Log lines are capped at 16 KiB, so a large timeline can be truncated.

See the lifecycle reference for callback shapes and delivery rules. The real-provider test in packages/server/src/server/plugins/lifecycle.real.e2e.test.ts runs both examples on an isolated daemon and saves evidence under .dev/lifecycle-proof/.

Run it from packages/server on Linux with Claude configured:

npx vitest run src/server/plugins/lifecycle.real.e2e.test.ts --bail=1

The test uses real provider calls and a temporary daemon home. Its failure check uses Linux /proc to identify and terminate only its own Claude subprocess. The credits check asks the real agent to emit the matching phrase; it does not exhaust an account's credits.