feat: RFC-003 Adapter Plugin Architecture + Dynamic Prompts #243
Reference in New Issue
Block a user
Delete Branch "feat/rfc-003-adapter-packages"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adapter plugin architecture for RFC-003 — each agent adapter in its own package, AgentRegistry accepts factories.
Changes
AgentRegistry plugin model
createAgentRegistry(agents, adapterFactories)— adapter map as second paramDynamic prompts
RoleSpec.prompt: string | ((start, messages) => Promise<string>)compileWorkflowSpechandles both static and dynamicNew packages
@uncaged/nerve-adapter-cursor— cursor-agent CLI spawn@uncaged/nerve-adapter-hermes— hermes CLI subagent spawnIntegration
Testing
559 tests, all pass ✅
Ref: #234
✅ Hermes Agent Review — APPROVED
总评
Adapter 插件化 + 动态 prompt,架构演进方向正确。插件模式让 adapter 独立包管理,减少不必要依赖;dynamic prompt 解决了实际场景的刚需。
✅ 亮点
createAgentRegistry(agents, adapterFactories)第二参数注入工厂,echo 内置、cursor/hermes 通过 factory map 注册,扩展性好PromptInput = string | ((start, messages) => Promise<string>),compileWorkflowSpec里 3 行处理,简洁createCursorAdapter/createHermesAdapter工厂签名统一workflow-utils保留旧的createCursorRole/createHermesRole,re-export adapter 函数,不 break 现有 workflow⚠️ 需要关注
spawn-safe.ts重复 —adapter-cursor/src/spawn-safe.ts和adapter-hermes/src/spawn-safe.ts是完全相同的 186 行文件(跟workflow-utils/src/shared/spawn-safe.ts也高度重叠)。这是 copy-paste,后续改一个忘改另一个会出 bug。建议:@uncaged/nerve-spawn或放@uncaged/nerve-core里共享不阻塞合入,但建议开个 issue 跟踪。
defaultAgentAdapterFactories()每次调用都 import — kernel 里createCursorAdapter和createHermesAdapter是顶层 import,如果 adapter 包未安装会直接 crash。这符合 "no runtime fallback" 策略,但意味着 daemon 包必须 depend on 两个 adapter 包。确认这是有意为之(看 package.json diff 确认 daemon 加了依赖)✅💡 Minor
hermes-agent.ts只剩 re-export + options resolution,可以考虑把 options resolution 也移到 adapter-hermes 包,让 workflow-utils 更薄KNOWN_AGENT_ADAPTER_IDS现在有 cursor/hermes/codex,但 codex adapter 包还没建。不影响运行(validate 只检查 factory map),但 ID 列表和实际 adapter 不一致Reviewed by 小墨 🖊️