omp packages

pi-pretty-task1.8.2

Background processes, log tails and scheduled agent wake-ups for pi, behind one panel.

GitHub Actions Published 21 hours ago MIT ~4.3K 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

pi-pretty-task

Background processes and scheduled agent wake-ups for pi, behind one panel.

verify npm license node

A build that takes six minutes. A watcher that runs all afternoon. A loop that wakes the model every ten minutes. They all land in the same list — readable, searchable, stoppable — and the output is still on disk when the turn is over.

A command is typed in an ordinary session and it runs in the foreground; ctrl+shift+b moves it to the background, and the card it leaves behind stays in the transcript — then /tasks, and the panel opens on every status, one task's output, following the log, back to the list, the task ends, f narrows to failed until the failed filter keeps the reason, and / search keeps the query; then the notice a finished task leaves, one line above the editor while the panel is closed, and a wait: true call answering with its output

Install

pi install npm:pi-pretty-task

Requires pi and Node >= 22.19. A local checkout works too: pi install ./path/to/pi-pretty-task, or pi install git:github.com/mystery4f/pi-pretty-task for the latest main.

Why use it

You want to… Use
Start a build, dev server or watcher and keep talking to the agent pretty_task_bg_run
Wait for it without sleeping, polling or burning a turn pretty_task_bg_wait
Read what it printed — or only what is new since last time pretty_task_bg_logs, add follow
Find the one error in 40 MB of output pretty_task_bg_grep
Stop it and its children, not just the parent pid pretty_task_bg_kill
Run something after another job succeeds, instead of now pretty_task_bg_run with after
Get a command's exit code and output tail in one call, without a second round trip pretty_task_bg_run with wait: true
Wake the agent on a schedule — interval or cron pretty_task_loop_create
Fire that wake once more, now, without moving the schedule pretty_task_loop_fire
Find out what that wake-up actually did pretty_task_loop_list with an id
Wake it only when something actually happened pretty_task_loop_create_event, then pretty_task_loop_listen
Stop listening again without deleting the loop pretty_task_loop_unlisten
Just look at everything /tasks or Shift↓ — the same door the status line prints

Event loops — pretty_task_loop_create_event with pretty_task_loop_listen — are designed in ADR-0036 and are not in a release yet; the table above names them so the design can be reviewed against the page a user will read.

One panel, three records

  • Task — a long-lived shell command in the background, watched, with its whole process tree killable. Output goes to a file, so "what did it print?" survives the turn.

    A task opened: npm run dev under way, its output tail refreshing once a second

  • Chain — a command queued behind another task or chain instead of started now. A step is recorded as waiting and starts only after the step ahead ends with exit 0; a failing step leaves the ones behind it skipped. The chain's own page is the only place the queue is visible as a queue: every step in run order, a › on the one running, and the child record each step became (ADR-0013).

    A chain opened: build, then release:test both done, release:publish still waiting, with the id each step will become

  • Loop / Iteration — wake the LLM on a schedule with a preset prompt (30s/10m/2h, or five-field cron such as 0 9 * * 1-5), and record every tool call of the turn that follows, so "what did that loop actually run?" has an answer.

    What you see. A fire that made no tool call prints its 0 calls as a fact, and two in a row are marked — a turn that read files and thought before acting is not a stall on its first occurrence. A command loop has no iterations to record, so it keeps its fires instead: each one with its outcome, exit code, duration and size, newest first, with the older ones the history cap dropped counted rather than hidden.

    A command loop's page: every fire with its outcome and exit code, including the one that failed

    What it says. A turn pi is retrying after a provider error says so — retry 2/4 · 529 on the loop row, and a Retry field on the iteration page — so four failed attempts are not mistaken for one slow one. When the provider finally gives up, that fire is counted: the loop keeps the error, the time and a run of consecutive failures, its row counts the run (2 failed beside the fire count) and its page prints the error the provider gave up with and reads that fire as failed rather than completed, and its next wake is pushed back instead of hammering a provider that is down — while a turn you stopped yourself counts for nothing. Wakes wait for an idle agent instead of interrupting a turn. A command loop that exits with one of the codes you declared as a signal is signalled, not failed: it keeps its schedule, and wakes you once per raised condition instead of once per fire.

    Where the rules are. ADR-0001 (a fire is a turn, not a shell command), ADR-0006 (cron beside intervals), ADR-0007 (history cap and restart repair), ADR-0009 (wakes wait for idle), ADR-0015 (the fire strip), ADR-0017 (overlap skips, failures back off), ADR-0018 (signal outcome and the minimum gap).

    A loop fire opened: the twelve tool calls that one wake-up made

