LLM-1521: reattach stdin to /dev/tty when piped#50
Conversation
When installing Kimchi via 'curl ... | bash', stdin is a pipe from curl and is already at EOF. This caused the first-run API key prompt to immediately fail with 'error: read API key: EOF'. Redirect kimchi's stdin from /dev/tty when the script detects it is running in a non-TTY context, so the interactive prompt still works. If no TTY is available, skip auto-launch and print a helpful message. Co-Authored-By: Kimchi <noreply@kimchi.dev>
Kimchi Code Review
Summary📊 Review Score: 95/100 (overall code quality — 0 lowest, 100 highest) 🧪 Tests: no — No automated tests are visible for the shell script changes. This is typical for install scripts, though manual testing across different execution contexts (direct execution, piped curl, SSH without TTY) would verify the TTY detection logic. No significant issues found. LGTM! 🎉 What to expectKimchi will analyze the changes in this pull request and post:
The review typically completes within a few minutes. This comment will be updated once the review is ready. Interact with Kimchi
ConfigurationReviews are configured by your organization admin. Powered by Kimchi — AI-powered code review by CAST AI |
There was a problem hiding this comment.
📊 Review Score: 95/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 1/5 (1 = trivial, 5 = very complex)
🧪 Tests: no — No automated tests are visible for the shell script changes. This is typical for install scripts, though manual testing across different execution contexts (direct execution, piped curl, SSH without TTY) would verify the TTY detection logic.
No significant issues found. LGTM! 🎉
OpenClaw's config set defaults to replace mode, which causes
the setup to fail when users already have model entries in
agents.defaults.models or agents.defaults.model.fallbacks.
Changes across all three code paths:
1. Batch JSON mode (writeOpenClawViaCLI):
- Split batch to only cover non-conflicting fields
(provider block + primary).
- Use separate openclaw config set --merge calls for
agents.defaults.model.fallbacks and agents.defaults.models.
2. Sequential CLI mode (writeOpenClawViaCLISequential):
- Add --merge flag for agent.defaults.model.fallbacks.
- Add --merge flag for agent.defaults.models.
3. Direct file-writing mode (writeOpenClawDirect):
- Merge Kimchi model catalog into existing defaults["models"]
instead of replacing it entirely.
- Merge into existing defaults["model"] map instead of
overwriting, preserving keys like temperature and max_tokens.
- Append Kimchi fallbacks to existing fallbacks array.
Co-Authored-By: Kimchi <noreply@kimchi.dev>
Fixes
1. Install script: API key prompt fails when piped (
curl | bash)When installing Kimchi via
curl ... | bash, stdin is a pipe from curl and is already at EOF. This caused the first-run API key prompt to immediately fail witherror: read API key: EOF.Fix in
scripts/install.sh: Redirect kimchi's stdin from/dev/ttywhen the script detects it is running in a non-TTY context, so the interactive prompt still works. If no TTY is available, skip auto-launch and print a helpful message.2. OpenClaw setup: refuses to overwrite existing model entries (closes #51)
When Kimchi sets
agents.defaults.models(andagents.defaults.model.fallbacks) via OpenClaw'sconfig setCLI, OpenClaw defaults to replace mode and refuses because the user already has other entries (e.g.,openai-codex/gpt-5.4).Error before:
Fix in
internal/tools/openclaw.go:openclaw config set --mergecalls for fallbacks and models.--mergeflag foragents.defaults.model.fallbacksandagents.defaults.models.defaults["models"], merge into existingdefaults["model"]map (preserving keys liketemperature,max_tokens), and append Kimchi fallbacks to existing fallbacks array.Co-Authored-By: Kimchi noreply@kimchi.dev
Kimchi Summary
What changed
Fixes the install script to handle piped execution (e.g.,
curl | bash) by redirecting input from/dev/ttywhen stdin is not a TTY. Also updates OpenClaw configuration logic to merge new Kimchi model settings with existing user configuration instead of overwriting.Why
Piped installation failed when Kimchi required interactive input because stdin was attached to the pipe rather than a terminal. Additionally, registering Kimchi models previously overwrote existing OpenClaw settings like
temperature,max_tokens, or custom model fallbacks.Key changes
scripts/install.sh: Added TTY detection—executeskimchidirectly if stdin is a TTY, falls back to/dev/ttyredirection if available, or prompts the user to run manually otherwise.internal/tools/openclaw.go:--mergeflag toopenclaw config setcalls foragents.defaults.model.fallbacksandagents.defaults.modelsto preserve existing entries.writeOpenClawViaCLIto handle merge-required fields in separate CLI calls outside of--batch-json.writeOpenClawDirectto merge into existingmodelconfiguration (preserving keys liketemperature) and append to existingfallbacksarrays rather than replacing them.writeOpenClawDirectto merge into the existing models catalog instead of creating a new map.Impact
temperature, custom fallbacks) are now preserved when registering Kimchi models./dev/ttyaccess.