Add role tag parsing to skill loader

t-308·WorkTask·
·
·
·Omni/Agent/Skills.hs
Created1 month ago·Updated1 month ago

Dependencies

Description

Edit

Summary

Extend the skill loader to parse <role:X> tags in skill files, load the referenced role definitions, and inject them into the skill content before returning to Claude.

Current State

Skills are loaded as plain text from SKILL.md files. See Omni/Agent/Skills.hs, specifically loadSkill and executeSkill functions.

Target Behavior

When a skill contains <role:product> tags:

1. Parse: Find all unique <role:X> tags in the skill body 2. Load: Load each referenced role from Omni/Agent/Roles/X.md 3. Inject: Prepend role definitions to the skill body 4. Return: Pass the enriched content to Claude

Example

Input skill (SKILL.md):

# Feature Development

<role:product>
Clarify requirements...
</role>

<role:engineer>
Implement...
</role>

Output (what Claude sees):

## Role Definitions

### Product
When thinking as Product, focus on:
- User value...

### Engineer
When thinking as Engineer, focus on:
- Correctness...

---

# Feature Development

<role:product>
Clarify requirements...
</role>

<role:engineer>
Implement...
</role>

Implementation

-- New function to parse role tags
parseRoleTags :: Text -> [Text]
parseRoleTags body = 
  -- Find all <role:X> patterns, extract unique role names
  -- e.g., "<role:product>" -> "product"

-- New function to load a role definition
loadRole :: Text -> IO (Either Text Text)
loadRole roleName = do
  let path = "Omni/Agent/Roles/" <> Text.unpack (capitalize roleName) <> ".md"
  -- Read file, parse frontmatter, return body
  
-- Modify loadSkill to inject roles
loadSkill :: Text -> Text -> IO (Either Text Skill)
loadSkill userName skillName' = do
  -- ... existing code to load skill ...
  let roleNames = parseRoleTags body
  roleDefinitions <- traverse loadRole roleNames
  let enrichedBody = formatRoleDefinitions roleDefinitions <> "\n---\n\n" <> body
  -- ... return skill with enrichedBody ...

Role File Location

Roles are in Omni/Agent/Roles/:

  • Product.md (note: capitalized filenames per repo convention)
  • Designer.md
  • Engineer.md
  • Reviewer.md

Edge Cases

  • Role not found: Return error listing available roles
  • No role tags: Return skill unchanged (backward compatible)
  • Duplicate role tags: Load each role only once
  • Malformed tags: <role:> or <role> without name - ignore or warn

Testing

1. Create a test skill with role tags 2. Verify roles are parsed correctly 3. Verify role definitions are loaded and injected 4. Verify skills without role tags still work 5. Verify missing role produces helpful error 6. Run bild --test Omni/Agent/Skills.hs

Acceptance Criteria

  • [ ] parseRoleTags extracts role names from <role:X> tags
  • [ ] loadRole loads role definition from Omni/Agent/Roles/X.md
  • [ ] loadSkill injects role definitions at top of skill body
  • [ ] Backward compatible - skills without role tags work unchanged
  • [ ] Missing role produces clear error message
  • [ ] Unit tests for parsing and loading

Timeline (2)

🔄[human]Open → InProgress1 month ago
🔄[human]InProgress → Done1 month ago