feat(cli): live command — real-time thread monitoring #57

Merged
xiaomo merged 2 commits from feat/37-live-command into main 2026-05-07 13:45:10 +00:00
Owner

What

Add uncaged-workflow live <thread-id> command for real-time thread monitoring with --latest, --debug, and --role flags.

Why

No way to observe running threads in real-time. Had to manually tail -f JSONL files.

Changes

  • packages/cli-workflow/src/cmd-live.ts — live tail with formatted output, fs.watch for running threads
  • packages/cli-workflow/src/live-argv.ts — flag parsing for --latest/--debug/--role
  • packages/cli-workflow/src/thread-scan.tsfindLatestThreadDataPath() for --latest
  • packages/workflow/src/worker.ts — write WorkflowResult to .data.jsonl for completion detection
  • packages/workflow/src/fork-thread.ts — handle WorkflowResult as last line
  • packages/cli-workflow/__tests__/live.test.ts — tests with JSONL fixtures
  • Various test adjustments for WorkflowResult in .data.jsonl

Testing

  • Phase 1 (#49): basic live monitoring
  • Phase 2 (#50): --latest/--debug/--role flags
  • All 161 tests pass, bun run check clean

Ref: #37

## What Add `uncaged-workflow live <thread-id>` command for real-time thread monitoring with `--latest`, `--debug`, and `--role` flags. ## Why No way to observe running threads in real-time. Had to manually `tail -f` JSONL files. ## Changes - `packages/cli-workflow/src/cmd-live.ts` — live tail with formatted output, fs.watch for running threads - `packages/cli-workflow/src/live-argv.ts` — flag parsing for --latest/--debug/--role - `packages/cli-workflow/src/thread-scan.ts` — `findLatestThreadDataPath()` for --latest - `packages/workflow/src/worker.ts` — write WorkflowResult to .data.jsonl for completion detection - `packages/workflow/src/fork-thread.ts` — handle WorkflowResult as last line - `packages/cli-workflow/__tests__/live.test.ts` — tests with JSONL fixtures - Various test adjustments for WorkflowResult in .data.jsonl ## Testing - Phase 1 (#49): basic live monitoring ✅ - Phase 2 (#50): --latest/--debug/--role flags ✅ - All 161 tests pass, `bun run check` clean Ref: #37
xingyue added 2 commits 2026-05-07 13:34:37 +00:00
- Add cmd-live.ts: tail .data.jsonl with formatted output
- Display role steps with timestamp, role name, truncated content, meta
- fs.watch for running threads, auto-exit on completion
- Write WorkflowResult to .data.jsonl in worker.ts for completion detection
- Add live.test.ts with JSONL fixtures

Testing: #49
- --latest: auto-find most recent thread by start timestamp
- --debug: display .info.jsonl debug log with tags
- --role: filter output to specific role
- Add live-argv.ts for flag parsing
- Add fixtures and test coverage for all flags

Testing: #50
xiaomo approved these changes 2026-05-07 13:37:37 +00:00
Dismissed
xiaomo left a comment
Owner

Review: command

架构设计合理,pump + watch 模式适合 tail 场景,测试覆盖全面

Minor

  1. ** chain** ( schedulePump) — 项目规范要求 always async/await,这里用了 ,建议改成 async queue
  2. ** 每次读整个文件** — 读完整 再 slice offset,长时间运行的 thread 会越来越慢。MVP 可以接受,后续建议用 fd + seek
  3. ** 同理** — 只需要第一行但读了整个文件

Blocker

  1. 合并冲突 — ,需要 rebase

rebase 后可以合并。

## Review: command 架构设计合理,pump + watch 模式适合 tail 场景,测试覆盖全面 ✅ ### Minor 1. ** chain** ( schedulePump) — 项目规范要求 always async/await,这里用了 ,建议改成 async queue 2. ** 每次读整个文件** — 读完整 再 slice offset,长时间运行的 thread 会越来越慢。MVP 可以接受,后续建议用 fd + seek 3. ** 同理** — 只需要第一行但读了整个文件 ### Blocker 4. **合并冲突** — ,需要 rebase rebase 后可以合并。
xiaomo approved these changes 2026-05-07 13:37:49 +00:00
xiaomo left a comment
Owner

Review: live command

架构设计合理,pump + watch 模式适合 tail 场景,测试覆盖全面

Minor

  1. .then() chain (schedulePump) — 项目规范要求 always async/await,建议改成 async queue
  2. pumpNewContent 每次读整个文件再 slice offset,长时间运行的 thread 会越来越慢。MVP 可以接受,后续建议用 fd + seek
  3. readThreadStartTimestampMs 同理,只需要第一行但读了整个文件

Blocker

  1. 合并冲突 — mergeable false,需要 rebase

rebase 后可以合并。

## Review: live command 架构设计合理,pump + watch 模式适合 tail 场景,测试覆盖全面 ### Minor 1. .then() chain (schedulePump) — 项目规范要求 always async/await,建议改成 async queue 2. pumpNewContent 每次读整个文件再 slice offset,长时间运行的 thread 会越来越慢。MVP 可以接受,后续建议用 fd + seek 3. readThreadStartTimestampMs 同理,只需要第一行但读了整个文件 ### Blocker 4. 合并冲突 — mergeable false,需要 rebase rebase 后可以合并。
xingyue force-pushed feat/37-live-command from 79a407f107 to c5f279ed54 2026-05-07 13:41:43 +00:00 Compare
xingyue force-pushed feat/37-live-command from c5f279ed54 to 8fe26417cf 2026-05-07 13:44:38 +00:00 Compare
xiaomo merged commit c342ff3737 into main 2026-05-07 13:45:10 +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#57