Skip to content

[dotnet-code] Consolidate shell argv helper #486

Description

@github-actions

Summary

Consolidated shell argv assembly through small unexported helpers so stateless and persistent shell launch paths share the same extra-argv composition logic. This keeps the Go shell internals closer to the .NET ResolvedShell shape, where shell-specific suffixes are selected separately from combining constructor-provided extra argv.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI.Tools.Shell/ShellResolver.cs - resolves shell kind and combines optional extra argv with stateless/persistent shell suffixes.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • Added TestResolvedShellArgvIncludesExtraArgv to preserve existing stateless and persistent argv shapes with ShellArgv extras.
  • gofmt -w tool/shelltool/localshell.go tool/shelltool/localshell_internal_test.go
  • go test ./tool/shelltool

Notes

Rejected sampled candidates:

  • dotnet/src/Microsoft.Agents.AI.Workflows/HandoffWorkflowBuilder.cs - Go handoff-related workflow builder changes would touch public/broader workflow behavior, and existing open [dotnet-code] workflow PRs already cover nearby workflow internals.
  • dotnet/src/Microsoft.Agents.AI.Workflows/IExternalRequestContext.cs - the Go external request area already has direct behavior coverage, and the sampled .NET interface did not suggest a narrow production cleanup without churn.
  • dotnet/src/Microsoft.Agents.AI.Mcp/Skills/McpJsonContext.cs - the .NET file is source-generated JSON context plumbing, with no useful direct Go equivalent beyond existing MCP JSON helpers.

Checked for open shelltool/ShellResolver [dotnet-code] PR overlap and found none before editing.

Generated by .NET-to-Go Code Portability Refactoring Agent · 520.7 AIC · ⌖ 31.4 AIC · ⊞ 20.8K ·


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 dotnet-code-shell-argv-helper-eaa3b82eebbe6f4f.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (131 of 131 lines)
From a9044ce31633e2437efc09aa42aa72963386561c Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 13 Jul 2026 22:46:12 +0000
Subject: [PATCH] Consolidate shell argv helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 tool/shelltool/localshell.go               | 32 ++++++++++++----------
 tool/shelltool/localshell_internal_test.go | 26 +++++++++++++++++-
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/tool/shelltool/localshell.go b/tool/shelltool/localshell.go
index 3fdc90636..11b618ef2 100644
--- a/tool/shelltool/localshell.go
+++ b/tool/shelltool/localshell.go
@@ -10,7 +10,6 @@ import (
 	"os"
 	"os/exec"
 	"runtime"
-	"slices"
 	"sort"
 	"strings"
 	"sync"
@@ -594,37 +593,42 @@ func shellKindDescription(shell resolvedShell) string {
 }
 
 func (s resolvedShell) statelessArgvForCommand(command string) []string {
-	var suffix []string
 	switch s.kind {
 	case shellKindPowerShell:
-		suffix = []string{"-NoProfile", "-NoLogo", "-NonInteractive", "-Command", command}
+		return s.argvWithExtra([]string{"-NoProfile", "-NoLogo", "-NonInteractive", "-Command", command})
 	case shellKindCmd:
-		suffix = []string{"/d", "/c", command}
+		return s.argvWithExtra([]string{"/d", "/c", command})
 	case shellKindBash:
-		suffix = []string{"--noprofile", "--norc", "-c", command}
+		return s.argvWithExtra([]string{"--noprofile", "--norc", "-c", command})
 	default:
-		suffix = []string{"-c", command}
+		return s.argvWithExtra([]string{"-c", command})
 	}
-	return combineArgv(s.extraArgv, suffix)
 }
 
 func (s resolvedShell) persistentArgv() ([]string, error) {
-	var suffix []string
 	switch s.kind {
 	case shellKindPowerShell:
-		suffix = []string{"-NoProfile", "-NoLogo", "-NonInteractive", "-Command", "-"}
+		return s.launchArgv([]string{"-NoProfile", "-NoLogo", "-NonInteractive", "-Command", "-"}), nil
 	case shellKindCmd:
 		return nil, fmt.Errorf("persistent mode is not supp
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions