#!/usr/bin/env python3
"""
PrePrompt Hook - User context loader example

Executed when system_prompt is loaded; can dynamically inject user-related
information into the prompt.
"""
import os
import sys


def main():
    """Read parameters from environment variables and output injected content."""
    user_identifier = os.environ.get('USER_IDENTIFIER', '')
    bot_id = os.environ.get('ASSISTANT_ID', '')

    # Example: query user context based on user_identifier
    # This is just a demo; in production, data should come from a database or other service
    if user_identifier:
        context_info = f"""## User Context

用户标识: {user_identifier}
Bot ID: {bot_id}

> 此内容由 user-context-loader skill 的 PrePrompt hook 注入。
> 实际使用时，可以在这里查询用户的位置、偏好、历史记录等信息。
"""
        print(context_info)
        return 0

    return 0


if __name__ == '__main__':
    sys.exit(main())
