← Catalog

pi-ghost-text

Ghost-text prompt suggestions (inline autocomplete + next-prompt) for the pi coding agent

ExtensionPrompt

Install

Install with PiG

pig install npm:pi-ghost-text

Install with Pi

pi install npm:pi-ghost-text
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "image": "https://raw.githubusercontent.com/jcv/pi-ghost-text/main/assets/social-preview.png",
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.2 (README.md). PiG does not review it.

pi-ghost-text

Ghost-text prompt suggestions for the pi coding agent — like Claude Code's inline autocomplete for the prompt box.

As you type (or after the agent finishes and the input is empty), a dimmed prediction of the likely next prompt appears after the cursor. Accept it, cycle alternatives, or keep typing.

Requirements

  • Interactive TUI mode. Suggestions are an editor feature and only appear in the interactive terminal (pi with no mode flag). They do not run in -p/--print, --mode json, or --mode rpc.
  • A model with a configured API key. With the default "model": "auto", the extension scans the available models for a fast/cheap one, in priority order: haiku, then gpt-*mini, then flash, then nano. If none match — or if an explicit provider/model-id isn't found — it falls back to the active session model. Set a specific model with /suggest-model.

Install

pi install npm:pi-ghost-text

Remove it:

pi remove npm:pi-ghost-text

Using it

KeyAction
TabCycle to the next candidate; accept when it's the last (or only) one
→ (right arrow, cursor at end)Accept the current suggestion
EscDismiss the ghost, keeping what you've typed
Move the cursor away from the endDismiss
Keep typingShrink the ghost while it still matches, otherwise regenerate

Tab only applies to the ghost when the file/command autocomplete dropdown is not open. Accepting inserts the suggestion into the editor for you to edit; press Enter to send it.

When candidates is 1 (the default), Tab simply accepts. Set candidates to 2 or 3 to fetch alternatives and cycle them.

Commands

CommandWhat it does
/suggestChoose mode: both, while-typing, after-turn, or off
/suggest-modelPick the suggestion model (or auto to prefer a fast, cheap one)
/suggest-contextSet the context window (messages × chars per message)

Configuration

Stored as JSON, resolved defaults ← global ← project:

  • global: ~/.pi/agent/prompt-suggestions.json
  • project: .pi/prompt-suggestions.json
{
  "model": "auto",
  "mode": "both",
  "candidates": 1,
  "streaming": true,
  "contextMessages": 8,
  "contextChars": 600,
  "maxPerTurn": 0,
  "debug": false
}
KeyDefaultDescription
model"auto""auto" (prefer a fast, cheap model) or an explicit provider/model-id
mode"both""both", "while-typing", "after-turn", or "off"
candidates1Alternatives to fetch (1–3); Tab cycles them
streamingtrueStream the single suggestion token-by-token (ignored when candidates > 1)
contextMessages8Recent messages included in the suggestion prompt (0 = none)
contextChars600Chars kept per message
maxPerTurn0Max suggestions shown per agent turn (0 = unlimited)
debugfalseAppend diagnostic lines to ~/.pi/agent/prompt-suggestions.log

mode, model, contextMessages, and contextChars are settable from the commands above; candidates, streaming, maxPerTurn, and debug are JSON-only. Commands write to the global scope, so a project override in .pi/prompt-suggestions.json takes precedence over a command-set value.

Privacy

When enabled, the suggestion model receives only:

  • the text you have typed so far, and
  • the last contextMessages user/assistant messages, each trimmed to contextChars characters.

It is never sent:

  • the full conversation transcript,
  • tool outputs,
  • file contents,
  • project or session metadata.

Suggestions are advisory and best-effort; failures are never surfaced in the UI. With "debug": true they are logged to ~/.pi/agent/prompt-suggestions.log with a stable category (timeout / error / no-suggestion).

Troubleshooting

If no suggestion appears:

  1. Confirm the mode is not off — run /suggest.
  2. Confirm the suggestion model has an API key configured (or, for auto, that one of the fast/cheap models does). /suggest-model shows what's available. An explicit model that isn't found silently falls back to the active session model, so check the spelling as provider/model-id.
  3. While-typing suggestions need ≥4 chars of plain text (not starting with / or !, not an @file completion in progress), a ~700ms pause, and the agent must be idle (not mid-response).
  4. After-turn suggestions only appear when the editor is empty right after the agent settles.
  5. If maxPerTurn is set, you may have hit the per-turn cap.
  6. Set "debug": true and check ~/.pi/agent/prompt-suggestions.log for [prompt-suggestions] lines — they state the reason (timeout, error, no-suggestion).
  7. If the ghost flakes with streaming enabled, set "streaming": false to force the non-streaming path.

Development

npm ci --ignore-scripts
npm test   # node --test (requires Node ≥ 23.6)

The rendering regression tests use the real Editor from the @earendil-works/pi-tui peer dependency, pinned by the committed package-lock.json.

Prior art

Inspired by supi-prompt-suggestions. This adds inline while-typing autocomplete (prefix-anchored, shrink-on-type), multi-candidate cycling, streaming ghost text, scoped global/project config, and explicit modes on top of the empty-box next-prompt suggestion.