this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Tighten summarizer prompts and fix Haiku malformed output

- Use mode: 'tool' to force proper structured output via tool calling
- Simplify prompts to focus on capabilities, not code artifacts
- Add scope (frontend/backend) to summaries
- Aggressively consolidate related changes into single features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

alice acfef719 569f6259

+47 -16
+47 -16
src/core/summarizer.ts
··· 18 18 const sessionSummarySchema = z.object({ 19 19 shortSummary: z 20 20 .string() 21 - .describe('1-2 sentence summary of what was BUILT, FIXED, or CHANGED. Never mention reading/exploring.'), 21 + .describe('1-2 sentence summary focusing on capabilities/value, not code artifacts. What can users do now? What problem was solved?'), 22 22 accomplishments: z 23 23 .array(z.string()) 24 - .describe('List of concrete outcomes only: features built, bugs fixed, code written. Never include exploration or research.'), 24 + .describe('List of outcomes framed as capabilities or value. Never list modules/types/components as accomplishments.'), 25 25 filesChanged: z 26 26 .array(z.string()) 27 27 .describe('List of files that were modified or created'), ··· 38 38 ): Promise<SessionSummary> { 39 39 const transcript = createCondensedTranscript(session); 40 40 41 - const systemPrompt = `You summarize Claude Code sessions for a worklog. 42 - Focus ONLY on outcomes: features built, bugs fixed, code written, problems solved. 43 - Never mention exploration, reading code, or research as accomplishments - those are not work. 44 - If files were edited, describe what was changed and why.`; 41 + const systemPrompt = `Summarize this Claude Code session for a worklog. Be concise. 42 + 43 + The transcript shows SCOPE (frontend/backend). Include it in parentheses. 44 + 45 + FORMAT: "[Action] [capability] ([scope])" 46 + Examples: 47 + - "Added multi-dose scheduling (backend, frontend)" 48 + - "Fixed dark mode styling (frontend)" 49 + - "Implemented HealthKit sync (backend, frontend)" 50 + 51 + Rules: 52 + - ONE main accomplishment, maybe two if truly separate work 53 + - Use action verbs: added, fixed, implemented, built 54 + - Never list code artifacts (modules, types, components) 55 + - Describe what users can DO, not what code exists 56 + 57 + Bad: "Created FrequencySelector component, extended type system, updated CSV export" 58 + Good: "Added dose frequency selection (frontend, backend)"`; 45 59 46 60 const userPrompt = `Summarize this Claude Code session:\n\n${transcript}`; 47 61 ··· 52 66 system: systemPrompt, 53 67 prompt: userPrompt, 54 68 maxTokens: 1024, 69 + mode: 'tool', // Force tool use mode for reliable structured output 55 70 }); 56 71 57 72 return { ··· 63 78 : Object.keys(session.stats.toolCalls), 64 79 }; 65 80 } catch (error) { 66 - console.error('Summarization error:', error); 67 - 81 + // Haiku sometimes returns malformed output - just use fallback 68 82 // Return a basic summary on failure 69 83 return { 70 84 shortSummary: `Worked on ${session.projectName}`, ··· 80 94 projects: z 81 95 .array(z.object({ 82 96 name: z.string().describe('Project name - use exactly as given'), 83 - summary: z.string().describe('Very brief OUTCOMES only, 5-10 words max, like "fixed auth bug, added tests". Never mention exploration.'), 97 + summary: z.string().describe('Brief capabilities with scope, like "multi-dose scheduling (backend, frontend), dark mode (frontend)"'), 84 98 })) 85 - .describe('List of projects with brief outcome summaries'), 99 + .describe('List of projects with brief outcome summaries including scope'), 86 100 }); 87 101 88 102 export type DailySummary = z.infer<typeof dailySummarySchema>; ··· 116 130 .map(([project, accs]) => `${project}: ${accs.join('; ')}`) 117 131 .join('\n'); 118 132 119 - const systemPrompt = `Summarize a developer's daily work by project. 120 - Keep each project summary VERY brief: 5-10 words max, like "fixed auth bug, added user settings". 121 - Focus on OUTCOMES only: what was built, fixed, or changed. Not what was read or explored. 122 - Comma-separated phrases, not full sentences. Use action verbs: built, fixed, added, refactored. 123 - IMPORTANT: Use the exact project names given - do not rename or paraphrase them.`; 133 + const systemPrompt = `Summarize a developer's daily work. Be EXTREMELY brief. 134 + 135 + FORMAT: "added [feature] ([scope])" or "fixed [thing] ([scope])" 136 + - Scope is just: frontend, backend, or both 137 + - ONE feature per project, maybe two if truly separate 138 + 139 + CONSOLIDATE aggressively: 140 + - "frequency UI; dose calculations; CSV updates" → "multi-dose scheduling (backend, frontend)" 141 + - "dark mode fixes; theme updates; color changes" → "dark mode (frontend)" 142 + - "tests; error handling; refactoring" → skip unless it's the ONLY work done 143 + 144 + Do NOT list: 145 + - Tests (unless the whole session was just tests) 146 + - Types/refactoring 147 + - Documentation updates 148 + - Individual files or components 149 + 150 + GOOD: "added multi-dose scheduling (backend, frontend)" 151 + BAD: "multi-dose scheduling engine with formulation matching (backend, types), dose frequency UI..." 152 + 153 + Use exact project names. Max 10 words per project.`; 124 154 125 155 const userPrompt = `Summarize this developer's day (${date}):\n\n${projectSummaries}`; 126 156 ··· 131 161 system: systemPrompt, 132 162 prompt: userPrompt, 133 163 maxTokens: 512, 164 + mode: 'tool', // Force tool use mode for reliable structured output 134 165 }); 135 166 136 167 return JSON.stringify(object); 137 168 } catch (error) { 138 - console.error('Brag summary error:', error); 169 + console.error('Brag summary error:', (error as Error).message); 139 170 140 171 // Generate a basic summary on failure 141 172 const projects = Array.from(accomplishmentsByProject.keys()).map(name => ({