Skip to content

Commit b92f4c0

Browse files
author
CyberdyneDevelopment
committed
Add project pattern filtering to build-fixer skill
- Add optional pattern parameter to WorkspaceManager.AnalyzeErrors() to filter projects by regex - Update GlobalServer endpoint to read pattern from request body and pass to WorkspaceManager - Update build-fixer skill to send command-line argument as pattern filter - Add System.Text.RegularExpressions and System.Text.Json using statements - Update AgentTestProcedure.md with clarified test criteria for pattern filtering - Pattern is matched against project names (e.g., "Bad" matches "TestProject.Bad") - Filtering happens before compilation for better performance
1 parent 3a338a1 commit b92f4c0

4 files changed

Lines changed: 73 additions & 16 deletions

File tree

AgentTestProcedure.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -700,36 +700,63 @@ Registered Solutions:
700700

701701
## PHASE 6: TEST build-fixer
702702

703+
**IMPORTANT:** The build-fixer skill now supports optional pattern filtering by project name.
704+
- Usage: `build-fixer [pattern]`
705+
- Pattern is matched as regex against project names (e.g., "Bad" matches "TestProject.Bad")
706+
- If no pattern provided, analyzes all projects in solution
707+
- Filtering happens BEFORE compilation, so only specified projects are analyzed
708+
703709
### Step 31: Analyze Bad Code Errors
704710

705-
**ACTION:** Use the build-fixer skill to analyze diagnostics for pattern "TestProject.Bad.*"
711+
**ACTION:** Use the build-fixer skill to analyze diagnostics with pattern "Bad"
712+
```bash
713+
~/.claude/skills/build-fixer/build-fixer "Bad"
714+
```
715+
716+
**PATTERN EXPLANATION:**
717+
- The pattern is a regex matched against PROJECT NAMES (not namespaces)
718+
- Pattern "Bad" matches "TestProject.Bad" project
719+
- This filters compilation to only analyze the Bad project
706720

707721
**EXPECTED RESULTS:**
708-
- At least 7+ compilation errors found
709-
- Errors from all 3 bad files:
722+
- At least 7+ compilation errors found (actual: 9 errors)
723+
- Errors ONLY from TestProject.Bad files:
710724
- BrokenCode.cs: CS1520 (missing return type), CS0246 (UndeclaredType), CS1002 (missing semicolon), CS1010 (unclosed string)
711-
- SyntaxErrors.cs: CS1513 (missing brace)
725+
- SyntaxErrors.cs: CS1513 (missing brace), CS1026 (missing paren), CS1002 (semicolon)
712726
- MissingUsings.cs: CS0103 (File not found), CS0246 (List not found)
713727
- Each error includes: errorCode, message, severity, filePath, line number
728+
- totalErrors: 9
714729

715730
**VERIFY:**
716731
- All syntax and semantic errors detected
717-
- Correct file paths and line numbers
732+
- Correct file paths and line numbers (all from TestProject.Bad directory)
718733
- Error messages are descriptive
734+
- NO errors from TestProject.Good files
719735

720736
---
721737

722738
### Step 32: Analyze Good Code (Should Have No Errors)
723739

724-
**ACTION:** Use the build-fixer skill to analyze diagnostics for pattern "TestProject.Good.*"
740+
**ACTION:** Use the build-fixer skill to analyze diagnostics with pattern "Good"
741+
```bash
742+
~/.claude/skills/build-fixer/build-fixer "Good"
743+
```
744+
745+
**PATTERN EXPLANATION:**
746+
- Pattern "Good" matches "TestProject.Good" project
747+
- This filters compilation to only analyze the Good project
748+
- TestProject.Good contains only valid code with no errors
725749

726750
**EXPECTED RESULTS:**
727-
- Skill returns success
728-
- Empty diagnostics array (no errors)
729-
- Good code passes compilation
751+
- Skill returns success (isSuccess: true)
752+
- Empty errors array: `"errors": []`
753+
- totalErrors: 0
754+
- totalWarnings: 0
755+
- Good code passes compilation cleanly
730756

731757
**VERIFY:**
732-
- No false positive errors
758+
- No false positive errors from Good project
759+
- Filter correctly excludes Bad project errors
733760
- Good code is correctly validated
734761

735762
---

Skills/build-fixer/executable/build-fixer/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444

4545
object BuildRequest(string[] args)
4646
{
47-
// Build fixer doesn't need any parameters - it analyzes the loaded solution
47+
// Optional pattern to filter by project name
48+
if (args.Length > 0)
49+
{
50+
return new { pattern = args[0] };
51+
}
4852
return new { };
4953
}
5054

src/CyberdyneDevelopment.RoslynTools.GlobalServer/Program.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.AspNetCore.SignalR;
55
using Microsoft.Build.Locator;
66
using System.Globalization;
7+
using System.Text.Json;
78

89
// Register MSBuild before creating any MSBuildWorkspace instances
910
if (!MSBuildLocator.IsRegistered)
@@ -328,9 +329,24 @@
328329
return Results.BadRequest(new { error = "Workspace not loaded" });
329330
}
330331

331-
var result = await manager.AnalyzeErrors();
332+
// Read pattern from request body
333+
string? pattern = null;
334+
try
335+
{
336+
var body = await JsonSerializer.DeserializeAsync<JsonElement>(context.Request.Body);
337+
if (body.TryGetProperty("pattern", out var patternElement))
338+
{
339+
pattern = patternElement.GetString();
340+
}
341+
}
342+
catch
343+
{
344+
// Ignore deserialization errors - pattern is optional
345+
}
346+
347+
var result = await manager.AnalyzeErrors(pattern);
332348

333-
await BroadcastActivity(hubContext, port, manager.SolutionPath ?? "", "BuildAnalyzer", $"Analyzed build errors");
349+
await BroadcastActivity(hubContext, port, manager.SolutionPath ?? "", "BuildAnalyzer", $"Analyzed build errors" + (pattern != null ? $" (pattern: {pattern})" : ""));
334350

335351
return result.IsSuccess
336352
? Results.Ok(result)

src/CyberdyneDevelopment.RoslynTools.Server/WorkspaceManager.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using DiffPlex.Chunkers;
99
using System.Collections.Immutable;
1010
using System.Globalization;
11+
using System.Text.RegularExpressions;
1112
using CyberdyneDevelopment.RoslynTools.CodeReader;
1213

1314
namespace CyberdyneDevelopment.RoslynTools.Server;
@@ -2427,7 +2428,8 @@ public async Task<CodeBlocksResult> ReadCodeBlocks(string projectName, string fi
24272428
/// <summary>
24282429
/// Analyze build errors and provide suggestions (ANALYSIS - not a transformation)
24292430
/// </summary>
2430-
public async Task<BuildFixerResult> AnalyzeErrors()
2431+
/// <param name="pattern">Optional regex pattern to filter by project name or namespace</param>
2432+
public async Task<BuildFixerResult> AnalyzeErrors(string? pattern = null)
24312433
{
24322434
await _workspaceLock.WaitAsync();
24332435
try
@@ -2440,8 +2442,16 @@ public async Task<BuildFixerResult> AnalyzeErrors()
24402442
var allErrors = new List<BuildError>();
24412443
var errorGroups = new Dictionary<string, List<Diagnostic>>(StringComparer.Ordinal);
24422444

2443-
// Get diagnostics from all projects
2444-
foreach (var project in _currentSolution.Projects)
2445+
// Filter projects if pattern provided
2446+
var projectsToAnalyze = _currentSolution.Projects;
2447+
if (!string.IsNullOrEmpty(pattern))
2448+
{
2449+
var regex = new Regex(pattern, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));
2450+
projectsToAnalyze = projectsToAnalyze.Where(p => regex.IsMatch(p.Name));
2451+
}
2452+
2453+
// Get diagnostics from filtered projects
2454+
foreach (var project in projectsToAnalyze)
24452455
{
24462456
var compilation = await project.GetCompilationAsync();
24472457
if (compilation == null) continue;

0 commit comments

Comments
 (0)