A fire that comes due while the previous one still runs is skipped and counted, never queued. An id says its kind on sight: bg- runs a command, lp- wakes the assistant, lc- runs a command on a schedule, ch- is a chain.

Deliberately not here: subagent/delegate/fusion tools, monitors-with-shell, workflow/orchestration families, provider-attested runs. See docs/scope-v1.md.

The panel

Opens with /tasks or Shift↓, and has three tabs — processes, loops, chains — plus five filters (all, running, failed, done, signal). It opens on all, so a session whose work has all ended still shows its rows; f narrows. One summary line above the editor stays after it closes; the footer row is shared with every other extension, so the count lives where it can be read.

List keys: ↑/↓ select, Enter open, k stop, a stop all, f cycle filter (all/running/failed/done/signal), o toggle other sessions' records, R rerun, c show the output path, / search, s open settings, x close from the list, 1/2/3 pick a tab, alt+q close from anywhere (the first press leaves search mode).

Detail keys: ↑/↓ scroll, r follow the log, ← back to the list, k stop the one that is open, R rerun, c show the output path, S save the command as a template (named after the task id, without its cwd; a name the target file already has is refused), 1/2/3 pick a tab, alt+q close.

Settings keys: ↑/↓ select a setting, Enter toggle or edit, d clear the setting from the target file, or — once ↓ has walked past the last setting onto the template list — remove the template under the cursor, t switch target file (project / agent), ← back to the list, alt+q close.

↑/↓ · Enter logs · k stop · f filter · o others · 1/2/3 tabs · / search · R rerun · a stop all · s settings · alt+q close

The /tasks panel: every process, loop and chain in one list, with the dev server's row still growing

The filter keeps the reason on the row — a failure keeps its exit code and its runtime — and the header counts what the filter left out, so a narrowed list never reads as an empty session.

The list filtered to failed: two rows, both showing exit 1, and the header still counting what the filter hides

Search matches the name, the command and a loop's prompt at once, and keeps filtering after alt+q leaves the box.

The search box with a query that hits: seven records narrowed to the ones whose command contains "run"

s opens the settings page on the same panel: every setting with the layer that owns it (env, project, agent, default), what the target file holds, and whether a change is live or needs /reload. A row shadowed by an environment variable says so, because a file edit there saves but never takes effect.

The settings page: eight settings with their source badge — one from env, one from project, two from agent, four from default — the project file's values beside them, and each row marked live or requires /reload; the selected row shows all four layers and the variable shadowing it

With the panel closed, one line stands in for it: how many records are running, how many command loops have a raised signal, how many have ended, and the way back in. It is a widget (PI_PRETTY_TASK slot), so another extension cannot take the line, and it reprints after every change the extension makes.

The status line above the editor: 9 running · 1 signal · 9 finished, and the command that reopens the panel

Every image on this page is a screenshot of the shipped panel, not a mock-up: npm run preview renders them from TasksPanel itself, so a change in src/ui/panel/ shows up in the next run instead of drifting away from the picture.

What lands in the transcript

Three cards, one per kind of event, so a reader scrolling back does not have to open /tasks to know what happened: task-finished (status, name, id, duration, exit code, the reason if there is one, and the last lines of output), loop-signal (a command loop's fire that raised its condition, with the report it printed) and loop-wake (the prompt a fire delivered, exactly as the loop carries it). Each is a session message — the model reads the same facts — and each renders from its details, never from prose.

Three cards in a row: a failed task with its output tail, a signalled command loop with its report, and the prompt one wake delivered

A fourth card, task-detached, is a session entry rather than a message: it records a command moved out of the front, and it is described under the takeover below.

Use it

pretty_task_bg_run    command: "npm run build", name: "build"
pretty_task_bg_run    command: "npm test", wait: true, waitSeconds: 240
pretty_task_bg_status id: "bg-4xq81"
pretty_task_bg_logs   id: "bg-4xq81", follow: true
pretty_task_bg_grep   id: "bg-4xq81", pattern: "error"
pretty_task_bg_wait   ids: ["bg-4xq81"], timeoutSeconds: 120
pretty_task_bg_kill   id: "bg-4xq81"

pretty_task_loop_create schedule: "10m", prompt: "Check the deploy and report drift."
pretty_task_loop_create schedule: "0 9 * * 1-5", command: "npm run nightly"
pretty_task_loop_create schedule: "10m", prompt: "Check the deploy and report drift.", guard: { path: ".pi/deploy-ready" }
pretty_task_loop_create schedule: "10m", prompt: "Handle new mail.", guard: { command: "bash scripts/inbox-has-new.sh", notifyExitCodes: [1] }
pretty_task_loop_update id: "lp-9f3kd", action: "pause"
pretty_task_loop_update id: "lp-9f3kd", prompt: "Check the deploy, and report only drift."
pretty_task_loop_fire   id: "lc-7k2m9"
pretty_task_loop_list   id: "lp-9f3kd"
pretty_task_loop_delete id: "lp-9f3kd"

pretty_task_loop_update also takes resume, complete, rearm (recompute the next fire from now on the same schedule, the way back onto a slot after a backoff) and clear-signal (drop a raised condition you have already dealt with, without waiting for a healthy round). pretty_task_loop_fire runs one fire of a command loop immediately without spending a schedule slot or touching the failure streak — the way to test a command before trusting it to a clock.

Stopping means the whole tree: SIGTERM, a grace period, SIGKILL, then a poll until the process group is really gone — grandchildren included. On Windows that is taskkill /PID <n> /T.

A command in front can be let go

Two kinds of call can be waiting on you, and one key lets exactly one of them go. A long build is already running in front of you — the first frames of the animation above are this exact move. With PI_PRETTY_TASK_ADOPT_FOREGROUND=on, the built-in bash tool — and your own ! commands — run through this extension, so ctrl+shift+b moves the one command currently in front to the background instead of killing it. The call ends with the output it had captured and a ↪ moved to bg-… line, and the command keeps running as an ordinary task: pretty_task_bg_logs, pretty_task_bg_status, pretty_task_bg_kill all work on it.

Both triggers — the key and the deadline — end the call with the same shape and say which one it was (ctrl+shift+b, or it had held the front for 91s), so a model reading the transcript can tell a person's decision from a clock's. The move also leaves one card in the transcript naming the record and the trigger, so you learn it happened without opening /tasks; the card is part of the session, so it is still there after a reload, and it never enters the model's context.

The detach card in the transcript, twice: once moved by ctrl+shift+b, once by the deadline — the record's id, how long it held the front, which trigger moved it, and the two commands that reach it

PI_PRETTY_TASK_FOREGROUND_TIMEOUT does the same on a timer, for the terminal you have already walked away from; 0, the default, never moves anything. A call's own timeout still stops the tree — a timeout is a failure, not a move. The takeover is off by default because it re-registers pi's own shell tools; see ADR-0020.

The key also works with the takeover off: the other waiting kind is a blocking run, which has nothing to do with adoption.

Waiting inside the call

pretty_task_bg_run normally answers as soon as the process is running. With wait: true it stays open instead and answers when the command ends: the status, exit code and kill reason, then the last 200 lines of its output. Either way it is the same task — recorded, listed in the panel, counted against PI_PRETTY_TASK_MAX_RUNNING_TASKS from the first millisecond — so nothing here waits for a record to appear first.

The choice is not taste. Wait when the command ends by itself, its result is what the next step needs, it should finish within 600 seconds, and nothing else is waiting for you to do meanwhile — and then pass waitSeconds as well, the expected seconds plus 60, at most 600. Start it in the background when you have other work you could be doing while it runs: finish that work, then read the result with pretty_task_bg_logs or a pretty_task_bg_wait on a task started earlier. Leave the wait off too when the result is not needed yet, when the command may run past ten minutes, or when you cannot say how long it takes — a task id is enough, and the tool call returns in the same second. Work that ends in seconds belongs in bash, not in a task. A command that never ends — a dev server, a watcher — is started once and read with pretty_task_bg_logs follow, never as tail -f in a task. And a pretty_task_bg_wait on the task your own previous call started is always the wrong shape: that wait belonged inside the run, which is why wait: true exits with three receipts instead of a second turn. Nothing streams while the call waits; the panel already shows the growing output, and a second copy in the transcript would cost the same bytes twice. Three ways out early: Esc ends the wait and leaves the task running, the same way pretty_task_bg_wait does; waitSeconds (1–600) is the caller's own deadline, and passing it ends only the wait — the task is untouched and the answer says so, which is what makes it different from timeoutSeconds, where the whole tree stops and the call answers with the ending that says timeout; ctrl+shift+b lets the call go: it answers with what it had captured plus ↪ moved to bg-… — no exit code, because none exists yet — and the press leaves the same detach card in the transcript that a foreground detach leaves. Leaving waitSeconds out keeps the wait unbounded; a queued step cannot be waited for at all, because after together with wait is refused before anything starts.

A detach closes the front for a minute. In that minute a foreground command and a wait: true call are both refused, and the refusal is the reminder itself — it names what just moved, why, and how many seconds are left — because a long command started right after one was moved would only be moved the same way. The receipt of the detach ends with the same rule. Background starts are never refused: putting work in the background is the answer, not the problem.

The rule above ships as part of the plugin's usage spec, injected into the system prompt as one <pretty-task> section, so it is in every session that holds these tools without anyone writing it into a config file, and it is the only copy: a tool description says what that tool does, a parameter description says what that parameter means here, and everything that spans calls lives in the spec. The section is written into the prompt in place, so it neither reorders what is already there nor invalidates the cached prefix. ADR-0032 records the three layers and the injection seam, ADR-0028 the rule itself and the measurement it is judged by. See ADR-0025, ADR-0026 and ADR-0027.

Leave it running while you are away

A prompt loop is a clock: every fire delivers a message into the session and starts one turn. That is enough to keep a long job moving overnight, provided the work has somewhere to live and the loop knows when to stop.

  • Keep the work in a progress file, one item per line with an acceptance check on each. "npm run test:unit exits 0" can be finished; "improve the code" cannot.
  • Put a closing contract in the loop's prompt: tick the item that finished, and when nothing is left call pretty_task_loop_update id=<id> action=complete.
  • Fine-tune the wording without touching the schedule: every fire reads the loop's prompt file (the path pretty_task_loop_list prints, and the loop's page in /tasks shows along with its first three lines and when the file last changed), so an edit takes effect on the next fire and deleting the loop deletes the file. The same change goes through pretty_task_loop_update id=<id> prompt="…" when the agent is the one refining the wording: the loop keeps its id, fire count and iteration history, the text given at create time stays the seed the file falls back to, and a write that cannot land leaves the old text in place and says so in the reply.
  • Always pass maxFires. It is the only stop that does not depend on the model's own judgement.
  • Gate a loop that mostly finds nothing to do. guard: { path: "…" } lets a fire wake the session only while that file or directory exists — relative paths resolve against the session directory. guard: { command: "…", notifyExitCodes: [1] } asks the system instead: the command runs in the session's task directory before each fire, and the fire wakes the session only when the command exits with one of those codes (exit 0 is refused as a code — for a gate it means "nothing to do"). The run is capped at 10 seconds unless timeoutSeconds says otherwise, and a timeout refuses the fire. Whatever a passing run printed — the last 20 lines, up to 2000 characters, from <loop-id>.guard.log beside the loop's records — travels with the wake under What the guard command printed before this fire:, so the turn starts knowing what the command found. A refused fire is recorded instead of delivered (refused: 12 in a row in pretty_task_loop_list, ⏸ guard on its row in /tasks, and a guard stop in the f filter), does not count as a fire, and never wakes the model; maxFires therefore still means wakes. Remove it with pretty_task_loop_update id=<id> guard="off". Gates are checked when the fire is due — so expect up to one interval of lag after the condition appears — and every due gate of the session is checked at the same time, so one slow command does not delay the other loops. A command loop has no guard: its exit code is already the gate.

The bundled pretty-task-unattended skill carries the whole recipe — the file shape, the exact contract text, and what to read the next morning. Ask for it in plain words ("run this unattended overnight") and it fills in the calls.

Bundled skills

Two skills ship with the package and are offered by name: pretty-task-unattended (the overnight recipe above) and pretty-task-templates (adding or changing a command template — what the file must contain, which of the two files wins, and that an edit applies to the next call without /reload).

Tools

Tool What it answers
pretty_task_bg_run Start a command, with wait: true to answer only when it ends; also starts a chain step with after, or a named template with template
pretty_task_bg_status Status, elapsed time, working directory, kill reason
pretty_task_bg_logs The output tail, or follow for only what arrived since the last read
pretty_task_bg_grep Matching lines of the whole output file
pretty_task_bg_wait Wait for one or more tasks (ids, mode: "all" | "any") up to 600 seconds and return the final view and output tail of each
pretty_task_bg_kill Stop the task and every process it started
pretty_task_loop_create A schedule: an interval, a cron expression, or a command that runs on it. A prompt loop also takes a guard — a path or a command — that decides whether its fire wakes the model
pretty_task_loop_list The loops, or one loop's fires and the tool calls of each iteration
pretty_task_loop_update Pause, resume, complete, retune the schedule, replace the prompt, replace or drop the guard, rearm, or clear a raised signal
pretty_task_loop_fire Run one fire of a command loop right now, off the schedule
pretty_task_loop_delete Delete a loop, its prompt file and its guard log

