Skip to content

Commit db249e4

Browse files
IEvangelistJamesNK
andauthored
Refactor agent environment scanners and add standard location support (#15022)
Co-authored-by: James Newton-King <james@newtonking.com>
1 parent a7375ab commit db249e4

39 files changed

Lines changed: 3878 additions & 903 deletions

src/Aspire.Cli/Agents/AgentEnvironmentScanContext.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Aspire.Cli.Agents;
99
internal sealed class AgentEnvironmentScanContext
1010
{
1111
private readonly List<AgentEnvironmentApplicator> _applicators = [];
12-
private readonly HashSet<string> _skillFileApplicatorPaths = new(StringComparer.OrdinalIgnoreCase);
1312
private readonly HashSet<string> _skillBaseDirectories = new(StringComparer.OrdinalIgnoreCase);
1413

1514
/// <summary>
@@ -30,25 +29,6 @@ internal sealed class AgentEnvironmentScanContext
3029
/// </summary>
3130
public bool PlaywrightApplicatorAdded { get; set; }
3231

33-
/// <summary>
34-
/// Checks if a skill file applicator has already been added for the specified path.
35-
/// </summary>
36-
/// <param name="skillRelativePath">The relative path to the skill file.</param>
37-
/// <returns>True if an applicator has already been added for this path.</returns>
38-
public bool HasSkillFileApplicator(string skillRelativePath)
39-
{
40-
return _skillFileApplicatorPaths.Contains(skillRelativePath);
41-
}
42-
43-
/// <summary>
44-
/// Marks a skill file path as having an applicator added.
45-
/// </summary>
46-
/// <param name="skillRelativePath">The relative path to the skill file.</param>
47-
public void MarkSkillFileApplicatorAdded(string skillRelativePath)
48-
{
49-
_skillFileApplicatorPaths.Add(skillRelativePath);
50-
}
51-
5232
/// <summary>
5333
/// Adds an applicator to the collection of detected agent environments.
5434
/// </summary>

src/Aspire.Cli/Agents/ClaudeCode/ClaudeCodeAgentEnvironmentScanner.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ internal sealed class ClaudeCodeAgentEnvironmentScanner : IAgentEnvironmentScann
1717
private const string ClaudeCodeFolderName = ".claude";
1818
private const string McpConfigFileName = ".mcp.json";
1919
private const string AspireServerName = "aspire";
20-
private static readonly string s_skillFilePath = Path.Combine(".claude", "skills", CommonAgentApplicators.AspireSkillName, "SKILL.md");
2120
private static readonly string s_skillBaseDirectory = Path.Combine(".claude", "skills");
22-
private const string SkillFileDescription = "Create Aspire skill file (.claude/skills/aspire/SKILL.md)";
2321

2422
private readonly IClaudeCodeCliRunner _claudeCodeCliRunner;
2523
private readonly PlaywrightCliInstaller _playwrightCliInstaller;
@@ -76,13 +74,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
7674

7775
// Register Playwright CLI installation applicator
7876
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
79-
80-
// Try to add skill file applicator for Claude Code
81-
CommonAgentApplicators.TryAddSkillFileApplicator(
82-
context,
83-
context.RepositoryRoot,
84-
s_skillFilePath,
85-
SkillFileDescription);
8677
}
8778
else
8879
{
@@ -107,13 +98,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
10798

10899
// Register Playwright CLI installation applicator
109100
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
110-
111-
// Try to add skill file applicator for Claude Code
112-
CommonAgentApplicators.TryAddSkillFileApplicator(
113-
context,
114-
context.RepositoryRoot,
115-
s_skillFilePath,
116-
SkillFileDescription);
117101
}
118102
else
119103
{

src/Aspire.Cli/Agents/CommonAgentApplicators.cs

Lines changed: 185 additions & 96 deletions
Large diffs are not rendered by default.

src/Aspire.Cli/Agents/CopilotCli/CopilotCliAgentEnvironmentScanner.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ internal sealed class CopilotCliAgentEnvironmentScanner : IAgentEnvironmentScann
1717
private const string CopilotFolderName = ".copilot";
1818
private const string McpConfigFileName = "mcp-config.json";
1919
private const string AspireServerName = "aspire";
20-
private static readonly string s_skillFilePath = Path.Combine(".github", "skills", CommonAgentApplicators.AspireSkillName, "SKILL.md");
2120
private static readonly string s_skillBaseDirectory = Path.Combine(".github", "skills");
22-
private const string SkillFileDescription = "Create Aspire skill file (.github/skills/aspire/SKILL.md)";
2321

2422
private readonly ICopilotCliRunner _copilotCliRunner;
2523
private readonly PlaywrightCliInstaller _playwrightCliInstaller;
@@ -75,13 +73,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
7573

7674
// Register Playwright CLI installation applicator
7775
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
78-
79-
// Try to add skill file applicator for GitHub Copilot
80-
CommonAgentApplicators.TryAddSkillFileApplicator(
81-
context,
82-
context.RepositoryRoot,
83-
s_skillFilePath,
84-
SkillFileDescription);
8576
return;
8677
}
8778

@@ -113,13 +104,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
113104

114105
// Register Playwright CLI installation applicator
115106
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
116-
117-
// Try to add skill file applicator for GitHub Copilot
118-
CommonAgentApplicators.TryAddSkillFileApplicator(
119-
context,
120-
context.RepositoryRoot,
121-
s_skillFilePath,
122-
SkillFileDescription);
123107
}
124108

