<?php

declare(strict_types=1);

namespace App\Command;

use App\Vector\VectorIndexBuilder;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'mto:agent:vector:rebuild')]
class VectorIngestCommand extends Command
{
    public function __construct(
        private readonly VectorIndexBuilder $builder
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('Rebuilding vector index...');
        $this->builder->rebuildFromNdjson();
        $output->writeln('Done.');

        return Command::SUCCESS;
    }
}
