task-sh 0.1.2

AI-powered shell command generator
task-sh-0.1.2 is not a library.

task.sh

Crates.io Downloads CI License

task.sh turns natural language task descriptions into safe shell command suggestions using OpenAI. The CLI is designed for cross-platform usage (Linux, macOS) and emphasizes safety, observability, and customization.

Features

  • task gen subcommand with --shell selection (bash, zsh).
  • Verbose mode prints raw AI output and explanations.
  • Regex-based command safety filters.
  • Optional TASK_SH_FAKE_RESPONSE environment variable for deterministic tests.

Getting Started

Prerequisites

  • Rust toolchain (via rustup).
  • OpenAI API key with access to GPT-3.5 (or compatible) models.

Installation

git clone https://github.com/barledge/task.sh.git
cd task.sh
cargo install --path .
cp .env.example .env

Edit .env and set OPENAI_API_KEY to your secret key.

Usage

# Generate a bash command with explanation
task gen "list large files" --shell bash -v

# Pipe input via stdin
echo "list staged changes" | task gen --verbose

# Use the fake response mode for testing/demos
TASK_SH_FAKE_RESPONSE=$'Command: ls\nExplanation: list files' task gen "anything"

Inspect all options:

sh --help

Environment

  • OPENAI_API_KEY: Required for live generation.
  • TASK_SH_FAKE_RESPONSE: Optional string that substitutes the OpenAI response for testing.

Development

cargo fmt
cargo clippy --all-targets
cargo test

Build Scripts

scripts/build-release.sh
scripts/publish.sh

For cross-compilation (requires cargo-zigbuild):

scripts/build-cross.sh x86_64-unknown-linux-gnu
scripts/build-cross.sh x86_64-pc-windows-gnu
scripts/build-cross.sh aarch64-apple-darwin

Documentation

The mdBook-based docs live in docs/.

cargo install mdbook
mdbook build docs

Publish to task.sh/docs or serve locally with mdbook serve docs.

Contributing

  1. Fork the repository and create a feature branch.
  2. Add tests covering new functionality.
  3. Run cargo fmt, cargo clippy, and cargo test before submitting a PR.
  4. Submit a PR with a concise description of the changes.

License

Licensed under the MIT License.