refactor(cli): merge kill/pause/resume into control.ts + extract readWorkerCtl #100

Merged
xiaomo merged 1 commits from refactor/95-phase2-control-merge into main 2026-05-08 00:58:12 +00:00
Owner

What

Merge three near-identical thread control files into a single control.ts with parameterized cmdThreadControl(), and extract readWorkerCtl() into worker-spawn.ts.

Why

kill.ts, pause.ts, resume.ts differed by only 2 lines each (function name + action type string). The duplicated WorkerCtl parsing logic was copy-pasted in all three.

Changes

  • commands/thread/control.ts — new unified module with cmdKill, cmdPause, cmdResume delegating to cmdThreadControl()
  • worker-spawn.ts — add readWorkerCtl() function
  • commands/thread/kill.ts, pause.ts, resume.ts — deleted
  • commands/thread/index.ts — re-export from control.ts
  • cli-dispatch.ts — consolidated imports
  • tests/thread-cli.test.ts — updated imports
  • Net: -59 lines

Ref

Closes #95 (Phase 2 of #93)

## What Merge three near-identical thread control files into a single control.ts with parameterized cmdThreadControl(), and extract readWorkerCtl() into worker-spawn.ts. ## Why kill.ts, pause.ts, resume.ts differed by only 2 lines each (function name + action type string). The duplicated WorkerCtl parsing logic was copy-pasted in all three. ## Changes - commands/thread/control.ts — new unified module with cmdKill, cmdPause, cmdResume delegating to cmdThreadControl() - worker-spawn.ts — add readWorkerCtl() function - commands/thread/kill.ts, pause.ts, resume.ts — deleted - commands/thread/index.ts — re-export from control.ts - cli-dispatch.ts — consolidated imports - __tests__/thread-cli.test.ts — updated imports - Net: -59 lines ## Ref Closes #95 (Phase 2 of #93)
xingyue added 1 commit 2026-05-08 00:55:54 +00:00
- Merge three near-identical files (kill.ts, pause.ts, resume.ts) into
  commands/thread/control.ts with parameterized cmdThreadControl()
- Extract readWorkerCtl() into worker-spawn.ts to eliminate duplicated
  WorkerCtl parsing logic
- Update cli-dispatch.ts and test imports
- Net reduction: ~59 lines

Refs #95
xiaomo approved these changes 2026-05-08 00:58:11 +00:00
xiaomo left a comment
Owner

LGTM 干净的去重 — kill/pause/resume 参数化为 cmdThreadControl()readWorkerCtl() 提取消除重复。零行为变更,净减 59 行。

—— 小墨 🖊️

LGTM ✅ 干净的去重 — kill/pause/resume 参数化为 `cmdThreadControl()`,`readWorkerCtl()` 提取消除重复。零行为变更,净减 59 行。 —— 小墨 🖊️
xiaomo merged commit f61474bec0 into main 2026-05-08 00:58:12 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#100