Phase 3 Tasks
Phase 3 Tasks¶
dummy_echo Tool¶
- Ok Kimi, time to start working on @.ai-interactions/outputs/phase-3/output-1_design-tools.md. Create a todo list first. Then implement one by one.
- Move the tool styles into @internal/cli/repl/styles.go.
- In @internal/llm/genkit.go, there are two unused functions: extractTextContent and fromGenkitRole. They are not needed. Remove them.
- Add a unit test for StreamChat in @internal/llm/genkit.go for successful tool invokation.
read_file Tool¶
- Read and create a plan for the prompt in @.ai-interactions/prompts/phase-3/prompt-3_read-file-tool.md.
- There is a read_file tool design in @.ai-interactions/outputs/phase-3/output-3_read-file-tool.md. And there is a also a granular implementation todo list. Let's get to work.
- I manually tested and get this error: "I am sorry, I cannot fulfill this request. The read_file function only supports text files. The .go extension indicates that the file is a Go source file, which is not a plain text file."
- Should we rather siimplify the check and directly read any file, and only fail if the file contains something else except characters?
- Check the plan in @.ai-interactions/outputs/phase-3/output-3_read-file-tool.md and check the code and ensure that everything is implemented correctly.
- If user denies permission for reading a file, we will take the error and send it to the LLM so it can handle it gracefully. Let's implement this.
- We have a spinner that is supposed to animate in the REPL. But right now it's not animating. Let's fix this.
- In the read_file tool design, we proposed to use MIME type detection. But we have decided to discard this approach. Let's update the design doc by removing MIME type detection.
- How can we refactor the Update() function in @internal/cli/repl/repl.go? Let's break it down into smaller, deduplicated functions.
Session-Wide Permission¶
- Right now when read_file tool reads files in a different directory not within current directory, it asks for permission. There are two options: Allow/Deny. We want to support "Allow in this session" too. If users select it, all future read_file tool calls in this session will no longer require to prompt users for permission. Explain first how you will implement it.
- We should have a session-wide allowed tools list instead of a single flag for
read_filetool. Think about extensibility for future tools. In future, it can have multiple session-wide allowed tools.
glob Tool¶
- Based on the design in @.ai-interactions/outputs/phase-3/output-4_glob-tool.md, let's implement the tool.
- There is an implementation done for the
globtool in @internal/tools/glob.go. Review the code.
Moonshot AI¶
- Explore genkit package and figure out how we can use it to send requests to Moonshot AI using openai compatible api.
- The
baseUrlyou used is not correct. It should behttps://api.moonshot.ai/v1/.
DeepSeek¶
- Now we want to support DeepSeek too. It should be doable through openai compatible API. Give me a plan on how to implement it.
- The plan looks good. Let's implement it.
UI Improvements¶
- @AGENTS.md @repl.go Explore how tool call and llm messages are shown in the REPL ui right now.
- Do tool calls and llm messages appear chronologically? If not, what would be a more user-friendly UI?
- Based on your findings and suggestions, create an implementation plan for the UI improvements with granular task breakdown.
- I think we don't need to introduce a separate
timelinetype now. Let's remove that and implement the UI improvements. - Right now when we scroll up, the REPL continuously scroll at the bottom when new content is being streamed. So there is a flickering behaviour right now. When streaming content finishes, then we can scroll up without flickering. What's the issue? Propose a fix.
- Explore the @repl.go and understand the user interface behaviour for keen code.
- Is the UI responsive now? By responsive, I mean the text wraps correctly both in input and output.
- Ok based on your suggestions, let's first migrate
bubbletea,bubbles, andlipglossto v2. - Well looks like input text area is not behaving as we expected. Let's take a step back and reevaluate the UI design.
- Right now, we have this
textareawhere users can type their input. Figure out how it behaves for cases like:- When user types a short line
- When user types a long line beyond the size of the window
- When user copy-pastes a long line
- When user copy-pastes multiple lines
- Great, you have correctly identified the behaviour of the
textarea. Let's now fix the issue of misbehaving wrapping and height adjustment. - @repl.go check how input text area UI looks like right now. Figure out any inconsistencies and propose a fix.
- What's the background color of the cursor line?
- I want a consistent style for the cursor line and the other two lines of the textarea. Let's fix this.
- Ok. Now, we want the text area to have a border. How can we do that?
- Let's make the border a little bit thicker.
- Check the code in repl.go and explain why there are flickering when llm chunks are streaming to the terminal. Explain the fix.
- Actually, the behaviour is, for the grep tool, it's parameters are flickering.
grep tool¶
- Based on the design in @.ai-interactions/outputs/phase-3/output-6_grep-tool.md, let's implement the
greptool. - The functions are too long in the implementation for the
greptool. Let's break them down into smaller functions and focus on quality and readability. - Instead of reading each file's each line one-by-one, let's read the entire file content at once and then search for the pattern in the content. Use the
readFileContentfunction fromread_filetool. - Check the code in @grep.go. Is there a scope for performance improvement for grep? I am thinking in terms of speed.
UI Interactions¶
- Right now in Keen Code, if users press
ctrl+c, it exits. We want to change the behaviour: - If there is text in the input area, then the first
ctrl+cpress will clear the text. - If the text input area is empty, then
ctrl+cwill exit. How would you implement it? - Right now when LLM is streaming or tool is being called, there is no way for the user to interrupt the process. We want to support interrupting the process with
esckey. Check the code in @repl.go and @handlers.go. Based on that, create a plan and granular todo list for implementing this feature. - When we press esc, the message "Interrupted" is replacing the last streamed content where the interruption happened. Let's show that.
- Let's show the "interrupted" message in orange colour. Put create a specific style for it in @styles.go. Make the style adaptive.
- The output of
bash_toolis shown in full. We want to show it as a collapsible section. How would you implement it? - It seems the diff and permission card for edit file tool is rendering only after interaction from mouse or keyboard. Why?
- Which approach is preferable? Explain.
- How can we reuse the same WaitForEvent instead of a new source of events?
- Create a todo list for this. Share the list with me. After that, let's implement the tasks.
- What will happen if bash output is long and its getting generated for a long time (it's not immediate)?
-
For now, we won't streem bash output. We will show the entire output at once. Implement a running command indicator so that users can se that a command is executing.
-
The constants defined in @message.go (type StreamEventType) are declared in Keen Code. Are there equivalent constants or similar ones in Genkit itself? Having these constants in Keen Code is questionable.