Skip to content

Stream tokens to the terminal during write (Rich live output) #55

Description

@telivity-otaip

Why

write currently waits for the full generation before printing. Streaming makes the CLI feel alive, helps users catch slop early, and is a classic high-visibility contribution for a terminal product.

Scope

  • Stream MLX generation tokens to stdout while drafting (--channel post first; article sections can stream per section)
  • Keep --json non-streaming (emit one final receipt) unless --json --stream is explicitly designed
  • Show a small Rich status line: channel, adapter=none|path, section N/M for articles
  • Ctrl-C should abort cleanly without corrupting profile state

Pointers

  • src/personality_protect/write.py — generation
  • src/personality_protect/write_article.py — section loop
  • src/personality_protect/mlx_runtime.py — MLX calls
  • cli.py write command

Acceptance criteria

  • Post channel prints tokens as they arrive on a TTY
  • Article channel streams each section (clear section separator, no markdown chrome)
  • --json remains a single final object (backward compatible)
  • Piped/non-TTY output either buffers safely or documents behavior
  • Tests cover the non-MLX / mock path (callback invoked with chunks)
  • No personal corpus in fixtures — Contoso only

Difficulty

Easy–Medium — mostly plumbing a stream callback through existing generate helpers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions