@liuser/pi-background-tasks

Background commands and attachable PTY/TUI sessions for Pi, with SSH Remote integration


Keywords
pi-package, pi, coding-agent, background-tasks, pty, tui, ssh, remote-terminal
License
MIT
Install
npm install @liuser/pi-background-tasks@1.0.1

Documentation

Pi Extensions

CI License: MIT

A focused collection of extensions for the Pi coding agent. Add background tasks, remote SSH workspaces, PowerShell support, Codex subscription tools, cursor effects, folded reasoning, or a compact todo workflow without installing an all-in-one bundle.

Every extension is published and versioned independently. Install only the capabilities you need.

Contents

Packages

Extensions

Extension npm What it adds
Background Tasks background-tasks Pipe and PTY background tasks with attach, logs, waits, input, signals, and local or SSH-backed execution
Codex API codex-api Codex OAuth text/vision delegation, image generation, search, Fast mode, and subscription usage
Cursor Effect cursor-effect Configurable effects for Pi's working, retry, compaction, and branch-summary cursors
PowerShell Adapter pwsh-adapter PowerShell 7 or Windows PowerShell 5.1 for Pi's shell and background tasks on Windows
DeepSeek Anchor deepseek-anchor Simulate DSH minimal mode's first request to induce a stronger DeepSeek V4 Pro agent trajectory
SSH Remote ssh-remote Remote Unix or Windows workspaces through reusable OpenSSH or ssh2 transports
Thinking Fold thinking-fold Timed, collapsible live-tail previews for long reasoning traces
Todo todo Atomic whole-plan updates, dependencies, reminders, and a read-only TUI widget

Shared libraries

Library npm Purpose
@99percentpeople/pi-shared-settings shared-settings Shared /99settings menu and namespaced settings store
@99percentpeople/pi-workspace-files workspace-files Binary workspace I/O protocol shared by Codex API and SSH Remote

The shared libraries are runtime dependencies, not Pi extensions. They register no tools or commands on their own.

Quick start

Install an extension

Choose one or more packages:

pi install npm:@99percentpeople/pi-background-tasks
pi install npm:@99percentpeople/pi-codex-api
pi install npm:@99percentpeople/pi-cursor-effect
pi install npm:@99percentpeople/pi-deepseek-anchor
pi install npm:@99percentpeople/pi-ssh-remote
pi install npm:@99percentpeople/pi-thinking-fold
pi install npm:@99percentpeople/pi-todo

On Windows, add the PowerShell adapter when Pi's bash tool and Background Tasks should both use PowerShell syntax:

pi install npm:@99percentpeople/pi-pwsh-adapter

Common setups

Remote workspace with attachable PTY tasks

pi install npm:@99percentpeople/pi-background-tasks
pi install npm:@99percentpeople/pi-ssh-remote
pi --ssh devbox:/srv/project

SSH Remote uses your existing OpenSSH aliases and credentials. The same Background Tasks workflow can then run htop, lazygit, nvim, or another TUI on the remote host without leaving the current Pi conversation.

Codex subscription tools

pi install npm:@99percentpeople/pi-codex-api

Sign in to Pi's openai-codex provider. No OpenAI API key or MCP server is required. To use the tools while another provider is active, enable Other providers in /99settings.

Todo replacement

Remove another extension that owns the same todo tool before installing this one:

pi remove npm:@juicesharp/rpiv-todo
pi install npm:@99percentpeople/pi-todo

DeepSeek first-request anchoring

pi install npm:@99percentpeople/pi-deepseek-anchor

Start a fresh deepseek/deepseek-v4-pro session. The extension simulates DSH minimal mode's first-request scaffold to induce a more effective tool-use trajectory. The default Pi-native profile keeps a one-sentence system anchor for the session, starts with bash and edit, then restores the full tool set after the bootstrap tool batch. A POSIX-only exact-dsh profile adds the DSH-compatible persistent Bash and str_replace_editor schemas for the bootstrap request. Configure the profile, mode, scope, and native tools through the shared /99settings menu; DeepSeek Anchor adds no private slash command.

