Newv1.1.0psh · Ollama · zdraw · zcurl

pchat.psh

My port of zchat.zsh to psh, the Performance Shell fork of Zsh. A full-screen terminal AI chat client with live streaming, collapsible reasoning, session history, and Markdown rendering—connecting to Ollama over native TCP and to remote providers through psh's bundled zcurl module.

Native psh modules out of the box: unlike zchat.zsh, pchat.psh drops vendored submodules and local C build scripts—loading zdraw and zcurl directly from psh with automatic fallback to stock zsh/curses. It also reuses ~/.config/zchat so your existing configuration, remote profiles, and saved conversations open directly.

The shell supplies the modules

psh supplies the interpreter and bundled loadable modules for terminal drawing, networking, and files, while JSON tokenization, Markdown rendering, and directory-backed session persistence stay in shell code. The application itself never invokes curl, jq, Python, fold, or coreutils at runtime.

pshRuntime & TCP
Supplies the interpreter and core modules (zsh/net/tcp, zsh/mapfile, zsh/curses, zsh/zselect) for native Ollama streaming and session storage.
zdrawBundled Terminal UI
Loaded directly from psh for deep teal RGB styling, rounded borders, grapheme-aware editing, bounded streaming paste, and synchronized frames—falling back cleanly to stock curses.
zcurlBundled Remote HTTPS
Loaded inside a fresh psh worker for verified HTTPS streaming to remote providers (chat-completions, responses, and messages) through private handoff files.

A terminal interface, not a prompt loop

Refreshed TUI without vendored builds

Deep teal surfaces, seafoam focus accents, amber labels, rounded borders, persistent sidebar toggle (Ctrl+B / /sidebar), and inline / slash suggestions—powered directly by psh's bundled zdraw module.

Live reasoning & auto-collapsing

Streams thinking and response tokens separately; completed reasoning collapses into a single summary line toggleable anytime with Ctrl+R or /think.

Rich terminal Markdown

Renders headings, fenced code blocks with line numbers, Unicode box tables, wrapped lists with hanging indents, nested blockquotes, and inline spans directly in the chat viewport.

Provider-agnostic remote models

Configure independent endpoints in ~/.config/zchat/remotes.json for chat-completions, responses, and messages APIs with env-var credentials, per-profile context limits, custom headers, and optional private PEM CA files.

Shared sessions & context compaction

Opens existing ~/.config/zchat settings, remote profiles, and directory-backed sessions from zchat.zsh, keeping full transcripts alongside automatic or manual (/compact) continuation checkpoints.

Stable copy & fail-closed streaming

Press Ctrl+Y or run /copy for a plain-text transcript view using native suspend/resume; malformed, incomplete, or cancelled streams fail closed instead of saving partial replies.

Ollama and remote models side by side

Ordinary model names talk directly to Ollama at localhost:11434 (or any server set through OLLAMA_HOST, --host, or /host) over native TCP, discovering active context allocations via /api/ps.

For hosted or self-hosted HTTP(S) providers, define independent aliases in ~/.config/zchat/remotes.json and select them with --model remote:work, /model remote:work, or the Ctrl+O model picker. Remote profiles use their own context and output limits, keep API keys in exported environment variables outside session files, and run remote compaction checkpoints without ever sending remote turns to Ollama.

{
  "models": {
    "work": {
      "protocol": "chat-completions",
      "url": "https://your-provider.example/v1/chat/completions",
      "model": "your-model-id",
      "api_key_env": "CHAT_API_KEY"
    }
  }
}

Try pchat.psh

Install psh with its bundled zdraw and zcurl modules. No submodules or C builds are needed in the pchat.psh repository—make zdraw zcurl verifies that psh can load both installed modules, and make compile precompiles lib/*.zsh into .zwc wordcode for faster startup.

ollama pull gemma4:12b
git clone https://github.com/ZaguanLabs/pchat.psh.git
cd pchat.psh
make zdraw zcurl
make compile
./pchat.psh

# Use another Ollama model or remote Ollama host
./pchat.psh --model MODEL_NAME --host HOST:11434

# Or select a configured zcurl remote profile
./pchat.psh --model remote:work

Pass ZCHAT_DRAW=stock ./pchat.psh to select stock curses explicitly, or run make test to execute syntax checks, PTY drawing/input/resize tests on both stock curses and bundled zdraw, and local remote HTTP/HTTPS integration checks.

Private storage, shared with zchat.zsh

Configuration, UI preferences, and directory-backed session transcripts live under ~/.config/zchat/ with mode 0600 files inside 0700 directories, read directly via zsh/mapfile. Switch freely between zchat.zsh and pchat.psh without migrating your history.