@productbrain/mcp 0.0.1-beta.16127 → 0.0.1-beta.16147

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.
@@ -1175,6 +1175,413 @@ var ORGANISATION_VALIDATION_REFUSALS = /* @__PURE__ */ new Set([
1175
1175
  "role_work_target_invalid"
1176
1176
  ]);
1177
1177
 
1178
+ // src/lib/statusCategories.ts
1179
+ var STATUS_CATEGORIES = ["draft", "current", "past", "discarded"];
1180
+ var STATUS_CATEGORY_SET = new Set(STATUS_CATEGORIES);
1181
+ var TRUST_ACCEPTED_WORDS = ["accepted", "active", "current"];
1182
+ function isTrustAccepted(status) {
1183
+ return TRUST_ACCEPTED_WORDS.includes(status);
1184
+ }
1185
+ var TRUST_ARCHIVED_WORDS = ["archived", "deprecated", "past", "discarded"];
1186
+ var TRUST_STATUS_LABELS = {
1187
+ draft: "Draft",
1188
+ current: "Current",
1189
+ // the live word every accept now stores
1190
+ accepted: "Accepted",
1191
+ archived: "Archived",
1192
+ active: "Accepted",
1193
+ deprecated: "Archived"
1194
+ };
1195
+ function entryStatusLabel(word) {
1196
+ return word.split(/[_-]/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
1197
+ }
1198
+ var ENTRY_STATUS_READ_WORDS = ["draft", ...TRUST_ACCEPTED_WORDS, ...TRUST_ARCHIVED_WORDS];
1199
+ var ENTRY_STATUS_WRITE_WORDS = ["draft", "archived"];
1200
+
1201
+ // src/lib/priority.ts
1202
+ var PRIORITY_LEVELS = {
1203
+ urgent: { word: "Urgent", order: 1, linearInt: 1, icon: "alert", line: "Fix now: hurts customers, money or security", question: "Who is hurt, or which promise slips?" },
1204
+ high: { word: "High", order: 2, linearInt: 2, icon: "bars-3", line: "A goal we set is stuck without this", question: "Which goal is stuck without this?" },
1205
+ medium: { word: "Medium", order: 3, linearInt: 3, icon: "bars-2", line: "Helps a goal we set, but can wait", question: "Which goal does this help?" },
1206
+ low: { word: "Low", order: 4, linearInt: 4, icon: "bars-1", line: "Nice to have, or keeping things tidy", question: "Why can this wait?" }
1207
+ };
1208
+ var PRIORITY_TOKENS = Object.keys(PRIORITY_LEVELS);
1209
+ var NO_PRIORITY = { word: "No priority", order: 5, linearInt: 0, icon: "dashes", line: "Not judged yet", question: "Why clear the priority?" };
1210
+ function priorityOf(value) {
1211
+ return typeof value === "string" && Object.prototype.hasOwnProperty.call(PRIORITY_LEVELS, value) ? value : null;
1212
+ }
1213
+
1214
+ // src/lib/dateValidation.ts
1215
+ var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
1216
+ function isValidISODate(value) {
1217
+ if (typeof value !== "string") return false;
1218
+ if (!ISO_DATE_REGEX.test(value)) return false;
1219
+ const parts = value.split("-");
1220
+ const year = Number(parts[0]);
1221
+ const month = Number(parts[1]);
1222
+ const day = Number(parts[2]);
1223
+ const date = new Date(year, month - 1, day);
1224
+ return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
1225
+ }
1226
+
1227
+ // src/lib/taskDue.ts
1228
+ var DAY = 864e5;
1229
+ var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1230
+ var STATE_WORDS = { overdue: "Overdue", dueToday: "Due today", due: "Due" };
1231
+ var TASK_DUE_WORDS = {
1232
+ ...STATE_WORDS,
1233
+ /** The due line on a task row: "due 7 Nov", the year only when it is not this year ("due 7 Nov 2027"). */
1234
+ line: (day) => `due ${day}`,
1235
+ /** pb get and the MCP get: "Due: 7 Nov, Overdue", "Due: today", "Due: 14 Nov". */
1236
+ label: (key, day) => `${STATE_WORDS.due}: ${key === "dueToday" ? "today" : day}${key === "overdue" ? `, ${STATE_WORDS.overdue}` : ""}`,
1237
+ /** Orient's counts line (RULE-17): the denominator is the open tasks the read judged, and a cut read says capped. */
1238
+ counts: (overdue, dueToday, read, capped) => `${overdue} ${STATE_WORDS.overdue}, ${dueToday} ${STATE_WORDS.dueToday} of ${read} open read${capped ? ", capped" : ""}.`
1239
+ };
1240
+ function utcDay(date) {
1241
+ return isValidISODate(date) ? Math.floor(Date.parse(date) / DAY) : null;
1242
+ }
1243
+ function dayText(dueDate, now) {
1244
+ const [year, month, day] = dueDate.split("-").map(Number);
1245
+ return `${day} ${MONTHS[month - 1]}${year === new Date(now).getUTCFullYear() ? "" : ` ${year}`}`;
1246
+ }
1247
+ function taskDue(input) {
1248
+ const due = utcDay(input.dueDate);
1249
+ if (!input.open || due === null) return null;
1250
+ const days = due - Math.floor(input.now / DAY);
1251
+ const key = days < 0 ? "overdue" : days === 0 ? "dueToday" : "due";
1252
+ const day = dayText(input.dueDate, input.now);
1253
+ return { key, word: STATE_WORDS[key], day, line: TASK_DUE_WORDS.line(day) };
1254
+ }
1255
+ function taskDueMark(due) {
1256
+ return due.key === "overdue" ? `${due.word}, ${due.line}` : due.key === "dueToday" ? due.word : due.line;
1257
+ }
1258
+
1259
+ // src/lib/workPackageList.ts
1260
+ var NOT_STARTED = "not started";
1261
+ var ALL_COMMAND_SAYS = "lists every live package";
1262
+ var WORK_PACKAGE_LIST_WORDS = {
1263
+ yours: "[yours]",
1264
+ /** Printed once under the heading when a row carries the mark, so a cold reader need not guess it (DEC-2445). */
1265
+ legend: "[yours] = a package your role owns",
1266
+ count: (shown, { team, otherTeams, noSingleOwner }, allCommand) => `Showing ${shown} of your team's ${team} live package${team === 1 ? "" : "s"}; ${otherTeams} more in other teams${noSingleOwner > 0 ? `; ${noSingleOwner} more with no single owner` : ""}. All ${team + otherTeams + noSingleOwner}: ${allCommand} (${ALL_COMMAND_SAYS})`,
1267
+ /** A seat's plan (TASK-1948): its first line, then every package in progress, the one next and the rest counted. */
1268
+ planLead: (team, n, capped) => `${team} has ${n}${capped ? "+" : ""} package${n === 1 && !capped ? "" : "s"} in progress.`,
1269
+ /** Two or more packages in progress share a level with no place set: only their ids order them inside it (DEC-2416, TASK-2098). */
1270
+ tied: (levels) => `Packages not ranked inside ${levels.join(" or ")}.`,
1271
+ /** The heading over the one next: the first package not started with no wait written (QUE-1480). */
1272
+ next: "Next",
1273
+ nextUnread: "The next package was not read: the read ran out of calls.",
1274
+ taskCounts: ({ open, done, doneWeek, weekAtLeast }) => `tasks: ${open} open, ${done} done, ${doneWeek}${weekAtLeast ? "+" : ""} done in 7 days`,
1275
+ notCounted: "tasks not counted",
1276
+ uncounted: (counted, of, capped) => `Tasks counted under ${counted} of ${of}${capped ? "+" : ""} packages in progress.`,
1277
+ /** The plan's last line, counted from the plan, never from the rows a door printed: with the lead it adds up to All N (RULE-17). */
1278
+ rest: (notGoing, next, waiting, { team, otherTeams, noSingleOwner }, capped, allCommand) => {
1279
+ const n = (count) => `${count}${capped ? "+" : ""}`, listed = [next && "the next", waiting > 0 && `${waiting} waiting`].filter(Boolean).join(" and ");
1280
+ return `${n(notGoing)} more not in progress${listed ? `, ${listed} among them` : ""}; ${n(otherTeams)} more in other teams${noSingleOwner > 0 ? `; ${n(noSingleOwner)} more with no single owner` : ""}. All ${n(team + otherTeams + noSingleOwner)}: ${allCommand} (${ALL_COMMAND_SAYS})`;
1281
+ },
1282
+ /** QUE-1484 point 6: the heading over packages not started skipped as the next for the wait each prints. */
1283
+ waiting: "Waiting",
1284
+ /** QUE-1484 point 4: what a plan row serves, names first, and the lines counting each one's packages by stage (RULE-17). */
1285
+ serves: (targets, cut) => `serves ${targets.join(", ")}${cut ? " and more not read" : ""}`,
1286
+ servesNone: "serves no key result or KPI",
1287
+ servesUnread: "key results or KPIs not read",
1288
+ /** The heading over each key result's line, as Next and Waiting head theirs (Product Design, round 2). */
1289
+ servesHeading: "Serves",
1290
+ keyResultLine: (target, stages, atLeast) => `${target}: ${stages.join(", ")}${atLeast ? ", and more not read" : ""}`,
1291
+ keyResultUncounted: (target) => `${target}: packages not counted`,
1292
+ mismatch: (notStarted, going) => `Stage and work disagree: ${notStarted} ${NOT_STARTED} with a task done in the last 7 days; ${going} in progress with none.`,
1293
+ /** The command each surface names at the end of the count line: every live work package of the workspace, under listHeading. */
1294
+ allCommand: {
1295
+ cli: "pb brief confidence",
1296
+ mcp: '`context action=brief briefType="confidence"`'
1297
+ },
1298
+ /** The heading of that command's list, so the count line and the list use one word. */
1299
+ listHeading: "Live work packages",
1300
+ /** That list's last line when it stopped at its cap; the brief has no way to continue past it. */
1301
+ listStops: (cap) => `More than ${cap} live packages; the list stops here.`,
1302
+ /** RULE-17: ticks are counted against the entry's whole done-when list. The brief's rows and the Bound scope's tasks print it. */
1303
+ ticks: (ticked, total) => total === 0 ? "no done-when" : `${ticked} of ${total} done-when ticked`,
1304
+ noStage: "no stage",
1305
+ /** After the ticks of a live package whose every item is ticked, so a reader closes it or adds what is left (TASK-1872). */
1306
+ allTicked: "(all ticked: close it, or add what is left)",
1307
+ /** A tension linked to a row, named and with its id so a reader can open it; each surface adds its own indent. */
1308
+ tension: (t) => `\u21B3 tension${t.entryId ? ` ${t.entryId}` : ""}: ${t.name}`,
1309
+ setOne: "Set one (urgent, high, medium or low):",
1310
+ /** The command each surface prints after setOne, ending the line so it pastes whole; a live priority change asks one line of why (DEC-2418). */
1311
+ setCommand: {
1312
+ cli: 'pb update <WP-ID> -f priority=high --change-reason "<why>"',
1313
+ mcp: '`entries action=update entryId="<WP-ID>" data={"priority":"high"} changeReason="<why>"`'
1314
+ }
1315
+ };
1316
+ function priorityWord(value) {
1317
+ const token = priorityOf(value);
1318
+ return token ? PRIORITY_LEVELS[token].word : NO_PRIORITY.word;
1319
+ }
1320
+ function workPackageListLines(rows, counts, surface) {
1321
+ const w = WORK_PACKAGE_LIST_WORDS, lines = [], plan = counts?.plan;
1322
+ const anyPriority = rows.some((row) => priorityOf(row.priority) !== null), live = counts ? counts.team + counts.otherTeams + counts.noSingleOwner : 0;
1323
+ if (counts && live > 0) lines.push(plan ? w.planLead(plan.teamName, plan.inProgress, plan.capped === true) : w.count(rows.length, counts, surface.allCommand));
1324
+ if (rows.some((row) => row.yours)) lines.push(w.legend);
1325
+ if (counts && rows.length > 0 && !anyPriority) lines.push(`${w.setOne} ${surface.setCommand}`);
1326
+ const going = rows.filter((row) => !row.next && !row.waiting), words = going.filter((row) => !row.placed).map((row) => priorityWord(row.priority));
1327
+ const tied = plan ? [...new Set(words)].filter((word) => word !== NO_PRIORITY.word && words.filter((x) => x === word).length > 1) : [];
1328
+ let level, tieSaid = tied.length === 0;
1329
+ for (const row of [...going, ...rows.filter((row2) => row2.waiting), ...rows.filter((row2) => row2.next)]) {
1330
+ const word = row.next ? w.next : row.waiting ? w.waiting : priorityWord(row.priority);
1331
+ if ((row.next || row.waiting) && !tieSaid) {
1332
+ lines.push(w.tied(tied));
1333
+ tieSaid = true;
1334
+ }
1335
+ if ((anyPriority || row.next || row.waiting) && word !== level) lines.push(surface.heading(word));
1336
+ level = word;
1337
+ lines.push(...surface.row(row, row.yours ? ` ${w.yours}` : ""));
1338
+ }
1339
+ if (!tieSaid) lines.push(w.tied(tied));
1340
+ if (plan?.nextUnread) lines.push(w.nextUnread);
1341
+ if (plan && plan.counted < plan.inProgress) lines.push(w.uncounted(plan.counted, plan.inProgress, plan.capped === true));
1342
+ const m = plan?.mismatch, n = (count, atLeast) => `${count}${atLeast ? "+" : ""}`;
1343
+ if (m && (m.notStarted > 0 || m.going > 0 || m.notStartedAtLeast || m.goingAtLeast)) lines.push(w.mismatch(n(m.notStarted, m.notStartedAtLeast), n(m.going, m.goingAtLeast)));
1344
+ if (plan && counts && live > 0) lines.push(w.rest(counts.team - plan.inProgress, plan.next === true, plan.waiting ?? 0, counts, plan.capped === true, surface.allCommand));
1345
+ if (plan?.keyResults?.length) lines.push(surface.heading(w.servesHeading), ...plan.keyResults.map((kr) => keyResultText(kr)));
1346
+ return lines;
1347
+ }
1348
+ function keyResultText(kr) {
1349
+ const w = WORK_PACKAGE_LIST_WORDS, target = `${kr.name} (${kr.entryId})`;
1350
+ return kr.stages === null ? w.keyResultUncounted(target) : w.keyResultLine(target, kr.stages.map((s) => `${s.count} ${entryStatusLabel(s.stage)}`), kr.atLeast === true);
1351
+ }
1352
+ function packageDetails(stage, { ticked, total }, due) {
1353
+ const w = WORK_PACKAGE_LIST_WORDS, sep = OPEN_TASK_LIST_WORDS.separator;
1354
+ return `${sep}${stage ? entryStatusLabel(stage) : w.noStage}${sep}${w.ticks(ticked, total)}${total > 0 && ticked === total ? ` ${w.allTicked}` : ""}${due ? `${sep}${taskDueMark(due)}` : ""}`;
1355
+ }
1356
+ function planRowDetails(row) {
1357
+ if (row.stage === void 0) return "";
1358
+ const w = WORK_PACKAGE_LIST_WORDS, tasks = row.tasks === null ? w.notCounted : row.tasks ? w.taskCounts(row.tasks) : "";
1359
+ const named = row.serves?.map((t) => `${t.name} (${t.entryId})`) ?? [];
1360
+ const serves = row.serves === null ? w.servesUnread : !row.serves ? "" : named.length > 0 ? w.serves(named, row.servesCut === true) : row.servesCut ? w.servesUnread : w.servesNone;
1361
+ const parts = [tasks, row.waiting ? waitText(row.wait, row.waitUnread) : "", serves].filter(Boolean);
1362
+ return `${packageDetails(row.stage, row.ticks ?? { ticked: 0, total: 0 }, row.due)}${parts.map((p) => `${OPEN_TASK_LIST_WORDS.separator}${p}`).join("")}`;
1363
+ }
1364
+ function planLines(view, surface) {
1365
+ if (!view) return [];
1366
+ const plan = cleanPlan(view.rows, view.counts, surface.clean);
1367
+ return [...workPackageListLines(plan.rows, plan.counts, {
1368
+ heading: surface.heading,
1369
+ setCommand: WORK_PACKAGE_LIST_WORDS.setCommand[surface.surface],
1370
+ allCommand: WORK_PACKAGE_LIST_WORDS.allCommand[surface.surface],
1371
+ row: (row, mark) => [`${surface.bullet}${row.entryId ? `${row.entryId} \u2014 ` : ""}${row.name}${mark}${planRowDetails(row)}`]
1372
+ }), ""];
1373
+ }
1374
+ function cleanPlan(rows, counts, clean) {
1375
+ const plan = counts?.plan, named = (t) => ({ ...t, entryId: clean(t.entryId), name: clean(t.name) });
1376
+ const keyResults = plan?.keyResults?.map((kr) => ({ ...named(kr), stages: kr.stages && kr.stages.map((s) => ({ ...s, stage: clean(s.stage) })) }));
1377
+ return {
1378
+ rows: rows.map((r) => ({
1379
+ ...r,
1380
+ name: clean(r.name),
1381
+ entryId: r.entryId === null ? null : clean(r.entryId),
1382
+ ...r.stage === void 0 ? {} : { stage: clean(r.stage) },
1383
+ ...r.serves ? { serves: r.serves.map(named) } : {},
1384
+ ...r.wait ? { wait: { ...named(r.wait), state: clean(r.wait.state) } } : {}
1385
+ })),
1386
+ counts: counts && plan ? { ...counts, plan: { ...plan, teamName: clean(plan.teamName), ...keyResults ? { keyResults } : {} } } : counts
1387
+ };
1388
+ }
1389
+ function doneWhenTicks(value) {
1390
+ const items = Array.isArray(value) ? value : [];
1391
+ return { ticked: items.filter((item) => typeof item === "object" && item !== null && item.done === true).length, total: items.length };
1392
+ }
1393
+ function liveWorkPackageRowText(row, now) {
1394
+ const due = taskDue({ dueDate: row.data?.["dueDate"], open: true, now });
1395
+ return `${row.entryId ? `${row.entryId} \u2014 ` : ""}${row.name}${packageDetails(row.workflowStatus, doneWhenTicks(row.data?.["doneWhen"]), due)}`;
1396
+ }
1397
+ function liveWorkPackageLines(rows, surface, now) {
1398
+ const marked = rows.map((row) => {
1399
+ const priority = priorityOf(row.data?.["priority"]);
1400
+ return { ...row, ...priority ? { priority } : {} };
1401
+ });
1402
+ return workPackageListLines(marked, void 0, {
1403
+ heading: surface.heading,
1404
+ setCommand: WORK_PACKAGE_LIST_WORDS.setCommand[surface.surface],
1405
+ allCommand: WORK_PACKAGE_LIST_WORDS.allCommand[surface.surface],
1406
+ row: (row) => [`${surface.bullet}${liveWorkPackageRowText(row, now)}`]
1407
+ });
1408
+ }
1409
+ var inTeam = (team) => team ? ` in ${team}` : "";
1410
+ var OPEN_TASK_LIST_WORDS = {
1411
+ heading: (roleName, team) => `${roleName}'s open tasks${inTeam(team)}`,
1412
+ separator: " \xB7 ",
1413
+ noOwner: "(no owner)",
1414
+ /** After a task whose package parents are all done or archived, so the agent finishes it or closes it (Product Design 2026-10-30). */
1415
+ packageClosed: "(its package is closed)",
1416
+ under: (pkg) => `under ${pkg.name} (${pkg.entryId})`,
1417
+ /** A row in progress's wait (a depends_on link), with its target's state; over when the target is done, stopped or archived. When the
1418
+ * same target is also what the row rests on due later, its due line follows the state, so one link is said once (TASK-2086, Voice). */
1419
+ waitsOn: (target, state2, due) => `waits on ${target}, ${state2}${due ? `, ${due}` : ""}`,
1420
+ waitOver: (target, state2) => `wait over: ${target} is ${state2}`,
1421
+ /** QUE-1484 point 6: a wait on an entry whose kind has no finished stage, said plainly. */
1422
+ waitNever: (target, state2, due) => `waits on ${target}, ${state2}${due ? `, ${due}` : ""}, which never finishes`,
1423
+ noWait: "no wait written",
1424
+ /** TASK-2086 (QUE-1519; Voice, round 2): a dated task that depends on an open entry due after it, with that entry's due line ("due 27 Nov"). */
1425
+ restsOn: (target, due) => `rests on ${target}, ${due}`,
1426
+ /** The read kept too few calls or bytes to look at what a dated row rests on: not the same as nothing due later. Each door adds its
1427
+ * command that shows the task's links (linksCommand), from the row's own id, so the step costs no read. */
1428
+ restsOnUnread: "what it rests on not read",
1429
+ linksCommand: { cli: (entryId) => `pb get ${entryId}`, mcp: (entryId) => `\`context action=get entryId="${entryId}"\`` },
1430
+ /** TASK-2086 (QUE-1519; Voice, round 2): after the due mark of an open task not started, its date 1 to DUE_SOON_DAYS days away. */
1431
+ dueSoon: (days) => `in ${days} day${days === 1 ? "" : "s"}, ${NOT_STARTED}`,
1432
+ /** The read kept too few calls to look for this row's wait: not the same as none. */
1433
+ waitUnread: "wait not read",
1434
+ /** Two or more rows share a level with no place set: only their ids order them inside it (DEC-2416, TASK-2098). */
1435
+ tied: (levels) => `Tasks not ranked inside ${levels.join(" or ")}.`,
1436
+ /** Orient shows at most this many rows; the cut note names the command for the rest. */
1437
+ shown: 5,
1438
+ more: (shown, total, capped, allCommand) => `Showing ${shown} of ${total}${capped ? "+" : ""}. The rest: ${allCommand}`,
1439
+ /** The tasks list's page, n of N, before the command for the next page (TASK-1948); N reads "N+" on a capped read, as `more` does. */
1440
+ page: (first, last, total, capped) => `Showing ${first}\u2013${last} of ${total}${capped ? "+" : ""}.`,
1441
+ allCommand: { cli: "pb tasks list", mcp: "`context action=tasks`" },
1442
+ compact: (count, capped, roleName, team, notStarted = 0) => `${count}${capped ? "+" : ""} open task(s) of ${roleName}${inTeam(team)}${notStarted > 0 ? `; ${notStarted}${capped ? "+" : ""} more under packages ${NOT_STARTED}` : ""}`,
1443
+ /** Only for a read that was not cut: a capped read that found none prints its capped line instead, never this. */
1444
+ empty: (roleName, team) => `${roleName} has no open tasks to list${inTeam(team)}.`,
1445
+ /** Tasks whose only live packages are not started (DEC-2459 as amended 2026-11-16): said as a number, never left out in silence. */
1446
+ underNotStarted: (count, capped) => `${count}${capped ? "+" : ""} more under packages ${NOT_STARTED}: counted, not listed.`,
1447
+ /** After the cap line only: the walk down the packages in progress stopped too, so a task under one may be missing (Voice, 2026-11-18). */
1448
+ walked: (read, of) => `Tasks read under ${read} of ${of} packages in progress. Others may be missing.`,
1449
+ /** The tasks list's last line when another page follows. */
1450
+ nextPage: (command) => `More: ${command}`,
1451
+ /** Printed whenever the read stopped at its cap, so rows it never read are not taken for none (signed by Voice, 2026-10-30).
1452
+ * The read goes newest ownership first, so what it leaves out is what the role has owned longest. */
1453
+ capped: (records) => `Read stopped at ${records} records; the tasks this role has owned longest are not listed.`,
1454
+ /** The read's refusal when no role is named and the session acts in none; each surface adds noRole with its own command. */
1455
+ noSessionRole: "This session acts in no role.",
1456
+ noRole: (command) => `Name the role: ${command}`,
1457
+ /** A cursor that is not a page number; the CLI refuses it rather than reading page 1. */
1458
+ badCursor: (value) => `Cursor ${value} is not a page number. Use the number the last page printed.`
1459
+ };
1460
+ function openTaskCommand(surface, input = {}) {
1461
+ if (surface === "cli") {
1462
+ return `${OPEN_TASK_LIST_WORDS.allCommand.cli}${input.role ? ` --role ${input.role}` : ""}${input.cursor !== void 0 ? ` --cursor ${input.cursor}` : ""}`;
1463
+ }
1464
+ const bare = OPEN_TASK_LIST_WORDS.allCommand.mcp.slice(1, -1);
1465
+ return `${bare}${input.role ? ` roleId=${input.role}` : ""}${input.cursor !== void 0 ? ` cursor=${input.cursor}` : ""}`;
1466
+ }
1467
+ function waitText(wait, unread, due) {
1468
+ const w = OPEN_TASK_LIST_WORDS;
1469
+ if (unread) return w.waitUnread;
1470
+ if (!wait) return w.noWait;
1471
+ const target = `${wait.name} (${wait.entryId})`, state2 = entryStatusLabel(wait.state);
1472
+ return wait.over ? w.waitOver(target, state2) : wait.never ? w.waitNever(target, state2, due) : w.waitsOn(target, state2, due);
1473
+ }
1474
+ function openTaskRowText(row, surface) {
1475
+ const w = OPEN_TASK_LIST_WORDS, t = row.doneWhen ?? { ticked: 0, total: 0 };
1476
+ const marks = [row.noOwner && w.noOwner, row.packageClosed && w.packageClosed].filter(Boolean).map((m) => ` ${m}`).join("");
1477
+ const restsDue = row.restsOn && TASK_DUE_WORDS.line(row.restsOn.day);
1478
+ const once = row.wait !== void 0 && row.wait.entryId === row.restsOn?.entryId;
1479
+ const restsOn = row.restsOn ? !once && w.restsOn(`${row.restsOn.name} (${row.restsOn.entryId})`, restsDue) : row.restsOnUnread && `${w.restsOnUnread}: ${w.linksCommand[surface](row.entryId)}`;
1480
+ const parts = [
1481
+ entryStatusLabel(row.inProgress ? "in_progress" : "open"),
1482
+ WORK_PACKAGE_LIST_WORDS.ticks(t.ticked, t.total),
1483
+ row.due && taskDueMark(row.due),
1484
+ row.dueSoon !== void 0 && w.dueSoon(row.dueSoon),
1485
+ restsOn,
1486
+ row.under && w.under(row.under),
1487
+ row.inProgress && waitText(row.wait, row.waitUnread, once ? restsDue : void 0)
1488
+ ];
1489
+ return `${priorityWord(row.priority)}${w.separator}${row.entryId} \u2014 ${row.name}${marks}${parts.filter(Boolean).map((p) => `${w.separator}${p}`).join("")}`;
1490
+ }
1491
+ function openTaskListLines(list, surface) {
1492
+ const w = OPEN_TASK_LIST_WORDS, shown = Math.min(surface.shown ?? list.rows.length, list.rows.length), rows = list.rows.slice(0, shown);
1493
+ const total = surface.total ?? list.rows.length;
1494
+ const due = list.dueCounts && total > 0 ? [TASK_DUE_WORDS.counts(list.dueCounts.overdue, list.dueCounts.dueToday, list.dueCounts.read, list.capped)] : [];
1495
+ const unplaced = rows.filter((row) => !row.placed), levels = [...new Set(unplaced.map((row) => priorityWord(row.priority)))].filter((word) => word !== NO_PRIORITY.word && unplaced.filter((row) => priorityWord(row.priority) === word).length > 1);
1496
+ const lines = [...due, ...rows.map((row) => `${surface.bullet}${openTaskRowText(row, surface.surface)}`), ...levels.length > 0 ? [w.tied(levels)] : []];
1497
+ if (total > shown && surface.from === void 0) lines.push(w.more(shown, total, list.capped, w.allCommand[surface.surface]));
1498
+ if (total > shown && surface.from !== void 0 && shown > 0) lines.push(w.page(surface.from + 1, surface.from + shown, total, list.capped));
1499
+ if (list.underNotStarted) lines.push(w.underNotStarted(list.underNotStarted, list.capped));
1500
+ if (list.capped) lines.push(w.capped(list.cappedAt ?? total), ...list.walked ? [w.walked(list.walked.read, list.walked.of)] : []);
1501
+ return lines;
1502
+ }
1503
+ function openTaskLead(list, heading) {
1504
+ const w = OPEN_TASK_LIST_WORDS, r = list.role.name;
1505
+ return list.rows.length > 0 ? heading(w.heading(r, list.team)) : list.total > 0 || list.capped ? w.compact(list.total, list.capped, r, list.team) : w.empty(r, list.team);
1506
+ }
1507
+ function openTaskSectionLines(list, surface) {
1508
+ if (!list || list.total === 0 && !list.capped && !list.underNotStarted) return [];
1509
+ return [openTaskLead(list, surface.heading), ...openTaskListLines(list, { bullet: surface.bullet, surface: surface.surface, shown: OPEN_TASK_LIST_WORDS.shown, total: list.total })];
1510
+ }
1511
+ var DRAFTS_MAY_BE_MORE = "there may be more";
1512
+ var SEAT_DRAFTS_CUT_WORDS = {
1513
+ cliNote: (count) => ` (${count}+, ${DRAFTS_MAY_BE_MORE})`,
1514
+ mcpLine: `${DRAFTS_MAY_BE_MORE.charAt(0).toUpperCase()}${DRAFTS_MAY_BE_MORE.slice(1)} drafts than shown.`,
1515
+ /** The scan stopped before it found one this seat wrote: a capped scan that found none is not a zero (signed by the Team Lead of
1516
+ * the Product Team covering Voice, 2026-11-14T02:50Z). The CLI heading takes the note with no colon, as no rows follow it. */
1517
+ cliNoneNote: ` (none found, ${DRAFTS_MAY_BE_MORE})`,
1518
+ cliNoneBrief: `no draft of yours found, ${DRAFTS_MAY_BE_MORE}`,
1519
+ mcpNoneLine: `No draft of yours found; ${DRAFTS_MAY_BE_MORE}.`
1520
+ };
1521
+ function cleanMarks(list, clean) {
1522
+ const mark = (m) => m && { ...m, entryId: clean(m.entryId), name: clean(m.name) };
1523
+ return list && { ...list, rows: list.rows.map((r) => ({
1524
+ ...r,
1525
+ ...r.under ? { under: mark(r.under) } : {},
1526
+ ...r.restsOn ? { restsOn: { ...mark(r.restsOn), day: clean(r.restsOn.day) } } : {},
1527
+ ...r.wait ? { wait: { ...mark(r.wait), state: clean(r.wait.state) } } : {}
1528
+ })) };
1529
+ }
1530
+ function openTaskCompactLines(list) {
1531
+ if (!list || list.total === 0 && !list.capped && !list.underNotStarted) return [];
1532
+ return [OPEN_TASK_LIST_WORDS.compact(list.total, list.capped, list.role.name, list.team, list.underNotStarted)];
1533
+ }
1534
+ var nameWithId = (entry) => `${entry.name}${entry.entryId ? ` (${entry.entryId})` : ""}`;
1535
+ var TASKS_UNDER_WORDS = {
1536
+ heading: (parent) => `Tasks under ${nameWithId(parent)}`,
1537
+ count: (total, statusCounts) => `${total} task${total === 1 ? "" : "s"}: ${statusCounts.map((s) => `${s.count} ${entryStatusLabel(s.status)}`).join(", ")}.`,
1538
+ empty: (parent) => `No task is part of ${nameWithId(parent)}.`,
1539
+ /** A floor ("3+") only when the count stopped at its own bound; past the list it still counts what the viewer may read. */
1540
+ notTasks: (count, atLeast = false) => `${count}${atLeast ? "+" : ""} other linked ${count === 1 && !atLeast ? "entry is not a task" : "entries are not tasks"}.`,
1541
+ /** Links come back oldest first, so what the list leaves out is the most recently linked; only tasks the viewer may read count. */
1542
+ cut: ({ unread, atLeast }) => atLeast ? unread === 0 ? "The read stopped early; recently linked tasks may not be listed." : `At least ${unread} of the most recently linked tasks are not listed.` : unread === 1 ? "The most recently linked task is not listed." : `The ${unread} most recently linked tasks are not listed.`,
1543
+ /** The cut's second sentence, ending in the surface's whole read of every part_of link: pb constellation, or context action=get. */
1544
+ cutStep: (command) => `Every task under it, by name: ${command}`,
1545
+ /** The read's refusal when an entry is named with a role or a page: the entry's list is one whole read. Each surface adds aloneFix. */
1546
+ alone: "A task list by entry takes no role and no cursor.",
1547
+ aloneFix: (command) => `List it without them: ${command}`
1548
+ };
1549
+ function taskUnderRowText(row) {
1550
+ const sep = OPEN_TASK_LIST_WORDS.separator, ticks = WORK_PACKAGE_LIST_WORDS.ticks(row.doneWhen.ticked, row.doneWhen.total);
1551
+ return `${row.entryId} \u2014 ${row.name}${sep}${entryStatusLabel(row.status)}${sep}${ticks}${row.due ? `${sep}${taskDueMark(row.due)}` : ""}`;
1552
+ }
1553
+ function tasksUnderLines(list, surface) {
1554
+ const w = TASKS_UNDER_WORDS, id = list.parent.entryId ?? list.parent.name;
1555
+ const whole = surface.surface === "cli" ? `pb constellation ${id}` : `context action=get entryId="${id}"`, step = w.cutStep(whole);
1556
+ const lead = list.rows.length > 0 ? [w.count(list.rows.length, list.statusCounts)] : list.cut ? [] : [w.empty(list.parent)];
1557
+ return [
1558
+ surface.heading(w.heading(list.parent)),
1559
+ ...lead,
1560
+ ...list.rows.map((row) => `${surface.bullet}${taskUnderRowText(row)}`),
1561
+ ...list.notTasks > 0 ? [w.notTasks(list.notTasks, list.cut?.atLeast), ` ${whole}`] : [],
1562
+ ...list.cut ? [`${w.cut(list.cut)} ${step}`] : []
1563
+ ];
1564
+ }
1565
+
1566
+ // src/lib/workPackagePlace.ts
1567
+ var OPEN_LABEL = "open";
1568
+ var PLANNED_LABEL = "planned";
1569
+ var [OPEN, PLANNED] = [entryStatusLabel(OPEN_LABEL), entryStatusLabel(PLANNED_LABEL)];
1570
+ var placeNextOf = (details) => {
1571
+ const found = details?.find((d) => typeof d?.placeNext === "object");
1572
+ return typeof found?.placeNext.entryId === "string" ? found.placeNext.entryId : void 0;
1573
+ };
1574
+ var PLACE_COMMAND = {
1575
+ cli: (entryId) => `Next: pb update ${entryId} --order <n>`,
1576
+ mcp: (entryId) => `Next: \`entries action=update entryId="${entryId}" order=<n>\``
1577
+ };
1578
+ var PLANNED_NEEDS_PLACE = `${PLANNED} needs a place in the order. Give it a place first.`;
1579
+ var OPEN_TAKES_NO_PLACE = `${OPEN} takes no place in the order. Set the place or ${OPEN}, not both.`;
1580
+ var NEW_PACKAGE_NOT_PLANNED = `A new package has no place yet, so it cannot be ${PLANNED}. Leave the status out, accept it, then set its place.`;
1581
+ var PLACE_MOVED_TO_PLANNED = `Moved to ${PLANNED} by itself: it has a place in the order.`;
1582
+ var OPEN_REMOVED_PLACE = `Its place in the order was removed: ${OPEN} takes none.`;
1583
+ var PLANNED_LANDS_OPEN = `Moved to ${OPEN} by itself: ${PLANNED} now needs a place.`;
1584
+
1178
1585
  // src/errors.ts
1179
1586
  var MCP_CALL_ERROR_RE = /^MCP call "([^"]+)" failed \(\d+\): (.+)$/s;
