@jefuriiij/synthra 0.1.17 → 0.1.18

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
@@ -7,6 +7,29 @@ For older versions, see [GitHub Releases](https://github.com/jefuriiij/synthra/r
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.1.18] — 2026-06-01
11
+
12
+ ### Fixed
13
+
14
+ - **Stop hook on Linux/macOS no longer posts zero tokens to the dashboard.** The bash
15
+ `stop.sh` hook extracted `transcript_path` from the Claude Code Stop payload using a
16
+ greedy `sed` capture (`\(.*\)"`). Because the real payload has additional fields after
17
+ `transcript_path`, the capture grabbed those trailing fields and produced a
18
+ non-existent path string. The `-f` file check therefore always failed, totals were
19
+ never POSTed to `/log`, and the dashboard stayed stuck at 0 on every turn (GitHub
20
+ issue #1). Fixed by parsing with `jq -r '.transcript_path // empty'` and moving the
21
+ `command -v jq` guard above the parse so the hook exits cleanly when `jq` is absent.
22
+ - **SessionStart/PreCompact primer hook (`prime.sh`) hardened the same way.** The
23
+ `/prime` response is `{"primer":"…","port":…}`, so the old greedy capture accidentally
24
+ injected trailing `","port":…` junk into the primer string. Because primer text can
25
+ contain inner quotes, a negated-class fix (`[^"]*`) would have truncated it at the
26
+ first quote — `jq -r '.primer // empty'` is the correct parse. Switched `printf '%b'`
27
+ to `printf '%s'` since `jq -r` already decodes JSON escapes.
28
+ - Both fixes are **bash-only**. The Windows PowerShell hooks (`stop.ps1`, `prime.ps1`)
29
+ use `ConvertFrom-Json` and were already correct.
30
+
31
+ ---
32
+
10
33
  ## [0.1.17] — 2026-05-29
11
34
 
12
35
  ### Added
package/dist/cli/index.js CHANGED
@@ -18,7 +18,7 @@ var init_package = __esm({
18
18
  "package.json"() {
19
19
  package_default = {
20
20
  name: "@jefuriiij/synthra",
21
- version: "0.1.17",
21
+ version: "0.1.18",
22
22
  publishConfig: {
23
23
  access: "public"
24
24
  },
@@ -1466,12 +1466,18 @@ if [ ! -f "$PORT_FILE" ]; then exit 0; fi
1466
1466
  PORT=$(cat "$PORT_FILE" 2>/dev/null | tr -d '[:space:]')
1467
1467
  if [ -z "$PORT" ]; then exit 0; fi
1468
1468
 
1469
+ # Parse the primer with jq, not sed. Primer text legitimately contains quotes, so a
1470
+ # negated-class capture ([^"]*) would truncate it at the first inner quote, while the
1471
+ # old greedy capture (.*") over-ran into the trailing "port" field and injected junk.
1472
+ # jq -r also decodes JSON escapes, so we print with %s (not %b). No jq \u2192 no primer.
1473
+ if ! command -v jq >/dev/null 2>&1; then exit 0; fi
1474
+
1469
1475
  PRIMER=$(curl -sS --max-time 3 "http://127.0.0.1:$PORT/prime" 2>/dev/null \\
1470
- | sed -n 's/.*"primer"[[:space:]]*:[[:space:]]*"\\(.*\\)".*/\\1/p' \\
1476
+ | jq -r '.primer // empty' 2>/dev/null \\
1471
1477
  | head -c 8000)
1472
1478
 
1473
1479
  if [ -n "$PRIMER" ]; then
1474
- printf '%b\\n' "$PRIMER"
1480
+ printf '%s\\n' "$PRIMER"
1475
1481
  fi
1476
1482
  exit 0
1477
1483
  `;
@@ -1564,7 +1570,13 @@ set +e\r
1564
1570
  INPUT=$(cat 2>/dev/null)\r
1565
1571
  if [ -z "$INPUT" ]; then exit 0; fi\r
1566
1572
  \r
1567
- TRANSCRIPT=$(printf '%s' "$INPUT" | sed -n 's/.*"transcript_path"[[:space:]]*:[[:space:]]*"\\(.*\\)".*/\\1/p')\r
1573
+ # jq is required for the parsing below \u2014 bail early (silent no-op) if it's absent.\r
1574
+ if ! command -v jq >/dev/null 2>&1; then exit 0; fi\r
1575
+ \r
1576
+ # Extract transcript_path with jq, not sed. A greedy sed capture (\\(.*\\)") grabs the\r
1577
+ # trailing JSON fields after transcript_path and yields a path that doesn't exist, so\r
1578
+ # the -f check below always failed and totals were never POSTed to /log. (issue #1)\r
1579
+ TRANSCRIPT=$(printf '%s' "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)\r
1568
1580
  if [ -z "$TRANSCRIPT" ] || [ ! -f "$TRANSCRIPT" ]; then exit 0; fi\r
1569
1581
  \r
1570
1582
  PORT_FILE="$PWD/.synthra-graph/mcp_port"\r
@@ -1572,8 +1584,6 @@ if [ ! -f "$PORT_FILE" ]; then exit 0; fi\r
1572
1584
  PORT=$(cat "$PORT_FILE" 2>/dev/null | tr -d '[:space:]')\r
1573
1585
  if [ -z "$PORT" ]; then exit 0; fi\r
1574
1586
  \r
1575
- if ! command -v jq >/dev/null 2>&1; then exit 0; fi\r
1576
- \r
1577
1587
  OFFSET_FILE="\${TRANSCRIPT}.stopoffset"\r
1578
1588
  START_OFFSET=0\r
1579
1589
  if [ -f "$OFFSET_FILE" ]; then\r