@hienlh/ppm 0.8.13 → 0.8.14

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.8.14] - 2026-03-24
4
+
5
+ ### Fixed
6
+ - **CLI error logging**: Always read stderr (even on exit code 0), log error event content to server logs for Windows CLI debugging
7
+
3
8
  ## [0.8.13] - 2026-03-24
4
9
 
5
10
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.8.13",
3
+ "version": "0.8.14",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "author": "hienlh",
6
6
  "license": "MIT",
@@ -231,6 +231,12 @@ export class ClaudeAgentSdkProvider implements AIProvider {
231
231
  }
232
232
  }
233
233
  }
234
+ // Log error/result events for diagnostics
235
+ if (event.type === "error") {
236
+ console.error(`[sdk-cli] error event: ${JSON.stringify(event).slice(0, 1000)}`);
237
+ } else if (event.type === "result" && event.is_error) {
238
+ console.error(`[sdk-cli] result error: ${JSON.stringify(event).slice(0, 1000)}`);
239
+ }
234
240
  // Always yield the original event too (for init, result, rate_limit, etc.)
235
241
  yield event;
236
242
  } catch {
@@ -248,22 +254,20 @@ export class ClaudeAgentSdkProvider implements AIProvider {
248
254
  const exitCode = await proc.exited;
249
255
  console.log(`[sdk-cli] process exited: code=${exitCode}`);
250
256
 
251
- // Read all stderr and surface error to frontend
252
- if (exitCode !== 0) {
253
- try {
254
- const errReader = proc.stderr.getReader();
255
- const stderrDecoder = new TextDecoder();
256
- const errParts: string[] = [];
257
- while (true) {
258
- const { done, value } = await errReader.read();
259
- if (done) break;
260
- if (value) errParts.push(stderrDecoder.decode(value, { stream: true }));
261
- }
262
- const fullStderr = errParts.join("").trim();
263
- if (fullStderr) {
264
- // Actual error is at the END (minified source dump comes first)
265
- console.error(`[sdk-cli] stderr (last 1500): ${fullStderr.slice(-1500)}`);
266
- // Extract meaningful error line (e.g. "Error: ...", "TypeError: ...")
257
+ // Always read stderr for diagnostics (errors can occur even with exit code 0)
258
+ try {
259
+ const errReader = proc.stderr.getReader();
260
+ const stderrDecoder = new TextDecoder();
261
+ const errParts: string[] = [];
262
+ while (true) {
263
+ const { done, value } = await errReader.read();
264
+ if (done) break;
265
+ if (value) errParts.push(stderrDecoder.decode(value, { stream: true }));
266
+ }
267
+ const fullStderr = errParts.join("").trim();
268
+ if (fullStderr) {
269
+ console.error(`[sdk-cli] stderr (last 1500): ${fullStderr.slice(-1500)}`);
270
+ if (exitCode !== 0) {
267
271
  const errMatch = fullStderr.match(/\b(?:Error|TypeError|SyntaxError|ReferenceError|RangeError):\s*.+/);
268
272
  const errorMsg = errMatch ? errMatch[0].slice(0, 500) : fullStderr.slice(-300);
269
273
  yield {
@@ -272,8 +276,8 @@ export class ClaudeAgentSdkProvider implements AIProvider {
272
276
  error: `CLI exited with code ${exitCode}: ${errorMsg}`,
273
277
  };
274
278
  }
275
- } catch {}
276
- }
279
+ }
280
+ } catch {}
277
281
  } finally {
278
282
  this.activeQueries.delete(opts.sessionId);
279
283
  try { proc.kill(); } catch {}
@@ -174,7 +174,9 @@ async function runStreamLoop(sessionId: string, providerId: string, content: str
174
174
  } else if (evType === "tool_result") {
175
175
  logSessionEvent(sessionId, "TOOL_RESULT", `error=${ev.isError ?? false} ${(ev.output ?? "").slice(0, 300)}`);
176
176
  } else if (evType === "error") {
177
- logSessionEvent(sessionId, "ERROR", ev.message ?? JSON.stringify(ev).slice(0, 300));
177
+ const errorDetail = ev.message ?? JSON.stringify(ev).slice(0, 500);
178
+ console.error(`[chat] session=${sessionId} error: ${errorDetail}`);
179
+ logSessionEvent(sessionId, "ERROR", errorDetail);
178
180
  } else if (evType === "done") {
179
181
  logSessionEvent(sessionId, "DONE", `subtype=${ev.resultSubtype ?? "none"} turns=${ev.numTurns ?? "?"} ctx=${ev.contextWindowPct ?? "?"}%`);
180
182
  if (ev.contextWindowPct != null) lastContextWindowPct = ev.contextWindowPct;
@@ -9,7 +9,7 @@ import {
9
9
  rmSync,
10
10
  renameSync,
11
11
  } from "node:fs";
12
- import { resolve, relative, basename, dirname, join, normalize } from "node:path";
12
+ import { resolve, relative, basename, dirname, join, normalize, sep } from "node:path";
13
13
  import ignore, { type Ignore } from "ignore";
14
14
  import type { FileNode } from "../types/project.ts";
15
15
 
@@ -43,7 +43,7 @@ class FileService {
43
43
  const normalizedTarget = normalize(resolve(projectPath, targetPath));
44
44
  const normalizedProject = normalize(projectPath);
45
45
  if (
46
- !normalizedTarget.startsWith(normalizedProject + "/") &&
46
+ !normalizedTarget.startsWith(normalizedProject + sep) &&
47
47
  normalizedTarget !== normalizedProject
48
48
  ) {
49
49
  throw new SecurityError("Path traversal not allowed");