Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(cli): 统一 add-skill 与 skills add 的导入流程 (#4939)
Qin Haojie4f430f65fe27
diff --git a/crates/ov_cli/src/client.rs b/crates/ov_cli/src/client.rsindex fb0e3a324..bd8b1c5fc 100644--- a/crates/ov_cli/src/client.rs+++ b/crates/ov_cli/src/client.rs@@ -1000,7 +1000,6 @@ impl HttpClient {&self,data: &str,wait: bool,- timeout: Option<f64>,show_progress: bool,verbose: bool,source_metadata: Option<Value>,@@ -1025,7 +1024,6 @@ impl HttpClient {let mut body = serde_json::json!({"temp_file_id": temp_file_id,"wait": wait,- "timeout": timeout,});if let Some(source_metadata) = source_metadata.clone() {body["source_metadata"] = source_metadata;@@ -1049,7 +1047,6 @@ impl HttpClient {let mut body = serde_json::json!({"temp_file_id": temp_file_id,"wait": wait,- "timeout": timeout,});if let Some(source_metadata) = source_metadata.clone() {body["source_metadata"] = source_metadata;@@ -1066,7 +1063,6 @@ impl HttpClient {let mut body = serde_json::json!({"data": data,"wait": wait,- "timeout": timeout,});if let Some(source_metadata) = source_metadata.clone() {body["source_metadata"] = source_metadata;@@ -1080,7 +1076,6 @@ impl HttpClient {let mut body = serde_json::json!({"data": data,"wait": wait,- "timeout": timeout,});if let Some(source_metadata) = source_metadata {body["source_metadata"] = source_metadata;diff --git a/crates/ov_cli/src/commands/resources.rs b/crates/ov_cli/src/commands/resources.rsindex 0afdc2512..e1e8189ad 100644--- a/crates/ov_cli/src/commands/resources.rs+++ b/crates/ov_cli/src/commands/resources.rs@@ -65,29 +65,3 @@ pub async fn add_resource(output_success(&result, format, compact);Ok(())}--pub async fn add_skill(- client: &HttpClient,- data: &str,- wait: bool,- timeout: Option<f64>,- parent: Option<&str>,- show_progress: bool,- verbose: bool,- format: OutputFormat,- compact: bool,-) -> Result<()> {- let result = client- .add_skill(data, wait, timeout, show_progress, verbose, None, parent)- .await?;-- if !wait && matches!(format, OutputFormat::Table) {- eprintln!("Note: Skill is being processed in the background.");- eprintln!(- "Use 'ov task status <task_id>' to check progress, or 'ov task list' to see all tasks."- );- }-- output_success(&result, format, compact);- Ok(())-}diff --git a/crates/ov_cli/src/commands/skills.rs b/crates/ov_cli/src/commands/skills.rsindex d33c21b4c..f3c76ae95 100644--- a/crates/ov_cli/src/commands/skills.rs+++ b/crates/ov_cli/src/commands/skills.rs@@ -122,7 +122,6 @@ pub async fn add(.add_skill(&target.data,wait,- None,show_progress,verbose,source_metadata,diff --git a/crates/ov_cli/src/handlers.rs b/crates/ov_cli/src/handlers.rsindex c524fe2f9..033db6ff6 100644--- a/crates/ov_cli/src/handlers.rs+++ b/crates/ov_cli/src/handlers.rs@@ -1,4 +1,3 @@-use crate::CliContext;use crate::PrivacyCommands;use crate::client;use crate::commands;@@ -10,6 +9,7 @@ use crate::terminal_ui::{};use crate::theme;use crate::tui;+use crate::{CliContext, SkillAddArgs, UploadCliOptions};use colored::Colorize;use serde_json::{Map, Value};@@ -320,23 +320,27 @@ mod add_resource_args_tests {}pub async fn handle_add_skill(- data: String,- wait: bool,- timeout: Option<f64>,- parent: Option<String>,+ args: SkillAddArgs,+ legacy_upload_options: UploadCliOptions,ctx: CliContext,) -> Result<()> {+ let ctx = ctx.with_upload_options(+ args.upload_options+ .merged_with_legacy(legacy_upload_options),+ );let client = ctx.get_client();- commands::resources::add_skill(+ commands::skills::add(&client,- &data,- wait,- timeout,- parent.as_deref(),+ &args.source,+ args.skills,+ args.list,+ args.wait,+ args.yes,ctx.should_show_progress(),ctx.is_verbose(),ctx.output_format,ctx.compact,+ args.parent.as_deref(),).await}diff --git a/crates/ov_cli/src/main.rs b/crates/ov_cli/src/main.rsindex fb4265291..dc3e637cc 100644--- a/crates/ov_cli/src/main.rs+++ b/crates/ov_cli/src/main.rs@@ -466,33 +466,8 @@ enum Commands {#[command(flatten)]upload_options: UploadCliOptions,},- /// [Data] Add a skill into OpenViking- AddSkill {- /// Skill directory, SKILL.md, or raw content- #[arg(value_name = "skill-path-or-content")]- data: String,- /// Wait until processing is complete- #[arg(long, help_heading = "Common options")]- wait: bool,- /// Wait timeout in seconds- #[arg(- long,- value_parser = config::parse_positive_timeout,- value_name = "seconds",- help_heading = "Common options"- )]- timeout: Option<f64>,- /// Parent skill root URI (e.g. viking://agent/skills); defaults to user-private skills- #[arg(- short = 'p',- long = "parent-auto-create",- value_name = "uri",- help_heading = "Skill options"- )]- parent: Option<String>,- #[command(flatten)]- upload_options: UploadCliOptions,- },+ /// [Data] Add skills from a source (same as `skills add`)+ AddSkill(SkillAddArgs),/// [Data] Manage installed skillsSkills {#[command(subcommand)]@@ -1299,7 +1274,14 @@ impl Commands {}fn supports_upload_options(&self) -> bool {- matches!(self, Self::AddResource { .. } | Self::AddSkill { .. })+ matches!(+ self,+ Self::AddResource { .. }+ | Self::AddSkill(_)+ | Self::Skills {+ action: SkillCommands::Add(_)+ }+ )}}@@ -1309,7 +1291,7 @@ fn legacy_upload_option_error() -> Option<&'static str> {if options.is_set() && !command.supports_upload_options() {Some(- "--progress, --no-progress, and --verbose are only supported for add-resource and add-skill.",+ "--progress, --no-progress, and --verbose are only supported for add-resource, add-skill, and skills add.",)} else {None@@ -1644,29 +1626,34 @@ enum SessionConfigCommands {},}+#[derive(Args)]+struct SkillAddArgs {+ /// Local skill file/directory, Git repository or GitHub tree URL, or raw content+ #[arg(value_name = "source")]+ source: String,+ /// Install only the named skill(s); use '*' to install all skills in a source+ #[arg(short = 's', long = "skill", value_name = "NAME", num_args = 1.., value_delimiter = ',')]+ skills: Vec<String>,+ /// List available skills in the source without installing+ #[arg(short = 'l', long = "list")]+ list: bool,+ /// Wait until processing is complete+ #[arg(short = 'w', long)]+ wait: bool,+ /// Skip confirmation prompt+ #[arg(short = 'y', long = "yes")]+ yes: bool,+ /// Parent skill root URI (e.g. viking://agent/skills); defaults to user-private skills+ #[arg(short = 'p', long = "parent-auto-create", value_name = "uri")]+ parent: Option<String>,+ #[command(flatten)]+ upload_options: UploadCliOptions,+}+#[derive(Subcommand)]enum SkillCommands {/// Add skills from a source- Add {- /// Skill source- #[arg(value_name = "source")]- source: String,- /// Install only the named skill(s); use '*' to install all skills in a source- #[arg(short = 's', long = "skill", value_name = "NAME", num_args = 1.., value_delimiter = ',')]- skills: Vec<String>,- /// List available skills in the source without installing- #[arg(short = 'l', long = "list")]- list: bool,- /// Wait until processing is complete- #[arg(short = 'w', long)]- wait: bool,- /// Skip confirmation prompt- #[arg(short = 'y', long = "yes")]- yes: bool,- /// Parent skill root URI (e.g. viking://agent/skills); defaults to user-private skills- #[arg(short = 'p', long = "parent-auto-create", value_name = "uri")]- parent: Option<String>,- },+ Add(SkillAddArgs),/// List installed agent skills#[command(alias = "ls")]List {@@ -3297,41 +3284,12 @@ async fn main() {))}}- Commands::AddSkill {- data,- wait,- timeout,- parent,- upload_options,- } => {- let ctx =- ctx.with_upload_options(upload_options.merged_with_legacy(legacy_upload_options));- handlers::handle_add_skill(data, wait, timeout, parent, ctx).await+ Commands::AddSkill(args) => {+ handlers::handle_add_skill(args, legacy_upload_options, ctx).await}Commands::Skills { action } => match action {- SkillCommands::Add {- source,- skills,- list,- wait,- yes,- parent,- } => {- let client = ctx.get_client();- commands::skills::add(- &client,- &source,- skills,- list,- wait,- yes,- ctx.should_show_progress(),- ctx.is_verbose(),- ctx.output_format,- ctx.compact,- parent.as_deref(),- )- .await+ SkillCommands::Add(args) => {+ handlers::handle_add_skill(args, legacy_upload_options, ctx).await}SkillCommands::List { node_limit, parent } => {let client = ctx.get_client();@@ -4649,13 +4607,13 @@ mod tests {let add_skill = Cli::try_parse_from(["ov", "add-skill", "./skill", "--no-progress"]).expect("add-skill upload flags should parse");match add_skill.command {- Commands::AddSkill { upload_options, .. } => {- assert!(upload_options.no_progress);+ Commands::AddSkill(args) => {+ assert!(args.upload_options.no_progress);}_ => panic!("expected add-skill command"),}- assert!(Cli::try_parse_from(["ov", "skills", "add", "./skill", "--progress"]).is_err());+ assert!(Cli::try_parse_from(["ov", "skills", "add", "./skill", "--progress"]).is_ok());assert!(Cli::try_parse_from(["ov", "skills", "update", "--progress"]).is_err());}@@ -4792,35 +4750,35 @@ mod tests {_ => panic!("expected skills update"),}- let add_selected = Cli::try_parse_from([- "ov",- "skills",- "add",- "https://github.com/acme/skills.git",- "--skill",- "foo",- "bar",- "--list",- "--yes",- ])- .expect("skills add RFC flags should parse");- match add_selected.command {- Commands::Skills {- action:- SkillCommands::Add {- source,- skills,- list,- yes,- ..- },- } => {- assert_eq!(source, "https://github.com/acme/skills.git");- assert_eq!(skills, vec!["foo", "bar"]);- assert!(list);- assert!(yes);- }- _ => panic!("expected skills add"),+ for mut argv in [vec!["ov", "add-skill"], vec!["ov", "skills", "add"]] {+ argv.extend([+ "https://github.com/acme/skills.git",+ "--skill",+ "foo",+ "bar",+ "--list",+ "--yes",+ "--wait",+ "--parent-auto-create",+ "viking://agent/skills",+ "--no-progress",+ ]);+ let add_selected = Cli::try_parse_from(argv)+ .expect("both skill add commands should accept the same options");+ let args = match add_selected.command {+ Commands::AddSkill(args)+ | Commands::Skills {+ action: SkillCommands::Add(args),+ } => args,+ _ => panic!("expected skill add command"),+ };+ assert_eq!(args.source, "https://github.com/acme/skills.git");+ assert_eq!(args.skills, vec!["foo", "bar"]);+ assert!(args.list);+ assert!(args.yes);+ assert!(args.wait);+ assert_eq!(args.parent.as_deref(), Some("viking://agent/skills"));+ assert!(args.upload_options.no_progress);}let show = Cli::try_parse_from([@@ -4918,7 +4876,7 @@ mod tests {assert_eq!(legacy_upload_option_error(upload_options, &tree.command),Some(- "--progress, --no-progress, and --verbose are only supported for add-resource and add-skill."+ "--progress, --no-progress, and --verbose are only supported for add-resource, add-skill, and skills add."));@@ -4928,12 +4886,7 @@ mod tests {let skills_add = Cli::try_parse_from(["ov", "--progress", "skills", "add", "./skill"]).expect("hidden legacy flag still parses before runtime validation");- assert_eq!(- legacy_upload_option_error(upload_options, &skills_add.command),- Some(- "--progress, --no-progress, and --verbose are only supported for add-resource and add-skill."- )- );+ assert!(legacy_upload_option_error(upload_options, &skills_add.command).is_none());}#[test]@@ -5015,7 +4968,6 @@ mod tests {fn all_timeout_options_require_positive_finite_seconds() {let command_prefixes = [vec!["ov", "add-resource", "https://example.com", "--timeout"],- vec!["ov", "add-skill", "skill", "--timeout"],vec!["ov", "rm", "viking://resources/item", "--timeout"],vec!["ov",diff --git a/docs/en/api/04-skills.md b/docs/en/api/04-skills.mdindex fdd6e62cb..169463afe 100644--- a/docs/en/api/04-skills.md+++ b/docs/en/api/04-skills.md@@ -341,8 +341,24 @@ fmt.Println(result["task_id"])**CLI**+`ov add-skill` and `ov skills add` share the same options and import flow. The CLI+clones Git repositories or GitHub `tree` directories locally, then packages and+uploads the selected skills. The server API still receives inline content or+temporary uploads. Supporting files such as `references/` and `scripts/` are included.+Use `--list` to inspect a collection and `--skill` to select skills. Batch imports+require confirmation unless `--yes` is set. By default, the command waits for downloading,+uploading, server-side parsing, overview generation, and file writes, but not vectorization.+`--wait` additionally waits for vectorization.+```bash-# Add skill (from file or directory+# Import one skill from the standalone skills branch; ov skills add also works+ov add-skill https://github.com/volcengine/OpenViking/tree/skills/llm-wiki --wait++# Inspect a local collection, then select skills to import+ov add-skill ./examples/compile/ov-compile-skills --list+ov add-skill ./examples/compile/ov-compile-skills --skill llm-wiki daily-report --yes++# Add a skill from a local file or directoryov add-skill ./skills/my-skill.jsonov add-skill ./skills/search-web/SKILL.mdov add-skill ./skills/code-runner/@@ -377,7 +393,7 @@ ov add-skill ./skills/my-skill/ -o json**CLI response (default table format)**:```-Note: Skill is being processed in the background.+Note: Skill processing may continue in the background.Use 'ov task status <task_id>' to check progress, or 'ov task list' to see all tasks.status successroot_uri viking://user/alice/skills/my-skilldiff --git a/docs/zh/api/04-skills.md b/docs/zh/api/04-skills.mdindex e2dcef6f3..2041cfba0 100644--- a/docs/zh/api/04-skills.md+++ b/docs/zh/api/04-skills.md@@ -340,7 +340,21 @@ fmt.Println(result["task_id"])**CLI**:+`ov add-skill` 与 `ov skills add` 使用同一套参数和导入流程。Git 仓库或+GitHub `tree` 目录由 CLI 克隆到本地,再将选中的技能打包上传;服务端 API+仍接收内联内容或临时上传文件。目录中的 `references/`、`scripts/` 等附件一并上传。+技能集合可以用 `--list` 查看、`--skill` 选择;批量导入需要确认,或使用 `--yes`。+默认不等待向量化完成,但仍需完成下载、上传,以及服务端的解析、overview 生成和文件写入。+`--wait` 额外等待向量化完成。+```bash+# 从独立 skills 分支导入一个技能;也可以写成 ov skills add+ov add-skill https://github.com/volcengine/OpenViking/tree/skills/llm-wiki --wait++# 查看本地技能集合,再选择导入+ov add-skill ./examples/compile/ov-compile-skills --list+ov add-skill ./examples/compile/ov-compile-skills --skill llm-wiki daily-report --yes+# 添加技能(从文件或目录)ov add-skill ./skills/my-skill.jsonov add-skill ./skills/search-web/SKILL.md@@ -376,7 +390,7 @@ ov add-skill ./skills/my-skill/ -o json**CLI 响应(默认表格格式)**:```-Note: Skill is being processed in the background.+Note: Skill processing may continue in the background.Use 'ov task status <task_id>' to check progress, or 'ov task list' to see all tasks.status successroot_uri viking://user/alice/skills/my-skill