A natural language shell interface for *nix systems

Overview

Orphic

A natural language shell interface for *nix systems.


Overview

Orphic is a CLI tool that uses GPT to translate complex tasks into shell commands to be executed on the system. It excels at tasks that are relatively straightforward but require complex and obscure commands to accomplish.

$ orphic delete all installers or tars from ~/Downloads that are more than a week old
find ~/Downloads -name '*.tar.*' -mtime +7 -delete; find ~/Downloads -name '*.dmg' -mtime +7 -delete
Execute? [Y/n] Y

Note: Orphic defaults to safe mode, and will not automatically execute commands without confirmation unless unsafe mode is specified.

Installation

  • Make sure your system has rust and cargo.
  • cargo install orphic
  • Orphic requires the OPENAI_API_KEY environment variable to be set. You can generate one here.

Usage

Orphic is designed to be used like you would use any other CLI tool.

$ orphic sort ~/Downloads into folders based on media type

$ orphic how strong is my network connection

$ orphic what version kernel am i running

$ orphic show me the name and size of all files larger than 8MB in ~/Downloads/

$ orphic <do task that would otherwise require complex commands that you don't know off the top of your head>

-u or --unsafe will execute commands without user verification.

-4 or --gpt4 will attempt to use GPT-4 instead of GPT-3.5-Turbo. Note that this will only work if your OpenAI account has access to the model.

-i or --interpret will describe the output of the task in natural language (note that this is generally very slow).

$ orphic -u -i how much disk space is available
You have 16GB available out of a total of 113GB on your main hard 
drive, which is mounted on the root directory. 
Other partitions and file systems are also listed with their 
respective usage percentages and mount points.

-d or --debug will display the raw GPT text along with the regular output, even in unsafe mode.

$ orphic -u -d count the lines of rust code in this directory excluding /target/.
{"command": "find . -name target -prune -o -name '*.rs' -type f -print0 | xargs -0 wc -l"}
61 ./src/prompts.rs
     219 ./src/main.rs
     280 total

-r or --repl will start Orphic in a REPL environment.

$ orphic -u -r
orphic> when did i last login
wtmp begins Sat Mar 18 14:55
orphic> quit
$

Usage tips and observations

Sometimes Orphic works. Sometimes it doesn't. GPT is inconsistent, and the prompts that I'm using leave a lot to be desired. Results seem to be better if you format your task as a command instead of a question ("list the currently open ports" instead of "what ports are currently open"). An error that often arises is that GPT will try to use commands or packages for a different OS/distribution, or will try to use tools that you don't currently have installed. A quick fix is to specify your OS if you think the task will require OS-specific tools, but I'm working on making Orphic more aware of which commands are at its disposal and which are not.

Contributing

Pull requests welcome. If you use Orphic and get a good/interesting output, please send it to me. Likewise, if you get a really bad output, please also send it to me or open an issue. This system is very experimental and I'm still trying to figure out what works and what doesn't when it comes to prompts and configurations.

License

MIT

Copyright (c) Will Savage, 2023

Comments
  • Error while parsing string

    Error while parsing string

    orphic how much space is free on the boot volume
    EOF while parsing a string at line 1 column 43
    {"command": "df -h / | awk 'NR==2{print $4}'"}
    

    The actual command df -h / | awk 'NR==2{print $4}' itself works fine when you copy and paste it on the commandline. This is for orphic 0.1.0. I'm running on PopOS 22.04 an Ubuntu derivative. My rustc is at 1.68.0. I installed via cargo install orphic

    Update. Another example of this:

    orphic show me the name and size of all files larger than one gigabyte in my home directory
    EOF while parsing a string at line 1 column 81
    EOF while parsing a string at line 1 column 81
    {"command": "find ~/ -type f -size +1G -printf '{\"name\":\"%f\",\"size\":\"%s\"}\\n'" }
    
    opened by johnblommers 4
  • Allow users to use GPT-4 if they have access to it.

    Allow users to use GPT-4 if they have access to it.

    Hey! I created a PR that will allow setting the model to GPT-4 by setting the env var ORPHIC_USE_GPT4 to true!

    This was a fairly straightforward process, and seems to work well.

    opened by JoeyEamigh 3
  • cd command does not work.

    cd command does not work.

    Executing this command orphic locate into test directory Returns command cd test and when I execute this through orphic it won't take me to the directory.

    opened by ScripterSugar 2
  • stream output of long-running command execution to stdout?

    stream output of long-running command execution to stdout?

    Hi. I'm trying orphic on mac machine with zsh.

    When I execute long-running command like "top", the program simply stucks after confirmation, and I have to abort manually and execute command on my own.

    It'd be nice if we can use these types of commands seamlessly :)

    opened by ScripterSugar 2
  • Error when passing API key

    Error when passing API key

    Ive tried to pass orphic the API key with $OPENAI_API_KEY envoirment variable but it thinks i didnt provide any keys (its a variable in the bash shell which is the shell i use in my terminal if it isnt the right way to do it then show me please)

    opened by Merhaba2232 2
  • Allow users to view the command and approve or reject it before it runs

    Allow users to view the command and approve or reject it before it runs

    This would allow for greater peace of mind before running a command, and allow users to not run a command if it seems dangerous.

    I may open a PR to do this myself if I have time in the future.

    opened by JoeyEamigh 2
  • v0.1.1 - Add safemode as default with option for unsafe execution + GPT-4 flag

    v0.1.1 - Add safemode as default with option for unsafe execution + GPT-4 flag

    Orphic will now default to safemode, which shows the user the command to be executed and allows them to choose whether or not to execute. The -u flag can be used to bypass this. Also added --gpt4 flag to allow users with access to GPT-4 to use it over 3.5.

    opened by ws-kj 0
  • Fix serialization error for commands containing braces

    Fix serialization error for commands containing braces

    try_extract terminated the command string at the first } instead of the last }. Switched from .find to .rfind to fix this. Also added another README example and fixed some formatting.

    opened by ws-kj 0
