Skip to content

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

chore(skills): remove unused scan helper

Steven Enamakel7ecbc638da8c
diff --git a/crates/openhuman-core/src/skills/ops_discover/scan.rs b/crates/openhuman-core/src/skills/ops_discover/scan.rs
index c8d5408e21..5043063987 100644
--- a/crates/openhuman-core/src/skills/ops_discover/scan.rs
+++ b/crates/openhuman-core/src/skills/ops_discover/scan.rs
@@ -1,30 +1,17 @@
-//! Root-directory scanning: which on-disk roots exist per scope, walking them
-//! into `Workflow` entries, and the shared multi-root scan engine that both
-//! the full discovery surface and the automations-only view share.
+//! Host adapter over `tinyskills::layout`.
+//!
+//! The on-disk root layout, scan order and cross-scope collision handling are
+//! owned by the module. This file feeds it the host-only inputs (the compiled-in
+//! builtin bundles and the per-agent home) and applies the `source_format`
+//! rename the product surface expects.
-use std::path::{Path, PathBuf};
+use std::path::Path;
-use tinyskills::{resolve_collisions_with, CollisionPolicy, TieBreak};
+use tinyskills::{discover_layout, LayoutQuery, RootKind};
-use {tinyskills::Skill as Workflow, tinyskills::SkillScope as WorkflowScope};
-
-/// Which on-disk root category a bundle was discovered under.
-///
-/// `Workflow` roots (`.openhuman/workflows/`) hold task *automations* authored
-/// via "New workflow". `Skill` roots (`.openhuman/skills/`, `.agents/skills/`,
-/// and the legacy `<workspace>/skills/`) hold capability *skills*. Both are the
-/// same on-disk primitive (SKILL.md / WORKFLOW.md bundles) and the agent
-/// harness loads both — but the Automations UI lists only `Workflow`-root
-/// bundles (see [`super::discover_automations`]) so capability skills don't
-/// masquerade as task templates.
-#[derive(Clone, Copy, PartialEq, Eq, Debug)]
-pub(crate) enum RootKind {
- Skill,
- Workflow,
-}
+pub(super) use tinyskills::{ALL_ROOT_KINDS, WORKFLOW_ROOT_KINDS};
-pub(super) const ALL_ROOT_KINDS: &[RootKind] = &[RootKind::Skill, RootKind::Workflow];
-pub(super) const WORKFLOW_ROOT_KINDS: &[RootKind] = &[RootKind::Workflow];
+use {tinyskills::Skill as Workflow, tinyskills::SkillScope as WorkflowScope};
/// Shared discovery core. `kinds` selects which root categories to scan,
/// letting the full surface ([`super::discover_workflows_inner`]) and the
@@ -44,108 +31,46 @@ pub(super) fn discover_filtered(
include_workflows = kinds.contains(&RootKind::Workflow),
"[workflows] discover:enter"
);
- // Scan order matters for collision resolution: among equal-precedence
- // scopes the last root to register a name wins (`TieBreak::LastWins`), so
- // we scan builtin first, then user, then project, then legacy.
- let mut discovered: Vec<Workflow> = Vec::new();
- // Builtin skills (`<workspace>/.openhuman/builtin-skills/`) are a skill
- // root scanned FIRST and at the lowest precedence, so every other scope
- // shadows them on a name collision. No trust marker is consulted: the
+ // Builtin skills (`<workspace>/.openhuman/builtin-skills/`) are registered
+ // first and at the lowest precedence. No trust marker is consulted: the
// directory is core-managed and its contents were written from constants
- // compiled into this binary, which is a stronger provenance claim than the
- // marker makes about a project directory. See `skills::bundled`.
- if let Some(ws) = workspace_dir {
- if kinds.contains(&RootKind::Skill) {
- let root = crate::skills::bundled::builtin_root(ws);
- tracing::trace!(
- root = %root.display(),
- scope = ?WorkflowScope::Builtin,
- "[workflows] discover:branch:builtin"
- );
- discovered.extend(scan_bundled_root(&root, WorkflowScope::Builtin));
- }
- }
-
- if let Some(home) = home_dir {
- for (root, kind) in user_roots(home) {
- if kinds.contains(&kind) {
- tracing::trace!(
- root = %root.display(),
- ?kind,
- scope = ?WorkflowScope::User,
- "[workflows] discover:branch:user"
- );
- discovered.extend(scan_root(&root, WorkflowScope::User));
- }
- }
- }
-
- if let Some(agent_home) = workspace_dir.and_then(crate::skills::write_root::agent_skill_home) {
- let [skills, workflows] = crate::skills::write_root::agent_user_roots(&agent_home);
- for (root, kind) in [(skills, RootKind::Skill), (workflows, RootKind::Workflow)] {
- if kinds.contains(&kind) {
- tracing::trace!(
- root = %root.display(),
- ?kind,
- scope = ?WorkflowScope::User,
- "[workflows] discover:branch:agent"
- );
- discovered.extend(scan_root(&root, WorkflowScope::User));
- }
- }
- }
-
- if let Some(ws) = workspace_dir {
- if trusted {
- for (root, kind) in project_roots(ws) {
- if kinds.contains(&kind) {
- tracing::trace!(
- root = %root.display(),
- ?kind,
- scope = ?WorkflowScope::Project,
- "[workflows] discover:branch:project"
- );
- discovered.extend(scan_root(&root, WorkflowScope::Project));
- }
- }
+ // compiled into this binary. See `skills::bundled`.
+ let builtin = match workspace_dir {
+ Some(ws) if kinds.contains(&RootKind::Skill) => {
+ scan_bundled_root(&crate::skills::bundled::builtin_root(ws))
}
- // Legacy `<workspace>/skills/` is a skill root: scanned for the full
- // surface (back-compat, no trust marker required) but excluded from the
- // automations-only view. Flagged with `legacy = true` so the UI can
- // nudge migration.
- if kinds.contains(&RootKind::Skill) {
- let legacy_root = ws.join("skills");
- tracing::trace!(
- root = %legacy_root.display(),
- scope = ?WorkflowScope::Legacy,
- "[workflows] discover:branch:legacy"
- );
- discovered.extend(scan_root(&legacy_root, WorkflowScope::Legacy));
- }
- }
-
- // Cross-scope precedence and shadowing warnings are owned by tinyskills;
- // `Profile` bundles are not a filesystem scope OpenHuman scans.
- let out = resolve_collisions_with(
- discovered,
- &CollisionPolicy {
- tie_break: TieBreak::LastWins,
- excluded_scopes: vec![WorkflowScope::Profile],
- id_noun: "workflow".into(),
- },
- );
+ _ => Vec::new(),
+ };
+
+ let extra_user_roots = workspace_dir
+ .and_then(crate::skills::write_root::agent_skill_home)
+ .map(|agent_home| {
+ let [skills, workflows] = crate::skills::write_root::agent_user_roots(&agent_home);
+ vec![(skills, RootKind::Skill), (workflows, RootKind::Workflow)]
+ })
+ .unwrap_or_default();
+
+ let mut out = discover_layout(&LayoutQuery {
+ home: home_dir,
+ workspace: workspace_dir,
+ trusted,
+ kinds,
+ builtin,
+ extra_user_roots,
+ id_noun: "workflow".into(),
+ });
+ out.iter_mut().for_each(normalize_source_format);
tracing::debug!(discovered_count = out.len(), "[workflows] discover:exit");
out
}
-fn scan_bundled_root(root: &Path, scope: WorkflowScope) -> Vec<Workflow> {
+fn scan_bundled_root(root: &Path) -> Vec<Workflow> {
let mut out = Vec::new();
for bundled in crate::skills::bundled::BUNDLED {
let dir = root.join(bundled.dir_name);
if crate::skills::bundled::is_current_materialization(&dir, bundled) {
- if let Some(mut workflow) = tinyskills::load_skill_dir(&dir, scope) {
- normalize_source_format(&mut workflow);
+ if let Some(workflow) = tinyskills::load_skill_dir(&dir, WorkflowScope::Builtin) {
out.push(workflow);
}
}
@@ -153,40 +78,6 @@ fn scan_bundled_root(root: &Path, scope: WorkflowScope) -> Vec<Workflow> {
out
}
-fn user_roots(home: &Path) -> Vec<(PathBuf, RootKind)> {
- // `workflows/` is the current layout (create writes here); the `skills/`
- // roots are still scanned for back-compat with installs created before the
- // skills→workflows rename. Order matters: `workflows/` is scanned last so a
- // same-named entry there wins over a legacy `skills/` one.
- vec![
- (home.join(".openhuman").join("skills"), RootKind::Skill),
- (home.join(".agents").join("skills"), RootKind::Skill),
- (
- home.join(".openhuman").join("workflows"),
- RootKind::Workflow,
- ),
- ]
-}
-
-fn project_roots(workspace: &Path) -> Vec<(PathBuf, RootKind)> {
- vec![
- (workspace.join(".openhuman").join("skills"), RootKind::Skill),
- (workspace.join(".agents").join("skills"), RootKind::Skill),
- (
- workspace.join(".openhuman").join("workflows"),
- RootKind::Workflow,
- ),
- ]
-}
-
-pub(super) fn scan_root(root: &Path, scope: WorkflowScope) -> Vec<Workflow> {
- let mut workflows = tinyskills::scan_root(root, scope);
- for workflow in &mut workflows {
- normalize_source_format(workflow);
- }
- workflows
-}
-
fn normalize_source_format(workflow: &mut Workflow) {
if workflow.source_format == "agentskills" {
workflow.source_format = "openhuman".to_string();