Configure installed extensions

Open the shared settings menu:

/99settings

Only installed extensions that expose settings appear in the menu.

Compatibility

Background Control protocol v2 integrations require this minimum set:

Package Minimum version
@99percentpeople/pi-background-tasks 2.0.0
@99percentpeople/pi-ssh-remote 0.5.0
@99percentpeople/pi-pwsh-adapter 1.1.0

Background Tasks works by itself. SSH Remote and the PowerShell Adapter matter only when those integrations are installed. Background Tasks 2.x rejects unnamed protocol-v1 providers so an active remote workspace cannot silently fall back to a local process.

Extension guide

Background Tasks

Run intentionally asynchronous finite commands, long-lived services, and interactive terminal programs without blocking the foreground Pi session. Use background execution only when the user requests it, the process must remain available for later interaction, or Pi can do useful independent work while it runs. A command being slow is not enough by itself; when its result is required before work can continue, use foreground bash with an appropriate timeout.

Tool Purpose
bg_start Start a pipe or PTY task
bg_wait Wait once for a finite task and return its latest pipe log line
bg_status Inspect task state, launch metadata, and latest pipe log line
bg_logs Read full retained pipe or PTY output
bg_send Send text, terminal keys, EOF, or an execution-environment signal
bg_kill Terminate a running or disconnected adapter-owned task

User commands:

  • /bg-attach <id> attaches to a PTY or follows new pipe output. Press Ctrl+] to detach.
  • /bg-kill selects and terminates a running task.

Task names can be used anywhere an ID is accepted. Same-task calls emitted in one model response execute in source order, while independent task chains run in parallel. PTY support uses node-pty; systems without a compatible native binary may require a C/C++ toolchain.

Read the Background Tasks documentation →

SSH Remote

Keep Pi local while routing workspace operations to a remote Unix or Windows host. SSH Remote handles:

  • read, write, edit, and bash;
  • optional grep, find, and ls tools;
  • user ! and !! commands;
  • binary workspace files used by Codex API;
  • Background Tasks PTY and signal control.

Auto transport selection uses managed OpenSSH multiplexing on Linux and macOS, and a persistent ssh2 connection with OpenSSH compatibility fallback on Windows. Both transports support ProxyJump; explicit OpenSSH mode also keeps native ProxyCommand behavior.

Session state records the target, remote platform, shell, and cwd. Resume and branch navigation restore that state transactionally, while failures block remote tools instead of falling back to Pi's local workspace.

Command Purpose
/ssh-connect <target> Connect or switch directly to another SSH target
/ssh-cd <path> Change the persistent remote cwd without reconnecting
/ssh-status Show the current local or remote environment
/ssh-reconnect Reconnect the active target
/ssh-exit Return explicitly to the local workspace
/ssh-forget-password [all] Remove cached password entries

Model-facing environment controls are disabled by default. Model-triggered password input has a 60-second deadline; manual connections can wait until the user responds.

Read the SSH Remote documentation →

PowerShell Adapter

This Windows-only extension:

  • prefers PowerShell 7 (pwsh.exe);
  • falls back to Windows PowerShell 5.1 (powershell.exe);
  • routes Pi's Bash backend and Background Tasks through the same runtime;
  • configures UTF-8 input and output;
  • preserves interactive PTY behavior.

Without the adapter, Background Tasks follows Pi's configured Bash resolution, including Git Bash on Windows.

Read the PowerShell Adapter documentation →

DeepSeek Anchor

Simulate DSH minimal mode's RL-aligned first request to place DeepSeek V4 Pro on a more effective agent trajectory without keeping the whole session on a two-tool catalog. Anchored mode keeps the profile's complete system prompt on every request, while restoring Pi's full tool set after the bootstrap tool batch. The default profile preserves Pi's normal Bash and editor implementations; the opt-in exact-dsh profile fixes the bootstrap schemas and uses a persistent local Bash process on POSIX during bootstrap. Profile/model gates are branch-aware, anchored phase survives reload, non-target models never lose tools, and non-max thinking is warned about rather than changed automatically. Settings apply immediately through /99settings; no extension-specific slash command is registered.

