@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.
- package/README.md +1 -1
- package/bin/ralph.js +1 -1
- package/dist/cli.d.ts +2 -19
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +30 -65
- package/dist/cli.js.map +1 -1
- package/dist/components/App.d.ts +10 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/App.js +16 -0
- package/dist/components/App.js.map +1 -0
- package/dist/components/EventDisplay.d.ts +7 -0
- package/dist/components/EventDisplay.d.ts.map +1 -0
- package/dist/components/EventDisplay.js +64 -0
- package/dist/components/EventDisplay.js.map +1 -0
- package/dist/components/EventDisplay.replay.test.d.ts +2 -0
- package/dist/components/EventDisplay.replay.test.d.ts.map +1 -0
- package/dist/components/EventDisplay.replay.test.js +403 -0
- package/dist/components/EventDisplay.replay.test.js.map +1 -0
- package/dist/components/EventDisplay.test.d.ts +2 -0
- package/dist/components/EventDisplay.test.d.ts.map +1 -0
- package/dist/components/EventDisplay.test.js +223 -0
- package/dist/components/EventDisplay.test.js.map +1 -0
- package/dist/components/Header.d.ts +8 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +15 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/Header.test.d.ts +2 -0
- package/dist/components/Header.test.d.ts.map +1 -0
- package/dist/components/Header.test.js +27 -0
- package/dist/components/Header.test.js.map +1 -0
- package/dist/components/InitRalph.d.ts +3 -0
- package/dist/components/InitRalph.d.ts.map +1 -0
- package/dist/components/InitRalph.js +100 -0
- package/dist/components/InitRalph.js.map +1 -0
- package/dist/components/IterationRunner.d.ts +7 -0
- package/dist/components/IterationRunner.d.ts.map +1 -0
- package/dist/components/IterationRunner.js +285 -0
- package/dist/components/IterationRunner.js.map +1 -0
- package/dist/components/IterationRunner.test.d.ts +2 -0
- package/dist/components/IterationRunner.test.d.ts.map +1 -0
- package/dist/components/IterationRunner.test.js +109 -0
- package/dist/components/IterationRunner.test.js.map +1 -0
- package/dist/components/ReplayLog.d.ts +7 -0
- package/dist/components/ReplayLog.d.ts.map +1 -0
- package/dist/components/ReplayLog.js +51 -0
- package/dist/components/ReplayLog.js.map +1 -0
- package/dist/components/StreamingText.d.ts +7 -0
- package/dist/components/StreamingText.d.ts.map +1 -0
- package/dist/components/StreamingText.js +36 -0
- package/dist/components/StreamingText.js.map +1 -0
- package/dist/components/StreamingText.test.d.ts +2 -0
- package/dist/components/StreamingText.test.d.ts.map +1 -0
- package/dist/components/StreamingText.test.js +86 -0
- package/dist/components/StreamingText.test.js.map +1 -0
- package/dist/components/ToolUse.d.ts +8 -0
- package/dist/components/ToolUse.d.ts.map +1 -0
- package/dist/components/ToolUse.js +10 -0
- package/dist/components/ToolUse.js.map +1 -0
- package/dist/components/ToolUse.test.d.ts +2 -0
- package/dist/components/ToolUse.test.d.ts.map +1 -0
- package/dist/components/ToolUse.test.js +43 -0
- package/dist/components/ToolUse.test.js.map +1 -0
- package/dist/components/eventToBlocks.d.ts +12 -0
- package/dist/components/eventToBlocks.d.ts.map +1 -0
- package/dist/components/eventToBlocks.js +142 -0
- package/dist/components/eventToBlocks.js.map +1 -0
- package/dist/components/eventToBlocks.test.d.ts +2 -0
- package/dist/components/eventToBlocks.test.d.ts.map +1 -0
- package/dist/components/eventToBlocks.test.js +412 -0
- package/dist/components/eventToBlocks.test.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/cleanupAllWorktrees.d.ts +5 -0
- package/dist/lib/cleanupAllWorktrees.d.ts.map +1 -0
- package/dist/lib/cleanupAllWorktrees.js +25 -0
- package/dist/lib/cleanupAllWorktrees.js.map +1 -0
- package/dist/lib/cleanupWorktree.d.ts +6 -0
- package/dist/lib/cleanupWorktree.d.ts.map +1 -0
- package/dist/lib/cleanupWorktree.js +33 -0
- package/dist/lib/cleanupWorktree.js.map +1 -0
- package/dist/lib/copyRalphFilesFromWorktree.d.ts +5 -0
- package/dist/lib/copyRalphFilesFromWorktree.d.ts.map +1 -0
- package/dist/lib/copyRalphFilesFromWorktree.js +19 -0
- package/dist/lib/copyRalphFilesFromWorktree.js.map +1 -0
- package/dist/lib/copyRalphFilesToWorktree.d.ts +5 -0
- package/dist/lib/copyRalphFilesToWorktree.d.ts.map +1 -0
- package/dist/lib/copyRalphFilesToWorktree.js +21 -0
- package/dist/lib/copyRalphFilesToWorktree.js.map +1 -0
- package/dist/lib/createWorktree.d.ts +6 -0
- package/dist/lib/createWorktree.d.ts.map +1 -0
- package/dist/lib/createWorktree.js +34 -0
- package/dist/lib/createWorktree.js.map +1 -0
- package/dist/lib/getClaudeVersion.d.ts +2 -0
- package/dist/lib/getClaudeVersion.d.ts.map +1 -0
- package/dist/lib/getClaudeVersion.js +17 -0
- package/dist/lib/getClaudeVersion.js.map +1 -0
- package/dist/lib/getClaudeVersion.test.d.ts +2 -0
- package/dist/lib/getClaudeVersion.test.d.ts.map +1 -0
- package/dist/lib/getClaudeVersion.test.js +39 -0
- package/dist/lib/getClaudeVersion.test.js.map +1 -0
- package/dist/lib/getGitRoot.d.ts +5 -0
- package/dist/lib/getGitRoot.d.ts.map +1 -0
- package/dist/lib/getGitRoot.js +18 -0
- package/dist/lib/getGitRoot.js.map +1 -0
- package/dist/lib/installDependencies.d.ts +5 -0
- package/dist/lib/installDependencies.d.ts.map +1 -0
- package/dist/lib/installDependencies.js +23 -0
- package/dist/lib/installDependencies.js.map +1 -0
- package/dist/lib/installDependencies.test.d.ts +2 -0
- package/dist/lib/installDependencies.test.d.ts.map +1 -0
- package/dist/lib/installDependencies.test.js +37 -0
- package/dist/lib/installDependencies.test.js.map +1 -0
- package/dist/lib/mergeWorktreeToMain.d.ts +6 -0
- package/dist/lib/mergeWorktreeToMain.d.ts.map +1 -0
- package/dist/lib/mergeWorktreeToMain.js +44 -0
- package/dist/lib/mergeWorktreeToMain.js.map +1 -0
- package/dist/lib/popStash.d.ts +5 -0
- package/dist/lib/popStash.d.ts.map +1 -0
- package/dist/lib/popStash.js +17 -0
- package/dist/lib/popStash.js.map +1 -0
- package/dist/lib/rel.test.d.ts +2 -0
- package/dist/lib/rel.test.d.ts.map +1 -0
- package/dist/lib/rel.test.js +36 -0
- package/dist/lib/rel.test.js.map +1 -0
- package/dist/lib/replayLog.d.ts.map +1 -1
- package/dist/lib/replayLog.js +20 -6
- package/dist/lib/replayLog.js.map +1 -1
- package/dist/lib/runIteration.d.ts.map +1 -1
- package/dist/lib/runIteration.js +19 -9
- package/dist/lib/runIteration.js.map +1 -1
- package/dist/lib/shortenTempPaths.test.d.ts +2 -0
- package/dist/lib/shortenTempPaths.test.d.ts.map +1 -0
- package/dist/lib/shortenTempPaths.test.js +46 -0
- package/dist/lib/shortenTempPaths.test.js.map +1 -0
- package/dist/lib/signalHandler.d.ts +3 -0
- package/dist/lib/signalHandler.d.ts.map +1 -0
- package/dist/lib/signalHandler.js +19 -0
- package/dist/lib/signalHandler.js.map +1 -0
- package/dist/lib/stashChanges.d.ts +6 -0
- package/dist/lib/stashChanges.d.ts.map +1 -0
- package/dist/lib/stashChanges.js +27 -0
- package/dist/lib/stashChanges.js.map +1 -0
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +5 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/worktree.d.ts +43 -0
- package/dist/lib/worktree.d.ts.map +1 -0
- package/dist/lib/worktree.js +210 -0
- package/dist/lib/worktree.js.map +1 -0
- package/dist/ui/EventProcessor.d.ts +11 -0
- package/dist/ui/EventProcessor.d.ts.map +1 -0
- package/dist/ui/EventProcessor.js +95 -0
- package/dist/ui/EventProcessor.js.map +1 -0
- package/dist/ui/IterationApp.d.ts +10 -0
- package/dist/ui/IterationApp.d.ts.map +1 -0
- package/dist/ui/IterationApp.js +21 -0
- package/dist/ui/IterationApp.js.map +1 -0
- package/dist/ui/IterationUI.d.ts +13 -0
- package/dist/ui/IterationUI.d.ts.map +1 -0
- package/dist/ui/IterationUI.js +19 -0
- package/dist/ui/IterationUI.js.map +1 -0
- package/dist/ui/TextDisplay.d.ts +7 -0
- package/dist/ui/TextDisplay.d.ts.map +1 -0
- package/dist/ui/TextDisplay.js +41 -0
- package/dist/ui/TextDisplay.js.map +1 -0
- package/dist/ui/ToolUseDisplay.d.ts +10 -0
- package/dist/ui/ToolUseDisplay.d.ts.map +1 -0
- package/dist/ui/ToolUseDisplay.js +10 -0
- package/dist/ui/ToolUseDisplay.js.map +1 -0
- package/package.json +23 -4
- package/templates/progress.md +1 -1
- package/templates/prompt.md +11 -1
- package/templates/todo.md +0 -1
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ Ralph is a thin wrapper around the Claude CLI that:
|
|
|
133
133
|
2. **Captures output** as streaming JSON events
|
|
134
134
|
3. **Processes events** to display tool usage (Read, Edit, Bash, etc.) in a readable format
|
|
135
135
|
4. **Logs everything** to `events.log` for replay and debugging
|
|
136
|
-
5. **Detects completion** when Claude outputs `<
|
|
136
|
+
5. **Detects completion** when Claude outputs `<promise>COMPLETE</promise>`
|
|
137
137
|
6. **Recursively runs** next iteration until count reached or todo list complete
|
|
138
138
|
|
|
139
139
|
## Requirements
|
package/bin/ralph.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import(
|
|
2
|
+
import("../dist/index.js").then(m => m.run())
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
replayFile?: undefined;
|
|
4
|
-
iterations?: undefined;
|
|
5
|
-
} | {
|
|
6
|
-
mode: "init";
|
|
7
|
-
replayFile?: undefined;
|
|
8
|
-
iterations?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
mode: "replay";
|
|
11
|
-
replayFile: string;
|
|
12
|
-
iterations?: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
mode: "run";
|
|
15
|
-
iterations: number;
|
|
16
|
-
replayFile?: undefined;
|
|
17
|
-
};
|
|
18
|
-
export declare const showHelp: () => void;
|
|
19
|
-
export declare const initRalph: () => void;
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export declare const program: Command;
|
|
20
3
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,eAAO,MAAM,OAAO,SAkBhB,CAAA"}
|
package/dist/cli.js
CHANGED
|
@@ -1,66 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.log(" ralph Run 10 iterations");
|
|
32
|
-
console.log(" ralph 5 Run 5 iterations");
|
|
33
|
-
console.log(" ralph init Create .ralph directory");
|
|
34
|
-
console.log(" ralph --replay Replay default log file");
|
|
35
|
-
console.log(" ralph --replay custom.log Replay custom log file\n");
|
|
36
|
-
};
|
|
37
|
-
export const initRalph = () => {
|
|
38
|
-
const ralphDir = join(process.cwd(), ".ralph");
|
|
39
|
-
if (existsSync(ralphDir)) {
|
|
40
|
-
console.log(chalk.yellow("⚠️ .ralph directory already exists"));
|
|
41
|
-
console.log(chalk.dim("To reinitialize, remove the directory first: rm -rf .ralph"));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
console.log(chalk.cyan("Initializing ralph..."));
|
|
45
|
-
mkdirSync(ralphDir, { recursive: true });
|
|
46
|
-
// Copy templates from package installation
|
|
47
|
-
const templatesDir = join(__dirname, "..", "templates");
|
|
48
|
-
const templates = ["prompt.md", "todo.md", "progress.md"];
|
|
49
|
-
for (const template of templates) {
|
|
50
|
-
const src = join(templatesDir, template);
|
|
51
|
-
const dest = join(ralphDir, template);
|
|
52
|
-
if (existsSync(src)) {
|
|
53
|
-
copyFileSync(src, dest);
|
|
54
|
-
console.log(chalk.green("✓") + ` Created ${chalk.dim(".ralph/" + template)}`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
console.error(chalk.red("✗") + ` Template not found: ${template}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
console.log(chalk.green("\n✓ Ralph initialized successfully!"));
|
|
61
|
-
console.log(chalk.dim("\nNext steps:"));
|
|
62
|
-
console.log(chalk.dim(" 1. Customize .ralph/prompt.md with your project's workflow"));
|
|
63
|
-
console.log(chalk.dim(" 2. Add tasks to .ralph/todo.md"));
|
|
64
|
-
console.log(chalk.dim(" 3. Run: ralph\n"));
|
|
65
|
-
};
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { render } from "ink";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { App } from "./components/App.js";
|
|
6
|
+
import { InitRalph } from "./components/InitRalph.js";
|
|
7
|
+
import { getClaudeVersion } from "./lib/getClaudeVersion.js";
|
|
8
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
9
|
+
export const program = new Command()
|
|
10
|
+
.name("ralph")
|
|
11
|
+
.description("Autonomous AI iteration engine for Claude CLI")
|
|
12
|
+
.version(packageJson.version)
|
|
13
|
+
.argument("[iterations]", "number of iterations to run", val => parseInt(val, 10), 10)
|
|
14
|
+
.option("--replay [file]", "replay events from log file")
|
|
15
|
+
.action((iterations, options) => {
|
|
16
|
+
const replayFile = options.replay !== undefined ?
|
|
17
|
+
typeof options.replay === "string" ?
|
|
18
|
+
options.replay
|
|
19
|
+
: join(process.cwd(), ".ralph", "events.log")
|
|
20
|
+
: undefined;
|
|
21
|
+
const claudeVersion = getClaudeVersion();
|
|
22
|
+
const ralphVersion = packageJson.version;
|
|
23
|
+
render(React.createElement(App, { iterations, replayFile, claudeVersion, ralphVersion }));
|
|
24
|
+
});
|
|
25
|
+
program
|
|
26
|
+
.command("init")
|
|
27
|
+
.description("initialize .ralph directory with templates")
|
|
28
|
+
.action(() => {
|
|
29
|
+
render(React.createElement(InitRalph));
|
|
30
|
+
});
|
|
66
31
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;KACjC,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,+CAA+C,CAAC;KAC5D,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5B,QAAQ,CAAC,cAAc,EAAE,6BAA6B,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;KACrF,MAAM,CAAC,iBAAiB,EAAE,6BAA6B,CAAC;KACxD,MAAM,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE;IAC9B,MAAM,UAAU,GACd,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QAC5B,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;YAClC,OAAO,CAAC,MAAM;YAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC;QAC/C,CAAC,CAAC,SAAS,CAAA;IAEb,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAA;IAExC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC,CAAC,CAAA;AAEJ,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4CAA4C,CAAC;KACzD,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AACxC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const App: ({ iterations, replayFile, claudeVersion, ralphVersion }: Props) => React.JSX.Element;
|
|
3
|
+
type Props = {
|
|
4
|
+
iterations: number;
|
|
5
|
+
replayFile?: string;
|
|
6
|
+
claudeVersion: string;
|
|
7
|
+
ralphVersion: string;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=App.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,eAAO,MAAM,GAAG,GAAI,yDAAyD,KAAK,sBAgBjF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import { Header } from "./Header.js";
|
|
4
|
+
import { IterationRunner } from "./IterationRunner.js";
|
|
5
|
+
import { ReplayLog } from "./ReplayLog.js";
|
|
6
|
+
export const App = ({ iterations, replayFile, claudeVersion, ralphVersion }) => {
|
|
7
|
+
if (replayFile) {
|
|
8
|
+
return (React.createElement(Box, { flexDirection: "column", marginX: 1 },
|
|
9
|
+
React.createElement(Header, { claudeVersion: claudeVersion, ralphVersion: ralphVersion }),
|
|
10
|
+
React.createElement(ReplayLog, { filePath: replayFile })));
|
|
11
|
+
}
|
|
12
|
+
return (React.createElement(Box, { flexDirection: "column", marginX: 1 },
|
|
13
|
+
React.createElement(Header, { claudeVersion: claudeVersion, ralphVersion: ralphVersion }),
|
|
14
|
+
React.createElement(IterationRunner, { totalIterations: iterations })));
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAS,EAAE,EAAE;IACpF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC;YACpC,oBAAC,MAAM,IAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAI;YACpE,oBAAC,SAAS,IAAC,QAAQ,EAAE,UAAU,GAAI,CAC/B,CACP,CAAA;IACH,CAAC;IAED,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC;QACpC,oBAAC,MAAM,IAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAI;QACpE,oBAAC,eAAe,IAAC,eAAe,EAAE,UAAU,GAAI,CAC5C,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventDisplay.d.ts","sourceRoot":"","sources":["../../src/components/EventDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAMlD,eAAO,MAAM,YAAY,GAAI,YAAY,KAAK,sBAuE7C,CAAA;AAED,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACvC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import { StreamingText } from "./StreamingText.js";
|
|
4
|
+
import { ToolUse } from "./ToolUse.js";
|
|
5
|
+
import { eventToBlocks } from "./eventToBlocks.js";
|
|
6
|
+
export const EventDisplay = ({ events }) => {
|
|
7
|
+
const [contentBlocks, setContentBlocks] = useState([]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
// Filter to only show complete assistant messages, not streaming events
|
|
10
|
+
// streaming events are incomplete and cause duplicate/disappearing content
|
|
11
|
+
const assistantEvents = events.filter(event => event.type === "assistant");
|
|
12
|
+
// Group by message ID and merge content from all versions
|
|
13
|
+
// The Claude CLI sends multiple snapshots of the same message as it builds up
|
|
14
|
+
const messageMap = new Map();
|
|
15
|
+
for (const event of assistantEvents) {
|
|
16
|
+
const message = event.message;
|
|
17
|
+
const messageId = message?.id;
|
|
18
|
+
const content = message?.content;
|
|
19
|
+
if (messageId && content) {
|
|
20
|
+
if (!messageMap.has(messageId)) {
|
|
21
|
+
messageMap.set(messageId, []);
|
|
22
|
+
}
|
|
23
|
+
// Collect all content blocks from all versions
|
|
24
|
+
messageMap.get(messageId).push(...content);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Create merged events with all content
|
|
28
|
+
const mergedEvents = Array.from(messageMap.entries()).map(([messageId, allContent]) => {
|
|
29
|
+
// Deduplicate content blocks by their ID (for tool_use) or text (for text blocks)
|
|
30
|
+
const seenBlocks = new Set();
|
|
31
|
+
const uniqueContent = [];
|
|
32
|
+
for (const block of allContent) {
|
|
33
|
+
const blockType = block.type;
|
|
34
|
+
let blockKey;
|
|
35
|
+
if (blockType === "tool_use") {
|
|
36
|
+
blockKey = block.id;
|
|
37
|
+
}
|
|
38
|
+
else if (blockType === "text") {
|
|
39
|
+
blockKey = `text:${block.text}`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
blockKey = JSON.stringify(block);
|
|
43
|
+
}
|
|
44
|
+
if (!seenBlocks.has(blockKey)) {
|
|
45
|
+
seenBlocks.add(blockKey);
|
|
46
|
+
uniqueContent.push(block);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
type: "assistant",
|
|
51
|
+
message: {
|
|
52
|
+
id: messageId,
|
|
53
|
+
content: uniqueContent,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const blocks = mergedEvents.flatMap(event => eventToBlocks(event));
|
|
58
|
+
setContentBlocks(blocks);
|
|
59
|
+
}, [events]);
|
|
60
|
+
return (React.createElement(Box, { flexDirection: "column", gap: 1 }, contentBlocks.map(block => block.type === "text" ?
|
|
61
|
+
React.createElement(StreamingText, { key: block.id, content: block.content })
|
|
62
|
+
: React.createElement(ToolUse, { key: block.id, name: block.name, arg: block.arg }))));
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=EventDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventDisplay.js","sourceRoot":"","sources":["../../src/components/EventDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAS,EAAE,EAAE;IAChD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAA;IAEtE,SAAS,CAAC,GAAG,EAAE;QACb,wEAAwE;QACxE,2EAA2E;QAC3E,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;QAE1E,0DAA0D;QAC1D,8EAA8E;QAC9E,MAAM,UA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