@hienlh/ppm 0.5.16 → 0.5.17

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,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.17] - 2026-03-18
4
+
5
+ ### Fixed
6
+ - **Windows: resume sessions that exist on disk** — when no explicit mapping but `getSessionMessages()` finds messages, use PPM UUID for `--resume` (session was created with that ID). Prevents losing conversation context when resuming old sessions via CLI fallback
7
+
3
8
  ## [0.5.16] - 2026-03-18
4
9
 
5
10
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.5.16",
3
+ "version": "0.5.17",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -108,18 +108,15 @@ export class ClaudeAgentSdkProvider implements AIProvider {
108
108
  prompt: string;
109
109
  cwd: string;
110
110
  sessionId: string;
111
- sdkId: string;
112
- isFirstMessage: boolean;
113
- shouldFork: boolean;
111
+ resumeSessionId?: string;
114
112
  env: Record<string, string | undefined>;
115
113
  providerConfig: Partial<import("../types/config.ts").AIProviderConfig>;
116
114
  }): AsyncGenerator<any> {
117
115
  const args = ["-p", opts.prompt, "--verbose", "--output-format", "stream-json"];
118
116
 
119
- // Session management — only resume if we have a confirmed CLI session ID.
120
- // When sdkId === sessionId, no init event was received (new or previously failed session).
121
- if (opts.sdkId !== opts.sessionId) {
122
- args.push("--resume", opts.sdkId);
117
+ // Session management — resume if caller confirmed a valid session ID
118
+ if (opts.resumeSessionId) {
119
+ args.push("--resume", opts.resumeSessionId);
123
120
  }
124
121
 
125
122
  // Config-driven options
@@ -464,14 +461,29 @@ export class ClaudeAgentSdkProvider implements AIProvider {
464
461
  let eventSource: AsyncIterable<any>;
465
462
 
466
463
  if (useDirectCli) {
467
- console.log(`[sdk] Windows detected using direct CLI fallback (bypasses SDK pipe issue)`);
464
+ // Determine resumeSessionId for CLI --resume flag:
465
+ // 1. Explicit mapping exists (sdkId !== sessionId) → use mapped SDK ID
466
+ // 2. No mapping but session has messages on disk → session was created with PPM UUID, resume it
467
+ // 3. No mapping, no messages → truly new session, don't resume
468
+ let resumeSessionId: string | undefined;
469
+ if (sdkId !== sessionId) {
470
+ resumeSessionId = sdkId;
471
+ } else if (!isFirstMessage) {
472
+ try {
473
+ const existingMsgs = await getSessionMessages(sessionId);
474
+ if (existingMsgs.length > 0) {
475
+ resumeSessionId = sessionId;
476
+ saveSessionMapping(sessionId, sessionId);
477
+ console.log(`[sdk] session ${sessionId} exists on disk (${existingMsgs.length} msgs) — will resume`);
478
+ }
479
+ } catch {}
480
+ }
481
+ console.log(`[sdk] Windows detected — using direct CLI fallback (resume=${resumeSessionId ?? "none"})`);
468
482
  eventSource = this.queryDirectCli({
469
483
  prompt: message,
470
484
  cwd: effectiveCwd,
471
485
  sessionId,
472
- sdkId,
473
- isFirstMessage,
474
- shouldFork,
486
+ resumeSessionId,
475
487
  env: queryEnv,
476
488
  providerConfig,
477
489
  });