Skip to content

feat(ai): secure LLM config with provider presets and api key protection#25

Merged
Ink-dark merged 4 commits into
mainfrom
feat/llm-config
Jun 21, 2026
Merged

feat(ai): secure LLM config with provider presets and api key protection#25
Ink-dark merged 4 commits into
mainfrom
feat/llm-config

Conversation

@Ink-dark

Copy link
Copy Markdown
Contributor

Summary

三层安全改进:

1. API key 持久化

  • 支持 ~/.agitconfig.toml(全局配置文件)存储 API key,配一次永久生效
  • 不从 .agit/config.toml 读取 api_key,防止密钥泄漏到仓库

2. 厂商预设

内置 6 家:openai / deepseek / anthropic / moonshot / zhipu / ollama
只需配置 provider = "deepseek",自动匹配 endpoint 和默认 model

3. init 安全守卫

agit init 始终创建 .gitignore,包含 .agit/ 防止配置目录被意外提交

配置方式

# ~/.agitconfig.toml — 推荐
[llm]
api_key = "sk-xxx"
provider = "deepseek"
# 环境变量 — 一次性
AGIT_LLM_API_KEY=sk-xxx AGIT_LLM_PROVIDER=deepseek agit commit --ai

安全

  • api_key 仅在 ~/.agitconfig.toml(全局)和 env 中读取
  • .agit/config.toml(仓库级)的 api_key 字段被忽略
  • init 自动将 .agit/ 写入 .gitignore

Ink-dark added 4 commits June 21, 2026 21:08
- Config: add [llm] section (api_key, provider, model)
- LLM: AGIT_LLM_PROVIDER preset table (openai/deepseek/anthropic/moonshot/zhipu/ollama)
- Priority: env var > repo .agit/config.toml > global ~/.agitconfig.toml > default
- LLM API: add 30s timeout, better error messages with config hints
- commit --ai: show detailed config guide when no API key set
- Config.llm, LlmConfig: #[allow(dead_code)]
- LLM_PROVIDERS, resolve_llm_provider: #[allow(dead_code)]
- Blob import + build_staged_summary: #[cfg(feature = "ai")]
@Ink-dark Ink-dark merged commit e45ab5e into main Jun 21, 2026
4 of 14 checks passed
@Ink-dark Ink-dark deleted the feat/llm-config branch June 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant