omp packages

@0xrsydn/pstack-pi0.18.0

Pi-native port of pstack with rigorous workflows, exact role routing, and isolated subagents.

GitHub Actions Published 6 hours ago MIT ~705 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pstack-pi

A Pi-native port of pstack, Lauren Tan's rigorous engineering workflow for Cursor.

The original skills, workflows, and prose are MIT-licensed work by Lauren Tan. This repository adapts harness-specific behavior to Pi.

Install

Use a pinned Git tag or commit for reproducible installs:

pi install git:github.com/0xrsydn/pstack-pi@v0.17.1

During development, load the local checkout:

pi -e /path/to/pstack-pi

The tag pins the published release. Use a full commit ID when you need an exact development revision.

Restart Pi after installation, or run /reload in an existing session. Run pi list to confirm the package declaration.

Set up models

Run the native command:

/setup-pstack

The command:

  1. Reads authenticated models from Pi's model registry.
  2. Asks for the pstack reasoning budget.
  3. Recommends the upstream Grok 4.7 and Claude Opus 5.5 pair when available.
  4. Shows every upstream routing role.
  5. Validates each model before saving.
  6. Writes ~/.pi/agent/pstack-models.json atomically.

Pi separates model identity from thinking level. The config follows the same design:

{
  "version": 1,
  "budget": "large",
  "roles": {
    "feature-refactoring": {
      "model": "opencode/grok-4.7",
      "thinking": "xhigh"
    },
    "judgment-prose": {
      "model": "anthropic/claude-opus-5-5",
      "thinking": "xhigh"
    },
    "arena-runners": [
      {
        "model": "anthropic/claude-opus-5-5",
        "thinking": "xhigh"
      },
      {
        "model": "opencode/grok-4.7",
        "thinking": "xhigh"
      }
    ]
  }
}

Provider names are examples. Grok and Claude are recommendations, not requirements. All 17 roles accept any chat model available through Pi, including models registered by custom provider extensions. pstack-pi does not store credentials or require a particular provider.

"model": "inherit-parent" uses the active parent model and, unless overridden, its thinking level. The bundled agents have no fixed model. A missing role therefore inherits the parent when you use a bundled agent. A custom agent can supply its own model; see routing precedence.

Without a config, the extension resolves the upstream Grok 4.7 and Claude Opus 5.5 pair from Pi's available models. It uses the large budget and falls back to the parent for an unavailable family. A partial config does not merge with that preset: omitted roles have no assignment.

The command migrates the old code / execution / judgment / panel file when possible.

Budget mapping:

Budget Pi thinking level
unlimited max
large xhigh
medium high
small medium

The default budget is large. Budget names are not thinking-level names: a medium budget requests high thinking. Setup has no low budget option.

Pi limits the effective thinking level to what the selected model supports. Unlike Cursor, pstack-pi does not encode effort in a model slug or invent a new slug for an unsupported tier.

Customize models

Run /setup-pstack, choose a budget, then select Change one role to edit any assignment. Panel roles let you choose models in order, including repeated models and inherit-parent. The interactive panel editor accepts up to eight entries.

For per-role thinking levels, edit ~/.pi/agent/pstack-models.json directly. These levels are accepted:

off, minimal, low, medium, high, xhigh, max

For example, this partial config uses GPT for code, Claude for judgment, and Grok at a lower effort for exploration:

{
  "version": 1,
  "budget": "medium",
  "roles": {
    "feature-refactoring": {
      "model": "openai-codex/gpt-6.1-sol",
      "thinking": "high"
    },
    "judgment-prose": {
      "model": "anthropic/claude-opus-5-5",
      "thinking": "high"
    },
    "how-explorer": {
      "model": "opencode/grok-4.7",
      "thinking": "low"
    },
    "arena-runners": [
      { "model": "openai-codex/gpt-6.1-sol", "thinking": "high" },
      { "model": "anthropic/claude-opus-5-5", "thinking": "high" },
      { "model": "inherit-parent" }
    ]
  }
}

