diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 48f3066..fb8a02b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,8 @@ All notable changes to MandoCode will be documented in this file. ### Added +- Paste clipboard images into ACP prompts with Alt+V when the connected agent advertises image support. Send in-memory PNG image blocks with text, retain per-pane attachment references and size limits, and explain unsupported agents or expired images without sending an incomplete prompt. + - ACP agent-provided commands appear in slash-command suggestions with the connected agent’s display name (for example `[Codex]`), descriptions, and input hints. Advertised commands and arguments are forwarded to the current agent as prompts; session updates replace the list, and MandoCode commands retain precedence on name collisions. - `/agent-acp-mode` opens a picker for the connected agent's permission and behavior modes, including the current selection and agent-provided descriptions. Select a mode directly with `/agent-acp-mode `. Changes preserve the current conversation, apply only to the ACP session, and are refused during active work. Agents without advertised modes receive an explanation. diff --git a/docs/acp-codex.md b/docs/acp-codex.md index 7c4ab37..a49d8e9 100644 --- a/docs/acp-codex.md +++ b/docs/acp-codex.md @@ -43,14 +43,15 @@ entry path with `node`. The live validation below was performed on Windows only. - `/agent-acp-mode` opens the agent's mode picker, with its descriptions and current selection. For example, Codex can offer Read-only, Workspace access, Auto review, and Full access. These are agent-defined permission and behavior modes, not MandoCode's native approval settings. - `/agent-acp-mode read-only` selects an advertised mode directly. Changes keep the conversation and are refused while the pane has active work. The selection applies to this session; it does not rewrite global Codex configuration. - `/model` uses the adapter's advertised model configuration. Available models depend on the account and adapter. -- `/compact` appears when the adapter advertises that command. +- `/compact` and other agent-provided commands appear when the adapter advertises them. +- Alt+V attaches a clipboard image when the connected adapter advertises image prompt support. - `/clear` starts another ACP conversation and preserves the native MandoCode conversation. - `/copy` and `/copy-code` read the ACP conversation's last reply. - `/agent-acp stop` returns to the native conversation. - Folder changes follow the normal ACP restart and confirmation flow. Capability handling remains shared with other ACP agents. This setup does not add native -agent mentions, image paste, context handoff, or the proposed MandoCode MCP bridge. +agent mentions, context handoff, or the proposed MandoCode MCP bridge. The generic ACP restrictions still apply even if Codex itself advertises additional features. The adapter also supports API-key authentication. Existing `OPENAI_API_KEY` and `CODEX_API_KEY` diff --git a/docs/acp.md b/docs/acp.md index 9392771..57f353c 100644 --- a/docs/acp.md +++ b/docs/acp.md @@ -161,7 +161,7 @@ One set in the code (`AcpPaneRestrictions`) feeds autocomplete, the command disp | `/setup`, `/retry`, `/config`, `/agent-settings` (Alt+S), `/force-skill`, `/plan`, `/plan-resume`, `/plan-discard`, `/context-snap-create`, `/context-snap-import` (Alt+C), `/ollama-*` | The external agent runs the conversation; MandoCode's own model loop, plans and context snapshots do not apply. | | `/skills` (Alt+K), `/mcp` (Alt+M), `/mcp tools`, `/mcp-reload` | The agent does not use MandoCode's skills or MCP servers (`mcpServers` is empty). | | `/history` (Alt+H) | Saved history restores native agents, and ACP panes are not saved to it. | -| Alt+V (paste image) | Images are not sent to ACP agents yet. | +| Alt+V (paste image) | Attach a clipboard image when the connected agent advertises image prompt support. | | Agents group of the `@` picker | See above. | Typing a blocked command, or pressing its shortcut, prints `/ is not available in an ACP agent pane: `. @@ -194,6 +194,18 @@ touched**. While a request is running `/clear` is refused (press Escape first). - `/compact` sends `/compact` to the agent as a prompt when it announced a `compact` command (`available_commands_update`), otherwise it says the agent does not support it. +### Clipboard image prompts + +When a connected agent advertises `promptCapabilities.image`, Alt+V attaches a clipboard image to the prompt. +Add a message and press Enter to send both together; deleting the image's `@reference` removes the attachment. +The image is sent as an ACP image block with base64 PNG data and an `image/png` MIME type. It stays in memory +in that pane and is not written into the project. Existing `@file` references continue to use resource links. + +Each image is limited to 4 MiB, with a 16 MiB total image limit per prompt. Duplicate references attach an image +once. An unavailable or expired clipboard reference produces an error asking you to paste it again. Image support +is checked at send time as well as paste time. Unsupported agents receive an explanation; Ctrl+V text paste +continues to work. On Windows, Ctrl+V also attaches clipboard images when the terminal forwards the key. + ### Agent-provided commands Other advertised agent commands appear in `/` suggestions with the connected agent’s display name (for example `[Codex]`, falling back to `[acp-agent]` if no name is available) and are sent as ordinary prompts, including their arguments. Suggestions follow the current session and update when the agent changes its command list. MandoCode commands take precedence on name collisions (except `/compact`, which belongs to the ACP agent in an ACP pane); blocked native commands remain blocked. Unadvertised commands still receive the unknown-command message. The agent decides what each forwarded command does. @@ -395,7 +407,7 @@ Deviations from the plan Known limitations - Markdown links in an agent's reply are shown as raw text (the transcript renderer does not turn them into links). -- Images are not sent; `terminal/*` is not offered. +- Clipboard images require the agent to advertise `promptCapabilities.image`; `terminal/*` is not offered. - Agents that cannot resume or load sessions always start fresh, and `/model` needs the agent to expose a model option. - Switching the folder (or `--resume`) affects one pane; restarting all ACP panes at once is a separate change. - MandoCode's agents are not reachable from an ACP agent, and no context is handed over between the two (a later phase). diff --git a/src/MandoCode/Components/Input/PromptInput.razor b/src/MandoCode/Components/Input/PromptInput.razor index 227f450..e6dfb3e 100644 --- a/src/MandoCode/Components/Input/PromptInput.razor +++ b/src/MandoCode/Components/Input/PromptInput.razor @@ -2,6 +2,7 @@ @inject IServiceProvider Services @using MandoCode.Models @using MandoCode.Services +@using MandoCode.Services.Acp @using Spectre.Console @using RazorConsole.Core.Renderables @implements IDisposable @@ -86,9 +87,14 @@ [Parameter] public Color LabelColor { get; set; } = Color.Green; [Parameter] public string Placeholder { get; set; } = "type / for commands, @ for files and agents, : for emojis · Alt+V paste image"; [Parameter] public bool ChatFeaturesEnabled { get; set; } = true; - // An ACP pane offers files only in the @ picker and no image paste (AcpPaneRestrictions). + // An ACP pane offers files in the @ picker; clipboard images depend on the agent capabilities. private bool IsAcpPane => Pane?.Runtime == AgentRuntime.Acp; - private string EffectivePlaceholder => IsAcpPane && ChatFeaturesEnabled ? "type / for commands, @ for files, : for emojis" : Placeholder; + private IAcpAgentRuntime? AcpRuntime => + ((Pane?.Services ?? Services).GetService(typeof(AcpRuntimeHolder)) as AcpRuntimeHolder)?.Runtime; + private string? ImageBlockReason => IsAcpPane ? AcpPaneRestrictions.ImagePasteReason(AcpRuntime) : null; + private string EffectivePlaceholder => IsAcpPane && ChatFeaturesEnabled + ? "type / for commands, @ for files, : for emojis" + (ImageBlockReason is null ? " · Alt+V paste image" : "") + : Placeholder; [Parameter] public bool AllowEmpty { get; set; } [Parameter] public string? PersistenceKey { get; set; } [Inject] private RazorConsole.Core.Focus.FocusManager Focus { get; set; } = default!; @@ -114,6 +120,12 @@ { if (Disabled || !ChatFeaturesEnabled || ModelPicker is not null || Pane is { Active: false }) return true; var services = Pane?.Services ?? Services; + bool BlockImage() + { + if (ImageBlockReason is not { } reason) return false; + _clipboardStatus = reason; _clipboardError = true; StateHasChanged(); return true; + } + if (explicitRequest && BlockImage()) return true; var reader = services.GetService(typeof(IClipboardImageReader)) as IClipboardImageReader ?? new WindowsClipboardImageReader(); // Linux terminal paste remains native; an injected reader can provide clipboard support on any OS. if (!explicitRequest && !OperatingSystem.IsWindows() && reader is WindowsClipboardImageReader) return false; @@ -130,6 +142,7 @@ if (text is not null) { _composer.Buffer.Insert(PromptPaste.Normalize(text)); _composer.Refresh(); _emojiOpen = false; _clipboardStatus = ""; return true; } _clipboardStatus = explicitRequest ? "No Image in the clipboard. Copy an image, then press Alt+V" : ""; return explicitRequest; } + if (BlockImage()) return true; var images = services.GetService(typeof(ClipboardImageStore)) as ClipboardImageStore ?? _fallbackClipboard; _composer.InsertFileReference(images.Add(png)); _clipboardStatus = "Clipboard image attached · Add a message, then Enter to send · Delete its @reference to remove"; @@ -277,11 +290,6 @@ if (key.Key is not ("ArrowUp" or "UpArrow" or "ArrowDown" or "DownArrow")) _cursorNavigation.Reset(); if (key.Key.Equals("v", StringComparison.OrdinalIgnoreCase) && (key.CtrlKey || key.AltKey) && ChatFeaturesEnabled && ModelPicker is null) { - if (IsAcpPane) - { - _clipboardStatus = $"Image paste is unavailable in an ACP pane: {MandoCode.Services.Acp.AcpPaneRestrictions.ImagePasteReason}."; - _clipboardError = true; StateHasChanged(); return true; - } return await PasteClipboardImage(key.AltKey); } if (AgentKeyboardRouter.TryHandleGlobal(Pane, key)) return true; diff --git a/src/MandoCode/Components/Shell/App.Acp.cs b/src/MandoCode/Components/Shell/App.Acp.cs index 4fd745a..83cc21c 100644 --- a/src/MandoCode/Components/Shell/App.Acp.cs +++ b/src/MandoCode/Components/Shell/App.Acp.cs @@ -327,7 +327,8 @@ private async Task ProcessAcpRequestAsync(string input) Spinner.Start("Thinking..."); var driver = new AcpTurnDriver(new PaneSink(this), AcpEntry, _acpTranscript); - var outcome = await driver.RunAsync(_acp, AcpPromptBuilder.Build(input, ProjectRoot.ProjectRoot), token); + var outcome = await driver.RunAsync(_acp, AcpPromptBuilder.Build(input, ProjectRoot.ProjectRoot, + Pane?.Services.GetService(), _acp.PromptCapabilities.Image), token); _lastRequestError = outcome.Error; if (outcome.ReplyText.Length > 0) diff --git a/src/MandoCode/Services/Acp/AcpPaneRestrictions.cs b/src/MandoCode/Services/Acp/AcpPaneRestrictions.cs index 2c50122..db9d812 100644 --- a/src/MandoCode/Services/Acp/AcpPaneRestrictions.cs +++ b/src/MandoCode/Services/Acp/AcpPaneRestrictions.cs @@ -42,8 +42,13 @@ public static class AcpPaneRestrictions ["h"] = "/history", }; - /// The Alt+V image paste: an ACP prompt carries text and file links only for now. - public const string ImagePasteReason = "images are not sent to ACP agents yet"; + /// Image paste follows the connected agent's advertised prompt capabilities. + public static string? ImagePasteReason(IAcpAgentRuntime? runtime) => + runtime is not { Status: AcpRuntimeStatus.Ready } + ? "Wait for the ACP agent to connect before attaching an image." + : !runtime.PromptCapabilities.Image + ? "This ACP agent does not support image prompts." + : null; /// The @ picker lists files only; MandoCode's agents are not reachable from an external agent. public static bool PickerShowsAgents => false; @@ -88,8 +93,6 @@ public static string Message(string command) => /// The command an Alt+ shortcut stands for, when that shortcut is blocked here. public static string? BlockedShortcutCommand(string key) => Shortcuts.TryGetValue(key, out var command) ? command : null; - public static bool IsImagePasteBlocked(string key) => key.Equals("v", StringComparison.OrdinalIgnoreCase); - private static string NameOf(string command) => command.TrimStart('/').Split(' ', 2)[0].ToLowerInvariant(); } diff --git a/src/MandoCode/Services/Acp/AcpTurnDriver.cs b/src/MandoCode/Services/Acp/AcpTurnDriver.cs index a03e0c9..8f949a9 100644 --- a/src/MandoCode/Services/Acp/AcpTurnDriver.cs +++ b/src/MandoCode/Services/Acp/AcpTurnDriver.cs @@ -241,23 +241,43 @@ async Task ConsumeAsync() } /// -/// Builds the prompt blocks for a user message: the text itself plus a resource_link for every @file inside +/// Builds prompt blocks: text, in-memory clipboard images when supported, and a resource_link for every @file inside /// the project. Mentions are read with the same parser as the native pane (, so /// @"src/My Component.cs" works) and judged by the same guard as the agent's own file requests: relative paths /// only inside the project folder, no .. escapes, no link or junction that leads out. /// public static class AcpPromptBuilder { - public static IReadOnlyList Build(string input, string projectRoot) + // Base64 expands image payloads by about one third. Keep them below the transport's 32 MiB line budget. + public const int MaxTotalImageBytes = 16 * 1024 * 1024; + + public static IReadOnlyList Build(string input, string projectRoot, + ClipboardImageStore? clipboard = null, bool supportsImages = false) { var blocks = new List { new TextContent(input) }; var seen = new HashSet(OperatingSystem.IsWindows() ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); var guard = new AcpFileSystemHandler(projectRoot); + var imageBytes = 0; foreach (var mention in FileReferenceToken.Paths(input)) { foreach (var candidate in Candidates(mention)) { + if (ClipboardImageStore.IsReference(candidate)) + { + if (!seen.Add(candidate)) break; + if (!supportsImages) throw new IOException("This ACP agent does not support image prompts. Remove the image reference to send text only."); + if (clipboard is null || !clipboard.TryGet(candidate, out var png)) + throw new IOException("This clipboard image is no longer available in this pane. Copy it again and press Alt+V."); + if (png.Length > AIService.MaxImageInputBytes) + throw new IOException("The clipboard image exceeds the 4 MiB attachment limit."); + imageBytes += png.Length; + if (imageBytes > MaxTotalImageBytes) + throw new IOException("Images exceed the 16 MiB total per prompt. Remove some image references and send them separately."); + blocks.Add(new ImageContent { Data = Convert.ToBase64String(png), MimeType = "image/png" }); + break; + } + if (TryResolve(guard, projectRoot, candidate) is not { } link || !seen.Add(link.Canonical)) continue; diff --git a/src/MandoCode/Services/Input/ClipboardImage.cs b/src/MandoCode/Services/Input/ClipboardImage.cs index dec09b4..a0be308 100644 --- a/src/MandoCode/Services/Input/ClipboardImage.cs +++ b/src/MandoCode/Services/Input/ClipboardImage.cs @@ -96,4 +96,8 @@ public string Add(byte[] png) return reference; } public bool TryGet(string reference, out byte[] png) => _images.TryGetValue(reference, out png!); + + internal static bool IsReference(string reference) => reference.Length == 46 && + reference.StartsWith("clipboard-", StringComparison.Ordinal) && reference.EndsWith(".png", StringComparison.Ordinal) && + Guid.TryParseExact(reference.AsSpan(10, 32), "N", out _); } \ No newline at end of file diff --git a/tests/MandoCode.Tests/Acp/AcpImagePromptTests.cs b/tests/MandoCode.Tests/Acp/AcpImagePromptTests.cs new file mode 100644 index 0000000..81a383d --- /dev/null +++ b/tests/MandoCode.Tests/Acp/AcpImagePromptTests.cs @@ -0,0 +1,148 @@ +using System.Reflection; +using MandoCode.Acp.Protocol; +using MandoCode.Components; +using MandoCode.Services; +using MandoCode.Services.Acp; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Xunit; + +namespace MandoCode.Tests.Acp; + +[Trait("Category", "Component")] +public class AcpImagePromptTests +{ + private static readonly byte[] Png = [137, 80, 78, 71, 13, 10, 26, 10, 1]; + private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.NonPublic; + + [Theory] + [InlineData(true, AcpRuntimeStatus.Ready, true, 1)] + [InlineData(true, AcpRuntimeStatus.Ready, false, 1)] + [InlineData(false, AcpRuntimeStatus.Ready, true, 0)] + [InlineData(false, AcpRuntimeStatus.Ready, false, 1)] + [InlineData(true, AcpRuntimeStatus.Starting, true, 0)] + public async Task PasteChecksTheConnectedAgentsCapability(bool image, AcpRuntimeStatus status, bool alt, int reads) + { + var reader = new Reader(Png); + await using var services = AcpTestHost.Services(configure: s => { s.AddSingleton(reader); s.AddSingleton(reader); }); + var pane = services.GetRequiredService().Add(acpAgent: "test"); + AcpPaneMode.Enter(pane, "test"); + var runtime = new FakeRuntime { Status = status }; + runtime.PromptCapabilities.Image = image; + pane.Services.GetRequiredService().Runtime = runtime; + await using var renderer = new HtmlRenderer(services, services.GetRequiredService()); + await renderer.Dispatcher.InvokeAsync(async () => + { + PromptInput input = null!; + var root = await renderer.RenderComponentAsync(ParameterView.FromDictionary(new Dictionary { + ["Pane"] = pane, ["Capture"] = (Action)(p => input = p) + })); + Assert.True(await (Task)typeof(PromptInput).GetMethod("PreviewKey", Flags)!.Invoke(input, + [new KeyboardEventArgs { Key = "v", AltKey = alt, CtrlKey = !alt }])!); + Assert.Equal(reads, reader.Reads); + var composer = (PromptComposerState)typeof(PromptInput).GetField("_composer", Flags)!.GetValue(input)!; + if (image && status == AcpRuntimeStatus.Ready) + { + var prompt = AcpPromptBuilder.Build(composer.Buffer.Text, Path.GetTempPath(), + pane.Services.GetRequiredService(), image); + Assert.Equal(Png, Convert.FromBase64String(Assert.Single(prompt.OfType()).Data)); + Assert.Contains("Clipboard image attached", root.ToHtmlString()); + } + else + { + Assert.Empty(composer.Buffer.Text); + Assert.Contains(status == AcpRuntimeStatus.Ready ? "does not support image prompts" : "Wait for the ACP agent", root.ToHtmlString()); + } + }); + } + + [Fact] + public async Task CtrlVTextStillWorksForAnAgentWithoutImageSupport() + { + var reader = new Reader(null); + await using var services = AcpTestHost.Services(configure: s => { s.AddSingleton(reader); s.AddSingleton(reader); }); + var pane = services.GetRequiredService().Add(acpAgent: "test"); + AcpPaneMode.Enter(pane, "test"); + pane.Services.GetRequiredService().Runtime = new FakeRuntime(); + await using var renderer = new HtmlRenderer(services, services.GetRequiredService()); + await renderer.Dispatcher.InvokeAsync(async () => + { + PromptInput input = null!; + await renderer.RenderComponentAsync(ParameterView.FromDictionary(new Dictionary { + ["Pane"] = pane, ["Capture"] = (Action)(p => input = p) + })); + Assert.True(await (Task)typeof(PromptInput).GetMethod("PreviewKey", Flags)!.Invoke(input, + [new KeyboardEventArgs { Key = "v", CtrlKey = true }])!); + var composer = (PromptComposerState)typeof(PromptInput).GetField("_composer", Flags)!.GetValue(input)!; + Assert.Equal("pasted text", composer.Buffer.Text); + }); + } + + [Fact] + public void PromptIncludesTextAndPngOnceAndRemovingReferenceRemovesImage() + { + var store = new ClipboardImageStore(); + var reference = store.Add(Png); + var input = $"describe @{reference} @{reference}."; + var blocks = AcpPromptBuilder.Build(input, Path.GetTempPath(), store, true); + Assert.Equal(input, Assert.IsType(blocks[0]).Text); + var image = Assert.Single(blocks.OfType()); + Assert.Equal("image/png", image.MimeType); + Assert.Equal(Png, Convert.FromBase64String(image.Data)); + Assert.Null(image.Uri); + Assert.Empty(blocks.OfType()); + Assert.Empty(AcpPromptBuilder.Build("describe", Path.GetTempPath(), store, true).OfType()); + } + + [Fact] + public void UnsupportedExpiredAndOtherPaneReferencesFailRatherThanSendingTextOnly() + { + var store = new ClipboardImageStore(); + var reference = store.Add(Png); + Assert.Contains("does not support", Assert.Throws(() => + AcpPromptBuilder.Build("@" + reference, Path.GetTempPath(), store, false)).Message); + Assert.Contains("no longer available", Assert.Throws(() => + AcpPromptBuilder.Build("@" + reference, Path.GetTempPath(), new ClipboardImageStore(), true)).Message); + for (var i = 0; i < ClipboardImageStore.Capacity; i++) store.Add(Png); + Assert.Contains("no longer available", Assert.Throws(() => + AcpPromptBuilder.Build("@" + reference, Path.GetTempPath(), store, true)).Message); + } + + [Fact] + public void CombinedImagesHaveAPromptBudget() + { + var store = new ClipboardImageStore(); + var large = new byte[AIService.MaxImageInputBytes]; + Png.CopyTo(large, 0); + var references = Enumerable.Range(0, 5).Select(_ => "@" + store.Add(large)).ToArray(); + Assert.Contains("16 MiB", Assert.Throws(() => + AcpPromptBuilder.Build(string.Join(" ", references), Path.GetTempPath(), store, true)).Message); + } + + private sealed class Reader(byte[]? png) : IClipboardImageReader, IClipboardTextReader + { + public int Reads; + public Task ReadPngAsync(CancellationToken cancellationToken) { Reads++; return Task.FromResult(png); } + public Task ReadTextAsync(CancellationToken cancellationToken) => Task.FromResult("pasted text"); + } + + public sealed class Host : ComponentBase + { + [Parameter] public AgentPane Pane { get; set; } = default!; + [Parameter] public Action? Capture { get; set; } + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenComponent>(0); + builder.AddAttribute(1, "Value", Pane); + builder.AddAttribute(2, "ChildContent", (RenderFragment)(b => { + b.OpenComponent(0); + b.AddComponentReferenceCapture(1, p => Capture?.Invoke((PromptInput)p)); + b.CloseComponent(); + })); + builder.CloseComponent(); + } + } +} diff --git a/tests/MandoCode.Tests/Acp/AcpPaneAppTests.cs b/tests/MandoCode.Tests/Acp/AcpPaneAppTests.cs index 8f98b97..4029ec4 100644 --- a/tests/MandoCode.Tests/Acp/AcpPaneAppTests.cs +++ b/tests/MandoCode.Tests/Acp/AcpPaneAppTests.cs @@ -299,6 +299,30 @@ public async Task AdvertisedCommand_ForwardsOriginalArgumentsAsPrompt() Assert.IsType(Assert.Single(Assert.Single(h.Runtime.Prompts))).Text); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ClipboardImageIsDeliveredOnlyWhenCurrentAgentSupportsIt(bool supported) + { + await using var h = Harness.Create(); + var png = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 1 }; + var reference = h.Pane.Services.GetRequiredService().Add(png); + h.Runtime.PromptCapabilities.Image = supported; + h.Runtime.Succeed(StopReasons.EndTurn); + await (Task)typeof(App).GetMethod("ProcessAcpRequestAsync", BindingFlags.Instance | BindingFlags.NonPublic)! + .Invoke(h.App, ["Describe @" + reference])!; + if (supported) + { + var image = Assert.Single(Assert.Single(h.Runtime.Prompts).OfType()); + Assert.Equal(png, Convert.FromBase64String(image.Data)); + } + else + { + Assert.Empty(h.Runtime.Prompts); + Assert.Contains("does not support image prompts", h.Output); + } + } + [Fact] public async Task AgentCommand_CannotOverrideNativeClearOrBlockedPlan() { diff --git a/tests/MandoCode.Tests/Acp/AcpTestHost.cs b/tests/MandoCode.Tests/Acp/AcpTestHost.cs index 40ca1d9..c70fbe2 100644 --- a/tests/MandoCode.Tests/Acp/AcpTestHost.cs +++ b/tests/MandoCode.Tests/Acp/AcpTestHost.cs @@ -17,7 +17,7 @@ private sealed class Lifetime : IHostApplicationLifetime public void StopApplication() { } } - public static ServiceProvider Services(string? projectRoot = null) + public static ServiceProvider Services(string? projectRoot = null, Action? configure = null) { var registrations = new ServiceCollection().AddLogging(); registrations.AddRazorConsoleServices(); @@ -25,6 +25,7 @@ public static ServiceProvider Services(string? projectRoot = null) Program.RegisterAgentServices(registrations, new MandoCodeConfig { EnableThemeCustomization = false, UseAgentNames = false, AllowPersistence = false }, projectRoot ?? Path.GetTempPath()); + configure?.Invoke(registrations); return registrations.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); } }