@voidwire/llm-summarize 3.9.4 → 3.10.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 +47 -26
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -28,13 +28,16 @@ export interface SessionInsights {
28
28
  // Optional fields populated by custom prompts (e.g., Lore injection)
29
29
  extractions?: Extraction[];
30
30
  keywords?: string[];
31
- // Insights mode fields
31
+ // Insights mode fields (delta extraction)
32
32
  current_focus?: string;
33
33
  next_steps?: string[];
34
34
  decisions?: string[];
35
+ corrections?: string[];
36
+ validated?: string[];
37
+ problems_solved?: string[];
38
+ // Legacy fields — kept for backward compatibility with existing session JSONL data
35
39
  patterns_used?: string[];
36
40
  preferences_expressed?: string[];
37
- problems_solved?: string[];
38
41
  }
39
42
 
40
43
  export interface SummarizeResult {
@@ -83,53 +86,71 @@ Output JSON only: {"summary": "One sentence summary"}`;
83
86
  * Note: userName param kept for API compatibility but not used in insights mode
84
87
  */
85
88
  function buildInsightsPrompt(_userName?: string): string {
86
- return `You are a session state extractor. Given a development conversation, produce a JSON snapshot of the session's current state.
89
+ return `You are a session delta extractor. Given a development conversation and the previous state snapshot, extract ONLY what is NEW since the last snapshot.
87
90
 
88
91
  <instructions>
89
- 1. Read the conversation in the <transcript> section
90
- 2. Ignore the <previous_state> section — it is background context only, not part of this session
91
- 3. Extract ONLY what happened in the transcript
92
- 4. Produce a JSON object with the fields described below
92
+ 1. Read the <previous_state> section this is what was already known
93
+ 2. Read the <transcript> section — this is what happened since
94
+ 3. Extract ONLY new information not already captured in previous_state
95
+ 4. Skip any lines containing markers (📁 CAPTURE, 📚 TEACH, 👤 OBSERVE, 🗣️, ─── REFLECT) — these are handled by a separate system
96
+ 5. Focus on: what decisions were made, what changed direction, what the user corrected, what approach was validated
97
+ 6. Produce a JSON delta object
93
98
  </instructions>
94
99
 
95
100
  <fields>
96
- - summary: One sentence describing what was accomplished this session
97
- - current_focus: The specific task or feature being worked on (omit if exploratory)
98
- - next_steps: Array of concrete next actions. Name the specific task.
99
- - decisions: Array of decisions made this session, each with rationale
100
- - patterns_used: Array of techniques or approaches applied, each with context
101
- - preferences_expressed: Array of user preferences revealed through direction or correction
102
- - problems_solved: Array of problems encountered with root cause and fix
101
+ - summary: One sentence what CHANGED since last snapshot, not a re-summary of the whole session
102
+ - current_focus: The specific task or topic right now (omit if unchanged from previous_state)
103
+ - decisions: New decisions only include the rationale ("X because Y"). Skip if already in previous_state.
104
+ - corrections: Things the user pushed back on or redirected. Quote their words when possible.
105
+ - validated: Approaches the user approved or confirmed worked. Only when non-obvious.
106
+ - next_steps: Concrete next actions that emerged THIS turn. Name specifics.
107
+ - problems_solved: New problems with root cause and fix. Skip re-statements.
103
108
  </fields>
104
109
 
105
- Include a field only when the transcript contains clear evidence. Omit empty arrays. Every value must be a complete sentence.
110
+ <rules>
111
+ - If nothing meaningful changed since previous_state, return {"summary": "continuation", "current_focus": "unchanged"}
112
+ - NEVER repeat information from previous_state — this is a delta, not a snapshot
113
+ - "User clarified X" is NOT a correction — only record corrections when the user explicitly redirects, rejects, or changes direction
114
+ - Every field value must be specific enough to be useful 6 months from now without context
115
+ </rules>
106
116
 
107
117
  <example>
108
118
  <input>
109
- <previous_state>Focus: Building authentication system</previous_state>
119
+ <previous_state>
120
+ ## Context
121
+ - **Focus:** JWT authentication implementation
122
+ - Chose JWT over sessions — eliminates Redis dependency
123
+ ## Next
124
+ - Test refresh token flow
125
+ </previous_state>
110
126
  <transcript>
111
- User Asked: Let's use JWT instead of sessions for auth
112
- Assistant Response: Switched from express-session to jsonwebtoken. JWTs are stateless so we don't need Redis for session storage anymore. Updated the middleware to verify tokens on each request.
113
- User Asked: Make sure the tokens expire after 24 hours
114
- Assistant Response: Set expiresIn to 24h in the sign options. Also added a refresh token flow so users don't get logged out mid-work.
127
+ User: Actually let's use sessions after all the team is more familiar with them and we already have Redis in prod
128
+ Assistant: Switched back to express-session with Redis store. Removed the JWT middleware.
129
+ User: Good. And make the session timeout 8 hours not the default 24.
115
130
  </transcript>
116
131
  </input>
117
132
  <output>
118
- {"summary":"Implemented JWT-based authentication replacing session-based auth, with 24-hour token expiry and refresh token flow","current_focus":"Authentication system implementation","next_steps":["Test the refresh token flow with expired tokens","Add token revocation for logout"],"decisions":["Chose JWT over sessions eliminates Redis dependency since tokens are stateless","Set 24-hour token expiry with refresh flow balances security with user convenience"],"preferences_expressed":["User directed specific token expiry of 24 hours"]}
133
+ {"summary":"Reversed JWT decision back to sessions team familiarity and existing Redis infra","current_focus":"Session-based authentication","decisions":["Reverted to express-session with Redis — team familiarity with sessions outweighs JWT's statelessness benefit, Redis already in production"],"corrections":["User reversed the JWT decision after initial implementationteam constraints weren't considered"],"next_steps":["Configure 8-hour session timeout","Remove JWT dependencies"]}
119
134
  </output>
120
135
  </example>
121
136
 
122
137
  <example>
123
138
  <input>
124
- <previous_state>Focus: Investigating test failures</previous_state>
139
+ <previous_state>
140
+ ## Context
141
+ - **Focus:** Debugging webhook test failures
142
+ - Fixed hardcoded timestamp in tests
143
+ ## Next
144
+ - Verify CI passes
145
+ </previous_state>
125
146
  <transcript>
126
- User Asked: The CI is failing on the webhook tests
127
- Assistant Response: Found the issue — the test was using a hardcoded timestamp that expired. Changed it to use a relative timestamp. Also found that the webhook handler had a race condition where two events could arrive simultaneously and both pass the idempotency check. Added a mutex lock.
128
- User Asked: Good catch on the race condition
147
+ User: CI is green now. Let's move on to the API rate limiter.
148
+ Assistant: Starting on the rate limiter. I'll use a sliding window approach with Redis.
149
+ User: Sounds good.
129
150
  </transcript>
130
151
  </input>
131
152
  <output>
132
- {"summary":"Fixed CI test failure caused by hardcoded timestamp and discovered a race condition in the webhook handler","current_focus":"Webhook test failures and handler reliability","problems_solved":["Fixed expired hardcoded timestamp in webhook tests replaced with relative timestamp calculation","Fixed race condition in webhook handler where simultaneous events bypassed idempotency check — added mutex lock"],"next_steps":["Verify CI passes with the timestamp and mutex fixes"]}
153
+ {"summary":"CI fixed, pivoted to API rate limiter","current_focus":"API rate limiter implementation","validated":["Sliding window rate limiting with Redisuser approved without pushback"],"next_steps":["Implement sliding window rate limiter with Redis"]}
133
154
  </output>
134
155
  </example>
135
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidwire/llm-summarize",
3
- "version": "3.9.4",
3
+ "version": "3.10.0",
4
4
  "description": "Structured session insight extraction for knowledge systems",
5
5
  "type": "module",
6
6
  "main": "./index.ts",