An AI-powdered CLI for your terminal and editor.
The goal of our project was to explore how a binary with access to LLM-powered capabilities could be used in the command line to recreate common features found across IDE's and other higher-level AI tools. In our case, we designed the API for such a binary by creating a neovim plugin with code-modification and chat capabilities.
This project consists of two components:
- A rust binary called
hackathon
- A neovim plugin under
lua/
- Install Rust: https://www.rust-lang.org/tools/install
- Set up model access in AWS Bedrock in a personal AWS account.
The binary is hardcoded to use the model
anthropic.claude-3-haiku-20240307-v1:0
in regionus-west-2
. - Set up credentials for calling Bedrock. This can be done with the following script which uses
ada
- seetoolbox install ada
:
#!/usr/bin/env sh
set -e
AWS_ACCOUNT=YOUR_AWS_ACCOUNT
ROLE="admin"
echo "Refreshing credentials for account ${AWS_ACCOUNT} with role ${ROLE}"
ada credentials update --account="${AWS_ACCOUNT}" --provider=isengard --role="${ROLE}" --once
- (optional) install neovim: https://github.com/neovim/neovim/blob/master/INSTALL.md Set this directory as a plugin in whatever plugin manager you use. Using Lazy:
{
dir = "~/workplace/hackathon",
opts = {},
}
See cargo run -- --help
for up-to-date options.
cat src/main.rs | cargo run -- code 'generate tests for this file'
h [options...]
is the user prompt
Reads the entirety of stdin until EOF, to use as context for the user prompt. Stdin is expected to be a code block, e.g. from a file.
options: -f, --file-context path to a file to use as context -p, --cursor-position where the user's cursor is positioned. Formatted as (row,col,[file_path]) -d, --directory-context path to a directory to use as context
output:
type CliOutput = {
type: 'chat',
message: string
} | {
type: 'code',
message: Array<{
language: string,
code: string,
file_path?: string
}>
};