@voidwire/llm-summarize 3.1.0 → 3.3.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.
- package/index.ts +53 -18
- package/package.json +5 -5
package/index.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface SummarizeOptions {
|
|
|
46
46
|
model?: string;
|
|
47
47
|
maxTokens?: number;
|
|
48
48
|
mode?: "quick" | "insights";
|
|
49
|
+
/** User name to include in summary (e.g., "Rudy") */
|
|
50
|
+
userName?: string;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export type ProviderType = "anthropic" | "openai" | "ollama";
|
|
@@ -56,45 +58,77 @@ export type SummarizeMode = "quick" | "insights";
|
|
|
56
58
|
// ============================================================================
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
|
-
*
|
|
61
|
+
* Build quick mode prompt with optional user name
|
|
60
62
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
function buildQuickPrompt(userName?: string): string {
|
|
64
|
+
const nameInstruction = userName ? `Start with "${userName}".` : "";
|
|
63
65
|
|
|
66
|
+
return `Summarize what the user is asking or doing in one sentence.
|
|
67
|
+
${nameInstruction}
|
|
64
68
|
Output JSON only: {"summary": "One sentence summary"}`;
|
|
69
|
+
}
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
|
-
*
|
|
72
|
+
* Build insights mode prompt for session insight extraction
|
|
73
|
+
* Note: userName param kept for API compatibility but not used in insights mode
|
|
68
74
|
*/
|
|
69
|
-
|
|
75
|
+
function buildInsightsPrompt(_userName?: string): string {
|
|
76
|
+
return `You are a senior engineering manager extracting reusable insights from development sessions.
|
|
77
|
+
|
|
78
|
+
You receive transcripts with clear role markers:
|
|
79
|
+
- "User Asked:" = the human directing work (requests, approves, provides context)
|
|
80
|
+
- "Assistant Response:" = the AI executing work (implements, builds, debugs, explains)
|
|
70
81
|
|
|
71
|
-
|
|
82
|
+
Your job: extract what's worth remembering for future sessions.
|
|
72
83
|
|
|
73
84
|
<output_schema>
|
|
74
85
|
{
|
|
75
|
-
"summary": "One sentence
|
|
76
|
-
"decisions": ["
|
|
77
|
-
"patterns_used": ["Development pattern or approach
|
|
78
|
-
"preferences_expressed": ["
|
|
79
|
-
"problems_solved": ["Problem
|
|
80
|
-
"tools_heavy": ["Tool used repeatedly or
|
|
86
|
+
"summary": "One sentence capturing what was accomplished and how",
|
|
87
|
+
"decisions": ["Decision made with reasoning and trade-offs considered"],
|
|
88
|
+
"patterns_used": ["Development pattern or approach, with context on why it was chosen"],
|
|
89
|
+
"preferences_expressed": ["Preference revealed through direction or feedback"],
|
|
90
|
+
"problems_solved": ["Problem encountered and the specific solution applied"],
|
|
91
|
+
"tools_heavy": ["Tool used repeatedly or for critical work"]
|
|
81
92
|
}
|
|
82
93
|
</output_schema>
|
|
83
94
|
|
|
95
|
+
<attribution_rules>
|
|
96
|
+
- User actions: requested, approved, directed, provided, chose, preferred
|
|
97
|
+
- Assistant actions: implemented, built, debugged, refactored, created, fixed
|
|
98
|
+
- Never say "User implemented" or "User built" — users direct, assistants execute
|
|
99
|
+
</attribution_rules>
|
|
100
|
+
|
|
101
|
+
<quality_guidance>
|
|
102
|
+
Extract specifics with context, not bare facts:
|
|
103
|
+
|
|
104
|
+
SPARSE (avoid):
|
|
105
|
+
- "Made a database decision"
|
|
106
|
+
- "Fixed a bug"
|
|
107
|
+
- "Used TypeScript"
|
|
108
|
+
|
|
109
|
+
RICH (prefer):
|
|
110
|
+
- "Chose SQLite over Postgres for single-user CLI tool — avoids server dependency"
|
|
111
|
+
- "Fixed race condition in webhook handler by adding mutex lock — was causing duplicate events"
|
|
112
|
+
- "Used Zod for runtime validation at API boundary — catches malformed input before it hits business logic"
|
|
113
|
+
</quality_guidance>
|
|
114
|
+
|
|
84
115
|
<rules>
|
|
85
|
-
-
|
|
86
|
-
- Include a field ONLY when the conversation provides clear evidence
|
|
87
|
-
- Extract specifics: "Chose SQLite over Postgres for single-user simplicity" not "Made a database decision"
|
|
116
|
+
- Include a field ONLY when the transcript provides clear evidence
|
|
88
117
|
- Omit empty arrays entirely
|
|
118
|
+
- Capture the "why" when present — reasoning is more valuable than the decision alone
|
|
119
|
+
- Technical specifics (library names, patterns, trade-offs) make insights reusable
|
|
89
120
|
</rules>
|
|
90
121
|
|
|
91
122
|
Output valid JSON only. No markdown code blocks, no explanation.`;
|
|
123
|
+
}
|
|
92
124
|
|
|
93
125
|
/**
|
|
94
126
|
* Get prompt for the specified mode
|
|
95
127
|
*/
|
|
96
|
-
function getPromptForMode(mode: SummarizeMode): string {
|
|
97
|
-
return mode === "quick"
|
|
128
|
+
function getPromptForMode(mode: SummarizeMode, userName?: string): string {
|
|
129
|
+
return mode === "quick"
|
|
130
|
+
? buildQuickPrompt(userName)
|
|
131
|
+
: buildInsightsPrompt(userName);
|
|
98
132
|
}
|
|
99
133
|
|
|
100
134
|
// ============================================================================
|
|
@@ -494,7 +528,8 @@ export async function summarize(
|
|
|
494
528
|
const maxTokens = options?.maxTokens || config.maxTokens;
|
|
495
529
|
const apiKey = config.apiKey;
|
|
496
530
|
const mode: SummarizeMode = options?.mode || "insights";
|
|
497
|
-
const
|
|
531
|
+
const userName = options?.userName;
|
|
532
|
+
const systemPrompt = getPromptForMode(mode, userName);
|
|
498
533
|
|
|
499
534
|
// Validate config
|
|
500
535
|
if (!provider) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidwire/llm-summarize",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Structured session insight extraction for knowledge systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"README.md",
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "bun test"
|
|
23
|
-
},
|
|
24
21
|
"keywords": [
|
|
25
22
|
"llm",
|
|
26
23
|
"summarize",
|
|
@@ -42,5 +39,8 @@
|
|
|
42
39
|
},
|
|
43
40
|
"engines": {
|
|
44
41
|
"bun": ">=1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "bun test"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|