feat: update preinstalled skills and CLI scripts, enhance packaging process, and add configuration for Windows and macOS

This commit is contained in:
DEV_DSW
2026-04-27 14:21:23 +08:00
parent 1667688931
commit 90e02636c7
16 changed files with 733 additions and 16 deletions

View File

@@ -0,0 +1,54 @@
#!/bin/sh
# OpenClaw CLI - managed by NIANXX
# Do not edit manually. Regenerated on NIANXX updates.
# Resolve the real path of this script (follow symlinks)
SCRIPT="$0"
while [ -L "$SCRIPT" ]; do
SCRIPT_DIR="$(cd -P "$(dirname "$SCRIPT")" && pwd)"
SCRIPT="$(readlink "$SCRIPT")"
[ "${SCRIPT#/}" = "$SCRIPT" ] && SCRIPT="$SCRIPT_DIR/$SCRIPT"
done
SCRIPT_DIR="$(cd -P "$(dirname "$SCRIPT")" && pwd)"
if [ "$(uname)" = "Darwin" ]; then
# macOS: <App>.app/Contents/Resources/cli/openclaw
# SCRIPT_DIR = .../Contents/Resources/cli
CONTENTS_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
ELECTRON="$CONTENTS_DIR/MacOS/NIANXX"
CLI="$CONTENTS_DIR/Resources/openclaw/openclaw.mjs"
else
# Linux: /opt/NIANXX/resources/cli/openclaw
# SCRIPT_DIR = .../resources/cli
INSTALL_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
CLI="$INSTALL_DIR/resources/openclaw/openclaw.mjs"
if [ -x "$INSTALL_DIR/nianxx" ]; then
ELECTRON="$INSTALL_DIR/nianxx"
elif [ -x "$INSTALL_DIR/NIANXX" ]; then
ELECTRON="$INSTALL_DIR/NIANXX"
else
ELECTRON="$INSTALL_DIR/zn-ai"
fi
fi
if [ ! -f "$ELECTRON" ]; then
echo "Error: NIANXX executable not found at $ELECTRON" >&2
echo "Please reinstall NIANXX or remove this script: $0" >&2
exit 1
fi
case "$1" in
update)
echo "openclaw is managed by NIANXX (bundled version)."
echo ""
echo "To update openclaw, update NIANXX:"
echo " Open NIANXX > Settings > Check for Updates"
echo ""
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --version 2>/dev/null || true
exit 0
;;
esac
export OPENCLAW_EMBEDDED_IN="NIANXX"
ELECTRON_RUN_AS_NODE=1 exec "$ELECTRON" "$CLI" "$@"

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# OpenClaw CLI wrapper for Git Bash / MSYS2 on Windows
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INSTALL_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
case "$1" in
update)
echo "openclaw is managed by NIANXX (bundled version)."
echo ""
echo "To update openclaw, update NIANXX:"
echo " Open NIANXX > Settings > Check for Updates"
exit 0
;;
esac
export OPENCLAW_EMBEDDED_IN="NIANXX"
NODE_EXE="$INSTALL_DIR/resources/bin/node.exe"
OPENCLAW_ENTRY="$INSTALL_DIR/resources/openclaw/openclaw.mjs"
if [ -f "$NODE_EXE" ]; then
if "$NODE_EXE" -e 'const [maj,min]=process.versions.node.split(".").map(Number);process.exit((maj>22||maj===22&&min>=16)?0:1)' >/dev/null 2>&1; then
exec "$NODE_EXE" "$OPENCLAW_ENTRY" "$@"
fi
fi
ELECTRON_RUN_AS_NODE=1 exec "$INSTALL_DIR/NIANXX.exe" "$OPENCLAW_ENTRY" "$@"

View File

@@ -0,0 +1,37 @@
@echo off
setlocal
if /i "%1"=="update" (
echo openclaw is managed by NIANXX ^(bundled version^).
echo.
echo To update openclaw, update NIANXX:
echo Open NIANXX ^> Settings ^> Check for Updates
exit /b 0
)
rem Switch console to UTF-8 so Unicode box-drawing and CJK text render correctly
rem on non-English Windows (e.g. Chinese CP936). Save the previous codepage to restore later.
for /f "tokens=2 delims=:." %%a in ('chcp') do set /a "_CP=%%a" 2>nul
chcp 65001 >nul 2>&1
set OPENCLAW_EMBEDDED_IN=NIANXX
set "NODE_EXE=%~dp0..\bin\node.exe"
set "OPENCLAW_ENTRY=%~dp0..\openclaw\openclaw.mjs"
set "_USE_BUNDLED_NODE=0"
if exist "%NODE_EXE%" (
"%NODE_EXE%" -e "const [maj,min]=process.versions.node.split('.').map(Number);process.exit((maj>22||maj===22&&min>=16)?0:1)" >nul 2>&1
if not errorlevel 1 set "_USE_BUNDLED_NODE=1"
)
if "%_USE_BUNDLED_NODE%"=="1" (
"%NODE_EXE%" "%OPENCLAW_ENTRY%" %*
) else (
set ELECTRON_RUN_AS_NODE=1
"%~dp0..\..\NIANXX.exe" "%OPENCLAW_ENTRY%" %*
)
set _EXIT=%ERRORLEVEL%
if defined _CP chcp %_CP% >nul 2>&1
endlocal & exit /b %_EXIT%

