Skip to content

Refactor: Unify skill/ralph abstractions to reduce duplication #514

@kasperjunge

Description

@kasperjunge

ralph.py is nearly a line-for-line copy of discovery functions in skill.py, just with RALPH_MARKER instead of SKILL_MARKER. Similarly, write_skill_metadata and write_ralph_metadata in metadata.py differ only in the presence of a tool field.

Proposal

Introduce a ResourceType abstraction:

@dataclass(frozen=True)
class ResourceType:
    marker: str          # "SKILL.md" or "RALPH.md"
    name: str            # "skill" or "ralph"
    has_tool_field: bool  # skills are per-tool, ralphs are tool-agnostic

Then parameterize shared functions on ResourceType rather than duplicating:

  • find_in_repo() / find_in_repo_listing() / discover_in_repo_listing()
  • write_metadata() / stamp_metadata()

Skill-specific and ralph-specific modules can still exist but would delegate to the shared implementation.

Affected files

  • agr/skill.py — discovery functions
  • agr/ralph.py — near-duplicate discovery functions
  • agr/metadata.pywrite_skill_metadata vs write_ralph_metadata, stamp_skill_metadata vs stamp_ralph_metadata
  • agr/fetcher.py — parallel install paths for skills and ralphs

Context

Identified in architecture audit: docs/contributing/architecture-audit.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions