-
Notifications
You must be signed in to change notification settings - Fork 993
Introduce OM1 skills #2516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YuchengZhou821
wants to merge
2
commits into
main
Choose a base branch
from
Introduce-skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Introduce OM1 skills #2516
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from skills.loader import SkillEntry, SkillLoader | ||
| from skills.orchestrator import SkillOrchestrator, SkillProcessResult | ||
|
|
||
| __all__ = [ | ||
| "SkillEntry", | ||
| "SkillLoader", | ||
| "SkillOrchestrator", | ||
| "SkillProcessResult", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,169 @@ | ||||||||||
| import logging | ||||||||||
| import re | ||||||||||
| from dataclasses import dataclass, field | ||||||||||
| from pathlib import Path | ||||||||||
| from typing import Dict, List, Optional | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @dataclass | ||||||||||
| class SkillEntry: | ||||||||||
| """A parsed skill definition. | ||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| name : str | ||||||||||
| Unique skill identifier. | ||||||||||
| description : str | ||||||||||
| Short description shown in the prompt catalog. | ||||||||||
| instructions : str | ||||||||||
| Full Markdown body. | ||||||||||
| source_path : Path | ||||||||||
| Absolute path to the ``SKILL.md`` file. | ||||||||||
| requires_tools : list[str] | ||||||||||
| tools required by this skill. | ||||||||||
| max_rounds : int | ||||||||||
| Max execution rounds for this skill. | ||||||||||
| priority : int | ||||||||||
| Priority among all skills. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| name: str | ||||||||||
| description: str | ||||||||||
| instructions: str | ||||||||||
| source_path: Path | ||||||||||
| requires_tools: List[str] = field(default_factory=list) | ||||||||||
| max_rounds: int = 8 | ||||||||||
| priority: int = 10 | ||||||||||
|
|
||||||||||
|
|
||||||||||
| _FRONTMATTER_RE = re.compile(r"^---\s*\n(.*?)\n---\s*\n?(.*)$", re.DOTALL) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def _parse_frontmatter(content: str) -> tuple: | ||||||||||
| """Split a SKILL.md file into metadata and body. | ||||||||||
|
|
||||||||||
| Uses a simple line-based parser that handles flat key: value pairs | ||||||||||
| and list items. No external dependencies required. | ||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| tuple[dict, str] | ||||||||||
| Parsed metadata dictionary and the Markdown body. | ||||||||||
| """ | ||||||||||
| match = _FRONTMATTER_RE.match(content) | ||||||||||
| if not match: | ||||||||||
| return {}, content | ||||||||||
|
|
||||||||||
| yaml_block = match.group(1) | ||||||||||
| body = match.group(2).strip() | ||||||||||
|
|
||||||||||
| meta: Dict = {} | ||||||||||
| current_key: Optional[str] = None | ||||||||||
| current_list: Optional[List[str]] = None | ||||||||||
|
|
||||||||||
| for line in yaml_block.splitlines(): | ||||||||||
| stripped = line.strip() | ||||||||||
| if not stripped or stripped.startswith("#"): | ||||||||||
| continue | ||||||||||
|
|
||||||||||
| if stripped.startswith("- ") and current_key: | ||||||||||
| value = stripped[2:].strip().strip('"').strip("'") | ||||||||||
| if current_list is not None: | ||||||||||
| current_list.append(value) | ||||||||||
| continue | ||||||||||
|
|
||||||||||
| if ":" in stripped: | ||||||||||
| key, _, value = stripped.partition(":") | ||||||||||
| key = key.strip() | ||||||||||
| value = value.strip().strip('"').strip("'") | ||||||||||
|
|
||||||||||
| if value: | ||||||||||
| meta[key] = value | ||||||||||
| current_key = key | ||||||||||
| current_list = None | ||||||||||
| else: | ||||||||||
| current_key = key | ||||||||||
| current_list = [] | ||||||||||
| meta[key] = current_list | ||||||||||
|
|
||||||||||
| return meta, body | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class SkillLoader: | ||||||||||
| """Scan and parse SKILL.md files from a skills directory. | ||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| skills_dir : str | ||||||||||
| Root directory containing skill subdirectories. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| def __init__(self, skills_dir: str) -> None: | ||||||||||
| self.skills_dir = Path(skills_dir) | ||||||||||
| self.skills: Dict[str, SkillEntry] = {} | ||||||||||
| self._load_all() | ||||||||||
|
|
||||||||||
| def _load_all(self) -> None: | ||||||||||
| """Scan and parse all SKILL.md files.""" | ||||||||||
| if not self.skills_dir.exists(): | ||||||||||
| logging.warning(f"Skills directory does not exist: {self.skills_dir}") | ||||||||||
| return | ||||||||||
|
|
||||||||||
| count = 0 | ||||||||||
| for child in sorted(self.skills_dir.iterdir()): | ||||||||||
| if not child.is_dir(): | ||||||||||
| continue | ||||||||||
| skill_file = child / "SKILL.md" | ||||||||||
| if not skill_file.exists(): | ||||||||||
| continue | ||||||||||
| try: | ||||||||||
| entry = self._parse_skill(skill_file) | ||||||||||
| self.skills[entry.name] = entry | ||||||||||
| count += 1 | ||||||||||
| logging.info(f"Loaded skill: {entry.name} ({skill_file})") | ||||||||||
| except Exception as exc: | ||||||||||
| logging.error(f"Failed to load skill from {skill_file}: {exc}") | ||||||||||
|
Comment on lines
+124
to
+125
|
||||||||||
| except Exception as exc: | |
| logging.error(f"Failed to load skill from {skill_file}: {exc}") | |
| except Exception: | |
| logging.exception(f"Failed to load skill from {skill_file}") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new skill-recall branch in _tick() introduces a multi-round control-flow (dispatch OM1 actions, read skills, recall LLM, and then proceed into MCP). There’s no unit test exercising this behavior (including deduplication across rounds and ensuring the MCP recall prompt inherits the augmented prompt). Adding a focused test in tests/runtime/test_cortex.py that simulates an LLM returning read_skill actions and verifies the subsequent recall + prompt propagation would help prevent regressions.