// Sage, 2026-10-09: isolation probe for the mosaic-stack bots on tasks.mosaicstack.dev (decisions 66 and 68). // Reads each token file in-process and prints statuses and ids only. // Usage: node probe.mjs SECRETS_DIR PROJECT_ID OTHER_PROJECT_ID import { readFileSync } from "node:fs"; const [S, P, OTHER] = process.argv.slice(2); const BASE = "https://tasks.mosaicstack.dev/api/v2"; async function get(path, tok) { const r = await fetch(BASE + path, { headers: { Authorization: `Bearer ${tok}` } }); let j = null; try { j = await r.json(); } catch {} return { s: r.status, j }; } const ids = (j) => (j?.items ?? (Array.isArray(j) ? j : [])).map((x) => x.id); for (const r of ["pm", "cto", "coder", "reviewer", "sync"]) { const tok = readFileSync(`${S}/${r}-vikunja.token`, "utf8").trim(); const own = await get(`/projects/${P}`, tok); const other = await get(`/projects/${OTHER}`, tok); const list = await get(`/projects`, tok); const labels = await get(`/labels`, tok); const tasks = await get(`/projects/${OTHER}/views`, tok); console.log(r, `own=${own.s}`, `other=${other.s}`, `projects=${list.s}:${JSON.stringify(ids(list.j))}`, `labels=${labels.s}:${JSON.stringify(ids(labels.j))}`, `otherViews=${tasks.s}`); }