Repository navigation
Description
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Two focused code-quality improvements to SystemCapability.cs:
1. Extract TryParseArgv helper
HandleRunPrepare and HandleRunAsync both contained near-identical ~20-line blocks for parsing the "command" field from JSON args (accepts either a string array or a plain string). This logic is now consolidated in a single private TryParseArgv method:
private static bool TryParseArgv(JsonElement args, out string[] argv)Both callers are simplified and the parsing contract is documented in one place.
2. Fix operator-precedence clarity in HandleExecApprovalsSet
The enabled boolean check was written as:
// Before — && binds tighter than ||, reads ambiguously
TryGetProperty("enabled", out var enEl) && enEl.ValueKind == JsonValueKind.True || enEl.ValueKind == JsonValueKind.FalseThe runtime behaviour happened to be correct in all cases (a failed TryGetProperty leaves enEl with ValueKind == Undefined, not False), but the expression is misleading to readers. Added parentheses to make the intent explicit:
// After — intent is clear
TryGetProperty("enabled", out var enEl) && (enEl.ValueKind == JsonValueKind.True || enEl.ValueKind == JsonValueKind.False)Test Status
OpenClaw.Shared.Tests: 503 passed, 18 skipped ✅ (Linux runner)- Includes all
SystemCapabilityTestsandExecApprovalPolicyTests
- Includes all
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.
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 331b49a33fda7ced0576f4e99ca2c8db8ee4d44f 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 <[email protected]>
---
.../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)Metadata
Metadata
Assignees
Type
Fields
Priority
Activity
shanselman commentedon Mar 22, 2026
Closing duplicate tracking issue — Repo Assist can now create PRs directly with Actions permissions enabled. Work continues in the associated branches.