Every task's child process starts with PYTHONUNBUFFERED=1: Python block-buffers a piped stdout, so without it a running task's log would stay empty until the process ends and pretty_task_bg_logs would have nothing to show. The variable sits underneath a call's own env, so env: {"PYTHONUNBUFFERED": "0"} restores Python's buffering (ADR-0034).

Configuration

Every setting resolves across four layers — process.env (PI_PRETTY_TASK_*) > <project>/.pi/pretty-task.json ("settings") > ~/.pi/agent/pretty-task.json ("settings") > built-in defaults — and can also be inspected and edited from the /tasks panel by pressing s. A value that cannot be honoured fails the extension load with the key or file name instead of silently falling back.

Key ("settings" / env) Default Meaning
outputCapBytes / PI_PRETTY_TASK_OUTPUT_CAP_BYTES 20971520 (20 MiB) Output file cap; crossing it kills the tree with reason output_cap
maxRunningTasks / PI_PRETTY_TASK_MAX_RUNNING_TASKS 20 Running process records per session, children and steps included
notify / PI_PRETTY_TASK_NOTIFY on Write an OSC 9 notification to the terminal when a task ends
retentionDays / PI_PRETTY_TASK_RETENTION_DAYS 7 Session directories older than this are pruned at startup (requires /reload)
shell, shellPath / PI_PRETTY_TASK_SHELL, _SHELL_PATH bash Windows shell (cmd, bash) and its absolute path; bash.exe comes from Git for Windows — the one pi was started from, then the git on PATH, the registry, the usual install dirs, then PATH
posixShell, posixShellPath / PI_PRETTY_TASK_POSIX_SHELL, _POSIX_SHELL_PATH bash POSIX shell (inherit, bash, sh) and its path
adoptForeground / PI_PRETTY_TASK_ADOPT_FOREGROUND off Run pi's bash tool and ! commands through this extension, so the command in front can be moved to a task; the powershell tool it registers has no such move (requires /reload)
foregroundTimeoutSeconds / PI_PRETTY_TASK_FOREGROUND_TIMEOUT 0 Seconds before the command in front is moved to the background by itself; 0 never moves; either trigger says which one it was, once, in the tool result and on a card

The OSC 9 notification rings once per task and only on an ending: completed, failed, killed and interrupted write \u001b]9;<name> <status>\u0007, a running or paused task writes nothing, and PI_PRETTY_TASK_NOTIFY=off (or "notify": "off") silences all of it. A terminal that ignores OSC 9 shows nothing at all, which is why the same ending is also a card.

Command templates and "settings" share <project>/.pi/pretty-task.json and ~/.pi/agent/pretty-task.json, project first. Editing settings from /tasks (s) writes atomically and preserves "templates" in the same file; a template edit applies to the next pretty_task_bg_run call, while the two startup-only settings (adoptForeground, retentionDays) need /reload and the remaining settings update the live session immediately. The settings page also lists every template of the merged catalog with its command (↓ past the last setting) and d removes the one under the cursor from the target file; the detail view's S saves a process's or command loop's command as a new template. Adding or changing a template by hand is covered by the bundled pretty-task-templates skill.

Full detail, including the four-layer rules, shell pairing, decoding order and per-call cwd/env: docs/configuration.md.

Documentation

Start at AGENTS.md for the product model and rules, and GLOSSARY.md for the vocabulary. Scope and decisions live in docs/ — docs/scope-v1.md and the ADRs under docs/adr/ — and the index for all of it is the wiki page .llm-wiki/wiki/syntheses/pi-pretty-task-文档索引.md. The screenshots and how they are made: docs/previews.md.

Development

npm install
npm run verify    # check + lint + test
npm run build     # emit dist/
npm run preview   # build, then re-render docs/preview*.{png,gif}

npm run check typechecks without emit, npm run lint is Biome, npm run test runs vitest over both projects, npm run test:unit the pure half in seconds. Style is machine-enforced by .editorconfig + Biome; dist/ is build output and is never committed. AGENTS.md has the full verification list.

npm run preview drives the built panel with scripted keystrokes in a headless browser and writes the images on this page; it needs a Chrome or Edge on the machine (PREVIEW_BROWSER points at another one). npm run preview:dump --only <label> prints the same frames as text without a browser. docs/previews.md covers the frames and the colours.

npm run load-check loads src/index.ts through pi's own extension loader and prints the errors the TUI shows only once at startup. Run it first when the pretty_task_* tools are missing after /reload: a pretty-task.json with an unknown key fails the whole extension on purpose, and nothing in the session record says why.

Releasing

Published to npm by .github/workflows/publish.yml when a GitHub Release is published. Steps, token requirements and the traps: docs/releasing.md.

License

MIT