feat(cli): thread poke — re-run head step with supplementary prompt #148

Merged
scottwei merged 1 commits from fix/144-thread-poke into main 2026-06-07 07:53:27 +00:00
Owner

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". resume requires a $SUSPEND and runs the moderator; we want a lightweight in-place re-run that keeps the role and graph position fixed.

Changes

File Change
packages/cli/src/commands/thread.ts Added cmdThreadPoke() + helpers validatePokePreconditions() and resolveCurrentRoleFromChain(). New log tag PL_THREAD_POKE = "P4Q9R3X7"
packages/cli/src/cli.ts Registered thread poke subcommand: <thread-id>, -p, --prompt <text> (required), --agent <cmd> (optional)
packages/cli/src/__tests__/thread-poke.test.ts 19 new test cases — full coverage of the planner's TDD spec (CLI args, guards, success path, agent resolution, prompt passthrough, edge cases)
.changeset/thread-poke.md Minor bump for @united-workforce/cli

Replace semantics

After the agent step is created (with prev = oldHead), cmdThreadPoke synthesizes a new StepNode whose prev is 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

  • 19/19 new thread-poke tests pass
  • 834/834 total monorepo tests pass
  • pnpm run check (Biome lint + log-tag validation), typecheck, and build all pass

Ref

Fixes #144

## 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". `resume` requires a `$SUSPEND` and runs the moderator; we want a lightweight in-place re-run that keeps the role and graph position fixed. ## Changes | File | Change | |------|--------| | `packages/cli/src/commands/thread.ts` | Added `cmdThreadPoke()` + helpers `validatePokePreconditions()` and `resolveCurrentRoleFromChain()`. New log tag `PL_THREAD_POKE = "P4Q9R3X7"` | | `packages/cli/src/cli.ts` | Registered `thread poke` subcommand: `<thread-id>`, `-p, --prompt <text>` (required), `--agent <cmd>` (optional) | | `packages/cli/src/__tests__/thread-poke.test.ts` | 19 new test cases — full coverage of the planner's TDD spec (CLI args, guards, success path, agent resolution, prompt passthrough, edge cases) | | `.changeset/thread-poke.md` | Minor bump for `@united-workforce/cli` | ### Replace semantics After the agent step is created (with `prev = oldHead`), `cmdThreadPoke` synthesizes a new StepNode whose `prev` is 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 - 19/19 new `thread-poke` tests pass - 834/834 total monorepo tests pass - `pnpm run check` (Biome lint + log-tag validation), `typecheck`, and `build` all pass ## Ref Fixes #144
xiaomo approved these changes 2026-06-07 06:14:13 +00:00
xiaomo left a comment
Owner

LGTM

Replace 语义正确(重写 prev 指针),guards 全面,atomic rollback 到位,19 个测试覆盖完整。

⚠️ Minor note: agent 中间产物和旧 head 成为 CAS 孤儿节点,但这是 CAS GC 的通用问题,不阻塞。

LGTM ✅ Replace 语义正确(重写 prev 指针),guards 全面,atomic rollback 到位,19 个测试覆盖完整。 ⚠️ Minor note: agent 中间产物和旧 head 成为 CAS 孤儿节点,但这是 CAS GC 的通用问题,不阻塞。
xiaoju force-pushed fix/144-thread-poke from 3c1fb1b71f to 21694c899f 2026-06-07 07:07:54 +00:00 Compare
xiaoju added 1 commit 2026-06-07 07:19:34 +00:00
feat(cli): add thread poke command
CI / check (pull_request) Successful in 3m43s
e4c46c8150
Re-runs the head step's agent with a supplementary prompt and replaces
the head step (rewires new step's prev to old head's prev) instead of
appending. Skips moderator re-route — the role of the head step is
reused.

Fixes #144
xiaoju force-pushed fix/144-thread-poke from 21694c899f to e4c46c8150 2026-06-07 07:19:34 +00:00 Compare
scottwei merged commit 4c5cc27d52 into main 2026-06-07 07:53:27 +00:00
scottwei deleted branch fix/144-thread-poke 2026-06-07 07:53:27 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#148