Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,21 @@ jobs:
# right an ordinary Windows user may not have. Codex and pi each read
# the shared ~\.agents\skills as well as their own folder, and the
# skills CLI lays pi's copy in the shared one since its 1.7.1.
# A skill comes from GitHub through npx, so one that is missing says
# which it is: a fetch the install could not make and named in its
# closing note, with what npm said, or a skill the install left out
# without saying so.
# A skill comes from GitHub through the skills CLI, which npm fetches
# from its registry first, so one that is missing says which it is:
# a fetch of the CLI or of the skill the install could not make and
# named in its closing note, with what npm said, or a skill the
# install left out without saying so.
$installLog = Get-Content -Raw -LiteralPath (Join-Path $env:TEMP "CodeGoblinsInstall.log")
foreach ($skill in "gh-axi", "chrome-devtools-axi", "no-mistakes") {
foreach ($folders in @(".claude\skills"), @(".pi\agent\skills", ".agents\skills"), @(".codex\skills", ".agents\skills")) {
$found = @($folders | ForEach-Object { Join-Path $env:USERPROFILE "$_\$skill" } | Where-Object { Test-Path -LiteralPath (Join-Path $_ "SKILL.md") })
if ($found.Count -eq 0) {
$failed = [regex]::Match($installLog, "(?ms)^skill\s+skills CLI\s.*?^WARN\s+skills CLI\s+npm install exited with code (-?\d+)")
if ($failed.Success) {
$npm = @([regex]::Matches($failed.Value, "(?m)^npm error code \S+") | ForEach-Object { $_.Value.Trim() } | Select-Object -Unique) -join "; "
throw "the install could not fetch the skills CLI and named the $skill skill in its closing note: npm exited with code $($failed.Groups[1].Value) after its retry ($npm), so $($folders -join ', ') hold none; a failed fetch, not a broken install"
}
$failed = [regex]::Match($installLog, "(?ms)^skill\s+$([regex]::Escape($skill))\s.*?^WARN\s+$([regex]::Escape($skill))\s+skill install exited with code (-?\d+)")
if ($failed.Success) {
$npm = @([regex]::Matches($failed.Value, "(?m)^npm error code \S+") | ForEach-Object { $_.Value.Trim() } | Select-Object -Unique) -join "; "
Expand Down
75 changes: 51 additions & 24 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,17 @@ public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wP
}

# The tools the fleet drives publish their own skills, installed once at
# user scope so every harness and every project sees them. npx fetches the
# skills CLI into npm's shared cache, and a fetch that breaks there leaves
# an entry every later npx of it fails on, as npm's "Lock compromised" did
# on a CI runner on 2026-10-07; so a failed skill install is tried again
# with a fresh npm cache of the install's own, which the skills after it
# use too, and which is removed once they are in.
# user scope so every harness and every project sees them, by the skills
# CLI. npm installs that CLI into a folder of the install's own, removed
# once the skills are in, and npx runs it from that folder with --no, so
# npx never installs a package itself. An npx that installs one holds a
# lock on its cache folder, which npm before 11.6.3, the npm Node.js 24.13
# ships, reports compromised (npm error code ECOMPROMISED) whenever the
# file system answers slowly, as a busy CI runner's did on 2026-10-07 and
# again on 2026-10-14 with a fresh npm cache (npm/cli#8710). npm's install
# takes no such lock. The npm is the one beside the npx, so the CLI is laid
# out the way that npx reads, and npx finds it by the folder it runs in.
Write-Detail ""
$sharedNpmCache = $env:npm_config_cache
$freshNpmCache = ""
# Where the skills CLI may put each skill, read before it runs, so the
# record names only the folders this install added.
$skillFolders = foreach ($skill in @("gh-axi", "chrome-devtools-axi", "no-mistakes")) {
Expand All @@ -818,39 +820,64 @@ public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wP
}
}
$skillsBefore = @($skillFolders | Where-Object { Test-Path -LiteralPath $_ })
# A missing npm is no failed fetch, so it is never tried again.
$npx = Get-Command npx.cmd -ErrorAction SilentlyContinue
$npm = if ($npx) { Join-Path (Split-Path -Parent $npx.Source) "npm.cmd" } else { "" }
$hasNode = $npx -and (Test-Path -LiteralPath $npm)
$skillsCli = Join-Path ([IO.Path]::GetTempPath()) ("code-goblins-skills-" + [Guid]::NewGuid().ToString("N"))
$hasSkillsCli = $false
if ($hasNode) {
# The CLI comes from npm's registry, and a fetch that fails once is
# tried once more before every skill is left out.
New-Item -ItemType Directory -Path $skillsCli | Out-Null
$cliArgs = @("install", "--prefix", $skillsCli, "--no-save", "--no-audit", "--no-fund", "skills@$skillsCliVersion")
Write-Detail ("skill {0,-20} npm {1}" -f "skills CLI", ($cliArgs -join " "))
$code = Invoke-Logged $npm $cliArgs
if ($code -ne 0) {
Write-Detail ("RETRY {0,-20} npm install exited with code {1}; trying once more" -f "skills CLI", $code)
Start-Sleep -Seconds 2
$code = Invoke-Logged $npm $cliArgs
}
if ($code -ne 0) {
Write-Detail ("WARN {0,-20} npm install exited with code {1}, so no skill is added" -f "skills CLI", $code)
}
$hasSkillsCli = $code -eq 0
}
foreach ($skill in @("gh-axi", "chrome-devtools-axi", "no-mistakes")) {
if (-not (Get-Command npx.cmd -ErrorAction SilentlyContinue)) {
if (-not $hasNode) {
Write-Detail ("PREREQ {0,-20} skill needs Node.js: winget install OpenJS.NodeJS.LTS" -f $skill)
$failedInstalls += "$skill skill"
continue
}
if (-not $hasSkillsCli) {
$failedInstalls += "$skill skill"
continue
}
# Only the fleet's harnesses, as copies: a symlink needs a right an
# ordinary Windows user may not have. The skill comes from GitHub, and
# a fetch that fails once, as one did on a hosted runner on
# 2026-10-06, is tried once more before the skill is left out.
$skillArgs = @("-y", "skills@$skillsCliVersion", "add", "kunchenguid/$skill", "--skill", $skill, "-g", "-y", "-a", "claude-code", "-a", "codex", "-a", "pi", "--copy")
Write-Detail ("skill {0,-20} npx {1}" -f $skill, ($skillArgs[1..($skillArgs.Count - 1)] -join " "))
$code = Invoke-Logged "npx.cmd" $skillArgs
if ($code -ne 0 -and -not $freshNpmCache) {
$freshNpmCache = Join-Path ([IO.Path]::GetTempPath()) ("code-goblins-npm-" + [Guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $freshNpmCache | Out-Null
$env:npm_config_cache = $freshNpmCache
Write-Detail ("RETRY {0,-20} skill install exited with code {1}; trying once more with a fresh npm cache, {2}" -f $skill, $code, $freshNpmCache)
$skillArgs = @("--no", "skills@$skillsCliVersion", "add", "kunchenguid/$skill", "--skill", $skill, "-g", "-y", "-a", "claude-code", "-a", "codex", "-a", "pi", "--copy")
Write-Detail ("skill {0,-20} npx {1}" -f $skill, ($skillArgs -join " "))
Push-Location -LiteralPath $skillsCli
try {
$code = Invoke-Logged "npx.cmd" $skillArgs
if ($code -ne 0) {
Write-Detail ("RETRY {0,-20} skill install exited with code {1}; trying once more" -f $skill, $code)
Start-Sleep -Seconds 2
$code = Invoke-Logged "npx.cmd" $skillArgs
}
}
elseif ($code -ne 0) {
Write-Detail ("RETRY {0,-20} skill install exited with code {1}; trying once more" -f $skill, $code)
Start-Sleep -Seconds 2
$code = Invoke-Logged "npx.cmd" $skillArgs
finally {
Pop-Location
}
if ($code -ne 0) {
Write-Detail ("WARN {0,-20} skill install exited with code {1}" -f $skill, $code)
$failedInstalls += "$skill skill"
}
}
if ($freshNpmCache) {
$env:npm_config_cache = $sharedNpmCache
Remove-Temporary $freshNpmCache
if ($hasNode) {
Remove-Temporary $skillsCli
}
foreach ($folder in $skillFolders) {
if ((Test-Path -LiteralPath $folder) -and -not ($skillsBefore -contains $folder)) {
Expand Down
2 changes: 1 addition & 1 deletion internal/installscript/install_lavish_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestOneLineInstallRefusesALavishDownloadThatDoesNotMatchItsPin(t *testing.T
t.Fatalf("npx was never called: %v\n%s", err, output)
}
for _, skill := range []string{"gh-axi", "chrome-devtools-axi", "no-mistakes"} {
want := fmt.Sprintf("-y skills@%s add kunchenguid/%s --skill %s -g -y -a claude-code -a codex -a pi --copy", skillsCliPin(t), skill, skill)
want := fmt.Sprintf("--no skills@%s add kunchenguid/%s --skill %s -g -y -a claude-code -a codex -a pi --copy", skillsCliPin(t), skill, skill)
if strings.Count(string(skills), want) != 1 {
t.Errorf("npx calls %q, want %q once", skills, want)
}
Expand Down
107 changes: 79 additions & 28 deletions internal/installscript/install_packages_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,56 +79,107 @@ func TestTheInstallPinsEveryPackageItFetchesFromNpm(t *testing.T) {
}
}

// npx fetches the skills CLI into npm's shared cache, and a fetch that breaks
// there, as npm's "Lock compromised" did on a CI runner on 2026-10-07, leaves
// an entry every later npx of that CLI fails on. So a skill install that
// fails is tried again with a fresh npm cache of the install's own, the rest
// go straight to it, and it is removed once the skills are in. The stand-in
// npx fails whenever it runs on the shared cache.
func TestOneLineInstallTriesASkillAgainWithAFreshNpmCache(t *testing.T) {
// An npx that installs a package holds a lock on its cache folder, which npm
// before 11.6.3 reports compromised (ECOMPROMISED) when the file system
// answers slowly, as it did on a CI runner on 2026-10-07 and again on
// 2026-10-14 with a fresh npm cache (issue #888). So the npm beside the npx
// installs the skills CLI into a folder of the install's own, npx runs it from
// that folder with --no, never installing a package itself, and the folder is
// removed once the skills are in. The stand-in npx fails with ECOMPROMISED
// whenever it would install the CLI itself.
func TestOneLineInstallAddsSkillsWithoutNpxInstallingAPackage(t *testing.T) {
// Arrange
folder := t.TempDir()
calls := filepath.Join(folder, installtest.NpxCalls)
npx := "@if \"%npm_config_cache%\"==\"\" (echo shared %6>>\"" + calls + "\"& exit /b 1)\r\n" +
"@echo fresh %6 %npm_config_cache%>>\"" + calls + "\"\r\n" +
"@if not exist \"%npm_config_cache%\" exit /b 2\r\n" +
cli := filepath.Join(folder, "npm-calls.txt")
npm := "@echo %*>>\"" + cli + "\"\r\n" +
"@if not \"%1 %2\"==\"install --prefix\" exit /b 0\r\n" +
"@mkdir \"%~3\\node_modules\\.bin\"\r\n" +
"@echo.>\"%~3\\node_modules\\.bin\\skills.cmd\"\r\n" +
"@exit /b 0\r\n"
npx := "@if not \"%1\"==\"--no\" (echo npm error code ECOMPROMISED& echo installs %6>>\"" + calls + "\"& exit /b 1)\r\n" +
"@if not exist \"%CD%\\node_modules\\.bin\\skills.cmd\" (echo installs %6>>\"" + calls + "\"& exit /b 1)\r\n" +
"@echo local %6 %CD%>>\"" + calls + "\"\r\n" +
"@exit /b 0\r\n"

// Act
output, _, temp := runInstallWithLavishDownload(t, installScript(t), []byte("not the release the script pins"), map[string]string{"npx": npx})
output, _, temp := runInstallWithLavishDownload(t, installScript(t), []byte("not the release the script pins"), map[string]string{"npm": npm, "npx": npx})

// Assert
fetched, err := os.ReadFile(cli)
if err != nil {
t.Fatalf("npm was never called: %v\n%s", err, output)
}
fetch := regexp.MustCompile(`(?m)^install --prefix (\S+) --no-save --no-audit --no-fund skills@` + regexp.QuoteMeta(skillsCliPin(t)) + `\s*$`).FindStringSubmatch(strings.ReplaceAll(string(fetched), "\r\n", "\n"))
if fetch == nil {
t.Fatalf("npm was called as %q, want it to install the pinned skills CLI into a folder of its own", fetched)
}
recorded, err := os.ReadFile(calls)
if err != nil {
t.Fatalf("npx was never called: %v\n%s", err, output)
}
lines := strings.Split(strings.TrimSpace(strings.ReplaceAll(string(recorded), "\r\n", "\n")), "\n")
if len(lines) != 4 || lines[0] != "shared gh-axi" {
t.Fatalf("npx was called as %q, want gh-axi on the shared cache, then each skill once on a fresh one", lines)
}
var cache string
for index, skill := range []string{"gh-axi", "chrome-devtools-axi", "no-mistakes"} {
fields := strings.SplitN(lines[index+1], " ", 3)
if len(fields) != 3 || fields[0] != "fresh" || fields[1] != skill {
t.Fatalf("call %d was %q, want %s on the fresh cache", index+2, lines[index+1], skill)
}
if cache == "" {
cache = fields[2]
}
want := []string{"gh-axi", "chrome-devtools-axi", "no-mistakes"}
if len(lines) != len(want) {
t.Fatalf("npx was called as %q, want each skill once from the skills CLI's folder", lines)
}
for index, skill := range want {
fields := strings.SplitN(lines[index], " ", 3)
// A runner's temporary folder can be spelt with 8.3 short names on
// one side and long ones on the other.
if fields[2] != cache || !strings.HasPrefix(strings.ToLower(fsx.LongPath(cache)), strings.ToLower(fsx.LongPath(temp))) {
t.Errorf("%s ran with the npm cache %q, want the one fresh cache in the temporary folder", skill, fields[2])
if len(fields) != 3 || fields[0] != "local" || fields[1] != skill || !strings.EqualFold(fsx.LongPath(fields[2]), fsx.LongPath(fetch[1])) {
t.Errorf("call %d was %q, want %s run in %s", index+1, lines[index], skill, fetch[1])
}
}
if _, err := os.Stat(cache); !os.IsNotExist(err) {
t.Errorf("the fresh npm cache %s outlived the install: %v", cache, err)
if !strings.HasPrefix(strings.ToLower(fsx.LongPath(fetch[1])), strings.ToLower(fsx.LongPath(temp))) {
t.Errorf("the skills CLI went into %s, want a folder in the temporary folder %s", fetch[1], temp)
}
if _, err := os.Stat(fetch[1]); !os.IsNotExist(err) {
t.Errorf("the skills CLI's folder %s outlived the install: %v", fetch[1], err)
}
if note := installNote.FindString(output); strings.Contains(note, "skill") {
t.Errorf("the install's Note is %q, want every skill installed:\n%s", note, output)
}
}

// The skills CLI comes from npm's registry, so a fetch of it that fails is
// tried once more, and one that fails again leaves every skill out, each
// named in the install's one Note line, with npx never run.
func TestOneLineInstallNamesEverySkillWhenTheSkillsCliCannotBeFetched(t *testing.T) {
// Arrange
folder := t.TempDir()
calls := filepath.Join(folder, installtest.NpxCalls)
cli := filepath.Join(folder, "npm-calls.txt")
npm := "@echo %*>>\"" + cli + "\"\r\n" +
"@if \"%1 %2\"==\"install --prefix\" exit /b 1\r\n" +
"@exit /b 0\r\n"
npx := "@echo %*>>\"" + calls + "\"\r\n@exit /b 0\r\n"

// Act
output, _, _ := runInstallWithLavishDownload(t, installScript(t), []byte("not the release the script pins"), map[string]string{"npm": npm, "npx": npx})

// Assert
fetched, err := os.ReadFile(cli)
if err != nil {
t.Fatalf("npm was never called: %v\n%s", err, output)
}
if got := strings.Count(string(fetched), "skills@"+skillsCliPin(t)); got != 2 {
t.Errorf("npm fetched the skills CLI %d times, want 2:\n%s", got, fetched)
}
if recorded, err := os.ReadFile(calls); err == nil {
t.Errorf("npx was called as %q, want it never run without the skills CLI", recorded)
}
note := installNote.FindString(output)
for _, skill := range []string{"gh-axi", "chrome-devtools-axi", "no-mistakes"} {
if !strings.Contains(note, skill+" skill") {
t.Errorf("the install's Note is %q, want it to name the %s skill:\n%s", note, skill, output)
}
}
if !strings.Contains(output, "skills CLI") || !strings.Contains(output, "npm install exited with code 1, so no skill is added") {
t.Errorf("the install's log does not say the skills CLI could not be fetched:\n%s", output)
}
}

// A skill comes from GitHub, so one whose install fails is tried once more,
// and one that fails again is left out and named in the install's one Note
// line while the install goes on. The stand-in npx fails gh-axi every time
Expand All @@ -154,7 +205,7 @@ func TestOneLineInstallTriesASkillAgainAndNamesOneThatStillFails(t *testing.T) {
t.Fatalf("npx was never called: %v\n%s", err, output)
}
for skill, want := range map[string]int{"gh-axi": 2, "chrome-devtools-axi": 2, "no-mistakes": 1} {
call := "-y skills@" + skillsCliPin(t) + " add kunchenguid/" + skill + " --skill " + skill + " -g -y -a claude-code -a codex -a pi --copy"
call := "--no skills@" + skillsCliPin(t) + " add kunchenguid/" + skill + " --skill " + skill + " -g -y -a claude-code -a codex -a pi --copy"
if got := strings.Count(string(recorded), call); got != want {
t.Errorf("npx was called %d times as %q, want %d:\n%s", got, call, want, recorded)
}
Expand Down
Loading