MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / extractSelectionReason

Function extractSelectionReason

cli/src/utils/implementor-helpers.ts:711–729  ·  view source on GitHub ↗

* Extract the selection reason from multi-prompt agent's set_output block. * set_output wraps data in a 'data' property, so we need to access input.data.reason

(
  blocks: ContentBlock[] | undefined,
)

Source from the content-addressed store, hash-verified

709 * set_output wraps data in a 'data' property, so we need to access input.data.reason
710 */
711function extractSelectionReason(
712 blocks: ContentBlock[] | undefined,
713): string | null {
714 if (!blocks || blocks.length === 0) return null
715
716 const setOutputBlock = blocks.find(
717 (block): block is ToolContentBlock =>
718 block.type === 'tool' &&
719 block.toolName === 'set_output' &&
720 hasSetOutputData(block.input) &&
721 typeof block.input.data?.reason === 'string',
722 )
723
724 if (!setOutputBlock || !hasSetOutputData(setOutputBlock.input)) {
725 return null
726 }
727
728 return setOutputBlock.input.data?.reason ?? null
729}
730
731/**
732 * Generate a progress-focused preview string for multi-prompt editor.

Callers 1

getMultiPromptPreviewFunction · 0.85

Calls 1

hasSetOutputDataFunction · 0.85

Tested by

no test coverage detected