Owner
Will Savage
https://ws-kj.github.io/
Will Savage
nl-sh: Natural Language Shell

The Natural Language Shell integrates GPT4 or local GGUF-formatted models directly into the terminal experience, allowing operators to describe their tasks in either POSIX commands or fluent human language

Mike Cvet 30 Mar 12, 2024
Progress In Nix - Pacman inspired frontend for Nix

Progress In Nix Pinix is a Pacman inspired frontend for Nix. It wraps a regular Nix command and replaces the output with a more modern and informative

Rémi Dupré 23 Mar 9, 2024
Dog command for *nix systems, Rust port of dog.

dog-rs Dog command for *nix systems, Rust port of dog. Because there is a cat command, should be a dog command too. It was written completely using VS

Juanjo Salvador 2 Sep 29, 2021
A flexible simple theme manager for *nix systems

tema A theme manager for *nix systems respecting the FHS spec configuration As of now all the configuration is done via $XDG_CONFIG_HOME/tema/config.y

lb06 2 Sep 23, 2022
rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and much more.

rpsc rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and mu

null 3 Dec 15, 2022
🦞 Rust library of natural language dictionaries using character-wise double-array tries.

?? Crawdad: ChaRActer-Wise Double-Array Dictionary Overview Crawdad is a library of natural language dictionaries using character-wise double-array tr

null 18 Dec 15, 2022
A command line interface meant to bridge the gap between Rust and shell scripting

clawbang A command line interface meant to bridge the gap between Rust and shell scripting. Intended for use with HEREDOCs and shebangs: $ clawbang <<

Chris Dickinson 52 Mar 25, 2022
The Amp programming language: a language designed for building high performance systems.

A language designed for building high performance systems. Platform Support x86_64-pc-windows ✅ x86_64-unknown-linux ⚠️ untested x86_64-unknown-darwin

The Amp Programming Language 5 Mar 17, 2023
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Stream-based visual programming language for systems observability

Stream-based visual programming language for systems observability. Metalens allows to build observability programs in a reactive and visual way. On L

Nikita Baksalyar 53 Dec 23, 2022
🛠️ An experimental functional systems programming language, written in Rust and powered by LLVM as a backend.

An experimental functional systems programming language, written in Rust, and powered by LLVM as a backend. ?? Goal: The intent is to create a program

codex 3 Nov 15, 2023
A simple gtk4/libadwaita software center to easily install and manage nix packages

Nix Software Center A graphical app store for Nix built with libadwaita, GTK4, and Relm4. Heavily inspired by GNOME Software. Features Install package

Victor Fuentes 169 Dec 30, 2022
Generate Nix packages from URLs

Generate Nix packages from URLs with hash prefetching, dependency inference, license detection, and more

Nix community projects 130 Feb 5, 2023
Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed.

nixseparatedebuginfod Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed

Guillaume Girol 16 Mar 6, 2023
A Nix template for full-stack web apps in Rust using Leptos

leptos-fullstack A Nix template for full-stack web apps in Rust using Leptos. Tech used: Leptos full-stack framework server functions ssr + hydration

Sridhar Ratnakumar 6 Aug 4, 2023
nix2sbom extracts the SBOM (Software Bill of Materials) from a Nix derivation

nix2sbom nix2sbom extracts the SBOM (Software Bill of Materials) from a Nix derivation ?? Documentation for using nix2sbom is here Warning This repo i

null 6 Aug 30, 2023
The official CLI for FlakeHub: search for flakes, and add new inputs to your Nix flake.

fh, the official FlakeHub CLI fh is a scrappy CLI for searching FlakeHub and adding new inputs to your Nix flakes. Usage Using fh from FlakeHub: nix s

Determinate Systems 35 Oct 11, 2023
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Alexandre Bury 3.3k Jan 9, 2023
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Alexandre Bury 3.3k Jan 3, 2023