Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
537a5d63d4 | ||
|
|
6d0a6ad8c4 | ||
|
|
4b5eec669e | ||
|
|
7a09ac8404 |
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/cli/install.sh text eol=lf
|
||||
/crates/codegen/hoshizukimio-mio-pager/scripts/install.sh text eol=lf
|
||||
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -6005,7 +6005,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoshizukimio-mio-pager"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
dependencies = [
|
||||
"agent-client-protocol",
|
||||
"ansi-to-tui",
|
||||
@@ -6115,7 +6115,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoshizukimio-mio-pager-bin"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -6491,7 +6491,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoshizukimio-mio-shell"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
dependencies = [
|
||||
"agent-client-protocol",
|
||||
"anyhow",
|
||||
@@ -6972,7 +6972,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoshizukimio-mio-version"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
12
README.md
12
README.md
@@ -2,21 +2,23 @@
|
||||
|
||||
mio-code is a terminal coding assistant maintained by **HoshizukiMio**. Run `mio` for the interactive TUI, `mio -p` for scripting, or `mio agent stdio` for editor integration through the Agent Client Protocol (ACP).
|
||||
|
||||
When asked about its identity, Mio can name the application and the model ID selected for the current request.
|
||||
|
||||
## Install and update
|
||||
|
||||
Download the current stable build from [mio-code Releases](https://git.hoshizukimio.com/HoshizukiMio/mio-code/releases). Installers are available for Windows x86-64 and Linux x86-64, including WSL.
|
||||
The scripts install the current stable build from [mio-code Releases](https://git.hoshizukimio.com/HoshizukiMio/mio-code/releases). Windows x86-64 requires PowerShell 5.1 or later. Linux x86-64, including WSL, requires glibc 2.35 or later, curl, gzip and GNU coreutils.
|
||||
|
||||
```powershell
|
||||
irm https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/crates/codegen/hoshizukimio-mio-pager/scripts/install.ps1 | iex
|
||||
irm https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.ps1 | iex
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/crates/codegen/hoshizukimio-mio-pager/scripts/install.sh | bash
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh | bash
|
||||
```
|
||||
|
||||
Both installers validate the release checksum and put `mio` in the current user's `.local/bin` directory by default. Set `MIO_BIN_DIR` to select another directory. Pass a version to the script or set `MIO_VERSION` to install a particular release.
|
||||
Both installers verify the executable's SHA-256 and version before installing it in the current user's `.local/bin` directory. Set `MIO_BIN_DIR` to select another directory or set `MIO_VERSION` before running the command to install a particular release. On Windows the installer adds the directory to the user PATH. On Linux it prints a reminder if the directory is missing from PATH.
|
||||
|
||||
Run `mio update --check` to check the latest stable release, `mio update` to install it, or `mio update --version 1.0.46` to install a specific version. Set `[cli].auto_update = false` in your configuration to disable background updates.
|
||||
Run `mio update --check` to check the latest stable release, `mio update` to install it, or `mio update --version 1.0.47` to install a specific version. Set `[cli].auto_update = false` in your configuration to disable background updates.
|
||||
|
||||
## Build
|
||||
|
||||
|
||||
155
cli/install.ps1
Normal file
155
cli/install.ps1
Normal file
@@ -0,0 +1,155 @@
|
||||
param(
|
||||
[Parameter(Position = 0)]
|
||||
[string]$Version = $env:MIO_VERSION,
|
||||
[string]$BinDir = $env:MIO_BIN_DIR,
|
||||
[switch]$NoPath,
|
||||
[Alias('?')]
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
if ($Help) {
|
||||
Write-Output 'Usage: install.ps1 [-Version VERSION] [-BinDir DIRECTORY] [-NoPath]'
|
||||
Write-Output 'Install the latest stable release or specify a version such as 1.0.47.'
|
||||
Write-Output 'MIO_VERSION sets the version. MIO_BIN_DIR defaults to ~\.local\bin.'
|
||||
Write-Output 'Requires Windows x86-64 and PowerShell 5.1 or later.'
|
||||
return
|
||||
}
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
function Show-DownloadProgress([long]$Received, [long]$Total) {
|
||||
if ($Total -gt 0) {
|
||||
$Percent = [Math]::Min(100, [Math]::Floor(100.0 * $Received / $Total))
|
||||
$Line = ' Downloading... {0:0.#} MB / {1:0.#} MB ({2}%)' -f ($Received / 1MB), ($Total / 1MB), $Percent
|
||||
} else {
|
||||
$Line = ' Downloading... {0:0.#} MB' -f ($Received / 1MB)
|
||||
}
|
||||
Write-Host ("`r" + $Line.PadRight(64)) -NoNewline
|
||||
}
|
||||
|
||||
function Save-ReleaseArchive([string]$Uri, [string]$Path) {
|
||||
$Request = [Net.HttpWebRequest]::CreateHttp($Uri)
|
||||
$Request.Timeout = 120000
|
||||
$Request.ReadWriteTimeout = 120000
|
||||
$Response = $Request.GetResponse()
|
||||
try {
|
||||
$Stream = $Response.GetResponseStream()
|
||||
try {
|
||||
$File = [IO.File]::Create($Path)
|
||||
try {
|
||||
$Total = $Response.ContentLength
|
||||
$Received = 0L
|
||||
$Buffer = New-Object byte[] 65536
|
||||
$Clock = [Diagnostics.Stopwatch]::StartNew()
|
||||
Show-DownloadProgress $Received $Total
|
||||
while (($Count = $Stream.Read($Buffer, 0, $Buffer.Length)) -gt 0) {
|
||||
$File.Write($Buffer, 0, $Count)
|
||||
$Received += $Count
|
||||
if ($Clock.ElapsedMilliseconds -ge 150 -and $Received -ne $Total) {
|
||||
Show-DownloadProgress $Received $Total
|
||||
$Clock.Restart()
|
||||
}
|
||||
}
|
||||
if ($Total -ge 0 -and $Received -ne $Total) {
|
||||
throw 'The mio-code archive download ended early.'
|
||||
}
|
||||
Show-DownloadProgress $Received $Total
|
||||
} finally {
|
||||
$File.Dispose()
|
||||
Write-Host ''
|
||||
}
|
||||
} finally {
|
||||
$Stream.Dispose()
|
||||
}
|
||||
} finally {
|
||||
$Response.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
$Repo = 'https://git.hoshizukimio.com/HoshizukiMio/mio-code'
|
||||
$ReleaseApi = 'https://git.hoshizukimio.com/api/v1/repos/HoshizukiMio/mio-code/releases'
|
||||
$Architecture = $env:PROCESSOR_ARCHITEW6432
|
||||
if (-not $Architecture) { $Architecture = $env:PROCESSOR_ARCHITECTURE }
|
||||
if ($env:OS -ne 'Windows_NT' -or $Architecture -ne 'AMD64') {
|
||||
throw 'This installer requires Windows x86-64.'
|
||||
}
|
||||
if (-not $BinDir) { $BinDir = Join-Path $env:USERPROFILE '.local\bin' }
|
||||
if (-not $Version) {
|
||||
Write-Host 'Fetching latest stable version...'
|
||||
$Release = Invoke-RestMethod -Uri "$ReleaseApi/latest"
|
||||
if ($Release.draft -or $Release.prerelease -or $Release.tag_name -notmatch '^v') {
|
||||
throw 'Could not resolve the latest stable mio-code release.'
|
||||
}
|
||||
$Version = $Release.tag_name
|
||||
}
|
||||
$Version = $Version -creplace '^v', ''
|
||||
if ($Version -notmatch '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$') {
|
||||
throw 'Expected a version such as 1.0.47.'
|
||||
}
|
||||
|
||||
$BinDir = [IO.Path]::GetFullPath($BinDir)
|
||||
[IO.Directory]::CreateDirectory($BinDir) | Out-Null
|
||||
$Destination = Join-Path $BinDir 'mio.exe'
|
||||
$Nonce = [Guid]::NewGuid().ToString('N')
|
||||
$Archive = Join-Path $BinDir ".mio-install-$Nonce.gz"
|
||||
$Staged = Join-Path $BinDir ".mio-install-$Nonce.exe"
|
||||
$Backup = Join-Path $BinDir ".mio-install-$Nonce.old"
|
||||
$Asset = "$Repo/releases/download/v$Version/mio-windows-x86_64.exe"
|
||||
Write-Host "Installing mio $Version (windows-x86_64)..."
|
||||
|
||||
try {
|
||||
$Checksum = (Invoke-WebRequest -UseBasicParsing -Uri "$Asset.sha256").Content
|
||||
if ($Checksum -is [byte[]]) { $Checksum = [Text.Encoding]::UTF8.GetString($Checksum) }
|
||||
$Checksum = $Checksum.Trim()
|
||||
if ($Checksum -notmatch '^[0-9a-fA-F]{64}$') { throw 'Invalid mio-code release checksum.' }
|
||||
Save-ReleaseArchive "$Asset.gz" $Archive
|
||||
$InputStream = [IO.File]::OpenRead($Archive)
|
||||
try {
|
||||
$Decoder = [IO.Compression.GZipStream]::new($InputStream, [IO.Compression.CompressionMode]::Decompress)
|
||||
try {
|
||||
$OutputStream = [IO.File]::Create($Staged)
|
||||
try { $Decoder.CopyTo($OutputStream) }
|
||||
finally { $OutputStream.Dispose() }
|
||||
} finally { $Decoder.Dispose() }
|
||||
} finally { $InputStream.Dispose() }
|
||||
|
||||
$Hasher = [Security.Cryptography.SHA256]::Create()
|
||||
try {
|
||||
$Binary = [IO.File]::OpenRead($Staged)
|
||||
try { $Digest = [BitConverter]::ToString($Hasher.ComputeHash($Binary)).Replace('-', '') }
|
||||
finally { $Binary.Dispose() }
|
||||
} finally { $Hasher.Dispose() }
|
||||
|
||||
if ($Digest -ne $Checksum) {
|
||||
throw 'mio-code release checksum did not match.'
|
||||
}
|
||||
$Reported = (& $Staged --version | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or ($Reported -ne "mio $Version" -and -not $Reported.StartsWith("mio $Version "))) {
|
||||
throw "Unexpected binary version: $Reported"
|
||||
}
|
||||
|
||||
if ([IO.File]::Exists($Destination)) { [IO.File]::Move($Destination, $Backup) }
|
||||
try { [IO.File]::Move($Staged, $Destination) }
|
||||
catch {
|
||||
if ([IO.File]::Exists($Backup)) { [IO.File]::Move($Backup, $Destination) }
|
||||
throw
|
||||
}
|
||||
if ([IO.File]::Exists($Backup)) { Remove-Item -LiteralPath $Backup -ErrorAction SilentlyContinue }
|
||||
} finally {
|
||||
foreach ($TemporaryFile in @($Archive, $Staged)) {
|
||||
if ([IO.File]::Exists($TemporaryFile)) { Remove-Item -LiteralPath $TemporaryFile -ErrorAction SilentlyContinue }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $NoPath) {
|
||||
$UserPath = [Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if (($UserPath -split ';').TrimEnd('\') -notcontains $BinDir.TrimEnd('\')) {
|
||||
[Environment]::SetEnvironmentVariable('Path', (@($UserPath, $BinDir) -ne '' -join ';').TrimStart(';'), 'User')
|
||||
}
|
||||
if (($env:Path -split ';').TrimEnd('\') -notcontains $BinDir.TrimEnd('\')) {
|
||||
$env:Path = "$env:Path;$BinDir"
|
||||
}
|
||||
}
|
||||
Write-Output "Installed $Reported at $Destination"
|
||||
81
cli/install.sh
Executable file
81
cli/install.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo=https://git.hoshizukimio.com/HoshizukiMio/mio-code
|
||||
if [[ ${1:-} == --help || ${1:-} == -h ]]; then
|
||||
printf '%s\n' 'Usage: bash install.sh [VERSION]' \
|
||||
'Install the latest stable release or specify a version such as 1.0.47.' \
|
||||
'MIO_VERSION sets the version. MIO_BIN_DIR defaults to ~/.local/bin.' \
|
||||
'Requires Linux x86-64 (including WSL), curl, gzip and GNU coreutils.'
|
||||
exit 0
|
||||
fi
|
||||
if (( $# > 1 )); then
|
||||
printf '%s\n' 'Usage: bash install.sh [VERSION]' >&2
|
||||
exit 2
|
||||
fi
|
||||
version=${1:-${MIO_VERSION:-}}
|
||||
bin_dir=${MIO_BIN_DIR:-"$HOME/.local/bin"}
|
||||
|
||||
if [[ "$(uname -s)-$(uname -m)" != Linux-x86_64 ]]; then
|
||||
printf '%s\n' 'This script installs the Linux x86-64 build. On Windows, use install.ps1.' >&2
|
||||
exit 1
|
||||
fi
|
||||
for program in curl gzip sha256sum; do
|
||||
if ! command -v "$program" >/dev/null; then
|
||||
printf 'Installation requires %s.\n' "$program" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$version" ]]; then
|
||||
printf '%s\n' 'Fetching latest stable version...' >&2
|
||||
latest=$(curl -fsSL --retry 2 -o /dev/null -w '%{url_effective}' "$repo/releases/latest")
|
||||
case "$latest" in
|
||||
"$repo/releases/tag/v"*) version=${latest##*/} ;;
|
||||
*) printf '%s\n' 'Could not resolve the latest mio-code release.' >&2; exit 1 ;;
|
||||
esac
|
||||
fi
|
||||
version=${version#v}
|
||||
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
|
||||
printf '%s\n' 'Expected a version such as 1.0.47.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
asset="$repo/releases/download/v$version/mio-linux-x86_64"
|
||||
printf 'Installing mio %s (linux-x86_64)...\n' "$version" >&2
|
||||
mkdir -p -- "$bin_dir"
|
||||
bin_dir=$(cd -- "$bin_dir" && pwd -P)
|
||||
work=$(mktemp -d -- "$bin_dir/.mio-install.XXXXXXXX")
|
||||
archive="$work/mio.gz"
|
||||
staged="$work/mio"
|
||||
trap 'rm -f -- "$archive" "$staged"; rmdir -- "$work"' EXIT
|
||||
|
||||
checksum=$(curl -fsSL --retry 2 "$asset.sha256")
|
||||
if [[ ! "$checksum" =~ ^[[:xdigit:]]{64}$ ]]; then
|
||||
printf '%s\n' 'Invalid mio-code release checksum.' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -t 2 ]]; then
|
||||
curl -fSL --progress-bar --retry 2 --output "$archive" "$asset.gz"
|
||||
else
|
||||
printf '%s\n' ' Downloading...' >&2
|
||||
curl -fsSL --retry 2 --output "$archive" "$asset.gz"
|
||||
fi
|
||||
gzip -dc -- "$archive" > "$staged"
|
||||
actual=$(sha256sum < "$staged")
|
||||
if [[ ${actual%% *} != "${checksum,,}" ]]; then
|
||||
printf '%s\n' 'mio-code release checksum did not match.' >&2
|
||||
exit 1
|
||||
fi
|
||||
chmod 755 -- "$staged"
|
||||
reported=$("$staged" --version)
|
||||
if [[ "$reported" != "mio $version" && "$reported" != "mio $version "* ]]; then
|
||||
printf 'Unexpected binary version: %s\n' "$reported" >&2
|
||||
exit 1
|
||||
fi
|
||||
mv -fT -- "$staged" "$bin_dir/mio"
|
||||
printf 'Installed %s at %s/mio\n' "$reported" "$bin_dir"
|
||||
case ":$PATH:" in
|
||||
*":$bin_dir:"*) ;;
|
||||
*) printf 'Add %q to your PATH to run mio by name.\n' "$bin_dir" ;;
|
||||
esac
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoshizukimio-mio-pager-bin"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
authors = ["HoshizukiMio"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoshizukimio-mio-pager"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
authors = ["HoshizukiMio"]
|
||||
|
||||
@@ -7,7 +7,7 @@ Bring Mio into your terminal. Fast, flicker-free CLI built for plans, subagents,
|
||||
## Install
|
||||
|
||||
```bash
|
||||
curl -fsSL https://hoshizukimio.invalid/cli/install.sh | bash
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh | bash
|
||||
```
|
||||
|
||||
Or install with npm:
|
||||
|
||||
@@ -1,88 +1,16 @@
|
||||
# Install mio-code from its public Gitea releases.
|
||||
# Compatibility entry point for the original installer URL.
|
||||
param(
|
||||
[Parameter(Position = 0)]
|
||||
[string]$Version = $env:MIO_VERSION,
|
||||
[string]$BinDir = $env:MIO_BIN_DIR,
|
||||
[switch]$NoPath
|
||||
[string]$Version,
|
||||
[string]$BinDir,
|
||||
[switch]$NoPath,
|
||||
[Alias('?')]
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
$Repo = 'https://git.hoshizukimio.com/HoshizukiMio/mio-code'
|
||||
$ReleaseApi = 'https://git.hoshizukimio.com/api/v1/repos/HoshizukiMio/mio-code/releases'
|
||||
$Architecture = $env:PROCESSOR_ARCHITEW6432
|
||||
if (-not $Architecture) { $Architecture = $env:PROCESSOR_ARCHITECTURE }
|
||||
if ($env:OS -ne 'Windows_NT' -or $Architecture -ne 'AMD64') {
|
||||
throw 'This installer requires Windows x86-64.'
|
||||
}
|
||||
if (-not $BinDir) { $BinDir = Join-Path $env:USERPROFILE '.local\bin' }
|
||||
if (-not $Version) {
|
||||
$Release = Invoke-RestMethod -Uri "$ReleaseApi/latest"
|
||||
if ($Release.draft -or $Release.prerelease -or $Release.tag_name -notmatch '^v') {
|
||||
throw 'Could not resolve the latest stable mio-code release.'
|
||||
}
|
||||
$Version = $Release.tag_name
|
||||
}
|
||||
$Version = $Version -creplace '^v', ''
|
||||
if ($Version -notmatch '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$') {
|
||||
throw 'Expected a version such as 1.0.46.'
|
||||
}
|
||||
|
||||
$BinDir = [IO.Path]::GetFullPath($BinDir)
|
||||
[IO.Directory]::CreateDirectory($BinDir) | Out-Null
|
||||
$Destination = Join-Path $BinDir 'mio.exe'
|
||||
$Nonce = [Guid]::NewGuid().ToString('N')
|
||||
$Archive = Join-Path $BinDir ".mio-install-$Nonce.gz"
|
||||
$Staged = Join-Path $BinDir ".mio-install-$Nonce.exe"
|
||||
$Backup = Join-Path $BinDir ".mio-install-$Nonce.old"
|
||||
$Asset = "$Repo/releases/download/v$Version/mio-windows-x86_64.exe"
|
||||
|
||||
try {
|
||||
$Checksum = (Invoke-WebRequest -UseBasicParsing -Uri "$Asset.sha256").Content
|
||||
if ($Checksum -is [byte[]]) { $Checksum = [Text.Encoding]::UTF8.GetString($Checksum) }
|
||||
$Checksum = $Checksum.Trim()
|
||||
if ($Checksum -notmatch '^[0-9a-fA-F]{64}$') { throw 'Invalid mio-code release checksum.' }
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "$Asset.gz" -OutFile $Archive
|
||||
$InputStream = [IO.File]::OpenRead($Archive)
|
||||
try {
|
||||
$Decoder = [IO.Compression.GZipStream]::new($InputStream, [IO.Compression.CompressionMode]::Decompress)
|
||||
try {
|
||||
$OutputStream = [IO.File]::Create($Staged)
|
||||
try { $Decoder.CopyTo($OutputStream) }
|
||||
finally { $OutputStream.Dispose() }
|
||||
} finally { $Decoder.Dispose() }
|
||||
} finally { $InputStream.Dispose() }
|
||||
|
||||
if ((Get-FileHash -LiteralPath $Staged -Algorithm SHA256).Hash -ne $Checksum) {
|
||||
throw 'mio-code release checksum did not match.'
|
||||
}
|
||||
$Reported = (& $Staged --version | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or ($Reported -ne "mio $Version" -and -not $Reported.StartsWith("mio $Version "))) {
|
||||
throw "Unexpected binary version: $Reported"
|
||||
}
|
||||
|
||||
if ([IO.File]::Exists($Destination)) { [IO.File]::Move($Destination, $Backup) }
|
||||
try { [IO.File]::Move($Staged, $Destination) }
|
||||
catch {
|
||||
if ([IO.File]::Exists($Backup)) { [IO.File]::Move($Backup, $Destination) }
|
||||
throw
|
||||
}
|
||||
if ([IO.File]::Exists($Backup)) { Remove-Item -LiteralPath $Backup -ErrorAction SilentlyContinue }
|
||||
} finally {
|
||||
foreach ($TemporaryFile in @($Archive, $Staged)) {
|
||||
if ([IO.File]::Exists($TemporaryFile)) { Remove-Item -LiteralPath $TemporaryFile -ErrorAction SilentlyContinue }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $NoPath) {
|
||||
$UserPath = [Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if (($UserPath -split ';').TrimEnd('\') -notcontains $BinDir.TrimEnd('\')) {
|
||||
[Environment]::SetEnvironmentVariable('Path', (@($UserPath, $BinDir) -ne '' -join ';').TrimStart(';'), 'User')
|
||||
}
|
||||
if (($env:Path -split ';').TrimEnd('\') -notcontains $BinDir.TrimEnd('\')) {
|
||||
$env:Path = "$env:Path;$BinDir"
|
||||
}
|
||||
}
|
||||
Write-Output "Installed $Reported at $Destination"
|
||||
$Uri = 'https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.ps1'
|
||||
$Installer = (Invoke-WebRequest -UseBasicParsing -Uri $Uri -ErrorAction Stop).Content
|
||||
if ($Installer -is [byte[]]) { $Installer = [Text.Encoding]::UTF8.GetString($Installer) }
|
||||
if ([string]::IsNullOrWhiteSpace($Installer)) { throw 'The mio-code installer download was empty.' }
|
||||
& ([scriptblock]::Create($Installer)) @PSBoundParameters
|
||||
|
||||
@@ -1,50 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install mio-code from its public Gitea releases.
|
||||
# Compatibility entry point for the original installer URL.
|
||||
set -euo pipefail
|
||||
|
||||
repo=https://git.hoshizukimio.com/HoshizukiMio/mio-code
|
||||
version=${1:-${MIO_VERSION:-}}
|
||||
bin_dir=${MIO_BIN_DIR:-"$HOME/.local/bin"}
|
||||
|
||||
if [[ "$(uname -s)-$(uname -m)" != Linux-x86_64 ]]; then
|
||||
printf '%s\n' 'This script installs the Linux x86-64 build. On Windows, use install.ps1.' >&2
|
||||
installer=$(curl -fsSL --retry 2 https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh)
|
||||
if [[ -z "$installer" ]]; then
|
||||
printf '%s\n' 'The mio-code installer download was empty.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$version" ]]; then
|
||||
latest=$(curl -fsSL --retry 2 -o /dev/null -w '%{url_effective}' "$repo/releases/latest")
|
||||
case "$latest" in
|
||||
"$repo/releases/tag/v"*) version=${latest##*/} ;;
|
||||
*) printf '%s\n' 'Could not resolve the latest mio-code release.' >&2; exit 1 ;;
|
||||
esac
|
||||
fi
|
||||
version=${version#v}
|
||||
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
|
||||
printf '%s\n' 'Expected a version such as 1.0.46.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
asset="$repo/releases/download/v$version/mio-linux-x86_64"
|
||||
mkdir -p -- "$bin_dir"
|
||||
staged=$(mktemp -- "$bin_dir/.mio-install.XXXXXXXX")
|
||||
trap 'rm -f -- "$staged"' EXIT
|
||||
|
||||
checksum=$(curl -fsSL --retry 2 "$asset.sha256")
|
||||
if [[ ! "$checksum" =~ ^[[:xdigit:]]{64}$ ]]; then
|
||||
printf '%s\n' 'Invalid mio-code release checksum.' >&2
|
||||
exit 1
|
||||
fi
|
||||
curl -fsSL --retry 2 "$asset.gz" | gzip -dc > "$staged"
|
||||
printf '%s %s\n' "$checksum" "$staged" | sha256sum --check --status
|
||||
chmod 755 -- "$staged"
|
||||
reported=$("$staged" --version)
|
||||
if [[ "$reported" != "mio $version" && "$reported" != "mio $version "* ]]; then
|
||||
printf 'Unexpected binary version: %s\n' "$reported" >&2
|
||||
exit 1
|
||||
fi
|
||||
mv -fT -- "$staged" "$bin_dir/mio"
|
||||
printf 'Installed %s at %s/mio\n' "$reported" "$bin_dir"
|
||||
case ":$PATH:" in
|
||||
*":$bin_dir:"*) ;;
|
||||
*) printf 'Add %q to your PATH to run mio by name.\n' "$bin_dir" ;;
|
||||
esac
|
||||
bash -s -- "$@" <<< "$installer"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
license = "Apache-2.0"
|
||||
name = "hoshizukimio-mio-shell"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
edition.workspace = true
|
||||
|
||||
[features]
|
||||
|
||||
@@ -8,7 +8,7 @@ Use it interactively as a TUI, or integrate it into your own apps via headless m
|
||||
|
||||
```bash
|
||||
# Install
|
||||
curl -fsSL https://hoshizukimio.invalid/cli/install.sh | bash
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh | bash
|
||||
|
||||
# Interactive TUI
|
||||
mio
|
||||
@@ -59,10 +59,10 @@ mio agent stdio
|
||||
|
||||
```bash
|
||||
# Install latest stable
|
||||
curl -fsSL https://hoshizukimio.invalid/cli/install.sh | bash
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh | bash
|
||||
|
||||
# Install a specific version
|
||||
curl -fsSL https://hoshizukimio.invalid/cli/install.sh | bash -s 0.1.42
|
||||
curl -fsSL https://git.hoshizukimio.com/HoshizukiMio/mio-code/raw/branch/mio-code/cli/install.sh | bash -s -- 1.0.47
|
||||
```
|
||||
|
||||
Verify installation:
|
||||
|
||||
@@ -1782,6 +1782,26 @@ impl SessionActor {
|
||||
self: &Arc<Self>,
|
||||
mut request: ConversationRequest,
|
||||
) -> Result<SamplerTurnOutcome, hoshizukimio_mio_sampler::SamplingErrorInfo> {
|
||||
// Attach model identity to the outgoing turn, so a restored session or a
|
||||
// model switch cannot leave a stale model ID in the saved system prompt.
|
||||
if let Some(model) = request.model.as_deref().filter(|model| !model.is_empty()) {
|
||||
let model = serde_json::Value::String(model.to_owned());
|
||||
let identity = format!(
|
||||
"You are Mio, the coding assistant in the mio-code application. \
|
||||
Configured model ID for this request: {model}. \
|
||||
When asked who you are or what powers you, state both the application and this exact model ID in the user's language. \
|
||||
Distinguish the model from the application's maintainer and avoid guessing the model's developer or provider."
|
||||
);
|
||||
if let Some(ConversationItem::System(system)) = request
|
||||
.items
|
||||
.iter_mut()
|
||||
.find(|item| item.is_primary_system_turn())
|
||||
{
|
||||
system.content = format!("{}\n\n{identity}", system.content).into();
|
||||
} else {
|
||||
request.items.insert(0, ConversationItem::system(identity));
|
||||
}
|
||||
}
|
||||
let request_id = hoshizukimio_mio_sampler::RequestId::random();
|
||||
self.turn_phases.record_sampling_request();
|
||||
let _sampling_phase = self.turn_phases.begin_sampling();
|
||||
|
||||
@@ -35,7 +35,7 @@ const MSG_RUN_UPDATE_MANUAL: &str = "Run `mio update` to get the latest version.
|
||||
|
||||
fn manual_install_cmd(_channel: &str) -> String {
|
||||
let base = format!(
|
||||
"{}/raw/branch/mio-code/crates/codegen/hoshizukimio-mio-pager/scripts",
|
||||
"{}/raw/branch/mio-code/cli",
|
||||
crate::version::RELEASE_REPO
|
||||
);
|
||||
if cfg!(windows) {
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
fn installer() -> PathBuf {
|
||||
let relative = "crates/codegen/hoshizukimio-mio-pager/scripts/install.sh";
|
||||
let relative = "cli/install.sh";
|
||||
if let Ok(runfiles) = std::env::var("TEST_SRCDIR") {
|
||||
let workspace = std::env::var("TEST_WORKSPACE").unwrap_or_else(|_| "_main".into());
|
||||
PathBuf::from(runfiles).join(workspace).join(relative)
|
||||
@@ -48,7 +48,7 @@ fn install_sh_checks_release_before_replacing_the_binary() {
|
||||
case "${!#}" in
|
||||
*/releases/latest) printf '%s' 'https://git.hoshizukimio.com/HoshizukiMio/mio-code/releases/tag/v1.0.46' ;;
|
||||
*/mio-linux-x86_64.sha256) printf '%s' "$RELEASE_CHECKSUM" ;;
|
||||
*/mio-linux-x86_64.gz) cat "$RELEASE_FIXTURE/binary.gz" ;;
|
||||
*/mio-linux-x86_64.gz) cp -- "$RELEASE_FIXTURE/binary.gz" "${@: -2:1}" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
"#);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
license = "Apache-2.0"
|
||||
name = "hoshizukimio-mio-version"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
edition.workspace = true
|
||||
description = "Lockstepped mio CLI version."
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import threading
|
||||
TEXT = "mio smoke passed"
|
||||
MODEL = "mio-smoke-model"
|
||||
KEY = "mio-test-credential"
|
||||
IDENTITY = b"You are Mio, the coding assistant in mio-code, maintained by HoshizukiMio."
|
||||
CHINESE_MAINTAINER = "星月澪(HoshizukiMio)".encode()
|
||||
IDENTITY = "You are Mio, the coding assistant in mio-code, maintained by HoshizukiMio."
|
||||
CHINESE_MAINTAINER = "星月澪(HoshizukiMio)"
|
||||
ROUTES = {
|
||||
"chat_completions": "/v1/chat/completions",
|
||||
"responses": "/v1/responses",
|
||||
@@ -288,7 +288,8 @@ def verify(binary, tui):
|
||||
endpoint += 'extra_headers = { "anthropic-version" = "2023-06-01" }\n'
|
||||
elif keyed:
|
||||
endpoint += 'env_key = "MIO_SMOKE_KEY"\n'
|
||||
model = f'[models]\ndefault = "smoke"\n[model.smoke]\nmodel = "{MODEL}"\nmax_retries = 0\n'
|
||||
model_id = MODEL if keyed else f"{MODEL}-local"
|
||||
model = f'[models]\ndefault = "smoke"\n[model.smoke]\nmodel = "{model_id}"\nmax_retries = 0\n'
|
||||
if inherited:
|
||||
model += 'model_provider = "local"\n[model_providers.local]\n'
|
||||
settings.write_text(model + endpoint, encoding="utf-8")
|
||||
@@ -312,9 +313,21 @@ def verify(binary, tui):
|
||||
assert headers.get("authorization") == f"Bearer {KEY}", headers
|
||||
else:
|
||||
assert not headers.get("authorization") and not headers.get("x-api-key"), headers
|
||||
actual_model = json.loads(body)["model"]
|
||||
assert actual_model == MODEL, (backend, method, path, actual_model)
|
||||
saw_identity |= IDENTITY in body and CHINESE_MAINTAINER in body
|
||||
payload = json.loads(body)
|
||||
actual_model = payload["model"]
|
||||
assert actual_model == model_id, (backend, method, path, actual_model)
|
||||
if backend == "messages":
|
||||
system = payload["system"]
|
||||
else:
|
||||
entries = payload["input" if backend == "responses" else "messages"]
|
||||
system = [entry for entry in entries if entry.get("role") == "system"]
|
||||
system_text = json.dumps(system, ensure_ascii=False)
|
||||
model_identity = f"Configured model ID for this request: {json.dumps(model_id)}."
|
||||
saw_identity |= (
|
||||
IDENTITY in system_text
|
||||
and CHINESE_MAINTAINER in system_text
|
||||
and json.dumps(model_identity)[1:-1] in system_text
|
||||
)
|
||||
assert saw_inference, backend
|
||||
assert saw_identity, (backend, "model request lacked the mio-code identity")
|
||||
assert unexpected.empty(), unexpected.get_nowait()
|
||||
|
||||
Reference in New Issue
Block a user