shadow-cljs

bhauman 2025-07-07T16:06:47.355199Z

OK this is in reference to ClojureMCP and giving the REPL some super powers: I've noticed the Claude Opus is very good at using the shadow repl. https://github.com/bhauman/clojure-mcp?tab=readme-ov-file#working-with-clojurescript-shadow-cljs I've seen it iterate through dom nodes to find all the z-index roots to solve z-index issues... that was impressive 🙂 I've seen it write it's own grep to use to repeatedly locate nodes in the dom... I'd like to work on a set of tools that support LLM cljs REPL use... The first one that comes to mind is to capture logs so that Claude can tail the logs.. I'm also very interested in how we can help the LLM visualize the application and help the LLM fire events to interact with it. I.E. repl tools that could help the llm interact with the application. Yes I know that playwright exists... however, I'm convinced a set of repl tools could be very successful alternative... I'm hoping folks can point me to ideas, libraries etc. As I'm keen to work on this a bit this week.

lilactown 2025-07-13T17:26:49.150479Z

Circling back to this, I think I misunderstood your original question. I think you're looking for a way to get the page into a textual format that the LLM can understand? I looked at how the MicroSoft https://github.com/microsoft/playwright-mcp works and it says > This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models. perhaps that's the unlock? We could very easily have a REPL command that takes that snapshot of the page and feeds it in, and then have subsequent REPL commands for interacting. It's not immediately clear how this is more powerful than playwright, but gets us out of the need for another tool.

bhauman 2025-07-13T18:07:50.359049Z

structured accessibility snapshots, very interesting ...

bhauman 2025-07-13T18:12:10.690819Z

An update on this... If you have the react devtools extention installed you can hook the devtools info on the webpage itself and inspect the react component information directly at window.REACT_DEVTOOLS_GLOBAL_HOOK__ you can then write some cljs repl tools to map from component names to the actual dom elements Find components that are active on the page inspect their params etc. Still don't know how valuable it is but it seems very promising.

thheller 2025-07-07T16:18:48.982869Z

have you seen good examples for this kind of thing someplace? I have tried feeding some data into some LLMs and trying to get it to structure/visualize the data but that all failed miserably

thheller 2025-07-07T16:20:11.447869Z

didn't expect much to begin with, but one thing I tried was dumping my entire component tree structure as EDN and then have the llm make an ascii tree view out of it. gemini got closest, but in some way they all failed

thheller 2025-07-07T16:20:59.872319Z

but I guess this mostly due to using my own framework thing it has no training data on. I suppose for react it might do pretty well

thheller 2025-07-07T16:21:18.566629Z

maybe just teach it how re-frame works and how to dispatch events and look at the data?

bhauman 2025-07-07T16:23:02.922489Z

I'm thinking why not help it here... the data is very complex but if we put effort into rendering it for the LLM we might get a big payback from that...

bhauman 2025-07-07T16:24:40.223439Z

rendering perhaps as a textual tree like a TOC

bhauman 2025-07-07T16:24:51.668519Z

with clear actions labeled

bhauman 2025-07-07T16:25:16.526089Z

or a tree that can be explored by depth

bhauman 2025-07-07T16:36:48.799409Z

Or can we grep the page for visible actions, with clear instructions on how to trigger those events?

lilactown 2025-07-07T17:07:10.247119Z

At my current gig, we have a tool I wrote called "revl" - it stands for "Read Eval View Loop" It's basically a secondary app that runs alongside your normal app build that allows you to send specific React elements from the REPL to be viewed in isolation. A human operating this: you evaluate your buffer to load the namespaces and then send this using a keystroke:

(revl/view ($ my-component {,,,}))
It then evals that in the :revl build REPL, which tells the revl app to render that element within the stage. This opens up the ability to have a REPL-driven development workflow a la Clojure but using the browser as a replacement for printing.

lilactown 2025-07-07T17:09:04.889129Z

Someone else was working on integrating it with clojure-mcp. I think using some kind of mixed-mode/computer vision way of interpreting the browser at that point would be good. Or basically whatever Claude currently uses today when controlling playwright.

cormacc 2025-07-07T20:23:37.311579Z

Re. repl tools to interact with the application, does Etaoin do what you need? Re. allowing the LLM to visualise your app - @christian767's excellent dataspex allows you to spy on the hiccup rendered by your app, and also browse the app state atom and/or datascript DB. Could you leverage something like this? @pez might have a perspective - he's been busy recently integrating dataspex with calva and think he's also playing with clojure-mcp...

pez 2025-07-07T20:53:12.262639Z

For a certain set of problems the LLM can have a lot of insight by running the view functions in a Replicant app. Since there the view is truly a function of application state. The LLM can see what actions are active in a view and trigger them, if we give it a dispatch function. This way it can “use” the app without any Playwright or similar involved. Not that I have tried, but since I can do it from the REPL and in test code, of course the LLM can too.

pez 2025-07-07T20:58:59.106889Z

I’ve not been using clojure-mcp much, because when I let the LLM loose with the REPL I mostly use Calva Backseat Driver, and mostly in efforts to try to improve it. 😃 It’s nowhere near as complete as clojure-mcp, but it has the repl tool and that takes it far. It’s also very easy to use with Clojure, ClojureScript, Babashka, or whatever that Calva can connect to.

bhauman 2025-07-07T22:44:00.009829Z

I put in a bunch of work in this weekend to allow using ClojureMCP with other dialects 🙂

🤘 1
rafaeldelboni 2025-07-07T18:46:46.015079Z

thheller, have you done more tests with wtr in the end? I'm interested in using it as replacement of karma, if yes what your thoughts on it? https://clojurians.slack.com/archives/C6N245JGG/p1718984593260779?thread_ts=1718981606.527989&cid=C6N245JGG

thheller 2025-07-07T20:43:47.988909Z

nope not at all. ran a few dummy tests that day and never touched it again

thheller 2025-07-07T20:44:33.016379Z

I'm not much of a test person, so not very motivated

rafaeldelboni 2025-07-07T20:45:40.523479Z

makes sense, I will invest some time in this them, imagine that config you shared is still relevant right?

thheller 2025-07-07T20:45:58.240279Z

yep

rafaeldelboni 2025-07-07T20:46:18.860779Z

Thanks! Have a great day