Versions 175 to 318
new file, 152 lines
1+// abso flag: read, flip and audit a server's feature flags, with no deploy. Each flag has its values, a safe default,
2+// and a line of what it gates; a value is set for the whole server, one project, or one person. The server decides who
3+// may: its admin token always, and an owner's key where it says so. The admin token is read at run time, sent only as a
11+
22+
23+export type FlagScope = { readonly env: true } | { readonly project: string } | { readonly person: string };
24+
35+
37+ 'abso flag [list] | abso flag log [--limit N] | abso flag set <flag> <value> --why "..." [--project <name> | --person person:<id>] | abso flag unset <flag> --why "..." [--project <name> | --person person:<id>]';
38+
39+/** The admin token when there is one for this server, else none: a server that takes an owner's key answers without it. */
40+export function adminFor(server: string, env: Readonly<Record<string, string | undefined>>): string | undefined {
48+
51+ for (const secret of secrets) if (secret.length > 0) out = out.split(secret).join("[redacted]");
54+
55+async function call(config: Config, admin: string | undefined, path: string, body?: unknown): Promise<unknown> {
78+ response.ok ? "the server's answer was not JSON" : scrub(text.slice(0, 500), secrets) || `${response.status}`,
84+ throw new UsageError(scrub(typeof error === "string" ? error : `the server answered ${response.status}`, secrets));
88+
91+ return "project" in scope ? `project ${scope.project}` : "person" in scope ? scope.person : "here";
93+
94+/** What abso flag list prints: each flag, what it takes, its safe value, and every place it's set. */
102+ `${name}: ${f.env ?? `${f.safe} (unset)`}. Takes ${f.values.join(", ")}; safe ${f.safe}${f.stagingOnly ? "; staging only" : ""}.`,
110+
113+ return `${shortWhen(Date.parse(c.at), now)} ${c.by} ${c.flag} ${scopeWords(c.scope)}: ${c.old ?? "unset"} to ${c.new ?? "unset"}. "${c.why}"`;
115+
130+ if (!/^[0-9]{1,3}$/.test(limit) || Number(limit) < 1) throw new UsageError("--limit is a number from 1 to 999");
131+ const body = (await call(config, admin, `/admin/flags/audit?limit=${limit}`)) as { changes: FlagChange[] };
132+ const text = body.changes.length === 0 ? "No changes yet." : body.changes.map((c) => changeText(c)).join("\n");
135+ const setting = sub === "set" && flag !== undefined && value !== undefined && extra.length === 0;
139+ if (why === undefined || why.trim().length < 3) throw new UsageError('every change says why: --why "..."');
144+ if (person !== undefined && !person.startsWith("person:")) throw new UsageError("--person is person:<id>");
- MCP
- compare on this site's /mcp
- CLI
- abso diff 175 318 client/src/flag-commands.ts --json
- JSON
- /christopher/abso-core/compare/175..318?file=client%2Fsrc%2Fflag-commands.ts&format=json