Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
63 lines (53 loc) · 1.86 KB
/
Copy pathProgram.cs
File metadata and controls
63 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using AccessibilityReport.Helpers;
using GitHub.Copilot;
Console.WriteLine("=== Accessibility Report Generator ===\n");
await using var client = new CopilotClient();
await client.StartAsync();
var ping = await client.PingAsync("workshop");
Console.WriteLine($"Connected to the Copilot runtime: {ping.Message}\n");
Console.Write("Enter URL to analyze: ");
var urlInput = Console.ReadLine()?.Trim();
if (string.IsNullOrWhiteSpace(urlInput))
{
Console.Error.WriteLine("Enter a URL to analyze.");
return;
}
if (!urlInput.Contains("://", StringComparison.Ordinal))
{
urlInput = $"https://{urlInput}";
}
if (!Uri.TryCreate(urlInput, UriKind.Absolute, out var targetUri) ||
targetUri.Scheme is not ("http" or "https"))
{
Console.Error.WriteLine("Enter an absolute HTTP or HTTPS URL.");
return;
}
var workingDirectory = Directory.GetCurrentDirectory();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Streaming = true,
OnPermissionRequest = WorkshopPermissionHandler.CreateForTarget(targetUri),
Tools =
[
AccessibilityRuleCatalog.CreateLookupTool(),
PlaywrightSnapshotReader.CreateTool(workingDirectory)
],
AvailableTools =
[
"accessibility_rule_lookup",
"read_latest_accessibility_snapshot",
"playwright-browser_navigate"
],
McpServers = new Dictionary<string, McpServerConfig>
{
["playwright"] = new McpStdioServerConfig
{
Command = "npx",
Args = ["-y", "@playwright/mcp@0.0.78", "--browser=msedge", "--output-dir", ".playwright-mcp", "--output-mode", "file"],
WorkingDirectory = workingDirectory,
Tools = ["browser_navigate"]
}
}
});
Console.WriteLine($"\nAnalyzing: {targetUri.AbsoluteUri}\n");
await ResponseStreamer.SendAndPrintAsync(session, Prompts.CreateReportPrompt(targetUri));