pi-mono/packages
Petr Houška e3da248ea9
fix(coding-agent): keep updating git packages when git clean fails (#11648)
Closes #11597

## Problem

On Windows, `pi update` stopped with `git clean -fdx failed with code 1`
for git extensions such as pi-lens.

1. Another pi session has the extension loaded, so a native module
(`@ast-grep/napi` `.node`) or `ast-grep.exe` is open in that process.
2. npm renames the in-use package dir to
`node_modules/@ast-grep/.napi-win32-x64-msvc-<hash>`. Windows allows the
rename, but npm cannot delete the dir afterwards.
3. The next `pi update` runs `git reset --hard`, then `git clean -fdx`.
git prints `warning: failed to remove ...: Invalid argument` and exits
1.
4. pi threw, leaving the checkout at the new commit with the old
dependencies.

The suggested `-ffdx` does not help. Reproduced locally (git 2.52,
Windows): with a running `.exe`, or a `.node` loaded by another node
process and its dir renamed, both `-fdx` and `-ffdx` fail with `Invalid
argument`. Once the process exits, `-fdx` succeeds.

## Fix

In `cleanAndInstallGitDependencies`, a failed `git clean` no longer
aborts the update. pi:

- prints a warning that files may be in use by another pi session
- still runs `npm install`, so dependencies match the new commit
- keeps the `.pi-update-incomplete` marker, so the next update retries
the clean

## Tests

- `test/git-update.test.ts`: new regression test. A failing clean still
updates and installs dependencies, warns, and keeps the marker. The next
update cleans and removes the marker.
- `test/package-manager.test.ts`: updated the test that expected the
throw.

`npm run check` reports `install-lock is out of date`, and
`package-manager.test.ts > should expand ~ in exclusion and exact
patterns` fails on Windows. Both also happen on `main` without this
change.
2026-10-31 18:19:44 +01:00
..
agent fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
ai fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
chord fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
codemode fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
coding-agent fix(coding-agent): keep updating git packages when git clean fails (#11648) 2026-10-31 18:19:44 +01:00
durable fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
env fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
evals fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
mcp fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
telemetry fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00
tui fix: remove vulnerable dependency chains 2026-10-31 17:54:29 +01:00