Skip to main content

No project description provided

Project description

SmartMan

SmartMan is a command-line interface tool designed to generate summaries, examples, and custom commands based on user intent using man pages and large language models (LLMs). This tool aims to simplify the process of retrieving and understanding command-line documentation.

Features

  • Generate concise summaries of man pages
  • Display practical usage examples for specific commands
  • Create custom commands based on natural language descriptions
  • Interactive mode for continuous querying
  • Support for multiple LLM providers (OpenAI and Anthropic)
  • Response caching to reduce API calls and improve speed

Installation

To install the SmartMan tool, you can either install via pip or clone the repository.

Option 1: Install via pip

pip install smartman

For development:

python3 -m venv ~/venvs/smartman
source ~/venvs/smartman/bin/activate
pip install -e .

Option 2: Clone the repository

git clone https://github.com/sajid-karim/cli-llm-man.git
cd cli-llm-man
pip install -r requirements.txt

Configuration

Before using the tool, you need to configure your LLM API key. You can do this in two ways:

Option 1: Environment Variable

Set one of the following environment variables:

For OpenAI (preferred)

export OPENAI_API_KEY='your-key-here'

For Anthropic

export ANTH_API_KEY='your-key-here'

Option 2: Configuration File

Create a configuration file at ~/.cli_llm_man/config.yaml with the following content:

# For OpenAI
LLM_API_KEY: your_openai_key_here
PROVIDER: openai  # Optional, defaults to openai
MODEL: gpt-4o    # Optional, defaults to gpt-4o

# OR for Anthropic
LLM_API_KEY: your_anthropic_key_here
PROVIDER: anthropic
MODEL: claude-3-opus-20240229  # Optional

You can find a sample configuration file in config.example.yaml.

Usage

Once installed and configured, you can use the SmartMan tool with the following commands:

Generate Summary

To generate a summary for a given command:

# Using the installed command
cli-llm-man summary ls

# OR using the module directly
python -m cli_llm_man.main summary ls

Show Usage Examples

To display usage examples for a specific command:

cli-llm-man example grep

# OR
python -m cli_llm_man.main example grep

Generate Command

To create a command based on your intent:

cli-llm-man generate "find all PDF files modified in the last 7 days"

# OR
python -m cli_llm_man.main generate "find all PDF files modified in the last 7 days"

Interactive Mode

For continuous interaction with the tool:

cli-llm-man interactive

# Then type commands like:
# summary ls
# example grep
# generate "count lines in all python files"
# exit

Alias Setup

To simplify running the SmartMan tool, you can add a shortcut alias to your shell profile. This alias allows you to run the tool using the command llm-man instead of typing out smartman.

To set up the alias, run the following command in your terminal:

setup-smartman-alias

This command will add the alias to your shell profile (e.g. .bashrc, .bash_profile, or .zshrc). After running the command, reload your shell (or source the profile) with:

source ~/.bashrc
# or
source ~/.bash_profile
# or for zsh users:
source ~/.zshrc

Now you can run the tool using the shorter command. For example:

llm-man summary ls
llm-man example grep
llm-man generate "find all PDF files modified in the last 7 days"

Caching

By default, responses are cached to improve performance and reduce API calls. The cache is stored in ~/.smartman/cache/. To disable caching, set use_cache: False in your config file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartman-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartman-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file smartman-0.1.0.tar.gz.

File metadata

  • Download URL: smartman-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for smartman-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98ac5e078964c3cb4d6b12d2d52c6dc2010eb07d88dd80789fb5b06bcd382668
MD5 a92b8d444a56d393df0856aded31b0f3
BLAKE2b-256 34a89f76672a2c6d2f1d223bc289f596b696dedf0a2445ce2e27e0b5bef68d95

See more details on using hashes here.

File details

Details for the file smartman-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: smartman-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for smartman-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be797f7ec6b65084ed29c7f18aa6c6ff784a77946546904f7932a7bfd7d16860
MD5 f14c434f4a461f13074389fe30a9f9ac
BLAKE2b-256 cb8d8451dae09cec613d2c16ac63a303780af3c6ed54aad7ea9a627a5f480d66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page