@herbcaudill/ralph 0.2.0 → 0.4.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/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 +286 -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 +18 -8
- 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 +23 -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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import BigText from "ink-big-text";
|
|
4
|
+
import Gradient from "ink-gradient";
|
|
5
|
+
export const Header = ({ claudeVersion, ralphVersion }) => {
|
|
6
|
+
return (React.createElement(Box, { flexDirection: "column", marginBottom: 1, borderStyle: "single", padding: 1, alignItems: "center" },
|
|
7
|
+
React.createElement(Gradient, { colors: ["#30A6E4", "#EBC635"] },
|
|
8
|
+
React.createElement(BigText, { text: "Ralph", font: "tiny" })),
|
|
9
|
+
React.createElement(Text, { dimColor: true },
|
|
10
|
+
"@herbcaudill/ralph v",
|
|
11
|
+
ralphVersion,
|
|
12
|
+
" \u2022 Claude Code v",
|
|
13
|
+
claudeVersion)));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,QAAQ,MAAM,cAAc,CAAA;AAEnC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,aAAa,EAAE,YAAY,EAAS,EAAE,EAAE;IAC/D,OAAO,CACL,oBAAC,GAAG,IACF,aAAa,EAAC,QAAQ,EACtB,YAAY,EAAE,CAAC,EACf,WAAW,EAAC,QAAQ,EACpB,OAAO,EAAE,CAAC,EACV,UAAU,EAAC,QAAQ;QAEnB,oBAAC,QAAQ,IAAC,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;YACtC,oBAAC,OAAO,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,MAAM,GAAG,CAC3B;QACX,oBAAC,IAAI,IAAC,QAAQ;;YACS,YAAY;;YAAkB,aAAa,CAC3D,CACH,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.test.d.ts","sourceRoot":"","sources":["../../src/components/Header.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import { render } from "ink-testing-library";
|
|
4
|
+
import { Header } from "./Header.js";
|
|
5
|
+
describe("Header", () => {
|
|
6
|
+
it("renders the title", () => {
|
|
7
|
+
const { lastFrame } = render(React.createElement(Header, { claudeVersion: "1.0.0", ralphVersion: "0.2.0" }));
|
|
8
|
+
const output = lastFrame();
|
|
9
|
+
// BigText renders ASCII art with ANSI codes
|
|
10
|
+
// Check for box-drawing characters or unicode that appear in the art
|
|
11
|
+
expect(output?.length).toBeGreaterThan(0);
|
|
12
|
+
expect(output).toContain("Claude Code");
|
|
13
|
+
});
|
|
14
|
+
it("displays both version numbers on the same line", () => {
|
|
15
|
+
const { lastFrame } = render(React.createElement(Header, { claudeVersion: "2.5.3", ralphVersion: "0.2.0" }));
|
|
16
|
+
const output = lastFrame();
|
|
17
|
+
expect(output).toContain("@herbcaudill/ralph v0.2.0");
|
|
18
|
+
expect(output).toContain("Claude Code v2.5.3");
|
|
19
|
+
expect(output).toContain("•");
|
|
20
|
+
});
|
|
21
|
+
it("displays versions with correct formatting", () => {
|
|
22
|
+
const { lastFrame } = render(React.createElement(Header, { claudeVersion: "1.0.0", ralphVersion: "0.1.0" }));
|
|
23
|
+
const output = lastFrame();
|
|
24
|
+
expect(output).toContain("@herbcaudill/ralph v0.1.0 • Claude Code v1.0.0");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=Header.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.test.js","sourceRoot":"","sources":["../../src/components/Header.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,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,aAAa,EAAC,OAAO,EAAC,YAAY,EAAC,OAAO,GAAG,CAAC,CAAA;QACnF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,4CAA4C;QAC5C,qEAAqE;QACrE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,aAAa,EAAC,OAAO,EAAC,YAAY,EAAC,OAAO,GAAG,CAAC,CAAA;QACnF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAA;QACrD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAA;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,aAAa,EAAC,OAAO,EAAC,YAAY,EAAC,OAAO,GAAG,CAAC,CAAA;QACnF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gDAAgD,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitRalph.d.ts","sourceRoot":"","sources":["../../src/components/InitRalph.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,eAAO,MAAM,SAAS,yBA+GrB,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Text, Box } from "ink";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { existsSync, mkdirSync, copyFileSync } from "fs";
|
|
4
|
+
import { join, dirname } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
export const InitRalph = () => {
|
|
8
|
+
const [status, setStatus] = useState("checking");
|
|
9
|
+
const [createdFiles, setCreatedFiles] = useState([]);
|
|
10
|
+
const [errors, setErrors] = useState([]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const initialize = async () => {
|
|
13
|
+
const ralphDir = join(process.cwd(), ".ralph");
|
|
14
|
+
const templatesDir = join(__dirname, "..", "..", "templates");
|
|
15
|
+
const templates = ["prompt.md", "todo.md", "progress.md"];
|
|
16
|
+
// Check if .ralph exists and all files are present
|
|
17
|
+
if (existsSync(ralphDir)) {
|
|
18
|
+
const allFilesExist = templates.every(template => existsSync(join(ralphDir, template)));
|
|
19
|
+
if (allFilesExist) {
|
|
20
|
+
setStatus("exists");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// If not all files exist, continue to create missing ones
|
|
24
|
+
}
|
|
25
|
+
setStatus("creating");
|
|
26
|
+
try {
|
|
27
|
+
mkdirSync(ralphDir, { recursive: true });
|
|
28
|
+
const created = [];
|
|
29
|
+
const failed = [];
|
|
30
|
+
for (const template of templates) {
|
|
31
|
+
const src = join(templatesDir, template);
|
|
32
|
+
const dest = join(ralphDir, template);
|
|
33
|
+
// Only copy if the destination doesn't exist
|
|
34
|
+
if (!existsSync(dest)) {
|
|
35
|
+
if (existsSync(src)) {
|
|
36
|
+
copyFileSync(src, dest);
|
|
37
|
+
created.push(template);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
failed.push(`Template not found: ${template}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
setCreatedFiles(created);
|
|
45
|
+
setErrors(failed);
|
|
46
|
+
setStatus("done");
|
|
47
|
+
// Exit after a brief delay so user can see success message
|
|
48
|
+
setTimeout(() => process.exit(0), 100);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
setErrors([`Failed to initialize: ${error}`]);
|
|
52
|
+
setStatus("done");
|
|
53
|
+
setTimeout(() => process.exit(1), 100);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
initialize();
|
|
57
|
+
}, []);
|
|
58
|
+
if (status === "checking") {
|
|
59
|
+
return React.createElement(Text, null, "Checking .ralph directory...");
|
|
60
|
+
}
|
|
61
|
+
if (status === "exists") {
|
|
62
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
63
|
+
React.createElement(Text, { color: "yellow" }, "\u26A0\uFE0F .ralph directory already exists"),
|
|
64
|
+
React.createElement(Text, { dimColor: true }, "To reinitialize, remove the directory first: rm -rf .ralph")));
|
|
65
|
+
}
|
|
66
|
+
if (status === "creating") {
|
|
67
|
+
return React.createElement(Text, { color: "cyan" }, "Initializing ralph...");
|
|
68
|
+
}
|
|
69
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
70
|
+
createdFiles.map(file => (React.createElement(Text, { key: file },
|
|
71
|
+
React.createElement(Text, { color: "green" }, "\u2713"),
|
|
72
|
+
" Created ",
|
|
73
|
+
React.createElement(Text, { dimColor: true },
|
|
74
|
+
".ralph/",
|
|
75
|
+
file)))),
|
|
76
|
+
errors.map((error, i) => (React.createElement(Text, { key: i },
|
|
77
|
+
React.createElement(Text, { color: "red" }, "\u2717"),
|
|
78
|
+
" ",
|
|
79
|
+
error))),
|
|
80
|
+
errors.length === 0 && (React.createElement(React.Fragment, null,
|
|
81
|
+
React.createElement(Text, { color: "green" },
|
|
82
|
+
"\n",
|
|
83
|
+
"\u2713 Ralph initialized successfully!"),
|
|
84
|
+
React.createElement(Text, { bold: true },
|
|
85
|
+
"\n",
|
|
86
|
+
"Before running ralph, you need to:"),
|
|
87
|
+
React.createElement(Text, null,
|
|
88
|
+
React.createElement(Text, { color: "cyan" }, " 1. Edit .ralph/prompt.md"),
|
|
89
|
+
React.createElement(Text, { dimColor: true }, " - Add your project context and workflow instructions")),
|
|
90
|
+
React.createElement(Text, null,
|
|
91
|
+
React.createElement(Text, { color: "cyan" }, " 2. Edit .ralph/todo.md"),
|
|
92
|
+
React.createElement(Text, { dimColor: true }, " - Add the tasks you want Ralph to work on")),
|
|
93
|
+
React.createElement(Text, null,
|
|
94
|
+
React.createElement(Text, { bold: true },
|
|
95
|
+
"\n",
|
|
96
|
+
"Then run: "),
|
|
97
|
+
React.createElement(Text, { color: "cyan" }, "ralph"),
|
|
98
|
+
"\n")))));
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=InitRalph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitRalph.js","sourceRoot":"","sources":["../../src/components/InitRalph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA8C,UAAU,CAAC,CAAA;IAC7F,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAA;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;YAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;YAC7D,MAAM,SAAS,GAAG,CAAC,WAAW,EAA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AG,EAAE,CAAC;YACV,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,aAAS;;YAAE,KAAK,CAC5B,CACR,CAAC;QACD,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CACtB;YACE,oBAAC,IAAI,IAAC,KAAK,EAAC,OAAO;gBAAE,IAAI;yDAAyC;YAClE,oBAAC,IAAI,IAAC,IAAI;gBAAE,IAAI;qDAA0C;YAC1D,oBAAC,IAAI;gBACH,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,gCAAiC;gBACnD,oBAAC,IAAI,IAAC,QAAQ,kEAA6D,CACtE;YACP,oBAAC,IAAI;gBACH,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,8BAA+B;gBACjD,oBAAC,IAAI,IAAC,QAAQ,uDAAkD,CAC3D;YACP,oBAAC,IAAI;gBACH,oBAAC,IAAI,IAAC,IAAI;oBAAE,IAAI;iCAAkB;gBAClC,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAAa;gBAC9B,IAAI,CACA,CACN,CACJ,CACG,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IterationRunner.d.ts","sourceRoot":"","sources":["../../src/components/IterationRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AA6B1D,eAAO,MAAM,eAAe,GAAI,qBAAqB,KAAK,sBAuTzD,CAAA;AAED,KAAK,KAAK,GAAG;IACX,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
2
|
+
import { Box, Text, useApp } from "ink";
|
|
3
|
+
import SelectInput from "ink-select-input";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import { execa } from "execa";
|
|
6
|
+
import { appendFileSync, mkdirSync, existsSync } from "fs";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
import { EventDisplay } from "./EventDisplay.js";
|
|
9
|
+
import { getGitRoot } from "../lib/getGitRoot.js";
|
|
10
|
+
import { stashChanges } from "../lib/stashChanges.js";
|
|
11
|
+
import { popStash } from "../lib/popStash.js";
|
|
12
|
+
import { createWorktree } from "../lib/createWorktree.js";
|
|
13
|
+
import { copyRalphFilesToWorktree } from "../lib/copyRalphFilesToWorktree.js";
|
|
14
|
+
import { copyRalphFilesFromWorktree } from "../lib/copyRalphFilesFromWorktree.js";
|
|
15
|
+
import { mergeWorktreeToMain } from "../lib/mergeWorktreeToMain.js";
|
|
16
|
+
import { cleanupWorktree } from "../lib/cleanupWorktree.js";
|
|
17
|
+
import { installDependencies } from "../lib/installDependencies.js";
|
|
18
|
+
import { registerCleanup, unregisterCleanup } from "../lib/signalHandler.js";
|
|
19
|
+
const repoRoot = process.cwd();
|
|
20
|
+
const ralphDir = join(repoRoot, ".ralph");
|
|
21
|
+
const checkRequiredFiles = () => {
|
|
22
|
+
const requiredFiles = ["prompt.md", "todo.md", "progress.md"];
|
|
23
|
+
const missing = requiredFiles.filter(file => !existsSync(join(ralphDir, file)));
|
|
24
|
+
return { missing, exists: missing.length === 0 };
|
|
25
|
+
};
|
|
26
|
+
export const IterationRunner = ({ totalIterations }) => {
|
|
27
|
+
const { exit } = useApp();
|
|
28
|
+
const [currentIteration, setCurrentIteration] = useState(1);
|
|
29
|
+
const [events, setEvents] = useState([]);
|
|
30
|
+
const [output, setOutput] = useState("");
|
|
31
|
+
const [error, setError] = useState();
|
|
32
|
+
const [needsInit, setNeedsInit] = useState(null);
|
|
33
|
+
const [initializing, setInitializing] = useState(false);
|
|
34
|
+
// Use refs for worktree/stash state to avoid triggering effect re-runs
|
|
35
|
+
const currentWorktreeRef = useRef(null);
|
|
36
|
+
const hasStashedChangesRef = useRef(false);
|
|
37
|
+
const childProcessRef = useRef(null);
|
|
38
|
+
// Only use input handling if stdin supports raw mode
|
|
39
|
+
const stdinSupportsRawMode = process.stdin.isTTY === true;
|
|
40
|
+
// Cleanup function for worktrees and stash
|
|
41
|
+
const cleanup = () => {
|
|
42
|
+
try {
|
|
43
|
+
if (currentWorktreeRef.current) {
|
|
44
|
+
const gitRoot = getGitRoot(repoRoot);
|
|
45
|
+
cleanupWorktree(gitRoot, currentWorktreeRef.current);
|
|
46
|
+
currentWorktreeRef.current = null;
|
|
47
|
+
}
|
|
48
|
+
if (hasStashedChangesRef.current) {
|
|
49
|
+
const gitRoot = getGitRoot(repoRoot);
|
|
50
|
+
popStash(gitRoot);
|
|
51
|
+
hasStashedChangesRef.current = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.error(`Cleanup error: ${err}`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// Register cleanup for SIGINT/SIGTERM (Ctrl+C)
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
registerCleanup(async () => {
|
|
61
|
+
const child = childProcessRef.current;
|
|
62
|
+
if (child) {
|
|
63
|
+
child.kill("SIGTERM");
|
|
64
|
+
await child; // Wait for process to actually terminate
|
|
65
|
+
childProcessRef.current = null;
|
|
66
|
+
}
|
|
67
|
+
cleanup();
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
unregisterCleanup();
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
const handleInitSelection = (item) => {
|
|
74
|
+
if (item.value === "yes") {
|
|
75
|
+
setInitializing(true);
|
|
76
|
+
try {
|
|
77
|
+
// Run ralph init in a separate process
|
|
78
|
+
execSync("pnpm ralph init", { stdio: "inherit" });
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
exit();
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}, 100);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
setError(`Failed to initialize: ${err instanceof Error ? err.message : String(err)}`);
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
exit();
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}, 100);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
exit();
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}, 100);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (currentIteration > totalIterations) {
|
|
101
|
+
// Clean up and exit
|
|
102
|
+
cleanup();
|
|
103
|
+
exit();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Check if required files exist
|
|
107
|
+
const { missing, exists } = checkRequiredFiles();
|
|
108
|
+
if (!exists) {
|
|
109
|
+
setNeedsInit(missing);
|
|
110
|
+
// If stdin doesn't support raw mode, exit after showing the message
|
|
111
|
+
if (!stdinSupportsRawMode) {
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
exit();
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}, 100);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let worktree = null;
|
|
120
|
+
try {
|
|
121
|
+
const gitRoot = getGitRoot(repoRoot);
|
|
122
|
+
// Stash changes before first iteration
|
|
123
|
+
if (currentIteration === 1) {
|
|
124
|
+
const hasChanges = stashChanges(gitRoot);
|
|
125
|
+
hasStashedChangesRef.current = hasChanges;
|
|
126
|
+
}
|
|
127
|
+
// Create worktree for this iteration
|
|
128
|
+
worktree = createWorktree(gitRoot);
|
|
129
|
+
currentWorktreeRef.current = worktree;
|
|
130
|
+
// Copy .ralph files to worktree
|
|
131
|
+
copyRalphFilesToWorktree(gitRoot, worktree.path);
|
|
132
|
+
// Install dependencies if package.json exists
|
|
133
|
+
installDependencies(worktree.path);
|
|
134
|
+
// Clear events for this iteration
|
|
135
|
+
setEvents([]);
|
|
136
|
+
setOutput("");
|
|
137
|
+
// Ensure .ralph directory exists in worktree
|
|
138
|
+
const worktreeRalphDir = join(worktree.path, ".ralph");
|
|
139
|
+
mkdirSync(worktreeRalphDir, { recursive: true });
|
|
140
|
+
const child = execa("claude", [
|
|
141
|
+
"--permission-mode",
|
|
142
|
+
"bypassPermissions",
|
|
143
|
+
"-p",
|
|
144
|
+
"@.ralph/prompt.md",
|
|
145
|
+
"@.ralph/todo.md",
|
|
146
|
+
"@.ralph/progress.md",
|
|
147
|
+
"--output-format",
|
|
148
|
+
"stream-json",
|
|
149
|
+
"--include-partial-messages",
|
|
150
|
+
"--verbose",
|
|
151
|
+
], {
|
|
152
|
+
cwd: worktree.path,
|
|
153
|
+
stdin: "inherit",
|
|
154
|
+
stdout: "pipe",
|
|
155
|
+
stderr: "inherit",
|
|
156
|
+
reject: false, // Don't throw on non-zero exit
|
|
157
|
+
detached: true, // Run in new process group to prevent SIGINT propagation
|
|
158
|
+
});
|
|
159
|
+
childProcessRef.current = child;
|
|
160
|
+
let fullOutput = "";
|
|
161
|
+
const worktreeLogFile = join(worktree.path, ".ralph", "events.log");
|
|
162
|
+
// Handle streaming stdout
|
|
163
|
+
child.stdout?.on("data", (data) => {
|
|
164
|
+
const chunk = data.toString();
|
|
165
|
+
for (const line of chunk.split("\n")) {
|
|
166
|
+
if (!line.trim())
|
|
167
|
+
continue;
|
|
168
|
+
try {
|
|
169
|
+
const event = JSON.parse(line);
|
|
170
|
+
appendFileSync(worktreeLogFile, JSON.stringify(event, null, 2) + "\n\n");
|
|
171
|
+
setEvents(prev => [...prev, event]);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
// Incomplete JSON line, ignore
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
fullOutput += chunk;
|
|
178
|
+
setOutput(fullOutput);
|
|
179
|
+
});
|
|
180
|
+
// Handle process completion
|
|
181
|
+
child.then(result => {
|
|
182
|
+
childProcessRef.current = null;
|
|
183
|
+
const gitRoot = getGitRoot(repoRoot);
|
|
184
|
+
// Handle error exit (but not if terminated by signal during cleanup)
|
|
185
|
+
if (result.exitCode !== 0 && !result.isTerminated) {
|
|
186
|
+
setError(`Claude exited with code ${result.exitCode}${result.signal ? ` (signal: ${result.signal})` : ""}\n\nLast 2000 chars:\n${fullOutput.slice(-2000)}`);
|
|
187
|
+
cleanupWorktree(gitRoot, worktree);
|
|
188
|
+
currentWorktreeRef.current = null;
|
|
189
|
+
setTimeout(() => {
|
|
190
|
+
cleanup();
|
|
191
|
+
exit();
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}, 100);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
// If terminated during cleanup, don't proceed
|
|
197
|
+
if (result.isTerminated) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Merge worktree changes back to main
|
|
201
|
+
try {
|
|
202
|
+
copyRalphFilesFromWorktree(gitRoot, worktree.path);
|
|
203
|
+
mergeWorktreeToMain(gitRoot, worktree);
|
|
204
|
+
cleanupWorktree(gitRoot, worktree);
|
|
205
|
+
currentWorktreeRef.current = null;
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
setError(`Failed to merge worktree: ${err}`);
|
|
209
|
+
cleanupWorktree(gitRoot, worktree);
|
|
210
|
+
currentWorktreeRef.current = null;
|
|
211
|
+
setTimeout(() => {
|
|
212
|
+
cleanup();
|
|
213
|
+
exit();
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}, 100);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Check if complete
|
|
219
|
+
if (fullOutput.includes("<promise>COMPLETE</promise>")) {
|
|
220
|
+
cleanup();
|
|
221
|
+
exit();
|
|
222
|
+
process.exit(0);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// Move to next iteration
|
|
226
|
+
setTimeout(() => setCurrentIteration(i => i + 1), 500);
|
|
227
|
+
});
|
|
228
|
+
return () => {
|
|
229
|
+
child.kill();
|
|
230
|
+
childProcessRef.current = null;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
setError(`Failed to set up worktree: ${err}`);
|
|
235
|
+
if (worktree) {
|
|
236
|
+
try {
|
|
237
|
+
const gitRoot = getGitRoot(repoRoot);
|
|
238
|
+
cleanupWorktree(gitRoot, worktree);
|
|
239
|
+
currentWorktreeRef.current = null;
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// Ignore cleanup errors
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
setTimeout(() => {
|
|
246
|
+
cleanup();
|
|
247
|
+
exit();
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}, 100);
|
|
250
|
+
}
|
|
251
|
+
}, [currentIteration, totalIterations, exit]);
|
|
252
|
+
if (needsInit) {
|
|
253
|
+
if (initializing) {
|
|
254
|
+
return (React.createElement(Box, { flexDirection: "column", paddingY: 1 },
|
|
255
|
+
React.createElement(Text, { color: "cyan" }, "Initializing ralph...")));
|
|
256
|
+
}
|
|
257
|
+
return (React.createElement(Box, { flexDirection: "column", paddingY: 1 },
|
|
258
|
+
React.createElement(Text, { color: "yellow" }, "Missing required files in .ralph directory:"),
|
|
259
|
+
React.createElement(Box, { flexDirection: "column", paddingLeft: 2, paddingY: 1 }, needsInit.map(file => (React.createElement(Text, { key: file, dimColor: true },
|
|
260
|
+
"\u2022 ",
|
|
261
|
+
file)))),
|
|
262
|
+
React.createElement(Box, { marginTop: 1 }, stdinSupportsRawMode ?
|
|
263
|
+
React.createElement(React.Fragment, null,
|
|
264
|
+
React.createElement(Text, null, "Initialize now?"),
|
|
265
|
+
React.createElement(Box, { marginTop: 1 },
|
|
266
|
+
React.createElement(SelectInput, { items: [
|
|
267
|
+
{ label: "Yes, initialize the project", value: "yes" },
|
|
268
|
+
{ label: "No, exit", value: "no" },
|
|
269
|
+
], onSelect: handleInitSelection })))
|
|
270
|
+
: React.createElement(Text, null,
|
|
271
|
+
"Run ",
|
|
272
|
+
React.createElement(Text, { color: "cyan" }, "ralph init"),
|
|
273
|
+
" to initialize the project."))));
|
|
274
|
+
}
|
|
275
|
+
if (error) {
|
|
276
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
277
|
+
React.createElement(Text, { color: "red" }, error)));
|
|
278
|
+
}
|
|
279
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
280
|
+
React.createElement(Box, { borderStyle: "round", borderColor: "cyan", paddingX: 1, marginTop: 1, marginBottom: 1 },
|
|
281
|
+
React.createElement(Text, { color: "cyan" },
|
|
282
|
+
"Iteration ",
|
|
283
|
+
currentIteration)),
|
|
284
|
+
React.createElement(EventDisplay, { events: events })));
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=IterationRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IterationRunner.js","sourceRoot":"","sources":["../../src/components/IterationRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,WAAW,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAA;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,C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AkB;kDACnC,CAEL,CACF,CACP,CAAA;IACH,CAAC;IAED,IAAI,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,WAAW,EAAC,OAAO,EAAC,WAAW,EAAC,MAAM,EAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;YACpF,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM;;gBAAY,gBAAgB,CAAQ,CAClD;QACN,oBAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,CAC5B,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IterationRunner.test.d.ts","sourceRoot":"","sources":["../../src/components/IterationRunner.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
// Note: Full integration testing of IterationRunner would require:
|
|
4
|
+
// 1. Mocking child_process.spawn to simulate Claude CLI
|
|
5
|
+
// 2. Mocking file system operations
|
|
6
|
+
// 3. Testing React component rendering with ink-testing-library
|
|
7
|
+
//
|
|
8
|
+
// These tests focus on the checkRequiredFiles logic which is the
|
|
9
|
+
// most testable pure function in the module.
|
|
10
|
+
// We'll test the logic by importing and mocking fs
|
|
11
|
+
vi.mock("fs", () => ({
|
|
12
|
+
existsSync: vi.fn(),
|
|
13
|
+
appendFileSync: vi.fn(),
|
|
14
|
+
writeFileSync: vi.fn(),
|
|
15
|
+
mkdirSync: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
describe("IterationRunner file checking", () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
vi.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.restoreAllMocks();
|
|
23
|
+
});
|
|
24
|
+
it("detects all files exist", () => {
|
|
25
|
+
const mockExistsSync = existsSync;
|
|
26
|
+
mockExistsSync.mockReturnValue(true);
|
|
27
|
+
// Simulate the logic from checkRequiredFiles
|
|
28
|
+
const requiredFiles = ["prompt.md", "todo.md", "progress.md"];
|
|
29
|
+
const missing = requiredFiles.filter(file => !existsSync(file));
|
|
30
|
+
const exists = missing.length === 0;
|
|
31
|
+
expect(exists).toBe(true);
|
|
32
|
+
expect(missing).toEqual([]);
|
|
33
|
+
});
|
|
34
|
+
it("detects missing prompt.md", () => {
|
|
35
|
+
const mockExistsSync = existsSync;
|
|
36
|
+
mockExistsSync.mockImplementation((path) => {
|
|
37
|
+
return !path.includes("prompt.md");
|
|
38
|
+
});
|
|
39
|
+
const requiredFiles = ["prompt.md", "todo.md", "progress.md"];
|
|
40
|
+
const missing = requiredFiles.filter(file => !existsSync(file));
|
|
41
|
+
const exists = missing.length === 0;
|
|
42
|
+
expect(exists).toBe(false);
|
|
43
|
+
expect(missing).toContain("prompt.md");
|
|
44
|
+
});
|
|
45
|
+
it("detects multiple missing files", () => {
|
|
46
|
+
const mockExistsSync = existsSync;
|
|
47
|
+
mockExistsSync.mockReturnValue(false);
|
|
48
|
+
const requiredFiles = ["prompt.md", "todo.md", "progress.md"];
|
|
49
|
+
const missing = requiredFiles.filter(file => !existsSync(file));
|
|
50
|
+
const exists = missing.length === 0;
|
|
51
|
+
expect(exists).toBe(false);
|
|
52
|
+
expect(missing).toEqual(["prompt.md", "todo.md", "progress.md"]);
|
|
53
|
+
});
|
|
54
|
+
it("detects only todo.md exists", () => {
|
|
55
|
+
const mockExistsSync = existsSync;
|
|
56
|
+
mockExistsSync.mockImplementation((path) => {
|
|
57
|
+
return path.includes("todo.md");
|
|
58
|
+
});
|
|
59
|
+
const requiredFiles = ["prompt.md", "todo.md", "progress.md"];
|
|
60
|
+
const missing = requiredFiles.filter(file => !existsSync(file));
|
|
61
|
+
const exists = missing.length === 0;
|
|
62
|
+
expect(exists).toBe(false);
|
|
63
|
+
expect(missing).toEqual(["prompt.md", "progress.md"]);
|
|
64
|
+
expect(missing).not.toContain("todo.md");
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
// Note: For comprehensive integration tests, you would want to:
|
|
68
|
+
//
|
|
69
|
+
// 1. Test child process spawning:
|
|
70
|
+
// - Mock spawn() to return a fake ChildProcess
|
|
71
|
+
// - Emit data events to simulate Claude output
|
|
72
|
+
// - Test JSON parsing of events
|
|
73
|
+
// - Test COMPLETE promise detection
|
|
74
|
+
// - Test exit code handling
|
|
75
|
+
//
|
|
76
|
+
// 2. Test file operations:
|
|
77
|
+
// - Mock appendFileSync/writeFileSync
|
|
78
|
+
// - Verify events are logged correctly
|
|
79
|
+
// - Test log file creation
|
|
80
|
+
//
|
|
81
|
+
// 3. Test React rendering:
|
|
82
|
+
// - Use ink-testing-library to render component
|
|
83
|
+
// - Test initialization prompts
|
|
84
|
+
// - Test error display
|
|
85
|
+
// - Test iteration counter
|
|
86
|
+
//
|
|
87
|
+
// Example structure for a full integration test:
|
|
88
|
+
//
|
|
89
|
+
// import { render } from 'ink-testing-library'
|
|
90
|
+
// import { EventEmitter } from 'events'
|
|
91
|
+
//
|
|
92
|
+
// vi.mock('child_process', () => ({
|
|
93
|
+
// spawn: vi.fn(() => {
|
|
94
|
+
// const mockProcess = new EventEmitter()
|
|
95
|
+
// mockProcess.stdout = new EventEmitter()
|
|
96
|
+
// mockProcess.kill = vi.fn()
|
|
97
|
+
// return mockProcess
|
|
98
|
+
// })
|
|
99
|
+
// }))
|
|
100
|
+
//
|
|
101
|
+
// it('parses streaming JSON events', () => {
|
|
102
|
+
// const { lastFrame } = render(<IterationRunner totalIterations={1} />)
|
|
103
|
+
// const mockChild = getLastSpawnedProcess()
|
|
104
|
+
//
|
|
105
|
+
// mockChild.stdout.emit('data', Buffer.from('{"type":"assistant"}\n'))
|
|
106
|
+
//
|
|
107
|
+
// expect(lastFrame()).toContain('expected output')
|
|
108
|
+
// })
|
|
109
|
+
//# sourceMappingURL=IterationRunner.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IterationRunner.test.js","sourceRoot":"","sources":["../../src/components/IterationRunner.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAE/B,mEAAmE;AACnE,wDAAwD;AACxD,oCAAoC;AACpC,gEAAgE;AAChE,EAAE;AACF,iEAAiE;AACjE,6CAA6C;AAE7C,mDAAmD;AACnD,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACnB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;IACnB,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE;IACvB,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;IACtB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;CACnB,CAAC,CAAC,CAAA;AAEH,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,aAAa,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,cAAc,GAAG,UAAiD,CAAA;QACxE,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAEpC,6CAA6C;QAC7C,MAAM,aAAa,GAAG,C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