piglet

module
v0.20.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT

README

piglet

piglet

A coding assistant that lives in your terminal.
Multi-provider, extension-first, built in Go.

Install · Extensions · Models · Getting Started · Write Your Own


What It Does

Piglet is a terminal-native coding assistant. It reads your files, runs commands, edits code in place, and persists sessions across days. No copy-pasting, no browser, no IDE plugin.

$ piglet
> refactor the auth middleware to use errgroup

  Reading cmd/server/middleware.go...
  Editing cmd/server/middleware.go...
  Running go build ./...
  Running go test ./cmd/server/...

  Done. Replaced sequential error handling with errgroup.
  3 files changed, tests passing.

One-shot mode for quick questions:

piglet "what does this function do"
piglet "find everywhere we call the payments API"

Install

Requires Go 1.26+.

go install github.com/dotcommander/piglet/cmd/piglet@latest

Verify: piglet --version

Set an API key and run it. First launch auto-detects your keys, picks a default model, and writes config to ~/.config/piglet/.

export ANTHROPIC_API_KEY=sk-ant-...   # or OPENAI_API_KEY, GOOGLE_API_KEY, etc.
piglet

If no API key is set, piglet tells you exactly which environment variables to set and still writes its config files so you're ready once you add a key.

Extensions

First launch automatically builds and installs the official extensions (memory, skills, LSP, safeguard, and more). You'll see per-extension progress on stderr — it takes a minute or two, then you're fully loaded.

To rebuild extensions later (e.g. after an update), run /update inside piglet.

Build from Source

git clone https://github.com/dotcommander/piglet
cd piglet
go build -o piglet ./cmd/piglet/

First Things to Try

piglet                          # interactive mode — ask anything
piglet "explain this repo"      # one-shot from any project directory

Inside a session:

Try this What happens
Ask a question about your code Piglet reads the relevant files and answers
fix the failing test Reads test output, edits code, runs tests again
/help See all available commands
/model Switch to a different LLM mid-session
Ctrl+C Stop streaming or exit

How It Works

Piglet is an agent loop: you send a message, the LLM responds with text or tool calls, piglet executes the tools, feeds results back, and repeats until the LLM is done. Streaming output appears as it's generated.

Built-in tools: read, write, edit, bash, grep, find, ls — everything the LLM needs to navigate and modify a codebase.

Extensions add everything else: project memory that persists across sessions, on-demand skill loading, LSP-powered code intelligence, repository structure maps, dangerous command blocking, clipboard image pasting, sub-agent delegation, and structured task planning. Extensions are standalone binaries that communicate via JSON-RPC — write them in Go, TypeScript, or Python.

Architecture

core/       Agent loop, streaming, types. Imports nothing from piglet.
ext/        Registration surface (ext.App) — the central API.
tool/       7 built-in tools (read, write, edit, bash, grep, find, ls).
command/    14 slash commands, 2 keyboard shortcuts, 6 status sections.
prompt/     System prompt builder + 2 prompt sections.
provider/   OpenAI, Anthropic, Google streaming providers.
shell/      Agent lifecycle — submit, events, notifications (frontend-agnostic).
tui/        Bubble Tea v2 terminal UI (consumes shell/).
sdk/        Go Extension SDK — standalone module (github.com/dotcommander/piglet/sdk).

Everything is an extension. The core agent loop knows nothing about files, git, or code — tools and extensions provide all capabilities through a single registration API (ext.App). The architecture test enforces dependency boundaries at build time.

Models

Switch mid-session with Ctrl+P or /model. No restart needed.

Provider Env Variable
Anthropic ANTHROPIC_API_KEY
OpenAI OPENAI_API_KEY
Google GOOGLE_API_KEY
xAI XAI_API_KEY
Groq GROQ_API_KEY
OpenRouter OPENROUTER_API_KEY
Z.AI ZAI_API_KEY
LM Studio — (localhost:1234)

Any OpenAI-compatible endpoint works via base URL override in config.

Use just the model ID (gpt-5) or the full form (openai/gpt-5). Override with PIGLET_DEFAULT_MODEL or defaultModel in config. Run /model to see all available models.

Piglet writes models.yaml to ~/.config/piglet/ on first run with the current model catalog. To refresh after a piglet upgrade, delete the file and restart — it regenerates automatically.

Commands and Shortcuts

Command Action
/help List available commands
/model Switch model
/session List and switch sessions
/branch Fork current session
/clear Clear conversation
/compact Summarize to free context
/search Search session history
/export Export current session
/undo Undo last file change
/step Toggle step-by-step tool approval
/bg Run a prompt in a background agent
/config Show or set up configuration
/extensions List loaded extensions
/quit Exit
Key Action
Ctrl+P Model selector
Ctrl+S Session picker
Ctrl+V Paste clipboard image
Ctrl+C Stop streaming / quit
Enter Send
Alt+Enter Newline

Extensions

Piglet's extension system is the same API used by its own built-in tools. Extensions register through five primitives:

Primitive What it does Example
Inject Add text to the system prompt Memory facts, skill instructions
React Respond to triggers Tools the LLM calls, slash commands
Intercept Modify or block tool calls Safeguard blocks rm -rf /, RTK rewrites bash for token savings
Hook Process user messages before the LLM Skill trigger matching
Observe React to lifecycle events Auto-title sessions after first exchange

Extension Packs

Piglet works without any extensions — the core agent has built-in tools, commands, and providers. Extensions add everything beyond the baseline.

Official extensions ship as consolidated packs (fewer processes, faster startup). Install with piglet-extensions:

Pack Extensions Purpose
pack-context memory, skill, gitcontext, behavior, prompts, session-tools, inbox Context injection — memory, skills, git status, behavior guidelines
pack-code lsp, repomap, sift, plan, suggest Code intelligence — LSP, repo mapping, planning mode
pack-agent safeguard, rtk, autotitle, clipboard, subagent, provider, loop Agent lifecycle — safety, token optimization, delegation
pack-core admin, export, extensions-list, undo, scaffold, background Convenience commands — export, undo, scaffolding
pack-workflow pipeline, bulk, webfetch, cache, usage, modelsdev Workflow tools — pipelines, bulk ops, web fetch
mcp Bridge MCP servers as piglet tools (standalone)

What You Need

Not all packs are required. Here's what matters:

Pack Verdict What you lose without it
pack-context Essential No session memory, no skills, no git context in prompt
pack-code Important No repo map, no LSP, no planning mode
pack-agent Important No command safety checks, no token optimization
pack-core Optional No /undo, /export, /ext-init — convenience only
pack-workflow Optional No /pipe, /bulk, web fetch — niche workflows
mcp Optional No MCP server bridging

Skip optional packs by setting disabled_extensions in config.yaml:

disabled_extensions:
  - pack-core
  - pack-workflow

Write Your Own

Scaffold a new extension:

/ext-init my-extension

Or build one from scratch in Go, TypeScript, or Python. Extensions communicate via JSON-RPC over stdin/stdout — no linking, no shared memory, any language works.

See docs/building-extensions.md for the SDK reference and examples.

Configuration

Everything lives in ~/.config/piglet/:

File Purpose
config.yaml Model, shell, theme, agent limits
auth.json API keys — literals, $ENV_VAR, or !shell command
prompt.md System prompt (overrides config)
behavior.md Behavioral guidelines
models.yaml Model catalog
sessions/ Conversation history (JSONL)
skills/ Markdown methodology files
prompts/ Templates that become slash commands
extensions/ Extension packs and binaries
# config.yaml
defaultModel: claude-opus-4-6
smallModel: claude-haiku-4-5-20251001   # for background tasks
agent:
  maxTurns: 10
  maxMessages: 200
  toolConcurrency: 10

Auth supports environment variable references and shell commands:

{
  "anthropic": "$ANTHROPIC_API_KEY",
  "openai": "sk-...",
  "google": "!op read op://vault/google/key"
}

Prompt templates in prompts/ register as slash commands — prompts/review.md becomes /review:

