Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Description

Extends aspire mcp init with an applicator-based approach for configuring agent environments. Users are presented with a list of available applicators and can select which configurations to apply.

Changes

Applicator-Based Configuration

  • Removed prompts in favor of applicators that users can individually select
  • Each detected agent environment offers up to 3 applicators:
    • Configure Aspire MCP server (if not already configured)
    • Configure Playwright MCP server (if not already configured, offered even when Aspire MCP exists)
    • Create agent instructions file (offered once across all scanners, only when AGENTS.md doesn't exist)

Context Extension

  • AgentEnvironmentScanContext includes:
    • AgentInstructionsApplicatorAdded - flag to ensure agent instructions applicator is added only once across all scanners

API Refactoring

  • IAgentEnvironmentDetector.DetectAsync() signature simplified to accept AgentEnvironmentScanContext and CancellationToken (2 parameters instead of 5)
  • Context construction moved from AgentEnvironmentDetector to McpInitCommand for better separation of concerns

Scanner Behavior

  • All four scanners (VS Code, Claude Code, OpenCode, Copilot CLI) add separate applicators for:
    • Aspire MCP server configuration (only if not already configured)
    • Playwright MCP server configuration (npx -y @playwright/mcp@latest) (only if not already configured)
    • Agent instructions file creation (via CommonAgentApplicators.TryAddAgentInstructionsApplicator)
  • Each applicator checks configuration state independently
  • Scanners are focused on MCP configuration, with agent instructions handled centrally

Agent Instructions

  • Centralized instruction file creation in CommonAgentApplicators helper class
  • Creates AGENTS.md at workspace root only if it doesn't already exist
  • Simple file existence check:
    • If AGENTS.md exists, no applicator is offered (regardless of content)
    • If AGENTS.md doesn't exist, offers to create it
    • Only creates AGENTS.md (no fallback to alternative filenames)
  • Single file standard across all agent environments
  • Applicator added only once via context flag

Example Output
When Aspire and Playwright applicators are selected for VS Code, mcp.json includes:

{
  "servers": {
    "aspire": {
      "type": "stdio",
      "command": "aspire",
      "args": ["mcp", "start"]
    },
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@playwright/mcp@latest"]
    }
  }
}

When the agent instructions applicator is selected, a file is created at the workspace root as AGENTS.md:

# Copilot instructions

This repository is set up to use Aspire. Aspire is an orchestrator for the entire application and will take care of configuring dependencies, building, and running the application. The resources that make up the application are defined in `apphost.cs` including application code and external dependencies.

...

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No
Original prompt

Add a prompt to the aspire mcp init that prompts whether the command should add agent environment specific instructions files based on the selected agent environments.

This selection will need to be passed into the the applicator as a context object with this option selected. If the context object has a flag that says that they do want the agent instructions created then applicators that support dropping agent instructions can create the files.

Also add a prompt to ask whether they want to pre-configure playwright MCP server (this should be added to the context as well).

Here is an example of the agent instructions that we should use. For the actual content of the agent instructions - for now just create a placeholder resource.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add prompts for agent environment instructions and Playwright configuration Add prompts to aspire mcp init for agent instructions and Playwright MCP server configuration Dec 8, 2025
Copilot AI requested a review from mitchdenny December 8, 2025 02:22
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13375

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13375"

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13375

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13375"

@mitchdenny
Copy link
Member

@copilot lift the instructions generation logic out of the scanners (and remove the flag from the scanner context). It looks like AGENTS.md file is pretty much the standard across most environments. If the AGENTS.md file does not exist create it, if it does exist create AGENTS.aspire.md.

Copy link
Contributor Author

Copilot AI commented Dec 8, 2025

@copilot lift the instructions generation logic out of the scanners (and remove the flag from the scanner context). It looks like AGENTS.md file is pretty much the standard across most environments. I...

Done in 561c11e. Removed agent-specific instruction file creation from all scanners and centralized it in McpInitCommand. Now creates AGENTS.md at the workspace root, or AGENTS.aspire.md if AGENTS.md already exists. The CreateAgentInstructions flag has been removed from the scanner context.

@mitchdenny
Copy link
Member

@copilot Change the logic so that instead of prompting for instruction files and playwright it just adds additional applicators.

In the case of the agent file we only want it added once so we need a flag on the context object which notes that the agent instructions were added so that subsequent scanners don't add an applicator for it. This means that the logic to add a playwright mcp ends up being a completely different applicator.

Make sure that even if the aspire MCP is already present that it will still prompt for the playwright one if it is not present.

Copy link
Contributor Author

