MCPcopy
hub / github.com/codeaashu/claude-code / generateSectionInsight

Function generateSectionInsight

src/commands/insights.ts:1572–1610  ·  view source on GitHub ↗
(
  section: InsightSection,
  dataContext: string,
)

Source from the content-addressed store, hash-verified

1570}
1571
1572async function generateSectionInsight(
1573 section: InsightSection,
1574 dataContext: string,
1575): Promise<{ name: string; result: unknown }> {
1576 try {
1577 const result = await queryWithModel({
1578 systemPrompt: asSystemPrompt([]),
1579 userPrompt: section.prompt + '\n\nDATA:\n' + dataContext,
1580 signal: new AbortController().signal,
1581 options: {
1582 model: getInsightsModel(),
1583 querySource: 'insights',
1584 agents: [],
1585 isNonInteractiveSession: true,
1586 hasAppendSystemPrompt: false,
1587 mcpTools: [],
1588 maxOutputTokensOverride: section.maxTokens,
1589 },
1590 })
1591
1592 const text = extractTextContent(result.message.content)
1593
1594 if (text) {
1595 // Parse JSON from response
1596 const jsonMatch = text.match(/\{[\s\S]*\}/)
1597 if (jsonMatch) {
1598 try {
1599 return { name: section.name, result: jsonParse(jsonMatch[0]) }
1600 } catch {
1601 return { name: section.name, result: null }
1602 }
1603 }
1604 }
1605 return { name: section.name, result: null }
1606 } catch (err) {
1607 logError(new Error(`${section.name} failed: ${toError(err).message}`))
1608 return { name: section.name, result: null }
1609 }
1610}
1611
1612async function generateParallelInsights(
1613 data: AggregatedData,

Callers 1

generateParallelInsightsFunction · 0.85

Calls 7

queryWithModelFunction · 0.85
asSystemPromptFunction · 0.85
getInsightsModelFunction · 0.85
jsonParseFunction · 0.85
toErrorFunction · 0.85
extractTextContentFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected