MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractApprovedPlan

Function extractApprovedPlan

src/utils/ultraplan/ccrSession.ts:333–349  ·  view source on GitHub ↗
(content: ToolResultBlockParam['content'])

Source from the content-addressed store, hash-verified

331// Plan is echoed in tool_result content as "## Approved Plan:\n<text>" or
332// "## Approved Plan (edited by user):\n<text>" (ExitPlanModeV2Tool).
333function extractApprovedPlan(content: ToolResultBlockParam['content']): string {
334 const text = contentToText(content)
335 // Try both markers — edited plans use a different label.
336 const markers = [
337 '## Approved Plan (edited by user):\n',
338 '## Approved Plan:\n',
339 ]
340 for (const marker of markers) {
341 const idx = text.indexOf(marker)
342 if (idx !== -1) {
343 return text.slice(idx + marker.length).trimEnd()
344 }
345 }
346 throw new Error(
347 `ExitPlanMode approved but tool_result has no "## Approved Plan:" marker — remote may have hit the empty-plan or isAgent branch. Content preview: ${text.slice(0, 200)}`,
348 )
349}
350

Callers 1

ingestMethod · 0.85

Calls 1

contentToTextFunction · 0.85

Tested by

no test coverage detected