// Pi Ask Tool CLI Agent

import { ask_claude } from "../../@piplugin/ask-claude"
import { sessionId } from '../shared';

export async function start() {
  console.log('Pi Ask Tool initialized');

  while (true) {
    // Get user input from TUI (simplified for example)
    const userInput = await getTUIInput('Ask a question:');

    // Handle multi-turn sessions via sessionId
    const response = await ask_claude({
      prompt: userInput,
      agent: 'code_review', // Default agent
      session_id: sessionId
    });

    // Display answer in TUI
    await showTUIResult(response);

    // Update session context if needed
    sessionId = response.session_id || sessionId;
  }
}

// Mock TUI handlers - implement actual TUI integration
async function getTUIInput(question: string) {
  // Replace with real TUI input method
  const input = process.stdin.read().toString();
  return input;
}

async function showTUIResult(result: any) {
  console.log('Answer:', result.summary || result);
}