Refactor inline skill/sub-agent extraction to shared parser helpers#36247
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Consolidates duplicated inline-section parsing logic between the inline skill and sub-agent extractors into a shared helper file, reducing drift risk while preserving public API behavior.
Changes:
- New
pkg/parser/inline_section_helpers.gowith shared helpers (collectH2Positions,extractInlineSection,nextH2After,validateUniqueInlineSectionNames,engineConfigDir). inline_skill_extractor.goandsub_agent_extractor.gorefactored to delegate to the shared helpers; duplicated regexes and switch statements removed.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/inline_section_helpers.go | New shared helpers for H2 boundary discovery, section slicing, duplicate name validation, and engine config dir resolution. |
| pkg/parser/inline_skill_extractor.go | Removes duplicated skill-specific helpers and regex; delegates to shared helpers. |
| pkg/parser/sub_agent_extractor.go | Removes duplicated sub-agent helpers and regex; delegates to shared helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit |
| return nil | ||
| } | ||
|
|
||
| func engineConfigDir(engineID string, resourceType string) string { |
There was a problem hiding this comment.
@copilot use agentic engine interface to resolve this folder
There was a problem hiding this comment.
Done. engineConfigDir is removed from parser/inline_section_helpers.go. GetEngineSkillDir and GetEngineSubAgentDir are now in pkg/workflow/engine_config_dir.go and use AgentFileProvider.GetAgentManifestPathPrefixes() from the global EngineRegistry to resolve the directory — no more hardcoded switch. As a side-effect, the pi engine (and any future engines) now automatically get the correct directory without requiring a code change. The pi golden file was updated accordingly (.pi/agents/.pi/skills instead of the old .github/ default).
…ution Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
The issue identified near-clone parser implementations for inline skills and inline sub-agents, creating avoidable duplication and drift risk in core markdown section parsing. This PR addresses the highest-impact low-risk refactor by consolidating shared extraction mechanics while preserving existing public behavior.
What changed
pkg/parser/inline_section_helpers.gofor:name+content)inline_skill_extractor.gosub_agent_extractor.goGetEngineSkillDirandGetEngineSubAgentDirfrom theparserpackage topkg/workflow/engine_config_dir.go, where they now resolve the engine config directory via theAgentFileProviderinterface (GetAgentManifestPathPrefixes()) from the globalEngineRegistry— replacing a hardcoded switch statement with a single source of truth.Behavior preserved
ExtractInlineSkills,ExtractInlineSubAgents).Bonus fix
pi,crush,opencode,antigravity) now correctly resolve to their own config directories (e.g..pi/agents) instead of falling back to.github/.Result