Files
chainbase-labs__agentkey/tests/dsh-install-target.ps1
T
zzAllenn 8e93c67a33 fix(installer): avoid PromptScript failure for DSH (#97)
## Summary

- install the AgentKey Skill through the Skills CLI universal target for
DSH-only installs
- avoid passing either dsh or the unsupported global PromptScript target
while preserving explicit mixed-agent targets
- update Bash, PowerShell, English/Chinese setup guidance, retry
instructions, and release-asset source docs
- add Bash mixed-target coverage and a Windows PowerShell invocation
regression

## Root cause

skills@1.5.23 -g -y adds PromptScript to its universal target set even
though PromptScript has no global install directory. The canonical
AgentKey Skill still installs, but the command prints Failed to install
1. Explicitly targeting universal writes the same
~/.agents/skills/agentkey copy without selecting PromptScript.

## Validation

- bats tests/ — 42/42
- bash -n scripts/install.sh
- bash -n scripts/uninstall.sh
- bash -n scripts/build-release-assets.sh
- scripts/build-release-assets.sh with an isolated output directory
- workflow YAML parse
- git diff --check
- Windows behavior regression added to the windows-latest Scripts tests
job

## Deployment follow-up

Merging/releasing this PR does not automatically update
agentkey.app/install.sh. After release, publish the current
Bash/PowerShell install and uninstall scripts to the website origin and
purge the CDN; the live endpoints were serving stale pre-DSH content
during verification.

Co-authored-by: Allen <0xfatdog@gmail.com>
2026-08-25 00:55:26 +08:00

50 lines
1.7 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path $PSScriptRoot -Parent
$installerPath = Join-Path $repoRoot 'scripts/install.ps1'
$tempRoot = if ([string]::IsNullOrWhiteSpace($env:RUNNER_TEMP)) { [System.IO.Path]::GetTempPath() } else { $env:RUNNER_TEMP }
$testRoot = Join-Path $tempRoot "agentkey-dsh-install-target-$([guid]::NewGuid())"
$fakeBin = Join-Path $testRoot 'bin'
$fakeAppData = Join-Path $testRoot 'appdata'
$logPath = Join-Path $testRoot 'npx.log'
New-Item -ItemType Directory -Force -Path $fakeBin, $fakeAppData | Out-Null
Remove-Item -Force -ErrorAction SilentlyContinue $logPath
$fakeNpx = @"
@echo off
echo %*>>"$logPath"
mkdir "%APPDATA%\amp\skills\agentkey" 2>nul
echo # fake skill>"%APPDATA%\amp\skills\agentkey\SKILL.md"
exit /b 0
"@
Set-Content -LiteralPath (Join-Path $fakeBin 'npx.cmd') -Value $fakeNpx -Encoding Ascii
$originalPath = $env:PATH
$originalAppData = $env:APPDATA
$originalDshHome = $env:DSH_HOME
try {
$env:PATH = "$fakeBin;$originalPath"
$env:APPDATA = $fakeAppData
$env:DSH_HOME = Join-Path $testRoot 'dsh-home'
& $installerPath -Yes -Only dsh -SkipMcp
if ($LASTEXITCODE -ne 0) {
throw "PowerShell installer exited with $LASTEXITCODE"
}
} finally {
$env:PATH = $originalPath
$env:APPDATA = $originalAppData
$env:DSH_HOME = $originalDshHome
}
$log = [System.IO.File]::ReadAllText($logPath)
if ($log -notmatch '(?m)-y skills add chainbase-labs/agentkey -g -a universal -s agentkey -y') {
throw "DSH-only install did not use the universal global target. npx log: $log"
}
if ($log -match '(?m)skills add .* -a .*dsh') {
throw "DSH was incorrectly passed to skills add -a. npx log: $log"
}
Write-Host 'PowerShell DSH universal-target regression: PASS'