Skip to main content

sem 🧰

PyPI version Python versions License: MIT Build Status

sem (distributed as the sempropos package) is an instant, offline-first CLI replacement for apropos, --help, and man. It indexes every command installed on your machine into a canonical structured ToolSpec representation and gives you fast answers in three modes:

  1. Synthesize (sem "..." / Ctrl+S): Turn plain English into a grounded, safety-checked shell command with optional flag-by-flag breakdowns.
  2. Inspect (sem show <tool> [subcommand]): Instant 0ms-LLM structured cheat-sheet cards replacing man and --help (usage, subcommands, searchable flags, verified examples).
  3. Discover (sem search <query>): Instant 0ms-LLM ranked tool search replacing apropos.

✨ Key Features

  • Canonical Structured ToolSpec Pipeline: Merges four complementary local sources into one typed, content-hashed SQLite v3 index:
    • Direct man(7) / mdoc(7) macro parser (reads compressed .gz/.xz/.bz2/.zst man pages directly from disk, capturing GNU coreutils flags inside DESCRIPTION and filtering out prose from EXAMPLES).
    • Offline tldr-pages cache/snapshot (task-focused summaries, verified examples, and hyphenated subcommands like git-commit, docker-run).
    • Static Fish & Zsh shell completion parsers (zero code execution).
    • Safe --help probe for non-man $PATH binaries (7z, uv, ruff, cargo, custom CLIs) with strict denylist, setuid exclusion, headless env, and hard timeouts.
  • High-Precision Local Retrieval: Porter-stemmed multi-column SQLite FTS5 (name, aliases, summary, tags, subcommands, examples, flags), file-extension/artifact hints (.7z, .tar.gz, .json, .service), compound intent matching, and confidence-gated vector recall (fastembed).
  • Task-Tailored Local Models + Clean External Providers:
    • Built-in managed GGUF (local_gguf): Curated small CLI-tuned models (tiny 0.5B, balanced 1.5B, quality 3B) with JSON-schema grammar constraints via sempropos[local-llm] (llama-cpp-python) or standalone llama-server.
    • Pure-HTTP Ollama & OpenAI-compatible: Zero extra SDKs, structured JSON output, configurable endpoints.
    • Tier-0 deterministic mode: Instant zero-LLM example matching and structured ToolSpec cards when offline or unconfigured.
  • Auto-Managed Warm Daemon: Lightweight Unix-domain-socket daemon (0600 private socket) with automatic idle shutdown (15m default) keeps SQLite, embeddings, and local models hot for sub-200ms queries and Ctrl+S transforms—with transparent in-process fallback.
  • Command Grounding & Safety Warnings: Verifies the executable exists on $PATH, cross-checks generated flags against ToolSpec to power --explain, and warns clearly on caution / destructive operations (rm -rf, find -delete, dd of=/dev/..., git reset --hard, curl | bash, etc.).

🚀 Quick Start

uv tool install sempropos
sem install                     # build structured v3 index (man + tldr + completions + safe --help)

Optional: enable built-in local GGUF synthesis without Ollama:

uv tool install "sempropos[local-llm]"   # or install llama-server on PATH
sem model install balanced               # downloads Qwen2.5-Coder-1.5B (~1 GB) & activates it

📖 Usage

1. Command Synthesis (ask / bare query)

sem "find files larger than 100MB"
sem -e "delete files older than 30 days"      # includes flag-by-flag breakdown + safety warning
sem -t tar "extract archive to /tmp"          # scope to a single tool
sem -n 3 "sync directory over ssh"            # request alternative commands
sem --porcelain "list open listening ports"   # raw command only (for scripts/widgets)
sem --json "show disk usage by folder"        # full machine-readable output

2. Instant Tool Reference Card (show — replaces man & --help)

sem show du                       # summary, usage, examples, top flags
sem show du --flags depth         # filter flags by keyword
sem show git commit               # inspect a specific subcommand
sem show 7z --examples            # verified usage examples only
sem show tar --json               # export canonical ToolSpec JSON

3. Instant Tool Discovery (search — replaces apropos)

sem search "disk usage by folder"
sem search "listening tcp ports"
sem search "archive" --category archive --limit 15

4. Management & Diagnostics

sem doctor               # index health, parse coverage %, unindexed PATH bins, daemon, providers
sem update               # incremental content-hash refresh + prune uninstalled binaries
sem model list           # list curated GGUF tiers and local runtime status
sem model install tiny   # download & activate tiny 0.5B GGUF model
sem daemon status        # inspect warm background daemon (start|stop|restart|status)
sem config show          # view resolved config.toml (also: config get/set/wizard)
sem providers            # check availability of synthesis and embedding backends
sem init zsh             # print Ctrl+S integration + tab completions (zsh, bash, fish)

🐚 Shell Integration (Ctrl+S + Tab Completion)

Add one line to your shell startup file:

# ~/.zshrc
eval "$(sem init zsh)"

# ~/.bashrc
eval "$(sem init bash)"

# ~/.config/fish/config.fish
sem init fish | source

Type a plain-English task on your prompt and press Ctrl+S — the line is replaced in place with the generated command (never auto-executed). Tab completion also completes sem subcommands and indexed tool names for sem show <TAB>.

📁 Data & Configuration Layout

  • Config: ~/.config/sempropos/config.toml (overridable via SEMPROPOS_CONFIG_DIR; automatically reads legacy intelligence.toml)
  • Data: ~/.local/share/sempropos/ (overridable via SEMPROPOS_DATA_DIR)
    • index.db — SQLite v3 + Porter-stemmed FTS5
    • tool_embeddings.npy, tool_embedding_ids.npy — tool_id-keyed L2-normalized tool-card embeddings
    • index.meta, last_indexed — atomic revision and staleness markers
    • tldr/ — offline tldr-pages snapshot
    • models/ — downloaded local GGUF models
    • embeddings/ — pinned FastEmbed ONNX model cache
  • Runtime socket: $XDG_RUNTIME_DIR/sempropos/sem.sock (0600, auto-cleaned on idle shutdown)

🧪 Development & Testing

uv sync --group dev
make check-all          # ruff lint + format check + strict mypy + pytest (unit, integration, 37-query eval)

All default tests run 100% offline with zero API keys required.

📄 License

MIT License — see LICENSE.

Metadata

Release files for sempropos 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sempropos 1.0.1
File Size Uploaded Provenance Actions
sempropos-1.0.1.tar.gz 110.2 kB With provenance Details for sempropos-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sempropos 1.0.1
File Interpreter ABI Platform Actions
sempropos-1.0.1-py3-none-any.whl Python 3 none any Details for sempropos-1.0.1-py3-none-any.whl

Total release size: 237.2 kB

Release files / sempropos-1.0.1.tar.gz

Download URL sempropos-1.0.1.tar.gz
Size 110.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b63940d7cf452841c233e7fdb286e384798b5b41309156ddbe3ad58f48f0d93f
BLAKE2b-256 checksum
How to use checksums
0fd250d3060e90aff4488a0f30d9b95ddabfadad467099e5348c4a2185ab7c38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / sempropos-1.0.1-py3-none-any.whl

Download URL sempropos-1.0.1-py3-none-any.whl
Size 126.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a08614285ce0404cc812c53b0a960542c61c1812da8aee4f89b95ba595557dcb
BLAKE2b-256 checksum
How to use checksums
a3ba5d0508f37bf3d6d726d6903288df37f75ce0893baaef7057f8f1f3696fd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for sempropos 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sempropos-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page