Skip to content

Support non-interactive mode in npx-thunderid for AI tools and CI environments#3077

Open
rajithacharith wants to merge 1 commit into
thunder-id:mainfrom
rajithacharith:npx-tool-2
Open

Support non-interactive mode in npx-thunderid for AI tools and CI environments#3077
rajithacharith wants to merge 1 commit into
thunder-id:mainfrom
rajithacharith:npx-tool-2

Conversation

@rajithacharith
Copy link
Copy Markdown
Contributor

@rajithacharith rajithacharith commented May 29, 2026

Purpose

npx thunderid hangs in non-interactive environments (AI coding tools, CI pipelines) because the install directory prompt uses @clack/prompts text(), which requires a TTY. There was no way to run a fully unattended setup without interactive input.

Approach

Added --install-dir <path> CLI flag and THUNDER_INSTALL_DIR env var to tools/npx-thunderid/src/index.ts. When either is provided, the interactive install directory prompt is skipped entirely. Admin credentials already flow through to setup.sh via --admin-username/--admin-password flags and ADMIN_USERNAME/ADMIN_PASSWORD env vars.

Non-interactive usage:

# via flags
npx thunderid --install-dir /tmp/thunderid --admin-username admin --admin-password secret

# via env vars
THUNDER_INSTALL_DIR=/tmp/thunderid ADMIN_USERNAME=admin ADMIN_PASSWORD=secret npx thunderid

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
    • Ran Vale and fixed all errors and warnings
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Added --install-dir <path> CLI option to specify custom installation directory.
    • Added THUNDER_INSTALL_DIR environment variable support for installation path configuration.
    • Enabled non-interactive installation workflows.
  • Bug Fixes

    • Improved existing installation detection logic for better reliability.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@rajithacharith, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 18 minutes and 7 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c8af46df-8346-4218-97e3-e0abbf54069e

📥 Commits

Reviewing files that changed from the base of the PR and between 1e3b439 and 6c11323.

📒 Files selected for processing (1)
  • tools/npx-thunderid/src/index.ts
📝 Walkthrough

Walkthrough

npx-thunderid CLI is updated to support non-interactive setup by adding --install-dir flag parsing and environment variable support. Argument parsing now extracts and returns the install directory option. Main function uses this flag or THUNDER_INSTALL_DIR env var to bypass interactive prompts; otherwise prompts interactively as before. Installation detection switches from filesystem existence check to Thunder-root verification.

Changes

Non-interactive install directory support

Layer / File(s) Summary
CLI argument parsing
tools/npx-thunderid/src/index.ts
parseCliArgs adds support for --install-dir <path> option and returns it in the function result alongside forceSetup and forwardedArgs.
Main function integration
tools/npx-thunderid/src/index.ts
Main destructures cliInstallDir and uses it for non-interactive directory selection via CLI flag or THUNDER_INSTALL_DIR env var, with fallback to interactive prompt. Installation detection changes from fs.existsSync to findThunderRoot root-based check.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding non-interactive mode support to npx-thunderid for AI tools and CI environments.
Description check ✅ Passed The PR description includes all essential sections: a clear Purpose explaining the problem, a detailed Approach describing the implementation with usage examples, Related Issues linking to #3076, and Security/Checklist sections.
Linked Issues check ✅ Passed The code changes implement all requirements from issue #3076: adding --install-dir flag and THUNDER_INSTALL_DIR env var to skip interactive prompts, and forwarding admin credentials to setup.sh via existing flags/env vars.
Out of Scope Changes check ✅ Passed All changes in index.ts are directly scoped to implementing non-interactive mode support. The parseCliArgs enhancement, installDir parameter handling, and Thunder-root detection change are all necessary to achieve the linked issue objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/npx-thunderid/src/index.ts`:
- Around line 37-40: The loop handling CLI args currently lets a bare
"--install-dir" fall through to forwardedArgs when it's the last token; update
the branch that checks "arg === '--install-dir'" to fail fast if there is no
following value (i + 1 >= argv.length) by printing a clear error and exiting (or
throwing) instead of forwarding it, and still consume the next token into
installDir when present (i.e., keep the existing installDir = argv[++i] behavior
and do not push the flag to forwardedArgs in the error or success cases);
reference the variables argv, arg, installDir, forwardedArgs and the
argument-parsing loop in index.ts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b00b80b7-f8fa-408c-a969-e291db9add39

📥 Commits

Reviewing files that changed from the base of the PR and between 111ad3c and 1e3b439.

📒 Files selected for processing (1)
  • tools/npx-thunderid/src/index.ts

Comment thread tools/npx-thunderid/src/index.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npx-thunderid: support non-interactive mode for AI tools and CI environments

2 participants