A careful coding agent for your terminal and desktop.
Bring your own model, keep project knowledge in Markdown, and review tool actions before they run.
Code Penguin (penguin) is an installable AI coding-agent harness for Linux
Ubuntu x86_64. It brings the useful parts of modern agent CLIs into one small,
auditable tool: a real model/tool loop, a permission policy and workspace path checks, persistent
sessions, checkpoints, project memory, MCP tools, subagents, lifecycle hooks, and
a headless JSON mode for CI.
The runtime is a single bundled ESM file with no production npm dependencies.
The installed command is penguin; code-penguin is an alias.
Status: early release (
0.2.0). The permission layer is enforced by the harness, not by an operating-system container. Read Security model before running it on an untrusted repository.
Requirements:
- Linux x86_64 (developed and tested on Ubuntu 26.04)
- Node.js 20 or newer, with npm
- No root privileges
From a checkout:
cd penguin-agent-harness
./install.shThis builds the bundle, packs it, and installs it into ~/.local with an
isolated npm cache. It never uses sudo or changes global npm configuration.
Use a different prefix with PENGUIN_PREFIX=/path ./install.sh. If the installer
prints a PATH hint, add the directory (usually ~/.local/bin) to your shell.
Verify:
penguin --version
penguin doctorFor release tarballs, offline installs, the npm route, custom prefixes, and uninstallation, see docs/INSTALL.md.
Install the Ubuntu amd64 package and open Code Penguin from Applications:
sudo apt install ./code-penguin-desktop_0.2.0_amd64.debThe installed app bundles Electron and the harness. From a checkout, use
Node.js 22.12 or newer and librsvg2-bin. Run npm ci, then build the package with
npm run package:deb. The result is under dist/packages/.
Use the sidebar workspace picker to open a project. Settings lets you add
provider profiles, enter model IDs and set permission and sandbox defaults.
Enter an API key to protect it with the Linux keyring. With a custom endpoint,
add an explicit key if authentication is required. The Harness default option
uses the CLI's configuration and environment. Add an Offline mock provider
with model ID mock to try the app without network access.
The desktop shares the CLI's saved chats. It stores provider profiles and desktop defaults separately. Chat shows tool calls and approvals as they happen. Agents lists delegated tasks and their results. MCP Servers loads configured connectors and lets you add workspace-specific servers.
# Code Penguin reads credentials from the environment; it never stores them
# in the JSON configuration.
export DEEPSEEK_API_KEY="your-key"
cd ~/src/my-project
penguin run "Find why the login test fails and fix it"
penguin plan "Propose a migration to the new API" # never edits files
penguin run # interactive session
penguin run "Add validation; show me the plan first" # approval prompts
penguin run --json "Run the test suite and summarize" # CI / scriptsThe default provider is DeepSeek (deepseek-chat, https://api.deepseek.com/v1).
Use --provider openai-compatible --base-url ... --model ..., --provider anthropic,
--provider ollama, or --provider mock for a deterministic offline smoke test.
See Providers and penguin config show.
When a tool needs approval, the CLI asks on a TTY. In non-interactive mode an
unanswered approval is denied. --yes approves ask-gated tools, but the
best-effort dangerous-command denylist still applies and plan mode stays
read-only. That denylist is not a sandbox: run untrusted code in a VM or container.
- One model/tool loop for any OpenAI-compatible endpoint, plus Anthropic and a deterministic mock provider.
- Agent tools:
bash,readFile,writeFile,editFile,applyPatch(Codex-style patch with rollback),glob,grep, andlistFiles. - Workspace confinement: file tools resolve paths against the workspace and
reject paths that leave it or contain symlink components.
read-onlyblocks mutating file tools and Bash. - Approval policy: common destructive shell commands are best-effort denied
even under
--yes. Allow, ask, and deny rules, plan mode, accept-edits, and bypass modes are supported. - Sessions: JSONL transcripts, resume/continue, list/show/export/delete.
- Conversation branches: fork with a compact hand-off or edit a user message in a new branch. Regeneration saves selectable response variants in the same chat.
- Checkpoints: snapshot the workspace before changes and rewind a checkpoint by its exact id.
- Memory: project
PENGUIN.mdandAGENTS.md, with user-level fallback in~/.penguin/; curated project notes live in.penguin/memory/*.mdand are managed by thememorySearch,memoryRead, andmemoryWritetools. - MCP: stdio and HTTP/HTTPS servers, namespaced tools, startup diagnostics, environment-based CLI credentials, and encrypted desktop credentials.
- Desktop appearance: System, Light, and Dark modes with independent green, blue, purple, orange, and rose accents saved between launches.
- Subagents: the model can delegate through a
tasktool to a read-onlyexplorehelper or a scopedgeneralhelper. Helpers have fresh context, isolated prompts, one-level depth, and return structured results. - Hooks: shell hooks for session start, pre/post tool, compact, and stop; a failing or timed-out guard hook fails closed.
- Plugin core: local manifest-based install, permission grants, compatibility checks, and lifecycle state. Extension contributions are not executed yet.
- Automation: one JSON result object on stdout in
--jsonmode; progress and tool output go to stderr. - No runtime dependency tree: the release bundle is one JS file.
penguin run [prompt] Run a session; no prompt enters the REPL
penguin plan [prompt] Read-only planning mode
penguin resume <session> Continue a saved session
penguin init Create .penguin/settings.json and PENGUIN.md
penguin doctor Check platform, config, tools, and credentials
penguin session <cmd> list | show | export | delete | resume
penguin config <cmd> show | get <key> | set <key> <value> | path
penguin mcp <cmd> list | tools | call | test
penguin checkpoint <cmd> list | create | rewind
penguin version
Useful run flags:
| Flag | Meaning |
|---|---|
-C, --cwd <dir> |
Workspace directory |
--provider <name> |
mock, deepseek, openai-compatible, anthropic, ollama |
--model <name> |
Model name |
--base-url <url> |
Provider endpoint |
--permission-mode <mode> |
default, plan, accept-edits, bypass |
--sandbox <mode> |
off, read-only, workspace-write |
--max-turns <n> |
Hard model-turn cap (default 20) |
--allowed-tools <list> |
Comma-separated tool allowlist |
--session <id> / --continue |
Resume saved state |
--no-session |
Do not persist this run |
--checkpoint |
Capture a checkpoint before the run |
--trust-project |
Trust hooks, MCP, and policy settings in this repository's .penguin/settings.json |
--json |
Emit one JSON result object |
-y, --yes, --yolo |
Approve ask-gated tools |
--no-tty |
Disable interactive UI and prompts |
-m, --message <text> |
Add prompt text |
--file <path> |
Read the prompt from a file |
Exit codes: 0 completed, 1 configuration/runtime failure or turn limit, and
130 interrupted with Ctrl-C.
penguin run --json --provider mock --no-session "say hello"returns one object shaped like:
{
"type": "result",
"success": true,
"content": "Done (mock response).",
"model": "mock",
"turns": 1,
"usage": { "promptTokens": 0, "completionTokens": 0 },
"stopReason": "complete"
}Omit --no-session to persist the transcript; a successful run then also
returns a sessionId you can pass to penguin resume or penguin session show.
Errors in JSON mode are emitted as {"type":"error","error":"..."} on stderr.
Configuration is layered, highest priority last:
- built-in defaults
$PENGUIN_HOME/penguin.json(default~/.penguin/penguin.json)<workspace>/.penguin/settings.json(presentation-only unless--trust-project)- a named entry under
profilesselected with--profile PENGUIN_<SECTION>__<KEY>environment overrides- CLI flags
penguin config path
penguin config show
penguin config set permissions.mode plan
penguin config set sandbox.mode read-only
penguin config get model.providerpenguin init creates a minimal .penguin/settings.json and PENGUIN.md.
Settings are plain JSON. Provider credentials are never written there: set
the environment variable named by model.apiKeyEnv (default PENGUIN_API_KEY;
the DeepSeek provider also checks DEEPSEEK_API_KEY). Explicit MCP env and
headers values are configuration, not a secret store; prefer environment
references supported by the server.
Example settings. Put this in ~/.penguin/penguin.json, or in a project's
.penguin/settings.json only when you trust that repository and run with
--trust-project (untrusted projects may set presentation fields only):
{
"version": 1,
"model": {
"provider": "openai-compatible",
"baseUrl": "http://127.0.0.1:11434/v1",
"name": "qwen2.5-coder",
"apiKeyEnv": "LOCAL_API_KEY"
},
"permissions": {
"mode": "default",
"default": "ask",
"rules": [
{ "tool": "bash", "pattern": "git status(?: --short)?", "decision": "allow" }
]
},
"sandbox": {
"mode": "workspace-write",
"denyPaths": ["~/.ssh", "~/.gnupg", ".env"]
},
"mcpServers": {
"filesystem": {
"transport": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
},
"hooks": [
{ "event": "pre_tool", "command": "my-audit-hook", "matcher": "bash" }
]
}| Provider | Default endpoint | Credential |
|---|---|---|
deepseek |
https://api.deepseek.com/v1 |
DEEPSEEK_API_KEY or PENGUIN_API_KEY |
openai-compatible |
configured baseUrl |
model.apiKeyEnv / PENGUIN_API_KEY |
anthropic |
https://api.anthropic.com |
ANTHROPIC_API_KEY |
ollama |
http://127.0.0.1:11434/v1 |
none |
mock |
none | none |
The provider layer supports tool calls, retry on transient HTTP statuses, request
timeouts, and redacted error messages. Use --provider mock for offline checks;
it is not a real model and only follows a few deterministic prompts used by tests.
Code Penguin has two independent layers:
- Policy: the permission engine classifies shell commands and ask-gates
mutations. A best-effort denylist blocks common destructive commands (for
example recursive deletion targeting protected absolute paths such as
/,/etcand/mnt/data, parent traversal, unresolved recursive targets, and disk formatting) even when--yesis supplied. Plan mode advertises only read-only tools and rejects mutations in the core loop.--allowed-toolsrestricts which agent tools are available. - Permission rules: the first matching rule wins, including
ask. A Bash pattern is a regular expression matched against an entire command segment. For example,git statuscovers that exact command, andgit status(?: --short)?also coversgit status --short. Bash segments joined by;,&&,||, or pipes are evaluated individually. Every segment must allow for automatic approval, and any deny blocks the call. Redirects, substitutions, shell expansions, and other complex syntax require approval unless already denied. Explicitaskrules also apply to tools that normally run without a prompt. - Workspace confinement: file tools reject paths outside the workspace and
symlink components.
read-onlyblocks mutating tools.workspace-writerestricts built-in file writes to the workspace. Bash receives a scrubbed environment (credential-looking variables are removed unless explicitly allowlisted) and starts in the workspace or a validatedcwd.
Important limits:
sandbox.denyPathsapplies to built-in path checks, including Bash's starting directory. Once Bash is running, it can read and write anywhere your account can unless you run it in an external filesystem sandbox.doctorcan detectbwrap. Code Penguin does not activate it. The shell checks use lexical heuristics and cannot resolve runtime variables, aliases, symlinks, scripts, or other programs that execute commands. Use OS isolation for untrusted code.- Project configuration is untrusted by default. Hooks, MCP servers, provider
routing, permission policy, and sandbox policy in
.penguin/settings.jsonare ignored unless you pass--trust-project(or setPENGUIN_TRUST_PROJECT=1) after reviewing the repository. Trusted hooks and MCP servers execute local commands; provider/destination settings from a trusted project can still redirect your API key, so review those too. - Hook matchers check raw string values as well as serialized event data.
A
post_toolhook can returndata.resultto replace the result orallowed: falseto withhold it from the model and interface. The tool has already run by that point, so withholding the result does not undo its effects. - Memory files can influence model behavior. Keep them under review.
- API credentials stay in environment variables. Avoid putting secrets in
command arguments or project config. The optional
penguin-desktopbrowser launcher passes a private temporary HTML file to the browser. The file is removed after the first authenticated request or launcher shutdown. With--no-openor if opening fails, the terminal shows the authenticated URL for manual use.
penguin run "start the refactor" # creates a session
penguin session list
penguin session show <id>
penguin session export <id> --output notes.md
penguin resume <id> "continue"
penguin run --continue "continue latest"Sessions are JSONL files under $PENGUIN_HOME/sessions/. Checkpoints are stored
under $PENGUIN_HOME/checkpoints/ with owner-only directory permissions. New
snapshots skip default protected paths such as .env at any depth and honor
configured sandbox.denyPaths. The manifest records incomplete snapshots,
including those that hit the file count or byte limit. Incomplete, empty, and
older checkpoints without a completeness marker restore captured eligible files
without deleting uncaptured files. A complete, nonempty checkpoint may remove
files created after capture. Capture and rewind operate on a live filesystem.
Avoid concurrent edits during either operation. Rewinding requires the exact
checkpoint ID and --yes in non-interactive mode.
PENGUIN.md and AGENTS.md are loaded from the workspace (with a per-file
fallback to ~/.penguin/) and injected as project instructions. Keep them short:
the loader caps memory at 128 KiB per file.
penguin mcp list
penguin mcp tools
penguin mcp call mcp__filesystem__read_file '{"path":"README.md"}'
penguin mcp testMCP tools are exposed as mcp__<server>__<tool> and pass through the same
approval path as built-in tools. Configure servers under mcpServers in layered
settings. For HTTP authentication, set authType to bearer, api-key, or
header (with authHeaderName) and store the credential in authTokenEnv.
CLI credentials use named environment variables; authEnv passes a stdio
credential to only that server. The desktop stores credentials encrypted and
supports custom HTTP headers and stdio environment credentials.
Agents can search and update durable project knowledge through the memory tools.
Notes are ordinary Markdown files in .penguin/memory/, so they can be reviewed,
edited, and committed like other project files. Agents should preserve useful
decisions and facts, not conversation transcripts.
Hooks receive { "event": "...", "data": ... } on stdin. A non-zero exit, a
timeout, a broken guard response, or {"allowed":false} blocks the action. A
hook may return {"data": ...} to transform the event payload. Hooks are local
shell commands and run with your user's privileges; configure only code you trust.
npm install
npm test # build + full integration test suite
npm run typecheck
./scripts/build-release.shDocumentation:
- Install and uninstall
- Architecture
- Design and feature rationale
- Feature research matrix
- Environment report
./uninstall.sh
# or: PENGUIN_PREFIX=/custom/prefix ./uninstall.shThe uninstaller removes only the launcher and the penguin-agent-harness package
directory under the chosen prefix. It does not delete sessions, checkpoints, or
$PENGUIN_HOME; keep or remove that state deliberately.
MIT. See LICENSE.