View File

@@ -0,0 +1,150 @@
param(
[Parameter(Mandatory = $true)]
[ValidateSet('add', 'remove')]
[string]$Action,
[Parameter(Mandatory = $true)]
[string]$CliDir
)
$ErrorActionPreference = 'Stop'
function Get-UserPathRegistryValue {
$raw = [Environment]::GetEnvironmentVariable('Path', 'User')
$kind = [Microsoft.Win32.RegistryValueKind]::ExpandString
try {
$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment', $false)
if ($null -ne $key) {
try {
$stored = $key.GetValue('Path', $null, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
if ($null -ne $stored) {
$raw = [string]$stored
}
} catch {
# Fallback to Environment API value
}
try {
$kind = $key.GetValueKind('Path')
} catch {
# Keep default ExpandString
}
$key.Close()
}
} catch {
# Fallback to Environment API value
}
return @{
Raw = $raw
Kind = $kind
}
}
function Normalize-PathEntry {
param([string]$Value)
if ([string]::IsNullOrWhiteSpace($Value)) {
return ''
}
return $Value.Trim().Trim('"').TrimEnd('\').ToLowerInvariant()
}
$pathMeta = Get-UserPathRegistryValue
$current = $pathMeta.Raw
$entries = @()
if (-not [string]::IsNullOrWhiteSpace($current)) {
$entries = $current -split ';' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
}
$target = Normalize-PathEntry $CliDir
$seen = [System.Collections.Generic.HashSet[string]]::new()
$nextEntries = New-Object System.Collections.Generic.List[string]
foreach ($entry in $entries) {
$normalized = Normalize-PathEntry $entry
if ([string]::IsNullOrWhiteSpace($normalized)) {
continue
}
if ($normalized -eq $target) {
continue
}
if ($seen.Add($normalized)) {
$nextEntries.Add($entry.Trim().Trim('"'))
}
}
$status = 'already-present'
if ($Action -eq 'add') {
if ($seen.Add($target)) {
$nextEntries.Add($CliDir)
$status = 'updated'
}
} elseif ($entries.Count -ne $nextEntries.Count) {
$status = 'updated'
}
$isLikelyCorruptedWrite = (
$Action -eq 'add' -and
$entries.Count -gt 1 -and
$nextEntries.Count -le 1
)
if ($isLikelyCorruptedWrite) {
throw "Refusing to rewrite user PATH: input had $($entries.Count) entries but output has $($nextEntries.Count)."
}
$newPath = if ($nextEntries.Count -eq 0) { $null } else { $nextEntries -join ';' }
try {
$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment', $true)
if ($null -eq $key) {
throw 'Unable to open HKCU\Environment for write.'
}
if ([string]::IsNullOrWhiteSpace($newPath)) {
$key.DeleteValue('Path', $false)
} else {
$kind = if ($pathMeta.Kind -eq [Microsoft.Win32.RegistryValueKind]::String) {
[Microsoft.Win32.RegistryValueKind]::String
} else {
[Microsoft.Win32.RegistryValueKind]::ExpandString
}
$key.SetValue('Path', $newPath, $kind)
}
$key.Close()
} catch {
throw "Failed to write HKCU\\Environment\\Path: $($_.Exception.Message)"
}
try {
Add-Type -Namespace OpenClaw -Name NativeMethods -MemberDefinition @"
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern System.IntPtr SendMessageTimeout(
System.IntPtr hWnd,
int Msg,
System.IntPtr wParam,
string lParam,
int fuFlags,
int uTimeout,
out System.IntPtr lpdwResult
);
"@
$result = [IntPtr]::Zero
[OpenClaw.NativeMethods]::SendMessageTimeout(
[IntPtr]0xffff,
0x001A,
[IntPtr]::Zero,
'Environment',
0x0002,
5000,
[ref]$result
) | Out-Null
} catch {
Write-Warning "PATH updated but failed to broadcast environment change: $($_.Exception.Message)"
}
Write-Output $status