تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Planning the CLI Rewrite0:00

It's time to turn our simple Ralph's script into a nice and flexible CLI with support for things like YoloBox. We'll do something fun in this lesson, we'll use Ralph itself to create a Ralph CLI. I have a rough idea of how this should look, so let's explore it together. First things first, I want the CLI to be a 2E, I will use Open2E for that. Before we create our PRD, let me first add the Open2E skill, so the model can reference it where needed.

reference it where needed. Now we have our Open2E skill installed and in Cloud it's going to be a sim link if I'm not mistaken to this directory in the agents directory. Then let's start creating our PRD, we'll start YoloBox Cloud and in here we'll say PRD. I want to turn the Ralph.js script into a CLI with a nice 2E, use BUN, this Open2E, look at the Open2E skill where relevant, create all new files in the Ralph CLI

Defining PRD Requirements1:00

Open2E, look at the Open2E skill where relevant, create all new files in the Ralph CLI directory. As you can see here on screen it's currently looking at the current implementation and loaded the Open2E skill to see how that works, all right. And now it's coming back with a few questions we need to answer, let's take a look, we want to use React. So regarding the screens, let's actually say I want to see tabs at the top, I

to use React. So regarding the screens, let's actually say I want to see tabs at the top, I can switch to and see the live output of the running Ralph loop. Here we'll say it's a single interactive flow, I want to be able to press C and have the CLI load all the PRDs in the PRD backlog directory and have me interactively select the PRD I want to run Ralph on and that looks good. I went a bit back and forth with the model and the PRD is now ready so let's

I want to run Ralph on and that looks good. I went a bit back and forth with the model and the PRD is now ready so let's take a look. So the idea is we'll rewrite the Ralph.js script into a modern 2E using BUN and Open2E, we'll replace Ralph.js with a multi-agent 2E that's fine, we'll provide a polished terminal experience with tab navigation, streaming output and keyboard-driven controls, we'll support both direct cloud execution and sandboxed yolo box executions,

controls, we'll support both direct cloud execution and sandboxed yolo box executions, this is one of the things I iterated on and we want to have a globally installable BUN CLI package. That looks good, let's quickly glance at the user stories, I want to press C to spawn a new agent, I want to see a real-time streaming output for each agent in its own tab so I can monitor the progress, I want to switch between the tabs on multiple running

own tab so I can monitor the progress, I want to switch between the tabs on multiple running agents, I want to run agents inside yolo box for sandboxed execution when working on risky changes and as a developer I want to install Ralph globally and run it from any project directory, that looks good, glancing over the functional requirements, I want a tab bar horizontally at the top of the screen, I want a spawn model by pressing C, by default I'll

horizontally at the top of the screen, I want a spawn model by pressing C, by default I'll execute cloud in print mode but I can also do dash dash yolo box so it's going to be yolo box clouds with the cloud config, git config and then in print mode which is fine, BUN I have streaming output, session ID, stinking blocks, text responses, tool calls, tool results, results summary, set looks good, we can pass an iterations flag, it defaults to 30, we

results summary, set looks good, we can pass an iterations flag, it defaults to 30, we 'll have a status bar at the bottom, we'll have some lifecycle indications, green for running, a check mark for complete, red for error stopped with a yellow indicator and completed stopped or error tabs stay open so we can take a look at the logs and review them, pressing X will close the tab and when the agent is still running we'll kill the agent and

pressing X will close the tab and when the agent is still running we'll kill the agent and otherwise we'll just kill the tab and pressing Q will kill the CLI entirely, scrolling down we have a small wireframe, this is irritating me so we have to align it, glancing over the child process spawning this looks good, cloud dash p will have our prompt output from extreme JSON and verbose and when doing yolo box we do cloud, cloud config, git config,

Reviewing Implementation Tasks4:07

extreme JSON and verbose and when doing yolo box we do cloud, cloud config, git config, dash dash and then the same so that's looking good as well, I'll include the markdown file for you to review but for now let's jump to the prioritize tasklist, we'll scaffold, the project, we'll implement the CLI parsing, we'll do the PRD discovery, prompt builder, stream JSON parser, child process spawner, this is all looking good, we'll have our hooks, a root

JSON parser, child process spawner, this is all looking good, we'll have our hooks, a root layout, agent panel spawn model, status bar, tab bar, this is good and we'll wire up the global keyboard shortcuts, that's fine, scrolling down we'll have our medium priority items, we 'll build or log entry, that's fine, we'll add an empty state, we'll add our status indicators, we'll handle terminal resizing, we'll add quit confirmation, we'll do some pre-flight checks

indicators, we'll handle terminal resizing, we'll add quit confirmation, we'll do some pre-flight checks , for example, to see if yolo box is installed, we'll configure package.json and we'll add a build and install CLI script in package.json, this is all looking fine, and finally we'll implement auto scroll, truncating, we'll add total cost aggregation, we'll add a help flag, we'll polish the border styles, this is fine, and finally we'll add a claw.md file, so future agents

Running the Final Script5:09

polish the border styles, this is fine, and finally we'll add a claw.md file, so future agents will have at least some form of context regarding this project. Since I'm pretty happy with the PRD, let's run our LGS node script one final time before we retire it and replace it with our much nicer CLI. Let's first create a new branch, get checkout -b, new Ralph, CLI and on this new branch let's run YoloBox and inside our YoloBox, let's say node, Ralph and let's say 30

Building and Installing CLI5:36

new branch let's run YoloBox and inside our YoloBox, let's say node, Ralph and let's say 30 iterations and we'll choose or 2e. I'll see you back once Ralph completes its work. All right, the loop completed without any issues and we have our new Ralph CLI directory. Let's test it and see if it actually works. Let's go into the new directory, see the Ralph CLI, let's say button install and then we 'll say button run start. All right, and this is already looking pretty neat. Let's exit out of it

'll say button run start. All right, and this is already looking pretty neat. Let's exit out of it , then let's say bun run build and then we can say bun run install CLI and to allow this action we need to enter or password and now when we say with Ralph, we can see we have a Ralph binary available in the path. Let's open up ghosty in our project directory and let's see if our CLI picks up our PRDs, we can say Ralph and we can spawn a new agent by pressing C and in here we can see our two

Testing Tabs and YoloBox6:30

our PRDs, we can say Ralph and we can spawn a new agent by pressing C and in here we can see our two PRDs. I added a small dummy PRD so we can stress test or 2e and now when we press enter we have a tab and we can actually add a few tabs. This is actually looking pretty amazing. We can navigate between the tabs with our keyboard, we can press X to close the tabs and we can press Q to quit the entire CLI. We can also run Ralph with dash dash YOLO box so all agents get spawned inside

the entire CLI. We can also run Ralph with dash dash YOLO box so all agents get spawned inside YOLO box as you can see here running inside YOLO box and we can see it still works and this is a much nicer experience because we are in control with our Ralph CLI we can choose whether or not to start it in YOLO box. Our Ralph CLI has support for multiple parallel agents but you may be wondering how that would work in practice because if you have multiple agents work in parallel on the

how that would work in practice because if you have multiple agents work in parallel on the same directory on different PRDs they will definitely get in each other's way and solving this issue will be the topic of next lesson. I'll see you there!

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