1180
1587
  function asKernelCallError(err) {
@@ -1298,7 +1705,8 @@ function classifyError(err) {
1298
1705
  if (questionDoor) return { code: "VALIDATION_ERROR", fn, message: `${questionDoor.line}
1299
1706
  ${questionDoor.next}`, recovery: questionDoor.next };
1300
1707
  const hasDiagnostics = missingRequiredFields?.length || fieldErrors?.length;
1301
- const next2 = spineNextLine(mcpErr.details) ?? roleRetireNextLine(mcpErr.details);
1708
+ const place = placeNextOf(mcpErr.details);
1709
+ const next2 = spineNextLine(mcpErr.details) ?? roleRetireNextLine(mcpErr.details) ?? (place ? PLACE_COMMAND.mcp(place) : null);
1302
1710
  return {
1303
1711
  code: "VALIDATION_ERROR",
1304
1712
  fn,
@@ -2001,6 +2409,31 @@ export {
2001
2409
  formatSeatSentence,
2002
2410
  formatInviteSentence,
2003
2411
  ORGANISATION_VALIDATION_REFUSALS,
2412
+ isTrustAccepted,
2413
+ TRUST_STATUS_LABELS,
2414
+ entryStatusLabel,
2415
+ ENTRY_STATUS_READ_WORDS,
2416
+ ENTRY_STATUS_WRITE_WORDS,
2417
+ PRIORITY_LEVELS,
2418
+ NO_PRIORITY,
2419
+ priorityOf,
2420
+ WORK_PACKAGE_LIST_WORDS,
2421
+ workPackageListLines,
2422
+ planRowDetails,
2423
+ planLines,
2424
+ cleanPlan,
2425
+ doneWhenTicks,
2426
+ liveWorkPackageLines,
2427
+ OPEN_TASK_LIST_WORDS,
2428
+ openTaskCommand,
2429
+ openTaskListLines,
2430
+ openTaskLead,
2431
+ openTaskSectionLines,
2432
+ SEAT_DRAFTS_CUT_WORDS,
2433
+ cleanMarks,
2434
+ openTaskCompactLines,
2435
+ TASKS_UNDER_WORDS,
2436
+ tasksUnderLines,
2004
2437
  API_KEY_PREFIX,
2005
2438
  AGENT_KEY_PREFIX,
2006
2439
  isApiKeyShaped,
@@ -2051,4 +2484,4 @@ export {
2051
2484
  appUrl,
2052
2485
  apiKeysUrl
2053
2486
  };
2054
- //# sourceMappingURL=chunk-IZCPANIR.js.map
2487
+ //# sourceMappingURL=chunk-Y73LQNAA.js.map