Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/plugin/commands/deploy-function.md.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: deploy-function
name: {{ language.name == 'CodexPlugin' ? 'deploy-function' | skillName(spec) : 'deploy-function' }}
description: Deploy a function using the {{ spec.info.title }} CLI
{% if language.name == 'ClaudePlugin' %}
disable-model-invocation: true
Expand Down
2 changes: 1 addition & 1 deletion templates/plugin/commands/deploy-site.md.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: deploy-site
name: {{ language.name == 'CodexPlugin' ? 'deploy-site' | skillName(spec) : 'deploy-site' }}
description: Deploy a site using the {{ spec.info.title }} CLI
{% if language.name == 'ClaudePlugin' %}
disable-model-invocation: true
Expand Down
39 changes: 38 additions & 1 deletion tests/generation/GenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
use Appwrite\SDK\Language;
use Appwrite\SDK\Language\Android;
use Appwrite\SDK\Language\Apple;
use Appwrite\SDK\Language\ClaudePlugin;
use Appwrite\SDK\Language\CLI;
use Appwrite\SDK\Language\CodexPlugin;
use Appwrite\SDK\Language\CursorPlugin;
use Appwrite\SDK\Language\Dart;
use Appwrite\SDK\Language\DotNet;
use Appwrite\SDK\Language\Flutter;
Expand All @@ -24,6 +27,7 @@
use Appwrite\SDK\Language\REST;
use Appwrite\SDK\Language\Ruby;
use Appwrite\SDK\Language\Rust;
use Appwrite\SDK\Language\Skills;
use Appwrite\SDK\Language\Swift;
use Appwrite\SDK\Language\Unity;
use Appwrite\SDK\Language\Web;
Expand Down Expand Up @@ -108,6 +112,19 @@ final class GenerationTest extends TestCase
'rust' => ['src/enums/webhook_event.rs', 'pub const UserCreated', 'src/enums/localized_status.rs', 'Value1,', 'src/enums/province_type.rs', 'Capital,'],
];

/**
* Targets that ship Agent Skills, whose `SKILL.md` frontmatter name must
* match the directory holding it.
*
* @var array<string, class-string<Language>>
*/
private const array SKILL_LANGUAGES = [
'skills' => Skills::class,
'claude-plugin' => ClaudePlugin::class,
'cursor-plugin' => CursorPlugin::class,
'codex-plugin' => CodexPlugin::class,
];

/**
* Package metadata each language must declare, by generated path: the
* runtime floor its code and dependencies need, and every interpreter
Expand Down Expand Up @@ -180,7 +197,7 @@ private static function languageClasses(): array

private function language(string $name): Language
{
$language = new (self::languageClasses()[$name])();
$language = new ((self::languageClasses() + self::SKILL_LANGUAGES)[$name])();
if ($language instanceof CLI) {
$language->setExecutableName('appwrite');
}
Expand Down Expand Up @@ -1254,6 +1271,26 @@ public function testSwiftModelDefaultsAreLiterals(): void
$this->assertStringContainsString('self.zzsettings = try container.contains(.zzsettings) ? container.decode([String: AnyCodable].self, forKey: .zzsettings) : ([String: Any]()).mapValues { AnyCodable($0) }', $model);
}

/** @return iterable<string, array{string}> */
public static function skillLanguages(): iterable
{
foreach (\array_keys(self::SKILL_LANGUAGES) as $name) {
yield $name => [$name];
}
}

#[DataProvider('skillLanguages')]
public function testSkillNamesMatchTheirDirectories(string $name): void
{
$skills = \array_filter($this->generate($name, 'console'), static fn(string $path): bool => \basename($path) === 'SKILL.md', ARRAY_FILTER_USE_KEY);
$this->assertNotEmpty($skills);

foreach ($skills as $path => $contents) {
$this->assertSame(1, \preg_match('/\\A---\\nname: (\\S+)\\n/', $contents, $match), "{$name}: {$path} has no frontmatter name");
$this->assertSame(\basename(\dirname($path)), $match[1], "{$name}: {$path}");
}
}

public function testGoModelCommentsAreNotHtmlEscaped(): void
{
$models = \array_filter($this->generate('go', 'server'), static fn(string $path): bool => \str_starts_with($path, 'models/') && \str_ends_with($path, '.go'), ARRAY_FILTER_USE_KEY);
Expand Down
Loading