---
description: Review code for issues
---
Review the following for bugs and style problems:

$@

See docs/configuration.md for the full settings reference.

License

MIT

Directories

Path Synopsis
cmd
bulk command
bulk — run a shell command across many items in parallel.
bulk — run a shell command across many items in parallel.
confirm command
depgraph command
fossil command
fossil — structured git history queries for LLM agents.
fossil — structured git history queries for LLM agents.
lspq command
lspq is a standalone CLI for querying language servers via the lsp package.
lspq is a standalone CLI for querying language servers via the lsp package.
memory command
memory — standalone CLI for per-project key-value memory.
memory — standalone CLI for per-project key-value memory.
piglet command
piglet-cron command
pipeline command
pipeline — standalone CLI for running YAML pipeline files.
pipeline — standalone CLI for running YAML pipeline files.
repomap command
repomap — standalone CLI for the repomap package.
repomap — standalone CLI for the repomap package.
sift command
sift — compress text output by collapsing blanks, repeats, and truncating.
sift — compress text output by collapsing blanks, repeats, and truncating.
webfetch command
webfetch — standalone CLI for web fetch and search.
webfetch — standalone CLI for web fetch and search.
Package command registers piglet's built-in slash commands via the extension API.
Package command registers piglet's built-in slash commands via the extension API.
Package core implements the agent loop, streaming, and message types.
Package core implements the agent loop, streaming, and message types.
examples
extensions/git-tool
Package gittool is an example piglet extension that adds a git_status tool.
Package gittool is an example piglet extension that adds a git_status tool.
extensions/quicknotes
Package quicknotes is an example piglet extension that adds a /note command.
Package quicknotes is an example piglet extension that adds a /note command.
ext
Package ext provides the extension registration surface for piglet.
Package ext provides the extension registration surface for piglet.
external
Package external implements the JSON-RPC stdio protocol for external piglet extensions.
Package external implements the JSON-RPC stdio protocol for external piglet extensions.
extensions
admin/cmd command
Admin extension.
Admin extension.
autotitle
Package autotitle provides automatic session title generation for piglet.
Package autotitle provides automatic session title generation for piglet.
autotitle/cmd command
Autotitle extension binary.
Autotitle extension binary.
background/cmd command
Background extension.
Background extension.
behavior
Package behavior loads behavioral guidelines from ~/.config/piglet/behavior.md and injects them as the earliest system prompt section.
Package behavior loads behavioral guidelines from ~/.config/piglet/behavior.md and injects them as the earliest system prompt section.
behavior/cmd command
Behavior extension.
Behavior extension.
bulk/cmd command
Bulk extension binary.
Bulk extension binary.
cache
Package cache provides a file-backed TTL cache for piglet extensions.
Package cache provides a file-backed TTL cache for piglet extensions.
cache/cmd command
Cache extension binary.
Cache extension binary.
changelog/cmd command
clipboard/cmd command
Clipboard extension binary.
Clipboard extension binary.
coordinator/cmd command
Coordinator extension binary.
Coordinator extension binary.
cron/cmd command
Cron scheduling extension for piglet.
Cron scheduling extension for piglet.
distill
Package distill extracts reusable skills from completed sessions.
Package distill extracts reusable skills from completed sessions.
export/cmd command
Export extension.
Export extension.
extensions-list/cmd command
Extensions-list extension.
Extensions-list extension.
gitcontext
Package gitcontext injects uncommitted changes, recent commits, and small diffs into the system prompt so the model knows the repo state.
Package gitcontext injects uncommitted changes, recent commits, and small diffs into the system prompt so the model knows the repo state.
gitcontext/cmd command
Git context extension.
Git context extension.
inbox
Package inbox provides a file-based message inbox for piglet.
Package inbox provides a file-based message inbox for piglet.
inbox/cmd command
internal/toolresult
Package toolresult provides helpers for reading and modifying the "details" payload that the piglet SDK passes through interceptor After callbacks.
Package toolresult provides helpers for reading and modifying the "details" payload that the piglet SDK passes through interceptor After callbacks.
internal/xdg
Package xdg resolves the piglet config directory using the same logic as the piglet host: $XDG_CONFIG_HOME/piglet or $HOME/.config/piglet.
Package xdg resolves the piglet config directory using the same logic as the piglet host: $XDG_CONFIG_HOME/piglet or $HOME/.config/piglet.
loop
Package loop provides a recurring-prompt scheduler for the piglet loop extension.
Package loop provides a recurring-prompt scheduler for the piglet loop extension.
loop/cmd command
Loop extension binary.
Loop extension binary.
lsp
Package lsp provides an LSP client for code intelligence.
Package lsp provides an LSP client for code intelligence.
lsp/cmd command
mcp
Package mcp provides MCP (Model Context Protocol) server integration for piglet.
Package mcp provides MCP (Model Context Protocol) server integration for piglet.
mcp/cmd command
MCP extension binary.
MCP extension binary.
memory/cmd command
Memory extension binary.
Memory extension binary.
modelsdev/cmd command
Modelsdev extension binary.
Modelsdev extension binary.
packs/agent command
packs/code command
packs/context command
packs/core command
packs/cron command
packs/eval command
packs/workflow command
pipeline/cmd command
Pipeline extension binary.
Pipeline extension binary.
plan
Package plan provides persistent structured task tracking for piglet.
Package plan provides persistent structured task tracking for piglet.
plan/cmd command
prompts
Package prompts scans prompt template directories for .md files and registers each as a slash command with positional argument expansion.
Package prompts scans prompt template directories for .md files and registers each as a slash command with positional argument expansion.
prompts/cmd command
Prompts extension.
Prompts extension.
provider/cmd command
Provider extension binary.
Provider extension binary.
recall
Package recall provides cross-session context search via a TF-IDF inverted index.
Package recall provides cross-session context search via a TF-IDF inverted index.
repomap/cmd command
route/cmd command
Route extension binary.
Route extension binary.
rtk
Package rtk provides the RTK bash-rewrite extension for piglet.
Package rtk provides the RTK bash-rewrite extension for piglet.
rtk/cmd command
RTK extension binary.
RTK extension binary.
safeguard
Package safeguard blocks dangerous commands before execution.
Package safeguard blocks dangerous commands before execution.
safeguard/cmd command
Safeguard extension binary.
Safeguard extension binary.
scaffold/cmd command
Scaffold extension.
Scaffold extension.
session-tools/cmd command
Session-tools extension.
Session-tools extension.
sift/cmd command
skill/cmd command
Skill extension binary.
Skill extension binary.
subagent
Package subagent provides the tmux-based agent dispatch tool for piglet.
Package subagent provides the tmux-based agent dispatch tool for piglet.
subagent/cmd command
Subagent extension binary.
Subagent extension binary.
suggest/cmd command
tokengate/cmd command
toolsearch
Package toolsearch provides a tool_search tool for finding extensions by name.
Package toolsearch provides a tool_search tool for finding extensions by name.
undo/cmd command
Undo extension.
Undo extension.
usage/cmd command
Usage extension binary.
Usage extension binary.
webfetch
Package webfetch provides web fetch and search capabilities via multiple providers.
Package webfetch provides web fetch and search capabilities via multiple providers.
webfetch/cmd command
Webfetch extension binary.
Webfetch extension binary.
Package prompt builds the system prompt from tools, config, and extensions.
Package prompt builds the system prompt from tools, config, and extensions.
Package sdk provides the Go Extension SDK for building piglet extensions.
Package sdk provides the Go Extension SDK for building piglet extensions.
Package session manages conversation persistence as tree-structured JSONL files.
Package session manages conversation persistence as tree-structured JSONL files.
Package tool implements the 7 built-in tools for piglet.
Package tool implements the 7 built-in tools for piglet.
Package tui implements the interactive terminal UI using Bubble Tea.
Package tui implements the interactive terminal UI using Bubble Tea.

Jump to

Keyboard shortcuts

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