Use only routes available in your Pi session. A custom provider route can replace any example above. Unavailable configured models stop delegation and require a config update; pstack-pi does not silently substitute a different paid model.

The budget field records the setup choice. Explicit role thinking values control delegation. Re-running setup reapplies the selected budget to all explicit assignments, including panels, and replaces manual thinking differences.

Configuration is read on each pstack_task call. Changing it affects subsequent calls without restarting Pi. It does not switch the parent chat model. Use Pi's /model and /thinking for the parent; save those defaults separately for new sessions.

Routing precedence

The agent selects instructions and tools. The role selects a model assignment. The bundled poteto-agent and general-purpose agents do not pin a provider or model.

The model is selected in this order:

  1. Explicit per-task model.
  2. Configured role assignment.
  3. Custom agent frontmatter model, if present.
  4. Active parent Pi model.

At either of the first two steps, inherit-parent or auto selects the parent directly and bypasses an agent's fixed model.

An explicit per-task thinking overrides the role's thinking value. When the model is inherited without an explicit thinking value, the child inherits the parent thinking level. An explicit model without a thinking value uses the child Pi default.

For a one-off override, ask Pi to call pstack_task with arguments such as:

{
  "agent": "poteto-agent",
  "role": "feature-refactoring",
  "model": "openai-codex/gpt-6.1-sol",
  "thinking": "high",
  "task": "Implement the agreed change and run the relevant tests."
}

Supplying model bypasses the role assignment, including its thinking value. Supply thinking too when you need a specific effort. The same overrides work on individual tasks[] and chain[] entries.

Exact routing roles

pstack-pi preserves all 17 upstream role boundaries. The preset assigns models as follows; every assignment can be changed.

Role Preset model Assignment shape
feature-refactoring Grok 4.7 Single
bug-fix Grok 4.7 Single
perf-issue Grok 4.7 Single
hillclimb Grok 4.7 Single
judgment-prose Claude Opus 5.5 Single
hardest-tasks Claude Opus 5.5 Single
how-explorer Grok 4.7 Single
how-explainer Claude Opus 5.5 Single
why-investigators Grok 4.7 Single
why-synthesizer Claude Opus 5.5 Single
reflect-tooling Grok 4.7 Single
reflect-judgment-divergent-synthesizer Claude Opus 5.5 Single
arena-runners Claude Opus 5.5, Grok 4.7 Panel
arena-cross-judge-pool Claude Opus 5.5, Grok 4.7 Panel
swarm-workers Grok 4.7 Single
architect-runners Claude Opus 5.5, Grok 4.7 Panel
interrogate-reviewers Claude Opus 5.5, Grok 4.7 Panel

A single role requires one assignment object. A panel requires a non-empty list. Skills use the runner or reviewer list length to decide how many tasks to submit. The extension does not create extra tasks merely because a panel has more entries.

Within each tool call, pstack_task cycles each panel in order. The arena cross-judge pool supplies one judge and prefers a model family different from the parent model.

Pi-native delegation

Extension loading versus skill invocation

Pi loads this package's declared extension at session startup or reload. The pi.extensions entry in package.json points to extensions/pstack/index.ts. Its factory registers /setup-pstack and pstack_task immediately.

Invoking a skill is not required to register or activate the tool. Disabling skills with --no-skills does not disable the extension. Package resource filters, --no-extensions, and tool-selection settings can disable extension loading or tool exposure independently.

A loaded extension does not mean a running subagent. Child processes start only when pstack_task is called. Skills provide workflow instructions; they do not act as an activation gate.

Do not copy the package entry point into ~/.pi/agent/extensions/ while also installing the package. Install it once to avoid duplicate tool and command registrations.

Delegation modes

The package registers pstack_task, a focused tool based on Pi's official subagent example. It starts isolated Pi subprocesses and supports:

  • One task.
  • Parallel tasks[] with bounded concurrency.
  • Sequential chain[] with {previous} substitution.
  • Per-task model and thinking overrides.
  • Exact pstack role routing.
  • Read-only tool restriction.
  • Streaming progress, usage, errors, and cancellation.
  • Package, user, and trusted project agent definitions.

The dedicated name avoids collisions with other Pi subagent extensions. pstack-pi does not require pi-subagents, tmux, or another orchestration package.

Package agents have the lowest precedence. User agents in ~/.pi/agent/agents/ can override them. With agentScope: "both", project agents in .pi/agents/ override both user and package agents. agentScope: "project" loads only project agents.

System design: Pi primitives

pstack-pi preserves pstack workflows, not Cursor's runtime. It uses Pi's extension, skill, model, and package interfaces instead of recreating Cursor services. Child tasks use Pi's command-line interface (CLI).

Responsibility Pi primitive pstack-pi choice
Workflow instructions Package skills and /skill:<name> Load detailed instructions only when needed
Interactive configuration registerCommand() and ctx.ui.select() Native /setup-pstack, separate from a model turn
Available model discovery ctx.modelRegistry.getAvailable() Use Pi authentication and custom providers; no second catalog
Delegation registerTool() with a TypeBox schema One named pstack_task tool with three execution modes
Child execution Pi CLI JSON/print mode Separate process and context per task
Agent instructions Markdown frontmatter and appended system prompt Reusable agent definitions, separate from model roles
Progress and results Tool onUpdate, content, and details Stream progress and retain structured child results
Usage accounting Tool-result usage Report child model usage through Pi's session totals
Terminal display Pi tool renderers and pi-tui components Use the host theme and transcript, not another terminal UI
Persistent routing getAgentDir() and withFileMutationQueue() Versioned JSON, queued atomic writes, file mode 0600
Distribution package.json Pi resource manifest Install extension and skills together from a pinned source

Why these choices

  • Skills for policy, extension code for execution. Playbooks remain readable instructions. Validation and process management are executable operations.
  • Separate agent, role, and model. Changing a provider does not require copying an agent prompt or rewriting a playbook.
  • Use Pi's provider layer. Models and credentials stay under Pi control. Custom providers need no pstack-specific integration.
  • Use isolated CLI children. This follows Pi's official subagent example and avoids shared conversation state. It adds process startup overhead.
  • Keep orchestration inside one tool call. Single, parallel, and chain modes avoid a required background-task service or external orchestrator.
  • Use a dedicated tool name. pstack_task avoids the generic subagent name used by other extensions.
  • Store routing outside session history. Model choices apply across sessions. Child outputs and usage remain attached to the parent's tool results.

No pi-subagents, tmux, cloud-agent service, or custom Pi runtime is required. The implementation uses the Pi CLI rather than an in-process session from Pi's software development kit (SDK).

Execution path

/skill:poteto-mode or another pstack skill
  -> parent Pi selects agent + role + task
  -> pstack_task reads routing and discovers agents
  -> resolve model, thinking, tools, and working directory
  -> launch pi --mode json -p --no-session
  -> collect child messages and stream progress
  -> return content + details + usage to the parent

The child receives the task brief and agent instructions, not the parent conversation. The bundled poteto-agent also receives the packaged poteto-mode skill path.

Limits and trust

  • A parallel call accepts at most eight tasks and runs at most four children concurrently.
  • A chain launches a fresh child for each step. {previous} passes the preceding text output, not a resumable child session.
  • Calls wait for their children. They do not provide durable background jobs or Cursor-style resume handles.
  • Cancellation forwards the tool abort signal to the child process. It is not an operating-system process-tree sandbox.
  • Children share the working directory unless a task supplies cwd. The tool does not automatically create worktrees or prevent competing writes.
  • readonly: true selects read,grep,find,ls as the child's declared tools. It is not a filesystem sandbox. It does not unload extensions or remove MCP integrations.
  • Children load their own Pi resources. Extensions loaded only through the parent's command line are not automatically forwarded.
  • Project agents are opt-in. Untrusted project agents require confirmation when a UI is available, unless confirmation is explicitly disabled.

