// Team report: your team as CLIDE keeps it, each bot with its title, whether it's on, its skills and the tasks given // to it, from `clide team`. It reads and changes nothing. Run it from CLIDE, or here, with the clide command installed: // bun team-report.ts // CLIDE tells every run where its own `clide` command is (CLIDE_COMMAND, run with its Bun); from a terminal, it's // `clide` on the PATH, once Settings has installed it. /** What `clide --json` printed, parsed; it exits with a plain message when there's no `clide` to ask. */ async function clide(args: string[]): Promise { const command = process.env.CLIDE_COMMAND ? [process.execPath, process.env.CLIDE_COMMAND] : Bun.which("clide") ? ["clide"] : null; if (!command) { console.error("Run this from CLIDE, or install the clide command from CLIDE's Settings to run it here."); process.exit(7); } const done = Bun.spawnSync([...command, ...args, "--json"], { stdout: "pipe", stderr: "pipe" }); const text = done.stdout.toString(); let answer: { ok?: boolean; message?: string } & T; try { answer = JSON.parse(text); } catch { console.error(`clide ${args.join(" ")} didn't answer as it should: ${done.stderr.toString().trim() || text.trim()}`); process.exit(1); } if (answer.ok === false) { console.error(answer.message ?? `clide ${args.join(" ")} failed.`); process.exit(1); } return answer; } type Team = { team: { name: string; handle: string; title: string; on: boolean; responsibilities: string[]; skills: { name: string; when: string }[]; tasks: { task: string; when: string; paused: boolean }[]; }[]; }; const { team } = await clide(["team"]); const on = team.filter((bot) => bot.on).length; const lines = [`# Your team, ${new Date().toLocaleDateString()}`, `${team.length} bot${team.length === 1 ? "" : "s"}, ${on} on.`, ""]; for (const bot of team) { lines.push(`## ${bot.name} (@${bot.handle})${bot.title && bot.title !== bot.name ? `, ${bot.title}` : ""}${bot.on ? "" : " ยท off"}`); lines.push(`Skills: ${bot.skills.map((skill) => skill.name).join(", ") || "none"}.`); lines.push(`Tasks given to it: ${bot.tasks.map((task) => `${task.task} (${task.when}${task.paused ? ", paused" : ""})`).join("; ") || "none"}.`); if (bot.responsibilities.length > 0) lines.push(`Responsible for: ${bot.responsibilities.join("; ")}.`); lines.push(""); } console.log(lines.join("\n").trim());