-
-
Notifications
You must be signed in to change notification settings - Fork 28
[#2302] Added support for prompts schema to make the installer AI-friendly. #2306
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| namespace DrevOps\VortexInstaller\Prompts\Handlers; | ||
|
|
||
| use DrevOps\VortexInstaller\Prompts\PromptType; | ||
| use DrevOps\VortexInstaller\Utils\Config; | ||
| use DrevOps\VortexInstaller\Utils\Converter; | ||
|
|
||
|
|
@@ -61,6 +62,49 @@ public static function id(): string { | |
| return Converter::machine(Converter::pascal2snake(str_replace('Handler', '', basename($filename, '.php')))); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public static function envName(): string { | ||
| return Converter::constant('VORTEX_INSTALLER_PROMPT_' . static::id()); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function type(): PromptType { | ||
| $options = $this->options([]); | ||
|
|
||
| if (is_array($options)) { | ||
| if (array_is_list($options)) { | ||
| return PromptType::Suggest; | ||
| } | ||
|
|
||
| $default = $this->default([]); | ||
|
|
||
| if (is_array($default)) { | ||
| return PromptType::MultiSelect; | ||
| } | ||
|
|
||
| return PromptType::Select; | ||
| } | ||
|
|
||
| $default = $this->default([]); | ||
|
|
||
| if (is_bool($default)) { | ||
| return PromptType::Confirm; | ||
| } | ||
|
|
||
| return PromptType::Text; | ||
| } | ||
|
Comment on lines
+75
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Type inference may produce inconsistent results when responses affect options/defaults. The Consider documenting this limitation or ensuring the type inference is only used for schema generation where an empty responses context is acceptable. 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function dependsOn(): ?array { | ||
| return NULL; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Handle
file_get_contentsfailure explicitly.Line 319 casts
file_get_contents()result to string, which convertsFALSE(on failure) to an empty string. This empty string then failsjson_decode()silently. Consider checking for file read failure explicitly to provide a more helpful error message.♻️ Proposed improvement
🤖 Prompt for AI Agents