Use trusted extensions and separate worktrees or non-overlapping file scopes for parallel writers.

Implementation: extension, agent discovery, routing config, and setup.

Pi references: extensions, skills, packages, and the official subagent example.

Cursor-to-Pi mapping

Cursor concept Pi adaptation
/setup-pstack skill-driven setup Native /setup-pstack extension command
Task pstack_task
subagent_type agent
Task model slug with effort suffix provider/model-id plus separate thinking
generalPurpose Bundled general-purpose agent
Background task fan-out One bounded parallel tasks[] call
Cursor model rule Versioned ~/.pi/agent/pstack-models.json
Cursor skill paths Pi package skills and .pi/skills/

Skills

Invoke the main mode explicitly:

/skill:poteto-mode

Other explicit skills use /skill:<name>, for example /skill:arena, /skill:why, or /skill:interrogate.

Skills added in 0.17.0:

  • /skill:correct fixes a repeated mistake class in the repository itself.
  • /skill:sharpen makes a task deeper before rewriting the prompt.
  • /skill:in-your-own-words restates the goal and the problem before work starts.
  • /skill:ketchup reports what changed since your last message and what waits on you.
  • /skill:benchmark-checklist vets a performance number before you report it.
  • /skill:create-formal-verification-skill and /skill:maintain-formal-verification-skill generate and maintain a project-local formal check.

The package retains Pi's progressive skill loading. Most pstack skills use disable-model-invocation: true and load only when explicitly invoked or referenced by another pstack workflow.

Cursor Cloud Automations are not included. Cursor-specific control plugins degrade to direct verification through the tools available in the Pi session.

Personal working preferences

Run /skill:automate-me to create or update a personal -mode skill. The workflow retrieves user and assistant text from Pi sessions for the selected working directory. It reports coverage and requires user confirmation before recording preferences. It does not schedule jobs or infer preferences from assistant responses alone.

The bundled Node.js helper reads the default workspace session directory and honors PI_CODING_AGENT_DIR and PI_CODING_AGENT_SESSION_DIR. For Pi's --session-dir or sessionDir setting, pass the resolved directory explicitly:

node skills/automate-me/scripts/read-history.mjs --cwd /path/to/project --session-dir /path/to/sessions --days 28

Each file's header must match the selected working directory before its messages are read. The helper retains stored branches, deduplicates fork copies, and strips expanded skill instructions from user evidence. It excludes tool output, generated summaries, context-edited messages, and sessions forked from outside the selected directory. These conservative exclusions can omit valid history. Prompt-template authorship still needs user confirmation. The CLI returns coverage only by default. Use --offset 0 --limit 50 for bounded message pages. It reports missing, malformed, or skipped data. Legacy messages without IDs are skipped. When history is unavailable, the workflow asks whether to correct retrieval or draft from direct answers only. Private history and evidence paths do not belong in the published mode skill.

Upstream scope

The skills and agents follow upstream cursor/plugins commit ee0b0d82edfc0b352f78943a4703b7866d0f98e6, adapted to Pi. This covers poteto-mode, its playbooks and worker.md, the routed skills (how, why, reflect, architect, arena, swarm, interrogate), the principle leaves, and the new reframe skill. The extension keeps the Pi-native setup, all 17 routing roles, and isolated delegation.

Upstream removed the Orchestrate playbook, its orch scripts, the check-plan script, and the reference prompts of how, why, reflect, architect, and interrogate. The port removes them too. interrogate follows upstream's structure: adversaries run arena Phase A and B, then every finding is verified by rerunning its command.

