Show HN: Canopy – 基于 Go 语言的 A2UI 实现,面向 macOS/AkkPit

1作者: artpar3 个月前
几个月前,我发现了 <a href="https:&#x2F;&#x2F;a2ui.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;a2ui.org&#x2F;</a>,并决定将其作为一个副项目来实现。<p>canopy 将 jsonl 文件渲染为功能强大且交互式的原生 GUI。<p>这是一个 Hello World 示例:<p>```example.jsonl<p>{&quot;type&quot;:&quot;createSurface&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;title&quot;:&quot;Tasks&quot;}<p>{&quot;type&quot;:&quot;updateDataModel&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;ops&quot;:[ {&quot;op&quot;:&quot;replace&quot;,&quot;path&quot;:&quot;&#x2F;tasks&quot;,&quot;value&quot;:[{&quot;title&quot;:&quot;Ship demo&quot;,&quot;done&quot;:false}]}]}<p>{&quot;type&quot;:&quot;updateComponents&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;components&quot;:[ {&quot;componentId&quot;:&quot;root&quot;,&quot;type&quot;:&quot;Column&quot;,&quot;children&quot;:[&quot;title&quot;]}, {&quot;componentId&quot;:&quot;title&quot;,&quot;type&quot;:&quot;Text&quot;,&quot;props&quot;:{&quot;content&quot;:{&quot;path&quot;:&quot;&#x2F;tasks&#x2F;0&#x2F;title&quot;}}} ]}<p>```<p>jsonl 到 GUI 渲染器只是一部分,canopy 可以直接连接到你的 LLM 提供商,并让 LLM 通过这些增量的 jsonl 构建应用程序。<p>canopy 在“反向控制模式”下支持 --claude 或 --codex 运行,以 canopy 作为 MCP 服务器并提供适当的提示启动 claude/codex。<p>MCP 还为其自身提供了一个“截图”工具,因此 LLM 实际上可以“看到”它构建的内容。 显然,它还可以与应用程序本身交互以进行测试。<p>readme 中的图像是真实的示例。<p>除了基本的原生组件(如输入字段、滚动、布局等)之外,canopy 还可以执行 - FFI 函数调用 - 截取自己的屏幕截图 - 音频/视频捕获 - API 调用。<p>对于“演示”应用程序,它运行良好,但我注意到在生成的应用程序中存在不同类型的“行为问题”,主要是在更复杂应用程序的状态管理方面,这个问题会被放大。 我尝试了一个“像素编辑器到 ico 导出”,编辑器部分运行良好(尽管用户体验为 0),但导出根本不起作用。 目前我无法获得可用的“sqlite 浏览器”。<p>但我相信这些都是提示问题/工具问题,可以通过更好的抽象(包、可重用组件)来解决。<p><a href="https:&#x2F;&#x2F;github.com&#x2F;artpar&#x2F;canopy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;artpar&#x2F;canopy</a><p>go build -o canopy
查看原文
I came across <a href="https:&#x2F;&#x2F;a2ui.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;a2ui.org&#x2F;</a> a couple of months ago and decided to do an implementation as a side project<p>canopy renders jsonl files as functional and interactive native GUI<p>Here is a hello world example<p>```example.jsonl<p>{&quot;type&quot;:&quot;createSurface&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;title&quot;:&quot;Tasks&quot;}<p>{&quot;type&quot;:&quot;updateDataModel&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;ops&quot;:[ {&quot;op&quot;:&quot;replace&quot;,&quot;path&quot;:&quot;&#x2F;tasks&quot;,&quot;value&quot;:[{&quot;title&quot;:&quot;Ship demo&quot;,&quot;done&quot;:false}]}]}<p>{&quot;type&quot;:&quot;updateComponents&quot;,&quot;surfaceId&quot;:&quot;main&quot;,&quot;components&quot;:[ {&quot;componentId&quot;:&quot;root&quot;,&quot;type&quot;:&quot;Column&quot;,&quot;children&quot;:[&quot;title&quot;]}, {&quot;componentId&quot;:&quot;title&quot;,&quot;type&quot;:&quot;Text&quot;,&quot;props&quot;:{&quot;content&quot;:{&quot;path&quot;:&quot;&#x2F;tasks&#x2F;0&#x2F;title&quot;}}} ]}<p>```<p>jsonl to gui renderer is one part, canopy can connect with your llm provider directly and let the llm build the app thru these incremental jsonl.<p>canopy supports --claude or --codex at run in &quot;reverse controlled mode&quot;, starts claude&#x2F;codex with canopy as an MCP server and appropriate prompt.<p>the mcp also exposes a &quot;screenshot&quot; tool for itself so the LLM can actually &quot;see&quot; whats its build. and it can obviously interact with the app itself to test it.<p>the images in the readme are real examples.<p>apart from the basic native components like input field, scroll, layouts etc, canopy can do - ffi function calls - take its own screenshot - audio&#x2F;video capture - api calls<p>for &quot;demo&quot; apps it works okay, i notice different kind of &quot;behavioral issues&quot; in the generated apps though, mostly in terms of state management for more complex apps, the issue gets multiplied. i tried a &quot;pixel editor to ico export&quot;, the editor part worked fine (0 ergonomics for the user though), the export did not work at all. i coulnt get to a usable &quot;sqlite browser&quot; at this point.<p>but i am sure these are prompt problems&#x2F;tooling that can be fixed with better abstractions (packages, reusable components)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;artpar&#x2F;canopy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;artpar&#x2F;canopy</a><p>go build -o canopy