feat: 添加对 project_openclaw 技能源的支持,更新相关描述和逻辑
This commit is contained in:
parent
4f7a8ed645
commit
ba0e1c2473
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ Cargo.lock
|
|||||||
.venv
|
.venv
|
||||||
PicoBot.code-workspace
|
PicoBot.code-workspace
|
||||||
.picobot
|
.picobot
|
||||||
|
.claude
|
||||||
|
|||||||
@ -74,6 +74,7 @@ fn default_skills_sources() -> Vec<String> {
|
|||||||
"user_agent".to_string(),
|
"user_agent".to_string(),
|
||||||
"project".to_string(),
|
"project".to_string(),
|
||||||
"project_agent".to_string(),
|
"project_agent".to_string(),
|
||||||
|
"project_openclaw".to_string(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,6 +895,7 @@ mod tests {
|
|||||||
"user_agent".to_string(),
|
"user_agent".to_string(),
|
||||||
"project".to_string(),
|
"project".to_string(),
|
||||||
"project_agent".to_string(),
|
"project_agent".to_string(),
|
||||||
|
"project_openclaw".to_string(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ pub enum SkillSource {
|
|||||||
UserAgent,
|
UserAgent,
|
||||||
Project,
|
Project,
|
||||||
ProjectAgent,
|
ProjectAgent,
|
||||||
|
ProjectOpenclaw,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
@ -329,6 +330,7 @@ impl SkillSource {
|
|||||||
SkillSource::UserAgent => "user_agent",
|
SkillSource::UserAgent => "user_agent",
|
||||||
SkillSource::Project => "project",
|
SkillSource::Project => "project",
|
||||||
SkillSource::ProjectAgent => "project_agent",
|
SkillSource::ProjectAgent => "project_agent",
|
||||||
|
SkillSource::ProjectOpenclaw => "project_openclaw",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,6 +567,11 @@ fn source_order(sources: &[String]) -> Vec<SkillSource> {
|
|||||||
result.push(SkillSource::ProjectAgent);
|
result.push(SkillSource::ProjectAgent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"project_openclaw" => {
|
||||||
|
if !result.contains(&SkillSource::ProjectOpenclaw) {
|
||||||
|
result.push(SkillSource::ProjectOpenclaw);
|
||||||
|
}
|
||||||
|
}
|
||||||
unknown => {
|
unknown => {
|
||||||
tracing::warn!(source = %unknown, "Unknown skills source ignored");
|
tracing::warn!(source = %unknown, "Unknown skills source ignored");
|
||||||
}
|
}
|
||||||
@ -577,6 +584,7 @@ fn source_order(sources: &[String]) -> Vec<SkillSource> {
|
|||||||
SkillSource::UserAgent,
|
SkillSource::UserAgent,
|
||||||
SkillSource::Project,
|
SkillSource::Project,
|
||||||
SkillSource::ProjectAgent,
|
SkillSource::ProjectAgent,
|
||||||
|
SkillSource::ProjectOpenclaw,
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
result
|
result
|
||||||
@ -603,6 +611,10 @@ fn project_agent_skills_root(cwd: &Path) -> PathBuf {
|
|||||||
cwd.join(".agents").join("skills")
|
cwd.join(".agents").join("skills")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn project_openclaw_skills_root(cwd: &Path) -> PathBuf {
|
||||||
|
cwd.join(".openclaw").join("skills")
|
||||||
|
}
|
||||||
|
|
||||||
fn project_skill_state_path(cwd: &Path) -> PathBuf {
|
fn project_skill_state_path(cwd: &Path) -> PathBuf {
|
||||||
cwd.join(".picobot").join("skill-state.json")
|
cwd.join(".picobot").join("skill-state.json")
|
||||||
}
|
}
|
||||||
@ -625,6 +637,7 @@ fn source_root(source: SkillSource, cwd: &Path) -> Option<PathBuf> {
|
|||||||
SkillSource::UserAgent => user_agent_skills_root(),
|
SkillSource::UserAgent => user_agent_skills_root(),
|
||||||
SkillSource::Project => Some(cwd.join(".picobot").join("skills")),
|
SkillSource::Project => Some(cwd.join(".picobot").join("skills")),
|
||||||
SkillSource::ProjectAgent => Some(project_agent_skills_root(cwd)),
|
SkillSource::ProjectAgent => Some(project_agent_skills_root(cwd)),
|
||||||
|
SkillSource::ProjectOpenclaw => Some(project_openclaw_skills_root(cwd)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,6 +1038,7 @@ mod tests {
|
|||||||
"user_agent".to_string(),
|
"user_agent".to_string(),
|
||||||
"project".to_string(),
|
"project".to_string(),
|
||||||
"project_agent".to_string(),
|
"project_agent".to_string(),
|
||||||
|
"project_openclaw".to_string(),
|
||||||
"project".to_string(),
|
"project".to_string(),
|
||||||
"unknown".to_string(),
|
"unknown".to_string(),
|
||||||
]);
|
]);
|
||||||
@ -1036,6 +1050,7 @@ mod tests {
|
|||||||
SkillSource::UserAgent,
|
SkillSource::UserAgent,
|
||||||
SkillSource::Project,
|
SkillSource::Project,
|
||||||
SkillSource::ProjectAgent,
|
SkillSource::ProjectAgent,
|
||||||
|
SkillSource::ProjectOpenclaw,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1244,4 +1259,38 @@ mod tests {
|
|||||||
assert!(user_enabled.disabled_in_scopes.is_empty());
|
assert!(user_enabled.disabled_in_scopes.is_empty());
|
||||||
assert!(runtime.get_skill("demo").is_some());
|
assert!(runtime.get_skill("demo").is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_discover_loads_project_openclaw_skills() {
|
||||||
|
let _lock = acquire_test_lock();
|
||||||
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
let home_dir = temp_dir.path().join("home");
|
||||||
|
let project_dir = temp_dir.path().join("project");
|
||||||
|
fs::create_dir_all(&home_dir).unwrap();
|
||||||
|
fs::create_dir_all(&project_dir).unwrap();
|
||||||
|
let _home = HomeDirGuard::enter(&home_dir);
|
||||||
|
let _guard = CurrentDirGuard::enter(&project_dir);
|
||||||
|
|
||||||
|
let openclaw_skill_dir = project_dir
|
||||||
|
.join(".openclaw")
|
||||||
|
.join("skills")
|
||||||
|
.join("demo-openclaw");
|
||||||
|
fs::create_dir_all(&openclaw_skill_dir).unwrap();
|
||||||
|
fs::write(
|
||||||
|
openclaw_skill_dir.join("SKILL.md"),
|
||||||
|
"---\ndescription: openclaw skill\n---\nUse openclaw",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let catalog = SkillCatalog::discover(&SkillsConfig {
|
||||||
|
enabled: true,
|
||||||
|
sources: vec!["project_openclaw".to_string()],
|
||||||
|
max_index_chars: 4000,
|
||||||
|
max_listed_skills: 32,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(catalog.len(), 1);
|
||||||
|
let payload = catalog.activation_event_payload("demo-openclaw").unwrap();
|
||||||
|
assert_eq!(payload["source"], "project_openclaw");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ impl Tool for SkillManageTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"Manage PicoBot skills stored under .picobot/skills or ~/.picobot/skills, while discovery also reads .agents/skills and ~/.agents/skills. Supports actions: list, get, create, update, delete, disable, reload."
|
"Manage PicoBot skills stored under .picobot/skills or ~/.picobot/skills, while discovery also reads .agents/skills, ~/.agents/skills, and .openclaw/skills. Supports actions: list, get, create, update, delete, disable, reload."
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parameters_schema(&self) -> serde_json::Value {
|
fn parameters_schema(&self) -> serde_json::Value {
|
||||||
@ -123,6 +123,7 @@ impl Tool for SkillManageTool {
|
|||||||
crate::skills::SkillSource::UserAgent => "user_agent",
|
crate::skills::SkillSource::UserAgent => "user_agent",
|
||||||
crate::skills::SkillSource::Project => "project",
|
crate::skills::SkillSource::Project => "project",
|
||||||
crate::skills::SkillSource::ProjectAgent => "project_agent",
|
crate::skills::SkillSource::ProjectAgent => "project_agent",
|
||||||
|
crate::skills::SkillSource::ProjectOpenclaw => "project_openclaw",
|
||||||
},
|
},
|
||||||
"path": skill.path.display().to_string(),
|
"path": skill.path.display().to_string(),
|
||||||
}),
|
}),
|
||||||
@ -325,6 +326,7 @@ fn list_skills_payload(skills: &Arc<SkillRuntime>) -> serde_json::Value {
|
|||||||
crate::skills::SkillSource::UserAgent => "user_agent",
|
crate::skills::SkillSource::UserAgent => "user_agent",
|
||||||
crate::skills::SkillSource::Project => "project",
|
crate::skills::SkillSource::Project => "project",
|
||||||
crate::skills::SkillSource::ProjectAgent => "project_agent",
|
crate::skills::SkillSource::ProjectAgent => "project_agent",
|
||||||
|
crate::skills::SkillSource::ProjectOpenclaw => "project_openclaw",
|
||||||
},
|
},
|
||||||
"path": skill.path.display().to_string(),
|
"path": skill.path.display().to_string(),
|
||||||
})).collect::<Vec<_>>()
|
})).collect::<Vec<_>>()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user