feat(cli): thread poke — re-run head step with supplementary prompt #148
Reference in New Issue
Block a user
Delete Branch "fix/144-thread-poke"
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
Adds a new
uwf thread poke <thread-id> -p <prompt>CLI command that re-runs the head step's agent with a supplementary prompt and replaces the current head step output. Phase 1 of Issue #144.Why
Sometimes the head step produced a near-correct answer but needs a small nudge — e.g. "explain the trade-off more", "use TypeScript instead".
resumerequires a$SUSPENDand runs the moderator; we want a lightweight in-place re-run that keeps the role and graph position fixed.Changes
packages/cli/src/commands/thread.tscmdThreadPoke()+ helpersvalidatePokePreconditions()andresolveCurrentRoleFromChain(). New log tagPL_THREAD_POKE = "P4Q9R3X7"packages/cli/src/cli.tsthread pokesubcommand:<thread-id>,-p, --prompt <text>(required),--agent <cmd>(optional)packages/cli/src/__tests__/thread-poke.test.ts.changeset/thread-poke.md@united-workforce/cliReplace semantics
After the agent step is created (with
prev = oldHead),cmdThreadPokesynthesizes a new StepNode whoseprevis the old head's prev, persists it, and updates the thread head — so the chain ends up with the new step replacing the old head, not appended after it. Moderator routing is not re-evaluated.Guards
Rejects threads that are running (background marker), completed, cancelled, or whose head is a StartNode.
Atomic rollback
Agent failure exits non-zero before any thread head update — the thread head remains pointing at the old step (verified by test 6.2).
Test results
thread-poketests passpnpm run check(Biome lint + log-tag validation),typecheck, andbuildall passRef
Fixes #144
LGTM ✅
Replace 语义正确(重写 prev 指针),guards 全面,atomic rollback 到位,19 个测试覆盖完整。
⚠️ Minor note: agent 中间产物和旧 head 成为 CAS 孤儿节点,但这是 CAS GC 的通用问题,不阻塞。
3c1fb1b71fto21694c899f21694c899ftoe4c46c8150