Skip to content

feat(init): prompt for harness when --ai is absent (TTY only) (#36)#37

Merged
kevinkod merged 1 commit intomainfrom
feat/init-harness-prompt
May 2, 2026
Merged

feat(init): prompt for harness when --ai is absent (TTY only) (#36)#37
kevinkod merged 1 commit intomainfrom
feat/init-harness-prompt

Conversation

@kevinkod
Copy link
Copy Markdown
Contributor

@kevinkod kevinkod commented May 2, 2026

Summary

  • specflow init no longer silently defaults to Claude when the user hasn't passed --ai. In an interactive terminal it now lists the 8 supported harnesses (Claude Code, Cursor, Codex, Gemini, Windsurf, Copilot, OpenCode, Antigravity) and asks the user to pick one — Enter selects the Claude default, invalid input re-prompts.
  • When stdin is not a TTY (CI, scripts, piped input), the silent Claude default is preserved — zero regression for automated usage.
  • Multi-select / multi-harness in a single project remains out of scope (see Prompt for harness selection on init when --ai is absent and stdin is a TTY #36 for the rationale on lock-format and inter-harness conflict resolution).

Implementation notes

  • New pure module src/cli/harness_picker.ts encapsulates the list, default, and re-prompt loop, with an injectable readLine callback so the picker logic is fully unit-testable without a real TTY.
  • Parser: intent.ai becomes Harness | null. The handler resolves null to a concrete harness via Deno.stdin.isTerminal() + pickHarness().
  • TerminalPrompt is left untouched — its select() doesn't support "empty-input as default" and the picker has its own loop semantics, so reusing it would have required a richer signature than this ticket needs.

Test plan

  • Unit tests cover every branch of the picker: empty → default, each 1-based index → matching harness, out-of-range / non-numeric → re-prompt, whitespace-only → default, null (EOF/Ctrl-D) → default.
  • Existing integration test renamed to specflow init (no --ai) defaults to Claude in non-TTY environments to reflect what it actually exercises (Deno.Command pipes stdin, so isTerminal() is false).
  • Sandbox E2E (non-TTY): specflow init --here from working tree against a fresh Vite project → no prompt shown, lock written with harness: claude, "Open the project in Claude Code" banner appears.
  • Local: deno task test — 339 passed.
  • CI green on macOS / Ubuntu / Windows cross-smoke.

Closes #36

🤖 Generated with Claude Code

…#36)

`specflow init` no longer silently defaults to Claude when the user
hasn't passed --ai. In an interactive terminal it now lists the 8
supported harnesses and asks the user to pick one (Enter = Claude
default, invalid input re-prompts). When stdin isn't a TTY (CI, scripts,
piped input), the silent Claude default is preserved — zero regression
for automated usage.

Implementation:
- New pure module src/cli/harness_picker.ts encapsulates the list,
  default, and re-prompt loop with an injectable readLine for testing.
- Parser: ai field becomes Harness | null. The handler resolves null
  to a concrete harness via Deno.stdin.isTerminal() + pickHarness.
- TerminalPrompt is left untouched — its select() doesn't support
  empty-input-as-default and the picker has its own loop semantics, so
  reusing it would have required a richer signature than this ticket
  needs.

Closes #36

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kevinkod kevinkod merged commit 3e52133 into main May 2, 2026
4 checks passed
@kevinkod kevinkod deleted the feat/init-harness-prompt branch May 2, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt for harness selection on init when --ai is absent and stdin is a TTY

1 participant