@hienlh/ppm 0.9.38 → 0.9.39

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/CHANGELOG.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [0.9.38] - 2026-04-06
3
+ ## [0.9.39] - 2026-04-06
4
4
 
5
5
  ### Fixed
6
6
  - **Stream hangs 3 minutes after AI finishes**: `done` event was received but the `for-await` loop didn't break — `break` inside `switch` only exits the switch, not the loop. Used labeled `break eventLoop` to properly terminate on `done`.
7
+ - **Identity never saved to memory**: Memory extraction only ran on session end. Now saves identity directly when user responds to onboarding prompt, and runs AI extraction every 5 messages.
7
8
 
8
9
  ## [0.9.36] - 2026-04-06
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.9.38",
3
+ "version": "0.9.39",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "author": "hienlh",
6
6
  "license": "MIT",
@@ -36,6 +36,15 @@ class PPMBotService {
36
36
  /** Sessions that already had their title set */
37
37
  private titledSessions = new Set<string>();
38
38
 
39
+ /** Chat IDs that just received identity onboarding prompt */
40
+ private identityPending = new Set<string>();
41
+
42
+ /** Message count per session for periodic memory save */
43
+ private messageCount = new Map<string, number>();
44
+
45
+ /** Interval (messages) between automatic memory saves */
46
+ private readonly MEMORY_SAVE_INTERVAL = 5;
47
+
39
48
  // ── Lifecycle ─────────────────────────────────────────────────
40
49
 
41
50
  async start(): Promise<void> {
@@ -77,6 +86,8 @@ class PPMBotService {
77
86
  this.debouncedTexts.clear();
78
87
  this.processing.clear();
79
88
  this.messageQueue.clear();
89
+ this.identityPending.clear();
90
+ this.messageCount.clear();
80
91
 
81
92
  console.log("[ppmbot] Stopped");
82
93
  }
@@ -192,6 +203,7 @@ class PPMBotService {
192
203
  // Identity onboarding: if no identity memories exist, ask user
193
204
  const identityMemories = this.memory.recall("_global", "user identity name role");
194
205
  if (identityMemories.length === 0) {
206
+ this.identityPending.add(chatId);
195
207
  await this.telegram!.sendMessage(
196
208
  Number(chatId),
197
209
  "📝 <b>Quick intro?</b>\n\n" +
@@ -430,6 +442,22 @@ class PPMBotService {
430
442
  },
431
443
  );
432
444
 
445
+ // Capture identity if onboarding was just shown
446
+ if (this.identityPending.has(chatId)) {
447
+ this.identityPending.delete(chatId);
448
+ this.memory.saveOne("_global", `User identity: ${text}`, "preference", session.sessionId);
449
+ console.log("[ppmbot] Saved identity memory from onboarding");
450
+ }
451
+
452
+ // Periodic memory extraction — fire-and-forget every N messages
453
+ const count = (this.messageCount.get(session.sessionId) ?? 0) + 1;
454
+ this.messageCount.set(session.sessionId, count);
455
+ if (count % this.MEMORY_SAVE_INTERVAL === 0) {
456
+ this.saveSessionMemory(chatId).catch((err) =>
457
+ console.warn("[ppmbot] Periodic memory save failed:", (err as Error).message),
458
+ );
459
+ }
460
+
433
461
  // Check context window — auto-rotate if near limit
434
462
  if (
435
463
  result.contextWindowPct != null &&