@voidwire/llm-summarize 3.3.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 +72 -4
  2. package/package.json +5 -5
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,13 +69,71 @@ 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.
111
+
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>
65
135
 
66
- return `Summarize what the user is asking or doing in one sentence.
67
- ${nameInstruction}
68
- Output JSON only: {"summary": "One sentence summary"}`;
136
+ Output valid JSON only. No markdown, no explanation.`;
69
137
  }
70
138
 
71
139
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidwire/llm-summarize",
3
- "version": "3.3.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",
@@ -18,6 +18,9 @@
18
18
  "README.md",
19
19
  "LICENSE"
20
20
  ],
21
+ "scripts": {
22
+ "test": "bun test"
23
+ },
21
24
  "keywords": [
22
25
  "llm",
23
26
  "summarize",
@@ -39,8 +42,5 @@
39
42
  },
40
43
  "engines": {
41
44
  "bun": ">=1.0.0"
42
- },
43
- "scripts": {
44
- "test": "bun test"
45
45
  }
46
- }
46
+ }