Skip to content

Remove ansi-escapes from cli-kit (inline OSC-8 hyperlink) - #7722

Closed
amcaplan wants to merge 1 commit into
mainfrom
remove-dep/ansi-escapes
Closed

Remove ansi-escapes from cli-kit (inline OSC-8 hyperlink)#7722
amcaplan wants to merge 1 commit into
mainfrom
remove-dep/ansi-escapes

Conversation

@amcaplan

@amcaplan amcaplan commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What

Removes the ansi-escapes npm dependency from @shopify/cli-kit and replaces its only usage with a self-contained 3-line OSC-8 hyperlink helper.

Why

ansi-escapes has generated 52 Dependabot version bumps over 24 months in this repo. The only API used is ansiEscapes.link(text, url), which is a trivial OSC-8 escape sequence. Inlining it eliminates the dependency entirely, reducing Dependabot churn with no functional change.

Implementation

The replacement helper (BEL terminator variant, matches the original library's output):

function osc8Link(text: string, url: string): string {
  return `\x1b]8;;\${url}\x07\${text}\x1b]8;;\x07`
}

Applied to:

  • packages/cli-kit/src/private/node/ui/components/Link.tsx
  • packages/cli-kit/src/private/node/content-tokens.ts

Platform/terminal hyperlink support detection continues to be handled externally by supports-hyperlinks — no change to that logic.

Validation

  • pnpm --filter @shopify/cli-kit type-check — passes
  • pnpm --filter @shopify/cli-kit lint — passes
  • pnpm --filter @shopify/cli-kit exec vitest run — Link + content-tokens tests: 10/10 passing

🤖 Automated dependency-removal initiative — AI-generated draft, needs human review.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Jun 5, 2026
@amcaplan amcaplan added dependency-removal Removes a dependency to cut Dependabot churn (cleanup initiative) claudeception Pull request created by Claudeception agents labels Jun 5, 2026
@amcaplan
amcaplan marked this pull request as ready for review June 7, 2026 14:28
Copilot AI review requested due to automatic review settings June 7, 2026 14:28
@amcaplan
amcaplan requested a review from a team as a code owner June 7, 2026 14:28
@github-actions github-actions Bot added no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. and removed Area: @shopify/cli @shopify/cli package issues labels Jun 7, 2026

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 removes the ansi-escapes dependency from @shopify/cli-kit by inlining a small OSC-8 hyperlink helper and switching the two prior call sites over to it, with corresponding dependency/lockfile updates.

Changes:

  • Removed ansi-escapes from packages/cli-kit/package.json.
  • Replaced ansiEscapes.link(...) usage with a local osc8Link(...) helper in the Ink <Link> component and in LinkContentToken.
  • Updated pnpm-lock.yaml to reflect the dependency change (and additional lockfile rewrites).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
pnpm-lock.yaml Removes ansi-escapes from the packages/cli-kit importer entry and updates lockfile entries.
packages/cli-kit/src/private/node/ui/components/Link.tsx Inlines osc8Link and replaces the previous ansiEscapes.link call for terminal hyperlink rendering.
packages/cli-kit/src/private/node/content-tokens.ts Inlines osc8Link and replaces the previous ansiEscapes.link call for hyperlink content tokens.
packages/cli-kit/package.json Drops the direct ansi-escapes dependency from @shopify/cli-kit.

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

Comment on lines 117 to 119
"ajv": "8.18.0",
"ansi-escapes": "6.2.1",
"archiver": "5.3.2",
"archiver": "5.3.2",
"bottleneck": "2.19.5",
Comment on lines +7 to +9
function osc8Link(text: string, url: string): string {
return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`
}
Comment on lines +8 to +10
function osc8Link(text: string, url: string): string {
return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`
}
Comment thread pnpm-lock.yaml
Comment on lines 882 to 886
'@ast-grep/napi-linux-arm64-gnu@0.33.0':
resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==, tarball: https://registry.npmjs.org/@ast-grep/napi-linux-arm64-gnu/-/napi-linux-arm64-gnu-0.33.0.tgz}
resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
Co-Authored-By: Claude <noreply@anthropic.com>
@amcaplan
amcaplan force-pushed the remove-dep/ansi-escapes branch from b0b30ee to 3ef7855 Compare June 8, 2026 15:17
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/private/node/hyperlink.d.ts
/**
 * Wraps `text` in an OSC-8 terminal hyperlink escape sequence pointing at `url`.
 *
 * See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for the
 * OSC-8 spec. The terminal must support hyperlinks for this to render as a link;
 * callers should gate on `supports-hyperlinks` before using it.
 */
export declare function osc8Link(text: string, url: string): string;

Existing type declarations

We found no diffs with existing type declarations

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudeception Pull request created by Claudeception agents dependency-removal Removes a dependency to cut Dependabot churn (cleanup initiative) no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. no-pr-activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants