{"id":13643834,"url":"https://github.com/builderio/ai-shell","last_synced_at":"2025-05-14T04:10:17.919Z","repository":{"id":151355077,"uuid":"624091446","full_name":"BuilderIO/ai-shell","owner":"BuilderIO","description":"A CLI that converts natural language to shell commands.","archived":false,"fork":false,"pushed_at":"2024-10-22T19:26:35.000Z","size":249,"stargazers_count":4720,"open_issues_count":49,"forks_count":324,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-04-24T01:52:40.601Z","etag":null,"topics":["ai"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BuilderIO.png","metadata":{"files":{"readme":"README-zh-Hans.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-05T18:17:07.000Z","updated_at":"2025-04-23T19:23:42.000Z","dependencies_parsed_at":"2024-01-06T21:51:20.720Z","dependency_job_id":"54e8856d-db85-4c44-8d10-08ea2c401f70","html_url":"https://github.com/BuilderIO/ai-shell","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuilderIO%2Fai-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuilderIO%2Fai-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuilderIO%2Fai-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuilderIO%2Fai-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BuilderIO","download_url":"https://codeload.github.com/BuilderIO/ai-shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254070112,"owners_count":22009559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai"],"created_at":"2024-08-02T01:01:53.390Z","updated_at":"2025-05-14T04:10:12.902Z","avatar_url":"https://github.com/BuilderIO.png","language":"TypeScript","funding_links":[],"categories":["CLIs"],"sub_categories":[],"readme":"\u003ch2 align=\"center\"\u003e\n   \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fb5b9997cec2c4fffb3e5c5e9bb4fed7d\"\u003e\n      \u003cimg width=\"300\" alt=\"AI Shell logo\" src=\"[https://user-images.githubusercontent.com/844291/230786555-a58479e4-75f3-4222-a6eb-74c5af953eac.png](https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fb7f9d2d9911a4199a9d26f8ba210b3f8)\"\u003e\n    \u003c/picture\u003e\n\u003c/h2\u003e\n\n\u003ch4 align=\"center\"\u003e\n   一个将自然语言转换为 Shell 命令的 CLI。\n\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://www.npmjs.com/package/@builder.io/ai-shell\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@builder.io/ai-shell\" alt=\"Current version\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003cimg alt=\"Gif Demo\" src=\"https://user-images.githubusercontent.com/844291/230413167-773845e7-4c9f-44a5-909c-02802b5e49f6.gif\" \u003e\n\u003cp\u003e\n\n\u003cp align=\"center\"\u003e\n   受 \u003ca href=\"https://githubnext.com/projects/copilot-cli\"\u003eGitHub Copilot X CLI\u003c/a\u003e 启发, 但是面向所有人开源.\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n# AI Shell\n\n## 安装\n\n\u003e 最低支持的 Node.js 版本是 v14\n\n1. 安装 _ai shell_:\n\n   ```sh\n   npm install -g @builder.io/ai-shell\n   ```\n\n2. 从 [OpenAI](https://platform.openai.com/account/api-keys) 获取您的 API 密钥\n\n   \u003e 注意：如果您还没有创建帐户并设置计费方式，您需要先进行这些步骤。\n\n3. 设置密钥以便 ai-shell 可以使用它：\n\n   ```sh\n   ai config set OPENAI_KEY=\u003cyour token\u003e\n   ```\n\n   这将在您的主目录中创建一个名为 `.ai-shell` 的文件。\n\n## 使用\n\n```bash\nai \u003cprompt\u003e\n```\n\n例如：\n\n```bash\nai 查找所有.log文件\n```\n\n然后您将会得到如下输出，您可以选择运行建议的命令、通过提示修改命令或者取消：\n\n```bash\n◇  您的脚本:\n│\n│  find . -name \"*.log\"\n│\n◇  解释:\n│\n│  这个脚本的步骤如下：\n│  1. 在当前目录下搜索所有后缀为\".log\"的文件。\n│  2. 输出所有找到的文件的路径。\n│\n◆  运行这个脚本?\n│  ● ✅ 是 (开始运行吧！)\n│  ○ 📝 修改\n│  ○ ❌ 取消\n└\n```\n\n### 特殊字符\n\n请注意，某些 shell 会处理某些特殊字符，如 `?` 或 `*` 或看起来像是文件路径的字符。如果您遇到奇怪的行为，可以将提示符用引号括起来以避免问题，例如下面的示例：\n\n```bash\nai '我的 IP 地址是什么？'\n```\n\n### 聊天模式\n\n![Chat demo](https://user-images.githubusercontent.com/844291/232889699-e13fb3fe-1659-4583-80ee-6c58d1bcbd06.gif)\n\n```bash\nai chat\n```\n\n通过此模式，您可以直接通过 CLI 与 AI 进行对话，并以自然、对话式的方式获得有用的响应：\n\n```sh\n┌  开始新的对话\n│\n◇  您:\n│  在 Express 中如何进行重定向服务？\n│\n◇  AI Shell:\n\n在 Express 中，您可以使用 `redirect()` 方法来进行重定向服务。`redirect()` 方法接受一个参数，即您要重定向到的 URL。\n\n以下是一个示例：\n\n\\`\\`\\`js\napp.get('/oldurl', (req, res) =\u003e {\n  res.redirect('/newurl');\n});\n\\`\\`\\`\n```\n\n### 静默模式（跳过解释）\n\n您可以使用 `-s` 或 `--silent` 标志来禁用和跳过解释部分。\n\n```bash\nai -s 列出所有日志文件\n```\n\n或者使用以下命令将选项保存为首选项：\n\n```bash\nai config set SILENT_MODE=true\n```\n\n### 自定义 API 端点\n\n您可以自定义 OpenAI API 端点以设置 OPENAI_API_ENDPOINT（默认值为 `https://api.openai.com/v1`）。\n\n```sh\nai config set OPENAI_API_ENDPOINT=\u003cyour proxy endpoint\u003e\n```\n\n### 设置语言\n\n![Language UI](https://user-images.githubusercontent.com/1784873/235330029-0a3b394c-d797-41d6-8717-9a6b487f1ae8.gif)\n\nAI Shell 的默认语言是英文，但您也可以参考下列语言对应的键，来设置您需要的语言界面：\n\n| 语言       | 键值    |\n| ---------- | ------- |\n| English    | en      |\n| 简体中文   | zh-Hans |\n| 繁体中文   | zh-Hant |\n| Español    | es      |\n| 日本語     | jp      |\n| 한국어     | ko      |\n| Français   | fr      |\n| Deutsch    | de      |\n| Русский    | ru      |\n| Українська | uk      |\n| Tiếng Việt | vi      |\n| العربية    | ar      |\n| Português  | pt      |\n\n例如，您要将语言设置为简体中文，可以在设置 LANGUAGE 的值为 zh-Hans:\n\n```sh\nai config set LANGUAGE=zh-Hans\n```\n\n这样您的语言就设置为了简体中文\n\n### 配置界面\n\n如果要使用更可视化的界面查看和设置配置选项，可以键入：\n\n```bash\nai config\n```\n\n要获取如下所示的交互式 UI：\n\n```bash\n◆  Set config:\n│  ○ OpenAI Key\n│  ○ OpenAI API Endpoint\n│  ○ Silent Mode\n│  ● Model (gpt-4o-mini)\n│  ○ Language\n│  ○ Cancel\n└\n```\n\n### 升级\n\n使用以下命令检查已安装的版本：\n\n```bash\nai --version\n```\n\n如果它不是[最新版本](https://github.com/BuilderIO/ai-shell/tags)，请运行：\n\n```bash\nnpm update -g @builder.io/ai-shell\n```\n\n或者只需使用 AI shell：\n\n```bash\nai update\n```\n\n## 常见问题\n\n### 429 错误\n\n一些用户报告了来自 OpenAI 的 429 错误。这是由于错误的计费设置或过度使用配额所致。请按照[此指南](https://help.openai.com/en/articles/6891831-error-code-429-you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)进行修复。\n\n您可以在[此链接](https://platform.openai.com/account/billing/overview)上激活计费。如果没有获得 OpenAI 的活动赠款，请确保添加支付方式。\n\n## 动机\n\n我不是一个 bash 巫师，迫切需要访问 copilot CLI，但我已经等不急了。\n\n## 贡献\n\n如果您想在 [Issues](https://github.com/BuilderIO/ai-shell/issues) 中修复错误或实现功能（提示：注意 `help wanted` 标签），请查看 [Contribution Guide](CONTRIBUTING.md) 以了解如何设置项目。\n\n## 致谢\n\n- 感谢 GitHub Copilot 提供的惊人工具和这个想法\n- 感谢 Hassan 和他在 [aicommits](https://github.com/Nutlope/aicommits) 上的工作，这启发了工作流程和部分代码和流程。\n\n## 社区\n\n欢迎加入 [Builder.io Discord](https://discord.gg/EMx6e58xnw) 并在 #ai-shell 房间与我们聊天。\n\n\u003cbr\u003e\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://www.builder.io/m/developers\"\u003e\n      \u003cpicture\u003e\n         \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/844291/230786554-eb225eeb-2f6b-4286-b8c2-535b1131744a.png\"\u003e\n         \u003cimg width=\"250\" alt=\"Made with love by Builder.io\" src=\"https://user-images.githubusercontent.com/844291/230786555-a58479e4-75f3-4222-a6eb-74c5af953eac.png\"\u003e\n       \u003c/picture\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuilderio%2Fai-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuilderio%2Fai-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuilderio%2Fai-shell/lists"}