The port also carries the current upstream text for files that had drifted before the recorded base, such as the principle leaves, tdd, typescript-best-practices, and blast-radius. upstream:drift keeps that true in CI, so a file that falls behind cannot hide again.

These upstream items stay excluded or follow-up work:

  • statechart and poteto-help, which need a Pi adaptation of Cursor-specific mechanics.
  • ketchup-video, which renders a video that a terminal cannot show inline.
  • make-bot-ui and the benny automations, which target Cursor and Grok Bot services.
  • The upstream model defaults and routing changes: an Opus-first preset, three-seat panels with Fable 5.2 and Gemini 4 Neon, nine roles instead of 17, and no level above xhigh. The extension keeps its own preset and roles until the maintainer decides.

Cursor-specific execution mechanics must be adapted to Pi before inclusion. Personal provider choices and the parent Pi default model are user configuration, not package defaults.

Upstream tracking

upstream.json records the upstream repository, the pstack directory, and the full upstream commit that the port last synced with. It also lists:

  • mapped: the directories the port ships (skills/, agents/).
  • excluded: upstream paths the port does not ship.
  • piOwned: files the port rewrites in Pi's terms, so a text comparison would always report them. setup-pstack is the main one.

Check how far the port is behind upstream:

npm run upstream:status

The command makes a bare clone of cursor/plugins in a temporary cache. It prints the upstream commits since the recorded base and puts every changed file in one class:

Class Meaning
Copied from upstream The Pi copy matches the upstream base, so the new upstream version replaces it.
Clean three-way merge Pi and upstream both edited the file, and git merge-file merged them without conflicts.
Merge conflict Pi and upstream both edited the same lines.
Deleted Upstream deleted the file, and the Pi copy matches the upstream base.
Deleted upstream, edited in Pi Upstream deleted the file, and the Pi copy has Pi edits. The file stays for review.
New upstream file Upstream added the file. It needs a Pi adaptation.
Excluded or removed in Pi The port does not ship the file. Nothing is applied.

node scripts/upstream.mjs prepare --report <file> applies copies, deletions, and merges to the working tree. It writes diff3 conflict markers into conflicted files and records the target commit in upstream.json. Files listed in piOwned are reported, never overwritten.

npm run upstream:check fails on unresolved conflict markers and on Cursor-only mechanics, such as ~/.cursor paths or run_in_background, in Markdown files under the mapped directories.

npm run upstream:drift compares every shipped file with the recorded upstream commit, not only the files that upstream changed since the base. For a file that differs, it finds the closest historical upstream version, three-way merges that version with the Pi copy and the target, and treats the file as adapted when the merge returns the Pi copy unchanged. It fails when:

  • The Pi copy matches an old upstream version, so upstream already fixed or shortened that text (stale).
  • Merging the target changes the Pi copy, so an upstream edit was never applied (stale-merge).
  • The Pi copy keeps a line that existed in an older upstream version but not in the target (stale-text). This catches text the sync cannot see, because the file drifted before the recorded base.
  • Upstream ships a file the port lacks (missing), or the port ships a file that upstream removed and piOwned does not list (unlisted).

--apply writes the upstream copy, or the merge result, over the stale files. Conflicted merges are written with diff3 markers. drift reports same-line edits that conflict without failing, because the Pi copy may already carry the new upstream wording.

CI runs upstream:check, upstream:drift, and release:verify on every pull request.

Automatic sync with Pullfrog

