Skip to content

feat: export color helpers#63

Merged
chenjiahan merged 1 commit intomainfrom
color_0308
Mar 8, 2026
Merged

feat: export color helpers#63
chenjiahan merged 1 commit intomainfrom
color_0308

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Export color helpers as a public API.

Copilot AI review requested due to automatic review settings March 8, 2026 01:25
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the color styling utilities by consolidating them into a single, exported color object. This change enhances the modularity and extensibility of the styling API, providing a more organized and consistent way to access various text and color formatting functions, including several new additions, and makes them available for external use.

Highlights

  • Color Utilities Refactoring: Individual color styling functions (e.g., bold, red) have been consolidated into a single, comprehensive color object in src/color.ts.
  • New Styling Options: The new color object introduces additional text and color styling utilities, including dim, blue, black, white, reset, underline, and strikethrough.
  • Internal Usage Update: All internal modules (src/constants.ts, src/createLogger.ts, src/gradient.ts) have been updated to consistently use the new color object for styling references.
  • Public API Export: The color object is now exported from src/index.ts, making these consolidated styling utilities publicly accessible as part of the library's API.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/color.ts
    • Replaced individual export const color functions with a single export const color object.
    • Added new styling functions (dim, blue, black, white, reset, underline, strikethrough) to the color object.
  • src/constants.ts
    • Updated imports to use the color object instead of individual color functions.
    • Modified LOG_TYPES definitions to reference colors via color.red, color.yellow, etc.
  • src/createLogger.ts
    • Updated imports to use the color object.
    • Modified internal usage of color functions (e.g., gray to color.gray, bold to color.bold, yellow to color.yellow).
  • src/gradient.ts
    • Updated imports to use the color object.
    • Modified internal usage of color functions (e.g., bold(cyan(message)) to color.cyan(message) and bold(output) to color.bold(output)).
  • src/index.ts
    • Added export { color } from './color.js'; to expose the new color utilities publicly.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the color helper functions into a single exported color object, which improves namespacing and organization. The changes are applied consistently across the codebase. I've added one suggestion to improve maintainability by sorting the properties within the new color object.

@chenjiahan chenjiahan merged commit eb129f7 into main Mar 8, 2026
6 checks passed
@chenjiahan chenjiahan deleted the color_0308 branch March 8, 2026 01:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes the package’s color styling helpers as part of the public API, and refactors internal usage to route all styling through the new color helper export.

Changes:

  • Export color from the public entrypoint (src/index.ts).
  • Replace internal named color imports (bold, cyan, etc.) with color.* usage.
  • Consolidate styling helpers into a single exported color object in src/color.ts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/index.ts Exports color from the public API surface.
src/gradient.ts Migrates to color.* helpers (but changes behavior for colorLevel === 2).
src/createLogger.ts Updates logger formatting to use color.* helpers.
src/constants.ts Updates log type color functions to reference color.*.
src/color.ts Replaces individual exports with a consolidated color object export.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

export let gradient = (message: string) => {
if (colorLevel < 3) {
return colorLevel === 2 ? bold(cyan(message)) : message;
return colorLevel === 2 ? color.cyan(message) : message;
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradient() previously returned bold cyan text when colorLevel === 2 (via bold(cyan(message))). The new code returns only color.cyan(message), which is a visible formatting regression for terminals with 256-color support. Restore the bold styling for the colorLevel === 2 branch (e.g., apply color.bold around the cyan output) to preserve prior behavior.

Suggested change
return colorLevel === 2 ? color.cyan(message) : message;
return colorLevel === 2 ? color.bold(color.cyan(message)) : message;

Copilot uses AI. Check for mistakes.
import { createLogger } from './createLogger.js';

export { createLogger };
export { color } from './color.js';
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color is now exported as a public API from src/index.ts, but there’s no test asserting that this export exists and remains stable (at least for the core keys like bold, red, etc.). Adding a small test that imports { color } from the public entrypoint and validates a couple of helpers return strings would help prevent accidental breaking changes to the new API.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7f56e2fb5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export let gradient = (message: string) => {
if (colorLevel < 3) {
return colorLevel === 2 ? bold(cyan(message)) : message;
return colorLevel === 2 ? color.cyan(message) : message;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep bold styling in level-2 gradient fallback

When supports-color reports level 2, gradient() now returns only color.cyan(message), whereas before this refactor it returned bold cyan text. This is a user-visible regression for terminals without truecolor support: greet banners lose emphasis at level 2 while level 3 still applies bold, so formatting becomes inconsistent across environments. The fallback should preserve the prior bold + cyan behavior.

Useful? React with 👍 / 👎.

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