@herbcaudill/ralph 0.1.0 → 0.3.0

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 (176) hide show
  1. package/README.md +1 -1
  2. package/bin/ralph.js +1 -1
  3. package/dist/cli.d.ts +2 -19
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +30 -65
  6. package/dist/cli.js.map +1 -1
  7. package/dist/components/App.d.ts +10 -0
  8. package/dist/components/App.d.ts.map +1 -0
  9. package/dist/components/App.js +16 -0
  10. package/dist/components/App.js.map +1 -0
  11. package/dist/components/EventDisplay.d.ts +7 -0
  12. package/dist/components/EventDisplay.d.ts.map +1 -0
  13. package/dist/components/EventDisplay.js +64 -0
  14. package/dist/components/EventDisplay.js.map +1 -0
  15. package/dist/components/EventDisplay.replay.test.d.ts +2 -0
  16. package/dist/components/EventDisplay.replay.test.d.ts.map +1 -0
  17. package/dist/components/EventDisplay.replay.test.js +403 -0
  18. package/dist/components/EventDisplay.replay.test.js.map +1 -0
  19. package/dist/components/EventDisplay.test.d.ts +2 -0
  20. package/dist/components/EventDisplay.test.d.ts.map +1 -0
  21. package/dist/components/EventDisplay.test.js +223 -0
  22. package/dist/components/EventDisplay.test.js.map +1 -0
  23. package/dist/components/Header.d.ts +8 -0
  24. package/dist/components/Header.d.ts.map +1 -0
  25. package/dist/components/Header.js +15 -0
  26. package/dist/components/Header.js.map +1 -0
  27. package/dist/components/Header.test.d.ts +2 -0
  28. package/dist/components/Header.test.d.ts.map +1 -0
  29. package/dist/components/Header.test.js +27 -0
  30. package/dist/components/Header.test.js.map +1 -0
  31. package/dist/components/InitRalph.d.ts +3 -0
  32. package/dist/components/InitRalph.d.ts.map +1 -0
  33. package/dist/components/InitRalph.js +100 -0
  34. package/dist/components/InitRalph.js.map +1 -0
  35. package/dist/components/IterationRunner.d.ts +7 -0
  36. package/dist/components/IterationRunner.d.ts.map +1 -0
  37. package/dist/components/IterationRunner.js +285 -0
  38. package/dist/components/IterationRunner.js.map +1 -0
  39. package/dist/components/IterationRunner.test.d.ts +2 -0
  40. package/dist/components/IterationRunner.test.d.ts.map +1 -0
  41. package/dist/components/IterationRunner.test.js +109 -0
  42. package/dist/components/IterationRunner.test.js.map +1 -0
  43. package/dist/components/ReplayLog.d.ts +7 -0
  44. package/dist/components/ReplayLog.d.ts.map +1 -0
  45. package/dist/components/ReplayLog.js +51 -0
  46. package/dist/components/ReplayLog.js.map +1 -0
  47. package/dist/components/StreamingText.d.ts +7 -0
  48. package/dist/components/StreamingText.d.ts.map +1 -0
  49. package/dist/components/StreamingText.js +36 -0
  50. package/dist/components/StreamingText.js.map +1 -0
  51. package/dist/components/StreamingText.test.d.ts +2 -0
  52. package/dist/components/StreamingText.test.d.ts.map +1 -0
  53. package/dist/components/StreamingText.test.js +86 -0
  54. package/dist/components/StreamingText.test.js.map +1 -0
  55. package/dist/components/ToolUse.d.ts +8 -0
  56. package/dist/components/ToolUse.d.ts.map +1 -0
  57. package/dist/components/ToolUse.js +10 -0
  58. package/dist/components/ToolUse.js.map +1 -0
  59. package/dist/components/ToolUse.test.d.ts +2 -0
  60. package/dist/components/ToolUse.test.d.ts.map +1 -0
  61. package/dist/components/ToolUse.test.js +43 -0
  62. package/dist/components/ToolUse.test.js.map +1 -0
  63. package/dist/components/eventToBlocks.d.ts +12 -0
  64. package/dist/components/eventToBlocks.d.ts.map +1 -0
  65. package/dist/components/eventToBlocks.js +142 -0
  66. package/dist/components/eventToBlocks.js.map +1 -0
  67. package/dist/components/eventToBlocks.test.d.ts +2 -0
  68. package/dist/components/eventToBlocks.test.d.ts.map +1 -0
  69. package/dist/components/eventToBlocks.test.js +412 -0
  70. package/dist/components/eventToBlocks.test.js.map +1 -0
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +3 -21
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/cleanupAllWorktrees.d.ts +5 -0
  76. package/dist/lib/cleanupAllWorktrees.d.ts.map +1 -0
  77. package/dist/lib/cleanupAllWorktrees.js +25 -0
  78. package/dist/lib/cleanupAllWorktrees.js.map +1 -0
  79. package/dist/lib/cleanupWorktree.d.ts +6 -0
  80. package/dist/lib/cleanupWorktree.d.ts.map +1 -0
  81. package/dist/lib/cleanupWorktree.js +33 -0
  82. package/dist/lib/cleanupWorktree.js.map +1 -0
  83. package/dist/lib/copyRalphFilesFromWorktree.d.ts +5 -0
  84. package/dist/lib/copyRalphFilesFromWorktree.d.ts.map +1 -0
  85. package/dist/lib/copyRalphFilesFromWorktree.js +19 -0
  86. package/dist/lib/copyRalphFilesFromWorktree.js.map +1 -0
  87. package/dist/lib/copyRalphFilesToWorktree.d.ts +5 -0
  88. package/dist/lib/copyRalphFilesToWorktree.d.ts.map +1 -0
  89. package/dist/lib/copyRalphFilesToWorktree.js +21 -0
  90. package/dist/lib/copyRalphFilesToWorktree.js.map +1 -0
  91. package/dist/lib/createWorktree.d.ts +6 -0
  92. package/dist/lib/createWorktree.d.ts.map +1 -0
  93. package/dist/lib/createWorktree.js +34 -0
  94. package/dist/lib/createWorktree.js.map +1 -0
  95. package/dist/lib/getClaudeVersion.d.ts +2 -0
  96. package/dist/lib/getClaudeVersion.d.ts.map +1 -0
  97. package/dist/lib/getClaudeVersion.js +17 -0
  98. package/dist/lib/getClaudeVersion.js.map +1 -0
  99. package/dist/lib/getClaudeVersion.test.d.ts +2 -0
  100. package/dist/lib/getClaudeVersion.test.d.ts.map +1 -0
  101. package/dist/lib/getClaudeVersion.test.js +39 -0
  102. package/dist/lib/getClaudeVersion.test.js.map +1 -0
  103. package/dist/lib/getGitRoot.d.ts +5 -0
  104. package/dist/lib/getGitRoot.d.ts.map +1 -0
  105. package/dist/lib/getGitRoot.js +18 -0
  106. package/dist/lib/getGitRoot.js.map +1 -0
  107. package/dist/lib/installDependencies.d.ts +5 -0
  108. package/dist/lib/installDependencies.d.ts.map +1 -0
  109. package/dist/lib/installDependencies.js +23 -0
  110. package/dist/lib/installDependencies.js.map +1 -0
  111. package/dist/lib/installDependencies.test.d.ts +2 -0
  112. package/dist/lib/installDependencies.test.d.ts.map +1 -0
  113. package/dist/lib/installDependencies.test.js +37 -0
  114. package/dist/lib/installDependencies.test.js.map +1 -0
  115. package/dist/lib/mergeWorktreeToMain.d.ts +6 -0
  116. package/dist/lib/mergeWorktreeToMain.d.ts.map +1 -0
  117. package/dist/lib/mergeWorktreeToMain.js +44 -0
  118. package/dist/lib/mergeWorktreeToMain.js.map +1 -0
  119. package/dist/lib/popStash.d.ts +5 -0
  120. package/dist/lib/popStash.d.ts.map +1 -0
  121. package/dist/lib/popStash.js +17 -0
  122. package/dist/lib/popStash.js.map +1 -0
  123. package/dist/lib/rel.test.d.ts +2 -0
  124. package/dist/lib/rel.test.d.ts.map +1 -0
  125. package/dist/lib/rel.test.js +36 -0
  126. package/dist/lib/rel.test.js.map +1 -0
  127. package/dist/lib/replayLog.d.ts.map +1 -1
  128. package/dist/lib/replayLog.js +20 -6
  129. package/dist/lib/replayLog.js.map +1 -1
  130. package/dist/lib/runIteration.d.ts.map +1 -1
  131. package/dist/lib/runIteration.js +19 -9
  132. package/dist/lib/runIteration.js.map +1 -1
  133. package/dist/lib/shortenTempPaths.test.d.ts +2 -0
  134. package/dist/lib/shortenTempPaths.test.d.ts.map +1 -0
  135. package/dist/lib/shortenTempPaths.test.js +46 -0
  136. package/dist/lib/shortenTempPaths.test.js.map +1 -0
  137. package/dist/lib/signalHandler.d.ts +3 -0
  138. package/dist/lib/signalHandler.d.ts.map +1 -0
  139. package/dist/lib/signalHandler.js +19 -0
  140. package/dist/lib/signalHandler.js.map +1 -0
  141. package/dist/lib/stashChanges.d.ts +6 -0
  142. package/dist/lib/stashChanges.d.ts.map +1 -0
  143. package/dist/lib/stashChanges.js +27 -0
  144. package/dist/lib/stashChanges.js.map +1 -0
  145. package/dist/lib/types.d.ts +8 -0
  146. package/dist/lib/types.d.ts.map +1 -0
  147. package/dist/lib/types.js +5 -0
  148. package/dist/lib/types.js.map +1 -0
  149. package/dist/lib/worktree.d.ts +43 -0
  150. package/dist/lib/worktree.d.ts.map +1 -0
  151. package/dist/lib/worktree.js +210 -0
  152. package/dist/lib/worktree.js.map +1 -0
  153. package/dist/ui/EventProcessor.d.ts +11 -0
  154. package/dist/ui/EventProcessor.d.ts.map +1 -0
  155. package/dist/ui/EventProcessor.js +95 -0
  156. package/dist/ui/EventProcessor.js.map +1 -0
  157. package/dist/ui/IterationApp.d.ts +10 -0
  158. package/dist/ui/IterationApp.d.ts.map +1 -0
  159. package/dist/ui/IterationApp.js +21 -0
  160. package/dist/ui/IterationApp.js.map +1 -0
  161. package/dist/ui/IterationUI.d.ts +13 -0
  162. package/dist/ui/IterationUI.d.ts.map +1 -0
  163. package/dist/ui/IterationUI.js +19 -0
  164. package/dist/ui/IterationUI.js.map +1 -0
  165. package/dist/ui/TextDisplay.d.ts +7 -0
  166. package/dist/ui/TextDisplay.d.ts.map +1 -0
  167. package/dist/ui/TextDisplay.js +41 -0
  168. package/dist/ui/TextDisplay.js.map +1 -0
  169. package/dist/ui/ToolUseDisplay.d.ts +10 -0
  170. package/dist/ui/ToolUseDisplay.d.ts.map +1 -0
  171. package/dist/ui/ToolUseDisplay.js +10 -0
  172. package/dist/ui/ToolUseDisplay.js.map +1 -0
  173. package/package.json +23 -4
  174. package/templates/progress.md +1 -1
  175. package/templates/prompt.md +11 -1
  176. package/templates/todo.md +0 -1
