Skip to content

tnh-setup

The tnh-setup command configures the TNH Scholar environment, setting up necessary directories and downloading default prompts.

Usage

tnh-setup [OPTIONS]

Options

--skip-env       Skip API key setup check
--skip-prompts  Skip prompt download
--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
  4. Creates logs directory

  5. Prompt Download

  6. Offers to download default prompts from GitHub
  7. Prompts are saved to ~/.config/tnh_scholar/prompts/
  8. Maintains directory structure from repository

  9. Environment Check

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

  12. yt-dlp Runtime Setup

  13. Offers to install a JS runtime (deno/node/bun)
  14. 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 download
tnh-setup --skip-prompts

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

Verification Only

tnh-setup --verify-only

Default Prompts

When downloading prompts, the following are included:

  • default_punctuate.md
  • default_section.md
  • default_line_translation.md
  • default_xml_format.md
  • default_xml_paragraph_format.md

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 Download Issues

  • Check internet connection
  • Verify GitHub access
  • Ensure write permissions in config directory
  • Check disk space

Post-Setup Verification

After running setup, verify:

  1. Directory Structure:
~/.config/tnh_scholar/
├── prompts/
└── logs/
  1. Prompt Files:
  2. Check that prompt files are present
  3. Verify file permissions
  4. Ensure proper formatting

  5. Environment:

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