Introducing humanscript
humanscript is an innovative scripting language designed to simplify and naturalize the way we interact with computers. At its core, humanscript is a script interpreter that uses large language models (LLMs) to understand and execute commands written in natural language. This unique approach allows users to write human-readable commands that are interpreted into executable code on the fly, with no predefined syntax required.
What Makes humanscript Special?
At the heart of humanscript is the "inferpreter"—a combination of inference and interpretation. It bridges the gap between natural language and machine-executable code by utilizing advanced LLMs. The inferpreter can work with a variety of LLM backends, including popular cloud-hosted models such as OpenAI's GPT-3.5 and GPT-4, as well as locally running open-source models like Llama 2.
Understanding humanscript Through an Example
Consider a humanscript called tidy-screenshots
. This script automates the organization of screenshots into directories based on their capture month. Here's how simple the script looks:
#!/usr/bin/env humanscript
loop over all files (ignoring directories) in $HOME/Screenshots
move each file into a subdirectory in the format year-month
while the task is running show an ascii loading spinner
show how many files where moved
show the size of each subdirectory
When executed, this script moves files as specified and provides real-time feedback on task progress. Here's a glimpse of its execution:
$ ./tidy-screenshots
Moved 593 files.
364K 2023-08
2.3M 2023-02
Behind the scenes, the inferpreter translates these intuitive commands into bash script code, executing tasks efficiently and providing immediate results.
How to Get Started with humanscript
There are several ways to install and use humanscript:
- Via Docker: To run it in a sandboxed environment, use:
docker run -it lukechilds/humanscript
- Native Installation: You can also install it on your system using Homebrew:
brew install lukechilds/tap/humanscript
- Manual Installation: Clone the repository and include
humanscript
in your PATH.
Writing and Executing a humanscript
humanscript is pre-configured to work with OpenAI's GPT-4 model. To start writing your own scripts, you need to set up your API key:
mkdir -p ~/.humanscript/
echo 'HUMANSCRIPT_API_KEY="<your-openai-api-key>"' >> ~/.humanscript/config
Create and execute a simple script:
echo '#!/usr/bin/env humanscript
print an ascii art human' > asciiman
chmod +x asciiman
Execute it:
./asciiman
O
/|\
/ \
Configuration Options
humanscript allows for customization via environment variables set globally in ~/.humanscript/config
or per script:
HUMANSCRIPT_API
: Endpoint for the LLM API.HUMANSCRIPT_API_KEY
: Your API key for OpenAI (if applicable).HUMANSCRIPT_MODEL
: Choose the inference model.HUMANSCRIPT_EXECUTE
: Decide whether to auto-execute the generated code.HUMANSCRIPT_REGENERATE
: Decide if the script should regenerate previously cached outputs for varied results.
humanscript is an exciting step towards making programming more accessible and intuitive by letting users write commands in their natural language. With its flexibility and ease of use, it’s a tool that bridges the gap between human thought and computational logic seamlessly.