Skip to content

Commit 997f547

Browse files
committed
Ask for input parameter if PR URL is missing from the initial poseidon:pr-review command
1 parent e08fc97 commit 997f547

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

commands/Poseidon_PR_Review.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Symfony\Component\Console\Input\InputOption;
1010
use Symfony\Component\Console\Output\OutputInterface;
1111
use Symfony\Component\Console\Question\ConfirmationQuestion;
12+
use Symfony\Component\Console\Question\Question;
1213
use Symfony\Component\Filesystem\Filesystem;
1314
use Symfony\Component\Process\Process;
1415
use WPCOMSpecialProjects\CLI\Helper\AutocompleteTrait;
@@ -100,7 +101,7 @@ protected function configure(): void {
100101
$this->setDescription( 'Runs the Poseidon AI code review against a pull request using your local `gh` and `claude` CLIs.' )
101102
->setHelp( "This command fetches the Poseidon review prompt from `a8cteam51/poseidon-actions` (trunk), clones the PR locally, and runs the local `claude` CLI to review it.\n\nIt uses your own `gh` and `claude` authentication (not OpsOasis), so it works on any PR you have GitHub access to — including repos outside a8cteam51 such as `Automattic`.\n\nBy default the review is printed to the terminal and nothing is posted. Pass `--post-to-github` to post the review to the PR as your `gh` user." );
102103

103-
$this->addArgument( 'pr', InputArgument::REQUIRED, 'Pull request URL (https://github.com/OWNER/REPO/pull/N) or OWNER/REPO#N.' );
104+
$this->addArgument( 'pr', InputArgument::OPTIONAL, 'Pull request URL (https://github.com/OWNER/REPO/pull/N) or OWNER/REPO#N. Prompted for if omitted.' );
104105

105106
$this->addOption( 'post-to-github', null, InputOption::VALUE_NONE, 'Post the review to the PR as your `gh` user. Off by default (prints to the terminal only).' );
106107
$this->addOption( 'no-clone', null, InputOption::VALUE_NONE, 'Skip cloning the repository; the agent reads the PR through the GitHub API. Faster, but loses AGENTS.md/.agents grounding and surrounding-code context.' );
@@ -114,7 +115,7 @@ protected function configure(): void {
114115
* @throws \InvalidArgumentException If the PR reference cannot be parsed.
115116
*/
116117
protected function initialize( InputInterface $input, OutputInterface $output ): void {
117-
$reference = get_string_input( $input, 'pr' );
118+
$reference = get_string_input( $input, 'pr', fn() => $this->prompt_pr_input( $input, $output ) );
118119
$parsed = $this->parse_pr_reference( $reference );
119120
if ( null === $parsed ) {
120121
throw new \InvalidArgumentException( "Could not parse a pull request reference from `$reference`. Expected a PR URL or OWNER/REPO#N." );
@@ -257,6 +258,19 @@ static function ( string $type, string $buffer ) use ( $output ): void {
257258

258259
// region HELPERS
259260

261+
/**
262+
* Prompts the user for a pull request reference.
263+
*
264+
* @param InputInterface $input The input object.
265+
* @param OutputInterface $output The output object.
266+
*
267+
* @return string|null
268+
*/
269+
private function prompt_pr_input( InputInterface $input, OutputInterface $output ): ?string {
270+
$question = new Question( '<question>Please enter the pull request URL or OWNER/REPO#N:</question> ' );
271+
return $this->getHelper( 'question' )->ask( $input, $output, $question );
272+
}
273+
260274
/**
261275
* Parses a PR reference (full URL or OWNER/REPO#N) into its parts.
262276
*

0 commit comments

Comments
 (0)