Skip to content

The agent that grows with you

refactor(skills): one disabled rule in the prompt index; hoist prefix import

kshitijk4poordf25bbf46949
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index ba9c7ee7549..08bfd995e58 100644
--- a/agent/prompt_builder.py
+++ b/agent/prompt_builder.py
@@ -1533,9 +1533,9 @@ def _build_skills_system_prompt_inner(
_SKILLS_PROMPT_CACHE.move_to_end(cache_key)
return cached
- def hides(frontmatter_name: str, skill_name: str, conditions: dict) -> bool:
+ def hides(skill_name: str, conditions: dict) -> bool:
"""Per-build visibility rule shared by every skill source (snapshot, scan, project, external)."""
- return (frontmatter_name in disabled or skill_name in disabled
+ return (skill_name in disabled
or not _skill_should_show(conditions, available_tools, available_toolsets, _platform_hint or None))
skills_by_category: dict[str, list[tuple[str, str]]] = {}
@@ -1567,7 +1567,7 @@ def _build_skills_system_prompt_inner(
category_descriptions.setdefault(cat, cat_desc)
resolved = resolve_skill_catalog([
{**entry, "name": _entry_name(entry), "path": entry["root"] / entry["rel"],
- "visible": ok and not hides(_entry_name(entry), entry.get("skill_name") or "", entry.get("conditions") or {})}
+ "visible": ok and not hides(entry.get("skill_name") or "", entry.get("conditions") or {})}
for entry, ok in rows])
visible_entries = [e for e in resolved
if e["visible"] and e["status"] != "shadowed" and not is_disabled_entry(e, disabled)]
diff --git a/agent/skill_commands.py b/agent/skill_commands.py
index 34f72b60d36..e3e4305fe95 100644
--- a/agent/skill_commands.py
+++ b/agent/skill_commands.py
@@ -11,6 +11,7 @@ from typing import Any, Dict, Optional
from hermes_constants import display_hermes_home
from agent.prompt_cache_boundary import register_stable_prefix
from agent.skill_preprocessing import load_skills_config as _load_skills_config, preprocess_skill_content
+from agent.skill_utils import AMBIGUOUS_SKILL_PREFIX
logger = logging.getLogger(__name__)
@@ -249,7 +250,6 @@ def ambiguous_skill_label(identifier: str, payload: dict) -> Optional[str]:
"""``Ambiguous skill name X: use one of <paths>`` when a failed skill_view *payload* is a same-tier
name collision, else None — so preload/cron say why instead of "Unknown"/"not found"."""
load_names = payload.get("load_names") if isinstance(payload, dict) else None
- from agent.skill_utils import AMBIGUOUS_SKILL_PREFIX
return f"{AMBIGUOUS_SKILL_PREFIX}{identifier}: use one of {', '.join(load_names)}" if load_names else None
@@ -267,7 +267,6 @@ def _missing_skill_label(identifier: str) -> str:
def format_missing_skills(missing: list[str]) -> str:
"""One error line for unresolved preload identifiers: ambiguous ones keep their own wording,
the rest are reported as ``Unknown skill(s): ...``."""
- from agent.skill_utils import AMBIGUOUS_SKILL_PREFIX
ambiguous = [m for m in missing if m.startswith(AMBIGUOUS_SKILL_PREFIX)]
unknown = [m for m in missing if m not in ambiguous]
return "; ".join(ambiguous + ([f"Unknown skill(s): {', '.join(unknown)}"] if unknown else []))
diff --git a/agent/skill_utils.py b/agent/skill_utils.py
index 51ecc7044b6..bb6658d2c46 100644
--- a/agent/skill_utils.py
+++ b/agent/skill_utils.py
@@ -484,7 +484,7 @@ def is_disabled_entry(entry: Dict[str, Any], disabled: Set[str]) -> bool:
"""``skills.disabled`` matches a resolved catalog entry by its declared name OR its ``load_name`` —
the exact path a same-tier duplicate's list/config/web row shows (``a/one``) and saves. A unique
copy elsewhere that merely sits at the same relative path is not matched."""
- return bool(disabled) and not disabled.isdisjoint({str(entry["name"]), entry.get("load_name")} - {None})
+ return not disabled.isdisjoint({str(entry["name"]), entry.get("load_name")} - {None})
def resolve_skill_catalog(entries: List[Dict[str, Any]]) -> List[Dict[str, Any]]: