buildPrompt method presentation ✓ 100.0%
Last updated: 2026-03-03T11:04:37.495Z
Metrics
LOC: 40
Complexity: 6
Params: 2
Coverage: 100.0% (10/10 lines, 14x executed)
Signature
buildPrompt(input: FormContextInput, userContext?: string): : string
Source Code
buildPrompt(input: FormContextInput, userContext?: string): string {
const fieldLines = input
.slice(0, FORM_CONTEXT_MAX_FIELDS)
.map((f) => {
const label = f.label?.trim()
? f.label.trim()
: (f.inputType ?? "field");
let line = `[${f.index}] ${label} (${f.fieldType})`;
if (f.options && f.options.length > 0) {
const opts = f.options
.filter((o) => o.trim().length > 0)
.slice(0, MAX_OPTIONS_PER_FIELD)
.join("|");
if (opts) line += `: ${opts}`;
}
return line;
})
.join("\n");
const contextBlock = buildUserContextBlock(userContext);
return (
`You are a cohesive test-data generator for Brazilian web forms.\n` +
`Generate realistic values for ALL fields below.\n` +
`RULES:\n` +
`- All values must belong to the SAME fictional person/company.\n` +
`- Use Brazilian Portuguese for names, addresses, and locale-specific data.\n` +
`- Valid CPF format: nnn.nnn.nnn-nn (with real check digits).\n` +
`- Valid CNPJ format: nn.nnn.nnn/nnnn-nn (with real check digits).\n` +
`- Use DD/MM/YYYY for dates unless the label says otherwise.\n` +
`- For SELECT fields, pick exactly one value from the provided options.\n` +
`- Respond ONLY with minified JSON: {"0":"value","1":"value",...}\n` +
`- Include ALL field indices listed below.\n` +
contextBlock +
`\nFields:\n${fieldLines}\n\n` +
`JSON:`
);
},
Dependencies (Outgoing)
| Target | Type |
|---|---|
| buildUserContextBlock | calls |
No incoming dependencies.