用途
recursive-router 用于在 recursive-mode 与 recursive-subagent 已确立委派角色后,让路由由用户可编辑的 CLI/模型策略驱动,而非由控制器临时决定。它把有界的委派工作分发到外部 CLI 和模型,但不会放松 recursive-mode 的标准:外部输出在经主智能体依据真实文件、真实 diff 与真实递归产物验证之前,始终不可信。
主要能力
- 探测当前环境中可用的受支持 CLI,并生成发现清单。
- 查看 CLI id 与所声明模型的发现清单。
- 在写入策略前安全地配置经验证的 CLI/模型绑定。
- 将子智能体角色解析为已配置的 CLI/模型对。
- 当策略要求 ask 时,向用户询问未解析的角色绑定。
- 在路由 CLI 不可用时保留显式回退行为。
内置发现目标包括 codex、kimi、opencode。内置模型发现来源:codex 使用 codex app-server --listen stdio:// 的原生 model/list,不可用时回退到 ~/.codex/models_cache.json;kimi 使用 ~/.kimi/config.toml 中已配置的模型别名;opencode 使用 opencode models 中已配置/已认证的 CLI 清单。
使用方式
初始化、探测、验证与解析路由的脚本命令(原样保留):
python ./.recursive/scripts/recursive-router-init.py --repo-root .
python ./.recursive/scripts/recursive-router-probe.py --repo-root . --json
python ./.recursive/scripts/recursive-router-configure.py --repo-root . --set code-reviewer=codex:gpt-5.4-mini --json
python ./.recursive/scripts/recursive-router-invoke.py --repo-root . --role code-reviewer --prompt-file "./.recursive/run/<run-id>/router-prompts/code-reviewer-bundle.md" --json
python ./.recursive/scripts/recursive-router-validate.py --repo-root .
python ./.recursive/scripts/recursive-router-resolve.py --repo-root . --role code-reviewer --json
pwsh -NoProfile -File ./.recursive/scripts/recursive-router-probe.ps1 -RepoRoot . -Json
pwsh -NoProfile -File ./.recursive/scripts/recursive-router-configure.ps1 -RepoRoot . -Set code-reviewer=codex:gpt-5.4-mini -Json
pwsh -NoProfile -File ./.recursive/scripts/recursive-router-invoke.ps1 -RepoRoot . -Role code-reviewer -PromptFile "./.recursive/run/<run-id>/router-prompts/code-reviewer-bundle.md" -Json
规范路径:路由策略位于 /.recursive/config/recursive-router.json;发现清单位于 /.recursive/config/recursive-router-discovered.json。规范脚本名为 recursive-router-,旧的 recursive-router-cli- 仅作为兼容包装存在。
规范角色:orchestrator、analyst、planner、implementer、code-reviewer、memory-auditor、tester。orchestrator 在策略中显式存在,但默认保持 local-only 并回退到 local-controller;它负责最终集成、修复与验收。旧兼容别名:phase-auditor -> analyst、traceability-auditor -> planner、bounded-implementer -> implementer、test-reviewer -> tester。
推荐工作流:若无配置脚手架先运行 init;运行 probe 并检查发现清单;以紧凑的 role=cli:model 形式询问未解析绑定;用 configure 脚本应用绑定(保存前先验证);按 recursive-subagent 契约构建或刷新评审/提示包;确保配置文件存在且为最新;在委派执行前立即 resolve 角色;若决策为 external-cli,用 invoke 脚本派发并核对真实仓库状态;若失败则修复上下文或提示后重试同一路由角色。
委派载荷应包含:委派角色、活动阶段与产物路径、规范评审包/提示包路径、需阅读的上游文档(如 00-requirements.md、01-as-is.md、02-to-be-plan.md 或当前被审计产物)、以及由 recursive-subagent 或生成的评审包拥有的精确输出契约。
读取顺序:/.recursive/RECURSIVE.md、../recursive-subagent/SKILL.md、/.recursive/config/recursive-router.json、/.recursive/config/recursive-router-discovered.json、/.recursive/memory/skills/SKILLS.md 及相关委派评审或能力说明。
适用场景
需要将审计、审查或有界实现工作通过外部 CLI/模型进行路由式委派的 recursive-mode 工作流;需要在多个提供商(如 Codex、Kimi、Opencode)之间配置模型路由;需要为审计角色设置模型绑定;需要把 code-reviewer 等角色路由到特定 CLI。触发用语示例:route、routing、router、set model、set provider、configure routing、configure model routing、use <provider/model> for <role>。
限制
路由是 recursive-subagent 的扩展而非替代;当前 CLI/IDE/智能体会话是单一工作流控制器,路由 CLI 只是助手而非自主阶段管理者。除非用户明确调用路由并确认设置,否则不得扫描本地 CLI/提供商/模型状态。外部 CLI 是可选的。策略为 ask 时不得擅自编造绑定。任何路由输出都必须经主智能体依据真实仓库状态验证。不得让路由角色自行选择阶段、输入或验收标准。路由角色不拥有最终验收权。默认探测超时为 50000 ms,默认调用超时为 180000 ms。具体的本地启动器差异需在 cli_overrides 或 custom_clis 中记录,不应硬编码。关于收费、价格或平台等事实,资料未提供。