Magic CLI是一个命令行实用程序,它使用LLMS帮助您更有效地使用命令行,灵感来自Amazon Q(Prov。FIG终端)和CLI的GitHub Copilot等项目。
magic-cli relies on the orch library for LLM interactions (execution, orchestration, model alignment, etc.).
阅读公告博客文章。
警告
该项目仍处于早期发展。
期望破坏变化和错误,请报告您遇到的任何问题。
谢谢你!
笔记
有关如何安装魔术CLI的更多选项,请参见“版本”页面以获取您要安装的版本。
curl -LsSf https://github.com/guywaldman/magic-cli/releases/download/0.0.6/magic-cli-installer.sh | shbrew install guywaldman/tap/magic-clipowershell - c " irm https://github.com/guywaldman/magic-cli/releases/download/0.0.6/magic-cli-installer.ps1 | iex "有关平台的二进制文件,请参见发布页面。
Add functions to your ~/.bashrc or ~/.zshrc to make formatting the prompts in the terminal easier (not requiring quotes).
例如:
function mcs {
model_prompt= " $* "
magic-cli suggest " $model_prompt "
}
function mcf {
model_prompt= " $* "
magic-cli search " $model_prompt "
}
function mca {
model_prompt= " $* "
magic-cli ask " $model_prompt "
}提供提示,以获取命令运行的建议。
这在您大约知道想要的东西(甚至工具)的情况下很有用,但不记得确切的论点或订单。
This is especially useful with CLI tools like ffmpeg or kubectl .

magic-cli suggest " Resize test_image.png to 300x300 with ffmpeg " Usage: magic-cli suggest <PROMPT>
Arguments:
<PROMPT> The prompt to suggest a command for (e.g., "Resize image to 300x300 with ffmpeg")
在您的外壳历史记录中搜索命令,并获取最佳结果列表。

magic-cli search " zellij attach " Usage: magic-cli search [OPTIONS] <PROMPT>
Arguments:
<PROMPT> The prompt to search for
重要的
明智的话:如果您使用非本地LLM,请警惕嵌入的成本,尤其是对于长外壳历史。
提供您希望该模型执行的任务的提示,并观看它尝试建议运行以实现目标的命令。如果需要更多上下文,它可能会促使您沿途运行命令。
magic-cli ask " Set up the dev environment as described in the README " Usage: magic-cli ask <PROMPT>
Arguments:
<PROMPT> The prompt to ask for (e.g., "Set up the development environment")
Magic CLI支持两个LLM提供商:
ollama : Ollama is a local LLM provider.该命令期望在本地计算机上安装并运行Ollama。openai : OpenAI is a cloud LLM provider.您可以配置API令牌,而Magic CLI将其与OpenAI API一起使用。 Magic CLI stores configurations in ~/.config/magic_cli/config.json .
Use magic-cli config (to see the options, use magic-cli config --help ) to set the configuration options:
Usage: magic-cli config <COMMAND>
Commands:
set Set a value
get Get a value
list List the configurations
reset Reset the configurations to the default values
path Get the path to the configuration file
当前的提倡配置选项是:
llm : The LLM to use for generating responses.支持的价值:“ Ollama”,“ Openai”ollama.base_url : The base URL of the Ollama API (default: "http://localhost:11434")ollama.embedding_model : The model to use for generating embeddings (default: "nomic-embed-text:latest")ollama.model : The model to use for generating responses (default: "codestral:latest")openai.api_key (secret): The API key for the OpenAI APIopenai.embedding_model : The model to use for generating embeddings (default: "text-embedding-ada-002")openai.model : The model to use for generating responses (default: "gpt-4o")suggest.add_to_history : Whether to add the suggested command to the shell history (default: false)suggest.mode : The mode to use for suggesting commands.支持的值:“剪贴板”(复制命令到剪贴板),“不安全执行”(在当前的shell会话中执行)(默认值:“ UNSFAFE-SEXECTION”)Note:
unsafe-executionis named as such to make it clear that the CLI executes the command in the current shell session.使用此模式时,请非常小心 - 魔术CLI对执行建议的命令不承担任何责任。
Windows支持(支持PowerShell,但尚未正确测试Windows)
支持更多的LLM提供商(例如,人为)
改善局部嵌入索引(目前以JSON的态度存储起来,请研究带有向量扩展的SQLLITE)
更多测试覆盖范围
安全受到认真对待,所有漏洞将以最大的谨慎和优先级处理。
在存储的数据方面,魔术CLI当前处理的敏感数据是:
~/.config/magic_cli ).有计划将此令牌存储在系统的安全密钥存储中,但尚未实施。
magic-cli search command, which are stored in the configuration within the user home directory ( ~/.config/magic_cli ) and are generated using the LLM provider of choice.请参阅Security.md,以获取更多信息以及有关如何报告潜在漏洞的说明。
欢迎捐款!
有关更多信息,请参见dragting.md。
我唯一的请求是,拉动请求遵循问题,以免由于缺乏背景或必要性而无法接受您的辛勤工作的情况。