ARTICLE · INTELLIGENCE

战地情报 · 详情页

来自尧图项目组的一线实战观察与深度解析

oh-my-claudecode 委派类别(Delegation Categories)实战指南:在 ComplexityTier 之上构建语义化任务分级与模型路由

oh-my-claudecode 委派类别(Delegation Categories)实战指南:在 ComplexityTier 之上构建语义化任务分级与模型路由 oh-my-claudecode 委派类别Delegation Categories实战指南在 ComplexityTier 之上构建语义化任务分级与模型路由【免费下载链接】oh-my-claudecodeTeams-first Multi-agent orchestration for Claude Code项目地址: https://gitcode.com/GitHub_Trending/oh/oh-my-claudecode导读本文聚焦 oh-my-claudecode 中的 Delegation Categories委派类别特性讲解它如何在底层 ComplexityTier复杂度分级系统之上提供一层语义化接口让开发者用ultrabrain、quick、writing等可读名称一次性地同时决定模型的复杂度档位tier、采样温度temperature、思考预算thinking budget与提示词附加指导prompt appendix。读完本文你将掌握 7 个内置类别的完整参数矩阵、自动检测与显式控制两种解析路径、与 Model Routing 系统的协作方式以及如何在任务委派与编排器中落地集成。一、背景为什么需要语义化委派类别oh-my-claudecode 的任务委派原本直接面向ComplexityTierLOW/MEDIUM/HIGH三档由 model-routing 系统 依据任务复杂度自动选择模型默认LOW→haiku、MEDIUM→sonnet、HIGH→opus见 TIER_TO_MODEL_TYPE。这种按“难度”分级的模型在选择上很高效但在使用上不够语义化——开发者需要自行把“设计一个漂亮的仪表盘”“排查一个并发竞态问题”这类任务翻译成 LOW/MEDIUM/HIGH 档位还得另外去设定温度和思考预算。Delegation Categories 正是为解决这一痛点而生它在 delegation-categories 模块 中定义了一组带语义名称的类别每个类别把tier、temperature、thinkingBudget、promptAppend四项配置打包在一起。从源码看其核心设计原则是“叠加而非取代”Layer, Dont Replace类别最终仍解析为ComplexityTier模型选择依旧由 tier 系统完成类别只是让调用方可以用更自然的方式触发它。二、内置类别全景参数矩阵与适用场景所有类别的配置集中定义在 CATEGORY_CONFIGS每个类别映射四个维度Complexity TierLOW/MEDIUM/HIGH决定最终使用的模型档位Temperature0–1 之间的采样温度控制输出的随机性与创造性Thinking Budget扩展思考extended thinking的 token 预算级别Prompt Appendix类别专属的提示词附加指导会在委派时追加到任务提示词尾部。visual-engineering视觉工程Tier: HIGH | Temperature: 0.7 | Thinking: high10k tokens面向 UI/视觉推理、前端工作、设计系统与美学决策。适合组件设计与样式布局与响应式设计视觉层级与无障碍accessibility动画与交互设计const config resolveCategory(visual-engineering); // - tier: HIGH, temperature: 0.7, model: opus其源码中的 promptAppend 为Focus on visual design, user experience, and aesthetic quality. Consider accessibility, responsive design, and visual hierarchy.ultrabrain超脑Tier: HIGH | Temperature: 0.3 | Thinking: max32k tokens面向复杂推理、架构决策、深度调试与系统性分析。适合架构与设计模式复杂调试与根因分析性能优化并发与竞态条件分析const config resolveCategory(ultrabrain); // - tier: HIGH, temperature: 0.3, model: opus, max thinkingpromptAppend 要求模型“深入且系统地思考考虑所有边界情况、影响与长期后果逐步推理问题”。artistry艺术创作Tier: MEDIUM | Temperature: 0.9 | Thinking: medium5k tokens面向创意写作、新颖方法与创新方案。适合创造性问题求解挑战的新颖方案头脑风暴与构思探索性设计const config resolveCategory(artistry); // - tier: MEDIUM, temperature: 0.9, model: sonnet它是全部类别中 temperature 最高0.9的体现“低确定性、高发散性”的创作定位。quick快速查询Tier: LOW | Temperature: 0.1 | Thinking: low1k tokens面向简单查找、直接任务与基础操作。适合查找文件或函数简单搜索操作基础信息检索快速状态检查const config resolveCategory(quick); // - tier: LOW, temperature: 0.1, model: haiku对应最低的 temperature0.1强调准确性优先、避免发散。writing写作Tier: MEDIUM | Temperature: 0.5 | Thinking: medium5k tokens面向文档、技术写作与内容创作。适合API 文档README 文件技术指南与教程代码注释与说明const config resolveCategory(writing); // - tier: MEDIUM, temperature: 0.5, model: sonnetunspecified-low / unspecified-high默认类别Tiers: LOW / HIGH当未检测到特定类别、或调用方显式提供了 tier 时使用作为兜底默认值。其中unspecified-low的 temperature 为 0.3unspecified-high为 0.5两者均无 promptAppend。思考预算的 token 映射类别使用符号化的预算级别实际 token 数由 THINKING_BUDGET_TOKENS 定义预算级别Token 数low1000medium5000high10000max32000三、核心 API从解析到增强的完整调用链模块对外导出的函数集中在 delegation-categories/index.ts类型定义见 types.ts。以下按使用场景逐一说明。3.1 基础用法resolveCategoryresolveCategory(category)把一个类别解析为完整配置返回ResolvedCategory在CategoryConfig基础上附带category字段import { resolveCategory } from ./delegation-categories; // Resolve a category to full configuration const config resolveCategory(ultrabrain); console.log(config.tier); // HIGH console.log(config.temperature); // 0.3 console.log(config.thinkingBudget); // max console.log(config.promptAppend); // Category-specific guidance对未知类别resolveCategory会抛出Unknown delegation category: name错误。3.2 自动检测getCategoryForTaskgetCategoryForTask(context)是日常委派时最常用的入口其解析优先级在源码中有明确顺序index.ts#L233-L253显式 tierexplicitTier直接绕过类别系统LOW映射到unspecified-low否则映射到unspecified-high显式类别explicitCategory直接解析该类别自动检测detectCategoryFromPrompt对任务提示词做关键词匹配兜底默认以上均未命中时返回unspecified-high。import { getCategoryForTask } from ./delegation-categories; // Auto-detect category from task prompt const detected getCategoryForTask({ taskPrompt: Design a beautiful dashboard with responsive layout }); console.log(detected.category); // visual-engineering console.log(detected.tier); // HIGH3.3 显式控制当关键词检测不准确或调用方已明确任务性质时可以显式指定// Explicit category const explicitCat getCategoryForTask({ taskPrompt: Some task, explicitCategory: ultrabrain }); // Explicit tier (bypasses categories) const explicitTier getCategoryForTask({ taskPrompt: Some task, explicitTier: LOW // Uses unspecified-low category });3.4 提示词增强enhancePromptWithCategoryenhancePromptWithCategory(taskPrompt, category)把类别对应的 promptAppend 追加到任务提示词之后实现“类别专属指导”注入若类别没有 promptAppend 则原样返回import { enhancePromptWithCategory } from ./delegation-categories; const basePrompt Create a login form; const enhanced enhancePromptWithCategory(basePrompt, visual-engineering); // Appends category-specific guidance about UX, accessibility, etc.3.5 工具函数模块还提供一组轻量访问器便于在不解析完整配置时快速取属性import { isValidCategory, getAllCategories, getCategoryDescription, getCategoryTier, getCategoryTemperature, getCategoryThinkingBudget, getCategoryThinkingBudgetTokens, } from ./delegation-categories; // Validation if (isValidCategory(ultrabrain)) { // Valid category } // Get all categories const categories getAllCategories(); // - [visual-engineering, ultrabrain, artistry, ...] // Get description const desc getCategoryDescription(ultrabrain); // - Complex reasoning, architecture decisions, deep debugging // Extract specific properties const tier getCategoryTier(ultrabrain); // HIGH const temp getCategoryTemperature(artistry); // 0.9 const budget getCategoryThinkingBudget(quick); // low const tokens getCategoryThinkingBudgetTokens(ultrabrain); // 32000对应的单测 index.test.ts 验证了这些访问器与CATEGORY_CONFIGS配置表的一致性对每个类别resolveCategory的结果必须等于{ category, ...config }且各个 getter 的返回值与配置表中的description、tier、temperature、thinkingBudget、token 换算、promptAppend一一对应。四、自动检测原理关键词打分机制detectCategoryFromPromptindex.ts#L185-L225的实现是一个轻量的关键词打分器把任务提示词转为小写遍历每个类别在CATEGORY_KEYWORDS中注册的关键词列表命中一个计 1 分在排除unspecified-*前缀类别后取得分最高的类别置信门槛只有最高分 ≥ 2即至少命中 2 个关键词才返回结果否则返回null由getCategoryForTask落到默认类别。各类的关键词举例完整列表见 index.ts#L105-L130visual-engineeringui、ux、design、frontend、component、style、css、visual、layout、responsive、dashboard、form、button、theme、color、typography、animation、interactiveultrabrainarchitecture、design pattern、refactor、optimize、debug、root cause、analyze、investigate、complex、system、performance、scalability、concurrency、race conditionquickfind、search、locate、list、show、get、fetch、where is、what is、display、print、lookupwritingdocument、readme、comment、explain、describe、write、draft、article、guide、tutorial、docs。源码注释特别说明了CATEGORY_KEYWORDS与 model-routing 中COMPLEXITY_KEYWORDS的关系model-routing/types.ts#L237-L254二者关键词存在有意重叠但职责不同——COMPLEXITY_KEYWORDS用于基于复杂度选择模型档位haiku/sonnet/opusCATEGORY_KEYWORDS用于通过 promptAppend 提供语义上下文增强指导同一提示词可以同时被两套系统命中互不冲突。五、向后兼容新旧调用方式并行类别系统与直接指定 tier 完全兼容两条路径最终都收敛到ComplexityTier// Old way (still works) const config getCategoryForTask({ taskPrompt: Task, explicitTier: HIGH // Direct tier }); // New way (preferred) const config2 getCategoryForTask({ taskPrompt: Task, explicitCategory: ultrabrain // Semantic category }); // Both resolve to ComplexityTier console.log(config.tier); // HIGH console.log(config2.tier); // HIGH这种兼容性由getCategoryForTask内部的优先级逻辑保证explicitTier分支把 tier 直接映射到unspecified-*类别不需要破坏旧的调用方。六、架构与调用链模块整体架构如下CategoryContext └─ detectCategoryFromPrompt() └─ resolveCategory() └─ CategoryConfig { tier, temperature, thinkingBudget } └─ ComplexityTier (LOW/MEDIUM/HIGH) └─ Model Selection (haiku/sonnet/opus)类别是覆盖在 tier 系统之上的语义层。tier 系统负责模型选择因此类别既不会绕过也不会取代它而是增强它。模型档位到具体模型 ID 的映射定义在 config/models.ts默认HIGH→claude-opus-4-8、MEDIUM→claude-sonnet-5、LOW→claude-haiku-4-5见 BUILTIN_TIER_MODEL_DEFAULTS并可通过环境变量OMC_MODEL_HIGH/OMC_MODEL_MEDIUM/OMC_MODEL_LOW覆盖。七、运行测试运行模块自带的手工测试脚本npx tsx src/features/delegation-categories/test-categories.tstest-categories.ts 覆盖 8 组用例resolveCategory全类别解析、isValidCategory校验、getCategoryDescription、基于多组提示词的detectCategoryFromPrompt含无关键词命中返回null的场景、getCategoryForTask的显式 tier / 显式类别 / 自动检测三路径、tier/temperature/thinkingBudget/token 提取、enhancePromptWithCategory增强效果、以及所有类别到 tier 的向后兼容映射。单元测试位于tests/index.test.ts。八、集成点与编排落地8.1 系统内的集成面Model Routingmodel-routing类别解析为ComplexityTier进而通过TIER_MODELS选择模型任务委派委派给 agent 时可指定类别联动 tier 与温度配置编排编排器Orchestrator可用类别做语义路由例如按检测到的类别分发给 designer、architect、writer 等不同 agent。8.2 委派中的组合用法在任务委派中可以先解析类别拿到模型、温度与思考预算再组装最终提示词import { getCategoryForTask } from ./features/delegation-categories; import { TIER_MODELS } from ./features/model-routing; async function delegateTask(taskPrompt: string, category?: string) { const resolved getCategoryForTask({ taskPrompt, explicitCategory: category as any, }); console.log(Delegating as ${resolved.category}:); console.log( Model: ${TIER_MODELS[resolved.tier]}); console.log( Temperature: ${resolved.temperature}); console.log( Thinking: ${resolved.thinkingBudget}); const finalPrompt resolved.promptAppend ? ${taskPrompt}\n\n${resolved.promptAppend} : taskPrompt; return await delegateToAgent({ prompt: finalPrompt, model: TIER_MODELS[resolved.tier], temperature: resolved.temperature, }); }8.3 编排器中的语义路由编排器可以基于检测到的类别做 switch 路由把任务分派给对应专业 agent并把tier、temperature、promptAppend作为该 agent 的运行参数传入。类别与 agent 的映射参考来自 INTEGRATION.md类别推荐 Agentvisual-engineeringdesignerultrabrainarchitectartistrydesigner高创造性quickexplorerwritingwriterunspecified-lowexecutor-lowunspecified-highexecutor九、设计决策与最佳实践9.1 五个核心设计决策叠加而非取代Layer, Dont Replace类别位于 tier 之上而非替代 tier语义化分组Semantic Grouping为常见任务模式提供有意义的名字完整配置Full Configuration每个类别打包 tier temperature thinking budget promptAppend向后兼容Backward Compatible直接指定 tier 依旧可用自动检测Auto-Detection关键词匹配提供便利显式控制随时可覆盖。9.2 使用建议当你知道任务的类型设计、调试、创作时用类别当你知道难度时直接用 tier自动检测对常见模式是可靠的但显式类别/显式 tier 优先级更高需要精确控制时务必显式指定用promptAppend为委派提示词注入类别专属指导关注成本ultrabrain、visual-engineering属于 HIGH tier会走 Opus 档模型。9.3 排查指引类别未检测到自动检测默认落到unspecified-high。可补充提示词中的关键词、改用显式类别或扩展 CATEGORY_KEYWORDS档位选择不符预期检查CATEGORY_CONFIGS定义并与显式 tier 的向后兼容路径核对温度偏高/偏低解析配置后做局部覆盖例如{ ...resolveCategory(artistry), temperature: 0.5 }。十、未来扩展方向模块文档列出的潜在增强包括agent 专属的类别默认值、用户自定义类别、根据成功委派学习类别偏好、以及用模型分析实现动态类别检测。这些方向都建立在当前“语义层 tier 映射”的稳定内核之上读者若需要在此基础上扩展可直接在 delegation-categories 目录内着手。结语Delegation Categories 是 oh-my-claudecode 委派体系中的一层轻量语义抽象它把“选模型、调温度、配思考预算、注入提示词”这四件事收敛为一个可读的类别名同时严格保持与底层 ComplexityTier / Model Routing 的兼容性。理解其参数矩阵、解析优先级与关键词检测机制你就可以在自己的任务委派与编排逻辑中以极低的侵入成本获得更清晰、更可控、更省成本的多 agent 路由能力。【免费下载链接】oh-my-claudecodeTeams-first Multi-agent orchestration for Claude Code项目地址: https://gitcode.com/GitHub_Trending/oh/oh-my-claudecode创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
RELATED READING

延伸阅读

更多一线实战笔记与深度复盘,助您持续精进