Skip to content

refactor(cli): replace comment-backed workarounds and name terminal escapes - #184

Merged
PunGrumpy merged 7 commits into
mainfrom
refactor/cli-workarounds
Oct 23, 2026
Merged

PunGrumpy merged 7 commits into
mainfrom
refactor/cli-workarounds

Conversation

@PunGrumpy

Copy link
Copy Markdown
Owner

Description

The comment audit of the CLI found comments that exist to excuse or decode the code next to them. This PR changes the code instead. Behavior and terminal output do not change.

Seven commits:

  1. Child processes are awaited with events.once. tryCopy and launchAgent wrapped spawn in new Promise under eslint-disable promise/avoid-new. once(child, "exit") resolves on exit and rejects on a spawn error, which is the same result. launchAgent's comment claimed it resolves true "when the agent process exits normally". It resolves true on any exit, so the comment now says that and a test pins it.
  2. isExecutableFile replaces an empty catch whose only content was a comment to satisfy no-empty.
  3. Terminal escapes have names. terminal-control.ts exports HIDE_CURSOR, SHOW_CURSOR, CLEAR_TO_LINE_END and cursorUp, and the comments that decoded each raw \u001B[… string ("Hide cursor during prompt", "Move cursor up 4 lines") go. The score animation moves up whaleLines.length lines instead of a literal 4.
  4. unanalyzedCount becomes failedFileCount. The parameter counts the files that failed to read or parse, not every unanalyzed file, which is why it needed a comment.
  5. agentDisplayName drops its "universal" special case. Its comment said getSkillAgentConfig rejects that id. agent-install 0.0.8 accepts it and returns "Universal".
  6. lineSuffix is defined once. It was copied word for word in handoff-payload.ts and diagnostics-dir.ts.
  7. The four remaining suppressions give a reason. The three prompts resolve from inside their keypress listener, and the score animation plays its frames one after another.

Not done here: moving the three prompts onto events.on iteration. It would remove their suppressions, but the prompts have no test harness yet.

Related Issues

N/A. Found by a comment audit of the repository.

Checklist

  • I've reviewed my code
  • I've written tests
  • I've generated a changeset file, if this changes a published package
  • I've updated the docs, if necessary

Screenshots (if applicable)

N/A. Terminal output is byte-identical (see below).

Additional Notes

  • CLI tests go from 101 to 108: clipboard fallback order and all-tools-fail (Linux), executable lookup (3 cases), an agent that exits 3, and install --agent universal printing "Universal". Each new test also passed against the old code.
  • Commit 3 was checked in a pseudo-terminal. script ran the old and the new build on test/fixtures/with-error through the spinner, the score animation, askConfirm and askSelect, and the two captures were identical apart from the scanned directory's name (4 hide-cursor, 5 show-cursor, 24 cursor-up and 17 clear-line sequences each). askMultiSelect only runs under install without --agent and was not captured.
  • ultracite check, typecheck and the generated docs are clean. With the reasons in place, oxlint still honors the four directives (removing them brings back three promise/avoid-new errors).
  • skip-changeset: no behavior visible to users changes.

@PunGrumpy PunGrumpy added pkg: cli Command-line interface in packages/docker-doctor skip-changeset This PR needs no changeset (no user-visible change to @docker-doctor/cli) labels Oct 23, 2026
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docker-doctor Skipped Skipped Oct 23, 2026 2:33am UTC

@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2d25d56

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest Docker Doctor scan for this pull request. Learn more about Docker Doctor.

File Status Issues Updated
Dockerfile Error 1 error, 2 info Oct 23, 2026 2:34am UTC

Score: 84 / 100 · Good

3 issues

Dockerfile

  • error Dockerfile:2 Potential secret found in ENV: 'DB_PASSWORD'. no-secrets-in-env
  • info Dockerfile:1 No HEALTHCHECK instruction found. require-healthcheck
  • info Dockerfile:1 No LABEL metadata was found in this Dockerfile. require-labels

Scanned by Docker Doctor for commit 2d25d56.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@docker-doctor/cli@184

commit: 2d25d56

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f76f262d-b56d-48cf-b1ff-6b8448ce683f
📥 Commits

Reviewing files that changed from the base of the PR and between 747bd91 and 2d25d56.

📒 Files selected for processing: 12
  • packages/docker-doctor/src/agents/clipboard.ts
  • packages/docker-doctor/src/agents/diagnostics-dir.ts
  • packages/docker-doctor/src/agents/handoff-payload.ts
  • packages/docker-doctor/src/agents/is-command-available.ts
  • packages/docker-doctor/src/agents/launch-agent.ts
  • packages/docker-doctor/src/cli.ts
  • packages/docker-doctor/src/formatters/terminal.ts
  • packages/docker-doctor/src/terminal-control.ts
  • packages/docker-doctor/test/cli.test.ts
  • packages/docker-doctor/test/clipboard.test.ts
  • packages/docker-doctor/test/is-command-available.test.ts
  • packages/docker-doctor/test/launch-agent.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

tryCopy and launchAgent each wrapped a child process in `new Promise`
under an `eslint-disable promise/avoid-new`. `once(child, "exit")` from
node:events gives the same result: it resolves on exit and rejects on a
spawn error.

launchAgent's comment also said it resolves true when the agent exits
normally. It resolves true on any exit, so the comment now says that and
a test pins it. New clipboard tests cover the fallback order and the
case where every tool fails.
isCommandAvailable kept an empty catch block alive with a comment that
existed only to satisfy no-empty. isExecutableFile returns true or false
instead, and the loop reads as a lookup. New tests cover an executable,
a file that is not executable and a missing command.
The prompts, the spinner and the score animation wrote raw escape
sequences such as `\u001B[?25l` and `\u001B[3A`, with a comment above
each to say what it does. terminal-control.ts names them (HIDE_CURSOR,
SHOW_CURSOR, CLEAR_TO_LINE_END and cursorUp), so those comments go. The
score animation now moves up `whaleLines.length` lines instead of a
literal 4.

The output is byte-identical. A pseudo-terminal capture of a scan with
its spinner, the score animation and two prompts matched the old build.
formatTerminal's last parameter was called unanalyzedCount, with a
comment saying it counts the files that could not be read or parsed. A
file with nothing to check is also unanalyzed, yet it is not in that
count. failedFileCount says what the caller passes.
agentDisplayName special-cased `universal` because, its comment said,
getSkillAgentConfig rejects that id. agent-install 0.0.8 accepts it and
returns "Universal", so the special case goes. A new install test pins
the name.
handoff-payload.ts and diagnostics-dir.ts each defined the same
lineSuffix with the same comment. diagnostics-dir.ts now exports it and
the handoff prompt imports it.
Four suppressions in the CLI gave no reason, which this repository asks
for. The three prompts resolve from inside their keypress listener, and
the score animation plays its frames one after another, so the rules
stay off at those lines with the reason written inline.
@PunGrumpy
PunGrumpy force-pushed the refactor/cli-workarounds branch from 8ddfdca to 2d25d56 Compare October 23, 2026 02:33
@PunGrumpy
PunGrumpy merged commit 2ca1312 into main Oct 23, 2026
21 of 22 checks passed
@PunGrumpy
PunGrumpy deleted the refactor/cli-workarounds branch October 23, 2026 02:35

This branch was previously deployed

1 inactive deployment
Preview — 2d25d56d Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: cli Command-line interface in packages/docker-doctor skip-changeset This PR needs no changeset (no user-visible change to @docker-doctor/cli)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant