Metadata-Version: 2.4
Name: auto-yes
Version: 1.1.1
Summary: Auto-respond to AI CLI prompts (Claude Code, Cursor, Codex, Copilot, Gemini, Aider). PTY proxy that auto-answers yes/no dialogs so your automation never blocks.
Project-URL: Homepage, https://github.com/host452b/auto-yes
Project-URL: Repository, https://github.com/host452b/auto-yes
Project-URL: Issues, https://github.com/host452b/auto-yes/issues
Project-URL: Changelog, https://github.com/host452b/auto-yes/releases
Project-URL: Documentation, https://github.com/host452b/auto-yes#readme
License-Expression: MIT
Keywords: ai-agent,ai-coding,aider,auto-yes,ci-cd,claude-code,cli-automation,codex,copilot,cursor-ai,devtools,gemini-cli,interactive-prompt,overnight-automation,prompt-automation,pseudo-terminal,pty-proxy,terminal,tty,yes-no
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Go
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# auto-yes

> **Auto-respond to AI CLI prompts. Never get blocked by interactive yes/no dialogs again.**

[![Go](https://img.shields.io/badge/Go-1.22+-00ADD8?logo=go)](https://go.dev)
[![PyPI](https://img.shields.io/pypi/v/auto-yes.svg)](https://pypi.org/project/auto-yes/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)](#development)
[![Platforms](https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows-blue.svg)](#platform-support)

`auto-yes` wraps any CLI command in a **PTY (pseudo-terminal) proxy**, watches the output stream for interactive prompts, and automatically injects the correct response — so your overnight AI agent loops, CI pipelines, and automation scripts never block waiting for a human.

Works out-of-the-box with **Claude Code**, **Cursor**, **Gemini CLI**, **OpenAI Codex**, **GitHub Copilot**, **Amazon Q**, **Aider**, **Windsurf**, and 10+ more AI coding tools. Also handles generic `[y/n]`, `Continue?`, SSH fingerprint, Terraform `yes`, multi-choice menus, and any custom regex you define.

```
╭─ without auto-yes ─────────────────────────────────────────╮
│  claude "refactor auth module"                              │
│  > Trust this folder?  1. Yes  2. No   ← blocks forever   │
╰─────────────────────────────────────────────────────────────╯

╭─ with auto-yes ────────────────────────────────────────────╮
│  auto-yes claude "refactor auth module"                     │
│  > Trust this folder?  1. Yes  2. No                       │
│  [auto-yes] responded 'y' (matched: ❯ 1. Yes, I trust…)   │
│  ✓ Continuing automatically…                               │
╰─────────────────────────────────────────────────────────────╯
```

---

## Installation

```bash
# pip (any platform)
pip install auto-yes

# Go
go install github.com/host452b/auto-yes/cmd/auto-yes@latest

# Or download binary directly
# → https://github.com/host452b/auto-yes/releases
```

Shorthand alias `ay` is included. `make build` also auto-installs Go if needed.

---

## Quick start

### Wrap an AI CLI tool directly (recommended)

```bash
auto-yes claude "fix the tests"          # wraps: claude "fix the tests"
auto-yes cursor chat "add unit tests"    # wraps: agent chat "add unit tests"
auto-yes gemini "review this PR"         # wraps: gemini "review this PR"
auto-yes codex "explain this function"   # wraps: codex "explain this function"
auto-yes aider --model gpt-4o           # wraps: aider --model gpt-4o
auto-yes copilot                         # wraps: gh copilot
auto-yes amazonq chat "help me"          # wraps: q chat "help me"
```

The profile name maps to the real binary automatically — run `auto-yes list` to see all 14 profiles.

### Overnight / unattended mode (`--auto`)

For unattended overnight runs where you want every prompt answered automatically:

```bash
# All profiles, near-zero cooldown (0.05s), verbose logging
auto-yes run --auto -- claude "work through the backlog"

# With heartbeat to keep the agent responsive
auto-yes run --auto --heartbeat 30 -- claude "big refactor"

# Loop until complete
for task in tasks/*.md; do
    auto-yes run --auto -- claude "$(cat $task)"
done
```

`--auto` automatically loads ALL AI profiles, sets cooldown to 0.05s, and enables verbose logging.

### Agent conversational multi-choice (new)

When an AI agent presents multiple options (A/B/C) and asks you to choose, `auto-yes` responds with:

> *"I'll go with your recommended option"*

This works for any agent that accepts natural language input in multi-choice scenarios.

### Shell session mode

```bash
auto-yes --on --cli claude
# → now inside an auto-yes session; type normally, prompts are handled
exit
```

### Human-in-loop session control

Control a running auto-yes from another terminal — pause for manual interaction, then resume:

```bash
# Terminal 1: running auto-yes
auto-yes run --auto -- claude "big refactor"

# Terminal 2: take over for a moment
auto-yes ls                   # see running sessions and PIDs
auto-yes toggle 12345         # pause ↔ resume
auto-yes pause all            # pause every session
auto-yes continue all         # resume all
```

---

## How it works

Built as a Go binary with a **multi-goroutine pipeline** architecture:

```
stdin ──▶ [g2: Stdin Reader] ──▶ ┌────────────┐
                                  │            │
child ──▶ [g1: PTY Reader]  ──▶  │   Proxy    │ ──▶ PTY master write
           │                      │  (select)  │
           ▼                      │            │
        [Cleaner] ──▶ [Scanner]   └─────┬──────┘
                         │              │
                         ▼              │
                     [Injector] ────────┘
                    (5 timing guards)
```

### Four-stage text cleaning pipeline

| Stage | Operation | Why |
|-------|-----------|-----|
| 1 | Expand `ESC[nC` → spaces | Claude Code 2.x word separators |
| 2 | Strip ANSI/OSC sequences | Remove visual formatting |
| 3 | Remove control characters | Null bytes, bells, etc. |
| 4 | Resolve `\r` overwrites | Handle `\r\r\n` from Claude Code 2.x |

### Five-layer anti-false-positive guards

| Guard | Threshold | What it prevents |
|-------|-----------|------------------|
| Typing suppress | 1s | User's own keystrokes triggering auto-responses |
| Match cooldown | 50ms | Terminal redraws re-triggering the same prompt |
| Response cooldown | 0.5s (configurable) | Rapid-fire duplicate responses |
| Session pause | file-based | External pause control from another terminal |
| Approval delay | configurable | Queued response with cancel window |

---

## Supported tools (14 profiles)

| Profile | Binary | Tool | Key patterns |
|---------|--------|------|-------------|
| `claude` | `claude` | Anthropic Claude Code | Trust folder, Allow once/always, Proceed? |
| `cursor` | `agent` | Cursor Agent | `(y)`, `[a] Trust this workspace` |
| `gemini` | `gemini` | Google Gemini CLI | Allow once/session/always |
| `codex` | `codex` | OpenAI Codex | Yes, Approve and run now |
| `copilot` | `gh copilot` | GitHub Copilot | Yes proceed, Allow Copilot |
| `aider` | `aider` | Aider AI Coding | (Y)es/(N)o, Run shell command? |
| `openhands` | `openhands` | OpenHands Agent | Execute action?, Approve |
| `windsurf` | `windsurf` | Codeium Windsurf | Accept changes?, Run command? |
| `qwen` | `qwen` | Alibaba Qwen Code | Yes, Approve execution? |
| `amazonq` | `q` | Amazon Q Developer | Approve action?, Accept suggestion? |
| `grok` | `grok` | xAI Grok | Yes |
| `auggie` | `auggie` | Augment Code | Enable indexing |
| `amp` | `amp` | Sourcegraph Amp | Approve |
| `generic` | — | Universal y/n | `[y/n]`, SSH, Terraform, Press Enter |

```bash
auto-yes list                  # see all profiles
auto-yes patterns claude       # inspect patterns for a specific tool
```

### Generic patterns (loaded with `--cli generic` or `--auto`)

- Bracket/styled choices: `[y/n]`, `[Y/n]`, `[yes/no]`, `[Y]es / [N]o`
- Question prompts: `Continue?`, `Proceed?`, `Are you sure?`
- Action prompts: `Allow?`, `Approve?`, `Accept?`, `Download?`, `Enable?`
- SSH: `continue connecting (yes/no)?` → responds `yes`
- Terraform: `Only 'yes' will be accepted` → responds `yes`
- Press Enter: `Press Enter to continue` → responds with empty string
- **Excluded (safety)**: `Overwrite?`, `Delete?`, `Remove?`, `Replace?`, `Upgrade?`, `Restart?`

---

## CLI reference

```
auto-yes <profile> [ARGS...]       wrap an AI CLI tool directly (recommended)
auto-yes --on [OPTIONS]            start an auto-yes shell session
auto-yes run [OPTIONS] -- CMD...   run a single command with auto-yes
auto-yes list                      list all available CLI profiles
auto-yes patterns [CATEGORY...]    list prompt patterns
auto-yes add-pattern REGEX         persist a custom regex pattern
auto-yes del-pattern REGEX         remove a custom pattern
auto-yes status                    check if auto-yes is active
auto-yes ls                        list running sessions
auto-yes toggle <pid|all>          pause ↔ resume
auto-yes pause/continue <pid|all>  pause or resume only
auto-yes off                       help for exiting a session
```

### Options

| Flag | Description | Default |
|------|-------------|---------|
| `--auto` | Overnight mode: all profiles, 0.05s cooldown, verbose | off |
| `--response TEXT` | Text to send when a prompt is detected | `y` |
| `--cooldown FLOAT` | Seconds between auto-responses | `0.5` |
| `--delay FLOAT` | Approval delay; press any key to cancel | `0` |
| `--heartbeat SECONDS` | Send Enter every N seconds of inactivity | `0` |
| `--verbose`, `-v` | Print each auto-response | off |
| `--quiet`, `-q` | Suppress all output | off |
| `--pattern REGEX` | Extra prompt pattern (repeatable) | — |
| `--cli NAME` | AI CLI profile to load (repeatable, or `all`) | — |
| `--log FILE` | Debug log (raw bytes, cleaned text, detections) | — |

---

## Configuration

Config file: `~/.config/auto-yes/config.yaml` (Linux/macOS) or `%APPDATA%\auto-yes\config.yaml` (Windows)

```yaml
response: "y"
cooldown: 0.5
verbose: false
delay: 0.0
heartbeat: 0.0
```

Custom patterns: `~/.config/auto-yes/patterns.yaml`

```yaml
patterns:
  - regex: 'my-internal-tool.*confirm'
    response: "y"
  - regex: 'deploy to staging.*\?'
    exclude: true  # never auto-confirm this
```

Upgrading from Python version? Config is auto-migrated from `config.json` to `config.yaml` on first run.

---

## Adding a new AI CLI profile

Create a YAML file in `pattern/builtin/`:

```yaml
name: my-tool
description: "My AI Tool CLI"
command: ["my-tool"]
patterns:
  - regex: 'approve action\?'
  - regex: 'type yes to confirm'
    response: "yes"
  - regex: 'press enter to continue'
    type: enter
    response: ""
```

Run `auto-yes list` to verify it appears. No other code changes needed.

---

## Comparison with `yes(1)`

| | `yes \| cmd` | `auto-yes run -- cmd` |
|---|---|---|
| Prompt detection | None — floods stdin blindly | Smart regex, bottom-up scan |
| User can still type | No | Yes, fully interactive |
| PTY (colors / progress bars) | Broken | Preserved |
| False-positive protection | None | 5-layer timing guards |
| AI-specific prompts | No | 14 tool profiles built-in |
| Multi-choice support | No | Menus + conversational |
| Custom patterns | No | Persisted or one-off |
| Cross-platform | Unix only | Linux + macOS + Windows |

---

## Platform support

| Platform | Method | Notes |
|----------|--------|-------|
| **Linux** | PTY + goroutines | Full PTY, zero external deps |
| **macOS** | PTY + goroutines | Full PTY, zero external deps |
| **Windows** | conpty (planned) | Stub exists, full implementation coming |

---

## Development

```bash
git clone https://github.com/host452b/auto-yes.git
cd auto-yes

# Build (auto-installs Go if needed)
make build

# Test
make test

# Lint
make lint

# Show build environment
make info

# Release: cross-compile 6 platforms + build .whl wheels
make release     # → release/wheels/auto_yes-<ver>-py3-none-any.whl

# Publish to PyPI
make publish     # → release + twine upload

# Clean all artifacts
make clean

# Help
make help
```

### Golden test cases

Drop a YAML file in `testdata/cases/` and it becomes a test automatically:

```yaml
name: "My edge case"
category: claude
raw: "❯ 1. Yes, I trust this folder"
expect:
  matched: true
  source: claude
```

See [`testdata/cases/README.md`](testdata/cases/README.md) for **8 reusable templates** covering all interaction scenarios: yes/no, numbered menus, agent multi-choice, Press Enter, SSH/Terraform, ANSI-encoded, dangerous actions (excluded), and long-output prompts. Plus real-world samples for Claude Code, Cursor, Gemini, Aider, and Terraform.

### Architecture

```
cmd/auto-yes/   → entry point
cli/             → cobra commands (wrap, run, shell, session, list, patterns)
proxy/           → core engine (goroutine orchestration, timing guards, injection)
term/            → Terminal interface (Unix PTY, Windows conpty)
detect/          → text cleaning pipeline + bottom-up scanner
pattern/         → YAML pattern registry (14 builtin + external + CLI)
config/          → config loading (YAML, JSON migration) + session management
testdata/cases/  → golden test cases (drop-in YAML)
packaging/       → Python pip wrapper (execvp, ~30 lines)
scripts/         → build_wheels.py (goreleaser → .whl)
```

---

## License

[MIT](LICENSE)
