Skip to content

fix(extension): inline agent content instead of path stubs in packaged plugins#907

Open
stablegenius49 wants to merge 1 commit intomicrosoft:mainfrom
stablegenius49:pr-factory/issue-785-inline-agent-content
Open

fix(extension): inline agent content instead of path stubs in packaged plugins#907
stablegenius49 wants to merge 1 commit intomicrosoft:mainfrom
stablegenius49:pr-factory/issue-785-inline-agent-content

Conversation

@stablegenius49
Copy link
Contributor

@stablegenius49 stablegenius49 commented Mar 6, 2026

Pull Request

Description

When plugins are packaged in non-symlink environments (e.g., Windows without Developer Mode, or when Copilot CLI installs plugins), agent files were being written as single-line relative path references instead of actual YAML frontmatter content. This caused Copilot CLI to fail with 'frontmatter is malformed' errors on all agent files.

Root Cause

The New-PluginLink function was writing text stubs containing relative paths when symlinks were not supported. The Copilot CLI expects agent .md files to begin with valid YAML frontmatter (--- delimited block with at least a description field), but received single-line path strings instead.

Fix

Changed New-PluginLink to copy the actual file content when symlinks are not supported, ensuring agent files have valid YAML frontmatter in installed plugins.

Before:

else {
    [System.IO.File]::WriteAllText($DestinationPath, $relativePath)
}

After:

else {
    # Copy the actual file content instead of writing a path reference
    # This ensures agent files have valid YAML frontmatter in installed plugins
    Copy-Item -Path $SourcePath -Destination $DestinationPath -Force
}

Related Issue(s)

Fixes #785

Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)
  • Copilot skill (.github/skills/*/SKILL.md)

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Testing

This fix ensures:

  • Agent files have valid YAML frontmatter when installed via copilot plugin install
  • Commands, instructions, and skills continue to work correctly
  • Plugin packaging works in both symlink and non-symlink environments

Validation

  • Local testing shows agent files now contain actual content instead of path references
  • The fix maintains the same directory structure and behavior for symlink environments
  • No changes to symlink behavior when supported

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

Required Automated Checks

The following validation commands must pass before merging:

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes

When plugins are packaged in non-symlink environments (e.g., Windows
without Developer Mode), agent files were being written as single-line
relative path references instead of actual YAML frontmatter content.
This caused Copilot CLI to fail with 'frontmatter is malformed' errors
on all agent files.

The fix changes New-PluginLink to copy actual file content when symlinks
are not supported, ensuring agent files have valid YAML frontmatter in
installed plugins.

Fixes microsoft#785

Co-Authored-By: Stable Genius <noreply@anthropic.com>
@stablegenius49 stablegenius49 requested a review from a team as a code owner March 6, 2026 01:30
@WilliamBerryiii
Copy link
Member

WilliamBerryiii commented Mar 6, 2026

@ Maintainers - please hold on this until we can fully confirm the backing issue is as described and we're sure of the approach. I'm on a windows box and can test this, but won't have time for a bit. @peterbryntesson .... if you have access to windows bare metal ... this would be a cool one to run to ground to make sure this fix is correct and we can generate these files correctly (e.g. the fake symlinks) without having to run the regenerate plugins in Admin via powershell.

@WilliamBerryiii
Copy link
Member

@stablegenius49 - please sign the LCA

@WilliamBerryiii
Copy link
Member

@stablegenius49 - I'm going to take over this branch and complete the work here so that you contribution marker remains. I really appreciate you taking a run at this one and your solution is close, but needs some additions. Should have this completed and tested today, but not sure I'll be able to cut a release until next week due to the other changes we've already merged down into main.

@WilliamBerryiii
Copy link
Member

We've updated the PR description to align with the current pull request template. All original content has been preserved and relocated into the appropriate template sections. No action needed on your end — though you're welcome to review the updated description and fill in any remaining sections (testing details, checklist confirmations, etc.) at your convenience.

@stablegenius49
Copy link
Contributor Author

@microsoft-github-policy-service agree

@WilliamBerryiii WilliamBerryiii changed the title fix: inline agent content instead of path stubs in packaged plugins fix(extension): inline agent content instead of path stubs in packaged plugins Mar 8, 2026
@WilliamBerryiii
Copy link
Member

PR Compliance Update — Added the missing (extension) scope to the PR title to align with the project's Conventional Commits convention:

  • Before: fix: inline agent content instead of path stubs in packaged plugins
  • After: fix(extension): inline agent content instead of path stubs in packaged plugins

The PR body and Fixes #785 reference were already correctly formatted. Thank you for the contribution! 🙏

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.

fix: Frontmatter formatter error using hve-core agents in Copilot CLI

2 participants