@alterset/alterspec-client 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { Command } from "commander";
4
+ import { Command, InvalidArgumentError } from "commander";
5
5
  import { join as join9 } from "path";
6
6
 
7
7
  // src/config.ts
@@ -256,12 +256,12 @@ function readConfigAt(root) {
256
256
  } catch {
257
257
  throw new ConfigError(`${path} is not valid JSON.`);
258
258
  }
259
- const parsed = ClientConfigSchema.safeParse(raw);
260
- if (!parsed.success)
259
+ const parsed2 = ClientConfigSchema.safeParse(raw);
260
+ if (!parsed2.success)
261
261
  throw new ConfigError(
262
- `${path} is not valid: ${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}.`
262
+ `${path} is not valid: ${parsed2.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}.`
263
263
  );
264
- return parsed.data;
264
+ return parsed2.data;
265
265
  }
266
266
  function loadConfig(cwd = process.cwd()) {
267
267
  for (const root of candidates(cwd)) {
@@ -296,9 +296,21 @@ var PRODUCT_TOOLS = [
296
296
  "answer",
297
297
  "reconcile",
298
298
  "feedback",
299
- "bug_reports"
299
+ "bug_reports",
300
+ "lift",
301
+ "release_notes",
302
+ "build_report"
300
303
  ];
301
- var PRODUCT_ONLY = /* @__PURE__ */ new Set(["answer", "reconcile", "bug_reports"]);
304
+ var OWNER_WRITES = /* @__PURE__ */ new Set(["feedback_outcome", "hold", "unhold"]);
305
+ var PRODUCT_ONLY = /* @__PURE__ */ new Set([
306
+ "answer",
307
+ "reconcile",
308
+ "bug_reports",
309
+ "lift",
310
+ "release_notes",
311
+ "build_report",
312
+ ...OWNER_WRITES
313
+ ]);
302
314
  function roleOf(whoami) {
303
315
  if (whoami.role === "product" || whoami.role === "developer") return whoami.role;
304
316
  return whoami.product === true ? "product" : "developer";
@@ -307,6 +319,11 @@ function allows(role, tool) {
307
319
  return role === "product" ? PRODUCT_TOOLS.includes(tool) : !PRODUCT_ONLY.has(tool);
308
320
  }
309
321
  function refusal(role, tool) {
322
+ if (role === "product" && OWNER_WRITES.has(tool))
323
+ return {
324
+ code: "CLI_ONLY",
325
+ message: `\`${tool}\` changes the dispatcher's records and runs only on the owner's typed word, from the CLI: \`npx @alterset/alterspec-client ${tool.replace(/_/g, "-")} \u2026 --confirm\`.`
326
+ };
310
327
  return role === "product" ? {
311
328
  code: "NOT_DEVELOPER",
312
329
  message: `Your key is registered as a product person; \`${tool}\` is the developers'. A product session sees the build's questions, feedback and bugs, never its tasks.`
@@ -343,7 +360,7 @@ function agentKeys() {
343
360
  return [];
344
361
  }
345
362
  }
346
- var isKeyLine = (s) => KEY_TYPES.some((t) => s.trim().startsWith(`${t} `));
363
+ var isKeyLine = (s2) => KEY_TYPES.some((t) => s2.trim().startsWith(`${t} `));
347
364
  function resolveKey(opts = {}) {
348
365
  const { configured, agent = agentKeys, home = homedir2() } = opts;
349
366
  if (configured) {
@@ -764,8 +781,8 @@ var DeltaSchema = z6.object({
764
781
  var DELTA_JSON = "delta.json";
765
782
  function parseDelta(json) {
766
783
  try {
767
- const parsed = DeltaSchema.safeParse(JSON.parse(json));
768
- return parsed.success ? parsed.data : void 0;
784
+ const parsed2 = DeltaSchema.safeParse(JSON.parse(json));
785
+ return parsed2.success ? parsed2.data : void 0;
769
786
  } catch {
770
787
  return void 0;
771
788
  }
@@ -828,21 +845,21 @@ function objectParts(text, kind) {
828
845
  const put = (label, heading, body2) => {
829
846
  const base = label === "front-matter" ? FRONT_MATTER_PART : slug(heading);
830
847
  let key = base;
831
- for (let n = 2; out.has(key); n++) key = `${base}-${n}`;
848
+ for (let n2 = 2; out.has(key); n2++) key = `${base}-${n2}`;
832
849
  out.set(key, { label, heading, text: body2 });
833
850
  };
834
851
  const t = forWork(text);
835
852
  if (kind === "doc") {
836
853
  const { raw, body: body2 } = splitFrontMatter(t);
837
854
  if (raw) put("front-matter", FRONT_MATTER_PART, raw);
838
- for (const s of headed(body2, "## ").sections) put("section", s.heading, s.text);
855
+ for (const s2 of headed(body2, "## ").sections) put("section", s2.heading, s2.text);
839
856
  return out;
840
857
  }
841
858
  const yaml = /^```ya?ml\n([\s\S]*?)\n```[^\S\n]*$/m.exec(t);
842
859
  if (yaml) put("front-matter", FRONT_MATTER_PART, yaml[1]);
843
860
  const body = yaml ? t.slice(yaml.index + yaml[0].length) : t.replace(/^## [^\n]*\n?/, "");
844
861
  const { sections: sections2 } = headed(body, "### ");
845
- if (sections2.length) for (const s of sections2) put("section", s.heading, s.text);
862
+ if (sections2.length) for (const s2 of sections2) put("section", s2.heading, s2.text);
846
863
  else for (const b of bullets(body)) put("line", b.heading, b.text);
847
864
  return out;
848
865
  }
@@ -886,7 +903,7 @@ function bullets(text) {
886
903
  }
887
904
  return out;
888
905
  }
889
- var lead = (s) => s.replace(/\*\*|__|`/g, "").split(/:\s|:$|\s[—–-]\s|\.\s|\.$/)[0].trim().split(/\s+/).slice(0, 8).join(" ");
906
+ var lead = (s2) => s2.replace(/\*\*|__|`/g, "").split(/:\s|:$|\s[—–-]\s|\.\s|\.$/)[0].trim().split(/\s+/).slice(0, 8).join(" ");
890
907
 
891
908
  // ../src/export/read.ts
892
909
  import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "fs";
@@ -954,16 +971,16 @@ function readJson(dir, name) {
954
971
  }
955
972
  function readExport(dir) {
956
973
  const exp = readJson(dir, EXPORT_JSON);
957
- const parsed = AnyWorkSchema.safeParse(readJson(dir, WORK_JSON));
958
- if (!parsed.success)
974
+ const parsed2 = AnyWorkSchema.safeParse(readJson(dir, WORK_JSON));
975
+ if (!parsed2.success)
959
976
  throw new ExportReadError(`${join3(dir, WORK_JSON)} is not a work.json this client reads.`);
960
- const sources = new Map((exp.sources ?? []).map((s) => [s.id, s]));
977
+ const sources = new Map((exp.sources ?? []).map((s2) => [s2.id, s2]));
961
978
  const has = (path) => existsSync3(join3(dir, path));
962
979
  const read = (path) => has(path) ? readFileSync3(join3(dir, path), "utf8") : void 0;
963
980
  const modules = () => existsSync3(join3(dir, "modules")) ? readdirSync(join3(dir, "modules")).map((m) => moduleDir(m)) : [];
964
981
  const shards = (file) => {
965
982
  const folder = shardDir(file);
966
- return has(folder) ? readdirSync(join3(dir, folder)).sort().map((n) => `${folder}/${n}`) : [];
983
+ return has(folder) ? readdirSync(join3(dir, folder)).sort().map((n2) => `${folder}/${n2}`) : [];
967
984
  };
968
985
  let indexCache = null;
969
986
  const index = () => {
@@ -976,7 +993,7 @@ function readExport(dir) {
976
993
  const proposalPath = (change) => [archiveDir(), ...modules().map((m) => `${m}/changes/archive`)].map((a) => `${a}/${change}/proposal.md`).find(has);
977
994
  return {
978
995
  dir,
979
- work: parsed.data,
996
+ work: parsed2.data,
980
997
  sources,
981
998
  has,
982
999
  read,
@@ -1002,7 +1019,7 @@ function readExport(dir) {
1002
1019
  },
1003
1020
  index,
1004
1021
  initiative(id) {
1005
- const work = parsed.data;
1022
+ const work = parsed2.data;
1006
1023
  const title = "initiatives" in work ? work.initiatives?.find((i) => i.id === id)?.title : void 0;
1007
1024
  const text = read(initiativePath(id));
1008
1025
  if (!title || text === void 0) return void 0;
@@ -1027,9 +1044,9 @@ var linesOf = (text) => text === "" ? [] : text.replace(/\n$/, "").split("\n");
1027
1044
  function diffLines(a, b) {
1028
1045
  const x = linesOf(a);
1029
1046
  const y = linesOf(b);
1030
- const n = x.length;
1047
+ const n2 = x.length;
1031
1048
  const m = y.length;
1032
- const max = n + m;
1049
+ const max = n2 + m;
1033
1050
  const v = /* @__PURE__ */ new Map([[1, 0]]);
1034
1051
  const trace = [];
1035
1052
  outer: for (let d = 0; d <= max; d++) {
@@ -1037,16 +1054,16 @@ function diffLines(a, b) {
1037
1054
  for (let k = -d; k <= d; k += 2) {
1038
1055
  let i2 = k === -d || k !== d && (v.get(k - 1) ?? -1) < (v.get(k + 1) ?? -1) ? v.get(k + 1) ?? 0 : (v.get(k - 1) ?? 0) + 1;
1039
1056
  let j2 = i2 - k;
1040
- while (i2 < n && j2 < m && x[i2] === y[j2]) {
1057
+ while (i2 < n2 && j2 < m && x[i2] === y[j2]) {
1041
1058
  i2++;
1042
1059
  j2++;
1043
1060
  }
1044
1061
  v.set(k, i2);
1045
- if (i2 >= n && j2 >= m) break outer;
1062
+ if (i2 >= n2 && j2 >= m) break outer;
1046
1063
  }
1047
1064
  }
1048
1065
  const out = [];
1049
- let i = n;
1066
+ let i = n2;
1050
1067
  let j = m;
1051
1068
  for (let d = trace.length - 1; d >= 0; d--) {
1052
1069
  const vd = trace[d];
@@ -1158,13 +1175,13 @@ function cutDocument(content) {
1158
1175
  const intro = lines.slice(0, parts.length ? parts[0].line - 1 : lines.length).join("\n").trim();
1159
1176
  if (intro) out.push({ name: INTRO_SHARD, kind: "introduction", text: `${intro}
1160
1177
  ` });
1161
- parts.forEach((s, i) => {
1162
- const text = s.text.trim();
1178
+ parts.forEach((s2, i) => {
1179
+ const text = s2.text.trim();
1163
1180
  out.push({
1164
- name: sectionShardName(i, s.heading),
1181
+ name: sectionShardName(i, s2.heading),
1165
1182
  kind: "section",
1166
- heading: s.heading,
1167
- text: `## ${s.heading}
1183
+ heading: s2.heading,
1184
+ text: `## ${s2.heading}
1168
1185
  ${text ? `
1169
1186
  ${text}
1170
1187
  ` : ""}`
@@ -1252,7 +1269,7 @@ function seen(x, change, key) {
1252
1269
  }
1253
1270
  function pinnedReader(x, change) {
1254
1271
  const byFile = /* @__PURE__ */ new Map();
1255
- for (const s of x.sources.values()) byFile.set(s.file, [...byFile.get(s.file) ?? [], s.id]);
1272
+ for (const s2 of x.sources.values()) byFile.set(s2.file, [...byFile.get(s2.file) ?? [], s2.id]);
1256
1273
  const isItem = (file, id) => x.has(itemShardPath(file, id));
1257
1274
  const keys = /* @__PURE__ */ new Map();
1258
1275
  const keyOf2 = (path) => {
@@ -1271,26 +1288,26 @@ function pinnedReader(x, change) {
1271
1288
  };
1272
1289
  const seenOf = /* @__PURE__ */ new Map();
1273
1290
  const see = (key) => {
1274
- let s = seenOf.get(key);
1275
- if (!s) seenOf.set(key, s = seen(x, change, key));
1276
- return s;
1291
+ let s2 = seenOf.get(key);
1292
+ if (!s2) seenOf.set(key, s2 = seen(x, change, key));
1293
+ return s2;
1277
1294
  };
1278
1295
  const files = /* @__PURE__ */ new Map();
1279
1296
  const none = /* @__PURE__ */ new Map();
1280
1297
  const pinnedFiles = (key) => {
1281
1298
  const known = files.get(key);
1282
1299
  if (known) return known;
1283
- const s = see(key);
1300
+ const s2 = see(key);
1284
1301
  const file = x.fileOf(key);
1285
1302
  let out = none;
1286
- if (s.text !== void 0 && file) {
1303
+ if (s2.text !== void 0 && file) {
1287
1304
  out = /* @__PURE__ */ new Map();
1288
- if (isItem(file, key)) out.set(itemShardPath(file, key), `${s.text.trim()}
1305
+ if (isItem(file, key)) out.set(itemShardPath(file, key), `${s2.text.trim()}
1289
1306
  `);
1290
1307
  else {
1291
- out.set(file, s.text);
1308
+ out.set(file, s2.text);
1292
1309
  if (file.endsWith(".md"))
1293
- for (const part of cutDocument(s.text)) out.set(`${shardDir(file)}/${part.name}`, part.text);
1310
+ for (const part of cutDocument(s2.text)) out.set(`${shardDir(file)}/${part.name}`, part.text);
1294
1311
  }
1295
1312
  }
1296
1313
  files.set(key, out);
@@ -1355,8 +1372,8 @@ function settled(args) {
1355
1372
  function aboutOf(args) {
1356
1373
  const cites = Array.isArray(args.cites) ? args.cites : [];
1357
1374
  const refs = [...cites, args.item].flatMap((r) => {
1358
- const s = str(r);
1359
- return s && !s.includes("/") ? [s.trim()] : [];
1375
+ const s2 = str(r);
1376
+ return s2 && !s2.includes("/") ? [s2.trim()] : [];
1360
1377
  });
1361
1378
  return [...new Set(refs)];
1362
1379
  }
@@ -1631,8 +1648,8 @@ var TaskAnswerSchema = z7.object({
1631
1648
  why: z7.string().nullish()
1632
1649
  });
1633
1650
  function parseAnswers(raw) {
1634
- const parsed = z7.array(TaskAnswerSchema).safeParse(raw);
1635
- return parsed.success && parsed.data.length ? parsed.data : void 0;
1651
+ const parsed2 = z7.array(TaskAnswerSchema).safeParse(raw);
1652
+ return parsed2.success && parsed2.data.length ? parsed2.data : void 0;
1636
1653
  }
1637
1654
  var QuestionsError = class extends Error {
1638
1655
  };
@@ -1656,10 +1673,10 @@ async function listQuestions(session, filter = {}) {
1656
1673
  ...filter.ids?.length ? { ids: filter.ids } : filter.task ? { task: filter.task } : filter.about ? { about: filter.about } : { mine: true },
1657
1674
  ...filter.open ? { status: "open" } : {}
1658
1675
  });
1659
- const parsed = z7.array(QuestionSchema).safeParse(answer.questions ?? []);
1660
- if (!parsed.success)
1676
+ const parsed2 = z7.array(QuestionSchema).safeParse(answer.questions ?? []);
1677
+ if (!parsed2.success)
1661
1678
  throw new QuestionsError("The dispatcher\u2019s questions are not in a form this client reads.");
1662
- return parsed.data;
1679
+ return parsed2.data;
1663
1680
  }
1664
1681
  async function taskQuestions(session, task) {
1665
1682
  try {
@@ -1757,26 +1774,23 @@ function answersSection(answers) {
1757
1774
 
1758
1775
  // src/ruled.ts
1759
1776
  var str2 = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
1777
+ var ids = (v) => Array.isArray(v) ? v.flatMap((x) => typeof x === "string" && x.trim() ? [x.trim()] : []) : [];
1760
1778
  function rulingOf(v) {
1761
- if (typeof v === "string")
1762
- return /^Q-\d+$/.test(v) ? { id: v, path: `alterspec-client questions ${v}` } : void 0;
1763
1779
  const r = v;
1764
- if (!r || typeof r !== "object") return void 0;
1765
- const id = str2(r.id) ?? str2(r.question_id) ?? (/^Q-\d+$/.test(String(r.question)) ? str2(r.question) : void 0);
1766
- if (!id) return void 0;
1767
- const answers = Array.isArray(r.answers) ? r.answers : [];
1768
- const answer = r.answer;
1769
- const text = r.full === false ? void 0 : str2(answer) ?? str2(answer?.text) ?? str2(r.text) ?? str2(answers.at(-1)?.text);
1770
- const question = str2(r.title) ?? (str2(r.question) === id ? void 0 : str2(r.question));
1771
- const about = [str2(r.task), str2(r.item) ?? str2(r.object)].filter(Boolean).join(" ") || void 0;
1772
- const state = str2(r.state);
1780
+ if (!r || typeof r !== "object" || Array.isArray(r)) return void 0;
1781
+ const id = str2(r.question_id);
1782
+ if (!id || !/^Q-\d+$/.test(id)) return void 0;
1783
+ const text = r.full === false ? void 0 : str2(r.answer);
1784
+ const touches = ids(r.touches);
1785
+ const about = touches.length ? touches : ids(r.cites);
1786
+ const at = str2(r.at);
1773
1787
  return {
1774
1788
  id,
1775
- ...question ? { question } : {},
1776
1789
  ...text ? { text } : {},
1777
- ...about ? { about } : {},
1778
- ...state ? { state } : {},
1779
- path: str2(r.path) ?? `alterspec-client questions ${id}`
1790
+ ...about.length ? { touches: about } : {},
1791
+ ...r.reversed === true ? { reversed: true } : {},
1792
+ ...at ? { at } : {},
1793
+ path: `alterspec-client questions ${id}`
1780
1794
  };
1781
1795
  }
1782
1796
  function parseRuled(value) {
@@ -1791,9 +1805,14 @@ function parseRuled(value) {
1791
1805
  }
1792
1806
  var one3 = (text) => text.replace(/\s+/g, " ").trim();
1793
1807
  function rulingLines(r) {
1794
- const head = `- ${r.id}${r.about || r.state ? ` (${[r.about, r.state].filter(Boolean).join("; ")})` : ""}`;
1795
- if (!r.text) return [`${head}: ${r.question ? `${one3(r.question)} ` : ""}\`${r.path}\``];
1796
- return [`${head}${r.question ? `: ${one3(r.question)}` : ""}`, ` - Ruled: ${one3(r.text)}`];
1808
+ const notes = [
1809
+ r.touches?.length ? r.touches.join(", ") : "",
1810
+ r.reversed ? "replaces an earlier answer" : "",
1811
+ r.at ? r.at.slice(0, 10) : ""
1812
+ ].filter(Boolean);
1813
+ const head = `- ${r.id}${notes.length ? ` (${notes.join("; ")})` : ""}`;
1814
+ if (!r.text) return [`${head}: \`${r.path}\``];
1815
+ return [head, ` - Ruled: ${one3(r.text)}`];
1797
1816
  }
1798
1817
  function ruledChangedLines(changed) {
1799
1818
  if (!changed?.length) return [];
@@ -2017,14 +2036,14 @@ function itemWhat(x, item, entry, track) {
2017
2036
  if (state) {
2018
2037
  const [, ux, scr, code, id] = state;
2019
2038
  const rule = /^rule-(.+)$/.exec(id)?.[1];
2020
- const page = mockupPath(code, scr);
2021
- const open = x.has(page) ? `; open \`${page}?state=${encodeURIComponent(id)}\`` : "";
2039
+ const page2 = mockupPath(code, scr);
2040
+ const open = x.has(page2) ? `; open \`${page2}?state=${encodeURIComponent(id)}\`` : "";
2022
2041
  return `state "${id}" of ${ux} (${named(x, scr)})${rule ? `: the message of RULE-${rule.toUpperCase()}` : ""}${open}`;
2023
2042
  }
2024
2043
  if (item.startsWith("file:")) {
2025
2044
  const path = item.slice(5);
2026
- const page = /\/mockups\/(SCR-[A-Z]{2,6}-\d{2})\.html$/.exec(path)?.[1];
2027
- const what2 = page ? `the mockup page of ${page}` : /\/design-system\.md$/.test(path) ? "the channel\u2019s design system" : /\/patterns\.md$/.test(path) ? "the channel\u2019s patterns" : "a file of the channel\u2019s experience";
2045
+ const page2 = /\/mockups\/(SCR-[A-Z]{2,6}-\d{2})\.html$/.exec(path)?.[1];
2046
+ const what2 = page2 ? `the mockup page of ${page2}` : /\/design-system\.md$/.test(path) ? "the channel\u2019s design system" : /\/patterns\.md$/.test(path) ? "the channel\u2019s patterns" : "a file of the channel\u2019s experience";
2028
2047
  return `${what2}: \`${path}\`${x.has(path) ? "" : " (not in the export now)"}`;
2029
2048
  }
2030
2049
  if (item.startsWith("term:")) return `glossary term "${item.slice(5)}"`;
@@ -2067,8 +2086,8 @@ function changedAttributes(entry) {
2067
2086
  const b = names(before2);
2068
2087
  const a = names(after2);
2069
2088
  const out = /* @__PURE__ */ new Set();
2070
- for (const [n, i] of a) if (!b.has(n) || attr(before2, b.get(n)) !== attr(after2, i)) out.add(n);
2071
- for (const n of b.keys()) if (!a.has(n)) out.add(n);
2089
+ for (const [n2, i] of a) if (!b.has(n2) || attr(before2, b.get(n2)) !== attr(after2, i)) out.add(n2);
2090
+ for (const n2 of b.keys()) if (!a.has(n2)) out.add(n2);
2072
2091
  return [...out];
2073
2092
  }
2074
2093
  function whereUsed(x, objects, entries, changed) {
@@ -2087,7 +2106,7 @@ function whereUsed(x, objects, entries, changed) {
2087
2106
  out.push({
2088
2107
  entity,
2089
2108
  attribute,
2090
- screens: index.screens.filter((s) => s.fields.some((f) => f.entity === entity && f.attributes.includes(attribute))).map((s) => piece(s.id, s.title, x.fileOf(s.id))),
2109
+ screens: index.screens.filter((s2) => s2.fields.some((f) => f.entity === entity && f.attributes.includes(attribute))).map((s2) => piece(s2.id, s2.title, x.fileOf(s2.id))),
2091
2110
  capabilities: index.capabilities.filter(
2092
2111
  (c) => [...c.inputs ?? [], ...c.outputs ?? []].some(
2093
2112
  (d) => "entity" in d && d.entity === entity && d.attributes.includes(attribute)
@@ -2097,7 +2116,7 @@ function whereUsed(x, objects, entries, changed) {
2097
2116
  });
2098
2117
  out.push({
2099
2118
  entity,
2100
- screens: index.screens.filter((s) => s.fields.some((f) => f.entity === entity)).map((s) => piece(s.id, s.title, x.fileOf(s.id))),
2119
+ screens: index.screens.filter((s2) => s2.fields.some((f) => f.entity === entity)).map((s2) => piece(s2.id, s2.title, x.fileOf(s2.id))),
2101
2120
  capabilities: index.capabilities.filter((c) => c.entities.some((e) => e.entity === entity)).map((c) => piece(c.id, c.title, x.fileOf(c.id))),
2102
2121
  rules: index.rules.filter((r) => r.entities.includes(entity) || (r.guards ?? []).some((g) => g.entity === entity)).map((r) => piece(r.id, r.title, x.fileOf(r.id)))
2103
2122
  });
@@ -2107,7 +2126,7 @@ function whereUsed(x, objects, entries, changed) {
2107
2126
  function lifecycleOf(x, id) {
2108
2127
  const e = x.index()?.entities.find((e2) => e2.id === id);
2109
2128
  if (!e?.states?.length) return void 0;
2110
- const states = e.states.map((s) => s === e.initial_state ? `${s} (initial)` : s).join(", ");
2129
+ const states = e.states.map((s2) => s2 === e.initial_state ? `${s2} (initial)` : s2).join(", ");
2111
2130
  const transitions = (e.transitions ?? []).map((t) => `${t.from}->${t.to}${t.by === "time" ? ` by time${t.at ? ` at ${t.at}` : ""}` : ""}`).join(", ");
2112
2131
  return `states ${states}${transitions ? `; transitions ${transitions}` : "; no transitions"}`;
2113
2132
  }
@@ -2146,7 +2165,7 @@ function reachOf(x, id, kind, changed) {
2146
2165
  ...changed.has(pid) ? { changed: true } : {},
2147
2166
  ...scope ? { scope } : {}
2148
2167
  });
2149
- const screenPiece = (sid) => piece(sid, index.screens.find((s) => s.id === sid)?.title ?? titleOf(x, sid));
2168
+ const screenPiece = (sid) => piece(sid, index.screens.find((s2) => s2.id === sid)?.title ?? titleOf(x, sid));
2150
2169
  const title = titleOf(x, id);
2151
2170
  if (kind === "rule") {
2152
2171
  const caps2 = index.capabilities.filter((c) => (c.rules ?? []).includes(id));
@@ -2170,13 +2189,13 @@ function reachOf(x, id, kind, changed) {
2170
2189
  };
2171
2190
  }
2172
2191
  const caps = index.capabilities.filter((c) => (c.roles ?? []).some((r) => r.role === id));
2173
- const screens = index.screens.filter((s) => (s.roles ?? []).some((r) => r.role === id));
2192
+ const screens = index.screens.filter((s2) => (s2.roles ?? []).some((r) => r.role === id));
2174
2193
  return {
2175
2194
  id,
2176
2195
  kind,
2177
2196
  ...title ? { title } : {},
2178
2197
  capabilities: caps.map((c) => piece(c.id, c.title, c.roles?.find((r) => r.role === id)?.scope)),
2179
- screens: screens.map((s) => piece(s.id, s.title))
2198
+ screens: screens.map((s2) => piece(s2.id, s2.title))
2180
2199
  };
2181
2200
  }
2182
2201
  function compatibilityOf(x, change, work, proposal) {
@@ -2205,8 +2224,8 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2205
2224
  const names = /* @__PURE__ */ new Set();
2206
2225
  const since = (key) => {
2207
2226
  names.add(key);
2208
- const s = x.seen(key);
2209
- return s.later.length ? { since: s.later.map((l) => l.change), ...s.absent ? { entered: true } : {} } : {};
2227
+ const s2 = x.seen(key);
2228
+ return s2.later.length ? { since: s2.later.map((l) => l.change), ...s2.absent ? { entered: true } : {} } : {};
2210
2229
  };
2211
2230
  const change = x.work.changes.find((c) => c.id === task.change);
2212
2231
  if (!change) throw new ContextError(`${task.change} is not in this export's work.json: pull the export.`);
@@ -2272,9 +2291,9 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2272
2291
  after: work.after,
2273
2292
  ...state.startFrom?.length ? { startFrom: state.startFrom } : {},
2274
2293
  ...state.siblings?.length ? {
2275
- siblings: state.siblings.map((s) => {
2276
- const alters = (change.tasks ?? []).find((t) => t.track === s.track)?.alters;
2277
- return alters ? { ...s, alters } : s;
2294
+ siblings: state.siblings.map((s2) => {
2295
+ const alters = (change.tasks ?? []).find((t) => t.track === s2.track)?.alters;
2296
+ return alters ? { ...s2, alters } : s2;
2278
2297
  })
2279
2298
  } : {},
2280
2299
  ...state.ruled?.length ? { ruled: state.ruled } : {},
@@ -2397,7 +2416,7 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2397
2416
  )
2398
2417
  );
2399
2418
  const screens = [
2400
- .../* @__PURE__ */ new Set([...work.objects.map(screenOf).filter((s) => !!s), ...performing])
2419
+ .../* @__PURE__ */ new Set([...work.objects.map(screenOf).filter((s2) => !!s2), ...performing])
2401
2420
  ];
2402
2421
  ctx.screens = screens.map((id) => {
2403
2422
  for (const key of [id, `UX-${id}-${track.code}`, `file:${mockupPath(track.code, id)}`]) names.add(key);
@@ -2445,15 +2464,15 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2445
2464
  return [{ id: name, path: at(path), ...text ? { text } : {}, ...since(`term:${name}`) }];
2446
2465
  });
2447
2466
  const moved = [...names].flatMap((key) => {
2448
- const s = x.seen(key);
2449
- if (!s.later.length) return [];
2467
+ const s2 = x.seen(key);
2468
+ if (!s2.later.length) return [];
2450
2469
  const now = currentText(current, key);
2451
- const changes = s.later.map((l) => ({
2470
+ const changes = s2.later.map((l) => ({
2452
2471
  id: l.change,
2453
2472
  ...opts.shown && !opts.shown.has(shownKey(key, l.change)) ? { fresh: true } : {}
2454
2473
  }));
2455
2474
  const first = changes.findIndex((ch) => ch.fresh);
2456
- const from = first < 0 || s.absent ? void 0 : first === 0 ? s.text : textAfter(s.later[first - 1].entry);
2475
+ const from = first < 0 || s2.absent ? void 0 : first === 0 ? s2.text : textAfter(s2.later[first - 1].entry);
2457
2476
  let diff;
2458
2477
  if (from !== void 0 && now !== void 0) {
2459
2478
  const [a, b] = [forDiff(key, from), forDiff(key, now)];
@@ -2465,13 +2484,13 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2465
2484
  const mine = entries.get(key);
2466
2485
  let checked = false;
2467
2486
  let lost2;
2468
- if (changed.has(key) && mine && !mine.binary && !s.absent) {
2487
+ if (changed.has(key) && mine && !mine.binary && !s2.absent) {
2469
2488
  checked = true;
2470
2489
  const wroteBefore = linesOf2(key, mine.exported.before ? mine.before : void 0);
2471
2490
  const wrote = [...linesOf2(key, mine.exported.after ? mine.after : void 0)].filter(
2472
2491
  (l) => !wroteBefore.has(l)
2473
2492
  );
2474
- lost2 = s.later.flatMap((l) => {
2493
+ lost2 = s2.later.flatMap((l) => {
2475
2494
  if (l.entry.binary) return [];
2476
2495
  const kept2 = linesOf2(key, l.entry.exported.after ? l.entry.after : void 0);
2477
2496
  const gone = [...linesOf2(key, l.entry.exported.before ? l.entry.before : void 0)].filter(
@@ -2489,7 +2508,7 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2489
2508
  ...pinned ? { pinned: at(pinned) } : {},
2490
2509
  ...diff ? { diff } : {},
2491
2510
  ...now === void 0 ? { gone: true } : {},
2492
- ...s.absent ? { entered: true } : {},
2511
+ ...s2.absent ? { entered: true } : {},
2493
2512
  ...checked ? { checked: true } : {},
2494
2513
  ...lost2?.length ? { lost: lost2 } : {}
2495
2514
  }
@@ -2609,15 +2628,15 @@ function renderChecklist(c) {
2609
2628
  function shippedLines(c) {
2610
2629
  const out = [];
2611
2630
  const kept = c.compatibility?.kept;
2612
- for (const s of c.siblings ?? []) {
2613
- if (s.status === "done") {
2614
- const where = [s.commit?.slice(0, 12), s.in_main_at ? "in main" : s.branch ?? "main"].filter(Boolean).join(", ");
2615
- const additive = s.alters !== void 0 && !s.alters.includes(c.track.code);
2631
+ for (const s2 of c.siblings ?? []) {
2632
+ if (s2.status === "done") {
2633
+ const where = [s2.commit?.slice(0, 12), s2.in_main_at ? "in main" : s2.branch ?? "main"].filter(Boolean).join(", ");
2634
+ const additive = s2.alters !== void 0 && !s2.alters.includes(c.track.code);
2616
2635
  out.push(
2617
- `**${s.track} has shipped this change** (${where})` + (kept ? ": the server keeps the old behaviour this change\u2019s Compatibility names until the other tracks\u2019 tasks are done (below)." : additive ? `: it alters nothing ${c.track.code} already does, so no test of yours should fail because of it.` : ": tests that check the behaviour it removes or changes are expected to fail until this task is done; updating them is part of this task. This is not a question of task order: don\u2019t ask about it, fix the tests with the work."),
2636
+ `**${s2.track} has shipped this change** (${where})` + (kept ? ": the server keeps the old behaviour this change\u2019s Compatibility names until the other tracks\u2019 tasks are done (below)." : additive ? `: it alters nothing ${c.track.code} already does, so no test of yours should fail because of it.` : ": tests that check the behaviour it removes or changes are expected to fail until this task is done; updating them is part of this task. This is not a question of task order: don\u2019t ask about it, fix the tests with the work."),
2618
2637
  ""
2619
2638
  );
2620
- } else if (s.status === "in_progress") out.push(`${s.track} is building this change now.`, "");
2639
+ } else if (s2.status === "in_progress") out.push(`${s2.track} is building this change now.`, "");
2621
2640
  }
2622
2641
  if (kept) {
2623
2642
  const ended = kept.endedBy.length ? `${kept.endedBy.join(", ")} ends it.` : "The change that ends it is not signed off yet.";
@@ -2647,18 +2666,18 @@ function renderContext(c) {
2647
2666
  ];
2648
2667
  const movedSince = (c.changedSince ?? []).filter((e) => !e.entered);
2649
2668
  if (movedSince.length) {
2650
- const n = movedSince.length;
2669
+ const n2 = movedSince.length;
2651
2670
  const fresh = movedSince.filter((e) => e.changes.some((ch) => ch.fresh)).length;
2652
2671
  out.push(
2653
2672
  "",
2654
- `This brief is the spec as ${c.change.id} saw it at its sign-off. ${n === 1 ? "One object it names was" : `${n} objects it names were`} changed since by later changes${fresh ? ` (${fresh} new since you last read this brief)` : ""}: those are the later changes\u2019 tasks, listed under "Changed since" at the end, never this task\u2019s work.` + (c.pins ? ` An absolute path under ${c.pins} is such an object as ${c.change.id} saw it.` : "")
2673
+ `This brief is the spec as ${c.change.id} saw it at its sign-off. ${n2 === 1 ? "One object it names was" : `${n2} objects it names were`} changed since by later changes${fresh ? ` (${fresh} new since you last read this brief)` : ""}: those are the later changes\u2019 tasks, listed under "Changed since" at the end, never this task\u2019s work.` + (c.pins ? ` An absolute path under ${c.pins} is such an object as ${c.change.id} saw it.` : "")
2655
2674
  );
2656
2675
  }
2657
2676
  if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
2658
2677
  if (c.startFrom?.length)
2659
2678
  out.push(
2660
2679
  "",
2661
- `Start from ${c.startFrom.map((s) => `\`${s.branch}\` (${s.id}${s.commit ? ` done at ${s.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the predecessor's work is pushed there and not merged yet (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
2680
+ `Start from ${c.startFrom.map((s2) => `\`${s2.branch}\` (${s2.id}${s2.commit ? ` done at ${s2.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the predecessor's work is pushed there and not merged yet (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
2662
2681
  );
2663
2682
  out.push("", ...ruledChangedLines(c.ruledChanged), ...shippedLines(c));
2664
2683
  if (c.questions?.length)
@@ -2817,10 +2836,10 @@ function renderContext(c) {
2817
2836
  pieces("Terms", c.terms, "The glossary terms the change\u2019s text uses.");
2818
2837
  if (c.screens?.length) {
2819
2838
  out.push("## Screens", "");
2820
- for (const s of c.screens) {
2821
- out.push(`- **${s.id}**: \`${s.file ?? "not in the export"}\``);
2822
- if (s.contract) out.push(` - experience contract: \`${s.contract}\``);
2823
- if (s.page) out.push(` - mockup page: \`${s.page}\``);
2839
+ for (const s2 of c.screens) {
2840
+ out.push(`- **${s2.id}**: \`${s2.file ?? "not in the export"}\``);
2841
+ if (s2.contract) out.push(` - experience contract: \`${s2.contract}\``);
2842
+ if (s2.page) out.push(` - mockup page: \`${s2.page}\``);
2824
2843
  }
2825
2844
  out.push("");
2826
2845
  if (c.design?.designSystem || c.design?.patterns)
@@ -2961,9 +2980,9 @@ async function listBugs(session, filter = {}) {
2961
2980
  ...filter.status ? { status: filter.status } : {},
2962
2981
  ...filter.track ? { track: filter.track } : {}
2963
2982
  });
2964
- const parsed = z8.array(BugSchema).safeParse(answer.bugs ?? []);
2965
- if (!parsed.success) throw new BugsError("The dispatcher\u2019s bugs are not in a form this client reads.");
2966
- return parsed.data;
2983
+ const parsed2 = z8.array(BugSchema).safeParse(answer.bugs ?? []);
2984
+ if (!parsed2.success) throw new BugsError("The dispatcher\u2019s bugs are not in a form this client reads.");
2985
+ return parsed2.data;
2967
2986
  }
2968
2987
  var one4 = (text) => text.replace(/\s+/g, " ").trim();
2969
2988
  function bugTaskWords(t) {
@@ -2984,8 +3003,8 @@ function bugsText(bugs) {
2984
3003
  return bugs.flatMap(bugLines).join("\n") + "\n";
2985
3004
  }
2986
3005
  function parseBug(raw) {
2987
- const parsed = BugSchema.safeParse(raw);
2988
- return parsed.success ? parsed.data : void 0;
3006
+ const parsed2 = BugSchema.safeParse(raw);
3007
+ return parsed2.success ? parsed2.data : void 0;
2989
3008
  }
2990
3009
  async function bugTaskState(session, task) {
2991
3010
  let answer;
@@ -3063,7 +3082,7 @@ function renderBugContext(c) {
3063
3082
  if (c.startFrom?.length)
3064
3083
  out.push(
3065
3084
  "",
3066
- `Start from ${c.startFrom.map((s) => `\`${s.branch}\` (${s.id}${s.commit ? ` done at ${s.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the work the bug is in is pushed there and not merged yet (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
3085
+ `Start from ${c.startFrom.map((s2) => `\`${s2.branch}\` (${s2.id}${s2.commit ? ` done at ${s2.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the work the bug is in is pushed there and not merged yet (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
3067
3086
  );
3068
3087
  out.push("");
3069
3088
  if (c.questions?.length) out.push(...questionsSection(c.questions));
@@ -3172,7 +3191,7 @@ function readShown(repo, task) {
3172
3191
  try {
3173
3192
  const data = JSON.parse(readFileSync4(path, "utf8"));
3174
3193
  return new Set(
3175
- Array.isArray(data.shown) ? data.shown.filter((s) => typeof s === "string") : []
3194
+ Array.isArray(data.shown) ? data.shown.filter((s2) => typeof s2 === "string") : []
3176
3195
  );
3177
3196
  } catch {
3178
3197
  return void 0;
@@ -3242,7 +3261,7 @@ function mainBranch(repo, configured) {
3242
3261
  const head = tryGit(repo, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]);
3243
3262
  return head?.replace(/^origin\//, "") || "main";
3244
3263
  }
3245
- var escape = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
3264
+ var escape = (s2) => s2.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
3246
3265
  function mergedCommit(repo, task, main) {
3247
3266
  const branch = branchOf(task);
3248
3267
  tryGit(repo, ["fetch", "--quiet", "origin", main]);
@@ -3398,7 +3417,7 @@ var invocation = (npxArgs = []) => ["npx", ...npxArgs, PACKAGE].join(" ");
3398
3417
  var mcpEntry = (npxArgs = []) => ({ command: "npx", args: [...npxArgs, PACKAGE, "mcp"] });
3399
3418
  var MCP_ENTRY = mcpEntry();
3400
3419
  function walk(dir) {
3401
- return readdirSync3(dir).sort().flatMap((n) => statSync(join7(dir, n)).isDirectory() ? walk(join7(dir, n)) : [join7(dir, n)]);
3420
+ return readdirSync3(dir).sort().flatMap((n2) => statSync(join7(dir, n2)).isDirectory() ? walk(join7(dir, n2)) : [join7(dir, n2)]);
3402
3421
  }
3403
3422
  var assetFiles = (sub) => walk(join7(ASSETS_DIR, sub)).map((f) => ({
3404
3423
  rel: relative(join7(ASSETS_DIR, sub), f).split("\\").join("/"),
@@ -3570,18 +3589,18 @@ function initClient(root, opts, version) {
3570
3589
  `This repository is set up for the product side (${CONFIG_FILE} has no export): remove that configuration first if a developer is to use it.`
3571
3590
  );
3572
3591
  const product = asked || existing !== void 0 && isProduct(existing);
3573
- const parsed = ClientConfigSchema.safeParse({ ...existing, ...defined });
3574
- if (!parsed.success) {
3575
- const missing = parsed.error.issues.map((i) => i.path.join(".")).filter(Boolean);
3592
+ const parsed2 = ClientConfigSchema.safeParse({ ...existing, ...defined });
3593
+ if (!parsed2.success) {
3594
+ const missing = parsed2.error.issues.map((i) => i.path.join(".")).filter(Boolean);
3576
3595
  throw new ConfigError(
3577
- existing ? `The configuration would not be valid: ${parsed.error.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}.` : product ? `init --product needs --dispatcher <url>${missing.length ? ` (missing or wrong: ${missing.join(", ")})` : ""}.` : `init needs --dispatcher <url> and --export <path to your clone of the export>${missing.length ? ` (missing or wrong: ${missing.join(", ")})` : ""}.`
3596
+ existing ? `The configuration would not be valid: ${parsed2.error.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}.` : product ? `init --product needs --dispatcher <url>${missing.length ? ` (missing or wrong: ${missing.join(", ")})` : ""}.` : `init needs --dispatcher <url> and --export <path to your clone of the export>${missing.length ? ` (missing or wrong: ${missing.join(", ")})` : ""}.`
3578
3597
  );
3579
3598
  }
3580
- if (!product && parsed.data.export === void 0)
3599
+ if (!product && parsed2.data.export === void 0)
3581
3600
  throw new ConfigError(
3582
3601
  "init needs --export <path to your clone of the export> for a developer\u2019s repository; the product side runs `init --product` instead."
3583
3602
  );
3584
- const next = written(parsed.data);
3603
+ const next = written(parsed2.data);
3585
3604
  const npxArgs = next.npx?.args ?? [];
3586
3605
  const before2 = existing && JSON.stringify(written(existing));
3587
3606
  const config = !existing ? "created" : before2 === JSON.stringify(next) ? "unchanged" : "updated";
@@ -3602,15 +3621,15 @@ function initClient(root, opts, version) {
3602
3621
  }
3603
3622
 
3604
3623
  // ../src/lib/names.ts
3605
- var normalizeName = (s) => s.toLowerCase().replace(/[_\-./]+/g, " ").replace(/[^\p{L}\p{N} ]+/gu, "").replace(/\s+/g, " ").trim();
3624
+ var normalizeName = (s2) => s2.toLowerCase().replace(/[_\-./]+/g, " ").replace(/[^\p{L}\p{N} ]+/gu, "").replace(/\s+/g, " ").trim();
3606
3625
  function aliasGroups(glossary) {
3607
3626
  const groups = glossary.map(
3608
3627
  (g) => new Set([g.term, ...g.forbidden ?? []].map(normalizeName))
3609
3628
  );
3610
3629
  return (name) => {
3611
- const n = normalizeName(name);
3612
- const out = /* @__PURE__ */ new Set([n]);
3613
- for (const g of groups) if (g.has(n)) for (const x of g) out.add(x);
3630
+ const n2 = normalizeName(name);
3631
+ const out = /* @__PURE__ */ new Set([n2]);
3632
+ for (const g of groups) if (g.has(n2)) for (const x of g) out.add(x);
3614
3633
  return out;
3615
3634
  };
3616
3635
  }
@@ -3685,16 +3704,16 @@ function lookup(x, opts) {
3685
3704
  const aliases = aliasGroups(index.glossary ?? []);
3686
3705
  const names = /* @__PURE__ */ new Map();
3687
3706
  const name = (said2, id) => {
3688
- for (const n of aliases(said2))
3689
- if (n.length > 2 && !names.has(n))
3690
- names.set(n, { id, ...n === normalizeName(said2) ? {} : { said: n } });
3707
+ for (const n2 of aliases(said2))
3708
+ if (n2.length > 2 && !names.has(n2))
3709
+ names.set(n2, { id, ...n2 === normalizeName(said2) ? {} : { said: n2 } });
3691
3710
  };
3692
3711
  for (const list2 of [entities, screens, caps, rules, events, index.roles ?? [], index.personas ?? []])
3693
3712
  for (const o of list2) name(o.title, o.id);
3694
3713
  for (const g of index.glossary ?? []) name(g.term, `term:${g.term}`);
3695
3714
  const spoken = ` ${normalizeName(text.replace(/\b[A-Z]+(?:-[A-Z0-9]+)+\b/g, " "))} `;
3696
- for (const [n, hit] of [...names].sort((a, b) => b[0].length - a[0].length))
3697
- if (new RegExp(` ${n}(?:s|es)? `).test(spoken) && !about.has(hit.id))
3715
+ for (const [n2, hit] of [...names].sort((a, b) => b[0].length - a[0].length))
3716
+ if (new RegExp(` ${n2}(?:s|es)? `).test(spoken) && !about.has(hit.id))
3698
3717
  add(hit.id, hit.said ? { said: hit.said } : {});
3699
3718
  for (const ref of opts.refs ?? [])
3700
3719
  if (!idsIn(ref, ID_KINDS).length && !/#/.test(ref) && !names.has(normalizeName(ref))) {
@@ -3734,18 +3753,18 @@ function lookup(x, opts) {
3734
3753
  out.push({ id: r.role, why: `performs ${id}${r.scope ? `, scope ${r.scope}` : ""}` });
3735
3754
  for (const d of cap.depends_on ?? []) out.push({ id: d, why: `${id} depends on it` });
3736
3755
  }
3737
- for (const s of screens) {
3738
- const acts = (s.actions ?? []).filter((a) => a.capability === id);
3756
+ for (const s2 of screens) {
3757
+ const acts = (s2.actions ?? []).filter((a) => a.capability === id);
3739
3758
  if (acts.length)
3740
3759
  out.push({
3741
- id: s.id,
3760
+ id: s2.id,
3742
3761
  why: `performs ${id} (${acts.map((a) => `${a.id}${a.label ? ` ${a.label}` : ""}`).join(", ")})`
3743
3762
  });
3744
- if (s.id === id) {
3745
- for (const a of s.actions ?? [])
3763
+ if (s2.id === id) {
3764
+ for (const a of s2.actions ?? [])
3746
3765
  if (a.capability) out.push({ id: a.capability, why: `${id}.${a.id} performs it` });
3747
- for (const f of s.fields ?? []) out.push({ id: f.entity, why: `shown on ${id}` });
3748
- } else if ((s.fields ?? []).some((f) => f.entity === id)) out.push({ id: s.id, why: `shows ${id}` });
3766
+ for (const f of s2.fields ?? []) out.push({ id: f.entity, why: `shown on ${id}` });
3767
+ } else if ((s2.fields ?? []).some((f) => f.entity === id)) out.push({ id: s2.id, why: `shows ${id}` });
3749
3768
  }
3750
3769
  for (const r of rules) {
3751
3770
  const guards = (r.guards ?? []).filter((g) => g.entity === id);
@@ -3782,12 +3801,12 @@ function lookup(x, opts) {
3782
3801
  }
3783
3802
  const scr = screenOfUx(id);
3784
3803
  if (scr) out.push({ id: scr, why: `${id} is its design` });
3785
- for (const s of x.sources.keys())
3786
- if (screenOfUx(s) === id) out.push({ id: s, why: `the design of ${id}` });
3804
+ for (const s2 of x.sources.keys())
3805
+ if (screenOfUx(s2) === id) out.push({ id: s2, why: `the design of ${id}` });
3787
3806
  if (!x.index()) {
3788
3807
  const file = x.fileOf(id);
3789
- for (const n of idsIn(frontMatterOf(file && x.read(file) || ""), ID_KINDS))
3790
- if (n !== id) out.push({ id: n, why: `named by ${id}` });
3808
+ for (const n2 of idsIn(frontMatterOf(file && x.read(file) || ""), ID_KINDS))
3809
+ if (n2 !== id) out.push({ id: n2, why: `named by ${id}` });
3791
3810
  }
3792
3811
  return out.filter((l) => x.sources.has(l.id));
3793
3812
  };
@@ -3898,7 +3917,7 @@ function renderLookup(l) {
3898
3917
  if (l.check.length)
3899
3918
  out.push("", "Open before calling the export silent:", ...l.check.map((c) => `- ${c.path} (${c.why})`));
3900
3919
  if (l.neighbours.length)
3901
- out.push("", "Neighbours, when one bears on it:", ...l.neighbours.map((n) => `- ${n.path} (${n.why})`));
3920
+ out.push("", "Neighbours, when one bears on it:", ...l.neighbours.map((n2) => `- ${n2.path} (${n2.why})`));
3902
3921
  if (l.views.length)
3903
3922
  out.push("", "Views, by the kind of question:", ...l.views.map((v) => `- ${v.path}: ${v.why}`));
3904
3923
  return out.join("\n") + "\n";
@@ -4103,6 +4122,294 @@ async function hookCwd(input, waitMs = 1e3) {
4103
4122
  }
4104
4123
  }
4105
4124
 
4125
+ // src/owner.ts
4126
+ import { z as z9 } from "zod";
4127
+ var OUTCOME_LISTS = ["unclear", "decided", "weight"];
4128
+ var OUTCOMES = ["lifted", "declined", "technical", "nothing", "open"];
4129
+ var OUTCOME_FILTERS = ["open", "lifted", "declined", "technical", "nothing", "all"];
4130
+ var KINDS = ["business", "technical", "untagged"];
4131
+ var REPORT_KINDS = ["mutual_waits", "chain_behind", "brief_size", "coupled_holds"];
4132
+ var MAX_LINES = 50;
4133
+ var MAX_REASON = 300;
4134
+ var PAGE = 50;
4135
+ var LINE_REF = /^(\d+):(unclear|decided|weight):(\d+)$/;
4136
+ function parseLineRef(s2) {
4137
+ const m = LINE_REF.exec(s2.trim());
4138
+ if (!m)
4139
+ throw new Error(
4140
+ `"${s2}" is not a feedback line: write <feedback>:<list>:<line>, the list unclear, decided or weight and the line from 0, as \`feedback\` prints it (e.g. 41:decided:0).`
4141
+ );
4142
+ return { feedback: Number(m[1]), list: m[2], line: Number(m[3]) };
4143
+ }
4144
+ var lineKey = (r) => `${r.feedback}:${r.list}:${r.line}`;
4145
+ function parsed(schema, value, tool) {
4146
+ const r = schema.safeParse(value);
4147
+ if (r.success) return r.data;
4148
+ const issue = r.error.issues[0];
4149
+ throw new Error(
4150
+ `The dispatcher's \`${tool}\` answer is not the shape this client reads (${issue.path.join(".") || "the answer"}: ${issue.message}); upgrade the client or tell the dispatcher's admin.`
4151
+ );
4152
+ }
4153
+ var LineSchema = z9.looseObject({
4154
+ feedback: z9.number().int().optional(),
4155
+ line: z9.number().int().nonnegative().optional(),
4156
+ text: z9.string(),
4157
+ kind: z9.enum(["business", "technical"]).nullish(),
4158
+ item: z9.string().nullish(),
4159
+ /** `closed`: a line that names only questions, closed by them (decision 22); absent or null: open. */
4160
+ outcome: z9.enum([...OUTCOMES, "closed"]).nullish(),
4161
+ ref: z9.string().nullish(),
4162
+ reason: z9.string().nullish()
4163
+ });
4164
+ var FeedbackSchema = z9.looseObject({
4165
+ id: z9.number().int().optional(),
4166
+ task: z9.string().nullish(),
4167
+ change: z9.string().nullish(),
4168
+ track: z9.string().nullish(),
4169
+ unclear: z9.array(LineSchema).default([]),
4170
+ decided: z9.array(LineSchema).default([]),
4171
+ weight: z9.array(LineSchema).default([])
4172
+ });
4173
+ var CountsSchema = z9.looseObject({
4174
+ open: z9.number().int(),
4175
+ without_outcome: z9.number().int(),
4176
+ business_not_lifted: z9.number().int()
4177
+ });
4178
+ var FeedbackAnswerSchema = z9.looseObject({
4179
+ feedback: z9.array(FeedbackSchema),
4180
+ counts: CountsSchema.optional()
4181
+ });
4182
+ function feedbackLines(answer) {
4183
+ const out = [];
4184
+ for (const f of parsed(FeedbackAnswerSchema, answer, "feedback").feedback) {
4185
+ const task = f.task ?? (f.change && f.track ? `${f.change}/${f.track}` : "?");
4186
+ for (const list2 of OUTCOME_LISTS)
4187
+ f[list2].forEach((l, i) => {
4188
+ const id = l.feedback ?? f.id;
4189
+ if (id === void 0)
4190
+ throw new Error(
4191
+ "The dispatcher's `feedback` answer names no feedback for a line; upgrade the client."
4192
+ );
4193
+ out.push({
4194
+ ref: { feedback: id, list: list2, line: l.line ?? i },
4195
+ task,
4196
+ text: l.text,
4197
+ kind: l.kind ?? null,
4198
+ outcome: l.outcome ?? "open",
4199
+ outcomeRef: l.ref ?? null,
4200
+ reason: l.reason ?? null,
4201
+ item: l.item ?? null
4202
+ });
4203
+ });
4204
+ }
4205
+ return out;
4206
+ }
4207
+ function countsText(counts) {
4208
+ const c = CountsSchema.safeParse(counts);
4209
+ if (!c.success) return void 0;
4210
+ return `Lines: ${c.data.open} open, ${c.data.without_outcome} without an outcome, ${c.data.business_not_lifted} business not lifted.`;
4211
+ }
4212
+ var cutText = (s2, n2 = 200) => s2.length > n2 ? `${s2.slice(0, n2 - 1)}\u2026` : s2;
4213
+ var oneLine = (s2) => s2.replace(/\s+/g, " ").trim();
4214
+ function lineText(l) {
4215
+ const outcome = l.outcome === "lifted" && l.outcomeRef ? `lifted ${l.outcomeRef}` : l.outcome === "declined" && l.reason ? `declined: ${cutText(l.reason, 80)}` : l.outcome;
4216
+ const kind = l.kind ? ` ${l.kind}` : "";
4217
+ const item = l.item ? ` ${l.item}` : "";
4218
+ return `${lineKey(l.ref)} ${l.task}${item}${kind} [${outcome}] ${cutText(oneLine(l.text))}`;
4219
+ }
4220
+ function page(items, offset, limit) {
4221
+ const shown = items.slice(offset, offset + limit);
4222
+ const rest = items.length - offset - shown.length;
4223
+ return {
4224
+ shown,
4225
+ more: rest > 0 ? `${rest} more: --offset ${offset + shown.length}.` : void 0
4226
+ };
4227
+ }
4228
+ async function owned(call) {
4229
+ try {
4230
+ return await call;
4231
+ } catch (e) {
4232
+ if (e instanceof DispatcherError) throw new Error(`${e.code}: ${e.message}`, { cause: e });
4233
+ throw e;
4234
+ }
4235
+ }
4236
+ var readFeedback = (session, filter) => owned(callTool(session, "feedback", { ...filter }));
4237
+ function feedbackText(answer, offset = 0, limit = PAGE) {
4238
+ const lines = feedbackLines(answer);
4239
+ const { shown, more } = page(lines, offset, limit);
4240
+ return [
4241
+ countsText(answer.counts),
4242
+ lines.length ? `${lines.length} line(s) match.` : "No line matches.",
4243
+ ...shown.map(lineText),
4244
+ more
4245
+ ].filter((l) => !!l).join("\n") + "\n";
4246
+ }
4247
+ var REF = /^(CHG|DEC)-\d+$/;
4248
+ function checkOutcome(r) {
4249
+ if (!r.lines.length) throw new Error("Name at least one line (<feedback>:<list>:<line>).");
4250
+ if (r.lines.length > MAX_LINES)
4251
+ throw new Error(
4252
+ `${r.lines.length} lines: at most ${MAX_LINES} in one call (all or nothing); send the rest in another.`
4253
+ );
4254
+ const keys = r.lines.map(lineKey);
4255
+ const twice = keys.filter((k, i) => keys.indexOf(k) !== i);
4256
+ if (twice.length) throw new Error(`Named twice: ${[...new Set(twice)].join(", ")}.`);
4257
+ if (r.outcome === "lifted") {
4258
+ if (!r.ref?.length || r.ref.length > 10)
4259
+ throw new Error(
4260
+ "A lifted line names the change that carried it: --ref with one to ten CHG-NNN or DEC-NNN."
4261
+ );
4262
+ } else if (r.ref?.length) throw new Error("--ref goes only with lifted.");
4263
+ const bad = (r.ref ?? []).filter((x) => !REF.test(x));
4264
+ if (bad.length) throw new Error(`Not a change or decision: ${bad.join(", ")} (CHG-NNN or DEC-NNN).`);
4265
+ if (r.outcome === "declined" && !r.reason?.trim())
4266
+ throw new Error("A declined line says why: --reason, at most 300 characters.");
4267
+ if (r.reason && r.reason.length > MAX_REASON)
4268
+ throw new Error(`The reason has ${r.reason.length} characters; at most ${MAX_REASON}.`);
4269
+ }
4270
+ function planOutcome(r, current, replace) {
4271
+ const byKey = new Map(current.map((l) => [lineKey(l.ref), l]));
4272
+ const found = [];
4273
+ const missing = [];
4274
+ for (const ref of r.lines) {
4275
+ const l = byKey.get(lineKey(ref));
4276
+ if (l) found.push(l);
4277
+ else missing.push(lineKey(ref));
4278
+ }
4279
+ const same = found.filter((l) => l.outcome === r.outcome);
4280
+ const settled2 = replace ? [] : found.filter((l) => l.outcome !== "open" && l.outcome !== "closed" && l.outcome !== r.outcome);
4281
+ return { found, missing, settled: settled2, same };
4282
+ }
4283
+ var outcomeArgs = (r) => ({
4284
+ lines: r.lines.map((l) => ({ feedback: l.feedback, list: l.list, line: l.line })),
4285
+ outcome: r.outcome,
4286
+ ...r.ref?.length ? { ref: r.ref.join(", ") } : {},
4287
+ ...r.reason ? { reason: r.reason } : {}
4288
+ });
4289
+ var LiftLineSchema = z9.looseObject({
4290
+ feedback: z9.number().int(),
4291
+ line: z9.number().int().nonnegative(),
4292
+ list: z9.enum(OUTCOME_LISTS),
4293
+ text: z9.string(),
4294
+ kind: z9.enum(["business", "technical"]).nullish(),
4295
+ ids: z9.array(z9.string()).default([]),
4296
+ task: z9.string().nullish(),
4297
+ change: z9.string().nullish(),
4298
+ export_commit: z9.string().nullish(),
4299
+ outcome: z9.string().nullish()
4300
+ });
4301
+ var LiftAnswerSchema = z9.looseObject({ lines: z9.array(LiftLineSchema) });
4302
+ function liftText(answer, offset = 0, limit = PAGE) {
4303
+ const lines = parsed(LiftAnswerSchema, answer, "lift").lines;
4304
+ const { shown, more } = page(lines, offset, limit);
4305
+ const out = [
4306
+ lines.length ? `${lines.length} business line(s) to lift.` : "No open business line."
4307
+ ];
4308
+ for (const l of shown)
4309
+ out.push(
4310
+ "",
4311
+ `${lineKey(l)} ${l.task ?? l.change ?? "?"}${l.export_commit ? ` (export ${l.export_commit.slice(0, 12)})` : ""}${l.outcome && l.outcome !== "open" ? ` [${l.outcome}]` : ""}`,
4312
+ ` ${oneLine(l.text)}`,
4313
+ ...l.ids.map((id) => ` - ${id}`)
4314
+ );
4315
+ if (more) out.push("", more);
4316
+ return out.join("\n") + "\n";
4317
+ }
4318
+ var TASK = /^CHG-\d+\/[A-Z][A-Z0-9]*$/;
4319
+ function parseTaskId(s2) {
4320
+ const t = s2.trim().toUpperCase();
4321
+ if (!TASK.test(t)) throw new Error(`"${s2}" is not a task: write CHG-<n>/<TRACK>, e.g. CHG-190/BE.`);
4322
+ return t;
4323
+ }
4324
+ function checkHoldReason(reason) {
4325
+ const r = reason?.trim() ?? "";
4326
+ if (!r) throw new Error("A hold says why: --reason, at most 300 characters.");
4327
+ if (r.length > MAX_REASON) throw new Error(`The reason has ${r.length} characters; at most ${MAX_REASON}.`);
4328
+ return r;
4329
+ }
4330
+ var rec = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
4331
+ var arr = (v) => Array.isArray(v) ? v : [];
4332
+ var strs = (v) => arr(v).filter((x) => typeof x === "string");
4333
+ var s = (v) => typeof v === "string" && v ? v : void 0;
4334
+ var n = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
4335
+ function countsOf(v) {
4336
+ const entries = Object.entries(rec(v)).filter(([k, x]) => k !== "total" && n(x) !== void 0);
4337
+ const total = n(rec(v).total);
4338
+ const list2 = entries.map(([k, x]) => `${k} ${String(x)}`).join(", ");
4339
+ if (total !== void 0) return list2 ? `${total} (${list2})` : String(total);
4340
+ return list2 || "0";
4341
+ }
4342
+ var ingestsOf = (a) => arr(a.ingests ?? a.release_notes ?? a.notes ?? a.releases).map(rec);
4343
+ function releaseNotesText(answer) {
4344
+ const ingests = ingestsOf(answer);
4345
+ if (!ingests.length) return "No ingest with a release note.\n";
4346
+ const out = [];
4347
+ for (const i of ingests) {
4348
+ const r = rec(i.release);
4349
+ const head = [
4350
+ n(i.ordinal) !== void 0 ? `#${String(i.ordinal)}` : "",
4351
+ s(i.commit)?.slice(0, 12) ?? "",
4352
+ s(i.at) ?? ""
4353
+ ].filter(Boolean).join(" ");
4354
+ out.push(
4355
+ `${head} ${s(r.id) ?? "no release"}${s(r.note) ? `: ${oneLine(s(r.note))}` : s(r.id) ? "" : " (every change released, no note)"}`
4356
+ );
4357
+ const changes = strs(r.changes);
4358
+ const held = strs(r.held);
4359
+ if (changes.length || held.length)
4360
+ out.push(` released ${changes.join(", ") || "none"}${held.length ? `; held ${held.join(", ")}` : ""}`);
4361
+ const touches = Object.entries(rec(i.touches ?? r.touches)).map(
4362
+ ([c, keys]) => `${c} ${arr(keys).length}`
4363
+ );
4364
+ if (touches.length) out.push(` objects touched: ${touches.join(", ")}`);
4365
+ if (i.tasks_in_work_touched !== void 0)
4366
+ out.push(` tasks in work touched: ${countsOf(i.tasks_in_work_touched)}`);
4367
+ if (i.new_tasks !== void 0) out.push(` new tasks: ${countsOf(i.new_tasks)}`);
4368
+ const warnings = Array.isArray(i.warnings) ? `${i.warnings.length}` : i.warnings !== void 0 ? countsOf(i.warnings) : "";
4369
+ if (warnings) out.push(` warnings: ${warnings}`);
4370
+ }
4371
+ return out.join("\n") + "\n";
4372
+ }
4373
+ var taskList = (v) => strs(v).join(" \u2192 ");
4374
+ function buildReportText(answer) {
4375
+ const out = [];
4376
+ const section = (key, title, line) => {
4377
+ if (!(key in answer)) return;
4378
+ const entries = arr(answer[key]).map(rec);
4379
+ out.push(`${title}: ${entries.length}`, ...entries.map((e) => ` ${line(e)}`));
4380
+ };
4381
+ section(
4382
+ "mutual_waits",
4383
+ "Mutual waits",
4384
+ (e) => `${strs(e.tasks).join(", ")}${strs(e.path).length ? ` (via ${taskList(e.path)})` : ""}`
4385
+ );
4386
+ section("chain_behind", "Behind a chain", (e) => {
4387
+ const path = strs(e.path);
4388
+ return `${s(e.task) ?? "?"} behind ${s(e.root) ?? "?"}${path.length ? `, ${path.length} deep: ${taskList(e.path)}` : ""}${e.before_ship === true ? " (before the server ships)" : ""}`;
4389
+ });
4390
+ section("brief_size", "Briefs over size", (e) => {
4391
+ const kb = n(e.bytes) !== void 0 ? `${Math.round(n(e.bytes) / 1024)} KB` : "? KB";
4392
+ const parts = arr(e.parts).map(rec).sort((a, b) => (n(b.bytes) ?? 0) - (n(a.bytes) ?? 0)).slice(0, 3).map((p) => `${s(p.key) ?? s(p.kind) ?? "?"} ${Math.round((n(p.bytes) ?? 0) / 1024)} KB`);
4393
+ return `${s(e.task) ?? "?"} ${kb}, weight ${n(e.weight) ?? "?"}${parts.length ? `; largest: ${parts.join(", ")}` : ""}`;
4394
+ });
4395
+ section("coupled_holds", "Held off main", (e) => {
4396
+ const waits = strs(e.waits_for ?? e.tasks);
4397
+ const reason = s(rec(e.held).reason) ?? s(e.reason);
4398
+ return `${s(e.task) ?? s(e.change) ?? "?"} (${s(e.kind) ?? "hold"})${reason ? `: ${cutText(oneLine(reason), 80)}` : ""}${waits.length ? `; waits for ${waits.join(", ")}` : ""}`;
4399
+ });
4400
+ return (out.length ? out.join("\n") : "Nothing to report.") + "\n";
4401
+ }
4402
+ function holdText(answer, verb) {
4403
+ const held = rec(answer.held);
4404
+ const reason = s(held.reason) ?? s(answer.reason);
4405
+ const waits = strs(answer.waits_for ?? answer.waiting ?? answer.open_tasks ?? answer.tasks);
4406
+ const count = n(answer.count) ?? waits.length;
4407
+ return [
4408
+ `${verb} ${s(answer.task) ?? "?"}${verb === "Held" ? " off the main branch" : ""}${reason ? `: ${oneLine(reason)}` : ""}.`,
4409
+ verb === "Held" && count ? `Its change's tasks not done on other tracks: ${count}${waits.length ? ` (${waits.join(", ")})` : ""}.` : ""
4410
+ ].filter(Boolean).join("\n") + "\n";
4411
+ }
4412
+
4106
4413
  // src/version.ts
4107
4414
  import { readFileSync as readFileSync8 } from "fs";
4108
4415
  function packageVersion() {
@@ -4236,7 +4543,8 @@ program.command("init").description(
4236
4543
  "",
4237
4544
  `Commit ${CONFIG_FILE} and ${MCP_JSON}.`,
4238
4545
  ...ignoreLines(r.ignore),
4239
- "The dispatcher\u2019s product tools (whoami, questions, answer, reconcile, feedback, bug_reports) appear in the next Claude Code session; /alterspec-answer post and /alterspec-reconcile use them."
4546
+ "The dispatcher\u2019s product tools (whoami, questions, answer, reconcile, feedback, bug_reports, lift, release_notes, build_report) appear in the next Claude Code session; /alterspec-answer post and /alterspec-reconcile use them.",
4547
+ "Setting a feedback line\u2019s outcome and holding a server task are never session tools: `alterspec-client feedback-outcome|hold|unhold \u2026 --confirm`, on the owner\u2019s word."
4240
4548
  ] : [
4241
4549
  `${CONFIG_FILE}: ${r.config}`,
4242
4550
  `${MCP_JSON} (server "dispatcher"): ${r.mcp}`,
@@ -4419,13 +4727,13 @@ program.command("questions").description(
4419
4727
  "print the questions the dispatcher keeps: some by number, a task\u2019s, or without either your own"
4420
4728
  ).argument("[ref...]", "a task, e.g. CHG-012/BE, or questions by number, e.g. Q-12 Q-14").option("--open", "only the ones still open").option("--about <id...>", "everyone\u2019s questions that name these IDs").option("--json", "print them as JSON").action(
4421
4729
  run(async (refs, opts) => {
4422
- const ids = refs.filter((r) => /^Q-\d+$/i.test(r)).map((r) => r.toUpperCase());
4730
+ const ids2 = refs.filter((r) => /^Q-\d+$/i.test(r)).map((r) => r.toUpperCase());
4423
4731
  const rest = refs.filter((r) => !/^Q-\d+$/i.test(r));
4424
- if (rest.length > 1 || rest.length && ids.length)
4732
+ if (rest.length > 1 || rest.length && ids2.length)
4425
4733
  throw new Error("Name one task, or questions by number (Q-<n>), not both.");
4426
4734
  const id = rest[0];
4427
4735
  const questions = await listQuestions(sessionOf(loadConfig()), {
4428
- ...ids.length ? { ids } : {},
4736
+ ...ids2.length ? { ids: ids2 } : {},
4429
4737
  ...id ? { task: parseTask(id).id } : {},
4430
4738
  ...opts.about ? { about: opts.about } : {},
4431
4739
  ...opts.open ? { open: true } : {}
@@ -4445,6 +4753,185 @@ program.command("bugs").description("print the bugs the dispatcher keeps: the on
4445
4753
  process.stdout.write(opts.json ? JSON.stringify(bugs, null, 2) + "\n" : bugsText(bugs));
4446
4754
  })
4447
4755
  );
4756
+ function productConfig(command) {
4757
+ const loaded = loadConfig();
4758
+ if (!isProduct(loaded.config))
4759
+ throw new Error(
4760
+ `\`${command}\` is the product side's: it runs in the spec project, set up with \`init --product\`, not in a developer's repository.`
4761
+ );
4762
+ return loaded;
4763
+ }
4764
+ var intOption = (name) => (v) => {
4765
+ const n2 = Number(v);
4766
+ if (!Number.isInteger(n2) || n2 < 0)
4767
+ throw new InvalidArgumentError(`${name} takes a whole number, not "${v}".`);
4768
+ return n2;
4769
+ };
4770
+ var oneOf = (name, values) => (v) => {
4771
+ if (!values.includes(v))
4772
+ throw new InvalidArgumentError(`${name} takes ${values.join(", ")}, not "${v}".`);
4773
+ return v;
4774
+ };
4775
+ program.command("feedback").description(
4776
+ "the product side: read the build\u2019s feedback lines with their counts, filtered by kind, outcome, list or level, a page at a time"
4777
+ ).option("--kind <kind>", `business, technical or untagged`, oneOf("--kind", KINDS)).option(
4778
+ "--outcome <outcome>",
4779
+ `${OUTCOME_FILTERS.join(", ")} (default open)`,
4780
+ oneOf("--outcome", OUTCOME_FILTERS)
4781
+ ).option("--list <list>", "unclear, decided or weight", oneOf("--list", OUTCOME_LISTS)).option("--level <n>", "the change map\u2019s level", intOption("--level")).option(
4782
+ "--has-outcome <yes|no>",
4783
+ "only lines with (yes) or without (no) an outcome",
4784
+ oneOf("--has-outcome", ["yes", "no"])
4785
+ ).option("--change <CHG>", "only this change\u2019s").option("--track <code>", "only this track\u2019s").option("--since <date>", "only feedback sent since this date").option("--offset <n>", "skip this many lines", intOption("--offset"), 0).option("--limit <n>", `print at most this many lines (default ${PAGE})`, intOption("--limit"), PAGE).option("--json", "print the dispatcher\u2019s answer as JSON").action(
4786
+ run(
4787
+ async (opts) => {
4788
+ const answer = await readFeedback(sessionOf(productConfig("feedback")), {
4789
+ ...opts.kind ? { kind: opts.kind } : {},
4790
+ ...opts.outcome ? { outcome: opts.outcome } : {},
4791
+ ...opts.list ? { list: opts.list } : {},
4792
+ ...opts.level !== void 0 ? { level: opts.level } : {},
4793
+ ...opts.hasOutcome ? { has_outcome: opts.hasOutcome === "yes" } : {},
4794
+ ...opts.change ? { change: opts.change.toUpperCase() } : {},
4795
+ ...opts.track ? { track: opts.track.toUpperCase() } : {},
4796
+ ...opts.since ? { since: opts.since } : {}
4797
+ });
4798
+ process.stdout.write(
4799
+ opts.json ? JSON.stringify(answer, null, 2) + "\n" : feedbackText(answer, opts.offset, opts.limit)
4800
+ );
4801
+ }
4802
+ )
4803
+ );
4804
+ program.command("feedback-outcome").description(
4805
+ "the product side, on the owner\u2019s typed word: set the outcome of feedback lines (lifted, declined, technical, nothing, or open again); previews without --confirm"
4806
+ ).argument("<outcome>", OUTCOMES.join(", ")).argument("<line...>", "the lines, <feedback>:<list>:<line> as `feedback` prints them, at most 50").option("--ref <id...>", "for lifted: the CHG-NNN or DEC-NNN that carried it").option("--reason <text>", "for declined (required): why, at most 300 characters").option("--replace", "also replace an outcome a line already has").option("--confirm", "send it; without it, only say what would change").option("--json", "print the dispatcher\u2019s answer as JSON").action(
4807
+ run(
4808
+ async (outcome, refs, opts) => {
4809
+ const request = {
4810
+ outcome: oneOf("the outcome", OUTCOMES)(outcome),
4811
+ lines: refs.map(parseLineRef),
4812
+ ...opts.ref ? {
4813
+ ref: opts.ref.flatMap((r) => r.split(/[\s,]+/)).filter(Boolean).map((r) => r.toUpperCase())
4814
+ } : {},
4815
+ ...opts.reason ? { reason: opts.reason.trim() } : {}
4816
+ };
4817
+ checkOutcome(request);
4818
+ const session = sessionOf(productConfig("feedback-outcome"));
4819
+ const plan = planOutcome(
4820
+ request,
4821
+ feedbackLines(await readFeedback(session, { outcome: "all" })),
4822
+ !!opts.replace
4823
+ );
4824
+ if (plan.missing.length)
4825
+ throw new Error(`The dispatcher holds no such line: ${plan.missing.join(", ")}. Nothing was sent.`);
4826
+ if (plan.settled.length)
4827
+ throw new Error(
4828
+ `Already settled, so nothing was sent:
4829
+ ${plan.settled.map(lineText).join("\n")}
4830
+ --replace replaces these outcomes with ${request.outcome}.`
4831
+ );
4832
+ const changes = plan.found.length - plan.same.length;
4833
+ const sameLine = plan.same.length ? `${plan.same.length} line(s) already ${request.outcome}: the dispatcher leaves them as they are.` : "";
4834
+ if (!opts.confirm) {
4835
+ process.stdout.write(
4836
+ [
4837
+ `Would set ${changes} line(s) to ${request.outcome}${request.ref ? ` (${request.ref.join(", ")})` : ""}:`,
4838
+ ...plan.found.filter((l) => !plan.same.includes(l)).map(lineText),
4839
+ sameLine,
4840
+ "Nothing was sent: --confirm sends it, on the owner\u2019s word."
4841
+ ].filter(Boolean).join("\n") + "\n"
4842
+ );
4843
+ return;
4844
+ }
4845
+ const answer = await owned(callTool(session, "feedback_outcome", outcomeArgs(request)));
4846
+ process.stdout.write(
4847
+ opts.json ? JSON.stringify(answer, null, 2) + "\n" : [`Set ${changes} line(s) to ${request.outcome}.`, sameLine, countsText(answer.counts)].filter(Boolean).join("\n") + "\n"
4848
+ );
4849
+ }
4850
+ )
4851
+ );
4852
+ program.command("lift").description(
4853
+ "the product side: the open business lines to take to the spec, each with the IDs it names (reads only)"
4854
+ ).argument(
4855
+ "[line...]",
4856
+ "the lines, <feedback>:<list>:<line>; none: the open business decided lines, oldest first, at most 50"
4857
+ ).option("--offset <n>", "skip this many lines", intOption("--offset"), 0).option("--limit <n>", `print at most this many lines (default ${PAGE})`, intOption("--limit"), PAGE).option("--json", "print the dispatcher\u2019s answer as JSON").action(
4858
+ run(async (refs, opts) => {
4859
+ const lines = refs.map(parseLineRef);
4860
+ if (lines.length > MAX_LINES) throw new Error(`At most ${MAX_LINES} lines in one call.`);
4861
+ const answer = await owned(
4862
+ callTool(
4863
+ sessionOf(productConfig("lift")),
4864
+ "lift",
4865
+ lines.length ? { lines: lines.map((l) => ({ ...l })) } : {}
4866
+ )
4867
+ );
4868
+ process.stdout.write(
4869
+ opts.json ? JSON.stringify(answer, null, 2) + "\n" : liftText(answer, opts.offset, opts.limit)
4870
+ );
4871
+ })
4872
+ );
4873
+ program.command("hold").description(
4874
+ "the product side, on the owner\u2019s typed word: hold one server task off the main branch (done only on a feature branch); previews without --confirm"
4875
+ ).argument("<task>", "the server task, e.g. CHG-190/BE").requiredOption("--reason <text>", "why, at most 300 characters").option("--confirm", "send it; without it, only say what would happen").option("--json", "print the dispatcher\u2019s answer as JSON").action(
4876
+ run(async (id, opts) => {
4877
+ const task = parseTaskId(id);
4878
+ const reason = checkHoldReason(opts.reason);
4879
+ const session = sessionOf(productConfig("hold"));
4880
+ if (!opts.confirm)
4881
+ return void process.stdout.write(
4882
+ `Would hold ${task} off the main branch: ${reason}
4883
+ Its developer may still finish it on a feature branch; \`done\` on main is refused until \`unhold\`.
4884
+ Nothing was sent: --confirm sends it, on the owner\u2019s word.
4885
+ `
4886
+ );
4887
+ const answer = await owned(callTool(session, "hold", { task, reason }));
4888
+ process.stdout.write(opts.json ? JSON.stringify(answer, null, 2) + "\n" : holdText(answer, "Held"));
4889
+ })
4890
+ );
4891
+ program.command("unhold").description(
4892
+ "the product side, on the owner\u2019s typed word: release a server task the owner held; previews without --confirm"
4893
+ ).argument("<task>", "the held task, e.g. CHG-190/BE").option("--confirm", "send it; without it, only say what would happen").option("--json", "print the dispatcher\u2019s answer as JSON").action(
4894
+ run(async (id, opts) => {
4895
+ const task = parseTaskId(id);
4896
+ const session = sessionOf(productConfig("unhold"));
4897
+ if (!opts.confirm)
4898
+ return void process.stdout.write(
4899
+ `Would release the owner's hold on ${task}: it may then reach the main branch.
4900
+ Nothing was sent: --confirm sends it, on the owner\u2019s word.
4901
+ `
4902
+ );
4903
+ const answer = await owned(callTool(session, "unhold", { task }));
4904
+ process.stdout.write(opts.json ? JSON.stringify(answer, null, 2) + "\n" : holdText(answer, "Released"));
4905
+ })
4906
+ );
4907
+ program.command("release-notes").description(
4908
+ "the product side: the release note of each ingested export, newest first, with counts (reads only)"
4909
+ ).option("--since <date>", "only ingests since this date").option("--limit <n>", "at most this many ingests, 1 to 100 (default 10)", intOption("--limit")).option("--json", "print the dispatcher\u2019s answer as JSON").action(
4910
+ run(async (opts) => {
4911
+ if (opts.limit !== void 0 && (opts.limit < 1 || opts.limit > 100))
4912
+ throw new Error("--limit takes 1 to 100.");
4913
+ const answer = await owned(
4914
+ callTool(sessionOf(productConfig("release-notes")), "release_notes", {
4915
+ ...opts.since ? { since: opts.since } : {},
4916
+ ...opts.limit !== void 0 ? { limit: opts.limit } : {}
4917
+ })
4918
+ );
4919
+ process.stdout.write(opts.json ? JSON.stringify(answer, null, 2) + "\n" : releaseNotesText(answer));
4920
+ })
4921
+ );
4922
+ program.command("build-report").description(
4923
+ "the product side: mutual waits, tasks behind a chain, briefs over size and holds off main, task IDs and counts only (reads only)"
4924
+ ).option("--ingest <commit>", "the export commit the report is of (default the latest)").option("--kind <kind>", REPORT_KINDS.join(", "), oneOf("--kind", REPORT_KINDS)).option("--json", "print the dispatcher\u2019s answer as JSON").action(
4925
+ run(async (opts) => {
4926
+ const answer = await owned(
4927
+ callTool(sessionOf(productConfig("build-report")), "build_report", {
4928
+ ...opts.ingest ? { ingest: opts.ingest } : {},
4929
+ ...opts.kind ? { kind: opts.kind } : {}
4930
+ })
4931
+ );
4932
+ process.stdout.write(opts.json ? JSON.stringify(answer, null, 2) + "\n" : buildReportText(answer));
4933
+ })
4934
+ );
4448
4935
  program.command("merged").description(
4449
4936
  "print the commit and branch to report done with: the pushed task branch\u2019s head, or the commit on origin/<main> that brought the task in"
4450
4937
  ).argument("<task>", "the task, e.g. CHG-012/BE").option("--json", "print { commit, branch } as JSON").action(