@puzzmo/cli 1.0.71 → 1.0.73

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.
Files changed (83) hide show
  1. package/lib/agents/claude.d.ts +2 -2
  2. package/lib/agents/claude.js +67 -16
  3. package/lib/agents/claude.js.map +1 -1
  4. package/lib/agents/codex.js +12 -1
  5. package/lib/agents/codex.js.map +1 -1
  6. package/lib/agents/copilot.js +10 -1
  7. package/lib/agents/copilot.js.map +1 -1
  8. package/lib/agents/gemini.js +9 -1
  9. package/lib/agents/gemini.js.map +1 -1
  10. package/lib/agents/index.d.ts +1 -1
  11. package/lib/agents/stream-json-cli.d.ts +5 -4
  12. package/lib/agents/stream-json-cli.js +29 -4
  13. package/lib/agents/stream-json-cli.js.map +1 -1
  14. package/lib/agents/types.d.ts +15 -0
  15. package/lib/commands/game/create.js +46 -18
  16. package/lib/commands/game/create.js.map +1 -1
  17. package/lib/commands/game/seedImport.d.ts +13 -0
  18. package/lib/commands/game/seedImport.js +25 -0
  19. package/lib/commands/game/seedImport.js.map +1 -0
  20. package/lib/commands/upload.js +8 -19
  21. package/lib/commands/upload.js.map +1 -1
  22. package/lib/download/page-downloader.js +20 -7
  23. package/lib/download/page-downloader.js.map +1 -1
  24. package/lib/skills/context.d.ts +6 -0
  25. package/lib/skills/context.js +74 -0
  26. package/lib/skills/context.js.map +1 -0
  27. package/lib/skills/mcp-client.d.ts +5 -0
  28. package/lib/skills/mcp-client.js +21 -0
  29. package/lib/skills/mcp-client.js.map +1 -1
  30. package/lib/skills/registry.d.ts +24 -3
  31. package/lib/skills/registry.js +47 -11
  32. package/lib/skills/registry.js.map +1 -1
  33. package/lib/skills/runner.d.ts +3 -6
  34. package/lib/skills/runner.js +45 -94
  35. package/lib/skills/runner.js.map +1 -1
  36. package/lib/skills/step.d.ts +25 -0
  37. package/lib/skills/step.js +29 -0
  38. package/lib/skills/step.js.map +1 -0
  39. package/lib/tui/pipeline.d.ts +3 -1
  40. package/lib/tui/pipeline.js +195 -75
  41. package/lib/tui/pipeline.js.map +1 -1
  42. package/lib/util/collapseRepeats.d.ts +20 -0
  43. package/lib/util/collapseRepeats.js +80 -0
  44. package/lib/util/collapseRepeats.js.map +1 -0
  45. package/lib/util/duration.d.ts +7 -0
  46. package/lib/util/duration.js +25 -0
  47. package/lib/util/duration.js.map +1 -0
  48. package/lib/util/exec.d.ts +15 -3
  49. package/lib/util/exec.js +37 -7
  50. package/lib/util/exec.js.map +1 -1
  51. package/lib/util/mascot.d.ts +18 -0
  52. package/lib/util/mascot.js +42 -0
  53. package/lib/util/mascot.js.map +1 -0
  54. package/package.json +3 -2
  55. package/scripts/demo-tui.mjs +108 -0
  56. package/src/agents/__fixtures__/README.md +1 -0
  57. package/src/agents/__fixtures__/claude-bash.jsonl +114 -0
  58. package/src/agents/claude.ts +64 -16
  59. package/src/agents/codex.ts +12 -1
  60. package/src/agents/copilot.ts +10 -1
  61. package/src/agents/gemini.ts +9 -1
  62. package/src/agents/index.ts +1 -1
  63. package/src/agents/parse-line.test.ts +40 -6
  64. package/src/agents/stream-json-cli.ts +32 -8
  65. package/src/agents/types.ts +16 -0
  66. package/src/commands/game/create.ts +47 -18
  67. package/src/commands/game/seedImport.ts +30 -0
  68. package/src/commands/upload.ts +7 -21
  69. package/src/download/page-downloader.ts +22 -7
  70. package/src/skills/context.ts +75 -0
  71. package/src/skills/mcp-client.ts +24 -0
  72. package/src/skills/registry.ts +66 -11
  73. package/src/skills/runner.ts +52 -103
  74. package/src/skills/step.ts +47 -0
  75. package/src/tui/pipeline.ts +200 -72
  76. package/src/util/collapseRepeats.test.ts +78 -0
  77. package/src/util/collapseRepeats.ts +77 -0
  78. package/src/util/duration.test.ts +37 -0
  79. package/src/util/duration.ts +25 -0
  80. package/src/util/exec.ts +40 -7
  81. package/src/util/mascot.ts +55 -0
  82. package/templates/minesweeper/README.md +3 -1
  83. package/templates/minesweeper/package.json +3 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Coarser sibling of `formatDuration` for a counter that repaints while it runs, where
