Hacker News new | ask | show | jobs
by clx75 55 days ago
I have similar experiences in Clojure. I use Pi and created an extension which teaches the LLM how to start a JVM with a Clojure nREPL listening in it. Added a tool which lets the agent evaluate any Clojure form inside the JVM. Sprinkled the setup with clj-reload and now the agent is using the nREPL as if it were its second nature.

What I like most is how fast testing goes: it modifies test code on disk, asks clj-reload to reload all affected namespaces, then reruns the tests. It's also fun to see how it verifies its assumptions by evaluating short programs through the nREPL.

I asked it to organize the various subsystems inside my playground repo into Integrant systems and make it possible for me to say things like "restart the http subsystem".

It also understands shadow-cljs: I replicated the necessary parts of the shadow CLI tooling in Clojure; now I can compile, watch and serve any number of CLJS apps located in various namespaces from inside the same JVM. There is no need to touch the command line any more: I just instruct the agent to start a particular CLJS app and it's there.

6 comments

I came across a very similar project recently.

https://github.com/DeadMeme5441/arrodes

It seems to be a bit more integrated than what you describe here because it's completely built around a Clojure REPL

this is great, thx for sharing
Seconded. I get excellent results with LLMs and Clojure. The first large LLMs struggled with less popular languages, modern LLMs don't seem to have this problem. I get excellent code quality in a large codebase.
Similar experience with Clojure here. IMO the functional orientation of the language makes it so that the LLMs don't write as much bloat, and it's much more pleasant for me to read and hand-refactor than TypeScript

I don't let the LLM write macros though, it creates too much opacity for me to easily reason about what they've done.

Have a look at https://github.com/rcarmo/gi - I am slowly cleaning it up to upgrade to the equivalent of pi 1.0.4
WHy aren't we doing this for Python?

Surely iPython (what powers Jupyter notebooks among other things) + maybe pdb could do it? And agents are definitely familiar with how those work.

Totally possible in Python, but clojure is typically more amenable to this kind of change because of how data is immutable by default, you can just replace without any consequences because the application is already developed with that concept in mind.

For iPython that's totally possible because the model there is just some kind of dependency graph. Regular python programs, much more complex I'd bet unless the architecture takes it into account

> For iPython that's totally possible because the model there is just some kind of dependency graph. Regular python programs, much more complex I'd bet unless the architecture takes it into account

The iPython shell has %autoreload 2 (autoreload on changes) which is incredibly helpful for debugging and iteration.

I do agree that Lisp is better, hooking an agent up to Emacs is a lot of fun (and I'm only getting started!).

Which extension do you use?
I developed my own:

https://github.com/cellux/pi-extensions/tree/master/extensio...

Note that this may not work for you standalone as it relies on my other agent-sandbox extension (which ensures all agent operations happen inside a sandbox container).

But point an LLM to its source code and it will extract the gist of it.