Skip to content

[cli] Add --no-color, combining the #688 community PRs - #1067

Merged
hermes-exosphere merged 9 commits into
mainfrom
claude/no-color-688
Nov 30, 2026
Merged

hermes-exosphere merged 9 commits into
mainfrom
claude/no-color-688

Conversation

@NiveditJain

Copy link
Copy Markdown
Member

Fixes #688. Combines the three community PRs for it, #695, #700 and #848, into one change, keeping each contributor's commits (cherry-picked with -x, original authors).

What #688 asked for, and where main stands

What each contribution brings

Commit From Kept
fix(cli): honor no-color for policy output #695, mjq2020 Unchanged. The flag is consumed at the top of bin/failproofai.mjs, before the aliases and the --hook fast path, by setting NO_COLOR=1 and removing it from argv, so it works in any position and no subcommand parser sees it. Help rows on the index and policies --help. End-to-end tests that run the real CLI with stdout presented as a TTY.
fix(policies): honour NO_COLOR in hooks manager output #700, chiliec The listHooks colour test. Its manager.ts rewrite targeted the 16 escapes main has since removed, so the code half resolved to main's.
test(policies): harden NO_COLOR test per review #700, chiliec Unchanged.
fix(cli): honour NO_COLOR in manager warning, add --no-color flag #848, lakshya-dhariwal Kept for credit, resolved to no code change: the warning it moved now goes through screenKit().caution(), and applyNoColorFlag() is not taken because importing tui.ts at the top of the bin reorders the bundle (renaming the builtin policies' ctx parameters, which changes the audit cache key; see the note above the --hook branch) and would load the kit on every hook call.
test(cli): cover NO_COLOR gating, --no-color flag, and raw-escape regression #848, lakshya-dhariwal The colorsEnabled / paint checks and the lock that manager.ts holds no hardcoded escapes.

Then three commits of mine: the #700 and #848 tests adapted to the current listing (it writes through printBlock, not console.log, and applyNoColorFlag's two tests become one that locks where the bin consumes the flag), a --no-color row in docs/reference/failproof-cli.mdx with the CHANGELOG entry, and a shorter policies --help row that fits on one line at 80 columns.

Testing

  • Under a real TTY (script), the checks CLI: failproofai policies ignores NO_COLOR, and --no-color does not exist #688 lists: failproofai policies prints 23 escape sequences; policies --no-color, --no-color policies, p --no-color, --help --no-color and NO_COLOR=1 failproofai policies print 0.
  • tsc --noEmit and eslint on the changed files pass.
  • __tests__/hooks/no-color.test.ts, manager-no-color.test.ts, help-index.test.ts, help-page-wrap.test.ts: 48/48.
  • __tests__/e2e/cli/cli-args.e2e.test.ts: 82/82.
  • Full e2e suite locally: 391 passed; the one failure is package/pinned-install, which needs a built dist/ (CI's e2e job builds it) and timed out without one.
  • Full unit suite locally: the only failures are in cloud-jev-policies, pack-selection-merge and publish-command, which fail the same way on a clean main checkout here (their test policies cannot resolve import "failproofai" without a build) and touch nothing this PR changes.

Thanks to mjq2020, chiliec and lakshya-dhariwal. Once this merges, #695, #700 and #848 can be closed in favour of it.

🤖 Generated with Claude Code

mjq2020 and others added 9 commits November 30, 2026 15:46
Closes #688. `failproofai policies` printed ANSI colour even when NO_COLOR
was set, because src/hooks/manager.ts hardcoded ANSI escapes at 16 sites
instead of gating on the shared predicate the rest of the CLI uses.

- Add an ansiHelpers() factory in manager.ts that gates on tui.ts's existing
  colorsEnabled() (!!out.isTTY && !process.env.NO_COLOR) — no new colour
  module (per #256). All 16 sites now route through green/yellow/red/dim
  wrappers that return the string unchanged when colour is off, so plain-text
  glyphs and column widths are byte-identical minus the escape sequences.
- Add a global --no-color flag in bin/failproofai.mjs that sets NO_COLOR=1 and
  is stripped from args before subcommand parsing; documented in COMMANDS help.
- Add a vitest regression test asserting listHooks emits zero ESC bytes under
  NO_COLOR (isTTY forced true) and still emits them with colour on.

Resolved onto current main: the 16 hardcoded escapes this replaced were
already removed when the policies listing moved onto tui.ts (#738, #880),
and the --no-color flag block is identical to the one from #695. Only the
listHooks NO_COLOR test is kept from this commit.

(cherry picked from commit f40a782)
- Assert on the convention-policy status row (team-policies.mjs) so the
  color-on test measures manager.ts's own gated output rather than incidental
  color elsewhere.
- Use vi.stubEnv("NO_COLOR", "") instead of delete process.env.NO_COLOR so
  vi.unstubAllEnvs() restores the worker's original value in afterEach.

(cherry picked from commit 4838d73)
…688)

Resolved onto current main with no code change. The duplicate-scope
warning this moved onto paint() now goes through screenKit().caution(),
and the flag stays inline in bin/failproofai.mjs (from #695) rather than
in tui.ts: importing tui.ts at the top of the bin reorders the bundle,
which renames the builtin policies' `ctx` parameters and so changes the
audit cache key, and it would load the kit on every --hook call. Kept
for credit; the tests from the next commit still apply.

(cherry picked from commit b0a30c8)
The listing now renders through tui.ts's printBlock, so the listHooks test
captures process.stdout.write instead of console.log, isolates
FAILPROOFAI_HOME and the pack directory, and checks the current header.

applyNoColorFlag() was not taken (the flag stays inline in the bin), so its
two unit tests become one that locks where the bin consumes --no-color:
before the aliases and the --hook fast path, with no tui.ts import ahead of
them. The flag itself is covered end to end in cli-args.e2e.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At 80 columns "works with every command" wrapped "command" onto a row of its
own; every other row on the policies help page fits on one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@hermes-exosphere
hermes-exosphere merged commit 8e9d7bd into main Nov 30, 2026
28 of 29 checks passed
@NiveditJain
NiveditJain deleted the claude/no-color-688 branch November 30, 2026 10:19
NiveditJain added a commit that referenced this pull request Nov 30, 2026
Bring in everything main merged since 24 Nov (#1033 through #1067), and
keep this PR to what main still lacks:

- Kept: Dependabot's notify 9.0.0 / rusqlite 0.43.0 bump, byte for byte.
- Kept, rewritten on top of #1066's workflow: the contributor-welcome
  workflow no longer has an approve-dependabot job, and drops
  `pull-requests: write`. GitHub refuses a workflow approval while
  "Allow GitHub Actions to create and approve pull requests" is off, so
  every Dependabot PR has had a failed run since 24 Nov; with it on, the
  approval would count as the one review main requires. A test pins it.
- Dropped as already on main: the CommonJS policy-loading fix and its
  tests (main has isCommonJsSource from #1033, covered by
  commonjs-policy-node.e2e.test.ts and the loader integration tests),
  the duplicate #1052 commits, and the old welcome test (main has #1066's).
- CHANGELOG entries move to the current 1.0.18-beta.0 section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

CLI: failproofai policies ignores NO_COLOR, and --no-color does not exist

5 participants