Skip to content

feat: add symlink and frontmatter support for shared agent references#138

Merged
l50 merged 1 commit into
mainfrom
shared-reference-resolution
Jul 2, 2026
Merged

feat: add symlink and frontmatter support for shared agent references#138
l50 merged 1 commit into
mainfrom
shared-reference-resolution

Conversation

@l50

@l50 l50 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Key Changes:

  • Extended loadReferences to accept an agentsDir fallback root, enabling references that are symlinks into shared skill directories to resolve correctly
  • Added automatic stripping of YAML frontmatter from reference content so SKILL.md files used as references don't inject host metadata into prompts
  • Added a dedicated test file covering the new symlink resolution, local file, and missing file error scenarios

Added:

  • Shared symlink resolution for references - when an agent-rooted read fails, loadReferences now retries the lookup using agentsDir as the traversal root, allowing symlinks like references/foo.md -> ../../skills/foo/SKILL.md to resolve correctly
  • YAML frontmatter stripping - reference content is passed through stripPromptFrontmatter before injection so that SKILL.md files doubling as references don't pollute the prompt with metadata fields like name and description
  • Comprehensive reference loading tests in agent/references_test.go covering symlink resolution with frontmatter stripping, plain local references with no frontmatter, and missing-file error behavior with the agentsDir retry path active

Changed:

  • loadReferences signature extended from (agentPath string, refs []string) to (agentPath, agentsDir string, refs []string) - all three call sites in BuildBundleWithOptions and BuildBundleInline updated accordingly, and existing internal tests updated to pass an empty string for agentsDir to preserve prior behavior
  • Inline documentation added to loadReferences explaining the fallback lookup strategy and frontmatter stripping rationale

**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

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@l50 l50 merged commit 1b7dc21 into main Jul 2, 2026
5 checks passed
@l50 l50 deleted the shared-reference-resolution branch July 2, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant