@robhowley/pi-structured-return 1.7.0 → 1.7.1

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.
@@ -161,7 +161,7 @@ export function formatResult(result: ParsedResult): string {
161
161
  }
162
162
  // If the parser detected failures but couldn't extract details, surface the
163
163
  // log path and raw tail so the model has a path forward instead of a dead end.
164
- if (result.status === "fail" && (result.failures ?? []).length === 0) {
164
+ if ((result.status === "fail" || result.status === "error") && (result.failures ?? []).length === 0) {
165
165
  if (result.logPath) lines.push(`log: ${result.logPath}`);
166
166
  if (result.rawTail) lines.push(result.rawTail);
167
167
  }
@@ -211,6 +211,13 @@ export function finalizeResult(
211
211
  };
212
212
  }
213
213
  const finalized: ParsedResult = { ...result, exitCode, cwd, logPath };
214
+ // Surface catastrophic failures (command not found, permission denied, missing
215
+ // interpreter, etc.) — the combined log contains the actual diagnostic.
216
+ if (finalized.status === "error" && exitCode !== 0 && !finalized.rawTail) {
217
+ const log = safeReadFile(logPath);
218
+ const lines = log.split(/\r?\n/);
219
+ finalized.rawTail = lines.slice(-200).join("\n");
220
+ }
214
221
  // Safety net: if the parser reports failures but couldn't extract any details
215
222
  // (e.g., tool output format changed), append the log tail so the model isn't
216
223
  // left with "2 failed" and nothing actionable.
@@ -10,8 +10,8 @@ function makeCtx(stderr: string, cwd = "/project"): RunContext {
10
10
  const stderrPath = path.join(dir, "stderr");
11
11
  const stdoutPath = path.join(dir, "stdout");
12
12
  const logPath = path.join(dir, "log");
13
- fs.writeFileSync(stderrPath, stderr);
14
- fs.writeFileSync(stdoutPath, "");
13
+ fs.writeFileSync(stderrPath, "");
14
+ fs.writeFileSync(stdoutPath, stderr);
15
15
  fs.writeFileSync(logPath, stderr);
16
16
  return {
17
17
  command: "npx ava test_math.js --no-color",
@@ -4,7 +4,7 @@ import { extractJsStackLocation, safeReadFile } from "./utils";
4
4
 
5
5
  /**
6
6
  * Parses AVA's default text output (--no-color).
7
- * Reads stderrPath — AVA writes all output (results + diagnostics) to stderr.
7
+ * Reads stdoutPath — AVA writes all output (results + diagnostics) to stdout.
8
8
  */
9
9
 
10
10
  // Summary line: "2 tests failed" or "3 tests passed"
@@ -16,7 +16,7 @@ const FAIL_MARKER_RE = /^\s*✘\s+\[fail\]:\s+(.+?)(?:\s+Error thrown in test)?$
16
16
  const parser: ParserModule = {
17
17
  id: "ava-text",
18
18
  async parse(ctx) {
19
- const stderr = safeReadFile(ctx.stderrPath);
19
+ const stderr = safeReadFile(ctx.stdoutPath);
20
20
  if (!stderr.trim()) {
21
21
  return { tool: "ava", status: "error", summary: "no output", logPath: ctx.logPath };
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robhowley/pi-structured-return",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Turn noisy CLI output into compact structured results (fewer tokens), full logs preserved.",
5
5
  "license": "MIT",
6
6
  "repository": {