@voidwire/llm-summarize 3.1.0 → 3.2.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 +28 -13
- package/package.json +1 -1
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,57 @@ 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 with optional user name
|
|
68
73
|
*/
|
|
69
|
-
|
|
74
|
+
function buildInsightsPrompt(userName?: string): string {
|
|
75
|
+
const nameInstruction = userName
|
|
76
|
+
? `Start the summary with "${userName}".`
|
|
77
|
+
: "";
|
|
78
|
+
|
|
79
|
+
return `You are an experienced engineering manager reviewing session transcripts to extract actionable insights.
|
|
70
80
|
|
|
71
|
-
Analyze the development session
|
|
81
|
+
Analyze the development session and extract structured observations.
|
|
72
82
|
|
|
73
83
|
<output_schema>
|
|
74
84
|
{
|
|
75
85
|
"summary": "One sentence: what was accomplished or decided",
|
|
76
86
|
"decisions": ["Specific decision and its reasoning"],
|
|
77
87
|
"patterns_used": ["Development pattern or approach observed"],
|
|
78
|
-
"preferences_expressed": ["
|
|
79
|
-
"problems_solved": ["Problem
|
|
80
|
-
"tools_heavy": ["Tool used repeatedly or
|
|
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"]
|
|
81
91
|
}
|
|
82
92
|
</output_schema>
|
|
83
93
|
|
|
84
94
|
<rules>
|
|
85
|
-
-
|
|
95
|
+
- ${nameInstruction || "Write summary in third person."}
|
|
86
96
|
- Include a field ONLY when the conversation provides clear evidence
|
|
87
97
|
- Extract specifics: "Chose SQLite over Postgres for single-user simplicity" not "Made a database decision"
|
|
88
98
|
- Omit empty arrays entirely
|
|
99
|
+
- IMPORTANT: Only use user name in the summary field, nowhere else
|
|
89
100
|
</rules>
|
|
90
101
|
|
|
91
102
|
Output valid JSON only. No markdown code blocks, no explanation.`;
|
|
103
|
+
}
|
|
92
104
|
|
|
93
105
|
/**
|
|
94
106
|
* Get prompt for the specified mode
|
|
95
107
|
*/
|
|
96
|
-
function getPromptForMode(mode: SummarizeMode): string {
|
|
97
|
-
return mode === "quick"
|
|
108
|
+
function getPromptForMode(mode: SummarizeMode, userName?: string): string {
|
|
109
|
+
return mode === "quick"
|
|
110
|
+
? buildQuickPrompt(userName)
|
|
111
|
+
: buildInsightsPrompt(userName);
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
// ============================================================================
|
|
@@ -494,7 +508,8 @@ export async function summarize(
|
|
|
494
508
|
const maxTokens = options?.maxTokens || config.maxTokens;
|
|
495
509
|
const apiKey = config.apiKey;
|
|
496
510
|
const mode: SummarizeMode = options?.mode || "insights";
|
|
497
|
-
const
|
|
511
|
+
const userName = options?.userName;
|
|
512
|
+
const systemPrompt = getPromptForMode(mode, userName);
|
|
498
513
|
|
|
499
514
|
// Validate config
|
|
500
515
|
if (!provider) {
|