Copilot AI commented Dec 8, 2025

@copilot Change the logic so that instead of prompting for instruction files and playwright it just adds additional applicators.

In the case of the agent file we only want it added once so we need ...

Done in ebef8fe. Changed the implementation to add applicators instead of prompts:

  1. Removed all prompts - Users now select from a list of applicators
  2. Separate applicators - Each scanner adds up to 3 applicators:
    • Configure Aspire MCP server
    • Configure Playwright MCP server
    • Create agent instructions file (added once across all scanners via AgentInstructionsApplicatorAdded flag)
  3. Playwright always offered - The Playwright applicator is added even if Aspire MCP is already configured, as long as Playwright itself isn't configured yet
  4. Independent checks - Each applicator checks configuration state independently

Users can now select any combination of applicators they want to apply.

Copilot AI changed the title Add prompts to aspire mcp init for agent instructions and Playwright MCP server configuration Add applicators to aspire mcp init for agent instructions and Playwright MCP server configuration Dec 8, 2025
@mitchdenny mitchdenny marked this pull request as ready for review December 9, 2025 02:07
Copilot AI review requested due to automatic review settings December 9, 2025 02:07
@mitchdenny
Copy link
Member

@copilot when the AGENTS.md file already exists check if it is the same as the content of the agent instructions we want to drop before proposing the creation of AGENTS.aspire.md. If the content is the same then don't create that applicator.

Copilot AI and others added 18 commits December 9, 2025 22:00
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
… individual parameters

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
…anners

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
- Removed CreateAgentInstructions flag from AgentEnvironmentScanContext
- Removed all Create*InstructionsAsync methods from individual scanners
- Added centralized CreateAgentInstructionsAsync in McpInitCommand
- Creates AGENTS.md, or AGENTS.aspire.md if AGENTS.md already exists
- Updated all tests to remove CreateAgentInstructions references

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
… and Playwright

- Removed ConfirmAsync prompts from McpInitCommand
- Added AgentInstructionsApplicatorAdded flag to AgentEnvironmentScanContext
- Created CommonAgentApplicators helper with TryAddAgentInstructionsApplicator
- Updated all four scanners to add separate applicators for:
  - Aspire MCP configuration
  - Playwright MCP configuration (only if not already configured)
  - Agent instructions (once across all scanners)
- Each applicator can be individually selected by users
- Playwright applicators are offered even if Aspire MCP is already configured
- Updated all tests to remove ConfigurePlaywrightMcpServer references

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
- Modified TryAddAgentInstructionsApplicator to read and compare AGENTS.md content
- Only proposes AGENTS.aspire.md if AGENTS.md exists with different content
- Skips applicator creation if AGENTS.md already has the same content
- Added comprehensive tests for all content comparison scenarios

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Check file existence before adding agent instructions applicator
- Only propose AGENTS.aspire.md when AGENTS.md exists with different content
- Update applicator description to show which file will be created
- Fix spelling errors in agent instructions content
- Improve test assertions to verify all applicators are empty when everything is configured
- Address PR review feedback from copilot-pull-request-reviewer bot

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
@mitchdenny mitchdenny force-pushed the copilot/add-agent-instructions-prompt branch from ba5cf02 to 717ecba Compare December 9, 2025 11:00
@mitchdenny
Copy link
Member

@copilot remove the logic to generate the AGENTS.aspire.md as a fallback. If there is a AGENTS.md file we just won't offer to create one.

…ists

- Removed AGENTS.aspire.md fallback logic entirely
- If AGENTS.md exists, don't offer to create instructions at all
- Simplified TryAddAgentInstructionsApplicator to check only for AGENTS.md existence
- Simplified CreateAgentInstructionsAsync to only create AGENTS.md
- Updated tests to reflect simplified behavior
- Removed tests for AGENTS.aspire.md creation and content comparison

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot remove the logic to generate the AGENTS.aspire.md as a fallback. If there is a AGENTS.md file we just won't offer to create one.

Done in the above commit. Removed AGENTS.aspire.md fallback logic - now the applicator is only offered when AGENTS.md doesn't exist, and it only creates AGENTS.md.

auto-merge was automatically disabled December 10, 2025 00:50

Head branch was pushed to by a user without write access

@mitchdenny mitchdenny merged commit 5632ef1 into main Dec 10, 2025
565 of 571 checks passed
@mitchdenny mitchdenny deleted the copilot/add-agent-instructions-prompt branch December 10, 2025 02:15
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Dec 10, 2025
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.

Aspire CLI can provide optimized instructions to enhance agent behavior when using Aspire.

3 participants