feat(cli): step ask — read-only query to historical step sessions #156
Reference in New Issue
Block a user
Delete Branch "fix/146-step-ask"
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
uwf step ask <step-hash> -p "question"— a read-only query command that asks a follow-up question to a completed step's agent without mutating thread state.Why
Closes the Phase 2b gap from issue #146: with the Phase 2a fork / session-cache infrastructure already in place, agents need a way to be re-queried about past work without polluting the immutable thread chain. Useful for clarifications and exploratory diagnostics on historical decisions.
Changes
packages/cli/src/cli.ts— wirestep asksubcommand (-p,--agent,--no-fork).packages/cli/src/commands/step.ts—cmdStepAskplus helpers (parseAgentOverride,resolveAskAgentConfig,deriveAgentName,loadDetailNode,spawnAskAgent,resolveAskWorkflow,performFork).StepNode, no thread-state mutation.<stepHash>:ask; subsequent asks reuse it.--no-forkfallback: fresh session with the step's detail ref injected as context.--agentflag → config alias for recorded agent → step's recorded raw command.packages/cli/src/__tests__/step-ask.test.ts— 16 cases across 6 groups (CLI validation, CAS errors, success path, fork-cache semantics, fallback path, agent resolution).packages/cli/README.md—step askrow + examples in the Step Commands section.packages/util/src/usage-reference.ts—step askentry rendered byuwf prompt usage, with prose explaining fork-cache and--no-forksemantics..changeset/step-ask.md—@united-workforce/climinor,@united-workforce/utilpatch.Verification
pnpm run build✓pnpm run check(Biome + log tag validation) ✓pnpm run typecheck✓pnpm run test✓ (91 files / 867 tests, including 16 new cases)Ref
Fixes #146
LGTM ✅
仔细审了代码,核心要点:
Read-only 保证 — 全程只有 CAS
.get()读取,无put()/setThread()。唯一的写操作是 ask-session cache(独立于 CAS 层)。测试 3.2/3.3 显式验证 head 指针和 step count 不变。Fork-cache 设计 —
stepHash:ask键隔离正确。performFork 先查缓存再 spawn,测试 4.1/4.2/4.3 覆盖了创建、复用、per-step 独立性。Agent 解析 — 优先级链合理:--agent flag → config alias → recorded agent → raw command。
16 个测试 — 全部是真实 shell mock-agent 的集成测试,不是 import mock。6 组覆盖了 CLI 验证、CAS 错误、核心行为、fork 缓存、fallback 路径、agent 解析。
小问题记录(不阻塞合入):
detailRef !== nullguard 是 dead code(L525 已 fail 过){ stderr?: Buffer }用了?:,但属于 Node.js external boundary,pragmaticresolveAskWorkflow标了 async 但没有 awaitopts.fork !== false双重否定可简化小橘 solve-issue 流水线越来越成熟了 👏