展示HN:我构建了“代码的Docker”,将AI逻辑隔离到语义容器中。

1作者: alonsovm大约 1 个月前原帖
你好,HN,我想分享一个我在过去30天里一直在做的业余项目——Glupe。没什么特别的。 我对大多数AI编码工具的“全有或全无”方法感到相当烦恼,这些工具虽然有用,但也存在风险。如果我告诉一个AI“修复这个bug”,它可能会做到,但它也可能(或会)产生虚假的库,搞乱我手动优化的代码,或者在没有解释或通知的情况下悄悄删除重要代码。 Glupe的总结就是:“停止给AI提供对你代码的根访问权限,Glupe将AI逻辑隔离到语义容器中,这样你的代码就能保持安全。” 与其将整个文件发送给大型语言模型(LLM)并祈祷它不会出错,使用Glupe,你可以精确地告诉AI在哪里写代码以及该做什么,使用$$ { logic } $$语法。容器外的代码保持不变。容器内的指令会被转化为源代码并嵌入到输出文件中。 容器可以命名,并且会被缓存和哈希,Glupe会检测源文件中哪些容器发生了变化;当你运行`glupe project.txt -make`时,它只会调用AI来更新“脏”逻辑容器,并使用缓存的代码处理干净的容器,从而节省时间和API调用,并允许使用AI进行增量构建。 如果输出代码中有语法错误怎么办?Glupe有一个自我修复循环,它会将错误历史反馈给LLM,并告诉它修复错误。再也不需要繁琐的调试了。 我为什么说它是“代码的Docker”?这是一个比喻,它将隔离的核心原则应用于源文本,就像Docker将其应用于运行的进程一样。 在服务器中:如果你直接在主机操作系统上运行一个应用程序,它具有“根访问权限”。如果它表现不佳,可能会删除系统文件。 在编码中:如果你给AI访问你的文件,它也具有“根访问权限”。它可以通过删除手动代码或更改签名来“崩溃”你的架构。 Docker保护操作系统不受应用程序的影响,而Glupe则保护你的架构不受AI的影响。 Docker解决了“在我的机器上可以运行”的问题,而Glupe旨在解决“我写了一份白皮书”这个问题,白皮书在仓库中可用。 欢迎并鼓励任何反馈或批评。 仓库链接: [https://github.com/alonsovm44/glupe](https://github.com/alonsovm44/glupe) 白皮书链接: [https://github.com/alonsovm44/glupe/blob/master/glupec.cpp](https://github.com/alonsovm44/glupe/blob/master/glupec.cpp)
查看原文
Hello HN, i want to share Glupe, a hobby project I&#x27;ve been working on for the last 30 days. Nothing fancy.<p>I&#x27;ve been pretty annoyed by the &quot;all or nothing&quot; approach of most AI coding tools, which are useful, yes, but also risky. If i tell an AI to &quot;fix this bug&quot; it may probably do it, but it can (or will) hallucinate a fake library, mess up my manually optimized code or subtly delete important code without explaination or notice.<p>Glupe summarized is this: &quot;Stop giving AI root access to your code, Glupe isolates AI logic into semantic containers, so your code stays safe&quot;.<p>Instead of sending your whole file to the LLM and pray it does not break, with Glupe you can surgically tell the AI were to write code and what to do using the $${ logic }$$ syntax. Code outside the container is preserved as is. Instructions inside the container are turned into source code and embedded into the output file.<p>Containers can be named and are cached and hashed, Glupe detects which containers changed in a source file; when you run `glupe project.txt -make` it only calls the AI to update the &quot;dirty&quot; logic containers and uses cached code for the clean ones, saving time and API calls and allowing for incremental builds using AI.<p>What if there is a syntax error on the output code? Glupe has a self-healing loop which feeds the error history back to the LLM and tells it to fix it. No more trivial debugging.<p>Why do I say it is &quot;Docker for code&quot;? It is a metaphor, it applies the same core principle of Isolation to source text that Docker applies to running processes.<p>In Servers: If you run an app directly on a host OS, it has &quot;root access.&quot; If it behaves badly, it can delete system files.<p>In Coding: If you give an AI access to your file, it has &quot;root access.&quot; It can &quot;crash&quot; your architecture by deleting manual code or changing signatures. Docker protects the OS from the App. Glupe protects your Architecture from the AI.<p>Docker solved &quot;it works on my machine&quot;, Glupe aims to solve &quot;<p>I wrote a white papaer on the subject which is available in the repo.<p>Any feedback or critcism is welcome and encouraged.<p>repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;glupe" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;glupe</a> white paper:<a href="https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;glupe&#x2F;blob&#x2F;master&#x2F;glupec.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;glupe&#x2F;blob&#x2F;master&#x2F;glupec.cpp</a>