(
input: ApplyCommentInput,
deps: GenerateViaAgentDeps = {},
)
| 482 | } |
| 483 | |
| 484 | export async function applyComment( |
| 485 | input: ApplyCommentInput, |
| 486 | deps: GenerateViaAgentDeps = {}, |
| 487 | ): Promise<GenerateOutput> { |
| 488 | const log = input.logger ?? NOOP_LOGGER; |
| 489 | const ctx = { |
| 490 | provider: input.model.provider, |
| 491 | modelId: input.model.modelId, |
| 492 | } as const; |
| 493 | |
| 494 | if (!input.comment.trim()) { |
| 495 | throw new CodesignError('Comment cannot be empty', ERROR_CODES.INPUT_EMPTY_COMMENT); |
| 496 | } |
| 497 | if (!input.artifactSource.trim()) { |
| 498 | throw new CodesignError('Existing design source cannot be empty', ERROR_CODES.INPUT_EMPTY_HTML); |
| 499 | } |
| 500 | |
| 501 | log.info('[apply_comment] step=build_request', ctx); |
| 502 | const buildStart = Date.now(); |
| 503 | const systemPrompt = composeSystemPrompt({ mode: 'revise' }); |
| 504 | const userPrompt = buildApplyCommentUserPrompt({ |
| 505 | comment: input.comment, |
| 506 | selection: input.selection, |
| 507 | }); |
| 508 | log.info('[apply_comment] step=build_request.ok', { |
| 509 | ...ctx, |
| 510 | ms: Date.now() - buildStart, |
| 511 | }); |
| 512 | |
| 513 | const agentInput: GenerateInput = { |
| 514 | prompt: userPrompt, |
| 515 | systemPrompt, |
| 516 | history: [], |
| 517 | model: input.model, |
| 518 | apiKey: input.apiKey, |
| 519 | workspaceRoot: input.workspaceRoot, |
| 520 | ...(input.baseUrl !== undefined ? { baseUrl: input.baseUrl } : {}), |
| 521 | ...(input.wire !== undefined ? { wire: input.wire } : {}), |
| 522 | ...(input.httpHeaders !== undefined ? { httpHeaders: input.httpHeaders } : {}), |
| 523 | ...(input.allowKeyless !== undefined ? { allowKeyless: input.allowKeyless } : {}), |
| 524 | ...(input.reasoningLevel !== undefined ? { reasoningLevel: input.reasoningLevel } : {}), |
| 525 | ...(input.designSystem !== undefined ? { designSystem: input.designSystem } : {}), |
| 526 | ...(input.attachments !== undefined ? { attachments: input.attachments } : {}), |
| 527 | ...(input.referenceUrl !== undefined ? { referenceUrl: input.referenceUrl } : {}), |
| 528 | ...(input.templatesRoot !== undefined ? { templatesRoot: input.templatesRoot } : {}), |
| 529 | ...(input.signal !== undefined ? { signal: input.signal } : {}), |
| 530 | ...(input.onRetry !== undefined ? { onRetry: input.onRetry } : {}), |
| 531 | ...(input.logger !== undefined ? { logger: input.logger } : {}), |
| 532 | }; |
| 533 | return runAgent(agentInput, deps); |
| 534 | } |
| 535 | |
| 536 | // --------------------------------------------------------------------------- |
| 537 | // Title generation — small synchronous completion used after the first prompt |
no test coverage detected