fix(cli): resolve the update check command like program() does by TURKI156 · Pull Request #485 · microsoft/playwright-cli · GitHub
Skip to content

fix(cli): resolve the update check command like program() does - #485

Closed
TURKI156 wants to merge 4 commits into
microsoft:mainfrom
TURKI156:fix-update-check-command-resolution
Closed

TURKI156 wants to merge 4 commits into
microsoft:mainfrom
TURKI156:fix-update-check-command-resolution

Conversation

@TURKI156

Copy link
Copy Markdown

Summary

  • Resolve the update check command with the same minimist options program() uses, instead of taking the first argument that does not start with -
  • Compare every markdown file of the installed skill, not only SKILL.md
  • Stop scripts/update.js from deleting skills/playwright-cli before the copy succeeds
  • Ignore the .playwright/ directory that install writes

Why

The update check never ran when a global option preceded the command. It picked the command with
process.argv.slice(2).find(arg => !arg.startsWith('-')), which returns the value of a preceding
option rather than the command. program() parses argv with minimist, where --config is not a
boolean option and therefore consumes the next token. So for the invocation documented in the README:

playwright-cli --config path/to/config.json open example.com

program() dispatches open, while the update check saw path/to/config.json, found it absent from
UPDATE_CHECK_COMMANDS, and returned early. Both the version notice and the stale-skill warning were
silently lost. The same applies to --session name open ….

minimist.js and help.json are internal to playwright-core and not in its exports map, so they
are resolved by path — the way skillCheck.js already resolves the bundled SKILL.md — and the old
heuristic remains as a fallback, keeping the check best-effort rather than letting a moved file break
every command.

The skill check only compared SKILL.md. The skill ships ten reference guides alongside it, and a
stale file under references/ misleads the agent just as much. A file missing from the installation
now reads as out of date too.

scripts/update.js could delete the committed skills folder. It removed skills/playwright-cli
and then copied the generated skill over it, with the whole block wrapped in a catch that printed
Generated skills directory not found and exited 0. Any failure in fs.cp therefore left the skills
deleted, reported a cause that was not the real one, and still looked successful — during the roll
flow documented in .claude/skills/dev/roll.md. The copy is now staged beside the target and swapped
in, the previous folder is restored if the swap fails, and real errors surface with a non-zero exit.

Tests

Two tests added:

  • update check runs when a global option precedes the command — uses --session work list, since
    --session is a global option that takes a value
  • update check warns when an installed reference file is out of date

All 11 tests pass locally.

Not covered

  • windowsHide: true was added to the npm view spawn (program() already sets it on its own
    spawns) but is not verified — it needs Windows
  • scripts/update.js has no automated test; it was verified end to end by running it and confirming
    skills/ came back byte-identical with no leftover staging directories

TURKI added 4 commits October 20, 2026 20:29
The update check picked the command with `argv.find(arg => !arg.startsWith('-'))`,
which returns the value of a preceding option rather than the command. For the
documented `playwright-cli --config path/to/config.json open example.com`, that
is `path/to/config.json`, so neither the version notice nor the stale skill
warning ever ran.

Parse argv with the same minimist options program() uses instead. Those files
are internal to playwright-core and not in its "exports" map, so resolve them
by path and fall back to the old heuristic if they ever move, keeping the
check best-effort rather than letting it break every command.
The skill ships SKILL.md plus ten reference guides, but the staleness check
only compared SKILL.md, so an out-of-date file under references/ was never
reported even though it misleads the agent just as much.

Walk the bundled skill directory and compare every markdown file; a file
missing from the installation now reads as out of date too.
update.js removed skills/playwright-cli and then copied the generated skill
over it, with the whole block wrapped in a catch that reported "Generated
skills directory not found" and exited 0. Any failure in fs.cp therefore left
the committed skills deleted, blamed a cause that was not the real one, and
still looked successful — during the documented roll flow.

Stage the copy next to the target and swap it in, restoring the previous
folder if the swap fails, and let real errors surface with a non-zero exit.
`install` writes .playwright/cli.config.json, so running scripts/update.js
during a roll leaves an untracked directory behind.
@pavelfeldman

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants