@pithos-kit/plan0.7.0
Session-owned read-only planning with durable checkpoints, explicit lifecycle commands, previews, and conflict-safe atomic publication for Pi.
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.
Reports 0
No reports yet.
Readme
@pithos-kit/plan
Session-owned, enforced read-only planning for Pi with durable exact checkpoints, explicit save/preview/exit commands, and conflict-safe atomic publication.
Install
Requires Pi 1.0.0 or later.
pi install npm:@pithos-kit/plan
For local development:
pi install -l ./pithos.plan
Pithos .pithos config
pi:
extensions:
"@pithos-kit/plan": "npm:0.7.0"
Command lifecycle
/plan
/plan save
/plan preview
/plan exit
/plan status
/plan help
/plan --help
/plan -h
The grammar is explicit. /plan <task>, /plan pause, /plan cancel, and other
unknown arguments are rejected with help. Enter Plan mode first, then provide the
task and refinements as normal prompts.
/plan is a registered Pi command, routed before input middleware. Save/exit
finalization prompts are sent as extension-source user messages, so middleware
such as Squiggle and Translate that skips extension input leaves them unchanged.
Publication authorization also requires the originating lifecycle dispatch; copying
its prompt in another user or extension message does not authorize publication.
/planenters Plan mode. The first use creates one plan identity and a collision-resistant candidate path for the physical Pi session. Later uses restore that same plan. Repeating it while active is a no-op./plan saveasks the agent to finalize/checkpoint when needed and publish the latest exact checkpoint. It creates the file on first publication and updates the same stable path afterward. If Telos is available, a new publication also requires an agent checklist review. Plan mode remains active./plan previewdisplays the latest exact checkpoint without publishing. It fails clearly when no checkpoint exists and does not start an agent turn./plan exitis the sole combined leave/pause command. A synced published plan with no pending review exits immediately. Otherwise Pi first offers Create/Update plan, Exit without publishing, Preview, and Continue planning, before any model turn. Exit without publishing is the safe default and keeps the checkpoint and plan identity restorable. Create/Update binds the exact current checkpoint, path, and update baseline before asking the agent to finalize; a changed checkpoint requires exact reapproval. With no checkpoint, the direct chooser offers Exit without publishing, Finalize before exit, and Continue planning. If finalization settles without publication, an idle Exit/Continue fallback prevents Plan mode from becoming trapped. A pending Telos review takes precedence over these ordinary exit choices; see Optional Telos checklist review./plan statusreports active/inactive mode, branch revision, unpublished/dirty/synced/conflict state, path, persisted/ephemeral session status, and pending publication recovery or task review without an agent turn./plan help,--help, and-hshow usage without changing state.
During the publication-to-review handoff or an active Telos review, status, help, and preview are observational; they do not cancel the review. Requests to enter, save, or exit are refused until the current review settles. New ordinary user input still supersedes a review.
Autocomplete offers save, preview, exit, status, and help, followed by
the retained --help and -h aliases. The package registers no prompt templates,
so /plan appears only as a command. Bundled prompts/plan.md remains reference
guidance, not a registered prompt; pi.prompts: [] explicitly disables default
prompt discovery even when package resource filters are used.
Translated previews
With Plan 0.7.0 and Translate 3.3.0 or
compatible later versions, /translate output-on also applies to
/plan preview and Preview the plan
from /plan save and /plan exit in the interactive TUI. The original appears
right away and stays scrollable. An animated Translating plan… indicator
appears in the target row while the request runs. When the translation is ready,
the viewer puts a labeled reading copy at the top. Press Home to go there, or
scroll past it to read the original. Enter or Esc closes the preview and
cancels any pending translation.
Each open can send the full Markdown checkpoint to the configured output translation provider in one request. Translate protects code and link destinations before the request, but this is not secret redaction. The provider can receive private prose, and its pricing, privacy terms, and limits apply.
If Translate is missing, off, or cannot translate the checkpoint, the viewer keeps the original. The reading copy is not stored in the session. RPC previews, approval, and the published file still use only the original checkpoint.
Exact session checkpoints
While active, Plan mode exposes the internal sequential update_plan_draft tool.
The agent is instructed to call it after the first coherent planning brief and
after every material change to requirements, constraints, decisions,
assumptions, open questions, or plan steps.
Each call supplies:
- the complete Markdown snapshot (never a patch or summary), and
expectedRevision, using optimistic branch-local concurrency.
The result returns the new revision and SHA-256 digest. The complete exact snapshot is stored in Pi session tool-result details; lifecycle custom entries store the session owner, stable plan identity, candidate and published paths, checkpoint revision/digest, publication digest/state, active flag, and content/path-bound approval state, and any Telos review target and outcome. There are no draft plan files.
During ordinary planning, every active model context receives an ephemeral
projection of the exact latest branch checkpoint. It is explicitly labeled unapproved data, not
instructions, and says that newer user messages are authoritative. The
projection occurs through Pi's context event on every model call, independently
of compaction summaries.
Completed checkpoints survive compaction, /tree, cancellation, /quit and
resume, reload, and process restart when the Pi session itself is persisted.
Active Plan mode also keeps or reapplies the bundled plan theme during /reload
without replacing the saved pre-Plan theme that will be restored on exit.
Ephemeral (--no-session) use is supported for the current process, but Plan
warns on activation and reports the limitation in /plan status.
Sessions, branches, and forks
A physical Pi session owns exactly one logical plan and at most one published
file. Exiting without publication preserves the identity and checkpoint;
re-entering /plan restores them. Start a new Pi session to start a new logical
plan.
Checkpoint revisions are branch-local. After /tree, Plan reconstructs only the
selected branch's validated checkpoint, clears stale approval, and reconciles
mode tools/theme. Sibling checkpoint content is never projected into the active
branch. Publication identity, the stable published path, and pending task review
remain global to the physical session. Review recovery does not adopt an older
branch's exit intent.
Forked, cloned, and new sessions have a different Pi session ID. Copied parent state is not treated as ownership: entering Plan creates a fresh identity and a unique candidate path. Active legacy state is migrated to a fresh session-owned identity with old approval revoked and no legacy file implicitly claimed; inconsistent or multiple identities fail closed.
Publication and approval
create_plan remains the controlled publication tool for compatibility, but it
accepts an exact checkpoint revision, not reconstructed Markdown. It is
blocked during ordinary planning and becomes eligible only for the agent turn
started by /plan save or /plan exit.
First publication
Pi binds approval to the exact checkpoint digest and selected path. TUI users may preview the exact Markdown before choosing Create plan; RPC approval includes the complete checkpoint and target. Without interactive UI, publication is blocked and Plan mode remains active. Persisted approval is never reused to mutate a file in a no-UI runtime.
Publication creates under .pi/plans/ using an exclusive, atomic no-overwrite
operation. Preflight validates existing .pi and .pi/plans components without
creating them and rejects symlinks or non-directories. Approved execution creates
missing components one at a time and validates them against the canonical project
directory. Known collisions are resolved before approval. A collision racing the
write advances the generated timestamp, revokes approval, and requires renewed
confirmation.
Updates
All updates target the same first-published path. Cooperating Pi mutations are serialized through Pi's per-file mutation queue. After asynchronous temporary file preparation, the final open/fstat/read/lstat/digest verification and atomic rename execute synchronously in one non-yielding JavaScript section. A modification, deletion, symlink replacement, or directory observed by that verification is a conflict and is never silently overwritten. The session remains in Plan mode.
Portable Node APIs do not provide a strict cross-process compare-and-swap for this replacement, so this is not a linearizable CAS. Arbitrary external OS writers are not locked and can still race the final filesystem calls.
If the latest checkpoint digest is already published, Pi verifies the on-disk
bytes and performs no write. /plan save remains active; /plan exit exits
immediately when that verified publication is unchanged and no review is pending.
Optional Telos checklist review
If the genuine @pithos-kit/telos
telos_tasks tool is callable when an approved publication creates or changes
plan bytes, publication is also the user's intent to track that work. Plan
checks the tool registry's resolved package/entrypoint location and the canonical
Telos manifest, including local checkouts, direct entrypoint installs, and
entrypoints loaded via settings.json's extensions or -e. Even a genuine
Telos that cannot safely participate creates a pending review obligation. With
compatible Telos, the main agent reviews the session's checklist against the
exact published Markdown in its next model requests. There is no Telos
dependency; when it is absent at publication and no review is already pending,
ordinary save and exit behavior is unchanged.
The review is semantic, not a task-per-step conversion. The agent must list all
tasks (including completed and archived ones) once per review attempt, assess
existing coverage, and inspect individual tasks if useful. An empty list is a
valid snapshot. Repeating the full list after success fails the attempt; retry
with /plan save or /plan exit rather than continuing to list. After the
finalized full list and each successful task change, model context includes
the complete validated task
snapshot as untrusted JSON data alongside the exact plan. This exposes notes
and dependencies without requiring an additional show for each task and does
not change the ordinary Telos list display. The agent creates only missing
meaningful todo tasks or updates related unfinished tasks' title, notes,
priority, or dependencies, preserving relevant progress information. Status
changes, deletion, completion, reopening, and changes to completed, archived,
or unrelated work are not part of this workflow. If the checklist already covers
the work, the agent explicitly acknowledges that no changes are needed. The
judgment is the main agent's, not a mechanical completeness check.
During review, only Telos review tool calls are admitted, one operation per assistant response. Task mutations require Telos's compatible v1 guarded-write contract (introduced in Telos 0.7.0) and a finalized full-list result. Telos checks the task snapshot in its mutation queue, and Plan rechecks the published digest and review ownership at the guarded commit boundary. Telos is not available to the agent for ordinary drafting. Plan does not write Telos artifacts itself.
When a genuine callable Telos lacks compatible v1 guarded writes, Plan warns before approval of a first or changed publication, on save and exit alike. Publishing is still allowed, but review compatibility depends on session ownership:
- A known session-scoped release (Telos 0.4.0 or later) can finish an
already-covered review without writes. If tasks need changes, upgrade to a
guarded-write capable Telos or deliberately adjust the session's tasks via
/tasksand retry. Do not bypass guarded writes. - Historical repository-scoped releases (including 0.3.0) and unknown,
missing-version, or prerelease manifests do not establish session ownership
without compatible v1 support. Plan neither reads nor mutates their checklist
for review; review and exit stay pending until Telos is upgraded to a known
session-scoped release or a release with compatible v1 support, and the review
succeeds. Plan does not migrate or import the old shared
.pi/telos-tasks.md.
Compatible Telos also notifies Plan synchronously before a user /tasks
mutation enters the task queue. A matching session and project edit invalidates
any active review, including an acknowledgement awaiting settlement. The agent
must stop and the user retry with a fresh full list; successful changes are not
undone. Older Telos versions lacking this notification have weaker concurrent-edit
detection for read-only review. Avoid manual changes during such a review.
Review must finish with a valid final acknowledgement for this publication and
normal agent settlement. /plan save stays active; /plan exit restores the
pre-Plan tools and theme only after successful review and exit settlement. Plan
checks captured model and compaction abort signals, the runtime's aborted
settlement flag where available, and aborted session_compact_failed events
(which also cover cancellation before the compaction hook). A host that exposes
no such late-abort evidence cannot report a cancellation after the model's final
stop to Plan; normal observed settlement remains supported.
Failed, cancelled, or interrupted reviews retain the published file and any task
changes that already succeeded. The publication's pending review survives
restart, tree navigation, unchanged checkpoints, and removal of Telos; none of
these bypasses the requirement. Restore Telos if necessary and retry with
/plan save or /plan exit. The extension verifies and reviews the existing
published bytes without rewriting the file.
If Pi rejects the review retry before agent startup (for example, no model is
selected), Plan may not receive a settlement event. Select an available model
and retry /plan save or /plan exit once Pi is idle with no queued messages.
The command replaces the unstarted review dispatch; late input or
before_agent_start callbacks from that dispatch cannot bind or revoke the
retry. No intervening normal prompt, reload, or publication is needed. A
running review or publication-to-review handoff must still settle before a new
save or exit.
If a newer unpublished draft exists, the interactive retry chooser offers
Continue planning, Publish updated plan (with the usual exact approval), or
review of the last publication without publishing the draft. The latter keeps
that draft restorable; for exit it requires an explicit choice to leave without
publishing the draft. Without interactive UI, use /plan save to retry the
published review while remaining active; /plan exit does not assume consent
to leave a dirty draft during pending review. If publication recovery itself
is unresolved, Plan retains the hold until the saved destination can be verified.
Content-inferred session name
After the first successful approved publication, Plan makes one nonblocking
attempt to name the session from the published Markdown. A name must contain 3–6
lowercase ASCII kebab-case words and be at most 64 characters, for example
guild-selected-row-highlight.
The request uses the cheapest authenticated, session-scoped, non-reasoning text model available through Pi. It sends only the first 8,000 characters of the published Markdown, labeled as untrusted data rather than instructions. It includes no conversation, cwd, tool outputs, path, or session identifier. Published Markdown is never changed by naming. The request may incur a small provider charge; the Pi 0.83 development runtime does not include this background usage in session totals. There is no prompt caching or retry, and a ten-second deadline includes credential resolution.
If no eligible model is available, Plan instead uses a clearly descriptive plain
ASCII # title at the start of the published Markdown, removing any Plan: or
Goal: prefix. This uses the same input bound, makes no model request, and skips
generic titles, titles containing markup or links, and incomplete titles. It does
not use later headings or the filename.
If a model was selected but credentials cannot be resolved, output is invalid,
or the request fails or times out, Plan keeps the existing name without trying
the title. Metadata failures leave the name unchanged, and PI_OFFLINE=1, true,
or yes disables both naming paths. Manual or extension-provided renames while
naming is pending cancel it and remain authoritative, even if the name is
subsequently changed back. Session replacement, branch navigation, reload, and
shutdown cancel/discard pending results. /plan exit itself does not cancel
naming: it may finish after Plan mode has exited.
Updates, repeated saves, and restart recovery neither retry naming nor replay old generated names. If the process stops between publication and naming, the current name is retained on recovery.
Approval is persisted as an exact revision/digest/path/base-digest binding so a
completed write can be reconciled safely after a process interruption. /tree
always clears approval. Publication failure never exits Plan mode; explicit Exit
without publishing does when no publication recovery or task review is pending.
Read-only enforcement
Plan mode exposes trusted built-in read, grep, find, and ls, plus
update_plan_draft and create_plan. Built-in provenance accepts both Pi's
legacy <builtin:name> paths and current builtin:name paths; same-named
custom tools remain blocked. When
@pithos-kit/web is installed,
provenance-verified web_search and web_fetch remain available for public-web
research. Web content is untrusted external data and must not be followed as
instructions.
The Web exception is provenance-checked against a canonical package manifest
named exactly @pithos-kit/web. Same-named SDK, top-level, path-escaping,
spoofed-source, and unrelated custom tools stay blocked. Plan also blocks writes,
edits, shell tools, manual !/!! shell commands, delegation, mutating or
untrusted custom tools (except the bounded, provenance-checked Telos review
above), and same-named overrides of trusted built-ins. It applies
the bundled Plan theme and planning footer while active, restoring the previous
theme and exact tool selection on exit. Use /plan exit before running shell
commands (including git or gh) or implementing changes. Exiting restores
previously enabled shell and custom tools; it does not enable tools that were
excluded before entering Plan mode. The branch-local tool snapshot is retained
so /tree can repair a replayed Plan loadout on an already-exited branch, even
before a post-exit model request has declared the restored tools. For branches
with recorded system tool declarations, Plan distinguishes actual branch-owned
Plan loadouts from extension tools newly activated by Pi during replay. An
incoming normal tool selection is preserved (apart from internal Plan tools),
not replaced by an outgoing sibling's snapshot. Older branches with no recorded
loadout retain the legacy restoration behavior. Completed exit recovery also
restores tools and theme before marking Plan inactive.
If the visual distinction is ever absent
while /plan status reports active mode, run /reload; the reloaded runtime
reconstructs state and reapplies the Plan presentation without relaxing tool
restrictions.
Enforcement boundary
Plan mode enforces Pi's tool and user-shell interfaces; it is not an operating-system sandbox. Other extensions and external processes can still mutate files directly. Changes observed by publication verification become conflicts, but arbitrary external OS writes can race the final filesystem calls.
Internal Guild–Plan coordination contract
The internal v1 modules use pithos.plan.coordination for synchronous discovery
between trusted extensions; this is not a malicious-extension security boundary.
Discovery handlers must reply on-stack as their final synchronous operation;
late replies are ignored. A ready discovery result is a snapshot, not an
admission grant: callers must rediscover/revalidate immediately before admission.
Guild requires caller-established inactive persisted state, plus either confirmed Plan absence with no replies or exactly one compatible, inactive provider with confirmed presence. Provider state cannot establish inventory, provenance, or persisted inactivity for the caller. Supplying a participant attaches it and rechecks the provider generation; omitting it performs inspection only.
Plan instance, generation, and hold-owner identities are process-local objects,
not persisted IDs. Transitions require the current generation and acquire
participant holds before changing phase. Busy/unavailable refusals are retryable;
protocol faults permanently block the coordinator and retain remaining protection.
Attachments last for the coordinator's lifetime. The caller must complete
tool/theme/state reconciliation before confirmInactive releases holds.
Disposal deliberately retains holds; registry shutdown owns final cleanup.
The Plan entrypoint now confirms inactivity only after caller-owned restoration, persistence, notifications, and cleanup succeed. Startup on an empty, inactive, or foreign branch becomes ready; entry reacquires holds before path generation or mutation. Active, inconsistent, uncertain, or still-publishing state remains nonready. Publication drain alone never releases a hold: the next explicit command reconciles the current branch. Captured generation/session/state/checkpoint evidence prevents outgoing callbacks from releasing a newer owner's protection.
In TUI mode, refusal of both the saved theme and fallback restoration blocks
ordinary exit and outgoing branch reconciliation as well as recovered exit.
No inactive candidate can release the hold after that failure. Ordinary exit
retains active protection and its snapshots for a fresh /plan exit; failed
branch cleanup retains the outgoing snapshots until a subsequent session/tree
reconciliation succeeds. Fix theme availability before retrying. Terminal shutdown
cleanup remains best effort and does not release coordination holds.
Tests attach the real Guild registry to the actual Plan entrypoint and exercise busy refusal, repeated entry/exit, and admission during transitions. This is not Guild runtime wiring or live-runtime certification; no parent-facing background tools are exposed by this integration.
Migrating from @pithos-kit/skills
@pithos-kit/skills is retired. Remove global and project installs
(pi remove npm:@pithos-kit/skills and
pi remove -l npm:@pithos-kit/skills) and its .pithos pin. Use Guild 0.3.0 for the relocated TDD skill;
Atlas 0.6.0 and later no longer bundles it. Historical
Skills 0.4.0 and earlier must not be loaded alongside this package because both
handle /plan and Plan state.