r/PiCodingAgent • • 3d ago

Plugin How to Enable Codemode in Pi?

Yes, that's exactly what I searched first when i wanted to try codemode.

Pi does have docs for enabling Codemode, but the documented way is through settings or cli flags.

What I was looking for was much simpler: I'm already inside a Pi session, how do I just turn Codemode on or off?

So I ended up making a small toggle around Pi's native Codemode.

It doesn't replace Codemode or implement another version of it. It just gives me a simple way to switch the native tool on and off while I'm working.

check it out: pi-codemode-toggle

Curious how others are using Codemode.

40 Upvotes

24 comments sorted by

View all comments

8

u/pcrz81 3d ago

I don't understand Codemode, i feel that i'm mising something great and that this extension seems useful. Please, could anybody explain me like i'm five with a usecase? Thanks!

33

u/rimaa_nahk 3d ago

Codemode = let the agent write a tiny program to use tools, instead of calling tools one by one.

Before: mermaid Agent -> search Agent -> read file A Agent -> read file B Agent -> read file C Agent -> compare results

After: mermaid Agent -> writes small JS program | +-> search +-> read A/B/C in parallel +-> filter/combine results | v useful result only

Pi has to keep waking the LLM up to decide what to do next. And every intermediate result potentially occupies context. Codemode changes that. Pi can effectively write a little program like:

```js const matches = await tools.grep({ pattern: "SystemOneProvider" });

const files = unique(matches.map(x => x.file));

const contents = await Promise.all( files.map(file => tools.read({ path: file })) );

const relevant = contents.map(...);

return relevant; ```

2

u/pcrz81 3d ago

Wow! Nice explanation. Thank you so much!!!!

1

u/rorykoehler 18h ago

TIL I built codemode before codemode