feat(cli): add plugin install and complete prompt/render host events

This commit is contained in:
Gregory Schier
2026-03-03 15:58:23 -08:00
parent b01b3a4c57
commit ad31755dbb
10 changed files with 845 additions and 35 deletions

View File

@@ -0,0 +1,10 @@
{
"name": "@gschier/prompt-form-cli-test",
"displayName": "Prompt Form CLI Test",
"description": "Tiny plugin to test prompt.form in the CLI host",
"private": true,
"version": "0.0.1",
"scripts": {
"build": "yaak plugin build"
}
}

View File

@@ -0,0 +1,59 @@
export const plugin = {
templateFunctions: [
{
name: 'prompt.form.demo',
description: 'Prompt for a few values using prompt.form and return a JSON string',
args: [],
async onRender(ctx, args) {
if (args.purpose !== 'send') {
return null;
}
const values = await ctx.prompt.form({
id: 'prompt-form-demo',
title: 'CLI Prompt Form Demo',
description: 'Fill out the fields to test prompt.form in the CLI.',
inputs: [
{
type: 'text',
name: 'username',
label: 'Username',
defaultValue: 'alice'
},
{
type: 'text',
name: 'password',
label: 'Password',
password: true,
optional: true
},
{
type: 'select',
name: 'region',
label: 'Region',
defaultValue: 'us',
options: [
{ label: 'US', value: 'us' },
{ label: 'EU', value: 'eu' },
{ label: 'APAC', value: 'apac' }
]
},
{
type: 'checkbox',
name: 'remember',
label: 'Remember',
defaultValue: 'true',
optional: true
}
]
});
if (values == null) {
throw new Error('Prompt form cancelled');
}
return JSON.stringify(values);
}
}
]
};

View File

@@ -0,0 +1,6 @@
{
"compilerOptions": {
"strict": true
},
"include": ["src"]
}