3
+ * sub-second precision only flickers: 0s / 12s / 6m02s.
4
+ */
5
+ export const formatElapsed = (ms) => {
6
+ const secs = Math.floor(ms / 1000);
7
+ return secs < 60 ? `${secs}s` : formatDuration(secs * 1000);
8
+ };
9
+ /** Renders a span as 340ms / 12.4s / 6m02s — short enough to sit at the end of a log line */
10
+ export const formatDuration = (ms) => {
11
+ if (ms < 1000)
12
+ return `${Math.round(ms)}ms`;
13
+ const totalSecs = ms / 1000;
14
+ if (totalSecs < 60)
15
+ return `${totalSecs.toFixed(1)}s`;
16
+ let mins = Math.floor(totalSecs / 60);
17
+ let secs = Math.round(totalSecs % 60);
18
+ // Rounding can push seconds to a full minute (119.7s would read "1m60s")
19
+ if (secs === 60) {
20
+ mins += 1;
21
+ secs = 0;
22
+ }
23
+ return `${mins}m${String(secs).padStart(2, "0")}s`;
24
+ };
25
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/util/duration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAU,EAAU,EAAE;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;IAClC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;AAC7D,CAAC,CAAA;AAED,6FAA6F;AAC7F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAU,EAAU,EAAE;IACnD,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAA;IAE3C,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAA;IAC3B,IAAI,SAAS,GAAG,EAAE;QAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IAErD,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAA;IACrC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAA;IACrC,yEAAyE;IACzE,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,IAAI,IAAI,CAAC,CAAA;QACT,IAAI,GAAG,CAAC,CAAA;IACV,CAAC;IACD,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAA;AACpD,CAAC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  type ExecOptions = {
2
2
  cwd?: string;
3
3
  };
4
+ export type PackageManagerName = "npm" | "yarn" | "pnpm";
4
5
  /** Runs a shell command, printing output */
5
6
  export declare const runCommand: (cmd: string, opts?: ExecOptions) => void;
6
7
  /** Runs a command and returns stdout */
@@ -9,9 +10,20 @@ export declare const runCommandOutput: (cmd: string, opts?: ExecOptions) => stri
9
10
  export declare const gitCommit: (message: string, opts?: ExecOptions) => void;
10
11
  /** True if a `git` executable is available on PATH */
11
12
  export declare const isGitInstalled: () => boolean;
12
- /** Runs vite build and returns success/failure */
13
- export declare const verifyBuild: (cwd: string) => {
13
+ /** Runs a command without blocking the event loop, capturing stdout and stderr together */
14
+ export declare const runCapture: (cmd: string, opts?: ExecOptions) => Promise<{
15
+ success: boolean;
16
+ output: string;
17
+ }>;
18
+ /** Runs the project's build and returns success/failure */
19
+ export declare const verifyBuild: (cwd: string, buildCmd: string) => Promise<{
14
20
  success: boolean;
15
21
  error?: string;
16
- };
22
+ }>;
23
+ /**
24
+ * The command that builds a game directory. Prefers the project's own `build` script so
25
+ * monorepo/PnP setups resolve the way they normally do, and only falls back to invoking
26
+ * vite directly for games that share a parent package.json.
27
+ */
28
+ export declare const resolveBuildCommand: (gameDir: string, pm: PackageManagerName) => string;
17
29
  export {};
package/lib/util/exec.js CHANGED
@@ -1,4 +1,6 @@
1
- import { execSync } from "node:child_process";
1
+ import { execSync, spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
2
4
  /** Runs a shell command, printing output */
3
5
  export const runCommand = (cmd, opts = {}) => {
4
6
  execSync(cmd, {
@@ -31,14 +33,42 @@ export const isGitInstalled = () => {
31
33
  return false;
32
34
  }
33
35
  };
34
- /** Runs vite build and returns success/failure */
35
- export const verifyBuild = (cwd) => {
36
+ /** Runs a command without blocking the event loop, capturing stdout and stderr together */
37
+ export const runCapture = (cmd, opts = {}) => new Promise((resolve) => {
38
+ const child = spawn(cmd, { cwd: opts.cwd, shell: true });
39
+ let output = "";
40
+ child.stdout?.on("data", (chunk) => (output += chunk.toString("utf-8")));
41
+ child.stderr?.on("data", (chunk) => (output += chunk.toString("utf-8")));
42
+ child.on("error", (e) => resolve({ success: false, output: output + e.message }));
43
+ child.on("close", (code) => resolve({ success: code === 0, output }));
44
+ });
45
+ /** Runs the project's build and returns success/failure */
46
+ export const verifyBuild = async (cwd, buildCmd) => {
47
+ const { success, output } = await runCapture(buildCmd, { cwd });
48
+ return success ? { success: true } : { success: false, error: output };
49
+ };
50
+ /**
51
+ * The command that builds a game directory. Prefers the project's own `build` script so
52
+ * monorepo/PnP setups resolve the way they normally do, and only falls back to invoking
53
+ * vite directly for games that share a parent package.json.
54
+ */
55
+ export const resolveBuildCommand = (gameDir, pm) => {
56
+ if (hasBuildScript(gameDir))
57
+ return pm === "yarn" ? "yarn build" : `${pm} run build`;
58
+ if (pm === "yarn")
59
+ return "yarn vite build";
60
+ if (pm === "pnpm")
61
+ return "pnpm exec vite build";
62
+ return "npx vite build";
63
+ };
64
+ /** True when the directory has its own package.json declaring a build script */
65
+ const hasBuildScript = (dir) => {
36
66
  try {
37
- execSync("npx vite build", { cwd, encoding: "utf-8", stdio: "pipe" });
38
- return { success: true };
67
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8"));
68
+ return Boolean(pkg.scripts?.build);
39
69
  }
40
- catch (e) {
41
- return { success: false, error: e.stderr || e.stdout || e.message };
70
+ catch {
71
+ return false;
42
72
  }
43
73
  };
44
74
  //# sourceMappingURL=exec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/util/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAI7C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,OAAoB,EAAE,EAAE,EAAE;IAChE,QAAQ,CAAC,GAAG,EAAE;QACZ,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB,EAAE,EAAU,EAAE;IAC9E,OAAO,QAAQ,CAAC,GAAG,EAAE;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC,IAAI,EAAE,CAAA;AACX,CAAC,CAAA;AAED,2BAA2B;AAC3B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,OAAoB,EAAE,EAAE,EAAE;IACnE,QAAQ,CAAC,kBAAkB,OAAO,GAAG,EAAE;QACrC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,SAAS;KACjB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAY,EAAE;IAC1C,IAAI,CAAC;QACH,QAAQ,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC9C,OAAO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AAC,CAAA;QAChF,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ /** The Puzzmo character rendered as terminal art, one string per row. */
2
+ export type Mascot = {
3
+ /** Rows of the art, each carrying its own ANSI escapes and ending in a reset. */
4
+ lines: string[];
5
+ /** Visible width in terminal columns, so callers can pad around it. */
6
+ width: number;
7
+ /** Height in terminal rows. */
8
+ height: number;
9
+ };
10
+ /** Braille art at 20x10 cells, for when there is room to spare. */
11
+ export declare const mascotLarge: Mascot;
12
+ /** Braille art at 16x8 cells, for tight spots like the upload summary. */
13
+ export declare const mascotSmall: Mascot;
14
+ /**
15
+ * The art to draw, or null when colour is unavailable. There is no plain-text
16
+ * fallback on purpose: nobody wants eight rows of braille in a CI log.
17
+ */
18
+ export declare const pickMascot: (preferred: Mascot) => Mascot | null;
@@ -0,0 +1,42 @@
1
+ // The Puzzmo brand mark traced into braille: each cell holds 2x4 dots, and only the
2
+ // yellow body is dotted so the dark face reads as holes. Rows are exactly `width`
3
+ // columns, which callers rely on to pad around the art without measuring it.
4
+ /** Braille art at 20x10 cells, for when there is room to spare. */
5
+ export const mascotLarge = {
6
+ lines: [
7
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⠇\x1b[0m",
8
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⢀⣠⣤⣴⣶⣶⣶⣦⣤⣀⠀⠀⠀⣾⣿⠀\x1b[0m",
9
+ "\x1b[38;2;255;192;0m⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣦⡀⠈⣿⣧\x1b[0m",
10
+ "\x1b[38;2;255;192;0m⠀⣾⣿⣿⣿⣿⣿⣿⣿⣧⣀⣽⣿⣿⣿⣿⣿⣾⡿⠁\x1b[0m",
11
+ "\x1b[38;2;255;192;0m⢸⣿⣿⣿⣿⣀⣹⣿⣿⡿⠟⠛⠉⢻⣿⣿⣿⣿⠀⠀\x1b[0m",
12
+ "\x1b[38;2;255;192;0m⢸⣿⣿⣿⣿⣿⠟⠋⠁⠀⠀⠀⠀⣸⣿⣿⣿⣿⠃⠀\x1b[0m",
13
+ "\x1b[38;2;255;192;0m⠘⣿⣿⣿⣿⣷⣄⠀⠀⠀⢀⣠⣴⣿⣿⣿⣿⡟⠀⠀\x1b[0m",
14
+ "\x1b[38;2;255;192;0m⠀⢘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀\x1b[0m",
15
+ "\x1b[38;2;255;192;0m⣰⣿⠟⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠁⠀⠀⠀⠀\x1b[0m",
16
+ "\x1b[38;2;255;192;0m⠻⣿⣶⣶⣶⠄⠀⠀⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀\x1b[0m",
17
+ ],
18
+ width: 20,
19
+ height: 10,
20
+ };
21
+ /** Braille art at 16x8 cells, for tight spots like the upload summary. */
22
+ export const mascotSmall = {
23
+ lines: [
24
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⠇\x1b[0m",
25
+ "\x1b[38;2;255;192;0m⠀⠀⢀⣤⣶⣶⣿⣿⣿⣷⣶⣤⡀⠐⣿⣄\x1b[0m",
26
+ "\x1b[38;2;255;192;0m⠀⣴⣿⣿⣿⣿⣿⣟⠉⣿⣿⣿⣿⣦⣾⠟\x1b[0m",
27
+ "\x1b[38;2;255;192;0m⣸⣿⣿⣿⣉⣿⣿⡿⠿⠛⠻⣿⣿⣿⡇⠀\x1b[0m",
28
+ "\x1b[38;2;255;192;0m⢻⣿⣿⣿⡿⠋⠁⠀⠀⠀⣰⣿⣿⣿⡇⠀\x1b[0m",
29
+ "\x1b[38;2;255;192;0m⠘⣿⣿⣿⣿⣦⣄⣀⣤⣶⣿⣿⣿⡿⠁⠀\x1b[0m",
30
+ "\x1b[38;2;255;192;0m⢠⣾⠿⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀\x1b[0m",
31
+ "\x1b[38;2;255;192;0m⢿⣷⣶⣶⠈⠉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀\x1b[0m",
32
+ ],
33
+ width: 16,
34
+ height: 8,
35
+ };
36
+ /**
37
+ * The art to draw, or null when colour is unavailable. There is no plain-text
38
+ * fallback on purpose: nobody wants eight rows of braille in a CI log.
39
+ */
40
+ export const pickMascot = (preferred) => (supportsColor() ? preferred : null);
41
+ const supportsColor = () => Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
42
+ //# sourceMappingURL=mascot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mascot.js","sourceRoot":"","sources":["../../src/util/mascot.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,kFAAkF;AAClF,6EAA6E;AAY7E,mEAAmE;AACnE,MAAM,CAAC,MAAM,WAAW,GAAW;IACjC,KAAK,EAAE;QACL,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;QACjD,iDAAiD;KAClD;IACD,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;CACX,CAAA;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAW;IACjC,KAAK,EAAE;QACL,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;QAC7C,6CAA6C;KAC9C;IACD,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,CAAC;CACV,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAiB,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAEpG,MAAM,aAAa,GAAG,GAAY,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puzzmo/cli",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "puzzmo": "./lib/index.js"
@@ -19,7 +19,8 @@
19
19
  "scripts": {
20
20
  "build": "tsc",
21
21
  "type-check": "tsc --noEmit",
22
- "test": "vitest run"
22
+ "test": "vitest run",
23
+ "demo-tui": "tsc && node scripts/demo-tui.mjs"
23
24
  },
24
25
  "dependencies": {
25
26
  "@cfworker/json-schema": "^4.1.1",
@@ -0,0 +1,108 @@
1
+ // Drives the migration TUI with a scripted agent, so rendering changes can be eyeballed
2
+ // without paying for a real agent run.
3
+ // Run: yarn workspace @puzzmo/cli demo-tui
4
+ //
5
+ // Ctrl+C quits. Pass --fast to skip the typing delays, --fail to watch a step go red.
6
+ import fs from "node:fs"
7
+ import os from "node:os"
8
+ import path from "node:path"
9
+ import { execFileSync } from "node:child_process"
10
+
11
+ const { AGENTS } = await import("../lib/agents/index.js")
12
+ const { runPipelineTUI } = await import("../lib/tui/pipeline.js")
13
+ const { newSession } = await import("../lib/skills/step.js")
14
+
15
+ const fast = process.argv.includes("--fast")
16
+ const shouldFail = process.argv.includes("--fail")
17
+ const gameDir = seedGameDir()
18
+
19
+ // The registry is a plain object, so a demo agent can be slotted in from outside.
20
+ AGENTS.demo = { name: "demo", run: ({ prompt }) => replay(scriptFor(prompt)) }
21
+
22
+ await runPipelineTUI(
23
+ {
24
+ agent: "demo",
25
+ gameDir,
26
+ repoContext: "Demo repo context",
27
+ // Cheap stand-ins for a real build, so the build phase renders without one.
28
+ buildCmd: shouldFail ? "false" : "true",
29
+ session: newSession(),
30
+ },
31
+ [
32
+ { name: "port-source", skills: [], preamble: "Port the source.", skipBuild: true },
33
+ { name: "puzzmo-lifecycle", skills: [], preamble: "Wire up the SDK." },
34
+ { name: "thumbnail", skills: [], preamble: "Make a thumbnail.", skipBuild: true },
35
+ ],
36
+ )
37
+
38
+ console.log(`\nDemo project: ${gameDir}`)
39
+
40
+ /** Events for one step. The middle step repeats an edit so the repeat-folding shows up. */
41
+ function scriptFor(prompt) {
42
+ const file = `${gameDir}/src/main.ts`
43
+ const events = [
44
+ { type: "system", text: "Session started" },
45
+ { type: "thinking", text: "Looking at what is already on disk.\n" },
46
+ { type: "text", text: "I'll start by reading the existing source.\n" },
47
+ { type: "tool_use", name: "Read", summary: file },
48
+ { type: "tool_result", ok: true, summary: "1 import { createPuzzmoSDK } from '@puzzmo/sdk'" },
49
+ { type: "text", text: "Now the port itself.\n" },
50
+ { type: "tool_use", name: "Write", summary: `${gameDir}/src/puzzle.ts` },
51
+ { type: "tool_result", ok: true, summary: `Created ${gameDir}/src/puzzle.ts` },
52
+ ]
53
+
54
+ // Five identical call/result pairs — the pane should fold these into one row.
55
+ if (prompt.includes("Wire up the SDK")) {
56
+ for (let i = 0; i < 5; i++) {
57
+ events.push({ type: "tool_use", name: "Edit", summary: file })
58
+ events.push({ type: "tool_result", ok: true, summary: `The file ${file} has been updated successfully.` })
59
+ }
60
+ events.push({ type: "text", text: "The lifecycle is wired up.\n" })
61
+ }
62
+
63
+ if (prompt.includes("thumbnail")) {
64
+ events.push({ type: "tool_use", name: "Bash", summary: "npm run build" })
65
+ events.push({ type: "tool_result", ok: false, summary: "Exit code 1" })
66
+ events.push({ type: "text", text: "Retrying with the right script name.\n" })
67
+ }
68
+
69
+ events.push({ type: "result", ok: true, costUSD: 0.0421 })
70
+ return events
71
+ }
72
+
73
+ /** Yields the scripted events, streaming text a word at a time like a real agent. */
74
+ async function* replay(events) {
75
+ for (const event of events) {
76
+ if (event.type === "text" || event.type === "thinking") {
77
+ for (const word of event.text.split(/(?<= )/)) {
78
+ yield { type: event.type, text: word }
79
+ await pause(fast ? 0 : 45)
80
+ }
81
+ continue
82
+ }
83
+ yield event
84
+ await pause(fast ? 0 : 320)
85
+ }
86
+ }
87
+
88
+ // A declaration, not a const: the top-level await above runs before this line is reached.
89
+ function pause(ms) {
90
+ return new Promise((resolve) => setTimeout(resolve, ms))
91
+ }
92
+
93
+ /** A throwaway git repo with enough in it that the project summary has something to say. */
94
+ function seedGameDir() {
95
+ const dir = path.join(os.tmpdir(), "puzzmo-tui-demo")
96
+ fs.rmSync(dir, { recursive: true, force: true })
97
+ fs.mkdirSync(path.join(dir, "src"), { recursive: true })
98
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify({ name: "tui-demo", scripts: { build: "true" } }, null, 2))
99
+ fs.writeFileSync(path.join(dir, "src", "main.ts"), "export const main = () => {}\n")
100
+ // commitStep runs git add/commit, which needs a repo to land in.
101
+ const git = (...args) => execFileSync("git", args, { cwd: dir, stdio: "ignore" })
102
+ git("init", "-q")
103
+ git("config", "user.email", "demo@example.com")
104
+ git("config", "user.name", "Demo")
105
+ git("add", "-A")
106
+ git("commit", "-qm", "initial")
107
+ return dir
108
+ }
@@ -9,6 +9,7 @@ against a real run when someone has that subscription.
9
9
  | Fixture | Source | Trust |
10
10
  | --- | --- | --- |
11
11
  | `claude.jsonl` | Real capture: `claude -p --output-format stream-json --include-partial-messages --verbose` (2026-07-18). IDs/paths trimmed; event shapes verbatim. | High — real |
12
+ | `claude-bash.jsonl` | Real capture, same flags (2026-08-20): two Bash calls in one turn, a Write, and a failing Bash. IDs/paths/signatures trimmed and `usage` dropped; runs of `input_json_delta` fragments clipped to three, since it's their existence rather than their number that matters. | High — real |
12
13
  | `codex.jsonl` | Transcribed from the `codex exec --json` event cheatsheet (takopi.dev) matching `@openai/codex-sdk`'s `ThreadEvent` union. | Medium — docs |
13
14
  | `gemini.jsonl` | Transcribed from the `gemini --output-format stream-json` cheatsheet (littlebearapps.com) / `@google/gemini-cli-core` `JsonStreamEvent`. | Medium — docs |
14
15
  | `copilot.jsonl` | Transcribed from GitHub's Copilot SDK "Streaming events" docs (session-events schema). | Medium — docs |
@@ -0,0 +1,114 @@
1
+ {"type": "system", "subtype": "init", "cwd": "/tmp/game", "session_id": "a1b2c3d4", "tools": ["Bash", "Read", "Write", "Edit"], "model": "claude-haiku-4-5-20251001", "permissionMode": "bypassPermissions", "terminal_slash_commands": ["doctor", "color"], "apiKeySource": "none", "claude_code_version": "2.1.234", "plugins": [{"name": "claude-opus-4-5-migration", "path": "/home/orta/.claude/plugins/cache/claude-code-plugins/claude-opus-4-5-migration/1.0.0", "source": "claude-opus-4-5-migration@claude-code-plugins", "version": "1.0.0"}, {"name": "rust-analyzer-lsp", "path": "/home/orta/.claude/plugins/cache/claude-plugins-official/rust-analyzer-lsp/1.0.0", "source": "rust-analyzer-lsp@claude-plugins-official", "version": "1.0.0"}, {"name": "ralph-loop", "path": "/home/orta/.claude/plugins/cache/claude-plugins-official/ralph-loop/1.0.0", "source": "ralph-loop@claude-plugins-official", "version": "1.0.0"}], "capabilities": ["interrupt_receipt_v1", "interrupt_cancel_queued_v1", "msg_lifecycle_v1"], "analytics_disabled": true, "product_feedback_disabled": false, "uuid": "u-0000", "memory_paths": {"auto": "/home/orta/.claude/projects/-tmp-claude-1000--home-orta-dev-puzmo-app2-5f22686a-33f3-4f16-8404-c8af9d3652ae-scratchpad-capture/memory/"}, "fast_mode_state": "off", "fast_mode_disabled_reason": "unknown"}
2
+ {"type": "system", "subtype": "status", "status": "requesting", "uuid": "u-0000", "session_id": "a1b2c3d4"}
3
+ {"type": "rate_limit_event", "rate_limit_info": {"status": "allowed", "resetsAt": 1787245200, "rateLimitType": "five_hour", "overageStatus": "rejected", "overageDisabledReason": "org_level_disabled", "isUsingOverage": false}, "uuid": "u-0000", "session_id": "a1b2c3d4"}
4
+ {"type": "stream_event", "event": {"type": "message_start", "message": {"model": "claude-haiku-4-5-20251001", "id": "msg_011CeE76xncc73g6fyzQYB4E", "type": "message", "role": "assistant", "content": [], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 10, "cache_creation_input_tokens": 27540, "cache_read_input_tokens": 0, "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 27540}, "output_tokens": 3, "service_tier": "standard", "inference_geo": "not_available"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000", "ttft_ms": 1014}
5
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
6
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 4, "estimated_tokens_delta": 4, "uuid": "u-0000", "session_id": "a1b2c3d4"}
7
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "The user wants", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
8
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 40, "estimated_tokens_delta": 36, "uuid": "u-0000", "session_id": "a1b2c3d4"}
9
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " me to:\n1. Run 'ls -la' and 'node --version' in parallel\n2. Write a file notes.txt containing the node version\n3. Run a command that fails: 'cat", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
10
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 72, "estimated_tokens_delta": 32, "uuid": "u-0000", "session_id": "a1b2c3d4"}
11
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " /nope/missing.txt'\n\nThey want me to be brief.\n\nLet me start by running the two commands in parallel using the Bash tool. I can", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
12
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 87, "estimated_tokens_delta": 15, "uuid": "u-0000", "session_id": "a1b2c3d4"}
13
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " make two calls simultaneously since they're independent.", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
14
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 156, "estimated_tokens_delta": 69, "uuid": "u-0000", "session_id": "a1b2c3d4"}
15
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "sig-trimmed"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
16
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "thinking", "thinking": "The user wants me to:\n1. Run 'ls -la' and 'node --version' in parallel\n2. Write a file notes.txt containing the node version\n3. Run a command that fails: 'cat /nope/missing.txt'\n\nThey want me to be brief.\n\nLet me start by running the two commands in parallel using the Bash tool. I can make two calls simultaneously since they're independent.", "signature": "sig-trimmed"}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:44.709Z", "request_id": "req_0000"}
17
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 0}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
18
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 1, "content_block": {"type": "tool_use", "id": "toolu_SR34ue", "name": "Bash", "input": {}, "caller": {"type": "direct"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
19
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
20
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"com"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
21
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "man"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
22
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "tool_use", "id": "toolu_SR34ue", "name": "Bash", "input": {"command": "ls -la", "description": "List files in current directory"}, "caller": {"type": "direct"}}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:45.411Z", "request_id": "req_0000"}
23
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 1}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
24
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 2, "content_block": {"type": "tool_use", "id": "toolu_Rsvgcm", "name": "Bash", "input": {}, "caller": {"type": "direct"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
25
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 2, "delta": {"type": "input_json_delta", "partial_json": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
26
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 2, "delta": {"type": "input_json_delta", "partial_json": "{\"com"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
27
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 2, "delta": {"type": "input_json_delta", "partial_json": "mand\": \"n"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
28
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "tool_use", "id": "toolu_Rsvgcm", "name": "Bash", "input": {"command": "node --version", "description": "Get node version"}, "caller": {"type": "direct"}}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:45.486Z", "request_id": "req_0000"}
29
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 2}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
30
+ {"type": "stream_event", "event": {"type": "message_delta", "delta": {"stop_reason": "tool_use", "stop_sequence": null, "stop_details": null}, "context_management": {"applied_edits": []}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
31
+ {"type": "stream_event", "event": {"type": "message_stop"}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
32
+ {"type": "user", "message": {"role": "user", "content": [{"tool_use_id": "toolu_SR34ue", "type": "tool_result", "content": "(Bash completed with no output)", "is_error": false}]}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:45.882Z", "tool_use_result": {"stdout": "", "stderr": "", "interrupted": false, "isImage": false, "noOutputExpected": false}}
33
+ {"type": "user", "message": {"role": "user", "content": [{"tool_use_id": "toolu_Rsvgcm", "type": "tool_result", "content": "v24.19.0", "is_error": false}]}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:45.885Z", "tool_use_result": {"stdout": "v24.19.0", "stderr": "", "interrupted": false, "isImage": false, "noOutputExpected": false}}
34
+ {"type": "system", "subtype": "status", "status": "requesting", "uuid": "u-0000", "session_id": "a1b2c3d4"}
35
+ {"type": "stream_event", "event": {"type": "message_start", "message": {"model": "claude-haiku-4-5-20251001", "id": "msg_011CeE77CVcpZH3v8fWXTKjC", "type": "message", "role": "assistant", "content": [], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 8, "cache_creation_input_tokens": 1449, "cache_read_input_tokens": 27540, "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 1449}, "output_tokens": 1, "service_tier": "standard", "inference_geo": "not_available"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000", "ttft_ms": 833}
36
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
37
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 1, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
38
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "Good", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
39
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 2, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
40
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": ",", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
41
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 3, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
42
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " I", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
43
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 4, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
44
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " got", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
45
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 7, "estimated_tokens_delta": 3, "uuid": "u-0000", "session_id": "a1b2c3d4"}
46
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " the node", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
47
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 9, "estimated_tokens_delta": 2, "uuid": "u-0000", "session_id": "a1b2c3d4"}
48
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " version", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
49
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 10, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
50
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": ":", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
51
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 26, "estimated_tokens_delta": 16, "uuid": "u-0000", "session_id": "a1b2c3d4"}
52
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " v24.19.0. The ls -la had no output (probably empty directory", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
53
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 47, "estimated_tokens_delta": 21, "uuid": "u-0000", "session_id": "a1b2c3d4"}
54
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "). Now I need to write the node version to notes.txt, then run the failing command", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
55
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 48, "estimated_tokens_delta": 1, "uuid": "u-0000", "session_id": "a1b2c3d4"}
56
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": ".", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
57
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 114, "estimated_tokens_delta": 66, "uuid": "u-0000", "session_id": "a1b2c3d4"}
58
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "sig-trimmed"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
59
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "thinking", "thinking": "Good, I got the node version: v24.19.0. The ls -la had no output (probably empty directory). Now I need to write the node version to notes.txt, then run the failing command.", "signature": "sig-trimmed"}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:47.895Z", "request_id": "req_0000"}
60
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 0}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
61
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 1, "content_block": {"type": "tool_use", "id": "toolu_W2cjBE", "name": "Write", "input": {}, "caller": {"type": "direct"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
62
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
63
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"file_pat"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
64
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "h\": \"/"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
65
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "tool_use", "id": "toolu_W2cjBE", "name": "Write", "input": {"file_path": "/tmp/game/notes.txt", "content": "v24.19.0"}, "caller": {"type": "direct"}}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:49.883Z", "request_id": "req_0000"}
66
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 1}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
67
+ {"type": "stream_event", "event": {"type": "message_delta", "delta": {"stop_reason": "tool_use", "stop_sequence": null, "stop_details": null}, "context_management": {"applied_edits": []}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
68
+ {"type": "stream_event", "event": {"type": "message_stop"}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
69
+ {"type": "user", "message": {"role": "user", "content": [{"tool_use_id": "toolu_W2cjBE", "type": "tool_result", "content": "File created successfully at: /tmp/game/notes.txt (file state is current in your context \u2014 no need to Read it back)"}]}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:49.923Z", "tool_use_result": {"type": "create", "filePath": "/tmp/game/notes.txt", "content": "v24.19.0", "structuredPatch": [], "originalFile": null, "userModified": false}}
70
+ {"type": "system", "subtype": "status", "status": "requesting", "uuid": "u-0000", "session_id": "a1b2c3d4"}
71
+ {"type": "stream_event", "event": {"type": "message_start", "message": {"model": "claude-haiku-4-5-20251001", "id": "msg_011CeE77VzqBQqmxh3ue1ytN", "type": "message", "role": "assistant", "content": [], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 8, "cache_creation_input_tokens": 382, "cache_read_input_tokens": 28989, "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 382}, "output_tokens": 3, "service_tier": "standard", "inference_geo": "not_available"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000", "ttft_ms": 937}
72
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
73
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 3, "estimated_tokens_delta": 3, "uuid": "u-0000", "session_id": "a1b2c3d4"}
74
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "Now I need", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
75
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 21, "estimated_tokens_delta": 18, "uuid": "u-0000", "session_id": "a1b2c3d4"}
76
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " to run the failing command: 'cat /nope/missing.txt'. This should fail", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
77
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 29, "estimated_tokens_delta": 8, "uuid": "u-0000", "session_id": "a1b2c3d4"}
78
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": " since the file doesn't exist.", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
79
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 98, "estimated_tokens_delta": 69, "uuid": "u-0000", "session_id": "a1b2c3d4"}
80
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "sig-trimmed"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
81
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "thinking", "thinking": "Now I need to run the failing command: 'cat /nope/missing.txt'. This should fail since the file doesn't exist.", "signature": "sig-trimmed"}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:51.558Z", "request_id": "req_0000"}
82
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 0}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
83
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 1, "content_block": {"type": "tool_use", "id": "toolu_VSKbcC", "name": "Bash", "input": {}, "caller": {"type": "direct"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
84
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
85
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"command\":"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
86
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": " \""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
87
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "tool_use", "id": "toolu_VSKbcC", "name": "Bash", "input": {"command": "cat /nope/missing.txt", "description": "Attempt to read a non-existent file"}, "caller": {"type": "direct"}}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:51.984Z", "request_id": "req_0000"}
88
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 1}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
89
+ {"type": "stream_event", "event": {"type": "message_delta", "delta": {"stop_reason": "tool_use", "stop_sequence": null, "stop_details": null}, "context_management": {"applied_edits": []}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
90
+ {"type": "stream_event", "event": {"type": "message_stop"}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
91
+ {"type": "user", "message": {"role": "user", "content": [{"type": "tool_result", "content": "Exit code 1\ncat: /nope/missing.txt: No such file or directory", "is_error": true, "tool_use_id": "toolu_VSKbcC"}]}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:52.020Z", "tool_use_result": "Error: Exit code 1\ncat: /nope/missing.txt: No such file or directory"}
92
+ {"type": "system", "subtype": "status", "status": "requesting", "uuid": "u-0000", "session_id": "a1b2c3d4"}
93
+ {"type": "stream_event", "event": {"type": "message_start", "message": {"model": "claude-haiku-4-5-20251001", "id": "msg_011CeE77emBWNQCp3dvEh45h", "type": "message", "role": "assistant", "content": [], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 8, "cache_creation_input_tokens": 198, "cache_read_input_tokens": 29371, "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 198}, "output_tokens": 1, "service_tier": "standard", "inference_geo": "not_available"}}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000", "ttft_ms": 723}
94
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
95
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 2, "estimated_tokens_delta": 2, "uuid": "u-0000", "session_id": "a1b2c3d4"}
96
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "Perfect", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
97
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 19, "estimated_tokens_delta": 17, "uuid": "u-0000", "session_id": "a1b2c3d4"}
98
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": ". All tasks completed:\n1. Ran ls -la and node --version in parallel ", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
99
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 47, "estimated_tokens_delta": 28, "uuid": "u-0000", "session_id": "a1b2c3d4"}
100
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\u2713\n2. Wrote node version to notes.txt \u2713\n3. Ran the failing command, which exited with code 1 and error message ", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
101
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 59, "estimated_tokens_delta": 12, "uuid": "u-0000", "session_id": "a1b2c3d4"}
102
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\u2713\n\nUser asked for brief, so I'll keep it short.", "estimated_tokens": null}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
103
+ {"type": "system", "subtype": "thinking_tokens", "estimated_tokens": 130, "estimated_tokens_delta": 71, "uuid": "u-0000", "session_id": "a1b2c3d4"}
104
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "sig-trimmed"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
105
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "thinking", "thinking": "Perfect. All tasks completed:\n1. Ran ls -la and node --version in parallel \u2713\n2. Wrote node version to notes.txt \u2713\n3. Ran the failing command, which exited with code 1 and error message \u2713\n\nUser asked for brief, so I'll keep it short.", "signature": "sig-trimmed"}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:53.730Z", "request_id": "req_0000"}
106
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 0}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
107
+ {"type": "stream_event", "event": {"type": "content_block_start", "index": 1, "content_block": {"type": "text", "text": ""}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
108
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": "Done. Node"}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
109
+ {"type": "stream_event", "event": {"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": " v24.19.0 written to notes.txt, and the cat command failed as expected with \"No such file or directory\"."}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
110
+ {"type": "assistant", "message": {"type": "message", "role": "assistant", "content": [{"type": "text", "text": "Done. Node v24.19.0 written to notes.txt, and the cat command failed as expected with \"No such file or directory\"."}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "context_management": null}, "parent_tool_use_id": null, "session_id": "a1b2c3d4", "uuid": "u-0000", "timestamp": "2026-08-20T13:48:54.003Z", "request_id": "req_0000"}
111
+ {"type": "stream_event", "event": {"type": "content_block_stop", "index": 1}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
112
+ {"type": "stream_event", "event": {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null, "stop_details": null}, "context_management": {"applied_edits": []}}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
113
+ {"type": "stream_event", "event": {"type": "message_stop"}, "session_id": "a1b2c3d4", "parent_tool_use_id": null, "uuid": "u-0000"}
114
+ {"is_error": false, "duration_api_ms": 12541, "num_turns": 5, "stop_reason": "end_turn", "session_id": "a1b2c3d4", "total_cost_usd": 0.072234, "usage": {"input_tokens": 34, "cache_creation_input_tokens": 29569, "cache_read_input_tokens": 85900, "output_tokens": 692, "output_tokens_details": {"thinking_tokens": 263}, "server_tool_use": {"web_search_requests": 0, "web_fetch_requests": 0}, "service_tier": "standard", "cache_creation": {"ephemeral_1h_input_tokens": 29569, "ephemeral_5m_input_tokens": 0}, "inference_geo": "not_available", "iterations": [], "speed": "standard"}, "modelUsage": {"claude-haiku-4-5-20251001": {"inputTokens": 976, "outputTokens": 706, "cacheReadInputTokens": 85900, "cacheCreationInputTokens": 29569, "webSearchRequests": 0, "costUSD": 0.072234, "contextWindow": 200000, "maxOutputTokens": 32000, "canonicalModel": "claude-haiku-4-5", "provider": "firstParty"}}, "permission_denials": [], "terminal_reason": "completed", "fast_mode_state": "off", "fast_mode_disabled_reason": "extra_usage_disabled", "subtype": "success", "api_error_status": null, "result": "Done. Node v24.19.0 written to notes.txt, and the cat command failed as expected with \"No such file or directory\".", "ttft_ms": 2420, "ttft_stream_ms": 1360, "time_to_request_ms": 347, "type": "result", "duration_ms": 11756, "uuid": "u-0000"}