diff --git a/json-schema.json b/json-schema.json index 779fc02..8592b63 100644 --- a/json-schema.json +++ b/json-schema.json @@ -820,7 +820,6 @@ "items": { "type": "object", "required": [ - "role", "content" ], "properties": { @@ -830,6 +829,7 @@ "user", "assistant" ], + "default": "user", "description": "The role of the message sender" }, "content": { diff --git a/tests/src/Feature/Console/GenerateCommand/PromptValidationTest.php b/tests/src/Feature/Console/GenerateCommand/PromptValidationTest.php index e08f1f9..f8e96aa 100644 --- a/tests/src/Feature/Console/GenerateCommand/PromptValidationTest.php +++ b/tests/src/Feature/Console/GenerateCommand/PromptValidationTest.php @@ -129,7 +129,7 @@ public function prompt_with_missing_message_content_should_be_rejected(string $c #[Test] #[DataProvider('commandsProvider')] - public function prompt_with_missing_message_role_should_be_rejected(string $command): void + public function prompt_with_missing_message_role_defaults_to_user(string $command): void { // Create a config with a prompt that has a message with missing role $configFile = $this->createTempFile( @@ -139,7 +139,7 @@ public function prompt_with_missing_message_role_should_be_rejected(string $comm description: "Prompt with message missing role" messages: - content: "This message is missing a role" - # Missing role + # Missing role defaults to "user" YAML, '.yaml', ); @@ -150,8 +150,8 @@ public function prompt_with_missing_message_role_should_be_rejected(string $comm command: $command, ); - // The implementation should reject a prompt with missing message role - $result->assertPromptCount(0); + $result->assertPromptCount(1); + $this->assertSame('user', $result->getResult()['prompts'][0]['messages'][0]['role'] ?? null); } #[Test] @@ -221,7 +221,7 @@ public function template_without_messages_should_be_invalid(string $command): vo type: template description: "Template with no messages" # Missing 'messages' - + - id: extending-empty description: "Prompt extending empty template" extend: @@ -259,7 +259,7 @@ public function prompt_with_invalid_extension_format_should_be_rejected(string $ messages: - role: user content: "Template content" - + - id: invalid-extension description: "Prompt with invalid extension format" extend: @@ -361,7 +361,7 @@ public function duplicated_prompt_ids_should_be_resolved(string $command): void messages: - role: user content: "First prompt content" - + - id: duplicate-id description: "Second prompt with the same ID" messages: @@ -420,7 +420,7 @@ public function prompt_with_both_messages_and_extensions_should_be_valid(string messages: - role: user content: "Template content with {{var}}." - + - id: valid-combined description: "Prompt with both messages and extensions" extend: @@ -469,7 +469,7 @@ public function circular_template_inheritance_should_be_detected(string $command messages: - role: user content: "Template A content" - + - id: template-b type: template extend: