| 1 | #nullable enable |
| 2 | |
| 3 | using CascadeIDE.Features.Agent.Environment; |
| 4 | using CascadeIDE.Features.Agent.Harness; |
| 5 | |
| 6 | namespace CascadeIDE.ViewModels; |
| 7 | |
| 8 | /// <summary>Agent harness: auto-verify coalescing after .cs writes (ADR 0166 interim).</summary> |
| 9 | public partial class MainWindowViewModel |
| 10 | { |
| 11 | private AgentVerifyCoalescer? _autoVerifyCoalescer; |
| 12 | |
| 13 | private AgentVerifyCoalescer AutoVerifyCoalescer => |
| 14 | _autoVerifyCoalescer ??= new AgentVerifyCoalescer( |
| 15 | _settings.Agent.Environment.CoalesceWindowMs, |
| 16 | FireCoalescedAutoVerify); |
| 17 | |
| 18 | private void FireCoalescedAutoVerify() |
| 19 | { |
| 20 | var path = Workspace.SolutionPath; |
| 21 | if (string.IsNullOrWhiteSpace(path)) |
| 22 | return; |
| 23 | |
| 24 | if (!AgentVerifyPolicyParser.TryParse(_settings.Agent.Environment.DefaultVerifyPolicy, out var policy)) |
| 25 | policy = AgentVerifyPolicy.Standard; |
| 26 | |
| 27 | UiScheduler.Default.Post(() => _agentEnvironment.StartVerify(path, policy)); |
| 28 | } |
| 29 | |
| 30 | internal void MaybeScheduleAutoVerifyAfterCsWrite(string? filePath) |
| 31 | { |
| 32 | if (!_settings.Agent.Harness.AutoVerifyAfterCsWrite) |
| 33 | return; |
| 34 | |
| 35 | if (string.IsNullOrWhiteSpace(filePath) |
| 36 | || !filePath.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)) |
| 37 | return; |
| 38 | |
| 39 | if (string.IsNullOrWhiteSpace(Workspace.SolutionPath)) |
| 40 | return; |
| 41 | |
| 42 | AutoVerifyCoalescer.Schedule(); |
| 43 | } |
| 44 | |
| 45 | internal bool ResolveAcpAutoInjectIdeMcp() |
| 46 | { |
| 47 | if (_settings.Agent.Harness.SuppressAcpIdeStdioInject) |
| 48 | return false; |
| 49 | |
| 50 | return AcpAutoInjectIdeMcp; |
| 51 | } |
| 52 | } |
| 53 | |