권한 모드 동등화: Plan 추가 및 claw-code 권한 별칭 정규화 반영
Some checks failed
Release Gate / gate (push) Has been cancelled
Some checks failed
Release Gate / gate (push) Has been cancelled
- 전역 권한 모드를 Ask/Plan/Auto/Deny 4단계로 확장 - claw-code 계열 권한 값(default/acceptEdits/dontAsk/bypassPermissions) 입력 시 내부 모드로 정규화 - AgentContext 권한 판정 경로(전역/도구 오버라이드/패턴 오버라이드) 정규화 적용 - Chat/Settings UI에서 Plan 모드 노출 및 인라인 순환(Ask->Plan->Auto->Deny) 반영 - AppState/SettingsViewModel/SettingsService에 권한값 정규화 및 저장 시 일관성 적용 - Permission lifecycle 이벤트 메시지에 유효 모드 표기 보강 - 빌드/테스트 검증: dotnet build 경고0 오류0, dotnet test 372/372 통과
This commit is contained in:
72
src/AxCopilot/Services/Agent/PermissionModeCatalog.cs
Normal file
72
src/AxCopilot/Services/Agent/PermissionModeCatalog.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
namespace AxCopilot.Services.Agent;
|
||||
|
||||
/// <summary>
|
||||
/// AX Agent permission mode constants and normalization helpers.
|
||||
/// Accepts legacy Ask/Auto/Deny values plus claw-code style aliases.
|
||||
/// </summary>
|
||||
public static class PermissionModeCatalog
|
||||
{
|
||||
public const string Ask = "Ask";
|
||||
public const string Plan = "Plan";
|
||||
public const string Auto = "Auto";
|
||||
public const string Deny = "Deny";
|
||||
|
||||
public static readonly IReadOnlyList<string> UserSelectableModes = new[]
|
||||
{
|
||||
Ask,
|
||||
Plan,
|
||||
Auto,
|
||||
Deny,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Normalize global permission mode.
|
||||
/// Supported aliases: ask/auto/deny/plan plus default, acceptEdits, dontAsk, bypassPermissions.
|
||||
/// </summary>
|
||||
public static string NormalizeGlobalMode(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return Ask;
|
||||
|
||||
return value.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"ask" => Ask,
|
||||
"default" => Ask,
|
||||
"plan" => Plan,
|
||||
"auto" => Auto,
|
||||
"acceptedits" => Auto,
|
||||
"dontask" => Auto,
|
||||
"deny" => Deny,
|
||||
"bypasspermissions" => Deny,
|
||||
_ => Ask,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normalize tool override permission.
|
||||
/// Tool override is constrained to ask/auto/deny.
|
||||
/// </summary>
|
||||
public static string NormalizeToolOverride(string? value)
|
||||
{
|
||||
var mode = NormalizeGlobalMode(value);
|
||||
return mode switch
|
||||
{
|
||||
Auto => "auto",
|
||||
Deny => "deny",
|
||||
_ => "ask",
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsAuto(string? mode) =>
|
||||
string.Equals(NormalizeGlobalMode(mode), Auto, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static bool IsDeny(string? mode) =>
|
||||
string.Equals(NormalizeGlobalMode(mode), Deny, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static bool RequiresUserApproval(string? mode)
|
||||
{
|
||||
var normalized = NormalizeGlobalMode(mode);
|
||||
return !string.Equals(normalized, Auto, StringComparison.OrdinalIgnoreCase)
|
||||
&& !string.Equals(normalized, Deny, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user