Repository navigation
feat: 增加交互式模型连接与安全凭据管理 - #12
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
首次使用和添加服务商仍要求手工维护环境变量与模型 ID。本 PR 在原生 CLI 增加首次引导、--connect、/connect 和 /models,复用 any-llm 客户端工厂;自定义兼容 API 保存端点元数据,后续无需重复填写 URL。
行为与边界
TTY 且未指定 --prompt 的首次启动缺少模型/凭据时进入向导;非交互调用保持显式配置,缺失返回 2。--connect 只配置并退出。
支持八类常见 Provider、自定义端点、隐藏密钥输入和 SDK 模型目录;10 秒超时/不支持目录时可手动输入 ID。
原子保存 connections.json 中的模型、端点及环境变量名,拒绝密钥字段和 URL 内凭据;密钥仅使用环境、可选 OS vault 或当前进程内存。
credentials extra 使用 keyring 25.7.0,拒绝不安全第三方文件后端;无法持久保存时明确说明,不将密钥降级写到 JSON。
模型优先级 CLI > JSON > 环境 > 保存默认值;显式全局凭据/端点覆盖语义保留。切换关闭旧客户端、新建会话并保留 Skill,旧会话不删除。
Legacy 和非菜单的原生 SDK(例如本地免密 Provider)保留显式配置。Gemini 等 SDK 扩展需单独安装,菜单不代表完整远端验收。
验证
Windows / Python 3.12:278 个离线测试通过,3 live cases 排除;最终 CLI/连接配置针对性 48 项检查通过。
模拟 HTTP 验证 SDK GET /models、自定义路由与客户端关闭;测试覆盖隐藏输入、无明文密钥、优先级、取消、错误脱敏、TTY 守卫和模型切换。
Windows WinVaultKeyring 临时凭据读写/删除通过;无真实账号密钥。macOS/Linux 原生凭据库未实机验证,CI 使用隔离 fixture。
Ruff F / compileall / wheel + sdist / 无可选扩展的独立安装通过;包括 credentials 的锁定生产依赖审计无已知漏洞。
本 PR 不把旧 Anspire 验收冒充为新向导的真实多 Provider 验收;新增向导本轮使用确定性协议与存储验证。
原生四文件核心 531 行,运行机制 833 行,全部包 Python 5056 行;总源码精简目标仍未完成。keyring 不进入默认安装。
最新修复提交 62cd999 的 8 项 CI 全部通过(Windows/Linux × Python 3.11/3.12),包括项目原则校验、回归、静态检查、生产审计、构建和最小安装:
文档、风险与回滚
中英文 README、.env.example、docs/model-connections.md、CHANGELOG 已同步。端点目录可能不可用;凭据库不可用时重启需要环境变量或重新连接。连接配置并发为 last-writer-wins;应一次只运行一个配置向导。
本 PR base 为 codex/lean-06-cli-release(#11),按 #6 → … → #11 → 本 PR 合入。原有 PR 保持内容独立;不合并 main,不发 tag。
回滚本 PR 后使用环境/JSON、显式模型启动旧 CLI;保留连接元数据、系统凭据与会话文件。插件响应式生命周期和 Loop 替换在后续独立 PR 实现。
2026-10-15 复审修复与项目原则