Files
CommandForge/src/CommandForge.Domain/UserCommand.cs
T
poli0981andClaude Opus 4.8 17d5a5cc19 feat(user-commands): non-elevated user-defined commands (v-next Đợt 5)
Implements B1 from docs/Extra.md Part 1, safety-critical (golden rule #1).

- Domain: UserCommand (id/name/executable/arguments).
- Application: IUserCommandStore port + UserCommandFactory.ToDefinition,
  which FORCES RequiresAdmin=false and namespaces the id as "user:" so
  it can never be routed to — or accepted by — the Elevator.
- Infrastructure: JsonUserCommandStore -> %AppData%\CommandForge\
  user-commands.json, fully separate from the embedded catalog. No
  telemetry; corrupt-file fallback.
- WPF: new "My commands" section (sidebar + View menu) with a persistent
  warning banner. Create/edit/save/delete; Run shows the exact command
  line and that it runs without admin, then executes asInvoker via the
  forced-non-elevated definition. Console bound to the shared execution.
- EN/VI .resx; docs/Security.md §2.1 (threat model).
- Tests: ToDefinition never RequiresAdmin, id is namespaced, the
  definition routes to the executor (never elevation), store round-trip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 15:01:05 +07:00

21 lines
774 B
C#

namespace CommandForge.Domain;
/// <summary>
/// A user-defined command. These are NOT part of the vetted, embedded catalog and ALWAYS run
/// without elevation (asInvoker) — see golden rule #1. Stored separately from the catalog.
/// </summary>
public sealed record UserCommand
{
/// <summary>Stable local id (generated when the command is created).</summary>
public required string Id { get; init; }
/// <summary>User-visible name.</summary>
public required string Name { get; init; }
/// <summary>Executable to run (e.g. <c>cmd</c>, <c>powershell</c>, or a full path).</summary>
public required string Executable { get; init; }
/// <summary>Command-line arguments (optional).</summary>
public string Arguments { get; init; } = "";
}