尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

ruflo 文档自动生成与漂移检测实战:基于 doc-gen Skill 的 document Worker 调度全解析

ruflo 文档自动生成与漂移检测实战:基于 doc-gen Skill 的 document Worker 调度全解析 ruflo 文档自动生成与漂移检测实战基于 doc-gen Skill 的 document Worker 调度全解析【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/rufloruflo 通过doc-genSkill 将文档生成、更新与漂移检测能力封装成可复用的 Agent 技能底层依赖document后台 Worker 与 MCP 工具链完成大规模文档作业。本文将围绕该 Skill 的完整用法展开包括 CLI 与 MCP 两种调度路径、api/full作用域语义、漂移检测原理、定时维护配置以及配套的api-docsSkill、docs-writerAgent 与 smoke 验证契约帮助你在 ruflo 生态中搭建可持续的文档自动化流水线。一、Skill 定位与能力边界doc-genSkill 位于 plugins/ruflo-docs/skills/doc-gen/SKILL.md它的 Frontmatter 定义了技能的触发语义与权限范围name: doc-gen description: Generate and maintain documentation with drift detection. Use when the user asks to write/update/refresh docs, detect doc drift against code, or schedule recurring documentation maintenance. argument-hint: [--target PATH] allowed-tools: Bash(npx *) mcp__plugin_ruflo-core_ruflo__hooks_worker-dispatch mcp__plugin_ruflo-core_ruflo__memory_store CronCreate Read Writedescription明确该技能适用于写/更新/刷新文档、检测代码与文档漂移、安排周期性文档维护三类场景argument-hint[--target PATH]表示可接受可选的目标路径参数allowed-tools只放行必要工具——Bash(npx *)用于执行 CLI 命令hooks_worker-dispatch用于触发文档 Workermemory_store用于持久化方案模式CronCreate用于定时任务Read/Write用于读写文档文件。从工具白名单可以看出该 Skill 刻意保持最小权限文档生成的实际计算发生在document后台 Worker 中Skill 本身只负责调度与状态记录。与 api-docs Skill 的分工同目录下的 plugins/ruflo-docs/skills/api-docs/SKILL.md 是互补技能doc-gen面向全量或指定路径的文档生成/刷新与漂移检测api-docs面向 API 文档的专项生成——扫描 TypeScript/JavaScript 公开导出解析param、returns、throws、example注解为未注释的公开 API 补齐 JSDoc并为 HTTP 端点生成 OpenAPI 3.0 定义。两者的调度入口一致均通过hooks_worker-dispatch携带trigger: document触发只是 scope 不同api与full/缺省。二、两条调度路径MCP 与 CLIdoc-genSkill 提供了两条等价的 Worker 调度路径。1. MCP 工具调用Agent 内嵌使用Agent 在对话上下文中直接调用 MCP 工具无需离开当前会话mcp__plugin_ruflo-core_ruflo__hooks_worker-dispatch({ trigger: document })完整的工具名称为mcp__plugin_ruflo-core_ruflo__hooks_worker-dispatch其中plugin_ruflo-core_ruflo是 MCP 服务前缀hooks_worker-dispatch是实际工具名。该工具由ruflo-core插件提供这也是 ruflo-docs 的硬依赖详见 plugins/ruflo-docs/README.md 的 Requires 一节。需要指定作用域时在调用中附加scope字段即可。等价命令行的写法是mcp tool call hooks_worker-dispatch --json -- {trigger: document, scope: api}2. CLI 命令终端手动执行对于人类用户或 CI 流水线推荐使用claude-flow/cli的 hooks 子命令# 全量项目文档生成 npx claude-flow/clilatest hooks worker dispatch --trigger document # 仅生成 API 文档 npx claude-flow/clilatest hooks worker dispatch --trigger document --scope apidoc-genSkill 中给出的完整示例为# API 文档 npx claude-flow/clilatest hooks worker dispatch --trigger document --scope api # 全量项目 npx claude-flow/clilatest hooks worker dispatch --trigger document --scope full3. Scope 语义对照根据 plugins/ruflo-docs/README.md 的 Document-worker contract 表格--scope的取值决定输出内容Scope输出缺省全项目文档生成api基于 JSDoc/TSDoc 的 API 参考 HTTP 端点的 OpenAPI 3.0 定义file-path单文件文档生成也就是说--scope full与缺省--trigger document的效果一致都执行全项目文档作业传入具体文件路径则可实现单文件粒度这也与argument-hint: [--target PATH]相呼应。三、document 后台 Worker12 个后台 Worker 之一触发链路的终端是document后台 Worker。根据 plugins/ruflo-loop-workers/README.mdruflo 共定义了 12 个后台 Workerultralearn、optimize、consolidate、predict、audit、map、preload、deepdive、document、refactor、benchmark、testgaps其中document专门负责生成 API 文档 漂移检测。Worker 的调度参数在 plugins/ruflo-loop-workers/agents/loop-worker-coordinator.md 中有明确记录Worker优先级触发机制调度节奏documentnormaldocument触发600s 循环 /0 */2 * * *cron这解释了doc-genSkill 中定时维护示例的来历——每 2 小时触发一次文档 Worker 的 cron 表达式正是 Worker 的推荐节奏。四、持续文档维护CronCreate 定时任务doc-gen支持将文档维护固化为定时任务示例CronCreate({ schedule: 0 */2 * * *, prompt: Run document worker })schedule: 0 */2 * * *标准 cron 五段表达式每小时的第 0 分钟触发即每 2 小时运行一次prompt: Run document worker任务到期后注入给 Agent 的提示词用于唤起文档 Worker 作业。该节奏与 plugins/ruflo-loop-workers/agents/loop-worker-coordinator.md 中documentWorker 的 cron 推荐值0 */2 * * *完全一致。将CronCreate与 Worker 调度组合使用即可实现代码演进 → 定期文档刷新 → 漂移检出的闭环。五、漂移检测代码与文档的一致性守卫漂移检测Drift Detection是doc-gen的核心职责之一Skill 原文的描述是Detect drift by comparing current code against existing docs and flagging inconsistencies.即比较当前代码与既有文档标记不一致之处。底层执行逻辑由 plugins/ruflo-docs/agents/docs-writer.md 中的docs-writerAgent 承担其漂移检测工作流为用Grep搜索源码中的export语句用Read读取对应的既有文档标记未记录的导出与过期文档。ruflo-docs 插件还声明了专用的docs-driftAgentDB 命名空间用于存放漂移检测状态每个文件上次看到的导出哈希。该命名空间遵循 plugins/ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md 中约定的 kebab-case 命名规范并通过memory_*工具命名空间路由访问且不得遮蔽pattern、claude-memories、default等保留命名空间详见 plugins/ruflo-docs/README.md 的 Namespace coordination 一节。六、模式沉淀memory_store 持久化doc-gen的最后一步是把成功方案写入长期记忆mcp__plugin_ruflo-core_ruflo__memory_store({ key: doc-pattern, value: APPROACH, namespace: patterns })key: doc-pattern模式键名value: APPROACH本次采用的方案描述实际使用时替换为具体做法namespace: patterns写入patterns命名空间。这与docs-writerAgent 的神经学习机制一脉相承——plugins/ruflo-docs/agents/docs-writer.md 提供了任务完成后的训练钩子npx claude-flow/clilatest hooks post-task --task-id TASK_ID --success true --train-neural true通过--train-neural true将成功模式回灌到神经网络训练管线使后续文档任务越来越贴合项目自身的文档风格。七、完整工作流编排从 Skill 到 Worker 再到记忆综合以上要素一次完整的 doc-gen 调用形成如下链路识别需求用户请求写/刷新文档或发现漂移触发doc-genSkill确定 scope--target/--scope决定是单文件、API 还是全项目调度 Worker经 MCPhooks_worker-dispatch({ trigger: document, scope: ... })或 CLInpx claude-flow/clilatest hooks worker dispatch --trigger document [--scope ...]触发documentWorker漂移检测Worker/Agent 对比源码export与既有文档标记过期与缺失项生成文档按 JSDoc/TSDoc/OpenAPI 规范产出或更新文档沉淀模式memory_store写入doc-pattern并可通过post-task --train-neural true参与神经训练。配合CronCreate({ schedule: 0 */2 * * *, ... })该链路可升级为完全自动化的周期性维护无需人工介入。八、验证与契约smoke.sh 十项检查ruflo-docs 的可靠性由 plugins/ruflo-docs/scripts/smoke.sh 以smoke-as-contract方式保障共 10 项检查plugin.json声明版本0.2.1且包含jsdoc、openapi、mcp关键字plugins/ruflo-docs/.claude-plugin/plugin.json 中可确认版本与关键字api-docs与doc-gen两个 Skill 均存在且 Frontmatter 含name:、description:、allowed-tools:docs-writerAgent 与ruflo-docs命令文件存在文档中引用了hooks_worker-dispatch/hooks worker dispatch且带document触发语义README 将claude-flow/cli固定到 v3.6README 引用 ruflo-agentdb 命名空间约定docs-drift命名空间已被声明README 记录了 document-worker scope 表格ADR-0001 存在且状态为 Accepted见 plugins/ruflo-docs/docs/adrs/0001-docs-contract.mddocs-writerAgent 使用 Haiku 模型成本效益考量。运行验证bash plugins/ruflo-docs/scripts/smoke.sh # Expected: 10 passed, 0 failedADR-0001 将该契约固定为架构决策插件版本0.1.0 → 0.2.0现已到0.2.1、keywords 增加jsdoc/openapi/mcp、smoke 脚本成为发布门禁详见 plugins/ruflo-docs/docs/adrs/0001-docs-contract.md。九、相关配套命令、Agent 与生态联动除 Skill 外ruflo-docs 还提供一条命令与一个 Agent/ruflo-docs命令plugins/ruflo-docs/commands/ruflo-docs.md解析$ARGUMENTS确定 scope——文件路径生成单文件文档、api生成 API 文档、无参数执行全项目文档生成然后依次执行分析公开 API → 检测漂移 → 生成/更新文档 → 报告变更四步docs-writerAgentplugins/ruflo-docs/agents/docs-writer.md固定使用 Haiku 模型成本效率优先负责 API 文档、架构文档ADR、使用示例、CLI 帮助、插件文档五类产出支持 600s 循环或 cron 调度的 Worker 驱动方式。在 ruflo 生态中ruflo-loop-workers定义documentWorker、ruflo-agentdb提供命名空间约定、ruflo-adr在 ADR 状态变更时触发文档生成、ruflo-sparc的 Documenter 模式Phase 5 Refinement也会消费本插件——doc-genSkill 实际是整个文档自动化能力的统一入口plugins/ruflo-docs/README.md。结语doc-genSkill 虽短小却串联起 ruflo 文档自动化的完整链路以hooks_worker-dispatch触发documentWorker、以--scope控制粒度、以CronCreate实现周期性维护、以漂移检测守卫文档与代码的一致性、以memory_store沉淀模式、以 smoke.sh 固化发布契约。对于需要长期维护大型 TypeScript 项目的团队可据此搭建代码提交 → 文档自动生成 → 漂移告警 → 模式沉淀的可持续文档流水线。【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/ruflo创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表