Python translation of OpenCode - AI-powered coding assistant
Project description
Hotaru Code
Hotaru Code 用于在终端中提供 AI 编码助手能力。
它支持 TUI、交互式 Chat 和一次性 Run 三种使用模式,并具备工具调用、权限控制、会话持久化、MCP 扩展等能力。
功能概览
- 多种交互方式
hotaru:默认进入 TUI(Textual)hotaru chat:交互式命令行聊天hotaru run "你的问题":一次性执行
- Agentic 工具调用循环
- LLM 输出可触发工具执行,结果会回注到上下文继续推理
- 内置工具
read、write、edit、bash、glob、grep、skill
- 细粒度权限系统
- 对
bash、edit、read等按规则allow/ask/deny - 支持“仅本次允许/始终允许/拒绝”交互
- 内置重复工具调用(doom loop)保护
- 对
- Provider 与模型抽象
- 支持 OpenAI、Anthropic 及 OpenAI-compatible 自定义服务
- 通过
provider/model选择模型
- MCP (Model Context Protocol)
- 支持本地(stdio)和远程(HTTP/SSE)MCP 服务
- MCP 工具会自动并入可调用工具列表
- Skill 系统
- 支持从
SKILL.md发现并加载领域技能
- 支持从
- 会话持久化
- 会话与消息写入本地 JSON 存储,可继续/切换历史会话
快速开始
1. 安装依赖
uv sync
2. 配置 API Key
至少配置一个可用 Provider 的密钥,例如:
# PowerShell
$env:OPENAI_API_KEY = "your-key"
# 或
$env:ANTHROPIC_API_KEY = "your-key"
3. 启动
# 默认进入 TUI
uv run hotaru
# 交互式 chat
uv run hotaru chat
# 一次性执行
uv run hotaru run "请分析这个仓库的结构"
常用命令
hotaru --help
hotaru --version
hotaru providers # 列出可用 provider 和模型
hotaru agents # 列出 agent
hotaru sessions -n 20 # 列出最近会话
hotaru config --show # 展示合并后的配置
hotaru config --path # 展示配置目录
run 子命令常用参数
hotaru run "修复 tests 失败" --model openai/gpt-4o-mini --agent build
hotaru run "总结这段日志" --json
hotaru run "重构这个函数" --yes
--model/-m:指定provider/model--agent/-a:指定 agent--session/-s/--continue/-c:继续会话--file/-f:附加文件--json:输出 JSON 事件流--yes/-y:自动通过权限请求
配置说明
Hotaru 会合并多来源配置(后者覆盖前者):
- 全局配置目录(
hotaru config --path可查看) - 项目目录向上查找的
hotaru.json/hotaru.jsonc .hotaru/hotaru.json/.hotaru/hotaru.jsonc- 环境变量
HOTARU_CONFIG_CONTENT - 托管配置目录(最高优先级)
最小 hotaru.json 示例
{
"model": "openai/gpt-4o-mini",
"default_agent": "build",
"provider": {
"openai": {
"options": {
"apiKey": "{env:OPENAI_API_KEY}"
}
}
},
"permission": {
"bash": "ask",
"edit": "ask",
"read": {
"*.env": "ask",
"*.env.example": "allow"
}
}
}
自定义 OpenAI-compatible Provider 示例
{
"provider": {
"my-provider": {
"type": "openai",
"name": "My Provider",
"options": {
"baseURL": "https://api.example.com/v1",
"apiKey": "{env:MY_PROVIDER_API_KEY}"
},
"models": {
"my-model": {
"name": "My Model"
}
}
}
}
}
MCP 示例(本地服务)
{
"mcp": {
"filesystem": {
"type": "local",
"command": [
"npx",
"-y",
"@modelcontextprotocol/server-filesystem",
"."
],
"enabled": true,
"timeout": 30
}
}
}
项目结构
src/hotaru/cli/:CLI 入口与命令实现src/hotaru/tui/:Textual TUIsrc/hotaru/session/:消息、会话、处理循环src/hotaru/tool/:内置工具与注册中心src/hotaru/provider/:Provider/模型抽象src/hotaru/mcp/:MCP 客户端与认证src/hotaru/permission/:权限规则与交互src/hotaru/skill/:Skill 发现与加载
开发
# 运行测试
uv run pytest tests
# 构建包
uv build
说明
- Python 版本要求:
>=3.12 - 包名:
hotaru-code - 命令行入口:
hotaru
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hotaru_code-0.1.0.tar.gz.
File metadata
- Download URL: hotaru_code-0.1.0.tar.gz
- Upload date:
- Size: 202.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae22d686b545f03f9a41f4a074b62eb07efa21d22342460cc85b3d97b5a11414
|
|
| MD5 |
a7f1e491514e6202518716c1aab0c641
|
|
| BLAKE2b-256 |
75bf48b9e2429bdd2de9c167ffccffc001e8245a4e3704dd601896efe2b14db2
|
Provenance
The following attestation bundles were made for hotaru_code-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on Tsukumi233/hotaru-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hotaru_code-0.1.0.tar.gz -
Subject digest:
ae22d686b545f03f9a41f4a074b62eb07efa21d22342460cc85b3d97b5a11414 - Sigstore transparency entry: 947294284
- Sigstore integration time:
-
Permalink:
Tsukumi233/hotaru-code@3a8a79e0bc21194470dfdee39923124e6b84dd6a -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Tsukumi233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3a8a79e0bc21194470dfdee39923124e6b84dd6a -
Trigger Event:
release
-
Statement type:
File details
Details for the file hotaru_code-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hotaru_code-0.1.0-py3-none-any.whl
- Upload date:
- Size: 197.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2faa8e6d470520f5267c1d6c34fec4808dcb4fc484353972e726bf08b262a3ca
|
|
| MD5 |
4881d5caa88d7ac731fd211b84e3f5c3
|
|
| BLAKE2b-256 |
efc44251a6da76474d37fc2c545eb3a75d1480972d2cd652e628e37ef764b5ac
|
Provenance
The following attestation bundles were made for hotaru_code-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on Tsukumi233/hotaru-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hotaru_code-0.1.0-py3-none-any.whl -
Subject digest:
2faa8e6d470520f5267c1d6c34fec4808dcb4fc484353972e726bf08b262a3ca - Sigstore transparency entry: 947294285
- Sigstore integration time:
-
Permalink:
Tsukumi233/hotaru-code@3a8a79e0bc21194470dfdee39923124e6b84dd6a -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Tsukumi233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3a8a79e0bc21194470dfdee39923124e6b84dd6a -
Trigger Event:
release
-
Statement type: