fix(cli): init crashed instead of setting up when there is no terminal - #6
Merged
Merged
Conversation
`ruleofcode init` asks its questions through inquirer, which needs a real terminal to answer them. In CI, in a container, or behind a pipe there is none: readline force-closes and the process dies with an ERR_USE_AFTER_CLOSE stack trace and exit 7 — a setup tool crashing rather than setting anything up. The site tells new users to run exactly this command. Three behaviours now, each of them stated out loud: - no terminal, no config yet: run the same defaults `--quick` documents, and say so rather than pretend the user chose them; - no terminal, config already there: refuse, and point at --force. Overwriting a tuned config because nobody was present to object is the destructive answer to the question; - --force still overwrites, terminal or not. The terminal requirement belongs to inquirer, so a caller that injects its own prompt function is unaffected. Verified end to end against the packed tarball in a fresh consumer, which is where the crash was found. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
ruleofcode initasks its questions through inquirer, which needs a real terminal to answer them. In CI, in a container, or behind a pipe there is none: readline force-closes and the process dies with an ERR_USE_AFTER_CLOSE stack trace and exit 7 — a setup tool crashing rather than setting anything up. The site tells new users to run exactly this command.Three behaviours now, each of them stated out loud:
--quickdocuments, and say so rather than pretend the user chose them;The terminal requirement belongs to inquirer, so a caller that injects its own prompt function is unaffected.
Verified end to end against the packed tarball in a fresh consumer, which is where the crash was found.
What this changes
Verdict impact
(then: state the before/after values and what a consumer must do)
Evidence
tests/detectionLimitsupdated if what the detector cannot see has changedGate
npm run lint— 0 errorsnpx jest— full suite greennpm run canary— red/green proven across stacksnode dist/cli.js audit— RuleOfCode still passes its own lawNotes for the reviewer