Skip to content

sogoiii/effect-streamdown-terminal

Repository files navigation

Streamdown Effect-TS

An Effect-TS port of Streamdown - a streaming markdown renderer for modern terminals.

Installation

bun install
bun run build

Usage

# Render a file
bun run dist/cli.js path/to/file.md

# Pipe from stdin
cat file.md | bun run dist/cli.js

# Simulate streaming (see output render incrementally)
cat file.md | while IFS= read -r line; do echo "$line"; sleep 0.1; done | bun run dist/cli.js

# Or use the bin alias after build
./dist/cli.js file.md

CLI Options

  • -w, --width <n> - Terminal width (0 = auto-detect)
  • -s, --scrape <dir> - Extract code blocks to directory
  • -p, --prompt <regex> - Prompt detection regex

Development

bun run dev          # Watch mode
bun run build        # Build dist
bun run typecheck    # TypeScript check
bun run lint         # Lint with Biome
bun run check        # Full Biome check
bun run test         # Unit tests (vitest)
bun run ci           # Full CI (typecheck + check + test)

Testing

Unit Tests

bun run test         # Run once
bun run test:watch   # Watch mode

Visual Tests

Visual tests render markdown fixtures through the CLI for manual inspection.

# Run all fixtures through CLI
bun run test:visual

# Simulate chunked streaming (like LLM APIs)
bun run test:chunk -- fixtures/example.md

# Simulate line-by-line streaming
bun run test:line -- fixtures/example.md

# Adjust timing with TIMEOUT env var
TIMEOUT=0.2 bun run test:line -- fixtures/code.md

Test fixtures are in tests/fixtures/. Files containing 🫣 use this as a chunk delimiter for streaming tests.

Test Scripts

Script Purpose
tests/run-tests.sh Batch run all fixtures
tests/chunk-buffer.sh Chunked streaming simulator
tests/line-buffer.sh Line-by-line streaming
tests/strip-chunks.sh Remove 🫣 markers from files

Architecture

  • src/cli.ts - CLI entry point
  • src/services/ - Parser, Renderer services
  • src/layers/ - Effect dependency layers
  • src/domain/ - Domain types
  • src/renderer/ - ANSI rendering
  • src/parser/ - Markdown parsing

About

A streaming markdown renderer for modern terminals written in effect

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published