import { runTool } from "../mcp/tool-runner.js";
export async function extractRepoHandler(req, res) {
try {
const repo = req.params.repo;
const ref = req.params.ref;
const force = req.query.force === "true";
const result = await runTool("extract_ref", { repo, ref, force });
res.json(result);
}
catch (error) {
res.status(500).json({
error: "Extraction failed",
message: error instanceof Error ? error.message : String(error),
});
}
}
export async function extractAllHandler(req, res) {
try {
const force = req.body.force === true;
const repos = req.body.repos;
const shallow = req.body.shallow !== false;
const refs = req.body.refs;
const result = await runTool("extract_all", { force, repos, shallow, refs });
res.json(result);
}
catch (error) {
res.status(500).json({
error: "Bulk extraction failed",
message: error instanceof Error ? error.message : String(error),
});
}
}
export async function extractionStatusHandler(req, res) {
try {
const jobId = req.params.jobId;
const result = await runTool("job_status", { jobId });
res.json(result);
}
catch (error) {
res.status(500).json({
error: "Failed to get job status",
message: error instanceof Error ? error.message : String(error),
});
}
}