Skip to content

tnh-setup

The tnh-setup command configures the TNH Scholar environment, prepares local prompt directories, and verifies core runtime prerequisites.

Usage

tnh-setup [OPTIONS]

Options

--skip-env       Skip API key setup check
--skip-prompts  Skip prompt directory setup guidance
--skip-ytdlp-runtime  Skip yt-dlp runtime setup
--verify-only    Only run environment verification
-y, --yes        Assume yes for all prompts
--no-input       Fail if a prompt would be required
--help          Show this message and exit

Configuration Steps

The setup process includes:

  1. Directory Creation
  2. Creates ~/.config/tnh-scholar/
  3. Creates prompts directory for user-level overrides
  4. Creates logs directory

  5. Prompt Setup

  6. Prepares ~/.config/tnh-scholar/prompts/ for local prompt overrides
  7. Reports the repo-local default workspace: ./tnh-prompts/
  8. Reports bundled runtime prompts at src/tnh_scholar/runtime_assets/prompts/
  9. Does not download prompts from an external repository

  10. Environment Check

  11. Verifies OpenAI API key configuration
  12. Provides guidance if key is missing

  13. yt-dlp Runtime Setup

  14. Offers to install a JS runtime (deno/node/bun)
  15. Offers to install curl_cffi for impersonation support

Examples

Complete Setup

# Run full setup
tnh-setup

Selective Setup

# Skip API key check
tnh-setup --skip-env

# Skip prompt setup guidance
tnh-setup --skip-prompts

# Skip both
tnh-setup --skip-env --skip-prompts

Verification Only

tnh-setup --verify-only

Prompt Locations

tnh-setup prepares and reports three prompt locations:

  • Repo-local default workspace: ./tnh-prompts/ when running inside the repository
  • User prompt directory: ~/.config/tnh-scholar/prompts/
  • Bundled runtime prompts: src/tnh_scholar/runtime_assets/prompts/

Environment Variables

The setup process checks for and uses:

  • OPENAI_API_KEY: Required for AI functionality
  • TNH_PROMPT_DIR: Optional custom prompt directory

Troubleshooting

Missing API Key

If the OpenAI API key is not found, the setup tool displays guidance:

>>>>>>>>>> OpenAI API key not found in environment. <<<<<<<<<

For AI processing with TNH-scholar:

1. Get an API key from https://platform.openai.com/api-keys
2. Set the OPENAI_API_KEY environment variable:

   export OPENAI_API_KEY='your-api-key-here'  # Linux/Mac
   set OPENAI_API_KEY=your-api-key-here       # Windows

For OpenAI API access help: https://platform.openai.com/

Prompt Setup Issues

  • Ensure write permissions in the config directory
  • Confirm the repository contains tnh-prompts/ when working from source
  • Use TNH_PROMPT_DIR or --prompt-dir if you intentionally store prompts elsewhere

Post-Setup Verification

After running setup, verify:

  1. Directory Structure:
~/.config/tnh-scholar/
├── prompts/
└── logs/
  1. Prompt Files:
  2. Check that repo-local prompts are present in ./tnh-prompts/ when working from source
  3. Check ~/.config/tnh-scholar/prompts/ for user overrides if you use them
  4. Verify file permissions

  5. Environment:

  6. Confirm API key is set
  7. Test basic AI functionality