This is an experimental client scaffold, not a performance guarantee, hidden chain-of-thought extractor, or server-route selector.

Read the DeepSeek Anchor documentation → · 中文文档 →

Codex API

Use a ChatGPT Codex subscription from Pi without an API key.

Tool or command Purpose
codex_ask Ask a live Codex model for an explicit multilingual text or vision second opinion
codex_image Generate or edit images and save non-overwriting PNG outputs
codex_search Search web/images, navigate pages, capture PDF pages, and query finance, weather, sports, or time data
/codex-usage Show quota, plan information, and reset cards
/codex-redeem Confirm and redeem an available reset card

The usage commands appear only after Pi confirms an openai-codex OAuth login. codex_ask requires Pi 0.84.1 or newer and uses Pi's model registry rather than a duplicate model catalog. Use the Tools submenu in /99settings to toggle Search, Image, and Ask Codex. Fast mode, Usage monitor, and Answer detail remain direct Codex API settings. When SSH Remote is active, generated files and image references use the remote binary workspace provider instead of a local staging directory.

Read the Codex API documentation →

Cursor Effect

Style Pi's main working, retry, compaction, and branch-summary cursors without changing tool loaders, widgets, messages, or model events. Built-in themes include Default, Claude Code, and Codex; Custom mode exposes independent loader and label controls.

Read the Cursor Effect documentation →

Thinking Fold

Long reasoning traces render beneath a once-per-second timed header. The live view keeps a compact tail, completed thinking defaults to Thought for xx.xs, and Ctrl+T restores the full original reasoning. Display-only patches never alter persisted messages or reasoning signatures.

Read the Thinking Fold documentation →

Todo

The todo tool writes one authoritative tasks[] snapshot instead of issuing per-task CRUD calls. It supports:

  • stable model-facing keys and same-call dependencies;
  • sparse updates for existing tasks;
  • stale-revision and dependency-graph validation;
  • omission-based deletion with no archive or cancelled state;
  • branch-aware persistence and compaction checkpoints;
  • a read-only widget with configurable reminders.

Completed tasks remain visible for the current response and are removed before the next response unless unfinished work still depends on them.

Read the Todo documentation →

Shared infrastructure

Shared settings

Configurable extensions share one atomically written file:

~/.pi/agent/99extensions.json
Namespace Main settings
background-tasks Collapsed task count and output previews
codex-api Tool switches, Answer detail, Fast mode, usage monitoring, provider access, search, and image quality
cursor-effect Themes and custom loader/label effects
deepseek-anchor Profile, mode, anchor scope, and bootstrap tools
ssh-remote Transport, password behavior, and AI controls
thinking-fold Fold threshold and streaming/completed display behavior
todo Widget size, dependency numbers, and reminder interval
Example 99extensions.json
{
  "background-tasks": {
    "collapsedTaskLimit": 0,
    "outputPreview": "finished"
  },
  "codex-api": {
    "searchEnabled": true,
    "imageEnabled": true,
    "askEnabled": true,
    "fastMode": false,
    "responseVerbosity": "auto",
    "usageStatus": true,
    "allowOtherProviders": false,
    "searchMode": "auto"
  },
  "deepseek-anchor": {
    "version": 1,
    "profile": "pi-native",
    "mode": "anchored",
    "scope": "session",
    "targetProvider": "deepseek",
    "targetModelId": "deepseek-v4-pro",
    "nativeBootstrapTools": ["bash", "edit"],
    "nativeSystemPrompt": "You are a helpful software engineer assistant."
  },
  "ssh-remote": {
    "transport": "auto"
  },
  "thinking-fold": {
    "foldThreshold": 5,
    "streamingBehavior": "auto",
    "completedBehavior": "auto"
  },
  "todo": {
    "collapsedTaskLimit": 3,
    "showDependencyNumbers": true,
    "reminderInterval": 3
  }
}

Workspace files

@99percentpeople/pi-workspace-files defines the binary workspace I/O protocol used by Codex API and SSH Remote. Consumers request the active file system and fall back to a workspace-confined local Node.js backend when no remote provider claims it.

The protocol covers native path resolution, buffered or streaming binary reads/writes, directory creation, existence checks, and cancellation.

Read the Workspace Files documentation →

Development

The repository is a private Bun 1.3.14 workspace containing independently published source packages.

Install, build, and test

bun install --frozen-lockfile
bun run build:all
bun run check
bun run pack:check

bun run check runs the privacy scanner, strict TypeScript checking, and the unit/integration test suite. The privacy scanner rejects developer-specific paths, accounts, hosts, emails, private IPs, and credential-shaped material in committed test and e2e fixtures.

Build output

Builds never create package-local dist/ directories. Each complete npm staging package is generated under the repository root:

dist/<package-name>/
├── index.min.js
├── index.min.js.map
├── package.json
├── README.md
└── LICENSE

Shared libraries additionally include declarations; package-specific skills or JSON assets are copied beside the runtime entrypoint. Root dist/ is ignored by Git and rebuilt from release tags.

Pi core peers and all npm runtime dependencies remain external. This preserves Pi's peer-module identity and lets native or dynamic dependencies use their normal package loaders.

Load source directly

pi -e ./extensions/background-tasks/index.ts
pi -e ./extensions/codex-api/index.ts
pi -e ./extensions/cursor-effect/index.ts
pi -e ./extensions/deepseek-anchor/index.ts
pi -e ./extensions/ssh-remote/index.ts --ssh devbox:/srv/project
pi -e ./extensions/thinking-fold/index.ts
pi -e ./extensions/todo/index.ts

On Windows:

pi -e ./extensions/pwsh-adapter/index.ts

Repository layout

Path Contents
extensions/ Eight independently published Pi extensions
packages/ Shared settings and workspace-file runtime libraries
tests/ Unit and optional live integration tests
e2e/ Local and remote Windows smoke tests
scripts/ Build, privacy, and package validation scripts
promo/ Demo assets used by package documentation

Windows SSH integration requires a live test host. See tests/README.md for the integration suite and e2e/README.md for local/remote smoke tests.

Publishing

.github/workflows/publish.yml publishes only from package-specific tags through npm Trusted Publishing and GitHub Actions OIDC. No NPM_TOKEN is required.

Configure a Trusted Publisher separately for all ten npm packages:

  • Provider: GitHub Actions
  • Organization or user: 99percentpeople
  • Repository: pi-extensions
  • Workflow filename: publish.yml
  • Allowed action: npm publish

Tags use the source directory name followed by the exact package version:

background-tasks-v2.1.0
codex-api-v0.2.9
deepseek-anchor-v0.1.1
ssh-remote-v0.5.3
workspace-files-v0.1.1

To release a package:

  1. Update its source package.json version and any internal dependency pins.
  2. Update package documentation when behavior changed.
  3. Run bun run pack:check.
  4. Commit and push the release changes.
  5. Create and push the matching tag.
git tag ssh-remote-v0.5.3
git push origin master ssh-remote-v0.5.3

Publish shared libraries before extensions that require their new versions. The workflow rejects tags that do not exactly match the selected package's package.json.

Uninstall

pi remove npm:@99percentpeople/pi-background-tasks
pi remove npm:@99percentpeople/pi-codex-api
pi remove npm:@99percentpeople/pi-cursor-effect
pi remove npm:@99percentpeople/pi-pwsh-adapter
pi remove npm:@99percentpeople/pi-deepseek-anchor
pi remove npm:@99percentpeople/pi-ssh-remote
pi remove npm:@99percentpeople/pi-thinking-fold
pi remove npm:@99percentpeople/pi-todo

License

MIT