Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

Plan to fix missing command error in scaffold package-readme

  • Understand the problem: tests fail because scaffolded commands aren't loaded when package-readme runs
  • Identify the root cause: package-readme needs to load wp-cli.yml automatically
  • Revert incorrect fix that hardcoded command filename
  • Implement correct fix: Use launch=true to spawn new process that loads wp-cli.yml
  • Verify code style and static analysis pass
  • Wait for CI tests to verify the fix works

Summary

The fix ensures that when wp scaffold package creates a new package and calls scaffold package-readme, the command is properly loaded via the automatically created wp-cli.yml file. Using launch => true spawns a new WP-CLI process that reads the wp-cli.yml configuration from the package directory.

Original prompt

This section details on the original issue you should resolve

<issue_title>When running wp scaffold package-readme, the output of README.md is incomplete if the custom package is not installed</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

I created a custom package containing a command named "bzmn." When I am in the directory containing the source, and I run wp scaffold package-readme ., the output in README.md is substantially truncated. For an example, please refer to README - without bzmn custom command installed.md. Command descriptions, options, and examples are all absent.

If I install the bzmn custom command via wp package install ., then run wp scaffold package-readme ., the output is complete. For an example, please refer to README - with bzmn custom command installed.md.

If you diff the files, the issue is glaring.

It seems to be the case that the README information is only correct (comprehensive, as in the second example) if the custom package is installed on the system. If it isn't installed, you get the incomplete "style" of README, as in the first example. Is that behaviour intentional? If so, is that desirable? My expectation is that the wp scaffold package-readme . command only sees and operates on the files in the current directory. If the developer's custom package needs to be installed for the package-readme subcommand to work, it may be helpful to note that in the documentation.

Since a developer running the command to generate the README probably already has the package installed, this issue may have been overlooked. I only encountered the issue when creating a Docker container to automatically generate the README. The container, of course, didn't have my custom package pre-installed, and it took a bit of time to figure out why the command output wasn't the same as on my local computer, when the commands themselves were identical.

Let us know what environment you are running this on

The output of wp --info:

OS:     Darwin 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:59 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T8112 x86_64
Shell:  /bin/zsh
PHP binary:     /usr/local/Cellar/[email protected]/8.3.23/bin/php
PHP version:    8.3.23
php.ini used:   /usr/local/etc/php/8.3/php.ini
MySQL binary:   /Users/Shared/DBngin/mysql/8.0.27/bin/mysql
MySQL version:  mysql  Ver 8.0.27 for macos11 on x86_64 (MySQL Community Server - GPL)
SQL modes:      ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       phar:///usr/local/bin/wp
WP-CLI packages dir:    /Users/saul/.wp-cli/packages/
WP-CLI cache dir:       /Users/saul/.wp-cli/cache
WP-CLI global config:   /Users/saul/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.12.0
```</issue_description>

<agent_instructions>There should be an error if the expected commands aren't actually in the cmd_dump</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@swissspidy</author><body>
Hi there,

Thanks for your report!

It sounds like some clarification in the documentation is in order.

Indeed, the `scaffold package-readme` command requires your command to be _loaded_ by WP-CLI in order to fetch all the documentation etc. for the readme. The alternative would be some static analysis of the codebase, but we don't do that. 

That doesn't mean you have to use `wp package install` though.

Typically, packages like yours have a `wp-cli.yml` file in the root with content like this:

```yml
require:
  - bzmn.php

Then, when you run wp scaffold package-readme . in your package folder, WP-CLI will read that file and load your command. The generated README then has the full contents in it as expected, I just tested it.

Tip: if you wanna keep the "There are a few automated processes. [...]" section at the end, check out the note regarding custom sections.</comment_new>
<comment_new>@swissspidy

You mentioned the package-readme subcommand isn't using static analysis. But it's clearly pulling some information from the source, no?

It loads some information from composer.json, yes. S...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix incomplete output of README.md when custom package not installed Error when scaffold package-readme commands are not loaded Jan 14, 2026
Copilot AI requested a review from swissspidy January 14, 2026 12:12
@swissspidy

This comment was marked as resolved.

When wp scaffold package creates a new package, it now explicitly loads the command file (hello-world-command.php) before calling package-readme. This ensures the command is registered in WP-CLI so it can be properly documented in the generated README.

Co-authored-by: swissspidy <[email protected]>

This comment was marked as resolved.

Changed package-readme call to use launch=true instead of launch=false. This spawns a new WP-CLI process that automatically loads the wp-cli.yml file from the package directory, which in turn loads the command file. This is cleaner than hardcoding the command filename.

Co-authored-by: swissspidy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When running wp scaffold package-readme, the output of README.md is incomplete if the custom package is not installed

2 participants