Show HN: Docgen – C++ AI 命令行工具,利用本地 LLM 解决文档编写难题

1作者: alonsovm5 个月前
Hi HN, 我是一个独立开发者,厌倦了“文档地狱”,要么花几个小时写文档,结果文档很快就过时了,要么干脆没有文档。我想要一个工具,将文档生成视为一个标准的构建步骤,所以我开发了Docgen。 Docgen是一个用C++编写的轻量级AI CLI工具,它将文档视为代码进行处理。它位于你的代码库中(通过一个.docgen文件夹和一个Docfile),并在你的源代码旁边生成Markdown文件。 以下是一些关于其工作原理的技术细节: - 本地优先 & 私有:它默认使用本地的Ollama,这样你的专有代码永远不会离开你的机器(尽管如果你愿意,它也支持像OpenAI/Gemini这样的云API)。 - 智能增量构建:它使用内容哈希。当你运行docgen update时,它只重新生成实际更改过的文件的文档,从而节省大量的API积分和计算时间。 - 上下文感知(RAG):它会自动分析#include依赖关系,为LLM提供正确的上下文,而不是盲目地向它提供单个文件。 - 零依赖:编译成一个单一的静态二进制文件。只需下载并运行即可。 - “自动”模式:这是我最喜欢的部分。如果你运行“docgen auto”,它会充当一个文件监视器,并内置了防抖动功能(在你停止输入/保存后等待几秒钟)。它会在后台默默地更新你的Markdown文档,让你保持流畅的开发状态。 我目前专注于改进RAG上下文处理。 你可以在这里查看:[https://github.com/alonsovm44/docgen](https://github.com/alonsovm44/docgen) 我很乐意听取你的想法,对架构的批评,或者你认为我应该处理的任何边缘情况!
查看原文
Hi HN,<p>I’m a solo dev who got tired of the &quot;documentation hell&quot;, either spending hours writing docs that immediately become outdated, or having no docs at all. I wanted a tool that treats documentation generation as a standard build step, so I built Docgen.<p>Docgen is a lightweight AI CLI tool written in C++ that automates docs-as-code. It sits in your repo (via a .docgen folder and a Docfile) and generates Markdown files next to your source.<p>A few technical details on how it works under the hood:<p>- Local-First &amp; Private: It defaults to using Ollama locally so your proprietary code never leaves your machine (though it supports cloud APIs like OpenAI&#x2F;Gemini if you prefer).<p>- Smart Incremental Builds: It uses content hashing. When you run docgen update, it only regenerates docs for files that actually changed, saving massive amounts of API credits and compute time.<p>- Context-Aware (RAG): It automatically analyzes #include dependencies to give the LLM the right context, rather than just blind-feeding it a single file.<p>- Zero Dependencies: Compiled as a single static binary. Just download and run.<p>- The &quot;Auto&quot; Mode: This is my favorite part. If you run &quot;docgen auto&quot;, it acts as a file watcher with a built-in debounce (waits a few seconds after you stop typing&#x2F;saving). It quietly updates your Markdown docs in the background while you stay in your flow state.<p>I’m currently focused on improving the RAG context handling.<p>You can check it out here: <a href="https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;docgen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alonsovm44&#x2F;docgen</a><p>I&#x27;d love to hear your thoughts, critique on the architecture, or any edge cases you think I should handle!