跳到正文
DEV Community· Akshra Jain·· 3 小時前AI 評分44

Poltergeist:在 PowerShell 提示符發出低語的幽靈

Poltergeist

AI 導讀

Poltergeist 是一款供 PowerShell 使用的唯讀工具,會記住經遮蔽的近期指令歷史,並在之後的提示符發出簡短低語;它不會執行、修改、阻止或取代指令。工具提供四種可選角色,並支援連接本機 Ollama,預設模型為 llama3.2:3b;沒有 Ollama 時則使用內置離線低語。推理在本機進行,指令歷史保存在用戶自己的裝置上。

正文

Poltergeist: A Ghost That Whispers at Your PowerShell Prompt

What I Built

Poltergeist is a read-only ghost for PowerShell. It remembers a redacted version of recent command history and offers short whispers at later prompts: sometimes eerie, sometimes funny, sometimes unexpectedly kind.

I interpreted “Ghost in the Machine” as a presence in the place developers already spend time: the terminal. The ghost never executes, edits, blocks, or replaces a command. It observes, redacts, and speaks only when its local rules allow it.

The project includes four selectable personas: Victorian Ghost, Ofrenda, COBOL Spirit, and Gremlin. Each has its own style, examples, and a pool of offline whispers.

Demo

There isn’t a hosted demo or video yet. You can run Poltergeist locally on Windows with Python 3.11+ and PowerShell:

python -m pip install -e .
ghost init

Setup previews the PowerShell profile change, backs up an existing profile, lets you choose a persona, and checks for a local Ollama server. Restart PowerShell after setup, run a few commands, and the ghost can leave a whisper at a later prompt. Try ghost mood or ghost remember as well.

Ollama is optional. Without it, Poltergeist uses its built-in offline whispers.

Code

GitHub repository: akshrakothari/Poltergeist

The repository includes the Python package, PowerShell integration, persona files, tests, latency measurement and model evaluation scripts, and a build log.

How I Built It

Poltergeist is written in Python and uses Typer for its command-line interface, Rich for terminal output, and SQLite for local command history. Persona definitions are stored in TOML files.

For AI inference, Poltergeist connects to Ollama on the local machine. The default model is llama3.2:3b; qwen2.5:3b is another suggested option. The Ollama client accepts only loopback URLs and disables proxy environment settings.

The PowerShell hook captures command text, exit status, elapsed time, working directory, and timestamp. It redacts command text before persistence, and the event store applies redaction again as a second safeguard. Before requesting a whisper, Poltergeist builds a compact brief and can include up to three facts derived from SQL queries over local history. A validator checks the response’s length and format and rejects unsupported numbers, quotes, and emoji. If the model is unavailable or the answer fails validation, Poltergeist falls back to a deterministic handwritten whisper.

The ghost speaks at the next prompt. Model work runs in a detached process; if it takes too long, the whisper is skipped instead of making the shell wait. The project also includes ghost hush, quiet hours, ghost remember, and ghost exorcise to remove its marked PowerShell hook and local data.

Why Does Open Innovation Matter?

A terminal history can contain sensitive details about someone’s work. Running inference locally means Poltergeist doesn’t need to send command context to a hosted AI service. Users can choose which supported local model to run, inspect how the app prepares the prompt, and keep history on their own machine.

Open models also let the project remain useful when inference is unavailable: the built-in persona lines work offline. The model is an optional local collaborator, rather than a remote service the shell depends on.

My Agent Session

I don’t have a saved agent-session link to include.

The Spirit of It

The ghost waits until a later prompt, so a comment arrives like an echo of the command that just finished. It might offer a gentle line after an error or a quiet acknowledgment after a familiar command.

The Ofrenda persona is written as a warm, respectful ancestor-like presence. It avoids imitating a cultural ritual or inventing cultural claims. I wanted the project’s Día de los Muertos interpretation to leave room for remembrance while treating the theme with care.

Prize Categories

  • DevRelay

  • Cursor

  • Antigravity

  • Backboard Studio

devchallenge #hf26challenge

來源:DEV Community · dev.to