pi-autocomplete

Local, private ghost-text word autocomplete for Pi with a personal dictionary and SmolLM2 fallback

Packages

Package details

extension

Install pi-autocomplete from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-autocomplete
Package
pi-autocomplete
Version
0.1.1
Published
Nov 23, 2026
Downloads
not available
Author
sheethappiness
License
MIT
Types
extension
Size
1.2 MB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/pi-ghost-autocomplete.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-autocomplete

Fast, private word completion for Pi – no API keys, no inference server to configure.

npm Pi TypeScript Rust SmolLM2 Node License

👻 What does it do?

pi-autocomplete adds inline ghost-text completion to Pi's prompt editor.

As you type, it suggests the rest of the current word as ghost text right at your cursor. It does not generate full prompts.

Press Tab or → to accept it.
Press Esc to dismiss it.

It uses a local dictionary for obvious completions and falls back to a small local language model when the prefix is ambiguous.

The goal: spend less time finishing repetitive words while keeping Pi's usual editor behavior.

Why this extension?

  • Instant dictionary-first suggestions for familiar words, with no model call.
  • On-device SmolLM2 fallback when a word prefix is ambiguous.
  • Personal vocabulary learned from prompts and accepted completions.
  • No API key, subscription or separate Ollama server – inference runs locally on CPU.

📦 Install

pi install npm:pi-autocomplete

Prebuilt native packages mean no Rust toolchain is needed for normal installation. On the first interactive start, the small model's files are downloaded, verified and cached; afterward, inference runs locally. The dictionary keeps working even if the model is unavailable.

View package in the Pi catalog · Report a bug or suggest an improvement

⚙️ How it works

The completion path is roughly:

typed prefix
    ↓
common dictionary
    ↓
personal dictionary
    ↓
SmolLM2 fallback
    ↓
ghost suggestion

The plugin first checks a bundled English frequency dictionary together with locally learned vocabulary.

If it finds a confident match, the completion is returned immediately without model inference.

If the prefix is ambiguous, it falls back to SmolLM2-135M running locally on CPU.

The model is prepared in the background when an interactive Pi session starts.

📖 Personal dictionary

The plugin can learn vocabulary from the prose you submit and from suggestions you accept.

Ranking takes into account:

  • common English frequency
  • your own word frequency
  • how recently you used the word
  • previous acceptances for the same prefix

The personal dictionary is stored locally and shared between Pi sessions.

Cyrillic words are learned from submitted prompts and accepted suggestions, just like Latin words. No language selection is needed: dictionary suggestions match the prefix you type, including in mixed English/Cyrillic prompts. Learned words remain available after restarting Pi.

There is no bundled Cyrillic dictionary. A personal word normally needs to appear in at least two submitted prompts, or be accepted as a suggestion, before it can be suggested; ambiguous prefixes may still produce no dictionary suggestion.

Repeated words inside one submitted prompt count once.

Code, paths, slash commands and paste markers are excluded from personal vocabulary learning.

To clear the learned dictionary:

/ghost dictionary clear

⌨️ Controls

Key Action
Tab Accept the current suggestion
→ Accept the current suggestion
Esc Dismiss it
Undo Undo one accepted completion

Pi's own slash commands and file completion keep priority.

Suggestions that cannot fit correctly in the available terminal width are hidden instead of forcing broken rendering.

🛠️ Commands

/ghost on
/ghost off
/ghost status
/ghost retry
/ghost dictionary clear

/ghost status reports dictionary and model readiness separately.

/ghost retry retries predictor initialization after a failure.

🛰️ Local model

The fallback model is SmolLM2-135M.

It runs through a native Rust predictor on a dedicated thread.

Model files are downloaded on first use, verified, and cached locally.

Prompt text is not sent to an external model service.

The dictionary remains usable while the model is loading or if the native predictor fails.

💿 Platforms

Prebuilt native packages are available for:

  • Windows x64
  • Linux x64
  • Linux ARM64
  • macOS ARM64

🧩 Stack

Pi · TypeScript · Rust · SmolLM2-135M · Node.js

The Pi extension, editor integration and completion orchestration are written in TypeScript.

The local predictor is implemented as a native Rust module.

🛠️ Development

npm ci --ignore-scripts
npm test
npm run check

Native development additionally requires Rust.

Release and packaging details are documented in docs/releasing.md.

🙏 Credits

Parts of the completion and predictor logic are adapted from Oh My Pi.

The fallback model is SmolLM2-135M, and the bundled English dictionary is based on wordfreq.

See THIRD_PARTY_NOTICES.md for full attribution and license details.

📄 License

MIT