Skip to content

feat: 新增 Bash CLI 基础框架与完整命令实现 (T3 + T5)#132

Merged
qin-ctx merged 6 commits intomainfrom
feat/bash_cli
Feb 11, 2026
Merged

feat: 新增 Bash CLI 基础框架与完整命令实现 (T3 + T5)#132
qin-ctx merged 6 commits intomainfrom
feat/bash_cli

Conversation

@qin-ctx
Copy link
Collaborator

@qin-ctx qin-ctx commented Feb 11, 2026

Description

实现 OpenViking Bash CLI 模块,完成技术方案中 T3(CLI 基础框架)和 T5(CLI 完整命令)两个任务。基于 Typer 构建非交互式 CLI,支持 Agent 通过 subprocess 调用,并统一配置加载机制。

Related Issue

Related to #48

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

T3: CLI 基础框架

  • 新增 openviking/cli/ 模块,基于 Typer 实现 CLI 入口 (main.py)
  • 实现 CLI 上下文管理 (context.py),统一管理 HTTPClient 连接和身份信息
  • 实现输出格式化 (output.py),支持 JSON / Table / Plain 三种输出模式
  • 实现统一错误处理 (errors.py),CLI 异常转为友好的终端输出
  • 实现核心命令:serve, ls, find, read, abstract, overview, add-resource

T5: CLI 完整命令

  • 文件系统命令:tree, stat, mkdir, rm, mv (commands/filesystem.py)
  • 搜索命令:search, grep, glob (commands/search.py)
  • 内容读取命令:read, abstract, overview (commands/content.py)
  • 会话命令:session new/list/get/commit/delete (commands/session.py)
  • 关联命令:link, unlink, relations (commands/relations.py)
  • 资源命令:add-resource, add-skill (commands/resources.py)
  • 导入导出命令:export, import (commands/pack.py)
  • 系统命令:status, health (commands/system.py)
  • 调试命令:debug status, debug health (commands/debug.py)
  • 观察者命令:observe (commands/observer.py)
  • 服务启动命令:serve (commands/serve.py)

配置加载机制统一

  • 新增 openviking/utils/config/config_loader.py,统一 ov.confovcli.conf 的加载逻辑
  • 通过 OPENVIKING_CONFIG_FILEOPENVIKING_CLI_CONFIG_FILE 两个环境变量管理配置文件路径
  • 移除旧的 parser_config.pyembedding_config.py,简化配置体系

Client 层改造

  • async_client.py / sync_client.py 适配新的配置加载方式
  • client/http.pyclient/local.py 适配新的初始化流程
  • client/session.py 移除创建 session 时的 user 参数(由 server 端管理)

文档更新

  • 更新中英文 API 文档、配置指南、部署指南、认证指南、快速开始等
  • 新增 examples/server_client/client_cli.sh 示例脚本
  • 新增 examples/ovcli.conf.example 配置示例

测试

  • 新增 tests/cli/test_cli.py:CLI 命令单元测试
  • 新增 tests/cli/conftest.py:CLI 测试 fixtures
  • 新增 tests/test_config_loader.py:配置加载器单元测试
  • 修复已有测试以适配新的配置和 session 机制

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

  • CLI 采用非交互式设计,适合 Agent 通过 subprocess 调用
  • 配置通过 ovcli.conf 文件管理连接信息(url/api_key/user),避免每次命令都传递全局参数
  • 输出格式支持 --output json/table/plain,默认 table 模式便于人类阅读,json 模式便于程序解析
  • 涉及 95 个文件变更,+3618 / -1443 行

引入基于 Typer 的完整 CLI 模块 (openviking/cli),支持 resources、
sessions、search、filesystem、content、relations、pack、debug、
observer、system 等子命令。

新增统一配置加载器 (config_loader),采用三级解析链(显式路径 →
环境变量 → ~/.openviking/),同时服务于 server (ov.conf) 和
CLI (ovcli.conf)。

精简 AsyncOpenViking / SyncOpenViking 客户端,移除 service 模式
(vectordb_url / agfs_url) 和环境变量回退逻辑,仅保留 embedded
和 HTTP 两种模式。

同步更新中英文文档、示例和测试。
@CLAassistant
Copy link

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@qin-ctx qin-ctx merged commit 6d55bf4 into main Feb 11, 2026
0 of 3 checks passed
@qin-ctx qin-ctx deleted the feat/bash_cli branch February 11, 2026 07:53
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.

3 participants