Skip to content

Make the CLI pretty ✨#2793

Merged
tempusfrangit merged 11 commits intomainfrom
bfirsh/console-output-styling
Mar 2, 2026
Merged

Make the CLI pretty ✨#2793
tempusfrangit merged 11 commits intomainfrom
bfirsh/console-output-styling

Conversation

@bfirsh
Copy link
Copy Markdown
Contributor

@bfirsh bfirsh commented Mar 2, 2026

Summary

Overhaul Cog's CLI output styling so framework messages are visually distinct from Docker build output and model prediction output.

Before:

Screenshot 2026-03-02 at 09 55 28

After:

Screenshot 2026-03-02 at 11 06 25 Screenshot 2026-03-02 at 11 06 40 Screenshot 2026-03-02 at 11 12 03

What changed

  • Icon prefixes — All Cog messages get a leading icon: (info/debug), (warn), (error/fatal), (success). Model output stays unstyled and flush-left.
  • Bold dynamic values — Image names, paths, URLs, and hostnames are bolded via console.Bold() to stand out without needing quotes.
  • console.Success() — New method with green prefix, displayed at info level via a Style enum system.
  • console.InfoUnformatted() — New method for prefix-free stderr output, used for interactive/conversational flows like login prompts.
  • Terminal-width line wrapping — Long lines wrap to terminal width when stderr is a TTY, with the same prefix on continuation lines. ANSI-aware so color codes don't cause premature breaks.
  • Spacing between phases — Blank lines separate build output, prediction output, and Cog messages for visual breathing room.
  • Demoted noisy messages — Schema generation, local wheel, and git commit/tag messages moved to debug level.
  • Build message moved to CLI layer — Each command controls whether to show the image name (cog build/cog push show it; cog predict/cog train/cog run/cog serve hide it since it's an internal detail).
  • Message wording improvements — Shorter, clearer error messages; cog init shows "Creating {filename}" before write instead of "Created {fullpath}" after.
  • Login flow cleanup — Replicate and generic login prompts use InfoUnformatted, prompt renamed to "Token:", improved spacing.

Files changed

  • pkg/util/console/ — Core styling, wrapping, Bold, Success, InfoUnformatted, Style enum
  • pkg/cli/ — All commands updated with spacing, bold values, moved build message
  • pkg/image/build.go — Removed build message (moved to CLI), demoted debug messages
  • pkg/predict/predictor.go — Shorter error wording
  • pkg/provider/ — Login flows use InfoUnformatted
  • pkg/dockerfile/standard_generator.go — Demoted wheel messages to debug

bfirsh added 5 commits March 2, 2026 10:51
Add a prefix and separator to all console log messages so Cog's
output is visually distinguishable from Docker build output and
model output:

- Info/Debug: dim ⚙ › prefix
- Warn: bold yellow ⚠ › prefix
- Error/Fatal: bold red ⅹ › prefix

Blank lines at info/debug level print without prefix for clean
spacing. Warn/error blank lines keep their prefix to maintain
visual continuity in multi-line error messages.

Output() (stdout, for model predictions) remains unstyled.
Add a Bold() helper to the console package that applies bold
formatting when color is enabled. Use it to highlight key dynamic
values (image names, paths, URLs, hostnames) in user-facing
messages so they stand out within the dim-prefixed lines.

Also remove single quotes around values where bold makes them
visually distinct without needing quoting.
Move 'Generating model schema...', 'Using local coglet wheel...',
and 'Using local cog wheel...' from info to debug level. These are
implementation details that clutter normal output but remain visible
with --debug.
Add blank lines after 'Building Docker image...' (before Docker
build output) and after 'Running prediction/training...' (before
model output) to visually separate Cog's framework messages from
external output.
Introduce a Style type that controls the icon/color of a log line
independently from the log level. This allows Success to display at
info level (same filtering) but with a green ✓ prefix.

New styles can be added by extending the Style enum without touching
the level hierarchy.

Apply Success to: image built, cog init completion, login success,
and image pushed messages. Drop the ✅ emoji from init since the
green ✓ prefix replaces it.
@bfirsh bfirsh requested a review from a team as a code owner March 2, 2026 19:10
bfirsh added 5 commits March 2, 2026 11:16
…ines

When stderr is a TTY, wrap console messages to the terminal width so
they don't overflow. Each continuation line gets the same prefix as the
first line for visual continuity.

Wrapping is ANSI-aware: escape codes are treated as zero-width so
colored/bold text doesn't cause premature breaks. Lines break on word
boundaries where possible, with hard breaks as a fallback.
Add InfoUnformatted/InfoUnformattedf methods that write to stderr at
info level without any icon prefix. These are used for conversational
and interactive output (login prompts, instructions) where the gear
prefix would be visual noise.

Long lines are wrapped to terminal width when stderr is a TTY, same
as prefixed output.

Apply to login flows in both Replicate and generic providers: replace
console.Info with console.InfoUnformatted for all user-facing prompts
and instructions. Rename 'CLI auth token:' prompt to 'Token:' and
improve spacing around the prompt.
- 'Failed to predict' → 'Failed to run prediction' in predict.go
- 'The inputs you passed to cog predict' → 'The inputs you passed' in
  predictor.go (shorter, less redundant since the user knows they ran cog)
- Add blank line after 'Running...' message in run.go for visual
  separation from Docker output
- Remove leading \n from 'Setting up...' message (prefix handles
  spacing), use separate console.Info('') for the blank line after
- Show 'Creating {filename}' (info, before write) instead of
  'Created {fullpath}' (success, after write) — less noisy, uses
  just the filename since the user knows their working directory
The 'Building Docker image...' message and surrounding blank lines are
user-facing concerns that belong in the CLI commands, not deep in
pkg/image/build.go. This lets each command control what it shows:

- cog build / cog push: show image name (user-chosen, meaningful)
- cog predict / cog train / cog run / cog serve: hide image name
  (ephemeral internal detail the user can't use)

Each CLI command now prints the message + blank line before calling
resolver.Build(), and the pre-ImageBuild blank lines are removed from
image/build.go.
@bfirsh bfirsh force-pushed the bfirsh/console-output-styling branch from 2691bc5 to 34ce886 Compare March 2, 2026 19:17
@tempusfrangit
Copy link
Copy Markdown
Contributor

This looks great! You'll need to massage the ITs but as soon as it passes CI we should be good to land it.

- build_cog_init: match 'Image built as' without 'cog-' prefix since
  the success prefix (✔) is now part of the line
- wheel_resolution: use --debug flag since wheel resolution messages
  were demoted to debug level
@tempusfrangit tempusfrangit merged commit 86bf503 into main Mar 2, 2026
53 of 56 checks passed
@tempusfrangit tempusfrangit deleted the bfirsh/console-output-styling branch March 2, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants