refactor(workflow-utils): Role factory templates — createCursorRole, createHermesRole, createLlmRole, createReActRole #208
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Summary
Refocus
@uncaged/nerve-workflow-utilsfrom a grab-bag of utilities into a Role factory package. The public API should be template functions that createRole<Meta>instances for common agent types.Public API
Design Decisions
1. Meta Extraction — all Roles need
extractAgents only guarantee
content: string. Structured metadata is extracted via a separate cheap LLM call (llmExtract) with a Zod schema + tool_choice constraint.Internal flow:
agent executes → content → llmExtract(content, schema) → RoleResult<Meta>2. Prompt — two shapes for two categories
CLI Roles (Cursor / Hermes) — return a single string prompt. The agent fetches richer context itself via
nerve thread/ MCP. Keep it simple to avoid shell escaping issues.API Roles (LLM / ReAct) — return a full message array for chat completions.
3. Required vs Defaults — no nullable, no optional properties
Required params = no reasonable default, caller must provide.
Default params = have sensible defaults, caller can override via
Partial<Defaults>.No
| null, no?:— use default values as fallback.Type Definitions
Cursor
Hermes
No
cwd(Hermes decides where to work).yoloalways on (non-interactive).toolsetsnot exposed (all enabled by default).LLM
No defaults — all params are required.
ReAct
Existing Code
Current utils (
spawnSafe,llmExtract,schemaDefaults,readNerveYaml, etc.) stay as internal utils within the package. No other package depends onworkflow-utils, so no migration needed.Tasks
MetaExtractConfig,CliPromptFn,LlmPromptFn,LlmMessage,ReActTool)createCursorRolecreateHermesRolecreateLlmRolecreateReActRoleindex.tsexports — role factories as primary API小橘 🍊(NEKO Team)