feat: add symlink and frontmatter support for shared agent references#138
Merged
Conversation
**Added:** - New `agentsDir` fallback in `loadReferences` to resolve symlinked references (e.g. `references/foo.md -> ../../skills/foo/SKILL.md`) that point outside the agent directory but within the shared agents root - YAML frontmatter stripping via `stripPromptFrontmatter` so SKILL.md files used as references inject only their body content, not host metadata - Comprehensive test suite in `agent/references_test.go` covering symlinked shared references with frontmatter stripping, plain local references without frontmatter, and missing reference error propagation with the retry path in place **Changed:** - `loadReferences` signature extended with `agentsDir string` parameter to support the wide-root retry; all three call sites in `BuildBundleWithOptions` and `BuildBundleInline` updated accordingly - Existing internal tests in `bundle_internal_test.go` updated to pass empty string for `agentsDir` to preserve original behaviour - Added doc comment to `loadReferences` explaining the symlink resolution strategy and frontmatter stripping rationale
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Key Changes:
loadReferencesto accept anagentsDirfallback root, enabling references that are symlinks into shared skill directories to resolve correctlyAdded:
loadReferencesnow retries the lookup usingagentsDiras the traversal root, allowing symlinks likereferences/foo.md -> ../../skills/foo/SKILL.mdto resolve correctlystripPromptFrontmatterbefore injection so that SKILL.md files doubling as references don't pollute the prompt with metadata fields likenameanddescriptionagent/references_test.gocovering symlink resolution with frontmatter stripping, plain local references with no frontmatter, and missing-file error behavior with the agentsDir retry path activeChanged:
loadReferencessignature extended from(agentPath string, refs []string)to(agentPath, agentsDir string, refs []string)- all three call sites inBuildBundleWithOptionsandBuildBundleInlineupdated accordingly, and existing internal tests updated to pass an empty string foragentsDirto preserve prior behaviorloadReferencesexplaining the fallback lookup strategy and frontmatter stripping rationale