-
-
Notifications
You must be signed in to change notification settings - Fork 35
feat: replace skill:install file copy with discovery stubs + skill:get #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da2f706
feat: replace skill:install file copy with discovery stubs + skill:ge…
mglaman c91151e
fix(ci): update skill:install test for discovery stub pattern
mglaman 4c75cdc
feat: skill:install writes single drupalorg-cli discovery stub
mglaman c52595e
test: add GetTest smoke test for skill:get command
mglaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace mglaman\DrupalOrgCli\Command\Skill; | ||
|
|
||
| use mglaman\DrupalOrgCli\Command\Command; | ||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| class Get extends Command | ||
| { | ||
| protected function configure(): void | ||
| { | ||
| $this | ||
| ->setName('skill:get') | ||
| ->setDescription('Outputs current skill content for agent consumption.') | ||
| ->addArgument('name', InputArgument::REQUIRED, 'Skill name (e.g. drupalorg-cli)') | ||
| ->addOption('full', null, InputOption::VALUE_NONE, 'Include reference files'); | ||
| } | ||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output): int | ||
| { | ||
| $name = (string) $input->getArgument('name'); | ||
| $skillFile = __DIR__ . '/../../../../skills/' . $name . '/SKILL.md'; | ||
|
|
||
| if (!is_file($skillFile)) { | ||
| $this->stdErr->writeln(sprintf('<error>Skill not found: %s</error>', $name)); | ||
| $available = $this->getAvailableSkills(); | ||
| if ($available !== []) { | ||
| $this->stdErr->writeln('Available skills: ' . implode(', ', $available)); | ||
| } | ||
| return 1; | ||
| } | ||
|
|
||
| $content = file_get_contents($skillFile); | ||
| if ($content === false) { | ||
| $this->stdErr->writeln(sprintf('<error>Could not read skill: %s</error>', $name)); | ||
| return 1; | ||
| } | ||
|
|
||
| $this->stdOut->write($content); | ||
|
|
||
| if ((bool) $input->getOption('full')) { | ||
| $refDir = __DIR__ . '/../../../../skills/' . $name . '/references'; | ||
| if (is_dir($refDir)) { | ||
| foreach (new \DirectoryIterator($refDir) as $fileInfo) { | ||
| if ($fileInfo->isDot() || !$fileInfo->isFile() || $fileInfo->getExtension() !== 'md') { | ||
| continue; | ||
| } | ||
| $refContent = file_get_contents($fileInfo->getPathname()); | ||
| if ($refContent !== false) { | ||
| $this->stdOut->writeln(''); | ||
| $this->stdOut->writeln('---'); | ||
| $this->stdOut->writeln('## Reference: ' . $fileInfo->getBasename('.md')); | ||
| $this->stdOut->writeln('---'); | ||
| $this->stdOut->writeln(''); | ||
| $this->stdOut->write($refContent); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * @return string[] | ||
| */ | ||
| private function getAvailableSkills(): array | ||
| { | ||
| $skillsRoot = __DIR__ . '/../../../../skills'; | ||
| if (!is_dir($skillsRoot)) { | ||
| return []; | ||
| } | ||
| $skills = []; | ||
| foreach (new \DirectoryIterator($skillsRoot) as $dir) { | ||
| if ($dir->isDot() || !$dir->isDir()) { | ||
| continue; | ||
| } | ||
| $skills[] = $dir->getFilename(); | ||
| } | ||
| sort($skills); | ||
| return $skills; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|
|
||
| namespace mglaman\DrupalOrg\Tests\Command\Skill; | ||
|
|
||
| use mglaman\DrupalOrgCli\Command\Skill\Get; | ||
| use PHPUnit\Framework\Attributes\CoversClass; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| #[CoversClass(Get::class)] | ||
| class GetTest extends TestCase | ||
| { | ||
| public function testClassExists(): void | ||
| { | ||
| $command = new Get(); | ||
| self::assertInstanceOf(Get::class, $command); | ||
| self::assertSame('skill:get', $command->getName()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.