Skip to main content

Convert natural language descriptions into terminal commands using AI

Project description

Semantic terminal

PyPI Lines of Code License: MIT

A single-purpose command-line tool in the Unix tradition: it does one thing and does it well. sem translates natural language into shell commands using AI.

Just like grep searches, sed edits, and awk processes text, sem translates intent into commands. It fits naturally into a terminal workflow -- describe what you want, get the command, run it.

Install

pip install semantic-terminal

Requires Python 3.10+.

Quick start

  1. Get a free API key at console.groq.com
  2. Run the setup wizard:
    sem config
    
  3. Start using it:
    sem "find all python files larger than 1MB"
    

Usage

sem <description>        # Generate a command
sem -r <description>     # Generate and execute
sem !                    # Re-run the last generated command

Examples

$ sem "list files sorted by size"
$ ls -lS

$ sem "find processes using port 8080"
$ lsof -i :8080

$ sem -r "disk usage of current directory, human readable"
$ du -sh .
4.2G    .

$ sem "compress all log files in /var/log older than 7 days"
$ find /var/log -name "*.log" -mtime +7 -exec gzip {} \;

The generated command targets your OS and shell automatically.

Configuration

Run the interactive wizard:

sem config

Or manage individual settings:

sem config show                              # View current config
sem config set api_base https://...          # Set API endpoint
sem config set api_key                       # Set API key (hidden prompt)
sem config set model llama-3.3-70b-versatile # Set model

Defaults

Setting Default
Provider Groq (free tier)
Model llama-3.3-70b-versatile
API Base https://api.groq.com/openai/v1

Any OpenAI-compatible API works -- just change api_base and model.

Environment variables

Environment variables take precedence over the config file:

Variable Purpose
SEM_API_KEY API key (highest priority)
GROQ_API_KEY Groq API key fallback
OPENAI_API_KEY OpenAI API key fallback
SEM_API_BASE API base URL override
SEM_MODEL Model override

Security

  • API key is entered via hidden prompt -- never exposed in shell history
  • Config file is stored with owner-only permissions (0600 / user-only ACL)
  • sem config show masks the API key in output

How it works

sem sends your description to the configured AI model with a system prompt that instructs it to return exactly one shell command targeting your OS and shell. The command is displayed, saved to history for sem ! recall, and optionally executed with -r.

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

semantic_terminal-1.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

semantic_terminal-1.0.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file semantic_terminal-1.0.1.tar.gz.

File metadata

  • Download URL: semantic_terminal-1.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for semantic_terminal-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ff5ff54f4bb6b908d2fa1a7c7dfe122bfc0957a88b860477722380e4b1ddb0f7
MD5 f66579922acf8bfe6b9dae5360669a3b
BLAKE2b-256 df28f207bf362c8e8f9b0315a850a579796e1ecebf2abb6915f6353476fd695b

See more details on using hashes here.

File details

Details for the file semantic_terminal-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_terminal-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba406778432fb2ea18bb4b995e279d9a11ee40931c3b7944565461a508aa04c
MD5 013883945834c56334b097bb01a194fe
BLAKE2b-256 328af88e3e1492820b7bc8ddef379174ed6c454e58554df36a12b664a5e50fe2

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