Skip to content

[Repo Assist] refactor: extract TryParseArgv helper in SystemCapability, fix operator precedence #89

Closed

Description

@github-actions

🤖 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

  1. Extract TryParseArgv helper — HandleRunPrepare and HandleRunAsync both contained near-identical JSON argv-array parsing logic (~20 lines each). Extracted 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). 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.

Click here to create the pull request

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 <[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)

Activity

  1. shanselman commented on Mar 22, 2026

    @shanselman
    Collaborator

    Closing duplicate tracking issue — Repo Assist can now create PRs directly with Actions permissions enabled. Work continues in the associated branches.

  2. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions