(payload)
| 351 | } |
| 352 | |
| 353 | function renderBudgetExplanation(payload) { |
| 354 | const budgetPayload = ensureBudgetPayload(payload); |
| 355 | const budgets = budgetPayload.budgets; |
| 356 | const whyBullets = [ |
| 357 | `- Budget method: ${budgets.method}.`, |
| 358 | `- Trigger and invoke tokens matter most because they are closest to always-loaded or frequently-loaded context.`, |
| 359 | ...(budgets.invocation_policy?.explicit_only_skill_count > 0 |
| 360 | ? [ |
| 361 | `- Explicit-only skills are excluded from trigger and invoke budgets, but their standalone load ceiling is shown separately.`, |
| 362 | ] |
| 363 | : []), |
| 364 | ...(budgetPayload.baselineEvidence |
| 365 | ? [`- Baseline corpus: skills=${budgetPayload.baselineEvidence.skillSamples}, plugins=${budgetPayload.baselineEvidence.pluginSamples}.`] |
| 366 | : []), |
| 367 | ]; |
| 368 | const fixFirst = ["- Nothing to fix from this view alone; use the next step to validate or contextualize the estimate."]; |
| 369 | |
| 370 | if (["heavy", "excessive"].includes(budgets.trigger_cost_tokens.band) || ["heavy", "excessive"].includes(budgets.invoke_cost_tokens.band)) { |
| 371 | fixFirst.unshift("- The active budget is heavy enough that measured usage is worth collecting before tuning copy or structure."); |
| 372 | } |
| 373 | |
| 374 | return [ |
| 375 | `# Budget Explanation: ${budgetPayload.target.name}`, |
| 376 | "", |
| 377 | section("At a Glance", [ |
| 378 | ...renderBudgets(budgets).split("\n"), |
| 379 | ]), |
| 380 | "", |
| 381 | section("Why It Matters", whyBullets), |
| 382 | "", |
| 383 | section("Fix First", fixFirst), |
| 384 | "", |
| 385 | section("Recommended Next Step", renderNextAction(budgetPayload.nextAction)), |
| 386 | "", |
| 387 | section("Details", [ |
| 388 | detailsBlock( |
| 389 | "Trigger components", |
| 390 | budgets.trigger_cost_tokens.components.map((component) => `- ${component.label}: ${component.tokens} tokens`).join("\n"), |
| 391 | ), |
| 392 | detailsBlock( |
| 393 | "Invoke components", |
| 394 | budgets.invoke_cost_tokens.components.map((component) => `- ${component.label}: ${component.tokens} tokens`).join("\n"), |
| 395 | ), |
| 396 | detailsBlock( |
| 397 | "Deferred components", |
| 398 | budgets.deferred_cost_tokens.components.length > 0 |
| 399 | ? budgets.deferred_cost_tokens.components.map((component) => `- ${component.label}: ${component.tokens} tokens`).join("\n") |
| 400 | : "- None", |
| 401 | ), |
| 402 | budgets.explicit_only_invoke_cost_tokens |
| 403 | ? detailsBlock( |
| 404 | "Explicit-only skill components", |
| 405 | budgets.explicit_only_invoke_cost_tokens.components.length > 0 |
| 406 | ? budgets.explicit_only_invoke_cost_tokens.components.map((component) => `- ${component.label}: ${component.tokens} tokens`).join("\n") |
| 407 | : "- None", |
| 408 | ) |
| 409 | : "", |
| 410 | detailsBlock("Use From Codex Chat", renderWorkflowGuide(budgetPayload.workflowGuide)), |
no test coverage detected