<commit_before>package agent

import (
	"strings"
	"unicode/utf8"

	"github.com/pkg/errors"

	"github.com/mutagen-io/mutagen/pkg/environment"
	"github.com/mutagen-io/mutagen/pkg/prompting"
)

// unameSToGOOS maps uname -s output values to their corresponding GOOS values.
// Although some Windows environments (Cygwin, MSYS, and MinGW) support uname,
// their values are handled by unameSIsWindowsPosix because they are so varied
// (their value depends on the POSIX environment and its version, the system
// architecture, and the NT kernel version).
var unameSToGOOS = map[string]string{
	"AIX":       "aix",
	"Darwin":    "darwin",
	"DragonFly": "dragonfly",
	"FreeBSD":   "freebsd",
	"Linux":     "linux",
	"NetBSD":    "netbsd",
	"OpenBSD":   "openbsd",
	"SunOS":     "solaris",
	// TODO: Add more obscure uname -s values as necessary, e.g.
	// debian/kFreeBSD, which returns "GNU/kFreeBSD".
}

// unameSIsWindowsPosix determines whether or not a uname -s output value
// represents a Windows POSIX environment.
func unameSIsWindowsPosix(value string) bool {
	return strings.HasPrefix(value, "CYGWIN") ||
		strings.HasPrefix(value, "MINGW") ||
		strings.HasPrefix(value, "MSYS")
}

// unameMToGOARCH maps uname -m output values to their corresponding GOARCH
// values.
var unameMToGOARCH = map[string]string{
	"i386":     "386",
	"i486":     "386",
	"i586":     "386",
	"i686":     "386",
	"x86_64":   "amd64",
	"amd64":    "amd64",
	"armv5l":   "arm",
	"armv6l":   "arm",
	"armv7l":   "arm",
	"armv8l":   "arm64",
	"aarch64":  "arm64",
	"mips":     "mips",
	"mipsel":   "mipsle",
	"mips64":   "mips64",
	"mips64el": "mips64le",
	"ppc64":    "ppc64",
	"ppc64le":  "ppc64le",
	"s390x":    "s390x",
	// TODO: Add any more obscure uname -m variations that we might encounter.
}

// osEnvToGOOS maps the value of the "OS" environment variable on Windows to the
// corresponding GOOS. There's only one supported value, but we keep things this
// way for symmetry and extensibility.
var osEnvToGOOS = map[string]string{
	"Windows_NT": "windows",<commit_msg>Added uname -m values for Apple Silicon and RISC-V (64-bit).<commit_after>package agent

import (
	"strings"
	"unicode/utf8"

	"github.com/pkg/errors"

	"github.com/mutagen-io/mutagen/pkg/environment"
	"github.com/mutagen-io/mutagen/pkg/prompting"
)

// unameSToGOOS maps uname -s output values to their corresponding GOOS values.
// Although some Windows environments (Cygwin, MSYS, and MinGW) support uname,
// their values are handled by unameSIsWindowsPosix because they are so varied
// (their value depends on the POSIX environment and its version, the system
// architecture, and the NT kernel version).
var unameSToGOOS = map[string]string{
	"AIX":       "aix",
	"Darwin":    "darwin",
	"DragonFly": "dragonfly",
	"FreeBSD":   "freebsd",
	"Linux":     "linux",
	"NetBSD":    "netbsd",
	"OpenBSD":   "openbsd",
	"SunOS":     "solaris",
	// TODO: Add more obscure uname -s values as necessary, e.g.
	// debian/kFreeBSD, which returns "GNU/kFreeBSD".
}

// unameSIsWindowsPosix determines whether or not a uname -s output value
// represents a Windows POSIX environment.
func unameSIsWindowsPosix(value string) bool {
	return strings.HasPrefix(value, "CYGWIN") ||
		strings.HasPrefix(value, "MINGW") ||
		strings.HasPrefix(value, "MSYS")
}

// unameMToGOARCH maps uname -m output values to their corresponding GOARCH
// values.
var unameMToGOARCH = map[string]string{
	"i386":     "386",
	"i486":     "386",
	"i586":     "386",
	"i686":     "386",
	"x86_64":   "amd64",
	"amd64":    "amd64",
	"armv5l":   "arm",
	"armv6l":   "arm",
	"armv7l":   "arm",
	"armv8l":   "arm64",
	"aarch64":  "arm64",
	"arm64":    "arm64",
	"mips":     "mips",
	"mipsel":   "mipsle",
	"mips64":   "mips64",
	"mips64el": "mips64le",
	"ppc64":    "ppc64",
	"ppc64le":  "ppc64le",
	"riscv64":  "riscv64",
	"s390x":    "s390x",
	// TODO: Add any more obscure uname -m variations that we might encounter.
}

// osEnvToGOOS maps the value of the "OS" environment variable on Windows to the
// corresponding GOOS. There's only one supported value, but we keep things this
// way for symmetry and extensibility.
var osEnvToGOOS = map[string]string{
	"Windows_NT": "windows",
{'fraction_non_alphanumeric': 0.1464922711058264, 'fraction_numerical': 0.034244946492271104, 'mean_word_length': 3.856812933025404, 'pattern_counts': {'":': 56, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3782264', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1556, 'n_words': 440}