Skip to content

Conversation

Copy link

Copilot AI commented Oct 30, 2025

  • Understand current codebase structure and how REPL works
  • Implement restart functionality in REPL class
    • Add special command detection for 'restart'
    • Return special exit code (10) when restart is requested
    • Update REPL loop to return instead of infinite loop on restart
    • Add 'exit' command support for clean exit
  • Implement wrapper loop in Shell_Command to restart REPL
    • Check return value and restart if needed
    • Handle restart loop with do-while pattern
  • Add comprehensive tests for restart and exit functionality
  • Implement --watch option for auto-restart on file changes
    • Add --watch parameter handling with validation
    • Add file modification time tracking
    • Implement recursive directory monitoring
    • Auto-restart when changes detected
    • Force --basic mode when --watch is used
  • Update documentation in docblocks with examples
  • Run code review (passed with no issues)
  • Run security checks (no issues found)
  • Fix PHPCS alignment issues
  • Remove unnecessary PHPStan ignore directive
  • Add SplFileInfo type hint for PHPStan

Implementation Complete

All requirements from the issue have been implemented and code style issues have been addressed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support restarting a shell</issue_title>
<issue_description>The wp shell command is super useful for debugging sessions, however it is quite tedious when you need to make code changes, as it does not reload the modified code.

By properly spawning the actual REPL in a new PHP process, and by checking the exit state for a specific result, it should be possible to inject a command that allows for restarting the REPL.

Bonus points: provide a wp shell --watch=<folder> command that watches for changes in a specific folder and restarts the shell automatically.</issue_description>

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

@danielbachhuber 💯

💡 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 and others added 3 commits October 30, 2025 12:22
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Support restarting the shell in wp shell command Add restart command and --watch option to wp shell Oct 30, 2025
Copilot AI requested a review from swissspidy October 30, 2025 12:31
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 26.00000% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_CLI/Shell/REPL.php 18.75% 26 Missing ⚠️
src/Shell_Command.php 38.88% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
Copy link
Member

@copilot Please fix the PHPCS issues ("Equals sign not aligned with surrounding assignments") and verify with composer phpcs. You can also use composer phpcbf to format the code.

Also, seems like that @phpstan-ignore while.alwaysTrue directive is no longer needed and can be removed.

Might need to cast $file as SplFileInfo via PHPDoc, otherwise PHPStan reports "Cannot call method getMTime() on mixed"

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 30, 2025

@copilot Please fix the PHPCS issues ("Equals sign not aligned with surrounding assignments") and verify with composer phpcs. You can also use composer phpcbf to format the code.

Also, seems li...

Fixed in f502d3d:

  • Aligned equals signs in get_recursive_mtime() method
  • Removed the @phpstan-ignore while.alwaysTrue directive (no longer needed since the loop can now return)
  • Added @var \SplFileInfo $file PHPDoc cast to resolve PHPStan warning about getMTime() on mixed type

@swissspidy swissspidy marked this pull request as ready for review October 30, 2025 21:25
@swissspidy swissspidy requested a review from a team as a code owner October 30, 2025 21:25
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.

Support restarting a shell

2 participants