Created greet tool extension returning 'hi'.
BuildUsed greet tool and confirmed output.
VerifyAdded custom tool call and result renderer with /reads command.
Build>rm .pi/extensions/greet.tsi want you to create an extension .pi/extensions, called greet.ts. it should have a custom tool "greet" that just returns hi when called.
The user wants me to create a custom extension with a tool called "greet" that returns "hi". I should first read the extensions documentation to understand the proper format.
Now I have a good understanding of how to create an extension with a custom tool. Let me create a simple greet extension that just returns "hi" when called.
Done. Created a simple extension with a "greet" tool that returns "hi" when called.
Created .pi/extensions/greet.ts with a greet tool that returns "hi" when called. The tool takes no parameters and will be auto-discovered when you run pi.
ok, use the tool
The user wants me to use the greet tool that was just created.
hiThe greet tool worked and returned "hi" as expected.
Done. The greet tool returned "hi".
ok, add a custom tool call and result renderer, just think about something simple
The user wants me to add custom renderCall and renderResult methods to the greet tool. Let me think of something simple but nice - maybe show a greeting emoji or styled text.
Let me add simple custom renderers. I'll make:
Done. Added custom renderers:
Updated the extension with custom renderers:
use the tool agian
The user wants me to use the greet tool again to see the custom rendering.
hiThe tool worked and returned "hi". The custom renderers should have displayed the styled output in the TUI.
Done. You should see the custom rendering with the 👋 and ✓ styled output.
add a /reads slash command, that goes through the active branch entries, and finds all assistant messages and the tool calls in them. and list the read files read via the read tool. you can find the types in @packages/ai/src/types.ts
The user wants me to add a slash command /reads that:
Let me first look at the types in packages/ai/src/types.ts to understand the structure of messages and tool calls.
>rg -n "role.*assistant|ToolCall|AssistantMessage" /Users/badlogic/workspaces/pi-mono/packages/ai/src/types.ts | head -50Now let me look at the ToolCall interface more closely and also check what the session entries look like.
Now I understand the structure. Let me check what the session entries look like in the coding-agent. I need to understand how to access them from an extension.
>rg -n "getBranch|getEntries|entry.type" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src --include="*.ts" | head -30Let me fix that - rg uses -g for glob patterns.
>rg -n "getBranch|getEntries|entry\.type" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src -g "*.ts" | head -40Good, I can see that:
ctx.sessionManager.getBranch() returns entries on the current branchtype field, and for messages it's "message" with an entry.message containing the actual messageentry.message.content which is an array of TextContent | ThinkingContent | ToolCalltype: "toolCall" and a name propertyNow let me look at how the read tool stores its arguments to know what to extract.
>rg -n "parameters.*Type\.Object" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src/core/tools/read.ts | head -5Let me look at the read tool directly to see its parameters structure.
Good, so the read tool takes a path parameter. Now I have everything I need to create the /reads command. Let me update the extension.
Now I have the info I need. Let me update the extension:
Now I'll add the /reads command that:
Done. Added the /reads command that:
ctx.sessionManager.getBranch()path argument from each tool callThe user can now use /reads to see all files that have been read in the current session.
Added the /reads command. It:
ctx.sessionManager.getBranch()Try it with /reads to see all files read in this session.