Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/skillspector/multi_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pathlib import Path

from skillspector.logging_config import get_logger
from skillspector.structured_skill import extract_structured_skill_context

logger = get_logger(__name__)

Expand Down Expand Up @@ -73,7 +74,7 @@ def detect_skills(directory: Path) -> MultiSkillDetectionResult:
continue
if child.name.startswith("."):
continue
if _has_skill_md(child):
if _has_skill_md(child) or _is_structured_skill_bundle(child):
name = _extract_skill_name(child)
skills.append(
SkillDirectory(
Expand All @@ -91,6 +92,11 @@ def detect_skills(directory: Path) -> MultiSkillDetectionResult:
)


def _is_structured_skill_bundle(child_dir: Path) -> bool:
"""Return true when a child directory contains a valid AISOP/AISP bundle."""
return extract_structured_skill_context(child_dir) is not None


def _has_skill_md(directory: Path) -> bool:
"""Check if directory contains a SKILL.md or skill.md at root level."""
return (directory / "SKILL.md").is_file() or (directory / "skill.md").is_file()
Expand Down
5 changes: 5 additions & 0 deletions src/skillspector/nodes/analyzers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
node as static_patterns_tool_misuse_node,
)
from skillspector.nodes.analyzers.static_yara import node as static_yara_node
from skillspector.nodes.analyzers.structured_skill_roles import (
node as structured_skill_roles_node,
)

ANALYZER_NODE_IDS: list[str] = [
"static_patterns_prompt_injection",
Expand All @@ -98,6 +101,7 @@
"mcp_least_privilege",
"mcp_tool_poisoning",
"mcp_rug_pull",
"structured_skill_roles",
"semantic_security_discovery",
"semantic_developer_intent",
"semantic_quality_policy",
Expand All @@ -124,6 +128,7 @@
"mcp_least_privilege": mcp_least_privilege_node,
"mcp_tool_poisoning": mcp_tool_poisoning_node,
"mcp_rug_pull": mcp_rug_pull_node,
"structured_skill_roles": structured_skill_roles_node,
"semantic_security_discovery": semantic_security_discovery_node,
"semantic_developer_intent": semantic_developer_intent_node,
"semantic_quality_policy": semantic_quality_policy_node,
Expand Down
75 changes: 75 additions & 0 deletions src/skillspector/nodes/analyzers/structured_skill_roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Structured skill role summary analyzer (SSR-*)."""

from __future__ import annotations

from skillspector.models import Finding
from skillspector.state import AnalyzerNodeResponse, SkillspectorState

ANALYZER_ID = "structured_skill_roles"


def _build_finding(context: dict[str, object]) -> Finding:
"""Build a single SSR-1 finding from validated structured-skill context."""
protocol = str(context.get("protocol", "AISOP/AISP"))
layout_kind = str(context.get("layout_kind", "structured"))
bundle_path = str(context.get("bundle_path", ""))
tools = context.get("declared_tools") or []
tools_text = ", ".join(sorted(str(t) for t in tools)) if isinstance(tools, list) else ""
if not tools_text:
tools_text = "(no declared tools)"

workflow_nodes = context.get("workflow_nodes") or []
workflow_text = ", ".join(str(n) for n in workflow_nodes) if workflow_nodes else "(none)"

constraints = context.get("constraint_anchors") or []
constraints_text = ", ".join(str(c) for c in constraints) if constraints else "(none)"

resources = context.get("resource_anchors") or []
resources_text = ", ".join(str(r) for r in resources) if resources else "(none)"

return Finding(
rule_id="SSR-1",
message=f"Structured {layout_kind} bundle detected ({protocol})",
severity="LOW",
confidence=1.0,
file=bundle_path,
tags=["AISOP", "AISP", "structured-skill"],
context=(
"Detected structured AISOP/AISP workflow for scan context. "
f"declared_tools=[{tools_text}], workflow_nodes=[{workflow_text}], "
f"constraints=[{constraints_text}], resources=[{resources_text}]"
),
matched_text=(
f"layout_kind={layout_kind}, protocol={protocol}, "
f"bundle={bundle_path}, declared_tools={tools_text}"
),
explanation=(
"This scan target appears to define a structured AISOP/AISP workflow. "
"The detector found a valid two-message AISOP/AISP contract and summarized "
"workflow roles, declared tool set, constraints, and resource anchors."
),
)


def node(state: SkillspectorState) -> AnalyzerNodeResponse:
"""Emit one LOW SSR-1 summary finding when structured context is present."""
context = state.get("structured_skill_context")
if not isinstance(context, dict):
return {"findings": []}

return {"findings": [_build_finding(context)]}
9 changes: 8 additions & 1 deletion src/skillspector/nodes/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from skillspector.constants import MODEL_CONFIG
from skillspector.logging_config import get_logger
from skillspector.state import SkillspectorState
from skillspector.structured_skill import extract_structured_skill_context

logger = get_logger(__name__)

Expand Down Expand Up @@ -231,8 +232,9 @@ def build_context(state: SkillspectorState) -> dict[str, object]:
file_cache = _read_file_cache(skill_dir, components)
manifest = _parse_manifest(skill_dir)
component_metadata, has_executable_scripts = _build_component_metadata(skill_dir, components)
structured_skill_context = extract_structured_skill_context(skill_dir)

return {
result = {
"components": components,
"file_cache": file_cache,
"ast_cache": {},
Expand All @@ -242,3 +244,8 @@ def build_context(state: SkillspectorState) -> dict[str, object]:
"component_metadata": component_metadata,
"has_executable_scripts": has_executable_scripts,
}

if structured_skill_context is not None:
result["structured_skill_context"] = structured_skill_context

return result
2 changes: 2 additions & 0 deletions src/skillspector/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class SkillspectorState(TypedDict, total=False):
# Component metadata for reporting and risk scoring (from build_context)
component_metadata: list[dict[str, object]]
has_executable_scripts: bool
# Structured workflow context for phase-1 AISOP/AISP summaries
structured_skill_context: dict[str, object]

# Output: report node writes formatted string here
output_format: str
Expand Down
Loading