#!/usr/bin/env node
import assert from 'assert';
import { createProvider, CLIProvider, APIProvider } from './src/core/llm-provider.js';

console.log('\n── LLM Provider Reuse ──');

const cliA = createProvider({
  llmProvider: 'cli',
  cliAvailable: true,
  model: 'claude-opus-4-6',
  port: 4000,
});
const cliB = createProvider({
  llmProvider: 'cli',
  cliAvailable: true,
  model: 'claude-opus-4-6',
  port: 4000,
});

assert(cliA instanceof CLIProvider, 'CLI provider should be created for cli mode');
assert.strictEqual(cliA, cliB, 'CLI provider instances should be reused for identical config');

const apiA = createProvider({
  llmProvider: 'api-key',
  apiKey: 'test-key-123',
  model: 'claude-opus-4-6',
  port: 4000,
});
const apiB = createProvider({
  llmProvider: 'api-key',
  apiKey: 'test-key-123',
  model: 'claude-opus-4-6',
  port: 4000,
});

assert(apiA instanceof APIProvider, 'API provider should be created for api-key mode');
assert.strictEqual(apiA, apiB, 'API provider instances should be reused for identical config');

console.log('PASS test-llm-provider-reuse.js');
