@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.
Files changed (2) hide show
  1. package/index.ts +28 -13
  2. 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
- * Quick mode: Fast one-liner summary for user prompts
61
+ * Build quick mode prompt with optional user name
60
62
  */
61
- const QUICK_PROMPT = `Summarize what the user is asking or doing in one sentence.
62
- Use the user's name from the context in your summary (e.g., "Rudy asked about...").
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
- * Insights mode: Full SessionInsights extraction for responses
72
+ * Build insights mode prompt with optional user name
68
73
  */
69
- const INSIGHTS_PROMPT = `You are an experienced engineering manager reviewing session transcripts to extract actionable team insights.
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 conversation and extract structured observations.
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": ["User preference revealed through actions or statements"],
79
- "problems_solved": ["Problem that was addressed and how"],
80
- "tools_heavy": ["Tool used repeatedly or in notable ways"]
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
- - Use the user's name from the context in the summary field (e.g., "Rudy implemented...")
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" ? QUICK_PROMPT : INSIGHTS_PROMPT;
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 systemPrompt = getPromptForMode(mode);
511
+ const userName = options?.userName;
512
+ const systemPrompt = getPromptForMode(mode, userName);
498
513
 
499
514
  // Validate config
500
515
  if (!provider) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidwire/llm-summarize",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Structured session insight extraction for knowledge systems",
5
5
  "type": "module",
6
6
  "main": "./index.ts",