125109
/// <summary>

src/Aspire.Cli/Agents/OpenCode/OpenCodeAgentEnvironmentScanner.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ internal sealed class OpenCodeAgentEnvironmentScanner : IAgentEnvironmentScanner
1616
{
1717
private const string OpenCodeConfigFileName = "opencode.jsonc";
1818
private const string AspireServerName = "aspire";
19-
private static readonly string s_skillFilePath = Path.Combine(".opencode", "skill", CommonAgentApplicators.AspireSkillName, "SKILL.md");
2019
private static readonly string s_skillBaseDirectory = Path.Combine(".opencode", "skill");
21-
private const string SkillFileDescription = "Create Aspire skill file (.opencode/skill/aspire/SKILL.md)";
2220

2321
private readonly IOpenCodeCliRunner _openCodeCliRunner;
2422
private readonly PlaywrightCliInstaller _playwrightCliInstaller;
@@ -70,13 +68,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
7068

7169
// Register Playwright CLI installation applicator
7270
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
73-
74-
// Try to add skill file applicator for OpenCode
75-
CommonAgentApplicators.TryAddSkillFileApplicator(
76-
context,
77-
context.RepositoryRoot,
78-
s_skillFilePath,
79-
SkillFileDescription);
8071
}
8172
else
8273
{
@@ -93,13 +84,6 @@ public async Task ScanAsync(AgentEnvironmentScanContext context, CancellationTok
9384

9485
// Register Playwright CLI installation applicator
9586
CommonAgentApplicators.AddPlaywrightCliApplicator(context, _playwrightCliInstaller, s_skillBaseDirectory);
96-
97-
// Try to add skill file applicator for OpenCode
98-
CommonAgentApplicators.TryAddSkillFileApplicator(
99-
context,
100-
context.RepositoryRoot,
101-
s_skillFilePath,
102-
SkillFileDescription);
10387
}
10488
else
10589
{

src/Aspire.Cli/Agents/Playwright/IPlaywrightCliRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal interface IPlaywrightCliRunner
2020
/// <summary>
2121
/// Installs Playwright CLI skill files into the workspace.
2222
/// </summary>
23-
/// <param name="workingDirectory">The directory in which to run the skill installation command.</param>
23+
/// <param name="workingDirectory">The directory to run the command from (skill files are written relative to this).</param>
2424
/// <param name="cancellationToken">A token to cancel the operation.</param>
2525
/// <returns>True if skill installation succeeded, false otherwise.</returns>
2626
Task<bool> InstallSkillsAsync(string workingDirectory, CancellationToken cancellationToken);

0 commit comments

Comments
 (0)