ghost

command module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ghost

   ▄████  ██░ ██  ▒█████   ██████  ████████
  ██▒ ▀█▒▓██░ ██▒▒██▒  ██▒ ██    ▒    ██
 ▒██░▄▄▄░▒██▀▀██░▒██░  ██▒ ▓██▄       ██
 ░▓█  ██▓░▓█ ░██ ▒██   ██░  ▒   ██▒   ██
 ░▒▓███▀▒░▓█▒░██▓░ ████▓▒░▒██████▒▒   ██
  ░▒   ▒   ▒ ░░▒░▒░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░   ░
   ░   ░   ▒ ░▒░ ░  ░ ▒ ▒░ ░ ░▒  ░ ░
 ░ ░   ░   ░  ░░ ░░ ░ ░ ▒  ░  ░  ░
       ░   ░  ░  ░    ░ ░        ░

Go Reference Build Status Build Status Go ReportCard license

Ghost is a local, general-purpose AI assistant CLI tool built in Go and powered by Ollama. It provides command-line access to AI capabilities for quick queries, code analysis, and task automation, running entirely on your own machine.

The vision for Ghost is inspired by cyberpunk media such as Shadowrun, Cyberpunk 2077, and The Matrix, bringing a versatile, always-on AI companion into a terminal-first experience.

Documents

Requirements

  • Go >= 1.24
  • Ollama installed and running locally
  • At least one model pulled (e.g., ollama pull llama3.1)

Installation

From Source
git clone https://github.com/theantichris/ghost.git
cd ghost
go build -v
From Release

Download pre-built binaries for Linux, macOS, or Windows from the releases page.

Usage

# Ask a single question
ghost ask "What is the capital of France?"

# Pipe input to Ghost for analysis
cat code.go | ghost ask "Explain this code"

# Combine piped input with additional context
cat error.log | ghost ask "What's causing this error?"

# Start an interactive chat session
ghost chat

# Run directly with go
go run main.go ask "Your question here"

Ghost processes your query through the configured LLM model and returns the response directly to stdout.

Commands
ask - Ask Ghost a question

Send a query to the LLM and get a response. Supports both direct queries and piped input.

chat - Start an interactive chat session

Enter an interactive multi-turn conversation with Ghost. Chat maintains in-memory conversation history throughout the session.

ghost chat

Chat controls:

  • Type your messages and press Enter to send
  • /bye or /exit - Display goodbye message and wait for any keypress to exit
  • Ctrl+D or Ctrl+C - Exit immediately without goodbye
  • Empty input is ignored (just press Enter again)
Global Flags
  • --ollama — Override the Ollama API base URL.
  • --model — Override the default LLM model
  • --timeout — Override the HTTP timeout for LLM requests (e.g., 5m, 30s)
  • --config — Specify config file location (default: $HOME/.config/ghost/config.toml)
Environment Variables
  • OLLAMA_BASE_URL — base URL of your local Ollama instance (e.g., http://127.0.0.1:11434).
  • DEFAULT_MODEL — default model name to use when -model is not provided.
Configuration

Ghost checks for configuration in the following order of precedence:

  1. Command-line flags
  2. Environment variables
  3. Config file (.ghost.toml)
  4. Default values
Config File Setup

Create a config.toml file in ~/.config/ghost/ to set default configuration:

# ~/.config/ghost/config.toml
ollama = "http://localhost:11434"
model = "llama3.1"
timeout = "5m"  # Optional: custom timeout for LLM requests

Configuration options:

  • ollama — Ollama API base URL (default: http://localhost:11434)
  • model — LLM model to use (default: llama3.1)
  • timeout — HTTP client timeout for LLM requests (default: 2m)

Features

  • CLI Command Interface: Enhanced command-line interface using Fang (built on Cobra framework) with styled help pages and improved user experience
  • Interactive Chat Mode: Multi-turn conversations with in-memory history, real-time streaming responses, and graceful exit commands
  • Pipe Support: Process files, logs, or command output by piping to Ghost
  • Streaming Output: Real-time token-by-token streaming for responsive user experience in both ask and chat modes
  • Think Block Filtering: Automatically filters out <think> blocks from model responses in both ask and chat modes
  • Flexible Configuration: Support for environment variables, config files, and command-line flags with sensible defaults
  • File Logging: All operations logged to ~/.config/ghost/ghost.log for debugging and troubleshooting (credentials never logged)
  • Error Handling: Comprehensive error messages with clear guidance on configuration issues

Documentation

Overview

Package main is the entry point for the Ghost CLI application.

Directories

Path Synopsis
Package cmd provides the command-line interface for Ghost, including the root command configuration, subcommands (ask, chat), and shared functionality like LLM client initialization.
Package cmd provides the command-line interface for Ghost, including the root command configuration, subcommands (ask, chat), and shared functionality like LLM client initialization.
internal
llm
stdio
Package stdio provides utilities for handling standard input/output operations, including piped input detection, output filtering, and think block processing for LLM streaming responses.
Package stdio provides utilities for handling standard input/output operations, including piped input detection, output filtering, and think block processing for LLM streaming responses.
tui
Package tui implements the terminal user interface for Ghost's interactive chat mode using the BubbleTea framework.
Package tui implements the terminal user interface for Ghost's interactive chat mode using the BubbleTea framework.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL