Contents

ryu0118/swift-interaction

**A terminal interaction library for Swift, providing prompts, choices,

Features

  • ⌨️ Read validated text input using the built-in ValidationRule.nonEmpty

or your own async-capable ValidationRule closures.

  • 📋 Present arrow-key navigable, filterable single- and multiple-choice menus.
  • 🎨 Render semantic ANSI-styled text and aligned tables that degrade

gracefully in non-TTY contexts.

Quick Start for Agents

Install the plugin for your agent, then ask it how to use the Interaction API.

Claude Code

/plugin marketplace add Ryu0118/swift-interaction
/plugin install interaction@interaction

Codex

codex plugin marketplace add Ryu0118/swift-interaction
codex plugin add interaction@interaction

The plugin provides the interaction-guide skill covering prompts, choices, tables, styled text, and validation.

Quick Start for Humans

Terminal is the entry point. Construct one and drive prompts against it:

import Interaction

let terminal = Terminal()

// Text input
let name = await terminal.readText(TextPrompt(message: "What is your name?"))

// Yes/no confirmation
let proceed = terminal.confirm(ConfirmationPrompt(question: "Continue?"))

// Single choice
let choice = terminal.choose(
    ChoicePrompt(question: "Pick one", options: ["a", "b", "c"])
)

ChoicePrompt/MultipleChoicePrompt options are any Equatable & CustomStringConvertible & Sendable type. See the DocC docs and the interaction-guide skill for the full, current API.

Installation

Add Interaction to your Package.swift:

dependencies: [
    .package(url: "https://github.com/Ryu0118/swift-interaction", from: "0.1.0"),
],

Then add it to your target:

.target(
    name: "YourCLI",
    dependencies: [
        .product(name: "Interaction", package: "swift-interaction"),
    ]
),

Requires macOS 26+ and Swift 6.2.

Documentation

Full API documentation is published at ryu0118.github.io/swift-interaction/documentation/interaction.

The DocC catalog lives in Sources/Interaction/Interaction.docc. Generate the archive locally with SwiftPM:

make docs

Development

make install-commands
make format
make lint
make test
make check

License

Interaction is available under the MIT License. See LICENSE for details.

Package Metadata

Repository: ryu0118/swift-interaction

Default branch: main

README: README.md