basant307/AI_Governance_Project
045
1/**2 * @license3 * Copyright 2025 Google LLC4 * SPDX-License-Identifier: Apache-2.05 */6 7import type { Argv, CommandModule } from 'yargs';8import { t } from '../i18n/index.js';9 10const shouldUseColor = () =>11 Boolean(process.stdout.isTTY && !process.env['NO_COLOR']);12 13const color = (value: string, code: string) =>14 shouldUseColor() ? `\x1b[${code}m${value}\x1b[0m` : value;15 16const cyan = (value: string) => color(value, '36');17const yellow = (value: string) => color(value, '33');18 19export const buildRemovalNotice = (): string =>20 [21 '',22 yellow(t('⚠ qwen auth has been removed.')),23 '',24 ` ${cyan(t('Interactive'))} → ${t('run qwen and use /auth to configure providers')}`,25 ` ${cyan(t('CI / Headless'))} → ${t('set provider environment variables, for example OPENAI_API_KEY + OPENAI_BASE_URL + OPENAI_MODEL')}`,26 ` ${t('or pass --openai-api-key, --openai-base-url, --model')}`,27 ` ${cyan(t('Coding Plan'))} → ${t('set BAILIAN_CODING_PLAN_API_KEY and use the Coding Plan base URL for your region')}`,28 ` ${t('China: https://coding.dashscope.aliyuncs.com/v1')}`,29 ` ${t('International: https://coding-intl.dashscope.aliyuncs.com/v1')}`,30 ` ${cyan(t('OpenRouter'))} → ${t('set OPENROUTER_API_KEY and OPENAI_BASE_URL=https://openrouter.ai/api/v1')}`,31 ` ${cyan(t('Requesty'))} → ${t('set REQUESTY_API_KEY and OPENAI_BASE_URL=https://router.requesty.ai/v1')}`,32 ` ${cyan(t('Qwen OAuth'))} → ${t('run qwen interactively and use /auth; OAuth cannot be configured with env vars alone')}`,33 ` ${cyan(t('Scripted'))} → ${t('edit ~/.qwen/settings.json, or run qwen interactively once')}`,34 '',35 ` ${t('Check auth status')} → ${cyan('/doctor')}`,36 '',37 ].join('\n');38 39export const printRemovalNotice = () => {40 process.stdout.write(buildRemovalNotice(), () => process.exit(0));41};42 43const legacySubcommands = [44 'status',45 'coding-plan',46 'openrouter',47 'requesty',48 'api-key',49 'qwen-oauth',50];51 52export const authCommand: CommandModule = {53 command: 'auth',54 describe: t('Configure authentication (removed)'),55 builder: (yargs: Argv) => {56 let y = yargs.version(false).strict(false);57 for (const name of legacySubcommands) {58 y = y.command({59 command: `${name} [legacyArgs..]`,60 describe: false,61 builder: (subYargs: Argv) => subYargs.strict(false),62 handler: printRemovalNotice,63 });64 }65 return y;66 },67 handler: printRemovalNotice,68};69 