Metadata-Version: 2.4
Name: wippen
Version: 0.1.0b1
Summary: A terminal coding agent harness
License-Expression: Apache-2.0
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: anthropic==1.15.0
Requires-Dist: openai==3.60.0
Requires-Dist: prompt_toolkit==3.0.53
Requires-Dist: python-dotenv==1.2.4
Requires-Dist: Pillow==13.0.0
Requires-Dist: httpcore2==2.16.2
Requires-Dist: httpx2==2.16.2
Requires-Dist: jsonschema==4.26.0
Requires-Dist: referencing==0.37.0
Requires-Dist: pathspec==0.12.1
Requires-Dist: mcp==2.3.0
Requires-Dist: PyYAML==6.0.3
Requires-Dist: keyring==25.7.0
Provides-Extra: test
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Sumire-no-kai/Wippen/master/docs/brand/wippen-mark-dark.svg">
    <img src="https://raw.githubusercontent.com/Sumire-no-kai/Wippen/master/docs/brand/wippen-mark-light.svg" width="128" height="128" alt="Wippen logo: five piano keys forming a W, the middle one pressed">
  </picture>
</p>

<h1 align="center">Wippen</h1>

<p align="center"><strong>A terminal coding agent you can replay and evaluate, step by step.</strong></p>

<p align="center">
  <img src="https://img.shields.io/badge/status-in%20development-E0A93B?style=flat-square" alt="Status: in development">
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-121110?style=flat-square" alt="License: Apache 2.0"></a>
  <img src="https://img.shields.io/badge/language-Python-121110?style=flat-square&amp;logo=python&amp;logoColor=F3EEE2" alt="Written in Python">
</p>

<p align="center">
  <code>wippen</code> · said <em>WIP-en</em> · <a href="docs/plan.md">Plan</a> · <a href="docs/architecture.md">Architecture</a> · <a href="docs/brand/">Brand</a>
</p>

---

## About Wippen

Wippen is an open-source Python harness for running a coding agent locally from the terminal. It sends the task and available tool definitions to a language model, runs the tools the model requests, and feeds their results back into the conversation. The project aims to make each step inspectable, so you can see what the agent tried, resume a session, replay a run, and measure what happened.

The core uses an append-only JSONL event log to record model and tool calls, tool results, stop reasons, token usage, and timings. It connects to model providers through separate adapters for Anthropic Messages, OpenAI Responses, compatible Chat Completions endpoints and Gemini Interactions. Evaluation will use a fixed task set and measure success, token use, and cost, including runs under faults injected by Tapedeck. Later stages cover permission rules, approval hooks and sandboxing, plus MCP, skills, subagents, multiple working directories, attachments, and memory.

**In development · Stage 3.** The `wippen` package runs tasks through four protocols. By default it asks before edits and shell commands. On macOS and Linux, approved commands run in a sandbox by default and reach the network only through approved destinations. It stores a unified conversation in a versioned event log. Anthropic Messages and OpenAI Responses also support native compaction. [Development plan ](https://github.com/Sumire-no-kai/Wippen/blob/master/docs/plan.md#stages-and-milestones)

## The name

A wippen is the lever assembly in a piano action that passes the motion of a key to the hammer. A harness plays the same part between a person and a model: the model proposes a tool call, and the harness turns it into execution that stays within its rules. The logo is five piano keys forming a W, with the middle key pressed.

## Install the PyPI beta

In a Python 3.13 or newer virtual environment on macOS or Linux, install the beta and open Wippen:

```bash
python -m pip install wippen==0.1.0b1
wippen --version
wippen
```

On first launch, Wippen opens a separate API settings screen. Choose the company that
issued your key, paste the key into the hidden field, and save with the suggested model
or choose another. During a conversation, open the same screen with `/settings` in the
status bar. `wippen setup` opens it directly from the shell. Use either entry point to
add another provider or replace a key, and choose whether to set a new default.

Wippen saves keys in macOS Keychain or Linux Secret Service. If the system store is
unavailable, the in-app settings can use the key until Wippen exits. An environment key
takes precedence. Saved keys are sent only to each provider's official API endpoint, so a
custom base URL needs its key in the environment. After you save, Wippen can open a new
conversation with the provider and model you chose. The earlier session keeps its original
provider and model. [Provider key names](https://github.com/Sumire-no-kai/Wippen/blob/master/docs/trying-wippen.md#what-you-need)

Run `wippen update` to update an isolated pip installation from PyPI. Beta installations
can pick up newer betas. Installs managed by pipx, uv, or a source checkout use their own
update mechanisms. The command reports the applicable path. To pass a literal task named
`setup` or `update`, use `wippen -- setup` or `wippen -- update`.

On Windows, install inside a Linux distribution under WSL. Approved shell commands use confinement by default. Wippen checks the sandbox backend at startup and says what is missing if it cannot start. See the [shell qualification](docs/stage-3-shell-qualification.md) for the tested platforms and known limits.

## Running the offline CLI

To use Wippen every day in your own repositories, start with [Trying Wippen](https://github.com/Sumire-no-kai/Wippen/blob/master/docs/trying-wippen.md).

```bash
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[test]'
.venv/bin/wippen --fake "Read scores.csv"
.venv/bin/python -m unittest discover -s tests
```

The smoke test returns a fixed JSON answer. An editable checkout loads its root
`.env` if present and gives existing environment variables precedence.

## Running a read-only task

Set `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` in the environment or in the checkout's `.env`, then run the corresponding command:

```bash
.venv/bin/wippen --provider anthropic --workdir prototype/workspace \
  "Read scores.csv with read_file and report the average score."
.venv/bin/wippen --provider openai --workdir prototype/workspace \
  "Read scores.csv with read_file and report the average score."
```

The CLI streams text to stderr and writes one final JSON object to stdout.
If an attachment fails validation before a one-shot session starts, the command exits with status 1. The final JSON has `stop_reason: "input_refused"` and both `session_id` and `event_log` are `null`.
The result includes the stop reason and log path. Use `--log-dir` to select
where the JSONL records are saved. They include the prompt and text
read from files. Use `--base-url`, `ANTHROPIC_BASE_URL`, or `OPENAI_BASE_URL` to select an endpoint
and `--max-turns` or `--token-budget` to bound the run; by default neither is
set. The token budget is checked after each response, so the last call can
exceed it.

Before generation with Anthropic Messages or OpenAI Responses, Wippen asks the provider to count the prepared input.
`--max-output-tokens` can reduce the model's default output allowance. Wippen
uses the catalog cap when it fits and reserves a smaller allowance for a
reduced context window or a model with no usable published cap. `--context-window`
can lower a known model's window or specify it for a custom model. The
`context.checked` event records the decision and timing. Proxies need to
forward the corresponding token-count endpoint. A large `read_file` result
includes an offset for the next page, measured in decoded characters.
The workspace's `AGENTS.md` must fit within 10,000 characters to load in full.
Repeat `--add-dir /path/to/directory` to grant file access to additional
directories. Relative paths still start at `--workdir`. Use absolute paths to
select files in an additional directory. Use `--load-dir-config` to load their
`AGENTS.md`, project configuration, skills, and commands at session startup.
Use `--yes` to explicitly authorize registered tools with side effects in a
non-interactive run. Tool approvals are recorded in the event log.

### Running a task with edits

```bash
.venv/bin/wippen --provider anthropic --workdir /path/to/project --yes \
  "Find the tests for the selected module, make the requested edit, and run its tests."
```

The built-ins can search by glob or regular expression, read a file by line
range, replace a unique match in a recently read file, and write a whole file
atomically. Search follows nested `.gitignore` files and excludes Git metadata
and private environment files. The final JSON includes the session's `todos`.

In a task, use `@path/to/file.py`, `@"a file with spaces.txt"`, or
`@path/to/file.py#20-45` to supply workspace text. Directories contribute a
one-level listing. UTF-8 files up to 256 KB are included. Larger and media
files remain path references.

An approved shell command runs with the current user's OS permissions. Stage 2
has no process sandbox. Commands have a timeout and their output is bounded, and
provider API key environment variables are removed from the child environment.

Automatic compaction starts at 90% of usable input by default. Use
`--compact-at 50000` for an absolute threshold or
`--compact-after-turn 1 --max-turns 3` after the first tool batch of an input.
Wippen estimates input growth and calls the provider's counter near the limit.
Anthropic also
supports `--clear-old-at 50000` for server-side tool-result clearing and
`--anthropic-prompt-cache` for automatic prefix caching. OpenAI uses its
automatic cache and its native compaction window to retire older history.

### Gemini Interactions

Set `GEMINI_API_KEY` and run the native Gemini Developer API in stateless mode:

```bash
.venv/bin/wippen --provider gemini --workdir prototype/workspace \
  "Use read_file to read scores.csv and report the average."
```

The default model is `gemini-3.8-flash`, with a documented input limit of 1,048,576 tokens and an output limit of 65,536. To use a proxy, give its API root, including the version path, with `--base-url`. Every generation sends the full local history with `store: false`. Wippen supports text and tool exchanges and keeps the provider's thought signatures for resume. The endpoint enforces its context limit. Model limits checked on 2026-12-01. [Gemini model reference](https://aistudio.google.com/docs/models/gemini-3.8-flash)

### Chat Completions endpoints

Set `DEEPSEEK_API_KEY` for `--preset deepseek` or `MOONSHOT_API_KEY` for
`--preset kimi`. For another compatible endpoint, use
`--provider chat-completions --base-url URL` with `WIPPEN_CHAT_API_KEY`.
Pass the model ID and context window for the selected endpoint. For example,
set `DEEPSEEK_MODEL` and `DEEPSEEK_CONTEXT_WINDOW` in your shell and run:

```bash
.venv/bin/wippen --preset deepseek --model "$DEEPSEEK_MODEL" \
  --context-window "$DEEPSEEK_CONTEXT_WINDOW" --workdir prototype/workspace \
  "Read scores.csv with read_file and report the average score."
```

This adapter estimates input size locally. Compatible endpoints need streaming function calls,
streamed token usage, and `tool_choice: "none"`. Wippen stops before dispatching
tools if the response cannot be accounted against the token budget. Anthropic
Messages and OpenAI Responses have native compaction. Other adapters use the
same model to write a summary when compaction is needed.

The log breaks down each turn into model, tool, context API, and local harness time.
Context API time includes counting, recounting, and standalone compaction.
Model time is elapsed time at the client excluding terminal writes. Time to first output
measures the first text, reasoning, or tool output observed in the stream.

The model IDs and streaming behavior were checked against the official docs on 2026-11-30.
[Anthropic model list](https://platform.claude.com/docs/en/models/overview) ·
[Anthropic streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) ·
[OpenAI model](https://developers.openai.com/api/docs/models/gpt-6.2-sol) ·
[OpenAI Responses reasoning](https://developers.openai.com/api/docs/guides/reasoning)

[Core code walkthrough and context measurements](https://github.com/Sumire-no-kai/Wippen/blob/master/docs/core-walkthrough.md) ·
[Unified messages and JSONL v1](https://github.com/Sumire-no-kai/Wippen/blob/master/docs/session-format.md)

## Running an interactive session

Start `wippen` without a task to open a line-based session in the terminal:

```bash
.venv/bin/wippen --provider anthropic --workdir prototype/workspace
```

Each message continues the same conversation and event log. Replies, tool
calls and per-reply timings print into the terminal's scrollback; only the
input line and the status line below it are redrawn. Press Enter to send,
Esc then Enter or Ctrl+J for a new line, Ctrl+C to stop the current turn,
and Ctrl+D or `/exit` to quit. `/help` lists the commands. `--max-turns`
and `--token-budget` apply to each message when set; by default there is no
limit.

The session has the same tools as a one-shot run: reading, searching,
editing and writing files, running commands, a todo list, read and write child
sessions, skills and allowed MCP servers. Edits, writes and commands ask
before they run, unless you pass `--yes`. Type `@` to complete a workspace
path and include that file in the message, `/add-dir PATH` to give the model
another directory, `/todo` to see the model's task list, and `/compact` to
summarize the conversation so far. Custom commands
from your command directories appear as slash commands.

To pick up where you left off, `--continue` opens the latest session for the
same directory and model, `--resume` lists earlier sessions to choose from, and
`/resume` switches sessions from inside the REPL. The conversation is rebuilt
from the session's event log, and new events are appended to the same log.

## Layered configuration

Wippen applies explicit flags, project settings, user settings, and built-in defaults in that order. Put user settings in `$XDG_CONFIG_HOME/wippen/config.json` (default `~/.config/wippen/config.json`) and project settings in `.wippen/config.json` under the selected `--workdir`. For example:

```json
{
  "provider": "anthropic",
  "max_turns": 6,
  "token_budget": 20000,
  "skill_dirs": ["skills"],
  "command_dirs": ["commands"],
  "mcp_servers": {
    "local-docs": {"transport": "streamable-http", "url": "http://localhost:8000/mcp"}
  }
}
```

The scalar keys are `provider` or `preset`, `model`, `base_url`, `max_turns`, `token_budget`, `child_max_turns`, `child_token_budget`, `child_timeout`, `max_cost`, `model_catalog_refresh`, `max_output_tokens`, `context_window`, `compact_after_turn`, `compact_at`, `clear_old_at`, and `anthropic_prompt_cache`. An MCP entry uses either `transport: "stdio"` with `command` and optional `args`, or `transport: "streamable-http"` with `url`. Repeating `--mcp-server NAME=JSON` overrides named entries. The highest layer that supplies a directory list replaces that list. File-relative directory paths start at the directory containing `config.json`. CLI overrides `--skill-dir` and `--command-dir` are relative to `--workdir`. Omitted lists use `skills` and `commands` under both the user and project configuration directories. The project settings file and project-defined extension directories must resolve inside the selected workspace.

With `--load-dir-config`, settings and named MCP definitions from added directories override user settings in `--add-dir` order. The primary project and explicit CLI flags have higher precedence. Each added directory contributes its own skill and command folders before those of the primary project. An explicit CLI directory list replaces discovery for that extension type. Project configuration and discovery folders resolve within the project directory that supplied them.

Use `workspace_dirs` to add file-access directories relative to the configuration file. A project-declared folder requires per-invocation consent through `--allow-project-folder PATH` or the interactive prompt. Missing directories are skipped with a warning.

Give each project MCP server startup consent for the current run with `--allow-project-mcp NAME`. Project-provided API endpoints are announced on stderr. If the project endpoint changes the API origin, pass `--allow-project-base-url` after reviewing it or supply an explicit `--base-url`. A user-level base URL applies to its configured provider or preset. If the user settings omit that choice, select it explicitly on the command line to use the user-level URL. Put API keys in the environment, the development checkout's `.env`, or the saved settings from `wippen setup` and `/settings`. Saved keys apply only to the provider's official endpoint. The v1 transcript records the effective run options and redacts endpoint paths, queries, and MCP command arguments.

Wippen discovers the tools of eligible MCP servers before the first model request. Tool names use the server namespace, such as `mcp__local-docs__lookup`. Every MCP tool call requires `--yes` in non-interactive mode, independently of startup consent. A failed server does not prevent built-in tools and other servers from running. Use stdio servers you trust because they run as local processes. Server results can carry text and images. Images follow the selected endpoint’s tool-result capabilities and input limits.

## Skills and custom commands

Place a skill in `skills/<name>/SKILL.md` under a configuration directory. Provide `name` and `description` in YAML frontmatter. The model sees those fields at startup and can call `use_skill` for the instructions, then use `read_file` with `skill:<name>/<path>` for related files.

Place a command such as `review.md` in a `commands` directory. `wippen '/review notes.md' --provider anthropic` sends that template with `$ARGUMENTS` replaced by `notes.md`. Command parameters are plain text.

When the same name is found in multiple enabled directories, the later directory wins. The default order puts the primary project's extensions last. Use user configuration or explicit directory flags for folders outside a project.

## Running the prototype

```bash
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
cp .env.example .env   # then add your ANTHROPIC_API_KEY
cd prototype
../.venv/bin/python agent.py "What is the average score in scores.csv?" --workdir workspace
```

`run_python` executes model-written code without a sandbox, so the prototype asks before each run unless `--yes` is given.

## Related project

[Tapedeck](https://github.com/Sumire-no-kai/Tapedeck) is a planned local proxy for testing agent harnesses with injected faults, recorded runs and profiling. Wippen is one of the harnesses it will test. The projects plan to share a task set and its graders.

## License

[Apache License 2.0](https://github.com/Sumire-no-kai/Wippen/blob/master/LICENSE).
