Skip to content

Commit fb28790

Browse files
committed
feat: ask for the variables of a file on a single screen
Experiment: the default reporter asks for all the variables of a file (and of each template) on one screen, in the style of an onboarding wizard. - Answered questions collapse to one line and can be edited again (up/down, tab). The focused question shows its description and input. - Questions appear and disappear as answers change their when conditions, and defaults that reference other variables follow the answers. - Answers are validated when a question is left and on submit (the first invalid question is focused). Escape cancels. - VariableResolver: optional form prompter. The form gets the fields for the current answers and validates answers with the same rules as the resolver, then the answers are applied as before. Presets and values passed by the template are not shown. Reporters without a form (plain, json) still ask one variable at a time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk5xkqnrsLyn9Eco1yn
1 parent 81f2f1a commit fb28790

8 files changed

Lines changed: 797 additions & 12 deletions

File tree

‎src/common/initialize-plugins.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export class PluginInitOrchestrator {
4747
): Promise<InitializationResult> {
4848
await ShellUtils.validateShell();
4949

50-
const variables = new VariableResolver((request) => reporter.promptVariable(request), args.variableValues);
50+
// Reporters that can show a form ask for the variables of a file on one screen
51+
const variables = new VariableResolver(
52+
(request) => reporter.promptVariable(request),
53+
args.variableValues,
54+
reporter.promptVariableForm ? (form) => reporter.promptVariableForm!(form) : undefined,
55+
);
5156
const project = await PluginInitOrchestrator.parseProject(
5257
args,
5358
reporter,

‎src/ui/components/default-component.tsx‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { ImportResult } from '../../orchestrators/import.js';
1212
import { RenderEvent } from '../reporters/reporter.js';
1313
import { RenderStatus, store } from '../store/index.js';
1414
import { StaticOutput } from './static-output.js';
15-
import type { VariablePromptRequest } from '../../variables/variable-resolver.js';
15+
import type { VariableForm, VariablePromptRequest } from '../../variables/variable-resolver.js';
16+
import { VariableFormPrompt } from './variable-form/variable-form.js';
1617
import { FileModificationDisplay } from './file-modification/file-modification.js';
1718
import { ImportResultComponent } from './import/import-result.js';
1819
import { ImportWarning } from './import/import-warning.js';
@@ -179,6 +180,17 @@ export function DefaultComponent(props: {
179180
</Box>
180181
)
181182
}
183+
{
184+
renderStatus === RenderStatus.PROMPT_VARIABLE_FORM && (
185+
<VariableFormPrompt
186+
form={renderData as VariableForm}
187+
// A new form for every file (and template)
188+
key={JSON.stringify([(renderData as VariableForm).scope, (renderData as VariableForm).location])}
189+
onCancel={() => emitter.emit(RenderEvent.PROMPT_RESULT, null)}
190+
onSubmit={(answers) => emitter.emit(RenderEvent.PROMPT_RESULT, answers)}
191+
/>
192+
)
193+
}
182194
{
183195
renderStatus === RenderStatus.PROMPT_VARIABLE && (
184196
<VariablePrompt

0 commit comments

Comments
 (0)