@@ -0,0 +1,51 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { Box, Text, useApp } from "ink";
3
+ import { readFileSync } from "fs";
4
+ import { EventDisplay } from "./EventDisplay.js";
5
+ export const ReplayLog = ({ filePath }) => {
6
+ const { exit } = useApp();
7
+ const [events, setEvents] = useState([]);
8
+ const [error, setError] = useState();
9
+ useEffect(() => {
10
+ try {
11
+ const content = readFileSync(filePath, "utf-8");
12
+ // Log file contains pretty-printed JSON objects separated by blank lines
13
+ const eventStrings = content.split(/\n\n+/).filter(s => s.trim());
14
+ const parsedEvents = [];
15
+ for (const eventStr of eventStrings) {
16
+ try {
17
+ const event = JSON.parse(eventStr);
18
+ parsedEvents.push(event);
19
+ }
20
+ catch {
21
+ // Skip malformed entries
22
+ }
23
+ }
24
+ setEvents(parsedEvents);
25
+ setTimeout(() => {
26
+ exit();
27
+ process.exit(0);
28
+ }, 100);
29
+ }
30
+ catch (err) {
31
+ setError(`Failed to read replay file: ${err instanceof Error ? err.message : String(err)}`);
32
+ setTimeout(() => {
33
+ exit();
34
+ process.exit(1);
35
+ }, 100);
36
+ }
37
+ }, [filePath, exit]);
38
+ if (error) {
39
+ return (React.createElement(Box, { flexDirection: "column" },
40
+ React.createElement(Text, { color: "red" }, error)));
41
+ }
42
+ return (React.createElement(Box, { flexDirection: "column" },
43
+ React.createElement(Box, { marginBottom: 1 },
44
+ React.createElement(Text, { color: "cyan" },
45
+ "Replaying: ",
46
+ filePath)),
47
+ React.createElement(Box, { marginBottom: 1 },
48
+ React.createElement(Text, { dimColor: true }, "─".repeat(40))),
49
+ React.createElement(EventDisplay, { events: events })));
50
+ };
51
+ //# sourceMappingURL=ReplayLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReplayLog.js","sourceRoot":"","sources":["../../src/components/ReplayLog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAS,EAAE,EAAE;IAC/C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAA;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA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I,KAAK,EAAE,CAAC;QACV,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;YACzB,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,IAAE,KAAK,CAAQ,CAC5B,CACP,CAAA;IACH,CAAC;IAED,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACzB,oBAAC,GAAG,IAAC,YAAY,EAAE,CAAC;YAClB,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM;;gBAAa,QAAQ,CAAQ,CAC3C;QACN,oBAAC,GAAG,IAAC,YAAY,EAAE,CAAC;YAClB,oBAAC,IAAI,IAAC,QAAQ,UAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAQ,CAClC;QACN,oBAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,CAC5B,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export declare const StreamingText: ({ content }: Props) => React.JSX.Element;
3
+ type Props = {
4
+ content: string;
5
+ };
6
+ export {};
7
+ //# sourceMappingURL=StreamingText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingText.d.ts","sourceRoot":"","sources":["../../src/components/StreamingText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,aAAa,GAAI,aAAa,KAAK,sBAgC/C,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { Text } from "ink";
3
+ import chalk from "chalk";
4
+ export const StreamingText = ({ content }) => {
5
+ // Process markdown formatting: **bold** and `code`
6
+ // Build a single string with chalk formatting to avoid Ink treating
7
+ // multiple Text components as separate blocks
8
+ let result = "";
9
+ let i = 0;
10
+ let inBold = false;
11
+ let inCode = false;
12
+ while (i < content.length) {
13
+ if (content[i] === "*" && content[i + 1] === "*") {
14
+ inBold = !inBold;
15
+ i += 2;
16
+ }
17
+ else if (content[i] === "`") {
18
+ inCode = !inCode;
19
+ i++;
20
+ }
21
+ else {
22
+ let char = content[i];
23
+ // Apply formatting
24
+ if (inCode) {
25
+ char = chalk.yellow(char);
26
+ }
27
+ else if (inBold) {
28
+ char = chalk.bold(char);
29
+ }
30
+ result += char;
31
+ i++;
32
+ }
33
+ }
34
+ return React.createElement(Text, null, result);
35
+ };
36
+ //# sourceMappingURL=StreamingText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingText.js","sourceRoot":"","sources":["../../src/components/StreamingText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAS,EAAE,EAAE;IAClD,mDAAmD;IACnD,oEAAoE;IACpE,8CAA8C;IAC9C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACjD,MAAM,GAAG,CAAC,MAAM,CAAA;YAChB,CAAC,IAAI,CAAC,CAAA;QACR,CAAC;aAAM,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC9B,MAAM,GAAG,CAAC,MAAM,CAAA;YAChB,CAAC,EAAE,CAAA;QACL,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;YAErB,mBAAmB;YACnB,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC3B,CAAC;iBAAM,IAAI,MAAM,EAAE,CAAC;gBAClB,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC;YAED,MAAM,IAAI,IAAI,CAAA;YACd,CAAC,EAAE,CAAA;QACL,CAAC;IACH,CAAC;IAED,OAAO,oBAAC,IAAI,QAAE,MAAM,CAAQ,CAAA;AAC9B,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StreamingText.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingText.test.d.ts","sourceRoot":"","sources":["../../src/components/StreamingText.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ import React from "react";
2
+ import { describe, it, expect } from "vitest";
3
+ import { render } from "ink-testing-library";
4
+ import { StreamingText } from "./StreamingText.js";
5
+ describe("StreamingText", () => {
6
+ it("renders plain text", () => {
7
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "Hello world" }));
8
+ const output = lastFrame();
9
+ expect(output).toContain("Hello world");
10
+ });
11
+ it("renders bold text", () => {
12
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "This is **bold** text" }));
13
+ const output = lastFrame();
14
+ expect(output).toContain("This is");
15
+ expect(output).toContain("bold");
16
+ expect(output).toContain("text");
17
+ });
18
+ it("renders code text", () => {
19
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "Use `console.log()` to debug" }));
20
+ const output = lastFrame();
21
+ expect(output).toContain("Use");
22
+ expect(output).toContain("console.log()");
23
+ expect(output).toContain("to debug");
24
+ });
25
+ it("renders multiple bold sections", () => {
26
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "**First** and **Second** bold" }));
27
+ const output = lastFrame();
28
+ expect(output).toContain("First");
29
+ expect(output).toContain("and");
30
+ expect(output).toContain("Second");
31
+ expect(output).toContain("bold");
32
+ });
33
+ it("renders multiple code sections", () => {
34
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "`foo` and `bar` are variables" }));
35
+ const output = lastFrame();
36
+ expect(output).toContain("foo");
37
+ expect(output).toContain("and");
38
+ expect(output).toContain("bar");
39
+ expect(output).toContain("are variables");
40
+ });
41
+ it("renders mixed bold and code", () => {
42
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "Use **bold** and `code` together" }));
43
+ const output = lastFrame();
44
+ expect(output).toContain("Use");
45
+ expect(output).toContain("bold");
46
+ expect(output).toContain("and");
47
+ expect(output).toContain("code");
48
+ expect(output).toContain("together");
49
+ });
50
+ it("handles empty string", () => {
51
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "" }));
52
+ const output = lastFrame();
53
+ expect(output).toBe("");
54
+ });
55
+ it("handles unclosed bold markers", () => {
56
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "This has **unclosed bold" }));
57
+ const output = lastFrame();
58
+ expect(output).toContain("This has");
59
+ expect(output).toContain("unclosed bold");
60
+ });
61
+ it("handles unclosed code markers", () => {
62
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "This has `unclosed code" }));
63
+ const output = lastFrame();
64
+ expect(output).toContain("This has");
65
+ expect(output).toContain("unclosed code");
66
+ });
67
+ it("handles text with only bold markers", () => {
68
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "****" }));
69
+ const output = lastFrame();
70
+ expect(output).toBe("");
71
+ });
72
+ it("handles text with only code markers", () => {
73
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "``" }));
74
+ const output = lastFrame();
75
+ expect(output).toBe("");
76
+ });
77
+ it("handles nested-style markers (bold inside code context)", () => {
78
+ const { lastFrame } = render(React.createElement(StreamingText, { content: "`code with **bold** inside`" }));
79
+ const output = lastFrame();
80
+ // Should treat the whole thing as code since it starts with backtick
81
+ expect(output).toContain("code with");
82
+ expect(output).toContain("bold");
83
+ expect(output).toContain("inside");
84
+ });
85
+ });
86
+ //# sourceMappingURL=StreamingText.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingText.test.js","sourceRoot":"","sources":["../../src/components/StreamingText.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,OAAO,EAAC,aAAa,GAAG,CAAC,CAAA;QACrE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,OAAO,EAAC,uBAAuB,GAAG,CAAC,CAAA;QAC/E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,OAAO,EA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C,MAAM,CAAC,CAAA;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ export declare const ToolUse: ({ name, arg }: Props) => React.JSX.Element;
3
+ type Props = {
4
+ name: string;
5
+ arg?: string;
6
+ };
7
+ export {};
8
+ //# sourceMappingURL=ToolUse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolUse.d.ts","sourceRoot":"","sources":["../../src/components/ToolUse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,eAAO,MAAM,OAAO,GAAI,eAAe,KAAK,sBAY3C,CAAA;AAED,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { Box, Text } from "ink";
3
+ export const ToolUse = ({ name, arg }) => {
4
+ return (React.createElement(Box, { paddingLeft: 2 },
5
+ React.createElement(Text, { color: "blue" }, name),
6
+ arg && (React.createElement(React.Fragment, null,
7
+ React.createElement(Text, null, " "),
8
+ React.createElement(Text, { dimColor: true }, arg)))));
9
+ };
10
+ //# sourceMappingURL=ToolUse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolUse.js","sourceRoot":"","sources":["../../src/components/ToolUse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE/B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAS,EAAE,EAAE;IAC9C,OAAO,CACL,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC;QACjB,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,IAAI,CAAQ;QAC/B,GAAG,IAAI,CACN;YACE,oBAAC,IAAI,YAAS;YACd,oBAAC,IAAI,IAAC,QAAQ,UAAE,GAAG,CAAQ,CAC1B,CACJ,CACG,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ToolUse.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolUse.test.d.ts","sourceRoot":"","sources":["../../src/components/ToolUse.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import { describe, it, expect } from "vitest";
3
+ import { render } from "ink-testing-library";
4
+ import { ToolUse } from "./ToolUse.js";
5
+ describe("ToolUse", () => {
6
+ it("renders tool name only when no arg provided", () => {
7
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "Read" }));
8
+ const output = lastFrame();
9
+ expect(output).toContain("Read");
10
+ });
11
+ it("renders tool name and arg when arg provided", () => {
12
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "Read", arg: "src/index.ts" }));
13
+ const output = lastFrame();
14
+ expect(output).toContain("Read");
15
+ expect(output).toContain("src/index.ts");
16
+ });
17
+ it("renders Bash command with $ symbol", () => {
18
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "$", arg: "npm test" }));
19
+ const output = lastFrame();
20
+ expect(output).toContain("$");
21
+ expect(output).toContain("npm test");
22
+ });
23
+ it("renders TodoWrite with formatted list", () => {
24
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "TodoWrite", arg: "\n [ ] Task 1\n [x] Task 2" }));
25
+ const output = lastFrame();
26
+ expect(output).toContain("TodoWrite");
27
+ expect(output).toContain("Task 1");
28
+ expect(output).toContain("Task 2");
29
+ });
30
+ it("renders Grep with pattern", () => {
31
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "Grep", arg: "TODO in src" }));
32
+ const output = lastFrame();
33
+ expect(output).toContain("Grep");
34
+ expect(output).toContain("TODO in src");
35
+ });
36
+ it("renders Glob with pattern", () => {
37
+ const { lastFrame } = render(React.createElement(ToolUse, { name: "Glob", arg: "**/*.ts" }));
38
+ const output = lastFrame();
39
+ expect(output).toContain("Glob");
40
+ expect(output).toContain("**/*.ts");
41
+ });
42
+ });
43
+ //# sourceMappingURL=ToolUse.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolUse.test.js","sourceRoot":"","sources":["../../src/components/ToolUse.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,IAAI,EAAC,MAAM,GAAG,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,IAAI,EAAC,MAAM,EAAC,GAAG,EAAC,cAAc,GAAG,CAAC,CAAA;QACxE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oCA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AAS,EAAE,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,IAAI,EAAC,MAAM,EAAC,GAAG,EAAC,SAAS,GAAG,CAAC,CAAA;QACnE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ export type ContentBlock = {
2
+ type: "text";
3
+ content: string;
4
+ id: string;
5
+ } | {
6
+ type: "tool";
7
+ name: string;
8
+ arg?: string;
9
+ id: string;
10
+ };
11
+ export declare const eventToBlocks: (event: Record<string, unknown>) => ContentBlock[];
12
+ //# sourceMappingURL=eventToBlocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventToBlocks.d.ts","sourceRoot":"","sources":["../../src/components/eventToBlocks.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5D,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,YAAY,EA4I1E,CAAA"}
@@ -0,0 +1,142 @@
1
+ import { rel } from "../lib/rel.js";
2
+ import { shortenTempPaths } from "../lib/shortenTempPaths.js";
3
+ export const eventToBlocks = (event) => {
4
+ if (event.type !== "assistant") {
5
+ return [];
6
+ }
7
+ const message = event.message;
8
+ const content = message?.content;
9
+ if (!content) {
10
+ return [];
11
+ }
12
+ const blocks = [];
13
+ const messageId = message?.id ?? "unknown";
14
+ let blockIndex = 0;
15
+ let textBuffer = ""; // Accumulate consecutive text blocks
16
+ for (const block of content) {
17
+ if (block.type === "text") {
18
+ const text = block.text;
19
+ if (text) {
20
+ textBuffer += text;
21
+ }
22
+ }
23
+ else if (block.type === "tool_use") {
24
+ // Flush accumulated text before processing tool
25
+ if (textBuffer) {
26
+ blocks.push({ type: "text", content: textBuffer, id: `${messageId}-${blockIndex++}` });
27
+ textBuffer = "";
28
+ }
29
+ const input = block.input;
30
+ const name = block.name;
31
+ if (name === "Read") {
32
+ const filePath = input?.file_path;
33
+ if (filePath) {
34
+ blocks.push({
35
+ type: "tool",
36
+ name: "Read",
37
+ arg: rel(filePath),
38
+ id: `${messageId}-${blockIndex++}`,
39
+ });
40
+ }
41
+ }
42
+ else if (name === "Edit" || name === "Write") {
43
+ const filePath = input?.file_path;
44
+ if (filePath) {
45
+ blocks.push({
46
+ type: "tool",
47
+ name,
48
+ arg: rel(filePath),
49
+ id: `${messageId}-${blockIndex++}`,
50
+ });
51
+ }
52
+ }
53
+ else if (name === "Bash") {
54
+ const command = input?.command;
55
+ if (command) {
56
+ blocks.push({
57
+ type: "tool",
58
+ name: "$",
59
+ arg: shortenTempPaths(command),
60
+ id: `${messageId}-${blockIndex++}`,
61
+ });
62
+ }
63
+ }
64
+ else if (name === "Grep") {
65
+ const pattern = input?.pattern;
66
+ const path = input?.path;
67
+ blocks.push({
68
+ type: "tool",
69
+ name: "Grep",
70
+ arg: `${pattern}${path ? ` in ${rel(path)}` : ""}`,
71
+ id: `${messageId}-${blockIndex++}`,
72
+ });
73
+ }
74
+ else if (name === "Glob") {
75
+ const pattern = input?.pattern;
76
+ const path = input?.path;
77
+ blocks.push({
78
+ type: "tool",
79
+ name: "Glob",
80
+ arg: `${pattern}${path ? ` in ${rel(path)}` : ""}`,
81
+ id: `${messageId}-${blockIndex++}`,
82
+ });
83
+ }
84
+ else if (name === "TodoWrite") {
85
+ const todos = input?.todos;
86
+ if (todos?.length) {
87
+ const summary = todos
88
+ .map(t => `[${t.status === "completed" ? "x"
89
+ : t.status === "in_progress" ? "~"
90
+ : " "}] ${t.content}`)
91
+ .join("\n ");
92
+ blocks.push({
93
+ type: "tool",
94
+ name: "TodoWrite",
95
+ arg: "\n " + summary,
96
+ id: `${messageId}-${blockIndex++}`,
97
+ });
98
+ }
99
+ else {
100
+ blocks.push({ type: "tool", name: "TodoWrite", id: `${messageId}-${blockIndex++}` });
101
+ }
102
+ }
103
+ else if (name === "WebFetch") {
104
+ const url = input?.url;
105
+ blocks.push({
106
+ type: "tool",
107
+ name: "WebFetch",
108
+ arg: url,
109
+ id: `${messageId}-${blockIndex++}`,
110
+ });
111
+ }
112
+ else if (name === "WebSearch") {
113
+ const query = input?.query;
114
+ blocks.push({
115
+ type: "tool",
116
+ name: "WebSearch",
117
+ arg: query,
118
+ id: `${messageId}-${blockIndex++}`,
119
+ });
120
+ }
121
+ else if (name === "Task") {
122
+ const description = input?.description;
123
+ blocks.push({
124
+ type: "tool",
125
+ name: "Task",
126
+ arg: description,
127
+ id: `${messageId}-${blockIndex++}`,
128
+ });
129
+ }
130
+ else if (name === "Skill") {
131
+ const skill = input?.skill;
132
+ blocks.push({ type: "tool", name: "Skill", arg: skill, id: `${messageId}-${blockIndex++}` });
133
+ }
134
+ }
135
+ }
136
+ // Flush any remaining text at the end
137
+ if (textBuffer) {
138
+ blocks.push({ type: "text", content: textBuffer, id: `${messageId}-${blockIndex++}` });
139
+ }
140
+ return blocks;
141
+ };
142
+ //# sourceMappingURL=eventToBlocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventToBlocks.js","sourceRoot":"","sources":["../../src/components/eventToBlocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAM7D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,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E,KAAK,EAAE,EAAE,EAAE,GAAG,SAAS,IAAI,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;IAED,sCAAsC;IACtC,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,SAAS,IAAI,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;IACxF,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=eventToBlocks.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventToBlocks.test.d.ts","sourceRoot":"","sources":["../../src/components/eventToBlocks.test.ts"],"names":[],"mappings":""}