import { Command } from "commander"; import chalk from "chalk"; import { apiRequest } from "../lib/api-client.js"; export const feedbackCommand = new Command("feedback") .description("Report execution outcome for a skill") .argument("", "Skill slug") .option("--success ", "Whether execution succeeded (true/false)", "true") .option("--rating ", "Rating 1-5") .option("--time ", "Execution time in milliseconds") .option("--agent ", "Agent type (claude-code, cursor, codex, etc.)") .action(async (slug: string, options) => { try { const success = options.success !== "false"; const body: Record = { success, source: "cli" }; if (options.rating) body.rating = parseInt(options.rating, 10); if (options.time) body.executionTimeMs = parseInt(options.time, 10); if (options.agent) body.agentType = options.agent; const result = await apiRequest<{ ok: boolean; id: string }>( `/api/v1/skills/${encodeURIComponent(slug)}/feedback`, { method: "POST", body: JSON.stringify(body) }, ); if (result.ok) { console.log(chalk.green(`✓ Feedback recorded (id: ${result.id})`)); } } catch (err) { console.error( chalk.red( err instanceof Error ? err.message : "Failed to record feedback", ), ); process.exit(1); } });