feat(cli): nerve workflow thread — agent-friendly context retrieval #77
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
Add
nerve workflow thread <runId>CLI command so that agents (Cursor, Hermes, OpenCode) can pull workflow thread context on demand instead of receiving it via CLI arguments (which breaks on escaping).Motivation
When a workflow role spawns an agent, the agent needs conversation history. Passing full context as CLI args is fragile (shell escaping, length limits). Instead, agents should self-serve:
Design
Two modes
Default mode (no
--before):--budget(default 8000 chars)... N messages omitted (use --before M to load) ...Pagination mode (
--before <round-id>):Output format
Each message:
round-id: 1-based sequential integer, derived at query time viaROW_NUMBER() OVER (ORDER BY id ASC)— no schema change needed[#<round> <role>] <ISO timestamp>---): YAML of the CommandEvent metadata (the structured fields from the role output)execute()results appear as roundsImplementation
Package:
packages/daemon(log-store.ts)getThreadRounds(runId: string): Array<{ round: number; role: string; ts: number; metadata: Record<string, unknown>; content: string }>methodROW_NUMBER() OVER (ORDER BY id ASC)onthread_command_eventrowsPackage:
packages/cli(commands/workflow.ts)threadsubcommand to the existingworkflowcommandrunId(positional),--before <round-id>(optional),--budget <chars>(default 8000)getThreadRounds(runId)--before: take first round + accumulate from end until >= budget. Insert omission hint in gap.--before N: accumulate backwards from round N-1 until >= budgetCommandEvent convention
For this to work, role
execute()must return CommandEvents with a consistent shape. The recommended convention:The
threadcommand treatstype,role, andcontentas reserved fields; everything else goes into the YAML frontmatter.Acceptance Criteria
nerve workflow thread <runId>shows first + last messages within budget--before <round>paginates backwards--budgetcontrols output size (default 8000)Notes
rolefield in CommandEvent is a new convention — existing workflows that dont set it can showunknownas fallback