Skip to content

Remove picocolors, add native util.styleText facade (src/style.ts) - #194

Merged
shouze merged 2 commits into
mainfrom
refactor/remove-picocolors
Aug 24, 2026
Merged

Remove picocolors, add native util.styleText facade (src/style.ts)#194
shouze merged 2 commits into
mainfrom
refactor/remove-picocolors

Conversation

@shouze

@shouze shouze commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes the picocolors dependency and replaces it with a native node:util styleText facade (src/style.ts), the last remaining external styling dependency in the codebase (closes #193).

  • Adds src/style.ts as the sole call site for node:util's styleText, mirroring the render/terminal.ts convention already used for Bun-native APIs. Exposes one function per style actually in use (dim, bold, italic, underline, red, green, yellow, cyan, magenta, white, black, bgMagenta) plus a style(names[], text) composer for multi-style call sites.
  • Adds src/style.d.ts: an ambient module augmentation, since @types/node (25.2.3, pulled transitively via bun-types) does not yet declare styleText, even though Bun 1.4 implements it at runtime.
  • Migrates all 9 production files that imported picocolors directly: src/render.ts, src/render/highlight.ts, src/render/summary.ts, src/render/team-pick.ts, src/tui.ts, src/upgrade.ts, src/api.ts, github-code-search.ts.
  • Converts nested style compositions (e.g. pc.bold(pc.yellow(x))) to style.style([...], x), using styleText's native array-of-formats support instead of chaining. This matters because bold and dim share the same SGR reset code (22); naive chained calls are not always safe for composed styles, while the array form is always correct.
  • Removes picocolors from package.json dependencies and updates bun.lock.
  • Updates AGENTS.md and .github/skills/documentation.md conventions to reference src/style.ts instead of picocolors.

Behavior-preserving refactor — no user-facing output changes.

How did you verify your code works?

  • Added src/style.test.ts: 23 golden-master tests comparing src/style.ts output byte-for-byte against the previous picocolors output, for every single style and every composed combination actually used in the codebase, plus NO_COLOR / FORCE_COLOR behavior tests.
  • bun test: full suite green (644 tests).
  • bun run lint, bun run format:check, bun run knip: all clean.
  • bun run build.ts: binary compiles; manually smoke-tested --help output (plain and with FORCE_COLOR=1) on the compiled binary.

- Add src/style.ts as the sole call site for node:util's styleText,
  mirroring the render/terminal.ts convention for Bun-native APIs.
- Add src/style.d.ts ambient augmentation: @types/node 25.2.3 does not
  yet declare styleText, though Bun 1.4 implements it at runtime.
- Migrate all 9 files importing picocolors directly (render.ts,
  render/highlight.ts, render/summary.ts, render/team-pick.ts, tui.ts,
  upgrade.ts, api.ts, github-code-search.ts) plus test fixtures.
- Nested style compositions (e.g. pc.bold(pc.yellow(x))) are converted
  to style.style([...], x) using styleText's native array-of-formats
  support, verified byte-identical to picocolors via golden-master
  tests in src/style.test.ts (bold/dim share the same SGR reset code,
  so naive chaining is not always safe for composed styles).
- Remove picocolors from package.json dependencies.
- Update AGENTS.md and .github/skills/documentation.md conventions.

Closes #193
Copilot AI lite review requested due to automatic review settings August 23, 2026 23:52
@github-actions

Copy link
Copy Markdown

Coverage after merging refactor/remove-picocolors into main will be

96.19%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.70%100%88.24%89.76%176, 200–205, 207–209, 211–212, 233, 421–422, 446–448, 516–520, 532–533, 538–545, 547–555, 557–560
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 replaces direct picocolors usage with a centralized native node:util.styleText facade while preserving terminal styling behavior.

Changes:

  • Adds the styling facade, typings, and parity tests.
  • Migrates production and test styling call sites.
  • Removes the direct dependency and updates documentation and lockfile metadata.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Summary
src/upgrade.ts Migrates upgrade-link styling.
src/tui.ts Migrates TUI styling.
src/test-setup.ts Updates color test setup.
src/style.ts Adds the native styling facade.
src/style.test.ts Adds ANSI parity and environment tests.
src/style.d.ts Declares styleText; Critical (1 vote): make the file an external module so it augments rather than replaces node:util declarations.
src/render/terminal.test.ts Migrates test styling.
src/render/team-pick.ts Migrates team-picker styling.
src/render/team-pick.test.ts Updates styling test references.
src/render/summary.ts Migrates summary styling.
src/render/highlight.ts Migrates syntax-highlighting styling.
src/render/highlight.test.ts Updates styling references.
src/render.ts Migrates rendering styles; Moderate (3 votes): split nested dim/bold spans to prevent reset collisions.
src/api.ts Migrates progress styling.
package.json Removes the direct dependency.
github-code-search.ts Migrates CLI help and error styling.
bun.lock Updates dependency metadata; Nit (2 votes): picocolors remains transitively and may conflict with the stated removal requirement.
AGENTS.md Documents the styling convention.
.github/skills/documentation.md Updates styling guidance.
Suppressed comments (2)

AGENTS.md:273

  • The list separator is malformed in this new documentation line: `chalk`/`picocolors`/or should use commas and a final or.
- `src/style.ts` is the sole call site for `node:util`'s `styleText` and the only styling dependency-free abstraction in the codebase; do not import `styleText` directly elsewhere, and do not add `chalk`/`picocolors`/or similar external styling packages.

package.json:55

  • Removing the workspace entry does not remove picocolors from the lockfile: it is still a transitive dependency of @babel/code-frame and postcss (bun.lock:69 and bun.lock:1333). This leaves the stated DoD/acceptance criterion that it no longer appears in bun.lock unmet; either remove those dependency paths or narrow the claim to the direct production dependency.
    "commander": "^15.0.0"

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/render.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sébastien HOUZÉ <sebastien.houze@fulll.fr>
@shouze
shouze force-pushed the refactor/remove-picocolors branch from f1a489f to cbdb668 Compare August 24, 2026 00:07
@github-actions

Copy link
Copy Markdown

Coverage after merging refactor/remove-picocolors into main will be

96.19%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.70%100%88.24%89.76%176, 200–205, 207–209, 211–212, 233, 421–422, 446–448, 516–520, 532–533, 538–545, 547–555, 557–560
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze
shouze merged commit 0188e0a into main Aug 24, 2026
5 checks passed
@shouze
shouze deleted the refactor/remove-picocolors branch August 24, 2026 00:09
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.

Remove picocolors dependency in favor of a native util.styleText facade

2 participants