| 1 | using CascadeIDE.ViewModels; |
| 2 | using CascadeIDE.Features.IdeMcp.Application; |
| 3 | using CascadeIDE.Models; |
| 4 | using CascadeIDE.Services; |
| 5 | |
| 6 | namespace CascadeIDE.Features.IdeMcp.Application; |
| 7 | |
| 8 | internal sealed partial class MainWindowIdeMcpHost |
| 9 | { |
| 10 | |
| 11 | public Task<string> GitStatusAsync() => |
| 12 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitStatusAsync()); |
| 13 | |
| 14 | public Task<string> GitDiffAsync(string? path, bool staged) => |
| 15 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitDiffAsync(path, staged)); |
| 16 | |
| 17 | public Task<string> GitLogAsync(int n) => |
| 18 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitLogAsync(n)); |
| 19 | |
| 20 | public Task<string> GitFetchAsync(string? remote, bool all, bool prune, bool dryRun) => |
| 21 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitFetchAsync(remote, all, prune, dryRun)); |
| 22 | |
| 23 | public Task<string> GitPullAsync(string? remote, string? branch, bool ffOnly, bool dryRun) => |
| 24 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitPullAsync(remote, branch, ffOnly, dryRun)); |
| 25 | |
| 26 | public Task<string> GitBranchAsync(string? action, string? name, string? startPoint, bool force) => |
| 27 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitBranchAsync(action, name, startPoint, force)); |
| 28 | |
| 29 | public Task<string> GitShowAsync(string rev, string? path, bool statOnly) => |
| 30 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitShowAsync(rev, path, statOnly)); |
| 31 | |
| 32 | public Task<string> GitSubmoduleAsync(string? action, string? path, bool recursive) => |
| 33 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitSubmoduleAsync(action, path, recursive)); |
| 34 | |
| 35 | public Task<string> GitPreflightAsync(bool staged, bool includeUntracked, bool includePatches) => |
| 36 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitPreflightAsync(staged, includeUntracked, includePatches)); |
| 37 | |
| 38 | public Task<string> GitPreflightFixSafeAsync(bool includePatches) => |
| 39 | IdeMcpGitOrchestrator.RunWithWorkspaceSession(_host.McpGitRunner, _host.McpGetWorkspacePath(), s => s.GitPreflightFixSafeAsync(includePatches)); |
| 40 | public async Task<string> GitCommitAsync(string message, IReadOnlyList<string>? paths) |
| 41 | { |
| 42 | if (!IdeMcpGitWorkspaceSession.TryCreate(_host.McpGitRunner, _host.McpGetWorkspacePath(), out var session, out var err)) |
| 43 | return err; |
| 44 | var json = await session.GitCommitAsync(message, paths).ConfigureAwait(false); |
| 45 | _ = _host.McpRefreshGitSummaryAsync(); |
| 46 | return json; |
| 47 | } |
| 48 | |
| 49 | public Task<string> GitPushAsync(string? remote, string? branch, bool dryRun) |
| 50 | { |
| 51 | if (!IdeMcpGitWorkspaceSession.TryCreate(_host.McpGitRunner, _host.McpGetWorkspacePath(), out var session, out var err)) |
| 52 | return Task.FromResult(err); |
| 53 | if (!dryRun) |
| 54 | _ = _host.McpRefreshGitSummaryAsync(); |
| 55 | return session.GitPushAsync(remote, branch, dryRun); |
| 56 | } |
| 57 | |
| 58 | } |
| 59 | |