Release Gate / gate (push) Has been cancelled
- claude-code 선택적 탐색 흐름을 참고해 Cowork/Code 시스템 프롬프트에서 folder_map 상시 선행 지시를 완화하고 glob/grep 기반 좁은 탐색을 우선하도록 조정함 - FolderMapTool 기본 depth를 2로, include_files 기본값을 false로 낮추고 MultiReadTool 최대 파일 수를 8개로 줄여 초기 과탐색 폭을 보수적으로 조정함 - AgentLoopExplorationPolicy partial을 추가해 탐색 범위 분류, broad-scan corrective hint, exploration_breadth 성능 로그를 연결함 - AgentLoopService에 탐색 범위 가이드 주입과 실행 중 탐색 폭 추적을 추가하고, 좁은 질문에서 반복적인 folder_map/대량 multi_read를 교정하도록 정리함 - DocxToHtmlConverter nullable 경고를 수정해 Release 빌드 경고 0 / 오류 0 기준을 다시 충족함 - README와 docs/DEVELOPMENT.md에 2026-04-09 10:36 (KST) 기준 개발 이력을 반영함
90 lines
3.1 KiB
C#
90 lines
3.1 KiB
C#
using System.Text.Json;
|
|
using System.Windows;
|
|
|
|
namespace AxCopilot.Services.Agent;
|
|
|
|
/// <summary>
|
|
/// Windows 클립보드 읽기·쓰기 도구.
|
|
/// 에이전트가 클립보드를 통해 데이터를 주고받을 수 있게 합니다.
|
|
/// </summary>
|
|
public class ClipboardTool : IAgentTool
|
|
{
|
|
public string Name => "clipboard_tool";
|
|
public string Description =>
|
|
"Read or write the Windows clipboard. Actions: " +
|
|
"'read' — get current clipboard text content; " +
|
|
"'write' — set clipboard text content; " +
|
|
"'has_text' — check if clipboard contains text; " +
|
|
"'has_image' — check if clipboard contains an image.";
|
|
|
|
public ToolParameterSchema Parameters => new()
|
|
{
|
|
Properties = new()
|
|
{
|
|
["action"] = new()
|
|
{
|
|
Type = "string",
|
|
Description = "Action to perform",
|
|
Enum = ["read", "write", "has_text", "has_image"],
|
|
},
|
|
["text"] = new()
|
|
{
|
|
Type = "string",
|
|
Description = "Text to write to clipboard (required for 'write' action)",
|
|
},
|
|
},
|
|
Required = ["action"],
|
|
};
|
|
|
|
public async Task<ToolResult> ExecuteAsync(JsonElement args, AgentContext context, CancellationToken ct = default)
|
|
{
|
|
var action = args.GetProperty("action").SafeGetString() ?? "";
|
|
|
|
try
|
|
{
|
|
// 클립보드는 STA 스레드에서만 접근 가능 — InvokeAsync로 UI 스레드 블로킹 방지
|
|
var result = await Application.Current.Dispatcher.InvokeAsync(() =>
|
|
{
|
|
return action switch
|
|
{
|
|
"read" => ReadClipboard(),
|
|
"write" => WriteClipboard(args),
|
|
"has_text" => ToolResult.Ok(Clipboard.ContainsText() ? "true" : "false"),
|
|
"has_image" => ToolResult.Ok(Clipboard.ContainsImage() ? "true" : "false"),
|
|
_ => ToolResult.Fail($"Unknown action: {action}"),
|
|
};
|
|
});
|
|
return result ?? ToolResult.Fail("클립보드 접근 실패");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ToolResult.Fail($"클립보드 오류: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private static ToolResult ReadClipboard()
|
|
{
|
|
if (!Clipboard.ContainsText())
|
|
return ToolResult.Ok("(clipboard is empty or contains non-text data)");
|
|
|
|
var text = Clipboard.GetText();
|
|
if (string.IsNullOrEmpty(text))
|
|
return ToolResult.Ok("(empty)");
|
|
|
|
if (text.Length > 10000)
|
|
return ToolResult.Ok(text[..10000] + $"\n\n... (truncated, total {text.Length} chars)");
|
|
|
|
return ToolResult.Ok(text);
|
|
}
|
|
|
|
private static ToolResult WriteClipboard(JsonElement args)
|
|
{
|
|
if (!args.SafeTryGetProperty("text", out var textProp))
|
|
return ToolResult.Fail("'text' parameter is required for write action");
|
|
|
|
var text = textProp.SafeGetString() ?? "";
|
|
Clipboard.SetText(text);
|
|
return ToolResult.Ok($"✓ Clipboard updated ({text.Length} chars)");
|
|
}
|
|
}
|