Skip to content

fix(cli): register the skill <skill-name> positional so strict parsing accepts it - #1027

Open
gewenyu99 wants to merge 4 commits into
mainfrom
posthog-code/fix-skill-positional-strict
Open

fix(cli): register the skill <skill-name> positional so strict parsing accepts it#1027
gewenyu99 wants to merge 4 commits into
mainfrom
posthog-code/fix-skill-positional-strict

Conversation

@gewenyu99

Copy link
Copy Markdown
Collaborator

Problem

wizard skill <skill-name> was documented but broken — running e.g. npx @posthog/wizard skill feature-flags-nextjs failed with Unknown arguments: skill-name, skillName. The command declared its positional only in the command-name string, so under .strictOptions() yargs rejected the value as unknown. Users had to fall back to the retired --skill route.

Changes

Register skill-name through the command's positionals field (the same pattern the audit family factory already uses), so strict parsing accepts the value. The registry-reading and skill-running machinery was already intact — this was purely the missing .positional() registration.

Test plan

  • wizard skill feature-flags-nextjs no longer errors with Unknown arguments.
  • wizard skill "" still gives the friendly "needs a skill name" message.
  • wizard skill list unaffected.
  • wizard skill -h renders the positional correctly; no extra option spam.
  • src/__tests__/cli.test.ts passes (33/33).

Created with PostHog from a Slack thread

…ing accepts it

The `skill` command declared its positional only in the command-name string,
not through the `positionals` field. Under `.strictOptions()`, yargs treats a
command-string positional as an "Unknown argument" unless it is also registered
via `.positional()`, so `wizard skill <name>` failed with
`Unknown arguments: skill-name, skillName`.

Declare `skill-name` in `positionals` (matching the pattern the audit family
factory already uses) so the value is accepted.

Generated-By: PostHog Code
Task-Id: 5c8a2c20-3055-4927-8952-114480ce3c72
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

@gewenyu99
gewenyu99 marked this pull request as ready for review July 29, 2026 17:13
@gewenyu99
gewenyu99 requested a review from a team as a code owner July 29, 2026 17:13
Comment thread src/commands/skill.ts
// `.positional()` too (see the `positionals` note on the Command interface).
// Declare `skill-name` here so `wizard skill <id>` actually accepts its value.
positionals: {
'skill-name': {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, valid, but rejects invalid skills after log in 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird... the cli rejects the argument? or does the agent reject the skill later downstream

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It rejects invalid skills downstream. I want this to reject before log in. Looking for where we have access to skill registry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeayea that makes sense. i think it's an mcp tool call

Addresses review feedback that an invalid `wizard skill <name>` was only
rejected far downstream, after the user had already authenticated.

`skillCommand` now fetches the skill menu and rejects an unknown id up front
with a friendly "run `wizard skill list`" message. The check resolves against
the same set `downloadSkill` uses (categories flattened by id), so it can't
false-reject a skill the download would accept. If the registry is unreachable
we stay silent and defer to the download step's own failure handling rather
than adding a second blocking network dependency.

Generated-By: PostHog Code
Task-Id: 5c8a2c20-3055-4927-8952-114480ce3c72
The handler is now async (it validates the skill id against the registry
before running), so the two handler tests that asserted synchronously no
longer saw runSkillMode called. Mock fetchSkillMenu, await the fire-and-forget
work, and add coverage for the two new branches: defer-and-run when the
registry is unreachable, and reject-before-run on an unknown skill id.

Generated-By: PostHog Code
Task-Id: 5c8a2c20-3055-4927-8952-114480ce3c72
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