Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(skills): respect CoreContext user_skill_roots flag in discovery

Steven Enamakel1fe3619e2401
diff --git a/crates/openhuman-core/src/skills/ops_discover.rs b/crates/openhuman-core/src/skills/ops_discover.rs
index 658e3eb8ae..47db4927fc 100644
--- a/crates/openhuman-core/src/skills/ops_discover.rs
+++ b/crates/openhuman-core/src/skills/ops_discover.rs
@@ -23,8 +23,9 @@ use collision::precedence;
use std::path::Path;
pub use api::{
- discover_automations, discover_workflows, discover_workflows_with_profile, init_workflows_dir,
- is_workspace_trusted, load_workflow_metadata, load_workflow_metadata_for_profile,
+ discover_automations, discover_workflows, discover_workflows_with_profile, discovery_home_dir,
+ init_workflows_dir, is_workspace_trusted, load_workflow_metadata,
+ load_workflow_metadata_for_profile,
};
pub use resource::{
profile_local_skill_ids, read_workflow_resource, read_workflow_resource_with_profile,
diff --git a/crates/openhuman-core/src/skills/ops_discover/api.rs b/crates/openhuman-core/src/skills/ops_discover/api.rs
index f83b261cbf..490dfa6913 100644
--- a/crates/openhuman-core/src/skills/ops_discover/api.rs
+++ b/crates/openhuman-core/src/skills/ops_discover/api.rs
@@ -33,6 +33,24 @@ pub fn init_workflows_dir(workspace_dir: &Path) -> Result<(), String> {
Ok(())
}
+/// The home directory skill discovery scans for user-scope roots
+/// (`~/.openhuman/skills/`, `~/.agents/skills/`, `~/.openhuman/workflows/`).
+///
+/// `dirs::home_dir()` for every ordinary caller. `None` when the ambient
+/// [`CoreContext`](crate::core::runtime::CoreContext) was derived with
+/// `user_skill_roots = false` — an embedded agent whose host installed its
+/// skills explicitly and must not see the operator's own — so the caller's
+/// discovery pipeline scans no user scope at all, exactly as passing `None`
+/// for `home_dir` always has.
+pub fn discovery_home_dir() -> Option<PathBuf> {
+ if crate::core::runtime::CoreContext::current_user_skill_roots() {
+ dirs::home_dir()
+ } else {
+ log::debug!("[skills][discover] user-scope roots hidden by the ambient context");
+ None
+ }
+}
+
/// Backwards-compatible shim for callers that only have a workspace path.
///
/// Delegates to [`discover_workflows`] with the current user's home directory
@@ -46,7 +64,7 @@ pub fn init_workflows_dir(workspace_dir: &Path) -> Result<(), String> {
/// on name collisions.
pub fn load_workflow_metadata(workspace_dir: &Path) -> Vec<Workflow> {
let trusted = is_workspace_trusted(workspace_dir);
- let home = dirs::home_dir();
+ let home = discovery_home_dir();
discover_workflows_inner(home.as_deref(), Some(workspace_dir), None, trusted)
}
@@ -64,7 +82,7 @@ pub fn load_workflow_metadata_for_profile(
profile_skills_root: Option<&Path>,
) -> Vec<Workflow> {
let trusted = is_workspace_trusted(workspace_dir);
- let home = dirs::home_dir();
+ let home = discovery_home_dir();
discover_workflows_inner(
home.as_deref(),
Some(workspace_dir),
diff --git a/crates/openhuman-core/src/skills/registry.rs b/crates/openhuman-core/src/skills/registry.rs
index 2d0bba4171..fa57da2ad9 100644
--- a/crates/openhuman-core/src/skills/registry.rs
+++ b/crates/openhuman-core/src/skills/registry.rs
@@ -204,7 +204,7 @@ fn load_workflows_and_discovered(
// Enumerate across all roots (deduped + scope-prioritised) via the same
// discovery the create/list path uses, then load each one's definition.
- let home = dirs::home_dir();
+ let home = super::ops_discover::discovery_home_dir();
let trusted = super::ops_discover::is_workspace_trusted(workspace_dir);
let discovered = super::ops_discover::discover_workflows_with_profile(
home.as_deref(),
diff --git a/crates/openhuman-core/src/skills/schemas/handlers.rs b/crates/openhuman-core/src/skills/schemas/handlers.rs
index 6532044e84..c982354064 100644
--- a/crates/openhuman-core/src/skills/schemas/handlers.rs
+++ b/crates/openhuman-core/src/skills/schemas/handlers.rs
@@ -36,7 +36,7 @@ pub(super) fn handle_skills_list(params: Map<String, Value>) -> ControllerFuture
tracing::debug!(include_skills, "[skills][rpc] list automations");
let workspace = resolve_workspace_dir().await;
let trusted = is_workspace_trusted(&workspace);
- let home = dirs::home_dir();
+ let home = crate::skills::ops_discover::discovery_home_dir();
// Default: automations-only (`workflows/` roots) so capability skills
// don't masquerade as task templates in the Automations UI. The Skills
// Explorer passes `include_skills=true` to also surface `skills/`-root
diff --git a/crates/openhuman-core/src/skills/search.rs b/crates/openhuman-core/src/skills/search.rs
index 143a2e8018..a8d250e68c 100644
--- a/crates/openhuman-core/src/skills/search.rs
+++ b/crates/openhuman-core/src/skills/search.rs
@@ -158,7 +158,7 @@ impl SkillSearchTool {
fn visible(&self) -> Vec<Workflow> {
let trusted = is_workspace_trusted(&self.workspace_dir);
let mut workflows = discover_workflows_with_profile(
- dirs::home_dir().as_deref(),
+ crate::skills::ops_discover::discovery_home_dir().as_deref(),
Some(&self.workspace_dir),
self.profile_skills_root.as_deref(),
trusted,
diff --git a/crates/openhuman-core/src/skills/tools/read.rs b/crates/openhuman-core/src/skills/tools/read.rs
index d657e4778a..6acda6440f 100644
--- a/crates/openhuman-core/src/skills/tools/read.rs
+++ b/crates/openhuman-core/src/skills/tools/read.rs
@@ -105,7 +105,10 @@ impl Tool for WorkflowListTool {
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
log::debug!("[tool][workflows] list invoked");
- let home = self.home_dir.clone().or_else(dirs::home_dir);
+ let home = self
+ .home_dir
+ .clone()
+ .or_else(crate::skills::ops_discover::discovery_home_dir);
let trusted = is_workspace_trusted(&self.workspace_dir);
let mut workflows = discover_workflows_with_profile(
home.as_deref(),