Repository navigation
[cli] Add --no-color, combining the #688 community PRs - #1067
Merged
Merged
Conversation
(cherry picked from commit 8b8e9db)
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)
…ression (cherry picked from commit d3c2e33)
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>
|
Caution Review failedThe pull request is closed.
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. |
hermes-exosphere
approved these changes
Nov 30, 2026
This was referenced Nov 30, 2026
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>
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
NO_COLORignored byfailproofai policies. Already fixed on main: the listing and every othermanager.tsmessage moved ontotui.ts(One noun for policies, packs you publish yourself, and a help screen that fits #738, feat: TUI redesign, config v2 and OpenTelemetry setup (one PR: #881 + #899 + OTel) #880), andoptsFor()/colorsEnabled()gate colour on a TTY with noNO_COLOR.manager.tshas no hardcoded escapes left.--no-colorflag. Still missing on main, wherefailproofai policies --no-colorfails withUnknown flag: --no-color.This PR adds it.What each contribution brings
bin/failproofai.mjs, before the aliases and the--hookfast path, by settingNO_COLOR=1and removing it from argv, so it works in any position and no subcommand parser sees it. Help rows on the index andpolicies --help. End-to-end tests that run the real CLI with stdout presented as a TTY.listHookscolour test. Itsmanager.tsrewrite targeted the 16 escapes main has since removed, so the code half resolved to main's.screenKit().caution(), andapplyNoColorFlag()is not taken because importingtui.tsat the top of the bin reorders the bundle (renaming the builtin policies'ctxparameters, which changes the audit cache key; see the note above the--hookbranch) and would load the kit on every hook call.colorsEnabled/paintchecks and the lock thatmanager.tsholds no hardcoded escapes.Then three commits of mine: the #700 and #848 tests adapted to the current listing (it writes through
printBlock, notconsole.log, andapplyNoColorFlag's two tests become one that locks where the bin consumes the flag), a--no-colorrow indocs/reference/failproof-cli.mdxwith the CHANGELOG entry, and a shorterpolicies --helprow that fits on one line at 80 columns.Testing
script), the checks CLI:failproofai policiesignoresNO_COLOR, and--no-colordoes not exist #688 lists:failproofai policiesprints 23 escape sequences;policies --no-color,--no-color policies,p --no-color,--help --no-colorandNO_COLOR=1 failproofai policiesprint 0.tsc --noEmitand 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.package/pinned-install, which needs a builtdist/(CI's e2e job builds it) and timed out without one.cloud-jev-policies,pack-selection-mergeandpublish-command, which fail the same way on a clean main checkout here (their test policies cannot resolveimport "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