Add BASECAMP_NONINTERACTIVE escape hatch for prompts

Merged
RO
5mo ago
+145-17

Problem

An agent that runs basecamp todos list --in <id> --md can be blocked by an interactive selection prompt (e.g. picking a todoset when a project has more than one), wedging the session. Reported in #395.

The root cause is that --md is deliberately not a machine-output mode — only --agent/--json/--quiet/--ids-only/--count suppress prompts (IsInteractive() in both internal/appctx/context.go and internal/tui/resolve/resolve.go). When the CLI runs under an allocated PTY, stdout looks like a terminal, so ambiguous resolutions fall through to a blocking picker even though a human isn't there to answer it.

Relying on the model to remember --agent per invocation is exactly what the issue asks us to avoid.

Change

Add BASECAMP_NONINTERACTIVE as an explicit escape hatch. When set to a truthy value (1/true), it forces IsInteractive() to false in both gates, so ambiguous resolutions become actionable errors (Multiple todosets found — specify one with --todoset <id>) instead of prompts.

Command-level prompt guards also consult the escape hatch, so direct confirmations such as basecamp chat delete ... without --force cannot wedge an agent session under a PTY.

Key property: it only disables prompts — it does not change the output format. That is the distinction from --agent (which also forces quiet JSON): you keep --md Markdown output and just lose the wedge.

Setting it is the environment/harness's responsibility (shell profile, MCP server env, wrapper), not the model's — so it doesn't depend on the LLM appending a flag every call. Mirrors the pattern the issue references from other agent CLIs.

Details

  • config.NonInteractiveEnv() reuses the existing strict parseEnvBool (accepts 1/true, ignores unrecognized values).
  • Both IsInteractive() chokepoints consult it first; resolver prompts and app.IsInteractive() command sites flow through those gates.
  • Command-level prompt guards also consult it, covering direct confirmations that do not use the resolver.
  • Explicit setup flows (basecamp setup and interactive skill/setup wizards) remain intentionally interactive; use direct flags/subcommands for non-interactive setup.
  • skills/basecamp/SKILL.md now documents that --md does not suppress prompts and points to the env var / disambiguating flags.

Notes for reviewers

  • The env var's effect on IsInteractive() is inherently TTY-dependent, so the unit tests assert the parser (config) and the invariant that the escape hatch does not flip IsMachineOutput() — matching the limitation of the existing IsInteractive tests.
  • This does not touch the pre-existing --agent behavior.

Refs #395


Summary by cubic

Add a BASECAMP_NONINTERACTIVE env escape hatch to disable prompts without changing output format, so --md runs under a PTY don’t get stuck. Also treats --jq as machine-output for the profile picker and clarifies character-device detection in docs.

  • New Features
    • Set BASECAMP_NONINTERACTIVE to 1 or true to force non-interactive mode across the app, resolver, profile picker, and command prompts; ambiguous targets return clear errors (e.g., use --todoset <id>).
    • Output format is unchanged; you can keep --md while suppressing prompts. --jq implies JSON and now suppresses the profile picker.
    • Docs updated to note stdout “character device (e.g., a terminal)” detection and fix disambiguation examples in skills/basecamp/SKILL.md; tests hardened to cover the env short-circuit, char-device stdout, and command prompt guards.