-
Notifications
You must be signed in to change notification settings - Fork 50
Description
π€ This is an automated contribution from Repo Assist.
Refactors argument-parsing logic in SystemCapability to improve clarity and fix a subtle operator-precedence issue.
Changes
-
Extract
TryParseArgvhelper βHandleRunPrepareandHandleRunAsyncboth contained near-identical JSON argv-array parsing logic (~20 lines each). Extracted into a private staticTryParseArgvmethod; both callers are simplified and the parsing contract is documented in one place. -
Fix operator precedence in
HandleExecApprovalsSetβ theenabledbool check was written as:TryGetProperty(...) && kind == True || kind == False
which C# parses as
(TryGetProperty(...) && kind == True) || (kind == False)rather than the intendedTryGetProperty(...) && (kind == True || kind == False). Added explicit parentheses to make intent clear.
Trade-offs
- Pure refactor: no behaviour changes.
- All existing tests continue to pass.
Test Status
Passed! - Failed: 0, Passed: 503, Skipped: 18, Total: 521 (OpenClaw.Shared.Tests)
Passed! - Failed: 0, Passed: 93, Skipped: 0, Total: 93 (OpenClaw.Tray.Tests)
Closes #75
Generated by Repo Assist Β· β·
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/improve-system-capability-argv-20260320-ba985f156baa4975-c754d17f02b1cde6-0e50d608ef36d499-a1b1254cf1354c5f.
To fix the permissions issue, go to Settings β Actions β General and enable Allow GitHub Actions to create and approve pull requests.
Show patch preview (210 of 210 lines)
From 7ed100921885ab6bff9305d75801da5561233ed7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 20 Mar 2026 01:00:05 +0000
Subject: [PATCH] refactor: extract TryParseArgv helper in SystemCapability,
fix operator precedence
Two related improvements to SystemCapability:
1. Extract TryParseArgv helper: HandleRunPrepare and HandleRunAsync both
contained near-identical JSON argv-array parsing logic (~20 lines each).
Extract into a private static TryParseArgv method. Both callers are
simplified and the parsing contract is documented in one place.
2. Fix operator precedence in HandleExecApprovalsSet: the 'enabled' bool
check was written as:
TryGetProperty(...) && kind == True || kind == False
which C# parses as:
(TryGetProperty(...) && kind == True) || (kind == False)
rather than the intended:
TryGetProperty(...) && (kind == True || kind == False)
Behaviour happened to be correct in all cases (default JsonElement has
ValueKind == Undefined, not False), but the unparenthesised form is
misleading. Added parentheses to make intent explicit.
503 tests pass, 18 skipped (integration/Windows-only).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
.../Capabilities/SystemCapability.cs | 133 +++++++++---------
1 file changed, 63 insertions(+), 70 deletions(-)
diff --git a/src/OpenClaw.Shared/Capabilities/SystemCapability.cs b/src/OpenClaw.Shared/Capabilities/SystemCapability.cs
index 986f3fb..4c89ae7 100644
--- a/src/OpenClaw.Shared/Capabilities/SystemCapability.cs
+++ b/src/OpenClaw.Shared/Capabilities/SystemCapability.cs
@@ -161,46 +161,60 @@ public class SystemCapability : NodeCapabilityBase
}
private static string FormatExecCommand(string[] argv) => ShellQuoting.FormatExecCommand(argv);
-
+
/// <summary>
- /// Pre-flight for system.run: echoes back the execution plan without running anything.
- /// The gat
... (truncated)