cog
86bf5037 - Make the CLI pretty ✨ (#2793)

Commit
7 days ago
Make the CLI pretty ✨ (#2793) * feat: add ⚙ �� prefix to console output for visual distinction 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. * feat: add console.Bold() and highlight dynamic values in messages 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. * chore: demote noisy build messages to debug level 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. * feat: add spacing between build/prediction output phases 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. * feat: add console.Success() with green ✓ prefix via Style system 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. * feat: wrap long lines to terminal width with prefix on continuation lines 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. * feat: add InfoUnformatted for prefix-free interactive output 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. * fix: improve error message wording and add spacing after run message - '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 * refactor: improve init command output style - 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 * refactor: move build message and spacing to CLI layer 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. * fix: update integration tests for console output changes - 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
Author
Parents
Loading