Crates.io | shlf |
lib.rs | shlf |
version | 0.8.2 |
source | src |
created_at | 2024-09-17 22:51:18.582343 |
updated_at | 2024-11-10 09:21:26.092301 |
description | AI-based command-line tools for developers |
homepage | |
repository | https://github.com/ab22593k/shelf |
max_upload_size | |
id | 1378417 |
size | 128,098 |
Shelf is a command-line tool for managing dotconf files and generating git commit messages using AI. It provides a simple interface to track dotfiles across your system and integrates with multiple AI providers to automatically generate meaningful commit messages through git hooks. With support for local and cloud-based AI models, Shelf makes both dotfile management and git commits effortless.
To install Shelf, you need to have Rust and Cargo installed on your system. If you don't have them, you can install them from rustup.rs.
Once you have Rust and Cargo installed, you can build and install Shelf using the following command:
cargo install --path .
Shelf provides commands for both dotfile management and git integration:
# Add a new dotfile to track
slf cp ~/.bashrc
# List all tracked dotfiles
slf ls
# Remove a dotfile from tracking
slf rm ~/.bashrc
# Interactive selection of dotfiles to track
slf suggest -i
# Show help
slf --help
Each command can be run with -h
or --help
for more information.
The gitai
subcommand provides AI-powered git commit message generation:
# Generate commit message for staged changes
slf gitai commit
# Install git hook for automatic message generation
slf gitai commit --install
# Remove git hook
slf gitai commit --uninstall
# Configure AI provider
slf gitai config set provider openai
slf gitai config set openai_api_key "your-api-key"
# Use specific provider for one commit
slf gitai commit -p openai
# List current configuration
slf gitai config list
The GitAI features support multiple AI providers:
The git hook integrates seamlessly with your normal git workflow:
# Hook will automatically generate message if none provided
git commit
# Your message takes precedence
git commit -m "feat: your message"
# AI helps with amending
git commit --amend
Shelf supports generating shell completion scripts for various shells. You can generate these scripts using the completion
subcommand:
# Generate completion script for Bash
slf completion bash > slf.bash
# Generate completion script for Zsh
slf completion zsh > _slf
# Generate completion script for Fish
slf completion fish > slf.fish
To use the completion scripts:
For Bash, add the following line to your ~/.bashrc
:
source /path/to/slf.bash
For Zsh, place the _slf
file in ~/.zfunc
, then add source ~/.zfunc/_slf
in ~/.zshrc
.
For Fish, place the slf.fish
file in ~/.config/fish/completions
.
After setting up the completion script, restart your shell or source the respective configuration file to enable completions for the slf
command.
GitAI settings are stored in ~/.config/shelf/gitai.json
(or $XDG_CONFIG_HOME/shelf/gitai.json
if set). You can configure:
provider
: AI provider to use (ollama
, openai
, anthropic
, gemini
)ollama_host
: Ollama server URL (default: http://localhost:11434
)ollama_model
: Ollama model to use (default: qwen2.5-coder
)openai_api_key
: OpenAI API key for GPT modelsproject_context
: Optional project-specific context for better commitsExample configuration:
{
"provider": "ollama",
"ollama_host": "http://localhost:11434",
"ollama_model": "qwen2.5-coder",
"project_context": "Rust CLI tool for dotfile management"
}
To build the project locally:
cargo build
To run tests:
cargo test
To run the project directly without installing:
cargo run -- [SUBCOMMAND]
Replace [SUBCOMMAND]
with the command you want to run, such as cp
, ls
, or rm
.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.