The Upstream sync workflow runs every Monday and on manual dispatch:

  1. It stops when an upstream-sync/* pull request is already open.
  2. It runs upstream.mjs status. It stops when no file needs work.
  3. It runs upstream.mjs prepare.
  4. A Pullfrog agent follows .github/upstream-sync/prompt.md. The agent resolves conflicts, adapts Cursor mechanics to Pi, updates this section and the changelog, and runs the checks.
  5. The agent pushes an upstream-sync/<commit> branch and opens a pull request. The push: restricted input blocks pushes to main and tag pushes.

The sync step always runs on Claude Opus at high effort. Other Pullfrog runs use the model setting in the Pullfrog console. The agent does not edit extensions/ and does not change the package version. Upstream changes to model defaults or routing go into the pull request as follow-up work.

Setup:

  1. Install the Pullfrog GitHub App on this repository.
  2. Click Verify manual installation on the repository's page in the Pullfrog console. The repository already has .github/workflows/pullfrog.yml.
  3. Give Pullfrog model access. Store a provider key in Pullfrog, use the Pullfrog Router, or add one of the keys that the workflow names as a GitHub Actions secret.
  4. Run Upstream sync once from the Actions tab to test the setup.

To sync by hand, run prepare, then resolve the report the same way the agent prompt describes.

Development

Requirements:

  • Pi 1.1.0 or newer.
  • Node.js 22.19 or newer.

Run the checks:

npm install --ignore-scripts
npm run check

The tests cover config validation, budget application, legacy migration, atomic persistence, workspace-scoped Pi history retrieval, upstream sync classification, and release version handling. History tests use temporary session files for branches, fork copies, date filtering, malformed data, and workspace isolation. TypeScript checks the extension against Pi's public extension types.

Release workflow

pstack-pi uses its own package version. It does not claim full parity with the same-numbered upstream Cursor release. The routing config's version is a separate schema version.

Versioning

  • Versions use MAJOR.MINOR.PATCH without prerelease suffixes.
  • Before 1.0, use a minor bump for breaking changes and a patch bump for compatible fixes.
  • package.json, both root version fields in package-lock.json, and a CHANGELOG.md section always name the same version. CI runs npm run release:verify to check this.
  • A published version number is never reused. Release tags are never moved or overwritten.

Changelog

Every pull request that changes shipped behavior adds an entry under ## Unreleased in CHANGELOG.md. Use ### Added, ### Changed, ### Removed, and ### Fixed subsections. Upstream sync pull requests add their own entries there. A release renames ## Unreleased to the new version, so the release notes are the text that reviewers already approved.

Cut a release

  1. Run the Release PR workflow from the Actions tab. Pick patch, minor, or major.
  2. The workflow runs node scripts/release.mjs prepare <bump>. It stops if ## Unreleased is empty, or if the tag, the npm version, or another release/* pull request already exists.
  3. The workflow pushes release/v<version>, opens a pull request, and starts CI on the branch.
  4. Review the pull request. Add migration notes and known limits to the changelog section on the branch if needed.
  5. Merge the pull request. The Release workflow then:
    1. Verifies the versions and the changelog against the tag name.
    2. Runs npm run check, npm run upstream:check, and npm pack.
    3. Creates the annotated v<version> tag on the merged commit through the GitHub API.
    4. Creates the GitHub release with the changelog section, install commands, the npm pack archive, and its SHA-256 file.
    5. Publishes the same archive to npm through trusted publishing, with provenance.
  6. Update consumers to the new tag. Install the new source and verify startup with skills disabled.

Each Release step checks whether its result exists before it runs. If a step fails, fix the cause and re-run Release from the Actions tab. When the tag exists, the re-run builds from the tagged commit, not from the newest main.

To prepare a release locally, run node scripts/release.mjs prepare <bump> in a new Jujutsu change and open the pull request yourself. Merging it starts the same Release workflow, so you never create or push tags by hand.

One-time setup

  1. In Settings > Actions > General, enable Allow GitHub Actions to create and approve pull requests. The Release PR workflow needs this setting to open the pull request.
  2. On npmjs.com, open the settings for @0xrsydn/pstack-pi. Add a trusted publisher for GitHub Actions with repository 0xrsydn/pstack-pi and workflow release.yml. No NPM_TOKEN secret is needed.
  3. To skip npm, set the repository variable NPM_PUBLISH to false. The tag and the GitHub release still publish.