{"id":34864449,"url":"https://github.com/pythonzm/libra","last_synced_at":"2026-05-22T22:33:13.050Z","repository":{"id":288568407,"uuid":"964319630","full_name":"pythonzm/libra","owner":"pythonzm","description":"命令行下的AI助理","archived":false,"fork":false,"pushed_at":"2025-04-18T09:46:27.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T22:30:40.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pythonzm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null}},"created_at":"2025-04-11T03:04:57.000Z","updated_at":"2025-04-18T09:46:31.000Z","dependencies_parsed_at":"2025-04-21T07:02:41.407Z","dependency_job_id":null,"html_url":"https://github.com/pythonzm/libra","commit_stats":null,"previous_names":["pythonzm/libra"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pythonzm/libra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonzm%2Flibra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonzm%2Flibra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonzm%2Flibra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonzm%2Flibra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pythonzm","download_url":"https://codeload.github.com/pythonzm/libra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonzm%2Flibra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33374207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-22T21:56:13.512Z","status":"ssl_error","status_checked_at":"2026-05-22T21:56:10.769Z","response_time":265,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-12-25T21:59:00.781Z","updated_at":"2026-05-22T22:33:13.045Z","avatar_url":"https://github.com/pythonzm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libra\n\n命令行下的AI助理\n\n## 安装\n\n在 [release](https://github.com/pythonzm/libra/releases) 页最新版本，找到适合自己机器的安装包下载即可\n\n### 要求\n\n本工具使用 [GitHub Models](https://docs.github.com/en/github-models) 编写，需要提前准备GitHub Token，至少要拥有 ` models:read` 权限\n\n配置 `GitHub Token` \n\n```bash\n# 可以通过环境变量\n$ export LIBRA_GITHUB_TOKEN=xxxxxx\n\n# 也可以先生成配置文件，在配置文件中修改\n$ ./libra i\n配置已成功写入文件: /home/zm/.libra.conf\n\n# 也可以通过命令行参数指定\n$ ./libra -g xxxxxxxxxx\n```\n\n## 使用\n\n[![asciicast](https://asciinema.org/a/716947.svg)](https://asciinema.org/a/716947)\n\n### 示例\n\n#### 查看帮助信息\n\n```bash\n$ ./libra h\nNAME:\n   libra - A AI helper for CLI\n\nUSAGE:\n   libra [global options] command [command options]\n\nVERSION:\n   1.3\n\nCOMMANDS:\n   init, i  生成配置文件\n   exec, e  将AI回答的答案存储至脚本文件用于执行\n   help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --config value, -c value                      指定配置文件路径 (default: \"/home/zm/.libra.conf\")\n   --github-token value, -g value                指定github token (default: \"YOUR_GITHUB_TOKEN\")\n   --apiurl value, -u value                      指定api地址，一般情况下默认即可 (default: \"https://models.github.ai/inference/chat/completions\")\n   --req-timeout value, -t value                 设置请求超时时间 (default: \"20s\")\n   --idle-timeout value, -T value, --idle value  设置空闲超时时间 (default: \"5m0s\")\n   --model value, -m value                       指定模型，更多可用模型：https://github.com/marketplace?type=models (default: \"openai/gpt-4o-mini\")\n   --chat-path value, -C value                   指定对话内容存储路径 (default: \"/home/zm/libra_data/chats\")\n   --prompt value, -p value                      指定自定义prompt\n   --help, -h                                    show help\n   --version, -v                                 print the version\n```\n\n#### 生成配置文件\n\n```bash\n$ ./libra i\n配置已成功写入文件: /home/zm/.libra.conf\n```\n\n#### 咨询问题\n\n```bash\n$ ./libra\n2025/04/18 10:44:58 common.go:26: 警告: 解析配置文件 '~/.libra.conf' 失败: 配置文件 '~/.libra.conf' 不存在，将使用环境变量/参数/默认值\n命令行助手已开启. 输入 'q', 'quit' 或者 'exit' 退出.\n\u003e\u003e\u003e 查看当前占用内存最多的5个进程\nps aux --sort=-%mem | head -n 6\n\u003e\u003e\u003e 占用CPU最多的5个进程\nps aux --sort=-%cpu | head -n 6\n\u003e\u003e\u003e q\n$ \n```\n\n#### 执行脚本\n\n```bash\n$ ./libra e\n2025/04/18 10:45:48 common.go:26: 警告: 解析配置文件 '~/.libra.conf' 失败: 配置文件 '~/.libra.conf' 不存在，将使用环境变量/参数/默认值\n命令行助手已开启. 输入 'q', 'quit' 或 'exit' 退出.\n\u003e\u003e\u003e \n\u003e\u003e\u003e 查看当前占用内存最多的5个进程\n#!/bin/bash\nps aux --sort=-%mem | head -n 6\n\u003e\u003e\u003e 是否执行脚本内容【y/n/q】 y\n2025/04/18 10:46:08 platform.go:57: 开始运行 Shell (bash) 脚本: /home/zm/libra_data/scripts/2025-04-18/chatcmpl-BNW1uKrAzEtZ9jR04hkqa0Tx2SkyN_104605.sh\n2025/04/18 10:46:08 platform.go:70: Shell (bash) 脚本成功执行。\n--- 输出 ---\nUSER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\nzm        978232  1.3  6.6 76324004 530088 pts/0 Sl+  Apr17  12:53 /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/node --dns-result-order=ipv4first /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/out/bootstrap-fork --type=extensionHost --transformURIs --useHostProxy=true\nzm        978496  0.0  2.3 3152468 189852 pts/0  Sl+  Apr17   0:20 /home/zm/go/bin/gopls -mode=stdio\nzm           351  0.0  1.4 11822156 114216 pts/0 Sl+  Apr14   3:05 /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/node /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/out/server-main.js --host=127.0.0.1 --port=0 --connection-token=2117758677-4276087677-485001766-151388202 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all\nzm        978307  0.0  1.0 1025256 84892 pts/0   Sl+  Apr17   0:02 /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/node /home/zm/.vscode-server/extensions/github.vscode-github-actions-0.27.1/dist/server-node.js --node-ipc --clientProcessId=978232\nzm           458  0.1  0.9 11620172 78420 pts/0  Sl+  Apr14   5:57 /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/node /home/zm/.vscode-server/bin/4949701c880d4bdb949e3c0e6b400288da7f474b/out/bootstrap-fork --type=ptyHost --logsPath /home/zm/.vscode-server/data/logs/20250414T100659\n\n----------\n\u003e\u003e\u003e q\n```\n\n#### 其他用途\n\n```bash\n$ ./libra -p \"你是一名出色的解梦大师，精通各种梦境解读\"\n2025/04/18 10:50:31 common.go:26: 警告: 解析配置文件 '~/.libra.conf' 失败: 配置文件 '~/.libra.conf' 不存在，将使用环境变量/参数/默认值\n命令行助手已开启. 输入 'q', 'quit' 或者 'exit' 退出.\n\u003e\u003e\u003e \n\u003e\u003e\u003e 梦到牙齿掉落\n梦见牙齿掉落是一种比较常见的梦境，通常被认为与个人的焦虑、烦恼或压力有关。不同文化对这个梦的解释可能存在差异，但以下是一些普遍的解读：\n\n1. **失去和不安**：梦到牙齿掉落可能象征着对失去的恐惧，或者对自我形象的担忧。这种梦境常常出现在生活中面临重大变化或压力时。\n\n2. **沟通问题**：牙齿在梦中也可能代表表达能力，掉落的牙齿可能意味着你在表达自己方面感到无能或困惑。\n\n3. **衰老和时间流逝**：牙齿掉落也可能象征对衰老的焦虑，或对时间流逝的敏感。\n\n4. **生活变化**：这种梦也可能预示着即将发生的一些重要变化，无论是积极的还是消极的。\n\n为了更深入解读，可以结合你最近的生活状态、情绪和心理压力。如果最近经历了一些重大事件或变化，这可能帮助你更好地理解这个梦的含义。\n\u003e\u003e\u003e q\n$ \n```\n\n## 注意\n\n既然AI接口可以免费使用，那肯定是有限制的，具体哪个模型有多少限制，可查看官方文档：[https://docs.github.com/en/github-models/prototyping-with-ai-models#rate-limits](https://docs.github.com/en/github-models/prototyping-with-ai-models#rate-limits)\n\n对于个人使用个人认为完全够用，一个模型达到限制之后继续换另一个模型就好了\n\n最新的接口地址已更新为：https://models.github.ai/inference/chat/completions，国内访问有时候可能会超时，可以使用原来的接口地址：https://models.inference.ai.azure.com/chat/completions，这个地址国内访问目前比较稳定，但是需要修改模型名称，比如 `openai/gpt-4o-mini` 要换成 `gpt-4o-mini` \n\n## License\n[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonzm%2Flibra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpythonzm%2Flibra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonzm%2Flibra/lists"}