@voidwire/llm-summarize 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +109 -21
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -18,8 +18,18 @@ import { join } from "path";
18
18
  // Types
19
19
  // ============================================================================
20
20
 
21
+ export interface Extraction {
22
+ term: string;
23
+ type: "project" | "topic" | "tool" | "person";
24
+ confidence: "high" | "medium";
25
+ }
26
+
21
27
  export interface SessionInsights {
22
28
  summary: string;
29
+ // Quick mode extraction fields
30
+ should_search?: boolean;
31
+ extractions?: Extraction[];
32
+ // Insights mode fields
23
33
  decisions?: string[];
24
34
  patterns_used?: string[];
25
35
  preferences_expressed?: string[];
@@ -59,44 +69,122 @@ export type SummarizeMode = "quick" | "insights";
59
69
 
60
70
  /**
61
71
  * Build quick mode prompt with optional user name
72
+ * Now includes context extraction for knowledge retrieval
62
73
  */
63
74
  function buildQuickPrompt(userName?: string): string {
64
- const nameInstruction = userName ? `Start with "${userName}".` : "";
75
+ const name = userName || "User";
76
+
77
+ return `You are a context classifier for knowledge retrieval. Analyze conversation context to determine what prior knowledge would be valuable.
78
+
79
+ Input format:
80
+ Project: <project name>
81
+ Previous Assistant: <last assistant message>
82
+ User Prompt: <current user message>
83
+
84
+ Produce JSON with:
85
+ 1. summary: Brief description (1-2 sentences) of what the user is doing/asking. Start with "${name}".
86
+ 2. should_search: Whether to search the knowledge base
87
+ 3. extractions: Terms worth searching for
88
+
89
+ should_search = true when:
90
+ - References past work, decisions, discussions
91
+ - Mentions project, tool, or person by name
92
+ - Asks "what was...", "how did we...", "remember when..."
93
+ - Technical domain benefits from prior learnings
94
+
95
+ should_search = false when:
96
+ - Greetings, acknowledgments ("ready", "thanks", "ok")
97
+ - Simple commands ("run tests", "commit this")
98
+ - Continuation signals ("yes", "do it", "go ahead")
99
+
100
+ Extraction types:
101
+ - project: Named codebase, repo, system (sable, lore, momentum)
102
+ - topic: Domain, concept, technical area (hooks, authentication, Tier 2)
103
+ - tool: Library, CLI, framework (llm-summarize, SQLite, Bun)
104
+ - person: Named individual
105
+
106
+ Confidence:
107
+ - high: Explicitly stated
108
+ - medium: Strongly implied
109
+
110
+ Skip generic words. Only extract terms that yield useful knowledge results.
65
111
 
66
- return `Summarize what the user is asking or doing in one sentence.
67
- ${nameInstruction}
68
- Output JSON only: {"summary": "One sentence summary"}`;
112
+ <example>
113
+ Project: sable
114
+ Previous Assistant: I'll update the UserPromptSubmit hook to call llm-summarize.
115
+ User Prompt: What does Lore return for project queries?
116
+
117
+ {"summary": "${name} is asking about Lore's return format for project queries", "should_search": true, "extractions": [{"term": "Lore", "type": "project", "confidence": "high"}, {"term": "project queries", "type": "topic", "confidence": "high"}]}
118
+ </example>
119
+
120
+ <example>
121
+ Project: sable
122
+ Previous Assistant: The extraction prompt is ready. Should I add it?
123
+ User Prompt: yes do it
124
+
125
+ {"summary": "${name} is confirming to proceed with the extraction prompt", "should_search": false, "extractions": []}
126
+ </example>
127
+
128
+ <example>
129
+ Project: sable
130
+ Previous Assistant: Starting new session.
131
+ User Prompt: What was the issue we hit with the stop hook last time?
132
+
133
+ {"summary": "${name} is asking about a previous issue with the stop hook", "should_search": true, "extractions": [{"term": "stop hook", "type": "topic", "confidence": "high"}, {"term": "sable", "type": "project", "confidence": "medium"}]}
134
+ </example>
135
+
136
+ Output valid JSON only. No markdown, no explanation.`;
69
137
  }
70
138
 
71
139
  /**
72
- * Build insights mode prompt with optional user name
140
+ * Build insights mode prompt for session insight extraction
141
+ * Note: userName param kept for API compatibility but not used in insights mode
73
142
  */
74
- function buildInsightsPrompt(userName?: string): string {
75
- const nameInstruction = userName
76
- ? `Start the summary with "${userName}".`
77
- : "";
143
+ function buildInsightsPrompt(_userName?: string): string {
144
+ return `You are a senior engineering manager extracting reusable insights from development sessions.
78
145
 
79
- return `You are an experienced engineering manager reviewing session transcripts to extract actionable insights.
146
+ You receive transcripts with clear role markers:
147
+ - "User Asked:" = the human directing work (requests, approves, provides context)
148
+ - "Assistant Response:" = the AI executing work (implements, builds, debugs, explains)
80
149
 
81
- Analyze the development session and extract structured observations.
150
+ Your job: extract what's worth remembering for future sessions.
82
151
 
83
152
  <output_schema>
84
153
  {
85
- "summary": "One sentence: what was accomplished or decided",
86
- "decisions": ["Specific decision and its reasoning"],
87
- "patterns_used": ["Development pattern or approach observed"],
88
- "preferences_expressed": ["Preference revealed through actions - DO NOT include user name"],
89
- "problems_solved": ["Problem addressed and how - DO NOT include user name"],
90
- "tools_heavy": ["Tool used repeatedly or notably"]
154
+ "summary": "One sentence capturing what was accomplished and how",
155
+ "decisions": ["Decision made with reasoning and trade-offs considered"],
156
+ "patterns_used": ["Development pattern or approach, with context on why it was chosen"],
157
+ "preferences_expressed": ["Preference revealed through direction or feedback"],
158
+ "problems_solved": ["Problem encountered and the specific solution applied"],
159
+ "tools_heavy": ["Tool used repeatedly or for critical work"]
91
160
  }
92
161
  </output_schema>
93
162
 
163
+ <attribution_rules>
164
+ - User actions: requested, approved, directed, provided, chose, preferred
165
+ - Assistant actions: implemented, built, debugged, refactored, created, fixed
166
+ - Never say "User implemented" or "User built" — users direct, assistants execute
167
+ </attribution_rules>
168
+
169
+ <quality_guidance>
170
+ Extract specifics with context, not bare facts:
171
+
172
+ SPARSE (avoid):
173
+ - "Made a database decision"
174
+ - "Fixed a bug"
175
+ - "Used TypeScript"
176
+
177
+ RICH (prefer):
178
+ - "Chose SQLite over Postgres for single-user CLI tool — avoids server dependency"
179
+ - "Fixed race condition in webhook handler by adding mutex lock — was causing duplicate events"
180
+ - "Used Zod for runtime validation at API boundary — catches malformed input before it hits business logic"
181
+ </quality_guidance>
182
+
94
183
  <rules>
95
- - ${nameInstruction || "Write summary in third person."}
96
- - Include a field ONLY when the conversation provides clear evidence
97
- - Extract specifics: "Chose SQLite over Postgres for single-user simplicity" not "Made a database decision"
184
+ - Include a field ONLY when the transcript provides clear evidence
98
185
  - Omit empty arrays entirely
99
- - IMPORTANT: Only use user name in the summary field, nowhere else
186
+ - Capture the "why" when present reasoning is more valuable than the decision alone
187
+ - Technical specifics (library names, patterns, trade-offs) make insights reusable
100
188
  </rules>
101
189
 
102
190
  Output valid JSON only. No markdown code blocks, no explanation.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidwire/llm-summarize",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Structured session insight extraction for knowledge systems",
5
5
  "type": "module",
6
6
  "main": "./index.ts",